root 2 éve
szülő
commit
cca159bcab

+ 48 - 0
api-common/src/main/java/api/common/pojo/constants/StateConstant.java

@@ -0,0 +1,48 @@
+package api.common.pojo.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.ToString;
+
+/**
+ * 任务状态
+ * Aborted 自动终止
+ * PendingAnalysis 待定分析
+ * Running 运行中
+ * Analysing 分析中
+ * Completed 已完成
+ * Terminated 手动中止  Terminating 手动中止(这两个英文单词合为一个中文单词)
+ * Pending 等待中
+ * Failed 失败
+ * Success 成功
+ * G 优秀
+ * A 良好
+ * M 一般
+ * P 较差
+ *
+ * @author martin
+ */
+@ToString
+@AllArgsConstructor
+@Getter
+public enum StateConstant {
+
+    Aborted("Aborted", "自动终止"),
+    PendingAnalysis("PendingAnalysis", "待定分析"),
+    Running("Running", "运行中"),
+    Analysing("Analysing", "分析中"),
+    Completed("Completed", "已完成"),
+    Terminated("Terminated", "手动中止"),
+    Terminating("Terminating", "手动中止"),
+    Pending("Pending", "等待中"),
+    Failed("Failed", "失败"),
+    Success("Success", "成功"),
+    G("G", "优秀"),
+    A("A", "良好"),
+    M("M", "一般"),
+    P("P", "较差");
+
+    private final String english;
+    private final String chinese;
+
+}

+ 7 - 5
api-common/src/main/java/api/common/pojo/param/algorithm/AlgorithmParameter.java

@@ -1,11 +1,13 @@
 package api.common.pojo.param.algorithm;
 
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.web.multipart.MultipartFile;
+import lombok.*;
 
-@Getter
-@Setter
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
 public class AlgorithmParameter extends PageParameter {
     //id
     private String id;

+ 2 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/mapper/AlgorithmMapper.java

@@ -51,4 +51,6 @@ public interface AlgorithmMapper {
     List<AlgorithmVO> selectSharedAlgorithmList(AlgorithmParameter param);
 
     int  selectDetailsBySy(AlgorithmParameter param);
+
+    String selectAlgorithmNameByAlgorithmId(@Param("algorithmId") String algorithmId);
 }

+ 5 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/home/ctrl/HomePageCtrl.java → simulation-resource-server/src/main/java/com/css/simulation/resource/home/controller/HomePageController.java

@@ -1,4 +1,4 @@
-package com.css.simulation.resource.home.ctrl;
+package com.css.simulation.resource.home.controller;
 
 import api.common.pojo.common.PageVO;
 import api.common.pojo.common.ResponseBodyVO;
@@ -27,7 +27,7 @@ import java.util.Map;
 @Slf4j
 @RestController
 @RequestMapping("/homePage")
-public class HomePageCtrl {
+public class HomePageController {
     @Resource
     private SceneNaturalService sceneNaturalService;
     @Resource
@@ -79,7 +79,7 @@ public class HomePageCtrl {
 
 
     /**
-     * 项目运行状态统计-饼图
+     * 首页 -- 系统监控 -- 状态统计 -- 项目运行状态统计
      */
     @RequestMapping("selectRunProjectByState")
     public ResponseBodyVO selectRunProjectByState() {
@@ -87,10 +87,10 @@ public class HomePageCtrl {
     }
 
     /**
-     * 任务运行状态统计-饼图
+     * 首页 -- 系统监控 -- 状态统计 -- 任务运行状态统计
      */
     @RequestMapping("selectRunTaskByState")
-    public ResponseBodyVO selectRunTaskByState() {
+    public ResponseBodyVO<List<Map<String, Object>>> selectRunTaskByState() {
         return simulationProjectService.selectRunTaskByState();
     }
 

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

@@ -3,6 +3,7 @@ package com.css.simulation.resource.project.impl;
 import api.common.pojo.common.PageVO;
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.constants.DictConstants;
+import api.common.pojo.constants.StateConstant;
 import api.common.pojo.param.KafkaParameter;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.algorithm.AlgorithmParameter;
@@ -2590,12 +2591,38 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     //任务运行状态统计-饼图
     @Override
-    public ResponseBodyVO selectRunTaskByState() {
+    public ResponseBodyVO<List<Map<String, Object>>> selectRunTaskByState() {
         Map<String, Object> params = new HashMap<>();
         params.put("createUserId", AuthUtil.getCurrentUserId());
-        List<Map> list = simulationProjectTaskMapper.selectRunTaskByState(params);
+        List<Map<String, Object>> list = simulationProjectTaskMapper.selectRunTaskByState(params);
+        list.forEach(map -> {
+            if (StateConstant.Aborted.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.Aborted.getChinese());
+            }
+            if (StateConstant.PendingAnalysis.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.PendingAnalysis.getChinese());
+            }
+            if (StateConstant.Running.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.Running.getChinese());
+            }
+            if (StateConstant.Analysing.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.Analysing.getChinese());
+            }
+            if (StateConstant.Completed.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.Completed.getChinese());
+            }
+            if (StateConstant.Terminated.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.Terminated.getChinese());
+            }
+            if (StateConstant.Terminating.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.Terminating.getChinese());
+            }
+            if (StateConstant.Pending.getEnglish().equals(map.get("runState"))) {
+                map.put("runState", StateConstant.Pending.getChinese());
+            }
+        });
 
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, list);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, list);
     }
 
     //项目运行状态统计-饼图
@@ -4135,9 +4162,6 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     @Override
     public void exportProjectTaskFileById(SimulationManualProjectParam param) {
         String id = param.getId();
-        if (StringUtil.isEmpty(id)) {
-            throw new RuntimeException("项目 id 不能为空。");
-        }
 
         //获取任务包信息
         ProjectTaskParam projectTaskParam = new ProjectTaskParam();
@@ -4243,11 +4267,12 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             if (param.getIsPagePdf() != null && param.getIsPagePdf()) {
                 // 获取工作信息
                 SimulationManualProjectPo p = simulationProjectMapper.selectProjectBaseById(param);
+                final String algorithmName = algorithmMapper.selectAlgorithmNameByAlgorithmId(param.getAlgorithm());
 
                 pdfFile = new File(param.getLocalPdfFilePath());
                 FileInputStream fileInputStream = new FileInputStream(pdfFile);
                 BufferedInputStream in = new BufferedInputStream(fileInputStream);
-                ZipEntry entry = new ZipEntry(rootPath + File.separator + p.getProjectName() + ".pdf");
+                ZipEntry entry = new ZipEntry(rootPath + File.separator + algorithmName + "评价报告.pdf");
                 zos.putNextEntry(entry);
                 while ((len = in.read(buffer)) != -1) {
                     zos.write(buffer, 0, len);
@@ -4276,26 +4301,16 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     @Override
     public void exportProjectReportAndTaskFileById(SimulationManualProjectParam param) {
-
-        String id = param.getId();
-        if (StringUtil.isEmpty(id)) {
-            throw new RuntimeException("工作id不能为空");
-        }
-
-        //生成本地pdf
-        String path = StringUtil.getRandomUUID();
+        // 生成本地pdf
         param.setIsCreateLocalPdfFile(true);
-        param.setLocalPdfFilePath(path);
-
-        exportProjectReport(param);
-
-        //下载报告和任务包
+        param.setLocalPdfFilePath(StringUtil.getRandomUUID() + ".pdf");
         param.setIsPagePdf(true);
-
+        // 下载报告和任务包
+        exportProjectReport(param);
         exportProjectTaskFileById(param);
-
     }
 
+
     @Override
     public ResponseBodyVO addOrUpdateAutomaticProject(SimulationManualProjectParam param) {
 

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

@@ -35,7 +35,7 @@ public interface SimulationProjectTaskMapper {
 
     SceneScoreVo selectSceneScoreNumQuery(SimulationMptSceneScorePo po);
 
-    List<Map> selectRunTaskByState(Map map);
+    List<Map<String, Object>> selectRunTaskByState(Map map);
 
     //更新仿真结果到数据库
     int updateTaksResult(ManualProjectTaskPo po);

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

@@ -6,6 +6,7 @@ import api.common.pojo.vo.project.*;
 import com.github.pagehelper.PageInfo;
 
 import java.util.List;
+import java.util.Map;
 
 
 public interface SimulationProjectService {
@@ -23,7 +24,7 @@ public interface SimulationProjectService {
     String getDictName(String type, String code);
     ResponseBodyVO analysisVehicleCoord() throws Exception;
     ResponseBodyVO selectProjectTaskList(SimulationManualProjectParam param);
-    ResponseBodyVO selectRunTaskByState();
+    ResponseBodyVO<List<Map<String, Object>>> selectRunTaskByState();
     ResponseBodyVO selectRunProjectByState();
     ResponseBodyVO selectEvaluationLevel();
     void exportProjectReport(SimulationManualProjectParam param);

+ 3 - 0
simulation-resource-server/src/main/resources/mapper/algorithm/AlgorithmMapper.xml

@@ -207,4 +207,7 @@
         </if>
 
     </select>
+    <select id="selectAlgorithmNameByAlgorithmId" resultType="java.lang.String">
+        select algorithm_name from algorithm where id = #{algorithmId}
+    </select>
 </mapper>