Przeglądaj źródła

保存评测等级

martin 2 lat temu
rodzic
commit
c3d6dd85e4

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

@@ -160,7 +160,7 @@ public class ProjectScheduler {
         try {
             projectMessageDTO = JsonUtil.jsonToBean(RedisUtil.getStringByKey(stringRedisTemplate, projectWaitingKey), ProjectMessageDTO.class);
         } catch (Exception e) {
-            log.error("ProjectScheduler--run 等待执行的项目信息已经从 redis 删除。");
+            log.info("ProjectScheduler--run 等待执行的项目信息已经从 redis 删除。");
             return;
         }
         //1 获取所有节点的剩余可用并行度

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

@@ -193,11 +193,11 @@ public class SimulationProjectCtrl {
     /**
      * 生成保存评测等级(任务结果返回时调用)
      *
-     * @return
+     * @return 响应对象
      */
     @RequestMapping("saveEvaluationLevel")
     @ResponseBody
-    public ResponseBodyVO saveEvaluationLevel(@RequestBody SimulationManualProjectParam param) {
+    public ResponseBodyVO<String> saveEvaluationLevel(@RequestBody SimulationManualProjectParam param) {
         return service.saveEvaluationLevel(param);
     }
 

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

@@ -70,25 +70,25 @@ import java.util.zip.ZipOutputStream;
 public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     @Resource
-     SimulationProjectMapper simulationProjectMapper;
+    SimulationProjectMapper simulationProjectMapper;
     @Resource
     ManualProjectMapper manualProjectMapper;
     @Resource
     AutoSubProjectMapper autoSubProjectMapper;
     @Resource
-     SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
+    SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
     @Resource
-     SimulationProjectTaskMapper simulationProjectTaskMapper;
+    SimulationProjectTaskMapper simulationProjectTaskMapper;
     @Resource
-     SimulationAutomaticSubProjectMapper simulationAutomaticSubProjectMapper;
+    SimulationAutomaticSubProjectMapper simulationAutomaticSubProjectMapper;
     @Resource
-     SimulationMptFirstTargetScoreMapper simulationMptFirstTargetScoreMapper;
+    SimulationMptFirstTargetScoreMapper simulationMptFirstTargetScoreMapper;
     @Resource
-     SimulationMptLastTargetScoreMapper simulationMptLastTargetScoreMapper;
+    SimulationMptLastTargetScoreMapper simulationMptLastTargetScoreMapper;
     @Resource
-     AlgorithmMapper algorithmMapper;
+    AlgorithmMapper algorithmMapper;
     @Resource
-     KafkaService kafkaService;
+    KafkaService kafkaService;
     @Resource
     DictService dictService;
 
@@ -3255,12 +3255,12 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         }
 
 
-        String scene = "";
+        String scene = null;
         // 手动运行
         if (DictConstants.PROJECT_TYPE_MANUAL.equals(projectType)) {
             SimulationManualProjectPo simulationManualProjectPo = simulationProjectMapper.selectProjectBaseById(param);
             if (simulationManualProjectPo == null) {
-                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有查到工作信息");
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "没有查到工作信息");
             }
             scene = simulationManualProjectPo.getScene();
         }
@@ -3268,16 +3268,15 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         else if (DictConstants.PROJECT_TYPE_AUTO_SUB.equals(projectType)) {
             SimulationManualProjectVo simulationManualProjectVo = simulationAutomaticSubProjectMapper.selectProjectInfo(param);
             if (simulationManualProjectVo == null) {
-                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有查到工作信息");
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "没有查到工作信息");
             }
             scene = simulationManualProjectVo.getScene();
         }
 
+        // -------------------------------- 计算评价等级 --------------------------------
         //TODO 该段代码可优化,有时间再优化
         List<ScenePackageSubListVO> scenePackageSubListVOS = simulationProjectMapper.selectSubSceneByPid(scene);
-
         String evaluationLevelReport = "";
-
         if (!isEmpty(scenePackageSubListVOS)) {
             double totalScore = 0D;
             for (ScenePackageSubListVO v : scenePackageSubListVOS) {
@@ -3291,16 +3290,16 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     continue;
                 }
                 Double score = simulationMptFirstTargetScorePo1.getScore();
-
                 totalScore += score * (weightDouble / 100);
             }
             evaluationLevelReport = getEvaluationLevelReport(saveTwoDecimalPlaces(totalScore));
         }
-
-        SimulationManualProjectPo simulationManualProjectPo = new SimulationManualProjectPo();
-        simulationManualProjectPo.setId(projectId);
-        simulationManualProjectPo.setEvaluationLevel(evaluationLevelReport);
-        simulationProjectMapper.saveEvaluationLevel(simulationManualProjectPo);
+        // -------------------------------- 保存结果 --------------------------------
+        if (DictConstants.PROJECT_TYPE_MANUAL.equals(projectType)) {
+            manualProjectMapper.updateEvaluationLevel(projectId, evaluationLevelReport);
+        } else if (DictConstants.PROJECT_TYPE_AUTO_SUB.equals(projectType)) {
+            autoSubProjectMapper.updateEvaluationLevel(projectId, evaluationLevelReport);
+        }
 
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
     }

+ 4 - 10
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/AutoSubProjectMapper.java

@@ -5,8 +5,6 @@ import api.common.pojo.po.project.SchedulerProjectPO;
 import org.apache.ibatis.annotations.*;
 import org.apache.ibatis.type.JdbcType;
 
-import java.util.List;
-
 @Mapper
 public interface AutoSubProjectMapper {
 
@@ -23,12 +21,8 @@ public interface AutoSubProjectMapper {
             "where sas.id = #{projectId}")
     SchedulerProjectPO selectById(@Param("projectId") String projectId);
 
-    @ResultMap("project")
-    @Select("select sas.id, sap.scene, sas.create_user_id, sap.parallelism, '2' project_type\n" +
-            "from simulation_automatic_subproject sas\n" +
-            "         left join simulation_automatic_project sap on sas.parent_id = sap.id\n" +
-            "where sas.is_deleted = '0'\n" +
-            "  and sas.now_run_state = #{nowRunState}")
-    List<SchedulerProjectPO> selectByNowRunState(@Param("nowRunState") String nowRunState);
-
+    @Update("update simulation_automatic_subproject\n" +
+            "set evaluation_level = #{evaluationLevel}\n" +
+            "where id = #{projectId}")
+    void updateEvaluationLevel(@Param("projectId") String projectId, @Param("evaluationLevel") String evaluationLevel);
 }

+ 4 - 8
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/ManualProjectMapper.java

@@ -5,8 +5,6 @@ import api.common.pojo.po.project.SchedulerProjectPO;
 import org.apache.ibatis.annotations.*;
 import org.apache.ibatis.type.JdbcType;
 
-import java.util.List;
-
 @Mapper
 public interface ManualProjectMapper {
 
@@ -23,12 +21,10 @@ public interface ManualProjectMapper {
             "where id = #{projectId}")
     SchedulerProjectPO selectById(@Param("projectId") String projectId);
 
-    @ResultMap("project")
-    @Select("select id, scene, create_user_id, parallelism, '1' project_type\n" +
-            "from simulation_manual_project\n" +
-            "where is_deleted = '0'\n" +
-            "  and now_run_state = #{nowRunState}")
-    List<SchedulerProjectPO> selectByNowRunState(@Param("nowRunState") String nowRunState);
+    @Update("update simulation_manual_project\n" +
+            "set evaluation_level = #{evaluationLevel}\n" +
+            "where id = #{projectId}")
+    void updateEvaluationLevel(@Param("projectId") String projectId, @Param("evaluationLevel") String evaluationLevel);
 
 
 }

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

@@ -107,7 +107,6 @@ public interface SimulationProjectMapper {
 
     SimulationManualProjectPo selectProjectReportIdByAlgorithmId(String algorithmId);
 
-    int saveEvaluationLevel(SimulationManualProjectPo po);
 
 
 }

+ 1 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/project/service/SimulationProjectService.java

@@ -2,7 +2,6 @@ package com.css.simulation.resource.project.service;
 
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.param.project.SimulationManualProjectParam;
-import org.springframework.web.bind.annotation.RequestBody;
 
 
 public interface SimulationProjectService {
@@ -45,7 +44,7 @@ public interface SimulationProjectService {
     String selectProjectReportIdByAlgorithmId(String algorithmId);
 
     //生成保存评价等级
-    ResponseBodyVO saveEvaluationLevel(SimulationManualProjectParam param);
+    ResponseBodyVO<String> saveEvaluationLevel(SimulationManualProjectParam param);
 
     //仿真结果保存到数据库
     ResponseBodyVO saveTaskResult(SimulationManualProjectParam param);

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

@@ -569,10 +569,4 @@
         limit 1
     </select>
 
-    <!--保存评测等级-->
-    <update id="saveEvaluationLevel" parameterType="api.common.pojo.po.project.SimulationManualProjectPo">
-        update simulation_manual_project
-        set evaluation_level = #{evaluationLevel,jdbcType=VARCHAR}
-        where id = #{id,jdbcType=VARCHAR} and is_deleted = '0'
-    </update>
 </mapper>