|
@@ -1,18 +1,13 @@
|
|
package com.css.simulation.resource.server.app.service;
|
|
package com.css.simulation.resource.server.app.service;
|
|
|
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.constants.DictConstants;
|
|
|
|
+import api.common.pojo.constants.LogConstants;
|
|
import api.common.pojo.param.MinioParameter;
|
|
import api.common.pojo.param.MinioParameter;
|
|
-import api.common.pojo.param.scene.SceneImportParam;
|
|
|
|
-import api.common.pojo.param.scene.SceneReferenceLibParam;
|
|
|
|
-import api.common.pojo.param.scene.SceneReferenceLibSelectParam;
|
|
|
|
-import api.common.pojo.po.scene.SceneComplexityPO;
|
|
|
|
-import api.common.pojo.po.scene.SceneReferenceLibPO;
|
|
|
|
-import api.common.pojo.po.scene.SceneRiskPO;
|
|
|
|
|
|
+import api.common.pojo.param.scene.*;
|
|
|
|
+import api.common.pojo.po.scene.*;
|
|
import api.common.pojo.po.system.SceneImportPO;
|
|
import api.common.pojo.po.system.SceneImportPO;
|
|
import api.common.util.*;
|
|
import api.common.util.*;
|
|
-import com.css.simulation.resource.server.infra.db.mysql.mapper.SceneComplexityMapper;
|
|
|
|
-import com.css.simulation.resource.server.infra.db.mysql.mapper.SceneReferenceLibMapper;
|
|
|
|
-import com.css.simulation.resource.server.infra.db.mysql.mapper.SceneRiskMapper;
|
|
|
|
|
|
+import com.css.simulation.resource.server.infra.db.mysql.mapper.*;
|
|
import com.css.simulation.resource.server.infra.feign.service.FileDownService;
|
|
import com.css.simulation.resource.server.infra.feign.service.FileDownService;
|
|
import com.css.simulation.resource.server.infra.util.AuthUtil;
|
|
import com.css.simulation.resource.server.infra.util.AuthUtil;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
@@ -20,13 +15,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import feign.Response;
|
|
import feign.Response;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.function.Function;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -40,10 +35,20 @@ public class SceneReferenceLibService {
|
|
private FileDownService fileDownService;
|
|
private FileDownService fileDownService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private SceneComplexityMapper sceneComplexityMapper;
|
|
|
|
|
|
+ private SceneEvaluationRuleService sceneEvaluationRuleService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private SceneRiskMapper sceneRiskMapper;
|
|
|
|
|
|
+ private ScenePackageSublistMapper scenePackageSublistMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ScenePackageMapper scenePackageMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private LogService logService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SystemScenePackageSublistMapper systemScenePackageSublistMapper;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取基准场景库列表
|
|
* 获取基准场景库列表
|
|
@@ -117,27 +122,17 @@ public class SceneReferenceLibService {
|
|
// 查询
|
|
// 查询
|
|
List<SceneReferenceLibPO> sceneReferenceLibPOS = sceneReferenceLibMapper.querySceneReferenceLibList(srl);
|
|
List<SceneReferenceLibPO> sceneReferenceLibPOS = sceneReferenceLibMapper.querySceneReferenceLibList(srl);
|
|
|
|
|
|
- SceneComplexityPO sceneComplexityPO = new SceneComplexityPO();
|
|
|
|
- sceneComplexityPO.setMinComplexity(params.getMinComplexity());
|
|
|
|
- sceneComplexityPO.setMaxComplexity(params.getMaxComplexity());
|
|
|
|
- sceneComplexityPO.setComplexityLevel(params.getComplexityLevel());
|
|
|
|
- // 查询复杂度的符合条件的第一条数据
|
|
|
|
- List<SceneComplexityPO> sceneReferenceLibCSPOS = sceneComplexityMapper.selectSceneIdsByEvaluation(sceneComplexityPO);
|
|
|
|
- Map<String, SceneComplexityPO> complexityPOMap = sceneReferenceLibCSPOS.stream().collect(Collectors.toMap(SceneComplexityPO::getSceneId, Function.identity()));
|
|
|
|
- SceneRiskPO sceneRiskPO = new SceneRiskPO();
|
|
|
|
- sceneRiskPO.setMaxRisk(params.getMaxRisk());
|
|
|
|
- sceneRiskPO.setMinRisk(params.getMinRisk());
|
|
|
|
- sceneRiskPO.setRiskLevel(params.getRiskLevel());
|
|
|
|
- // 查询复杂度的符合条件的第一条数据
|
|
|
|
- List<SceneRiskPO> sceneReferenceLibCRPOS = sceneRiskMapper.selectSceneIdsByEvaluation(sceneRiskPO);
|
|
|
|
- Map<String, SceneRiskPO> riskPOMap = sceneReferenceLibCRPOS.stream().collect(Collectors.toMap(SceneRiskPO::getSceneId, Function.identity()));
|
|
|
|
|
|
|
|
|
|
+ SceneEvaluationForListParam sceneEvaluationForListParam = new SceneEvaluationForListParam();
|
|
|
|
+ BeanUtils.copyProperties(params, sceneEvaluationForListParam);
|
|
|
|
+ SceneEvaluationOperatePO sceneEvaluationOperatePO = sceneEvaluationRuleService.getSceneEvaluationFirst(sceneEvaluationForListParam);
|
|
|
|
+ Map<String, SceneComplexityPO> complexityPOMap = sceneEvaluationOperatePO.getSceneComplexityPOMap();
|
|
|
|
+ Map<String, SceneRiskPO> riskPOMap = sceneEvaluationOperatePO.getSceneRiskPOMap();
|
|
// 筛选
|
|
// 筛选
|
|
List<SceneReferenceLibPO> finalSceneReferenceLibPOList = sceneReferenceLibPOS.stream()
|
|
List<SceneReferenceLibPO> finalSceneReferenceLibPOList = sceneReferenceLibPOS.stream()
|
|
.filter(srf -> complexityPOMap.get(srf.getSceneId()) != null && riskPOMap.get(srf.getSceneId()) != null)
|
|
.filter(srf -> complexityPOMap.get(srf.getSceneId()) != null && riskPOMap.get(srf.getSceneId()) != null)
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
-
|
|
|
|
for (SceneReferenceLibPO po : finalSceneReferenceLibPOList) {
|
|
for (SceneReferenceLibPO po : finalSceneReferenceLibPOList) {
|
|
// 赋值复杂度
|
|
// 赋值复杂度
|
|
po.setComplexity(String.valueOf(complexityPOMap.get(po.getSceneId()).getComplexity()));
|
|
po.setComplexity(String.valueOf(complexityPOMap.get(po.getSceneId()).getComplexity()));
|
|
@@ -330,5 +325,110 @@ public class SceneReferenceLibService {
|
|
LogUtil.update();
|
|
LogUtil.update();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ public void batchDeleteSceneReference(List<String> sceneNames) {
|
|
|
|
+ batchDeleteSceneReferenceBySceneId(sceneNames);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ public void batchDeleteSceneReferenceBySceneId(List<String> sceneNames) {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ try {
|
|
|
|
+ //* -------------------------------- 场景表 --------------------------------
|
|
|
|
+ // 1 根据场景名称查询出同名的所有场景名称
|
|
|
|
+ List<String> sceneIds = sceneReferenceLibMapper.selectIdsByNames(sceneNames);
|
|
|
|
+ if (CollectionUtil.isEmpty(sceneIds)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 2 删除场景数据
|
|
|
|
+ SceneDeleteParam sceneDeleteParam = SceneDeleteParam.builder()
|
|
|
|
+ .sceneNames(sceneNames)
|
|
|
|
+ .modifyTime(TimeUtil.getNowForMysql())
|
|
|
|
+ .modifyUserId(AuthUtil.getCreateUserId())
|
|
|
|
+ .build();
|
|
|
|
+ sceneReferenceLibMapper.deleteBySceneNames(sceneDeleteParam);
|
|
|
|
+ //* -------------------------------- 场景测试包指标表 & 场景测试包表 --------------------------------
|
|
|
|
+ // 1 根据自然驾驶场景ID查询场景测试包指标
|
|
|
|
+ List<ScenePackageSublistPO> indexes = scenePackageSublistMapper.selectBySceneIds(ScenePackageSublistParam.builder()
|
|
|
|
+ .sceneIds(sceneIds)
|
|
|
|
+ .sceneType(DictConstants.SCENE_REFERENCE_LIB)
|
|
|
|
+ .build());
|
|
|
|
+ if (CollectionUtil.isEmpty(indexes)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 2 根据指标 ID 查询场景测试包
|
|
|
|
+ List<ScenePackagePO> testPackages = scenePackageMapper.selectByIndexIds(ScenePackageParam.builder()
|
|
|
|
+ .indexIds(indexes.stream().map(ScenePackageSublistPO::getSublistId).collect(Collectors.toList()))
|
|
|
|
+ .build());
|
|
|
|
+ // 3 设置包为已禁用
|
|
|
|
+ testPackages.forEach(testPackage -> testPackage.setIsUnavailable(DictConstants.IS_UNAVAILABLE));
|
|
|
|
+ // 4 遍历删除场景
|
|
|
|
+ AtomicInteger deleteNum = new AtomicInteger();
|
|
|
|
+ indexes.forEach(index -> {
|
|
|
|
+ final String sceneReferenceLibIdsStr = index.getSceneReferenceLibIds();
|
|
|
|
+ List<String> sceneReferenceLibIds = new ArrayList<>();
|
|
|
|
+ if (StringUtil.isNotEmpty(sceneReferenceLibIdsStr)) {
|
|
|
|
+ sceneReferenceLibIds = CollectionUtil.sequenceStringToList(sceneReferenceLibIdsStr, ",");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ final String sceneNaturalIdsString = index.getSceneReferenceLibIds();
|
|
|
|
+ List<String> sceneNaturalIds = new ArrayList<>();
|
|
|
|
+ if (StringUtil.isNotEmpty(sceneNaturalIdsString)) {
|
|
|
|
+ sceneNaturalIds = CollectionUtil.sequenceStringToList(sceneNaturalIdsString, ",");
|
|
|
|
+ }
|
|
|
|
+ final String sceneTrafficIdsString = index.getSceneTrafficIds();
|
|
|
|
+ List<String> sceneTrafficIds = new ArrayList<>();
|
|
|
|
+ if (StringUtil.isNotEmpty(sceneTrafficIdsString)) {
|
|
|
|
+ sceneTrafficIds = CollectionUtil.sequenceStringToList(sceneTrafficIdsString, ",");
|
|
|
|
+ }
|
|
|
|
+ final String sceneStatueIdsString = index.getSceneStatueIds();
|
|
|
|
+ List<String> sceneStatueIds = new ArrayList<>();
|
|
|
|
+ if (StringUtil.isNotEmpty(sceneStatueIdsString)) {
|
|
|
|
+ sceneStatueIds = CollectionUtil.sequenceStringToList(sceneStatueIdsString, ",");
|
|
|
|
+ }
|
|
|
|
+ final String sceneGeneralizationIdsString = index.getSceneGeneralizationIds();
|
|
|
|
+ List<String> sceneGeneralizationIds = new ArrayList<>();
|
|
|
|
+ if (StringUtil.isNotEmpty(sceneGeneralizationIdsString)) {
|
|
|
|
+ sceneGeneralizationIds = CollectionUtil.sequenceStringToList(sceneGeneralizationIdsString, ",");
|
|
|
|
+ }
|
|
|
|
+ final Iterator<String> iterator = sceneReferenceLibIds.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ final String sceneId = iterator.next();
|
|
|
|
+ if (sceneIds.contains(sceneId)) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ deleteNum.getAndIncrement();
|
|
|
|
+ testPackages.forEach(testPackage ->
|
|
|
|
+ testPackage.setSceneNum(testPackage.getSceneNum() - 1)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+// index.setSceneNum(sceneReferenceLibIds.size() + sceneNaturalIds.size() + sceneTrafficIds.size() +
|
|
|
|
+// sceneStatueIds.size() + sceneGeneralizationIds.size());
|
|
|
|
+ index.setSceneNum(index.getSceneNum() - deleteNum.get());
|
|
|
|
+ index.setSceneReferenceLibIds(CollectionUtil.listToSequence(sceneReferenceLibIds));
|
|
|
|
+ index.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
|
+ index.setModifyUserId(AuthUtil.getCurrentUserId());
|
|
|
|
+ });
|
|
|
|
+ // 5 更新指标
|
|
|
|
+ scenePackageSublistMapper.update(indexes);
|
|
|
|
+ // 6 更新包
|
|
|
|
+ scenePackageMapper.update(testPackages);
|
|
|
|
+
|
|
|
|
+ //* -------------------------------- 场景包表 --------------------------------
|
|
|
|
+ // 1 将所有场景包中的该场景删除
|
|
|
|
+ systemScenePackageSublistMapper.deleteBySceneNames(SystemScenePackageParam.builder()
|
|
|
|
+ .sceneNames(sceneNames)
|
|
|
|
+ .modifyTime(TimeUtil.getNowForMysql())
|
|
|
|
+ .modifyUserId(AuthUtil.getCurrentUserId())
|
|
|
|
+ .build());
|
|
|
|
+ } finally {
|
|
|
|
+ //* -------------------------------- 日志表 --------------------------------
|
|
|
|
+ map.put("sceneNames", JsonUtil.listToJson(sceneNames));
|
|
|
|
+ map.put("type", DictConstants.SCENE_NATURAL);
|
|
|
|
+ logService.logSceneDelete(LogConstants.SYS_LOG_SCENE_DELETE, map);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|