Browse Source

项目详情

root 2 năm trước cách đây
mục cha
commit
6068fdc6ac

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

@@ -8,12 +8,12 @@ import api.common.util.StringUtil;
 import com.css.simulation.resource.project.service.SimulationProjectService;
 import com.css.simulation.resource.system.service.ClusterService;
 import com.github.pagehelper.PageInfo;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -23,10 +23,10 @@ import java.util.List;
 @RequestMapping("/simulationProject")
 public class SimulationProjectCtrl {
 
-    @Autowired
+    @Resource
     private SimulationProjectService service;
 
-    @Autowired
+    @Resource
     private ClusterService clusterService;
 
 
@@ -308,7 +308,7 @@ public class SimulationProjectCtrl {
      */
     @RequestMapping("selectSubProjectInfo")
     @ResponseBody
-    public ResponseBodyVO selectSubProjectInfo(@RequestBody SimulationManualProjectParam param) {
+    public ResponseBodyVO<AutomaticProjectVo> selectSubProjectInfo(@RequestBody SimulationManualProjectParam param) {
         return service.selectSubProjectInfo(param);
     }
 

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

@@ -274,6 +274,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 .id(projectId)
                 .projectType(DictConstants.PROJECT_TYPE_MANUAL).build()).getInfo();
         String infoJson = JsonUtil.beanToJson(info);
+        log.info("updateProjectNowRunState() 项目 " + projectId + " 的详情信息为:" + infoJson);
         simulationProjectMapper.updateDetailsById(projectId, infoJson);
 
         //1 根据 id 查询项目信息
@@ -417,17 +418,16 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     @SneakyThrows
     public ResponseBodyVO<ProjectDetailsVo> selectProjectDetailsById(SimulationManualProjectParam param) {
 
-        if (isEmpty(param.getId())) {
-            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE);
-        }
+        String s = null;
+        if (DictConstants.PROJECT_TYPE_MANUAL.equals(param.getProjectType())) {   // 手动运行任务
+            s = manualProjectMapper.selectDetailsById(param.getId());
 
-        if (isEmpty(param.getProjectType())) {
-            param.setProjectType("1");//默认
+        } else if (DictConstants.PROJECT_TYPE_AUTO_SUB.equals(param.getProjectType())) {
+            s = autoSubProjectMapper.selectDetailsById(param.getId());
         }
 
-        String s = manualProjectMapper.selectDetailsById(param.getId());
 
-        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, JsonUtil.jsonToBean(s,ProjectDetailsVo.class));
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, JsonUtil.jsonToBean(s, ProjectDetailsVo.class));
     }
 //    @Override
 //    public ResponseBodyVO<ProjectDetailsVo> selectProjectDetailsById(SimulationManualProjectParam param) {
@@ -4034,10 +4034,18 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     @SneakyThrows
     @Override
-    public ResponseBodyVO createAutomaticSubProject(SimulationManualProjectParam param) {
+    public ResponseBodyVO<String> createAutomaticSubProject(SimulationManualProjectParam param) {
+        String projectId = param.getId();
+        ProjectDetailsVo info = selectProjectDetailsByIdBackUp(SimulationManualProjectParam.builder()
+                .id(projectId)
+                .projectType(DictConstants.PROJECT_TYPE_AUTO_SUB).build()).getInfo();
+        String infoJson = JsonUtil.beanToJson(info);
+        log.info("updateProjectNowRunState() 项目 " + projectId + " 的详情信息为:" + infoJson);
+        autoSubProjectMapper.updateDetailsById(projectId, infoJson);
+
 
         if (StringUtil.isEmpty(param.getId())) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "id不能为空");
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "id不能为空");
         }
         SimulationAutomaticProjectPo po = simulationAutomaticProjectMapper.selectById(param.getId());
         String projectName = po.getProjectName();
@@ -4072,13 +4080,13 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         int i = simulationAutomaticSubProjectMapper.addAutomaticSubProject(subprojectPo);
         if (i <= 0) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "执行失败");
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "执行失败");
         }
 
         //推送消息到kafka
         autoProjectRunToKafka(po, subprojectPo.getId());
 
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, null);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, null);
     }
 
     private void autoProjectRunToKafka(SimulationAutomaticProjectPo po, String subId) throws JsonProcessingException {
@@ -4140,50 +4148,41 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "删除失败");
     }
 
+
     /**
-     * 实际上查询的是父项目,名字不对
-     *
+     * 自动项目父项目信息
      * @param param
      * @return
      */
     @Override
-    public ResponseBodyVO selectSubProjectInfo(SimulationManualProjectParam param) {
-
+    public ResponseBodyVO<AutomaticProjectVo> selectSubProjectInfo(SimulationManualProjectParam param) {
         /*
         项目名称、项目描述、算法名称、车辆、传感器、场景、运行周期、并行度、是否选择GPU、最大运行时间
          */
         String id = param.getId();
-
         if (StringUtil.isEmpty(id)) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "id不能为空");
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "id不能为空");
         }
-
         AutomaticProjectVo automaticProjectVo = simulationAutomaticProjectMapper.selectAutomaticProjectInfoById(id);
         if (StringUtil.isEmpty(automaticProjectVo)) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有查询到数据");
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "没有查询到数据");
         }
-
         List<DropDownTypeVo> result = new ArrayList<>();
         setVehicleDropDown(result, automaticProjectVo.getVehicle());
         DropDownTypeVo dropDownTypeVo = result.get(0);
         DropDownVo dropDownVo = dropDownTypeVo.getDropDownList().get(0);
-
         automaticProjectVo.setVehicle(dropDownVo.getName());
-        ;
         automaticProjectVo.setSensor(dropDownVo.getSensor());
-
         String isChoiceGpu = automaticProjectVo.getIsChoiceGpu();
         if ("0".equals(isChoiceGpu)) {
             isChoiceGpu = "是";
-
         } else if ("1".equals(isChoiceGpu)) {
             isChoiceGpu = "否";
         } else {
             isChoiceGpu = "未知";
         }
         automaticProjectVo.setIsChoiceGpu(isChoiceGpu);
-
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, automaticProjectVo);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, automaticProjectVo);
 
     }
 

+ 11 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/AutoSubProjectMapper.java

@@ -25,4 +25,15 @@ public interface AutoSubProjectMapper {
             "set evaluation_level = #{evaluationLevel}\n" +
             "where id = #{projectId}")
     void updateEvaluationLevel(@Param("projectId") String projectId, @Param("evaluationLevel") String evaluationLevel);
+
+    @Update("update simulation_automatic_subproject\n" +
+            "set details = #{details}\n" +
+            "where id = #{projectId}")
+    void updateDetailsById(@Param("projectId") String projectId, @Param("details") String details);
+
+    @Select("select details\n" +
+            "from simulation_automatic_subproject\n" +
+            "where id = #{projectId}")
+    String selectDetailsById(@Param("projectId") String projectId);
+
 }

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

@@ -101,6 +101,7 @@ public interface SimulationProjectMapper {
     SystemUserVo selectUserById(String id);
 
     List<ConfigPO> selectConfigVehicle(ConfigPO configPO);
+
     List<ConfigPO> selectConfigVehicle2(ConfigPO configPO);
 
     List<ConfigSensorPO> selectConfigSensor(String id);
@@ -127,6 +128,6 @@ public interface SimulationProjectMapper {
     @Update("update simulation_manual_project\n" +
             "set details = #{details}\n" +
             "where id = #{projectId}")
-    void updateDetailsById(@Param("projectId")String projectId,@Param("details")String details);
+    void updateDetailsById(@Param("projectId") String projectId, @Param("details") String details);
 
 }

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

@@ -65,11 +65,11 @@ public interface SimulationProjectService {
 
     ResponseBodyVO<PageInfo<SimulationManualProjectVo>> selectAutomaticProject(SimulationManualProjectParam param);
 
-    ResponseBodyVO createAutomaticSubProject(SimulationManualProjectParam param);
+    ResponseBodyVO<String> createAutomaticSubProject(SimulationManualProjectParam param);
 
     ResponseBodyVO deleteAutomaticSubProjectByIds(SimulationManualProjectParam param);
 
-    ResponseBodyVO selectSubProjectInfo(SimulationManualProjectParam param);
+    ResponseBodyVO<AutomaticProjectVo> selectSubProjectInfo(SimulationManualProjectParam param);
 
     ResponseBodyVO<PageInfo<SimulationManualProjectVo>> selectSubProjectList(SimulationManualProjectParam param);