| | |
| | | @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 生成出库任务,获取波次单据信息 |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val, taskParams, loginUserId); |
| | | } |
| | | 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); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | .select("id", "loc_id", "loc_code", "order_id", "SUM(anfme) anfme", "SUM(qty) qty", "SUM(work_qty) work_qty", "splr_batch", "fields_index", "matnr_code") |
| | | .lambda() |
| | | .eq(LocItem::getMatnrCode, waveItem.getMatnrCode()) |
| | | .eq(LocItem::getSplrBatch, waveItem.getSplrBatch()) |
| | | .eq(StringUtils.isNotBlank(waveItem.getFieldsIndex()), LocItem::getFieldsIndex, waveItem.getFieldsIndex()) |
| | | .groupBy(LocItem::getMatnrCode, LocItem::getSplrBatch, LocItem::getFieldsIndex, LocItem::getId)); |
| | | .eq(StringUtils.isNotEmpty(waveItem.getSplrBatch()), LocItem::getSplrBatch, waveItem.getSplrBatch()) |
| | | // .eq(StringUtils.isNotBlank(waveItem.getFieldsIndex()), LocItem::getFieldsIndex, waveItem.getFieldsIndex()) |
| | | .groupBy(LocItem::getMatnrCode, LocItem::getSplrBatch, LocItem::getId)); |
| | | List<Double> doubles1 = locItems.stream().map(LocItem::getAnfme).collect(Collectors.toList()); |
| | | double[] doubles = doubles1.stream().mapToDouble(Double::doubleValue).toArray(); |
| | | |