|
@@ -47,6 +47,8 @@ public class TaskDomainService {
|
|
private String pyPath;
|
|
private String pyPath;
|
|
@Value("${scheduler.linux-path.temp}")
|
|
@Value("${scheduler.linux-path.temp}")
|
|
private String linuxTempPath;
|
|
private String linuxTempPath;
|
|
|
|
+ @Value("${scheduler.scene-evaluation.script}")
|
|
|
|
+ private String sceneEvaluationScript;
|
|
@Resource
|
|
@Resource
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
@Resource
|
|
@Resource
|
|
@@ -72,7 +74,15 @@ public class TaskDomainService {
|
|
@Resource
|
|
@Resource
|
|
private CustomConfiguration customConfiguration;
|
|
private CustomConfiguration customConfiguration;
|
|
@Resource
|
|
@Resource
|
|
- private ProjectApplicationService projectApplicationService;
|
|
|
|
|
|
+ private SceneEvaluationRuleMapper sceneEvaluationRuleMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private SceneComplexityMapper sceneComplexityMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private SceneRiskMapper sceneRiskMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private SceneMapper sceneMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private IndexTemplateMapper indexTemplateMapper;
|
|
|
|
|
|
public void batchInsertTask(List<TaskEntity> taskEntityList) {
|
|
public void batchInsertTask(List<TaskEntity> taskEntityList) {
|
|
try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
|
|
try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
|
|
@@ -120,7 +130,7 @@ public class TaskDomainService {
|
|
List<IndexTemplateEntity> leafIndexTemplateList = JsonUtil.jsonToList(leafIndexTemplateListJson, IndexTemplateEntity.class);
|
|
List<IndexTemplateEntity> leafIndexTemplateList = JsonUtil.jsonToList(leafIndexTemplateListJson, IndexTemplateEntity.class);
|
|
log.debug("共有 " + leafIndexTemplateList.size() + "个叶子节点:" + leafIndexTemplateListJson);
|
|
log.debug("共有 " + leafIndexTemplateList.size() + "个叶子节点:" + leafIndexTemplateListJson);
|
|
int maxLevel = 1; // 用于计算指标得分
|
|
int maxLevel = 1; // 用于计算指标得分
|
|
- List<SceneEntity> sceneEntityList = projectApplicationService.getSceneList(projectId, packageId);
|
|
|
|
|
|
+ List<SceneEntity> sceneEntityList = getSceneList(projectId, packageId);
|
|
Map<String, SceneEntity> sceneEntityMap = sceneEntityList.stream().collect(Collectors.toMap(SceneEntity::getId, Function.identity()));
|
|
Map<String, SceneEntity> sceneEntityMap = sceneEntityList.stream().collect(Collectors.toMap(SceneEntity::getId, Function.identity()));
|
|
List<LeafIndexEntity> leafIndexList = new ArrayList<>();
|
|
List<LeafIndexEntity> leafIndexList = new ArrayList<>();
|
|
for (int i = 0; i < leafIndexTemplateList.size(); i++) {
|
|
for (int i = 0; i < leafIndexTemplateList.size(); i++) {
|
|
@@ -320,6 +330,8 @@ public class TaskDomainService {
|
|
|
|
|
|
leafIndexList.add(leafIndex);
|
|
leafIndexList.add(leafIndex);
|
|
}
|
|
}
|
|
|
|
+ // 删除临时文件
|
|
|
|
+ FileUtil.rm(linuxTempPath + "scene/evaluation/" + projectId + "/"); // 删除临时文件
|
|
// 保存叶子指标得分
|
|
// 保存叶子指标得分
|
|
taskIndexRepository.batchInsertLeafIndex(leafIndexList);
|
|
taskIndexRepository.batchInsertLeafIndex(leafIndexList);
|
|
// 保存一级指标分数
|
|
// 保存一级指标分数
|
|
@@ -440,8 +452,7 @@ public class TaskDomainService {
|
|
public boolean computeSceneReference(SceneImportParam param, SceneEvaluationComputeParam sceneEvaluationComputeParam) {
|
|
public boolean computeSceneReference(SceneImportParam param, SceneEvaluationComputeParam sceneEvaluationComputeParam) {
|
|
String ruleId = param.getSceneEvaluationRuleId();
|
|
String ruleId = param.getSceneEvaluationRuleId();
|
|
// 获取场景评价规则
|
|
// 获取场景评价规则
|
|
-// SceneEvaluationRulePO sceneEvaluationRulePO = sceneEvaluationRuleMapper.querySceneEvaluationPyById(ruleId);
|
|
|
|
- SceneEvaluationRulePO sceneEvaluationRulePO = new SceneEvaluationRulePO();
|
|
|
|
|
|
+ SceneEvaluationRulePO sceneEvaluationRulePO = sceneEvaluationRuleMapper.querySceneEvaluationPyById(ruleId);
|
|
if (sceneEvaluationRulePO == null) {
|
|
if (sceneEvaluationRulePO == null) {
|
|
log.error(ruleId + " 的场景评价规则已删除");
|
|
log.error(ruleId + " 的场景评价规则已删除");
|
|
return false;
|
|
return false;
|
|
@@ -460,7 +471,7 @@ public class TaskDomainService {
|
|
"/scenario_evaluation_utils52.py"
|
|
"/scenario_evaluation_utils52.py"
|
|
);
|
|
);
|
|
for (String pyFilePath : scriptFilePath) {
|
|
for (String pyFilePath : scriptFilePath) {
|
|
-// MinioUtil.downloadToFile(minioClient, bucketName, sceneEvaluationScript + pyFilePath, scriptsPath + pyFilePath);
|
|
|
|
|
|
+ MinioUtil.downloadToFile(minioClient, bucketName, sceneEvaluationScript + pyFilePath, scriptsPath + pyFilePath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 下载场景评价脚本到脚本目录
|
|
// 下载场景评价脚本到脚本目录
|
|
@@ -550,7 +561,7 @@ public class TaskDomainService {
|
|
sceneComplexityPO.setIsDeleted(DictConstants.IS_NOT_DELETED);
|
|
sceneComplexityPO.setIsDeleted(DictConstants.IS_NOT_DELETED);
|
|
sceneComplexityPO.setCreateUserId(null);
|
|
sceneComplexityPO.setCreateUserId(null);
|
|
sceneComplexityPO.setCreateTime(TimeUtil.getNowForMysql());
|
|
sceneComplexityPO.setCreateTime(TimeUtil.getNowForMysql());
|
|
-// sceneComplexityMapper.saveSceneComplexity(sceneComplexityPO);
|
|
|
|
|
|
+ sceneComplexityMapper.saveSceneComplexity(sceneComplexityPO);
|
|
} else {
|
|
} else {
|
|
String risk = rootNode.path("危险度").asText();
|
|
String risk = rootNode.path("危险度").asText();
|
|
String riskLevel = rootNode.path("危险度等级").asText();
|
|
String riskLevel = rootNode.path("危险度等级").asText();
|
|
@@ -565,8 +576,52 @@ public class TaskDomainService {
|
|
sceneRiskPO.setIsDeleted(DictConstants.IS_NOT_DELETED);
|
|
sceneRiskPO.setIsDeleted(DictConstants.IS_NOT_DELETED);
|
|
sceneRiskPO.setCreateUserId(null);
|
|
sceneRiskPO.setCreateUserId(null);
|
|
sceneRiskPO.setCreateTime(TimeUtil.getNowForMysql());
|
|
sceneRiskPO.setCreateTime(TimeUtil.getNowForMysql());
|
|
-// sceneRiskMapper.saveSceneRisk(sceneRiskPO);
|
|
|
|
|
|
+ sceneRiskMapper.saveSceneRisk(sceneRiskPO);
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ public List<SceneEntity> getSceneList(String projectId, String packageId) {
|
|
|
|
+
|
|
|
|
+ String allIndexPrefix = "project:" + projectId + ":package:" + packageId + ":all";
|
|
|
|
+ String leafIndexPrefix = "project:" + projectId + ":package:" + packageId + ":leaf";
|
|
|
|
+ //1 查询该场景包的所有指标列表,包删了无所谓,但要过滤删掉的指标。并保存成 json 文件。
|
|
|
|
+ List<IndexTemplateEntity> allIndexList = indexTemplateMapper.selectByPackageIdIncludeDeleted(packageId);
|
|
|
|
+ stringRedisTemplate.opsForValue().set(allIndexPrefix, JsonUtil.listToJson(allIndexList));
|
|
|
|
+ //2 查询场景包叶子指标
|
|
|
|
+ List<IndexTemplateEntity> leafIndexList = allIndexList.stream().filter(index -> StringUtil.isNotEmpty(index.getRuleId())).collect(Collectors.toList());
|
|
|
|
+ log.info("项目 " + projectId + " 的叶子指标为:" + leafIndexList);
|
|
|
|
+ stringRedisTemplate.opsForValue().set(leafIndexPrefix, JsonUtil.listToJson(leafIndexList));
|
|
|
|
+ List<SceneEntity> sceneList = new ArrayList<>();
|
|
|
|
+ leafIndexList.forEach(leafIndex -> {
|
|
|
|
+ String naturalIds = leafIndex.getSceneNaturalIds();
|
|
|
|
+ String standardIds = leafIndex.getSceneStatueIds();
|
|
|
|
+ String accidentIds = leafIndex.getSceneTrafficIds();
|
|
|
|
+ String generalizationIds = leafIndex.getSceneGeneralizationIds();
|
|
|
|
+ String sceneReferenceIds = leafIndex.getSceneReferenceLibIds();
|
|
|
|
+ if (StringUtil.isNotEmpty(naturalIds)) {
|
|
|
|
+ List<String> naturalIdList = new ArrayList<>(Arrays.asList(naturalIds.split(",")));
|
|
|
|
+ sceneList.addAll(sceneMapper.selectNaturalByIdList(naturalIdList));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotEmpty(standardIds)) {
|
|
|
|
+ List<String> standardIdList = new ArrayList<>(Arrays.asList(standardIds.split(",")));
|
|
|
|
+ sceneList.addAll(sceneMapper.selectStandardByIdList(standardIdList));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotEmpty(accidentIds)) {
|
|
|
|
+ List<String> accidentIdList = new ArrayList<>(Arrays.asList(accidentIds.split(",")));
|
|
|
|
+ sceneList.addAll(sceneMapper.selectAccidentByIdList(accidentIdList));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotEmpty(generalizationIds)) {
|
|
|
|
+ List<String> generalizationIdList = new ArrayList<>(Arrays.asList(generalizationIds.split(",")));
|
|
|
|
+ sceneList.addAll(sceneMapper.selectGeneralizationByIdList(generalizationIdList));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotEmpty(sceneReferenceIds)) {
|
|
|
|
+ List<String> sceneReferenceIdList = new ArrayList<>(Arrays.asList(sceneReferenceIds.split(",")));
|
|
|
|
+ sceneList.addAll(sceneMapper.selectReferenceLibByIdList(sceneReferenceIdList));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ log.info("项目" + projectId + " 共有 " + sceneList.size() + " 个任务:" + sceneList);
|
|
|
|
+ return sceneList;
|
|
|
|
+ }
|
|
}
|
|
}
|