martin 2 anni fa
parent
commit
725699b855

+ 3 - 3
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/consumer/ProjectConsumer.java

@@ -90,7 +90,7 @@ public class ProjectConsumer {
      */
     @KafkaListener(groupId = "simulation-resource-scheduler", topics = "${scheduler.start-topic}")
     @SneakyThrows
-    public void cacheManualProject(ConsumerRecord<String, String> projectRecord) {
+    public void cacheProject(ConsumerRecord<String, String> projectRecord) {
         String projectJson = projectRecord.value();
         log.info("ProjectConsumer--cacheManualProject 接收到项目开始消息为:" + projectJson);
         //1 读取 kafka 的 project 信息
@@ -168,7 +168,7 @@ public class ProjectConsumer {
     public void run(String clusterId, String projectId, String projectRunningKey, String projectJson) {
         log.info("ProjectConsumer--run 集群 " + clusterId + " 将项目 " + projectId + " 执行!");
         redisTemplate.opsForValue().set(projectRunningKey, projectJson);
-        parseManualProject(projectJson, "cluster:" + clusterId, projectRunningKey);
+        parseProject(projectJson, "cluster:" + clusterId, projectRunningKey);
     }
 
     public void wait(String clusterId, String projectId, String projectWaitingKey, String projectJson) {
@@ -183,7 +183,7 @@ public class ProjectConsumer {
      * @param projectJson 项目启动消息
      */
     @SneakyThrows
-    public void parseManualProject(String projectJson, String clusterPrefix, String projectRunningPrefix) {
+    public void parseProject(String projectJson, String clusterPrefix, String projectRunningPrefix) {
 
         // -------------------------------- 0 准备 --------------------------------
         log.info("ProjectConsumer--parseManualProject 接收到项目开始消息为:" + projectJson);

+ 2 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/mapper/IndexTemplateMapper.java

@@ -20,6 +20,7 @@ public interface IndexTemplateMapper {
             @Result(column = "scene_natural_ids", property = "sceneNaturalIds", jdbcType = JdbcType.VARCHAR),
             @Result(column = "scene_traffic_ids", property = "sceneTrafficIds", jdbcType = JdbcType.VARCHAR),
             @Result(column = "scene_statue_ids", property = "sceneStatueIds", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "scene_generalization_ids", property = "sceneGeneralizationIds", jdbcType = JdbcType.VARCHAR),
             @Result(column = "weight", property = "weight", jdbcType = JdbcType.VARCHAR),
             @Result(column = "parent_id", property = "parentId", jdbcType = JdbcType.VARCHAR),
             @Result(column = "root_id", property = "rootId", jdbcType = JdbcType.VARCHAR),
@@ -32,6 +33,7 @@ public interface IndexTemplateMapper {
             "       sps.scene_natural_ids,\n" +
             "       sps.scene_traffic_ids,\n" +
             "       sps.scene_statue_ids,\n" +
+            "       sps.scene_generalization_ids,\n" +
             "       sps.weight,\n" +
             "       sps.parent_id,\n" +
             "       sps.root_id,\n" +

+ 18 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/mapper/SceneMapper.java

@@ -100,5 +100,22 @@ public interface SceneMapper {
             "</script>")
     List<ScenePO> selectAccidentByIdList(@Param("idList") List<String> idList);
 
-
+    @ResultMap("scene")
+    @Select("<script>" +
+            "select id           id,\n" +
+            "       scene_id     name,\n" +
+            "       '4'          type,\n" +
+            "       xosc_address osc,\n" +
+            "       osgb_address osgb,\n" +
+            "       xodr_address odr\n" +
+            "from scene_general_data\n" +
+            "where 1 = 1\n\n" +
+            "<if test='idList != null and idList.size() > 0'>\n" +
+            "   and id in\n" +
+            "       <foreach collection='idList' index='index' item='item' open='(' close=')' separator=','>\n" +
+            "           #{item}" +
+            "       </foreach>\n" +
+            "</if>\n" +
+            "</script>")
+    List<ScenePO> selectGeneralizationByIdList(List<String> generalizationIdList);
 }

+ 1 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/pojo/po/IndexTemplatePO.java

@@ -15,6 +15,7 @@ public class IndexTemplatePO {
     private String sceneNaturalIds;
     private String sceneTrafficIds;
     private String sceneStatueIds;
+    private String sceneGeneralizationIds;
     private String weight;  // 权重
     private String parentId;  // 父指标 id
     private String rootId;  // 场景测试包 id

+ 2 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/scheduler/ProjectScheduler.java

@@ -96,6 +96,7 @@ public class ProjectScheduler {
             if (CollectionUtil.isNotEmpty(clusterRunningKeySet)) {
                 runningProjectSet = projectUtil.getRunningProjectList(clusterRunningKeySet);
                 if (CollectionUtil.isNotEmpty(runningProjectSet)) {
+                    log.info("ProjectScheduler--dispatchProject 运行中的项目的 key 有:"+runningProjectSet);
                     long parallelismSum = 0;
                     for (String runningProjectKey : runningProjectSet) {
                         parallelismSum += JsonUtil.jsonToBean(redisTemplate.opsForValue().get(runningProjectKey), ProjectMessageDTO.class).getParallelism();
@@ -132,7 +133,7 @@ public class ProjectScheduler {
         }
         redisTemplate.opsForValue().set(projectRunningKey, projectJson);
         log.info("ProjectScheduler--run 项目 " + projectId + " 从等待队列进入执行状态!");
-        projectConsumer.parseManualProject(projectJson, clusterPrefix, projectRunningKey);
+        projectConsumer.parseProject(projectJson, clusterPrefix, projectRunningKey);
     }
 
 

+ 5 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/ProjectService.java

@@ -123,6 +123,7 @@ public class ProjectService {
             String naturalIds = leafIndex.getSceneNaturalIds();
             String standardIds = leafIndex.getSceneStatueIds();
             String accidentIds = leafIndex.getSceneTrafficIds();
+            String generalizationIds = leafIndex.getSceneGeneralizationIds();
             if (StringUtil.isNotEmpty(naturalIds)) {
                 List<String> naturalIdList = new ArrayList<>(Arrays.asList(naturalIds.split(",")));
                 sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
@@ -135,6 +136,10 @@ public class ProjectService {
                 List<String> accidentIdList = new ArrayList<>(Arrays.asList(accidentIds.split(",")));
                 sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
             }
+            if (StringUtil.isNotEmpty(generalizationIds)) {
+                List<String> generalizationIdList = new ArrayList<>(Arrays.asList(generalizationIds.split(",")));
+                sceneList.addAll(sceneMapper.selectGeneralizationByIdList(generalizationIdList));
+            }
         });
         log.info("ProjectService--handlePackage 项目" + projectId + " 共有 " + sceneList.size() + " 个任务!");
         return sceneList;