From 3b3ff1836b8837ffd541cc7eefde8d5e5d195110 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期四, 18 十二月 2025 16:32:13 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 307 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 210 insertions(+), 97 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_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 ca42579..73308c9 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"
@@ -130,17 +130,18 @@
_task_HtyService = task_HtyService;
}
- public async Task TaskStatusChange(string taskNum,TaskStatusEnum taskStatusEnum)
+ public async Task TaskStatusChange(string taskNum, TaskStatusEnum taskStatusEnum)
{
if (int.TryParse(taskNum, out var newTaskNum))
{
- await Db.Updateable<Dt_Task>().SetColumns(it => new Dt_Task {
- TaskStatus = taskStatusEnum.ObjToInt()
- })
+ await Db.Updateable<Dt_Task>().SetColumns(it => new Dt_Task
+ {
+ TaskStatus = taskStatusEnum.ObjToInt()
+ })
.Where(it => it.TaskNum == newTaskNum)
.ExecuteCommandAsync();
}
-
+
}
/// <summary>
@@ -291,14 +292,21 @@
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
// BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
- var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+ var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
if (!result)
{
await Db.Deleteable(task).ExecuteCommandAsync();
}
- _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
+ try
+ {
+ _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
- _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"InboundTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
+ }
try
{
foreach (var inboundOrder in inboundOrders)
@@ -450,10 +458,17 @@
var feedbackresult = await _invokeMESService.FeedbackInbound(feedmodel);
if (feedbackresult != null && feedbackresult.code == 200)
{
- _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
+ _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1, Remark = "" })
.Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
_inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
.Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
+ }
+ else
+ {
+ _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2, Remark = feedbackresult.message })
+ .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+ _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 })
+ .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
}
}
}
@@ -487,27 +502,27 @@
locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
_locationInfoService.Repository.UpdateData(locationInfo);
- var outloks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.TaskNum == task.TaskNum).ToListAsync();
-
- var stockids = outloks.Select(x => x.StockId).ToList();
-
- _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>()
- .SetColumns(it => new Dt_StockInfo
- {
- StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()
- })
- .Where(it => stockids.Contains(it.Id))
- .ExecuteCommand();
-
- _stockService.StockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
- .SetColumns(it => new Dt_StockInfoDetail
- {
- Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()
- })
- .Where(it => stockids.Contains(it.StockId))
- .ExecuteCommand();
+ var stock = _stockService.StockInfoService.Db.Queryable<Dt_StockInfo>()
+ .Includes(x => x.Details)
+ .Where(x => x.PalletCode == task.PalletCode)
+ .First();
+ stock.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
+ stock.LocationCode = "";
+
+ stock.Details.ForEach(x =>
+ {
+ x.Status = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
+ });
+
+ _stockService.StockInfoService.Db.UpdateNav(stock).IncludesAllFirstLayer().ExecuteCommand();
+
+ var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+ if (!result)
+ {
+ await Db.Deleteable(task).ExecuteCommandAsync();
+ }
return WebResponseContent.Instance.OK();
@@ -551,26 +566,31 @@
stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
_stockRepository.UpdateData(stockInfo);
- var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().First(x => x.OrderNo == task.OrderNo);
+ //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.浜哄伐瀹屾垚);
var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
if (!result)
{
await Db.Deleteable(task).ExecuteCommandAsync();
}
- _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
-
-
- if (outboundOrder != null)
+ try
{
- await HandleOutboundOrderToMESCompletion(outboundOrder, outboundOrder.OrderNo);
+ _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
}
- else
+ catch (Exception ex)
{
- _logger.LogInformation($"TaskService InEmptyTaskCompleted: {task.TaskNum} ,鏈壘鍒板嚭搴撳崟銆� ");
+ _logger.LogInformation($"InEmptyTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
}
+
+ //if (outboundOrder != null)
+ //{
+ // await HandleOutboundOrderToMESCompletion(outboundOrder, outboundOrder.OrderNo);
+ //}
+ //else
+ //{
+ // _logger.LogInformation($"TaskService InEmptyTaskCompleted: {task.TaskNum} ,鏈壘鍒板嚭搴撳崟銆� ");
+ //}
return content;
}
@@ -586,7 +606,7 @@
_logger.LogInformation($"TaskService InPickTaskCompleted: {task.TaskNum}");
try
- {
+ {
// 鏌ュ簱瀛�
Dt_StockInfo stockInfo = await _stockRepository.Db.Queryable<Dt_StockInfo>()
.Includes(x => x.Details)
@@ -615,23 +635,23 @@
var beforelocationStatus = locationInfo.LocationStatus;
// 鑾峰彇鎵�鏈夊洖搴撲腑鐨勫嚭搴撻攣瀹氳褰�
- var returnLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
- .Where(it => it.OrderNo == task.OrderNo &&
- it.PalletCode == task.PalletCode &&
- it.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
- .ToListAsync();
+ //var returnLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ // .Where(it => it.OrderNo == task.OrderNo &&
+ // it.PalletCode == task.PalletCode &&
+ // it.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
+ // .ToListAsync();
// 鏇存柊鍑哄簱閿佸畾璁板綍鐘舵�佷负鍥炲簱瀹屾垚
- foreach (var lockInfo in returnLocks)
- {
- lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
- }
+ //foreach (var lockInfo in returnLocks)
+ //{
+ // lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
+ //}
- if (returnLocks.Any())
- {
- await _outStockLockInfoService.Db.Updateable(returnLocks).ExecuteCommandAsync();
- _logger.LogInformation($"鏇存柊{returnLocks.Count}鏉¢攣瀹氳褰曚负宸插洖搴撶姸鎬�");
- }
+ //if (returnLocks.Any())
+ //{
+ // await _outStockLockInfoService.Db.Updateable(returnLocks).ExecuteCommandAsync();
+ // _logger.LogInformation($"鏇存柊{returnLocks.Count}鏉¢攣瀹氳褰曚负宸插洖搴撶姸鎬�");
+ //}
// 鏇存柊搴撳瓨淇℃伅
stockInfo.LocationCode = task.TargetAddress;
@@ -643,7 +663,7 @@
foreach (var detail in stockInfo.Details)
{
detail.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
- detail.OutboundQuantity = 0; // 鍏ュ簱瀹屾垚鏃跺嚭搴撴暟閲忔竻闆�
+ detail.OutboundQuantity = 0;
}
_stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
}
@@ -652,7 +672,7 @@
// 鍒犻櫎闆跺簱瀛樻暟鎹�
await DeleteZeroQuantityStockDetails(stockInfo.Id);
- await UpdateAffectedOrderDetails(task.OrderNo, returnLocks);
+ //await UpdateAffectedOrderDetails(task.OrderNo, returnLocks);
// 鏇存柊璐т綅鐘舵��
if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
{
@@ -675,43 +695,50 @@
{
await Db.Deleteable(task).ExecuteCommandAsync();
}
- // 璁板綍璐т綅鐘舵�佸彉鏇�
- _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
- locationInfo,
- beforelocationStatus,
- StockChangeType.Inbound.ObjToInt(),
- "",
- task.TaskNum
- );
- await RecalculateOrderStatus(task.OrderNo);
-
- _logger.LogInformation($"鎵樼洏鍥炲簱瀹屾垚澶勭悊鎴愬姛 - 浠诲姟鍙�: {task.TaskNum}, 鎵樼洏: {task.PalletCode}, 璁㈠崟: {task.OrderNo}");
- _ = Task.Run(async () =>
+ //await RecalculateOrderStatus(task.OrderNo);
+ try
{
- try
- {
- var outboundOrder = await _outboundOrderService.Db.Queryable<Dt_OutboundOrder>()
- .FirstAsync(x => x.OrderNo == task.OrderNo);
+ // 璁板綍璐т綅鐘舵�佸彉鏇�
+ _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
+ locationInfo,
+ beforelocationStatus,
+ StockChangeType.Inbound.ObjToInt(),
+ "",
+ task.TaskNum
+ );
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"InPickTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
+ }
- if (outboundOrder != null)
- {
- // 妫�鏌ヨ鍗曟槸鍚﹀凡瀹屾垚锛屽彧鏈夊畬鎴愭椂鎵嶅悜MES鍙嶉
- if (outboundOrder.OrderStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
- {
- await HandleOutboundOrderToMESCompletion(outboundOrder, outboundOrder.OrderNo);
- }
- else
- {
- _logger.LogInformation($"璁㈠崟{task.OrderNo}鐘舵�佷负{outboundOrder.OrderStatus}锛屾殏涓嶅悜MES鍙嶉");
- }
- }
- }
- catch (Exception ex)
- {
- _logger.LogError($"寮傛MES鍙嶉澶勭悊澶辫触 - OrderNo: {task.OrderNo}, Error: {ex.Message}");
- }
- });
+ //_logger.LogInformation($"鎵樼洏鍥炲簱瀹屾垚澶勭悊鎴愬姛 - 浠诲姟鍙�: {task.TaskNum}, 鎵樼洏: {task.PalletCode}, 璁㈠崟: {task.OrderNo} 璐т綅鐘舵�侊細{locationInfo.LocationStatus}");
+ //_ = Task.Run(async () =>
+ //{
+ // try
+ // {
+ // var outboundOrder = await _outboundOrderService.Db.Queryable<Dt_OutboundOrder>()
+ // .FirstAsync(x => x.OrderNo == task.OrderNo);
+
+ // if (outboundOrder != null)
+ // {
+ // // 妫�鏌ヨ鍗曟槸鍚﹀凡瀹屾垚锛屽彧鏈夊畬鎴愭椂鎵嶅悜MES鍙嶉
+ // if (outboundOrder.OrderStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
+ // {
+ // await HandleOutboundOrderToMESCompletion(outboundOrder, outboundOrder.OrderNo);
+ // }
+ // else
+ // {
+ // _logger.LogInformation($"璁㈠崟{task.OrderNo}鐘舵�佷负{outboundOrder.OrderStatus}锛屾殏涓嶅悜MES鍙嶉");
+ // }
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // _logger.LogError($"寮傛MES鍙嶉澶勭悊澶辫触 - OrderNo: {task.OrderNo}, Error: {ex.Message}");
+ // }
+ //});
}
catch (Exception ex)
{
@@ -729,8 +756,8 @@
{
try
{
-
-
+
+
// 鑾峰彇鍙楀奖鍝嶇殑璁㈠崟鏄庣粏ID锛堝幓閲嶏級
//var affectedDetailIds = returnLocks
// .Select(x => x.OrderDetailId)
@@ -964,14 +991,14 @@
await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
.SetColumns(x => new Dt_OutboundOrder
{
- OrderStatus = newStatus,
+ OrderStatus = newStatus,
})
.Where(x => x.OrderNo == orderNo)
.ExecuteCommandAsync();
_logger.LogInformation($"鏇存柊璁㈠崟鐘舵�� - OrderNo: {orderNo}, 鏃х姸鎬�: {outboundOrder.OrderStatus}, 鏂扮姸鎬�: {newStatus}");
}
-
+
}
catch (Exception ex)
{
@@ -1108,6 +1135,34 @@
allocatefeedmodel.Details.Add(detailModel);
}
+ var groupedResult = allocatefeedmodel.Details
+ .GroupBy(item => new { item.WarehouseCode, item.MaterialCode, item.Unit, item.LineNo })
+ .Select(group =>
+ {
+
+ var deduplicatedBarcodes = group.SelectMany(x => x.Barcodes)
+ .GroupBy(b => b.Barcode)
+ .Select(b => new BarcodeInfo
+ {
+ Barcode = b.Key,
+ BatchNo = b.First().BatchNo,
+ SupplyCode = b.First().SupplyCode,
+ Qty = b.Max(x => x.Qty),
+ Unit = b.First().Unit
+ }).ToList();
+ return new AllocateDtoDetail
+ {
+ WarehouseCode = group.Key.WarehouseCode,
+ MaterialCode = group.Key.MaterialCode,
+ LineNo = group.Key.LineNo,
+ Qty = deduplicatedBarcodes.Sum(b => b.Qty),
+ Unit = group.Key.Unit,
+ Barcodes = deduplicatedBarcodes
+ };
+ }).ToList();
+
+ allocatefeedmodel.Details = groupedResult;
+
var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
if (result != null && result.code == 200)
@@ -1119,9 +1174,22 @@
await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
.SetColumns(x => new Dt_OutboundOrder
{
- ReturnToMESStatus = 1,
+ ReturnToMESStatus = 1,
}).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync();
}
+ else
+ {
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(x => x.ReturnToMESStatus == 2)
+ .Where(x => x.OrderId == outboundOrder.Id)
+ .ExecuteCommandAsync();
+
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = result.message })
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
+
}
}
else if (outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt())
@@ -1195,6 +1263,33 @@
feedmodel.details.Add(detailModel);
}
+ var groupedResult = feedmodel.details
+ .GroupBy(item => new { item.warehouseCode, item.materialCode, item.unit, item.lineNo })
+ .Select(group =>
+ {
+ var deduplicatedBarcodes = group.SelectMany(x => x.barcodes)
+ .GroupBy(b => b.barcode)
+ .Select(b => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = b.Key,
+ batchNo = b.First().batchNo,
+ supplyCode = b.First().supplyCode,
+ qty = b.Max(x => x.qty),
+ unit = b.First().unit
+ }).ToList();
+ return new FeedbackOutboundDetailsModel
+ {
+ warehouseCode = group.Key.warehouseCode,
+ materialCode = group.Key.materialCode,
+ lineNo = group.Key.lineNo,
+ qty = deduplicatedBarcodes.Sum(b => b.qty),
+ unit = group.Key.unit,
+ barcodes = deduplicatedBarcodes
+ };
+ }).ToList();
+
+ feedmodel.details = groupedResult;
+
var result = await _invokeMESService.FeedbackOutbound(feedmodel);
if (result != null && result.code == 200)
{
@@ -1204,8 +1299,20 @@
.ExecuteCommandAsync();
await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
- .SetColumns(x => x.ReturnToMESStatus == 1)
+ .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = "" })
.Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
+ else
+ {
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(x => x.ReturnToMESStatus == 2)
+ .Where(x => x.OrderId == outboundOrder.Id)
+ .ExecuteCommandAsync();
+
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = result.message })
+ .Where(x => x.OrderNo == orderNo)
.ExecuteCommandAsync();
}
}
@@ -1260,12 +1367,18 @@
var stockresult = _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
if (!stockresult)
- {
+ {
_stockRepository.Db.Deleteable(stockInfo).ExecuteCommand();
}
_stockService.StockInfoService.DeleteData(stockInfo);
- _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
-
+ try
+ {
+ _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo?.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"TaskService OutEmptyTaskCompleted AddLocationStatusChangeRecord: {ex.Message} ");
+ }
return await Task.FromResult(WebResponseContent.Instance.OK());
}
--
Gitblit v1.9.3