root 2 rokov pred
rodič
commit
405d5eb424

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

+ 19 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/ScenePackageMapper.java

@@ -2,10 +2,12 @@ package com.css.simulation.resource.scene.mapper;
 
 import api.common.pojo.param.scene.ScenePackageParam;
 import api.common.pojo.po.scene.ScenePackagePO;
+import api.common.pojo.po.system.UserPO;
 import api.common.pojo.vo.scene.ScenePackageNewVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -41,5 +43,21 @@ public interface ScenePackageMapper {
             "from scene_package\n" +
             "where is_deleted = '0'\n" +
             " and package_id = #{packageId}")
-    String selectShareById(@Param("packageId")String packageId);
+    String selectShareById(@Param("packageId") String packageId);
+
+    @Update("update scene_package\n" +
+            "set is_unavailable = #{isUnavailable}\n" +
+            "where package_id in (select root_id from scene_package_sublist where scene_natural_ids like concat('%', #{sceneId}, '%'))")
+    void updateIsUnavailableByPackageId(@Param("isUnavailable") String isUnavailable,@Param("sceneId") String sceneId);
+
+    @Select("<script> " +
+            "select count(*) from users\n" +
+            "  <where>\n" +
+            "    id in\n" +
+            "    <foreach item='item' collection='list' separator=',' open='(' close=')' index=''>\n" +
+            "      #{item.id, jdbcType=NUMERIC}\n" +
+            "    </foreach>\n" +
+            "  </where>\n" +
+            "</script>")
+    UserPO selectById(@Param("userId")String userId);
 }

+ 10 - 19
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/ScenePackageSublistMapper.java

@@ -2,8 +2,7 @@ package com.css.simulation.resource.scene.mapper;
 
 import api.common.pojo.po.scene.ScenePackageSublistPO;
 import api.common.pojo.vo.scene.ScenePackageSublistVO;
-import org.apache.ibatis.annotations.*;
-import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
 
@@ -24,22 +23,14 @@ public interface ScenePackageSublistMapper {
     //指标名查唯一
     List<ScenePackageSublistVO> queryBySublistName(ScenePackageSublistPO params);
 
+//    @Update("update scene_package_sublist\n" +
+//            "set scene_natural_ids =\n" +
+//            "        if(scene_natural_ids like concat( '%',#{sceneId}, '%'),\n" +
+//            "           replace(replace(replace(scene_natural_ids, concat(#{sceneId}, ','), ''), concat(',', #{sceneId}), ''),\n" +
+//            "                   #{sceneId}, ''),\n" +
+//            "           scene_natural_ids)")
+//    void updateSceneNaturalIdsBySceneId(@Param("sceneId") String sceneId);
+
+
 
-    @Results(id = "scenePackageSublist", value = {
-            @Result(column = "sublist_id", property = "id", jdbcType = JdbcType.VARCHAR),
-            @Result(column = "root_id", property = "rootId", jdbcType = JdbcType.VARCHAR),
-            @Result(column = "scene_natural_ids", property = "sceneNaturalIds", jdbcType = JdbcType.VARCHAR)
-    })
-    @Select("select sublist_id, root_id, scene_natural_ids\n" +
-            "from scene_package_sublist\n" +
-            "where scene_natural_ids like concat('%',#{naturalId},'%')")
-    List<ScenePackageSublistPO> selectIdByNaturalId(@Param("naturalId") String naturalId);
-
-    @Update("update scene_package_sublist\n" +
-            "set scene_natural_ids =\n" +
-            "        if(scene_natural_ids like concat( '%',#{sceneId}, '%'),\n" +
-            "           replace(replace(replace(scene_natural_ids, concat(#{sceneId}, ','), ''), concat(',', #{sceneId}), ''),\n" +
-            "                   #{sceneId}, ''),\n" +
-            "           scene_natural_ids)")
-    void updateSceneNaturalIdsBySceneId(@Param("sceneId") String sceneId);
 }

+ 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());