martin 2 жил өмнө
parent
commit
14199d2f9c

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

@@ -32,7 +32,7 @@ public class AlgorithmScheduler {
     /**
     /**
      * 定时删除算法镜像
      * 定时删除算法镜像
      */
      */
-    @Scheduled(fixedDelay = 60 * 1000)
+    @Scheduled(fixedDelay = 60 * 60 * 1000)
     @SneakyThrows
     @SneakyThrows
     public void removeAlgorithmImage() {
     public void removeAlgorithmImage() {
         int maxAlgorithmImage = dockerConfiguration.getMaxAlgorithmImage();
         int maxAlgorithmImage = dockerConfiguration.getMaxAlgorithmImage();

+ 16 - 8
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/ProjectService.java

@@ -2,17 +2,16 @@ package com.css.simulation.resource.scheduler.service;
 
 
 import api.common.pojo.constants.DictConstants;
 import api.common.pojo.constants.DictConstants;
 import api.common.util.*;
 import api.common.util.*;
+import com.css.simulation.resource.scheduler.configuration.kubernetes.KubernetesConfiguration;
 import com.css.simulation.resource.scheduler.mapper.*;
 import com.css.simulation.resource.scheduler.mapper.*;
 import com.css.simulation.resource.scheduler.pojo.po.*;
 import com.css.simulation.resource.scheduler.pojo.po.*;
 import com.css.simulation.resource.scheduler.pojo.to.*;
 import com.css.simulation.resource.scheduler.pojo.to.*;
 import com.css.simulation.resource.scheduler.util.GitUtil;
 import com.css.simulation.resource.scheduler.util.GitUtil;
 import com.css.simulation.resource.scheduler.util.KubernetesUtil;
 import com.css.simulation.resource.scheduler.util.KubernetesUtil;
 import com.css.simulation.resource.scheduler.util.MinioUtil;
 import com.css.simulation.resource.scheduler.util.MinioUtil;
-import com.css.simulation.resource.scheduler.util.ProjectUtil;
 import com.fasterxml.jackson.core.JsonProcessingException;
 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.kubernetes.client.openapi.ApiClient;
 import io.minio.MinioClient;
 import io.minio.MinioClient;
 import lombok.SneakyThrows;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
@@ -70,9 +69,7 @@ public class ProjectService {
     @Resource
     @Resource
     AlgorithmMapper algorithmMapper;
     AlgorithmMapper algorithmMapper;
     @Resource
     @Resource
-    ApiClient apiClient;
-    @Resource
-    ProjectUtil projectUtil;
+    KubernetesConfiguration kubernetesConfiguration;
 
 
     // -------------------------------- Comment --------------------------------
     // -------------------------------- Comment --------------------------------
 
 
@@ -272,15 +269,23 @@ public class ProjectService {
     }
     }
 
 
 
 
+    /**
+     * 将 master 节点设置成镜像仓库,导入镜像的同时 commit 到仓库当中,供其他节点 pull
+     * @param projectId
+     * @param algorithmId
+     * @return
+     */
     @SneakyThrows
     @SneakyThrows
     @Transactional
     @Transactional
     public String handleAlgorithm(String projectId, String algorithmId) {
     public String handleAlgorithm(String projectId, String algorithmId) {
-        String dockerImage;
         //4-1 根据算法 id 获取算法文件地址、是否已导入成镜像。
         //4-1 根据算法 id 获取算法文件地址、是否已导入成镜像。
         AlgorithmPO algorithmPO = algorithmMapper.selectById(algorithmId);
         AlgorithmPO algorithmPO = algorithmMapper.selectById(algorithmId);
-        String algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmId + ".tar";
-        dockerImage = "algorithm_" + algorithmId + ":latest";
+        String dockerImage;
+        String algorithmTarLinuxTempPath;
+
         if (algorithmPO == null) {
         if (algorithmPO == null) {
+            dockerImage = "algorithm_" + algorithmId + ":latest";
+            algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmId + ".tar";
             // 访问索为远程接口
             // 访问索为远程接口
             String tokenUri = "http://open-api.zoogooy.com/cgi-bin/token/token?grant_type=client_credential";
             String tokenUri = "http://open-api.zoogooy.com/cgi-bin/token/token?grant_type=client_credential";
             String appid = "3e64be4a29e5478f9717d53c11ab26ad";
             String appid = "3e64be4a29e5478f9717d53c11ab26ad";
@@ -329,6 +334,9 @@ public class ProjectService {
             FileUtil.writeInputStreamToLocalFile(inputStream, algorithmTarLinuxTempPath);
             FileUtil.writeInputStreamToLocalFile(inputStream, algorithmTarLinuxTempPath);
             LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
             LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
         } else {
         } else {
+            String algorithmCode = algorithmPO.getAlgorithmCode();
+            dockerImage = "algorithm_" + algorithmCode + ":latest";
+            algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmCode + ".tar";
             if ("1".equals(algorithmPO.getDockerImport()) && StringUtil.isNotEmpty(algorithmPO.getDockerImage())) {
             if ("1".equals(algorithmPO.getDockerImport()) && StringUtil.isNotEmpty(algorithmPO.getDockerImage())) {
                 dockerImage = algorithmPO.getDockerImage();
                 dockerImage = algorithmPO.getDockerImage();
             } else if ("0".equals(algorithmPO.getDockerImport()) || algorithmPO.getDockerImport() == null) {
             } else if ("0".equals(algorithmPO.getDockerImport()) || algorithmPO.getDockerImport() == null) {

+ 5 - 6
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/util/ProjectUtil.java

@@ -11,7 +11,6 @@ import com.css.simulation.resource.scheduler.pojo.po.UserPO;
 import com.css.simulation.resource.scheduler.pojo.to.KubernetesNodeTO;
 import com.css.simulation.resource.scheduler.pojo.to.KubernetesNodeTO;
 import com.css.simulation.resource.scheduler.pojo.to.PrefixTO;
 import com.css.simulation.resource.scheduler.pojo.to.PrefixTO;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.kafka.core.KafkaTemplate;
 import org.springframework.kafka.core.KafkaTemplate;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
@@ -28,15 +27,15 @@ import java.util.stream.Collectors;
 @Slf4j
 @Slf4j
 public class ProjectUtil {
 public class ProjectUtil {
 
 
-    @Autowired
+    @Resource
     ManualProjectMapper manualProjectMapper;
     ManualProjectMapper manualProjectMapper;
-    @Autowired
+    @Resource
     AutoSubProjectMapper autoSubProjectMapper;
     AutoSubProjectMapper autoSubProjectMapper;
-    @Autowired
+    @Resource
     UserMapper userMapper;
     UserMapper userMapper;
-    @Autowired
+    @Resource
     ClusterMapper clusterMapper;
     ClusterMapper clusterMapper;
-    @Autowired
+    @Resource
     KafkaTemplate<String, String> kafkaTemplate;
     KafkaTemplate<String, String> kafkaTemplate;
     @Resource
     @Resource
     KubernetesConfiguration kubernetesConfiguration;
     KubernetesConfiguration kubernetesConfiguration;

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

@@ -907,7 +907,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         resultVo.setTaskId(po.getId());
         resultVo.setTaskId(po.getId());
         String sceneId = po.getSceneId();
         String sceneId = po.getSceneId();
         String sceneType = po.getSceneType();
         String sceneType = po.getSceneType();
-        SceneBaseInfoVo sceneBaseInfoVo = getsceneNameAndOther(sceneId, sceneType);
+        SceneBaseInfoVo sceneBaseInfoVo = getSceneNameAndOther(sceneId, sceneType);
         resultVo.setSceneName(sceneBaseInfoVo.getCommonSceneName());
         resultVo.setSceneName(sceneBaseInfoVo.getCommonSceneName());
         resultVo.setRunStartTime(getRqStr(po.getRunStartTime(),1));
         resultVo.setRunStartTime(getRqStr(po.getRunStartTime(),1));
         resultVo.setRunEndTime(getRqStr(po.getRunEndTime(),1));
         resultVo.setRunEndTime(getRqStr(po.getRunEndTime(),1));
@@ -1321,7 +1321,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
      * 根据场景id和场景类型获取场景名
      * 根据场景id和场景类型获取场景名
      * @return
      * @return
      */
      */
-    private SceneBaseInfoVo getsceneNameAndOther(String sceneId, String sceneType){
+    private SceneBaseInfoVo getSceneNameAndOther(String sceneId, String sceneType){
         SceneBaseInfoVo resultVo = new SceneBaseInfoVo();
         SceneBaseInfoVo resultVo = new SceneBaseInfoVo();
         if(DictConstants.SCENE_NATURAL.equals(sceneType)){
         if(DictConstants.SCENE_NATURAL.equals(sceneType)){
             SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(sceneId);
             SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(sceneId);
@@ -3636,7 +3636,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 if(!isEmpty(runResultFilePath)){
                 if(!isEmpty(runResultFilePath)){
 
 
                     //获取场景名
                     //获取场景名
-                    SceneBaseInfoVo sceneBaseInfoVo = getsceneNameAndOther(v.getSceneId(), v.getSceneType());
+                    SceneBaseInfoVo sceneBaseInfoVo = getSceneNameAndOther(v.getSceneId(), v.getSceneType());
                     String sceneName = sceneBaseInfoVo.getCommonSceneName();
                     String sceneName = sceneBaseInfoVo.getCommonSceneName();
 
 
                     //任务包路径
                     //任务包路径

+ 5 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationProjectMapper.java

@@ -1,15 +1,15 @@
 package com.css.simulation.resource.project.mapper;
 package com.css.simulation.resource.project.mapper;
 
 
-import api.common.pojo.param.project.ProjectTaskParam;
-import api.common.pojo.param.project.SceneScoreParam;
 import api.common.pojo.param.project.SimulationManualProjectParam;
 import api.common.pojo.param.project.SimulationManualProjectParam;
 import api.common.pojo.po.algorithm.AlgorithmPO;
 import api.common.pojo.po.algorithm.AlgorithmPO;
 import api.common.pojo.po.model.ConfigPO;
 import api.common.pojo.po.model.ConfigPO;
 import api.common.pojo.po.model.ConfigSensorPO;
 import api.common.pojo.po.model.ConfigSensorPO;
 import api.common.pojo.po.model.VehiclePO;
 import api.common.pojo.po.model.VehiclePO;
-import api.common.pojo.po.project.*;
+import api.common.pojo.po.project.SimulationManualProjectPo;
+import api.common.pojo.po.project.SimulationMptFirstTargetScorePo;
+import api.common.pojo.po.project.SimulationMptLastTargetScorePo;
+import api.common.pojo.po.project.SimulationMptSceneScorePo;
 import api.common.pojo.po.scene.ScenePackagePO;
 import api.common.pojo.po.scene.ScenePackagePO;
-import api.common.pojo.po.scene.ScenePackageSublistPO;
 import api.common.pojo.vo.project.*;
 import api.common.pojo.vo.project.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
@@ -66,6 +66,7 @@ public interface SimulationProjectMapper {
     SceneBaseInfoVo selectSceneNatural(String id);
     SceneBaseInfoVo selectSceneNatural(String id);
 
 
     SceneBaseInfoVo selectSceneGeneralDataById(String id);
     SceneBaseInfoVo selectSceneGeneralDataById(String id);
+
     SceneBaseInfoVo selectSceneStandardsRegulations(String id);
     SceneBaseInfoVo selectSceneStandardsRegulations(String id);
 
 
     List<ScenePackageSubListVO> selectSubSceneByPid(String id);
     List<ScenePackageSubListVO> selectSubSceneByPid(String id);

+ 1 - 1
simulation-resource-server/src/main/resources/mapper/project/SimulationProjectMapper.xml

@@ -360,7 +360,7 @@
     </select>
     </select>
     <!--查询泛化场景信息-->
     <!--查询泛化场景信息-->
     <select id="selectSceneGeneralDataById" parameterType="string" resultType="api.common.pojo.vo.project.SceneBaseInfoVo">
     <select id="selectSceneGeneralDataById" parameterType="string" resultType="api.common.pojo.vo.project.SceneBaseInfoVo">
-        select scene_id
+        select scene_id scene_name
         from scene_general_data
         from scene_general_data
         where id = #{id,jdbcType=VARCHAR}
         where id = #{id,jdbcType=VARCHAR}
     </select>
     </select>