ソースを参照

Merge remote-tracking branch 'origin/master'

martin 3 年 前
コミット
2d96f88914
42 ファイル変更656 行追加141 行削除
  1. 3 0
      api-common/src/main/java/api/common/pojo/param/scene/SystemScenePackageParam.java
  2. 1 0
      api-common/src/main/java/api/common/pojo/vo/scene/SystemScenePackageVO.java
  3. 3 0
      api-common/src/main/java/api/common/pojo/vo/system/UserVO.java
  4. 3 0
      api-common/src/main/java/api/common/util/ObjectUtil.java
  5. 2 1
      simulation-oauth-client/src/main/java/com/css/simulation/oauth/client/controller/SignController.java
  6. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/Application.java
  7. 12 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/common/exception/GlobalExceptionHandler.java
  8. 35 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/AuthorityCheck.java
  9. 2 2
      simulation-resource-server/src/main/java/com/css/simulation/resource/open/ctrl/MonitorCtrl.java
  10. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneAccidentController.java
  11. 47 2
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneGeneralTemplateController.java
  12. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneNaturalController.java
  13. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/ScoringRulesController.java
  14. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/StandardsRegulationsController.java
  15. 1 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/ScenePackageSublistMapper.java
  16. 31 20
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneAccidentService.java
  17. 5 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralExampleService.java
  18. 170 69
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralTemplateService.java
  19. 11 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneNaturalService.java
  20. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/ScenePackageService.java
  21. 24 12
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/StandardsRegulationsService.java
  22. 0 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ParameterCtrl.java
  23. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/SceneImportCtrl.java
  24. 4 11
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserCtrl.java
  25. 155 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserInfoCtrl.java
  26. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ClusterMapper.java
  27. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/MenuMapper.java
  28. 1 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ParameterMapper.java
  29. 6 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/UserMapper.java
  30. 14 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ClusterService.java
  31. 2 2
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/MenuService.java
  32. 17 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ParameterService.java
  33. 25 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/UserService.java
  34. 10 0
      simulation-resource-server/src/main/resources/bootstrap-test.yaml
  35. 2 2
      simulation-resource-server/src/main/resources/mapper/scene/SceneGeneralExampleMapper.xml
  36. 1 1
      simulation-resource-server/src/main/resources/mapper/scene/SceneGeneralTemplateMapper.xml
  37. 3 1
      simulation-resource-server/src/main/resources/mapper/scene/ScenePackageSublistMapper.xml
  38. 8 2
      simulation-resource-server/src/main/resources/mapper/scene/SystemScenePackageMapper.xml
  39. 4 0
      simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml
  40. 4 4
      simulation-resource-server/src/main/resources/mapper/system/MenuMapper.xml
  41. 6 0
      simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml
  42. 28 1
      simulation-resource-server/src/main/resources/mapper/system/UserMapper.xml

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

@@ -21,6 +21,9 @@ public class SystemScenePackageParam extends CommonPO   implements Serializable
     private String packageName;        // 场景包名
     private String sceneDescribe;          // 场景包描述
     private String userName;          // 账号名称
+    private String userId;          // 账号id
+
+
 
     public String yearMax;//结束时间
 

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

@@ -24,6 +24,7 @@ public class SystemScenePackageVO extends CommonPO implements Serializable {
     private Integer bzCount;            // 标准法规数量
     private Integer jtCount;            // 交通事故数量
     private Integer fhCount;          // 泛化数量
+    private Integer totalCount;          // 总数量
 
     private String userId;
     private String userName;

+ 3 - 0
api-common/src/main/java/api/common/pojo/vo/system/UserVO.java

@@ -11,11 +11,14 @@ public class UserVO {
     private String username;        // 登录用户名
     private String nickname;        // 用户昵称,用于显示
     private String password;        // 密码(加密)
+    private String newPassword;        // 新密码
     private String phone;           // 联系电话
     private String photo;           // 头像
     private String company;         // 所属公司
     private String roleCode;       // 账户角色类型
+    private String roleCodeName;       // 账户角色类型名称
     private String useType;       // 占用类型
+    private String useTypeName;       // 占用类型名称
     private String visible;         // 是否启用
     public Timestamp createTime;    //创建时间
     public String createUserName;    //创建人

+ 3 - 0
api-common/src/main/java/api/common/util/ObjectUtil.java

@@ -160,6 +160,9 @@ public class ObjectUtil {
      * @return
      */
     public static <T> List<T> listToTree(List<T> list){
+        if(isNull(list)){
+            return new LinkedList<T>();
+        }
         return listToTree(list,"0");
     }
 

+ 2 - 1
simulation-oauth-client/src/main/java/com/css/simulation/oauth/client/controller/SignController.java

@@ -185,7 +185,8 @@ public class SignController {
             newUser.setPassword(password);
             newUser.setCompany("国汽");
             newUser.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);//默认为国汽账户子账户
-            newUser.setVisible("1");//启动页面登录功能
+            newUser.setUseType(DictConstants.USE_TYPE_EXCLUSIVE);//占用类型
+            newUser.setVisible("1");//启用登录功能
             newUser.setCreateUserId(oauthParameter.getSimulationZoogooyUserId());
             newUser.setModifyUserId(oauthParameter.getSimulationZoogooyUserId());
             newUser.setCreateTime(TimeUtil.getNowForMysql());

+ 2 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/Application.java

@@ -4,6 +4,7 @@ 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.config.annotation.method.configuration.EnableGlobalMethodSecurity;
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
@@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableResourceServer
 @EnableTransactionManagement
 @EnableAsync
+@EnableGlobalMethodSecurity(prePostEnabled=true)
 public class Application {
 
     public static void main(String[] args) {

+ 12 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/common/exception/GlobalExceptionHandler.java

@@ -4,6 +4,7 @@ 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.security.access.AccessDeniedException;
 import org.springframework.web.bind.MethodArgumentNotValidException;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -35,6 +36,17 @@ public class GlobalExceptionHandler {
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "Required request body is missing!");
     }
 
+
+    /**
+     * 权限校验异常统一处理
+     */
+    @ExceptionHandler(AccessDeniedException.class)
+    @ResponseBody
+    public ResponseBodyVO<Object> handleAccessDeniedException(Exception e) {
+        log.error(e.getMessage(), e);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "Access is denied!");
+    }
+
     /**
      * 服务器错误异常统一处理
      */

+ 35 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/AuthorityCheck.java

@@ -0,0 +1,35 @@
+package com.css.simulation.resource.common.oauth;
+
+import api.common.pojo.constants.DictConstants;
+import com.css.simulation.resource.common.utils.AuthUtil;
+import org.springframework.stereotype.Component;
+
+@Component("AuthorityCheck")
+public class AuthorityCheck {
+
+    public boolean admin(){
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        switch (roleCode){
+            case DictConstants.ROLE_CODE_SYSADMIN:
+                return true;
+            case DictConstants.ROLE_CODE_ADMIN:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    public boolean adminAndUser(){
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        switch (roleCode){
+            case DictConstants.ROLE_CODE_SYSADMIN:
+                return true;
+            case DictConstants.ROLE_CODE_ADMIN:
+                return true;
+            case DictConstants.ROLE_CODE_UESR:
+                return true;
+            default:
+                return false;
+        }
+    }
+}

+ 2 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/open/ctrl/MonitorCtrl.java

@@ -36,9 +36,9 @@ public class MonitorCtrl {
 
         System.out.println("运行自动任务:"+ Calendar.getInstance().getTime()+"/"+paramMap.get("id"));
 
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+        //return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
 
-//        return service.createAutomaticSubProject(param);
+        return service.createAutomaticSubProject(param);
 
     }
 

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneAccidentController.java

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.scene.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.scene.SceneAccidentParam;
 import api.common.pojo.param.scene.SceneImportParam;
@@ -74,7 +75,7 @@ public class SceneAccidentController {
     public ResponseBodyVO<String> saveSceneAccidentBatch(@RequestBody SceneImportParam sceneImportParam) {
         SceneImportPO sceneImportPO=new  SceneImportPO();
         sceneImportPO.setId(sceneImportParam.getId());
-        sceneImportPO.setStatus("3");
+        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_3);
         sceneImportService.updateStatus(sceneImportPO);
         sceneImportPO= sceneAccidentService.importMiNio(sceneImportParam);
         sceneImportService.updateInfo(sceneImportPO);

+ 47 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneGeneralTemplateController.java

@@ -1,10 +1,12 @@
 package com.css.simulation.resource.scene.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.scene.SceneGeneralTemplateParam;
 import api.common.pojo.po.scene.SceneGeneralDataPO;
 import api.common.pojo.po.scene.SceneGeneralExamplePO;
 import api.common.pojo.po.scene.SceneGeneralTemplatePO;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.pojo.vo.scene.SceneGeneralTemplateVO;
 import api.common.util.HttpUtil;
 import api.common.util.JsonUtil;
@@ -14,6 +16,7 @@ import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.feign.FileDownService;
 import com.css.simulation.resource.scene.service.SceneGeneralExampleService;
 import com.css.simulation.resource.scene.service.SceneGeneralTemplateService;
+import com.css.simulation.resource.system.service.SceneImportService;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.PageInfo;
@@ -43,6 +46,8 @@ public class SceneGeneralTemplateController {
     SceneGeneralExampleService exampleService;
     @Resource
     private FileDownService fileDownService;
+    @Resource
+    SceneImportService sceneImportService;
 
     //查询列表
     @PostMapping("/querySceneGeneralTemplateList")
@@ -65,6 +70,42 @@ public class SceneGeneralTemplateController {
 
     }
 
+    //新增泛化模板 带任务的
+    @PostMapping("/saveSceneGeneralTemplateNew")
+    @ResponseBody
+    public ResponseBodyVO<String> saveSceneGeneralTemplateNew(@RequestParam("file") MultipartFile multipartFile,@RequestBody SceneImportPO sceneImportPO) {
+        File file = null;
+        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);
+        SceneImportPO  sceneImportPO1=sceneImportService.saveTask(sceneImportPO);
+        try {
+            ResponseBodyVO<String> respon;
+           // Integer nowTime = TimeUtil.getRq(new Date(), 0);
+            String fileName = "泛化场景/" + version + "/" + originalFilename;
+            respon = fileDownService.upload(multipartFile, fileName);
+
+            String[] filename = originalFilename.split("\\.");
+            file = File.createTempFile(filename[0], filename[1]);
+            multipartFile.transferTo(file);
+            file.deleteOnExit();
+        } catch (IOException e) {
+            e.printStackTrace();
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "模板解析失败,请检查模板.");
+
+        }
+        sceneImportPO1.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+        sceneImportService.updateStatus(sceneImportPO1);
+        sceneImportPO =sceneGeneralTemplateService.saveSceneGeneralTemplateNew(file, version,sceneImportPO);
+        sceneImportService.updateStatus(sceneImportPO);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+
+    }
+
     //新增泛化模板
     @PostMapping("/saveSceneGeneralTemplate")
     @ResponseBody
@@ -79,7 +120,7 @@ public class SceneGeneralTemplateController {
         String version = TimeUtil.getToStringDate(new Date(), 5);
         try {
             ResponseBodyVO<String> respon;
-           // Integer nowTime = TimeUtil.getRq(new Date(), 0);
+            // Integer nowTime = TimeUtil.getRq(new Date(), 0);
             String fileName = "泛化场景/" + version + "/" + originalFilename;
             respon = fileDownService.upload(multipartFile, fileName);
 
@@ -92,10 +133,14 @@ public class SceneGeneralTemplateController {
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "模板解析失败,请检查模板.");
 
         }
-        return sceneGeneralTemplateService.saveSceneGeneralTemplate(file, version);
+
+        sceneGeneralTemplateService.saveSceneGeneralTemplate(file, version);
+
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
 
     }
 
+
     //删除泛化模板
     @PostMapping("/deleteSceneGeneralTemplateById")
     @ResponseBody

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

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.scene.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.scene.SceneImportParam;
 import api.common.pojo.param.scene.SceneNaturalNewParam;
 import api.common.pojo.param.scene.SceneNaturalParam;
@@ -72,7 +73,7 @@ public class SceneNaturalController {
     public ResponseBodyVO<String> saveSceneNaturalBatch(@RequestBody SceneImportParam sceneImportParam) {
         SceneImportPO sceneImportPO=new  SceneImportPO();
         sceneImportPO.setId(sceneImportParam.getId());
-        sceneImportPO.setStatus("3");
+        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_3);
         sceneImportService.updateStatus(sceneImportPO);
         sceneImportPO= sceneNaturalService.importMiNio(sceneImportParam);
         sceneImportService.updateInfo(sceneImportPO);

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

@@ -120,7 +120,7 @@ public class ScoringRulesController {
     public ResponseBodyVO<List<ScoringRulesPO>> queryCsb() {
         ScoringRulesParam params = new ScoringRulesParam();
         params.setShare("0");
-        params.setCreateUserId(AuthUtil.getCurrentUserId());
+        //params.setCreateUserId(AuthUtil.getCurrentUserId());
         List<ScoringRulesPO> list = scoringRulesService.queryScoringRulesList(params);
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, list);
     }

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/StandardsRegulationsController.java

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.scene.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.scene.SceneImportParam;
 import api.common.pojo.param.scene.StandardsRegulationsParam;
 import api.common.pojo.po.scene.StandardsRegulationsPO;
@@ -71,7 +72,7 @@ public class StandardsRegulationsController {
     public ResponseBodyVO<String> saveStandardsRegulationsBatch(@RequestBody SceneImportParam sceneImportParam) {
         SceneImportPO sceneImportPO=new  SceneImportPO();
         sceneImportPO.setId(sceneImportParam.getId());
-        sceneImportPO.setStatus("3");
+        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_3);
         sceneImportService.updateStatus(sceneImportPO);
         sceneImportPO= standardsRegulationsService.importMiNio(sceneImportParam);
         sceneImportService.updateInfo(sceneImportPO);

+ 1 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/ScenePackageSublistMapper.java

@@ -16,6 +16,7 @@ public interface ScenePackageSublistMapper {
     void saveScenePackageSublistAll(List<ScenePackageSublistPO> treeList);
 
     void deleteScenePackageSublist(String rootId);
+    void deleteScenePackageSublistById(String sublistId);
 
     List<ScenePackageSublistVO> queryScenePackageSublistList(ScenePackageSublistPO params);
 

+ 31 - 20
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneAccidentService.java

@@ -1,6 +1,7 @@
 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.SceneAccidentParam;
 import api.common.pojo.param.scene.SceneImportParam;
@@ -556,8 +557,6 @@ public class SceneAccidentService {
     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());
@@ -594,25 +593,36 @@ public class SceneAccidentService {
                                     JsonNode root = objMap.readTree(json);
                                     //判断场景名称唯一
                                     String sceneName = root.path("场景名称").asText();
+                                    String selfDriving =   root.path("自车驾驶行为").asText();
+                                    String conflictType =   root.path("冲突类型").asText();
+                                    String conflictBehavior =  root.path("冲突行为").asText();
+                                    String  selfReaction=root.path("自车反应行为").asText();
+                                    if(ObjectUtil.isNull(selfDriving)&&ObjectUtil.isNull(conflictType)&&ObjectUtil.isNull(conflictBehavior)&&ObjectUtil.isNull(selfReaction)){
+                                        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+                                        sceneImportPO.setErrorMessage("该文件:"+adress+"与交通事故场景类型不匹配,解析失败,请检查");
+                                        return sceneImportPO;
+                                    }
                                     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();
+                                    sceneAccidentPO.setAccidentId(StringUtil.getRandomUUID());
+                                    sceneAccidentPO.setSceneName(sceneName);
+                                    sceneAccidentPO.setScenceResume(root.path("场景描述").asText());
+                                    sceneAccidentPO.setSelfDriving(selfDriving);
+                                    sceneAccidentPO.setTargetDriving(root.path("目标驾驶行为").asText());
+                                    sceneAccidentPO.setSelfReaction(selfReaction);
+                                    sceneAccidentPO.setConflictBehavior(conflictBehavior);
+                                    sceneAccidentPO.setConflictType(conflictType);
+                                    sceneAccidentPO.setSceneTime(root.path("时间").asText());
+                                    sceneAccidentPO.setSceneWeather(root.path("天气").asText());
+                                    sceneAccidentPO.setMaxTime(root.path("max_time").asText());
+                                    sceneAccidentPO.setIsDeleted("0");
+                                    if(ObjectUtil.isNull(sceneAccidentPO.getOsgbAddress())){
+                                        sceneAccidentPO.setOsgbAddress(osgbAdress);
+                                    }
+                                    if(ObjectUtil.isNull(sceneAccidentPO.getXodrAddress())){
+                                        sceneAccidentPO.setXodrAddress(xodrAdress);
+                                    }
                                     if (ObjectUtil.isNull(sceneId)) {
                                         isupdate = "0";
                                     } else {
@@ -656,14 +666,15 @@ public class SceneAccidentService {
                     }
                 }
             }
-            sceneImportPO.setStatus("4");
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_4);
             sceneImportPO.setSuccessNum(successNum);
             sceneImportPO.setFalseNum(falseNum);
             sceneImportPO.setErrorMessage(errorMessage);
            // sceneImportTaskService.updateSceneImportTask(sceneImportTaskPO);
             return sceneImportPO;
         }catch (Exception e){
-            sceneImportPO.setStatus("2");
+            sceneImportPO.setErrorMessage("该文件地址:"+parms.getMinioDirectory()+"解析失败,请检查");
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
            // sceneImportTaskService.updateSceneImportTask(sceneImportTaskPO);
             return sceneImportPO;
         }

+ 5 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralExampleService.java

@@ -54,7 +54,8 @@ public class SceneGeneralExampleService {
                 examplePo.setIsTure("1");
             }
         }
-
+           String generalizationType =JsonUtil.stringToJson(examplePo.getGeneralizationType());
+           examplePo.setGeneralizationType(generalizationType);
 
            //转换为vo
            SceneGeneralTemplatePO po=new SceneGeneralTemplatePO();
@@ -71,6 +72,8 @@ public class SceneGeneralExampleService {
                listMb.add(mbVO);
            }
            vo.setListMb(listMb);
+           vo.setTemplateId(examplePo.getTemplateId());
+           vo.setIsTure(examplePo.getIsTure());
 
 
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, vo);
@@ -211,6 +214,7 @@ public class SceneGeneralExampleService {
         exampleMapper.saveSceneGeneralExample(po);
         Map map1=new HashMap();
         map1.put("exampleId",exampleId);//实例id
+        map1.put("sceneNum",list.size());//场景数量
         map1.put("templateId",po.getTemplateId()); //模板id
         map1.put("sceneGeneralizationIds",sceneGeneralizationIds);//泛化场景数组
         map1.put("sublistId",sublistId); //指标id

+ 170 - 69
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralTemplateService.java

@@ -2,7 +2,9 @@ package com.css.simulation.resource.scene.service;
 
 
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.scene.SceneGeneralTemplateParam;
+import api.common.pojo.po.system.SceneImportPO;
 import api.common.pojo.vo.scene.SceneGeneralTemplateMbVO;
 import api.common.pojo.vo.scene.SceneGeneralTemplateVO;
 import api.common.util.JsonUtil;
@@ -117,88 +119,187 @@ public class SceneGeneralTemplateService {
     /**
      * 泛化模板导入:
      */
-    @SneakyThrows
-    public ResponseBodyVO<String> saveSceneGeneralTemplate(File excelFile,String version) {
-        FileInputStream is = new FileInputStream(excelFile); //文件流
-        Workbook workbook = WorkbookFactory.create(is); //这种方式 Excel 2003/2007/2010 都是可以处理的
-        int sheetCount = workbook.getNumberOfSheets();  //Sheet的数量
-        List<SceneGeneralTemplatePO> list=new ArrayList<>();
-        List<String> fileNameAll=new ArrayList<>();
-        //遍历每个Sheet
-        for (int s = 0; s < sheetCount; s++) {
-            Sheet sheet = workbook.getSheetAt(s);
-            String sheetName = sheet.getSheetName();  //文件Sheet的名称
-            //验证模板名称是否正确  filrName为字典中的类别名
+    public void saveSceneGeneralTemplate(File excelFile, String version) {
+        try {
+            FileInputStream is = new FileInputStream(excelFile); //文件流
+            Workbook workbook = WorkbookFactory.create(is); //这种方式 Excel 2003/2007/2010 都是可以处理的
+            int sheetCount = workbook.getNumberOfSheets();  //Sheet的数量
+            List<SceneGeneralTemplatePO> list = new ArrayList<>();
+            List<String> fileNameAll = new ArrayList<>();
+            //遍历每个Sheet
+            for (int s = 0; s < sheetCount; s++) {
+                Sheet sheet = workbook.getSheetAt(s);
+                String sheetName = sheet.getSheetName();  //文件Sheet的名称
+                //验证模板名称是否正确  filrName为字典中的类别名
            /* Map<String, String> map = dictService.getDictMapByType("fileName");
             String fileName = map.get(sheetName);
             if (ObjectUtil.isNotNull(fileName)) {*/
-            int rowCount = sheet.getPhysicalNumberOfRows(); //获取总行数
-            //效验sheet页是否符合标准
-            Cell ce00 = sheet.getRow(0).getCell(0);
-            //ce00.setCellType(CellType.STRING);
-            String c00Value = ce00.getStringCellValue();
-            if (c00Value != null && c00Value.equals("场景编号")) {
-                //遍历每一行
-                for (int r = 1; r < rowCount; r++) {
-                    Row row = sheet.getRow(r);
-                    int cellCount = row.getPhysicalNumberOfCells(); //获取总列数
-                    SceneGeneralTemplatePO po = new SceneGeneralTemplatePO();
-                    Field[] field = po.getClass().getDeclaredFields();
-                    //遍历每一个单元格
-                    for (int c = 0; c < cellCount; c++) {
-                        int a = c + 1;
-                        Cell cell = row.getCell(c);
-                        String cellValue = null;
-                        if (r > 0 && c == 3) {
-                            Date aaa = cell.getDateCellValue();
-                            cellValue = TimeUtil.getToStringDate(aaa, 4);
-                        } else {
-                            //在读取单元格内容前,设置所有单元格中内容都是字符串类型
-                            cell.setCellType(CellType.STRING);
-                            //按照字符串类型读取单元格内数据
-                            cellValue = cell.getStringCellValue();
+                int rowCount = sheet.getPhysicalNumberOfRows(); //获取总行数
+                //效验sheet页是否符合标准
+                Cell ce00 = sheet.getRow(0).getCell(0);
+                //ce00.setCellType(CellType.STRING);
+                String c00Value = ce00.getStringCellValue();
+                if (c00Value != null && c00Value.equals("场景编号")) {
+                    //遍历每一行
+                    for (int r = 1; r < rowCount; r++) {
+                        Row row = sheet.getRow(r);
+                        int cellCount = row.getPhysicalNumberOfCells(); //获取总列数
+                        SceneGeneralTemplatePO po = new SceneGeneralTemplatePO();
+                        Field[] field = po.getClass().getDeclaredFields();
+                        //遍历每一个单元格
+                        for (int c = 0; c < cellCount; c++) {
+                            int a = c + 1;
+                            Cell cell = row.getCell(c);
+                            String cellValue = null;
+                            if (r > 0 && c == 3) {
+                                Date aaa = cell.getDateCellValue();
+                                cellValue = TimeUtil.getToStringDate(aaa, 4);
+                            } else {
+                                //在读取单元格内容前,设置所有单元格中内容都是字符串类型
+                                cell.setCellType(CellType.STRING);
+                                //按照字符串类型读取单元格内数据
+                                cellValue = cell.getStringCellValue();
+                            }
+                            /*在这里可以对每个单元格中的值进行二次操作转化*/
+                            //    System.out.print(cellValue + "    ");
+                            if (r > 0) {
+                                //获取属性的名字
+                                String name = field[a].getName();
+                                //将属性名的第一位字母大写
+                                name = name.substring(0, 1).toUpperCase() + name.substring(1);
+                                //调用setter方法设属性值
+                                Class[] parameterTypes = new Class[1];
+                                parameterTypes[0] = field[a].getType();
+                                Method getOrSet = po.getClass().getDeclaredMethod("set" + name, parameterTypes);
+                                getOrSet.invoke(po, cellValue);
+                            }
                         }
-                        /*在这里可以对每个单元格中的值进行二次操作转化*/
-                        //    System.out.print(cellValue + "    ");
+                        System.out.println();
                         if (r > 0) {
-                            //获取属性的名字
-                            String name = field[a].getName();
-                            //将属性名的第一位字母大写
-                            name = name.substring(0, 1).toUpperCase() + name.substring(1);
-                            //调用setter方法设属性值
-                            Class[] parameterTypes = new Class[1];
-                            parameterTypes[0] = field[a].getType();
-                            Method getOrSet = po.getClass().getDeclaredMethod("set" + name, parameterTypes);
-                            getOrSet.invoke(po, cellValue);
+                            po.setCreateTime(TimeUtil.getNowForMysql());
+                            po.setCreateUserId(AuthUtil.getCurrentUserId());
+                            po.setModifyUserId(AuthUtil.getCurrentUserId());
+                            po.setModifyTime(TimeUtil.getNowForMysql());
+                            po.setIsDeleted("0");
+                            po.setId(StringUtil.getRandomUUID());
+                            po.setFileName(sheetName);
+                            po.setVersion(version);
+                            fileNameAll.add(sheetName);
+                            list.add(po);
                         }
                     }
-                    System.out.println();
-                    if (r > 0) {
-                        po.setCreateTime(TimeUtil.getNowForMysql());
-                        po.setCreateUserId(AuthUtil.getCurrentUserId());
-                        po.setModifyUserId(AuthUtil.getCurrentUserId());
-                        po.setModifyTime(TimeUtil.getNowForMysql());
-                        po.setIsDeleted("0");
-                        po.setId(StringUtil.getRandomUUID());
-                        po.setFileName(sheetName);
-                        po.setVersion(version);
-                        fileNameAll.add(sheetName);
-                        list.add(po);
-                    }
                 }
+                //}
+            }
+            if (ObjectUtil.isNotNull(list)) {
+                SceneGeneralTemplatePO po = list.get(0);
+                po.setFileNameAll(fileNameAll);
+                mapper.deleteSceneGeneralTemplateAll(po);
+                mapper.saveSceneGeneralTemplateAll(list);
+
             }
-        //}
+        }catch (Exception e){
         }
-        if(ObjectUtil.isNotNull(list)){
-            SceneGeneralTemplatePO po=list.get(0);
-            po.setFileNameAll(fileNameAll);
-            mapper.deleteSceneGeneralTemplateAll(po);
-            mapper.saveSceneGeneralTemplateAll(list);
-            return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+
+    }
+
+
+    /**
+     * 泛化模板导入:
+     */
+    public SceneImportPO saveSceneGeneralTemplateNew(File excelFile, String version,SceneImportPO sceneImportPO) {
+        try {
+            FileInputStream is = new FileInputStream(excelFile); //文件流
+            Workbook workbook = WorkbookFactory.create(is); //这种方式 Excel 2003/2007/2010 都是可以处理的
+            int sheetCount = workbook.getNumberOfSheets();  //Sheet的数量
+            List<SceneGeneralTemplatePO> list = new ArrayList<>();
+            List<String> fileNameAll = new ArrayList<>();
+            //遍历每个Sheet
+            for (int s = 0; s < sheetCount; s++) {
+                Sheet sheet = workbook.getSheetAt(s);
+                String sheetName = sheet.getSheetName();  //文件Sheet的名称
+                //验证模板名称是否正确  filrName为字典中的类别名
+           /* Map<String, String> map = dictService.getDictMapByType("fileName");
+            String fileName = map.get(sheetName);
+            if (ObjectUtil.isNotNull(fileName)) {*/
+                int rowCount = sheet.getPhysicalNumberOfRows(); //获取总行数
+                //效验sheet页是否符合标准
+                Cell ce00 = sheet.getRow(0).getCell(0);
+                //ce00.setCellType(CellType.STRING);
+                String c00Value = ce00.getStringCellValue();
+                if (c00Value != null && c00Value.equals("场景编号")) {
+                    //遍历每一行
+                    for (int r = 1; r < rowCount; r++) {
+                        Row row = sheet.getRow(r);
+                        int cellCount = row.getPhysicalNumberOfCells(); //获取总列数
+                        SceneGeneralTemplatePO po = new SceneGeneralTemplatePO();
+                        Field[] field = po.getClass().getDeclaredFields();
+                        //遍历每一个单元格
+                        for (int c = 0; c < cellCount; c++) {
+                            int a = c + 1;
+                            Cell cell = row.getCell(c);
+                            String cellValue = null;
+                            if (r > 0 && c == 3) {
+                                Date aaa = cell.getDateCellValue();
+                                cellValue = TimeUtil.getToStringDate(aaa, 4);
+                            } else {
+                                //在读取单元格内容前,设置所有单元格中内容都是字符串类型
+                                cell.setCellType(CellType.STRING);
+                                //按照字符串类型读取单元格内数据
+                                cellValue = cell.getStringCellValue();
+                            }
+                            /*在这里可以对每个单元格中的值进行二次操作转化*/
+                            //    System.out.print(cellValue + "    ");
+                            if (r > 0) {
+                                //获取属性的名字
+                                String name = field[a].getName();
+                                //将属性名的第一位字母大写
+                                name = name.substring(0, 1).toUpperCase() + name.substring(1);
+                                //调用setter方法设属性值
+                                Class[] parameterTypes = new Class[1];
+                                parameterTypes[0] = field[a].getType();
+                                Method getOrSet = po.getClass().getDeclaredMethod("set" + name, parameterTypes);
+                                getOrSet.invoke(po, cellValue);
+                            }
+                        }
+                        System.out.println();
+                        if (r > 0) {
+                            po.setCreateTime(TimeUtil.getNowForMysql());
+                            po.setCreateUserId(AuthUtil.getCurrentUserId());
+                            po.setModifyUserId(AuthUtil.getCurrentUserId());
+                            po.setModifyTime(TimeUtil.getNowForMysql());
+                            po.setIsDeleted("0");
+                            po.setId(StringUtil.getRandomUUID());
+                            po.setFileName(sheetName);
+                            po.setVersion(version);
+                            fileNameAll.add(sheetName);
+                            list.add(po);
+                        }
+                    }
+                }
+                //}
+            }
+            if (ObjectUtil.isNotNull(list)) {
+                SceneGeneralTemplatePO po = list.get(0);
+                po.setFileNameAll(fileNameAll);
+                mapper.deleteSceneGeneralTemplateAll(po);
+                mapper.saveSceneGeneralTemplateAll(list);
+
+                sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_4);
+                sceneImportPO.setSuccessNum(list.size());
+                return sceneImportPO;
+            }
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+            return sceneImportPO;
+        }catch (Exception e){
+            sceneImportPO.setErrorMessage("该文件解析失败,请检查");
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+            return  sceneImportPO;
         }
-        return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "模板解析失败,请检查模板");
+
     }
 
+
     public List<SceneGeneralTemplatePO> querySceneGeneralTemplateList(SceneGeneralTemplateParam po) {
         List<SceneGeneralTemplatePO> list=mapper.querySceneGeneralTemplateList(po);
      Map<String,String>  scenarioRoadTypeMap= dictService.getDictMapByType("scenarioRoadType");

+ 11 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneNaturalService.java

@@ -1,6 +1,7 @@
 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;
@@ -443,6 +444,12 @@ public class SceneNaturalService {
                                     JsonNode selfDrivingBehavior = root.path("自车行为");
                                     // -------------------------------- 目标行为 --------------------------------
                                     JsonNode targetBehavior = root.path("目标行为");
+
+                                    if(ObjectUtil.isNull(naturalEnvironment)&&ObjectUtil.isNull(road)&&ObjectUtil.isNull(selfDrivingBehavior)&&ObjectUtil.isNull(targetBehavior)){
+                                        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+                                        sceneImportPO.setErrorMessage("该文件:"+adress+"与自然场景类型不匹配,解析失败,请检查");
+                                        return sceneImportPO;
+                                    }
                                     sceneNaturalPO.setNaturalId(api.common.util.StringUtil.getRandomUUID());
                                     sceneNaturalPO.setNaturalName(fileName);
                                     sceneNaturalPO.setWeather(getSequenceNew(naturalEnvironment, "天气情况"));
@@ -533,15 +540,15 @@ public class SceneNaturalService {
                     }
                 }
             }
-            sceneImportPO.setStatus("4");
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_4);
             sceneImportPO.setSuccessNum(successNum);
             sceneImportPO.setFalseNum(falseNum);
             sceneImportPO.setErrorMessage(errorMessage);
-          //  sceneImportTaskService.updateSceneImportTask(sceneImportTaskPO);
             return sceneImportPO;
         }catch (Exception e){
-            sceneImportPO.setStatus("2");
-           return sceneImportPO;
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+            sceneImportPO.setErrorMessage("该文件地址:"+parms.getMinioDirectory()+"解析失败,请检查");
+            return sceneImportPO;
         }
     }
 

+ 2 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/ScenePackageService.java

@@ -312,6 +312,8 @@ public class ScenePackageService {
             if (ObjectUtil.isNull(parentVoList.get(i).getSceneGeneralizationIds())) {
                 String uuId = StringUtil.getRandomUUID();
                 params.setId(uuId);   //主键ID
+            }else if(ObjectUtil.isNotNull(parentVoList.get(i).getSceneGeneralizationIds())){
+                scenePackageSublistMapper.deleteScenePackageSublistById(parentVoList.get(i).getId());
             }
             params.setIsDeleted("0");
             params.setShare(share);

+ 24 - 12
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/StandardsRegulationsService.java

@@ -1,6 +1,7 @@
 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;
@@ -192,19 +193,29 @@ public class StandardsRegulationsService {
                                     JsonNode root = objMap.readTree(json);
                                     //判断场景名称唯一
                                     String sceneName = root.path("场景名称").asText();
+                                    String regulationType=root.path("法规类型").asText();
+                                    String standardType=root.path("标准类型").asText();
+                                    if(ObjectUtil.isNull(regulationType)&&ObjectUtil.isNull(standardType)){
+                                        sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+                                        sceneImportPO.setErrorMessage("该文件:"+adress+"与标准法规场景类型不匹配,解析失败,请检查");
+                                        return sceneImportPO;
+                                    }
                                     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();
+                                    standardsRegulationsPO.setRegulationsId(StringUtil.getRandomUUID());
+                                    standardsRegulationsPO.setSceneName(sceneName);
+                                    standardsRegulationsPO.setRegulationType(regulationType);
+                                    standardsRegulationsPO.setStandardType(standardType);
+                                    standardsRegulationsPO.setMaxTime(root.path("max_time").asText());
+                                    standardsRegulationsPO.setIsDeleted("0");
+
+                                    if(ObjectUtil.isNull(standardsRegulationsPO.getOsgbAddress())){
+                                        standardsRegulationsPO.setOsgbAddress(osgbAdress);
+                                    }
+                                    if(ObjectUtil.isNull(standardsRegulationsPO.getXodrAddress())){
+                                        standardsRegulationsPO.setXodrAddress(xodrAdress);
+                                    }
                                     if (ObjectUtil.isNull(sceneId)) {
                                         isupdate = "0";
                                     } else {
@@ -248,13 +259,14 @@ public class StandardsRegulationsService {
                     }
                 }
             }
-            sceneImportPO.setStatus("4");
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_4);
             sceneImportPO.setSuccessNum(successNum);
             sceneImportPO.setFalseNum(falseNum);
             sceneImportPO.setErrorMessage(errorMessage);
             return sceneImportPO;
         }catch (Exception e){
-            sceneImportPO.setStatus("2");
+            sceneImportPO.setStatus(DictConstants.SCENE_IMPORT_STATUS_2);
+            sceneImportPO.setErrorMessage("该文件地址:"+parms.getMinioDirectory()+"解析失败,请检查");
             return sceneImportPO;
         }
     }

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

@@ -73,5 +73,4 @@ public class ParameterCtrl {
         return response;
     }
 
-
 }

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

@@ -10,6 +10,7 @@ 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.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -20,6 +21,7 @@ import javax.servlet.http.HttpServletRequest;
 
 @Controller
 @RequestMapping("/sceneImport")
+@PreAuthorize("@AuthorityCheck.admin()")
 public class SceneImportCtrl {
 
     @Autowired

+ 4 - 11
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserCtrl.java

@@ -8,6 +8,7 @@ import api.common.util.ObjectUtil;
 import com.css.simulation.resource.system.service.UserService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,22 +17,12 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 @Controller()
 @RequestMapping("/user")
+@PreAuthorize("@AuthorityCheck.adminAndUser()")
 public class UserCtrl {
 
     @Autowired
     UserService userService;
 
-    /**
-     * 获取当前登录人详情
-     */
-    @RequestMapping("/getCurrentUserInfo")
-    @ResponseBody
-    public ResponseBodyVO getCurrentUserInfo() {
-        ResponseBodyVO<UserVO> response = new ResponseBodyVO<UserVO>(ResponseBodyVO.Response.SUCCESS);
-        response.setInfo(userService.getCurrentUserInfo());
-        return response;
-    }
-
     /**
      * 获取人员列表
      */
@@ -95,4 +86,6 @@ public class UserCtrl {
         userService.saveVisible(userPO);
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
     }
+
+
 }

+ 155 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserInfoCtrl.java

@@ -0,0 +1,155 @@
+package com.css.simulation.resource.system.ctrl;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
+import api.common.pojo.param.scene.SystemScenePackageParam;
+import api.common.pojo.po.system.UserPO;
+import api.common.pojo.vo.scene.SystemScenePackageVO;
+import api.common.pojo.vo.system.ClusterVO;
+import api.common.pojo.vo.system.ParameterVO;
+import api.common.pojo.vo.system.UserVO;
+import api.common.util.ObjectUtil;
+import com.css.simulation.resource.common.utils.AuthUtil;
+import com.css.simulation.resource.scene.service.SystemScenePackageService;
+import com.css.simulation.resource.system.service.ClusterService;
+import com.css.simulation.resource.system.service.ParameterService;
+import com.css.simulation.resource.system.service.UserService;
+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 javax.annotation.Resource;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.List;
+
+
+@Controller()
+@RequestMapping("/userInfo")
+public class UserInfoCtrl {
+
+
+    @Autowired
+    UserService userService;
+
+    @Autowired
+    ClusterService clusterService;
+
+    @Autowired
+    ParameterService parameterService;
+
+    @Resource
+    SystemScenePackageService systemScenePackageService;
+
+
+    /**
+     * 获取当前登录人详情
+     */
+    @RequestMapping("/getCurrentUserInfo")
+    @ResponseBody
+    public ResponseBodyVO getCurrentUserInfo() {
+        ResponseBodyVO<UserVO> response = new ResponseBodyVO<UserVO>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(userService.getCurrentUserInfo());
+        return response;
+    }
+
+
+    /**
+     * 根据user_id查询参数配置信息
+     */
+    @RequestMapping("/getParameterByUserId")
+    @ResponseBody
+    public ResponseBodyVO<ParameterVO> getParameterByUserId() {
+        ResponseBodyVO<ParameterVO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        ParameterVO param = parameterService.getParameterByUserId();
+        response.setInfo(param);
+        return response;
+    }
+
+    /**
+     * 根据user_id查询集群配置信息
+     */
+    @RequestMapping("/getClusterByUserId")
+    @ResponseBody
+    public ResponseBodyVO<ClusterVO> getClusterByUserId() {
+        ResponseBodyVO<ClusterVO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        ClusterVO clusterVO = clusterService.getClusterByUserId();
+        response.setInfo(clusterVO);
+        return response;
+    }
+
+    /**
+     * 获取当前登录人详情
+     */
+    @RequestMapping("/getSceneResource")
+    @ResponseBody
+    public ResponseBodyVO getSceneResource() {
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        String userId = AuthUtil.getCurrentUserId();
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){ //管理员账户
+            return null;
+        }else if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
+            //查询父账户
+            userId = AuthUtil.getCreateUserId();
+        }
+        SystemScenePackageParam param = new SystemScenePackageParam();
+        param.setUserId(userId);
+        List<SystemScenePackageVO> list = systemScenePackageService.querySystemScenePackageList(param);
+        long zrTotalCount = list.stream().mapToLong(SystemScenePackageVO::getZrCount).sum();
+        long bzTotalCount = list.stream().mapToLong(SystemScenePackageVO::getBzCount).sum();
+        long jtTotalCount = list.stream().mapToLong(SystemScenePackageVO::getJtCount).sum();
+        long fhTotalCount = list.stream().mapToLong(SystemScenePackageVO::getFhCount).sum();
+        long sum = list.stream().mapToLong(SystemScenePackageVO::getTotalCount).sum();
+        SystemScenePackageVO last = new SystemScenePackageVO();
+        last.setPackageName("合计");
+        last.setZrCount((int)zrTotalCount);
+        last.setBzCount((int)bzTotalCount);
+        last.setFhCount((int)fhTotalCount);
+        last.setJtCount((int)jtTotalCount);
+        last.setTotalCount((int)sum);
+        list.add(last);
+        ResponseBodyVO<List> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(list);
+        return response;
+    }
+
+    /**
+     * 个人信息管理-修改联系方式
+     */
+    @RequestMapping("/savePhone")
+    @ResponseBody
+    public ResponseBodyVO savePhone(@RequestBody UserPO userPO) {
+        if(ObjectUtil.isNull(userPO)){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        if(ObjectUtil.isNull(userPO.getId()) || ObjectUtil.isNull(userPO.getNickname())|| ObjectUtil.isNull(userPO.getPhone())){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        userService.savePhone(userPO);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    /**
+     * 个人信息管理-修改密码
+     */
+    @RequestMapping("/savePassword")
+    @ResponseBody
+    public ResponseBodyVO savePassword(@RequestBody UserVO userVO) throws NoSuchAlgorithmException {
+        if(ObjectUtil.isNull(userVO)){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        if(ObjectUtil.isNull(userVO.getId()) || ObjectUtil.isNull(userVO.getPassword()) || ObjectUtil.isNull(userVO.getNewPassword())){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        UserPO userPORes = userService.savePassword(userVO);
+        if(ObjectUtil.isNull(userPORes)){
+            return new ResponseBodyVO(false, 400, "原密码错误!",null);
+        }
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+
+
+}

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

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

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

@@ -11,7 +11,7 @@ import java.util.List;
 @Repository
 public interface MenuMapper {
 
-    List<MenuVO> getMyMenuTree(@Param("userId") String userId);
+    List<MenuVO> getMyMenuTree(@Param("roleCode") String userId);
 
     List<MenuVO> getMenuTree();
 

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

@@ -24,4 +24,5 @@ public interface ParameterMapper {
 
     HashMap<String, Integer> getSceneParam(@Param("userId") String userId);
 
+    ParameterVO getParameterByUserId(String userId);
 }

+ 6 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/UserMapper.java

@@ -32,4 +32,10 @@ public interface UserMapper {
     void saveDefaultPassword(UserPO userPO);
 
     void saveVisible(UserPO userPO);
+
+    void savePhone(UserPO userPO);
+
+    List<UserVO> checkPassword(UserVO userVO);
+
+    void savePassword(UserPO userPO);
 }

+ 14 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ClusterService.java

@@ -117,4 +117,18 @@ public class ClusterService {
         }
         return simulationLicenseNum;
     }
+
+    public ClusterVO getClusterByUserId() {
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        String useType = AuthUtil.getCurrentUseType();
+        String userId = AuthUtil.getCurrentUserId();
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){ //管理员账户
+            return null;
+        }else if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode) && DictConstants.USE_TYPE_PUBLIC.equals(useType)){
+            //查询父账户
+            userId = AuthUtil.getCreateUserId();
+        }
+        ClusterVO clusterVO = clusterMapper.getClusterByUserId(userId);
+        return clusterVO;
+    }
 }

+ 2 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/MenuService.java

@@ -23,8 +23,8 @@ public class MenuService {
     }
 
     public List<MenuVO> getMyMenuTree() {
-        String userId = AuthUtil.getCurrentUserId();
-        List<MenuVO> menus = menuMapper.getMyMenuTree(userId);
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        List<MenuVO> menus = menuMapper.getMyMenuTree(roleCode);
         List<MenuVO> menuVOS = ObjectUtil.listToTree(menus);//注解方式转tree
         return menuVOS;
     }

+ 17 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ParameterService.java

@@ -73,4 +73,21 @@ public class ParameterService {
         return sceneParam;
     }
 
+    public ParameterVO getParameterByUserId() {
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        String userId = AuthUtil.getCurrentUserId();
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){ //管理员账户
+            return null;
+        }else if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
+            //查询父账户
+            userId = AuthUtil.getCreateUserId();
+        }
+        ParameterVO param = parameterMapper.getParameterByUserId(userId);
+        if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){ //普通账户子账户设置可创建子账号数量为0
+            param.setNumCreateUser(0);
+        }
+
+        return param;
+
+    }
 }

+ 25 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/UserService.java

@@ -41,6 +41,10 @@ public class UserService {
     public UserVO getCurrentUserInfo() {
         String userId = AuthUtil.getCurrentUserId();
         UserVO userVO = userMapper.getUserInfo(userId);
+        Map<String, String> useTypeDictMap = dictService.getDictMapByType(DictConstants.USE_TYPE);
+        userVO.setUseTypeName(useTypeDictMap.get(userVO.getUseType()));
+        Map<String, String> roleCodeDictMap = dictService.getDictMapByType(DictConstants.ROLE_CODE);
+        userVO.setRoleCodeName(roleCodeDictMap.get(userVO.getRoleCode()));
         return userVO;
     }
 
@@ -126,4 +130,25 @@ public class UserService {
         }
 
     }
+
+    public void savePhone(UserPO userPO) {
+        PoUtil.initUpdatePo(userPO);
+        userMapper.savePhone(userPO);
+    }
+
+    public UserPO savePassword(UserVO userVO) throws NoSuchAlgorithmException {
+        //确认原密码是否正确
+        userVO.setPassword(EncryptUtil.getLowerMD5(userVO.getPassword()));
+        List<UserVO> list = userMapper.checkPassword(userVO);
+        if(ObjectUtil.isNull(list)){
+            return null;
+        }
+        //修改密码
+        UserPO userPO = new UserPO();
+        userPO.setId(userVO.getId());
+        userPO.setPassword(EncryptUtil.getLowerMD5(userVO.getNewPassword()));
+        PoUtil.initUpdatePo(userPO);
+        userMapper.savePassword(userPO);
+        return userPO;
+    }
 }

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

@@ -0,0 +1,10 @@
+spring:
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 47.93.135.21:8848
+        namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
+      config:
+        server-addr: 47.93.135.21:8848
+        namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
+        file-extension: yaml

+ 2 - 2
simulation-resource-server/src/main/resources/mapper/scene/SceneGeneralExampleMapper.xml

@@ -68,10 +68,10 @@
         obs_lateral_acceleration,obs_longitudinal_acceleration,
         obs_heading_angle_rel,obs_velocity_status,obs_trajectory,obs_duration_time,obs_velocity_time,
         obs_trail_time,generalization_type,scenario_resume,scene_detailed_description,evaluating_indicator,
-        video_link,file_name,template_id,sublist_id,version,
+        video_link,file_name,template_id,sublist_id,
         create_user_id,create_time,modify_time
         from simulation.scene_general_example
-        where id #{id,jdbcType=VARCHAR}
+        where id =#{id,jdbcType=VARCHAR}
 
     </select>
 

+ 1 - 1
simulation-resource-server/src/main/resources/mapper/scene/SceneGeneralTemplateMapper.xml

@@ -86,7 +86,7 @@
         obs_lateral_acceleration,obs_longitudinal_acceleration,
         obs_heading_angle_rel,obs_velocity_status,obs_trajectory,obs_duration_time,obs_velocity_time,
         obs_trail_time,generalization_type,scenario_resume,scene_detailed_description,evaluating_indicator,
-        video_link,file_name,version,
+        video_link,file_name,version,is_deleted,
         create_user_id,create_time,modify_time
         from simulation.scene_general_template
         where id = #{id,jdbcType=VARCHAR}

+ 3 - 1
simulation-resource-server/src/main/resources/mapper/scene/ScenePackageSublistMapper.xml

@@ -81,7 +81,9 @@
         set is_deleted='1'
         where root_id = #{rootId,jdbcType=VARCHAR}
     </update>
-
+    <delete id="deleteScenePackageSublistById" parameterType="java.lang.String">
+    delete from simulation.scene_package_sublist  where sublist_id = #{sublistId,jdbcType=VARCHAR}
+    </delete>
     <select id="queryBySublistName" parameterType="api.common.pojo.po.scene.ScenePackageSublistPO"
             resultType="api.common.pojo.vo.scene.ScenePackageSublistVO">
         select sublist_id id,sublist_name

+ 8 - 2
simulation-resource-server/src/main/resources/mapper/scene/SystemScenePackageMapper.xml

@@ -26,13 +26,19 @@
         SUM(CASE WHEN s.scene_type = '1' THEN 1 ELSE 0 END) as zrCount,
         SUM(CASE WHEN s.scene_type = '2' THEN 1 ELSE 0 END) as bzCount,
         SUM(CASE WHEN s.scene_type = '3' THEN 1 ELSE 0 END) as jtCount,
-        SUM(CASE WHEN s.scene_type = '4' THEN 1 ELSE 0 END) as fhCount
+        SUM(CASE WHEN s.scene_type = '4' THEN 1 ELSE 0 END) as fhCount,
+        SUM(1) as totalCount
         FROM (
         select
         p.*,
         COUNT(u.id) as userCount
         FROM system_scene_package p
-        JOIN system_user_scene u on p.id = u.scene_id and u.is_deleted = '0' and p.is_deleted = '0'
+        JOIN system_user_scene u on p.id = u.package_id and u.is_deleted = '0' and p.is_deleted = '0'
+        <where>
+            <if test="userId != null and userId != ''">
+                and u.user_id = #{userId,jdbcType=VARCHAR}
+            </if>
+        </where>
         GROUP BY p.id
         ) t
         JOIN system_scene_package_sublist s on t.id = s.scene_and_package

+ 4 - 0
simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml

@@ -136,4 +136,8 @@
         select num_simulation_license from system_cluster
         where is_deleted = '0' and DATE(date_simulation_license) >= DATE(NOW()) and user_id = #{userId,jdbcType=VARCHAR}
     </select>
+    <select id="getClusterByUserId" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.ClusterVO">
+        select num_simulation_license, date_simulation_license, num_dynamic_license, date_dynamic_license from system_cluster
+        where is_deleted = '0' and user_id = #{userId,jdbcType=VARCHAR}
+    </select>
 </mapper>

+ 4 - 4
simulation-resource-server/src/main/resources/mapper/system/MenuMapper.xml

@@ -12,11 +12,11 @@
             m.sort,
             m.parent_id,
             m.visible
-        FROM system_user_role ur
-		INNER JOIN system_role r ON r.id = ur.role_id AND r.visible='1' AND r.is_deleted='0'
-        INNER JOIN system_role_menu rm ON rm.role_id = ur.role_id AND rm.is_deleted='0'
+				FROM system_role r
+        INNER JOIN system_role_menu rm ON rm.role_id = r.id AND rm.is_deleted='0'
         INNER JOIN system_menu m ON m.id=rm.menu_id AND m.visible='1' AND m.is_deleted='0'
-        WHERE ur.user_id = #{userId,jdbcType=VARCHAR}
+        WHERE r.role_code = #{roleCode,jdbcType=VARCHAR}
+		  AND r.visible='1' AND r.is_deleted='0'
         ORDER BY m.sort
     </select>
 

+ 6 - 0
simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml

@@ -86,5 +86,11 @@
         where is_deleted = '0' and user_id = #{userId,jdbcType=VARCHAR}
     </select>
 
+    <select id="getParameterByUserId" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.ParameterVO">
+        select num_create_user, num_scene_per_package, num_create_scene_package
+        from system_parameter
+        where is_deleted = '0' and user_id = #{userId,jdbcType=VARCHAR}
+    </select>
+
 
 </mapper>

+ 28 - 1
simulation-resource-server/src/main/resources/mapper/system/UserMapper.xml

@@ -11,7 +11,8 @@
             photo,
             phone,
             company,
-            role_code
+            role_code,
+            use_type
         FROM system_user WHERE id = #{userId,jdbcType=VARCHAR}
     </select>
 
@@ -95,6 +96,15 @@
         </if>
     </select>
 
+    <select id="checkPassword" parameterType="api.common.pojo.vo.system.UserVO" resultType="api.common.pojo.vo.system.UserVO">
+        select
+        id
+        from system_user
+        where is_deleted = '0'
+        and password = #{password,jdbcType=VARCHAR}
+        and id = #{id,jdbcType=VARCHAR}
+    </select>
+
     <insert id="insert" parameterType="api.common.pojo.po.system.UserPO">
         INSERT INTO system_user(
             id,
@@ -162,5 +172,22 @@
         where id = #{id,jdbcType=VARCHAR}
     </update>
 
+    <update id="savePhone" parameterType="api.common.pojo.po.system.UserPO">
+        update system_user set
+            nickname = #{nickname,jdbcType=VARCHAR},
+            phone = #{phone,jdbcType=VARCHAR},
+            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
+    </update>
+
+    <update id="savePassword" parameterType="api.common.pojo.po.system.UserPO">
+        update system_user set
+            password = #{password,jdbcType=VARCHAR},
+            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
+    </update>
+
 
 </mapper>