From bbc4a3a07baf111c9074ceee7728158fb3eedf1a Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期二, 25 十一月 2025 05:33:35 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs | 9
项目代码/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue | 13 -
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 162 ++++++++++++-----
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 139 ++++++++++++++-
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ESSController.cs | 2
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs | 2
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs | 165 +++++++----------
7 files changed, 320 insertions(+), 172 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
index 39ead12..2fc26e1 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
@@ -935,21 +935,16 @@
if (res.status) {
successCount++;
+ this.$message.success(`鎴愬姛鍙栨秷`);
} else {
errorCount++;
- console.error(`鍙栨秷鎷i�夊け璐�: ${row.Barcode}`, res.message);
+ this.$message.warning(`鍙栨秷鎷i�夊け璐�: ${row.currentBarcode} - ${res.message}`);
}
} catch (error) {
errorCount++;
- console.error(`鍙栨秷鎷i�夊け璐�: ${row.Barcode}`, error);
+ this.$message.warning(`鍙栨秷鎷i�夊け璐�: ${row.currentBarcode} - ${error.message}` );
}
- }
-
- if (errorCount === 0) {
- this.$message.success(`鎴愬姛鍙栨秷 ${successCount} 椤筦);
- } else {
- this.$message.warning(`鎴愬姛鍙栨秷 ${successCount} 椤癸紝澶辫触 ${errorCount} 椤筦);
- }
+ }
this.loadData();
this.selectedPickedRows = [];
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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
index 9d98d85..a14fd53 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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
@@ -103,7 +103,7 @@
return JsonConvert.DeserializeObject<ResponseModel>(body);
}
- public async Task<ResponseModel> FeedbackAllocate(AllocateDto model)
+ public async Task<ResponseModel> FeedbackAllocate(AllocateDto model)
{
string json = JsonConvert.SerializeObject(model, new JsonSerializerSettings
{
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/OutboundOrderDetailService.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/OutboundOrderDetailService.cs"
index 14257d7..e856df7 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/OutboundOrderDetailService.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/OutboundOrderDetailService.cs"
@@ -21,9 +21,9 @@
private readonly IUnitOfWorkManage _unitOfWorkManage;
public IRepository<Dt_OutboundOrderDetail> Repository => BaseDal;
-
+
private readonly IStockService _stockService;
-
+
private readonly IOutStockLockInfoService _outStockLockInfoService;
private readonly ILocationInfoService _locationInfoService;
private readonly IBasicService _basicService;
@@ -68,16 +68,16 @@
List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
- // 鎸夌墿鏂欏拰鎵规鍒嗙粍澶勭悊
+ // 鎸夌墿鏂欍�佹壒娆°�佷緵搴斿晢鍒嗙粍
var groupDetails = outboundOrderDetails
- .GroupBy(x => new { x.MaterielCode, x.BatchNo ,x.SupplyCode})
+ .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode })
.Select(x => new
{
- MaterielCode = x.Key.MaterielCode,
- BatchNo = x.Key.BatchNo,
- SupplyCode = x.Key.SupplyCode,
+ x.Key.MaterielCode,
+ x.Key.BatchNo,
+ x.Key.SupplyCode,
Details = x.ToList(),
- TotalNeedQuantity = x.Sum(v => v.OrderQuantity - v.OverOutQuantity - v.LockQuantity-v.MoveQty)
+ TotalNeedQuantity = x.Sum(v => v.OrderQuantity - v.OverOutQuantity - v.LockQuantity - v.MoveQty)
})
.Where(x => x.TotalNeedQuantity > 0)
.ToList();
@@ -86,125 +86,98 @@
{
var needQuantity = item.TotalNeedQuantity;
- // 鑾峰彇鍙敤搴撳瓨锛堟寜鍏堣繘鍏堝嚭鎺掑簭锛�
- List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo,item.SupplyCode);
+ // 鑾峰彇鍙敤搴撳瓨锛堝凡鎸夊厛杩涘厛鍑烘帓搴忥級
+ List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(
+ item.MaterielCode, item.BatchNo, item.SupplyCode);
+
if (!stockInfos.Any())
{
throw new Exception($"鐗╂枡[{item.MaterielCode}]鎵规[{item.BatchNo}]鏈壘鍒板彲鍒嗛厤搴撳瓨");
}
- // 鍒嗛厤搴撳瓨锛堟寜鍏堣繘鍏堝嚭锛�
+ // 鍒嗛厤搴撳瓨
var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(
stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
- if (residueQuantity > 0 && residueQuantity == needQuantity)
+ // 妫�鏌ュ垎閰嶇粨鏋�
+ if (residueQuantity > 0)
{
- throw new Exception($"鐗╂枡[{item.MaterielCode}]搴撳瓨涓嶈冻锛岄渶瑕亄needQuantity}锛屽彲鐢▄needQuantity - residueQuantity}");
+ var allocatedQuantity = needQuantity - residueQuantity;
+ throw new Exception($"鐗╂枡[{item.MaterielCode}]搴撳瓨涓嶈冻锛岄渶瑕亄needQuantity}锛屽疄闄呭垎閰峽allocatedQuantity}");
}
outStocks.AddRange(autoAssignStocks);
- // 鎸夊厛杩涘厛鍑哄師鍒欏垎閰嶉攣瀹氭暟閲忓埌鍚勪釜鏄庣粏
- DistributeLockQuantityByFIFO(item.Details, autoAssignStocks, stockAllocations, outStockLockInfos, outboundOrder);
+ // 鎸夊厛杩涘厛鍑哄垎閰嶉攣瀹氭暟閲�
+ DistributeLockQuantityByFIFO(item.Details, autoAssignStocks, stockAllocations,
+ outStockLockInfos, outboundOrder);
}
- locationInfos.AddRange(_locationInfoService.GetLocationInfos(outStocks.Select(x => x.LocationCode).Distinct().ToList()));
+ locationInfos.AddRange(_locationInfoService.GetLocationInfos(
+ outStocks.Select(x => x.LocationCode).Distinct().ToList()));
return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
}
-
+
/// <summary>
/// 鎸夊厛杩涘厛鍑哄師鍒欏垎閰嶉攣瀹氭暟閲忓埌鍚勪釜鏄庣粏
/// </summary>
- private void DistributeLockQuantityByFIFO(
- List<Dt_OutboundOrderDetail> details,
- List<Dt_StockInfo> assignStocks,
- Dictionary<int, decimal> stockAllocations,
- List<Dt_OutStockLockInfo> outStockLockInfos,
- Dt_OutboundOrder outboundOrder)
+ private void DistributeLockQuantityByFIFO(List<Dt_OutboundOrderDetail> details,List<Dt_StockInfo> assignStocks,Dictionary<int, decimal> stockAllocations,List<Dt_OutStockLockInfo> outStockLockInfos,
+ Dt_OutboundOrder outboundOrder)
{
- // 鎸夊厛杩涘厛鍑烘帓搴忓嚭搴撳崟鏄庣粏锛堝亣璁惧厛鍒涘缓鐨勬槑缁嗛渶瑕佷紭鍏堟弧瓒筹級
- var sortedDetails = details
- .Where(d => d.OrderQuantity - d.OverOutQuantity - d.LockQuantity -d.MoveQty> 0) // 鍙鐞嗚繕闇�瑕佸垎閰嶇殑鏁伴噺
- .OrderBy(x => x.Id)
- .ToList();
+ var sortedStocks = assignStocks.OrderBy(x => x.CreateDate).ToList();
+
+ var totalNeedQuantity = details.Sum(d => d.OrderQuantity - d.OverOutQuantity - d.LockQuantity - d.MoveQty);
+ decimal allocatedQuantity = 0;
- if (!sortedDetails.Any()) return;
-
- // 鑾峰彇鎵�鏈夊垎閰嶄簡搴撳瓨鐨勬槑缁嗭紝鎸夊厛杩涘厛鍑烘帓搴�
- var allocatedStockDetails = assignStocks
- .SelectMany(x => x.Details)
- .Where(x => stockAllocations.ContainsKey(x.Id))
- .OrderBy(x => x.CreateDate)
- .ThenBy(x => x.StockId)
- .ToList();
-
- // 涓烘瘡涓簱瀛樻槑缁嗗垱寤哄垎閰嶈褰�
- foreach (var stockDetail in allocatedStockDetails)
+ foreach (var stock in sortedStocks)
{
- if (!stockAllocations.TryGetValue(stockDetail.Id, out decimal allocatedQuantity))
+ if (allocatedQuantity >= totalNeedQuantity) break;
+
+ if (!stockAllocations.TryGetValue(stock.Id, out decimal stockAllocation) || stockAllocation <= 0)
continue;
- if (allocatedQuantity <= 0) continue;
+ var sortedDetails = details
+ .Where(d => d.OrderQuantity - d.OverOutQuantity - d.LockQuantity - d.MoveQty > 0)
+ .OrderBy(x => x.Id)
+ .ToList();
- var stockInfo = assignStocks.First(x => x.Id == stockDetail.StockId);
- decimal remainingAllocate = allocatedQuantity;
-
- // 鎸夐『搴忓垎閰嶇粰鍚勪釜鍑哄簱鍗曟槑缁�
foreach (var detail in sortedDetails)
{
- if (remainingAllocate <= 0) break;
+ if (stockAllocation <= 0) break;
- // 璁$畻杩欎釜鏄庣粏杩橀渶瑕佸垎閰嶇殑鏁伴噺
- var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity-detail.MoveQty;
+ var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity - detail.MoveQty;
if (detailNeed <= 0) continue;
- // 鍒嗛厤鏁伴噺
- var assignQuantity = Math.Min(remainingAllocate, detailNeed);
+ var assignQuantity = Math.Min(stockAllocation, detailNeed);
- // 楠岃瘉鏉$爜鏄惁瀛樺湪
- if (string.IsNullOrEmpty(stockDetail.Barcode))
+ // 浣跨敤搴撳瓨涓殑鏈夋晥鏉$爜
+ var barcode = stock.Details
+ .Where(d => !string.IsNullOrEmpty(d.Barcode))
+ .Select(d => d.Barcode)
+ .FirstOrDefault();
+
+ if (string.IsNullOrEmpty(barcode))
{
- throw new Exception($"搴撳瓨鏄庣粏ID[{stockDetail.Id}]鐨勬潯鐮佷负绌�");
+ throw new Exception($"搴撳瓨ID[{stock.Id}]鐨勬潯鐮佷负绌�");
}
- // 鍒涘缓鍑哄簱閿佸畾淇℃伅
var lockInfo = _outStockLockInfoService.GetOutStockLockInfo(
- outboundOrder, detail, stockInfo, assignQuantity, stockDetail.Barcode);
+ outboundOrder, detail, stock, assignQuantity, barcode);
outStockLockInfos.Add(lockInfo);
- // 鏇存柊鏄庣粏鐨勯攣瀹氭暟閲�
detail.LockQuantity += assignQuantity;
- remainingAllocate -= assignQuantity;
+ stockAllocation -= assignQuantity;
+ allocatedQuantity += assignQuantity;
+
+ if (allocatedQuantity >= totalNeedQuantity) break;
}
+ }
- // 濡傛灉杩樻湁鍓╀綑鍒嗛厤鏁伴噺锛岄噸鏂板垎閰嶆垨璁板綍璀﹀憡
- if (remainingAllocate > 0)
- {
- // 閲嶆柊鍒嗛厤缁欏叾浠栭渶瑕佸垎閰嶇殑鏄庣粏
- foreach (var detail in sortedDetails)
- {
- if (remainingAllocate <= 0) break;
-
- var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity;
- if (detailNeed <= 0) continue;
-
- var assignQuantity = Math.Min(remainingAllocate, detailNeed);
-
- var lockInfo = _outStockLockInfoService.GetOutStockLockInfo(
- outboundOrder, detail, stockInfo, assignQuantity, stockDetail.Barcode);
- outStockLockInfos.Add(lockInfo);
-
- detail.LockQuantity += assignQuantity;
- remainingAllocate -= assignQuantity;
- }
-
- // 濡傛灉杩樻湁鍓╀綑锛岃褰曡鍛婁絾涓嶆姏鍑哄紓甯�
- if (remainingAllocate > 0)
- {
- _logger.LogWarning($"搴撳瓨鍒嗛厤鍚庝粛鏈夊墿浣欐暟閲忔湭鍒嗛厤: {remainingAllocate}, 鏉$爜: {stockDetail.Barcode}");
- }
- }
+ // 楠岃瘉鏄惁瀹屽叏鍒嗛厤
+ if (allocatedQuantity < totalNeedQuantity)
+ {
+ _logger.LogWarning($"搴撳瓨鍒嗛厤涓嶅畬鍏紝闇�瑕亄totalNeedQuantity}锛屽疄闄呭垎閰峽allocatedQuantity}");
}
}
@@ -218,8 +191,8 @@
/// <param name="locationStatus"></param>
/// <param name="tasks"></param>
/// <returns></returns>
- public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_OutboundOrderDetail> outboundOrderDetails,
- List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos,
+ public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_OutboundOrderDetail> outboundOrderDetails,
+ List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos,
LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null)
{
try
@@ -227,7 +200,7 @@
// 鏇存柊搴撳瓨鐘舵��
stockInfos.ForEach(x => x.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾);
_stockService.StockInfoService.Repository.UpdateData(stockInfos);
-
+
// 鏇存柊搴撳瓨鏄庣粏
var stockDetails = stockInfos.SelectMany(x => x.Details).ToList();
_stockService.StockInfoDetailService.Repository.UpdateData(stockDetails);
@@ -280,16 +253,16 @@
SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_InboundOrderDetail.OrderId).FirstLetterToLower());
if (searchParameters != null)
{
- sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId== searchParameters.Value.ObjToInt());
- var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount);
+ sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId == searchParameters.Value.ObjToInt());
+ var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount);
return new PageGridData<Dt_OutboundOrderDetail>(totalCount, dataList);
}
}
-
+
}
}
- return new PageGridData<Dt_OutboundOrderDetail> ();
+ return new PageGridData<Dt_OutboundOrderDetail>();
}
@@ -299,12 +272,12 @@
if (!checkResult.Item1) throw new Exception(checkResult.Item2);
Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
- var originalNeedQuantity = outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity-outboundOrderDetail.MoveQty;
+ var originalNeedQuantity = outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity - outboundOrderDetail.MoveQty;
var needQuantity = originalNeedQuantity;
List<Dt_StockInfo> outStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList());
- var assignQuantity =0m;
+ var assignQuantity = 0m;
outStocks.ForEach(x =>
{
x.Details.ForEach(v =>
@@ -324,9 +297,9 @@
needQuantity -= assignQuantity;
if (outboundOrderDetail.OrderQuantity > outboundOrderDetail.LockQuantity)
{
- List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode, outboundOrderDetail.BatchNo,"");
+ List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode, outboundOrderDetail.BatchNo, "");
stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)).ToList();
- var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity);
+ var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity);
outboundOrderDetail.LockQuantity += needQuantity - residueQuantity;
outStocks.AddRange(autoAssignStocks);
outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
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/OutboundPickingService.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/OutboundPickingService.cs"
index 4e34b27..01a0644 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/OutboundPickingService.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/OutboundPickingService.cs"
@@ -293,14 +293,15 @@
_unitOfWorkManage.CommitTran();
-
+
// 鍒涘缓鍥炲簱浠诲姟
- await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InPick);
+ await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InPick,task.PalletType);
// 鏇存柊璁㈠崟鐘舵�侊紙涓嶈Е鍙慚ES鍥炰紶锛�
await UpdateOrderStatusForReturn(orderNo);
- return WebResponseContent.Instance.OK($"鍥炲簱鎿嶄綔鎴愬姛锛屽叡鍥炲簱鏁伴噺锛歿statusAnalysis.TotalReturnQty}");
+ return WebResponseContent.Instance.OK($"鍥炲簱鎿嶄綔鎴愬姛");
+ //return WebResponseContent.Instance.OK($"鍥炲簱鎿嶄綔鎴愬姛锛屽叡鍥炲簱鏁伴噺锛歿statusAnalysis.TotalReturnQty}");
}
catch (Exception ex)
{
@@ -616,7 +617,7 @@
result.FinalBarcode = newBarcode;
result.SplitResults.AddRange(CreateSplitResults(lockInfo, actualQty, remainingStockQty, newBarcode, stockDetail.Barcode));
-
+
_logger.LogInformation($"鎷嗗寘鍒嗘嫞瀹屾垚 - OrderDetailId: {lockInfo.OrderDetailId}, 鍒嗘嫞鏁伴噺: {actualQty}");
}
@@ -1037,7 +1038,7 @@
return task;
}
-
+
private async Task<decimal> CalculateSplitReturnQuantity(List<Dt_SplitPackageRecord> splitRecords, int stockId)
{
decimal totalQty = 0;
@@ -1045,11 +1046,14 @@
foreach (var splitRecord in splitRecords)
{
+ if (splitRecord.Status != (int)SplitPackageStatusEnum.宸叉挙閿�)
+ continue;
// 妫�鏌ュ師鏉$爜
if (!processedBarcodes.Contains(splitRecord.OriginalBarcode))
{
var originalStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
- .Where(it => it.Barcode == splitRecord.OriginalBarcode && it.StockId == stockId)
+ .Where(it => it.Barcode == splitRecord.OriginalBarcode && it.StockId == stockId &&
+ it.Status != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
.FirstAsync();
if (originalStock != null && originalStock.StockQuantity > 0)
@@ -1063,7 +1067,7 @@
if (!processedBarcodes.Contains(splitRecord.NewBarcode))
{
var newStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
- .Where(it => it.Barcode == splitRecord.NewBarcode && it.StockId == stockId)
+ .Where(it => it.Barcode == splitRecord.NewBarcode && it.StockId == stockId && it.Status != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
.FirstAsync();
if (newStock != null && newStock.StockQuantity > 0)
@@ -1111,11 +1115,13 @@
else
{
locationtype = stockInfo.LocationType;
+ _stockInfoService.DeleteData(stockInfo);
}
var targetAddress = originalTask.TargetAddress;
await CleanupZeroStockData(stockInfoId);
+
var emptystockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = palletCode, LocationType = locationtype };
emptystockInfo.Details = new List<Dt_StockInfoDetail>();
@@ -1123,7 +1129,7 @@
//绌烘墭鐩樺浣曞鐞� 杩樻湁涓�涓嚭搴撲换鍔¤澶勭悊銆�
originalTask.PalletType = PalletTypeEnum.Empty.ObjToInt();
- await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty);
+ await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty,PalletTypeEnum.Empty.ObjToInt());
}
catch (Exception ex)
@@ -1143,19 +1149,41 @@
{
await HandleRemainingLocksReturn(analysis.RemainingLocks, stockInfo.Id);
- // await UpdateOrderDetailsOnReturn(analysis.RemainingLocks);
- }
+ // await UpdateOrderDetailsOnReturn(analysis.RemainingLocks);
+ }
// 澶勭悊鎵樼洏涓婂叾浠栧簱瀛樿揣鐗�
if (analysis.HasPalletStockGoods)
{
- await HandlePalletStockGoodsReturn(analysis.PalletStockGoods);
+ var validStockGoods = analysis.PalletStockGoods
+ .Where(x => x.Status != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+ .ToList();
+
+ if (validStockGoods.Any())
+ {
+ await HandlePalletStockGoodsReturn(analysis.PalletStockGoods);
+ }
+ else
+ {
+ _logger.LogInformation("娌℃湁鏈夋晥鐨勫簱瀛樿揣鐗╅渶瑕佸洖搴�");
+ }
}
// 澶勭悊鎷嗗寘璁板綍
if (analysis.HasSplitRecords)
{
- await HandleSplitRecordsReturn(analysis.SplitRecords, orderNo, palletCode);
+ var validSplitRecords = analysis.SplitRecords
+ .Where(x => x.Status != (int)SplitPackageStatusEnum.宸叉嫞閫�)
+ .ToList();
+
+ if (validSplitRecords.Any())
+ {
+ await HandleSplitRecordsReturn(analysis.SplitRecords, orderNo, palletCode);
+ }
+ else
+ {
+ _logger.LogInformation("娌℃湁鏈夋晥鐨勬媶鍖呰褰曢渶瑕佸鐞�");
+ }
}
// 鏇存柊搴撳瓨涓昏〃鐘舵��
@@ -1179,7 +1207,13 @@
foreach (var lockInfo in remainingLocks)
{
decimal returnQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
+ if (returnQty <= 0)
+ {
+ _logger.LogWarning($"閿佸畾璁板綍{lockInfo.Id}鏃犻渶鍥炲簱锛屽垎閰嶆暟閲�: {lockInfo.AssignQuantity}, 宸叉嫞閫�: {lockInfo.PickedQty}");
+ continue;
+ }
+ _logger.LogInformation($"澶勭悊閿佸畾璁板綍鍥炲簱 - 閿佸畾ID: {lockInfo.Id}, 鏉$爜: {lockInfo.CurrentBarcode}, 鍥炲簱鏁伴噺: {returnQty}");
// 鏌ユ壘瀵瑰簲鐨勫簱瀛樻槑缁�
var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
.Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
@@ -1195,23 +1229,23 @@
else
{
// 鍒涘缓鏂扮殑搴撳瓨璁板綍
- var newStockDetail = new Dt_StockInfoDetail
- {
- StockId = lockInfo.StockId,
- MaterielCode = lockInfo.MaterielCode,
- MaterielName = lockInfo.MaterielName,
- OrderNo = lockInfo.OrderNo,
- BatchNo = lockInfo.BatchNo,
- StockQuantity = returnQty,
- OutboundQuantity = 0,
- Barcode = lockInfo.CurrentBarcode,
- InboundOrderRowNo = "",
- Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
- SupplyCode = lockInfo.SupplyCode,
- WarehouseCode = lockInfo.WarehouseCode,
- Unit = lockInfo.Unit,
- };
- await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
+ //var newStockDetail = new Dt_StockInfoDetail
+ //{
+ // StockId = lockInfo.StockId,
+ // MaterielCode = lockInfo.MaterielCode,
+ // MaterielName = lockInfo.MaterielName,
+ // OrderNo = lockInfo.OrderNo,
+ // BatchNo = lockInfo.BatchNo,
+ // StockQuantity = returnQty,
+ // OutboundQuantity = 0,
+ // Barcode = lockInfo.CurrentBarcode,
+ // InboundOrderRowNo = "",
+ // Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+ // SupplyCode = lockInfo.SupplyCode,
+ // WarehouseCode = lockInfo.WarehouseCode,
+ // Unit = lockInfo.Unit,
+ //};
+ //await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
}
}
}
@@ -1255,23 +1289,41 @@
{
_logger.LogInformation($"寰呭洖搴撹揣鐗� - 鏉$爜: {stockGood.Barcode}, 鏁伴噺: {stockGood.StockQuantity}, 褰撳墠鐘舵��: {stockGood.Status}");
- // 鎭㈠搴撳瓨鐘舵��
- stockGood.OutboundQuantity = 0;
- stockGood.Status = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+ if (stockGood.Status != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+ {
+ stockGood.OutboundQuantity = 0;
+ stockGood.Status = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+ await _stockInfoDetailService.Db.Updateable(stockGood).ExecuteCommandAsync();
- await _stockInfoDetailService.Db.Updateable(stockGood).ExecuteCommandAsync();
+ _logger.LogInformation($"搴撳瓨璐х墿鍥炲簱瀹屾垚 - 鏉$爜: {stockGood.Barcode}, 鏂扮姸鎬�: {stockGood.Status}");
+ }
+ else
+ {
+ _logger.LogWarning($"璺宠繃宸插嚭搴撳畬鎴愮殑璐х墿 - 鏉$爜: {stockGood.Barcode}");
+ }
}
}
private async Task HandleSplitRecordsReturn(List<Dt_SplitPackageRecord> splitRecords, string orderNo, string palletCode)
{
+ var validRecords = splitRecords.Where(x => x.Status != (int)SplitPackageStatusEnum.宸叉嫞閫�).ToList();
+
+ if (!validRecords.Any())
+ {
+ _logger.LogInformation("娌℃湁闇�瑕佸洖搴撶殑鎷嗗寘璁板綍");
+ return;
+ }
+
+ _logger.LogInformation($"鏇存柊{validRecords.Count}鏉℃媶鍖呰褰曠姸鎬佷负宸插洖搴�");
+
// 鏇存柊鎷嗗寘璁板綍鐘舵��
await _splitPackageService.Db.Updateable<Dt_SplitPackageRecord>()
.SetColumns(x => new Dt_SplitPackageRecord
{
Status = (int)SplitPackageStatusEnum.宸插洖搴�,
+ Operator = App.User.UserName
})
- .Where(x => x.OrderNo == orderNo && x.PalletCode == palletCode && !x.IsReverted)
+ .Where(x => validRecords.Select(r => r.Id).Contains(x.Id))
.ExecuteCommandAsync();
}
@@ -1290,7 +1342,7 @@
/// <param name="originalTask"></param>
/// <param name="analysis"></param>
/// <returns></returns>
- private async Task CreateReturnTaskAndHandleESS(string orderNo, string palletCode, Dt_Task originalTask, TaskTypeEnum taskTypeEnum)
+ private async Task CreateReturnTaskAndHandleESS(string orderNo, string palletCode, Dt_Task originalTask, TaskTypeEnum taskTypeEnum,int palletType)
{
var firstLocation = await _locationInfoService.Db.Queryable<Dt_LocationInfo>()
.FirstAsync(x => x.LocationCode == originalTask.SourceAddress);
@@ -1304,15 +1356,16 @@
Grade = 0,
PalletCode = palletCode,
NextAddress = "",
- OrderNo = originalTask.OrderNo,
+ // OrderNo = originalTask.OrderNo,
+ OrderNo = orderNo,
Roadway = newLocation.RoadwayNo,
SourceAddress = stations[originalTask.TargetAddress],
TargetAddress = newLocation.LocationCode,
TaskStatus = TaskStatusEnum.New.ObjToInt(),
TaskType = taskTypeEnum.ObjToInt(),
- PalletType = originalTask.PalletType,
+ PalletType = palletType,
WarehouseId = originalTask.WarehouseId
-
+
};
// 淇濆瓨鍥炲簱浠诲姟
await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
@@ -1420,10 +1473,10 @@
.ExecuteCommandAsync();
// 鍙湁姝e父鍒嗘嫞瀹屾垚鏃舵墠鍚慚ES鍙嶉
- if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
- {
- await HandleOrderCompletion(outboundOrder, orderNo);
- }
+ //if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
+ //{
+ // await HandleOrderCompletion(outboundOrder, orderNo);
+ //}
}
}
catch (Exception ex)
@@ -1432,7 +1485,7 @@
}
}
-
+
private async Task UpdateOrderStatusForReturn(string orderNo)
{
@@ -1728,7 +1781,7 @@
StockId = stockId
};
- // 1. 鍒嗘瀽鏈垎鎷g殑鍑哄簱閿佸畾璁板綍
+ // 鍒嗘瀽鏈垎鎷g殑鍑哄簱閿佸畾璁板綍
var remainingLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
.Where(it => it.OrderNo == orderNo &&
it.PalletCode == palletCode &&
@@ -1740,9 +1793,10 @@
result.HasRemainingLocks = true;
result.RemainingLocks = remainingLocks;
result.RemainingLocksReturnQty = remainingLocks.Sum(x => x.AssignQuantity - x.PickedQty);
+ _logger.LogInformation($"鍙戠幇{remainingLocks.Count}鏉℃湭鍒嗘嫞閿佸畾璁板綍锛屾�绘暟閲�: {result.RemainingLocksReturnQty}");
}
- // 2. 鍒嗘瀽鎵樼洏涓婄殑搴撳瓨璐х墿
+ // 鍒嗘瀽鎵樼洏涓婄殑搴撳瓨璐х墿
var palletStockGoods = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
.Where(it => it.StockId == stockId &&
(it.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt() ||
@@ -1756,13 +1810,21 @@
result.HasPalletStockGoods = true;
result.PalletStockGoods = palletStockGoods;
result.PalletStockReturnQty = palletStockGoods.Sum(x => x.StockQuantity);
+ _logger.LogInformation($"鍙戠幇{palletStockGoods.Count}涓簱瀛樿揣鐗╋紝鎬绘暟閲�: {result.PalletStockReturnQty}");
+
+ // 璁板綍璇︾粏鐘舵�佸垎甯�
+ var statusGroups = palletStockGoods.GroupBy(x => x.Status);
+ foreach (var group in statusGroups)
+ {
+ _logger.LogInformation($"搴撳瓨鐘舵�亄group.Key}: {group.Count()}涓揣鐗╋紝鏁伴噺: {group.Sum(x => x.StockQuantity)}");
+ }
}
- // 3. 鍒嗘瀽鎷嗗寘璁板綍
+ //鍒嗘瀽鎷嗗寘璁板綍
var splitRecords = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
.Where(it => it.OrderNo == orderNo &&
it.PalletCode == palletCode &&
- !it.IsReverted &&
+ !it.IsReverted && it.Status != (int)SplitPackageStatusEnum.宸叉嫞閫� &&
it.Status != (int)SplitPackageStatusEnum.宸插洖搴�)
.ToListAsync();
@@ -1771,6 +1833,8 @@
result.HasSplitRecords = true;
result.SplitRecords = splitRecords;
result.SplitReturnQty = await CalculateSplitReturnQuantity(splitRecords, stockId);
+
+ _logger.LogInformation($"鍙戠幇{splitRecords.Count}鏉℃湭鎷i�夋媶鍖呰褰曪紝鎬绘暟閲�: {result.SplitReturnQty}");
}
// 4. 璁$畻鎬诲洖搴撴暟閲忓拰绌烘墭鐩樼姸鎬�
@@ -1785,6 +1849,10 @@
x.TaskStatus == (int)TaskStatusEnum.New)
.AnyAsync();
+ _logger.LogInformation($"鎵樼洏鐘舵�佸垎鏋愬畬鎴� - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}, " +
+ $"鎬诲洖搴撴暟閲�: {result.TotalReturnQty}, 鏄惁绌烘墭鐩�: {result.IsEmptyPallet}, " +
+ $"鏈夎繘琛屼腑浠诲姟: {result.HasActiveTasks}");
+
return result;
}
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_StockService/StockInfoService.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_StockService/StockInfoService.cs"
index 7303c19..e550934 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_StockService/StockInfoService.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_StockService/StockInfoService.cs"
@@ -201,12 +201,9 @@
if (!string.IsNullOrEmpty(supplyCode))
{
query = query.Where(x => x.Details.Any(d => d.SupplyCode == supplyCode));
- }
+ }
- var stocks = query.ToList();
-
- return stocks.OrderBy(x => x.Details.Where(d => d.MaterielCode == materielCode && (string.IsNullOrEmpty(supplyCode) || d.SupplyCode == supplyCode) &&
- (string.IsNullOrEmpty(lotNo) || d.BatchNo == lotNo)).Min(d => d.CreateDate)).ToList();
+ return query.OrderBy(x => x.CreateDate).ToList();
//ISugarQueryable<Dt_LocationInfo> sugarQueryable = Db.Queryable<Dt_LocationInfo>().Where(x => locationCodes.Contains(x.LocationCode));
//ISugarQueryable<Dt_StockInfo> sugarQueryable1 = Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode));
//return sugarQueryable.InnerJoin(sugarQueryable1, (a, b) => a.LocationCode == b.LocationCode).Select((a, b) => b).OrderBy(a => a.CreateDate).Includes(a => a.Details).ToList();
@@ -227,7 +224,7 @@
public List<Dt_StockInfo> GetStockInfosByPalletCodes(List<string> palletCodes)
{
- return Db.Queryable<Dt_StockInfo>().Where(x => palletCodes.Contains(x.PalletCode)).Includes(x => x.Details).ToList();
+ return Db.Queryable<Dt_StockInfo>().Where(x => palletCodes.Contains(x.PalletCode)).Includes(x => x.Details).OrderBy(x => x.CreateDate).ToList();
}
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_TaskInfoService/TaskService.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_TaskInfoService/TaskService.cs"
index df616ba..6a804a7 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_TaskInfoService/TaskService.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_TaskInfoService/TaskService.cs"
@@ -41,6 +41,7 @@
using WIDESEA_DTO.Allocate;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Inbound;
+using WIDESEA_DTO.Outbound;
using WIDESEA_DTO.Task;
using WIDESEA_IAllocateService;
using WIDESEA_IBasicService;
@@ -126,7 +127,7 @@
if (int.TryParse(taskNum, out var newTaskNum))
{
- task = BaseDal.QueryFirst(x => x.TaskNum == newTaskNum);
+ task =await BaseDal.QueryFirstAsync(x => x.TaskNum == newTaskNum);
if (task == null)
{
return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�");
@@ -141,10 +142,28 @@
MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted");
if (methodInfo != null)
{
- WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task });
- if (responseContent != null)
+ object? taskResult = methodInfo.Invoke(this, new object[] { task });
+ if (taskResult is Task<WebResponseContent> asyncTask)
{
- return responseContent;
+ try
+ {
+ // 3. 寮傛绛夊緟 Task 瀹屾垚锛岃嚜鍔ㄨВ鏋愬嚭 WebResponseContent
+ WebResponseContent responseContent = await asyncTask;
+ if (responseContent != null)
+ {
+ return responseContent;
+ }
+ }
+ catch (AggregateException ex)
+ {
+ _logger.LogError($"TaskService TaskCompleted taskResult: {ex.Message} ");
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ catch(Exception ex)
+ {
+ _logger.LogError(ex, $"Unexpected error in {task.TaskType}");
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
}
}
return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫");
@@ -363,7 +382,7 @@
return WebResponseContent.Instance.OK();
}
- public WebResponseContent OutboundTaskCompleted(Dt_Task task)
+ public async Task<WebResponseContent> OutboundTaskCompleted(Dt_Task task)
{
_logger.LogInformation($"TaskService OutboundTaskCompleted: {task.TaskNum}");
//鏌ヨ揣浣�
@@ -375,7 +394,7 @@
locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
_locationInfoService.Repository.UpdateData(locationInfo);
- var outloks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.TaskNum == task.TaskNum).ToList();
+ var outloks =await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.TaskNum == task.TaskNum).ToListAsync();
var stockids = outloks.Select(x => x.StockId).ToList();
@@ -439,12 +458,22 @@
stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
_stockRepository.UpdateData(stockInfo);
+ var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().First(x => x.OrderNo == task.OrderNo);
+
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
_locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
+ if (outboundOrder != null)
+ {
+ await HandleOutboundOrderToMESCompletion(outboundOrder, outboundOrder.OrderNo);
+ }
+ else
+ {
+ _logger.LogInformation($"TaskService InEmptyTaskCompleted: {task.TaskNum} ,鏈壘鍒板嚭搴撳崟銆� ");
+ }
return content;
}
@@ -460,25 +489,30 @@
try
{
//鏌ュ簱瀛�
- Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == task.PalletCode).First();
+ Dt_StockInfo stockInfo =await _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == task.PalletCode).FirstAsync();
if (stockInfo == null)
{
+ _logger.LogInformation($"TaskService InPickTaskCompleted: 鏈壘鍒版墭鐩樺搴旂殑缁勭洏淇℃伅.{task.TaskNum}");
return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺搴旂殑缁勭洏淇℃伅");
}
if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt())
{
+ _logger.LogInformation($"TaskService InPickTaskCompleted: 鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅.{task.TaskNum}");
return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
}
//鏌ヨ揣浣�
Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
if (locationInfo == null)
{
+ _logger.LogInformation($"TaskService InPickTaskCompleted: 鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅 {task.TaskNum}.");
return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
}
+
+ var beforelocationStatus = locationInfo.LocationStatus;
// 鑾峰彇鎵�鏈夊洖搴撲腑鐨勫嚭搴撻攣瀹氳褰�
- var returnLocks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ var returnLocks =await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
.Where(it => it.OrderNo == task.OrderNo && it.PalletCode == task.PalletCode && it.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
- .ToList();
+ .ToListAsync();
// 鏇存柊鍑哄簱閿佸畾璁板綍鐘舵�佷负鍥炲簱瀹屾垚
foreach (var lockInfo in returnLocks)
{
@@ -512,17 +546,98 @@
locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
}
_locationInfoService.Repository.UpdateData(locationInfo);
-
+ var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().First(x => x.OrderNo == task.OrderNo);
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
BaseDal.DeleteData(task);
+ _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
+
+ if (outboundOrder != null)
+ {
+ await HandleOutboundOrderToMESCompletion(outboundOrder, outboundOrder.OrderNo);
+ }
+ else
+ {
+ _logger.LogInformation($"TaskService InPickTaskCompleted: {task.TaskNum} ,鏈壘鍒板嚭搴撳崟銆� ");
+ }
}
catch (Exception ex)
{
_logger.LogInformation($"TaskService InPickTaskCompleted: {task.TaskNum} , {ex.Message}");
}
- return WebResponseContent.Instance.OK();
+ return await Task.FromResult(WebResponseContent.Instance.OK());
+ }
+
+
+ private async Task HandleOutboundOrderToMESCompletion(Dt_OutboundOrder outboundOrder, string orderNo)
+ {
+ // 鑾峰彇璁㈠崟鏄庣粏鏁版嵁
+ var orderDetails = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+ .LeftJoin<Dt_OutboundOrder>((d, o) => d.OrderId == o.Id)
+ .Where((d, o) => o.OrderNo == orderNo)
+ .Select((d, o) => d)
+ .ToListAsync();
+
+ var feedmodel = new FeedbackOutboundRequestModel
+ {
+ reqCode = Guid.NewGuid().ToString(),
+ reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ business_type = outboundOrder.BusinessType,
+ factoryArea = outboundOrder.FactoryArea,
+ operationType = 1,
+ Operator = App.User.UserName,
+ orderNo = outboundOrder.UpperOrderNo,
+ documentsNO = outboundOrder.OrderNo,
+ status = outboundOrder.OrderStatus,
+ details = new List<FeedbackOutboundDetailsModel>()
+ };
+
+ // 浣跨敤璁㈠崟鏄庣粏鐨凮verOutQuantity浣滀负鍥炰紶鏁伴噺
+ foreach (var detail in orderDetails)
+ {
+ // 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
+ var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == orderNo &&
+ x.OrderDetailId == detail.Id &&
+ x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
+ .ToListAsync();
+
+ var detailModel = new FeedbackOutboundDetailsModel
+ {
+ materialCode = detail.MaterielCode,
+ lineNo = detail.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
+ warehouseCode = detail.WarehouseCode,
+ qty = detail.OverOutQuantity, // 浣跨敤璁㈠崟鏄庣粏鐨勫凡鍑哄簱鏁伴噺
+ currentDeliveryQty = detail.OverOutQuantity,
+ unit = detail.Unit,
+ barcodes = detailLocks.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = lockInfo.CurrentBarcode,
+ supplyCode = lockInfo.SupplyCode,
+ batchNo = lockInfo.BatchNo,
+ unit = lockInfo.Unit,
+ qty = lockInfo.PickedQty // 鏉$爜绾у埆鐨勬暟閲忎粛鐢ㄩ攣瀹氳褰�
+ }).ToList()
+ };
+
+ feedmodel.details.Add(detailModel);
+ }
+
+ var result = await _invokeMESService.FeedbackOutbound(feedmodel);
+ if (result != null && result.code == 200)
+ {
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.OrderId == outboundOrder.Id)
+ .ExecuteCommandAsync();
+
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
+
}
/// <summary>
@@ -611,7 +726,7 @@
_locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
- return WebResponseContent.Instance.OK();
+ return await Task.FromResult(WebResponseContent.Instance.OK());
}
catch (Exception ex)
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_WMSServer/Controllers/ESSController.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_WMSServer/Controllers/ESSController.cs"
index 8740074..4a26da8 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_WMSServer/Controllers/ESSController.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_WMSServer/Controllers/ESSController.cs"
@@ -217,7 +217,7 @@
_logger.LogInformation("浠诲姟瀹屾垚: TaskCode={TaskCode}, Container={Container}, Robot={Robot}",
request.TaskCode, request.ContainerCode, request.RobotCode);
- _taskService.TaskCompleted(request.TaskCode);
+ await _taskService.TaskCompleted(request.TaskCode);
// 鏍规嵁涓嶅悓鐨勪换鍔$被鍨嬭繘琛岀壒娈婂鐞�
if (request.Weight.HasValue)
{
--
Gitblit v1.9.3