mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-01 03:28:59 +08:00
refactor(系统设置): 优化定时任务
This commit is contained in:
parent
9ca8b7ac0f
commit
13b683d671
@ -191,14 +191,15 @@
|
||||
LEFT JOIN test_resource_pool t ON ar.pool_id = t.id
|
||||
left join project on ar.project_id = project.id
|
||||
where
|
||||
ar.test_plan_id = 'NONE'
|
||||
and ar.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
ar.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
|
||||
and
|
||||
ar.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
<if test="projectIds != null and projectIds.size() > 0">
|
||||
and
|
||||
ar.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and ( if(ar.integrated, ar.id, c.num) like concat('%', #{request.keyword},'%')
|
||||
|
||||
|
@ -163,18 +163,20 @@
|
||||
INNER JOIN api_scenario s on a.api_scenario_id = s.id
|
||||
left JOIN test_resource_pool t on asr.pool_id = t.id
|
||||
left join project on asr.project_id = project.id
|
||||
where asr.test_plan_id = 'NONE'
|
||||
and asr.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
and
|
||||
asr.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
where asr.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
<if test="projectIds != null and projectIds.size() > 0">
|
||||
and
|
||||
asr.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and (
|
||||
if(asr.integrated, asr.id, s.num) like concat('%', #{request.keyword},'%')
|
||||
or if(asr.integrated, asr.name,s.name) like concat('%', #{request.keyword},'%')
|
||||
)
|
||||
or if(asr.integrated, asr.name,s.name) like concat('%', #{request.keyword},'%')
|
||||
)
|
||||
</if>
|
||||
<include refid="filters">
|
||||
<property name="filter" value="request.filter"/>
|
||||
|
@ -99,7 +99,7 @@ public class ApiTaskCenterService {
|
||||
public Pager<List<TaskCenterDTO>> getProjectPage(TaskCenterPageRequest request, String projectId) {
|
||||
checkProjectExist(projectId);
|
||||
List<OptionDTO> projectList = getProjectOption(projectId);
|
||||
return createTaskCenterPager(request, projectList);
|
||||
return createTaskCenterPager(request, projectList, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +111,7 @@ public class ApiTaskCenterService {
|
||||
public Pager<List<TaskCenterDTO>> getOrganizationPage(TaskCenterPageRequest request, String organizationId) {
|
||||
checkOrganizationExist(organizationId);
|
||||
List<OptionDTO> projectList = getOrgProjectList(organizationId);
|
||||
return createTaskCenterPager(request, projectList);
|
||||
return createTaskCenterPager(request, projectList, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,22 +122,22 @@ public class ApiTaskCenterService {
|
||||
*/
|
||||
public Pager<List<TaskCenterDTO>> getSystemPage(TaskCenterPageRequest request) {
|
||||
List<OptionDTO> projectList = getSystemProjectList();
|
||||
return createTaskCenterPager(request, projectList);
|
||||
return createTaskCenterPager(request, projectList, true);
|
||||
}
|
||||
|
||||
private Pager<List<TaskCenterDTO>> createTaskCenterPager(TaskCenterPageRequest request, List<OptionDTO> projectList) {
|
||||
private Pager<List<TaskCenterDTO>> createTaskCenterPager(TaskCenterPageRequest request, List<OptionDTO> projectList, boolean isSystem) {
|
||||
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : DEFAULT_SORT);
|
||||
return PageUtils.setPageInfo(page, getPage(request, projectList));
|
||||
return PageUtils.setPageInfo(page, getPage(request, projectList, isSystem));
|
||||
}
|
||||
|
||||
public List<TaskCenterDTO> getPage(TaskCenterPageRequest request, List<OptionDTO> projectList) {
|
||||
public List<TaskCenterDTO> getPage(TaskCenterPageRequest request, List<OptionDTO> projectList, boolean isSystem) {
|
||||
List<TaskCenterDTO> list = new ArrayList<>();
|
||||
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
|
||||
if (request != null && !projectIds.isEmpty()) {
|
||||
Map<String, ExecuteReportDTO> historyDeletedMap = new HashMap<>();
|
||||
if (request.getModuleType().equals(TaskCenterResourceType.API_CASE.toString())) {
|
||||
list = extApiReportMapper.taskCenterlist(request, projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
list = extApiReportMapper.taskCenterlist(request, isSystem ? new ArrayList<>() : projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
//执行历史列表
|
||||
List<String> reportIds = list.stream().map(TaskCenterDTO::getId).toList();
|
||||
if (CollectionUtils.isNotEmpty(reportIds)) {
|
||||
@ -145,7 +145,7 @@ public class ApiTaskCenterService {
|
||||
historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity()));
|
||||
}
|
||||
} else if (request.getModuleType().equals(TaskCenterResourceType.API_SCENARIO.toString())) {
|
||||
list = extApiScenarioReportMapper.taskCenterlist(request, projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
list = extApiScenarioReportMapper.taskCenterlist(request, isSystem ? new ArrayList<>() : projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
List<String> reportIds = list.stream().map(TaskCenterDTO::getId).toList();
|
||||
if (CollectionUtils.isNotEmpty(reportIds)) {
|
||||
List<ExecuteReportDTO> historyDeletedList = extApiScenarioReportMapper.getHistoryDeleted(reportIds);
|
||||
@ -220,7 +220,7 @@ public class ApiTaskCenterService {
|
||||
}
|
||||
|
||||
public void systemStop(TaskCenterBatchRequest request, String userId) {
|
||||
stopApiTask(request, getSystemProjectList().stream().map(OptionDTO::getId).toList(), userId, SYSTEM_STOP, HttpMethodConstants.POST.name(), OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
||||
stopApiTask(request, new ArrayList<>(), userId, SYSTEM_STOP, HttpMethodConstants.POST.name(), OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
||||
}
|
||||
|
||||
private void stopApiTask(TaskCenterBatchRequest request, List<String> projectIds, String userId, String path, String method, String module) {
|
||||
|
@ -179,4 +179,41 @@ public class TaskCenterController {
|
||||
taskCenterService.batchEnableProject(request, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId(), "/task/center/project/schedule/batch-disable", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER, false);
|
||||
}
|
||||
|
||||
@GetMapping("/system/schedule/total")
|
||||
@Operation(summary = "系统-任务中心-定时任务总数")
|
||||
public int systemScheduleTotal() {
|
||||
return taskCenterService.getSystemScheduleTotal();
|
||||
}
|
||||
|
||||
@GetMapping("/org/schedule/total")
|
||||
@Operation(summary = "组织-任务中心-定时任务总数")
|
||||
public int orgScheduleTotal() {
|
||||
return taskCenterService.getOrgScheduleTotal(SessionUtils.getCurrentOrganizationId());
|
||||
}
|
||||
|
||||
@GetMapping("/project/schedule/total")
|
||||
@Operation(summary = "项目-任务中心-定时任务总数")
|
||||
public int projectScheduleTotal() {
|
||||
return taskCenterService.getProjectScheduleTotal(SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
@GetMapping("/system/real/total")
|
||||
@Operation(summary = "系统-任务中心-实时任务总数")
|
||||
public int systemRealTotal() {
|
||||
return taskCenterService.getSystemRealTotal();
|
||||
}
|
||||
|
||||
@GetMapping("/org/real/total")
|
||||
@Operation(summary = "组织-任务中心-实时任务总数")
|
||||
public int orgRealTotal() {
|
||||
return taskCenterService.getOrgRealTotal(SessionUtils.getCurrentOrganizationId());
|
||||
}
|
||||
|
||||
@GetMapping("/project/real/total")
|
||||
@Operation(summary = "项目-任务中心-实时任务总数")
|
||||
public int projectRealTotal() {
|
||||
return taskCenterService.getProjectRealTotal(SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package io.metersphere.system.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtRealMapper {
|
||||
int caseReportCountByProjectIds(@Param("ids") List<String> ids, @Param("startTime") long startTime, @Param("endTime") long endTime);
|
||||
|
||||
int scenarioReportCountByProjectIds(@Param("ids") List<String> ids, @Param("startTime") long startTime, @Param("endTime") long endTime);
|
||||
|
||||
int testPlanReportCountByProjectIds(@Param("ids") List<String> ids, @Param("startTime") long startTime, @Param("endTime") long endTime);
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.system.mapper.ExtRealMapper">
|
||||
|
||||
<select id="caseReportCountByProjectIds" resultType="java.lang.Integer">
|
||||
select count(distinct ar.id)
|
||||
FROM
|
||||
api_report ar
|
||||
where
|
||||
ar.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
and
|
||||
ar.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="scenarioReportCountByProjectIds" resultType="java.lang.Integer">
|
||||
select count(distinct asr.id)
|
||||
FROM
|
||||
api_scenario_report asr
|
||||
where
|
||||
asr.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
and
|
||||
asr.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="testPlanReportCountByProjectIds" resultType="java.lang.Integer">
|
||||
select count(distinct tpr.id)
|
||||
FROM
|
||||
test_plan_report tpr
|
||||
where
|
||||
tpr.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
and
|
||||
tpr.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
@ -39,4 +39,6 @@ public interface ExtScheduleMapper {
|
||||
|
||||
List<Schedule> getSchedule(@Param("request") TaskCenterScheduleBatchRequest request, @Param("projectIds") List<String> projectIds);
|
||||
|
||||
|
||||
int countByProjectIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
@ -2,26 +2,26 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.system.mapper.ExtScheduleMapper">
|
||||
<select id="taskCenterSchedulelist" resultType="io.metersphere.system.dto.taskcenter.TaskCenterScheduleDTO">
|
||||
select task.*, QRTZ_TRIGGERS.NEXT_FIRE_TIME AS next_time from (
|
||||
<if test="request.scheduleTagType == 'API_IMPORT'">
|
||||
SELECT
|
||||
schedule.id,
|
||||
schedule.name as taskname,
|
||||
schedule.project_id,
|
||||
resource_type,
|
||||
ads.num as resource_num,
|
||||
ads.name as resource_name,
|
||||
ads.id as resource_id,
|
||||
schedule.value,
|
||||
schedule.enable,
|
||||
schedule.create_user AS createUserName,
|
||||
schedule.create_time,
|
||||
ads.swagger_url
|
||||
FROM
|
||||
schedule
|
||||
inner join api_definition_swagger ads on schedule.resource_id = ads.id
|
||||
select task.*, QRTZ_TRIGGERS.NEXT_FIRE_TIME AS next_time from (
|
||||
<if test="request.scheduleTagType == 'API_IMPORT'">
|
||||
SELECT
|
||||
schedule.id,
|
||||
schedule.name as taskname,
|
||||
schedule.project_id,
|
||||
resource_type,
|
||||
ads.num as resource_num,
|
||||
ads.name as resource_name,
|
||||
ads.id as resource_id,
|
||||
schedule.value,
|
||||
schedule.enable,
|
||||
schedule.create_user AS createUserName,
|
||||
schedule.create_time,
|
||||
ads.swagger_url
|
||||
FROM
|
||||
schedule
|
||||
inner join api_definition_swagger ads on schedule.resource_id = ads.id
|
||||
|
||||
</if>
|
||||
</if>
|
||||
<if test="request.scheduleTagType == 'API_SCENARIO'">
|
||||
SELECT
|
||||
schedule.id,
|
||||
@ -59,23 +59,25 @@
|
||||
inner join test_plan on schedule.resource_id = test_plan.id
|
||||
</if>
|
||||
|
||||
) task left join project on task.project_id = project.id
|
||||
left join QRTZ_TRIGGERS on task.resource_id = QRTZ_TRIGGERS.TRIGGER_NAME
|
||||
) task left join project on task.project_id = project.id
|
||||
left join QRTZ_TRIGGERS on task.resource_id = QRTZ_TRIGGERS.TRIGGER_NAME
|
||||
where
|
||||
task.resource_type =#{request.scheduleTagType}
|
||||
and task.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
<if test="projectIds != null and projectIds.size() > 0">
|
||||
and task.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and (
|
||||
task.resource_name like concat('%', #{request.keyword},'%')
|
||||
or
|
||||
or
|
||||
task.resource_num like concat('%', #{request.keyword},'%')
|
||||
|
||||
<if test="request.scheduleTagType == 'API_IMPORT'">
|
||||
or task.swagger_url like concat('%', #{request.keyword},'%')
|
||||
</if>
|
||||
<if test="request.scheduleTagType == 'API_IMPORT'">
|
||||
or task.swagger_url like concat('%', #{request.keyword},'%')
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<include refid="taskCenterScheduleFilters">
|
||||
@ -176,7 +178,7 @@
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getSchedule" resultType="io.metersphere.system.domain.Schedule">
|
||||
select task.* from (
|
||||
select task.* from (
|
||||
<if test="request.scheduleTagType == 'API_IMPORT'">
|
||||
SELECT
|
||||
schedule.*,
|
||||
@ -210,10 +212,12 @@
|
||||
) task left join project on task.project_id = project.id
|
||||
where
|
||||
task.resource_type =#{request.scheduleTagType}
|
||||
and task.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
<if test="projectIds != null and projectIds.size() > 0">
|
||||
and task.project_id IN
|
||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.condition.keyword != null and request.condition.keyword != ''">
|
||||
and (
|
||||
task.resource_name like concat('%', #{request.condition.keyword},'%')
|
||||
@ -225,5 +229,16 @@
|
||||
<property name="filter" value="request.condition.filter"/>
|
||||
</include>
|
||||
</select>
|
||||
<select id="countByProjectIds" resultType="java.lang.Integer">
|
||||
select count(*) from schedule
|
||||
where resource_type in ('API_IMPORT', 'API_SCENARIO', 'TEST_PLAN')
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
and project_id in
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and project_id in
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -8,6 +8,7 @@ import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.TaskCenterResourceType;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.DateUtils;
|
||||
import io.metersphere.sdk.util.SubListUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.Organization;
|
||||
@ -93,6 +94,8 @@ public class TaskCenterService {
|
||||
ApiScheduleNoticeService apiScheduleNoticeService;
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
@Resource
|
||||
ExtRealMapper extRealMapper;
|
||||
|
||||
|
||||
private static final String CREATE_TIME_SORT = "create_time desc";
|
||||
@ -101,33 +104,31 @@ public class TaskCenterService {
|
||||
public Pager<List<TaskCenterScheduleDTO>> getProjectSchedulePage(TaskCenterSchedulePageRequest request, String projectId) {
|
||||
checkProjectExist(projectId);
|
||||
List<OptionDTO> projectList = getProjectOption(projectId);
|
||||
return createTaskCenterSchedulePager(request, projectList);
|
||||
return createTaskCenterSchedulePager(request, projectList, false);
|
||||
}
|
||||
|
||||
public Pager<List<TaskCenterScheduleDTO>> getOrgSchedulePage(TaskCenterSchedulePageRequest request, String organizationId) {
|
||||
checkOrganizationExist(organizationId);
|
||||
List<OptionDTO> projectList = getOrgProjectList(organizationId);
|
||||
return createTaskCenterSchedulePager(request, projectList);
|
||||
return createTaskCenterSchedulePager(request, projectList, false);
|
||||
}
|
||||
|
||||
public Pager<List<TaskCenterScheduleDTO>> getSystemSchedulePage(TaskCenterSchedulePageRequest request) {
|
||||
List<OptionDTO> projectList = getSystemProjectList();
|
||||
return createTaskCenterSchedulePager(request, projectList);
|
||||
return createTaskCenterSchedulePager(request, projectList, true);
|
||||
}
|
||||
|
||||
private Pager<List<TaskCenterScheduleDTO>> createTaskCenterSchedulePager(TaskCenterSchedulePageRequest request, List<OptionDTO> projectList) {
|
||||
private Pager<List<TaskCenterScheduleDTO>> createTaskCenterSchedulePager(TaskCenterSchedulePageRequest request, List<OptionDTO> projectList, boolean isSystem) {
|
||||
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : CREATE_TIME_SORT);
|
||||
return PageUtils.setPageInfo(page, getSchedulePage(request, projectList));
|
||||
return PageUtils.setPageInfo(page, getSchedulePage(request, projectList, isSystem));
|
||||
}
|
||||
|
||||
public List<TaskCenterScheduleDTO> getSchedulePage(TaskCenterSchedulePageRequest request, List<OptionDTO> projectList) {
|
||||
public List<TaskCenterScheduleDTO> getSchedulePage(TaskCenterSchedulePageRequest request, List<OptionDTO> projectList, boolean isSystem) {
|
||||
List<TaskCenterScheduleDTO> list = new ArrayList<>();
|
||||
if (request != null && !projectList.isEmpty()) {
|
||||
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
|
||||
list = extScheduleMapper.taskCenterSchedulelist(request, projectIds);
|
||||
processTaskCenterSchedule(list, projectList, projectIds);
|
||||
}
|
||||
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
|
||||
list = extScheduleMapper.taskCenterSchedulelist(request, isSystem ? new ArrayList<>() : projectIds);
|
||||
processTaskCenterSchedule(list, projectList, projectIds);
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -272,8 +273,7 @@ public class TaskCenterService {
|
||||
}
|
||||
|
||||
public void batchEnable(TaskCenterScheduleBatchRequest request, String userId, String path, String module, boolean enable, String projectId) {
|
||||
List<OptionDTO> projectList = getSystemProjectList();
|
||||
batchOperation(request, userId, path, module, projectList, enable, projectId);
|
||||
batchOperation(request, userId, path, module, new ArrayList<>(), enable, projectId);
|
||||
}
|
||||
|
||||
public void batchEnableOrg(TaskCenterScheduleBatchRequest request, String userId, String orgId, String path, String module, boolean enable, String projectId) {
|
||||
@ -353,4 +353,51 @@ public class TaskCenterService {
|
||||
throw new MSException(Translator.get("no_permission_to_resource"));
|
||||
}
|
||||
}
|
||||
|
||||
public int getSystemScheduleTotal() {
|
||||
List<OptionDTO> projectList = getSystemProjectList();
|
||||
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
|
||||
return extScheduleMapper.countByProjectIds(projectIds);
|
||||
}
|
||||
|
||||
public int getOrgScheduleTotal(String currentOrganizationId) {
|
||||
checkOrganizationExist(currentOrganizationId);
|
||||
List<OptionDTO> projectList = getOrgProjectList(currentOrganizationId);
|
||||
//获取项目id
|
||||
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
|
||||
return extScheduleMapper.countByProjectIds(projectIds);
|
||||
}
|
||||
|
||||
public int getProjectScheduleTotal(String currentProjectId) {
|
||||
checkProjectExist(currentProjectId);
|
||||
return extScheduleMapper.countByProjectIds(List.of(currentProjectId));
|
||||
}
|
||||
|
||||
public int getSystemRealTotal() {
|
||||
List<OptionDTO> projectList = getSystemProjectList();
|
||||
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
|
||||
int apiTestCaseTotal = extRealMapper.caseReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
int apiScenarioTotal = extRealMapper.scenarioReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
int testPlanTotal = extRealMapper.testPlanReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
return apiTestCaseTotal + apiScenarioTotal + testPlanTotal;
|
||||
}
|
||||
|
||||
public int getOrgRealTotal(String currentOrganizationId) {
|
||||
checkOrganizationExist(currentOrganizationId);
|
||||
List<OptionDTO> projectList = getOrgProjectList(currentOrganizationId);
|
||||
//获取项目id
|
||||
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
|
||||
int apiTestCaseTotal = extRealMapper.caseReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
int apiScenarioTotal = extRealMapper.scenarioReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
int testPlanTotal = extRealMapper.testPlanReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
return apiTestCaseTotal + apiScenarioTotal + testPlanTotal;
|
||||
}
|
||||
|
||||
public int getProjectRealTotal(String currentProjectId) {
|
||||
checkProjectExist(currentProjectId);
|
||||
int apiTestCaseTotal = extRealMapper.caseReportCountByProjectIds(List.of(currentProjectId), DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
int apiScenarioTotal = extRealMapper.scenarioReportCountByProjectIds(List.of(currentProjectId), DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
int testPlanTotal = extRealMapper.testPlanReportCountByProjectIds(List.of(currentProjectId), DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
return apiTestCaseTotal + apiScenarioTotal + testPlanTotal;
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,16 @@ class TaskCenterScheduleControllerTests extends BaseTest {
|
||||
doTaskCenterSchedulePage("FILTER", SCHEDULED_ORG_PAGE, ScheduleTagType.TEST_PLAN.toString());
|
||||
doTaskCenterSchedulePage("KEYWORD", SCHEDULED_SYSTEM_PAGE, ScheduleTagType.TEST_PLAN.toString());
|
||||
doTaskCenterSchedulePage("FILTER", SCHEDULED_SYSTEM_PAGE, ScheduleTagType.TEST_PLAN.toString());
|
||||
|
||||
|
||||
this.requestGet("/task/center/system/schedule/total");
|
||||
this.requestGet("/task/center/org/schedule/total");
|
||||
this.requestGet("/task/center/project/schedule/total");
|
||||
|
||||
this.requestGet("/task/center/system/real/total");
|
||||
this.requestGet("/task/center/org/real/total");
|
||||
this.requestGet("/task/center/project/real/total");
|
||||
|
||||
}
|
||||
|
||||
private void doTaskCenterSchedulePage(String search, String url, String scheduleTagType) throws Exception {
|
||||
@ -163,7 +173,6 @@ class TaskCenterScheduleControllerTests extends BaseTest {
|
||||
void testDel() throws Exception {
|
||||
LogUtils.info("delete Schedule test");
|
||||
String scheduleId = "1";
|
||||
Schedule oldSchedule = scheduleMapper.selectByPrimaryKey(scheduleId);
|
||||
// @@请求成功
|
||||
this.requestGet("/task/center/system/schedule/delete/" + "API_IMPORT/" + scheduleId);
|
||||
Schedule schedule = scheduleMapper.selectByPrimaryKey(scheduleId);
|
||||
|
@ -16,12 +16,18 @@ import {
|
||||
enableScheduleOrgTaskUrl,
|
||||
enableScheduleProTaskUrl,
|
||||
enableScheduleSysTaskUrl,
|
||||
orgRealTotal,
|
||||
orgScheduleTotal,
|
||||
projectRealTotal,
|
||||
projectScheduleTotal,
|
||||
scheduleOrgCenterListUrl,
|
||||
scheduleProCenterListUrl,
|
||||
scheduleSysCenterListUrl,
|
||||
stopRealOrdApiUrl,
|
||||
stopRealProjectApiUrl,
|
||||
stopRealSysApiUrl,
|
||||
systemRealTotal,
|
||||
systemScheduleTotal,
|
||||
taskOrgRealCenterListUrl,
|
||||
taskProRealCenterListUrl,
|
||||
taskSysRealCenterListUrl,
|
||||
@ -62,9 +68,11 @@ export function batchStopRealProjectApi(data: TableQueryParams) {
|
||||
export function stopRealSysApi(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${stopRealSysApiUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
|
||||
export function stopRealOrdApi(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${stopRealOrdApiUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
|
||||
export function stopRealProjectApi(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${stopRealProjectApiUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
@ -86,10 +94,12 @@ export function getScheduleProApiCaseList(data: TableQueryParams) {
|
||||
export function deleteScheduleSysTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${deleteScheduleSysTaskUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
|
||||
// 组织删除定时任务
|
||||
export function deleteScheduleOrgTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${deleteScheduleOrgTaskUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
|
||||
// 项目删除定时任务
|
||||
export function deleteScheduleProTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${deleteScheduleProTaskUrl}/${moduleType}/${id}` });
|
||||
@ -99,46 +109,57 @@ export function deleteScheduleProTask(moduleType: keyof typeof TaskCenterEnum, i
|
||||
export function enableScheduleSysTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${enableScheduleSysTaskUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
|
||||
// 组织启用定时任务
|
||||
export function enableScheduleOrgTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${enableScheduleOrgTaskUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
|
||||
// 项目启用定时任务
|
||||
export function enableScheduleProTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
|
||||
return MSR.get({ url: `${enableScheduleProTaskUrl}/${moduleType}/${id}` });
|
||||
}
|
||||
|
||||
// 系统更新定时任务规则
|
||||
export function updateRunRules(moduleType: keyof typeof TaskCenterEnum, id: string, data: string) {
|
||||
return MSR.post({ url: `${updateScheduleSysTaskUrl}/${moduleType}/${id}`, data });
|
||||
}
|
||||
|
||||
// 组织更新定时任务规则
|
||||
export function updateRunRulesOrg(moduleType: keyof typeof TaskCenterEnum, id: string, data: string) {
|
||||
return MSR.post({ url: `${updateScheduleOrgTaskUrl}/${moduleType}/${id}`, data });
|
||||
}
|
||||
|
||||
// 项目更新定时任务规则
|
||||
export function updateRunRulesPro(moduleType: keyof typeof TaskCenterEnum, id: string, data: string) {
|
||||
return MSR.post({ url: `${updateScheduleProTaskUrl}/${moduleType}/${id}`, data });
|
||||
}
|
||||
|
||||
// 系统批量开启定时任务
|
||||
export function batchEnableScheduleSysTask(data: TableQueryParams) {
|
||||
return MSR.post({ url: `${batchEnableScheduleSysTaskUrl}`, data });
|
||||
}
|
||||
|
||||
// 组织批量开启定时任务
|
||||
export function batchEnableScheduleOrgTask(data: TableQueryParams) {
|
||||
return MSR.post({ url: `${batchEnableScheduleOrgTaskUrl}`, data });
|
||||
}
|
||||
|
||||
// 项目批量开启定时任务
|
||||
export function batchEnableScheduleProTask(data: TableQueryParams) {
|
||||
return MSR.post({ url: `${batchEnableScheduleProTaskUrl}`, data });
|
||||
}
|
||||
|
||||
// 系统批量关闭定时任务
|
||||
export function batchDisableScheduleSysTask(data: TableQueryParams) {
|
||||
return MSR.post({ url: `${batchDisableScheduleSysTaskUrl}`, data });
|
||||
}
|
||||
|
||||
// 组织批量关闭定时任务
|
||||
export function batchDisableScheduleOrgTask(data: TableQueryParams) {
|
||||
return MSR.post({ url: `${batchDisableScheduleOrgTaskUrl}`, data });
|
||||
}
|
||||
|
||||
// 项目批量关闭定时任务
|
||||
export function batchDisableScheduleProTask(data: TableQueryParams) {
|
||||
return MSR.post({ url: `${batchDisableScheduleProTaskUrl}`, data });
|
||||
@ -147,4 +168,29 @@ export function batchDisableScheduleProTask(data: TableQueryParams) {
|
||||
export function switchSchedule(id: string) {
|
||||
return MSR.get({ url: `${enableSchedule}/${id}` });
|
||||
}
|
||||
|
||||
export function getSystemScheduleTotal() {
|
||||
return MSR.get({ url: `${systemScheduleTotal}` });
|
||||
}
|
||||
|
||||
export function getOrgScheduleTotal() {
|
||||
return MSR.get({ url: `${orgScheduleTotal}` });
|
||||
}
|
||||
|
||||
export function getProjectScheduleTotal() {
|
||||
return MSR.get({ url: `${projectScheduleTotal}` });
|
||||
}
|
||||
|
||||
export function getSystemRealTotal() {
|
||||
return MSR.get({ url: `${systemRealTotal}` });
|
||||
}
|
||||
|
||||
export function getOrgRealTotal() {
|
||||
return MSR.get({ url: `${orgRealTotal}` });
|
||||
}
|
||||
|
||||
export function getProjectRealTotal() {
|
||||
return MSR.get({ url: `${projectRealTotal}` });
|
||||
}
|
||||
|
||||
export default {};
|
||||
|
@ -68,3 +68,11 @@ export const batchDisableScheduleSysTaskUrl = '/task/center/system/schedule/batc
|
||||
export const batchDisableScheduleOrgTaskUrl = '/task/center/org/schedule/batch-disable';
|
||||
// 项目定时任务 批量关闭
|
||||
export const batchDisableScheduleProTaskUrl = '/task/center/project/schedule/batch-disable';
|
||||
|
||||
export const systemScheduleTotal = '/task/center/system/schedule/total';
|
||||
export const orgScheduleTotal = '/task/center/org/schedule/total';
|
||||
export const projectScheduleTotal = '/task/center/project/schedule/total';
|
||||
|
||||
export const systemRealTotal = '/task/center/system/real/total';
|
||||
export const orgRealTotal = '/task/center/org/real/total';
|
||||
export const projectRealTotal = '/task/center/project/real/total';
|
||||
|
@ -405,24 +405,7 @@
|
||||
TEST_PLAN: [...resourceColumns, ...staticColumns],
|
||||
},
|
||||
};
|
||||
const orgApiCaseFilter = ref([]);
|
||||
const orgApiScenarioFilter = ref([]);
|
||||
const orgTestPlanFilter = ref([]);
|
||||
|
||||
const orgFiltersMap = ref<Record<string, string[]>>({
|
||||
API_IMPORT: orgApiCaseFilter.value,
|
||||
API_SCENARIO: orgApiScenarioFilter.value,
|
||||
TEST_PLAN: orgTestPlanFilter.value,
|
||||
});
|
||||
|
||||
const projectApiCaseFilter = ref([]);
|
||||
const projectApiScenarioFilter = ref([]);
|
||||
const projectTestPlanFilter = ref([]);
|
||||
const projectFiltersMap = ref<Record<string, string[]>>({
|
||||
API_CASE: projectApiCaseFilter.value,
|
||||
API_SCENARIO: projectApiScenarioFilter.value,
|
||||
TEST_PLAN: projectTestPlanFilter.value,
|
||||
});
|
||||
const typeFilter = computed(() => {
|
||||
if (showType.value === 'All') {
|
||||
return [];
|
||||
|
Loading…
Reference in New Issue
Block a user