| | |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateOutTask(List<OrderOutItemDto> itemParams, Long loginUserId, Wave wave) throws Exception { |
| | | for (OrderOutItemDto itemDto : itemParams) { |
| | | Map<Long, List<OrderOutItemDto>> listMap = itemParams.stream().collect(Collectors.groupingBy(OrderOutItemDto::getLocId)); |
| | | listMap.keySet().forEach(id -> { |
| | | double sum = listMap.get(id).stream().mapToDouble(OrderOutItemDto::getAnfme).sum(); |
| | | List<LocItem> items = new ArrayList<>(); |
| | | //生成明细 |
| | | listMap.get(id).forEach(orderOutItemDto -> { |
| | | items.add(orderOutItemDto.getLocItem()); |
| | | }); |
| | | //获取不为空站点 |
| | | List<OrderOutItemDto> itemDtos = listMap.get(id).stream().filter(orderOutItemDto -> !Objects.isNull(orderOutItemDto.getSitesNo())).collect(Collectors.toList()); |
| | | OrderOutItemDto itemDto = itemDtos.stream().findFirst().get(); |
| | | itemDto.setAnfme(sum); |
| | | LocToTaskParams taskParams = new LocToTaskParams(); |
| | | Loc loc = locService.getById(itemDto.getLocId()); |
| | | if (Objects.isNull(loc)) { |
| | | continue; |
| | | } |
| | | taskParams.setItems(Arrays.asList(itemDto.getLocItem())) |
| | | taskParams.setItems(items) |
| | | .setSiteNo(itemDto.getSitesNo()) |
| | | .setType(Constants.TASK_TYPE_WAVE_OUT_STOCK) |
| | | .setSourceId(wave.getId()) |
| | | .setTarLoc(loc.getCode()); |
| | | |
| | | //TODO 生成出库任务,获取波次单据信息 |
| | | try { |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val, taskParams, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException("出库任务生成失败!"); |
| | | } |
| | | }); |
| | | |
| | | // for (OrderOutItemDto itemDto : itemParams) { |
| | | // LocToTaskParams taskParams = new LocToTaskParams(); |
| | | // Loc loc = locService.getById(itemDto.getLocId()); |
| | | // if (Objects.isNull(loc)) { |
| | | // continue; |
| | | // } |
| | | // taskParams.setItems(Arrays.asList(itemDto.getLocItem())) |
| | | // .setSiteNo(itemDto.getSitesNo()) |
| | | // .setType(Constants.TASK_TYPE_WAVE_OUT_STOCK) |
| | | // .setSourceId(wave.getId()) |
| | | // .setTarLoc(loc.getCode()); |
| | | // |
| | | // //TODO 生成出库任务,获取波次单据信息 |
| | | // locItemService.generateTask(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val, taskParams, loginUserId); |
| | | // } |
| | | } |
| | | |
| | | /** |