瀏覽代碼

泛化模块功能

wangzhiqiang 3 年之前
父節點
當前提交
1eaf1e96c2
共有 15 個文件被更改,包括 304 次插入116 次删除
  1. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneAccidentController.java
  2. 47 2
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneGeneralTemplateController.java
  3. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/SceneNaturalController.java
  4. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/ScoringRulesController.java
  5. 2 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/StandardsRegulationsController.java
  6. 1 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/ScenePackageSublistMapper.java
  7. 31 20
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneAccidentService.java
  8. 5 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralExampleService.java
  9. 170 69
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneGeneralTemplateService.java
  10. 11 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneNaturalService.java
  11. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/ScenePackageService.java
  12. 24 12
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/StandardsRegulationsService.java
  13. 2 2
      simulation-resource-server/src/main/resources/mapper/scene/SceneGeneralExampleMapper.xml
  14. 1 1
      simulation-resource-server/src/main/resources/mapper/scene/SceneGeneralTemplateMapper.xml
  15. 3 1
      simulation-resource-server/src/main/resources/mapper/scene/ScenePackageSublistMapper.xml

+ 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;
         }
     }

+ 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