| | |
| | | using WIDESEA_IStorageTaskRepository; |
| | | using WIDESEA_IStorageTaskServices; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.ERP; |
| | | using WIDESEA_Model.Models.Order; |
| | | using WIDESEA_OrderRepository; |
| | | |
| | | namespace WIDESEA_OrderServices |
| | | { |
| | |
| | | private readonly IDt_TaskService _taskService; |
| | | private readonly ILocationInfoRepository _locationRepository; |
| | | private readonly IDt_TaskRepository _taskRepository; |
| | | private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; |
| | | private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; |
| | | private readonly IDt_OrderOutDetailsRepository _outDetailsRepository; |
| | | |
| | | public Dt_ProductionOutboundOrderService(IDt_ProductionOutboundOrderRepository BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | |
| | | IDt_TaskService taskService, |
| | | ILocationInfoRepository locationRepository, |
| | | IDt_TaskRepository taskRepository, |
| | | ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal) |
| | | ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, |
| | | IDt_OrderOutDetailsRepository outDetailsRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _productionoutboundOrderDetailRepository = productionoutboundOrderDetailRepository; |
| | |
| | | _locationRepository = locationRepository; |
| | | _taskRepository = taskRepository; |
| | | _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository; |
| | | _outDetailsRepository = outDetailsRepository; |
| | | } |
| | | |
| | | public WebResponseContent GetProductOutboundOrder(OutboundOrderGetDTO outboundOrderGetDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | |
| | | if (result.Item1.Count <= 0) |
| | | { |
| | | return content.Error("æªæ¾å°åºååé
ï¼è¯·ç¡®è®¤æ¯å¦åå¨åºåæåæ®æ°éå·²åºå®"); |
| | | return content.Error($"订å{outboundOrder.UpperOrderNo}ç©æç¼ç {outboundOrderdetail.MaterielCode}æªæ¾å°åºååé
ï¼è¯·ç¡®è®¤æ¯å¦åå¨åºåæåæ®æ°éå·²åºå®"); |
| | | } |
| | | |
| | | List<Dt_OrderOutDetails> outDetails = new List<Dt_OrderOutDetails>(); |
| | | result.Item1.Distinct().ForEach(item => |
| | | { |
| | | RequestTaskDto task = new RequestTaskDto |
| | |
| | | MaterielCode = outboundOrderdetail.MaterielCode, |
| | | Position = item.LocationCode, |
| | | PalletCode = item.PalletCode, |
| | | AreaId = Convert.ToInt32(requestOut.AreaId), |
| | | //AreaId = Convert.ToInt32(requestOut.AreaId), |
| | | AreaId = Convert.ToInt32(2), |
| | | }; |
| | | taskDtos.Add(task); |
| | | item.StockInfoDetails.Where(x => x.MaterielCode == outboundOrderdetail.MaterielCode).FirstOrDefault().Status = (int)StockStateEmun.åºåºéå®; |
| | | item.StockStatus = (int)StockStateEmun.åºåºéå®; |
| | | |
| | | item.StockInfoDetails.Where(x => x.OutboundQuantity > 0 && x.MaterielCode == outboundOrderdetail.MaterielCode).ForEach(x => |
| | | { |
| | | outDetails.Add(new Dt_OrderOutDetails() |
| | | { |
| | | OrderNo = outboundOrder.UpperOrderNo, |
| | | PalletCode = item.PalletCode, |
| | | OrderType = outboundOrder.OrderType, |
| | | ERPOrderId = outboundOrderdetail.ERPOrderId, |
| | | MaterielCode = outboundOrderdetail.MaterielCode, |
| | | MaterielName = outboundOrderdetail.MaterielName, |
| | | Warehouse = "æºè½ç«åº", |
| | | WareHouseId = "107", |
| | | OutboundQuantity = x.OutboundQuantity, |
| | | }); |
| | | }); |
| | | }); |
| | | List<Dt_Task> taskNews = new List<Dt_Task>(); |
| | | List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO>(); |
| | | foreach (var item in taskDtos) |
| | | { |
| | | taskNews.Add(await _taskService.RequestOutboundTaskAsync(item)); |
| | | |
| | | } |
| | | List<DtLocationStatusChangeRecord> locationStatusChangeRecords = new List<DtLocationStatusChangeRecord>(); |
| | | List<DtLocationInfo> locations = new List<DtLocationInfo>(); |
| | | if (taskNews.Count <= 0) |
| | | { |
| | | throw new Exception($"{outboundOrderdetail.MaterielCode}æªæ¾å°å¯åºåºæç"); |
| | | } |
| | | //List<DtStockInfo> stockNew = new List<DtStockInfo>(); |
| | | //List<Dt_OrderOutDetails> outDetailsNew = new List<Dt_OrderOutDetails>(); |
| | | foreach (var item in taskNews) |
| | | { |
| | | taskDTOs.Add(CreateTaskDTO(item)); |
| | |
| | | locations.AddRange(result1.Item2); |
| | | locations.AddRange(result2.Item2); |
| | | } |
| | | |
| | | outboundOrder.OrderStatus = (int)OrderStateEmun.å¼å§; |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | _taskRepository.AddData(taskNews); |
| | | _stockInfoRepository.UpdateDataNav(result.Item1); |
| | | await _locationStatusChangeRecordRepository.AddDataAsync(locationStatusChangeRecords); |
| | | await _locationRepository.UpdateDataAsync(locations); |
| | | BaseDal.UpdateData(outboundOrder); |
| | | _productionoutboundOrderDetailRepository.UpdateData(result.Item2); |
| | | _outDetailsRepository.AddData(outDetails); |
| | | }); |
| | | content = await _taskService.SendWCSTask(taskDTOs); |
| | | } |
| | |
| | | |
| | | foreach (var item in outStocks) |
| | | { |
| | | var stockDetail = item.StockInfoDetails |
| | | .Where(d => d.MaterielCode == outboundOrderdetail.MaterielCode && d.Quantity > 0); |
| | | var stockDetail = item.StockInfoDetails.Where(d => d.MaterielCode == outboundOrderdetail.MaterielCode && d.Quantity > 0); |
| | | if (needQuantity <= 0) |
| | | { |
| | | continue; |
| | |
| | | |
| | | } |
| | | outboundOrderdetail.OverOutQuantity = outboundOrderdetail.OrderQuantity - needQuantity; |
| | | outboundOrderdetail.NotOutQuantity = outboundOrderdetail.OrderQuantity - outboundOrderdetail.OverOutQuantity; |
| | | |
| | | if (outboundOrderdetail.OverOutQuantity != 0) |
| | | { |
| | | outboundOrderdetail.OrderDetailStatus = (int)OrderStateEmun.å¼å§; |
| | | } |
| | | if (outboundOrderdetail.OverOutQuantity == outboundOrderdetail.OrderQuantity) |
| | | { |
| | | outboundOrderdetail.OrderDetailStatus = (int)OrderStateEmun.已宿; |
| | | } |
| | | return (outStockNews, outboundOrderdetail); |
| | | } |
| | | |