|
@@ -109,13 +109,15 @@ public class ManualProjectConsumer {
|
|
|
// 根据 packageId,拿到场景 id,然后获取每个场景的文件地址。
|
|
|
String packageId = projectMessageDTO.getScenePackageId();
|
|
|
List<IndexTemplatePO> leafIndexList = indexTemplateMapper.selectLeafIndexByPackageId(packageId);
|
|
|
- List<String> naturalIdList = new ArrayList<>();
|
|
|
- List<String> standardIdList = new ArrayList<>();
|
|
|
- List<String> accidentIdList = new ArrayList<>();
|
|
|
- for (IndexTemplatePO indexTemplatePO : leafIndexList) {
|
|
|
- String naturalIds = indexTemplatePO.getSceneNaturalIds();
|
|
|
- String standardIds = indexTemplatePO.getSceneStatueIds();
|
|
|
- String accidentIds = indexTemplatePO.getSceneTrafficIds();
|
|
|
+ log.info("------- ManualProjectConsumer 项目 " + projectId + " 的叶子指标为:" + leafIndexList);
|
|
|
+ List<ScenePO> sceneList = new ArrayList<>();
|
|
|
+ leafIndexList.forEach(leafIndex -> {
|
|
|
+ List<String> naturalIdList = new ArrayList<>();
|
|
|
+ List<String> standardIdList = new ArrayList<>();
|
|
|
+ List<String> accidentIdList = new ArrayList<>();
|
|
|
+ String naturalIds = leafIndex.getSceneNaturalIds();
|
|
|
+ String standardIds = leafIndex.getSceneStatueIds();
|
|
|
+ String accidentIds = leafIndex.getSceneTrafficIds();
|
|
|
if (StringUtil.isNotEmpty(naturalIds)) {
|
|
|
String[] naturalIdArray = naturalIds.split(",");
|
|
|
naturalIdList.addAll(Arrays.asList(naturalIdArray));
|
|
@@ -128,17 +130,17 @@ public class ManualProjectConsumer {
|
|
|
String[] accidentIdArray = accidentIds.split(",");
|
|
|
accidentIdList.addAll(Arrays.asList(accidentIdArray));
|
|
|
}
|
|
|
- }
|
|
|
- List<ScenePO> sceneList = new ArrayList<>();
|
|
|
- if (CollectionUtil.isNotEmpty(naturalIdList)) {
|
|
|
- sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
|
|
|
- }
|
|
|
- if (CollectionUtil.isNotEmpty(standardIdList)) {
|
|
|
- sceneList.addAll(sceneMapper.selectStandardByIdList(standardIdList));
|
|
|
- }
|
|
|
- if (CollectionUtil.isNotEmpty(accidentIdList)) {
|
|
|
- sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
|
|
|
- }
|
|
|
+ if (CollectionUtil.isNotEmpty(naturalIdList)) {
|
|
|
+ sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(standardIdList)) {
|
|
|
+ sceneList.addAll(sceneMapper.selectStandardByIdList(standardIdList));
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(accidentIdList)) {
|
|
|
+ sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
int taskNumber = sceneList.size();
|
|
|
log.info("------- ManualProjectConsumer 共有 " + taskNumber + " 个任务!");
|
|
|
projectMapper.updateTaskNumber(projectId, taskNumber);
|
|
@@ -255,28 +257,11 @@ public class ManualProjectConsumer {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- }else {// 重新执行任务
|
|
|
- taskIdList.forEach(taskId->{
|
|
|
+ } else {// 重新执行任务
|
|
|
+ taskIdList.forEach(taskId -> {
|
|
|
String resultPath = resultPathMinio + projectId + "/" + taskId;
|
|
|
String lastTargetId = taskMapper.selectLastTargetIdById(taskId);
|
|
|
- // 保存任务信息
|
|
|
- TaskPO taskPO = TaskPO.builder() // run_start_time 和 run_end_time 不填
|
|
|
- .id(taskId)
|
|
|
- .pId(projectId)
|
|
|
- .sceneId(sceneId)
|
|
|
- .lastTargetId(lastTargetId)
|
|
|
- .sceneName(scenePO.getName())
|
|
|
- .sceneType(scenePO.getType())
|
|
|
- .runState(DictConstants.TASK_PENDING)
|
|
|
- .runResultFilePath(resultPath)
|
|
|
- .build();
|
|
|
- taskPO.setCreateTime(TimeUtil.getNowForMysql());
|
|
|
- taskPO.setCreateUserId(USER_ID);
|
|
|
- taskPO.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
- taskPO.setModifyUserId(USER_ID);
|
|
|
- taskPO.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
- taskPO.setIsDeleted("0");
|
|
|
- taskMapper.insert(taskPO);
|
|
|
+ taskMapper.updateStateById(DictConstants.TASK_PENDING, taskId);
|
|
|
// 心跳信息存在緩存中
|
|
|
redisTemplate.opsForValue().set(manualProjectTopic + ":" + projectId + ":" + taskId, TimeUtil.getNowString());
|
|
|
// 组装 task 消息
|
|
@@ -409,17 +394,16 @@ public class ManualProjectConsumer {
|
|
|
LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
|
|
|
} else {
|
|
|
String minioPath = algorithmPO.getMinioPath();
|
|
|
-
|
|
|
if ("0".equals(algorithmPO.getDockerImport())) {
|
|
|
-
|
|
|
// 下载算法文件到本地( 2 到仓库服务器)
|
|
|
MinioUtil.downloadToFile(minioClient, bucketName, minioPath, algorithmTarLinuxTempPath);
|
|
|
//4-2 本地执行 docker load 算法文件成镜像(集群版可改成用 docker-java 操作仓库)
|
|
|
LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
|
|
|
+ algorithmMapper.updateDockerImportAndDockerImageById("1", dockerImage, algorithmId);
|
|
|
} else if ("1".equals(algorithmPO.getDockerImport()) && StringUtil.isNotEmpty(algorithmPO.getDockerImage())) {
|
|
|
dockerImage = algorithmPO.getDockerImage();
|
|
|
} else {
|
|
|
- throw new RuntimeException("算法 " + algorithmId + "的 mysql 数据有误!");
|
|
|
+ throw new RuntimeException("算法 " + algorithmId + " 的 mysql 数据有误!");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -435,13 +419,14 @@ public class ManualProjectConsumer {
|
|
|
String replace0 = yamlSource.replace("job-cloud-simulation", "project-" + projectId);
|
|
|
String replace1 = replace0.replace("vtd-container", "vtd-" + projectId);
|
|
|
String replace2 = replace1.replace("algorithm-container", "algorithm-" + projectId);
|
|
|
- String replace3 = replace2.replace("projectId", projectId);
|
|
|
- String replace4 = replace3.replace("completions-number", completions + "");
|
|
|
- String replace5 = replace4.replace("parallelism-number", parallelism + "");
|
|
|
- String replace6 = replace5.replace("apiVers1on", "apiVersion");
|
|
|
- String replace7 = replace6.replace("1atch/v1", "batch/v1");
|
|
|
- log.info("------- ManualProjectConsumer 开始执行 yaml 文件" + replace7);
|
|
|
- FileUtil.writeStringToLocalFile(replace7, jobTemplateYamlPathTarget);
|
|
|
+ String replace3 = replace1.replace("algorithm-image", dockerImage);
|
|
|
+ String replace4 = replace3.replace("projectId", projectId);
|
|
|
+ String replace5 = replace4.replace("completions-number", completions + "");
|
|
|
+ String replace6 = replace5.replace("parallelism-number", parallelism + "");
|
|
|
+ String replace7 = replace6.replace("apiVers1on", "apiVersion");
|
|
|
+ String replace8 = replace7.replace("1atch/v1", "batch/v1");
|
|
|
+ log.info("------- ManualProjectConsumer 开始执行 yaml 文件" + replace8);
|
|
|
+ FileUtil.writeStringToLocalFile(replace8, jobTemplateYamlPathTarget);
|
|
|
LinuxUtil.execute("kubectl apply -f " + jobTemplateYamlPathTarget);
|
|
|
}
|
|
|
|