fix: 禁用资源池检查资源占用

This commit is contained in:
CaptainB 2021-11-05 17:20:45 +08:00 committed by 刘瑞斌
parent 0f40c075d4
commit 7a61254e99
3 changed files with 19 additions and 23 deletions

View File

@ -8,8 +8,6 @@ import java.util.List;
public interface ExtTaskMapper { public interface ExtTaskMapper {
void deleteByResourceId(String id);
List<TaskCenterDTO> getTasks(@Param("request") TaskCenterRequest request); List<TaskCenterDTO> getTasks(@Param("request") TaskCenterRequest request);
int getRunningTasks(@Param("request") TaskCenterRequest request); int getRunningTasks(@Param("request") TaskCenterRequest request);
@ -18,6 +16,6 @@ public interface ExtTaskMapper {
List<TaskCenterDTO> getScenario(@Param("id") String id); List<TaskCenterDTO> getScenario(@Param("id") String id);
int checkActuator (@Param("actuator") String actuator); List<String> checkActuator (@Param("actuator") String actuator);
} }

View File

@ -89,25 +89,23 @@
)tt ORDER BY tt.executionTime DESC; )tt ORDER BY tt.executionTime DESC;
</select> </select>
<select id="checkActuator" resultType="java.lang.Integer" parameterType="java.lang.String"> <select id="checkActuator" resultType="java.lang.String" parameterType="java.lang.String">
SELECT SELECT
sum( sum_actuator ) name
FROM
(
SELECT
count( id ) AS sum_actuator
FROM FROM
api_scenario_report api_scenario_report
WHERE WHERE
actuator =#{actuator} actuator =#{actuator}
AND `status` in ('Running','Waiting') UNION ALL AND `status` in ('Running','Waiting')
UNION ALL
SELECT SELECT
count( id ) AS sum_actuator name
FROM FROM
api_definition_exec_result api_definition_exec_result
WHERE WHERE
actuator = #{actuator} actuator = #{actuator}
AND `status` in ('Running','Waiting') AND `status` in ('Running','Waiting')
) AS total
</select> </select>
</mapper> </mapper>

View File

@ -105,9 +105,6 @@ public class TestResourcePoolService {
testResourcePool.setStatus(status); testResourcePool.setStatus(status);
// 禁用/删除 资源池 // 禁用/删除 资源池
if (INVALID.name().equals(status) || DELETE.name().equals(status)) { if (INVALID.name().equals(status) || DELETE.name().equals(status)) {
if(extTaskMapper.checkActuator(testResourcePool.getId())>0){
MSException.throwException("当前资源池正在使用中不能删除");
}
testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool); testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool);
return; return;
} }
@ -154,6 +151,9 @@ public class TestResourcePoolService {
} }
}); });
} }
// api
List<String> apiNames = extTaskMapper.checkActuator(testResourcePool.getId());
builder.append(StringUtils.join(apiNames, "; "));
result.setTestName(builder.toString()); result.setTestName(builder.toString());
return result; return result;
} }