using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Common.OrderEnum; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Core.CodeConfigEnum; using WIDESEA_Core.Helper; using WIDESEA_DTO.Basic; using WIDESEA_DTO.MES; using WIDESEA_IBasicRepository; using WIDESEA_IInboundRepository; using WIDESEA_IInboundService; using WIDESEA_IOutboundService; using WIDESEA_Model.Models; namespace WIDESEA_InboundService { public class MesProInOrderService : ServiceBase, IMesProInOrderService { public IMesProInOrderRepository Repository => BaseDal; private readonly IUnitOfWorkManage _unitOfWorkManage; private readonly IInboundRepository _inboundRepository; public MesProInOrderService(IMesProInOrderRepository BaseDal, IUnitOfWorkManage unitOfWorkManag, IInboundRepository inboundRepository) : base(BaseDal) { _unitOfWorkManage = unitOfWorkManag; _inboundRepository = inboundRepository; } /// /// 成品入库扫码 /// /// /// /// public WebResponseContent ProInboundScan(int Id,string serNum) { WebResponseContent content = new WebResponseContent(); try { //获取对应MES成品入库单据 Dt_MesProInOrder mesProInOrder = BaseDal.Db.Queryable().Includes(x => x.Details).First(); if (mesProInOrder==null) { return content.Error("当前MES入库单据不存在"); } if (mesProInOrder.MesProStatus>= InOrderStatusEnum.入库完成.ObjToInt()) { return content.Error("当前单据已入库或关闭状态"); } ProSerNumAnalysisModel model = CodeAnalysisHelper.CodeAnalysis(AnalysisCodeEnum.ProSerNumAnalysis, serNum); float SumPCSQty = mesProInOrder.Details.Sum(x => x.OKPCSQTY); float OverPCSQty = mesProInOrder.Details.Sum(x=>x.OverInQuantity); if ((OverPCSQty+model.OKPCSQTY.ObjToInt())>SumPCSQty) { return content.Error($"当前入库订单数量溢出{(OverPCSQty + model.OKPCSQTY.ObjToInt())- SumPCSQty}"); } //获取对应内包明细 Dt_MesProInOrderDetail? proInOrderDetail = mesProInOrder.Details.FirstOrDefault(x=>x.BagNo==model.BagNO) ?? throw new Exception($"未找到"); } catch (Exception ex) { content.Error(ex.Message); } return content; } } }