1
heshaofeng
2026-01-29 e430d5c3916e44b397923dc90581a343f2681af6
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs
@@ -22,6 +22,7 @@
using WIDESEA_DTO.Base;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.CalcOut;
using WIDESEA_DTO.Outbound;
using WIDESEA_DTO.ReturnMES;
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
@@ -62,6 +63,8 @@
        private readonly IESSApiService _eSSApiService;
        private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
        private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfoRepository;
        public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository;
        public readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
        private Dictionary<string, string> stations = new Dictionary<string, string>
        {
@@ -75,7 +78,7 @@
            {"3-1","3-5" },
        };
        public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository)
        public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository)
        {
            _mapper = mapper;
            _unitOfWorkManage = unitOfWorkManage;
@@ -98,6 +101,35 @@
            _eSSApiService = eSSApiService;
            _allocateOrderRepository = allocateOrderRepository;
            _allocateMaterialInfoRepository = allocateMaterialInfoRepository;
            _inboundOrderDetailRepository = inboundOrderDetailRepository;
            _inboundOrderRepository = inboundOrderRepository;
        }
        public WebResponseContent PrintFromData (string barcode)
        {
            var detail = _inboundOrderDetailRepository.QueryFirst(x => x.Barcode == barcode);
            if(detail == null)
            {
                return WebResponseContent.Instance.Error();
            }
            var inbound = _inboundOrderRepository.QueryFirst(x=>x.Id ==  detail.OrderId);
            if(inbound == null)
            {
                return WebResponseContent.Instance.Error();
            }
            var printFormData = new PrintFromDataDTO {
                materialCode = detail.MaterielCode,
                materialName = detail.MaterielName,
                materialSpec = detail.Unit,
                batchNo = detail.BatchNo,
                pruchaseOrderNo = inbound.UpperOrderNo,
                factoryArea = inbound.FactoryArea,
                suplierCode = detail.SupplyCode,
                quantity = detail.BarcodeQty
            };
            return WebResponseContent.Instance.OK(data:printFormData);
        }
        #region å‡ºåº“分配
@@ -209,6 +241,11 @@
                string responseMsg = totalActualAllocate == totalNeedAllocate
                    ? "分拣任务分配成功"
                    : $"分拣任务分配完成(实际分配{totalActualAllocate},需求{totalNeedAllocate},库存不足部分未分配)";
                if(totalActualAllocate == 0 && !outboundOrder.Details.Any(x=>x.LockQuantity >0))
                {
                    UpdateOutboundOrderStatus(request.OrderNo, (int)OutOrderStatusEnum.未开始);
                    return WebResponseContent.Instance.Error("分配库存数量为0,无法出库");
                }
                response.Success = true;
                response.Message = responseMsg;
                response.Tasks = tasks;
@@ -1113,7 +1150,14 @@
                        {
                            barcodeQuantity = item.LockQuantity - item.OverOutQuantity;
                            allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity);
                            item.CurrentDeliveryQty = item.LockQuantity - item.OverOutQuantity;
                            if(item.ReturnToMESStatus == 0)
                            {
                                item.CurrentDeliveryQty = item.LockQuantity;
                            }
                            else
                            {
                                item.CurrentDeliveryQty = item.LockQuantity - item.OverOutQuantity;
                            }
                            item.OverOutQuantity = item.LockQuantity;
                        }
@@ -1478,8 +1522,15 @@
                        {
                            barcodeQuantity = item.LockQuantity - item.OverOutQuantity;
                            allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity);
                            if (item.ReturnToMESStatus == 0)
                            {
                                item.CurrentDeliveryQty = item.LockQuantity;
                            }
                            else
                            {
                                item.CurrentDeliveryQty += item.LockQuantity - item.OverOutQuantity;
                            }
                            item.OverOutQuantity = item.LockQuantity;
                            item.CurrentDeliveryQty = item.LockQuantity;
                        }
                        updateDetails.Add(item);
@@ -1980,7 +2031,7 @@
                if (stock.Details.Count <= 0)
                {
                    stock.PalletType = (int)PalletTypeEnum.Empty;
                    stock.StockStatus = (int)StockStatusEmun.组盘暂存;
                    stock.StockStatus = (int)StockStatusEmun.入库确认;
                    stock.LocationCode = "";
                }
                else if (stock.Details.Count > 0)
@@ -1994,7 +2045,7 @@
                    {
                        return content.Error($"托盘{palletCode}库存未拣选完不允许回库");
                    }
                    stock.StockStatus = (int)StockStatusEmun.组盘暂存;
                    stock.StockStatus = (int)StockStatusEmun.入库确认;
                    stock.LocationCode = "";
                }
@@ -2010,6 +2061,11 @@
                // åˆ†é…æ–°è´§ä½
                var newLocation = _locationInfoService.AssignLocation(stock.LocationType);
                if(newLocation == null)
                {
                    return WebResponseContent.Instance.Error("没有空闲库位可回库");
                }
                var newTask = new Dt_Task()
                {
                    CurrentAddress = stations.GetValueOrDefault(station) ?? "",