Kaynağa Gözat

王耀栋--工作台模块代码,算法下拉获取方式修改

wangyaodong 3 yıl önce
ebeveyn
işleme
fb4b56dd73

+ 3 - 0
api-common/src/main/java/api/common/pojo/param/project/SimulationManualProjectParam.java

@@ -31,6 +31,9 @@ public class SimulationManualProjectParam extends PageVO {
     //算法
     //算法
     private String algorithm;
     private String algorithm;
 
 
+    //算法名称
+    private String algorithmName;
+
     //车辆
     //车辆
     private String vehicle;
     private String vehicle;
 
 

+ 5 - 0
api-common/src/main/java/api/common/pojo/po/project/SimulationManualProjectPo.java

@@ -75,6 +75,11 @@ public class SimulationManualProjectPo extends BasePo {
     //算法得分
     //算法得分
     private Double algorithmScore;
     private Double algorithmScore;
 
 
+    //算法类型
+    private String algorithmType;
+
+
+
 
 
 
 
 }
 }

+ 3 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/project/constants/ProjectConstants.java

@@ -8,4 +8,7 @@ public class ProjectConstants {
     //任务运行 Kafka推送主题
     //任务运行 Kafka推送主题
     public static final String RUN_TASK_TOPIC = "manualProject";
     public static final String RUN_TASK_TOPIC = "manualProject";
 
 
+    //第三方算法类型(索为)
+    public static final String SY_ALGORITHM_TYPE="3";
+
 }
 }

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

@@ -9,6 +9,7 @@ import api.common.pojo.param.project.SceneScoreParam;
 import api.common.pojo.param.project.SimulationManualProjectKafkaParam;
 import api.common.pojo.param.project.SimulationManualProjectKafkaParam;
 import api.common.pojo.param.project.SimulationManualProjectParam;
 import api.common.pojo.param.project.SimulationManualProjectParam;
 import api.common.pojo.param.system.DictParam;
 import api.common.pojo.param.system.DictParam;
+import api.common.pojo.po.algorithm.AlgorithmPO;
 import api.common.pojo.po.project.*;
 import api.common.pojo.po.project.*;
 import api.common.pojo.po.scene.ScenePackageSublistPO;
 import api.common.pojo.po.scene.ScenePackageSublistPO;
 import api.common.pojo.vo.project.*;
 import api.common.pojo.vo.project.*;
@@ -29,6 +30,7 @@ import com.css.simulation.resource.system.service.DictService;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import lombok.SneakyThrows;
 import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -42,6 +44,7 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 
 
 @Service
 @Service
+@Slf4j
 public class SimulationProjectServiceImpl implements SimulationProjectService {
 public class SimulationProjectServiceImpl implements SimulationProjectService {
 
 
     @Autowired
     @Autowired
@@ -78,6 +81,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
 
             int add = simulationProjectMapper.add(po);
             int add = simulationProjectMapper.add(po);
             if(add > 0){
             if(add > 0){
+                //第三方算法存到算发表(索为)
+//                insertOtherAlgorithm(param);
+
                 return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,ResponseBodyVO.Response.SUCCESS.getMessage(),po.getId());
                 return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,ResponseBodyVO.Response.SUCCESS.getMessage(),po.getId());
             }
             }
             return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
             return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
@@ -92,6 +98,8 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             po.updatePo(AuthUtil.getCurrentUserId());
             po.updatePo(AuthUtil.getCurrentUserId());
             int update = simulationProjectMapper.update(po);
             int update = simulationProjectMapper.update(po);
             if(update > 0){
             if(update > 0){
+                //第三方算法存到算发表(索为)
+//                insertOtherAlgorithm(param);
                 return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,ResponseBodyVO.Response.SUCCESS.getMessage(),po.getId());
                 return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,ResponseBodyVO.Response.SUCCESS.getMessage(),po.getId());
             }
             }
 
 
@@ -199,6 +207,8 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     @SneakyThrows
     @SneakyThrows
     @Override
     @Override
     public ResponseBodyVO updateProjectNowRunState(SimulationManualProjectParam param) {
     public ResponseBodyVO updateProjectNowRunState(SimulationManualProjectParam param) {
+        log.info("updateProjectNowRunState_id:"+param.getId());
+        log.info("updateProjectNowRunState_nowRunState:"+param.getNowRunState());
 
 
         SimulationManualProjectPo po = simulationProjectMapper.selectProjectById(param);
         SimulationManualProjectPo po = simulationProjectMapper.selectProjectById(param);
 
 
@@ -245,6 +255,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
         kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
         String data = JsonUtil.beanToJson(kafkaParam);
         String data = JsonUtil.beanToJson(kafkaParam);
         kafkaParameter.setData(data);
         kafkaParameter.setData(data);
+        log.info("推送消息到kafka:"+data);
         kafkaService.send(kafkaParameter);
         kafkaService.send(kafkaParameter);
     }
     }
 
 
@@ -759,6 +770,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         //po.setRuleView(param.getRuleView());
         //po.setRuleView(param.getRuleView());
         po.setIsChoiceGpu(param.getIsChoiceGpu());
         po.setIsChoiceGpu(param.getIsChoiceGpu());
         po.setNowRunState(param.getNowRunState());
         po.setNowRunState(param.getNowRunState());
+        po.setAlgorithmType(param.getAlgorithmType());
         return po;
         return po;
 
 
     }
     }
@@ -1839,4 +1851,24 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         params.put("createUserId", AuthUtil.getCurrentUserId());
         params.put("createUserId", AuthUtil.getCurrentUserId());
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, simulationProjectMapper.selectEvaluationLevel(params));
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, simulationProjectMapper.selectEvaluationLevel(params));
     }
     }
+
+
+    private void insertOtherAlgorithm(SimulationManualProjectParam param){
+        if(ProjectConstants.SY_ALGORITHM_TYPE.equals(param.getAlgorithmType())){
+            AlgorithmPO po = new AlgorithmPO();
+            po.setId(param.getAlgorithm());
+            po.setAlgorithmName(param.getAlgorithmName());
+            AlgorithmPO po1 = simulationProjectMapper.selectalgorithmByQuery(po);
+            if(po1 == null){
+                simulationProjectMapper.insertOtherAlgorithm(po);
+            }else{
+                if(!po1.getAlgorithmName().equals(param.getAlgorithmName())){
+                    simulationProjectMapper.updateOtherAlgorithm(po);
+                }
+            }
+
+        }
+
+
+    }
 }
 }

+ 8 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationProjectMapper.java

@@ -3,6 +3,7 @@ package com.css.simulation.resource.project.mapper;
 import api.common.pojo.param.project.ProjectTaskParam;
 import api.common.pojo.param.project.ProjectTaskParam;
 import api.common.pojo.param.project.SceneScoreParam;
 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.project.*;
 import api.common.pojo.po.project.*;
 import api.common.pojo.po.scene.ScenePackageSublistPO;
 import api.common.pojo.po.scene.ScenePackageSublistPO;
 import api.common.pojo.vo.project.*;
 import api.common.pojo.vo.project.*;
@@ -109,4 +110,11 @@ public interface SimulationProjectMapper {
     List<Map> selectRunProjectByState(Map map);
     List<Map> selectRunProjectByState(Map map);
     List<Map> selectEvaluationLevel(Map map);
     List<Map> selectEvaluationLevel(Map map);
 
 
+    int insertOtherAlgorithm(AlgorithmPO po);
+
+    int updateOtherAlgorithm(AlgorithmPO po);
+
+    AlgorithmPO selectalgorithmByQuery(AlgorithmPO po);
+
+
 }
 }

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

@@ -14,6 +14,7 @@
         project_name,
         project_name,
         project_describe,
         project_describe,
         algorithm,
         algorithm,
+        algorithm_type,
         vehicle,
         vehicle,
         scene,
         scene,
         operation_cycle,
         operation_cycle,
@@ -42,6 +43,7 @@
         #{projectName,jdbcType=VARCHAR},
         #{projectName,jdbcType=VARCHAR},
         #{projectDescribe,jdbcType=VARCHAR},
         #{projectDescribe,jdbcType=VARCHAR},
         #{algorithm,jdbcType=VARCHAR},
         #{algorithm,jdbcType=VARCHAR},
+        #{algorithmType,jdbcType=VARCHAR},
         #{vehicle,jdbcType=VARCHAR},
         #{vehicle,jdbcType=VARCHAR},
         #{scene,jdbcType=VARCHAR},
         #{scene,jdbcType=VARCHAR},
         #{operationCycle,jdbcType=VARCHAR},
         #{operationCycle,jdbcType=VARCHAR},
@@ -70,6 +72,7 @@
         project_name = #{projectName,jdbcType=VARCHAR},
         project_name = #{projectName,jdbcType=VARCHAR},
         project_describe = #{projectDescribe,jdbcType=VARCHAR},
         project_describe = #{projectDescribe,jdbcType=VARCHAR},
         algorithm = #{algorithm,jdbcType=VARCHAR},
         algorithm = #{algorithm,jdbcType=VARCHAR},
+        algorithm_type = #{algorithmType,jdbcType=VARCHAR},
         vehicle = #{vehicle,jdbcType=VARCHAR},
         vehicle = #{vehicle,jdbcType=VARCHAR},
         scene = #{scene,jdbcType=VARCHAR},
         scene = #{scene,jdbcType=VARCHAR},
         max_simulation_time = #{maxSimulationTime,jdbcType=BIGINT},
         max_simulation_time = #{maxSimulationTime,jdbcType=BIGINT},
@@ -208,10 +211,10 @@
             <if test="nowRunState != null and nowRunState != ''">
             <if test="nowRunState != null and nowRunState != ''">
                 now_run_state = #{nowRunState,jdbcType=VARCHAR},
                 now_run_state = #{nowRunState,jdbcType=VARCHAR},
             </if>
             </if>
-            <if test="nowRunState == '10'">
+            <if test="startTime != null">
                 start_time=#{startTime,jdbcType=TIMESTAMP},
                 start_time=#{startTime,jdbcType=TIMESTAMP},
             </if>
             </if>
-            <if test="nowRunState == '30'">
+            <if test="finishTime != null">
                 finish_time=#{finishTime,jdbcType=TIMESTAMP},
                 finish_time=#{finishTime,jdbcType=TIMESTAMP},
             </if>
             </if>
         </set>
         </set>
@@ -616,4 +619,34 @@
         </if>
         </if>
         group by evaluation_level
         group by evaluation_level
     </select>
     </select>
+
+    <!--添加第三方算法信息到算发表-->
+    <insert id="insertOtherAlgorithm" parameterType="api.common.pojo.po.algorithm.AlgorithmPO">
+        insert into algorithm
+        (
+        id,
+        algorithm_name
+        )
+        values
+        (
+        id=#{id,jdbcType=VARCHAR},
+        algorithm_name=#{algorithmName,jdbcType=VARCHAR}
+        )
+    </insert>
+
+    <!--更新第三方算法信息到算法表-->
+    <update id="updateOtherAlgorithm" parameterType="api.common.pojo.po.algorithm.AlgorithmPO">
+        update algorithm
+        set algorithm_name=#{algorithmName,jdbcType=VARCHAR}
+        where id=#{id,jdbcType=VARCHAR}
+        and is_deleted = '0'
+    </update>
+
+    <!--查询第三方算法信息是否已经存在-->
+    <select id="selectalgorithmByQuery" parameterType="api.common.pojo.po.algorithm.AlgorithmPO" resultType="api.common.pojo.po.algorithm.AlgorithmPO">
+        select id, algorithmName
+        from algorithm
+        where id=#{id,jdbcType=VARCHAR}
+        and is_deleted = '0'
+    </select>
 </mapper>
 </mapper>