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

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

View File

@ -8,8 +8,6 @@ import java.util.List;
public interface ExtTaskMapper {
void deleteByResourceId(String id);
List<TaskCenterDTO> getTasks(@Param("request") TaskCenterRequest request);
int getRunningTasks(@Param("request") TaskCenterRequest request);
@ -18,6 +16,6 @@ public interface ExtTaskMapper {
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;
</select>
<select id="checkActuator" resultType="java.lang.Integer" parameterType="java.lang.String">
<select id="checkActuator" resultType="java.lang.String" parameterType="java.lang.String">
SELECT
sum( sum_actuator )
name
FROM
(
SELECT
count( id ) AS sum_actuator
FROM
api_scenario_report
WHERE
actuator =#{actuator}
AND `status` in ('Running','Waiting') UNION ALL
SELECT
count( id ) AS sum_actuator
FROM
api_definition_exec_result
WHERE
actuator = #{actuator}
api_scenario_report
WHERE
actuator =#{actuator}
AND `status` in ('Running','Waiting')
) AS total
UNION ALL
SELECT
name
FROM
api_definition_exec_result
WHERE
actuator = #{actuator}
AND `status` in ('Running','Waiting')
</select>
</mapper>

View File

@ -105,9 +105,6 @@ public class TestResourcePoolService {
testResourcePool.setStatus(status);
// 禁用/删除 资源池
if (INVALID.name().equals(status) || DELETE.name().equals(status)) {
if(extTaskMapper.checkActuator(testResourcePool.getId())>0){
MSException.throwException("当前资源池正在使用中不能删除");
}
testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool);
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());
return result;
}