1
hutongqing
2025-01-11 9be8d6e3232971246ec6cb2acac1ad4d05798e9b
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService_Pick.cs
@@ -36,7 +36,11 @@
                {
                    return WebResponseContent.Instance.Error($"该托盘还未出库完成");
                }
                List<Dt_OutStockLockInfo> outStockLockInfos = Repository.QueryData(x => x.PalletCode == palletCode);
                List<Dt_OutStockLockInfo> outStockLockInfos = Repository.QueryData(x => x.PalletCode == palletCode && x.Status == OutLockStockStatusEnum.出库完成.ObjToInt());
                if (outStockLockInfos == null || outStockLockInfos.Count == 0)
                {
                    return WebResponseContent.Instance.Error("该托盘已全部分拣完成");
                }
                for (int i = 0; i < outStockLockInfos.Count; i++)
                {
                    outStockLockInfos[i].Status = OutLockStockStatusEnum.拣选完成.ObjToInt();
@@ -44,6 +48,7 @@
                List<Dt_StockInfoDetail> beforeDetaile = stockInfo.Details.GroupBy(x => x.MaterielCode).Select(x => new Dt_StockInfoDetail { MaterielCode = x.Key, StockQuantity = x.Sum(v => v.StockQuantity) }).ToList();
                List<Dt_StockInfoDetail> updateDetailList = new List<Dt_StockInfoDetail>();
                List<Dt_StockInfoDetail> deleteDetailList = new List<Dt_StockInfoDetail>();
                List<Dt_StockInfoDetail> residueDetailList = new List<Dt_StockInfoDetail>();
                for (int i = 0; i < stockInfo.Details.Count; i++)
                {
                    if (stockInfo.Details[i].OutboundQuantity > 0)
@@ -58,30 +63,26 @@
                            deleteDetailList.Add(stockInfo.Details[i]);
                        }
                    }
                    else
                    {
                        residueDetailList.Add(stockInfo.Details[i]);
                    }
                }
                List<string> mCodes = stockInfo.Details.GroupBy(x => x.MaterielCode).Select(x => x.Key).ToList();
                _unitOfWorkManage.BeginTran();
                foreach (string code in mCodes)
                {
                    _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, updateDetailList, deleteDetailList, StockChangeTypeEnum.Outbound);
                    _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, residueDetailList, updateDetailList, deleteDetailList, StockChangeTypeEnum.Outbound);
                }
                updateDetailList.ForEach(x =>
                {
                    x.OutboundQuantity = 0;
                });
                stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
                //_stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(deleteDetailList, OperateTypeEnum.自动完成);
                if (stockInfo.Details.Sum(x=>x.StockQuantity)== stockInfo.Details.Sum(x => x.OutboundQuantity))
                {
                    _stockService.StockInfoService.Repository.DeleteData(stockInfo);
                }
                else
                {
                    _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                }
                _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(deleteDetailList, OperateTypeEnum.自动完成);
                _stockService.StockInfoDetailService.Repository.UpdateData(updateDetailList);
                _stockService.StockInfoDetailService.Repository.DeleteData(deleteDetailList);
                //_stockService.StockInfoDetailService.Repository.DeleteData(deleteDetailList);
                BaseDal.UpdateData(outStockLockInfos);
                _unitOfWorkManage.BeginTran();
                return WebResponseContent.Instance.OK();