From 981a80940e47409300c09847684ca530f75b4a5f Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 10 一月 2025 23:56:33 +0800
Subject: [PATCH] 优化WCS辅料出库逻辑
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService_Pick.cs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 48 insertions(+), 6 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService_Pick.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService_Pick.cs"
index d682cdc..6254dbf 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService_Pick.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService_Pick.cs"
@@ -9,15 +9,20 @@
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_IOutboundRepository;
+using WIDESEA_IRecordService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
namespace WIDESEA_IOutboundService
{
- public partial class OutStockLockInfoService : ServiceBase<Dt_OutStockLockInfo, IOutStockLockInfoRepository>, IOutStockLockInfoService
+ public partial class OutStockLockInfoService
{
- IStockService _stockService;
+ /// <summary>
+ /// 鍒嗘嫞
+ /// </summary>
+ /// <param name="palletCode">鎵樼洏鍙�</param>
+ /// <returns></returns>
public WebResponseContent MaterialPick(string palletCode)
{
try
@@ -27,20 +32,57 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨淇℃伅");
}
+ if (stockInfo.StockStatus != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樿繕鏈嚭搴撳畬鎴�");
+ }
List<Dt_OutStockLockInfo> outStockLockInfos = Repository.QueryData(x => x.PalletCode == palletCode);
for (int i = 0; i < outStockLockInfos.Count; i++)
{
- float assignQuantity = outStockLockInfos[i].AssignQuantity;
- List<Dt_StockInfoDetail> stockInfoDetails = stockInfo.Details.Where(x => x.MaterielCode == outStockLockInfos[i].MaterielCode).ToList();
- for (int j = 0; j < stockInfoDetails.Count; j++)
+ outStockLockInfos[i].Status = OutLockStockStatusEnum.鎷i�夊畬鎴�.ObjToInt();
+ }
+ 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>();
+ for (int i = 0; i < stockInfo.Details.Count; i++)
+ {
+ if (stockInfo.Details[i].OutboundQuantity > 0)
{
- // if(assignQuantity > stockInfoDetails[j])
+ if (stockInfo.Details[i].StockQuantity > stockInfo.Details[i].OutboundQuantity)
+ {
+ stockInfo.Details[i].StockQuantity -= stockInfo.Details[i].OutboundQuantity;
+ updateDetailList.Add(stockInfo.Details[i]);
+ }
+ else
+ {
+ deleteDetailList.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);
+ }
+ updateDetailList.ForEach(x =>
+ {
+ x.OutboundQuantity = 0;
+ });
+ stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt();
+ //_stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(deleteDetailList, OperateTypeEnum.鑷姩瀹屾垚);
+ _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+ _stockService.StockInfoDetailService.Repository.UpdateData(updateDetailList);
+ _stockService.StockInfoDetailService.Repository.DeleteData(deleteDetailList);
+ BaseDal.UpdateData(outStockLockInfos);
+ _unitOfWorkManage.BeginTran();
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
{
+ _unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
}
}
--
Gitblit v1.9.3