using DOAN.Model.MES.product; using DOAN.Model.Mobile.Dto; 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(IPADPrintAndReportWorkService), ServiceLifetime = LifeTime.Transient)] public class PADPrintAndReportWorkService : BaseService, IPADPrintAndReportWorkService { /// /// 校验箱子标签 /// /// /// /// public bool InspectionBoxLabel(string box_label, string workorder) { return true; } /// /// 校验产品标签 /// /// /// /// public bool InspectionProductLabel(string product_label, string workorder) { return true; } /// /// 箱子标签和产品标签关联,及产品标签检验,及其工单报工 /// /// /// public int BoxLabelAndProductLabel(BoxLabelAndProductLabelDto boxLabelAndProductLabelDto) { // 1. 校验产品标签 //2. 箱子标签和产品标签关联 List ProReportworkDetailList = new List(); if(boxLabelAndProductLabelDto.ProductLabelArray != null && boxLabelAndProductLabelDto.ProductLabelArray.Length > 0) { foreach (var productLabel in boxLabelAndProductLabelDto.ProductLabelArray) { ProReportworkDetail proReportworkDetail = new ProReportworkDetail() { Id = Guid.NewGuid().ToString(), Workorder = boxLabelAndProductLabelDto.Workorder, PackageLabelCode = boxLabelAndProductLabelDto.BoxLabel, ProductionLabelCode = productLabel, LineCode = boxLabelAndProductLabelDto.LineCode, GroupCode = boxLabelAndProductLabelDto.GroupCode, CreatedBy = "PDA" }; ProReportworkDetailList.Add(proReportworkDetail); } } if(ProReportworkDetailList.Count > 0) { int affectedRows = 0; UseTran2(() => { Context.Insertable(ProReportworkDetailList).ExecuteCommand(); Context.Updateable() .SetColumns(it => it.FinishedNum == it.FinishedNum + ProReportworkDetailList.Count) .SetColumns(it => it.UpdatedTime == DateTime.Now) .SetColumns(it => it.UpdatedBy == "PDA") .Where(it => it.FkWorkorder == boxLabelAndProductLabelDto.Workorder) .ExecuteCommand(); }); return affectedRows; } return 0; } } }