| | |
| | | [ApiDescriptionSettings(ApplicationConst.WmsTaskGroupName, Order = 100)] |
| | | public class WmsOperationTaskService : IDynamicApiController, ITransient |
| | | { |
| | | private static readonly SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); |
| | | private static readonly SemaphoreSlim semaphore2 = new SemaphoreSlim(1, 1); |
| | | |
| | | private readonly SqlSugarRepository<WmsRbLineTask> _rep; |
| | | private readonly SqlSugarRepository<WmsStockQuan> _wmsStockQuanRep; |
| | | private readonly SqlSugarRepository<Mes_Package_Gather> _mesPackageGatherRep; |
| | |
| | | private readonly SqlSugarRepository<Mes_Upi_LineQueue> _mes_Upi_LineQueueRep; |
| | | private readonly SqlSugarRepository<Mes_Package_LineQueue> _mes_Package_LineQueueRep; |
| | | private readonly SqlSugarRepository<WmsRecordUpiNg> _wmsRecordUpiNgRep; |
| | | private readonly SqlSugarRepository<Mes_Package_UnLine_Record> _mes_Package_UnLine_RecordRep; |
| | | private readonly WmsCommonnQueryService _wmsCommonnQueryService; |
| | | |
| | | public WmsOperationTaskService( |
| | |
| | | , SqlSugarRepository<WmsRecordUpiNg> wmsRecordUpiNgRep |
| | | , WmsCommonnQueryService wmsCommonnQueryService |
| | | , SqlSugarRepository<Mes_Package_LineQueue> mes_Package_LineQueueRep |
| | | , SqlSugarRepository<Mes_Package_UnLine_Record> mes_Package_UnLine_RecordRep |
| | | ) |
| | | { |
| | | _mes_Package_LineQueueRep = mes_Package_LineQueueRep; |
| | |
| | | _wmsRecordUpiProcessRep = wmsRecordUpiProcessRep; |
| | | _wmsRecordPackageProcessRep = wmsRecordPackageProcessRep; |
| | | _mes_Upi_LineQueueRep = mes_Upi_LineQueueRep; |
| | | _mes_Package_UnLine_RecordRep = mes_Package_UnLine_RecordRep; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断齐套 |
| | | /// 下线放行 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | [UnitOfWork] |
| | | public async Task<ValidateQiTaoOutput> ValdateQiTao(ValidateQiTaoInput input) |
| | | { |
| | | ValidateQiTaoOutput output = new ValidateQiTaoOutput(); |
| | | if (input == null || input.PackageCode == null) |
| | | await semaphore2.WaitAsync(); |
| | | try |
| | | { |
| | | throw Oops.Oh("参数不能为空"); |
| | | } |
| | | |
| | | var package = await _mesPackageGatherRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); |
| | | if (package == null) |
| | | { |
| | | throw Oops.Oh($"没有找到包号{input.PackageCode}的汇总数据"); |
| | | } |
| | | |
| | | |
| | | |
| | | var sysConfig = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.WmsBZ30_QiTao); |
| | | if (sysConfig == null) |
| | | { |
| | | throw Oops.Oh($"没有配置 判断齐套 值"); |
| | | } |
| | | if (!string.IsNullOrEmpty(sysConfig.Value) && sysConfig.Value.Trim() != "无") |
| | | { |
| | | throw Oops.Oh($"判断齐套值已经存在值{sysConfig.Value},不允许操作"); |
| | | } |
| | | |
| | | //记录工作时间和工作人 |
| | | var curUserName = App.User.FindFirst(ClaimConst.RealName)?.Value; |
| | | |
| | | var setValue = ""; |
| | | var _QiTaoReuslt = ""; |
| | | |
| | | bool isNeedQueryQiTao = true; |
| | | var order = await _mesOrderGatherRep.AsQueryable().Where(x => x.Info5 == package.Info5).FirstAsync(); |
| | | if (order == null) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (order.IsKitting != null) |
| | | ValidateQiTaoOutput output = new ValidateQiTaoOutput(); |
| | | if (input == null || input.PackageCode == null) |
| | | { |
| | | _QiTaoReuslt = (bool)order.IsKitting ? "齐套" : "不齐套"; |
| | | isNeedQueryQiTao = false; |
| | | throw Oops.Oh("参数不能为空"); |
| | | } |
| | | } |
| | | if (isNeedQueryQiTao) |
| | | { |
| | | var other_orderList = await _mesPackageGatherRep.AsQueryable().Where(x => x.Info5 == package.Info5 && x.PackageCode != input.PackageCode).ToListAsync(); |
| | | var num = other_orderList.Where(x => x.UpiStatus == UpiStatusEnum.初始).Count(); |
| | | if (num > 0) |
| | | |
| | | var package = await _mesPackageGatherRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); |
| | | if (package == null) |
| | | { |
| | | //不齐套 |
| | | _QiTaoReuslt = "不齐套"; |
| | | throw Oops.Oh($"没有找到包号{input.PackageCode}的汇总数据"); |
| | | } |
| | | |
| | | if (package.UpiStatus == UpiStatusEnum.已下线) |
| | | { |
| | | throw Oops.Oh($"包{input.PackageCode}已下线"); |
| | | } |
| | | |
| | | var unlineObj = await _mes_Package_UnLine_RecordRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); |
| | | if (unlineObj != null) |
| | | { |
| | | throw Oops.Oh($"包号{input.PackageCode}已经下线"); |
| | | } |
| | | |
| | | //判断是否是新生产订单 |
| | | var _QiTaoReuslt = ""; |
| | | bool isNewOrder = false; |
| | | string _location = "BZ-33"; |
| | | var lastPackageUnline = await _mes_Package_UnLine_RecordRep.AsQueryable().Where(x => x.UpiFlag == UpiFlagEnum.正常 && x.Location != "人工").OrderByDescending(x => x.Id).FirstAsync(); |
| | | if (lastPackageUnline == null) |
| | | {//认为是新生产订单 |
| | | isNewOrder = true; |
| | | } |
| | | else |
| | | { |
| | | _QiTaoReuslt = "齐套"; |
| | | if (lastPackageUnline.Info5 != package.Info5) |
| | | {//认为是新生产订单 |
| | | isNewOrder = true; |
| | | if (lastPackageUnline.Location == "BZ-33") |
| | | { |
| | | _location = "BZ-32"; |
| | | } |
| | | else |
| | | { |
| | | _location = "BZ-33"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _location = lastPackageUnline.Location; |
| | | } |
| | | } |
| | | } |
| | | setValue = $"{input.PackageCode}|{_QiTaoReuslt}|" + curUserName; |
| | | |
| | | if (package.UpiStatus == UpiStatusEnum.已下线) |
| | | { |
| | | throw Oops.Oh($"包已下线,齐套结果[{_QiTaoReuslt}]"); |
| | | } |
| | | |
| | | if (order == null) |
| | | { |
| | | Mes_Order_Gather newOrder = new Mes_Order_Gather() |
| | | { |
| | | Info5 = package.Info5, |
| | | IsKitting = _QiTaoReuslt == "齐套" ? true : false, |
| | | PlanNo = package.PlanNo, |
| | | OrderId = package.OrderId |
| | | }; |
| | | await _mesOrderGatherRep.InsertAsync(newOrder); |
| | | } |
| | | else |
| | | { |
| | | order.IsKitting = _QiTaoReuslt == "齐套" ? true : false; |
| | | await _mesOrderGatherRep.UpdateAsync(order); |
| | | } |
| | | |
| | | |
| | | sysConfig.Value = setValue; |
| | | await _sysConfigRep.UpdateAsync(sysConfig); |
| | | //*/ |
| | | |
| | | |
| | | var sysConfig_wms_unline_oper = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.wms_unline_oper); |
| | | if (sysConfig_wms_unline_oper == null) |
| | | { |
| | | throw Oops.Oh($"没有配置 包装下线操作人 值"); |
| | | } |
| | | if (sysConfig_wms_unline_oper.Value != curUserName) |
| | | { |
| | | sysConfig_wms_unline_oper.Value = curUserName; |
| | | await _sysConfigRep.UpdateAsync(sysConfig_wms_unline_oper); |
| | | |
| | | var sysConfig_wms_unline_time = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.wms_unline_time); |
| | | if (sysConfig_wms_unline_time == null) |
| | | { |
| | | throw Oops.Oh($"没有配置 包装下线登陆时间 值"); |
| | | if (string.IsNullOrEmpty(_location)) |
| | | {//默认 |
| | | _location = "BZ-33"; |
| | | } |
| | | sysConfig_wms_unline_time.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | await _sysConfigRep.UpdateAsync(sysConfig_wms_unline_time); |
| | | |
| | | _QiTaoReuslt = (bool)isNewOrder ? "新订单" : "当前订单"; |
| | | |
| | | |
| | | //记录工作时间和工作人 |
| | | var curUserName = App.User.FindFirst(ClaimConst.RealName)?.Value; |
| | | |
| | | var sysConfig_wms_unline_oper = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.wms_unline_oper); |
| | | if (sysConfig_wms_unline_oper == null) |
| | | { |
| | | throw Oops.Oh($"没有配置 包装下线操作人 值"); |
| | | } |
| | | if (sysConfig_wms_unline_oper.Value != curUserName) |
| | | { |
| | | sysConfig_wms_unline_oper.Value = curUserName; |
| | | await _sysConfigRep.UpdateAsync(sysConfig_wms_unline_oper); |
| | | |
| | | var sysConfig_wms_unline_time = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.wms_unline_time); |
| | | if (sysConfig_wms_unline_time == null) |
| | | { |
| | | throw Oops.Oh($"没有配置 包装下线登陆时间 值"); |
| | | } |
| | | sysConfig_wms_unline_time.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | await _sysConfigRep.UpdateAsync(sysConfig_wms_unline_time); |
| | | } |
| | | |
| | | |
| | | |
| | | //请求PLC |
| | | //判断方向 |
| | | bool myLocation = false; |
| | | if (_location == "BZ-33") |
| | | { |
| | | myLocation = false; |
| | | } |
| | | else |
| | | { |
| | | myLocation = true; |
| | | } |
| | | var client = await WCFServiceHelper.GetWCFService_SAPCC_Client(_sysConfigRep); |
| | | var res = await client.WriteQiTaoInfoAsync(myLocation); |
| | | if (res.result == false) |
| | | { |
| | | throw Oops.Oh(res.resMsg); |
| | | } |
| | | |
| | | |
| | | //更新数据 |
| | | package.UpiStatus = UpiStatusEnum.已下线; |
| | | package.AreaCode = AreaCodeEnum.下线区域; |
| | | await _mesPackageGatherRep.UpdateAsync(package); |
| | | |
| | | var upiList = await _mesBatchOrderUpiRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).ToListAsync(); |
| | | foreach (var item in upiList) |
| | | { |
| | | item.UpiStatus = UpiStatusEnum.已下线; |
| | | item.AreaCode = AreaCodeEnum.下线区域; |
| | | item.UpdateTime = DateTime.Now; |
| | | } |
| | | await _mesBatchOrderUpiRep.UpdateRangeAsync(upiList); |
| | | //删除队列信息 |
| | | var lineQueue = await _mes_Package_LineQueueRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); |
| | | if (lineQueue != null) |
| | | { |
| | | await _mes_Package_LineQueueRep.DeleteAsync(lineQueue); |
| | | } |
| | | //处理表 mes_order_gather |
| | | await UpdateOrderGather(package, false); |
| | | |
| | | var _cretaorName = App.User.FindFirst(ClaimConst.RealName)?.Value; |
| | | |
| | | //新增下线记录表 |
| | | var all_upiList = await _mesBatchOrderUpiRep.AsQueryable().Where(x => x.Info5 == package.Info5).ToListAsync(); |
| | | var all_unlineList = await _mes_Package_UnLine_RecordRep.AsQueryable().Where(x => x.Info5 == package.Info5).ToListAsync(); |
| | | Mes_Package_UnLine_Record record = new Mes_Package_UnLine_Record(); |
| | | record = package.Adapt<Mes_Package_UnLine_Record>(); |
| | | record.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | record.Location = _location; |
| | | record.AllPackageNum = all_upiList.GroupBy(x => x.PackageCode).Count(); |
| | | record.CurUnlineIndexPackageNum = all_unlineList.GroupBy(x => x.PackageCode).Count() + 1; |
| | | record.CreateTime = DateTime.Now; |
| | | record.CreateUserName = _cretaorName; |
| | | await _mes_Package_UnLine_RecordRep.InsertAsync(record); |
| | | |
| | | //记录包履历 |
| | | WmsRecordPackageProcess wmsRecordPackage = new WmsRecordPackageProcess(); |
| | | wmsRecordPackage = package.Adapt<WmsRecordPackageProcess>(); |
| | | wmsRecordPackage.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordPackage.Location = ""; |
| | | wmsRecordPackage.OperRemark = "正常下线"; |
| | | wmsRecordPackage.CreateTime = DateTime.Now; |
| | | wmsRecordPackage.CreateUserName = _cretaorName; |
| | | await _wmsRecordPackageProcessRep.InsertAsync(wmsRecordPackage); |
| | | |
| | | |
| | | output = package.Adapt<ValidateQiTaoOutput>(); |
| | | output.QiTaoReuslt = _QiTaoReuslt + $",第{record.CurUnlineIndexPackageNum}包下线,共{record.AllPackageNum}包"; |
| | | output.IsNewOrder = isNewOrder; |
| | | //output.IsNewOrder = false; |
| | | return output; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | finally |
| | | { |
| | | semaphore2.Release(); |
| | | } |
| | | |
| | | |
| | | output = package.Adapt<ValidateQiTaoOutput>(); |
| | | output.QiTaoReuslt = _QiTaoReuslt; |
| | | return output; |
| | | } |
| | | |
| | | |
| | |
| | | [UnitOfWork] |
| | | public async Task UnlineForNGPackage(UnlineForNGPackageInput input) |
| | | { |
| | | if (input == null) |
| | | await semaphore.WaitAsync(); |
| | | try |
| | | { |
| | | throw Oops.Oh("参数不能为空"); |
| | | } |
| | | if (string.IsNullOrEmpty(input.PackageCode)) |
| | | { |
| | | throw Oops.Oh("包号不能为空"); |
| | | } |
| | | //if (string.IsNullOrEmpty(input.Reason)) |
| | | //{ |
| | | // throw Oops.Oh("原因不能为空"); |
| | | //} |
| | | string _OperRemark = "正常人工下线"; |
| | | UpiFlagEnum upiFlagEnum = UpiFlagEnum.正常; |
| | | if (input.IsNG) |
| | | { |
| | | upiFlagEnum = UpiFlagEnum.NG; |
| | | _OperRemark = "NG下线"; |
| | | } |
| | | |
| | | var singlePackage = await _mesPackageGatherRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); |
| | | if (singlePackage == null) |
| | | { |
| | | throw Oops.Oh($"没有找到包号{input.PackageCode}的汇总数据"); |
| | | } |
| | | |
| | | if (singlePackage.UpiStatus == UpiStatusEnum.已下线) |
| | | { |
| | | throw Oops.Oh($"包号{input.PackageCode}已经下线"); |
| | | } |
| | | |
| | | singlePackage.UpiFlag = upiFlagEnum; |
| | | singlePackage.UpdateTime = DateTime.Now; |
| | | singlePackage.UpiStatus = UpiStatusEnum.已下线; |
| | | singlePackage.AreaCode = AreaCodeEnum.下线区域; |
| | | |
| | | var upiLineQueueList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).ToListAsync(); |
| | | if (upiLineQueueList?.Count > 0) |
| | | { |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(upiLineQueueList); |
| | | } |
| | | |
| | | var upiList = await _mesBatchOrderUpiRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).ToListAsync(); |
| | | if (upiList == null) |
| | | { |
| | | throw Oops.Oh($"没有找到包号{input.PackageCode}的板件数据"); |
| | | } |
| | | var _cretaorName = App.User.FindFirst(ClaimConst.RealName)?.Value; |
| | | |
| | | foreach (var item in upiList) |
| | | { |
| | | item.UpiFlag = UpiFlagEnum.NG; |
| | | item.UpdateTime = DateTime.Now; |
| | | item.UpiStatus = UpiStatusEnum.已下线; |
| | | item.AreaCode = AreaCodeEnum.下线区域; |
| | | |
| | | WmsRecordUpiProcess wmsRecordUpi = new WmsRecordUpiProcess(); |
| | | wmsRecordUpi = item.Adapt<WmsRecordUpiProcess>(); |
| | | wmsRecordUpi.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordUpi.CreateTime = DateTime.Now; |
| | | wmsRecordUpi.CreateUserName = _cretaorName; |
| | | wmsRecordUpi.Location = ""; |
| | | wmsRecordUpi.OperRemark = _OperRemark; |
| | | await _wmsRecordUpiProcessRep.InsertAsync(wmsRecordUpi); |
| | | |
| | | WmsRecordUpiNg wmsRecordUpiNg = new WmsRecordUpiNg(); |
| | | wmsRecordUpiNg = item.Adapt<WmsRecordUpiNg>(); |
| | | wmsRecordUpiNg.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordUpiNg.CreateTime = DateTime.Now; |
| | | wmsRecordUpiNg.CreateUserName = _cretaorName; |
| | | wmsRecordUpiNg.OperRemark = _OperRemark; |
| | | await _wmsRecordUpiNgRep.InsertAsync(wmsRecordUpiNg); |
| | | |
| | | |
| | | |
| | | //清理 队列表 |
| | | var removeUpiList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.Upi == item.UPI).ToListAsync(); |
| | | if (removeUpiList?.Count > 0) |
| | | if (input == null) |
| | | { |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(removeUpiList); |
| | | throw Oops.Oh("参数不能为空"); |
| | | } |
| | | if (string.IsNullOrEmpty(input.PackageCode)) |
| | | { |
| | | throw Oops.Oh("包号不能为空"); |
| | | } |
| | | //if (string.IsNullOrEmpty(input.Reason)) |
| | | //{ |
| | | // throw Oops.Oh("原因不能为空"); |
| | | //} |
| | | string _OperRemark = "正常人工下线"; |
| | | UpiFlagEnum upiFlagEnum = UpiFlagEnum.正常; |
| | | if (input.IsNG) |
| | | { |
| | | upiFlagEnum = UpiFlagEnum.NG; |
| | | _OperRemark = "NG下线"; |
| | | } |
| | | |
| | | var removePackageList = await _mes_Package_LineQueueRep.AsQueryable().Where(x => x.PackageCode == item.PackageCode).ToListAsync(); |
| | | if (removePackageList?.Count > 0) |
| | | var singlePackage = await _mesPackageGatherRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); |
| | | if (singlePackage == null) |
| | | { |
| | | await _mes_Package_LineQueueRep.DeleteAsync(removePackageList); |
| | | throw Oops.Oh($"没有找到包号{input.PackageCode}的汇总数据"); |
| | | } |
| | | |
| | | if (singlePackage.UpiStatus == UpiStatusEnum.已下线) |
| | | { |
| | | throw Oops.Oh($"包号{input.PackageCode}已经下线"); |
| | | } |
| | | |
| | | singlePackage.UpiFlag = upiFlagEnum; |
| | | singlePackage.UpdateTime = DateTime.Now; |
| | | singlePackage.UpiStatus = UpiStatusEnum.已下线; |
| | | singlePackage.AreaCode = AreaCodeEnum.下线区域; |
| | | |
| | | var upiLineQueueList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).ToListAsync(); |
| | | if (upiLineQueueList?.Count > 0) |
| | | { |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(upiLineQueueList); |
| | | } |
| | | |
| | | var upiList = await _mesBatchOrderUpiRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).ToListAsync(); |
| | | if (upiList == null) |
| | | { |
| | | throw Oops.Oh($"没有找到包号{input.PackageCode}的板件数据"); |
| | | } |
| | | var _cretaorName = App.User.FindFirst(ClaimConst.RealName)?.Value; |
| | | |
| | | foreach (var item in upiList) |
| | | { |
| | | item.UpiFlag = UpiFlagEnum.NG; |
| | | item.UpdateTime = DateTime.Now; |
| | | item.UpiStatus = UpiStatusEnum.已下线; |
| | | item.AreaCode = AreaCodeEnum.下线区域; |
| | | |
| | | WmsRecordUpiProcess wmsRecordUpi = new WmsRecordUpiProcess(); |
| | | wmsRecordUpi = item.Adapt<WmsRecordUpiProcess>(); |
| | | wmsRecordUpi.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordUpi.CreateTime = DateTime.Now; |
| | | wmsRecordUpi.CreateUserName = _cretaorName; |
| | | wmsRecordUpi.Location = ""; |
| | | wmsRecordUpi.OperRemark = _OperRemark; |
| | | await _wmsRecordUpiProcessRep.InsertAsync(wmsRecordUpi); |
| | | |
| | | WmsRecordUpiNg wmsRecordUpiNg = new WmsRecordUpiNg(); |
| | | wmsRecordUpiNg = item.Adapt<WmsRecordUpiNg>(); |
| | | wmsRecordUpiNg.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordUpiNg.CreateTime = DateTime.Now; |
| | | wmsRecordUpiNg.CreateUserName = _cretaorName; |
| | | wmsRecordUpiNg.OperRemark = _OperRemark; |
| | | await _wmsRecordUpiNgRep.InsertAsync(wmsRecordUpiNg); |
| | | |
| | | |
| | | |
| | | //清理 队列表 |
| | | var removeUpiList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.Upi == item.UPI).ToListAsync(); |
| | | if (removeUpiList?.Count > 0) |
| | | { |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(removeUpiList); |
| | | } |
| | | |
| | | var removePackageList = await _mes_Package_LineQueueRep.AsQueryable().Where(x => x.PackageCode == item.PackageCode).ToListAsync(); |
| | | if (removePackageList?.Count > 0) |
| | | { |
| | | await _mes_Package_LineQueueRep.DeleteAsync(removePackageList); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | //下线更新 订单表数据 _mesOrderGatherRep |
| | | await UpdateOrderGather(singlePackage, input.IsNG); |
| | | |
| | | |
| | | WmsRecordPackageProcess wmsRecordPackage = new WmsRecordPackageProcess(); |
| | | wmsRecordPackage = singlePackage.Adapt<WmsRecordPackageProcess>(); |
| | | wmsRecordPackage.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordPackage.Location = ""; |
| | | wmsRecordPackage.OperRemark = _OperRemark; |
| | | wmsRecordPackage.CreateTime = DateTime.Now; |
| | | wmsRecordPackage.CreateUserName = _cretaorName; |
| | | await _wmsRecordPackageProcessRep.InsertAsync(wmsRecordPackage); |
| | | |
| | | |
| | | //新增下线记录表 |
| | | var all_upiList = await _mesBatchOrderUpiRep.AsQueryable().Where(x => x.Info5 == singlePackage.Info5).ToListAsync(); |
| | | var all_unlineList = await _mes_Package_UnLine_RecordRep.AsQueryable().Where(x => x.Info5 == singlePackage.Info5).ToListAsync(); |
| | | Mes_Package_UnLine_Record record = new Mes_Package_UnLine_Record(); |
| | | record = singlePackage.Adapt<Mes_Package_UnLine_Record>(); |
| | | record.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | record.Location = "人工"; |
| | | record.AllPackageNum = all_upiList.GroupBy(x => x.PackageCode).Count(); |
| | | record.CurUnlineIndexPackageNum = all_unlineList.GroupBy(x => x.PackageCode).Count() + 1; |
| | | record.CreateTime = DateTime.Now; |
| | | record.CreateUserName = _cretaorName; |
| | | await _mes_Package_UnLine_RecordRep.InsertAsync(record); |
| | | |
| | | |
| | | await _mesPackageGatherRep.UpdateAsync(singlePackage); |
| | | await _mesBatchOrderUpiRep.UpdateRangeAsync(upiList); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | //下线更新 订单表数据 _mesOrderGatherRep |
| | | await UpdateOrderGather(singlePackage, input.IsNG); |
| | | |
| | | |
| | | WmsRecordPackageProcess wmsRecordPackage = new WmsRecordPackageProcess(); |
| | | wmsRecordPackage = singlePackage.Adapt<WmsRecordPackageProcess>(); |
| | | wmsRecordPackage.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordPackage.Location = ""; |
| | | wmsRecordPackage.OperRemark = _OperRemark; |
| | | wmsRecordPackage.CreateTime = DateTime.Now; |
| | | wmsRecordPackage.CreateUserName = _cretaorName; |
| | | await _wmsRecordPackageProcessRep.InsertAsync(wmsRecordPackage); |
| | | |
| | | |
| | | await _mesPackageGatherRep.UpdateAsync(singlePackage); |
| | | await _mesBatchOrderUpiRep.UpdateRangeAsync(upiList); |
| | | |
| | | throw; |
| | | } |
| | | finally |
| | | { |
| | | semaphore.Release(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下线更新 订单表数据 |
| | | /// 公共-下线更新 订单表数据 |
| | | /// </summary> |
| | | /// <param name="singlePackage"></param> |
| | | /// <returns></returns> |
| | |
| | | } |
| | | var packageList = await _mesPackageGatherRep.AsQueryable().Where(x => x.Info5 == singlePackage.Info5).ToListAsync(); |
| | | order.PackageNum = packageList.Count(); |
| | | order.UnLinePackageNum = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线).Count() + 1; |
| | | |
| | | order.NgPackageNum = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线 && x.UpiFlag == UpiFlagEnum.NG).Count(); |
| | | //计算已下线数 |
| | | var xiaList = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线).ToList(); |
| | | order.UnLinePackageNum = xiaList.Count(); |
| | | if (xiaList.Select(x => x.PackageCode).ToList().Contains(singlePackage.PackageCode) == false) |
| | | { |
| | | order.UnLinePackageNum += 1; |
| | | } |
| | | if (order.UnLinePackageNum > order.PackageNum) |
| | | { |
| | | order.UnLinePackageNum = order.PackageNum; |
| | | } |
| | | var ng_xiaList = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线 && x.UpiFlag == UpiFlagEnum.NG).ToList(); |
| | | order.NgPackageNum = ng_xiaList.Count(); |
| | | if (isNG) |
| | | { |
| | | order.NgPackageNum = order.NgPackageNum + 1; |
| | | if (ng_xiaList.Select(x => x.PackageCode).ToList().Contains(singlePackage.PackageCode) == false) |
| | | { |
| | | order.NgPackageNum += 1; |
| | | } |
| | | } |
| | | if (order.NgPackageNum > order.PackageNum) |
| | | { |
| | | order.NgPackageNum = order.PackageNum; |
| | | } |
| | | |
| | | order.NoUnLinePackageNum = order.PackageNum - order.UnLinePackageNum; |
| | | |
| | | order.AllPackageArea = packageList.Sum(x => Convert.ToDecimal(x.Info13)); |
| | | order.ScanPackageArea = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线 && x.UpiFlag == (int)UpiFlagEnum.正常).Sum(x => Convert.ToDecimal(x.Info13)); |
| | | if (isNG == false) |
| | | var scan_list = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线 && x.UpiFlag == (int)UpiFlagEnum.正常).ToList(); |
| | | order.ScanPackageArea = scan_list.Sum(x => Convert.ToDecimal(x.Info13)); |
| | | //if (isNG == false) |
| | | //{ |
| | | if (scan_list.Select(x => x.PackageCode).ToList().Contains(singlePackage.PackageCode) == false) |
| | | { |
| | | order.ScanPackageArea = order.ScanPackageArea + Convert.ToDecimal(singlePackage.Info13); |
| | | order.ScanPackageArea += Convert.ToDecimal(singlePackage.Info13); |
| | | } |
| | | //} |
| | | if (order.ScanPackageArea > order.AllPackageArea) |
| | | { |
| | | order.ScanPackageArea = order.AllPackageArea; |
| | | } |
| | | |
| | | order.NoScanPackageArea = order.AllPackageArea - order.ScanPackageArea; |
| | | |
| | | //判断该订单是否已下线 |
| | | if (order.NoUnLinePackageNum == 0) |
| | | { |
| | | order.IsUnline = true; |
| | | order.UnlineTime = DateTime.Now; |
| | | //order.UnlinePerson = _UnlinePerson; |
| | | } |
| | | |
| | | if (isAdd) |
| | | { |
| | | await _mesOrderGatherRep.InsertAsync(order); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 一键清理板件队列数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [ApiDescriptionSettings(Name = "OneKeyClearUpiQueue")] |
| | | [Description("WmsOperationTask/OneKeyClearUpiQueue")] |
| | | [UnitOfWork] |
| | | public async Task OneKeyClearUpiQueue() |
| | | { |
| | | var upiList = await _mes_Upi_LineQueueRep.AsQueryable().ToListAsync(); |
| | | if (upiList?.Count == 0) |
| | | { |
| | | throw Oops.Oh($"没有板件数据"); |
| | | } |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(upiList); |
| | | |
| | | } |
| | | } |
| | | |