| | |
| | | [ApiDescriptionSettings(ApplicationConst.WmsTaskGroupName, Order = 100)] |
| | | public class WmsOperationTaskService : IDynamicApiController, ITransient |
| | | { |
| | | private static readonly SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); |
| | | |
| | | private readonly SqlSugarRepository<WmsRbLineTask> _rep; |
| | | private readonly SqlSugarRepository<WmsStockQuan> _wmsStockQuanRep; |
| | | private readonly SqlSugarRepository<Mes_Package_Gather> _mesPackageGatherRep; |
| | |
| | | var _QiTaoReuslt = ""; |
| | | bool isNewOrder = false; |
| | | string _location = "BZ-33"; |
| | | var lastPackageUnline = await _mes_Package_UnLine_RecordRep.AsQueryable().Where(x => x.UpiFlag == UpiFlagEnum.正常).OrderByDescending(x => x.Id).FirstAsync(); |
| | | 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; |
| | |
| | | [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> |
| | |
| | | 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; |
| | | |
| | | if (order.UnLinePackageNum > order.PackageNum) |
| | | { |
| | | order.UnLinePackageNum = order.PackageNum; |
| | | } |
| | | order.NgPackageNum = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线 && x.UpiFlag == UpiFlagEnum.NG).Count(); |
| | | if (isNG) |
| | | { |
| | | order.NgPackageNum = order.NgPackageNum + 1; |
| | | } |
| | | if (order.NgPackageNum > order.PackageNum) |
| | | { |
| | | order.NgPackageNum = order.PackageNum; |
| | | } |
| | | |
| | | order.NoUnLinePackageNum = order.PackageNum - order.UnLinePackageNum; |
| | | |