lichunyang 1 jaar geleden
bovenliggende
commit
25f46366b4

+ 26 - 27
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneReferenceLibService.java

@@ -52,29 +52,6 @@ public class SceneReferenceLibService {
     private SystemScenePackageSublistMapper systemScenePackageSublistMapper;
 
 
-    public SceneEvaluationOperatePO getSceneEvaluationFirst(SceneReferenceLibParam params, List<String> sceneIdList) {
-        // 添加复杂度 危险度数据
-        SceneEvaluationForListParam sceneEvaluationForListParam = new SceneEvaluationForListParam();
-        BeanUtils.copyProperties(params, sceneEvaluationForListParam);
-        sceneEvaluationForListParam.setSceneIdList(sceneIdList);
-        return sceneEvaluationRuleService.getSceneEvaluationFirst(sceneEvaluationForListParam);
-    }
-
-    private void copyEvaluationParams(SceneReferenceLibParam params, SceneReferenceLibSelectParam po) {
-        po.setComplexityLevel(params.getComplexityLevel());
-        po.setMinComplexity(params.getMinComplexity());
-        po.setMaxComplexity(params.getMaxComplexity());
-        po.setRiskLevel(params.getRiskLevel());
-        po.setMinRisk(params.getMinRisk());
-        po.setMaxRisk(params.getMaxRisk());
-        if (StringUtil.isNotEmpty(params.getComplexityLevel()) || StringUtil.isNotEmpty(params.getMinComplexity()) || StringUtil.isNotEmpty(params.getMaxComplexity())) {
-            po.setNeedComplexity("1");
-        }
-        if (StringUtil.isNotEmpty(params.getRiskLevel()) || StringUtil.isNotEmpty(params.getMinRisk()) || StringUtil.isNotEmpty(params.getMaxRisk())) {
-            po.setNeedRisk("1");
-        }
-    }
-
     /**
      * 获取基准场景库列表
      *
@@ -84,7 +61,6 @@ public class SceneReferenceLibService {
     public List<SceneReferenceLibPO> querySceneReferenceLibList(SceneReferenceLibParam params) {
 
         SceneReferenceLibSelectParam srl = new SceneReferenceLibSelectParam();
-        copyEvaluationParams(params, srl);
         // 场景名称
         String sceneName = params.getSceneName();
         // 主车行为
@@ -147,7 +123,30 @@ public class SceneReferenceLibService {
 
         // 查询
         List<SceneReferenceLibPO> sceneReferenceLibPOS = sceneReferenceLibMapper.querySceneReferenceLibList(srl);
-        for (SceneReferenceLibPO po : sceneReferenceLibPOS) {
+
+
+        SceneEvaluationForListParam sceneEvaluationForListParam = new SceneEvaluationForListParam();
+        BeanUtils.copyProperties(params, sceneEvaluationForListParam);
+        sceneEvaluationForListParam.setSceneIdList(sceneReferenceLibPOS.stream().map(SceneReferenceLibPO::getSceneId).collect(Collectors.toList()));
+        SceneEvaluationOperatePO sceneEvaluationOperatePO = sceneEvaluationRuleService.getSceneEvaluationFirst(sceneEvaluationForListParam);
+        Map<String, SceneComplexityPO> complexityPOMap = sceneEvaluationOperatePO.getSceneComplexityPOMap();
+        Map<String, SceneRiskPO> riskPOMap = sceneEvaluationOperatePO.getSceneRiskPOMap();
+        // 筛选
+        List<SceneReferenceLibPO> finalSceneReferenceLibPOList = sceneReferenceLibPOS.stream()
+                .filter(srf -> sceneEvaluationRuleService.checkSelectReferenceComplexity(srf.getSceneId(), sceneEvaluationForListParam, complexityPOMap) &&
+                        sceneEvaluationRuleService.checkSelectReferenceRisk(srf.getSceneId(), sceneEvaluationForListParam, riskPOMap))
+                .collect(Collectors.toList());
+
+        for (SceneReferenceLibPO po : finalSceneReferenceLibPOList) {
+            // 赋值复杂度
+            if (complexityPOMap.get(po.getSceneId()) != null) {
+                po.setComplexity(String.valueOf(complexityPOMap.get(po.getSceneId()).getComplexity()));
+                po.setComplexityLevel(String.valueOf(complexityPOMap.get(po.getSceneId()).getComplexityLevel()));
+            }
+            if (riskPOMap.get(po.getSceneId()) != null) {
+                po.setRisk(String.valueOf(riskPOMap.get(po.getSceneId()).getRisk()));
+                po.setRiskLevel(String.valueOf(riskPOMap.get(po.getSceneId()).getRiskLevel()));
+            }
             if (po.getRoadType().equals("高速")) {
                 if (ObjectUtil.isNull(po.getLabel())) {
                     po.setLabel("高速");
@@ -185,7 +184,7 @@ public class SceneReferenceLibService {
             }
         }
 
-        return sceneReferenceLibPOS;
+        return finalSceneReferenceLibPOList;
     }
 
 
@@ -359,7 +358,7 @@ public class SceneReferenceLibService {
                         }
                     }
                     // 计算复杂度
-                    if (!StringUtils.isEmpty(params.getSceneEvaluationRuleId())) {
+                    if (CollectionUtil.isNotEmpty(paramList)) {
                         try {
                             sceneEvaluationRuleService.computeSceneReference(params, paramList);
                         } catch (Exception e) {