| | |
| | | private readonly IOutStockLockInfoService _outStockLockInfoService; |
| | | private readonly IOutboundOrderRepository _outboundOrderRepository; |
| | | |
| | | 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, |
| | | IOutboundOrderRepository outboundOrderRepository) : base(BaseDal) |
| | | { |
| | |
| | | } |
| | | saveModel.DetailData[0].Add("orderDetailStatus", OrderDetailStatusEnum.New.ObjToInt()); |
| | | return base.AddData(saveModel); |
| | | } |
| | | public WebResponseContent GetOutboundOrders(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | int pageNo = saveModel.MainData["pageNo"].ObjToInt(); |
| | | string? orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | int warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | List<Dt_OutboundOrder> dt_ReceiveOrders = new List<Dt_OutboundOrder>(); |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderStatus < OutLockStockStatusEnum.åºåºå®æ.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5); |
| | | } |
| | | else |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_OutboundOrder>().Where(x => (x.OrderNo.Contains(orderNo)) && x.OrderStatus < OutLockStockStatusEnum.åºåºå®æ.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent ReceiveOutOrder(ErpOutOrderDTO model) |
| | | { |
| | |
| | | MaterielName = materielInfo.MaterielName, |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | OrderQuantity = model.Qty, |
| | | Unit=materielInfo.MaterielUnit |
| | | 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(), |
| | |
| | | } |
| | | } |
| | | //䏿¥åºåºå®æ |
| | | 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>(); |
| | | int overCount = outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | if (outboundOrder.Details.Count == overCount) |
| | | { |
| | | outboundOrder.OrderStatus = OutOrderStatusEnum.åºåºå®æ.ObjToInt(); |
| | | _outboundOrderRepository.UpdateData(outboundOrder); |
| | | } |
| | | if (outboundOrder==null) |
| | | if (outboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("åºåºåä¸åå¨"); |
| | | } |
| | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | //æµè¯æ¶åºç»ERP䏿¥åºåºå®æ |
| | | if (warehouse.WarehouseCode==WarehouseEnum.HA64.ToString()) |
| | | 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, |
| | |
| | | } |
| | | else |
| | | { |
| | | List<ERPPickModel> eRPPickModels= new List<ERPPickModel>(); |
| | | |
| | | List<ERPPickModel> eRPPickModels = new List<ERPPickModel>(); |
| | | |
| | | //è·ååºåºè¯¦æ
å |
| | | foreach (var item in outStockLockInfos) |
| | | { |
| | |
| | | Qty = pickItemModel.Qty, |
| | | Dataitem = new List<ERPPickItemModel> { pickItemModel } |
| | | }; |
| | | if (item.OrderQuantity==item.AssignQuantity) |
| | | if (item.OrderQuantity == item.AssignQuantity) |
| | | { |
| | | item.Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(); |
| | | } |
| | |
| | | Issitem = new List<ERPIssueItemModel>() { issueItemModel }, |
| | | }; |
| | | } |
| | | |
| | | |
| | | if (stockInfos.Count > 0) |
| | | { |
| | | _stockInfoRepository.UpdateData(stockInfos); |
| | |
| | | { |
| | | //è·ååºåºååºå |
| | | 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($"åºåä¸è¶³"); |
| | | } |