Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

wangzhiqiang 2 gadi atpakaļ
vecāks
revīzija
673db89369

+ 25 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SceneNaturalMapper.java

@@ -2,7 +2,9 @@ package com.css.simulation.resource.scene.mapper;
 
 import api.common.pojo.param.scene.SceneNaturalParam;
 import api.common.pojo.po.scene.SceneNaturalPO;
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -13,11 +15,14 @@ import java.util.Map;
 public interface SceneNaturalMapper {
 
     void saveSceneNatural(SceneNaturalPO params);
+
     void saveSceneNaturalList(List<SceneNaturalPO> list);
 
     List<SceneNaturalPO> querySceneNaturalList(SceneNaturalParam params);
-    List<SceneNaturalPO> querySceneNaturalListByBqAndXlk(Map<String,SceneNaturalParam> map);
-    List<SceneNaturalPO> querySceneNaturalListByBq(Map<String,SceneNaturalParam> map);
+
+    List<SceneNaturalPO> querySceneNaturalListByBqAndXlk(Map<String, SceneNaturalParam> map);
+
+    List<SceneNaturalPO> querySceneNaturalListByBq(Map<String, SceneNaturalParam> map);
 
     void deleteSceneNatural(SceneNaturalPO params);
 
@@ -26,10 +31,26 @@ public interface SceneNaturalMapper {
     Integer querySceneNumBySy(SceneNaturalParam params);
 
     void updateSceneNatural(SceneNaturalPO params);
+
     void updateSceneNaturalList(List<SceneNaturalPO> list);
 
     List<SceneNaturalPO> querySceneNaturalListByQx(SceneNaturalParam params);
-    List<SceneNaturalPO> querySceneNaturalListByBqAndXlkAndQx(Map<String,SceneNaturalParam> map);
-    List<SceneNaturalPO> querySceneNaturalListByBqAndQx(Map<String,SceneNaturalParam> map);
+
+    List<SceneNaturalPO> querySceneNaturalListByBqAndXlkAndQx(Map<String, SceneNaturalParam> map);
+
+    List<SceneNaturalPO> querySceneNaturalListByBqAndQx(Map<String, SceneNaturalParam> map);
+
     SceneNaturalPO querySceneNaturalById(String id);
+
+    @Select("select natural_id\n" +
+            "from scene_natural\n" +
+            "where natural_name = #{naturalName}")
+    List<String> selectIdByName(String sceneName);
+
+
+    @Delete("update scene_natural\n" +
+            "set is_deleted  = '1',\n" +
+            "    modify_time = now()\n" +
+            "where natural_name = '#{sceneName}'\n")
+    void deleteByName(String sceneName);
 }

+ 8 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemScenePackageSublistMapper.java

@@ -1,9 +1,9 @@
 package com.css.simulation.resource.scene.mapper;
 
-import api.common.pojo.param.scene.SystemScenePackageParam;
-import api.common.pojo.po.scene.SystemScenePackagePO;
 import api.common.pojo.po.scene.SystemScenePackageSublistPO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -19,4 +19,10 @@ public interface SystemScenePackageSublistMapper {
     List<String> querySceneGeneralTemplateList(SystemScenePackageSublistPO po);
 
     void deleteSystemScenePackageSublist(SystemScenePackageSublistPO po);
+
+    @Update("update system_scene_package_sublist\n" +
+            "set is_deleted  = '1',\n" +
+            "    modify_time = now()\n" +
+            "where scene_name = #{sceneName}")
+    void deleteBySceneName(@Param("sceneName") String sceneName);
 }

+ 17 - 31
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneNaturalService.java

@@ -8,7 +8,6 @@ import api.common.pojo.param.scene.SceneImportParam;
 import api.common.pojo.param.scene.SceneNaturalNewParam;
 import api.common.pojo.param.scene.SceneNaturalParam;
 import api.common.pojo.po.scene.SceneNaturalPO;
-import api.common.pojo.po.scene.ScenePackageSublistPO;
 import api.common.pojo.po.system.SceneImportPO;
 import api.common.util.ObjectUtil;
 import api.common.util.ParamUtil;
@@ -16,11 +15,7 @@ import api.common.util.TimeUtil;
 import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.feign.FileDownService;
 import com.css.simulation.resource.log.service.LogService;
-import com.css.simulation.resource.scene.mapper.SceneNaturalMapper;
-import com.css.simulation.resource.scene.mapper.ScenePackageMapper;
-import com.css.simulation.resource.scene.mapper.ScenePackageSublistMapper;
-import com.css.simulation.resource.scene.mapper.SystemScenePackageMapper;
-import com.css.simulation.resource.system.service.DictService;
+import com.css.simulation.resource.scene.mapper.*;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.util.StringUtil;
@@ -31,7 +26,6 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
-import java.util.stream.Collectors;
 
 
 @Slf4j
@@ -46,12 +40,13 @@ public class SceneNaturalService {
     private ScenePackageMapper scenePackageMapper;
     @Resource
     private SystemScenePackageMapper systemScenePackageMapper;
+    @Resource
+    private SystemScenePackageSublistMapper systemScenePackageSublistMapper;
+
     @Resource
     private LogService logService;
     @Resource
     private FileDownService fileDownService;
-    @Resource
-    private DictService dictService;
 
     /**
      * 获取自然驾驶场景数据:包括切分数据和标注数据
@@ -440,29 +435,20 @@ public class SceneNaturalService {
     public void deleteSceneNatural(SceneNaturalPO params) {
 
         //1 获取参数
-        String sceneId = params.getNaturalId();     // 场景id
         String sceneName = params.getNaturalName(); // 场景名称
-        //2 根据场景id查询所有指标id和场景测试包id
-        List<ScenePackageSublistPO> scenePackageSublistPOS = scenePackageSublistMapper.selectIdByNaturalId(sceneId);
-        List<String> sceneIdList = scenePackageSublistPOS.stream().map(ScenePackageSublistPO::getId).collect(Collectors.toList());
-        Set<String> sceneTestPackageIdSet = scenePackageSublistPOS.stream().map(ScenePackageSublistPO::getRootId).collect(Collectors.toSet());
-        //3 删除场景测试包中的场景
-        for (String sceneIdTemp : sceneIdList) {
-            scenePackageSublistMapper.updateSceneNaturalIdsBySceneId(sceneIdTemp);
-        }
-        //4 修改场景测试包状态为已禁用
-
-
-        //4 根据参数名称查询场景包所有 id
-        //5 删除场景包中的场景兵修改场景数量
-
-
-        params.setIsDeleted("1");
-        params.setModifyTime(TimeUtil.getNowForMysql());
-        params.setModifyUserId(AuthUtil.getCurrentUserId());
-        sceneNaturalMapper.deleteSceneNatural(params);
-
-        // 日志
+        //2 根据场景名称查询出同名的所有场景id,包括公有和私有
+        List<String> sceneIdList = sceneNaturalMapper.selectIdByName(sceneName);
+        for (String sceneId : sceneIdList) {
+            //3 将所有场景测试包指标中的该场景删除
+//            scenePackageSublistMapper.updateSceneNaturalIdsBySceneId()
+            //4 将所有包含该场景的场景测试包状态为已禁用
+            scenePackageMapper.updateIsUnavailableByPackageId("1", sceneId);
+        }
+        //5 将所有场景包中的该场景删除
+        systemScenePackageSublistMapper.deleteBySceneName(sceneName);
+        //6 删除所有同名场景(包括公有和私有)
+        sceneNaturalMapper.deleteByName(sceneName);
+        //7 记录日志
         Map<String, String> map = new HashMap<>();
         map.put("sceneId", params.getNaturalId());
         map.put("sceneName", params.getNaturalName());