root il y a 2 ans
Parent
commit
8f0e50d6e8

+ 1 - 0
api-common/src/main/java/api/common/pojo/dto/ProjectMessageDTO.java

@@ -23,6 +23,7 @@ import lombok.NoArgsConstructor;
 public class ProjectMessageDTO {
 
     private String projectId;// 项目 id
+    private String modelType;// vtd carsim
     private String algorithmId;// 算法 id
     private String vehicleConfigId;// 车辆配置 id
     private String scenePackageId;// 场景包 id

+ 13 - 10
api-common/src/main/java/api/common/util/FileUtil.java

@@ -35,18 +35,21 @@ public class FileUtil {
         fileInputStream.close();
     }
 
-    @SneakyThrows
     public static void cpR(String sourceDirectoryPath, String targetDirectoryPath) {
-        File[] files = new File(sourceDirectoryPath).listFiles();
-        for (File file : files) {
-            if (file.isDirectory()) {
-                file.mkdir();
-            }
-            if (file.isFile()) {
-                String sourceFilePath = file.getAbsolutePath();
-                String targetFilePath = sourceFilePath.replace(sourceDirectoryPath, targetDirectoryPath);
-                cp(sourceFilePath, targetFilePath);
+        try {
+            File[] files = new File(sourceDirectoryPath).listFiles();
+            for (File file : files) {
+                if (file.isDirectory()) {
+                    file.mkdir();
+                }
+                if (file.isFile()) {
+                    String sourceFilePath = file.getAbsolutePath();
+                    String targetFilePath = sourceFilePath.replace(sourceDirectoryPath, targetDirectoryPath);
+                    cp(sourceFilePath, targetFilePath);
+                }
             }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
     }
 

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

@@ -386,6 +386,7 @@ public class ProjectConsumer {
     @SneakyThrows
     public void parseProject(ProjectMessageDTO projectMessageDTO, String projectRunningKey) {
         String projectId = projectMessageDTO.getProjectId();    // 项目 id
+        String modelType = projectMessageDTO.getModelType();
         ProjectPO projectPO = projectUtil.getProjectByProjectId(projectId);
         log.info("项目 " + projectId + " 信息为:" + projectPO);
         String isChoiceGpu = projectPO.getIsChoiceGpu();
@@ -468,7 +469,7 @@ public class ProjectConsumer {
             }
 
             log.info("项目 " + projectId + " 准备创建 yaml:是否使用 gpu " + isChoiceGpu + ",当前节点名称为:" + currentNodeName + ",当前节点已创建 yaml 个数为:" + currentCount);
-            String tempYaml = projectManager.createTempYaml(projectId, algorithmDockerImage, currentNodeName, partition, offset, isChoiceGpu);
+            String tempYaml = projectManager.createTempYaml(projectId, modelType, algorithmDockerImage, currentNodeName, partition, offset, isChoiceGpu);
             if (currentCount == 0) {
                 log.info("加入到启动列表 " + tempYaml);
                 yamlListToRun.add(tempYaml);

+ 68 - 37
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/manager/ProjectManager.java

@@ -17,8 +17,10 @@ import java.io.File;
 @Slf4j
 public class ProjectManager {
 
-    @Value("${scheduler.linux-path.pod-template-yaml}")
-    String podTemplateYaml;
+    @Value("${scheduler.linux-path.vtd-pod-template-yaml}")
+    String vtdPodTemplateYaml;
+    @Value("${scheduler.linux-path.carsim-pod-template-yaml}")
+    String carsimPodTemplateYaml;
     @Value("${scheduler.linux-path.pod-yaml-directory}")
     String podYamlDirectory;
     @Value("${spring.kafka.bootstrap-servers}")
@@ -33,12 +35,10 @@ public class ProjectManager {
 
     /**
      * 创建一个临时 yaml,node 在最后用 # 号隔开
-     *
-     * @param projectId
-     * @param algorithmDockerImage
      */
     @SneakyThrows
     public String createTempYaml(String projectId,
+                                 String modelType,
                                  String algorithmDockerImage,
                                  String nodeName,
                                  int kafkaPartition,
@@ -48,39 +48,70 @@ public class ProjectManager {
     ) {
         String podName = projectUtil.getRandomPodName(projectId);   // 生成 podName
         String podYaml = projectUtil.getPodYamlName(nodeName, podName);     // 模板文件名称
-        String podString = FileUtil.read(new File(podTemplateYaml));
-        String replace0 = podString.replace("vtd-container", "vtd-" + projectId);
-        String replace1 = replace0.replace("algorithm-container", "algorithm-" + projectId);
-        String replace2 = replace1.replace("algorithm-image", algorithmDockerImage);
-        String replace3 = replace2.replace("kafka-topic", projectId);     // 消息主题名称为 projectId
-        String replace4 = replace3.replace("kafka-ip", kafkaIp);
-        String replace5 = replace4.replace("kafka-partition", "\"" + kafkaPartition + "\"");
-        String replace6 = replace5.replace("kafka-offset", "\"" + kafkaOffset + "\"");
-        String replace7 = replace6.replace("minio-ip", minioConfiguration.getEndpointWithoutHttp());
-        String replace8 = replace7.replace("minio-access-key", minioConfiguration.getAccessKey());
-        String replace9 = replace8.replace("minio-secret-key", minioConfiguration.getSecretKey());
-        String replace10 = replace9.replace("pod-name", podName); // pod 名称包括 projectId 和 随机字符串
-        String replace11 = replace10.replace("namespace-name", kubernetesConfiguration.getNamespace()); // pod 名称包括 projectId 和 随机字符串
-        String replace12 = replace11.replace("node-name", nodeName);     // 指定 pod 运行节点
+        if ("1".equals(modelType)) {
+            String podString = FileUtil.read(new File(vtdPodTemplateYaml));
+            String replace0 = podString.replace("vtd-container", "vtd-" + projectId);
+            String replace1 = replace0.replace("algorithm-container", "algorithm-" + projectId);
+            String replace2 = replace1.replace("algorithm-image", algorithmDockerImage);
+            String replace3 = replace2.replace("kafka-topic", projectId);     // 消息主题名称为 projectId
+            String replace4 = replace3.replace("kafka-ip", kafkaIp);
+            String replace5 = replace4.replace("kafka-partition", "\"" + kafkaPartition + "\"");
+            String replace6 = replace5.replace("kafka-offset", "\"" + kafkaOffset + "\"");
+            String replace7 = replace6.replace("minio-ip", minioConfiguration.getEndpointWithoutHttp());
+            String replace8 = replace7.replace("minio-access-key", minioConfiguration.getAccessKey());
+            String replace9 = replace8.replace("minio-secret-key", minioConfiguration.getSecretKey());
+            String replace10 = replace9.replace("pod-name", podName); // pod 名称包括 projectId 和 随机字符串
+            String replace11 = replace10.replace("namespace-name", kubernetesConfiguration.getNamespace()); // pod 名称包括 projectId 和 随机字符串
+            String replace12 = replace11.replace("node-name", nodeName);     // 指定 pod 运行节点
 
-        String finalYaml = null;
-        if (DictConstants.USE_GPU.equals(isChoiceGpu)) {
-            log.info("项目 " + projectId + " 使用 gpu 生成视频");
-            String replace13 = replace12.replace("vtd-image", kubernetesConfiguration.getVtdImageUseGpu());
-            finalYaml = replace13.replace("vtd-command", kubernetesConfiguration.getVtdCommandUseGpu());
-        }
-        if (DictConstants.NOT_USE_GPU.equals(isChoiceGpu)) {
-            log.info("项目 " + projectId + " 不使用 gpu 生成视频");
-            String replace13 = replace12.replace("vtd-image", kubernetesConfiguration.getVtdImageNotUseGpu());
-            finalYaml = replace13.replace("vtd-command", kubernetesConfiguration.getVtdCommandNotUseGpu());
+            String finalYaml = null;
+            if (DictConstants.USE_GPU.equals(isChoiceGpu)) {
+                log.info("项目 " + projectId + " 使用 gpu 生成视频");
+                String replace13 = replace12.replace("vtd-image", kubernetesConfiguration.getVtdImageUseGpu());
+                finalYaml = replace13.replace("vtd-command", kubernetesConfiguration.getVtdCommandUseGpu());
+            }
+            if (DictConstants.NOT_USE_GPU.equals(isChoiceGpu)) {
+                log.info("项目 " + projectId + " 不使用 gpu 生成视频");
+                String replace13 = replace12.replace("vtd-image", kubernetesConfiguration.getVtdImageNotUseGpu());
+                finalYaml = replace13.replace("vtd-command", kubernetesConfiguration.getVtdCommandNotUseGpu());
+            }
+            log.info("保存项目 " + projectId + " 的 yaml 文件:" + finalYaml);
+            FileUtil.writeStringToLocalFile(finalYaml, podYamlDirectory + podYaml);
+            return podYamlDirectory + podYaml;
+        } else if ("2".equals(modelType)) {
+            String podString = FileUtil.read(new File(carsimPodTemplateYaml));
+            String replace0 = podString.replace("vtd-container", "vtd-" + projectId);
+            String replace1 = replace0.replace("algorithm-container", "algorithm-" + projectId);
+            String replace2 = replace1.replace("algorithm-image", algorithmDockerImage);
+            String replace3 = replace2.replace("kafka-topic", projectId);     // 消息主题名称为 projectId
+            String replace4 = replace3.replace("kafka-ip", kafkaIp);
+            String replace5 = replace4.replace("kafka-partition", "\"" + kafkaPartition + "\"");
+            String replace6 = replace5.replace("kafka-offset", "\"" + kafkaOffset + "\"");
+            String replace7 = replace6.replace("minio-ip", minioConfiguration.getEndpointWithoutHttp());
+            String replace8 = replace7.replace("minio-access-key", minioConfiguration.getAccessKey());
+            String replace9 = replace8.replace("minio-secret-key", minioConfiguration.getSecretKey());
+            String replace10 = replace9.replace("pod-name", podName); // pod 名称包括 projectId 和 随机字符串
+            String replace11 = replace10.replace("namespace-name", kubernetesConfiguration.getNamespace()); // pod 名称包括 projectId 和 随机字符串
+            String replace12 = replace11.replace("node-name", nodeName);     // 指定 pod 运行节点
+
+            String finalYaml = null;
+            if (DictConstants.USE_GPU.equals(isChoiceGpu)) {
+                log.info("项目 " + projectId + " 使用 gpu 生成视频");
+                String replace13 = replace12.replace("vtd-image", kubernetesConfiguration.getVtdImageUseGpu());
+                finalYaml = replace13.replace("vtd-command", kubernetesConfiguration.getVtdCommandUseGpu());
+            }
+            if (DictConstants.NOT_USE_GPU.equals(isChoiceGpu)) {
+                log.info("项目 " + projectId + " 不使用 gpu 生成视频");
+                String replace13 = replace12.replace("vtd-image", kubernetesConfiguration.getVtdImageNotUseGpu());
+                finalYaml = replace13.replace("vtd-command", kubernetesConfiguration.getVtdCommandNotUseGpu());
+            }
+            log.info("保存项目 " + projectId + " 的 yaml 文件:" + finalYaml);
+            FileUtil.writeStringToLocalFile(finalYaml, podYamlDirectory + podYaml);
+            return podYamlDirectory + podYaml;
+        } else {
+            throw new RuntimeException("createTempYaml() 模型类型错误:" + modelType);
         }
-        log.info("保存项目 " + projectId + " 的 yaml 文件:" + finalYaml);
-        FileUtil.writeStringToLocalFile(finalYaml, podYamlDirectory + podYaml);
-//        log.info("ProjectService--createPod 在节点 " + nodeName + " 开始执行 pod。");
-//        projectUtil.createPod(nodeName, podName, tempPodString);
-        return podYamlDirectory + podYaml;
-//        if (count == 0) {
-//            projectUtil.createPod2(podYamlDirectory + podYaml);
-//        }
+
+
     }
 }

+ 12 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/util/VehicleUtil.java

@@ -38,6 +38,12 @@ public class VehicleUtil {
             vehiclePO.setShiftTimeUp45Json(JsonUtil.listToJson(vehiclePO.getShiftTimeUp45()));
             vehiclePO.setShiftTimeUp56Json(JsonUtil.listToJson(vehiclePO.getShiftTimeUp56()));
 
+            vehiclePO.setShiftTimeDown12Json(JsonUtil.listToJson(vehiclePO.getShiftTimeDown12()));
+            vehiclePO.setShiftTimeDown23Json(JsonUtil.listToJson(vehiclePO.getShiftTimeDown23()));
+            vehiclePO.setShiftTimeDown34Json(JsonUtil.listToJson(vehiclePO.getShiftTimeDown34()));
+            vehiclePO.setShiftTimeDown45Json(JsonUtil.listToJson(vehiclePO.getShiftTimeDown45()));
+            vehiclePO.setShiftTimeDown56Json(JsonUtil.listToJson(vehiclePO.getShiftTimeDown56()));
+
             vehiclePO.setRelationCurveRightWheelAngleAndSteeringGearOutputJson(JsonUtil.listToJson(vehiclePO.getRelationCurveRightWheelAngleAndSteeringGearOutput()));
             vehiclePO.setRelationCurveLeftWheelAngleAndSteeringGearOutputJson(JsonUtil.listToJson(vehiclePO.getRelationCurveLeftWheelAngleAndSteeringGearOutput()));
 
@@ -77,6 +83,12 @@ public class VehicleUtil {
         vehicleVO.setShiftTimeUp45(JsonUtil.jsonToCommonList(vehicleVO.getShiftTimeUp45Json()));
         vehicleVO.setShiftTimeUp56(JsonUtil.jsonToCommonList(vehicleVO.getShiftTimeUp56Json()));
 
+        vehicleVO.setShiftTimeDown12(JsonUtil.jsonToCommonList(vehicleVO.getShiftTimeDown12Json()));
+        vehicleVO.setShiftTimeDown23(JsonUtil.jsonToCommonList(vehicleVO.getShiftTimeDown23Json()));
+        vehicleVO.setShiftTimeDown34(JsonUtil.jsonToCommonList(vehicleVO.getShiftTimeDown34Json()));
+        vehicleVO.setShiftTimeDown45(JsonUtil.jsonToCommonList(vehicleVO.getShiftTimeDown45Json()));
+        vehicleVO.setShiftTimeDown56(JsonUtil.jsonToCommonList(vehicleVO.getShiftTimeDown56Json()));
+
         vehicleVO.setRelationCurveRightWheelAngleAndSteeringGearOutput(JsonUtil.jsonToCommonList(vehicleVO.getRelationCurveRightWheelAngleAndSteeringGearOutputJson()));
         vehicleVO.setRelationCurveLeftWheelAngleAndSteeringGearOutput(JsonUtil.jsonToCommonList(vehicleVO.getRelationCurveLeftWheelAngleAndSteeringGearOutputJson()));
 

+ 1 - 1
simulation-resource-server/src/main/resources/mapper/model/VehicleMapper.xml

@@ -107,7 +107,7 @@
         <result column="steeringGearRatio" property="steeringGearRatio" jdbcType="VARCHAR"/>
         <result column="relationCurveRightWheelAngleAndSteeringGearOutput" property="relationCurveRightWheelAngleAndSteeringGearOutputJson" jdbcType="VARCHAR"/>
         <result column="relationCurveLeftWheelAngleAndSteeringGearOutput" property="relationCurveLeftWheelAngleAndSteeringGearOutputJson" jdbcType="VARCHAR"/>
-        <result column="wheelCenterToTop" property="share" jdbcType="VARCHAR"/>
+        <result column="wheelCenterToTop" property="wheelCenterToTop" jdbcType="VARCHAR"/>
     </resultMap>
 
     <select id="getVehicleList" parameterType="api.common.pojo.param.model.VehicleParam" resultMap="VehicleVOMap">