1
hutongqing
2025-01-08 413f243b73ef073f4ac83889fda2f5bf6d1e727c
´úÂë¹ÜÀí/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;
@@ -115,7 +115,7 @@
                        };
                        Dt_OutboundOrder outboundOrder = new Dt_OutboundOrder()
                        {
                            OrderNo=model.OrderNo,
                            OrderNo = model.OrderNo,
                            UpperOrderNo = model.OrderNo,
                            OrderStatus = OutOrderStatusEnum.未开始.ObjToInt(),
                            OrderType = OutOrderTypeEnum.Issue.ObjToInt(),
@@ -172,30 +172,31 @@
            }
        }
        //上报出库完成
        public WebResponseContent TestOutUpload(int id,Dt_StockInfo stockInfo)
        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>();
                //测试架库给ERP上报出库完成
                if (stockInfo==null)
                if (outStockLockInfos.Count <= 0 || outStockLockInfos == null)
                {
                    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,
@@ -224,25 +225,34 @@
                }
                else
                {
                    Dt_OutboundOrderDetail orderDetail = outboundOrder.Details.FirstOrDefault(x => x.MaterielCode == stockInfo.Details[0].MaterielCode);
                    ERPPickItemModel pickItemModel = new ERPPickItemModel()
                    List<ERPPickModel> eRPPickModels = new List<ERPPickModel>();
                    //获取出库详情单
                    foreach (var item in outStockLockInfos)
                    {
                        Lotno = stockInfo.Details[0].BatchNo,
                        Qty = stockInfo.Details[0].StockQuantity.ObjToInt().ToString(),
                        Location = stockInfo.LocationCode
                    };
                    ERPPickModel pickModel = new ERPPickModel()
                    {
                        Rowindex = outboundOrder.Details[0].RowNo,
                        Material = outboundOrder.Details[0].MaterielCode,
                        Qty = (outboundOrder.Details[0].OrderQuantity.ObjToInt()).ToString(),
                        Dataitem = new List<ERPPickItemModel> { pickItemModel }
                    };
                        ERPPickItemModel pickItemModel = new ERPPickItemModel()
                        {
                            Lotno = item.BatchNo,
                            Qty = item.AssignQuantity.ObjToInt().ToString(),
                            Location = item.LocationCode
                        };
                        //获取出库单明细
                        Dt_OutboundOrderDetail outboundOrderDetail = outboundOrder.Details.FirstOrDefault(x => x.Id == item.OrderDetailId);
                        ERPPickModel pickModel = new ERPPickModel()
                        {
                            Rowindex = outboundOrderDetail.RowNo,
                            Material = outboundOrderDetail.MaterielCode,
                            Qty = pickItemModel.Qty,
                            Dataitem = new List<ERPPickItemModel> { pickItemModel }
                        };
                        item.Status = OutLockStockStatusEnum.出库完成.ObjToInt();
                        eRPPickModels.Add(pickModel);
                        _OutStockLockInfos.Add(item);
                    }
                    ERPIssueItemModel issueItemModel = new ERPIssueItemModel()
                    {
                        Pickcode = outboundOrder.UpperOrderNo,
                        PickList = new List<ERPPickModel>() { pickModel }
                        PickList = eRPPickModels
                    };
                    issueModel = new ERPIssueModel()
                    {
@@ -257,21 +267,18 @@
                        Issitem = new List<ERPIssueItemModel>() { issueItemModel },
                    };
                }
                string response = _invokeERPService.InvokeOutStandardsApi(issueModel);
                ErpRequestContent requestContent = response.DeserializeObject<ErpRequestContent>();
                if (requestContent.res == 1)
                if (stockInfos.Count > 0)
                {
                    if (stockInfos.Count>0)
                    {
                        _stockInfoRepository.UpdateData(stockInfos);
                    }
                    return WebResponseContent.Instance.OK(requestContent.Data);
                    _stockInfoRepository.UpdateData(stockInfos);
                }
                else
                {
                    return WebResponseContent.Instance.Error(requestContent.Data);
                    _outStockLockInfoService.Repository.UpdateData(_OutStockLockInfos);
                }
                //出库完成上报ERP æµ‹è¯•注释
                _invokeERPService.InvokeOutStandardsApi(issueModel);
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
@@ -290,7 +297,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($"库存不足");
                }