diff --git a/src/main/java/club/joylink/rtss/services/training/GenerateTask.java b/src/main/java/club/joylink/rtss/services/training/GenerateTask.java index e8aaf89fe..cc479f8ce 100644 --- a/src/main/java/club/joylink/rtss/services/training/GenerateTask.java +++ b/src/main/java/club/joylink/rtss/services/training/GenerateTask.java @@ -124,37 +124,37 @@ public class GenerateTask { @Transactional public String generateNewTrainings(Long mapId, MapVO mapVO) { log.warn("generate training start...[{}]", LocalTime.now()); - // 查询通用运行图 - RunPlanVO planVO = this.iRunPlanTemplateService.getFirstRunPlanByMapId(mapVO.getId()); - this.delete(mapId); - GenerateConfig config = new GenerateConfig(); - config.setMapId(mapId); - List results = new ArrayList<>(); - List commandDefinitions = iCommandService.queryDefinitionsByLineCode(mapVO.getLineCode()); - Map> groupByPrdType = commandDefinitions.stream() - .collect(Collectors.groupingBy(CommandDefinitionVO::getPrdType)); - groupByPrdType.forEach((r, cdr) -> { - config.setPrdType(r); - SimulationBuildParams params = SimulationBuildParams.builder() - .createTime(LocalDateTime.now()) - .map(mapVO) - .prodType(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType())) - .runPlan(planVO) - .build(); - Simulation simulation = SimulationBuilder.build(params); - Map> groupByOperationObject = cdr.stream() - .collect(Collectors.groupingBy(CommandDefinitionVO::getOperateObject)); - groupByOperationObject.forEach((o, cdo) -> { - config.setTrainingType(o); - config.setOperateType(cdo.stream().map(cd -> cd.getOperate()).collect(Collectors.toList())); - List list = this.generateNew(config, mapVO, simulation); - if (!CollectionUtils.isEmpty(list)) { - results.addAll(list); - } - }); + // 查询通用运行图 + RunPlanVO planVO = this.iRunPlanTemplateService.getFirstRunPlanByMapId(mapVO.getId()); + this.delete(mapId); + GenerateConfig config = new GenerateConfig(); + config.setMapId(mapId); + List results = new ArrayList<>(); + List commandDefinitions = iCommandService.queryDefinitionsByLineCode(mapVO.getLineCode()); + Map> groupByPrdType = commandDefinitions.stream() + .collect(Collectors.groupingBy(CommandDefinitionVO::getPrdType)); + groupByPrdType.forEach((r, cdr) -> { + config.setPrdType(r); + SimulationBuildParams params = SimulationBuildParams.builder() + .createTime(LocalDateTime.now()) + .map(mapVO) + .prodType(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType())) + .runPlan(planVO) + .build(); + Simulation simulation = SimulationBuilder.build(params); + Map> groupByOperationObject = cdr.stream() + .collect(Collectors.groupingBy(CommandDefinitionVO::getOperateObject)); + groupByOperationObject.forEach((o, cdo) -> { + config.setTrainingType(o); + config.setOperateType(cdo.stream().map(cd -> cd.getOperate()).collect(Collectors.toList())); + List list = this.generateNew(config, mapVO, simulation); + if (!CollectionUtils.isEmpty(list)) { + results.addAll(list); + } }); - log.warn("generate training end...[{}]", LocalTime.now()); - return CollectionUtils.isEmpty(results) ? "成功" : String.join(",", results); + }); + log.warn("generate training end...[{}]", LocalTime.now()); + return CollectionUtils.isEmpty(results) ? "成功" : String.join(",", results); } @Async