李春阳 1 年之前
父节点
当前提交
0def95091c
共有 27 个文件被更改,包括 1282 次插入142 次删除
  1. 3 0
      api-common/src/main/java/api/common/pojo/param/scene/SceneImportParam.java
  2. 62 0
      api-common/src/main/java/api/common/pojo/param/scene/SceneReferenceLibParam.java
  3. 64 0
      api-common/src/main/java/api/common/pojo/param/scene/SceneReferenceLibSelectParam.java
  4. 29 0
      api-common/src/main/java/api/common/pojo/po/scene/SceneComplexityPO.java
  5. 76 0
      api-common/src/main/java/api/common/pojo/po/scene/SceneReferenceLibPO.java
  6. 27 0
      api-common/src/main/java/api/common/pojo/po/scene/SceneRiskPO.java
  7. 49 0
      api-common/src/main/java/api/common/pojo/vo/scene/SceneReferenceLibVO.java
  8. 5 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/feign/SceneService.java
  9. 5 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/feign/SceneServiceFallback.java
  10. 3 1
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/controller/SceneImportController.java
  11. 39 0
      simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/adapter/entity/SceneEvaluationMessageEntity.java
  12. 90 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/scene_library/scene_reference_lib/SceneReferenceLibController.java
  13. 9 5
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/scene_library/score_rule/ScoreRuleController.java
  14. 10 5
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/system_manage/scene_upload/SceneUploadController.java
  15. 160 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneEvaluationRuleService.java
  16. 0 7
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneImportService.java
  17. 334 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneReferenceLibService.java
  18. 3 123
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/ScoringRulesService.java
  19. 14 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/SceneComplexityMapper.java
  20. 6 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/SceneEvaluationRuleMapper.java
  21. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/ScenePackageMapper.java
  22. 19 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/SceneReferenceLibMapper.java
  23. 14 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/SceneRiskMapper.java
  24. 52 0
      simulation-resource-server/src/main/resources/mysql/mapper/SceneComplexityMapper.xml
  25. 3 0
      simulation-resource-server/src/main/resources/mysql/mapper/SceneEvaluationRuleMapper.xml
  26. 7 0
      simulation-resource-server/src/main/resources/mysql/mapper/ScenePackageMapper.xml
  27. 197 0
      simulation-resource-server/src/main/resources/mysql/mapper/SceneReferenceLibMapper.xml

+ 3 - 0
api-common/src/main/java/api/common/pojo/param/scene/SceneImportParam.java

@@ -10,4 +10,7 @@ public class SceneImportParam {
     //Minio路径
     private String minioDirectory;
 
+    // 场景评价规则 id
+    private String sceneEvaluationRuleId;
+
 }

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

@@ -0,0 +1,62 @@
+package api.common.pojo.param.scene;
+
+import api.common.pojo.common.PageVO;
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 基准场景库前端传参
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneReferenceLibParam extends PageVO implements Serializable {
+
+    // 主键 id (uuid)
+    private String sceneId;
+    // 基准场景名称
+    private String sceneName;
+    // 主车动作
+    private String[][] mainBehavior;
+    // 他车动作
+    private String[][] otherBehavior;
+    // 天气
+    private String[][] weather;
+    // 道路类型
+    private String[][] roadType;
+    // 道路几何-平面
+    private String[][] roadGeometryPlane;
+    // 道路几何-纵断面
+    private String[][] roadGeometryVertical;
+    // 自动驾驶功能
+    private String[][] autoDriveFunction;
+    // 运行区域
+    private String[][] operationArea;
+    // 场景描述
+    private String sceneDescription;
+    // 复杂度下限
+    private Integer minComplexity;
+    // 复杂度上限
+    private Integer maxComplexity;
+    // 危险度下限
+    private Integer minRisk;
+    // 危险度上限
+    private Integer maxRisk;
+    // 复杂度等级
+    private Integer complexityLevel;
+    // 危险度等级
+    private Integer riskLevel;
+    // 标签
+    private String label;
+    // 供场景上传任务删除使用
+    private List<String> sceneNames;
+    // 用于批量删除的名称列表
+    private List<String> sceneNameList;
+    private String[] ids; //回显数组
+    private List<String> AllIds; //权限集合
+    private String userId;
+}

+ 64 - 0
api-common/src/main/java/api/common/pojo/param/scene/SceneReferenceLibSelectParam.java

@@ -0,0 +1,64 @@
+package api.common.pojo.param.scene;
+
+import api.common.pojo.common.PageVO;
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 基准场景库前端传参
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneReferenceLibSelectParam extends PageVO implements Serializable {
+
+    // 主键 id (uuid)
+    private String sceneId;
+    // 基准场景名称
+    private String sceneName;
+    // 主车动作
+    private List<String> mainBehavior;
+    // 他车动作
+    private List<String> otherBehavior;
+    // 天气
+    private List<String> weather;
+    // 道路类型
+    private List<String> roadType;
+    // 道路几何-平面
+    private List<String> roadGeometryPlane;
+    // 道路几何-纵断面
+    private List<String> roadGeometryVertical;
+    // 自动驾驶功能
+    private List<String> autoDriveFunction;
+    // 运行区域
+    private List<String> operationArea;
+    // 场景描述
+    private String sceneDescription;
+    // 复杂度下限
+    private Integer minComplexity;
+    // 复杂度上限
+    private Integer maxComplexity;
+    // 危险度下限
+    private Integer minRisk;
+    // 危险度上限
+    private Integer maxRisk;
+    // 复杂度等级
+    private Integer complexityLevel;
+    // 危险度等级
+    private Integer riskLevel;
+    // 标签
+    private String label;
+    // 是否联表查询(复杂度,危险度表)
+    private String isUnionOther;
+    // 供场景上传任务删除使用
+    private List<String> sceneNames;
+    // 用于批量删除的名称列表
+    private List<String> sceneNameList;
+    private String[] ids; //回显数组
+    private List<String> AllIds; //权限集合
+    private String userId;
+}

+ 29 - 0
api-common/src/main/java/api/common/pojo/po/scene/SceneComplexityPO.java

@@ -0,0 +1,29 @@
+package api.common.pojo.po.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 复杂度数据
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneComplexityPO implements Serializable {
+    private List<String> sceneIdList;
+    private String complexityId;
+    private String sceneId;
+    private String sceneType;
+    private String ruleId;
+    private String taskId;
+    private Integer complexity;
+    private Integer complexityLevel;
+    // 复杂度下限
+    private Integer minComplexity;
+    // 复杂度上限
+    private Integer maxComplexity;
+}

+ 76 - 0
api-common/src/main/java/api/common/pojo/po/scene/SceneReferenceLibPO.java

@@ -0,0 +1,76 @@
+package api.common.pojo.po.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.List;
+
+/**
+ * 基准场景
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneReferenceLibPO implements Serializable {
+
+    // 主键 id (uuid)
+    private String sceneId;
+    // 基准场景名称
+    private String sceneName;
+    // 主车动作
+    private String mainBehavior;
+    // 他车动作
+    private String otherBehavior;
+    // 天气
+    private String weather;
+    // 道路类型
+    private String roadType;
+    // 道路几何-平面
+    private String roadGeometryPlane;
+    // 道路几何-纵断面
+    private String roadGeometryVertical;
+    // 自动驾驶功能
+    private String autoDriveFunction;
+    // 运行区域
+    private String operationArea;
+    // 场景描述
+    private String sceneDescription;
+    // 标签
+    private String label;
+    // 是否已删除
+    public String isDeleted;
+
+    // 复杂度
+    private String complexity;
+    // 危险度
+    private String risk;
+    // 复杂度等级
+    private String complexityLevel;
+    // 危险度等级
+    private String riskLevel;
+
+    // 视频地址
+    private String videoAddress;
+    private String osgbAddress;
+    private String xmlAddress;
+    private String xodrAddress;
+    private String jsonAddress;
+    // 视频预览地址
+    private String videoPreview;
+    // 该场景仿真最大时长
+    private String maxTime;
+    // 供场景上传任务删除使用
+    private List<String> sceneNames;
+    // 记录创建时间
+    public Timestamp createTime;
+    // 记录最后更新时间(包括删除)
+    public Timestamp modifyTime;
+    // 记录创建人(用户id)
+    public String createUserId;
+    // 记录最后更新人(包括删除)(用户id)
+    public String modifyUserId;
+
+}

+ 27 - 0
api-common/src/main/java/api/common/pojo/po/scene/SceneRiskPO.java

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

+ 49 - 0
api-common/src/main/java/api/common/pojo/vo/scene/SceneReferenceLibVO.java

@@ -0,0 +1,49 @@
+package api.common.pojo.vo.scene;
+
+import api.common.pojo.common.PageVO;
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 基准场景库返回前端
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneReferenceLibVO extends PageVO implements Serializable {
+
+    // 主键 id (uuid)
+    private String sceneId;
+    // 基准场景名称
+    private String sceneName;
+    // 主车动作
+    private String mainBehavior;
+    // 他车动作
+    private String otherBehavior;
+    // 天气
+    private String weather;
+    // 道路类型
+    private String roadType;
+    // 道路几何-平面
+    private String roadGeometryPlane;
+    // 道路几何-纵断面
+    private String roadGeometryVertical;
+    // 自动驾驶功能
+    private String autoDriveFunction;
+    // 运行区域
+    private String operationArea;
+    // 场景描述
+    private String sceneDescription;
+    // 标签
+    private String label;
+    // 视频地址
+    private String videoAddress;
+    // 视频预览地址
+    private String videoPreview;
+    // 该场景仿真最大时长
+    private String maxTime;
+
+}

+ 5 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/feign/SceneService.java

@@ -29,4 +29,9 @@ public interface SceneService {
     @Async
     @PostMapping("/StandardsRegulations/saveStandardsRegulationsBatch")
     ResponseBodyVO saveStandardsRegulationsBatch(SceneImportParam sceneImportParam);
+
+    // 基准场景库
+    @Async
+    @PostMapping("/SceneReferenceLib/saveSceneReferenceLibBatch")
+    ResponseBodyVO saveSceneReferenceLibBatch(SceneImportParam sceneImportParam);
 }

+ 5 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/feign/SceneServiceFallback.java

@@ -19,4 +19,9 @@ public class SceneServiceFallback implements SceneService {
     public ResponseBodyVO saveStandardsRegulationsBatch(SceneImportParam sceneImportParam) {
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE);
     }
+
+    @Override
+    public ResponseBodyVO saveSceneReferenceLibBatch(SceneImportParam sceneImportParam) {
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE);
+    }
 }

+ 3 - 1
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/controller/SceneImportController.java

@@ -66,6 +66,7 @@ public class SceneImportController {
         SceneImportParam param = new SceneImportParam();
         param.setId(po.getId());
         param.setMinioDirectory(po.getDataDirectory());
+        param.setSceneEvaluationRuleId(po.getSceneEvaluationRuleId());
         String authorization = request.getHeader("Authorization");
         AuthorizationHolder.setAuthorization(authorization);
         switch (po.getSceneType()) {
@@ -79,7 +80,8 @@ public class SceneImportController {
                 sceneService.saveSceneAccidentBatch(param);
                 break;
             case DictConstants.SCENE_REFERENCE_LIB:  // 基准场景库
-                sceneService.saveSceneAccidentBatch(param);
+                sceneService.saveSceneReferenceLibBatch(param);
+                break;
         }
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
     }

+ 39 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/adapter/entity/SceneEvaluationMessageEntity.java

@@ -0,0 +1,39 @@
+package com.css.simulation.resource.scheduler.adapter.entity;
+
+import lombok.*;
+
+/**
+ * {
+ * "algorithmId": "sadfasdfs", // 算法 id
+ * "vehicleId": "sadfasdfs", // 车辆 id
+ * "scenePackageId": "sadfasdfs", // 场景包 id
+ * "ruleId": "uuid"  // 场景评价规则 id
+ * "scriptPath": "/123/123/qqq.py"  // 场景评价脚本路径
+ * "taskId": "uuid"  // 标准化测试 id
+ * "ruleType": "1"  // 场景评价类型
+ * }
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode
+public class SceneEvaluationMessageEntity {
+
+    // 算法 id 计算危险度用
+    private String algorithmId;
+    // 车辆配置 id 计算危险度用
+    private String vehicleConfigId;
+    // 场景包 id  计算复杂率用
+    private String scenePackageId;
+    // 场景评价规则 id
+    private String ruleId;
+    // 场景评价脚本路径
+    private String scriptPath;
+    // 标准化测试 id
+    private String taskId;
+    // 场景评价类型
+    private String ruleType;
+
+
+}

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

@@ -0,0 +1,90 @@
+package com.css.simulation.resource.server.adapter.controller.scene_library.scene_reference_lib;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
+import api.common.pojo.param.scene.SceneImportParam;
+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.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.PageUtil;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.BeanUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 基准场景库
+ */
+@RestController
+@RequestMapping("/sceneReference")
+public class SceneReferenceLibController {
+
+    @Resource
+    private SceneImportService sceneImportService;
+
+    @Resource
+    private SceneReferenceLibService sceneReferenceLibService;
+
+    //* -------------------------------- 场景上传 --------------------------------
+
+    @PostMapping("/saveSceneReferenceLibBatch")
+    public ResponseBodyVO<String> saveSceneReferenceLibBatch(@RequestBody SceneImportParam sceneImportParam) {
+        SceneImportPO sceneImportPO = new SceneImportPO();
+        sceneImportPO.setId(sceneImportParam.getId());
+        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_3);
+        sceneImportService.updateStatus(sceneImportPO);
+        // 解析参数
+        sceneImportPO = sceneReferenceLibService.importMinio(sceneImportParam);
+        sceneImportService.updateInfo(sceneImportPO);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    //* -------------------------------- Comment --------------------------------
+
+    /**
+     * 查询基准场景库列表
+     *
+     * @param params
+     * @return
+     */
+    @PostMapping("/querySceneReferenceLibList")
+    public ResponseBodyVO<PageInfo<SceneReferenceLibVO>> querySceneReferenceLibList(@RequestBody SceneReferenceLibParam params) {
+        PageUtil.setPageInfo(params);
+        List<SceneReferenceLibPO> list = sceneReferenceLibService.querySceneReferenceLibList(params);
+        PageInfo<SceneReferenceLibPO> objectPageInfo = new PageInfo<>(list);
+        List<SceneReferenceLibVO> list1 = new ArrayList<>();
+        for (SceneReferenceLibPO po : list) {
+            SceneReferenceLibVO vo = new SceneReferenceLibVO();
+            BeanUtils.copyProperties(po, vo);
+            list1.add(vo);
+        }
+        PageInfo<SceneReferenceLibVO> pageInfo = new PageInfo<>(list1);
+        pageInfo.setTotal(objectPageInfo.getTotal());
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, pageInfo);
+    }
+
+
+    @PostMapping("/saveSceneReferenceById")
+    public ResponseBodyVO<String> saveSceneReference(@RequestBody SceneReferenceLibPO sceneReferenceLibPO) {
+        if (ObjectUtil.isNull(sceneReferenceLibPO.getSceneName())) {
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "参数 SceneName 不能为空,请检查");
+        }
+        if (ObjectUtil.isNull(sceneReferenceLibPO.getSceneId())) {
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "参数 SceneId 不能为空,请检查");
+        }
+        sceneReferenceLibService.updateSceneReference(sceneReferenceLibPO);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+    }
+
+
+}

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

@@ -12,6 +12,7 @@ import api.common.pojo.vo.scene.ScoringRulesVO;
 import api.common.util.ObjectUtil;
 import api.common.util.PythonUtil;
 import api.common.util.StringUtil;
+import com.css.simulation.resource.server.app.service.SceneEvaluationRuleService;
 import com.css.simulation.resource.server.app.service.ScoringRulesService;
 import com.css.simulation.resource.server.infra.util.AuthUtil;
 import com.css.simulation.resource.server.infra.util.PageUtil;
@@ -36,6 +37,9 @@ public class ScoreRuleController {
     @Resource
     private ScoringRulesService scoringRulesService;
 
+    @Resource
+    private SceneEvaluationRuleService sceneEvaluationRuleService;
+
     //查询列表
     @PostMapping("/queryScoringRulesList")
     public ResponseBodyVO<PageInfo<ScoringRulesVO>> queryScoringRulesList(@RequestBody ScoringRulesParam parms) {
@@ -180,7 +184,7 @@ public class ScoreRuleController {
         if (ObjectUtil.isNull(sceneEvaluationRulePO.getRuleName())) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "参数 RulesName 不能为空,请检查");
         }
-        return scoringRulesService.uploadPyScriptAndSaveRule(file, sceneEvaluationRulePO);
+        return sceneEvaluationRuleService.uploadPyScriptAndSaveRule(file, sceneEvaluationRulePO);
     }
 
 
@@ -190,7 +194,7 @@ public class ScoreRuleController {
     @PostMapping("/querySceneEvaluationRuleList")
     public ResponseBodyVO<PageInfo<SceneEvaluationRuleVO>> querySceneEvaluationRuleList(@RequestBody SceneEvaluationRuleParam params) {
         PageUtil.setPageInfo(params);
-        List<SceneEvaluationRulePO> list = scoringRulesService.querySceneEvaluationRuleList(params);
+        List<SceneEvaluationRulePO> list = sceneEvaluationRuleService.querySceneEvaluationRuleList(params);
         PageInfo<SceneEvaluationRulePO> sceneEvaluationRulePOPageInfo = new PageInfo<>(list);
         List<SceneEvaluationRuleVO> list1 = new ArrayList<>();
         // po 转 vo
@@ -209,9 +213,9 @@ public class ScoreRuleController {
      */
     @PostMapping("/querySceneComplexityScript")
     public ResponseBodyVO<List<SceneEvaluationRuleVO>> querySceneComplexityScript() {
-        List<SceneEvaluationRulePO> list = scoringRulesService.querySceneComplexityScript();
+        List<SceneEvaluationRulePO> list = sceneEvaluationRuleService.querySceneComplexityScript();
         List<SceneEvaluationRuleVO> list1 = new ArrayList<>();
-        //po转vo
+        // po  vo
         for (SceneEvaluationRulePO po : list) {
             SceneEvaluationRuleVO vo = new SceneEvaluationRuleVO();
             BeanUtils.copyProperties(po, vo);
@@ -229,7 +233,7 @@ public class ScoreRuleController {
         if (!DictConstants.ROLE_CODE_ADMIN.equals(roleCode) && !DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "非管理员禁止删除");
         }
-        scoringRulesService.deleteSceneEvaluationRule(params);
+        sceneEvaluationRuleService.deleteSceneEvaluationRule(params);
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
     }
 

+ 10 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/server/adapter/controller/system_manage/scene_upload/SceneUploadController.java

@@ -5,6 +5,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.system.SceneImportPageParam;
 import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.ObjectUtil;
+import com.css.simulation.resource.server.app.service.SceneEvaluationRuleService;
 import com.css.simulation.resource.server.infra.oauth.AuthorizationHolder;
 import com.css.simulation.resource.server.infra.feign.service.SceneService;
 import com.css.simulation.resource.server.app.service.SceneImportService;
@@ -28,6 +29,9 @@ public class SceneUploadController {
     @Resource
     private SceneService sceneService;
 
+    @Resource
+    private SceneEvaluationRuleService sceneEvaluationRuleService;
+
 //    @RequestMapping("/batchDeleteTask")
 //    public ResponseBodyVO<String> batchDeleteTask(@RequestBody SceneImportPO sceneImportPO) {
 //        List<String> idList = sceneImportPO.getIdList();
@@ -58,16 +62,17 @@ public class SceneUploadController {
         if (ObjectUtil.isNull(sceneType) || DictConstants.SCENE_GENERAL.equals(sceneType)) {
             return new ResponseBodyVO<>(false, 500, "参数错误!", null);
         }
+        // 判断是否选择复杂度脚本
+        String sceneEvaluationRuleId = po.getSceneEvaluationRuleId();
+        if (ObjectUtil.isNotNull(sceneEvaluationRuleId) && !sceneEvaluationRuleService.checkSceneEvaluationScript(sceneEvaluationRuleId)) {
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "复杂度脚本类型错误,请检查脚本类型.");
+        }
         // 保存场景导入任务
         po = sceneImportService.saveTask(po);
         if (ObjectUtil.isNull(po.getId())) {
             return new ResponseBodyVO<>(false, 500, "任务名称重复!", null);
         }
-        // 判断是否选择复杂度脚本 todo
-        String sceneEvaluationRuleId = po.getSceneEvaluationRuleId();
-//        if (ObjectUtil.isNotNull(sceneEvaluationRuleId) && !scoringRulesService.checkSceneEvaluationScript(sceneEvaluationRuleId)) {
-//            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "复杂度脚本类型错误,请检查脚本类型.");
-//        }
+
         ResponseBodyVO<SceneImportPO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
         response.setInfo(po);
         //异步-启动上传

+ 160 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneEvaluationRuleService.java

@@ -0,0 +1,160 @@
+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.SceneEvaluationRuleParam;
+import api.common.pojo.po.scene.SceneEvaluationRulePO;
+import api.common.util.LogUtil;
+import api.common.util.PythonUtil;
+import api.common.util.StringUtil;
+import api.common.util.TimeUtil;
+import com.alibaba.druid.util.StringUtils;
+import com.css.simulation.resource.server.infra.db.mysql.mapper.SceneEvaluationRuleMapper;
+import com.css.simulation.resource.server.infra.db.mysql.mapper.ScenePackageMapper;
+import com.css.simulation.resource.server.infra.feign.service.FileDownService;
+import com.css.simulation.resource.server.infra.util.AuthUtil;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+import java.util.List;
+
+@Slf4j
+@Service
+public class SceneEvaluationRuleService {
+
+    @Resource
+    private ScenePackageMapper scenePackageMapper;
+
+    @Resource
+    private SceneEvaluationRuleMapper sceneEvaluationRuleMapper;
+
+    @Resource
+    private FileDownService fileDownService;
+
+    @SneakyThrows
+    public int querySceneEvaluationRuleOnly(String ruleName, String ruleId) {
+        return sceneEvaluationRuleMapper.querySceneEvaluationRuleOnly(ruleName, ruleId);
+    }
+
+    @SneakyThrows
+    public ResponseBodyVO<String> uploadPyScriptAndSaveRule(MultipartFile file, SceneEvaluationRulePO sceneEvaluationRulePO) {
+
+        boolean hasRuleId = StringUtil.isEmpty(sceneEvaluationRulePO.getRuleId());
+
+        // 检查是否存在同名场景评价规则
+        int repeatPyScriptAndSaveRuleCount = querySceneEvaluationRuleOnly(sceneEvaluationRulePO.getRuleName(),
+                hasRuleId ? null : sceneEvaluationRulePO.getRuleId());
+        if (repeatPyScriptAndSaveRuleCount > 0) {
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "场景规则 " + sceneEvaluationRulePO.getRuleName() + " 已存在,请重新命名。");
+        }
+        // 新建或者是编辑时重新上传文件
+        if ((hasRuleId) || sceneEvaluationRulePO.getUploadNewFile()) {
+            String roleCode = AuthUtil.getCurrentUserRoleCode();
+            if (!DictConstants.ROLE_CODE_ADMIN.equals(roleCode) && !DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "非管理员禁止上传文件");
+            }
+            // 检查文件内容是否合规
+            String pyStr = new String(file.getBytes(), StandardCharsets.UTF_8);
+            //1 校验 python 语法错误
+            String pylint = PythonUtil.pylint(pyStr, PythonUtil.C, PythonUtil.R, PythonUtil.W, PythonUtil.E0401, PythonUtil.E0601);
+            if (!pylint.contains(PythonUtil.PASS)) {
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "代码格式错误,请检查。");
+            }
+            // 获取文件原本的名字
+            String originName = file.getOriginalFilename();
+            if (null == originName) {
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "文件名为空,请检查!");
+            }
+            String fileName = originName.substring(0, originName.lastIndexOf("."));
+            Integer nowTime = TimeUtil.getRq(new Date(), 0);
+            String randomCode = StringUtil.getRandomCode();
+            fileName = "/" + DictConstants.SCENE_EVALUATION_RULE_PY_FILE + "/" + nowTime + "/" + randomCode + "/" + fileName;
+            ResponseBodyVO<String> response = fileDownService.upload(file, fileName);
+            if (response.isStatus()) {
+                String previewUrl = response.getInfo();
+                sceneEvaluationRulePO.setScriptName(fileName);
+                sceneEvaluationRulePO.setScriptPath(previewUrl);
+            }
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "上传失败!");
+        }
+
+        // 判断 ruleId 是否为空
+        if (StringUtil.isEmpty(sceneEvaluationRulePO.getRuleId())) {
+            // 创建
+            saveSceneEvaluationRule(sceneEvaluationRulePO);
+        } else {
+            // 修改
+            updateSceneEvaluationRule(sceneEvaluationRulePO);
+        }
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    @SneakyThrows
+    public void deleteSceneEvaluationRule(SceneEvaluationRulePO params) {
+        // todo 如果是复杂度脚本需要校验是否有自然/交通等模板有引用
+        params.setIsDeleted("1");
+        params.setModifyTime(TimeUtil.getNowForMysql());
+        params.setModifyUserId(AuthUtil.getCurrentUserId());
+        sceneEvaluationRuleMapper.updateSceneEvaluationRule(params);
+        // 同步把使用该评分规则的测试包设为禁用
+        scenePackageMapper.updateIsUnavailableBySceneEvaluationRuleId(params);
+        LogUtil.delete();
+    }
+
+
+    /**
+     * 查询场景评价规则列表
+     */
+    @SneakyThrows
+    public List<SceneEvaluationRulePO> querySceneEvaluationRuleList(SceneEvaluationRuleParam params) {
+        return sceneEvaluationRuleMapper.querySceneEvaluationRuleList(params);
+    }
+
+    /**
+     * 查询复杂度脚本
+     */
+    @SneakyThrows
+    public List<SceneEvaluationRulePO> querySceneComplexityScript() {
+        return sceneEvaluationRuleMapper.querySceneComplexityScript();
+    }
+
+    /**
+     * 查询复杂度脚本类型
+     */
+    @SneakyThrows
+    public boolean checkSceneEvaluationScript(String sceneEvaluationRuleId) {
+        SceneEvaluationRulePO sceneEvaluationRulePO = sceneEvaluationRuleMapper.querySceneEvaluationPyById(sceneEvaluationRuleId);
+        if (sceneEvaluationRulePO == null) {
+            return false;
+        }
+        return StringUtils.equals(DictConstants.COMPLEXITY, sceneEvaluationRulePO.getRuleId());
+    }
+
+
+    @SneakyThrows
+    public void saveSceneEvaluationRule(SceneEvaluationRulePO params) {
+        params.setCreateTime(TimeUtil.getNowForMysql());
+        params.setModifyTime(TimeUtil.getNowForMysql());
+        params.setRuleId(StringUtil.getRandomUUID());
+        params.setRuleCode(StringUtil.getRandomCode());
+        params.setCreateUserId(AuthUtil.getCurrentUserId());
+        params.setIsDeleted("0");
+        sceneEvaluationRuleMapper.saveSceneEvaluationRule(params);
+        LogUtil.insert();
+    }
+
+    @SneakyThrows
+    public void updateSceneEvaluationRule(SceneEvaluationRulePO params) {
+        params.setModifyTime(TimeUtil.getNowForMysql());
+        params.setModifyUserId(AuthUtil.getCurrentUserId());
+        sceneEvaluationRuleMapper.updateSceneEvaluationRule(params);
+        LogUtil.update();
+    }
+
+
+}

+ 0 - 7
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneImportService.java

@@ -41,8 +41,6 @@ public class SceneImportService {
     private SceneAccidentService sceneAccidentService;
     @Resource
     private SceneGeneralTemplateService sceneGeneralTemplateService;
-    @Resource
-    private ScoringRulesService scoringRulesService;
 
     public SceneImportPO saveTask(SceneImportPO po) {
         // 名称校验
@@ -51,11 +49,6 @@ public class SceneImportService {
             po.setId(null);
             return po;
         }
-        // 判断是否选择复杂度脚本 todo
-        String sceneEvaluationRuleId = po.getSceneEvaluationRuleId();
-//        if (ObjectUtil.isNotNull(sceneEvaluationRuleId) && !scoringRulesService.checkSceneEvaluationScript(sceneEvaluationRuleId)) {
-//            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "复杂度脚本类型错误,请检查脚本类型.");
-//        }
         // 常规字段赋值
         PoUtil.initAddPo(po);
         String id = po.getId();

+ 334 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/SceneReferenceLibService.java

@@ -0,0 +1,334 @@
+package com.css.simulation.resource.server.app.service;
+
+import api.common.pojo.constants.DictConstants;
+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.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.feign.service.FileDownService;
+import com.css.simulation.resource.server.infra.util.AuthUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import feign.Response;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class SceneReferenceLibService {
+
+    @Resource
+    private SceneReferenceLibMapper sceneReferenceLibMapper;
+
+    @Resource
+    private FileDownService fileDownService;
+
+    @Resource
+    private SceneComplexityMapper sceneComplexityMapper;
+
+    @Resource
+    private SceneRiskMapper sceneRiskMapper;
+
+    /**
+     * 获取基准场景库列表
+     *
+     * @param params
+     * @return
+     */
+    public List<SceneReferenceLibPO> querySceneReferenceLibList(SceneReferenceLibParam params) {
+
+        SceneReferenceLibSelectParam srl = new SceneReferenceLibSelectParam();
+        // 场景名称
+        String sceneName = params.getSceneName();
+        // 主车行为
+        String[][] mainBehavior = params.getMainBehavior();
+        String[][] otherBehavior = params.getOtherBehavior();
+        String[][] weather = params.getWeather();
+        String[][] roadType = params.getRoadType();
+        String[][] roadGeometryPlane = params.getRoadGeometryPlane();
+        String[][] roadGeometryVertical = params.getRoadGeometryVertical();
+        String[][] autoDriveFunction = params.getAutoDriveFunction();
+        String[][] operationArea = params.getOperationArea();
+
+        if (mainBehavior != null && mainBehavior.length > 0) {
+            ParamUtil.arrConvertObj(mainBehavior, srl);
+            for (String[] arr : mainBehavior) {
+                if (arr != null && arr.length == 1) {
+                    List<String> list = srl.getMainBehavior();
+                    if (list == null) {
+                        List<String> newList = new ArrayList<>();
+                        newList.add(arr[0]);
+                        srl.setMainBehavior(newList);
+                    } else {
+                        list.add(arr[0]);
+                        srl.setMainBehavior(list);
+                    }
+                }
+            }
+        }
+        srl.setSceneId(params.getSceneId());
+        srl.setMinComplexity(params.getMinComplexity());
+        srl.setMaxComplexity(params.getMaxComplexity());
+        srl.setMinRisk(params.getMinRisk());
+        srl.setMaxRisk(params.getMaxRisk());
+        srl.setComplexityLevel(params.getComplexityLevel());
+        srl.setRiskLevel(params.getRiskLevel());
+        srl.setSceneDescription(params.getSceneDescription());
+        srl.setLabel(params.getLabel());
+        srl.setSceneName(sceneName);
+        if (otherBehavior != null && otherBehavior.length > 0) {
+            ParamUtil.arrConvertObj(otherBehavior, srl);
+        }
+        if (weather != null && weather.length > 0) {
+            ParamUtil.arrConvertObj(weather, srl);
+        }
+        if (roadType != null && roadType.length > 0) {
+            ParamUtil.arrConvertObj(roadType, srl);
+        }
+        if (roadGeometryPlane != null && roadGeometryPlane.length > 0) {
+            ParamUtil.arrConvertObj(roadGeometryPlane, srl);
+        }
+        if (roadGeometryVertical != null && roadGeometryVertical.length > 0) {
+            ParamUtil.arrConvertObj(roadGeometryVertical, srl);
+        }
+        if (autoDriveFunction != null && autoDriveFunction.length > 0) {
+            ParamUtil.arrConvertObj(autoDriveFunction, srl);
+        }
+        if (operationArea != null && operationArea.length > 0) {
+            ParamUtil.arrConvertObj(operationArea, 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()));
+
+        // 筛选
+        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()));
+            po.setComplexityLevel(String.valueOf(complexityPOMap.get(po.getSceneId()).getComplexityLevel()));
+            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("高速");
+                } else {
+                    po.setLabel(po.getLabel() + ",高速");
+                }
+            }
+            if (po.getOtherBehavior().contains("机动车从左侧切入成功") || po.getOtherBehavior().contains("机动车从右侧切入成功")) {
+                if (ObjectUtil.isNull(po.getLabel())) {
+                    po.setLabel("切入");
+                } else {
+                    po.setLabel(po.getLabel() + ",切入");
+                }
+            }
+            if (po.getOtherBehavior().equals("机动车向左侧切出成功") || po.getOtherBehavior().equals("机动车向右侧切出成功")) {
+                if (ObjectUtil.isNull(po.getLabel())) {
+                    po.setLabel("切出");
+                } else {
+                    po.setLabel(po.getLabel() + ",切出");
+                }
+            }
+            if (po.getMainBehavior().contains("直路掉头") || po.getMainBehavior().contains("路口掉头")) {
+                if (ObjectUtil.isNull(po.getLabel())) {
+                    po.setLabel("掉头");
+                } else {
+                    po.setLabel(po.getLabel() + ",掉头");
+                }
+            }
+            if (po.getMainBehavior().contains("向左变道成功") || po.getMainBehavior().equals("向右变道成功") || po.getMainBehavior().contains("向左连续变道") || po.getMainBehavior().indexOf("向右连续变道") > -1 || po.getMainBehavior().indexOf("向左变道超车") > -1 || po.getMainBehavior().indexOf("向右变道超车") > -1) {
+                if (ObjectUtil.isNull(po.getLabel())) {
+                    po.setLabel("变道");
+                } else {
+                    po.setLabel(po.getLabel() + ",变道");
+                }
+            }
+        }
+
+        return finalSceneReferenceLibPOList;
+    }
+
+
+    /**
+     * 获取基准场景数据
+     */
+    public SceneImportPO importMinio(SceneImportParam params) {
+        SceneImportPO sceneImportPO = new SceneImportPO();
+        sceneImportPO.setId(params.getId());
+        try {
+            MinioParameter MI = new MinioParameter();
+            MI.setObjectName(params.getMinioDirectory());
+            List<String> list = fileDownService.listDeepOne(MI).getInfo();
+            String OsgbPath = null;
+            String XodrPath = null;
+            int successNum = 0;
+            int falseNum = 0;
+            String errorMessage = "";
+            for (String filePath : list) {
+                if (filePath.contains("/OSGB")) {
+                    OsgbPath = filePath;
+                } else if (filePath.contains("/XODR")) {
+                    XodrPath = filePath;
+                }
+            }
+            String sceneName = null;
+            List<String> sceneNames = new ArrayList<>();
+            for (String filePath : list) {
+                if (filePath.contains("/Scenarios")) {
+                    MI.setObjectName(filePath);
+                    List<String> listScene = fileDownService.listDeepOne(MI).getInfo();
+                    log.info("importMinio() 共需要上传 " + listScene.size() + " 个基准场景");
+                    for (String scenePath : listScene) {
+                        try {
+                            MI.setObjectName(scenePath);
+                            List<String> addressList = fileDownService.listDeepOne(MI).getInfo();
+                            SceneReferenceLibPO sceneReferenceLibPO = new SceneReferenceLibPO();
+                            boolean isupdate = false;
+                            List<SceneReferenceLibPO> scenes = new ArrayList<>();
+                            for (String address : addressList) {
+                                if (address.contains(".json")) {
+                                    MI.setObjectName(address);
+                                    Response download = fileDownService.download(MI);
+                                    // -------------------------------- label.json --------------------------------
+                                    String json = download.body().toString();
+                                    ObjectMapper objMap = new ObjectMapper();
+                                    JsonNode root = objMap.readTree(json);
+                                    // 判断场景名称唯一
+                                    sceneName = root.path("场景名称").asText();
+                                    sceneNames.add(sceneName);
+                                    String osgb = root.path("osgb").asText();
+                                    String xodr = root.path("xodr").asText();
+                                    if (StringUtil.isEmpty(sceneName)) {
+                                        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+                                        String em = "文件 " + address + " 内容不符合标准格式(场景名称不为空)。";
+                                        log.error(em);
+                                        sceneImportPO.setErrorMessage(em);
+                                        return sceneImportPO;
+                                    }
+                                    String osgbAdress = OsgbPath + "/" + osgb;
+                                    String xodrAdress = XodrPath + "/" + xodr;
+                                    sceneReferenceLibPO.setSceneName(sceneName);
+                                    scenes = sceneReferenceLibMapper.selectAllByName(sceneReferenceLibPO);
+                                    // 新增数据
+                                    if (CollectionUtil.isNotEmpty(scenes)) {
+                                        isupdate = true;
+                                    }
+                                    String mainBehavior = root.path("主车行为").asText();
+                                    String otherBehavior = root.path("他车行为").asText();
+                                    sceneReferenceLibPO.setMainBehavior(mainBehavior);
+                                    sceneReferenceLibPO.setOtherBehavior(otherBehavior);
+                                    sceneReferenceLibPO.setMaxTime(root.path("max_time").asText());
+                                    sceneReferenceLibPO.setWeather(root.path("天气").asText());
+                                    sceneReferenceLibPO.setRoadType(root.path("道路类型").asText());
+                                    sceneReferenceLibPO.setRoadGeometryPlane(root.path("道路几何-平面").asText());
+                                    sceneReferenceLibPO.setRoadGeometryVertical(root.path("道路几何-纵断面").asText());
+                                    sceneReferenceLibPO.setAutoDriveFunction(root.path("自动驾驶功能").asText());
+                                    sceneReferenceLibPO.setOperationArea(root.path("运行区域").asText());
+                                    sceneReferenceLibPO.setSceneDescription(root.path("场景描述").asText());
+                                    sceneReferenceLibPO.setLabel(root.path("标签").asText());
+                                    sceneReferenceLibPO.setAutoDriveFunction(root.path("自动驾驶功能").asText());
+                                    sceneReferenceLibPO.setIsDeleted(DictConstants.IS_AVAILABLE);
+                                    if (ObjectUtil.isNull(sceneReferenceLibPO.getOsgbAddress())) {
+                                        sceneReferenceLibPO.setOsgbAddress(osgbAdress);
+                                    }
+                                    if (ObjectUtil.isNull(sceneReferenceLibPO.getXodrAddress())) {
+                                        sceneReferenceLibPO.setXodrAddress(xodrAdress);
+                                    }
+                                    sceneReferenceLibPO.setJsonAddress(address);
+                                } else if (address.contains(".xml") || address.contains(".xosc")) {
+                                    sceneReferenceLibPO.setXmlAddress(address);
+                                } else if (address.contains(".xodr")) {
+                                    sceneReferenceLibPO.setXodrAddress(address);
+                                } else if (address.contains(".osgb")) {
+                                    sceneReferenceLibPO.setOsgbAddress(address);
+                                } else if (address.contains("simulation.mp4")) {
+                                    sceneReferenceLibPO.setVideoAddress(address);
+                                } else if (address.contains(".mp4")) {
+                                    sceneReferenceLibPO.setVideoPreview(address);
+                                }
+                            }
+                            if (isupdate) {
+                                // -------------------------------- 修改数据到 mysql --------------------------------
+                                scenes.forEach(scene -> {
+                                    sceneReferenceLibPO.setSceneId(scene.getSceneId());
+                                    sceneReferenceLibPO.setModifyTime(TimeUtil.getNowForMysql());
+                                    sceneReferenceLibPO.setModifyUserId(AuthUtil.getCurrentUserId());
+                                    sceneReferenceLibMapper.updateSceneReference(sceneReferenceLibPO);
+                                });
+                            } else {
+                                // -------------------------------- 新增数据到 mysql --------------------------------
+                                sceneReferenceLibPO.setSceneId(StringUtil.getRandomUUID());
+                                sceneReferenceLibPO.setCreateTime(TimeUtil.getNowForMysql());
+                                sceneReferenceLibPO.setCreateUserId(AuthUtil.getCurrentUserId());
+                                sceneReferenceLibPO.setModifyTime(TimeUtil.getNowForMysql());
+                                sceneReferenceLibMapper.saveSceneReference(sceneReferenceLibPO);
+
+                            }
+                            successNum += 1;
+                        } catch (Exception e) {
+                            errorMessage = e.getMessage();
+                            log.error("parse scene reference lib file failed.", e);
+                            falseNum += 1;
+                        }
+                    }
+                }
+            }
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_4);
+            sceneImportPO.setSuccessNum(successNum);
+            sceneImportPO.setFalseNum(falseNum);
+            sceneImportPO.setErrorMessage(errorMessage);
+            sceneImportPO.setSceneNames(CollectionUtil.listToSequence(sceneNames));
+            return sceneImportPO;
+        } catch (Exception e) {
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+            sceneImportPO.setErrorMessage("该文件地址:" + params.getMinioDirectory() + "解析失败,请检查");
+            return sceneImportPO;
+        }
+    }
+
+    @SneakyThrows
+    public void updateSceneReference(SceneReferenceLibPO sceneReferenceLibPO) {
+        sceneReferenceLibPO.setModifyTime(TimeUtil.getNowForMysql());
+        sceneReferenceLibPO.setModifyUserId(AuthUtil.getCurrentUserId());
+        sceneReferenceLibMapper.updateSceneReference(sceneReferenceLibPO);
+        LogUtil.update();
+    }
+
+
+}

+ 3 - 123
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/service/ScoringRulesService.java

@@ -1,24 +1,18 @@
 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.SceneEvaluationRuleParam;
 import api.common.pojo.param.scene.ScoringRulesParam;
-import api.common.pojo.po.scene.SceneEvaluationRulePO;
 import api.common.pojo.po.scene.ScoringRulesPO;
-import api.common.util.*;
-import com.css.simulation.resource.server.infra.db.mysql.mapper.SceneEvaluationRuleMapper;
+import api.common.util.LogUtil;
+import api.common.util.StringUtil;
+import api.common.util.TimeUtil;
 import com.css.simulation.resource.server.infra.db.mysql.mapper.ScenePackageMapper;
 import com.css.simulation.resource.server.infra.db.mysql.mapper.ScoringRulesMapper;
-import com.css.simulation.resource.server.infra.feign.service.FileDownService;
 import com.css.simulation.resource.server.infra.util.AuthUtil;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 @Slf4j
@@ -29,12 +23,6 @@ public class ScoringRulesService {
     private ScoringRulesMapper scoringRulesMapper;
     @Resource
     private ScenePackageMapper scenePackageMapper;
-    @Resource
-    private SceneEvaluationRuleMapper sceneEvaluationRuleMapper;
-
-    @Resource
-    private FileDownService fileDownService;
-
     /**
      * 打分规则数据录入:
      */
@@ -91,11 +79,6 @@ public class ScoringRulesService {
         return scoringRulesMapper.querySelfOnly(ruleName, createUserId);
     }
 
-    @SneakyThrows
-    public int querySceneEvaluationRuleOnly(String ruleName, String ruleId) {
-        return sceneEvaluationRuleMapper.querySceneEvaluationRuleOnly(ruleName, ruleId);
-    }
-
     @SneakyThrows
     public void updateScoringRules(ScoringRulesPO params) {
         params.setModifyTime(TimeUtil.getNowForMysql());
@@ -168,107 +151,4 @@ public class ScoringRulesService {
         return treeList;
     }
 
-
-    @SneakyThrows
-    public ResponseBodyVO<String> uploadPyScriptAndSaveRule(MultipartFile file, SceneEvaluationRulePO sceneEvaluationRulePO) {
-
-        boolean hasRuleId = StringUtil.isEmpty(sceneEvaluationRulePO.getRuleId());
-
-        // 检查是否存在同名场景评价规则
-        int repeatPyScriptAndSaveRuleCount = querySceneEvaluationRuleOnly(sceneEvaluationRulePO.getRuleName(),
-                hasRuleId ? null : sceneEvaluationRulePO.getRuleId());
-        if (repeatPyScriptAndSaveRuleCount > 0) {
-            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "场景规则 " + sceneEvaluationRulePO.getRuleName() + " 已存在,请重新命名。");
-        }
-        // 新建或者是编辑时重新上传文件
-        if ((hasRuleId) || sceneEvaluationRulePO.getUploadNewFile()) {
-            String roleCode = AuthUtil.getCurrentUserRoleCode();
-            if (!DictConstants.ROLE_CODE_ADMIN.equals(roleCode) && !DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
-                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "非管理员禁止上传文件");
-            }
-            // 检查文件内容是否合规
-            String pyStr = new String(file.getBytes(), StandardCharsets.UTF_8);
-            //1 校验 python 语法错误
-            String pylint = PythonUtil.pylint(pyStr, PythonUtil.C, PythonUtil.R, PythonUtil.W, PythonUtil.E0401, PythonUtil.E0601);
-            if (!pylint.contains(PythonUtil.PASS)) {
-                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "代码格式错误,请检查。");
-            }
-            // 获取文件原本的名字
-            String originName = file.getOriginalFilename();
-            if (null == originName) {
-                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "文件名为空,请检查!");
-            }
-            String fileName = originName.substring(0, originName.lastIndexOf("."));
-            Integer nowTime = TimeUtil.getRq(new Date(), 0);
-            String randomCode = StringUtil.getRandomCode();
-            fileName = "/" + DictConstants.SCENE_EVALUATION_RULE_PY_FILE + "/" + nowTime + "/" + randomCode + "/" + fileName;
-            ResponseBodyVO<String> response = fileDownService.upload(file, fileName);
-            if (response.isStatus()) {
-                String previewUrl = response.getInfo();
-                sceneEvaluationRulePO.setScriptName(fileName);
-                sceneEvaluationRulePO.setScriptPath(previewUrl);
-            }
-            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "上传失败!");
-        }
-
-        // 判断 ruleId 是否为空
-        if (StringUtil.isEmpty(sceneEvaluationRulePO.getRuleId())) {
-            // 创建
-            saveSceneEvaluationRule(sceneEvaluationRulePO);
-        } else {
-            // 修改
-            updateSceneEvaluationRule(sceneEvaluationRulePO);
-        }
-        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
-    }
-
-    @SneakyThrows
-    public void deleteSceneEvaluationRule(SceneEvaluationRulePO params) {
-        params.setIsDeleted("1");
-        params.setModifyTime(TimeUtil.getNowForMysql());
-        params.setModifyUserId(AuthUtil.getCurrentUserId());
-//        scoringRulesMapper.updateScoringRules(params);
-        //同步把使用该评分规则的测试包设为禁用
-//        scenePackageMapper.updateIsUnavailable3(params);
-        LogUtil.delete();
-    }
-
-
-    /**
-     * 查询场景评价规则列表
-     */
-    @SneakyThrows
-    public List<SceneEvaluationRulePO> querySceneEvaluationRuleList(SceneEvaluationRuleParam params) {
-        return sceneEvaluationRuleMapper.querySceneEvaluationRuleList(params);
-    }
-
-    /**
-     * 查询复杂度脚本
-     */
-    @SneakyThrows
-    public List<SceneEvaluationRulePO> querySceneComplexityScript() {
-        return sceneEvaluationRuleMapper.querySceneComplexityScript();
-    }
-
-
-    @SneakyThrows
-    public void saveSceneEvaluationRule(SceneEvaluationRulePO params) {
-        params.setCreateTime(TimeUtil.getNowForMysql());
-        params.setModifyTime(TimeUtil.getNowForMysql());
-        params.setRuleId(StringUtil.getRandomUUID());
-        params.setRuleCode(StringUtil.getRandomCode());
-        params.setCreateUserId(AuthUtil.getCurrentUserId());
-        params.setIsDeleted("0");
-        sceneEvaluationRuleMapper.saveSceneEvaluationRule(params);
-        LogUtil.insert();
-    }
-
-    @SneakyThrows
-    public void updateSceneEvaluationRule(SceneEvaluationRulePO params) {
-        params.setModifyTime(TimeUtil.getNowForMysql());
-        params.setModifyUserId(AuthUtil.getCurrentUserId());
-        sceneEvaluationRuleMapper.updateSceneEvaluationRule(params);
-        LogUtil.update();
-    }
-
 }

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

@@ -0,0 +1,14 @@
+package com.css.simulation.resource.server.infra.db.mysql.mapper;
+
+import api.common.pojo.po.scene.SceneComplexityPO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+
+@Mapper
+public interface SceneComplexityMapper {
+
+    List<SceneComplexityPO> selectSceneIdsByEvaluation(SceneComplexityPO sceneComplexityPO);
+
+}

+ 6 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/SceneEvaluationRuleMapper.java

@@ -33,7 +33,12 @@ public interface SceneEvaluationRuleMapper {
 
     @Select("select rule_id, rule_name, script_name\n" +
             "from scene_evaluation_rule\n" +
-            "where is_deleted = '1' AND rule_type = '1'  \n")
+            "where is_deleted = '0' AND rule_type = '1'  \n")
     List<SceneEvaluationRulePO> querySceneComplexityScript();
 
+    @Select("select rule_id, rule_name, rule_type,script_name, script_path\n" +
+            "from scene_evaluation_rule\n" +
+            "where is_deleted = '0' AND rule_id =  #{ruleId} \n")
+    SceneEvaluationRulePO querySceneEvaluationPyById(@Param("ruleId") String ruleId);
+
 }

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

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.server.infra.db.mysql.mapper;
 
 import api.common.pojo.param.scene.ScenePackageParam;
+import api.common.pojo.po.scene.SceneEvaluationRulePO;
 import api.common.pojo.po.scene.ScenePackagePO;
 import api.common.pojo.po.scene.ScoringRulesPO;
 import api.common.pojo.vo.scene.ScenePackageNewVO;
@@ -31,6 +32,7 @@ public interface ScenePackageMapper {
     @Select("select is_deleted from scene_package where package_id = #{packageId}")
     String selectIsDeletedByPackageId(@Param("packageId") String packageId);
     void updateIsUnavailable3(ScoringRulesPO params);
+    void updateIsUnavailableBySceneEvaluationRuleId(SceneEvaluationRulePO params);
     List<ScenePackagePO> selectByIndexIds(ScenePackageParam scenePackageParam);
     void update(@Param("testPackages") List<ScenePackagePO> testPackages);
 }

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

@@ -0,0 +1,19 @@
+package com.css.simulation.resource.server.infra.db.mysql.mapper;
+
+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 java.util.List;
+
+
+@Mapper
+public interface SceneReferenceLibMapper {
+    void saveSceneReference(SceneReferenceLibPO params);
+    List<SceneReferenceLibPO> querySceneReferenceLibList(SceneReferenceLibSelectParam params);
+    List<SceneReferenceLibPO> selectAllByName(SceneReferenceLibPO sceneReferenceLibPO);
+    void updateSceneReference(SceneReferenceLibPO params);
+    void deleteBySceneNames(SceneDeleteParam sceneDeleteParam);
+
+}

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

@@ -0,0 +1,14 @@
+package com.css.simulation.resource.server.infra.db.mysql.mapper;
+
+import api.common.pojo.po.scene.SceneRiskPO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+
+@Mapper
+public interface SceneRiskMapper {
+
+    List<SceneRiskPO> selectSceneIdsByEvaluation(SceneRiskPO sceneRiskPO);
+
+}

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

@@ -0,0 +1,52 @@
+<?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">
+    <select id="selectSceneIdsByEvaluation" resultType="java.lang.String">
+        select accident_id
+        from scene_accident
+        where is_deleted = '0'
+        and scene_name in
+        <foreach item="item" collection="list" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="selectSceneIdsByEvaluation" parameterType="api.common.pojo.po.scene.SceneComplexityPO"
+            resultType="api.common.pojo.po.scene.SceneComplexityPO">
+        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_complexity sc ON srl.scene_id = sc.scene_id
+        <where>
+            is_deleted = '0'
+            <if test="minComplexity != null and minComplexity != ''">
+                AND complexity >= #{minComplexity}
+            </if>
+            <if test="maxComplexity != null and maxComplexity != ''">
+                AND complexity &lt;=  #{maxComplexity}
+            </if>
+            <if test="complexityLevel != null and complexityLevel != ''">
+                AND complexity_level >=  #{complexityLevel}
+            </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>

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

@@ -57,6 +57,9 @@
             <if test="ruleCode != null and ruleCode != ''">
                 and rule_code = #{ruleCode,jdbcType=VARCHAR}
             </if>
+            <if test="ruleType != null and ruleType != ''">
+                and rule_type = #{ruleType,jdbcType=VARCHAR}
+            </if>
             <if test="ruleName != null and ruleName != ''">
                 and rule_name like CONCAT('%',#{ruleName,jdbcType=VARCHAR},'%')
             </if>

+ 7 - 0
simulation-resource-server/src/main/resources/mysql/mapper/ScenePackageMapper.xml

@@ -256,6 +256,13 @@
             modify_time    = #{modifyTime}
         where package_id in (select distinct root_id from scene_package_sublist where package_and_rules = #{rulesId})
     </update>
+    <update id="updateIsUnavailableBySceneEvaluationRuleId" parameterType="api.common.pojo.po.scene.SceneEvaluationRulePO">
+        update simulation.scene_package
+        set is_unavailable = '1',
+            modify_user_id = #{modifyUserId},
+            modify_time    = #{modifyTime}
+        where package_id in (select distinct root_id from scene_package_sublist where package_and_rules = #{ruleId})
+    </update>
     <update id="update" parameterType="java.util.List">
         <foreach collection="testPackages" item="item" index="index" open="" close="" separator=";">
             update scene_package

+ 197 - 0
simulation-resource-server/src/main/resources/mysql/mapper/SceneReferenceLibMapper.xml

@@ -0,0 +1,197 @@
+<?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">
+
+
+    <insert id="saveStandardsRegulations" parameterType="api.common.pojo.po.scene.StandardsRegulationsPO">
+        insert into simulation.scene_standards_regulations
+        (regulations_id, scene_name, regulation_type, standard_type,
+         create_user_id, create_time, modify_user_id, modify_time,
+         is_deleted, share, video_preview, video_address, osgb_address, xml_address, xodr_address,
+         json_address, max_time)
+        values (#{regulationsId,jdbcType=VARCHAR}, #{sceneName,jdbcType=VARCHAR}, #{regulationType,jdbcType=VARCHAR},
+                #{standardType,jdbcType=VARCHAR},
+                #{createUserId,jdbcType=VARCHAR}, #{createTime}, #{modifyUserId,jdbcType=VARCHAR}, #{modifyTime},
+                #{isDeleted,jdbcType=VARCHAR}, #{share,jdbcType=VARCHAR}, #{videoPreview,jdbcType=VARCHAR},
+                #{videoAddress,jdbcType=VARCHAR}, #{osgbAddress,jdbcType=VARCHAR},
+                #{xmlAddress,jdbcType=VARCHAR}, #{xodrAddress,jdbcType=VARCHAR}, #{jsonAddress,jdbcType=VARCHAR},
+                #{maxTime,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="selectAllByName" parameterType="api.common.pojo.po.scene.SceneReferenceLibPO"
+            resultType="api.common.pojo.po.scene.SceneReferenceLibPO">
+        select scene_id,
+               scene_name,
+               main_behavior,
+               other_behavior,
+               create_user_id,
+               create_time,
+               modify_user_id,
+               modify_time,
+               is_deleted,
+               video_preview,
+               video_address,
+               osgb_address,
+               xml_address,
+               xodr_address,
+               json_address,
+               max_time
+        from simulation.scene_reference_lib
+        where is_deleted = '0'
+          and scene_name = #{sceneName,jdbcType=VARCHAR}
+    </select>
+
+    <update id="updateSceneReference" parameterType="api.common.pojo.po.scene.SceneReferenceLibPO">
+        update simulation.scene_reference_lib
+        set scene_name=#{sceneName},
+            main_behavior=#{mainBehavior},
+            other_behavior=#{otherBehavior},
+            weather=#{weather},
+            road_type=#{roadType},
+            road_geometry_plane=#{roadGeometryPlane},
+            road_geometry_vertical=#{roadGeometryVertical},
+            auto_drive_function=#{autoDriveFunction},
+            operation_area=#{operationArea},
+            scene_description=#{sceneDescription},
+            label=#{label},
+            is_deleted=#{isDeleted},
+            modify_user_id=#{modifyUserId},
+            modify_time=#{modifyTime},
+            video_address=#{videoAddress},
+            osgb_address=#{osgbAddress},
+            xml_address=#{xmlAddress},
+            xodr_address=#{xodrAddress},
+            json_address=#{jsonAddress},
+            video_preview=#{videoPreview},
+            max_time=#{maxTime}
+        where scene_id = #{sceneId,jdbcType=VARCHAR}
+    </update>
+
+    <select id="querySceneReferenceLibList" parameterType="api.common.pojo.param.scene.SceneReferenceLibParam"
+            resultType="api.common.pojo.po.scene.SceneReferenceLibPO">
+        SELECT
+           scene_id,
+           scene_name,
+           main_behavior,
+           other_behavior,
+           weather,
+           road_type,
+           road_geometry_plane,
+           road_geometry_vertical,
+           auto_drive_function,
+           operation_area,
+           scene_description,
+           label,
+           create_time,
+           modify_user_id,
+           modify_time,
+           video_preview,
+           video_address,
+           osgb_address,
+           xml_address,
+           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>
+        <where>
+            is_deleted = '0'
+            <if test="sceneName != null and sceneName != ''">
+                AND srl.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}
+            </if>
+            <if test="label != null and label != ''">
+                AND srl.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}
+                </foreach>
+
+            </if>
+            <if test="otherBehavior != null and otherBehavior.size()>0">
+                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}
+                </foreach>
+            </if>
+            <if test="weather != null and weather.size()>0 ">
+                AND srl.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
+                <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
+                <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
+                <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
+                <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
+                <foreach collection="operationArea" item="item" index="index"
+                         separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        ORDER BY srl.create_time,srl.scene_name DESC
+
+    </select>
+
+</mapper>