From b1a419c2886666934da6499ee552516d0769562e Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期四, 16 四月 2026 13:40:56 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 189 ++++++++++++++++++++++++++++++++++++-----------
1 files changed, 144 insertions(+), 45 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 b29c7aa..0089f6b 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)
@@ -356,7 +358,7 @@
_detailRepository.UpdateData(outboundOrderDetails);
if (pickedDetails.Any())
{
- UpdateStockStatus(pickedDetails.Select(x => x.PalletCode).ToList(), StockStatusEmun.鍑哄簱閿佸畾.ObjToInt());
+ UpdateStockStatus(pickedDetails.Select(x => x.PalletCode).ToList(), StockStatusEmun.鍑哄簱閿佸畾.ObjToInt(),outboundOrder);
UpdateLocationStatus(pickedDetails.Select(x => x.LocationCode).ToList(), LocationStatusEnum.Lock.ObjToInt());
}
//閲嶆鍗曚笉鎷i�夛紝鍘绘帀閿佸畾璁板綍鍥炲簱锛屽啀娆$粍鐩樻椂鎵i櫎鍘熸潯鐮�
@@ -982,11 +984,16 @@
}
}
- public bool UpdateStockStatus(List<string> palletCodes, int status)
+ public bool UpdateStockStatus(List<string> palletCodes, int status,Dt_OutboundOrder outOrder)
{
try
{
List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x => palletCodes.Contains(x.PalletCode));
+ ///鏅轰粨璋冩櫤浠撳崟鎹褰�
+ if(outOrder.OrderType == 117)
+ {
+ stockInfos.ForEach(stockInfo => stockInfo.Remark = outOrder.OrderNo);
+ }
stockInfos.ForEach(stockInfo => stockInfo.StockStatus = status);
_stockInfoRepository.UpdateData(stockInfos);
return true;
@@ -1376,9 +1383,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.鑷姩鍒犻櫎);
@@ -1804,9 +1815,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.鑷姩鍒犻櫎);
@@ -2241,6 +2256,48 @@
return content.Error($"鏈壘鍒版墭鐩榹palletCode}搴撳瓨淇℃伅涓嶅厑璁稿洖搴�");
}
+ var task = await _taskRepository.Db.Queryable<Dt_Task>()
+ .Where(x => x.PalletCode == palletCode)
+ .FirstAsync();
+
+ if (task != null)
+ {
+ return content.Error($"鎵樼洏{palletCode}瀛樺湪浠诲姟鍥炲簱澶辫触!");
+ }
+
+ // 鍒嗛厤鏂拌揣浣�
+ var newLocation = _locationInfoService.AssignLocation(stock.LocationType);
+
+ if (newLocation == null)
+ {
+ return WebResponseContent.Instance.Error("娌℃湁绌洪棽搴撲綅鍙洖搴�");
+ }
+
+ if(stock.Remark !=null && stock.Remark != "")
+ {
+ Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == stock.Remark && x.OrderType == 117 && x.OrderStatus == OutOrderStatusEnum.鍑哄簱涓�.ObjToInt());
+ if (outboundOrder != null)
+ {
+ // 1. 鏍规嵁璁㈠崟鍙锋煡璇㈣皟鎷ㄧ墿鏂欎俊鎭�
+ List<Dt_AllocateMaterialInfo> allocateMaterialInfos = _allocateMaterialInfoRepository.QueryData(x => x.OrderNo == outboundOrder.OrderNo);
+
+ // 2. 鍒ゆ柇鏄惁瀛樺湪璋冩嫧鐗╂枡锛屾病鏈夊垯鐩存帴璺宠繃鏍¢獙
+ if (allocateMaterialInfos != null && allocateMaterialInfos.Any())
+ {
+ // 3. 鎻愬彇鎵�鏈� Barcode 闆嗗悎
+ List<string> barcodes = allocateMaterialInfos.Select(x => x.Barcode).ToList();
+
+ // 4. 鏍规嵁 Barcode 鎵归噺鏌ヨ搴撳瓨鏄庣粏
+ List<Dt_StockInfoDetail> stockInfoDetails = _stockDetailRepository.QueryData(x => barcodes.Contains(x.Barcode) && x.OrderNo == outboundOrder.OrderNo);
+
+ // 5. 鏁伴噺瀵规瘮锛氫笉鐩哥瓑 鈫� 鏈叏閮ㄧ粍鐩樺畬鎴�
+ if (barcodes.Count != stockInfoDetails.Count)
+ {
+ return WebResponseContent.Instance.Error($"鏅轰粨璋冩櫤浠撳崟鎹畕outboundOrder.OrderNo}灏氭湭鍏ㄩ儴缁勭洏瀹屾垚锛岃鍏堣繘琛岀粍鐩樺啀鍥炲簱鍗曟嵁鐩稿叧鏂欑");
+ }
+ }
+ }
+ }
if (stock.Details.Count <= 0)
{
stock.PalletType = (int)PalletTypeEnum.Empty;
@@ -2344,23 +2401,6 @@
stock.StockStatus = (int)StockStatusEmun.鍏ュ簱纭;
stock.LocationCode = "";
- }
-
- var task = await _taskRepository.Db.Queryable<Dt_Task>()
- .Where(x => x.PalletCode == palletCode)
- .FirstAsync();
-
- if (task != null)
- {
- return content.Error($"鎵樼洏{palletCode}瀛樺湪浠诲姟鍥炲簱澶辫触!");
- }
-
- // 鍒嗛厤鏂拌揣浣�
- var newLocation = _locationInfoService.AssignLocation(stock.LocationType);
-
- if(newLocation == null)
- {
- return WebResponseContent.Instance.Error("娌℃湁绌洪棽搴撲綅鍙洖搴�");
}
var newTask = new Dt_Task()
@@ -2496,16 +2536,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 =>
@@ -2514,13 +2557,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)
{
@@ -2530,21 +2608,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);
@@ -2757,4 +2825,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