martin 3 лет назад
Родитель
Сommit
b7534ada78

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

@@ -5,7 +5,6 @@ import io.kubernetes.client.util.ClientBuilder;
 import io.kubernetes.client.util.KubeConfig;
 import io.kubernetes.client.util.KubeConfig;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.util.ResourceUtils;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileReader;
@@ -16,9 +15,9 @@ public class KubernetesConfiguration {
 
 
     @Bean
     @Bean
     public ApiClient apiClient() throws IOException {
     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("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");
 //        ClassPathResource classPathResource = new ClassPathResource("kubernetes/config");
 //        InputStream inputStream = classPathResource.getInputStream();
 //        InputStream inputStream = classPathResource.getInputStream();

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

@@ -143,7 +143,7 @@ public class ManualProjectConsumer {
 
 
         int taskNumber = sceneList.size();
         int taskNumber = sceneList.size();
         Set<ScenePO> sceneSet = new HashSet<>(sceneList);
         Set<ScenePO> sceneSet = new HashSet<>(sceneList);
-        log.info("------- ManualProjectConsumer 共有 " + taskNumber + " 个任务,对应 " + sceneSet.size() + " 个场景!");
+        log.info("------- ManualProjectConsumer 项目" + projectId + " 共有 " + taskNumber + " 个任务,对应 " + sceneSet.size() + " 个场景!");
         manualProjectMapper.updateTaskNumber(projectId, taskNumber);
         manualProjectMapper.updateTaskNumber(projectId, taskNumber);
         // -------------------------------- 2 模型 --------------------------------
         // -------------------------------- 2 模型 --------------------------------
         // 根据车辆配置id vehicleConfigId, 获取 模型信息和传感器信息
         // 根据车辆配置id vehicleConfigId, 获取 模型信息和传感器信息
@@ -458,5 +458,4 @@ public class ManualProjectConsumer {
     }
     }
 
 
 
 
-
 }
 }

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

@@ -51,7 +51,7 @@ public interface SceneMapper {
             "       osgb_address osgb,\n" +
             "       osgb_address osgb,\n" +
             "       xodr_address odr\n" +
             "       xodr_address odr\n" +
             "from scene_natural\n" +
             "from scene_natural\n" +
-            "where is_deleted = '0'\n" +
+            "where 1=1\n" +
             "<if test='idList != null and idList.size() > 0'>\n" +
             "<if test='idList != null and idList.size() > 0'>\n" +
             "   and natural_id in\n" +
             "   and natural_id in\n" +
             "       <foreach collection='idList' index='index' item='item' open='(' close=')' separator=','>\n" +
             "       <foreach collection='idList' index='index' item='item' open='(' close=')' separator=','>\n" +
@@ -71,7 +71,7 @@ public interface SceneMapper {
             "       osgb_address osgb,\n" +
             "       osgb_address osgb,\n" +
             "       xodr_address odr\n" +
             "       xodr_address odr\n" +
             "from scene_standards_regulations\n" +
             "from scene_standards_regulations\n" +
-            "where is_deleted = '0'\n" +
+            "where 1=1\n" +
             "<if test='idList != null and idList.size() > 0'>\n" +
             "<if test='idList != null and idList.size() > 0'>\n" +
             "   and regulations_id in\n" +
             "   and regulations_id in\n" +
             "       <foreach collection='idList' index='index' item='item' open='(' close=')' separator=','>\n" +
             "       <foreach collection='idList' index='index' item='item' open='(' close=')' separator=','>\n" +
@@ -90,7 +90,7 @@ public interface SceneMapper {
             "       osgb_address osgb,\n" +
             "       osgb_address osgb,\n" +
             "       xodr_address odr\n" +
             "       xodr_address odr\n" +
             "from scene_accident\n" +
             "from scene_accident\n" +
-            "where is_deleted = '0'\n" +
+            "where 1=1\n" +
             "<if test='idList != null and idList.size() > 0'>\n" +
             "<if test='idList != null and idList.size() > 0'>\n" +
             "   and accident_id in\n" +
             "   and accident_id in\n" +
             "       <foreach collection='idList' index='index' item='item' open='(' close=')' separator=','>\n" +
             "       <foreach collection='idList' index='index' item='item' open='(' close=')' separator=','>\n" +

+ 3 - 8
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/TaskService.java

@@ -14,7 +14,6 @@ import com.css.simulation.resource.scheduler.pojo.po.TaskIndexPO;
 import com.css.simulation.resource.scheduler.pojo.po.TaskPO;
 import com.css.simulation.resource.scheduler.pojo.po.TaskPO;
 import com.css.simulation.resource.scheduler.pojo.to.ScoreTO;
 import com.css.simulation.resource.scheduler.pojo.to.ScoreTO;
 import com.css.simulation.resource.scheduler.util.MinioUtil;
 import com.css.simulation.resource.scheduler.util.MinioUtil;
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import io.minio.MinioClient;
 import io.minio.MinioClient;
@@ -234,6 +233,7 @@ public class TaskService {
 //                        String command = "python3 " + pyPath + " " + runResultLinux + " " + task2.getSceneType();  // 默认使用场景名称找打分脚本
 //                        String command = "python3 " + pyPath + " " + runResultLinux + " " + task2.getSceneType();  // 默认使用场景名称找打分脚本
                     String scoreCommand = "python3 " + pyPath + "main.py " + runResultLinux + " " + task2.getSceneType() + " " + ruleName; // 指定打分脚本
                     String scoreCommand = "python3 " + pyPath + "main.py " + runResultLinux + " " + task2.getSceneType() + " " + ruleName; // 指定打分脚本
                     String scoreResult;
                     String scoreResult;
+                    ScoreTO score;
                     try {
                     try {
                         try {
                         try {
                             log.info("TaskService--state 下载 minio 上的结果文件 " + runResultMinio + " 到本地:" + runResultLinux);
                             log.info("TaskService--state 下载 minio 上的结果文件 " + runResultMinio + " 到本地:" + runResultLinux);
@@ -246,6 +246,8 @@ public class TaskService {
 //                            scoreResult = SshUtil.execute(sessionScore, command);
 //                            scoreResult = SshUtil.execute(sessionScore, command);
                             scoreResult = SshUtil.execute(session, scoreCommand);
                             scoreResult = SshUtil.execute(session, scoreCommand);
                             log.info("TaskService--state 项目" + projectId + "的任务" + task2Id + "打分结束,结果为:" + scoreResult);
                             log.info("TaskService--state 项目" + projectId + "的任务" + task2Id + "打分结束,结果为:" + scoreResult);
+                            String replace = StringUtil.replace(scoreResult, "'", "\"");
+                            score = JsonUtil.jsonToBean(replace, ScoreTO.class);
                         } catch (IOException e) {
                         } catch (IOException e) {
                             throw new RuntimeException("------- TaskService--state 项目" + projectId + "的任务" + task2Id + " 打分出错,命令为:" + scoreCommand + " 修改状态为:" + DictConstants.TASK_ABORTED + "\n" + e.getMessage());
                             throw new RuntimeException("------- TaskService--state 项目" + projectId + "的任务" + task2Id + " 打分出错,命令为:" + scoreCommand + " 修改状态为:" + DictConstants.TASK_ABORTED + "\n" + e.getMessage());
                         }
                         }
@@ -254,13 +256,6 @@ public class TaskService {
                         taskMapper.updateFailStateWithStopTime(task2Id, DictConstants.TASK_ABORTED, TimeUtil.getNowForMysql(), DictConstants.TASK_ERROR_REASON_5);
                         taskMapper.updateFailStateWithStopTime(task2Id, DictConstants.TASK_ABORTED, TimeUtil.getNowForMysql(), DictConstants.TASK_ERROR_REASON_5);
                         throw new RuntimeException(e.getMessage());
                         throw new RuntimeException(e.getMessage());
                     }
                     }
-                    ScoreTO score = null;
-                    try {
-                        String replace = StringUtil.replace(scoreResult, "'", "\"");
-                        score = JsonUtil.jsonToBean(replace, ScoreTO.class);
-                    } catch (JsonProcessingException e) {
-                        e.printStackTrace();
-                    }
                     assert score != null;
                     assert score != null;
                     task2.setReturnSceneId(score.getUnit_scene_ID());
                     task2.setReturnSceneId(score.getUnit_scene_ID());
 //                    task2.setScore(new Random().nextInt(10) * 10.0);
 //                    task2.setScore(new Random().nextInt(10) * 10.0);