|
@@ -1,10 +1,9 @@
|
|
|
package com.css.simulation.resource.scheduler.service;
|
|
|
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
|
+import api.common.pojo.param.MinioParameter;
|
|
|
import api.common.pojo.param.RedisParameter;
|
|
|
-import api.common.util.CollectionUtil;
|
|
|
-import api.common.util.StringUtil;
|
|
|
-import api.common.util.TimeUtil;
|
|
|
+import api.common.util.*;
|
|
|
import com.css.simulation.resource.scheduler.feign.CommonService;
|
|
|
import com.css.simulation.resource.scheduler.manager.TaskIndexManager;
|
|
|
import com.css.simulation.resource.scheduler.manager.TaskManager;
|
|
@@ -17,12 +16,14 @@ import com.css.simulation.resource.scheduler.pojo.po.ProjectPO;
|
|
|
import com.css.simulation.resource.scheduler.pojo.po.TaskIndexPO;
|
|
|
import com.css.simulation.resource.scheduler.pojo.po.TaskPO;
|
|
|
import com.css.simulation.resource.scheduler.pojo.to.ScoreTO;
|
|
|
-import com.css.simulation.resource.scheduler.util.ScoreUtil;
|
|
|
+import feign.Response;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -47,6 +48,16 @@ public class TaskService {
|
|
|
private IndexTemplateMapper indexTemplateMapper;
|
|
|
@Value("${spring.kafka.consumer.topic.manual-project}")
|
|
|
private String manualProjectTopic;
|
|
|
+ @Value("${scheduler.manual-project.score.hostname}")
|
|
|
+ static String hostname;
|
|
|
+ @Value("${scheduler.manual-project.score.username}")
|
|
|
+ static String username;
|
|
|
+ @Value("${scheduler.manual-project.score.password}")
|
|
|
+ static String password;
|
|
|
+ @Value("${scheduler.manual-project.score.py-path}")
|
|
|
+ static String pyPath;
|
|
|
+ @Value("${scheduler.manual-project.result-path-linux}")
|
|
|
+ String manualProjectResultPathLinux;
|
|
|
|
|
|
public void taskTick(String taskId) {
|
|
|
// 刷新 redis 心跳时间
|
|
@@ -99,14 +110,26 @@ public class TaskService {
|
|
|
.filter(task1 -> sceneIdSet.contains(task1.getSceneId()))
|
|
|
.mapToDouble(task2 -> {
|
|
|
// 计算每个任务的得分
|
|
|
- ScoreTO score = ScoreUtil.score(task2.getRunResult(), ruleDetails);
|
|
|
- task2.setReturnSceneId(score.getUnitSceneID());
|
|
|
- task2.setScore(score.getUnitSceneScore());
|
|
|
- task2.setTargetEvaluate(score.getEvaluateItem());
|
|
|
- task2.setScoreExplain(score.getScoreDescription());
|
|
|
+ ScoreTO score = new ScoreTO();
|
|
|
+ try {
|
|
|
+ String runResultMinio = task2.getRunResult();
|
|
|
+ String runResultLinux = manualProjectResultPathLinux + runResultMinio.substring(1);
|
|
|
+ Response download = commonService.download(MinioParameter.builder().objectName(runResultMinio).build());
|
|
|
+ Response.Body body = download.body();
|
|
|
+ InputStream inputStream = body.asInputStream();
|
|
|
+ FileUtil.writeInputStreamToLocalFile(inputStream, runResultLinux);
|
|
|
+ String executeResult = SshUtil.execute(hostname, username, password, "python3 " + pyPath + " " + runResultLinux + " " + task2.getSceneType());
|
|
|
+ score = JsonUtil.jsonToBean(executeResult, ScoreTO.class);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ task2.setReturnSceneId(score.getUnit_scene_ID());
|
|
|
+ task2.setScore(score.getUnit_scene_score());
|
|
|
+ task2.setTargetEvaluate(score.getEvaluate_item());
|
|
|
+ task2.setScoreExplain(score.getScore_description());
|
|
|
task2.setModifyUserId(USER_ID);
|
|
|
task2.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
- return score.getUnitSceneScore();
|
|
|
+ return score.getUnit_scene_score();
|
|
|
}).sum();
|
|
|
long notStandardSceneNum = taskList.stream() // 计算不合格的任务数(不到100分就是不合格)
|
|
|
.filter(task1 -> sceneIdSet.contains(task1.getSceneId()) && task1.getScore() < 100)
|