hutongqing
2025-01-09 59c8d02d2bc7c7d9651edbd755ad73e4e7843ed8
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs
@@ -44,7 +44,7 @@
        private readonly IInvokeERPService _invokeERPService;
        private readonly IOutStockLockInfoService _outStockLockInfoService;
        public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService,
        public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper,IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService,
          IStockInfoRepository stockInfoRepository, IInvokeERPService invokeERPService, IOutStockLockInfoService outStockLockInfoService) : base(BaseDal)
        {
            _mapper = mapper;
@@ -56,7 +56,19 @@
            _invokeERPService = invokeERPService;
            _outStockLockInfoService = outStockLockInfoService;
        }
        public override WebResponseContent AddData(SaveModel saveModel)
        {
            if (saveModel.MainData.TryGetValue(nameof(Dt_OutboundOrder.UpperOrderNo).FirstLetterToLower(), out object? upperOrderNo) && upperOrderNo != null && !string.IsNullOrEmpty(upperOrderNo.ToString()))
            {
                Dt_OutboundOrder outboundOrder = BaseDal.QueryFirst(x => x.UpperOrderNo == upperOrderNo.ToString() && x.WarehouseId == Convert.ToInt32(saveModel.MainData[nameof(Dt_OutboundOrder.WarehouseId).FirstLetterToLower()]));
                if (outboundOrder != null)
                {
                    return WebResponseContent.Instance.Error($"{upperOrderNo}领料单号已存在");
                }
            }
            saveModel.DetailData[0].Add("orderDetailStatus", OrderDetailStatusEnum.New.ObjToInt());
            return base.AddData(saveModel);
        }
        public WebResponseContent ReceiveOutOrder(ErpOutOrderDTO model)
        {
            try
@@ -112,10 +124,11 @@
                            MaterielName = materielInfo.MaterielName,
                            OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
                            OrderQuantity = model.Qty,
                            Unit=materielInfo.MaterielUnit
                        };
                        Dt_OutboundOrder outboundOrder = new Dt_OutboundOrder()
                        {
                            OrderNo = model.OrderNo,
                            OrderNo=model.OrderNo,
                            UpperOrderNo = model.OrderNo,
                            OrderStatus = OutOrderStatusEnum.未开始.ObjToInt(),
                            OrderType = OutOrderTypeEnum.Issue.ObjToInt(),
@@ -172,31 +185,39 @@
            }
        }
        //上报出库完成
        public WebResponseContent TestOutUpload(int id, List<Dt_OutStockLockInfo>? outStockLockInfos)
        public WebResponseContent TestOutUpload(int id,List<Dt_OutStockLockInfo>? outStockLockInfos)
        {
            try
            {
                Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == id).Includes(x => x.Details).First();
                Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x=>x.Id==id).Includes(x=>x.Details).First();
                Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == outboundOrder.WarehouseId);
                ERPIssueModel issueModel = new ERPIssueModel();
                List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
                List<Dt_OutStockLockInfo> _OutStockLockInfos = new List<Dt_OutStockLockInfo>();
                List<Dt_OutStockLockInfo> _OutStockLockInfos=new List<Dt_OutStockLockInfo>();
                if (outboundOrder==null)
                {
                    return WebResponseContent.Instance.Error("出库单不存在");
                }
                if (outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt())
                {
                    return WebResponseContent.Instance.OK();
                }
                //测试架库给ERP上报出库完成
                if (outStockLockInfos.Count <= 0 || outStockLockInfos == null)
                if (warehouse.WarehouseCode==WarehouseEnum.HA64.ToString())
                {
                    stockInfos = TestOutStocksUpdate(warehouse).Data as List<Dt_StockInfo> ?? new List<Dt_StockInfo>();
                    List<ERPPickItemModel> eRPOutPick = new List<ERPPickItemModel>();
                    List<ERPPickItemModel> eRPOutPick =new List<ERPPickItemModel>();
                    for (int i = 0; i < stockInfos.Count; i++)
                    {
                        ERPPickItemModel pickItemModel = new ERPPickItemModel()
                        {
                            Lotno = stockInfos[i].Details[0].BatchNo,
                            Qty = stockInfos[i].Details[0].StockQuantity.ObjToInt().ToString(),
                            Location = warehouse.WarehouseCode
                            Lotno= stockInfos[i].Details[0].BatchNo,
                            Qty= stockInfos[i].Details[0].StockQuantity.ObjToInt().ToString(),
                            Location= warehouse.WarehouseCode
                        };
                        eRPOutPick.Add(pickItemModel);
                    }
                    ERPPickModel pickModel = new ERPPickModel()
                    {
                        Rowindex = outboundOrder.Details[0].RowNo,
@@ -225,8 +246,8 @@
                }
                else
                {
                    List<ERPPickModel> eRPPickModels = new List<ERPPickModel>();
                    List<ERPPickModel> eRPPickModels= new List<ERPPickModel>();
                    //获取出库详情单
                    foreach (var item in outStockLockInfos)
                    {
@@ -245,7 +266,7 @@
                            Qty = pickItemModel.Qty,
                            Dataitem = new List<ERPPickItemModel> { pickItemModel }
                        };
                        item.Status = OutLockStockStatusEnum.出库完成.ObjToInt();
                        item.Status= OutLockStockStatusEnum.出库完成.ObjToInt();
                        eRPPickModels.Add(pickModel);
                        _OutStockLockInfos.Add(item);
                    }
@@ -267,7 +288,7 @@
                        Issitem = new List<ERPIssueItemModel>() { issueItemModel },
                    };
                }
                if (stockInfos.Count > 0)
                {
                    _stockInfoRepository.UpdateData(stockInfos);
@@ -297,7 +318,7 @@
            {
                //获取出库单库存
                List<Dt_StockInfo> stockInfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).ToList();
                if (stockInfos.Count <= 0)
                if (stockInfos.Count<=0)
                {
                    return WebResponseContent.Instance.Error($"库存不足");
                }