|
@@ -17,6 +17,7 @@ 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 feign.Response;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -28,6 +29,7 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class TaskService {
|
|
|
|
|
|
private final String USER_ID = "simulation-resource-scheduler";
|
|
@@ -79,16 +81,16 @@ public class TaskService {
|
|
|
String scenePackageId = projectPO.getScenePackageId();
|
|
|
int taskNum = projectMapper.selectTaskNumById(projectId);
|
|
|
int completedTaskNum = projectMapper.selectTaskNumByProjectIdAndState(projectId, DictConstants.TASK_COMPLETED);
|
|
|
- if (taskNum != completedTaskNum) {
|
|
|
+ if (taskNum != completedTaskNum) {
|
|
|
return;
|
|
|
- }
|
|
|
+ }
|
|
|
List<TaskPO> taskList = taskMapper.selectTaskListByProjectId(projectId);
|
|
|
+
|
|
|
List<IndexTemplatePO> leafIndexTemplateList = indexTemplateMapper.selectLeafIndexWithRuleDetailsByPackageId(scenePackageId);
|
|
|
List<TaskIndexPO> leafTaskIndexList = new ArrayList<>();
|
|
|
-
|
|
|
-
|
|
|
for (IndexTemplatePO indexTemplatePO : leafIndexTemplateList) {
|
|
|
- String ruleDetails = indexTemplatePO.getRuleDetails();
|
|
|
+
|
|
|
+
|
|
|
Set<String> sceneIdSet = new HashSet<>();
|
|
|
String naturalIds = indexTemplatePO.getSceneNaturalIds();
|
|
|
String standardIds = indexTemplatePO.getSceneStatueIds();
|
|
@@ -106,22 +108,27 @@ public class TaskService {
|
|
|
sceneIdSet.addAll(Arrays.asList(accidentIdArray));
|
|
|
}
|
|
|
int resultNumberOfCurrentIndex = sceneIdSet.size();
|
|
|
+
|
|
|
double sum = taskList.stream()
|
|
|
.filter(task1 -> sceneIdSet.contains(task1.getSceneId()))
|
|
|
.mapToDouble(task2 -> {
|
|
|
|
|
|
- ScoreTO score = new ScoreTO();
|
|
|
+ ScoreTO score;
|
|
|
+ String runResultMinio = task2.getRunResult();
|
|
|
+ String runResultLinux = manualProjectResultPathLinux + runResultMinio.substring(1);
|
|
|
+ String command = "python3 " + pyPath + " " + runResultLinux + " " + task2.getSceneType();
|
|
|
+
|
|
|
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);
|
|
|
+ log.info("------- 开始执行打分命令:" + command);
|
|
|
+ score = JsonUtil.jsonToBean(SshUtil.execute(hostname, username, password, command), ScoreTO.class);
|
|
|
+ log.info("------- 打分结束,结果为:" + score);
|
|
|
} catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("------- 打分出错,命令为:" + command);
|
|
|
+ throw new RuntimeException();
|
|
|
}
|
|
|
task2.setReturnSceneId(score.getUnit_scene_ID());
|
|
|
task2.setScore(score.getUnit_scene_score());
|
|
@@ -131,10 +138,11 @@ public class TaskService {
|
|
|
task2.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
return score.getUnit_scene_score();
|
|
|
}).sum();
|
|
|
- long notStandardSceneNum = taskList.stream()
|
|
|
- .filter(task1 -> sceneIdSet.contains(task1.getSceneId()) && task1.getScore() < 100)
|
|
|
- .count();
|
|
|
- double leafIndexScore = sum / resultNumberOfCurrentIndex;
|
|
|
+
|
|
|
+ long notStandardSceneNum = taskList.stream().filter(task1 -> sceneIdSet.contains(task1.getSceneId()) && task1.getScore() < 100).count();
|
|
|
+
|
|
|
+ double leafIndexScore = sum / resultNumberOfCurrentIndex;
|
|
|
+
|
|
|
indexTemplatePO.setTempScore(leafIndexScore);
|
|
|
TaskIndexPO leafTaskIndex = TaskIndexPO.builder()
|
|
|
.id(StringUtil.getRandomUUID())
|
|
@@ -151,14 +159,14 @@ public class TaskService {
|
|
|
leafTaskIndexList.add(leafTaskIndex);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
double totalScore = compute(leafIndexTemplateList);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
taskManager.batchUpdateByScoreResult(taskList);
|
|
|
-
|
|
|
+
|
|
|
taskIndexManager.batchInsertLeafIndex(leafTaskIndexList);
|
|
|
-
|
|
|
+
|
|
|
TaskIndexPO totalTaskIndex = TaskIndexPO.builder()
|
|
|
.id(StringUtil.getRandomUUID())
|
|
|
.pId(projectId)
|