From 9baffa8a8a5c9fbdda690544132b95db9196cc88 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周一, 16 12月 2024 15:22:08 +0800 Subject: [PATCH] 22 --- LA24030_LuLiPackageLine_Wms/Admin.NET.Application/Service/WmsOperationTask/WmsOperationTaskService.cs | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 151 insertions(+), 8 deletions(-) diff --git a/LA24030_LuLiPackageLine_Wms/Admin.NET.Application/Service/WmsOperationTask/WmsOperationTaskService.cs b/LA24030_LuLiPackageLine_Wms/Admin.NET.Application/Service/WmsOperationTask/WmsOperationTaskService.cs index 831130c..a3a26bf 100644 --- a/LA24030_LuLiPackageLine_Wms/Admin.NET.Application/Service/WmsOperationTask/WmsOperationTaskService.cs +++ b/LA24030_LuLiPackageLine_Wms/Admin.NET.Application/Service/WmsOperationTask/WmsOperationTaskService.cs @@ -27,6 +27,7 @@ private readonly SqlSugarRepository<WmsRecordUpiProcess> _wmsRecordUpiProcessRep; private readonly SqlSugarRepository<WmsRecordPackageProcess> _wmsRecordPackageProcessRep; 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 WmsCommonnQueryService _wmsCommonnQueryService; @@ -41,8 +42,10 @@ , SqlSugarRepository<WmsRecordPackageProcess> wmsRecordPackageProcessRep , SqlSugarRepository<WmsRecordUpiNg> wmsRecordUpiNgRep , WmsCommonnQueryService wmsCommonnQueryService + , SqlSugarRepository<Mes_Package_LineQueue> mes_Package_LineQueueRep ) { + _mes_Package_LineQueueRep = mes_Package_LineQueueRep; _wmsCommonnQueryService = wmsCommonnQueryService; _wmsRecordUpiNgRep = wmsRecordUpiNgRep; _sysConfigRep = sysConfigRep; @@ -95,12 +98,42 @@ //鏇存柊鐘舵�� foreach (var quan in quanList) { + if (quan.StockStatus != StockStatusEnum.鍦ㄥ簱 && quan.StockStatus != StockStatusEnum.宸插喕缁�) + { + throw Oops.Oh($"閮ㄤ欢鏉$爜{quan.Upi}鐨勫簱瀛樼姸鎬佷笉鏄�'{StockStatusEnum.鍦ㄥ簱.ToString()}鎴杮StockStatusEnum.宸插喕缁�.ToString()}'鐘舵��"); + } + quan.StockStatus = StockStatusEnum.浜哄伐寮哄埗寰呭嚭搴�; quan.StockStatusName = StockStatusEnum.浜哄伐寮哄埗寰呭嚭搴�.ToString(); quan.UpdateTime = DateTime.Now; quan.OperReason = "浜哄伐寮哄埗寰呭嚭搴�"; } updateQuanList.AddRange(quanList); + + var packageObj = await _mesPackageGatherRep.GetFirstAsync(x => x.PackageCode == item); + packageObj.UpiFlag = UpiFlagEnum.NG; + packageObj.UpiStatus = UpiStatusEnum.宸蹭笅绾�; + await _mesPackageGatherRep.UpdateAsync(packageObj); + + + //涓嬬嚎鏇存柊 璁㈠崟琛ㄦ暟鎹� _mesOrderGatherRep + await UpdateOrderGather(packageObj); + + foreach (var quan in quanList) + { + //娓呯悊 闃熷垪琛� + var removeUpiList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.Upi == quan.Upi).ToListAsync(); + if (removeUpiList?.Count > 0) + { + await _mes_Upi_LineQueueRep.DeleteAsync(removeUpiList); + } + + var removePackageList = await _mes_Package_LineQueueRep.AsQueryable().Where(x => x.PackageCode == quan.PackageCode).ToListAsync(); + if (removePackageList?.Count > 0) + { + await _mes_Package_LineQueueRep.DeleteAsync(removePackageList); + } + } } //妯″紡鍒ゆ柇 @@ -153,12 +186,21 @@ //鏇存柊鐘舵�� foreach (var quan in quanList) { + if (quan.StockStatus != StockStatusEnum.鍦ㄥ簱 && quan.StockStatus != StockStatusEnum.宸插喕缁�) + { + throw Oops.Oh($"閮ㄤ欢鏉$爜{quan.Upi}鐨勫簱瀛樼姸鎬佷笉鏄�'{StockStatusEnum.鍦ㄥ簱.ToString()}鎴杮StockStatusEnum.宸插喕缁�.ToString()}'鐘舵��"); + } quan.StockStatus = StockStatusEnum.榻愬寘寰呭嚭搴�; quan.StockStatusName = StockStatusEnum.榻愬寘寰呭嚭搴�.ToString(); quan.UpdateTime = DateTime.Now; quan.OperReason = "浜哄伐榻愬寘鍑哄簱"; } updateQuanList.AddRange(quanList); + + var packageObj = await _mesPackageGatherRep.GetFirstAsync(x => x.PackageCode == item); + packageObj.UpiStatus = UpiStatusEnum.宸查綈鍖�; + packageObj.IsQiBao = true; + await _mesPackageGatherRep.UpdateAsync(packageObj); } //妯″紡鍒ゆ柇 @@ -213,18 +255,57 @@ var setValue = ""; var _QiTaoReuslt = ""; - 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.鍒濆 || x.UpiStatus == UpiStatusEnum.涓嶉綈鍖�).Count(); - if (num > 0) + + bool isNeedQueryQiTao = true; + var order = await _mesOrderGatherRep.AsQueryable().Where(x => x.Info5 == package.Info5).FirstAsync(); + if (order == null) { - //涓嶉綈濂� - setValue = $"{input.PackageCode}|涓嶉綈濂梶" + curUserName; - _QiTaoReuslt = "涓嶉綈濂�"; + } else { - setValue = $"{input.PackageCode}|榻愬|" + curUserName; - _QiTaoReuslt = "榻愬"; + if (order.IsKitting != null) + { + _QiTaoReuslt = (bool)order.IsKitting ? "榻愬" : "涓嶉綈濂�"; + isNeedQueryQiTao = false; + } + } + 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) + { + //涓嶉綈濂� + _QiTaoReuslt = "涓嶉綈濂�"; + } + else + { + _QiTaoReuslt = "榻愬"; + } + } + 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); } @@ -345,6 +426,11 @@ throw Oops.Oh($"娌℃湁鎵惧埌鍖呭彿{input.PackageCode}鐨勬眹鎬绘暟鎹�"); } + if (singlePackage.UpiStatus == UpiStatusEnum.宸蹭笅绾�) + { + throw Oops.Oh($"鍖呭彿{input.PackageCode}宸茬粡涓嬬嚎"); + } + singlePackage.UpiFlag = UpiFlagEnum.NG; singlePackage.UpdateTime = DateTime.Now; singlePackage.UpiStatus = UpiStatusEnum.宸蹭笅绾�; @@ -388,7 +474,25 @@ 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); WmsRecordPackageProcess wmsRecordPackage = new WmsRecordPackageProcess(); @@ -407,6 +511,45 @@ } /// <summary> + /// 涓嬬嚎鏇存柊 璁㈠崟琛ㄦ暟鎹� + /// </summary> + /// <param name="singlePackage"></param> + /// <returns></returns> + private async Task UpdateOrderGather(Mes_Package_Gather singlePackage) + { + //涓嬬嚎鏇存柊 璁㈠崟琛ㄦ暟鎹� _mesOrderGatherRep + bool isAdd = false; + var order = await _mesOrderGatherRep.AsQueryable().Where(x => x.Info5 == singlePackage.Info5).FirstAsync(); + if (order == null) + { + isAdd = true; + order = new Mes_Order_Gather() + { + Info5 = singlePackage.Info5, + OrderId = singlePackage.OrderId, + PlanNo = singlePackage.PlanNo, + }; + } + 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() + 1; + 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.姝e父).Sum(x => Convert.ToDecimal(x.Info13)); + order.NoScanPackageArea = order.AllPackageArea - order.ScanPackageArea; + if (isAdd) + { + await _mesOrderGatherRep.InsertAsync(order); + } + else + { + await _mesOrderGatherRep.UpdateAsync(order); + } + } + + /// <summary> /// 鏍囪NG-鎵弿浠跺彿 /// </summary> /// <param name="input"></param> -- Gitblit v1.9.3