From 7cbc27cf7ec7005f9e5f6f87612eb7cfaffc2ac6 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期一, 08 十二月 2025 21:20:11 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 176 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 119 insertions(+), 57 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 6e1a64e..12d0d4c 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"
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
@@ -32,9 +33,11 @@
using WIDESEA_IInboundService;
using WIDESEA_IOutboundService;
using WIDESEA_IStockService;
+using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Check;
+using WIDESEA_Model.Models.Outbound;
namespace WIDESEA_OutboundService
{
@@ -63,7 +66,9 @@
private readonly IInboundOrderDetailService _inboundOrderDetailService;
private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
private readonly IReCheckOrderService _reCheckOrderService;
+ private readonly ITask_HtyService _task_HtyService;
private readonly ILogger<OutboundPickingService> _logger;
+ private readonly IRepository<Dt_InterfaceLog> _interfaceLog;
private Dictionary<string, string> stations = new Dictionary<string, string>
{
@@ -82,7 +87,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, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService) : base(BaseDal)
+ IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService, ITask_HtyService task_HtyService, IRepository<Dt_InterfaceLog> interfaceLog) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -103,6 +108,8 @@
_inboundOrderDetailService = inboundOrderDetailService;
_warehouseAreaRepository = warehouseAreaRepository;
_reCheckOrderService = reCheckOrderService;
+ _task_HtyService = task_HtyService;
+ _interfaceLog = interfaceLog;
}
@@ -297,7 +304,27 @@
var statusAnalysis = await AnalyzePalletStatus(orderNo, palletCode, stockInfo.Id);
if (!statusAnalysis.HasItemsToReturn)
- return await HandleNoReturnItems(orderNo, palletCode, task, stockInfo.Id);
+ {
+ try
+ {
+ var result = await HandleNoReturnItems(orderNo, palletCode, task, stockInfo.Id);
+ _unitOfWorkManage.CommitTran();
+ if (result.Status)
+ {
+ task.PalletType = PalletTypeEnum.Empty.ObjToInt();
+ await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InEmpty, PalletTypeEnum.Empty.ObjToInt());
+ }
+ return result;
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ _logger.LogError($"ReturnRemaining 鍥炲簱绌虹澶辫触 - OrderNo: {orderNo}, PalletCode: {palletCode}, Error: {ex.Message}");
+ return WebResponseContent.Instance.Error($"鍥炲簱绌虹鎿嶄綔澶辫触: {ex.Message}");
+ }
+
+
+ }
// 4. 妫�鏌ユ槸鍚︽湁杩涜涓殑浠诲姟
if (statusAnalysis.HasActiveTasks)
@@ -1307,8 +1334,6 @@
//绌烘墭鐩樺浣曞鐞� 杩樻湁涓�涓嚭搴撲换鍔¤澶勭悊銆�
originalTask.PalletType = PalletTypeEnum.Empty.ObjToInt();
- await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty, PalletTypeEnum.Empty.ObjToInt());
-
}
catch (Exception ex)
{
@@ -1684,15 +1709,31 @@
WarehouseId = originalTask.WarehouseId
};
- // 淇濆瓨鍥炲簱浠诲姟
- await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
+ try
+ {
+ // 淇濆瓨鍥炲簱浠诲姟
+ var insertcount = await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
+ if (insertcount <= 0)
+ {
+ throw new Exception("鍒涘缓浠诲姟澶辫触锛�");
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"CreateReturnTaskAndHandleESS 鍒涘缓浠诲姟澶辫触: {orderNo} 锛� {palletCode}");
+ throw new Exception("鍒涘缓浠诲姟澶辫触锛�");
+ }
var targetAddress = originalTask.TargetAddress;
+ _logger.LogInformation($"CreateReturnTaskAndHandleESS 鍒犻櫎鍘嗗彶浠诲姟: {orderNo} 锛� {originalTask.TaskNum}");
// 鍒犻櫎鍘熷鍑哄簱浠诲姟
- _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
- await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
-
-
+ // _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
+ var result = _task_HtyService.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.浜哄伐鍒犻櫎);
+ if (!result)
+ {
+ await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
+ }
+ _logger.LogInformation($"CreateReturnTaskAndHandleESS 鍒犻櫎鍘嗗彶浠诲姟: {orderNo} 锛� {originalTask.TaskNum},褰卞搷琛� {result}");
// 缁� ESS 鍙戦�佹祦鍔ㄤ俊鍙峰拰鍒涘缓浠诲姟
await SendESSCommands(palletCode, targetAddress, returnTask);
@@ -2096,8 +2137,7 @@
.Where(x => x.StockId == stockId && x.StockQuantity == 0)
.ExecuteCommandAsync();
- await _stockInfoService.Db.Deleteable<Dt_StockInfo>()
- .Where(x => x.Id == stockId).ExecuteCommandAsync();
+ _stockInfoService.DeleteData(stockId);
_logger.LogInformation($"娓呯悊闆跺簱瀛樻槑缁嗚褰� - StockId: {stockId}, 鍒犻櫎璁板綍鏁�: {deleteDetailCount}");
@@ -2752,15 +2792,15 @@
TaskNum = 0,
Status = (int)OutLockStockStatusEnum.鎷i�夊畬鎴�,
Unit = outboundOrderDetail.Unit,
- SupplyCode = outboundOrderDetail.SupplyCode?? "鏃�",
+ SupplyCode = outboundOrderDetail.SupplyCode ?? "鏃�",
OrderType = outboundOrder.OrderType,
CurrentBarcode = inboundOrderDetail.Barcode,
IsSplitted = 1,
Operator = App.User.UserName,
- lineNo= outboundOrderDetail.lineNo,
+ lineNo = outboundOrderDetail.lineNo,
WarehouseCode = outboundOrderDetail.WarehouseCode ?? "鏃�",
- BarcodeQty=outboundOrderDetail.NoStockOutQty,
- BarcodeUnit =outboundOrderDetail.BarcodeUnit,
+ BarcodeQty = outboundOrderDetail.NoStockOutQty,
+ BarcodeUnit = outboundOrderDetail.BarcodeUnit,
BatchNo = outboundOrderDetail.BatchNo
};
_outStockLockInfoService.AddData(newLockInfo);
@@ -2832,29 +2872,30 @@
var result1 = await _invokeMESService.FeedbackInbound(infeedmodel);
if (result1 != null && result1.code == 200)
{
+ var orderIds = inboundOrderDetails.Select(x => x.Id).Distinct().ToList();
_inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
.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();
+ .Where(it => orderIds.Contains(it.Id)).ExecuteCommand();
}
//鍑哄簱鍥炰紶MES
var documentNo = UniqueValueGenerator.Generate();
var outfeedmodel = 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 = documentNo,
- status = outboundOrder.OrderStatus,
- details = new List<FeedbackOutboundDetailsModel>()
- };
- foreach (var detail in outboundOrder.Details)
+ {
+ 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 = documentNo,
+ status = outboundOrder.OrderStatus,
+ details = new List<FeedbackOutboundDetailsModel>()
+ };
+ foreach (var detail in outboundOrderDetails)
{
// 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
@@ -2863,38 +2904,57 @@
(x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴� || x.Status == (int)OutLockStockStatusEnum.宸插洖搴�))
.ToListAsync();
- var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
- .Select(group => new FeedbackOutboundDetailsModel
- {
+ var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, 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.BarcodeUnit,
- barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
- {
- barcode = lockInfo.CurrentBarcode,
- supplyCode = lockInfo.SupplyCode,
- batchNo = lockInfo.BatchNo,
- unit = lockInfo.BarcodeUnit,
- qty = lockInfo.PickedQty
- }).ToList()
- }).ToList();
- outfeedmodel.details.AddRange(groupdata);
- }
- var result = await _invokeMESService.FeedbackOutbound(outfeedmodel);
- if (result != null && result.code == 200)
- {
- await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
- .SetColumns(x => x.ReturnToMESStatus == 1)
- .Where(x => x.OrderId == outboundOrder.Id)
- .ExecuteCommandAsync();
+ 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.BarcodeUnit,
+ barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = lockInfo.CurrentBarcode,
+ supplyCode = lockInfo.SupplyCode,
+ batchNo = lockInfo.BatchNo,
+ unit = lockInfo.BarcodeUnit,
+ qty = lockInfo.PickedQty
+ }).ToList()
+ }).ToList();
+ outfeedmodel.details.AddRange(groupdata);
+ }
+ //瀛樺偍鍥炰紶鍙傛暟锛屼繚璇佸紓甯告墜鍔ㄥ洖浼�
+ Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog
+ {
+ OrderNo = outboundOrder.UpperOrderNo,
+ DocumentNo = documentNo,
+ OrderType = "铏氭嫙鍑哄叆搴�",
+ Content = outfeedmodel.ToJson(),
+ ReturnToMESStatus = 0,
+ IsDeleted = false
+ };
+ _interfaceLog.AddData(interfaceLog);
+
+ var result = await _invokeMESService.FeedbackOutbound(outfeedmodel);
+ if (result != null && result.code == 200)
+ {
+ var orderIds = outboundOrderDetails.Select(x => x.Id).Distinct().ToList();
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => orderIds.Contains(x.Id))
+ .ExecuteCommandAsync();
+
await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
.SetColumns(x => x.ReturnToMESStatus == 1)
.Where(x => x.Id == outboundOrder.Id)
+ .ExecuteCommandAsync();
+
+ await _interfaceLog.Db.Updateable<Dt_InterfaceLog>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.DocumentNo == documentNo)
.ExecuteCommandAsync();
}
return WebResponseContent.Instance.OK();
@@ -3218,6 +3278,8 @@
public List<Dt_StockInfoDetail> PalletStockGoods { get; set; } = new List<Dt_StockInfoDetail>();
public List<Dt_SplitPackageRecord> SplitRecords { get; set; } = new List<Dt_SplitPackageRecord>();
+ // 銆愭柊澧炪�戝凡澶勭悊鐨勬潯鐮侀泦鍚堬紙鐢ㄤ簬閬垮厤閲嶅锛�
+ public HashSet<string> ProcessedBarcodes { get; set; } = new HashSet<string>();
public List<string> AllBarcodes { get; set; } = new List<string>();
// 绌烘墭鐩樼浉鍏冲睘鎬�
public bool IsEmptyPallet { get; set; }
--
Gitblit v1.9.3