zhuangpei-mesbackend/DOAN.Service/Mobile/PADPrintAndReportWork2Service.cs
qianhao.xu 7b836f2db1 1
2025-04-09 15:20:11 +08:00

135 lines
4.5 KiB
C#

using DOAN.Model.MES.product;
using DOAN.Model.Mobile;
using DOAN.Service.Mobile.IService;
using Infrastructure.Attribute;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DOAN.Service.Mobile
{
[AppService(ServiceType = typeof(IPADPrintAndReportWork2Service), ServiceLifetime = LifeTime.Transient)]
public class PADPrintAndReportWork2Service : BaseService<ProReportwork>, IPADPrintAndReportWork2Service
{
public string GetFirstInspectionLabel(string workorder)
{
return Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Select(it => it.FirstLabel).First()??"";
}
public string CheckFirstInspectionLabel(string workorder, string first_label)
{
if (!string.IsNullOrEmpty(first_label))
{
string[] stringArray = first_label.Split("|");
if (stringArray.Length > 0)
{
if (stringArray[0] == workorder)
{
bool isExist= Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Any();
if (isExist) {
Context.Updateable<ProInspectionLabel>()
.WhereColumns(it => it.Workorder == workorder)
.SetColumns(it => new ProInspectionLabel() { FirstLabel = first_label, UpdatedTime = DateTime.Now })
.ExecuteCommand();
}
else
{
ProInspectionLabel insert = new ProInspectionLabel()
{
Id = XueHua,
Workorder = workorder,
FirstLabel = first_label,
CreatedTime = DateTime.Now,
};
Context.Insertable(insert).ExecuteCommand();
}
return "合格";
}
else
{
return "标签不匹配";
}
}
else
{
return "标签异常";
}
}
else
{
return "标签异常";
}
}
public string CheckEndInspectionLabel(string workorder, string end_label)
{
if (!string.IsNullOrEmpty(end_label))
{
string[] stringArray = end_label.Split("|");
if (stringArray.Length > 0)
{
if (stringArray[0] == workorder)
{
bool isExist = Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Any();
if (isExist)
{
Context.Updateable<ProInspectionLabel>()
.WhereColumns(it => it.Workorder == workorder)
.SetColumns(it => new ProInspectionLabel() { EndLabel = end_label, UpdatedTime = DateTime.Now })
.ExecuteCommand();
}
else
{
ProInspectionLabel insert = new ProInspectionLabel()
{
Id = XueHua,
Workorder = workorder,
FirstLabel = end_label,
CreatedTime = DateTime.Now,
};
Context.Insertable(insert).ExecuteCommand();
}
return "合格";
}
else
{
return "标签不匹配";
}
}
else
{
return "标签异常";
}
}
else
{
return "标签异常";
}
}
public string GetEndInspectionLabel(string workorder)
{
return Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Select(it => it.EndLabel).First() ?? "";
}
}
}