夜得朦胧 il y a 1 an
Parent
commit
e65343a496

+ 35 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/impl/MultiSimulationProjectServiceImpl.java

@@ -167,6 +167,7 @@ public class MultiSimulationProjectServiceImpl implements MultiSimulationProject
                 }
                 MultiSimulationSceneCarParam sceneCarParam = new MultiSimulationSceneCarParam();
                 sceneCarParam.setSceneId(sceneVoId);
+                sceneCarParam.setMapId(mapId);
                 List<MultiSimulationSceneCarVO> multiSimulationSceneCarVOS = sceneCarMapper.selectSceneCarList(sceneCarParam);
                 ResponseBodyVO sceneCars = checkAllSceneCars(multiSimulationSceneCarVOS, sceneVoId);
                 if (sceneCars.getCode() != ResponseBodyVO.Response.SUCCESS.getCode()){
@@ -413,6 +414,19 @@ public class MultiSimulationProjectServiceImpl implements MultiSimulationProject
         if (Objects.isNull(param.getPageSize())) {
             param.setPageSize(10);
         }
+        if (StringUtils.isBlank(param.getMapId())){
+            PageInfo<MultiSimulationSceneCarVO> pageInfo = new PageInfo<>(new ArrayList<>());
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, pageInfo);
+//            MultiSimulationSceneVO sceneVO = simulationSceneMapper.selectSceneDetailBySceneId(sceneId);
+//            String mapId = sceneVO.getMapId();
+//            if (StringUtils.isBlank(mapId)){
+//
+//            }else {
+//                param.setMapId(mapId);
+//            }
+        }else {
+            param.setMapId(param.getMapId());
+        }
         setPage(param.getPageNum(), param.getPageSize());
         List<MultiSimulationSceneCarVO> multiSimulationSceneCarVOS = sceneCarMapper.selectSceneCarList(param);
         if (!CollectionUtils.isEmpty(multiSimulationSceneCarVOS)) {
@@ -468,6 +482,20 @@ public class MultiSimulationProjectServiceImpl implements MultiSimulationProject
     }
 
     public ResponseBodyVO<MultiSimulationSceneCarVO> addOrUpdateMultiSimulationSceneCar(MultiSimulationSceneCarParam param) {
+
+        String mapId = param.getMapId();
+        if (StringUtils.isBlank(mapId)){
+            String pathId = param.getPathId();
+            if (StringUtils.isBlank(pathId)){
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "地图id为空");
+            }else {
+                SimulationMapPathVO simulationMapPathVO = mapPathMapper.selectSimulationMapById(pathId);
+                if (simulationMapPathVO == null){
+                    return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "地图id为空");
+                }
+                param.setMapId(mapId);
+            }
+        }
         param.setCarId(StringUtils.isBlank(param.getCarId()) ? "" : param.getCarId());
         param.setAlgorithmId(StringUtils.isBlank(param.getAlgorithmId()) ? "" : param.getAlgorithmId());
         param.setPathId(StringUtils.isBlank(param.getPathId()) ? "" : param.getPathId());
@@ -477,10 +505,8 @@ public class MultiSimulationProjectServiceImpl implements MultiSimulationProject
 //        param.setPathEndPoint(StringUtils.isBlank(param.getPathEndPoint()) ? "" : param.getPathEndPoint());
         param.setCarSort(Objects.isNull(param.getCarSort()) ? 0 : param.getCarSort());
         param.setAlgorithmType(param.getAlgorithmType() == null ? 0 : param.getAlgorithmType());
-
         param.setPathStartStr(param.getPathStart().toJSONString());
         param.setPathEndStr(param.getPathEnd().toJSONString());
-
         if (StringUtils.isBlank(param.getSceneCarId())) {
             param.setSceneCarId(StringUtil.getRandomUUID());
             if (StringUtils.isBlank(param.getSceneId())) {
@@ -504,6 +530,7 @@ public class MultiSimulationProjectServiceImpl implements MultiSimulationProject
 
     @Transactional
     public ResponseBodyVO<List<MultiSimulationSceneCarVO>> addOrUpdateMultiSimulationSceneCarList(AddOrUpdateMultiSimulationSceneCarParam sceneCarParam) {
+        String mapId = sceneCarParam.getMapId();
         List<MultiSimulationSceneCarParam> paramList = sceneCarParam.getParamList();
         if (CollectionUtils.isEmpty(paramList) || StringUtils.isBlank(sceneCarParam.getMapId())) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "数据为空");
@@ -522,14 +549,15 @@ public class MultiSimulationProjectServiceImpl implements MultiSimulationProject
         }
         List<MultiSimulationSceneCarVO> ids = new ArrayList<>();
         for (MultiSimulationSceneCarParam param : paramList) {
+            param.setMapId(mapId);
             ResponseBodyVO<MultiSimulationSceneCarVO> responseBodyVO = addOrUpdateMultiSimulationSceneCar(param);
             if (responseBodyVO.getCode() != 200) {
                 throw new RuntimeException("操作失败");
             }
             ids.add(responseBodyVO.getInfo());
         }
-        String mapId = sceneVO.getMapId();
-        if (!StringUtils.equals(mapId, sceneCarParam.getMapId())){
+        String oldMapId = sceneVO.getMapId();
+        if (!StringUtils.equals(oldMapId, sceneCarParam.getMapId())){
             int i = simulationSceneMapper.updateMultiSimulationSceneMapId(sceneCarParam.getMapId(), sceneCarParam.getSceneId());
             if (i <= 0){
                 throw new RuntimeException("操作失败");
@@ -797,7 +825,9 @@ public class MultiSimulationProjectServiceImpl implements MultiSimulationProject
         JSONObject objectEnd = JSONObject.parseObject(pathEnd);
         MultiSimulationSceneCarParam multiSimulationSceneCarParam = new MultiSimulationSceneCarParam();
         multiSimulationSceneCarParam.setSceneCarId(carVO.getId()).setSceneId(newSceneId)
-            .setCarId(carVO.getCarId()).setAlgorithmId(carVO.getAlgorithmId()).setPathId(carVO.getPathId())
+            .setCarId(carVO.getCarId()).setAlgorithmId(carVO.getAlgorithmId())
+            .setMapId(carVO.getMapId())
+            .setPathId(carVO.getPathId())
             .setPathStart(objectStart).setPathEnd(objectEnd)
             .setPathStartStr(pathStart)
             .setPathEndStr(pathEnd)

+ 9 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/server/infra/db/mysql/mapper/MultiSimulationSceneCarMapper.java

@@ -11,8 +11,8 @@ import java.util.List;
 
 @Mapper
 public interface MultiSimulationSceneCarMapper {
-    @Insert("insert into multi_simulation_scene_car (id,scene_id,car_id,algorithm_id,algorithm_type,path_id,path_start,path_end,car_sort,is_simulation_car) values" +
-        "(#{sceneCarId},#{sceneId},#{carId},#{algorithmId},#{algorithmType},#{pathId},#{pathStartStr},#{pathEndStr},#{carSort},#{isSimulationCar})")
+    @Insert("insert into multi_simulation_scene_car (id,scene_id,car_id,algorithm_id,algorithm_type,map_id,path_id,path_start,path_end,car_sort,is_simulation_car) values" +
+        "(#{sceneCarId},#{sceneId},#{carId},#{algorithmId},#{algorithmType},#{mapId},#{pathId},#{pathStartStr},#{pathEndStr},#{carSort},#{isSimulationCar})")
     int addMultiSimulationSceneCar(MultiSimulationSceneCarParam param);
 
     @Select("select count(*) from multi_simulation_scene_car where scene_id = #{sceneId} and deleted = 0")
@@ -20,7 +20,7 @@ public interface MultiSimulationSceneCarMapper {
 
 
     @Update("<script>" +
-        "update multi_simulation_scene_car set car_id = #{carId},algorithm_id = #{algorithmId}, algorithm_type = #{algorithmType}, path_id = #{pathId}," +
+        "update multi_simulation_scene_car set car_id = #{carId},algorithm_id = #{algorithmId}, algorithm_type = #{algorithmType}, map_id = #{mapId}, path_id = #{pathId}," +
         "path_start = #{pathStartStr},path_end = #{pathEndStr},car_sort = #{carSort} " +
         "where id = #{sceneCarId}" +
         "</script>")
@@ -36,8 +36,13 @@ public interface MultiSimulationSceneCarMapper {
     int deleteMultiSimulationSceneCar(MultiSimulationSceneCarParam param);
 //
     @Select("<script>" +
-        "select id,scene_id,car_id,algorithm_id,algorithm_type,path_id,path_start,path_end,car_sort,is_simulation_car,create_time from multi_simulation_scene_car where deleted = 0 " +
+        "select id,scene_id,car_id,algorithm_id,algorithm_type,map_id,path_id,path_start,path_end,car_sort,is_simulation_car,create_time from multi_simulation_scene_car where deleted = 0 " +
         "and scene_id = #{sceneId} " +
+
+        "<if test='mapId != null'> " +
+        " AND map_id = #{mapId}" +
+        "</if>" +
+
         "order by car_sort, create_time desc" +
         "</script>")
     List<MultiSimulationSceneCarVO> selectSceneCarList(MultiSimulationSceneCarParam param);