| | |
| | | using WIDESEA_DTO.Order; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_IBusinessesRepository; |
| | | using WIDESEA_IOrderRepository; |
| | | using WIDESEA_IOrderServices; |
| | | using WIDESEA_IStorageBasicRepository; |
| | |
| | | private readonly IDt_TaskRepository _taskRepository; |
| | | private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; |
| | | private readonly IDt_OrderOutDetailsRepository _outDetailsRepository; |
| | | private readonly IDt_AreaInfoRepository _areaInfoRepository; |
| | | |
| | | public Dt_AllocateOutboundOrderService(IDt_AllocateOutboundOrderRepository BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | |
| | | ILocationInfoRepository locationRepository, |
| | | IDt_TaskRepository taskRepository, |
| | | ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, |
| | | IDt_OrderOutDetailsRepository outDetailsRepository) : base(BaseDal) |
| | | IDt_OrderOutDetailsRepository outDetailsRepository, |
| | | IDt_AreaInfoRepository areaInfoRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _allocateoutboundOrderDetailRepository = allocateoutboundOrderDetailRepository; |
| | |
| | | _taskRepository = taskRepository; |
| | | _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository; |
| | | _outDetailsRepository = outDetailsRepository; |
| | | _areaInfoRepository = areaInfoRepository; |
| | | } |
| | | public WebResponseContent GetAllocateOutboundOrder(OutboundOrderGetDTO outboundOrderGetDTO) |
| | | { |
| | |
| | | { |
| | | foreach (var orderId in requestOut.orderIds) |
| | | { |
| | | Dt_AreaInfo areaInfo = null; |
| | | if (requestOut.Warehouse != "") |
| | | areaInfo = _areaInfoRepository.QueryFirst(x => x.AreaCode == requestOut.Warehouse); |
| | | |
| | | |
| | | List<RequestTaskDto> taskDtos = new List<RequestTaskDto>(); |
| | | Dt_AllocateOutboundOrderDetail allocateoutboundOrderdetail = _allocateoutboundOrderDetailRepository.QueryFirst(x => x.Id == orderId); |
| | | Dt_AllocateOutboundOrder outboundOrder = BaseDal.QueryFirst(x => x.Id == allocateoutboundOrderdetail.OrderId); |
| | |
| | | MaterielCode = allocateoutboundOrderdetail.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 == allocateoutboundOrderdetail.MaterielCode).FirstOrDefault().Status = (int)StockStateEmun.åºåºéå®; |
| | | item.StockStatus = (int)StockStateEmun.åºåºéå®; |
| | | item.Remark = requestOut.Warehouse; |
| | | item.OrderNo = outboundOrder.UpperOrderNo; |
| | | outDetails.Add(new Dt_OrderOutDetails() |
| | | |
| | | item.StockInfoDetails.Where(x => x.OutboundQuantity > 0 && x.MaterielCode == allocateoutboundOrderdetail.MaterielCode).ForEach(x => |
| | | { |
| | | OrderNo = outboundOrder.UpperOrderNo, |
| | | PalletCode = item.PalletCode, |
| | | OrderType = outboundOrder.OrderType, |
| | | ERPOrderId = allocateoutboundOrderdetail.ERPOrderId, |
| | | MaterielCode = allocateoutboundOrderdetail.MaterielCode, |
| | | MaterielName = allocateoutboundOrderdetail.MaterielName, |
| | | AllocateWarehouse = requestOut.Warehouse == null ? item.StockInfoDetails.Where(x => x.MaterielCode == allocateoutboundOrderdetail.MaterielCode).FirstOrDefault().Warehouse : requestOut.Warehouse, |
| | | Warehouse = "æºè½ç«åº", |
| | | WareHouseId = allocateoutboundOrderdetail.WareHouseId, |
| | | OutboundQuantity = item.StockInfoDetails.Where(x => x.MaterielCode == allocateoutboundOrderdetail.MaterielCode).Sum(x => x.Quantity), |
| | | outDetails.Add(new Dt_OrderOutDetails() |
| | | { |
| | | OrderNo = outboundOrder.UpperOrderNo, |
| | | PalletCode = item.PalletCode, |
| | | OrderType = outboundOrder.OrderType, |
| | | ERPOrderId = allocateoutboundOrderdetail.ERPOrderId, |
| | | MaterielCode = allocateoutboundOrderdetail.MaterielCode, |
| | | MaterielName = allocateoutboundOrderdetail.MaterielName, |
| | | AllocateWarehouse = areaInfo == null ? item.StockInfoDetails.Where(x => x.MaterielCode == allocateoutboundOrderdetail.MaterielCode).FirstOrDefault().Warehouse : areaInfo.AreaName, |
| | | AllocateWarehouseId = areaInfo == null ? item.StockInfoDetails.Where(x => x.MaterielCode == allocateoutboundOrderdetail.MaterielCode).FirstOrDefault().WareHouseId : areaInfo.AreaCode, |
| | | Warehouse = "æºè½ç«åº", |
| | | WareHouseId = "107", |
| | | OutboundQuantity = x.OutboundQuantity, |
| | | }); |
| | | }); |
| | | }); |
| | | List<Dt_Task> taskNews = new List<Dt_Task>(); |
| | |
| | | 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($"{allocateoutboundOrderdetail.MaterielCode}æªæ¾å°å¯åºåºæç"); |
| | | } |
| | | 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 () => |
| | | { |
| | | BaseDal.UpdateData(outboundOrder); |
| | | _taskRepository.AddData(taskNews); |
| | | _stockInfoRepository.UpdateDataNav(result.Item1); |
| | | await _locationStatusChangeRecordRepository.AddDataAsync(locationStatusChangeRecords); |
| | |
| | | |
| | | } |
| | | allocateoutboundOrderdetail.OverOutQuantity = allocateoutboundOrderdetail.OrderQuantity - needQuantity; |
| | | allocateoutboundOrderdetail.NotOutQuantity = allocateoutboundOrderdetail.OrderQuantity - allocateoutboundOrderdetail.OverOutQuantity; |
| | | |
| | | if (allocateoutboundOrderdetail.OverOutQuantity != 0) |
| | | { |
| | | allocateoutboundOrderdetail.OrderDetailStatus = (int)OrderStateEmun.å¼å§; |
| | | } |
| | | if (allocateoutboundOrderdetail.OverOutQuantity == allocateoutboundOrderdetail.OrderQuantity) |
| | | { |
| | | allocateoutboundOrderdetail.OrderDetailStatus = (int)OrderStateEmun.已宿; |
| | | } |
| | | return (outStockNews, allocateoutboundOrderdetail); |
| | | } |
| | | |