From 0023d3db5bd701864b73e57c0240c219c40c3a4e Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期一, 14 七月 2025 14:12:34 +0800 Subject: [PATCH] 1 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/辅料仓/AGV_FLExtend.cs | 2 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs | 5 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IMesRworkOutboundOrderService.cs | 2 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs | 123 ++--------------- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ErpProScrapSheetDetailService.cs | 94 ------------- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockService/ProStockInfoService.cs | 41 ----- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 2 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/成品仓/AGV_CPExtend.cs | 2 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs | 12 + 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesRworkOutboundOrderService.cs | 115 ++++++++++------ 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs | 2 11 files changed, 109 insertions(+), 291 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs" index 5ae5962..9d24261 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs" @@ -177,8 +177,7 @@ switch (agvUpdateModel.Method.ToUpper()) { case "END": - if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt() - || task.TaskType == TaskTypeEnum.OutAllocate.ObjToInt() || task.TaskType == TaskTypeEnum.OutProduct.ObjToInt()) + if (task.TaskType.GetTaskTypeGroup()==TaskTypeGroup.OutbondGroup) PutFinish(task.NextAddress); _taskService.TaskCompleted(task.TaskNum); break; @@ -356,7 +355,7 @@ TakeFinish(task.CurrentAddress); //_taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing); } - else if(task.TaskType == TaskTypeEnum.OutProduct.ObjToInt()) + else if(task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) { task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt(); _taskRepository.UpdateData(task); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" index 8909902..5e4b31f 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" @@ -29,7 +29,7 @@ { try { - if (task.TaskType == TaskTypeEnum.OutProduct.ObjToInt()) + if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) task.CurrentAddress = GetAGVAddress(task.CurrentAddress); else task.NextAddress = GetAGVAddress(task.NextAddress); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\350\276\205\346\226\231\344\273\223/AGV_FLExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\350\276\205\346\226\231\344\273\223/AGV_FLExtend.cs" index 1101c7f..49172e3 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\350\276\205\346\226\231\344\273\223/AGV_FLExtend.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\350\276\205\346\226\231\344\273\223/AGV_FLExtend.cs" @@ -32,7 +32,7 @@ { try { - if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt() || task.TaskType == TaskTypeEnum.OutAllocate.ObjToInt()) + if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) task.CurrentAddress = GetAGVAddress(task.CurrentAddress); else task.NextAddress = GetAGVAddress(task.NextAddress); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IMesRworkOutboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IMesRworkOutboundOrderService.cs" index 88b8e64..3de89fb 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IMesRworkOutboundOrderService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IMesRworkOutboundOrderService.cs" @@ -28,6 +28,8 @@ //搴撳瓨鏉垮嚭搴� WebResponseContent ProductOutBoundSync(MesProductOutBound model); + + MesProductOutBound MesProOutBound(Dt_MesRworkOutboundOrder mesRworkOutboundOrder, List<Dt_ProStockInfoDetail> proStockInfoDetails); /// <summary> /// 鎴愬搧MES鎻愬簱鍑哄簱瀹屽悗涓�鍖呬竴鍖呮嫞閫� /// </summary> diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ErpProScrapSheetDetailService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ErpProScrapSheetDetailService.cs" index 7aa1a90..c699330 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ErpProScrapSheetDetailService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ErpProScrapSheetDetailService.cs" @@ -99,7 +99,7 @@ { PartNum = item.ScrapProCode, PartRev = item.ScrapProVersion, - Lotno = item.ScrapProVersion, + Lotno = item.ScrapProCode, QtyOfArray = item.ScrapSETQty, QtyOfUnit = item.ScrapPcsQty, QtyOfArray_Alloc = 0, @@ -131,7 +131,7 @@ { PartNum = item.ScrapProCode, PartRev = item.ScrapProVersion, - Lotno = item.ScrapProVersion, + Lotno = item.ScrapProCode, QtyOfArray = item.ScrapSETQty, QtyOfUnit = item.ScrapPcsQty, QtyOfArray_Alloc = 0, @@ -212,87 +212,6 @@ List<Dt_ProStockInfo> outStocks = new List<Dt_ProStockInfo>(); List<Dt_OutProStockInfo> outProStockInfos = new List<Dt_OutProStockInfo>(); List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); - //List<Dt_ProOutOrderDetail> groupDetails = proOutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail() - //{ - // QtyPcs = x.Sum(x => x.QtyPcs) - x.Sum(x => x.OverQtyPcs), - // SaleOrder = x.Key.SaleOrder, - // PCode = x.Key.PCode, - // PVer = x.Key.PVer, - // PLot = x.Key.PLot, - // DateCode = x.Key.DateCode, - //}).ToList(); - //foreach (var item in groupDetails) - //{ - // float needQty = item.QtyPcs; - // //鏌ユ壘鍙敤搴撳瓨 - // List<Dt_ProStockInfo> stockInfoss = _stockInfoService.ProStockInfoService.GetUseableStocks(proOutOrder.WarehouseId, item); - // if (!stockInfoss.Any()) - // { - // throw new Exception("鏈壘鍒板彲鍒嗛厤搴撳瓨"); - // } - // //鑾峰彇鍑哄簱搴撳瓨 - // List<Dt_ProStockInfo> assignOutStocks = _stockInfoService.ProStockInfoService.GetOutboundStocks(stockInfoss, item, needQty, out float residueQuantity); - // item.LockQtyPcs += needQty - residueQuantity; - // if (item.QtyPcs> item.LockQtyPcs) - // { - // throw new Exception($"浜у搧缂栫爜{item.PCode}鍙垎閰嶆暟閲忎笉瓒�,鍙敤鏁伴噺{item.LockQtyPcs}"); - // } - // outStocks.AddRange(assignOutStocks); - // float assignQuantity = needQty - residueQuantity; - // bool isCanLot = string.IsNullOrEmpty(item.PLot); - // bool isCanDate = string.IsNullOrEmpty(item.DateCode); - // List<Dt_ProOutOrderDetail> details = proOutOrderDetails - // .Where(x =>x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode)) - // .ToList(); - - // for (int i = 0; i < details.Count; i++) - // { - // float orderQuantity = details[i].QtyPcs; - // for (int j = 0; j < assignOutStocks.Count; j++) - // { - // //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲� - // float detailAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity); - - // float palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity); - // //鍑哄簱璇︽儏宸插垎閰嶆暟閲� - // palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲� - // float palletOutboundQuantity = assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); - // if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭� - // { - // float orderDetailNeedQuantity = details[i].QtyPcs - detailAssignQuantity; - // if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity) - // { - // details[i].LockQtyPcs += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity; - // Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity); - // outProStockInfos.Add(outStockLockInfo); - // } - // else - // { - // Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], details[i].QtyPcs - details[i].LockQtyPcs); - // outProStockInfos.Add(outStockLockInfo); - // details[i].LockQtyPcs = details[i].QtyPcs; - // break; - // } - - // } - // } - // } - // List<string> locationArr = outStocks.Select(x => x.LocationCode).ToList(); - - // locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(locationArr)); - - //} foreach (var item in proOutOrderDetails) { float needQty = item.ScrapPcsQty; @@ -315,15 +234,6 @@ { //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲� float detailAssignQuantity = outProStockInfos.Where(x => x.OrderDetailId == item.Id).Sum(x => x.AssignQuantity); - ////鍑哄簱璇︽儏宸插垎閰嶆暟閲� - //float palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity); - ////鍑哄簱璇︽儏宸插垎閰嶆暟閲� - //float palletOutboundQuantity = assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); - //if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭� - //{ float orderDetailNeedQuantity = item.ScrapPcsQty - detailAssignQuantity; if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity)) { diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesRworkOutboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesRworkOutboundOrderService.cs" index 332fcd7..c0b232b 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesRworkOutboundOrderService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesRworkOutboundOrderService.cs" @@ -26,6 +26,8 @@ using WIDESEA_OutboundRepository; using WIDESEA_Common.APIEnum; using WIDESEA_Common.OrderEnum; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; +using System.Reflection.Metadata; namespace WIDESEA_OutboundService { @@ -66,63 +68,50 @@ Dt_MesRworkOutboundOrder assignOutOrder= new Dt_MesRworkOutboundOrder(); List<Dt_OutProStockInfo> outProStockInfos=new List<Dt_OutProStockInfo>(); List<Dt_LocationInfo> locationInfos=new List<Dt_LocationInfo>(); - float originalNeedQuantity = mesRworkOutboundOrder.RequiredQuantity; - - float needQuantity = originalNeedQuantity; - + float needQty = mesRworkOutboundOrder.RequiredQuantity; //鏌ユ壘鍙敤搴撳瓨 List<Dt_ProStockInfo> stockInfoss = _stockService.ProStockInfoService.GetUseableStocks(mesRworkOutboundOrder); if (!stockInfoss.Any()) { throw new Exception("鏈壘鍒板彲鍒嗛厤搴撳瓨"); } - List<Dt_ProStockInfo> autoAssignStocks = _stockService.ProStockInfoService.GetOutboundStocks(stockInfoss,mesRworkOutboundOrder, needQuantity,out float residueQuantity); - mesRworkOutboundOrder.LockQuantity += needQuantity - residueQuantity; - autoAssignStocks.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.StockPcsQty).ToList(); - proStockInfos.AddRange(autoAssignStocks); - float assignQuantity = needQuantity - residueQuantity; - + //鑾峰彇鍑哄簱搴撳瓨 + List<Dt_ProStockInfo> assignOutStocks = _stockService.ProStockInfoService.GetOutboundStocks(stockInfoss, mesRworkOutboundOrder, needQty, out float residueQuantity); + mesRworkOutboundOrder.LockQuantity += needQty - residueQuantity; + if (mesRworkOutboundOrder.RequiredQuantity > mesRworkOutboundOrder.LockQuantity) + { + throw new Exception($"浜у搧缂栫爜{mesRworkOutboundOrder.ProductCode},鐗堟湰{mesRworkOutboundOrder.ProductVersion}鍙垎閰嶆暟閲忎笉瓒�,鍙敤鏁伴噺{mesRworkOutboundOrder.LockQuantity}"); + } + proStockInfos.AddRange(assignOutStocks); + //鍒嗛厤鍑哄簱鐨凱CS鏁伴噺 + float assignQuantity = needQty; + //璁㈠崟鏄庣粏鐨勫嚭搴揚CS鏁伴噺 float orderQuantity = mesRworkOutboundOrder.RequiredQuantity; - bool isCanDate = string.IsNullOrEmpty(mesRworkOutboundOrder.DateCode); - for (int j = 0; j < autoAssignStocks.Count; j++) + for (int j = 0; j < assignOutStocks.Count; j++) { //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲� - float detailAssignQuantity = outProStockInfos - .Where(x => x.SaleOrder == mesRworkOutboundOrder.SaleOrder - && x.PCode == mesRworkOutboundOrder.ProductCode - && x.PVer == mesRworkOutboundOrder.ProductVersion - && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) - .Sum(x => x.AssignQuantity); + float detailAssignQuantity = outProStockInfos.Where(x => x.OrderDetailId == mesRworkOutboundOrder.Id).Sum(x => x.AssignQuantity); - //鍑哄簱璇︽儏宸插垎閰嶆暟閲� - float palletAssignQuantity = outProStockInfos - .Where(x => x.SaleOrder == mesRworkOutboundOrder.SaleOrder - && x.PCode == mesRworkOutboundOrder.ProductCode - && x.PVer == mesRworkOutboundOrder.ProductVersion - && x.PalletCode == autoAssignStocks[j].PalletCode - && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) - .Sum(x => x.AssignQuantity); - - float palletOutboundQuantity = autoAssignStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); - if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭� + //鎵�鍓╂暟閲� + float orderDetailNeedQuantity = mesRworkOutboundOrder.RequiredQuantity - detailAssignQuantity; + //鐢熸垚鍑哄簱璇︽儏 + if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity)) { - float orderDetailNeedQuantity = mesRworkOutboundOrder.RequiredQuantity - detailAssignQuantity; - if (orderDetailNeedQuantity > autoAssignStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity) - { - mesRworkOutboundOrder.LockQuantity += autoAssignStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity; - Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(mesRworkOutboundOrder, autoAssignStocks[j], autoAssignStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity); - outProStockInfos.Add(outStockLockInfo); - } - else - { - Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(mesRworkOutboundOrder, autoAssignStocks[j], mesRworkOutboundOrder.RequiredQuantity-mesRworkOutboundOrder.LockQuantity); - outProStockInfos.Add(outStockLockInfo); - mesRworkOutboundOrder.LockQuantity = mesRworkOutboundOrder.RequiredQuantity; - break; - } + mesRworkOutboundOrder.LockQuantity += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); + Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(mesRworkOutboundOrder, assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity)); + outProStockInfos.Add(outStockLockInfo); + } + else + { + Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(mesRworkOutboundOrder, assignOutStocks[j], mesRworkOutboundOrder.RequiredQuantity - detailAssignQuantity); + outProStockInfos.Add(outStockLockInfo); + mesRworkOutboundOrder.LockQuantity = mesRworkOutboundOrder.RequiredQuantity; + break; } } - locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(proStockInfos.Select(x => x.LocationCode).ToList())); + List<string> locationArr = proStockInfos.Select(x => x.LocationCode).ToList(); + + locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(locationArr)); return (proStockInfos, mesRworkOutboundOrder, outProStockInfos, locationInfos); } @@ -311,6 +300,44 @@ }; return mesProductOutBound; } + //搴撳瓨鏉挎暟鎹浆鎹� + public MesProductOutBound MesProOutBound(Dt_MesRworkOutboundOrder mesRworkOutboundOrder, List<Dt_ProStockInfoDetail> proStockInfoDetails) + { + //鑾峰彇浠撳簱淇℃伅 + Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == mesRworkOutboundOrder.WarehouseId); + List<MesInventoryInfo> inventoryInfos = new List<MesInventoryInfo>(); + foreach (var item in proStockInfoDetails.Where(x=>x.OutboundQuantity>0)) + { + int setinterval = (int)item.StockPcsQty / (int)item.SETQty; + if (setinterval == 0) + { + throw new Exception($"{item.BagNo}鑾峰彇SET鏁伴噺杞崲澶辫触"); + } + item.OutSETQty = (int)item.OutboundQuantity / setinterval; + if (item.OutSETQty == 0) + { + throw new Exception($"{item.BagNo}鑾峰彇SET鏁伴噺杞崲澶辫触"); + } + MesInventoryInfo mesInventoryInfo = new MesInventoryInfo() + { + Warhouseno = warehouse.WarehouseCode, + InternalPackageNumber = item.BagNo, + SetCount = (int)item.OutSETQty, + EligiblePcsCount = (int)item.OutboundQuantity + }; + inventoryInfos.Add(mesInventoryInfo); + } + MesProductOutBound mesProductOutBound = new MesProductOutBound() + { + TaskNo = mesRworkOutboundOrder.TaskNo, + ProductCode = mesRworkOutboundOrder.ProductCode, + ProductVersion = mesRworkOutboundOrder.ProductVersion, + DateCode = mesRworkOutboundOrder.DateCode, + SaleOrder = mesRworkOutboundOrder.SaleOrder, + InventoryInfo = inventoryInfos + }; + return mesProductOutBound; + } /// <summary> /// 鎴愬搧搴撳瓨鏉垮悓姝ユ帴鍙� /// </summary> diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs" index 2acec89..cb4e9f8 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs" @@ -106,87 +106,6 @@ { throw new Exception("鏈壘鍒版垚鍝佽鍗�"); } - //List<Dt_ProOutOrderDetail> groupDetails = proOutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail() - //{ - // QtyPcs = x.Sum(x => x.QtyPcs) - x.Sum(x => x.OverQtyPcs), - // SaleOrder = x.Key.SaleOrder, - // PCode = x.Key.PCode, - // PVer = x.Key.PVer, - // PLot = x.Key.PLot, - // DateCode = x.Key.DateCode, - //}).ToList(); - //foreach (var item in groupDetails) - //{ - // float needQty = item.QtyPcs; - // //鏌ユ壘鍙敤搴撳瓨 - // List<Dt_ProStockInfo> stockInfoss = _stockInfoService.ProStockInfoService.GetUseableStocks(proOutOrder.WarehouseId, item); - // if (!stockInfoss.Any()) - // { - // throw new Exception("鏈壘鍒板彲鍒嗛厤搴撳瓨"); - // } - // //鑾峰彇鍑哄簱搴撳瓨 - // List<Dt_ProStockInfo> assignOutStocks = _stockInfoService.ProStockInfoService.GetOutboundStocks(stockInfoss, item, needQty, out float residueQuantity); - // item.LockQtyPcs += needQty - residueQuantity; - // if (item.QtyPcs> item.LockQtyPcs) - // { - // throw new Exception($"浜у搧缂栫爜{item.PCode}鍙垎閰嶆暟閲忎笉瓒�,鍙敤鏁伴噺{item.LockQtyPcs}"); - // } - // outStocks.AddRange(assignOutStocks); - // float assignQuantity = needQty - residueQuantity; - // bool isCanLot = string.IsNullOrEmpty(item.PLot); - // bool isCanDate = string.IsNullOrEmpty(item.DateCode); - // List<Dt_ProOutOrderDetail> details = proOutOrderDetails - // .Where(x =>x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode)) - // .ToList(); - - // for (int i = 0; i < details.Count; i++) - // { - // float orderQuantity = details[i].QtyPcs; - // for (int j = 0; j < assignOutStocks.Count; j++) - // { - // //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲� - // float detailAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity); - - // float palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity); - // //鍑哄簱璇︽儏宸插垎閰嶆暟閲� - // palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲� - // float palletOutboundQuantity = assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); - // if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭� - // { - // float orderDetailNeedQuantity = details[i].QtyPcs - detailAssignQuantity; - // if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity) - // { - // details[i].LockQtyPcs += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity; - // Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity); - // outProStockInfos.Add(outStockLockInfo); - // } - // else - // { - // Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], details[i].QtyPcs - details[i].LockQtyPcs); - // outProStockInfos.Add(outStockLockInfo); - // details[i].LockQtyPcs = details[i].QtyPcs; - // break; - // } - - // } - // } - // } - // List<string> locationArr = outStocks.Select(x => x.LocationCode).ToList(); - - // locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(locationArr)); - - //} foreach (var item in proOutOrderDetails) { float needQty = item.QtyPcs; @@ -206,39 +125,29 @@ outStocks.AddRange(assignOutStocks); //鍒嗛厤鍑哄簱鐨凱CS鏁伴噺 float assignQuantity = needQty; - bool isCanLot = string.IsNullOrEmpty(item.PLot); - bool isCanDate = string.IsNullOrEmpty(item.DateCode); //璁㈠崟鏄庣粏鐨勫嚭搴揚CS鏁伴噺 float orderQuantity = item.QtyPcs; for (int j = 0; j < assignOutStocks.Count; j++) { //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲� float detailAssignQuantity = outProStockInfos.Where(x => x.OrderDetailId == item.Id).Sum(x => x.AssignQuantity); - ////鍑哄簱璇︽儏宸插垎閰嶆暟閲� - //float palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer - // && (isCanLot ? isCanLot : x.PLot == item.PLot) - // && (isCanDate ? isCanDate : x.DateCode == item.DateCode) - // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity); - ////鍑哄簱璇︽儏宸插垎閰嶆暟閲� - //float palletOutboundQuantity = assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); - //if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭� - //{ - float orderDetailNeedQuantity = item.QtyPcs - detailAssignQuantity; - if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity)) - { - item.LockQtyPcs += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); - Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, item, assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity)); - outProStockInfos.Add(outStockLockInfo); - } - else - { - Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, item, assignOutStocks[j], item.QtyPcs - detailAssignQuantity); - outProStockInfos.Add(outStockLockInfo); - item.LockQtyPcs = item.QtyPcs; - break; - } - //} + + float orderDetailNeedQuantity = item.QtyPcs - detailAssignQuantity; + //鐢熸垚鍑哄簱璇︽儏 + if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity)) + { + item.LockQtyPcs += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity); + Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, item, assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity)); + outProStockInfos.Add(outStockLockInfo); + } + else + { + Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, item, assignOutStocks[j], item.QtyPcs - detailAssignQuantity); + outProStockInfos.Add(outStockLockInfo); + item.LockQtyPcs = item.QtyPcs; + break; + } } List<string> locationArr = outStocks.Select(x => x.LocationCode).ToList(); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs" index f7845f3..0f2a144 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs" @@ -74,7 +74,7 @@ { List<Dt_ProStockInfo>? proStockInfos = null; bool isCanDate = string.IsNullOrEmpty(mesRworkOutboundOrder.DateCode); - proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute==ProStockAttributeEnum.灏炬暟.ObjToInt()) + proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode)) .Includes(x => x.proStockInfoDetails) .Where(x => x.proStockInfoDetails .Any(v => v.SaleOrder == mesRworkOutboundOrder.SaleOrder diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/ProStockInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/ProStockInfoService.cs" index 00a3ae1..07c8b06 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/ProStockInfoService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/ProStockInfoService.cs" @@ -339,47 +339,6 @@ index++; } } - else - { - for (int i = 0; i < stockInfos.Count; i++) - { - Dt_ProStockInfo stockInfo = stockInfos[i]; - float useableStockQuantity = stockInfo.proStockInfoDetails - .Where(x => x.SaleOrder == mesRworkOutboundOrder.SaleOrder - && x.ProductCode == mesRworkOutboundOrder.ProductCode - && x.ProductVersion == mesRworkOutboundOrder.ProductVersion - && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) - .Sum(x => x.StockPcsQty - x.OutboundQuantity); - if (useableStockQuantity < needQuantity) - { - stockInfo.proStockInfoDetails.ForEach(x => x.OutboundQuantity = x.StockPcsQty); - needQuantity -= useableStockQuantity; - } - else - { - stockInfo.proStockInfoDetails.ForEach(x => - { - if (x.StockPcsQty > x.OutboundQuantity && x.SaleOrder == mesRworkOutboundOrder.SaleOrder - && x.ProductCode == mesRworkOutboundOrder.ProductCode - && x.ProductVersion == mesRworkOutboundOrder.ProductVersion - && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) - { - if (x.StockPcsQty - x.OutboundQuantity >= needQuantity) - { - x.OutboundQuantity += needQuantity; - needQuantity = 0; - } - else - { - needQuantity -= (x.StockPcsQty - x.OutboundQuantity); - x.OutboundQuantity = x.StockPcsQty; - } - } - }); - } - assignOutStocks.Add(stockInfo); - } - } residueQuantity = needQuantity; return assignOutStocks; } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs" index 8f54ef4..d56e520 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs" @@ -541,6 +541,7 @@ { return content.Error($"鎻愬簱浠诲姟鍗晎model.TaskNo}宸插瓨鍦�"); } + //鐢熸垚鎻愬簱鍗� Dt_MesRworkOutboundOrder mesRworkOutboundOrder = new Dt_MesRworkOutboundOrder() { WarehouseId = warehouse.WarehouseId, @@ -560,6 +561,7 @@ List<Dt_ProStockInfo>? proStockInfos = null; List<Dt_OutProStockInfo>? outProStockInfos = null; List<Dt_LocationInfo>? locationInfos = null; + List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); //鍒嗛厤搴撳瓨鐢熸垚鎻愬簱浠诲姟 (List<Dt_ProStockInfo>?, Dt_MesRworkOutboundOrder?, List<Dt_OutProStockInfo>?, List<Dt_LocationInfo>) result = _outboundService.RworkOutboundOrderService.AssignMesStocks(mesRworkOutboundOrder); if (result.Item1 != null && result.Item1.Count > 0) @@ -585,6 +587,10 @@ x.TargetAddress = "5236"; x.OrderNo = mesRworkOutboundOrder.TaskNo; }); + proStockInfos.ForEach(x => + { + proStockInfoDetails.AddRange(x.proStockInfoDetails); + }); _unitOfWorkManage.BeginTran(); int id = BaseDal.AddData(tasks); @@ -604,6 +610,12 @@ } } _outboundService.RworkOutboundOrderService.Repository.AddData(mesRworkOutboundOrder); + //MES鎴愬搧搴撳瓨鏉垮嚭搴撳悓姝� + WebResponseContent responseContent = _outboundService.RworkOutboundOrderService.ProductOutBoundSync(_outboundService.RworkOutboundOrderService.MesProOutBound(mesRworkOutboundOrder, proStockInfoDetails)); + if (!responseContent.Status) + { + throw new Exception("鍚屾MES搴撳瓨鏉垮嚭搴撳け璐�,閿欒:" + responseContent.Message); + } _unitOfWorkManage.CommitTran(); return content.OK("鎻愪緵杩斿簱鍗曟帴鏀舵垚鍔�"); } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index b453a70..a0ff157 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -1073,7 +1073,6 @@ } proStockInfoDetails.ForEach(x => { - x.OutboundQuantity = 0; x.ProOutDetailStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); }); proStockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); @@ -1087,6 +1086,7 @@ //璐т綅鍙樺姩璁板綍 int beforeStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _outboundRepository.ErpProScrapDetailRepository.UpdateData(erpProScrapSheetDetail); _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, proStockInfo.PalletType, LocationStatusEnum.Free, locationInfo.WarehouseId); _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationStatusEnum.Free, LocationChangeType.OutboundCompleted, erpProScrapSheet?.ProScrapSheetOrderNo ?? "", task.TaskNum); _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); -- Gitblit v1.9.3