zhuangpei-mesbackend/DOAN.Service/Mobile/PADPrintAndReportWork2Service.cs

176 lines
6.0 KiB
C#
Raw Normal View History

2025-04-09 10:27:09 +08:00
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)
{
2025-04-09 13:31:23 +08:00
return Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Select(it => it.FirstLabel).First()??"";
2025-04-09 10:27:09 +08:00
}
2025-04-10 13:37:13 +08:00
2025-04-10 15:24:00 +08:00
public string CheckBoxInspectionLabel(string workorder, string box_label)
2025-04-10 13:37:13 +08:00
{
2025-04-10 15:24:00 +08:00
try
2025-04-10 13:37:13 +08:00
{
2025-04-10 15:24:00 +08:00
if (string.IsNullOrEmpty(box_label))
{
return "箱标签传入为空!";
}
//TODO U16 U13 箱标签解析
2025-04-10 13:37:13 +08:00
string[] stringArray = box_label.Split("|");
2025-04-10 15:24:00 +08:00
// 提取标签规格
string labelSpecification = stringArray[0];
if (string.IsNullOrEmpty(labelSpecification))
2025-04-10 13:37:13 +08:00
{
2025-04-10 15:24:00 +08:00
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 "合格";
2025-04-10 13:37:13 +08:00
}
else
{
2025-04-10 15:24:00 +08:00
return "外箱标签规格与工单规格不匹配";
2025-04-10 13:37:13 +08:00
}
2025-04-10 15:24:00 +08:00
2025-04-10 13:37:13 +08:00
}
2025-04-10 15:24:00 +08:00
catch (Exception)
2025-04-10 13:37:13 +08:00
{
2025-04-10 15:24:00 +08:00
throw;
2025-04-10 13:37:13 +08:00
}
}
2025-04-09 10:27:09 +08:00
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)
{
2025-04-09 11:38:34 +08:00
bool isExist= Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Any();
if (isExist) {
Context.Updateable<ProInspectionLabel>()
2025-04-09 15:32:29 +08:00
.Where(it => it.Workorder == workorder)
2025-04-16 10:53:33 +08:00
.SetColumns(it => new ProInspectionLabel() { FirstLabel = first_label, UpdatedTime = DateTime.Now ,UpdatedBy="U13和U16"})
2025-04-09 11:38:34 +08:00
.ExecuteCommand();
}
else
{
ProInspectionLabel insert = new ProInspectionLabel()
{
2025-04-09 15:20:11 +08:00
Id = XueHua,
2025-04-09 11:38:34 +08:00
Workorder = workorder,
FirstLabel = first_label,
CreatedTime = DateTime.Now,
2025-04-16 10:53:33 +08:00
CreatedBy= "U13和U1"
2025-04-09 11:38:34 +08:00
};
Context.Insertable(insert).ExecuteCommand();
}
return "合格";
2025-04-09 10:27:09 +08:00
}
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)
{
2025-04-09 11:38:34 +08:00
bool isExist = Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Any();
if (isExist)
{
Context.Updateable<ProInspectionLabel>()
2025-04-09 15:32:29 +08:00
.Where(it => it.Workorder == workorder)
2025-04-16 10:53:33 +08:00
.SetColumns(it => new ProInspectionLabel() { EndLabel = end_label, UpdatedTime = DateTime.Now ,CreatedBy= "U13和U1" })
2025-04-09 11:38:34 +08:00
.ExecuteCommand();
}
else
{
ProInspectionLabel insert = new ProInspectionLabel()
{
2025-04-09 15:20:11 +08:00
Id = XueHua,
2025-04-09 11:38:34 +08:00
Workorder = workorder,
FirstLabel = end_label,
CreatedTime = DateTime.Now,
2025-04-16 10:53:33 +08:00
CreatedBy = "U13和U1"
2025-04-09 11:38:34 +08:00
};
Context.Insertable(insert).ExecuteCommand();
}
2025-04-09 10:27:09 +08:00
return "合格";
}
else
{
return "标签不匹配";
}
}
else
{
return "标签异常";
}
}
else
{
return "标签异常";
}
}
public string GetEndInspectionLabel(string workorder)
{
2025-04-09 13:31:23 +08:00
return Context.Queryable<ProInspectionLabel>().Where(it => it.Workorder == workorder).Select(it => it.EndLabel).First() ?? "";
2025-04-09 10:27:09 +08:00
}
}
}