zhuangpei-mesbackend/DOAN.Service/Mobile/PADPrintAndReportWorkService.cs
2025-04-06 16:23:17 +08:00

93 lines
3.3 KiB
C#

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<ProReportwork>, IPADPrintAndReportWorkService
{
/// <summary>
/// 校验箱子标签
/// </summary>
/// <param name="box_label"></param>
/// <param name="workorder"></param>
/// <returns></returns>
public bool InspectionBoxLabel(string box_label, string workorder)
{
return true;
}
/// <summary>
/// 校验产品标签
/// </summary>
/// <param name="product_label"></param>
/// <param name="workorder"></param>
/// <returns></returns>
public bool InspectionProductLabel(string product_label, string workorder)
{
return true;
}
/// <summary>
/// 箱子标签和产品标签关联,及产品标签检验,及其工单报工
/// </summary>
/// <param name="boxLabelAndProductLabelDto"></param>
/// <returns></returns>
public int BoxLabelAndProductLabel(BoxLabelAndProductLabelDto boxLabelAndProductLabelDto)
{
// 1. 校验产品标签
//2. 箱子标签和产品标签关联
List<ProReportworkDetail> ProReportworkDetailList = new List<ProReportworkDetail>();
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<ProReportwork>()
.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;
}
}
}