martin 3 år sedan
förälder
incheckning
1801de5569

+ 3 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/configuration/kubernetes/KubernetesConfiguration.java

@@ -5,6 +5,7 @@ import io.kubernetes.client.util.ClientBuilder;
 import io.kubernetes.client.util.KubeConfig;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.util.ResourceUtils;
 
 import java.io.File;
 import java.io.FileReader;
@@ -15,9 +16,9 @@ public class KubernetesConfiguration {
 
     @Bean
     public ApiClient apiClient() throws IOException {
-//        File config = ResourceUtils.getFile("classpath:kubernetes/config");  // 开发环境可用,生产环境不行,无法从jar 包读取
+        File config = ResourceUtils.getFile("classpath:kubernetes/config");  // 开发环境可用,生产环境不行,无法从jar 包读取
 //        File config = new File("D:\\idea-project\\simulation-cloud\\simulation-resource-scheduler\\src\\main\\resources\\kubernetes\\config");  //windows
-        File config = new File("/root/.kube/config");   //linux
+//        File config = new File("/root/.kube/config");   //linux
 //
 //        ClassPathResource classPathResource = new ClassPathResource("kubernetes/config");
 //        InputStream inputStream =classPathResource.getInputStream();

+ 21 - 8
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/consumer/ManualProjectConsumer.java

@@ -3,6 +3,7 @@ package com.css.simulation.resource.scheduler.consumer;
 
 import api.common.pojo.constants.DictConstants;
 import api.common.pojo.dto.ProjectMessageDTO;
+import api.common.util.CollectionUtil;
 import api.common.util.JsonUtil;
 import api.common.util.StringUtil;
 import api.common.util.TimeUtil;
@@ -113,9 +114,15 @@ public class ManualProjectConsumer {
             }
         }
         List<ScenePO> sceneList = new ArrayList<>();
-        sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
-        sceneList.addAll(sceneMapper.selectStandardByIdList(standardIdList));
-        sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
+        if (CollectionUtil.isNotEmpty(naturalIdList)){
+            sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
+        }
+        if (CollectionUtil.isNotEmpty(standardIdList)){
+            sceneList.addAll(sceneMapper.selectStandardByIdList(standardIdList));
+        }
+        if (CollectionUtil.isNotEmpty(accidentIdList)){
+            sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
+        }
         projectMapper.updateTaskNumber(projectId, sceneList.size()); // 有多少场景就有多少任务
         // -------------------------------- 2 模型 --------------------------------
         // 根据车辆配置id vehicleConfigId, 获取 模型信息和传感器信息
@@ -315,9 +322,15 @@ public class ManualProjectConsumer {
             }
         }
         List<ScenePO> sceneList = new ArrayList<>();
-        sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
-        sceneList.addAll(sceneMapper.selectStandardByIdList(standardIdList));
-        sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
+        if (CollectionUtil.isNotEmpty(naturalIdList)){
+            sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
+        }
+        if (CollectionUtil.isNotEmpty(standardIdList)){
+            sceneList.addAll(sceneMapper.selectStandardByIdList(standardIdList));
+        }
+        if (CollectionUtil.isNotEmpty(accidentIdList)){
+            sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
+        }
         projectMapper.updateTaskNumber(projectId, sceneList.size()); // 有多少场景就有多少任务
         // -------------------------------- 2 模型 --------------------------------
         // 根据车辆配置id vehicleConfigId, 获取 模型信息和传感器信息
@@ -397,8 +410,8 @@ public class ManualProjectConsumer {
             //4-4 将对象转成 json
             String taskJson = JsonUtil.beanToJson(taskTO);
             //4-5 将 projectId 作为 topic 名称,发送 task 信息到 kafka
-//            kafkaTemplate.send(projectId, taskJson).addCallback(success -> {
-            kafkaTemplate.send("test", taskJson).addCallback(success -> {
+            kafkaTemplate.send(projectId, taskJson).addCallback(success -> {
+//            kafkaTemplate.send("test", taskJson).addCallback(success -> {
                 // 消息发送到的topic
                 String topic = success.getRecordMetadata().topic();
                 // 消息发送到的分区

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

@@ -8,7 +8,7 @@ import org.apache.ibatis.type.JdbcType;
 public interface VehicleMapper {
 
     @Results(id = "vehicle", value = {
-            @Result(column = "model_label", property = "modelLabel", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "vehicle_model", property = "modelLabel", jdbcType = JdbcType.VARCHAR),
             @Result(column = "max_speed", property = "maxSpeed", jdbcType = JdbcType.DECIMAL),
             @Result(column = "engine_power", property = "enginePower", jdbcType = JdbcType.DECIMAL),
             @Result(column = "max_deceleration", property = "maxDeceleration", jdbcType = JdbcType.DECIMAL),
@@ -27,7 +27,7 @@ public interface VehicleMapper {
             @Result(column = "height_distance", property = "heightDistance", jdbcType = JdbcType.DECIMAL),
             @Result(column = "wheelbase", property = "wheelbase", jdbcType = JdbcType.DECIMAL),
     })
-    @Select("select vehicle_type + '_' + vehicle_model + '_' + vehicle_colour model_label,\n" +
+    @Select("select vehicle_model,\n" +
             "       max_speed,\n" +
             "       engine_power,\n" +
             "       max_deceleration,\n" +

+ 4 - 1
simulation-resource-scheduler/src/main/resources/bootstrap.yml

@@ -1,5 +1,8 @@
+server:
+  tomcat:
+    connection-timeout: 36000000
 spring:
   application:
     name: simulation-resource-scheduler
   profiles:
-    active: aliyun
+    active: aliyun