Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

martin 3 vuotta sitten
vanhempi
commit
1a8c6e1bfd
100 muutettua tiedostoa jossa 2819 lisäystä ja 529 poistoa
  1. 17 0
      api-common/src/main/java/api/common/pojo/constants/DictConstants.java
  2. 26 13
      api-common/src/main/java/api/common/pojo/constants/LogConstants.java
  3. 3 0
      api-common/src/main/java/api/common/pojo/param/algorithm/AlgorithmParameter.java
  4. 2 0
      api-common/src/main/java/api/common/pojo/param/project/ProjectTaskParam.java
  5. 13 0
      api-common/src/main/java/api/common/pojo/param/scene/SceneImportParam.java
  6. 33 0
      api-common/src/main/java/api/common/pojo/param/scene/SystemScenePackageParam.java
  7. 21 0
      api-common/src/main/java/api/common/pojo/param/system/SceneImportPageParam.java
  8. 5 1
      api-common/src/main/java/api/common/pojo/po/algorithm/AlgorithmPO.java
  9. 27 0
      api-common/src/main/java/api/common/pojo/po/scene/SystemScenePackageNewPO.java
  10. 22 0
      api-common/src/main/java/api/common/pojo/po/scene/SystemScenePackagePO.java
  11. 23 0
      api-common/src/main/java/api/common/pojo/po/scene/SystemScenePackageSublistPO.java
  12. 2 3
      api-common/src/main/java/api/common/pojo/po/scene/SystemUserScenePO.java
  13. 1 0
      api-common/src/main/java/api/common/pojo/po/system/ClusterPO.java
  14. 1 0
      api-common/src/main/java/api/common/pojo/po/system/ParameterPO.java
  15. 27 0
      api-common/src/main/java/api/common/pojo/po/system/SceneImportPO.java
  16. 8 0
      api-common/src/main/java/api/common/pojo/vo/project/ProjectDetailsVo.java
  17. 3 0
      api-common/src/main/java/api/common/pojo/vo/project/ProjectReportVo.java
  18. 4 0
      api-common/src/main/java/api/common/pojo/vo/project/ProjectTaskDetailsVo.java
  19. 20 0
      api-common/src/main/java/api/common/pojo/vo/scene/PackageVO.java
  20. 34 0
      api-common/src/main/java/api/common/pojo/vo/scene/SystemScenePackageVO.java
  21. 23 0
      api-common/src/main/java/api/common/pojo/vo/scene/SystemUserSceneVO.java
  22. 21 0
      api-common/src/main/java/api/common/pojo/vo/scene/UserSceneVO.java
  23. 1 1
      api-common/src/main/java/api/common/pojo/vo/system/ClusterVO.java
  24. 4 4
      api-common/src/main/java/api/common/util/LogUtil.java
  25. 41 12
      api-common/src/main/java/api/common/util/TimeUtil.java
  26. 1 0
      pom.xml
  27. 1 0
      simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/cofiguration/oauth/MyUserAuthenticationConverter.java
  28. 1 0
      simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/cofiguration/security/MyUserDetails.java
  29. 1 0
      simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/cofiguration/security/MyUserDetailsService.java
  30. 1 0
      simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/mapper/UserMapper.java
  31. 2 2
      simulation-resource-monitor/src/main/resources/bootstrap-dev.yaml
  32. 128 0
      simulation-resource-scene/pom.xml
  33. 66 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SceneImportCtrl.java
  34. 13 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SceneImportMapper.java
  35. 25 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SceneImportService.java
  36. 19 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SimulationResourceSceneApplication.java
  37. 30 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/config/FeignConfiguration.java
  38. 53 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/config/OAuth2Config.java
  39. 85 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/config/TransactionConfig.java
  40. 48 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/exception/GlobalExceptionHandler.java
  41. 45 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/oauth/MyUserAuthenticationConverter.java
  42. 59 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/oauth/MyUserDetails.java
  43. 16 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/oauth/OauthParameter.java
  44. 62 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/utils/AuthUtil.java
  45. 48 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/utils/PoUtil.java
  46. 18 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/feign/SceneService.java
  47. 12 0
      simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/feign/SceneServiceFallback.java
  48. 11 0
      simulation-resource-scene/src/main/resources/bootstrap-dev.yaml
  49. 10 0
      simulation-resource-scene/src/main/resources/bootstrap.yaml
  50. 14 0
      simulation-resource-scene/src/main/resources/mapper/SceneImportMapper.xml
  51. 7 13
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/ctrl/AlgorithmCtrl.java
  52. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/mapper/AlgorithmMapper.java
  53. 2 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/AlgorithmService.java
  54. 76 72
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java
  55. 1 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/MyUserAuthenticationConverter.java
  56. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/MyUserDetails.java
  57. 14 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/common/utils/AuthUtil.java
  58. 3 3
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/RedisService.java
  59. 24 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/SceneService.java
  60. 13 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/SceneServiceFallback.java
  61. 93 9
      simulation-resource-server/src/main/java/com/css/simulation/resource/log/service/LogService.java
  62. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/CameraCtrl.java
  63. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/ConfigCtrl.java
  64. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/GpsCtrl.java
  65. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/LidarCtrl.java
  66. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/OgtCtrl.java
  67. 5 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/CameraService.java
  68. 5 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/ConfigService.java
  69. 5 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/GpsService.java
  70. 5 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/LidarService.java
  71. 5 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/OgtService.java
  72. 8 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/VehicleTempService.java
  73. 0 3
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/constants/ProjectConstants.java
  74. 9 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/ctrl/SimulationProjectCtrl.java
  75. 172 75
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java
  76. 2 9
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationAutomaticProjectMapper.java
  77. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationProjectMapper.java
  78. 5 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationProjectTaskMapper.java
  79. 15 5
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneAccidentController.java
  80. 20 29
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneGeneralTemplateController.java
  81. 17 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneNaturalController.java
  82. 7 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/ScenePackageController.java
  83. 17 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/StandardsRegulationsController.java
  84. 128 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SystemScenePackageController.java
  85. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/ScenePackageMapper.java
  86. 26 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemScenePackageMapper.java
  87. 18 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemScenePackageSublistMapper.java
  88. 6 5
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemUserSceneMapper.java
  89. 115 95
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneAccidentService.java
  90. 8 3
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralExampleService.java
  91. 170 3
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneNaturalService.java
  92. 92 76
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/ScenePackageService.java
  93. 114 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/StandardsRegulationsService.java
  94. 342 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SystemScenePackageService.java
  95. 5 17
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SystemUserSceneService.java
  96. 15 54
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ClusterCtrl.java
  97. 15 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ParameterCtrl.java
  98. 64 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/SceneImportCtrl.java
  99. 1 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ClusterMapper.java
  100. 3 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ParameterMapper.java

+ 17 - 0
api-common/src/main/java/api/common/pojo/constants/DictConstants.java

@@ -28,6 +28,10 @@ public class DictConstants {
     public static final String VALIDATION_STATUS = "validationStatus";//项目运行状态
     public static final String ROLE_CODE = "roleCode";//用户类型(角色编码)
     public static final String USE_TYPE = "useType";//占用类型
+    public static final String SCENE_TYPE = "sceneType";//场景类型
+    public static final String SCENE_IMPORT_STATUS = "sceneImportStatus";//场景上传状态
+
+
 
     public static final String ALGORITHM_FILE = "algorithmFile";//算法文件上传type
 
@@ -79,6 +83,8 @@ public class DictConstants {
     //算法上传方式
     public static final String FILE = "1"; //文件上传
     public static final String GIT = "2"; //仓库地址
+    public static final String PLATFORM = "3"; //算法平台
+
 
     //报告评测等级
     public static final String REPORT_LEVEL_G = "G";
@@ -98,4 +104,15 @@ public class DictConstants {
     public static final String TASK_ERROR_REASON_3 = "容器终止!";
     public static final String TASK_ERROR_REASON_4 = "未知状态!";
     public static final String TASK_ERROR_REASON_5 = "打分出错!";
+
+    public static final String USE_TYPE_EXCLUSIVE = "1";//独占使用
+    public static final String USE_TYPE_PUBLIC = "2";//公共使用
+
+    //场景上传任务状态
+    public static final String SCENE_IMPORT_STATUS_0 = "0"; //未上传
+    public static final String SCENE_IMPORT_STATUS_1 = "1"; //上传中
+    public static final String SCENE_IMPORT_STATUS_2 = "2"; //上传完成
+    public static final String SCENE_IMPORT_STATUS_3 = "3"; //解析中
+    public static final String SCENE_IMPORT_STATUS_4 = "4"; //解析完成
+
 }

+ 26 - 13
api-common/src/main/java/api/common/pojo/constants/LogConstants.java

@@ -3,23 +3,22 @@ package api.common.pojo.constants;
 public class LogConstants {
 
     //字典类型
-    public static final String MODULE_TYPE = "moduleType";//模块
+    public static final String MODULE_TYPE = "moduleType";//菜单模块
     public static final String OPERATION_TYPE = "operationType";//操作类型
     public static final String SYS_LOG_TYPE = "sysLogType";//系统日志类型
 
     //字典项
-    public static final String MODULE_VEHICLE = "1";//模块-车辆模型
-    public static final String MODULE_CAMERA = "2";//模块-传感器模型-摄像头
-    public static final String MODULE_OGT = "3";//模块-传感器模型-完美传感器
-    public static final String MODULE_LIDAR = "4";//模块-传感器模型-激光雷达
-    public static final String MODULE_GPS = "5";//模块-传感器模型-GPS
-    public static final String MODULE_CONFIG = "6";//模块-车辆配置
-    public static final String MODULE_ALGORITH = "7";//模块-算法库
-    public static final String MODULE_SCENE_TEST_PACKAGE = "8";//模块-场景库-场景测试包
-    public static final String MODULE_SCORING = "9";//模块-场景库-评分规则
-    public static final String MODULE_SCENE_NATURAL = "10";//模块-场景库-自然驾驶场景
-    public static final String MODULE_SCENE_STANDARDS = "11";//模块-场景库-标准法规场景
-    public static final String MODULE_SCENE_ACCIDENT = "12";//模块-场景库-交通事故场景
+    public static final String MODULE_VEHICLE = "01";//模块-车辆模型
+    public static final String MODULE_CAMERA = "02";//模块-传感器模型-摄像头
+    public static final String MODULE_OGT = "03";//模块-传感器模型-完美传感器
+    public static final String MODULE_LIDAR = "04";//模块-传感器模型-激光雷达
+    public static final String MODULE_GPS = "05";//模块-传感器模型-GPS
+    public static final String MODULE_CONFIG = "06";//模块-车辆配置
+    public static final String MODULE_ALGORITH = "07";//模块-算法库
+    public static final String MODULE_SCENE_TEST_PACKAGE = "08";//模块-场景库-场景测试包
+    public static final String MODULE_SCORING = "09";//模块-场景库-评分规则
+    public static final String MODULE_PROJECT_MANUAL = "10";//模块-工作管理-手动运行项目
+    public static final String MODULE_PROJECT_AUTO = "11";//模块-工作管理-自动运行项目
 
 
     public static final String SYS_LOG_USER = "01";//用户管理
@@ -28,5 +27,19 @@ public class LogConstants {
     public static final String SYS_LOG_USER_RESET = "0103";//用户管理-重置密码
     public static final String SYS_LOG_USER_START = "0104";//用户管理-启用
     public static final String SYS_LOG_USER_STOP = "0105";//用户管理-停用
+    public static final String SYS_LOG_PARAM = "02";//参数管理
+    public static final String SYS_LOG_PARAM_INSERT = "0201";//参数管理-编辑即新增
+    public static final String SYS_LOG_PARAM_DELETE = "0202";//集群管理-删除
+    public static final String SYS_LOG_CLUSTER = "03";//集群管理
+    public static final String SYS_LOG_CLUSTER_INSERT = "0301";//集群管理-编辑即新增
+    public static final String SYS_LOG_CLUSTER_DELETE = "0302";//集群管理-删除
+    public static final String SYS_LOG_VEHICLE = "04";//车辆模板管理
+    public static final String SYS_LOG_VEHICLE_INSERT = "0401";//车辆模板管理-新增
+    public static final String SYS_LOG_VEHICLE_UPDATE = "0402";//车辆模板管理-修改
+    public static final String SYS_LOG_VEHICLE_DEL = "0403";//车辆模板管理-删除
+    public static final String SYS_LOG_SCENE_TASK = "05";//场景上传
+    public static final String SYS_LOG_SCENE = "06";//场景管理
+    public static final String SYS_LOG_PACKAGE = "07";//场景包管理
+    public static final String SYS_LOG_PACKAGE_GRANT = "08";//场景包分配
 
 }

+ 3 - 0
api-common/src/main/java/api/common/pojo/param/algorithm/AlgorithmParameter.java

@@ -34,6 +34,9 @@ public class AlgorithmParameter extends PageParameter {
     //代码仓库访问密码
     private String gitPassword;
 
+    //代码仓库版本号
+    private String gitVersion;
+
     //算法文件在 minio 上的位置
     private String minioPath;
 

+ 2 - 0
api-common/src/main/java/api/common/pojo/param/project/ProjectTaskParam.java

@@ -15,4 +15,6 @@ public class ProjectTaskParam {
     private String pId;
 
     private String sceneId;
+
+    private String taskId;
 }

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

@@ -0,0 +1,13 @@
+package api.common.pojo.param.scene;
+
+import lombok.Data;
+
+@Data
+public class SceneImportParam {
+
+    //任务id
+    private String id;
+    //Minio路径
+    private String minioDirectory;
+
+}

+ 33 - 0
api-common/src/main/java/api/common/pojo/param/scene/SystemScenePackageParam.java

@@ -0,0 +1,33 @@
+package api.common.pojo.param.scene;
+
+import api.common.pojo.common.CommonPO;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 人员场景包表。
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemScenePackageParam extends CommonPO   implements Serializable {
+    private String id;              // 主键
+    private String packageName;        // 场景包名
+    private String sceneDescribe;          // 场景包描述
+    private String userName;          // 账号名称
+
+    public String yearMax;//结束时间
+
+    public String yearMin;//开始时间
+
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    private Integer currentPage=1;
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    private Integer pageSize=10;
+}

+ 21 - 0
api-common/src/main/java/api/common/pojo/param/system/SceneImportPageParam.java

@@ -0,0 +1,21 @@
+package api.common.pojo.param.system;
+
+import api.common.pojo.common.PageVO;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.sql.Timestamp;
+
+@Data
+public class SceneImportPageParam extends PageVO {
+
+    //任务名称
+    private String name;
+    //开始时间
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Timestamp timeBegin;
+    //结束时间
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Timestamp timeEnd;
+
+}

+ 5 - 1
api-common/src/main/java/api/common/pojo/po/algorithm/AlgorithmPO.java

@@ -1,5 +1,6 @@
 package api.common.pojo.po.algorithm;
 
+import api.common.pojo.common.CommonPO;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -8,7 +9,10 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-public class AlgorithmPO extends BasePo {
+public class AlgorithmPO extends CommonPO {
+
+    //算法id
+    private String id;
 
     //算法名称
     private String algorithmName;

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

@@ -0,0 +1,27 @@
+package api.common.pojo.po.scene;
+
+import api.common.pojo.common.CommonPO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 人员场景包表。
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemScenePackageNewPO extends CommonPO implements Serializable {
+    private String id;              // 主键
+    private String packageName;        // 场景包名
+    private String sceneDescribe;          // 场景包描述
+    private List<String> zrIds;          // 自然场景ids
+    private List<String> bzIds;          // 标准法规场景ids
+    private List<String> jtIds;          // 交通事故自然场景ids
+    private List<String> fhIds;          // 泛化模板场景ids
+}

+ 22 - 0
api-common/src/main/java/api/common/pojo/po/scene/SystemScenePackagePO.java

@@ -0,0 +1,22 @@
+package api.common.pojo.po.scene;
+
+import api.common.pojo.common.CommonPO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 人员场景包表。
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemScenePackagePO extends CommonPO implements Serializable {
+    private String id;              // 主键
+    private String packageName;        // 场景包名
+    private String sceneDescribe;          // 场景包描述
+}

+ 23 - 0
api-common/src/main/java/api/common/pojo/po/scene/SystemScenePackageSublistPO.java

@@ -0,0 +1,23 @@
+package api.common.pojo.po.scene;
+
+import api.common.pojo.common.CommonPO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 人员场景包子表。
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemScenePackageSublistPO extends CommonPO implements Serializable {
+    private String sublistId;              // 主键
+    private String sceneType;        // 场景类型
+    private String sceneId;        // 场景id
+    private String sceneAndPackage;          // 关联场景包id
+}

+ 2 - 3
api-common/src/main/java/api/common/pojo/po/scene/SystemUserScenePO.java

@@ -7,7 +7,6 @@ import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
-import java.util.List;
 
 /**
  * 用户场景关联表。
@@ -19,6 +18,6 @@ import java.util.List;
 public class SystemUserScenePO extends CommonPO implements Serializable {
     private String id;              // 主键
     private String userId;        // 用户id
-    private String sceneId;          // 场景id
-    private String sceneType;          // 场景类型
+    private String packageId;          // 场景包id
+
 }

+ 1 - 0
api-common/src/main/java/api/common/pojo/po/system/ClusterPO.java

@@ -10,6 +10,7 @@ public class ClusterPO extends CommonPO {
 
     private String id;              // 用户主键(唯一)
     private String userId;        // 账户id
+    private String userName;      //账户名称
     private int numSimulationLicense;        // 仿真软件license数量
     private Date dateSimulationLicense;       // 仿真软件license到期时间
     private int numDynamicLicense;        // 动力学软件license数量

+ 1 - 0
api-common/src/main/java/api/common/pojo/po/system/ParameterPO.java

@@ -8,6 +8,7 @@ public class ParameterPO extends CommonPO {
 
     private String id;              // 用户主键(唯一)
     private String userId;        // 账户id
+    private String userName;      //账户名称
     private int numCreateUser;        // 可创建子账户数量
     private int numCreateScenePackage;           // 最多可创建场景测试包数量
     private int numScenePerPackage;           // 场景测试包最大场景数量

+ 27 - 0
api-common/src/main/java/api/common/pojo/po/system/SceneImportPO.java

@@ -0,0 +1,27 @@
+package api.common.pojo.po.system;
+
+import api.common.pojo.common.CommonPO;
+import lombok.Data;
+
+@Data
+public class SceneImportPO extends CommonPO {
+    
+    //任务id
+    private String id;
+    //任务名称
+    private String name;
+    //场景包路径
+    private String dataDirectory;
+    //场景类型
+    private String sceneType;
+    //任务执行状态
+    private String status;
+    //成功数量
+    private int successNum;
+    //失败数量
+    private int falseNum;
+    //错误信息
+    private String errorMessage;
+    //总用时长
+    private String totalTime;
+}

+ 8 - 0
api-common/src/main/java/api/common/pojo/vo/project/ProjectDetailsVo.java

@@ -75,6 +75,9 @@ public class ProjectDetailsVo {
     //运行结果统计
     private List<ProjectRunResultRatioNumVo> resultList;
 
+    //运行得分统计
+    private List<ProjectRunResultRatioNumVo> resultScoreList;
+
     //并行度
     private String parallelism;
 
@@ -87,5 +90,10 @@ public class ProjectDetailsVo {
     //是否生成报告
     private boolean createReport;
 
+    //场景包名
+    private String packageName;
+
+    //算法测试得分
+    private List<AlgorithmScoreVo> algorithmScoreList;
 
 }

+ 3 - 0
api-common/src/main/java/api/common/pojo/vo/project/ProjectReportVo.java

@@ -56,6 +56,9 @@ public class ProjectReportVo {
 
     private List<SceneScListVo> sceneScoreLi;
 
+    //场景包名
+    private String packageName;
+
 
 }
 

+ 4 - 0
api-common/src/main/java/api/common/pojo/vo/project/ProjectTaskDetailsVo.java

@@ -97,5 +97,9 @@ public class ProjectTaskDetailsVo {
     //视频地址
     private List<String> videoUrl;
 
+    private List<Map> sceneScoreLiTitle;
+
+    private List<SceneScListVo> sceneScoreLi;
+
 
 }

+ 20 - 0
api-common/src/main/java/api/common/pojo/vo/scene/PackageVO.java

@@ -0,0 +1,20 @@
+package api.common.pojo.vo.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 场景包用
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class PackageVO implements Serializable {
+    private String id;
+    private String packageId;              // 场景包id
+    private String packageName;        // 场景包名称
+
+}

+ 34 - 0
api-common/src/main/java/api/common/pojo/vo/scene/SystemScenePackageVO.java

@@ -0,0 +1,34 @@
+package api.common.pojo.vo.scene;
+
+import api.common.pojo.common.CommonPO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 人员场景包表。
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemScenePackageVO extends CommonPO implements Serializable {
+    private String id;              // 主键
+    private String packageName;        // 场景包名
+    private String sceneDescribe;          // 场景包描述
+    private Integer userCount;            // 配置人数
+    private Integer zrCount;             // 自然场景数量
+    private Integer bzCount;            // 标准法规数量
+    private Integer jtCount;            // 交通事故数量
+    private Integer fhCount;          // 泛化数量
+
+    private String userId;
+    private String userName;
+    private String packageId;
+
+
+
+}

+ 23 - 0
api-common/src/main/java/api/common/pojo/vo/scene/SystemUserSceneVO.java

@@ -0,0 +1,23 @@
+package api.common.pojo.vo.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 用户场景关联表。
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemUserSceneVO  implements Serializable {
+    private String id;              // 主键
+    private String packageId;        // 场景包id
+    private String userId;//用户id
+    private List<UserSceneVO> userIds;//用户集合
+    private List<PackageVO> packageList;//场景包集合
+
+}

+ 21 - 0
api-common/src/main/java/api/common/pojo/vo/scene/UserSceneVO.java

@@ -0,0 +1,21 @@
+package api.common.pojo.vo.scene;
+
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 场景包用
+ */
+@EqualsAndHashCode()
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class UserSceneVO implements Serializable {
+    private String id;
+    private String userId;              // 用户id
+    private String userName;        // 用户名
+
+}

+ 1 - 1
api-common/src/main/java/api/common/pojo/vo/system/ClusterVO.java

@@ -9,7 +9,7 @@ public class ClusterVO {
 
     private String id;              // 用户主键(唯一)
     private String userName;        // 账户名称
-    private String userType;        // 占用类型
+    private String useType;        // 占用类型
     private String userId;        // 账户id
     private int numSimulationLicense;        // 仿真软件license数量
     private Date dateSimulationLicense;       // 仿真软件license到期时间

+ 4 - 4
api-common/src/main/java/api/common/util/LogUtil.java

@@ -5,15 +5,15 @@ public abstract class LogUtil {
     protected static final ThreadLocal<String> OPERATION_TYPE = new ThreadLocal();
 
     public static void insert(){
-        OPERATION_TYPE.set("1");
+        OPERATION_TYPE.set("01");
     };
 
     public static void update(){
-        OPERATION_TYPE.set("2");
+        OPERATION_TYPE.set("02");
     };
 
     public static void delete(){
-        OPERATION_TYPE.set("0");
+        OPERATION_TYPE.set("00");
     };
 
     public static String getOperationType(){
@@ -25,7 +25,7 @@ public abstract class LogUtil {
     };
 
     public static void share() {
-        OPERATION_TYPE.set("3");
+        OPERATION_TYPE.set("03");
     }
 
 }

+ 41 - 12
api-common/src/main/java/api/common/util/TimeUtil.java

@@ -7,17 +7,18 @@ import java.util.*;
 
 public class TimeUtil {
 
-    private static String[] dateFmtArr= new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss","yyyy-MM-dd","HHmmssSS","HH:mm:ss","yyyyMMddHHmmss"};
+    private static String[] dateFmtArr = new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "HHmmssSS", "HH:mm:ss", "yyyyMMddHHmmss"};
 
     public static long getNow() {
         return System.currentTimeMillis();
     }
+
     public static long getNowLong() {
         return System.currentTimeMillis();
     }
 
     public static String getNowString() {
-        return System.currentTimeMillis()+"";
+        return System.currentTimeMillis() + "";
     }
 
     public static Timestamp getNowForMysql() {
@@ -27,19 +28,21 @@ public class TimeUtil {
     public static long zeroOfToday() {
         return System.currentTimeMillis() / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();
     }
-        //获取时间类型格式转化
-    public static Integer getRq(Date date, int index){
+
+    //获取时间类型格式转化
+    public static Integer getRq(Date date, int index) {
         SimpleDateFormat sdf = new SimpleDateFormat(dateFmtArr[index]);
-        if(date == null){
+        if (date == null) {
             date = new Date();
         }
         return Integer.valueOf(sdf.format(date));
 
     }
+
     //获取时间类型格式转化
-    public static String getToStringDate(Date date, int index){
+    public static String getToStringDate(Date date, int index) {
         SimpleDateFormat sdf = new SimpleDateFormat(dateFmtArr[index]);
-        if(date == null){
+        if (date == null) {
             date = new Date();
         }
         return sdf.format(date);
@@ -47,17 +50,17 @@ public class TimeUtil {
     }
 
     //获取过去某天的起始日期
-    public static Map<String,Object> getPastTime(Integer num) {
+    public static Map<String, Object> getPastTime(Integer num) {
         Calendar c = Calendar.getInstance();
         c.setTime(new Date());
         c.add(Calendar.DATE, -num);
         Date d = c.getTime();
-        String  startDate=getToStringDate(d,2) + " 00:00:00";
-        String  endDate=getToStringDate(d,2) + " 23:59:59";
-        Map<String,Object> map = new HashMap();
+        String startDate = getToStringDate(d, 2) + " 00:00:00";
+        String endDate = getToStringDate(d, 2) + " 23:59:59";
+        Map<String, Object> map = new HashMap();
         map.put("startDate", startDate);
         map.put("endDate", endDate);
-        map.put("toDate", getToStringDate(d,2));
+        map.put("toDate", getToStringDate(d, 2));
         return map;
     }
 
@@ -65,4 +68,30 @@ public class TimeUtil {
     public static Timestamp getPostTimestamp(int secends) {
         return new Timestamp(System.currentTimeMillis() + secends * 1000);
     }
+
+    //获取两个时间间隔
+    public static String getTimeDifference(Date dateStart, Date dateStop) {
+        String message = "";
+        try {
+            //毫秒ms
+            long diff = dateStop.getTime() - dateStart.getTime();
+            long diffSeconds = diff / 1000 % 60;
+            long diffMinutes = diff / (60 * 1000) % 60;
+            long diffHours = diff / (60 * 60 * 1000) % 24;
+            long diffDays = diff / (24 * 60 * 60 * 1000);
+            if (diffDays > 0) {
+                message = diffDays + "天" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒";
+            } else if (diffDays == 0 && diffHours != 0) {
+                message = diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒";
+            } else if (diffDays == 0 && diffHours == 0 && diffMinutes != 0) {
+                message = diffMinutes + "分钟" + diffSeconds + "秒";
+            } else if (diffDays == 0 && diffHours == 0 && diffMinutes == 0 && diffSeconds != 0) {
+                message = diffSeconds + "秒";
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return message;
+    }
+
 }

+ 1 - 0
pom.xml

@@ -20,6 +20,7 @@
         <module>api-common</module>
         <module>simulation-resource-common</module>
         <module>simulation-resource-monitor</module>
+        <module>simulation-resource-scene</module>
     </modules>
 
 

+ 1 - 0
simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/cofiguration/oauth/MyUserAuthenticationConverter.java

@@ -20,6 +20,7 @@ public class MyUserAuthenticationConverter extends DefaultUserAuthenticationConv
         response.put("id", myUserDetails.getId());
         response.put("username", authentication.getName());
         response.put("roleCode", myUserDetails.getRoleCode());
+        response.put("useType", myUserDetails.getUseType());
         response.put("createUserId", myUserDetails.getCreateUserId());
         //2 用户权限信息
         if (authentication.getAuthorities() != null && !authentication.getAuthorities().isEmpty()) {

+ 1 - 0
simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/cofiguration/security/MyUserDetails.java

@@ -20,6 +20,7 @@ public class MyUserDetails implements UserDetails, Serializable {
     private String username;
     private String password;
     private String roleCode;
+    private String useType;       // 占用类型
     private String createUserId;
     private Set<GrantedAuthority> authorities;
 

+ 1 - 0
simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/cofiguration/security/MyUserDetailsService.java

@@ -26,6 +26,7 @@ public class MyUserDetailsService implements UserDetailsService {
                 userPO.getUsername(),
                 userPO.getPassword(),
                 userPO.getRoleCode(),
+                userPO.getUseType(),
                 userPO.getCreateUserId(),
                 CollectionUtil.createHashSet(new SimpleGrantedAuthority("default11111111111"))
         );

+ 1 - 0
simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/mapper/UserMapper.java

@@ -14,6 +14,7 @@ public interface UserMapper {
             " username," +
             " password," +
             " role_code," +
+            " use_type," +
             " create_user_id" +
             " from system_user" +
             " where is_deleted = '0'" +

+ 2 - 2
simulation-resource-monitor/src/main/resources/bootstrap-dev.yaml

@@ -2,9 +2,9 @@ spring:
   cloud:
     nacos:
       discovery:
-        server-addr: 47.94.105.148:8848
+        server-addr: 10.12.10.70:8848
         namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
       config:
-        server-addr: 47.94.105.148:8848
+        server-addr: 10.12.10.70:8848
         namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
         file-extension: yaml

+ 128 - 0
simulation-resource-scene/pom.xml

@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>simulation-cloud</artifactId>
+        <groupId>com.css</groupId>
+        <version>1.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>simulation-resource-scene</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+    <dependencies>
+
+        <!-- 数据库 - 开始 -->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!-- 数据库 - 结束 -->
+
+        <!-- 权限认证 - 开始 -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-security</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-oauth2</artifactId>
+        </dependency>
+        <!-- 权限认证 - 结束 -->
+
+        <!-- nacos - 开始 -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+        <!-- nacos - 结束 -->
+
+        <!-- api-common -->
+        <dependency>
+            <groupId>com.css</groupId>
+            <artifactId>api-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- 基础 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-loadbalancer</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                    <addResources>true</addResources>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 66 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SceneImportCtrl.java

@@ -0,0 +1,66 @@
+package com.css.simulation.resource.scene;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
+import api.common.pojo.param.scene.SceneImportParam;
+import api.common.pojo.po.system.SceneImportPO;
+import com.css.simulation.resource.scene.feign.SceneService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.request.RequestContextHolder;
+
+import javax.annotation.Resource;
+
+@Controller
+@RequestMapping("/sceneImport")
+public class SceneImportCtrl {
+
+    @Autowired
+    SceneImportService sceneImportService;
+
+    @Resource
+    SceneService sceneService;
+
+    /**
+     * 上传
+     */
+    @RequestMapping("/startImport")
+    @ResponseBody
+    public ResponseBodyVO startImport(@RequestBody SceneImportPO po) {
+        try {
+            //开始上传
+            po.setStatus(DictConstants.SCENE_IMPORT_STATUS_1);
+            sceneImportService.updateStatus(po);
+            //上传
+            sceneImportService.startImport(po);
+            //上传成功
+            po.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+            sceneImportService.updateStatus(po);
+            SceneImportParam param = new SceneImportParam();
+            param.setId(po.getId());
+            param.setMinioDirectory(po.getDataDirectory());
+            //异步-启动解析
+            RequestContextHolder.setRequestAttributes(RequestContextHolder.getRequestAttributes(),true);
+            switch (po.getSceneType()){
+                case DictConstants.SCENE_NATURAL://自然驾驶
+                    sceneService.saveSceneAccidentBatch(param);
+                    break;
+                case DictConstants.SCENE_STANDARD:// 标准法规
+                    sceneService.saveSceneAccidentBatch(param);
+                    break;
+                case DictConstants.SCENE_ACCIDENT:// 交通事故
+                    sceneService.saveSceneAccidentBatch(param);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            po.setStatus(DictConstants.SCENE_IMPORT_STATUS_0);
+            po.setErrorMessage("上传失败");
+            sceneImportService.updateStatus(po);
+            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE);
+        }
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+}

+ 13 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SceneImportMapper.java

@@ -0,0 +1,13 @@
+package com.css.simulation.resource.scene;
+
+import api.common.pojo.po.system.SceneImportPO;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface SceneImportMapper {
+
+    void updateStatus(SceneImportPO po);
+
+}

+ 25 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SceneImportService.java

@@ -0,0 +1,25 @@
+package com.css.simulation.resource.scene;
+
+import api.common.pojo.po.system.SceneImportPO;
+import com.css.simulation.resource.scene.common.utils.PoUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SceneImportService {
+
+    @Autowired
+    SceneImportMapper sceneImportMapper;
+
+    public Boolean startImport(SceneImportPO po) {
+        //TODO
+        System.out.println(123);
+        return true;
+    }
+
+    public void updateStatus(SceneImportPO po) {
+        PoUtil.initUpdatePo(po);
+        sceneImportMapper.updateStatus(po);
+    }
+
+}

+ 19 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/SimulationResourceSceneApplication.java

@@ -0,0 +1,19 @@
+package com.css.simulation.resource.scene;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+
+@SpringBootApplication
+@EnableFeignClients
+@EnableResourceServer
+@EnableAsync
+public class SimulationResourceSceneApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(SimulationResourceSceneApplication.class, args);
+        System.out.println("-------------启动成功----------------");
+    }
+}

+ 30 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/config/FeignConfiguration.java

@@ -0,0 +1,30 @@
+package com.css.simulation.resource.scene.common.config;
+
+import feign.Logger;
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 转发 token
+ */
+@Configuration
+public class FeignConfiguration implements RequestInterceptor {
+
+    @Bean
+    public Logger.Level feignLoggerLevel() {
+        return Logger.Level.FULL;
+    }
+
+    @Override
+    public void apply(RequestTemplate requestTemplate) {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = attributes.getRequest();
+        requestTemplate.header("Authorization", request.getHeader("Authorization"));
+    }
+}

+ 53 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/config/OAuth2Config.java

@@ -0,0 +1,53 @@
+package com.css.simulation.resource.scene.common.config;
+
+import com.css.simulation.resource.scene.common.oauth.MyUserAuthenticationConverter;
+import com.css.simulation.resource.scene.common.oauth.OauthParameter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
+
+import javax.annotation.Resource;
+
+@Configuration
+public class OAuth2Config extends ResourceServerConfigurerAdapter {
+
+    @Resource
+    private OauthParameter oauthParameter;
+
+    @Resource
+    MyUserAuthenticationConverter myUserAuthenticationConverter;
+
+    @Override
+    public void configure(ResourceServerSecurityConfigurer resources) {
+        //令牌解析服务配置
+        RemoteTokenServices services = new RemoteTokenServices();
+        services.setCheckTokenEndpointUrl(oauthParameter.getCheckTokenEndpointUrl());  // 需要在授权服务器公开 /oauth/check_token
+        services.setClientId(oauthParameter.getClientId());
+        services.setClientSecret(oauthParameter.getClientSecret());
+        //自定义令牌转换器
+        DefaultAccessTokenConverter defaultAccessTokenConverter = new DefaultAccessTokenConverter();
+        defaultAccessTokenConverter.setUserTokenConverter(myUserAuthenticationConverter);
+        services.setAccessTokenConverter(defaultAccessTokenConverter);
+        resources.resourceId(oauthParameter.getResourceId())      // 资源 id
+                .tokenServices(services)    // 使用远程服务验证令牌的服务
+                .stateless(true);   // 无状态模式,即无需用户登录,无 session
+    }
+
+    /**
+     * 配置拦截请求,通过 scope
+     */
+    @Override
+    public void configure(HttpSecurity http) throws Exception {
+        http.csrf().disable()   // 禁用 csrf
+                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)// 无状态验证
+                .and()
+                .authorizeRequests()
+                .antMatchers("/druid/**").permitAll()
+                .anyRequest().access("#oauth2.hasScope('all')") // 拦截所有请求判断 scope
+        ;
+    }
+}

+ 85 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/config/TransactionConfig.java

@@ -0,0 +1,85 @@
+package com.css.simulation.resource.scene.common.config;
+
+import org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionManager;
+import org.springframework.transaction.interceptor.*;
+
+import javax.sql.DataSource;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 声明式事务配置
+ */
+@Configuration
+public class TransactionConfig {
+
+    @Autowired
+    DataSource dataSource;
+
+    @Bean(name = "masterTransactionManager")
+    public DataSourceTransactionManager masterTransactionManager(DataSource dataSource) {
+        return new DataSourceTransactionManager(dataSource);
+    }
+
+    @Autowired
+    @Qualifier(value = "masterTransactionManager")
+    private TransactionManager transactionManager;
+
+    @Bean
+    public TransactionInterceptor txAdvice() {
+
+        /*只读事务,不做更新操作*/
+        RuleBasedTransactionAttribute readOnlyTx = new RuleBasedTransactionAttribute();
+        readOnlyTx.setReadOnly(true);
+        readOnlyTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_NOT_SUPPORTED);
+
+        /*当前存在事务就使用当前事务,当前不存在事务就创建一个新的事务*/
+        RuleBasedTransactionAttribute requiredTx = new RuleBasedTransactionAttribute();
+        requiredTx.setRollbackRules(Collections.singletonList(new RollbackRuleAttribute(Exception.class)));
+        requiredTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
+        requiredTx.setTimeout(5000);
+
+
+        Map<String, TransactionAttribute> txMap = new HashMap<>();
+        txMap.put("save*", requiredTx);
+        txMap.put("insert*", requiredTx);
+        txMap.put("update*", requiredTx);
+        txMap.put("remove*", requiredTx);
+        txMap.put("add*", requiredTx);
+        txMap.put("share*", requiredTx);
+        txMap.put("fx*", requiredTx);
+        txMap.put("del*", requiredTx);
+        /*select,count开头的方法,开启只读,提高数据库访问性能*/
+        txMap.put("select*", readOnlyTx);
+        txMap.put("query*", readOnlyTx);
+        txMap.put("get*", readOnlyTx);
+        txMap.put("list*", readOnlyTx);
+        txMap.put("find*", readOnlyTx);
+        txMap.put("count*", readOnlyTx);
+        txMap.put("*", requiredTx);
+
+        NameMatchTransactionAttributeSource source = new NameMatchTransactionAttributeSource();
+        source.setNameMap(txMap);
+
+        TransactionInterceptor txAdvice = new TransactionInterceptor(transactionManager, source);
+        return txAdvice;
+    }
+
+    @Bean
+    public BeanNameAutoProxyCreator txProxy() {
+        final BeanNameAutoProxyCreator creator = new BeanNameAutoProxyCreator();
+        creator.setInterceptorNames("txAdvice");
+        creator.setBeanNames("*Service");
+        creator.setProxyTargetClass(true);
+        return creator;
+    }
+
+}

+ 48 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/exception/GlobalExceptionHandler.java

@@ -0,0 +1,48 @@
+package com.css.simulation.resource.scene.common.exception;
+
+import api.common.pojo.common.ResponseBodyVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Scope;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.Objects;
+
+@ControllerAdvice
+@Slf4j
+@Scope("singleton")
+public class GlobalExceptionHandler {
+    /**
+     * 方法参数校验
+     */
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    @ResponseBody
+    public ResponseBodyVO<Object> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
+        log.error(e.getMessage(), e);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, Objects.requireNonNull(e.getBindingResult().getFieldError()).getDefaultMessage());
+    }
+
+    /**
+     * 请求体缺失异常统一处理
+     */
+    @ExceptionHandler(HttpMessageNotReadableException.class)
+    @ResponseBody
+    public ResponseBodyVO<Object> handleHttpMessageNotReadableException(Exception e) {
+        log.error(e.getMessage(), e);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "Required request body is missing!");
+    }
+
+    /**
+     * 服务器错误异常统一处理
+     */
+    @ExceptionHandler(Exception.class)
+    @ResponseBody
+    public ResponseBodyVO<Object> handleException(Exception e) {
+        log.error(e.getMessage(), e);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "服务器错误!");
+    }
+
+}

+ 45 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/oauth/MyUserAuthenticationConverter.java

@@ -0,0 +1,45 @@
+package com.css.simulation.resource.scene.common.oauth;
+
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.AuthorityUtils;
+import org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class MyUserAuthenticationConverter extends DefaultUserAuthenticationConverter {
+
+    @Override
+    public Authentication extractAuthentication(Map<String, ?> map) {
+        List<GrantedAuthority> list = new LinkedList<>();
+        //解析权限
+        if (map.containsKey(AUTHORITIES)) {
+            Object authorities = map.get(AUTHORITIES);
+            if (authorities instanceof String) {
+                list = AuthorityUtils.commaSeparatedStringToAuthorityList((String) authorities);
+            } else if (authorities instanceof Collection) {
+                list = AuthorityUtils.commaSeparatedStringToAuthorityList(StringUtils.collectionToCommaDelimitedString((Collection) authorities));
+            } else {
+                throw new IllegalArgumentException("Authorities must be either a String or a Collection");
+            }
+        }
+        //解析当前登录人信息
+        MyUserDetails userDetails = new MyUserDetails();
+        userDetails.setId((String) map.get("id"));
+        userDetails.setUsername((String) map.get("username"));
+        userDetails.setRoleCode((String) map.get("roleCode"));
+        userDetails.setUseType((String) map.get("useType"));
+        userDetails.setCreateUserId((String) map.get("createUserId"));
+        return new UsernamePasswordAuthenticationToken(userDetails, "N/A", list);
+    }
+
+
+
+}

+ 59 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/oauth/MyUserDetails.java

@@ -0,0 +1,59 @@
+package com.css.simulation.resource.scene.common.oauth;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.io.Serializable;
+import java.util.Set;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class MyUserDetails implements UserDetails, Serializable {
+    private static final long serialVersionUID = -158357727659030597L;
+    private String id;
+    private String username;
+    private String password;
+    private String roleCode;
+    private String useType;
+    private String createUserId;
+    private Set<GrantedAuthority> authorities;
+
+
+    /**
+     * 默认 false 是将用户账号过期,需改成 true 不过期
+     */
+    @Override
+    public boolean isAccountNonExpired() {
+        return true;
+    }
+
+    /**
+     * 默认 false 是将用户上锁,需改成 true 不上锁
+     */
+    @Override
+    public boolean isAccountNonLocked() {
+        return true;
+    }
+
+    /**
+     * 默认 false 是用户凭证国汽,需改成 true 不过期
+     */
+    @Override
+    public boolean isCredentialsNonExpired() {
+        return true;
+    }
+
+    /**
+     * 默认 false 是将用户失效,需改成 true 不失效
+     */
+    @Override
+    public boolean isEnabled() {
+        return true;
+    }
+}

+ 16 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/oauth/OauthParameter.java

@@ -0,0 +1,16 @@
+package com.css.simulation.resource.scene.common.oauth;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Data
+@Component
+@ConfigurationProperties(prefix="oauth")
+public class OauthParameter {
+
+    private String resourceId;
+    private String checkTokenEndpointUrl;
+    private String clientId;
+    private String clientSecret;
+}

+ 62 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/utils/AuthUtil.java

@@ -0,0 +1,62 @@
+package com.css.simulation.resource.scene.common.utils;
+
+import com.css.simulation.resource.scene.common.oauth.MyUserDetails;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * 认证信息工具类
+ */
+public class AuthUtil {
+
+    /**
+     * 获取当前登录人id
+     */
+    public static String getCurrentUserId(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
+        String userId = userDetails.getId();
+        return userId;
+    }
+
+    /**
+     * 获取当前登录人roleCode
+     */
+    public static String getCurrentUserRoleCode(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
+        String roleCode = userDetails.getRoleCode();
+        return roleCode;
+    }
+
+    /**
+     * 获取当前登录人useType
+     */
+    public static String getCurrentUseType(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
+        String useType = userDetails.getUseType();
+        return useType;
+    }
+
+    /**
+     * 获取当前登录人username
+     */
+    public static String getCurrentUsername(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
+        String username = userDetails.getUsername();
+        return username;
+    }
+
+    /**
+     * 获取当前登录人createUserId
+     */
+    public static String getCreateUserId(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
+        String createUserId = userDetails.getCreateUserId();
+        return createUserId;
+    }
+
+}

+ 48 - 0
simulation-resource-scene/src/main/java/com/css/simulation/resource/scene/common/utils/PoUtil.java

@@ -0,0 +1,48 @@
+package com.css.simulation.resource.scene.common.utils;
+
+import api.common.pojo.common.CommonPO;
+import api.common.pojo.constants.DictConstants;
+import api.common.util.ObjectUtil;
+import api.common.util.TimeUtil;
+
+import java.sql.Timestamp;
+
+public class PoUtil {
+
+    /**
+     * 初始化po的常规字段
+     */
+    public static void initAddPo(CommonPO po){
+        if(ObjectUtil.isNull(po)){
+            return ;
+        }
+        String currentUserId = AuthUtil.getCurrentUserId();
+        Timestamp currentTime = TimeUtil.getNowForMysql();
+        po.setCreateUserId(currentUserId);
+        po.setCreateTime(currentTime);
+        po.setModifyUserId(currentUserId);
+        po.setModifyTime(currentTime);
+        po.setIsDeleted(DictConstants.NO);
+    };
+
+    public static void initDelPo(CommonPO po){
+        if(ObjectUtil.isNull(po)){
+            return ;
+        }
+        String currentUserId = AuthUtil.getCurrentUserId();
+        Timestamp currentTime = TimeUtil.getNowForMysql();
+        po.setModifyUserId(currentUserId);
+        po.setModifyTime(currentTime);
+        po.setIsDeleted(DictConstants.YES);
+    };
+
+    public static void initUpdatePo(CommonPO po){
+        if(ObjectUtil.isNull(po)){
+            return ;
+        }
+        String currentUserId = AuthUtil.getCurrentUserId();
+        Timestamp currentTime = TimeUtil.getNowForMysql();
+        po.setModifyUserId(currentUserId);
+        po.setModifyTime(currentTime);
+    };
+}

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

@@ -0,0 +1,18 @@
+package com.css.simulation.resource.scene.feign;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.scene.SceneImportParam;
+import com.css.simulation.resource.scene.common.config.FeignConfiguration;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+
+@FeignClient(value = "simulation-resource-server",
+        contextId = "SceneService",
+        path = "/simulation/resource/server",
+        fallback = SceneServiceFallback.class,
+        configuration = FeignConfiguration.class)
+public interface SceneService {
+
+    @PostMapping("/SceneAccident/saveSceneAccidentBatch")
+    ResponseBodyVO saveSceneAccidentBatch(SceneImportParam sceneImportParam);
+}

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

@@ -0,0 +1,12 @@
+package com.css.simulation.resource.scene.feign;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.scene.SceneImportParam;
+
+public class SceneServiceFallback implements SceneService {
+
+    @Override
+    public ResponseBodyVO saveSceneAccidentBatch(SceneImportParam sceneImportParam) {
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE);
+    }
+}

+ 11 - 0
simulation-resource-scene/src/main/resources/bootstrap-dev.yaml

@@ -0,0 +1,11 @@
+#nacos配置
+spring:
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 10.12.10.70:8848
+        namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
+      config:
+        server-addr: 10.12.10.70:8848
+        namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
+        file-extension: yaml

+ 10 - 0
simulation-resource-scene/src/main/resources/bootstrap.yaml

@@ -0,0 +1,10 @@
+spring:
+  application:
+    name: simulation-resource-scene
+  profiles:
+    active: dev
+
+mybatis:
+  mapper-locations: classpath:/mapper/*.xml
+  configuration:
+    map-underscore-to-camel-case: true

+ 14 - 0
simulation-resource-scene/src/main/resources/mapper/SceneImportMapper.xml

@@ -0,0 +1,14 @@
+<?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.scene.SceneImportMapper" >
+
+    <update id="updateStatus" parameterType="api.common.pojo.po.system.SceneImportPO">
+        update scene_import_task set
+          error_message = #{errorMessage,jdbcType=VARCHAR},
+          status = #{status,jdbcType=VARCHAR},
+          modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+          modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
+    </update>
+
+</mapper>

+ 7 - 13
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/ctrl/AlgorithmCtrl.java

@@ -2,6 +2,7 @@ package com.css.simulation.resource.algorithm.ctrl;
 
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.algorithm.AlgorithmParameter;
 import com.css.simulation.resource.algorithm.service.AlgorithmService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +18,7 @@ import java.security.NoSuchAlgorithmException;
  * 算法库模块
  */
 @Controller
-@RequestMapping("/algorithm")
+@RequestMapping(value = "/algorithm",name = LogConstants.MODULE_ALGORITH)
 public class AlgorithmCtrl {
 
     @Autowired
@@ -70,16 +71,6 @@ public class AlgorithmCtrl {
         return service.selectSharedAlgorithmList(param);
     }
 
-    /**
-     * 判断算法绑定的项目是否正在运行
-     * @return
-     */
-    @RequestMapping("isAlgorithmRunning")
-    @ResponseBody
-    public ResponseBodyVO isAlgorithmRunning(@RequestBody AlgorithmParameter param){
-        return service.isAlgorithmRunning(param);
-    }
-
      /**
      * 删除算法
      * @return
@@ -110,7 +101,8 @@ public class AlgorithmCtrl {
     @RequestMapping("selectDetailsById")
     @ResponseBody
     public ResponseBodyVO selectDetailsById(@RequestBody AlgorithmParameter param){
-        return service.selectDetailsById(param);
+        String algorithmId = param.getId();
+        return service.selectDetailsById(algorithmId);
     }
 
     /**
@@ -132,7 +124,9 @@ public class AlgorithmCtrl {
     @RequestMapping("getGitVersion")
     @ResponseBody
     public ResponseBodyVO getGitVersion(@RequestBody AlgorithmParameter param) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
-        return service.getGitVersion(param);
+        String id = param.getId();
+        String gitVersion = service.getGitVersion(id);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"请求成功", gitVersion);
     }
 
 }

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/mapper/AlgorithmMapper.java

@@ -22,7 +22,7 @@ public interface AlgorithmMapper {
 
     int deleteByid(AlgorithmParameter param);
 
-    AlgorithmPO selectDetailsById(AlgorithmParameter param);
+    AlgorithmPO selectDetailsById(@Param("algorithmId") String algorithmId);
 
     List<AlgorithmPO> selectAlgorithmName(AlgorithmParameter param);
 

+ 2 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/AlgorithmService.java

@@ -20,9 +20,7 @@ public interface AlgorithmService {
 
     ResponseBodyVO deleteByid(AlgorithmParameter param);
 
-    ResponseBodyVO selectDetailsById(AlgorithmParameter param);
-
-    ResponseBodyVO isAlgorithmRunning(AlgorithmParameter param);
+    ResponseBodyVO selectDetailsById(String algorithmId);
 
     ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param);
 
@@ -30,7 +28,7 @@ public interface AlgorithmService {
 
     ResponseBodyVO testConnection(AlgorithmParameter param);
 
-    ResponseBodyVO getGitVersion(AlgorithmParameter param) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException;
+    String getGitVersion(String algorithmId);
 
     Map<String,Integer> selectDetailsBySy();
 }

+ 76 - 72
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java

@@ -12,10 +12,12 @@ import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
 import com.css.simulation.resource.algorithm.service.AlgorithmService;
+import com.css.simulation.resource.common.utils.PoUtil;
 import com.css.simulation.resource.feign.AlgoPlatformService;
 import com.css.simulation.resource.feign.FileDownService;
 import com.css.simulation.resource.feign.SchedulerService;
 import com.css.simulation.resource.system.service.DictService;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.github.pagehelper.PageInfo;
 import feign.Response;
 import org.eclipse.jgit.lib.Ref;
@@ -59,44 +61,55 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         if(algorithmPOS != null && algorithmPOS.size() > 0){
             return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法名称已存在!");
         }else {
-            String minioPath = param.getMinioPath();
-            ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
-            if(checkRes.isStatus()){
-                if(isEmpty(param.getId())){
-                    //添加
-                    String algorithmId = StringUtil.getRandomUUID();
-                    param.setId(algorithmId);
-                    String algorithmCode = StringUtil.getRandomCode();
-                    param.setAlgorithmCode(algorithmCode);
-                    AlgorithmPO po = setPo(param, false);
-                    int add = algorithmMapper.add(po);
-                    if(add > 0){
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
-                    }else {
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
-                    }
+            String uploadMode = param.getUploadMode();
+            if(DictConstants.FILE.equals(uploadMode)){
+                String minioPath = param.getMinioPath();
+                ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
+                if(checkRes.isStatus()){
+                    return doAddOrUpdate(param);
                 }else {
-                    //编辑
-                    AlgorithmPO po = setPo(param, true);
-                    int add = algorithmMapper.update(po);
-                    if (add > 0) {
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                    MinioParameter minioParameter = new MinioParameter();
+                    minioParameter.setObjectName(minioPath);
+                    Response remove =fileDownService.remove(minioParameter);
+                    if(remove.status() == 200){
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件已删除!");
                     }else {
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件删除失败!");
                     }
                 }
             }else {
-                MinioParameter minioParameter = new MinioParameter();
-                minioParameter.setObjectName(minioPath);
-                Response remove =fileDownService.remove(minioParameter);
-                if(remove.status() == 200){
-                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件已删除!");
-                }else {
-                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件删除失败!");
-                }
+                 return doAddOrUpdate(param);
             }
+        }
+    }
 
+    private ResponseBodyVO doAddOrUpdate(AlgorithmParameter param) {
+        if(isEmpty(param.getId())){
+            //添加
+            String algorithmId = StringUtil.getRandomUUID();
+            param.setId(algorithmId);
+            String algorithmCode = StringUtil.getRandomCode();
+            param.setAlgorithmCode(algorithmCode);
+            AlgorithmPO po = setPo(param, false);
+            int add = algorithmMapper.add(po);
+            if(add > 0){
+                LogUtil.insert();
+                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+            }else {
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
+            }
+        }else {
+            //编辑
+            AlgorithmPO po = setPo(param, true);
+            int add = algorithmMapper.update(po);
+            if (add > 0) {
+                LogUtil.update();
+                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+            }else {
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
+            }
         }
+
     }
 
     @Override
@@ -179,7 +192,8 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         if(isEmpty(param.getId())){
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
         }else {
-            AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+            String algorithmId = param.getId();
+            AlgorithmPO po = algorithmMapper.selectDetailsById(algorithmId);
             List<AlgorithmPO> algorithmPOS = algorithmMapper.selectSharedAlgorithmName(po.getAlgorithmName());
             if(algorithmPOS != null && algorithmPOS.size() > 0){
                 return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法名称已存在, 无法分享!");
@@ -189,6 +203,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
                 po.setAlgorithmCode(StringUtil.getRandomCode());
                 int add = algorithmMapper.add(po);
                 if(add > 0){
+                    LogUtil.share();
                     return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"分享成功");
                 }
                 return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"分享失败");
@@ -208,31 +223,34 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     }
 
     @Override
-    public ResponseBodyVO getGitVersion(AlgorithmParameter param) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
-
-        AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+    public String getGitVersion(String algorithmId)  {
+        AlgorithmPO po = algorithmMapper.selectDetailsById(algorithmId);
         String gitUrl = po.getGitUrl();
         if(StringUtil.isEmpty(gitUrl)){
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+            return "";
         }
         //拼接get请求地址
         String prefix = "https://api.github.com/repos/";
         String suffix = "/commits?page=1&per_page=1";
         String gitInfo = gitUrl.substring(19, gitUrl.length()-4);
         String requestUrl = prefix + gitInfo + suffix;
-        String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), requestUrl);
-        List<HashMap> hashMaps = JsonUtil.jsonToList(result, HashMap.class);
-        String sha = "";
-        if(hashMaps.size() > 0){
-            HashMap hashMap = hashMaps.get(0);
-            sha = hashMap.get("sha").toString();
+        try {
+            String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), requestUrl);
+            List<HashMap> hashMaps = JsonUtil.jsonToList(result, HashMap.class);
+            if(hashMaps.size() > 0){
+                HashMap hashMap = hashMaps.get(0);
+                String version = hashMap.get("sha").toString();
+                return version;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"请求成功", sha);
+        return StringUtil.getRandomCode();
     }
 
+
     @Override
-    public ResponseBodyVO isAlgorithmRunning(AlgorithmParameter param)
-    {
+    public ResponseBodyVO deleteByid(AlgorithmParameter param) {
         if(isEmpty(param.getId())){
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
         }else {
@@ -245,34 +263,25 @@ public class AlgorithmServiceImpl implements AlgorithmService {
                     stringBuffer.append(projectId+",");
                 }
                 String substring = stringBuffer.substring(0, stringBuffer.lastIndexOf(","));
-                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"已被工作ID:"+ substring +" 应用,无法删除");
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"已被工作ID:"+ substring +" 应用,无法删除");
             }else {
-                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
-            }
-
-        }
-    }
-
-    @Override
-    public ResponseBodyVO deleteByid(AlgorithmParameter param) {
-        if(isEmpty(param.getId())){
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
-        }else {
-            int i = algorithmMapper.deleteByid(param);
-            if(i > 0){
-                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                int i = algorithmMapper.deleteByid(param);
+                if(i > 0){
+                    LogUtil.delete();
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                }
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"删除失败");
             }
-            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"删除失败");
         }
 
     }
 
     @Override
-    public ResponseBodyVO selectDetailsById(AlgorithmParameter param) {
-        if(isEmpty(param.getId())){
+    public ResponseBodyVO selectDetailsById(String algorithmId) {
+        if(isEmpty(algorithmId)){
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
         }else {
-            AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+            AlgorithmPO po = algorithmMapper.selectDetailsById(algorithmId);
             po.setValidationStatus(getDictName(DictConstants.VALIDATION_STATUS, po.getValidationStatus()));
             return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,po);
         }
@@ -296,7 +305,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
 
         AlgorithmPO po = new AlgorithmPO();
         //设置po信息
-        if("2".equals(param.getUploadMode())){ //使用仓库地址上传
+        if(DictConstants.GIT.equals(param.getUploadMode())){ //使用仓库地址上传
             String gitUrl = param.getGitUrl();
             String gitUserName = param.getGitUserName();
             String gitPassword = param.getGitPassword();
@@ -315,18 +324,13 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         po.setDescription(param.getDescription());
         po.setUploadMode(param.getUploadMode());
         po.setValidationStatus(DictConstants.SUCCESS);
-        po.setShare("0");
+        po.setShare(DictConstants.NO);
         po.setId(param.getId());
 
         if(isEdit){
-            po.setModifyTime(TimeUtil.getNowForMysql());
-            po.setModifyUserId(AuthUtil.getCurrentUserId());
+            PoUtil.initUpdatePo(po);
         }else {
-            po.setIsDeleted("0");
-            po.setCreateTime(TimeUtil.getNowForMysql());
-            po.setModifyTime(TimeUtil.getNowForMysql());
-            po.setCreateUserId(AuthUtil.getCurrentUserId());
-            po.setModifyUserId(AuthUtil.getCurrentUserId());
+            PoUtil.initAddPo(po);
         }
         return po;
 

+ 1 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/MyUserAuthenticationConverter.java

@@ -32,6 +32,7 @@ public class MyUserAuthenticationConverter extends DefaultUserAuthenticationConv
         userDetails.setId((String) map.get("id"));
         userDetails.setUsername((String) map.get("username"));
         userDetails.setRoleCode((String) map.get("roleCode"));
+        userDetails.setUseType((String) map.get("useType"));
         userDetails.setCreateUserId((String) map.get("createUserId"));
         return new UsernamePasswordAuthenticationToken(userDetails, "N/A", list);
     }

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/MyUserDetails.java

@@ -20,7 +20,7 @@ public class MyUserDetails implements UserDetails, Serializable {
     private String username;
     private String password;
     private String roleCode;
-    private String userType;
+    private String useType;
     private String createUserId;
     private Set<GrantedAuthority> authorities;
 

+ 14 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/common/utils/AuthUtil.java

@@ -30,13 +30,13 @@ public class AuthUtil {
     }
 
     /**
-     * 获取当前登录人roleCode
+     * 获取当前登录人useType
      */
-    public static String getCurrentUserType(){
+    public static String getCurrentUseType(){
         Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
         MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
-        String userType = userDetails.getUserType();
-        return userType;
+        String useType = userDetails.getUseType();
+        return useType;
     }
 
     /**
@@ -49,4 +49,14 @@ public class AuthUtil {
         return username;
     }
 
+    /**
+     * 获取当前登录人createUserId
+     */
+    public static String getCreateUserId(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
+        String createUserId = userDetails.getCreateUserId();
+        return createUserId;
+    }
+
 }

+ 3 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/RedisService.java

@@ -13,12 +13,12 @@ import java.util.List;
 import java.util.Map;
 
 //@FeignClient(name = "test", url = "http://10.15.12.72:8001", fallback = RedisServiceFallback.class, configuration = FeignConfiguration.class)
-@FeignClient(name = "test1", url = "http://47.93.217.159", path = "/simulation/resource/common", fallback = RedisServiceFallback.class, configuration = FeignConfiguration.class)
-/*@FeignClient(value = "simulation-resource-common",
+//@FeignClient(name = "test1", url = "http://47.93.217.159", path = "/simulation/resource/common", fallback = RedisServiceFallback.class, configuration = FeignConfiguration.class)
+@FeignClient(value = "simulation-resource-common",
         contextId = "redis",
         path = "/simulation/resource/common",
         fallback = RedisServiceFallback.class,
-        configuration = FeignConfiguration.class)*/
+        configuration = FeignConfiguration.class)
 public interface RedisService {
 
     @PostMapping("/redis/setDictLists")

+ 24 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/SceneService.java

@@ -0,0 +1,24 @@
+package com.css.simulation.resource.feign;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.po.system.SceneImportPO;
+import com.css.simulation.resource.common.config.FeignConfiguration;
+import com.css.simulation.resource.feign.fallback.SceneServiceFallback;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.web.bind.annotation.PostMapping;
+
+
+
+@FeignClient(value = "simulation-resource-scene",
+        contextId = "scene",
+        path = "/simulation/resource/scene",
+        fallback = SceneServiceFallback.class,
+        configuration = FeignConfiguration.class)
+public interface SceneService {
+
+    @Async
+    @PostMapping("/sceneImport/startImport")
+    ResponseBodyVO startImport(SceneImportPO po);
+
+}

+ 13 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/SceneServiceFallback.java

@@ -0,0 +1,13 @@
+package com.css.simulation.resource.feign.fallback;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.po.system.SceneImportPO;
+import com.css.simulation.resource.feign.SceneService;
+
+public class SceneServiceFallback implements SceneService {
+
+    @Override
+    public ResponseBodyVO startImport(SceneImportPO po) {
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE);
+    }
+}

+ 93 - 9
simulation-resource-server/src/main/java/com/css/simulation/resource/log/service/LogService.java

@@ -1,10 +1,14 @@
 package com.css.simulation.resource.log.service;
 
+import api.common.pojo.constants.DictConstants;
 import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.log.LogPageParam;
 import api.common.pojo.po.log.LogLoginPO;
 import api.common.pojo.po.log.LogOperationPO;
 import api.common.pojo.po.log.LogSystemPO;
+import api.common.pojo.po.model.VehicleTempPO;
+import api.common.pojo.po.system.ClusterPO;
+import api.common.pojo.po.system.ParameterPO;
 import api.common.pojo.po.system.UserPO;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
@@ -31,6 +35,9 @@ public class LogService {
     @Autowired
     DictService dictService;
 
+    /**
+     * 保存普通操作日志(异步)
+     */
     @Async
     public void saveOperationLog(LogOperationPO po) {
         po.setId(StringUtil.getRandomUUID());
@@ -38,12 +45,18 @@ public class LogService {
         logMapper.insertOperationLog(po);
     }
 
+    /**
+     * 查询登录日志
+     */
     public PageInfo<LogLoginPO> getLoginLogPageList(LogPageParam pageParam) {
         PageUtil.setPageInfo(pageParam);
         List<LogLoginPO> list = logMapper.getLoginLogPageList(pageParam);
         return new PageInfo<>(list);
     }
 
+    /**
+     * 查询普通操作日志
+     */
     public PageInfo<LogOperationPO> getOperationLogPageList(LogPageParam pageParam) {
         PageUtil.setPageInfo(pageParam);
         List<LogOperationPO> list = logMapper.getOperationLogPageList(pageParam);
@@ -56,27 +69,28 @@ public class LogService {
         return new PageInfo<>(list);
     }
 
+    /**
+     * 查询系统管理日志
+     */
     public PageInfo<LogSystemPO> getSystemLogPageList(LogPageParam pageParam) {
         PageUtil.setPageInfo(pageParam);
         List<LogSystemPO> list = logMapper.getSystemLogPageList(pageParam);
         //字典翻译
-        Map<String, Map<String, String>> dictMaps = dictService.getDictMapsByTypes(LogConstants.SYS_LOG_TYPE);
+        Map<String, Map<String, String>> dictMaps = dictService.getDictMapsByTypes(LogConstants.SYS_LOG_TYPE + "," + DictConstants.ROLE_CODE);
         list.forEach(po ->{
             po.setModule(dictMaps.get(LogConstants.SYS_LOG_TYPE).get(po.getModule()));
             po.setOperationType(dictMaps.get(LogConstants.SYS_LOG_TYPE).get(po.getOperationType()));
+            po.setRoleCode(dictMaps.get(DictConstants.ROLE_CODE).get(po.getRoleCode()));
         });
         return new PageInfo<>(list);
     }
 
+    /**
+     * 记录用户管理模块日志
+     */
     public void logUser(String operationType, UserPO userPO) {
         try {
-            LogSystemPO po = new LogSystemPO();
-            po.setId(StringUtil.getRandomUUID());
-            po.setCreateTime(TimeUtil.getNowForMysql());
-            po.setUserId(AuthUtil.getCurrentUserId());
-            po.setUsername(AuthUtil.getCurrentUsername());
-            po.setRoleCode(AuthUtil.getCurrentUserRoleCode());
-            po.setModule(LogConstants.SYS_LOG_USER);
+            LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_USER, operationType);
             String userId = userPO.getId();
             String username = userPO.getUsername();
             if(ObjectUtil.isNull(username)){
@@ -84,10 +98,80 @@ public class LogService {
             }
             String content = username + " ( ID: " + userId + " )";
             po.setContent(content);
-            po.setOperationType(operationType);
             logMapper.insertSystemLog(po);
         }catch (Exception e){
             e.printStackTrace();
         }
     }
+
+    /**
+     * 记录车辆模板管理模块日志
+     */
+    public void logVehicle(String operationType, VehicleTempPO vehicleTempPO) {
+        try {
+            LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_VEHICLE, operationType);
+            String vehicleTempId = vehicleTempPO.getId();
+            String vehicleName = vehicleTempPO.getVehicleName();
+            String content = vehicleName + " ( ID: " + vehicleTempId + " )";
+            po.setContent(content);
+            logMapper.insertSystemLog(po);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 记录参数管理模块日志
+     */
+    public void logParameter(String operationType, ParameterPO parameterPO) {
+        try {
+            LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_PARAM, operationType);
+            String paramId = parameterPO.getId();
+            String userId = parameterPO.getUserId();
+            String userName = parameterPO.getUserName();
+            String content = "账户:" + userName +  " ( ID: " + userId + " ); 参数配置" +  " ( ID: " + paramId + " )";
+            po.setContent(content);
+            logMapper.insertSystemLog(po);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 记录集群管理模块日志
+     */
+    public void logCluster(String operationType, ClusterPO clusterPO) {
+        try {
+            LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_CLUSTER, operationType);
+            String clusterId = clusterPO.getId();
+            String userId = clusterPO.getUserId();
+            String userName = clusterPO.getUserName();
+            String content = "账户:" + userName +  " ( ID: " + userId + " ); 节点配置" +  " ( ID: " + clusterId + " )";
+            po.setContent(content);
+            logMapper.insertSystemLog(po);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
+
+
+
+
+
+    /**
+     * 获取系统管理日志对象
+     */
+    private LogSystemPO getLogSystemPO(String module, String operationType) {
+        LogSystemPO po = new LogSystemPO();
+        po.setId(StringUtil.getRandomUUID());
+        po.setCreateTime(TimeUtil.getNowForMysql());
+        po.setUserId(AuthUtil.getCurrentUserId());
+        po.setUsername(AuthUtil.getCurrentUsername());
+        po.setRoleCode(AuthUtil.getCurrentUserRoleCode());
+        po.setModule(module);
+        po.setOperationType(operationType);
+        return po;
+    }
 }

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/CameraCtrl.java

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.model.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.model.CameraParam;
 import api.common.pojo.po.model.CameraPO;
 import api.common.pojo.vo.model.CameraVO;
@@ -15,7 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import java.util.List;
 
 @Controller
-@RequestMapping("/camera")
+@RequestMapping(value = "/camera" , name = LogConstants.MODULE_CAMERA)
 public class CameraCtrl {
 
     @Autowired

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/ConfigCtrl.java

@@ -2,6 +2,7 @@ package com.css.simulation.resource.model.ctrl;
 
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.model.ConfigPageParam;
 import api.common.pojo.po.model.ConfigPO;
 import api.common.pojo.vo.model.ConfigSensorVO;
@@ -20,7 +21,7 @@ import java.util.List;
 import java.util.Map;
 
 @Controller
-@RequestMapping("/config")
+@RequestMapping(value = "/config",name = LogConstants.MODULE_CONFIG)
 public class ConfigCtrl {
 
     @Autowired

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/GpsCtrl.java

@@ -2,6 +2,7 @@ package com.css.simulation.resource.model.ctrl;
 
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.model.GpsParam;
 import api.common.pojo.po.model.GpsPO;
 import api.common.pojo.vo.model.GpsVO;
@@ -16,7 +17,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import java.util.List;
 
 @Controller
-@RequestMapping("/gps")
+@RequestMapping(value = "/gps",name = LogConstants.MODULE_GPS)
 public class GpsCtrl {
 
     @Autowired

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/LidarCtrl.java

@@ -2,6 +2,7 @@ package com.css.simulation.resource.model.ctrl;
 
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.model.LidarParam;
 import api.common.pojo.po.model.LidarPO;
 import api.common.pojo.vo.model.LidarVO;
@@ -16,7 +17,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import java.util.List;
 
 @Controller
-@RequestMapping("/lidar")
+@RequestMapping(value = "/lidar",name = LogConstants.MODULE_LIDAR)
 public class LidarCtrl {
 
     @Autowired

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/model/ctrl/OgtCtrl.java

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.model.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.model.OgtParam;
 import api.common.pojo.po.model.OgtPO;
 import api.common.pojo.vo.model.OgtVO;
@@ -15,7 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import java.util.List;
 
 @Controller
-@RequestMapping("/ogt")
+@RequestMapping(value = "/ogt",name = LogConstants.MODULE_OGT)
 public class OgtCtrl {
 
     @Autowired

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/CameraService.java

@@ -4,6 +4,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.model.CameraParam;
 import api.common.pojo.po.model.CameraPO;
 import api.common.pojo.vo.model.CameraVO;
+import api.common.util.LogUtil;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
 import api.common.util.TimeUtil;
@@ -61,8 +62,10 @@ public class CameraService {
             cameraPO.setId(StringUtil.getRandomUUID());
             cameraPO.setSensorCode(StringUtil.getRandomCode());
             cameraMapper.insert(cameraPO);
+            LogUtil.insert();
         }else{//修改
             cameraMapper.update(cameraPO);
+            LogUtil.update();
         }
         return cameraPO;
     }
@@ -89,6 +92,7 @@ public class CameraService {
         cameraPO.setId(StringUtil.getRandomUUID());
         cameraPO.setSensorCode(StringUtil.getRandomCode());
         cameraMapper.insert(cameraPO);
+        LogUtil.share();
         return cameraPO;
     }
 
@@ -97,6 +101,7 @@ public class CameraService {
         cameraPO.setModifyUserId(AuthUtil.getCurrentUserId());
         cameraPO.setModifyTime(TimeUtil.getNowForMysql());
         int i = cameraMapper.delCameraById(cameraPO);
+        LogUtil.delete();
         return i;
     }
 }

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/ConfigService.java

@@ -6,6 +6,7 @@ import api.common.pojo.po.model.ConfigPO;
 import api.common.pojo.po.model.ConfigSensorPO;
 import api.common.pojo.vo.model.ConfigSensorVO;
 import api.common.pojo.vo.model.ConfigVO;
+import api.common.util.LogUtil;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
 import api.common.util.TimeUtil;
@@ -83,8 +84,10 @@ public class ConfigService {
             configPO.setId(configId);
             configPO.setConfigCode(StringUtil.getRandomCode());
             configMapper.insertConfig(configPO);
+            LogUtil.insert();
         }else{//修改
             configMapper.updateConfig(configPO);
+            LogUtil.update();
         }
         //删除子表旧数据
         configMapper.delConfigSensors(configPO);
@@ -124,6 +127,7 @@ public class ConfigService {
         po.setModifyUserId(AuthUtil.getCurrentUserId());
         po.setModifyTime(TimeUtil.getNowForMysql());
         int i = configMapper.delConfigById(po);
+        LogUtil.delete();
         return i;
     }
 
@@ -186,6 +190,7 @@ public class ConfigService {
     public ConfigPO shareConfigById(ConfigVO configVO) {
         configVO = getConfigInfo(configVO);
         ConfigPO configPO = shareConfigByInfo(configVO);
+        LogUtil.share();
         return configPO;
     }
 

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/GpsService.java

@@ -4,6 +4,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.model.GpsParam;
 import api.common.pojo.po.model.GpsPO;
 import api.common.pojo.vo.model.GpsVO;
+import api.common.util.LogUtil;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
 import com.css.simulation.resource.common.utils.AuthUtil;
@@ -54,8 +55,10 @@ public class GpsService {
             gpsPO.setId(StringUtil.getRandomUUID());
             gpsPO.setSensorCode(StringUtil.getRandomCode());
             gpsMapper.insert(gpsPO);
+            LogUtil.insert();
         }else{//修改
             gpsMapper.update(gpsPO);
+            LogUtil.update();
         }
         return gpsPO;
     }
@@ -76,12 +79,14 @@ public class GpsService {
         gpsPO.setId(StringUtil.getRandomUUID());
         gpsPO.setSensorCode(StringUtil.getRandomCode());
         gpsMapper.insert(gpsPO);
+        LogUtil.share();
         return gpsPO;
     }
 
     public int delGpsById(GpsPO gpsPO) {
         PoUtil.initDelPo(gpsPO);
         int i = gpsMapper.delGpsById(gpsPO);
+        LogUtil.delete();
         return i;
     }
 }

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/LidarService.java

@@ -4,6 +4,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.model.LidarParam;
 import api.common.pojo.po.model.LidarPO;
 import api.common.pojo.vo.model.LidarVO;
+import api.common.util.LogUtil;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
 import api.common.util.TimeUtil;
@@ -60,8 +61,10 @@ public class LidarService {
             lidarPO.setId(StringUtil.getRandomUUID());
             lidarPO.setSensorCode(StringUtil.getRandomCode());
             lidarMapper.insert(lidarPO);
+            LogUtil.insert();
         }else{//修改
             lidarMapper.update(lidarPO);
+            LogUtil.update();
         }
         return lidarPO;
     }
@@ -88,6 +91,7 @@ public class LidarService {
         lidarPO.setId(StringUtil.getRandomUUID());
         lidarPO.setSensorCode(StringUtil.getRandomCode());
         lidarMapper.insert(lidarPO);
+        LogUtil.share();
         return lidarPO;
     }
 
@@ -96,6 +100,7 @@ public class LidarService {
         lidarPO.setModifyUserId(AuthUtil.getCurrentUserId());
         lidarPO.setModifyTime(TimeUtil.getNowForMysql());
         int i = lidarMapper.delLidarById(lidarPO);
+        LogUtil.delete();
         return i;
     }
 }

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/OgtService.java

@@ -5,6 +5,7 @@ import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.model.OgtParam;
 import api.common.pojo.po.model.OgtPO;
 import api.common.pojo.vo.model.OgtVO;
+import api.common.util.LogUtil;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
 import api.common.util.TimeUtil;
@@ -62,8 +63,10 @@ public class OgtService {
             ogtPO.setId(StringUtil.getRandomUUID());
             ogtPO.setSensorCode(StringUtil.getRandomCode());
             ogtMapper.insert(ogtPO);
+            LogUtil.insert();
         }else{//修改
             ogtMapper.update(ogtPO);
+            LogUtil.update();
         }
         return ogtPO;
     }
@@ -90,6 +93,7 @@ public class OgtService {
         ogtPO.setId(StringUtil.getRandomUUID());
         ogtPO.setSensorCode(StringUtil.getRandomCode());
         ogtMapper.insert(ogtPO);
+        LogUtil.share();
         return ogtPO;
     }
 
@@ -98,6 +102,7 @@ public class OgtService {
         ogtPO.setModifyUserId(AuthUtil.getCurrentUserId());
         ogtPO.setModifyTime(TimeUtil.getNowForMysql());
         int i = ogtMapper.delOgtById(ogtPO);
+        LogUtil.delete();
         return i;
     }
 }

+ 8 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/VehicleTempService.java

@@ -1,5 +1,6 @@
 package com.css.simulation.resource.model.service;
 
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.model.VehiclePageParam;
 import api.common.pojo.po.model.VehicleTempPO;
 import api.common.pojo.vo.model.VehicleDefaultValueVO;
@@ -8,6 +9,7 @@ import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.common.utils.PoUtil;
+import com.css.simulation.resource.log.service.LogService;
 import com.css.simulation.resource.model.mapper.VehicleTempMapper;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +25,9 @@ public class VehicleTempService {
     @Autowired
     VehicleTempMapper vehicleTempMapper;
 
+    @Autowired
+    LogService logService;
+
     public List getVehicleTempTree() {
         List<VehicleTempVO> list = vehicleTempMapper.getVehicleTempTree();
         List<Map> treeList = new ArrayList<>();
@@ -80,14 +85,17 @@ public class VehicleTempService {
             po.setId(StringUtil.getRandomUUID());
             po.setVehicleCode(StringUtil.getRandomCode());
             vehicleTempMapper.insert(po);
+            logService.logVehicle(LogConstants.SYS_LOG_VEHICLE_INSERT,po);
         }else{//修改
             vehicleTempMapper.update(po);
+            logService.logVehicle(LogConstants.SYS_LOG_VEHICLE_UPDATE,po);
         }
         return po;
     }
 
     public int delVehicleTempById(VehicleTempPO po) {
         PoUtil.initDelPo(po);
+        logService.logVehicle(LogConstants.SYS_LOG_VEHICLE_DEL,po);
         return vehicleTempMapper.delVehicleTempById(po);
     }
 }

+ 0 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/project/constants/ProjectConstants.java

@@ -17,9 +17,6 @@ public class ProjectConstants {
     //自动任务运行中止
     public static final String STOP_AUTO_PROJECT = "stopAutoProject";
 
-    //第三方算法类型(索为)
-    public static final String SY_ALGORITHM_TYPE="3";
-
     //任务运行状态字典
     public static final String TASK_RUN_STATE = "taskRunState";
 

+ 9 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/project/ctrl/SimulationProjectCtrl.java

@@ -4,6 +4,7 @@ import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.param.project.DictParam;
 import api.common.pojo.param.project.SimulationManualProjectParam;
 import com.css.simulation.resource.project.service.SimulationProjectService;
+import com.css.simulation.resource.system.service.ClusterService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
@@ -18,6 +19,9 @@ public class SimulationProjectCtrl {
     @Autowired
     private SimulationProjectService service;
 
+    @Autowired
+    private ClusterService clusterService;
+
 
     /**
      * 创建/修改工作
@@ -123,7 +127,11 @@ public class SimulationProjectCtrl {
     @RequestMapping("selectMaxParallelism")
     @ResponseBody
     public ResponseBodyVO selectMaxParallelism(){
-        return service.selectMaxParallelism();
+
+        Integer licenseNum = clusterService.getLicenseNum();
+
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,null,licenseNum);
+//        return service.selectMaxParallelism();
     }
 
     /**

+ 172 - 75
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -20,6 +20,7 @@ import api.common.pojo.po.scene.ScenePackagePO;
 import api.common.pojo.vo.project.*;
 import api.common.pojo.vo.scene.RunProjectVO;
 import api.common.util.*;
+import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
 import com.css.simulation.resource.algorithm.service.AlgorithmService;
 import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
@@ -45,20 +46,17 @@ import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.server.ServletServerHttpRequest;
 import org.springframework.scheduling.support.CronExpression;
 import org.springframework.stereotype.Service;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URLEncoder;
-import java.nio.file.Files;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -88,6 +86,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     @Autowired
     private SimulationMptLastTargetScoreMapper simulationMptLastTargetScoreMapper;
 
+    @Autowired
+    private AlgorithmMapper algorithmMapper;
+
     @Resource
     private KafkaService kafkaService;
 
@@ -392,7 +393,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         }
 
+        //获取场景包信息
+        ScenePackagePO scenePackagePO = simulationProjectMapper.selectScenePackageInfoById(poParam.getScene());
 
+        projectDetailsVo.setPackageName(scenePackagePO.getPackageName());
 
         //评测等级
         String s = getEvaluationLevel(poParam);
@@ -400,6 +404,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         //算法配置
         AlgorithmPO algorithmBaseInfoVo = getAlgorithmInfo(poParam);
 
+
+        //获取测试得分列表
+        List<AlgorithmScoreVo> firstTargetScore = getFirstTargetScore(param.getId());
+        projectDetailsVo.setAlgorithmScoreList(firstTargetScore);
+
         //车辆配置
         VehiclePO vehicleBaseInfoVo = null;
         String vehicleConfigId = poParam.getVehicle();
@@ -465,15 +474,21 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         //任务运行状态统计
         List<ProjectRunStateNumVo> projectRunStateNumVos = null;
+
+        //任务运行结果统计
+        List<ProjectRunResultRatioNumVo> resultScoreList = null;
+
         Integer size = simulationProjectTaskMapper.selectProjectTaskNumByProjectId(projectTaskParam);
         if(size > 0){
             projectRunStateNumVos = simulationProjectTaskMapper.selectRunStateCount(poParam.getId());
             taskRunState(projectRunStateNumVos, size);
 
-
             projectRunResultRatioNumVos = simulationProjectTaskMapper.selectRunResultCount(poParam.getId());
             taskResultState(projectRunResultRatioNumVos, size);
 
+            resultScoreList = simulationProjectTaskMapper.selectScoreCount(poParam.getId());
+            taskScore(resultScoreList,size);
+
         }
 
         projectDetailsVo.setProjectId(poParam.getProjectId());
@@ -502,6 +517,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         projectDetailsVo.setSensorGpsList(sensorGpsList);
         projectDetailsVo.setStateList(projectRunStateNumVos);
         projectDetailsVo.setResultList(projectRunResultRatioNumVos);
+        projectDetailsVo.setResultScoreList(resultScoreList);
 
         projectDetailsVo.setParallelism(poParam.getParallelism());
         projectDetailsVo.setMaxSimulationTime(poParam.getMaxSimulationTime());
@@ -592,6 +608,18 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         }
     }
 
+    /**
+     * 得分统计
+     */
+    private void taskScore(List<ProjectRunResultRatioNumVo> vos,Integer size){
+        for(ProjectRunResultRatioNumVo rv : vos){
+            Integer num = rv.getNum();
+            Double d = (double)num/size;
+            d = saveTwoDecimalPlaces(d);
+            rv.setRatio(d);
+        }
+    }
+
     private void setVehicleConfig(SensorBaseInfoVo vo, ConfigSensorPO vs){
         vo.setConfigId(vs.getConfigId());
         vo.setSensorId(vs.getSensorId());
@@ -750,7 +778,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             algorithmScoreVo.setWeight("100");
             algorithmScoreVo.setScore(saveTwoDecimalPlaces(totalScore));
 
-//            totalScoreRatio = Double.valueOf(totalSceneScoreNum)/Double.valueOf(totalSceneNum)*100;
+            totalScoreRatio = Double.valueOf(totalSceneScoreNum)/Double.valueOf(totalSceneNum)*100;
             //汇总得分率计算方式修改
             Double d = 0D;
             if(!isEmpty(algorithmScoreVoList)){
@@ -758,7 +786,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     d +=a.getScoreRatio();
                 }
                 totalScoreRatio = saveTwoDecimalPlaces(d/algorithmScoreVoList.size());*/
-                totalScoreRatio = saveTwoDecimalPlaces(totalScoreRatio/algorithmScoreVoList.size());
+//                totalScoreRatio = saveTwoDecimalPlaces(totalScoreRatio/algorithmScoreVoList.size());
             }
 
             algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(totalScoreRatio));
@@ -767,7 +795,8 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             projectReportVo.setScoreRatio(saveTwoDecimalPlaces(totalScoreRatio));
 
             projectReportVo.setAlgorithmScore(saveTwoDecimalPlaces(totalScore));
-            evaluationLevelReport = getEvaluationLevelReport(saveTwoDecimalPlaces(totalScore));
+//            evaluationLevelReport = getEvaluationLevelReport(saveTwoDecimalPlaces(totalScore));
+            evaluationLevelReport = poParam.getEvaluationLevel();
             projectReportVo.setEvaluationLevel(evaluationLevelReport);
 
             sceneNames = stringBuffer.substring(0,stringBuffer.lastIndexOf("、"));
@@ -795,7 +824,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         //场景得分列表
 //        Map<String, Object> maps = selectSceneScore(pos, po.getId());
-        Map<String, Object> maps = selectSceneScore(poParam.getScene(), poParam.getId());
+        Map<String, Object> maps = selectSceneScore(poParam.getScene(), poParam.getId(), null);
         projectReportVo.setSceneScoreLiTitle((List<Map>) maps.get("cloums"));
         projectReportVo.setSceneScoreLi((List<SceneScListVo>) maps.get("result"));
 
@@ -878,6 +907,40 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         resultVo.setFinishState(po.getRunResult());
         resultVo.setSceneDescribe("");
 
+        /*
+        获取任务得分详情
+         */
+
+
+        if(isEmpty(param.getProjectType())){
+            param.setProjectType("1");//默认
+        }
+
+        //获取项目基本信息
+        //封装要使用到的数据
+        SimulationManualProjectPo poParam = new SimulationManualProjectPo();
+
+        if("1".equals(param.getProjectType())){
+            //项目基本信息
+            SimulationManualProjectPo spo = simulationProjectMapper.selectProjectBaseById(param);
+            if(spo == null){
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
+            }
+            poParam = spo;
+        }else if("2".equals(param.getProjectType())){
+            SimulationManualProjectVo spo = simulationAutomaticSubProjectMapper.selectProjectInfo(param);
+            if(spo == null){
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
+            }
+
+            BeanUtils.copyProperties(po, poParam);
+
+        }
+
+        Map<String, Object> stringObjectMap = selectSceneScore(poParam.getScene(), poParam.getId(), taskId);
+        resultVo.setSceneScoreLiTitle((List<Map>) stringObjectMap.get("cloums"));
+        resultVo.setSceneScoreLi((List<SceneScListVo>) stringObjectMap.get("result"));
+
 
         //1.获取仿真结果文件
         InputStream fileInputStream = null;
@@ -1089,7 +1152,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 Double aDouble = lateral_velocity_list.get(i);
                 Double aDouble1 = longitudinal_velocity_list.get(i);
                 Double d = Math.pow(aDouble,2)+Math.pow(aDouble1,2);
-                velocity_list.add(Math.sqrt(d));
+                velocity_list.add(Math.sqrt(d)*3.6);
             }
 
             //获取视频预览路径
@@ -1112,7 +1175,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
             //任务详情信息
             resultVo.setMileage(lc.toString());
-            resultVo.setAverageVelocity(pjsd.toString());
+            resultVo.setAverageVelocity(saveTwoDecimalPlaces(pjsd*3.6, 4).toString());
             resultVo.setMaximunSpeed(zdsd.toString());
             resultVo.setMinimunVelocity(zxsd.toString());
             resultVo.setMaximumAcceleration(zdjiasd.toString());
@@ -1133,7 +1196,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             CurveData.put("steeting",steeting_wheel_list);
             CurveData.put("throttle",throttle_list);
             CurveData.put("yaw_rate",yawrate_list);
-            CurveData.put("velocity",velocity_list);
+            CurveData.put("velocity",velocity_list); //速度变化曲线
             resultVo.setCurveData(CurveData);
 
 
@@ -1280,7 +1343,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         List<DropDownVo> algorithmList = new ArrayList<>();
 
-        if(ProjectConstants.SY_ALGORITHM_TYPE.equals(algorithmType)){
+        if(DictConstants.PLATFORM.equals(algorithmType)){
             //第三方算法平台获取(索为)
             String sort = "algorithmId-desc";
             Integer page = 1;
@@ -1635,7 +1698,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     }
 
 
-    private Map<String, Object> selectSceneScore(String scenePackageId, String projectId) {
+    private Map<String, Object> selectSceneScore(String scenePackageId, String projectId, String taskId) {
 
         //查询场景包所有数据(包括得分信息)
         SimulationManualProjectParam query = new SimulationManualProjectParam();
@@ -1649,6 +1712,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         //1.获取项目下所有场景得分
         ProjectTaskParam param = new ProjectTaskParam();
         param.setPId(projectId);
+        if(!isEmpty(taskId)){
+            param.setTaskId(taskId);
+        }
         List<ManualProjectTaskVo> manualProjectTaskVos = simulationProjectTaskMapper.selectProjectTaskByProjectId(param);
 
         List<SublistScoreVo> lastSubList = new ArrayList<>();
@@ -3788,51 +3854,32 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         int i = simulationAutomaticProjectMapper.updateAutomaticRunState(param);
         if(i > 0){
             SimulationAutomaticProjectPo po = simulationAutomaticProjectMapper.selectById(id);
-            String algorithm = po.getAlgorithm();
+            String algorithmId = po.getAlgorithm();
             if("0".equals(param.getAutomaticRunState())){
                 //启动
                 //检查算法版本
-                AlgorithmPO algorithmParam = new AlgorithmPO();
-                algorithmParam.setId(algorithm);
-                AlgorithmPO aPo = simulationAutomaticProjectMapper.getAlgorithmGitVersion(algorithmParam);
+                //获取数据库中的算法版本
+                AlgorithmPO aPo = algorithmMapper.selectDetailsById(algorithmId);
                 String gitVersion = aPo.getGitVersion();
+                //获取当前算法版本
+                String currentGitVersion = algorithmService.getGitVersion(algorithmId);
 
-                AlgorithmParameter algorithmParameter = new AlgorithmParameter();
-                algorithmParameter.setId(algorithm);
+                boolean isRun = false; //判断是否启动运行
                 //首次获取版本
                 if(StringUtil.isEmpty(gitVersion)){
-
-                    //更新版本
-                    updateAlgorithm(algorithmParameter,algorithmParam);
-
-                    //添加一条子工作信息并推送消息到kafka ,执行项目
-                    createAutomaticSubProject(param);
-
-                    //推送定时请求,启动运行周期
-                    projectTaskStart(po);
-
+                    isRun = true;
                 }else{
                     //非首次,比对版本,校验是否执行任务
-                    String algorithmGitVersion = getAlgorithmGitVersion(algorithmParameter);
-                    if(algorithmGitVersion == null){
-                        throw new RuntimeException("------- 获取git算法版本信息失败");
-                    }
-
-                    if(!gitVersion.equals(algorithmGitVersion)){
-
-                        updateAlgorithmVersion(algorithmGitVersion, algorithmParam);
-
-                        //添加一条子工作信息并推送消息到kafka ,执行项目
-                        createAutomaticSubProject(param);
-
-                        //推送定时请求,启动运行周期
-                        projectTaskStart(po);
-
+                    if(!gitVersion.equals(currentGitVersion)){
+                        isRun = true;
                     }
-
                 }
-
-
+                if(isRun){ //启动运行
+                    AlgorithmParameter algorithmParam = new AlgorithmParameter();
+                    algorithmParam.setId(algorithmId);
+                    algorithmParam.setGitVersion(currentGitVersion);
+                    runProject(algorithmParam, param, po);
+                }
             }else if("1".equals(param.getAutomaticRunState())){
                 //停止
                 //推送定时请求
@@ -3857,41 +3904,20 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);*/
     }
 
-    private void updateAlgorithm(AlgorithmParameter algorithmParameter, AlgorithmPO algorithmParam){
-
-        String gitVersion = getAlgorithmGitVersion(algorithmParameter);
-        if(gitVersion == null){
-            throw new RuntimeException("------- 获取git算法版本信息失败");
-        }
 
-        updateAlgorithmVersion(gitVersion, algorithmParam);
-
-    }
-
-    private void updateAlgorithmVersion(String gitVersion, AlgorithmPO algorithmParam){
+    private void runProject(AlgorithmParameter algorithmParam, SimulationManualProjectParam simulationManualProjectParam, SimulationAutomaticProjectPo simulationAutomaticProjectPo){
 
         //更新算法版本
-        algorithmParam.setGitVersion(gitVersion);
         simulationAutomaticProjectMapper.updateAlgorithmGitVersion(algorithmParam);
 
-    }
+        //添加一条子工作信息并推送消息到kafka ,执行项目
+        createAutomaticSubProject(simulationManualProjectParam);
 
-    private String getAlgorithmGitVersion(AlgorithmParameter algorithmParameter){
-        try {
-            ResponseBodyVO gitVersion = algorithmService.getGitVersion(algorithmParameter);
-            if(200 == gitVersion.getCode()){
-                return gitVersion.getInfo().toString();
-            }else{
-                return null;
-            }
-        }catch (Exception e){
-            throw new RuntimeException("------- 请求错误:" + e.toString());
-        }
+        //推送定时请求,启动运行周期
+        projectTaskStart(simulationAutomaticProjectPo);
 
     }
 
-
-
     @Override
     public ResponseBodyVO selectAutomaticProject(SimulationManualProjectParam param) {
 
@@ -4221,11 +4247,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
 
     private void insertOtherAlgorithm(SimulationManualProjectParam param){
-        if(ProjectConstants.SY_ALGORITHM_TYPE.equals(param.getAlgorithmType())){
+        if(DictConstants.PLATFORM.equals(param.getAlgorithmType())){
             AlgorithmPO po = new AlgorithmPO();
             po.setId(param.getAlgorithm());
             po.setAlgorithmName(param.getAlgorithmName());
-            po.setUploadMode(ProjectConstants.SY_ALGORITHM_TYPE);
+            po.setUploadMode(DictConstants.PLATFORM);
             po.setIsDeleted("0");
             AlgorithmPO po1 = simulationProjectMapper.selectalgorithmByQuery(po);
             if(po1 == null){
@@ -4266,4 +4292,75 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             throw new RuntimeException("自动运行项目停止失败:"+po.getId());
         }
     }
+
+    /**
+     * 获取一级指标得分列表
+     * @return
+     */
+    private List<AlgorithmScoreVo> getFirstTargetScore(String id){
+        //算法测试得分表
+        /*
+        汇总测试得分计算方法:(每一项一级指标的测试得分*测试权重)累加
+        得分率计算方法:每一项一级指标的所有场景得分不为0的数量/每一项一级指标的场景数量
+        汇总得分率计算方法:(每一项一级指标的所有场景得分不为0的数量_累加/每一项一级指标的场景数量_累加)换成(得分累加取平均值)
+         */
+        //获取得分表一级指标信息
+        SimulationMptFirstTargetScorePo par = new SimulationMptFirstTargetScorePo();
+        par.setPId(id);
+        List<SimulationMptFirstTargetScorePo> pos = simulationMptFirstTargetScoreMapper.selectFirstTargetByPid(par);
+
+        List<AlgorithmScoreVo> algorithmScoreVoList = new ArrayList();
+        String evaluationLevelReport = "";
+        if(!isEmpty(pos)){
+            StringBuffer stringBuffer = new StringBuffer("");
+
+            //汇总数据初始化
+            Integer totalSceneNum = 0;
+            Double totalScore = 0D;
+            Double totalScoreRatio=0D;
+            Integer totalSceneScoreNum = 0;
+
+            for(SimulationMptFirstTargetScorePo v : pos){
+
+
+                stringBuffer.append(v.getSublistName()+"、");
+                AlgorithmScoreVo algorithmScoreVo = new AlgorithmScoreVo();
+                algorithmScoreVo.setProjectName(v.getSublistName());
+                Integer sceneNum = v.getSceneNum();
+                totalSceneNum += sceneNum;
+                algorithmScoreVo.setSceneNum(sceneNum);
+                String weight = v.getWeight();
+                Double weightDouble = Double.valueOf(weight);
+                algorithmScoreVo.setWeight(weight);
+                //单个二级指标得分
+                Double score = v.getScore();
+                totalScore += BigDecimal.valueOf(score).multiply(BigDecimal.valueOf(weightDouble).divide(BigDecimal.valueOf(100))).doubleValue();
+                algorithmScoreVo.setScore(saveTwoDecimalPlaces(score));
+                //获取得分不为0的场景数量
+                Integer scoreNum = getSetScoreNum(v.getSublistId(),id);
+                totalSceneScoreNum += scoreNum;
+                algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(Double.valueOf(scoreNum)/Double.valueOf(sceneNum)*100));
+                algorithmScoreVoList.add(algorithmScoreVo);
+
+                totalScoreRatio += Double.valueOf(scoreNum)/Double.valueOf(sceneNum)*100;
+            }
+            //汇总
+            AlgorithmScoreVo algorithmScoreVo = new AlgorithmScoreVo();
+            algorithmScoreVo.setProjectName("汇总");
+            algorithmScoreVo.setSceneNum(totalSceneNum);
+            //指标权重总和默认是100%
+            algorithmScoreVo.setWeight("100");
+            algorithmScoreVo.setScore(saveTwoDecimalPlaces(totalScore));
+
+            totalScoreRatio = Double.valueOf(totalSceneScoreNum)/Double.valueOf(totalSceneNum)*100;
+
+            algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(totalScoreRatio));
+            algorithmScoreVoList.add(algorithmScoreVo);
+
+
+        }
+
+        return algorithmScoreVoList;
+
+    }
 }

+ 2 - 9
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationAutomaticProjectMapper.java

@@ -1,18 +1,13 @@
 package com.css.simulation.resource.project.mapper;
 
+import api.common.pojo.param.algorithm.AlgorithmParameter;
 import api.common.pojo.param.project.SimulationManualProjectParam;
-import api.common.pojo.po.algorithm.AlgorithmPO;
-import api.common.pojo.po.model.ConfigPO;
-import api.common.pojo.po.model.ConfigSensorPO;
-import api.common.pojo.po.model.VehiclePO;
 import api.common.pojo.po.project.*;
-import api.common.pojo.po.scene.ScenePackagePO;
 import api.common.pojo.vo.project.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
-import java.util.Map;
 
 @Mapper
 @Repository
@@ -39,9 +34,7 @@ public interface SimulationAutomaticProjectMapper {
 
      AutomaticProjectVo selectAutomaticProjectInfoById(String id);
 
-     AlgorithmPO getAlgorithmGitVersion(AlgorithmPO po);
-
-     int updateAlgorithmGitVersion(AlgorithmPO po);
+     int updateAlgorithmGitVersion(AlgorithmParameter algorithmParameter);
 
      int updateAutomaticRunTimes(SimulationAutomaticProjectPo po);
 

+ 2 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationProjectMapper.java

@@ -47,6 +47,8 @@ public interface SimulationProjectMapper {
 
     List<ScenePackagePO> selectScenePackageBaseById(ScenePackagePO scenePackagePO);
 
+    ScenePackagePO selectScenePackageInfoById(String id);
+
     List<ConfigSensorPO> selectVehicleSensor(String id);
 
     SensorBaseInfoVo selectSensorCamera(String id);

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationProjectTaskMapper.java

@@ -26,6 +26,8 @@ public interface SimulationProjectTaskMapper {
 
     List<ProjectRunResultRatioNumVo> selectRunResultCount(String id);
 
+    List<ProjectRunResultRatioNumVo> selectScoreCount(String id);
+
     List<SceneScoreVo> selectSceneScoreByIds(SceneScoreParam param);
 
     SceneScoreVo selectSceneScoreNumQuery(SimulationMptSceneScorePo po);
@@ -40,6 +42,9 @@ public interface SimulationProjectTaskMapper {
     SceneScoreVo selectRunStateByAborted(SimulationMptSceneScorePo po);
 
 
+    List<ManualProjectTaskVo> selectProjectTaskById(String id);
+
+
 
 
 

+ 15 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneAccidentController.java

@@ -3,11 +3,15 @@ package com.css.simulation.resource.scene.ctrl;
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.scene.SceneAccidentParam;
+import api.common.pojo.param.scene.SceneImportParam;
 import api.common.pojo.po.scene.SceneAccidentPO;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.pojo.vo.scene.SceneAccidentVO;
 import api.common.util.ObjectUtil;
+import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.scene.service.SceneAccidentService;
+import com.css.simulation.resource.system.service.SceneImportService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
@@ -23,6 +27,8 @@ public class SceneAccidentController {
 
     @Resource
     SceneAccidentService sceneAccidentService;
+    @Resource
+    SceneImportService sceneImportService;
 
     //查询列表
     @PostMapping("/querySceneAccidentList")
@@ -63,12 +69,16 @@ public class SceneAccidentController {
     }
 
     //测试批量导入
-    @PostMapping("/saveAll")
+    @PostMapping("/saveSceneAccidentBatch")
     @ResponseBody
-    public ResponseBodyVO<String> saveAll(@RequestBody MinioParameter parms) {
-
-      return  sceneAccidentService.importMiNio(parms);
-        //return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    public ResponseBodyVO<String> saveSceneAccidentBatch(@RequestBody SceneImportParam sceneImportParam) {
+        SceneImportPO sceneImportPO=new  SceneImportPO();
+        sceneImportPO.setId(sceneImportParam.getId());
+        sceneImportPO.setStatus("3");
+        sceneImportService.updateStatus(sceneImportPO);
+        sceneImportPO= sceneAccidentService.importMiNio(sceneImportParam);
+        sceneImportService.updateInfo(sceneImportPO);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
     }
 
 }

+ 20 - 29
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneGeneralTemplateController.java

@@ -17,7 +17,6 @@ import com.css.simulation.resource.scene.service.SceneGeneralTemplateService;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.PageInfo;
-import lombok.SneakyThrows;
 import org.apache.http.client.config.RequestConfig;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -44,20 +43,21 @@ public class SceneGeneralTemplateController {
     SceneGeneralExampleService exampleService;
     @Resource
     private FileDownService fileDownService;
+
     //查询列表
     @PostMapping("/querySceneGeneralTemplateList")
     @ResponseBody
     public ResponseBodyVO<List<SceneGeneralTemplatePO>> querySceneGeneralTemplateList(@RequestBody SceneGeneralTemplateParam po) {
         PageUtil.setPageInfo(po);
         List<SceneGeneralTemplatePO> list = sceneGeneralTemplateService.querySceneGeneralTemplateList(po);
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,  new PageInfo<>(list));
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, new PageInfo<>(list));
     }
 
     //查模板详情
     @PostMapping("/querySceneGeneralTemplateById")
     @ResponseBody
     public ResponseBodyVO<SceneGeneralTemplateVO> querySceneGeneralTemplateById(@RequestBody SceneGeneralTemplateParam param) {
-        if(param!=null&&ObjectUtil.isNotNull(param.getId())){
+        if (param != null && ObjectUtil.isNotNull(param.getId())) {
             SceneGeneralTemplateVO po = sceneGeneralTemplateService.querySceneGeneralTemplateById(param.getId());
             return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, po);
         }
@@ -65,30 +65,22 @@ public class SceneGeneralTemplateController {
 
     }
 
-    /*
-        //新增泛化模板
-        @PostMapping("/saveSceneGeneralTemplate")
-        @ResponseBody
-        public ResponseBodyVO<String> saveSceneGeneralTemplate() {
-            return   sceneGeneralTemplateService.saveSceneGeneralTemplate1();
-
-        }*/
     //新增泛化模板
     @PostMapping("/saveSceneGeneralTemplate")
     @ResponseBody
     public ResponseBodyVO<String> saveSceneGeneralTemplate(@RequestParam("file") MultipartFile multipartFile) {
         File file = null;
-        String originalFilename =  multipartFile.getOriginalFilename();
-        if(originalFilename.indexOf(".xls")==-1&&originalFilename.indexOf(".xlsx")==-1){
+        String originalFilename = multipartFile.getOriginalFilename();
+        if (originalFilename.indexOf(".xls") == -1 && originalFilename.indexOf(".xlsx") == -1) {
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "文件格式错误,请检查模板.");
 
         }
         //版本号
-        String version=TimeUtil.getToStringDate(new Date(),5);
+        String version = TimeUtil.getToStringDate(new Date(), 5);
         try {
             ResponseBodyVO<String> respon;
-            Integer nowTime = TimeUtil.getRq(new Date(), 0);
-          String  fileName = "泛化场景/" + version +"/"+originalFilename;
+           // Integer nowTime = TimeUtil.getRq(new Date(), 0);
+            String fileName = "泛化场景/" + version + "/" + originalFilename;
             respon = fileDownService.upload(multipartFile, fileName);
 
             String[] filename = originalFilename.split("\\.");
@@ -100,7 +92,7 @@ public class SceneGeneralTemplateController {
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "模板解析失败,请检查模板.");
 
         }
-        return sceneGeneralTemplateService.saveSceneGeneralTemplate(file,version);
+        return sceneGeneralTemplateService.saveSceneGeneralTemplate(file, version);
 
     }
 
@@ -117,8 +109,8 @@ public class SceneGeneralTemplateController {
     @PostMapping("/queryGeneralTemplateByFh")
     @ResponseBody
     public ResponseBodyVO queryGeneralTemplateByFh(@RequestBody SceneGeneralExamplePO param) {
-        if(param!=null&&ObjectUtil.isNotNull(param.getId())){
-            return  exampleService.querySceneGeneralExampleById(param.getId());
+        if (param != null && ObjectUtil.isNotNull(param.getId())) {
+            return exampleService.querySceneGeneralExampleById(param.getId());
         }
         return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "参数id不能为空,请检查");
     }
@@ -128,8 +120,8 @@ public class SceneGeneralTemplateController {
     @PostMapping("/saveSceneGeneralExample")
     @ResponseBody
     public ResponseBodyVO saveSceneGeneralExample(@RequestBody SceneGeneralTemplateVO vo) {
-        if(ObjectUtil.isNotNull(vo)){
-            return  exampleService.saveSceneGeneralExample(vo);
+        if (ObjectUtil.isNotNull(vo)) {
+            return exampleService.saveSceneGeneralExample(vo);
         }
         return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "参数不能为空,请检查");
     }
@@ -138,21 +130,19 @@ public class SceneGeneralTemplateController {
     @PostMapping("/queryType")
     @ResponseBody
     public ResponseBodyVO queryType() {
-            return  exampleService.queryType();
+        return exampleService.queryType();
     }
 
 
-
-
     //测试
     @PostMapping("/test1")
     @ResponseBody
     public ResponseBodyVO test1(@RequestBody SceneGeneralTemplatePO po) throws IllegalAccessException, IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
-      Map map=  beanToMap(po);
+        Map map = beanToMap(po);
         RequestConfig requestConfig = RequestConfig.custom()
-                .setSocketTimeout(6*10*1000)
-                .setConnectTimeout(6*10*1000)
-                .setConnectionRequestTimeout(6*10*1000)
+                .setSocketTimeout(6 * 10 * 1000)
+                .setConnectTimeout(6 * 10 * 1000)
+                .setConnectionRequestTimeout(6 * 10 * 1000)
                 .setRedirectsEnabled(false)
                 .setExpectContinueEnabled(false)
                 .build();
@@ -162,12 +152,13 @@ public class SceneGeneralTemplateController {
         // 实例化 ObjectMapper 对象
         ObjectMapper objectMapper = new ObjectMapper();
         String newjson = objectMapper.writeValueAsString(params);
-       List<SceneGeneralDataPO>  list=JsonUtil.jsonToList(newjson,SceneGeneralDataPO.class);
+        List<SceneGeneralDataPO> list = JsonUtil.jsonToList(newjson, SceneGeneralDataPO.class);
         return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "参数不能为空,请检查");
     }
 
     /**
      * 对象转Map
+     *
      * @param object
      * @return
      * @throws IllegalAccessException

+ 17 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneNaturalController.java

@@ -1,13 +1,16 @@
 package com.css.simulation.resource.scene.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.scene.SceneImportParam;
 import api.common.pojo.param.scene.SceneNaturalNewParam;
 import api.common.pojo.param.scene.SceneNaturalParam;
 import api.common.pojo.po.scene.SceneNaturalPO;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.pojo.vo.scene.SceneNaturalVO;
 import api.common.util.ObjectUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.scene.service.SceneNaturalService;
+import com.css.simulation.resource.system.service.SceneImportService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
@@ -23,6 +26,8 @@ public class SceneNaturalController {
 
     @Resource
     SceneNaturalService sceneNaturalService;
+    @Resource
+    SceneImportService sceneImportService;
 
     //查询列表
     @PostMapping("/querySceneNaturalList")
@@ -61,6 +66,17 @@ public class SceneNaturalController {
         sceneNaturalService.deleteSceneNatural(params);
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
     }
-
+    //批量导入
+    @PostMapping("/saveSceneNaturalBatch")
+    @ResponseBody
+    public ResponseBodyVO<String> saveSceneNaturalBatch(@RequestBody SceneImportParam sceneImportParam) {
+        SceneImportPO sceneImportPO=new  SceneImportPO();
+        sceneImportPO.setId(sceneImportParam.getId());
+        sceneImportPO.setStatus("3");
+        sceneImportService.updateStatus(sceneImportPO);
+        sceneImportPO= sceneNaturalService.importMiNio(sceneImportParam);
+        sceneImportService.updateInfo(sceneImportPO);
+       return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
 
 }

+ 7 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/ScenePackageController.java

@@ -99,5 +99,12 @@ public class ScenePackageController {
         scenePackageService.deleteList(parms);
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
     }
+    //查询测试包数量
+    @PostMapping("/queryPackageCount")
+    @ResponseBody
+    public ResponseBodyVO<Map> queryPackageCount() {
 
+       Map map= scenePackageService.queryPackageCount();
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,map);
+    }
 }

+ 17 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/StandardsRegulationsController.java

@@ -1,12 +1,15 @@
 package com.css.simulation.resource.scene.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.scene.SceneImportParam;
 import api.common.pojo.param.scene.StandardsRegulationsParam;
 import api.common.pojo.po.scene.StandardsRegulationsPO;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.pojo.vo.scene.StandardsRegulationsVO;
 import api.common.util.ObjectUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.scene.service.StandardsRegulationsService;
+import com.css.simulation.resource.system.service.SceneImportService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
@@ -21,6 +24,8 @@ public class StandardsRegulationsController {
 
     @Resource
     StandardsRegulationsService standardsRegulationsService;
+    @Resource
+    SceneImportService sceneImportService;
 
     //查询列表
     @PostMapping("/queryStandardsRegulationsList")
@@ -60,5 +65,17 @@ public class StandardsRegulationsController {
         standardsRegulationsService.deleteStandardsRegulations(params);
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
     }
+    //测试批量导入
+    @PostMapping("/saveStandardsRegulationsBatch")
+    @ResponseBody
+    public ResponseBodyVO<String> saveStandardsRegulationsBatch(@RequestBody SceneImportParam sceneImportParam) {
+        SceneImportPO sceneImportPO=new  SceneImportPO();
+        sceneImportPO.setId(sceneImportParam.getId());
+        sceneImportPO.setStatus("3");
+        sceneImportService.updateStatus(sceneImportPO);
+        sceneImportPO= standardsRegulationsService.importMiNio(sceneImportParam);
+        sceneImportService.updateInfo(sceneImportPO);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
 
 }

+ 128 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SystemScenePackageController.java

@@ -0,0 +1,128 @@
+package com.css.simulation.resource.scene.ctrl;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.scene.SystemScenePackageParam;
+import api.common.pojo.po.scene.ScoringRulesPO;
+import api.common.pojo.po.scene.SystemScenePackageNewPO;
+import api.common.pojo.po.scene.SystemScenePackagePO;
+import api.common.pojo.vo.scene.SystemScenePackageVO;
+import api.common.pojo.vo.scene.SystemUserSceneVO;
+import api.common.util.ObjectUtil;
+import com.css.simulation.resource.common.utils.PageUtil;
+import com.css.simulation.resource.scene.service.SystemScenePackageService;
+import com.github.pagehelper.PageInfo;
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+//场景包
+@RestController
+@RequestMapping("/SystemScenePackage")
+public class SystemScenePackageController {
+
+    @Resource
+    SystemScenePackageService systemScenePackageService;
+
+    //查询列表
+    @PostMapping("/querySystemScenePackageList")
+    @ResponseBody
+    public ResponseBodyVO<List<SystemScenePackageVO> > querySystemScenePackageList(@RequestBody SystemScenePackageParam parms) {
+        PageUtil.setPageInfo(parms);
+        List<SystemScenePackageVO>  list = systemScenePackageService.querySystemScenePackageList(parms);
+
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,  new PageInfo(list));
+    }
+
+    //查询场景包详情
+    @PostMapping("/querySystemScenePackageById")
+    @ResponseBody
+    public ResponseBodyVO<SystemScenePackageNewPO> querySystemScenePackageById(@RequestBody SystemScenePackageParam parms) {
+        if (ObjectUtil.isNull(parms.getId())) {
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "参数id不能为空,请检查");
+        }
+        SystemScenePackageNewPO po = systemScenePackageService.querySystemScenePackageById(parms);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, po);
+
+    }
+
+    //新增打分规则
+    @PostMapping("/saveSystemScenePackage")
+    @ResponseBody
+    public ResponseBodyVO<String> saveSystemScenePackage(@RequestBody SystemScenePackageNewPO parms) {
+        systemScenePackageService.saveSystemScenePackage(parms);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+
+    //删除
+    @PostMapping("/deleteSystemScenePackage")
+    @ResponseBody
+    public ResponseBodyVO<String> deleteScoringRules(@RequestBody SystemScenePackagePO params) {
+        systemScenePackageService.deleteSystemScenePackage(params);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    //编辑场景包
+    @PostMapping("/updateSystemScenePackage")
+    @ResponseBody
+    public ResponseBodyVO<List<ScoringRulesPO>> updateSystemScenePackage(@RequestBody SystemScenePackageNewPO params) {
+        systemScenePackageService.updateSystemScenePackage(params);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    //场景包配置账号查询
+    @PostMapping("/queryUserByPackageId")
+    @ResponseBody
+    public ResponseBodyVO<SystemUserSceneVO> queryUserByPackageId(@RequestBody SystemScenePackageNewPO params) {
+        SystemUserSceneVO vo=  systemScenePackageService.queryUserByPackageId(params);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,vo);
+    }
+    //场景包配置账号添加
+    @PostMapping("/saveUserByPackageId")
+    @ResponseBody
+    public ResponseBodyVO<String> saveUserByPackageId(@RequestBody SystemUserSceneVO params) {
+         systemScenePackageService.saveUserByPackageId(params);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+    //场景包配置账号删除
+    @PostMapping("/deleteUserByPackageId")
+    @ResponseBody
+    public ResponseBodyVO<String> deleteUserByPackageId(@RequestBody SystemUserSceneVO params) {
+        systemScenePackageService.deleteUserByPackageId(params);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    //场景包配置场景列表
+    @PostMapping("/queryPackageList")
+    @ResponseBody
+    public ResponseBodyVO<List<Map>> queryPackageList() {
+        List<Map> list=  systemScenePackageService.queryPackageList();
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,list);
+    }
+
+    //人员添加场景包
+    @PostMapping("/savePackageByUserId")
+    @ResponseBody
+    public ResponseBodyVO<String> savePackageByUserId(@RequestBody SystemUserSceneVO params) {
+        systemScenePackageService.savePackageByUserId(params);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+    //配置账号删除场景包
+    @PostMapping("/deletePackageByUserId")
+    @ResponseBody
+    public ResponseBodyVO<String> deletePackageByUserId(@RequestBody SystemUserSceneVO params) {
+        systemScenePackageService.deletePackageByUserId(params);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    //人员场景包列表
+    @PostMapping("/queryPackageByUserIdList")
+    @ResponseBody
+    public ResponseBodyVO<String> queryPackageByUserIdList(@RequestBody SystemScenePackageParam parms) {
+            PageUtil.setPageInfo(parms);
+            List<SystemScenePackageVO>  list = systemScenePackageService.queryPackageByUserIdList(parms);
+
+            return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,  new PageInfo(list));
+    }
+}

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

@@ -28,5 +28,7 @@ public interface ScenePackageMapper {
 
     //测试包名查唯一
     List<ScenePackageNewVO> queryByPackageName(ScenePackagePO params);
+    //测试包数量
+    Integer queryPackageCount(ScenePackagePO params);
 
 }

+ 26 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemScenePackageMapper.java

@@ -0,0 +1,26 @@
+package com.css.simulation.resource.scene.mapper;
+
+import api.common.pojo.param.scene.SystemScenePackageParam;
+import api.common.pojo.po.scene.SystemScenePackagePO;
+import api.common.pojo.vo.scene.SystemScenePackageVO;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+@Repository
+public interface SystemScenePackageMapper {
+
+    void saveSystemScenePackage(SystemScenePackagePO po);
+
+    List<SystemScenePackageVO> querySystemScenePackageList(SystemScenePackageParam params);
+    List<SystemScenePackageVO> queryPackageByUserIdList(SystemScenePackageParam params);
+    List<Map> queryPackageList( );
+    SystemScenePackagePO querySystemScenePackageById(SystemScenePackageParam params);
+    void deleteSystemScenePackage(SystemScenePackagePO po);
+    void updateSystemScenePackage(SystemScenePackagePO po);
+
+
+}

+ 18 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemScenePackageSublistMapper.java

@@ -0,0 +1,18 @@
+package com.css.simulation.resource.scene.mapper;
+
+import api.common.pojo.param.scene.SystemScenePackageParam;
+import api.common.pojo.po.scene.SystemScenePackagePO;
+import api.common.pojo.po.scene.SystemScenePackageSublistPO;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface SystemScenePackageSublistMapper {
+
+    void saveSystemScenePackageSublist(List<SystemScenePackageSublistPO> list);
+    List<String> querySystemScenePackageSublistList(SystemScenePackageSublistPO po);
+    void deleteSystemScenePackageSublist(SystemScenePackageSublistPO po);
+}

+ 6 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemUserSceneMapper.java

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.scene.mapper;
 
 import api.common.pojo.po.scene.SystemUserScenePO;
+import api.common.pojo.vo.scene.UserSceneVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
@@ -15,12 +16,12 @@ public interface SystemUserSceneMapper {
 
     List<SystemUserScenePO> querySystemUserScene(SystemUserScenePO po);
 
-    //场景列表展示时使用
-    List<String> querySystemUserSceneByType(SystemUserScenePO po);
+    //场景列表展示时使用根据人查包
+    List<String> querySystemUserSceneByUserId(SystemUserScenePO po);
+    //场景列表展示时使用根据包查人
+    List<UserSceneVO> queryUserByPackageId(String packageId);
 
-    //根据用户id删除
-    void deleteSystemUserSceneByUserId(SystemUserScenePO po);
     //场景删除时关联删除关系表
-    void deleteSystemUserSceneBySceneId(SystemUserScenePO po);
+    void deleteSystemUserScene(SystemUserScenePO po);
 
 }

+ 115 - 95
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneAccidentService.java

@@ -3,7 +3,9 @@ package com.css.simulation.resource.scene.service;
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.scene.SceneAccidentParam;
+import api.common.pojo.param.scene.SceneImportParam;
 import api.common.pojo.po.scene.SceneAccidentPO;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.FileUtil;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
@@ -17,9 +19,12 @@ import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.fileupload.FileItem;
 import org.springframework.web.multipart.MultipartFile;
+
 import java.util.Date;
+
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
 import javax.annotation.Resource;
 import java.io.File;
 import java.util.ArrayList;
@@ -56,7 +61,7 @@ public class SceneAccidentService {
         //判断场景名称唯一
         String sceneName = root.path("场景名称").asText();
         String sceneId = SceneAccidentMapper.querySceneAccidentByNmae(sceneName);
-        SceneAccidentPO sceneAccidentPO = null;
+        SceneAccidentPO sceneAccidentPO = new SceneAccidentPO();
         sceneAccidentPO = sceneAccidentPO.builder()
                 .accidentId(StringUtil.getRandomUUID())
                 .sceneName(sceneName)
@@ -187,7 +192,7 @@ public class SceneAccidentService {
         if (ObjectUtil.isNotNull(params.getRearEndCollision()) || ObjectUtil.isNotNull(params.getCutIn()) || ObjectUtil.isNotNull(params.getDriveCurve()) || ObjectUtil.isNotNull(params.getCarConflict())) {
             params.setBq(1);
         }
-        List<SceneAccidentPO> list = null;
+        List<SceneAccidentPO> list = new ArrayList<>();
         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")){
@@ -316,7 +321,7 @@ public class SceneAccidentService {
                 if (scenes1 == null) {
                     throw new RuntimeException("目录:" + dataUrlNew + " 下没有文件!");
                 }
-                SceneAccidentPO sceneAccidentPO = null;
+                SceneAccidentPO sceneAccidentPO = new SceneAccidentPO();
                 Integer nowTime = TimeUtil.getRq(new Date(), 0);
                 for (File scene : scenes1) {
                     String dataUrl = scene.getAbsolutePath();
@@ -436,7 +441,7 @@ public class SceneAccidentService {
                         if (scenes2 == null) {
                             throw new RuntimeException("目录:" + dataUrlNew1 + " 下没有文件!");
                         }
-                        SceneAccidentPO sceneAccidentPO = null;
+                        SceneAccidentPO sceneAccidentPO = new SceneAccidentPO();
                         String isUpdate = "";
                         for (File scene3 : scenes2) {
                             String dataUrl = scene3.getAbsolutePath();
@@ -548,105 +553,120 @@ public class SceneAccidentService {
     /**
      * 获取交通事故场景数据:
      */
-    public ResponseBodyVO<String> importMiNio(MinioParameter parms) {
-
-        MinioParameter MI = new MinioParameter();
-
-        MI.setObjectName(parms.getObjectName());
-        List<String>  errList=new ArrayList<>();
-        List<String> list = fileDownService.listDeepOne(MI).getInfo();
-        String OsgbPath=null;
-        String XodrPath=null;
-        for (String filePath:list) {
-            if (filePath.indexOf("/OSGB") != -1) {
-                OsgbPath = filePath;
-            } else if (filePath.indexOf("/XODR") != -1) {
-                XodrPath = filePath;
+    public SceneImportPO importMiNio(SceneImportParam parms) {
+        SceneImportPO  sceneImportPO=new  SceneImportPO();
+        sceneImportPO.setId(parms.getId());
+        //sceneImportPO.setStatus("3");
+       // sceneImportTaskService.updateSceneImportTask(sceneImportTaskPO);
+        try {
+            MinioParameter MI = new MinioParameter();
+            MI.setObjectName(parms.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.indexOf("/OSGB") != -1) {
+                    OsgbPath = filePath;
+                } else if (filePath.indexOf("/XODR") != -1) {
+                    XodrPath = filePath;
+                }
             }
-        }
-        for (String filePath:list) {
-            if(filePath.indexOf("/Scenarios")!=-1){
-                MI.setObjectName(filePath);
-                List<String> listScene = fileDownService.listDeepOne(MI).getInfo();
-                for (String scenePath:listScene) {
-
-                    try {
-                        MI.setObjectName(scenePath);
-                        List<String> listAderss = fileDownService.list(MI).getInfo();
-                        SceneAccidentPO sceneAccidentPO = null;
-                        String isupdate = null;
-                        for (String adress : listAderss) {
-                            if (adress.indexOf(".json") != -1) {
-                                MI.setObjectName(adress);
-                                Response download = fileDownService.download(MI);
-                                // -------------------------------- label.json --------------------------------
-                                String json = download.body().toString();
-                                ObjectMapper objMap = new ObjectMapper();
-                                JsonNode root = objMap.readTree(json);
-                                //判断场景名称唯一
-                                String sceneName = root.path("场景名称").asText();
-                                String sceneId = SceneAccidentMapper.querySceneAccidentByNmae(sceneName);
-                                String osgbAdress = OsgbPath + "/" + root.path("osgb").asText();
-                                String xodrAdress = XodrPath + "/" + root.path("xodr").asText();
-                                sceneAccidentPO = sceneAccidentPO.builder()
-                                        .accidentId(StringUtil.getRandomUUID())
-                                        .sceneName(sceneName)
-                                        .scenceResume(root.path("场景描述").asText())
-                                        .selfDriving(root.path("自车驾驶行为").asText())
-                                        .targetDriving(root.path("目标驾驶行为").asText())
-                                        .selfReaction(root.path("自车反应行为").asText())
-                                        .conflictBehavior(root.path("冲突行为").asText())
-                                        .conflictType(root.path("冲突类型").asText())
-                                        .sceneTime(root.path("时间").asText())
-                                        .sceneWeather(root.path("天气").asText())
-                                        .maxTime(root.path("max_time").asText())
-                                        .xodrAddress(xodrAdress)
-                                        .osgbAddress(osgbAdress)
-                                        .isDeleted("0")
-                                        .build();
-                                if (ObjectUtil.isNull(sceneId)) {
-                                    isupdate = "0";
-                                } else {
-                                    isupdate = "1";
-                                    sceneAccidentPO.setAccidentId(sceneId);
+            for (String filePath : list) {
+                if (filePath.indexOf("/Scenarios") != -1) {
+                    MI.setObjectName(filePath);
+                    List<String> listScene = fileDownService.listDeepOne(MI).getInfo();
+                    for (String scenePath : listScene) {
+                        try {
+                            MI.setObjectName(scenePath);
+                            List<String> listAderss = fileDownService.list(MI).getInfo();
+                            SceneAccidentPO sceneAccidentPO = new SceneAccidentPO();
+                            String isupdate = null;
+                            for (String adress : listAderss) {
+                                if (adress.indexOf(".json") != -1) {
+                                    MI.setObjectName(adress);
+                                    Response download = fileDownService.download(MI);
+                                    // -------------------------------- label.json --------------------------------
+                                    String json = download.body().toString();
+                                    ObjectMapper objMap = new ObjectMapper();
+                                    JsonNode root = objMap.readTree(json);
+                                    //判断场景名称唯一
+                                    String sceneName = root.path("场景名称").asText();
+                                    String sceneId = SceneAccidentMapper.querySceneAccidentByNmae(sceneName);
+                                    String osgbAdress = OsgbPath + "/" + root.path("osgb").asText();
+                                    String xodrAdress = XodrPath + "/" + root.path("xodr").asText();
+                                    sceneAccidentPO = sceneAccidentPO.builder()
+                                            .accidentId(StringUtil.getRandomUUID())
+                                            .sceneName(sceneName)
+                                            .scenceResume(root.path("场景描述").asText())
+                                            .selfDriving(root.path("自车驾驶行为").asText())
+                                            .targetDriving(root.path("目标驾驶行为").asText())
+                                            .selfReaction(root.path("自车反应行为").asText())
+                                            .conflictBehavior(root.path("冲突行为").asText())
+                                            .conflictType(root.path("冲突类型").asText())
+                                            .sceneTime(root.path("时间").asText())
+                                            .sceneWeather(root.path("天气").asText())
+                                            .maxTime(root.path("max_time").asText())
+                                            .xodrAddress(xodrAdress)
+                                            .osgbAddress(osgbAdress)
+                                            .isDeleted("0")
+                                            .build();
+                                    if (ObjectUtil.isNull(sceneId)) {
+                                        isupdate = "0";
+                                    } else {
+                                        isupdate = "1";
+                                        sceneAccidentPO.setAccidentId(sceneId);
+                                    }
+                                }
+                                if (adress.indexOf(".json") != -1) {
+                                    sceneAccidentPO.setJsonAddress(adress);
+                                } else if (adress.indexOf(".xml") != -1 || adress.indexOf(".xosc") != -1) {
+                                    sceneAccidentPO.setXmlAddress(adress);
+                                } else if (adress.indexOf(".xodr") != -1) {
+                                    sceneAccidentPO.setXodrAddress(adress);
+                                } else if (adress.indexOf(".osgb") != -1) {
+                                    sceneAccidentPO.setOsgbAddress(adress);
+                                } else if (adress.indexOf(".mp4") != -1) {
+                                    sceneAccidentPO.setVideoAddress(adress);
                                 }
-
                             }
-                            if (adress.indexOf(".json") != -1) {
-                                sceneAccidentPO.setJsonAddress(adress);
-                            } else if (adress.indexOf(".xml") != -1 || adress.indexOf(".xosc") != -1) {
-                                sceneAccidentPO.setXmlAddress(adress);
-                            } else if (adress.indexOf(".xodr") != -1) {
-                                sceneAccidentPO.setXodrAddress(adress);
-                            } else if (adress.indexOf(".osgb") != -1) {
-                                sceneAccidentPO.setOsgbAddress(adress);
-                            } else if (adress.indexOf(".mp4") != -1) {
-                                sceneAccidentPO.setVideoAddress(adress);
+                            if (isupdate.equals("0")) {
+                                // -------------------------------- 保存数据到 mysql --------------------------------
+                                sceneAccidentPO.setCreateTime(TimeUtil.getNowForMysql());
+                                sceneAccidentPO.setCreateUserId(AuthUtil.getCurrentUserId());
+                                sceneAccidentPO.setModifyTime(TimeUtil.getNowForMysql());
+                                SceneAccidentMapper.saveSceneAccident(sceneAccidentPO);
+                            } else if (isupdate.equals("1")) {
+                                // -------------------------------- 修改数据到 mysql --------------------------------
+                                sceneAccidentPO.setModifyTime(TimeUtil.getNowForMysql());
+                                sceneAccidentPO.setModifyUserId(AuthUtil.getCurrentUserId());
+                                SceneAccidentMapper.updateSceneAccident(sceneAccidentPO);
                             }
-
-                        }
-                        if (isupdate.equals("0")) {
-                            // -------------------------------- 保存数据到 mysql --------------------------------
-                            sceneAccidentPO.setCreateTime(TimeUtil.getNowForMysql());
-                            sceneAccidentPO.setCreateUserId(AuthUtil.getCurrentUserId());
-                            sceneAccidentPO.setModifyTime(TimeUtil.getNowForMysql());
-                            SceneAccidentMapper.saveSceneAccident(sceneAccidentPO);
-                        } else if (isupdate.equals("1")) {
-                            // -------------------------------- 修改数据到 mysql --------------------------------
-                            sceneAccidentPO.setModifyTime(TimeUtil.getNowForMysql());
-                            sceneAccidentPO.setModifyUserId(AuthUtil.getCurrentUserId());
-                            SceneAccidentMapper.updateSceneAccident(sceneAccidentPO);
+                            successNum = successNum + 1;
+                        } catch (Exception e) {
+                            if (ObjectUtil.isNull(errorMessage)) {
+                                errorMessage = scenePath;
+                            } else {
+                                errorMessage = errorMessage + ";" + scenePath;
+                            }
+                            falseNum = falseNum + 1;
                         }
-                    }catch (Exception e){
-                        errList.add(scenePath);
-                }
+                    }
                 }
             }
-
+            sceneImportPO.setStatus("4");
+            sceneImportPO.setSuccessNum(successNum);
+            sceneImportPO.setFalseNum(falseNum);
+            sceneImportPO.setErrorMessage(errorMessage);
+           // sceneImportTaskService.updateSceneImportTask(sceneImportTaskPO);
+            return sceneImportPO;
+        }catch (Exception e){
+            sceneImportPO.setStatus("2");
+           // sceneImportTaskService.updateSceneImportTask(sceneImportTaskPO);
+            return sceneImportPO;
         }
-
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
-
     }
 
 }

+ 8 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralExampleService.java

@@ -87,9 +87,9 @@ public class SceneGeneralExampleService {
 
     @SneakyThrows
     public  ResponseBodyVO saveSceneGeneralExample(SceneGeneralTemplateVO vo) {
-          /* //测试用
-        SceneGeneralTemplatePO po1=templateMapper.querySceneGeneralTemplateById(po.getTemplateId());
-        BeanUtils.copyProperties(po1, po);*/
+   /*        //测试用
+        SceneGeneralTemplatePO po1=templateMapper.querySceneGeneralTemplateById(vo.getTemplateId());
+        BeanUtils.copyProperties(po1, vo);*/
 
         //查询泛化标志位并赋值
         SceneGeneralTemplatePO poV= templateMapper.querySceneGeneralTemplateById(vo.getTemplateId());
@@ -164,6 +164,11 @@ public class SceneGeneralExampleService {
                 .build();
 
         String post = HttpUtil.post(HttpUtil.getHttpClient(), requestConfig, "http://47.94.105.148:5000/test_1.0", null, map);
+       Boolean success= JsonUtil.readTree(post).get("success").asBoolean();
+       if(!success){
+           String message= JsonUtil.readTree(post).get("message").toString();
+           return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, message);
+       }
         JsonNode params = JsonUtil.readTree(post).get("params");
         // 实例化 ObjectMapper 对象
         ObjectMapper objectMapper = new ObjectMapper();

+ 170 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneNaturalService.java

@@ -1,11 +1,12 @@
 package com.css.simulation.resource.scene.service;
 
 import api.common.pojo.common.ResponseBodyVO;
-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.SceneNaturalNewParam;
 import api.common.pojo.param.scene.SceneNaturalParam;
 import api.common.pojo.po.scene.SceneNaturalPO;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.ObjectUtil;
 import api.common.util.ParamUtil;
 import api.common.util.TimeUtil;
@@ -67,7 +68,7 @@ public class SceneNaturalService {
         JsonNode selfDrivingBehavior = root.path("自车行为");
         // -------------------------------- 目标行为 --------------------------------
         JsonNode targetBehavior = root.path("目标行为");
-        SceneNaturalPO sceneNaturalPO = null;
+        SceneNaturalPO sceneNaturalPO = new SceneNaturalPO();
         sceneNaturalPO = sceneNaturalPO.builder()
                 .naturalId(api.common.util.StringUtil.getRandomUUID())
                 .naturalName(fileName)
@@ -302,7 +303,7 @@ public class SceneNaturalService {
          map.put("poBq",poBq);
         //List<SceneNaturalPO> list = sceneNaturalMapper.querySceneNaturalList(po);
         //只有标签,或下拉框,或者两者都为空
-        List<SceneNaturalPO> list=null;
+        List<SceneNaturalPO> list=new ArrayList<>();
         if((po.getXlk().equals("0")&&po.getBq().equals("0"))||(po.getXlk().equals("1")&&po.getBq().equals("0"))){
             list = sceneNaturalMapper.querySceneNaturalList(po);
         }else if((po.getXlk().equals("0")&&po.getBq().equals("1"))) {
@@ -378,4 +379,170 @@ public class SceneNaturalService {
         params.setCreateUserId(AuthUtil.getCurrentUserId());
        return sceneNaturalMapper.querySceneNumBySy(params);
     }
+
+
+
+    /**
+     * 获取自然场景数据:
+     */
+    public SceneImportPO importMiNio(SceneImportParam parms) {
+        SceneImportPO sceneImportPO=new  SceneImportPO();
+        sceneImportPO.setId(parms.getId());
+        try {
+            MinioParameter MI = new MinioParameter();
+            MI.setObjectName(parms.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.indexOf("/OSGB") != -1) {
+                    OsgbPath = filePath;
+                } else if (filePath.indexOf("/XODR") != -1) {
+                    XodrPath = filePath;
+                }
+            }
+            for (String filePath : list) {
+                if (filePath.indexOf("/Scenarios") != -1) {
+                    MI.setObjectName(filePath);
+                    List<String> listScene = fileDownService.listDeepOne(MI).getInfo();
+                    for (String scenePath : listScene) {
+                        try {
+                            MI.setObjectName(scenePath);
+                            List<String> listAderss = fileDownService.list(MI).getInfo();
+                            SceneNaturalPO sceneNaturalPO = new SceneNaturalPO();
+                            String isupdate = null;
+                            for (String adress : listAderss) {
+                                if (adress.indexOf(".json") != -1) {
+                                    MI.setObjectName(adress);
+                                    Response download = fileDownService.download(MI);
+                                    // -------------------------------- label.json --------------------------------
+                                    String json = download.body().toString();
+                                    ObjectMapper objMap = new ObjectMapper();
+                                    JsonNode root = objMap.readTree(json);
+                                    //判断场景名称唯一
+                                    int idx = adress.lastIndexOf("/");
+                                    int end = adress.lastIndexOf(".");
+                                    String fileName = adress.substring(idx + 1, end);
+                                    String sceneId = sceneNaturalMapper.querySceneNaturaByName(fileName);
+                                    String osgbAdress = OsgbPath + "/" + root.path("osgb").asText();
+                                    String xodrAdress = XodrPath + "/" + root.path("xodr").asText();
+                                    // -------------------------------- 自然环境 --------------------------------
+                                    JsonNode naturalEnvironment = root.path("自然环境");
+                                    // -------------------------------- 道路 --------------------------------
+                                    JsonNode road = root.path("道路");
+                                    // -------------------------------- 基础设施 --------------------------------
+                                    JsonNode infrastructure = root.path("基础设施");
+                                    // -------------------------------- 临时性操纵 --------------------------------
+                                    JsonNode temporaryManipulation = root.path("临时性操纵");
+                                    // -------------------------------- 交通状况 --------------------------------
+                                    JsonNode traffic = root.path("交通状况");
+                                    // -------------------------------- 自车行为 --------------------------------
+                                    JsonNode selfDrivingBehavior = root.path("自车行为");
+                                    // -------------------------------- 目标行为 --------------------------------
+                                    JsonNode targetBehavior = root.path("目标行为");
+                                    sceneNaturalPO.setNaturalId(api.common.util.StringUtil.getRandomUUID());
+                                    sceneNaturalPO.setNaturalName(fileName);
+                                    sceneNaturalPO.setWeather(getSequenceNew(naturalEnvironment, "天气情况"));
+                                    sceneNaturalPO.setBacklight(getSequenceNew(naturalEnvironment, "逆光"));
+                                    sceneNaturalPO.setLightChange(getSequenceNew(naturalEnvironment, "隧道光线变化"));
+                                    sceneNaturalPO.setRoadType(getSequenceNew(road, "道路类型"));
+                                    sceneNaturalPO.setRoadMatrrial(getSequenceNew(road, "路面材质"));
+                                    sceneNaturalPO.setDrivewayNum(getSequenceNew(road, "车道数量"));
+                                    sceneNaturalPO.setDrivewayType(getSequenceNew(road, "车道类型"));
+                                    sceneNaturalPO.setRoadFlatness(getSequenceNew(road, "道路平坦程度"));
+                                    sceneNaturalPO.setRoadCurvature(getSequenceNew(road, "道路弯曲度"));
+                                    sceneNaturalPO.setRamp(getSequenceNew(road, "匝道"));
+                                    sceneNaturalPO.setIntersectionType(getSequenceNew(road, "路口类型"));
+                                    sceneNaturalPO.setPlaneIntersection(getSequenceNew(road, "道路与铁路平面交叉"));
+                                    sceneNaturalPO.setBridge(getSequenceNew(road, "桥梁"));
+                                    sceneNaturalPO.setTunnel(getSequenceNew(road, "隧道"));
+                                    sceneNaturalPO.setSpeedLimit(getSequenceNew(infrastructure, "限速标志"));
+                                    sceneNaturalPO.setMinSpeedLimit(getSequenceNew(infrastructure, "最低限速标志"));
+                                    sceneNaturalPO.setNoEntry(getSequenceNew(infrastructure, "禁止通行"));
+                                    sceneNaturalPO.setNoStopping(getSequenceNew(infrastructure, "禁止停车"));
+                                    sceneNaturalPO.setLeftLaneLine(getSequenceNew(infrastructure, "左侧车道线"));
+                                    sceneNaturalPO.setRightLaneLine(getSequenceNew(infrastructure, "右侧车道线"));
+                                    sceneNaturalPO.setConductorMarking(getSequenceNew(infrastructure, "导线标线及标志"));
+                                    sceneNaturalPO.setPedestrianCrossing(getSequenceNew(infrastructure, "人行横道"));
+                                    sceneNaturalPO.setTrafficLight(getSequenceNew(infrastructure, "交通信号灯"));
+                                    sceneNaturalPO.setDecelerationMarking(getSequenceNew(infrastructure, "减速标线"));
+                                    sceneNaturalPO.setPavementCondition(getSequenceNew(temporaryManipulation, "路面状况"));
+                                    sceneNaturalPO.setNaturalDisaster(getSequenceNew(temporaryManipulation, "自然灾害"));
+                                    sceneNaturalPO.setRoadSafetySigns(getSequenceNew(temporaryManipulation, "道路施工安全标识"));
+                                    sceneNaturalPO.setSafetyWarningBoard(getSequenceNew(temporaryManipulation, "三角安全警示牌"));
+                                    sceneNaturalPO.setTrafficAccident(getSequenceNew(traffic, "交通事故"));
+                                    sceneNaturalPO.setViolation(getSequenceNew(traffic, "违规"));
+                                    sceneNaturalPO.setSpecialVehicleYield(getSequenceNew(traffic, "特种车辆让行"));
+                                    sceneNaturalPO.setPatency(getSequenceNew(traffic, "通畅情况"));
+                                    sceneNaturalPO.setDoubleFlashingCar(getSequenceNew(traffic, "双闪车辆"));
+                                    sceneNaturalPO.setSelfBehavior(getSequenceNew(selfDrivingBehavior));
+                                    sceneNaturalPO.setTargetBehavior(getSequenceNew(targetBehavior));
+                                    sceneNaturalPO.setMaxTime(root.path("max_time").asText());
+                                             sceneNaturalPO.setIsDeleted("0");
+                                    if(ObjectUtil.isNull(sceneNaturalPO.getOsgbAddress())){
+                                        sceneNaturalPO.setOsgbAddress(osgbAdress);
+                                    }
+                                    if(ObjectUtil.isNull(sceneNaturalPO.getXodrAddress())){
+                                        sceneNaturalPO.setXodrAddress(xodrAdress);
+                                    }
+                                    if (ObjectUtil.isNull(sceneId)) {
+                                        isupdate = "0";
+                                    } else {
+                                        isupdate = "1";
+                                        sceneNaturalPO.setNaturalId(sceneId);
+                                    }
+                                }
+                                if (adress.indexOf(".json") != -1) {
+                                    sceneNaturalPO.setJsonAddress(adress);
+                                } else if (adress.indexOf(".xml") != -1 || adress.indexOf(".xosc") != -1) {
+                                    sceneNaturalPO.setXoscAddress(adress);
+                                } else if (adress.indexOf(".xodr") != -1) {
+                                    sceneNaturalPO.setXodrAddress(adress);
+                                } else if (adress.indexOf(".osgb") != -1) {
+                                    sceneNaturalPO.setOsgbAddress(adress);
+                                } else if (adress.indexOf("simulation.mp4") != -1) {
+                                    sceneNaturalPO.setVideoAddress(adress);
+                                }else if (adress.indexOf(".mp4") != -1) {
+                                    sceneNaturalPO.setVideoPreview(adress);
+                                }
+                            }
+                            if (isupdate.equals("0")) {
+                                // -------------------------------- 保存数据到 mysql --------------------------------
+                                sceneNaturalPO.setCreateTime(TimeUtil.getNowForMysql());
+                                sceneNaturalPO.setCreateUserId(AuthUtil.getCurrentUserId());
+                                sceneNaturalPO.setModifyTime(TimeUtil.getNowForMysql());
+                                sceneNaturalMapper.saveSceneNatural(sceneNaturalPO);
+                            } else if (isupdate.equals("1")) {
+                                // -------------------------------- 修改数据到 mysql --------------------------------
+                                sceneNaturalPO.setModifyTime(TimeUtil.getNowForMysql());
+                                sceneNaturalPO.setModifyUserId(AuthUtil.getCurrentUserId());
+                                sceneNaturalMapper.updateSceneNatural(sceneNaturalPO);
+                            }
+                            successNum = successNum + 1;
+                        } catch (Exception e) {
+                            if (ObjectUtil.isNull(errorMessage)) {
+                                errorMessage = scenePath;
+                            } else {
+                                errorMessage = errorMessage + ";" + scenePath;
+                            }
+                            falseNum = falseNum + 1;
+                        }
+                    }
+                }
+            }
+            sceneImportPO.setStatus("4");
+            sceneImportPO.setSuccessNum(successNum);
+            sceneImportPO.setFalseNum(falseNum);
+            sceneImportPO.setErrorMessage(errorMessage);
+          //  sceneImportTaskService.updateSceneImportTask(sceneImportTaskPO);
+            return sceneImportPO;
+        }catch (Exception e){
+            sceneImportPO.setStatus("2");
+           return sceneImportPO;
+        }
+    }
+
 }

+ 92 - 76
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/ScenePackageService.java

@@ -12,10 +12,12 @@ import api.common.util.TimeUtil;
 import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.scene.mapper.ScenePackageMapper;
 import com.css.simulation.resource.scene.mapper.ScenePackageSublistMapper;
+import com.css.simulation.resource.system.service.ParameterService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
 import java.util.*;
 
@@ -27,6 +29,8 @@ public class ScenePackageService {
     private ScenePackageMapper scenePackageMapper;
     @Resource
     private ScenePackageSublistMapper scenePackageSublistMapper;
+    @Resource
+    private ParameterService parameterService;
 
     /**
      * 测试包数据录入大保存:
@@ -41,7 +45,7 @@ public class ScenePackageService {
             po.setShare("0");
             List<ScenePackageNewVO> listName = scenePackageMapper.queryByPackageName(po);
             if (listName != null && listName.size() > 0) {
-                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "测试包名称packName=" + po.getPackageName() + "已存在,请重新命名");
+                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "测试包名称:" + po.getPackageName() + "已存在,请重新命名");
             }
             po.setWeight(vo.getWeight());
             po.setRemarks(vo.getRemarks());
@@ -58,24 +62,24 @@ public class ScenePackageService {
         po.setCreateUserId(AuthUtil.getCurrentUserId());
 
         List<ScenePackageSublistPO> poList = new ArrayList<>();
-        List<ScenePackageSublistPO> treeList = instShareListTree(listSublictTree, uuId, uuId, poList, "0",1);
-       //校验指标名称唯一
+        List<ScenePackageSublistPO> treeList = instShareListTree(listSublictTree, uuId, uuId, poList, "0", 1);
+        //校验指标名称唯一
         if (treeList == null || treeList.size() < 1) {
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "指标数据为空,请检查");
         }
-        if(treeList!=null && treeList.size()>1){
-            Set set=new HashSet();
-        Map map=new HashMap<>();
-            for (ScenePackageSublistPO vo: treeList ) {
-              Object sublistName=  map.get(vo.getSublistName());
-              if(ObjectUtil.isNull(sublistName)){
-                  map.put(vo.getSublistName(),vo.getSublistName());
-              }else{
-                      set.add(vo.getSublistName());
-              }
+        if (treeList != null && treeList.size() > 1) {
+            Set set = new HashSet();
+            Map map = new HashMap<>();
+            for (ScenePackageSublistPO vo : treeList) {
+                Object sublistName = map.get(vo.getSublistName());
+                if (ObjectUtil.isNull(sublistName)) {
+                    map.put(vo.getSublistName(), vo.getSublistName());
+                } else {
+                    set.add(vo.getSublistName());
+                }
             }
-            if(ObjectUtil.isNotNull(set)){
-                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "该条数据中指标名称:"+set+"重复,请检查");
+            if (ObjectUtil.isNotNull(set)) {
+                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "该条数据中指标名称:" + set + "重复,请检查");
             }
         }
         scenePackageMapper.saveScenePackage(po);
@@ -103,7 +107,7 @@ public class ScenePackageService {
             po.setPackageId(vo.getId());
             List<ScenePackageNewVO> listName = scenePackageMapper.queryByPackageName(po);
             if (listName != null && listName.size() > 0) {
-                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "测试包名称packName=" + po.getPackageName() + "已存在,请重新命名");
+                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "测试包名称:" + po.getPackageName() + "已存在,请重新命名");
             }
             po.setWeight(vo.getWeight());
             po.setRemarks(vo.getRemarks());
@@ -117,23 +121,23 @@ public class ScenePackageService {
         po.setIsDeleted("0");
         po.setShare("0");
         List<ScenePackageSublistPO> poList = new ArrayList<>();
-        List<ScenePackageSublistPO> treeList = instShareListTree(listSublictTree, po.getPackageId(), po.getPackageId(), poList, "0",1);
+        List<ScenePackageSublistPO> treeList = instShareListTree(listSublictTree, po.getPackageId(), po.getPackageId(), poList, "0", 1);
         if (treeList == null || treeList.size() < 1) {
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "指标数据为空,请检查");
         }
-        if(treeList!=null && treeList.size()>1){
-            Set set=new HashSet();
-            Map map=new HashMap<>();
-            for (ScenePackageSublistPO vo: treeList ) {
-                Object sublistName=  map.get(vo.getSublistName());
-                if(ObjectUtil.isNull(sublistName)){
-                    map.put(vo.getSublistName(),vo.getSublistName());
-                }else{
+        if (treeList != null && treeList.size() > 1) {
+            Set set = new HashSet();
+            Map map = new HashMap<>();
+            for (ScenePackageSublistPO vo : treeList) {
+                Object sublistName = map.get(vo.getSublistName());
+                if (ObjectUtil.isNull(sublistName)) {
+                    map.put(vo.getSublistName(), vo.getSublistName());
+                } else {
                     set.add(vo.getSublistName());
                 }
             }
-            if(ObjectUtil.isNotNull(set)){
-                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "该条数据中指标名称:"+set+"重复,请检查");
+            if (ObjectUtil.isNotNull(set)) {
+                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "该条数据中指标名称:" + set + "重复,请检查");
             }
         }
         scenePackageMapper.updateScenePackage(po);
@@ -217,12 +221,12 @@ public class ScenePackageService {
         ScenePackageSublistPO params = new ScenePackageSublistPO();
         params.setParentId(scenePackageId);
         if (isRoot) {
-                //查找一级节点
-                parentVoList = scenePackageSublistMapper.queryScenePackageSublistList(params);
-                if (parentVoList != null && parentVoList.size() > 0) {
-                    selectScenePackageSubListTree(parentVoList, false, null);
-                }
-            } else {
+            //查找一级节点
+            parentVoList = scenePackageSublistMapper.queryScenePackageSublistList(params);
+            if (parentVoList != null && parentVoList.size() > 0) {
+                selectScenePackageSubListTree(parentVoList, false, null);
+            }
+        } else {
             //获取子节点集合
             for (ScenePackageSublistVO pvo : parentVoList) {
                 params.setParentId(pvo.getId());
@@ -250,7 +254,7 @@ public class ScenePackageService {
         po.setPackageName(scenePackagePO.getPackageName());
         List<ScenePackageNewVO> listName = scenePackageMapper.queryByPackageName(po);
         if (listName != null && listName.size() > 0) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "测试包名称packName=" + listName.get(0).getPackageName() + "的测试包已存在,请检查");
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "测试包名称:" + listName.get(0).getPackageName() + "的测试包已存在,请检查");
         }
         BeanUtils.copyProperties(scenePackagePO, po);
         po.setCreateTime(TimeUtil.getNowForMysql());
@@ -263,20 +267,20 @@ public class ScenePackageService {
         po.setShare("1");
         List<ScenePackageSublistPO> poList = new ArrayList<>();
         List<ScenePackageSublistVO> listSublist = selectScenePackageSubListTree(null, true, params.getPackageId());
-        List<ScenePackageSublistPO> treeList = instShareListTree(listSublist, uuId, uuId, poList, "1",1);
-        if(treeList!=null && treeList.size()>1){
-            Set set=new HashSet();
-            Map map=new HashMap<>();
-            for (ScenePackageSublistPO vo: treeList ) {
-                Object sublistName=  map.get(vo.getSublistName());
-                if(ObjectUtil.isNull(sublistName)){
-                    map.put(vo.getSublistName(),vo.getSublistName());
-                }else{
+        List<ScenePackageSublistPO> treeList = instShareListTree(listSublist, uuId, uuId, poList, "1", 1);
+        if (treeList != null && treeList.size() > 1) {
+            Set set = new HashSet();
+            Map map = new HashMap<>();
+            for (ScenePackageSublistPO vo : treeList) {
+                Object sublistName = map.get(vo.getSublistName());
+                if (ObjectUtil.isNull(sublistName)) {
+                    map.put(vo.getSublistName(), vo.getSublistName());
+                } else {
                     set.add(vo.getSublistName());
                 }
             }
-            if(ObjectUtil.isNotNull(set)){
-                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "该条数据中指标名称:"+set+"重复,请检查");
+            if (ObjectUtil.isNotNull(set)) {
+                return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "该条数据中指标名称:" + set + "重复,请检查");
             }
         }
         scenePackageMapper.saveScenePackage(po);
@@ -292,38 +296,38 @@ public class ScenePackageService {
      * @return
      */
     public List<ScenePackageSublistPO> instShareListTree(List<ScenePackageSublistVO> parentVoList,
-                                       String scenePackageId, String rootId, List<ScenePackageSublistPO> poList
-            , String share,Integer level) {
-            //获取子节点集合
-            for (int i = 0; i < parentVoList.size(); i++) {
-                ScenePackageSublistPO params = new ScenePackageSublistPO();
-                BeanUtils.copyProperties(parentVoList.get(i), params);
-                params.setParentId(scenePackageId);
-                params.setRootId(rootId);
-                params.setSublistName(parentVoList.get(i).getSublistName());
-                params.setCreateTime(TimeUtil.getNowForMysql());
-                params.setModifyTime(TimeUtil.getNowForMysql());
-                params.setCreateUserId(AuthUtil.getCurrentUserId());
-                //添加泛化后处理
-                if(ObjectUtil.isNull(parentVoList.get(i).getId())){
-                    String uuId = StringUtil.getRandomUUID();
-                    params.setId(uuId);   //主键ID
-                }
-                params.setIsDeleted("0");
-                params.setShare(share);
-                params.setPackageLevel(level);
-                params.setTreeNode(parentVoList.get(i).getTreeNode());
-                List<ScenePackageSublistVO> cvoList = parentVoList.get(i).getChildren();
-                poList.add(params);
-                if (cvoList != null && cvoList.size() > 0) {
-                    //继续查找下一节点
-                    int b=level+1;
-                    instShareListTree(cvoList, params.getId(), rootId, poList, share,b);
-                }
-                parentVoList.remove(parentVoList.get(i));
-                i--;
-
+                                                         String scenePackageId, String rootId, List<ScenePackageSublistPO> poList
+            , String share, Integer level) {
+        //获取子节点集合
+        for (int i = 0; i < parentVoList.size(); i++) {
+            ScenePackageSublistPO params = new ScenePackageSublistPO();
+            BeanUtils.copyProperties(parentVoList.get(i), params);
+            params.setParentId(scenePackageId);
+            params.setRootId(rootId);
+            params.setSublistName(parentVoList.get(i).getSublistName());
+            params.setCreateTime(TimeUtil.getNowForMysql());
+            params.setModifyTime(TimeUtil.getNowForMysql());
+            params.setCreateUserId(AuthUtil.getCurrentUserId());
+            //添加泛化后处理  如果是泛化用返回值中的结果
+            if (ObjectUtil.isNull(parentVoList.get(i).getId())&&parentVoList.get(i).getId().length()<10) {
+                String uuId = StringUtil.getRandomUUID();
+                params.setId(uuId);   //主键ID
             }
+            params.setIsDeleted("0");
+            params.setShare(share);
+            params.setPackageLevel(level);
+            params.setTreeNode(parentVoList.get(i).getTreeNode());
+            List<ScenePackageSublistVO> cvoList = parentVoList.get(i).getChildren();
+            poList.add(params);
+            if (cvoList != null && cvoList.size() > 0) {
+                //继续查找下一节点
+                int b = level + 1;
+                instShareListTree(cvoList, params.getId(), rootId, poList, share, b);
+            }
+            parentVoList.remove(parentVoList.get(i));
+            i--;
+
+        }
 
 
         return poList;
@@ -334,4 +338,16 @@ public class ScenePackageService {
         return scenePackageMapper.queryByPackageName(params);
     }
 
+    //查询个人测试包数量
+    @SneakyThrows
+    public Map queryPackageCount() {
+        ScenePackagePO params=new ScenePackagePO();
+        params.setCreateUserId(AuthUtil.getCurrentUserId());
+        params.setShare("0");
+        int myPackageCount= scenePackageMapper.queryPackageCount(params);
+        HashMap<String, Integer> sceneParam = parameterService.getSceneParam();
+        sceneParam.put("myPackageCount",myPackageCount);//场景包数量
+        return sceneParam;
+    }
+
 }

+ 114 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/StandardsRegulationsService.java

@@ -1,11 +1,11 @@
 package com.css.simulation.resource.scene.service;
 
 import api.common.pojo.common.ResponseBodyVO;
-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.StandardsRegulationsParam;
-import api.common.pojo.po.scene.SceneAccidentPO;
 import api.common.pojo.po.scene.StandardsRegulationsPO;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
 import api.common.util.TimeUtil;
@@ -48,7 +48,7 @@ public class StandardsRegulationsService {
         String sceneName = root.path("场景名称").asText();
        String sceneId = standardsRegulationsMapper.queryStandardsRegulationsByName(sceneName);
 
-        StandardsRegulationsPO standardsRegulationsPO = null;
+        StandardsRegulationsPO standardsRegulationsPO = new StandardsRegulationsPO();
         standardsRegulationsPO = standardsRegulationsPO.builder()
                 .regulationsId(StringUtil.getRandomUUID())
                 .sceneName(sceneName)
@@ -106,7 +106,7 @@ public class StandardsRegulationsService {
         if(params.getLabel()!=null&&params.getLabel().size()>0){
             params.setBq("1");
         }
-        List<StandardsRegulationsPO> list =null;
+        List<StandardsRegulationsPO> list =new ArrayList<>();
 
         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 =  standardsRegulationsMapper.queryStandardsRegulationsList(params);
@@ -148,4 +148,114 @@ public class StandardsRegulationsService {
         standardsRegulationsMapper.deleteStandardsRegulations(params);
        // systemUserSceneService.deleteSystemUserSceneBySceneId(params.getRegulationsId());
     }
+
+
+    /**
+     * 获取交通事故场景数据:
+     */
+    public SceneImportPO importMiNio(SceneImportParam parms) {
+        SceneImportPO sceneImportPO=new  SceneImportPO();
+        sceneImportPO.setId(parms.getId());
+        try {
+            MinioParameter MI = new MinioParameter();
+            MI.setObjectName(parms.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.indexOf("/OSGB") != -1) {
+                    OsgbPath = filePath;
+                } else if (filePath.indexOf("/XODR") != -1) {
+                    XodrPath = filePath;
+                }
+            }
+            for (String filePath : list) {
+                if (filePath.indexOf("/Scenarios") != -1) {
+                    MI.setObjectName(filePath);
+                    List<String> listScene = fileDownService.listDeepOne(MI).getInfo();
+                    for (String scenePath : listScene) {
+                        try {
+                            MI.setObjectName(scenePath);
+                            List<String> listAderss = fileDownService.list(MI).getInfo();
+                            StandardsRegulationsPO standardsRegulationsPO = new StandardsRegulationsPO();
+                            String isupdate = null;
+                            for (String adress : listAderss) {
+                                if (adress.indexOf(".json") != -1) {
+                                    MI.setObjectName(adress);
+                                    Response download = fileDownService.download(MI);
+                                    // -------------------------------- label.json --------------------------------
+                                    String json = download.body().toString();
+                                    ObjectMapper objMap = new ObjectMapper();
+                                    JsonNode root = objMap.readTree(json);
+                                    //判断场景名称唯一
+                                    String sceneName = root.path("场景名称").asText();
+                                    String sceneId = standardsRegulationsMapper.queryStandardsRegulationsByName(sceneName);
+                                    String osgbAdress = OsgbPath + "/" + root.path("osgb").asText();
+                                    String xodrAdress = XodrPath + "/" + root.path("xodr").asText();
+                                    standardsRegulationsPO = standardsRegulationsPO.builder()
+                                            .regulationsId(StringUtil.getRandomUUID())
+                                            .sceneName(sceneName)
+                                            .regulationType(root.path("法规类型").asText())
+                                            .standardType(root.path("标准类型").asText())
+                                            .maxTime(root.path("max_time").asText())
+                                            .xodrAddress(xodrAdress)
+                                            .osgbAddress(osgbAdress)
+                                            .isDeleted("0")
+                                            .build();
+                                    if (ObjectUtil.isNull(sceneId)) {
+                                        isupdate = "0";
+                                    } else {
+                                        isupdate = "1";
+                                        standardsRegulationsPO.setRegulationsId(sceneId);
+                                    }
+                                }
+                                if (adress.indexOf(".json") != -1) {
+                                    standardsRegulationsPO.setJsonAddress(adress);
+                                } else if (adress.indexOf(".xml") != -1 || adress.indexOf(".xosc") != -1) {
+                                    standardsRegulationsPO.setXmlAddress(adress);
+                                } else if (adress.indexOf(".xodr") != -1) {
+                                    standardsRegulationsPO.setXodrAddress(adress);
+                                } else if (adress.indexOf(".osgb") != -1) {
+                                    standardsRegulationsPO.setOsgbAddress(adress);
+                                } else if (adress.indexOf(".mp4") != -1) {
+                                    standardsRegulationsPO.setVideoAddress(adress);
+                                }
+                            }
+                            if (isupdate.equals("0")) {
+                                // -------------------------------- 保存数据到 mysql --------------------------------
+                                standardsRegulationsPO.setCreateTime(TimeUtil.getNowForMysql());
+                                standardsRegulationsPO.setCreateUserId(AuthUtil.getCurrentUserId());
+                                standardsRegulationsPO.setModifyTime(TimeUtil.getNowForMysql());
+                                standardsRegulationsMapper.saveStandardsRegulations(standardsRegulationsPO);
+                            } else if (isupdate.equals("1")) {
+                                // -------------------------------- 修改数据到 mysql --------------------------------
+                                standardsRegulationsPO.setModifyTime(TimeUtil.getNowForMysql());
+                                standardsRegulationsPO.setModifyUserId(AuthUtil.getCurrentUserId());
+                                standardsRegulationsMapper.updateStandardsRegulations(standardsRegulationsPO);
+                            }
+                            successNum = successNum + 1;
+                        } catch (Exception e) {
+                            if (ObjectUtil.isNull(errorMessage)) {
+                                errorMessage = scenePath;
+                            } else {
+                                errorMessage = errorMessage + ";" + scenePath;
+                            }
+                            falseNum = falseNum + 1;
+                        }
+                    }
+                }
+            }
+            sceneImportPO.setStatus("4");
+            sceneImportPO.setSuccessNum(successNum);
+            sceneImportPO.setFalseNum(falseNum);
+            sceneImportPO.setErrorMessage(errorMessage);
+            return sceneImportPO;
+        }catch (Exception e){
+            sceneImportPO.setStatus("2");
+            return sceneImportPO;
+        }
+    }
 }

+ 342 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SystemScenePackageService.java

@@ -0,0 +1,342 @@
+package com.css.simulation.resource.scene.service;
+
+import api.common.pojo.param.scene.ScoringRulesParam;
+import api.common.pojo.param.scene.SystemScenePackageParam;
+import api.common.pojo.po.scene.*;
+import api.common.pojo.vo.scene.PackageVO;
+import api.common.pojo.vo.scene.SystemScenePackageVO;
+import api.common.pojo.vo.scene.SystemUserSceneVO;
+import api.common.pojo.vo.scene.UserSceneVO;
+import api.common.util.ObjectUtil;
+import api.common.util.StringUtil;
+import api.common.util.TimeUtil;
+import com.css.simulation.resource.common.utils.AuthUtil;
+import com.css.simulation.resource.scene.mapper.ScoringRulesMapper;
+import com.css.simulation.resource.scene.mapper.SystemScenePackageMapper;
+import com.css.simulation.resource.scene.mapper.SystemScenePackageSublistMapper;
+import com.css.simulation.resource.scene.mapper.SystemUserSceneMapper;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class SystemScenePackageService {
+
+    @Resource
+    private SystemScenePackageMapper systemScenePackageMapper;
+    @Resource
+    private SystemScenePackageSublistMapper systemScenePackageSublistMapper;
+    @Resource
+    private SystemUserSceneMapper systemUserSceneMapper;
+
+    /**
+     * 场景包录入
+     */
+    @SneakyThrows
+    public void saveSystemScenePackage(SystemScenePackageNewPO params) {
+
+        SystemScenePackagePO  po=new SystemScenePackagePO();
+        po.setPackageName(params.getPackageName());
+        po.setSceneDescribe(params.getSceneDescribe());
+        String packId=StringUtil.getRandomUUID();
+        po.setId(packId);
+        po.setCreateTime(TimeUtil.getNowForMysql());
+        po.setModifyTime(TimeUtil.getNowForMysql());
+        po.setCreateUserId(AuthUtil.getCurrentUserId());
+        po.setIsDeleted("0");
+        //zr
+        List<String> zrIds=params.getZrIds();
+        if(ObjectUtil.isNotNull(zrIds)){
+            List<SystemScenePackageSublistPO> zrList=new ArrayList<>();
+            for (String id:zrIds) {
+                SystemScenePackageSublistPO zrPo=new SystemScenePackageSublistPO();
+                zrPo.setSublistId(StringUtil.getRandomUUID());
+                zrPo.setSceneType("1");
+                zrPo.setSceneId(id);
+                zrPo.setSceneAndPackage(packId);
+                zrPo.setCreateTime(TimeUtil.getNowForMysql());
+                zrPo.setModifyTime(TimeUtil.getNowForMysql());
+                zrPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                zrList.add(zrPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(zrList);
+        }
+//zr
+        List<String> bzIds=params.getBzIds();
+        if(ObjectUtil.isNotNull(bzIds)){
+            List<SystemScenePackageSublistPO> bzList=new ArrayList<>();
+            for (String id:bzIds) {
+                SystemScenePackageSublistPO bzPo=new SystemScenePackageSublistPO();
+                bzPo.setSublistId(StringUtil.getRandomUUID());
+                bzPo.setSceneType("2");
+                bzPo.setSceneId(id);
+                bzPo.setSceneAndPackage(packId);
+                bzPo.setCreateTime(TimeUtil.getNowForMysql());
+                bzPo.setModifyTime(TimeUtil.getNowForMysql());
+                bzPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                bzList.add(bzPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(bzList);
+        }
+        //zr
+        List<String> jtIds=params.getJtIds();
+        if(ObjectUtil.isNotNull(jtIds)){
+            List<SystemScenePackageSublistPO> jtList=new ArrayList<>();
+            for (String id:jtIds) {
+                SystemScenePackageSublistPO jtPo=new SystemScenePackageSublistPO();
+                jtPo.setSublistId(StringUtil.getRandomUUID());
+                jtPo.setSceneType("3");
+                jtPo.setSceneId(id);
+                jtPo.setSceneAndPackage(packId);
+                jtPo.setCreateTime(TimeUtil.getNowForMysql());
+                jtPo.setModifyTime(TimeUtil.getNowForMysql());
+                jtPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                jtList.add(jtPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(jtList);
+        }
+        //zr
+        List<String> fhIds=params.getFhIds();
+        if(ObjectUtil.isNotNull(fhIds)){
+            List<SystemScenePackageSublistPO> fhList=new ArrayList<>();
+            for (String id:zrIds) {
+                SystemScenePackageSublistPO fhPo=new SystemScenePackageSublistPO();
+                fhPo.setSublistId(StringUtil.getRandomUUID());
+                fhPo.setSceneType("4");
+                fhPo.setSceneId(id);
+                fhPo.setSceneAndPackage(packId);
+                fhPo.setCreateTime(TimeUtil.getNowForMysql());
+                fhPo.setModifyTime(TimeUtil.getNowForMysql());
+                fhPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                fhList.add(fhPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(fhList);
+        }
+        systemScenePackageMapper.saveSystemScenePackage(po);
+    }
+    //场景包列表
+    @SneakyThrows
+    public List<SystemScenePackageVO> querySystemScenePackageList(SystemScenePackageParam params) {
+        List<SystemScenePackageVO> list = systemScenePackageMapper.querySystemScenePackageList(params);
+        return list;
+    }
+    //编辑场景包
+    @SneakyThrows
+    public SystemScenePackageNewPO querySystemScenePackageById(SystemScenePackageParam params) {
+        SystemScenePackageNewPO newPo=new SystemScenePackageNewPO();
+        SystemScenePackagePO po = systemScenePackageMapper.querySystemScenePackageById(params);
+        SystemScenePackageSublistPO sublistPo=new SystemScenePackageSublistPO();
+        sublistPo.setSceneAndPackage(params.getId());
+        sublistPo.setSceneType("1");
+       List<String>  zrList=systemScenePackageSublistMapper.querySystemScenePackageSublistList(sublistPo);
+        sublistPo.setSceneType("2");
+        List<String>  bzList=systemScenePackageSublistMapper.querySystemScenePackageSublistList(sublistPo);
+        sublistPo.setSceneType("3");
+        List<String>  jtList=systemScenePackageSublistMapper.querySystemScenePackageSublistList(sublistPo);
+        sublistPo.setSceneType("4");
+        List<String>  fhList=systemScenePackageSublistMapper.querySystemScenePackageSublistList(sublistPo);
+        BeanUtils.copyProperties(po, newPo);
+        newPo.setZrIds(zrList);
+        newPo.setBzIds(bzList);
+        newPo.setJtIds(jtList);
+        newPo.setFhIds(fhList);
+        return newPo;
+    }
+    //编辑场景包
+    @SneakyThrows
+    public void updateSystemScenePackage(SystemScenePackageNewPO params) {
+        SystemScenePackagePO  po=new SystemScenePackagePO();
+        po.setPackageName(params.getPackageName());
+        po.setSceneDescribe(params.getSceneDescribe());
+        String packId=params.getId();
+        po.setId(packId);
+        //删除之前的子表
+        SystemScenePackageSublistPO sublistPO=new SystemScenePackageSublistPO();
+        sublistPO.setModifyTime(TimeUtil.getNowForMysql());
+        sublistPO.setModifyUserId(AuthUtil.getCurrentUserId());
+        sublistPO.setSceneAndPackage(packId);
+        sublistPO.setIsDeleted("1");
+        systemScenePackageSublistMapper.deleteSystemScenePackageSublist(sublistPO);
+        //zr
+        List<String> zrIds=params.getZrIds();
+        if(ObjectUtil.isNotNull(zrIds)){
+            List<SystemScenePackageSublistPO> zrList=new ArrayList<>();
+            for (String id:zrIds) {
+                SystemScenePackageSublistPO zrPo=new SystemScenePackageSublistPO();
+                zrPo.setSublistId(StringUtil.getRandomUUID());
+                zrPo.setSceneType("1");
+                zrPo.setSceneId(id);
+                zrPo.setSceneAndPackage(packId);
+                zrPo.setCreateTime(TimeUtil.getNowForMysql());
+                zrPo.setModifyTime(TimeUtil.getNowForMysql());
+                zrPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                zrList.add(zrPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(zrList);
+        }
+//zr
+        List<String> bzIds=params.getBzIds();
+        if(ObjectUtil.isNotNull(bzIds)){
+            List<SystemScenePackageSublistPO> bzList=new ArrayList<>();
+            for (String id:bzIds) {
+                SystemScenePackageSublistPO bzPo=new SystemScenePackageSublistPO();
+                bzPo.setSublistId(StringUtil.getRandomUUID());
+                bzPo.setSceneType("2");
+                bzPo.setSceneId(id);
+                bzPo.setSceneAndPackage(packId);
+                bzPo.setCreateTime(TimeUtil.getNowForMysql());
+                bzPo.setModifyTime(TimeUtil.getNowForMysql());
+                bzPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                bzList.add(bzPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(bzList);
+        }
+        //zr
+        List<String> jtIds=params.getJtIds();
+        if(ObjectUtil.isNotNull(jtIds)){
+            List<SystemScenePackageSublistPO> jtList=new ArrayList<>();
+            for (String id:jtIds) {
+                SystemScenePackageSublistPO jtPo=new SystemScenePackageSublistPO();
+                jtPo.setSublistId(StringUtil.getRandomUUID());
+                jtPo.setSceneType("3");
+                jtPo.setSceneId(id);
+                jtPo.setSceneAndPackage(packId);
+                jtPo.setCreateTime(TimeUtil.getNowForMysql());
+                jtPo.setModifyTime(TimeUtil.getNowForMysql());
+                jtPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                jtList.add(jtPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(jtList);
+        }
+        //zr
+        List<String> fhIds=params.getFhIds();
+        if(ObjectUtil.isNotNull(fhIds)){
+            List<SystemScenePackageSublistPO> fhList=new ArrayList<>();
+            for (String id:zrIds) {
+                SystemScenePackageSublistPO fhPo=new SystemScenePackageSublistPO();
+                fhPo.setSublistId(StringUtil.getRandomUUID());
+                fhPo.setSceneType("4");
+                fhPo.setSceneId(id);
+                fhPo.setSceneAndPackage(packId);
+                fhPo.setCreateTime(TimeUtil.getNowForMysql());
+                fhPo.setModifyTime(TimeUtil.getNowForMysql());
+                fhPo.setCreateUserId(AuthUtil.getCurrentUserId());
+                fhList.add(fhPo);
+            }
+            systemScenePackageSublistMapper.saveSystemScenePackageSublist(fhList);
+        }
+
+        po.setModifyTime(TimeUtil.getNowForMysql());
+        po.setModifyUserId(AuthUtil.getCurrentUserId());
+        systemScenePackageMapper.updateSystemScenePackage(po);
+    }
+    //删除场景包
+    @SneakyThrows
+    public void deleteSystemScenePackage(SystemScenePackagePO params) {
+        params.setIsDeleted("1");
+        params.setModifyTime(TimeUtil.getNowForMysql());
+        params.setModifyUserId(AuthUtil.getCurrentUserId());
+        systemScenePackageMapper.deleteSystemScenePackage(params);
+    }
+    //根据场景包查询配置账号
+    @SneakyThrows
+    public SystemUserSceneVO queryUserByPackageId(SystemScenePackageNewPO params) {
+        SystemUserSceneVO VO=new SystemUserSceneVO();
+        List<UserSceneVO> userIds=systemUserSceneMapper.queryUserByPackageId(params.getId());
+        VO.setPackageId(params.getId());
+        VO.setUserIds(userIds);
+        return VO;
+    }
+
+    //根据场景包添加配置账号
+    @SneakyThrows
+    public void saveUserByPackageId(SystemUserSceneVO params) {
+        List<UserSceneVO> listVo=params.getUserIds();
+        List<SystemUserScenePO>  list=new ArrayList<>();
+        for (UserSceneVO vo:listVo){
+            SystemUserScenePO po=new SystemUserScenePO();
+            po.setPackageId(params.getPackageId());
+            po.setId(StringUtil.getRandomUUID());
+            po.setCreateTime(TimeUtil.getNowForMysql());
+            po.setModifyTime(TimeUtil.getNowForMysql());
+            po.setCreateUserId(AuthUtil.getCurrentUserId());
+            po.setIsDeleted("0");
+            po.setUserId(vo.getUserId());
+            list.add(po);
+        }
+        systemUserSceneMapper.saveSystemUserScene(list);
+    }
+    //根据场景包删除配置账号
+    @SneakyThrows
+    public void deleteUserByPackageId(SystemUserSceneVO params) {
+        List<UserSceneVO> listVo=params.getUserIds();
+        for (UserSceneVO vo:listVo){
+            SystemUserScenePO po=new SystemUserScenePO();
+            po.setPackageId(params.getPackageId());
+            po.setModifyTime(TimeUtil.getNowForMysql());
+            po.setModifyUserId(AuthUtil.getCurrentUserId());
+            po.setIsDeleted("0");
+            po.setUserId(vo.getUserId());
+            systemUserSceneMapper.deleteSystemUserScene(po);
+
+        }
+    }
+
+    //场景分配时场景包的列表
+    @SneakyThrows
+    public  List<Map> queryPackageList( ) {
+        List<Map> list=systemScenePackageMapper.queryPackageList();
+        return list;
+    }
+
+
+    //根据配置账号添加场景包
+    @SneakyThrows
+    public void savePackageByUserId(SystemUserSceneVO params) {
+        List<PackageVO> listVo=params.getPackageList();
+        List<SystemUserScenePO>  list=new ArrayList<>();
+        for (PackageVO vo:listVo){
+            SystemUserScenePO po=new SystemUserScenePO();
+            po.setPackageId(vo.getPackageId());
+            po.setId(StringUtil.getRandomUUID());
+            po.setCreateTime(TimeUtil.getNowForMysql());
+            po.setModifyTime(TimeUtil.getNowForMysql());
+            po.setCreateUserId(AuthUtil.getCurrentUserId());
+            po.setIsDeleted("0");
+            po.setUserId(params.getUserId());
+            list.add(po);
+        }
+        systemUserSceneMapper.saveSystemUserScene(list);
+    }
+
+    //根据场景包删除配置账号
+    @SneakyThrows
+    public void deletePackageByUserId(SystemUserSceneVO params) {
+        List<PackageVO> listVo=params.getPackageList();
+        for (PackageVO vo:listVo){
+            SystemUserScenePO po=new SystemUserScenePO();
+            po.setPackageId(vo.getPackageId());
+            po.setModifyTime(TimeUtil.getNowForMysql());
+            po.setModifyUserId(AuthUtil.getCurrentUserId());
+            po.setIsDeleted("0");
+            po.setUserId(params.getUserId());
+            systemUserSceneMapper.deleteSystemUserScene(po);
+
+        }
+    }
+
+    //配置人员场景包列表
+    @SneakyThrows
+    public List<SystemScenePackageVO> queryPackageByUserIdList(SystemScenePackageParam params) {
+        List<SystemScenePackageVO> list = systemScenePackageMapper.queryPackageByUserIdList(params);
+        return list;
+    }
+}

+ 5 - 17
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SystemUserSceneService.java

@@ -36,11 +36,10 @@ public class SystemUserSceneService {
 
     //场景列表展示时使用
     @SneakyThrows
-    public  List<String> querySystemUserSceneByType(String type) {
+    public  List<String> querySystemUserSceneByUserId() {
         SystemUserScenePO po=new SystemUserScenePO();
-        po.setSceneType(type);
         po.setUserId(AuthUtil.getCurrentUserId());
-        return systemUserSceneMapper.querySystemUserSceneByType(po);
+        return systemUserSceneMapper.querySystemUserSceneByUserId(po);
     }
 
     @SneakyThrows
@@ -48,24 +47,13 @@ public class SystemUserSceneService {
         po.setUserId(AuthUtil.getCurrentUserId());
        return systemUserSceneMapper.querySystemUserScene(po);
     }
-    //根据用户id删除
-    @SneakyThrows
-    public void deleteSystemUserSceneByUserId() {
-        SystemUserScenePO po=new SystemUserScenePO();
-        po.setUserId(AuthUtil.getCurrentUserId());
-        po.setIsDeleted("1");
-        po.setModifyTime(TimeUtil.getNowForMysql());
-        po.setModifyUserId(AuthUtil.getCurrentUserId());
-        systemUserSceneMapper.deleteSystemUserSceneByUserId(po);
-    }
+
     //场景删除时关联删除关系表
     @SneakyThrows
-    public void deleteSystemUserSceneBySceneId(String sceneId) {
-        SystemUserScenePO po=new SystemUserScenePO();
-        po.setSceneId(sceneId);
+    public void deleteSystemUserScene(SystemUserScenePO po) {
         po.setIsDeleted("1");
         po.setModifyTime(TimeUtil.getNowForMysql());
         po.setModifyUserId(AuthUtil.getCurrentUserId());
-        systemUserSceneMapper.deleteSystemUserSceneBySceneId(po);
+        systemUserSceneMapper.deleteSystemUserScene(po);
     }
 }

+ 15 - 54
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ClusterCtrl.java

@@ -1,12 +1,10 @@
 package com.css.simulation.resource.system.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
-import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.system.ClusterParam;
 import api.common.pojo.po.system.ClusterPO;
 import api.common.pojo.vo.system.ClusterVO;
 import api.common.util.ObjectUtil;
-import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.system.service.ClusterService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,30 +30,6 @@ public class ClusterCtrl {
     @RequestMapping("/getClusterList")
     @ResponseBody
     public ResponseBodyVO<PageInfo<ClusterVO>> getClusterList(@RequestBody ClusterParam clusterParam){
-
-        String roleCode = AuthUtil.getCurrentUserRoleCode();
-        if(roleCode == null){
-            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE);
-        }
-        //当前账户为普通账户子账户,列表显示空
-        if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
-            clusterParam.setRoleCode("-1");//查不到
-        }
-        //当前账户为管理员账户,需要查询普通账户,设置roleCode为2
-        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){
-            clusterParam.setRoleCode(DictConstants.ROLE_CODE_UESR);
-        }
-        // 当前账户为普通账户,需要查询该账户创建的普通账户子账户,设置roleCode为3及当前创建用户id
-        if(DictConstants.ROLE_CODE_UESR.equals(roleCode)){
-            String userType = AuthUtil.getCurrentUserType();
-            if("1".equals(userType)){//独占
-                clusterParam.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);
-                clusterParam.setCreateUserId(AuthUtil.getCurrentUserId());
-            }else {
-                clusterParam.setRoleCode("-1"); //查不到
-            }
-
-        }
         ResponseBodyVO<PageInfo<ClusterVO>> response = new ResponseBodyVO<PageInfo<ClusterVO>>(ResponseBodyVO.Response.SUCCESS);
         response.setInfo(clusterService.getClusterList(clusterParam));
         return response;
@@ -66,7 +40,7 @@ public class ClusterCtrl {
      */
     @RequestMapping("/saveCluster")
     @ResponseBody
-    public ResponseBodyVO<ClusterPO> saveCluster(@RequestBody ClusterPO clusterPO) throws Exception {
+    public ResponseBodyVO<ClusterPO> saveCluster(@RequestBody ClusterPO clusterPO) {
         if(ObjectUtil.isNull(clusterPO)){
             return new ResponseBodyVO(false, 400, "参数必传!",null);
         }
@@ -82,7 +56,6 @@ public class ClusterCtrl {
     @RequestMapping("/getClusterHistory")
     @ResponseBody
     public ResponseBodyVO<PageInfo<ClusterVO>> getClusterHistory(@RequestBody ClusterParam clusterParam){
-
         ResponseBodyVO<PageInfo<ClusterVO>> response = new ResponseBodyVO<PageInfo<ClusterVO>>(ResponseBodyVO.Response.SUCCESS);
         response.setInfo(clusterService.getClusterHistory(clusterParam));
         return response;
@@ -93,35 +66,23 @@ public class ClusterCtrl {
      */
     @RequestMapping("/getClusterNum")
     @ResponseBody
-    public ResponseBodyVO<HashMap<String, Integer>> getClusterNum() throws Exception {
-
-        ClusterParam clusterParam = new ClusterParam();
+    public ResponseBodyVO<HashMap<String, Integer>> getClusterNum() {
         ResponseBodyVO<HashMap<String, Integer>> response = new ResponseBodyVO<HashMap<String, Integer>>(ResponseBodyVO.Response.SUCCESS);
-        String roleCode = AuthUtil.getCurrentUserRoleCode();
-        if(roleCode == null){
-            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE);
-        }
-        if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
-            response.setInfo(null);
-        }
-        //当前账户为管理员账户,需要查询普通账户,设置roleCode为2
-        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){
-            clusterParam.setRoleCode(DictConstants.ROLE_CODE_UESR);
-        }
-        // 当前账户为普通账户,需要查询该账户创建的普通账户子账户,设置roleCode为3及当前创建用户id
-        if(DictConstants.ROLE_CODE_UESR.equals(roleCode)){
-            String userType = AuthUtil.getCurrentUserType();
-            if("1".equals(userType)){//独占
-                clusterParam.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);
-                clusterParam.setCreateUserId(AuthUtil.getCurrentUserId());
-            }else {
-                response.setInfo(null);
-            }
-
-        }
-        HashMap<String, Integer> resMap = clusterService.getClusterNum(clusterParam);
+        HashMap<String, Integer> resMap = clusterService.getClusterNum();
         response.setInfo(resMap);
         return response;
     }
 
+    /**
+     * 查询已分配未到期节点数量
+     */
+    @RequestMapping("/getLicenseNum")
+    @ResponseBody
+    public ResponseBodyVO<Integer> getLicenseNum() {
+        ResponseBodyVO<Integer> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        Integer simulationLicenseNum = clusterService.getLicenseNum();
+        response.setInfo(simulationLicenseNum);
+        return response;
+    }
+
 }

+ 15 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ParameterCtrl.java

@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.util.HashMap;
+
 
 @Controller()
 @RequestMapping("/parameter")
@@ -38,7 +40,7 @@ public class ParameterCtrl {
      */
     @RequestMapping("/saveParameter")
     @ResponseBody
-    public ResponseBodyVO<ParameterPO> saveParameter(@RequestBody ParameterPO parameterPO) throws Exception {
+    public ResponseBodyVO<ParameterPO> saveParameter(@RequestBody ParameterPO parameterPO) {
         if(ObjectUtil.isNull(parameterPO)){
             return new ResponseBodyVO(false, 400, "参数必传!",null);
         }
@@ -59,5 +61,17 @@ public class ParameterCtrl {
         return response;
     }
 
+    /**
+     * 查询场景分配配置信息
+     */
+    @RequestMapping("/getSceneParam")
+    @ResponseBody
+    public ResponseBodyVO<HashMap<String, Integer>> getSceneParam() {
+        ResponseBodyVO<HashMap<String, Integer>> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        HashMap<String, Integer> sceneParam = parameterService.getSceneParam();
+        response.setInfo(sceneParam);
+        return response;
+    }
+
 
 }

+ 64 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/SceneImportCtrl.java

@@ -0,0 +1,64 @@
+package com.css.simulation.resource.system.ctrl;
+
+import api.common.pojo.common.ResponseBodyVO;
+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.feign.SceneService;
+import com.css.simulation.resource.system.service.SceneImportService;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.request.RequestContextHolder;
+
+import javax.annotation.Resource;
+
+@Controller
+@RequestMapping("/sceneImport")
+public class SceneImportCtrl {
+
+    @Autowired
+    SceneImportService sceneImportService;
+
+    @Resource
+    SceneService sceneService;
+
+    /**
+     * 保存上传任务
+     */
+    @RequestMapping("/saveTask")
+    @ResponseBody
+    public ResponseBodyVO saveTask(@RequestBody SceneImportPO po) {
+        if(ObjectUtil.isNull(po)){
+            return new ResponseBodyVO(false, 500, "参数错误!",null);
+        }
+        String sceneType = po.getSceneType();
+        if(ObjectUtil.isNull(sceneType) || DictConstants.SCENE_GENERAL.equals(sceneType)){
+            return new ResponseBodyVO(false, 500, "参数错误!",null);
+        }
+        po = sceneImportService.saveTask(po);
+        if(ObjectUtil.isNull(po.getId())){
+            return new ResponseBodyVO(false, 500, "任务名称重复!",null);
+        }
+        ResponseBodyVO<SceneImportPO> response = new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(po);
+        //异步-启动上传
+        RequestContextHolder.setRequestAttributes(RequestContextHolder.getRequestAttributes(),true);
+        sceneService.startImport(po);
+        return response;
+    }
+
+    //查询列表
+    @RequestMapping("/getSceneImporPagetList")
+    @ResponseBody
+    public ResponseBodyVO<PageInfo<SceneImportPO>> getSceneImporPagetList(@RequestBody SceneImportPageParam param) {
+        ResponseBodyVO<PageInfo<SceneImportPO>> response = new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(sceneImportService.getSceneImporPagetList(param));
+        return response;
+    }
+
+}

+ 1 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ClusterMapper.java

@@ -24,4 +24,5 @@ public interface ClusterMapper {
 
     HashMap<String, Integer> getClusterNum(ClusterParam clusterParam);
 
+    Integer getLicenseNum(@Param("userId") String userId);
 }

+ 3 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ParameterMapper.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.HashMap;
 import java.util.List;
 
 @Mapper
@@ -21,4 +22,6 @@ public interface ParameterMapper {
 
     List<ParameterVO> getParamHistory(ParameterParam pageParam);
 
+    HashMap<String, Integer> getSceneParam(@Param("userId") String userId);
+
 }

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä