| | |
| | | using WIDESEA_DTO.CalcOut; |
| | | using Newtonsoft.Json.Serialization; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_DTO.Basic; |
| | | |
| | | namespace WIDESEA_InboundService |
| | | { |
| | |
| | | private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository; |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly IFeedbackMesService _feedbackMesService; |
| | | public TakeStockOrderService(IRepository<Dt_TakeStockOrder> BaseDal, IUnitOfWorkManage unitOfWorkManage,IRepository<Dt_TakeStockOrder> takeStockOrder,IRepository<Dt_StockInfo> stockInfoRepository,IRepository<Dt_TakeStockOrderDetail> takeStockOrderDetail,IRepository<Dt_Task> taskRepository,ILocationInfoService locationInfoService, IRepository<Dt_InboundOrder> inboundOrderRepository,IRepository<Dt_OutboundOrder> outboundOrderRepository,IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_OutboundOrderDetail> outboundOrderDetailRepository, IOutboundPickingService outboundPickingService, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IOutboundService outboundService,IFeedbackMesService feedbackMesService) : base(BaseDal) |
| | | private readonly IESSApiService _eSSApiService; |
| | | public TakeStockOrderService(IRepository<Dt_TakeStockOrder> BaseDal, IUnitOfWorkManage unitOfWorkManage,IRepository<Dt_TakeStockOrder> takeStockOrder,IRepository<Dt_StockInfo> stockInfoRepository,IRepository<Dt_TakeStockOrderDetail> takeStockOrderDetail,IRepository<Dt_Task> taskRepository,ILocationInfoService locationInfoService, IRepository<Dt_InboundOrder> inboundOrderRepository,IRepository<Dt_OutboundOrder> outboundOrderRepository,IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_OutboundOrderDetail> outboundOrderDetailRepository, IOutboundPickingService outboundPickingService, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IOutboundService outboundService,IFeedbackMesService feedbackMesService,IESSApiService eSSApiService) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _takeStockOrder = takeStockOrder; |
| | |
| | | _stockInfoDetailRepository = stockInfoDetailRepository; |
| | | _outboundService = outboundService; |
| | | _feedbackMesService = feedbackMesService; |
| | | _eSSApiService = eSSApiService; |
| | | } |
| | | |
| | | private Dictionary<string, string> stations = new Dictionary<string, string> |
| | | { |
| | | {"2-1","2-9" }, |
| | | {"3-1","3-9" }, |
| | | }; |
| | | |
| | | private Dictionary<string, string> movestations = new Dictionary<string, string> |
| | | { |
| | | {"2-1","2-5" }, |
| | | {"3-1","3-5" }, |
| | | }; |
| | | public WebResponseContent ValidateBoxNo(string orderNo, string boxNo) |
| | | { |
| | | try |
| | |
| | | { |
| | | return content.Error("æªæ¾å°è¯¥çç¹åæ®"); |
| | | } |
| | | var stock = _stockInfoRepository.QueryFirst(x => x.PalletCode == boxNo); |
| | | var stock = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == boxNo).Includes(x=>x.Details).First(); |
| | | |
| | | if (stock == null) |
| | | { |
| | |
| | | NextAddress = "", |
| | | OrderNo = takeStockOrder.OrderNo, |
| | | Roadway = newLocation.RoadwayNo, |
| | | SourceAddress = sourceAddress, |
| | | SourceAddress = stations.GetValueOrDefault(sourceAddress)??"", |
| | | TargetAddress = newLocation.LocationCode, |
| | | TaskStatus = (int)TaskStatusEnum.New, |
| | | TaskType = TaskTypeEnum.InInventory.ObjToInt(), |
| | | PalletType = stock.PalletType, |
| | | WarehouseId = stock.WarehouseId |
| | | }; |
| | | if (stock.Details.Count <= 0) |
| | | { |
| | | stock.PalletType = (int)PalletTypeEnum.Empty; |
| | | newTask.TaskType = TaskTypeEnum.InEmpty.ObjToInt(); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockInfoRepository.UpdateData(stock); |
| | | _takeStockOrder.UpdateData(takeStockOrder); |
| | | _taskRepository.AddData(newTask); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | //var moveResult = await _eSSApiService.MoveContainerAsync(new MoveContainerRequest |
| | | //{ |
| | | // slotCode = movestations[station], |
| | | // containerCode = palletCode |
| | | //}); |
| | | var moveResult = _eSSApiService.MoveContainerAsync(new MoveContainerRequest |
| | | { |
| | | slotCode = movestations[sourceAddress], |
| | | containerCode = boxNo |
| | | }); |
| | | return content.OK(); |
| | | |
| | | } |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°è¯¥çç¹å·®å¼æ°æ®"); |
| | | } |
| | | //if(takeStockOrderDetail.Remark == "çç") |
| | | //{ |
| | | // Dt_InboundOrderDetail inboundOrderDetail = _inboundOrderDetailRepository.QueryFirst(x => x.Id == orderId); |
| | | // if(inboundOrderDetail == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error("æªæ¾å°éæ©çææ¶å¹³è´¦åæ®"); |
| | | // } |
| | | // Dt_InboundOrder inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x=>x.Id == inboundOrderDetail.OrderId).Includes(x=>x.Details).First(); |
| | | // Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x=>x.PalletCode == takeStockOrderDetail.TakePalletCode && x.StockStatus == StockStatusEmun.çç¹åºå宿.ObjToInt()).Includes(x=>x.Details).First(); |
| | | // if(stockInfo== null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"çç¹æç{takeStockOrderDetail.TakePalletCode}çåºåä¿¡æ¯æªæ¾å°ï¼ææçç¶æä¸æ£ç¡®"); |
| | | // } |
| | | // var datevaliDate = _inboundOrderRepository.Db.Queryable<Dt_MaterialExpirationDate>().Where(x => x.MaterialCode.Contains(inboundOrderDetail.MaterielCode.Substring(0, 6))).First(); |
| | | // var newStockDetail = new Dt_StockInfoDetail |
| | | // { |
| | | // StockId = stockInfo == null ? 0 : stockInfo.Id, |
| | | // Barcode = inboundOrderDetail.Barcode, |
| | | // MaterielCode = inboundOrderDetail.MaterielCode, |
| | | // MaterielName = inboundOrderDetail.MaterielName, |
| | | // BatchNo = inboundOrderDetail.BatchNo, |
| | | // Unit = inboundOrderDetail.Unit, |
| | | // InboundOrderRowNo = inboundOrderDetail.lineNo, |
| | | // SupplyCode = inboundOrderDetail.SupplyCode, |
| | | // WarehouseCode = inboundOrderDetail.WarehouseCode, |
| | | // StockQuantity = inboundOrderDetail.OrderQuantity, |
| | | // BarcodeQty = inboundOrderDetail.BarcodeQty, |
| | | // BarcodeUnit = inboundOrderDetail.BarcodeUnit, |
| | | // FactoryArea = inboundOrder.FactoryArea, |
| | | // Status = 0, |
| | | // OrderNo = inboundOrder.InboundOrderNo, |
| | | // BusinessType = inboundOrder.BusinessType, |
| | | // ValidDate = inboundOrder.BusinessType == BusinessTypeEnum.å¤é¨ä»åºè°æºä».ToString() ? inboundOrderDetail.ValidDate : datevaliDate == null ? null : Convert.ToDateTime(DateTime.Now).AddDays(Convert.ToDouble(datevaliDate.ValidityDays)), |
| | | // }; |
| | | // stockInfo.Details.Add(newStockDetail); |
| | | |
| | | // inboundOrderDetail.ReceiptQuantity = inboundOrderDetail.OrderQuantity; |
| | | // inboundOrderDetail.OverInQuantity = inboundOrderDetail.OrderQuantity; |
| | | // inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // int overCount = 1; |
| | | // int moreOverCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()); |
| | | // if (inboundOrder.Details.Count() == overCount + moreOverCount) |
| | | // { |
| | | // inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | // } |
| | | // else |
| | | // { |
| | | // inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | // } |
| | | // takeStockOrderDetail.DifferenceQty -= inboundOrderDetail.OrderQuantity; |
| | | // if(takeStockOrderDetail.DifferenceQty > 0) |
| | | // { |
| | | // takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.ææ¶æå平账å¤çä¸.ObjToInt(); |
| | | // } |
| | | // else if (takeStockOrderDetail.DifferenceQty == 0) |
| | | // { |
| | | // takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.ææ¶æå平账å¤ç.ObjToInt(); |
| | | // } |
| | | // else |
| | | // { |
| | | // return WebResponseContent.Instance.Error("è¯¥ææ¶åæ®æç»æ¡ç æ°é大äºå¾
平账æ°éï¼è¯·å¦éå
¶ä»åæ®å¹³è´¦"); |
| | | // } |
| | | |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // _inboundOrderRepository.UpdateData(inboundOrder); |
| | | // _inboundOrderDetailRepository.UpdateData(inboundOrderDetail); |
| | | // _takeStockOrderDetail.UpdateData(takeStockOrderDetail); |
| | | // BaseDal.Db.Insertable(newStockDetail).ExecuteCommand(); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // List<string> barcodes = new List<string>(); |
| | | // barcodes.Add(inboundOrderDetail.Barcode); |
| | | // _outboundPickingService.NoStockOutBatchInOrderFeedbackToMes(inboundOrder.Id, barcodes); |
| | | |
| | | |
| | | //} |
| | | //else |
| | | //{ |
| | | Dt_OutboundOrderDetail outboundOrderDetail = _outboundOrderDetailRepository.QueryFirst(x => x.Remark == takeStockOrderDetail.TakeStockNo && (x.OrderQuantity-x.LockQuantity-x.MoveQty)>0); |
| | | if (outboundOrderDetail == null) |
| | | { |
| | |
| | | List<Dt_OutboundOrderDetail> details = _outboundOrderDetailRepository.QueryData(x => x.OrderId == outboundOrder.Id); |
| | | if(details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty)) |
| | | { |
| | | _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo); |
| | | outboundOrder.OrderStatus = OutOrderStatusEnum.åºåºå®æ.ObjToInt(); |
| | | _outboundOrderRepository.UpdateData(outboundOrder); |
| | | } |
| | | _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo); |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |