李春阳 hai 1 ano
pai
achega
c239adf25e
Modificáronse 30 ficheiros con 636 adicións e 145 borrados
  1. 9 0
      api-common/src/main/java/api/common/pojo/param/project/SimulationManualProjectParam.java
  2. 20 0
      api-common/src/main/java/api/common/pojo/param/scene/SceneEvaluationDetailParam.java
  3. 29 0
      api-common/src/main/java/api/common/pojo/param/scene/SceneEvaluationForListParam.java
  4. 1 1
      api-common/src/main/java/api/common/pojo/param/scene/SceneReferenceLibParam.java
  5. 9 0
      api-common/src/main/java/api/common/pojo/po/project/SimulationManualProjectPO.java
  6. 8 8
      api-common/src/main/java/api/common/pojo/po/scene/SceneAccidentPO.java
  7. 19 0
      api-common/src/main/java/api/common/pojo/po/scene/SceneEvaluationOperatePO.java
  8. 8 9
      api-common/src/main/java/api/common/pojo/po/scene/SceneGeneralTemplatePO.java
  9. 8 0
      api-common/src/main/java/api/common/pojo/po/scene/SceneNaturalPO.java
  10. 2 0
      api-common/src/main/java/api/common/pojo/po/scene/ScenePackageSublistPO.java
  11. 8 10
      api-common/src/main/java/api/common/pojo/po/scene/StandardsRegulationsPO.java
  12. 24 0
      api-common/src/main/java/api/common/pojo/vo/scene/SceneComplexityVO.java
  13. 2 0
      api-common/src/main/java/api/common/pojo/vo/scene/ScenePackageSublistVO.java
  14. 28 0
      api-common/src/main/java/api/common/pojo/vo/scene/SceneRiskVO.java
  15. 15 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/scene_library/scene_reference_lib/SceneReferenceLibController.java
  16. 52 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/scene_library/score_rule/ScoreRuleController.java
  17. 4 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/impl/SimulationProjectServiceImpl.java
  18. 29 6
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneAccidentService.java
  19. 29 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneEvaluationRuleService.java
  20. 39 19
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneGeneralTemplateService.java
  21. 29 6
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneNaturalService.java
  22. 130 30
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneReferenceLibService.java
  23. 29 5
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneStandardsService.java
  24. 3 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/SceneReferenceLibMapper.java
  25. 1 1
      simulation-resource-server/src/main/resources/mysql/mapper/SceneComplexityMapper.xml
  26. 1 1
      simulation-resource-server/src/main/resources/mysql/mapper/SceneEvaluationRuleMapper.xml
  27. 5 0
      simulation-resource-server/src/main/resources/mysql/mapper/ScenePackageSublistMapper.xml
  28. 42 43
      simulation-resource-server/src/main/resources/mysql/mapper/SceneReferenceLibMapper.xml
  29. 42 0
      simulation-resource-server/src/main/resources/mysql/mapper/SceneRiskMapper.xml
  30. 11 2
      simulation-resource-server/src/main/resources/mysql/mapper/SimulationManualProjectMapper.xml

+ 9 - 0
api-common/src/main/java/api/common/pojo/param/project/SimulationManualProjectParam.java

@@ -57,6 +57,15 @@ public class SimulationManualProjectParam extends PageVO {
     private String parentId;    //父级项目id
     private String projectType; //项目类型 1.手动;2.自动
 
+    // 复杂度规则
+    private String complexityEvaluationRuleId;
+    // 危险度
+    private String riskEvaluationRuleId;
+    // 暴露率
+    private String exposureRateEvaluationRuleId;
+    // 覆盖率
+    private String coverageRateEvaluationRuleId;
+
     //算法数组(公私有)
     private String[] algorithmArrayS;
     //车辆模型数组(公私有)

+ 20 - 0
api-common/src/main/java/api/common/pojo/param/scene/SceneEvaluationDetailParam.java

@@ -0,0 +1,20 @@
+package api.common.pojo.param.scene;
+
+import api.common.pojo.common.PageVO;
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 基准场景库前端传参
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneEvaluationDetailParam extends PageVO implements Serializable {
+
+    // 主键 id (uuid)
+    private String sceneId;
+}

+ 29 - 0
api-common/src/main/java/api/common/pojo/param/scene/SceneEvaluationForListParam.java

@@ -0,0 +1,29 @@
+package api.common.pojo.param.scene;
+
+import api.common.pojo.common.PageVO;
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 查询各种场景的列表页时的场景评价传参
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneEvaluationForListParam extends PageVO implements Serializable {
+    // 复杂度下限
+    private Integer minComplexity;
+    // 复杂度上限
+    private Integer maxComplexity;
+    // 危险度下限
+    private Integer minRisk;
+    // 危险度上限
+    private Integer maxRisk;
+    // 复杂度等级
+    private Integer complexityLevel;
+    // 危险度等级
+    private Integer riskLevel;
+}

+ 1 - 1
api-common/src/main/java/api/common/pojo/param/scene/SceneReferenceLibParam.java

@@ -55,7 +55,7 @@ public class SceneReferenceLibParam extends PageVO implements Serializable {
     // 供场景上传任务删除使用
     private List<String> sceneNames;
     // 用于批量删除的名称列表
-    private List<String> sceneNameList;
+    private List<String> sceneIdList;
     private String[] ids; //回显数组
     private List<String> AllIds; //权限集合
     private String userId;

+ 9 - 0
api-common/src/main/java/api/common/pojo/po/project/SimulationManualProjectPO.java

@@ -41,4 +41,13 @@ public class SimulationManualProjectPO extends BasePO {
     private String sceneArray;  //场景测试包数组(公私有)
     private String newId;  // 用于重新运行时修改项目id
 
+    // 复杂度规则
+    private String complexityEvaluationRuleId;
+    // 危险度
+    private String riskEvaluationRuleId;
+    // 暴露率
+    private String exposureRateEvaluationRuleId;
+    // 覆盖率
+    private String coverageRateEvaluationRuleId;
+
 }

+ 8 - 8
api-common/src/main/java/api/common/pojo/po/scene/SceneAccidentPO.java

@@ -42,14 +42,14 @@ public class SceneAccidentPO implements Serializable {
     public String modifyUserId; //记录最后更新人(包括删除)(用户id)
     public String isDeleted; //是否已删除
 
-
-
-
-
-
-
-
-
+    // 复杂度
+    private String complexity;
+    // 危险度
+    private String risk;
+    // 复杂度等级
+    private String complexityLevel;
+    // 危险度等级
+    private String riskLevel;
 
 
 

+ 19 - 0
api-common/src/main/java/api/common/pojo/po/scene/SceneEvaluationOperatePO.java

@@ -0,0 +1,19 @@
+package api.common.pojo.po.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * 复杂度数据
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneEvaluationOperatePO implements Serializable {
+    private Map<String, SceneComplexityPO> sceneComplexityPOMap;
+    private Map<String, SceneRiskPO>  sceneRiskPOMap;
+}

+ 8 - 9
api-common/src/main/java/api/common/pojo/po/scene/SceneGeneralTemplatePO.java

@@ -80,15 +80,14 @@ public class SceneGeneralTemplatePO implements Serializable {
      */
     public String isDeleted;
 
-
-
-
-
-
-
-
-
-
+    // 复杂度
+    private String complexity;
+    // 危险度
+    private String risk;
+    // 复杂度等级
+    private String complexityLevel;
+    // 危险度等级
+    private String riskLevel;
 
 
 }

+ 8 - 0
api-common/src/main/java/api/common/pojo/po/scene/SceneNaturalPO.java

@@ -70,5 +70,13 @@ public class SceneNaturalPO implements Serializable {
     public String modifyUserId; //记录最后更新人(包括删除)(用户id)
     public String isDeleted;    //是否已删除
 
+    // 复杂度
+    private String complexity;
+    // 危险度
+    private String risk;
+    // 复杂度等级
+    private String complexityLevel;
+    // 危险度等级
+    private String riskLevel;
 
 }

+ 2 - 0
api-common/src/main/java/api/common/pojo/po/scene/ScenePackageSublistPO.java

@@ -25,6 +25,8 @@ public class ScenePackageSublistPO implements Serializable {
     private String sceneTrafficIds;//关联交通事故场景ids
     private String sceneStatueIds;//关联标准法规ids
     private String sceneGeneralizationIds;//关联泛化场景ids
+    // 关联基准场景库 Ids
+    private String sceneReferenceLibIds;
 
     private Integer sceneNum;//场景数量
     private String parentId;//父节点id

+ 8 - 10
api-common/src/main/java/api/common/pojo/po/scene/StandardsRegulationsPO.java

@@ -36,15 +36,13 @@ public class StandardsRegulationsPO implements Serializable {
     public String modifyUserId; //记录最后更新人(包括删除)(用户id)
     public String isDeleted;    //是否已删除
 
-
-
-
-
-
-
-
-
-
-
+    // 复杂度
+    private String complexity;
+    // 危险度
+    private String risk;
+    // 复杂度等级
+    private String complexityLevel;
+    // 危险度等级
+    private String riskLevel;
 
 }

+ 24 - 0
api-common/src/main/java/api/common/pojo/vo/scene/SceneComplexityVO.java

@@ -0,0 +1,24 @@
+package api.common.pojo.vo.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 复杂度数据
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneComplexityVO implements Serializable {
+    private String riskId;
+    private String sceneId;
+    private String sceneType;
+    private String ruleId;
+    private String taskId;
+    private String ruleName;
+    private Integer complexity;
+    private Integer complexityLevel;
+}

+ 2 - 0
api-common/src/main/java/api/common/pojo/vo/scene/ScenePackageSublistVO.java

@@ -24,6 +24,8 @@ public class ScenePackageSublistVO implements Serializable {
     private String sceneTrafficIds;//关联交通事故场景ids
     private String sceneStatueIds;//关联标准法规ids
     private String sceneGeneralizationIds;//关联泛化场景ids
+    // 基准场景库 id
+    private String sceneReferenceLibIds;
     private Integer sceneNum=0;//场景数量
     private String parentId;//父节点id
     private String rootId;//根id

+ 28 - 0
api-common/src/main/java/api/common/pojo/vo/scene/SceneRiskVO.java

@@ -0,0 +1,28 @@
+package api.common.pojo.vo.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 复杂度数据
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneRiskVO implements Serializable {
+    private String riskId;
+    private String sceneId;
+    private String sceneType;
+    private String ruleId;
+    private String ruleName;
+    private String algorithmId;
+    private String algorithmName;
+    private String vehicleId;
+    private String vehicleName;
+    private String taskId;
+    private Integer risk;
+    private Integer riskLevel;
+}

+ 15 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/scene_library/scene_reference_lib/SceneReferenceLibController.java

@@ -7,9 +7,11 @@ import api.common.pojo.param.scene.SceneReferenceLibParam;
 import api.common.pojo.po.scene.SceneReferenceLibPO;
 import api.common.pojo.po.system.SceneImportPO;
 import api.common.pojo.vo.scene.SceneReferenceLibVO;
+import api.common.util.CollectionUtil;
 import api.common.util.ObjectUtil;
 import com.css.simulation.resource.server.app.service.SceneImportService;
 import com.css.simulation.resource.server.app.service.SceneReferenceLibService;
+import com.css.simulation.resource.server.infra.util.AuthUtil;
 import com.css.simulation.resource.server.infra.util.PageUtil;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.BeanUtils;
@@ -87,4 +89,17 @@ public class SceneReferenceLibController {
     }
 
 
+    @PostMapping("/batchDeleteSceneReference")
+    public ResponseBodyVO<String> batchDeleteSceneReference(@RequestBody SceneReferenceLibParam params) {
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        if (!DictConstants.ROLE_CODE_ADMIN.equals(roleCode) && !DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "非管理员禁止删除");
+        }
+        if(CollectionUtil.isEmpty(params.getSceneNames())){
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        }
+        sceneReferenceLibService.batchDeleteSceneReference(params.getSceneNames());
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+    }
+
 }

+ 52 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/scene_library/score_rule/ScoreRuleController.java

@@ -3,11 +3,16 @@ package com.css.simulation.resource.server.adapter.controller.scene_library.scor
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.constants.DictConstants;
 import api.common.pojo.constants.LogConstants;
+import api.common.pojo.param.scene.SceneEvaluationDetailParam;
 import api.common.pojo.param.scene.SceneEvaluationRuleParam;
 import api.common.pojo.param.scene.ScoringRulesParam;
+import api.common.pojo.po.scene.SceneComplexityPO;
 import api.common.pojo.po.scene.SceneEvaluationRulePO;
+import api.common.pojo.po.scene.SceneRiskPO;
 import api.common.pojo.po.scene.ScoringRulesPO;
+import api.common.pojo.vo.scene.SceneComplexityVO;
 import api.common.pojo.vo.scene.SceneEvaluationRuleVO;
+import api.common.pojo.vo.scene.SceneRiskVO;
 import api.common.pojo.vo.scene.ScoringRulesVO;
 import api.common.util.ObjectUtil;
 import api.common.util.PythonUtil;
@@ -237,4 +242,51 @@ public class ScoreRuleController {
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
     }
 
+    /**
+     * 查询复杂度详情
+     */
+    @PostMapping("/querySceneEvaluationRiskDetail")
+    public ResponseBodyVO<PageInfo<SceneRiskVO>> querySceneEvaluationRiskDetail(@RequestBody SceneEvaluationDetailParam params) {
+        if (StringUtil.isEmpty(params.getSceneId())) {
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "请输入 sceneId");
+        }
+        PageUtil.setPageInfo(params);
+        List<SceneRiskPO> list = sceneEvaluationRuleService.querySceneEvaluationRiskDetail(params);
+        PageInfo<SceneRiskPO> sceneRiskPOPageInfo = new PageInfo<>(list);
+        List<SceneRiskVO> list1 = new ArrayList<>();
+        // po 转 vo
+        for (SceneRiskPO po : list) {
+            SceneRiskVO vo = new SceneRiskVO();
+            BeanUtils.copyProperties(po, vo);
+            list1.add(vo);
+        }
+        PageInfo<SceneRiskVO> pageInfo = new PageInfo<>(list1);
+        pageInfo.setTotal(sceneRiskPOPageInfo.getTotal());
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, pageInfo);
+    }
+
+    /**
+     * 查询危险度详情
+     */
+    @PostMapping("/querySceneEvaluationComplexityDetail")
+    public ResponseBodyVO<PageInfo<SceneComplexityVO>> querySceneEvaluationComplexityDetail(@RequestBody SceneEvaluationDetailParam params) {
+        if (StringUtil.isEmpty(params.getSceneId())) {
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "请输入 sceneId");
+        }
+        PageUtil.setPageInfo(params);
+        List<SceneComplexityPO> list = sceneEvaluationRuleService.querySceneEvaluationComplexityDetail(params);
+        PageInfo<SceneComplexityPO> sceneComplexityPOPageInfo = new PageInfo<>(list);
+        List<SceneComplexityVO> list1 = new ArrayList<>();
+        // po 转 vo
+        for (SceneComplexityPO po : list) {
+            SceneComplexityVO vo = new SceneComplexityVO();
+            BeanUtils.copyProperties(po, vo);
+            list1.add(vo);
+        }
+        PageInfo<SceneComplexityVO> pageInfo = new PageInfo<>(list1);
+        pageInfo.setTotal(sceneComplexityPOPageInfo.getTotal());
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, pageInfo);
+    }
+
+
 }

+ 4 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/impl/SimulationProjectServiceImpl.java

@@ -1734,6 +1734,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         po.setIsChoiceGpu(param.getIsChoiceGpu());
         po.setNowRunState(param.getNowRunState());
         po.setAlgorithmType(param.getAlgorithmType());
+        po.setComplexityEvaluationRuleId(param.getComplexityEvaluationRuleId());
+        po.setRiskEvaluationRuleId(param.getRiskEvaluationRuleId());
+        po.setExposureRateEvaluationRuleId(param.getExposureRateEvaluationRuleId());
+        po.setCoverageRateEvaluationRuleId(param.getCoverageRateEvaluationRuleId());
 
         if (ObjectUtil.isNotNull(param.getVehicleArrayS())) {
             po.setVehicleArray(StringUtils.join(Arrays.asList(param.getVehicleArrayS()), ','));

+ 29 - 6
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneAccidentService.java

@@ -5,9 +5,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.scene.*;
-import api.common.pojo.po.scene.SceneAccidentPO;
-import api.common.pojo.po.scene.ScenePackagePO;
-import api.common.pojo.po.scene.ScenePackageSublistPO;
+import api.common.pojo.po.scene.*;
 import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.*;
 import com.css.simulation.resource.server.infra.util.AuthUtil;
@@ -21,11 +19,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import feign.Response;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -45,6 +45,9 @@ public class SceneAccidentService {
     @Resource
     private LogService logService;
 
+    @Resource
+    private SceneEvaluationRuleService sceneEvaluationRuleService;
+
     /**
      * 获取交通事故场景数据:
      */
@@ -220,6 +223,18 @@ public class SceneAccidentService {
 
         }
 
+
+        // 添加复杂度 危险度数据
+        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<SceneAccidentPO> sceneAccidentPOS = list.stream()
+                .filter(sn -> complexityPOMap.get(sn.getAccidentId()) != null && riskPOMap.get(sn.getAccidentId()) != null)
+                .collect(Collectors.toList());
+
      /*   if ((params.getXlk().equals("1") && params.getBq().equals(1)) || (params.getXlk().equals("0") && params.getBq().equals(0)) || (params.getXlk().equals("1") && params.getBq().equals(0))) {
             list = sceneAccidentMapper.querySceneAccidentList(params);
         }*//*else if(params.getXlk().equals("1")&&params.getBq().equals("0")){
@@ -284,7 +299,12 @@ public class SceneAccidentService {
             params.setAllIds(listA);
         }*/
 
-        for (SceneAccidentPO po : list) {
+        for (SceneAccidentPO po : sceneAccidentPOS) {
+            // 赋值复杂度
+            po.setComplexity(String.valueOf(complexityPOMap.get(po.getAccidentId()).getComplexity()));
+            po.setComplexityLevel(String.valueOf(complexityPOMap.get(po.getAccidentId()).getComplexityLevel()));
+            po.setRisk(String.valueOf(riskPOMap.get(po.getAccidentId()).getRisk()));
+            po.setRiskLevel(String.valueOf(riskPOMap.get(po.getAccidentId()).getRiskLevel()));
             if (po.getConflictBehavior().contains("追尾")) {
                 po.setLabel("追尾");
             }
@@ -313,7 +333,7 @@ public class SceneAccidentService {
             }
         }
 
-        return list;
+        return sceneAccidentPOS;
     }
 
 
@@ -404,6 +424,7 @@ public class SceneAccidentService {
             //3 设置包为已禁用
             testPackages.forEach(testPackage -> testPackage.setIsUnavailable(DictConstants.IS_UNAVAILABLE));
             //4 遍历删除场景
+            AtomicInteger deleteNum = new AtomicInteger();
             indexes.forEach(index -> {
                 final String sceneNaturalIdsString = index.getSceneNaturalIds();
                 List<String> sceneNaturalIds = new ArrayList<>();
@@ -430,12 +451,14 @@ public class SceneAccidentService {
                     final String sceneId = iterator.next();
                     if (sceneIds.contains(sceneId)) {
                         iterator.remove();
+                        deleteNum.getAndIncrement();
                         testPackages.forEach(testPackage -> {
                             testPackage.setSceneNum(testPackage.getSceneNum() - 1);
                         });
                     }
                 }
-                index.setSceneNum(sceneNaturalIds.size() + sceneTrafficIds.size() + sceneStatueIds.size() + sceneGeneralizationIds.size());
+//                index.setSceneNum(sceneNaturalIds.size() + sceneTrafficIds.size() + sceneStatueIds.size() + sceneGeneralizationIds.size());
+                index.setSceneNum(index.getSceneNum() - deleteNum.get());
                 index.setSceneNaturalIds(CollectionUtil.listToSequence(sceneNaturalIds));
                 index.setModifyTime(TimeUtil.getNowForMysql());
                 index.setModifyUserId(AuthUtil.getCurrentUserId());

+ 29 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneEvaluationRuleService.java

@@ -2,8 +2,11 @@ package com.css.simulation.resource.server.app.service;
 
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.constants.DictConstants;
+import api.common.pojo.param.scene.SceneEvaluationDetailParam;
+import api.common.pojo.param.scene.SceneEvaluationForListParam;
 import api.common.pojo.param.scene.SceneEvaluationRuleParam;
 import api.common.pojo.po.scene.SceneComplexityPO;
+import api.common.pojo.po.scene.SceneEvaluationOperatePO;
 import api.common.pojo.po.scene.SceneEvaluationRulePO;
 import api.common.pojo.po.scene.SceneRiskPO;
 import api.common.util.LogUtil;
@@ -26,6 +29,9 @@ import javax.annotation.Resource;
 import java.nio.charset.StandardCharsets;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -167,13 +173,32 @@ public class SceneEvaluationRuleService {
     }
 
     @SneakyThrows
-    public List<SceneComplexityPO> querySceneEvaluationComplexityDetail(String sceneId) {
-        return sceneComplexityMapper.querySceneEvaluationComplexityDetail(sceneId);
+    public List<SceneComplexityPO> querySceneEvaluationComplexityDetail(SceneEvaluationDetailParam param) {
+        return sceneComplexityMapper.querySceneEvaluationComplexityDetail(param.getSceneId());
     }
 
     @SneakyThrows
-    public List<SceneRiskPO> querySceneEvaluationRiskDetail(String sceneId) {
-        return sceneRiskMapper.querySceneEvaluationRiskDetail(sceneId);
+    public List<SceneRiskPO> querySceneEvaluationRiskDetail(SceneEvaluationDetailParam param) {
+        return sceneRiskMapper.querySceneEvaluationRiskDetail(param.getSceneId());
+    }
+
+    @SneakyThrows
+    public SceneEvaluationOperatePO getSceneEvaluationFirst(SceneEvaluationForListParam param) {
+        SceneComplexityPO sceneComplexityPO = new SceneComplexityPO();
+        sceneComplexityPO.setMinComplexity(param.getMinComplexity());
+        sceneComplexityPO.setMaxComplexity(param.getMaxComplexity());
+        sceneComplexityPO.setComplexityLevel(param.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(param.getMaxRisk());
+        sceneRiskPO.setMinRisk(param.getMinRisk());
+        sceneRiskPO.setRiskLevel(param.getRiskLevel());
+        // 查询复杂度的符合条件的第一条数据
+        List<SceneRiskPO> sceneReferenceLibCRPOS = sceneRiskMapper.selectSceneIdsByEvaluation(sceneRiskPO);
+        Map<String, SceneRiskPO> riskPOMap = sceneReferenceLibCRPOS.stream().collect(Collectors.toMap(SceneRiskPO::getSceneId, Function.identity()));
+        return SceneEvaluationOperatePO.builder().sceneComplexityPOMap(complexityPOMap).sceneRiskPOMap(riskPOMap).build();
     }
 
 }

+ 39 - 19
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneGeneralTemplateService.java

@@ -4,11 +4,9 @@ package com.css.simulation.resource.server.app.service;
 import api.common.pojo.constants.DictConstants;
 import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.scene.SceneDeleteParam;
+import api.common.pojo.param.scene.SceneEvaluationForListParam;
 import api.common.pojo.param.scene.SceneGeneralTemplateParam;
-import api.common.pojo.po.scene.SceneGeneralTemplatePO;
-import api.common.pojo.po.scene.ScenePackagePO;
-import api.common.pojo.po.scene.ScenePackageSublistPO;
-import api.common.pojo.po.scene.SystemScenePackageSublistPO;
+import api.common.pojo.po.scene.*;
 import api.common.pojo.po.system.SceneImportPO;
 import api.common.pojo.vo.scene.SceneGeneralTemplateMbVO;
 import api.common.pojo.vo.scene.SceneGeneralTemplateVO;
@@ -31,6 +29,7 @@ import java.io.FileInputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -49,6 +48,9 @@ public class SceneGeneralTemplateService {
     @Resource
     LogService logService;
 
+    @Resource
+    private SceneEvaluationRuleService sceneEvaluationRuleService;
+
     /**
      * 泛化模板导入:
      */
@@ -270,9 +272,27 @@ public class SceneGeneralTemplateService {
         }
         Map<String, String> scenarioRoadTypeMap = dictService.getDictMapByType("scenarioRoadType");
         Map<String, String> scenarioWeatherMap = dictService.getDictMapByType("scenarioWeather");
-        for (SceneGeneralTemplatePO vo : list) {
+
+        // 添加复杂度 危险度数据
+        SceneEvaluationForListParam sceneEvaluationForListParam = new SceneEvaluationForListParam();
+        BeanUtils.copyProperties(po, sceneEvaluationForListParam);
+        SceneEvaluationOperatePO sceneEvaluationOperatePO = sceneEvaluationRuleService.getSceneEvaluationFirst(sceneEvaluationForListParam);
+        Map<String, SceneComplexityPO> complexityPOMap = sceneEvaluationOperatePO.getSceneComplexityPOMap();
+        Map<String, SceneRiskPO> riskPOMap = sceneEvaluationOperatePO.getSceneRiskPOMap();
+        // 筛选
+        List<SceneGeneralTemplatePO> sceneGeneralTemplatePOS = list.stream()
+                .filter(st -> complexityPOMap.get(st.getId()) != null && riskPOMap.get(st.getId()) != null)
+                .collect(Collectors.toList());
+
+
+        for (SceneGeneralTemplatePO vo : sceneGeneralTemplatePOS) {
             vo.setScenarioRoadType(scenarioRoadTypeMap.get(vo.getScenarioRoadType()));
             vo.setScenarioWeather(scenarioWeatherMap.get(vo.getScenarioWeather()));
+            // 赋值复杂度
+            vo.setComplexity(String.valueOf(complexityPOMap.get(vo.getId()).getComplexity()));
+            vo.setComplexityLevel(String.valueOf(complexityPOMap.get(vo.getId()).getComplexityLevel()));
+            vo.setRisk(String.valueOf(riskPOMap.get(vo.getId()).getRisk()));
+            vo.setRiskLevel(String.valueOf(riskPOMap.get(vo.getId()).getRiskLevel()));
         }
         return list;
     }
@@ -363,26 +383,26 @@ public class SceneGeneralTemplateService {
         //删除测试包中场景
         SceneDeleteParam parm = new SceneDeleteParam();
         parm.setModifyUserId(AuthUtil.getCurrentUserId());
-       // Set<String> set = new HashSet<>();
+        // Set<String> set = new HashSet<>();
         for (String id : idS) {
             parm.setModifyTime(TimeUtil.getNowForMysql());
             parm.setSceneFhId(id);
 
-           // List<String> packageIdS = scenePackageSublistMapper.selectPackageIdById(parm);
-            List<ScenePackageSublistPO> listPo= scenePackageSublistMapper.selectPackageFhById(parm);
-                for (ScenePackageSublistPO scenePackageSublistPO : listPo) {
-                    ScenePackagePO scenePackagePO = new ScenePackagePO();
-                    scenePackagePO.setModifyUserId(AuthUtil.getCurrentUserId());
-                    scenePackagePO.setModifyTime(TimeUtil.getNowForMysql());
-                    scenePackagePO.setIsUnavailable("1");
-                    scenePackagePO.setSceneNum(scenePackageSublistPO.getSceneNum());
-                    scenePackagePO.setPackageId(scenePackageSublistPO.getRootId());
-                    //改变测试包状态及数量
-                    scenePackageMapper.updateIsUnavailable(scenePackagePO);
-                }
+            // List<String> packageIdS = scenePackageSublistMapper.selectPackageIdById(parm);
+            List<ScenePackageSublistPO> listPo = scenePackageSublistMapper.selectPackageFhById(parm);
+            for (ScenePackageSublistPO scenePackageSublistPO : listPo) {
+                ScenePackagePO scenePackagePO = new ScenePackagePO();
+                scenePackagePO.setModifyUserId(AuthUtil.getCurrentUserId());
+                scenePackagePO.setModifyTime(TimeUtil.getNowForMysql());
+                scenePackagePO.setIsUnavailable("1");
+                scenePackagePO.setSceneNum(scenePackageSublistPO.getSceneNum());
+                scenePackagePO.setPackageId(scenePackageSublistPO.getRootId());
+                //改变测试包状态及数量
+                scenePackageMapper.updateIsUnavailable(scenePackagePO);
+            }
             //set.addAll(packageIdS);
             //删除场景测试包
-                scenePackageSublistMapper.updateScenePackageSublistById(parm);
+            scenePackageSublistMapper.updateScenePackageSublistById(parm);
             //改变场景包场景数量
 
         }

+ 29 - 6
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneNaturalService.java

@@ -5,9 +5,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.scene.*;
-import api.common.pojo.po.scene.SceneNaturalPO;
-import api.common.pojo.po.scene.ScenePackagePO;
-import api.common.pojo.po.scene.ScenePackageSublistPO;
+import api.common.pojo.po.scene.*;
 import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.*;
 import com.css.simulation.resource.server.infra.util.AuthUtil;
@@ -23,11 +21,13 @@ import com.github.pagehelper.util.StringUtil;
 import feign.Response;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 
@@ -51,6 +51,9 @@ public class SceneNaturalService {
     @Resource
     private FileDownService fileDownService;
 
+    @Resource
+    private SceneEvaluationRuleService sceneEvaluationRuleService;
+
     /**
      * 获取自然驾驶场景数据:包括切分数据和标注数据
      */
@@ -298,7 +301,25 @@ public class SceneNaturalService {
                 list = sceneNaturalMapper.querySceneNaturalListByQx(po);
             }
         }
-        for (SceneNaturalPO vo : list) {
+
+        // 添加复杂度 危险度数据
+        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<SceneNaturalPO> finalSceneNaturalList = list.stream()
+                .filter(sn -> complexityPOMap.get(sn.getNaturalId()) != null && riskPOMap.get(sn.getNaturalId()) != null)
+                .collect(Collectors.toList());
+
+
+        for (SceneNaturalPO vo : finalSceneNaturalList) {
+            // 赋值复杂度
+            vo.setComplexity(String.valueOf(complexityPOMap.get(vo.getNaturalId()).getComplexity()));
+            vo.setComplexityLevel(String.valueOf(complexityPOMap.get(vo.getNaturalId()).getComplexityLevel()));
+            vo.setRisk(String.valueOf(riskPOMap.get(vo.getNaturalId()).getRisk()));
+            vo.setRiskLevel(String.valueOf(riskPOMap.get(vo.getNaturalId()).getRiskLevel()));
             if (vo.getRoadType().equals("高速")) {
                 if (ObjectUtil.isNull(vo.getLabel())) {
                     vo.setLabel("高速");
@@ -349,7 +370,7 @@ public class SceneNaturalService {
                 }
             }
         }
-        return list;
+        return finalSceneNaturalList;
     }
 
 
@@ -392,6 +413,7 @@ public class SceneNaturalService {
             //3 设置包为已禁用
             testPackages.forEach(testPackage -> testPackage.setIsUnavailable(DictConstants.IS_UNAVAILABLE));
             //4 遍历删除场景
+            AtomicInteger deleteNum = new AtomicInteger();
             indexes.forEach(index -> {
                 final String sceneNaturalIdsString = index.getSceneNaturalIds();
                 List<String> sceneNaturalIds = new ArrayList<>();
@@ -418,12 +440,13 @@ public class SceneNaturalService {
                     final String sceneId = iterator.next();
                     if (sceneIds.contains(sceneId)) {
                         iterator.remove();
+                        deleteNum.getAndIncrement();
                         testPackages.forEach(testPackage -> {
                             testPackage.setSceneNum(testPackage.getSceneNum() - 1);
                         });
                     }
                 }
-                index.setSceneNum(sceneNaturalIds.size() + sceneTrafficIds.size() + sceneStatueIds.size() + sceneGeneralizationIds.size());
+                index.setSceneNum(index.getSceneNum() - deleteNum.get());
                 index.setSceneNaturalIds(CollectionUtil.listToSequence(sceneNaturalIds));
                 index.setModifyTime(TimeUtil.getNowForMysql());
                 index.setModifyUserId(AuthUtil.getCurrentUserId());

+ 130 - 30
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneReferenceLibService.java

@@ -1,18 +1,13 @@
 package com.css.simulation.resource.server.app.service;
 
 import api.common.pojo.constants.DictConstants;
+import api.common.pojo.constants.LogConstants;
 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.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.util.AuthUtil;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -20,13 +15,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import feign.Response;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 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;
 
 @Slf4j
@@ -40,10 +35,20 @@ public class SceneReferenceLibService {
     private FileDownService fileDownService;
 
     @Resource
-    private SceneComplexityMapper sceneComplexityMapper;
+    private SceneEvaluationRuleService sceneEvaluationRuleService;
 
     @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);
 
-        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()
                 .filter(srf -> complexityPOMap.get(srf.getSceneId()) != null && riskPOMap.get(srf.getSceneId()) != null)
                 .collect(Collectors.toList());
 
-
         for (SceneReferenceLibPO po : finalSceneReferenceLibPOList) {
             // 赋值复杂度
             po.setComplexity(String.valueOf(complexityPOMap.get(po.getSceneId()).getComplexity()));
@@ -330,5 +325,110 @@ public class SceneReferenceLibService {
         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);
+        }
+    }
+
 
 }

+ 29 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneStandardsService.java

@@ -5,9 +5,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.scene.*;
-import api.common.pojo.po.scene.ScenePackagePO;
-import api.common.pojo.po.scene.ScenePackageSublistPO;
-import api.common.pojo.po.scene.StandardsRegulationsPO;
+import api.common.pojo.po.scene.*;
 import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.*;
 import com.css.simulation.resource.server.infra.util.AuthUtil;
@@ -21,11 +19,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import feign.Response;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -46,6 +46,9 @@ public class SceneStandardsService {
     @Resource
     LogService logService;
 
+    @Resource
+    private SceneEvaluationRuleService sceneEvaluationRuleService;
+
     /**
      * 获取标准法规场景数据:
      */
@@ -140,6 +143,24 @@ public class SceneStandardsService {
                 list = sceneStandardsRegulationsMapper.queryStandardsRegulationsListByQx(params);
             }
         }
+
+        // 添加复杂度 危险度数据
+        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<StandardsRegulationsPO> standardsRegulationsPOS = list.stream()
+                .filter(sn -> complexityPOMap.get(sn.getRegulationsId()) != null && riskPOMap.get(sn.getRegulationsId()) != null)
+                .collect(Collectors.toList());
+        standardsRegulationsPOS.stream().forEach(po -> {            // 赋值复杂度
+            po.setComplexity(String.valueOf(complexityPOMap.get(po.getRegulationsId()).getComplexity()));
+            po.setComplexityLevel(String.valueOf(complexityPOMap.get(po.getRegulationsId()).getComplexityLevel()));
+            po.setRisk(String.valueOf(riskPOMap.get(po.getRegulationsId()).getRisk()));
+            po.setRiskLevel(String.valueOf(riskPOMap.get(po.getRegulationsId()).getRiskLevel()));
+        });
+
        /* if(params.getLabel()!=null&&params.getLabel().size()>0){
             if(params.getRegulationType()!=null&&params.getRegulationType().size()>0){
                 List<String> regulationType= params.getRegulationType();
@@ -161,7 +182,7 @@ public class SceneStandardsService {
             listA.add("没有权限");
             params.setAllIds(listA);
         }*/
-        return list;
+        return standardsRegulationsPOS;
     }
 
     @Transactional
@@ -203,6 +224,7 @@ public class SceneStandardsService {
             //3 设置包为已禁用
             testPackages.forEach(testPackage -> testPackage.setIsUnavailable(DictConstants.IS_UNAVAILABLE));
             //4 遍历删除场景
+            AtomicInteger deleteNum = new AtomicInteger();
             indexes.forEach(index -> {
                 final String sceneNaturalIdsString = index.getSceneNaturalIds();
                 List<String> sceneNaturalIds = new ArrayList<>();
@@ -228,11 +250,13 @@ public class SceneStandardsService {
                 while (iterator.hasNext()) {
                     final String sceneId = iterator.next();
                     if (sceneIds.contains(sceneId)) {
+                        deleteNum.getAndIncrement();
                         iterator.remove();
                         testPackages.forEach(testPackage -> testPackage.setSceneNum(testPackage.getSceneNum() - 1));
                     }
                 }
-                index.setSceneNum(sceneNaturalIds.size() + sceneTrafficIds.size() + sceneStatueIds.size() + sceneGeneralizationIds.size());
+//                index.setSceneNum(sceneNaturalIds.size() + sceneTrafficIds.size() + sceneStatueIds.size() + sceneGeneralizationIds.size());
+                index.setSceneNum(index.getSceneNum() - deleteNum.get());
                 index.setSceneNaturalIds(CollectionUtil.listToSequence(sceneNaturalIds));
                 index.setModifyTime(TimeUtil.getNowForMysql());
                 index.setModifyUserId(AuthUtil.getCurrentUserId());

+ 3 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/SceneReferenceLibMapper.java

@@ -4,6 +4,7 @@ import api.common.pojo.param.scene.SceneDeleteParam;
 import api.common.pojo.param.scene.SceneReferenceLibSelectParam;
 import api.common.pojo.po.scene.SceneReferenceLibPO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -16,4 +17,6 @@ public interface SceneReferenceLibMapper {
     void updateSceneReference(SceneReferenceLibPO params);
     void deleteBySceneNames(SceneDeleteParam sceneDeleteParam);
 
+    List<String> selectIdsByNames(@Param("list")List<String> list);
+
 }

+ 1 - 1
simulation-resource-server/src/main/resources/mysql/mapper/SceneComplexityMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.SceneStandardsRegulationsMapper">
+<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.SceneComplexityMapper">
     <select id="selectSceneIdsByEvaluation" parameterType="api.common.pojo.po.scene.SceneComplexityPO"
             resultType="api.common.pojo.po.scene.SceneComplexityPO">
         SELECT

+ 1 - 1
simulation-resource-server/src/main/resources/mysql/mapper/SceneEvaluationRuleMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.ScoringRulesMapper">
+<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.SceneEvaluationRuleMapper">
 
     <insert id="saveSceneEvaluationRule" parameterType="api.common.pojo.po.scene.SceneEvaluationRulePO">
         insert into simulation.scene_evaluation_rule

+ 5 - 0
simulation-resource-server/src/main/resources/mysql/mapper/ScenePackageSublistMapper.xml

@@ -206,6 +206,11 @@
                 scene_traffic_ids like concat('%',#{item},'%')
             </foreach>
         </if>
+        <if test='sceneType == "4"'>
+            <foreach item="item" collection="sceneIds" separator=" or " open="(" close=")">
+                scene_reference_lib_ids like concat('%',#{item},'%')
+            </foreach>
+        </if>
     </select>
     <select id="selectSceneNumByPackageId" resultType="java.lang.Integer">
         select sum(scene_num)

+ 42 - 43
simulation-resource-server/src/main/resources/mysql/mapper/SceneReferenceLibMapper.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.SceneStandardsRegulationsMapper">
+<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.SceneReferenceLibMapper">
 
 
-    <insert id="saveStandardsRegulations" parameterType="api.common.pojo.po.scene.StandardsRegulationsPO">
+    <insert id="saveSceneReference" parameterType="api.common.pojo.po.scene.SceneReferenceLibPO">
         insert into simulation.scene_standards_regulations
         (regulations_id, scene_name, regulation_type, standard_type,
          create_user_id, create_time, modify_user_id, modify_time,
@@ -92,48 +92,26 @@
            xodr_address,
            json_address,
            max_time
-        FROM simulation.scene_reference_lib srl
-        <if test="isUnionOther != null and isUnionOther = '1'">
-            LEFT JOIN scene_risk sr ON srl.scene_id = sr.scene_id
-            LEFT JOIN scene_complexity  sc ON srl.scene_id = sc.scene_id
-        </if>
+        FROM simulation.scene_reference_lib
         <where>
             is_deleted = '0'
             <if test="sceneName != null and sceneName != ''">
-                AND srl.scene_name LIKE CONCAT('%',#{sceneName,jdbcType=VARCHAR},'%')
+                AND scene_name LIKE CONCAT('%',#{sceneName,jdbcType=VARCHAR},'%')
             </if>
             <if test="sceneDescription != null and sceneDescription != ''">
-                AND srl.scene_description LIKE CONCAT('%',#{sceneDescription,jdbcType=VARCHAR},'%')
-            </if>
-            <if test="minComplexity != null and minComplexity != ''">
-                AND sc.complexity >= #{minComplexity}
-            </if>
-            <if test="maxComplexity != null and maxComplexity != ''">
-                AND sc.complexity &lt;=  #{maxComplexity}
-            </if>
-            <if test="minRisk != null and minRisk != ''">
-                AND sr.risk >= #{minRisk}
-            </if>
-            <if test="maxRisk != null and maxRisk != ''">
-                AND sr.risk &lt;=  #{maxRisk}
-            </if>
-            <if test="complexityLevel != null and complexityLevel != ''">
-                AND sc.complexity_level >=  #{complexityLevel}
-            </if>
-            <if test="riskLevel != null and riskLevel != ''">
-                AND sr.risk_level >=  #{riskLevel}
+                AND scene_description LIKE CONCAT('%',#{sceneDescription,jdbcType=VARCHAR},'%')
             </if>
             <if test="label != null and label != ''">
-                AND srl.label LIKE CONCAT('%',#{label,jdbcType=VARCHAR},'%')
+                AND label LIKE CONCAT('%',#{label,jdbcType=VARCHAR},'%')
             </if>
             <if test="mainBehavior != null and mainBehavior.size()>0">
                 AND
                 <foreach collection="mainBehavior" item="item" index="index"
                          separator=" or " open="(" close=")">
-                    srl.main_behavior LIKE CONCAT('%,',#{item},',%')
-                    OR srl.main_behavior LIKE CONCAT('%,',#{item}) OR
-                    srl.main_behavior LIKE CONCAT(#{item},',%') OR
-                    srl.main_behavior=#{item}
+                    main_behavior LIKE CONCAT('%,',#{item},',%')
+                    OR main_behavior LIKE CONCAT('%,',#{item}) OR
+                    main_behavior LIKE CONCAT(#{item},',%') OR
+                    main_behavior=#{item}
                 </foreach>
 
             </if>
@@ -141,57 +119,78 @@
                 and
                 <foreach collection="otherBehavior" item="item" index="index"
                          separator=" or " open="(" close=")">
-                    srl.other_behavior LIKE CONCAT('%,',#{item},',%')
-                    OR srl.other_behavior LIKE CONCAT('%,',#{item}) OR
-                    srl.other_behavior LIKE CONCAT(#{item},',%') OR
-                    srl.other_behavior=#{item}
+                    other_behavior LIKE CONCAT('%,',#{item},',%')
+                    OR other_behavior LIKE CONCAT('%,',#{item}) OR
+                    other_behavior LIKE CONCAT(#{item},',%') OR
+                    other_behavior=#{item}
                 </foreach>
             </if>
             <if test="weather != null and weather.size()>0 ">
-                AND srl.weather IN
+                AND weather IN
                 <foreach collection="weather" item="item" index="index"
                          separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="roadType != null and roadType.size()>0">
-                AND srl.road_type IN
+                AND road_type IN
                 <foreach collection="roadType" item="item" index="index"
                          separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="roadGeometryPlane != null and roadGeometryPlane.size()>0">
-                AND srl.road_geometry_plane IN
+                AND road_geometry_plane IN
                 <foreach collection="roadGeometryPlane" item="item" index="index"
                          separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="roadGeometryVertical != null and roadGeometryVertical.size()>0">
-                AND srl.road_geometry_vertical IN
+                AND road_geometry_vertical IN
                 <foreach collection="roadGeometryVertical" item="item" index="index"
                          separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="autoDriveFunction != null and autoDriveFunction.size()>0">
-                AND srl.auto_drive_function IN
+                AND auto_drive_function IN
                 <foreach collection="autoDriveFunction" item="item" index="index"
                          separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="operationArea != null and operationArea.size()>0">
-                AND srl.operation_area IN
+                AND operation_area IN
                 <foreach collection="operationArea" item="item" index="index"
                          separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
         </where>
-        ORDER BY srl.create_time,srl.scene_name DESC
+        ORDER BY create_time,scene_name DESC
 
     </select>
 
+    <select id="selectIdsByNames" resultType="java.lang.String">
+        select scene_id
+        from scene_reference_lib
+        where is_deleted = '0'
+        and scene_name in
+        <foreach item="item" collection="list" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+    <update id="deleteBySceneNames">
+        update scene_reference_lib
+        set is_deleted = '1',
+        modify_user_id = #{modifyUserId},
+        modify_time = #{modifyTime}
+        where is_deleted = '0' and scene_name in
+        <foreach item="item" collection="sceneNames" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </update>
+
+
 </mapper>

+ 42 - 0
simulation-resource-server/src/main/resources/mysql/mapper/SceneRiskMapper.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.SceneRiskMapper">
+    <select id="selectSceneIdsByEvaluation" parameterType="api.common.pojo.po.scene.SceneRiskPO"
+            resultType="api.common.pojo.po.scene.SceneRiskPO">
+        SELECT
+        *
+        FROM
+        (
+        SELECT
+        srl.scene_id scene_id,
+        sc.complexity complexity,
+        sc.complexity_level complexity_level,
+        sc.create_time create_time
+        FROM
+        simulation.scene_reference_lib srl
+        LEFT JOIN scene_risk sc ON srl.scene_id = sc.scene_id
+        <where>
+            is_deleted = '0'
+            <if test="minRisk != null and minRisk != ''">
+                AND risk >= #{minRisk}
+            </if>
+            <if test="maxRisk != null and maxRisk != ''">
+                AND risk &lt;=  #{maxRisk}
+            </if>
+            <if test="riskLevel != null and riskLevel != ''">
+                AND risk_level >=  #{riskLevel}
+            </if>
+            <if test="sceneIdList != null and sceneIdList.size()>0">
+                AND srl.scene_id IN
+                <foreach collection="sceneIdList" item="item" index="index"
+                         separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        ORDER BY
+        sc.create_time DESC
+        ) srlsc GROUP BY scene_id;
+    </select>
+
+</mapper>

+ 11 - 2
simulation-resource-server/src/main/resources/mysql/mapper/SimulationManualProjectMapper.xml

@@ -36,7 +36,11 @@
          algorithm_array,
          vehicle_array,
          scene_array,
-         details)
+         details,
+         complexity_evaluation_rule_id,
+         risk_evaluation_rule_id,
+         exposure_rate_rvaluation_rule_id,
+         coverage_rate_evaluation_ruleId)
         values (#{id},
                 #{projectDate,jdbcType=INTEGER},
                 #{projectNum,jdbcType=INTEGER},
@@ -67,7 +71,8 @@
                 #{algorithmArray},
                 #{vehicleArray},
                 #{sceneArray},
-                #{details})
+                #{details}, #{complexityEvaluationRuleId}, #{riskEvaluationRuleId}, #{exposureRateEvaluationRuleId},
+                #{coverageRateEvaluationRuleId})
     </insert>
 
     <!--修改-->
@@ -80,6 +85,10 @@
             vehicle             = #{vehicle},
             scene               = #{scene},
             max_simulation_time = #{maxSimulationTime,jdbcType=BIGINT},
+            complexity_evaluation_rule_id = #{complexityEvaluationRuleId},
+            risk_evaluation_rule_id = #{riskEvaluationRuleId},
+            exposure_rate_rvaluation_rule_id = #{exposureRateEvaluationRuleId},
+            coverage_rate_evaluation_ruleId = #{coverageRateEvaluationRuleId},
             parallelism         = #{parallelism},
             is_choice_gpu       = #{isChoiceGpu},
             algorithm_array     = #{algorithmArray},