pan
2025-12-02 550ae4989da1ce9ca874a00aec7423d252b67a27
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -27,6 +27,7 @@
using System.Reflection.Emit;
using System.Threading.Tasks;
using System.Xml.Linq;
using WIDESEA_Common.AllocateEnum;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
@@ -51,6 +52,7 @@
using WIDESEA_IStockService;
using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Check;
using WIDESEA_Model.Models.Outbound;
namespace WIDESEA_TaskInfoService
@@ -66,6 +68,7 @@
        private readonly IInboundOrderService _inboundOrderService;
        private readonly IInboundOrderDetailService _inboundOrderDetailService;
        private readonly IRepository<Dt_ReCheckOrder> _reCheckOrderRepository;
        private readonly IRepository<Dt_OutboundBatch> _OutboundBatchRepository;
        private readonly IOutboundOrderService _outboundOrderService;
        private readonly IOutboundOrderDetailService _outboundOrderDetailService;
@@ -95,7 +98,7 @@
        public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
        public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository) : base(BaseDal)
        public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository,IRepository<Dt_ReCheckOrder> reCheckOrderRepository) : base(BaseDal)
        {
            _mapper = mapper;
            _unitOfWorkManage = unitOfWorkManage;
@@ -114,6 +117,7 @@
            _outStockLockInfoService = outStockLockInfoService;
            _allocateService = allocateService;
            _OutboundBatchRepository = outboundBatchRepository;
            _reCheckOrderRepository = reCheckOrderRepository;
        }
@@ -282,7 +286,7 @@
                            {
                                ReqCode = Guid.NewGuid().ToString(),
                                ReqTime = DateTime.Now.ToString(),
                                BusinessType = "2",
                                BusinessType = BusinessTypeEnum.外部仓库调智仓.ObjToInt().ToString(),
                                FactoryArea = inboundOrder.FactoryArea,
                                OperationType = 1,
                                Operator = inboundOrder.Operator,
@@ -308,7 +312,7 @@
                                       Qty = row.BarcodeQty,
                                       BatchNo = row.BatchNo,
                                       SupplyCode = row.SupplyCode,
                                       Unit = row.Unit
                                       Unit = row.BarcodeUnit
                                   }).ToList()
                               }).ToList();
                            allocatefeedmodel.Details = groupedData;
@@ -325,11 +329,60 @@
                    }
                    else if (inboundOrder.OrderType == InOrderTypeEnum.ReCheck.ObjToInt()) //重检入库
                    {
                        //不需要回传。占一个位置。
                    }
                    else if (inboundOrder.OrderType == InOrderTypeEnum.InternalAllocat.ObjToInt()) //智仓调智仓
                    {
                        _logger.LogInformation($"InboundTaskCompleted å›žå†™MES  : {inboundOrder.InboundOrderNo }  ,ordertype: {InOrderTypeEnum.InternalAllocat.ObjToInt()} "  );
                        // BusinessTypeEnum.智仓调智仓
                        if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.入库完成.ObjToInt())
                        {
                            var allocate = _allocateService.Repository.QueryData(x => x.OrderNo == inboundOrder.InboundOrderNo).First();
                            var allocatefeedmodel = new AllocateDto
                            {
                                ReqCode = Guid.NewGuid().ToString(),
                                ReqTime = DateTime.Now.ToString(),
                                BusinessType = BusinessTypeEnum.智仓调智仓.ObjToInt().ToString(),
                                FactoryArea = inboundOrder.FactoryArea,
                                OperationType = 1,
                                Operator = inboundOrder.Operator,
                                OrderNo = inboundOrder.UpperOrderNo,
                                fromWarehouse = allocate?.FromWarehouse ?? "",
                                toWarehouse = allocate?.ToWarehouse ?? "",
                                Details = new List<AllocateDtoDetail>()
                            };
                            var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
                               .Select(group => new AllocateDtoDetail
                               {
                                   MaterialCode = group.Key.MaterielCode,
                                   LineNo = group.Key.lineNo,
                                   WarehouseCode = group.Key.WarehouseCode,
                                   Qty = group.Sum(x => x.BarcodeQty),
                                   // warehouseCode= "1072",
                                   Unit = group.Key.BarcodeUnit,
                                   Barcodes = group.Select(row => new BarcodeInfo
                                   {
                                       Barcode = row.Barcode,
                                       Qty = row.BarcodeQty,
                                       BatchNo = row.BatchNo,
                                       SupplyCode = row.SupplyCode,
                                       Unit = row.BarcodeUnit
                                   }).ToList()
                               }).ToList();
                            allocatefeedmodel.Details = groupedData;
                            var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
                            if (result != null && result.code == 200)
                            {
                                _inboundOrderService.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();
                            }
                        }
                    }
                    else
                    {
@@ -626,7 +679,7 @@
                        {
                            ReqCode = Guid.NewGuid().ToString(),
                            ReqTime = DateTime.Now.ToString(),
                            BusinessType = "3",
                            BusinessType = "2",
                            FactoryArea = outboundOrder.FactoryArea,
                            OperationType = 1,
                            Operator = outboundOrder.Operator,
@@ -660,8 +713,8 @@
                                    Barcode = lockInfo.CurrentBarcode,
                                    SupplyCode = lockInfo.SupplyCode,
                                    BatchNo = lockInfo.BatchNo,
                                    Unit = lockInfo.Unit,
                                    Qty = lockInfo.PickedQty // æ¡ç çº§åˆ«çš„æ•°é‡ä»ç”¨é”å®šè®°å½•
                                    Unit = lockInfo.BarcodeUnit,
                                    Qty = lockInfo.BarcodeQty // æ¡ç çº§åˆ«çš„æ•°é‡ä»ç”¨é”å®šè®°å½•
                                }).ToList()
                            };
@@ -684,7 +737,7 @@
                    }
                    else if (outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt())
                    {
                        //不用回传
                    }
                    else
                    {
@@ -717,16 +770,16 @@
                                materialCode = detail.MaterielCode,
                                lineNo = detail.lineNo, // æ³¨æ„ï¼šè¿™é‡Œå¯èƒ½éœ€è¦è°ƒæ•´å­—段名
                                warehouseCode = detail.WarehouseCode,
                                qty = detail.OverOutQuantity, // ä½¿ç”¨è®¢å•明细的已出库数量
                                currentDeliveryQty = detail.OverOutQuantity,
                                qty = detail.BarcodeQty,
                                currentDeliveryQty = detail.BarcodeQty,
                                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 // æ¡ç çº§åˆ«çš„æ•°é‡ä»ç”¨é”å®šè®°å½•
                                    unit = lockInfo.BarcodeUnit,
                                    qty = lockInfo.BarcodeQty // æ¡ç çº§åˆ«çš„æ•°é‡ä»ç”¨é”å®šè®°å½•
                                }).ToList()
                            };