refactor(系统设置): 优化任务sql查询
This commit is contained in:
parent
73cf6fb06b
commit
9d2a050983
|
@ -266,7 +266,7 @@
|
|||
</if>
|
||||
</select>
|
||||
<select id="getHistoryDeleted" resultType="io.metersphere.api.dto.definition.ExecuteReportDTO">
|
||||
select ar.* from api_report ar INNER JOIN api_report_step ars on ar.id = ars.report_id
|
||||
select distinct ar.* from api_report ar INNER JOIN api_report_step ars on ar.id = ars.report_id
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
where ar.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
|
|
|
@ -245,7 +245,7 @@
|
|||
</if>
|
||||
</select>
|
||||
<select id="getHistoryDeleted" resultType="io.metersphere.api.dto.definition.ExecuteReportDTO">
|
||||
select asr.* from
|
||||
select distinct asr.* from
|
||||
api_scenario_report asr inner join api_scenario_report_step ars on asr.id = ars.report_id
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
where asr.id in
|
||||
|
|
|
@ -136,14 +136,18 @@ public class ApiTaskCenterService {
|
|||
list = extApiReportMapper.taskCenterlist(request, projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime());
|
||||
//执行历史列表
|
||||
List<String> reportIds = list.stream().map(TaskCenterDTO::getId).toList();
|
||||
if (CollectionUtils.isNotEmpty(reportIds)){
|
||||
List<ExecuteReportDTO> historyDeletedList = extApiReportMapper.getHistoryDeleted(reportIds);
|
||||
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<String> reportIds = list.stream().map(TaskCenterDTO::getId).toList();
|
||||
if (CollectionUtils.isNotEmpty(reportIds)) {
|
||||
List<ExecuteReportDTO> historyDeletedList = extApiScenarioReportMapper.getHistoryDeleted(reportIds);
|
||||
historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity()));
|
||||
}
|
||||
}
|
||||
processTaskCenter(list, projectList, projectIds, historyDeletedMap);
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -561,14 +561,17 @@ public class ApiTestCaseService extends MoveNodeService {
|
|||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
//执行历史列表
|
||||
List<String> reportIds = executeList.stream().map(ExecuteReportDTO::getId).toList();
|
||||
Map<String, ExecuteReportDTO> historyDeletedMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(reportIds)) {
|
||||
List<ExecuteReportDTO> historyDeletedList = extApiReportMapper.getHistoryDeleted(reportIds);
|
||||
Map<String, ExecuteReportDTO> historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity()));
|
||||
|
||||
historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity()));
|
||||
}
|
||||
Map<String, ExecuteReportDTO> finalHistoryDeletedMap = historyDeletedMap;
|
||||
executeList.forEach(apiReport -> {
|
||||
apiReport.setOperationUser(userMap.get(apiReport.getCreateUser()));
|
||||
Date date = new Date(apiReport.getStartTime());
|
||||
apiReport.setNum(sdf.format(date));
|
||||
apiReport.setHistoryDeleted(MapUtils.isNotEmpty(historyDeletedMap) && !historyDeletedMap.containsKey(apiReport.getId()));
|
||||
apiReport.setHistoryDeleted(MapUtils.isNotEmpty(finalHistoryDeletedMap) && !finalHistoryDeletedMap.containsKey(apiReport.getId()));
|
||||
});
|
||||
return executeList;
|
||||
}
|
||||
|
|
|
@ -2827,16 +2827,20 @@ public class ApiScenarioService extends MoveNodeService {
|
|||
.collect(Collectors.toSet());
|
||||
//执行历史列表
|
||||
List<String> reportIds = executeList.stream().map(ExecuteReportDTO::getId).toList();
|
||||
Map<String, ExecuteReportDTO> historyDeletedMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(reportIds)) {
|
||||
List<ExecuteReportDTO> historyDeletedList = extApiScenarioReportMapper.getHistoryDeleted(reportIds);
|
||||
Map<String, ExecuteReportDTO> historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity()));
|
||||
historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity()));
|
||||
|
||||
}
|
||||
Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userSet));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
Map<String, ExecuteReportDTO> finalHistoryDeletedMap = historyDeletedMap;
|
||||
executeList.forEach(apiReport -> {
|
||||
apiReport.setOperationUser(userMap.get(apiReport.getCreateUser()));
|
||||
Date date = new Date(apiReport.getStartTime());
|
||||
apiReport.setNum(sdf.format(date));
|
||||
apiReport.setHistoryDeleted(MapUtils.isNotEmpty(historyDeletedMap) && !historyDeletedMap.containsKey(apiReport.getId()));
|
||||
apiReport.setHistoryDeleted(MapUtils.isNotEmpty(finalHistoryDeletedMap) && !finalHistoryDeletedMap.containsKey(apiReport.getId()));
|
||||
});
|
||||
return executeList;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
<MsButton
|
||||
:disabled="
|
||||
record.historyDeleted ||
|
||||
hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
!hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
"
|
||||
class="!mr-0"
|
||||
@click="showResult(record, rowIndex)"
|
||||
|
@ -100,7 +100,7 @@
|
|||
<MsButton
|
||||
:disabled="
|
||||
record.historyDeleted ||
|
||||
hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
!hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
"
|
||||
class="!mr-0"
|
||||
@click="showResult(record, rowIndex)"
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<MsButton
|
||||
:disabled="
|
||||
record.historyDeleted ||
|
||||
hasAnyPermission(['PROJECT_API_SCENARIO:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
!hasAnyPermission(['PROJECT_API_SCENARIO:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
"
|
||||
class="!mr-0"
|
||||
@click="showResult(record)"
|
||||
|
@ -92,7 +92,7 @@
|
|||
<MsButton
|
||||
:disabled="
|
||||
record.historyDeleted ||
|
||||
hasAnyPermission(['PROJECT_API_SCENARIO:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
!hasAnyPermission(['PROJECT_API_SCENARIO:READ+EXECUTE', 'PROJECT_API_REPORT:READ'])
|
||||
"
|
||||
class="!mr-0"
|
||||
@click="showResult(record)"
|
||||
|
|
|
@ -61,5 +61,5 @@ export default {
|
|||
'project.taskCenter.disableSuccess': 'Disable successfully',
|
||||
'project.taskCenter.filterPlaceholderText': 'Please select a project',
|
||||
'project.taskCenter.filterOrgPlaceholderText': 'Please select an organization',
|
||||
'project.executionHistory.cleared': 'Execution history has been cleared',
|
||||
'project.executionHistory.cleared': 'Execution result has been cleared',
|
||||
};
|
||||
|
|
|
@ -59,5 +59,5 @@ export default {
|
|||
'project.taskCenter.disableSuccess': '关闭成功',
|
||||
'project.taskCenter.filterProPlaceholderText': '请选择所属项目',
|
||||
'project.taskCenter.filterOrgPlaceholderText': '请选择所属组织',
|
||||
'project.executionHistory.cleared': '执行历史被清理',
|
||||
'project.executionHistory.cleared': '执行结果被清理',
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue