root hace 2 años
padre
commit
b01025e016

+ 0 - 8
simulation-resource-server/src/main/java/com/css/simulation/resource/project/ctrl/SimulationProjectCtrl.java

@@ -44,9 +44,6 @@ public class SimulationProjectCtrl {
 
     /**
      * 查询项目列表
-     *
-     * @param param
-     * @return
      */
     @RequestMapping("selectProject")
     @ResponseBody
@@ -67,8 +64,6 @@ public class SimulationProjectCtrl {
 
     /**
      * 删除工作(支持批量删除)
-     *
-     * @return
      */
     @RequestMapping("deleteProjectByids")
     @ResponseBody
@@ -78,9 +73,6 @@ public class SimulationProjectCtrl {
 
     /**
      * 修改工作运行状态
-     *
-     * @param param
-     * @return
      */
     @RequestMapping("updateProjectNowRunState")
     @ResponseBody

+ 15 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -32,6 +32,7 @@ import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
 import com.css.simulation.resource.project.enums.SceneTypeEnum;
 import com.css.simulation.resource.project.mapper.*;
 import com.css.simulation.resource.project.service.SimulationProjectService;
+import com.css.simulation.resource.scene.mapper.ScenePackageMapper;
 import com.css.simulation.resource.system.service.DictService;
 import com.css.simulation.resource.util.ApacheKafkaUtil;
 import com.css.simulation.resource.util.ProjectUtil;
@@ -107,9 +108,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     private MonitorService monitorService;
     @Resource
     private ProjectUtil projectUtil;
-
     @Resource
     private VehicleMapper vehicleMapper;
+    @Resource
+    private ScenePackageMapper scenePackageMapper;
 
     //* -------------------------------- Comment --------------------------------
 
@@ -270,6 +272,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         // 已经完成的项目再次运行
         if (DictConstants.PROJECT_COMPLETED.equals(po.getNowRunState())) {
+            //1 查询场景测试包是否被禁用
+            String isUnavailable = scenePackageMapper.selectIsUnavailableByPackageId(po.getScene());
+            if("1".equals(isUnavailable)){
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "包已经动过了,不能运行,编辑测试包后可重新运行。");
+            }
             po.createPo(AuthUtil.getCurrentUserId());
             // 生成id
             createProjectId(po);
@@ -294,12 +301,17 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             simulationProjectMapper.updateDetailsById(projectId, infoJson);
             // Kafka推送消息
             projectRunToKafka(po);
-        } else if (DictConstants.PROJECT_TERMINATED.equals(param.getNowRunState())) {   //项目终止,推送到kafka
+        } else if (DictConstants.PROJECT_TERMINATED.equals(param.getNowRunState())) {   // 项目终止,推送到kafka
             String projectId = param.getId();
             ApacheKafkaUtil.deleteTopic(kafkaAdminClient, projectId);
             projectStopToKafka(po);
             simulationProjectMapper.updateProjectNowRunState(param);
-        } else {    // 创建新的项目
+        } else {    // 创建新的项目或者重新运行被终止的项目
+            //1 查询场景测试包是否被禁用
+            String isUnavailable = scenePackageMapper.selectIsUnavailableByPackageId(po.getScene());
+            if("1".equals(isUnavailable)){
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "包已经动过了,不能运行,编辑测试包后可重新运行。");
+            }
             // 查询项目详情信息并保存
             String projectId = param.getId();
             ProjectDetailsVo info = selectProjectDetailsByIdBackUp(

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/ScenePackageMapper.java

@@ -5,6 +5,7 @@ import api.common.pojo.po.scene.ScenePackagePO;
 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;
 
@@ -52,4 +53,8 @@ public interface ScenePackageMapper {
             "where package_id in (select root_id from scene_package_sublist where scene_traffic_ids like concat('%', #{sceneId}, '%'))")
     void  updateIsUnavailableByAccidentId(@Param("isUnavailable")String isUnavailable,@Param("sceneId")String sceneId);
 
+
+    @Select("select is_unavailable from scene_package where package_id = #{packageId}")
+    String  selectIsUnavailableByPackageId(@Param("packageId")String packageId);
+
 }