zhuangpei-mesbackend/DOAN.Service/Mobile/PADPrintAndReportWork2Service.cs
2025-04-16 10:53:33 +08:00

176 lines
6.0 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 CheckBoxInspectionLabel(string workorder, string box_label)
{
try
{
if (string.IsNullOrEmpty(box_label))
{
return "箱标签传入为空!";
}
//TODO U16 U13 箱标签解析
string[] stringArray = box_label.Split("|");
// 提取标签规格
string labelSpecification = stringArray[0];
if (string.IsNullOrEmpty(labelSpecification))
{
return "标签异常,规格为空!";
}
// 提取工单规格
string workorderSpecification = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == workorder).Select(it => it.Specification).First();
if (string.IsNullOrEmpty(workorderSpecification))
{
return "工单规格异常,规格为空!";
}
if(labelSpecification == workorderSpecification)
{
return "合格";
}
else
{
return "外箱标签规格与工单规格不匹配";
}
}
catch (Exception)
{
throw;
}
}
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>()
.Where(it => it.Workorder == workorder)
.SetColumns(it => new ProInspectionLabel() { FirstLabel = first_label, UpdatedTime = DateTime.Now ,UpdatedBy="U13和U16"})
.ExecuteCommand();
}
else
{
ProInspectionLabel insert = new ProInspectionLabel()
{
Id = XueHua,
Workorder = workorder,
FirstLabel = first_label,
CreatedTime = DateTime.Now,
CreatedBy= "U13和U1"
};
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>()
.Where(it => it.Workorder == workorder)
.SetColumns(it => new ProInspectionLabel() { EndLabel = end_label, UpdatedTime = DateTime.Now ,CreatedBy= "U13和U1" })
.ExecuteCommand();
}
else
{
ProInspectionLabel insert = new ProInspectionLabel()
{
Id = XueHua,
Workorder = workorder,
FirstLabel = end_label,
CreatedTime = DateTime.Now,
CreatedBy = "U13和U1"
};
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() ?? "";
}
}
}