From a44fa8cf7d3530deb2896aa0f4e003f2b49c7fc9 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期四, 16 四月 2026 13:40:47 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 135 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 108 insertions(+), 27 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
index 81372d7..5503ec7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
@@ -70,6 +70,7 @@
public readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
public readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
public readonly IRepository<Dt_LocationType> _locationTypeRepository;
+ public readonly IRepository<Dt_OutboundOrderDetail> _outboundOrderDetailRepository;
private Dictionary<string, string> stations = new Dictionary<string, string>
{
@@ -83,7 +84,7 @@
{"3-1","3-5" },
};
- public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository)
+ public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_OutboundOrderDetail> outboundOrderDetailRepository)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -110,6 +111,7 @@
_inboundOrderRepository = inboundOrderRepository;
_locationTypeRepository = locationTypeRepository;
_warehouseAreaRepository = warehouseAreaRepository;
+ _outboundOrderDetailRepository = outboundOrderDetailRepository;
}
public WebResponseContent PrintFromData (string barcode)
@@ -330,7 +332,19 @@
foreach (var detail in materielCalc.Details)
{
if (remainingToLock <= 0) break;
- decimal maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity-detail.LockQuantity;
+ decimal maxLockableQty = 0;
+ if (detail.LockQuantity > detail.OverOutQuantity && detail.OverOutQuantity > 0)
+ {
+ maxLockableQty = detail.OrderQuantity - detail.LockQuantity;
+ }
+ else if(detail.OverOutQuantity > 0)
+ {
+ maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity;
+ }
+ else
+ {
+ maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity;
+ }
if (maxLockableQty <= 0) continue;
decimal currentLockQty = Math.Min(remainingToLock, maxLockableQty);
detail.LockQuantity += currentLockQty;
@@ -1364,9 +1378,13 @@
Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode;
- List<Dt_OutStockLockInfo> stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
- x.OrderNo == request.OrderNo &&
- x.MaterielCode == stockInfoDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList();
+ var stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
+ x.OrderDetailIds == lockInfo.OrderDetailIds &&
+ x.OrderNo == request.OrderNo &&
+ x.MaterielCode == stockInfoDetail.MaterielCode)
+ .Where(supWhere)
+ .Where(wareWhere)
+ .ToList();
if (stockLockInfos != null && stockLockInfos.Any())
{
_outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩鍒犻櫎);
@@ -1792,9 +1810,13 @@
Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode;
- List<Dt_OutStockLockInfo> stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
- x.OrderNo == request.OrderNo &&
- x.MaterielCode == stockDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList();
+ var stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
+ x.OrderDetailIds == lockInfo.OrderDetailIds &&
+ x.OrderNo == request.OrderNo &&
+ x.MaterielCode == stockDetail.MaterielCode)
+ .Where(supWhere)
+ .Where(wareWhere)
+ .ToList();
if (stockLockInfos != null && stockLockInfos.Any())
{
_outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩鍒犻櫎);
@@ -2484,16 +2506,19 @@
Dt_StockInfoDetail_Hty historyDetail = _stockDetailHistoryRepository.QueryFirst(x =>
x.Barcode == request.Barcode &&
-
(x.OperateType == "鍑哄簱瀹屾垚" || x.OperateType == "鎷嗗寘-鍘熷璁板綍"));
- if(historyDetail != null)
+ if (historyDetail != null)
{
double minutesDiff = (DateTime.Now - historyDetail.InsertTime).TotalMinutes;
if (minutesDiff >= 30)
{
return WebResponseContent.Instance.Error($"鏉$爜{request.Barcode}宸叉棤娉曟挙閿�");
}
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error($"鏉$爜{request.Barcode}宸叉棤娉曟挙閿�");
}
Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x =>
@@ -2502,13 +2527,48 @@
x.MaterielCode == historyDetail.MaterielCode &&
x.PalletCode == stockInfo.PalletCode);
+ if (lockInfo == null)
+ {
+ return WebResponseContent.Instance.Error("璇ユ墭鐩樺凡鍏ㄩ儴鎷i�夊畬,涓嶅厑璁告挙閿�");
+ }
+
+ var details = _outboundOrderDetailRepository.QueryData(x => x.OrderId == outboundOrder.Id);
+
+ var outboundDetails = details
+ .Where(x =>
+ x.MaterielCode == historyDetail.MaterielCode
+ &&
+ !string.IsNullOrEmpty(lockInfo.OrderDetailIds)
+ &&
+ lockInfo.OrderDetailIds.Split(",")
+ .Any(idStr => idStr.Trim() == x.Id.ToString())
+ ).ToList();
+
+ var detail = outboundDetails.FirstOrDefault();
+ if (detail != null && !string.IsNullOrEmpty(detail.ReturnJsonData))
+ {
+ try
+ {
+ string deleteBarcode = request.Barcode;
+
+ var list = JsonConvert.DeserializeObject<List<BarcodeItem>>(detail.ReturnJsonData);
+ if (list != null)
+ {
+ var filteredList = list.Where(x => x.barcode != deleteBarcode).ToList();
+
+ detail.ReturnJsonData = JsonConvert.SerializeObject(filteredList);
+ _outboundOrderDetailRepository.UpdateData(detail);
+ }
+ }
+ catch
+ {
+
+ }
+ }
+
_unitOfWorkManage.BeginTran();
try
{
- if(lockInfo == null)
- {
- return WebResponseContent.Instance.Error("璇ユ墭鐩樺凡鍏ㄩ儴鎷i�夊畬,涓嶅厑璁告挙閿�");
- }
bool isUnpack = historyDetail.OperateType == "鎷嗗寘-鍘熷璁板綍";
if (isUnpack)
{
@@ -2518,21 +2578,11 @@
{
ReverseFullOutboundOperation(historyDetail, stockInfo, request);
}
+
RollbackOutboundOrderDetails(historyDetail.MaterielCode, request.OrderNo, historyDetail.StockQuantity, stockInfo.Id);
- if (lockInfo != null)
- {
- lockInfo.SortedQuantity = Math.Max(0, (decimal)(lockInfo.SortedQuantity - historyDetail.StockQuantity));
-
- if (lockInfo.SortedQuantity == 0)
- {
- _outboundLockInfoRepository.UpdateData(lockInfo);
- }
- else
- {
- _outboundLockInfoRepository.UpdateData(lockInfo);
- }
- }
+ lockInfo.SortedQuantity = Math.Max(0, (decimal)(lockInfo.SortedQuantity - historyDetail.StockQuantity));
+ _outboundLockInfoRepository.UpdateData(lockInfo);
_stockDetailHistoryRepository.DeleteData(historyDetail);
@@ -2745,4 +2795,35 @@
}
+
+ /// <summary>
+ /// 鏉$爜鏄庣粏瀹炰綋
+ /// </summary>
+ public class BarcodeItem
+ {
+ /// <summary>
+ /// 鏉$爜
+ /// </summary>
+ public string barcode { get; set; }
+
+ /// <summary>
+ /// 鏁伴噺
+ /// </summary>
+ public decimal qty { get; set; }
+
+ /// <summary>
+ /// 渚涘簲鍟嗙紪鐮�
+ /// </summary>
+ public string supplyCode { get; set; }
+
+ /// <summary>
+ /// 鎵规鍙�
+ /// </summary>
+ public string batchNo { get; set; }
+
+ /// <summary>
+ /// 鍗曚綅
+ /// </summary>
+ public string unit { get; set; }
+ }
}
--
Gitblit v1.9.3