root 2 gadi atpakaļ
vecāks
revīzija
13f15bbb74

+ 11 - 5
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/manager/TaskManager.java

@@ -31,6 +31,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.io.File;
 import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -211,8 +212,16 @@ public class TaskManager {
                 maxLevel = packageLevel;
             }
             log.info("TaskService--state 开始执行对第 " + (i + 1) + " 个叶子节点 " + indexId + " 进行打分!");
+            //1 判断有没有用户目录,没有则复制
+            String scoreDirectoryOfUser = linuxTempPath + "score/" + userId + "/";
+            if (!new File(scoreDirectoryOfUser + "main.py").exists()) {
+                // 复制 main.py
+                FileUtil.createDirectory(scoreDirectoryOfUser);
+                LinuxUtil.execute("cp -r " + pyPath + "* " + scoreDirectoryOfUser);
+            }
+            //2 将打分规则保存到script目录
 
-            String ruleFilePath = pyPath + "scripts/" + ruleName.split("_")[0] + "/" + ruleName + ".py";
+            String ruleFilePath = scoreDirectoryOfUser + "scripts/" + ruleName.split("_")[0] + "/" + ruleName + ".py";
             FileUtil.writeInputStreamToLocalFile(IoUtil.stringToInputStream(ruleDetails), ruleFilePath);
             log.info("TaskService--state 将叶子节点 " + indexId + " 对应的打分规则保存到临时目录:" + ruleFilePath);
             List<TaskPO> taskListOfLeafIndex = taskList.stream()
@@ -235,10 +244,7 @@ public class TaskManager {
                         String result1OfLinux = linuxTempPath + result1OfMinio;
                         String result2OfMinio = taskOfLeaf.getRunResultFilePath() + "/evaluation.csv";
                         String result2OfLinux = linuxTempPath + result2OfMinio;
-                        String scoreCommand = "python3 " + pyPath + "main.py "
-                                + result1OfLinux + " "
-                                + result2OfLinux + " "
-                                + taskOfLeaf.getSceneType() + " " + ruleName; // 指定打分脚本
+                        String scoreCommand = "python3 " + scoreDirectoryOfUser + "main.py " + result1OfLinux + " " + result2OfLinux + " " + taskOfLeaf.getSceneType() + " " + ruleName; // 指定打分脚本
                         String scoreResult;
                         ScoreTO score;
                         try {

+ 0 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/project/ctrl/SimulationProjectCtrl.java

@@ -212,8 +212,6 @@ public class SimulationProjectCtrl {
     /**
      * 保存仿真结果到数据库(任务结果返回时调用)
      *
-     * @param param
-     * @return
      */
     @RequestMapping("saveTaskResult")
     @ResponseBody

+ 7 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -984,6 +984,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 String[] split = line.split(",");
 
                 ////添加异常捕获,非正常数据默认为0
+                //1时间 6横向速度 7纵向速度 8横向加速度 9纵向加速度 12steering_angle 13yawrate 27lane_center_offset
                 // 时间
                 try {
                     double aDouble = Double.parseDouble(split[1]);
@@ -1045,7 +1046,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     longitudinal_acceleration_list.add(0D);
                 }
 
-                //
+                // steering_angle
                 try {
                     double aDouble = Double.parseDouble(split[12]);
                     if (Double.isNaN(aDouble)) {
@@ -2404,7 +2405,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             ProjectReportVo vo = (ProjectReportVo) bodyVO.getInfo();
 
             //下载 or 保存本地
-            if (param.getIsCreateLocalPdfFile() != null && param.getIsCreateLocalPdfFile() == true) {
+            if (param.getIsCreateLocalPdfFile() != null && param.getIsCreateLocalPdfFile()) {
                 File file = new File(param.getLocalPdfFilePath());
                 os = new BufferedOutputStream(Files.newOutputStream(file.toPath()));
             } else {
@@ -3460,7 +3461,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     public void exportProjectTaskFileById(SimulationManualProjectParam param) {
         String id = param.getId();
         if (StringUtil.isEmpty(id)) {
-            throw new RuntimeException("工作id不能为空");
+            throw new RuntimeException("项目 id 不能为空。");
         }
 
         //获取任务包信息
@@ -3468,7 +3469,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         projectTaskParam.setPId(id);
         List<ManualProjectTaskVo> manualProjectTaskVos = simulationProjectTaskMapper.selectProjectTaskByProjectId(projectTaskParam);
         if (isEmpty(manualProjectTaskVos)) {
-            throw new RuntimeException("没有获取到任务信息");
+            throw new RuntimeException("没有获取到任务信息");
         }
 
         //压缩包根路径
@@ -3501,7 +3502,8 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     String sceneName = sceneBaseInfoVo.getCommonSceneName();
 
                     //任务包路径
-                    String taskPagePath = rootPath + File.separator + sceneName + "(" + i + ")";
+//                    String taskPagePath = rootPath + File.separator + sceneName + "(" + i + ")";
+                    String taskPagePath = rootPath + File.separator + sceneName;
 
                     //视频文件路径
                     MinioParameter minioParameter1 = new MinioParameter();