From 415931fc8e37495b1be97b975bc409c5b279ce6f Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期六, 29 十一月 2025 17:52:20 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 366 +++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 274 insertions(+), 92 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/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 4797f8c..f9c44da 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"
@@ -20,9 +20,11 @@
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Allocate;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Outbound;
+using WIDESEA_IAllocateService;
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
using WIDESEA_IStockService;
@@ -50,6 +52,7 @@
private readonly IESSApiService _eSSApiService;
private readonly IInvokeMESService _invokeMESService;
private readonly IDailySequenceService _dailySequenceService;
+ private readonly IAllocateService _allocateService;
private readonly ILogger<OutboundPickingService> _logger;
@@ -70,7 +73,7 @@
public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService,
IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService,
IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService,
- IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService) : base(BaseDal)
+ IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -86,6 +89,7 @@
_logger = logger;
_invokeMESService = invokeMESService;
_dailySequenceService = dailySequenceService;
+ _allocateService = allocateService;
}
@@ -225,14 +229,14 @@
}
_unitOfWorkManage.BeginTran();
- // 1. 鍓嶇疆楠岃瘉
+ // 鍓嶇疆楠岃瘉
var validationResult = await ValidateCancelRequest(orderNo, palletCode, barcode);
if (!validationResult.IsValid)
return WebResponseContent.Instance.Error(validationResult.ErrorMessage);
var (pickingRecord, lockInfo, orderDetail) = validationResult.Data;
- // 2. 鎵ц鍙栨秷閫昏緫
+ //鎵ц鍙栨秷閫昏緫
await ExecuteCancelLogic(lockInfo, pickingRecord, orderDetail, orderNo);
_unitOfWorkManage.CommitTran();
@@ -291,11 +295,13 @@
//鎵ц鍥炲簱鎿嶄綔
await ExecuteReturnOperations(orderNo, palletCode, stockInfo, task, statusAnalysis);
+ await ReleaseAllLocksForReallocation(orderNo, palletCode, statusAnalysis);
+
_unitOfWorkManage.CommitTran();
// 鍒涘缓鍥炲簱浠诲姟
- await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InPick,task.PalletType);
+ await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InPick, task.PalletType);
// 鏇存柊璁㈠崟鐘舵�侊紙涓嶈Е鍙慚ES鍥炰紶锛�
await UpdateOrderStatusForReturn(orderNo);
@@ -742,7 +748,7 @@
{
try
{
- // 1. 楠岃瘉璁㈠崟鏄庣粏鏁版嵁
+ // 楠岃瘉璁㈠崟鏄庣粏鏁版嵁
var currentOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
.FirstAsync(x => x.Id == context.OrderDetail.Id);
@@ -752,26 +758,26 @@
if (currentOrderDetail.PickedQty < context.PickingRecord.PickQuantity)
return ValidationResult<bool>.Error($"璁㈠崟鏄庣粏宸叉嫞閫夋暟閲�({currentOrderDetail.PickedQty})灏忎簬鍙栨秷鏁伴噺({context.PickingRecord.PickQuantity})");
- // 2. 楠岃瘉閿佸畾淇℃伅鏁版嵁
+ // 楠岃瘉閿佸畾淇℃伅鏁版嵁
var currentLockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
.FirstAsync(x => x.Id == context.LockInfo.Id);
if (currentLockInfo.PickedQty < context.PickingRecord.PickQuantity)
return ValidationResult<bool>.Error($"閿佸畾淇℃伅宸叉嫞閫夋暟閲�({currentLockInfo.PickedQty})灏忎簬鍙栨秷鏁伴噺({context.PickingRecord.PickQuantity})");
- // 3. 楠岃瘉搴撳瓨鏁版嵁
- var currentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
- .FirstAsync(x => x.Barcode == context.PickingRecord.Barcode && x.StockId == context.PickingRecord.StockId);
+ ////// 楠岃瘉搴撳瓨鏁版嵁
+ ////var currentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ //// .FirstAsync(x => x.Barcode == context.PickingRecord.Barcode && x.StockId == context.PickingRecord.StockId);
- if (currentStockDetail == null)
- return ValidationResult<bool>.Error($"鏈壘鍒板搴旂殑搴撳瓨鏄庣粏璁板綍");
+ ////if (currentStockDetail == null)
+ //// return ValidationResult<bool>.Error($"鏈壘鍒板搴旂殑搴撳瓨鏄庣粏璁板綍");
- if (currentStockDetail.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt() ||
- currentStockDetail.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
- return ValidationResult<bool>.Error($"鏉$爜{context.PickingRecord.Barcode}宸茬粡鍥炲簱锛屾棤娉曞彇娑堝垎鎷�");
+ ////if (currentStockDetail.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt() ||
+ //// currentStockDetail.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
+ //// return ValidationResult<bool>.Error($"鏉$爜{context.PickingRecord.Barcode}宸茬粡鍥炲簱锛屾棤娉曞彇娑堝垎鎷�");
- // 4. 楠岃瘉鐘舵�佹祦杞殑鍚堟硶鎬�
- if (!await CanCancelPicking(currentLockInfo, currentStockDetail))
+ // 楠岃瘉鐘舵�佹祦杞殑鍚堟硶鎬�
+ if (!await CanCancelPicking(currentLockInfo, null))
return ValidationResult<bool>.Error($"褰撳墠鐘舵�佷笉鍏佽鍙栨秷鍒嗘嫞");
return ValidationResult<bool>.Success(true);
@@ -789,9 +795,9 @@
if (lockInfo.Status != (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
return false;
- // 搴撳瓨鐘舵�佹鏌�
- if (stockDetail.Status == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
- return false;
+ ////// 搴撳瓨鐘舵�佹鏌�
+ ////if (stockDetail.Status == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+ //// return false;
// 濡傛灉鏄媶鍖呰褰曪紝杩橀渶瑕佹鏌ョ埗閿佸畾淇℃伅鐘舵��
if (lockInfo.IsSplitted == 1 && lockInfo.ParentLockId.HasValue)
@@ -916,7 +922,7 @@
{
decimal cancelQty = pickingRecord.PickQuantity;
- // 1. 鏁版嵁涓�鑷存�ч獙璇�
+ // 鏁版嵁涓�鑷存�ч獙璇�
var context = new CancelPickingContext
{
LockInfo = lockInfo,
@@ -930,7 +936,7 @@
if (!validationResult.IsValid)
throw new Exception(validationResult.ErrorMessage);
- // 2. 澶勭悊涓嶅悓绫诲瀷鐨勫彇娑�
+ // 澶勭悊涓嶅悓绫诲瀷鐨勫彇娑�
if (lockInfo.IsSplitted == 1 && lockInfo.ParentLockId.HasValue)
{
await HandleSplitBarcodeCancel(lockInfo, pickingRecord, cancelQty);
@@ -956,9 +962,9 @@
// 閲嶆柊妫�鏌ヨ鍗曠姸鎬�
await UpdateOrderStatusForReturn(orderNo);
-
+
}
-
+
private async Task HandleSplitBarcodeCancel(Dt_OutStockLockInfo lockInfo, Dt_PickingRecord pickingRecord, decimal cancelQty)
{
// 鏌ユ壘鐖堕攣瀹氫俊鎭�
@@ -1097,7 +1103,7 @@
.SetColumns(it => new Dt_OutboundOrderDetail
{
PickedQty = newPickedQty,
- OverOutQuantity = newOverOutQuantity
+ OverOutQuantity = newOverOutQuantity
})
.Where(it => it.Id == orderDetailId)
.ExecuteCommandAsync();
@@ -1234,7 +1240,7 @@
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>();
@@ -1242,7 +1248,7 @@
//绌烘墭鐩樺浣曞鐞� 杩樻湁涓�涓嚭搴撲换鍔¤澶勭悊銆�
originalTask.PalletType = PalletTypeEnum.Empty.ObjToInt();
- await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty,PalletTypeEnum.Empty.ObjToInt());
+ await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty, PalletTypeEnum.Empty.ObjToInt());
}
catch (Exception ex)
@@ -1303,6 +1309,116 @@
await UpdateStockInfoStatus(stockInfo);
}
+ /// <summary>
+ /// 瀹屽叏閲婃斁閿佸畾锛屽厑璁搁噸鏂板垎閰嶅簱瀛�
+ /// </summary>
+ private async Task ReleaseAllLocksForReallocation(string orderNo, string palletCode, PalletStatusAnalysis analysis)
+ {
+ _logger.LogInformation($"寮�濮嬮噴鏀鹃攣瀹氫互渚块噸鏂板垎閰� - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+
+ // 1. 澶勭悊鏈垎鎷g殑鍑哄簱閿佸畾璁板綍 - 瀹屽叏閲婃斁
+ if (analysis.HasRemainingLocks)
+ {
+ await ReleaseRemainingLocks(analysis.RemainingLocks);
+ }
+
+ // 2. 澶勭悊宸插洖搴撶殑閿佸畾璁板綍 - 鍒犻櫎鎴栨爣璁颁负鏃犳晥
+ await CleanupReturnedLocks(orderNo, palletCode);
+
+ // 3. 閲嶇疆璁㈠崟鏄庣粏鐨勯攣瀹氭暟閲�
+ await ResetOrderDetailLockQuantities(analysis);
+
+ _logger.LogInformation($"閿佸畾閲婃斁瀹屾垚 - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+ }
+
+ /// <summary>
+ /// 閲婃斁鏈垎鎷g殑閿佸畾璁板綍
+ /// </summary>
+ private async Task ReleaseRemainingLocks(List<Dt_OutStockLockInfo> remainingLocks)
+ {
+ var lockIds = remainingLocks.Select(x => x.Id).ToList();
+
+ // 灏嗛攣瀹氳褰曠姸鎬佹敼涓�"宸查噴鏀�"锛屾垨鑰呯洿鎺ュ垹闄�
+ // 鏍囪涓哄凡閲婃斁
+ await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>()
+ .SetColumns(it => new Dt_OutStockLockInfo
+ {
+ Status = (int)OutLockStockStatusEnum.宸查噴鏀�, // 闇�瑕佹柊澧炶繖涓姸鎬�
+ // ReleaseTime = DateTime.Now,
+ Operator = App.User.UserName
+ })
+ .Where(it => lockIds.Contains(it.Id))
+ .ExecuteCommandAsync();
+
+ // 鐩存帴鍒犻櫎锛堟洿褰诲簳锛�
+ // await _outStockLockInfoService.Db.Deleteable<Dt_OutStockLockInfo>()
+ // .Where(it => lockIds.Contains(it.Id))
+ // .ExecuteCommandAsync();
+
+ _logger.LogInformation($"閲婃斁{remainingLocks.Count}鏉℃湭鍒嗘嫞閿佸畾璁板綍");
+ }
+
+ /// <summary>
+ /// 娓呯悊宸插洖搴撶殑閿佸畾璁板綍
+ /// </summary>
+ private async Task CleanupReturnedLocks(string orderNo, string palletCode)
+ {
+ // 鏌ユ壘鎵�鏈夌姸鎬佷负鍥炲簱涓殑閿佸畾璁板綍骞堕噴鏀�
+ var returnedLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(it => it.OrderNo == orderNo &&
+ it.PalletCode == palletCode &&
+ it.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
+ .ToListAsync();
+
+ if (returnedLocks.Any())
+ {
+ var returnedLockIds = returnedLocks.Select(x => x.Id).ToList();
+
+ await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>()
+ .SetColumns(it => new Dt_OutStockLockInfo
+ {
+ Status = (int)OutLockStockStatusEnum.宸查噴鏀�,
+ //ReleaseTime = DateTime.Now,
+ Operator = App.User.UserName
+ })
+ .Where(it => returnedLockIds.Contains(it.Id))
+ .ExecuteCommandAsync();
+
+ _logger.LogInformation($"娓呯悊{returnedLocks.Count}鏉″洖搴撲腑閿佸畾璁板綍");
+ }
+ }
+
+ /// <summary>
+ /// 閲嶇疆璁㈠崟鏄庣粏鐨勯攣瀹氭暟閲�
+ /// </summary>
+ private async Task ResetOrderDetailLockQuantities(PalletStatusAnalysis analysis)
+ {
+ // 鏀堕泦鎵�鏈夊彈褰卞搷鐨勮鍗曟槑缁咺D
+ var affectedOrderDetailIds = new HashSet<int>();
+
+ if (analysis.HasRemainingLocks)
+ {
+ foreach (var lockInfo in analysis.RemainingLocks)
+ {
+ affectedOrderDetailIds.Add(lockInfo.OrderDetailId);
+ }
+ }
+
+ // 閲嶇疆杩欎簺璁㈠崟鏄庣粏鐨勯攣瀹氭暟閲�
+ foreach (var orderDetailId in affectedOrderDetailIds)
+ {
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(it => new Dt_OutboundOrderDetail
+ {
+ LockQuantity = 0, // 閲嶇疆閿佸畾鏁伴噺
+ OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt() // 閲嶇疆鐘舵�佷负鏂板缓
+ })
+ .Where(it => it.Id == orderDetailId)
+ .ExecuteCommandAsync();
+ }
+
+ _logger.LogInformation($"閲嶇疆{affectedOrderDetailIds.Count}涓鍗曟槑缁嗙殑閿佸畾鏁伴噺");
+ }
private async Task HandleRemainingLocksReturn(List<Dt_OutStockLockInfo> remainingLocks, int stockId)
{
var lockIds = remainingLocks.Select(x => x.Id).ToList();
@@ -1455,7 +1571,7 @@
/// <param name="originalTask"></param>
/// <param name="analysis"></param>
/// <returns></returns>
- private async Task CreateReturnTaskAndHandleESS(string orderNo, string palletCode, Dt_Task originalTask, TaskTypeEnum taskTypeEnum,int palletType)
+ 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);
@@ -1478,7 +1594,7 @@
TaskType = taskTypeEnum.ObjToInt(),
PalletType = palletType,
WarehouseId = originalTask.WarehouseId
-
+
};
// 淇濆瓨鍥炲簱浠诲姟
await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
@@ -1512,15 +1628,15 @@
containerCode = palletCode
});
- if (moveResult)
+ //if (moveResult)
+ //{
+ // 2. 鍒涘缓鍥炲簱浠诲姟
+ var essTask = new TaskModel()
{
- // 2. 鍒涘缓鍥炲簱浠诲姟
- var essTask = new TaskModel()
- {
- taskType = "putaway",
- taskGroupCode = "",
- groupPriority = 0,
- tasks = new List<TasksType>{ new() {
+ taskType = "putaway",
+ taskGroupCode = "",
+ groupPriority = 0,
+ tasks = new List<TasksType>{ new() {
taskCode = returnTask.TaskNum.ToString(),
taskPriority = 0,
taskDescribe = new TaskDescribeType
@@ -1534,11 +1650,11 @@
storageTag = ""
}
} }
- };
+ };
- var resultTask = await _eSSApiService.CreateTaskAsync(essTask);
- _logger.LogInformation($"ReturnRemaining 鍒涘缓浠诲姟鎴愬姛: {resultTask}");
- }
+ var resultTask = await _eSSApiService.CreateTaskAsync(essTask);
+ _logger.LogInformation($"ReturnRemaining 鍒涘缓浠诲姟鎴愬姛: {resultTask}");
+ //}
}
catch (Exception ex)
{
@@ -1581,10 +1697,11 @@
if (outboundOrder.OrderStatus != newStatus)
{
await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
- .SetColumns( x=> new Dt_OutboundOrder {
- OrderStatus = newStatus,
- Operator = App.User.UserName,
- })
+ .SetColumns(x => new Dt_OutboundOrder
+ {
+ OrderStatus = newStatus,
+ Operator = App.User.UserName,
+ })
.Where(x => x.OrderNo == orderNo)
.ExecuteCommandAsync();
@@ -1632,7 +1749,7 @@
if (outboundOrder.OrderStatus != newStatus)
{
- await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
.SetColumns(x => new Dt_OutboundOrder
{
OrderStatus = newStatus,
@@ -1653,78 +1770,141 @@
private async Task HandleOrderCompletion(Dt_OutboundOrder outboundOrder, string orderNo)
{
// 璋冩嫧鍑哄簱鍜岄噸妫�鍑哄簱涓嶉渶瑕佸弽棣圡ES
- if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt() ||
- outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt())
+ if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt())
{
- return;
- }
-
- try
- {
- var feedmodel = new FeedbackOutboundRequestModel
+ var allocate = _allocateService.Repository.QueryData(x => x.UpperOrderNo == outboundOrder.UpperOrderNo).First();
+ var allocatefeedmodel = new AllocateDto
{
- reqCode = Guid.NewGuid().ToString(),
- reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- business_type = outboundOrder.BusinessType,
- factoryArea = outboundOrder.FactoryArea,
- operationType = 1,
+ ReqCode = Guid.NewGuid().ToString(),
+ ReqTime = DateTime.Now.ToString(),
+ BusinessType = "3",
+
+ FactoryArea = outboundOrder.FactoryArea,
+ OperationType = 1,
Operator = App.User.UserName,
- orderNo = outboundOrder.UpperOrderNo,
- documentsNO = outboundOrder.OrderNo,
- status = outboundOrder.OrderStatus,
- details = new List<FeedbackOutboundDetailsModel>()
- };
+ OrderNo = outboundOrder.UpperOrderNo,
+ // documentsNO = outboundOrder.OrderNo,
+ // status = outboundOrder.OrderStatus,
+ fromWarehouse = allocate?.FromWarehouse ?? "",
+ toWarehouse = allocate?.ToWarehouse ?? "",
+ Details = new List<AllocateDtoDetail>()
+ };
// 鍙幏鍙栧凡鎷i�夊畬鎴愮殑閿佸畾璁板綍
var lists = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
.Where(x => x.OrderNo == orderNo && x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
.ToListAsync();
var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.Unit, item.WarehouseCode })
- .Select(group => new FeedbackOutboundDetailsModel
+ .Select(group => new AllocateDtoDetail
{
- materialCode = group.Key.MaterielCode,
- lineNo = group.Key.lineNo,
- warehouseCode = group.Key.WarehouseCode,
- qty = group.Sum(x => x.PickedQty),
- currentDeliveryQty = group.Sum(x => x.PickedQty),
- unit = group.Key.Unit,
- barcodes = group.Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
+ MaterialCode = group.Key.MaterielCode,
+ LineNo = group.Key.lineNo,
+ WarehouseCode = group.Key.WarehouseCode,
+ Qty = group.Sum(x => x.PickedQty),
+
+ Unit = group.Key.Unit,
+ Barcodes = group.Select(row => new BarcodeInfo
{
- barcode = row.CurrentBarcode,
- supplyCode = row.SupplyCode,
- batchNo = row.BatchNo,
- unit = row.Unit,
- qty = row.PickedQty
+ Barcode = row.CurrentBarcode,
+ SupplyCode = row.SupplyCode,
+ BatchNo = row.BatchNo,
+ Unit = row.Unit,
+ Qty = row.PickedQty
}).ToList()
+
+
}).ToList();
+ allocatefeedmodel.Details = groupedData;
- feedmodel.details = groupedData;
-
- var result = await _invokeMESService.FeedbackOutbound(feedmodel);
+ var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
if (result != null && result.code == 200)
- {
+ {
await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
- .SetColumns(x => x.ReturnToMESStatus == 1)
- .Where(x => x.OrderId == outboundOrder.Id)
- .ExecuteCommandAsync();
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
- await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
.SetColumns(x => new Dt_OutboundOrder
{
ReturnToMESStatus = 1,
Operator = App.User.UserName,
- })
-
- .Where(x => x.OrderNo == orderNo)
- .ExecuteCommandAsync();
+ }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync();
}
-
- _logger.LogError($"FeedbackOutbound鎴愬姛 - OrderNo: {orderNo}, {JsonSerializer.Serialize(result)}");
}
- catch (Exception ex)
+ else if (outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt())
{
- _logger.LogError($"FeedbackOutbound澶辫触 - OrderNo: {orderNo}, Error: {ex.Message}");
+
+ }
+ else
+ {
+ try
+ {
+ 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>()
+ };
+
+ // 鍙幏鍙栧凡鎷i�夊畬鎴愮殑閿佸畾璁板綍
+ var lists = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == orderNo && x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
+ .ToListAsync();
+
+ var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.Unit, item.WarehouseCode })
+ .Select(group => new FeedbackOutboundDetailsModel
+ {
+ materialCode = group.Key.MaterielCode,
+ lineNo = group.Key.lineNo,
+ warehouseCode = group.Key.WarehouseCode,
+ qty = group.Sum(x => x.PickedQty),
+ currentDeliveryQty = group.Sum(x => x.PickedQty),
+ unit = group.Key.Unit,
+ barcodes = group.Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = row.CurrentBarcode,
+ supplyCode = row.SupplyCode,
+ batchNo = row.BatchNo,
+ unit = row.Unit,
+ qty = row.PickedQty
+ }).ToList()
+ }).ToList();
+
+ feedmodel.details = groupedData;
+
+ 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 => new Dt_OutboundOrder
+ {
+ ReturnToMESStatus = 1,
+ Operator = App.User.UserName,
+ })
+
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
+
+ _logger.LogError($"FeedbackOutbound鎴愬姛 - OrderNo: {orderNo}, {JsonSerializer.Serialize(result)}");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"FeedbackOutbound澶辫触 - OrderNo: {orderNo}, Error: {ex.Message}");
+ }
}
}
@@ -2100,6 +2280,8 @@
FactoryArea = originalLock.FactoryArea,
lineNo = originalLock.lineNo,
WarehouseCode = originalLock.WarehouseCode,
+ BarcodeQty=originalLock.BarcodeQty,
+ BarcodeUnit=originalLock.BarcodeUnit,
};
--
Gitblit v1.9.3