feat(任务中心): 补充批量任务列表创建人字段
This commit is contained in:
parent
cd8962225a
commit
91bf2b4053
|
@ -20,4 +20,7 @@ public class ApiDocShareDTO extends ApiDocShare {
|
||||||
|
|
||||||
@Schema(title = "截止日期")
|
@Schema(title = "截止日期")
|
||||||
private Long deadline;
|
private Long deadline;
|
||||||
|
|
||||||
|
@Schema(title = "创建人")
|
||||||
|
private String createUserName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,23 @@
|
||||||
<if test="request.keyword != null and request.keyword != ''">
|
<if test="request.keyword != null and request.keyword != ''">
|
||||||
and name like concat('%', #{request.keyword},'%')
|
and name like concat('%', #{request.keyword},'%')
|
||||||
</if>
|
</if>
|
||||||
|
<include refid="filter"/>
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<sql id="filter">
|
||||||
|
<if test="request.filter != null and request.filter.size() > 0">
|
||||||
|
<foreach collection="request.filter.entrySet()" index="key" item="values">
|
||||||
|
<if test="values != null and values.size() > 0">
|
||||||
|
<choose>
|
||||||
|
<!-- 创建人 -->
|
||||||
|
<when test="key == 'createUser'">
|
||||||
|
and create_user in
|
||||||
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
|
@ -15,6 +15,7 @@ import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||||
|
import io.metersphere.system.service.UserToolService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
@ -22,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,6 +36,8 @@ import java.util.Map;
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class ApiDocShareService {
|
public class ApiDocShareService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserToolService userToolService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtApiDefinitionMapper extApiDefinitionMapper;
|
private ExtApiDefinitionMapper extApiDefinitionMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -53,8 +57,11 @@ public class ApiDocShareService {
|
||||||
* @return 分享列表
|
* @return 分享列表
|
||||||
*/
|
*/
|
||||||
public List<ApiDocShareDTO> list(ApiDocSharePageRequest request) {
|
public List<ApiDocShareDTO> list(ApiDocSharePageRequest request) {
|
||||||
List<ApiDocShareDTO> list = extApiDocShareMapper.list(request);
|
List<ApiDocShareDTO> shareList = extApiDocShareMapper.list(request);
|
||||||
return buildApiShareExtra(list);
|
if (CollectionUtils.isEmpty(shareList)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return buildApiShareExtra(shareList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,10 +177,13 @@ public class ApiDocShareService {
|
||||||
* @return 分享列表
|
* @return 分享列表
|
||||||
*/
|
*/
|
||||||
public List<ApiDocShareDTO> buildApiShareExtra(List<ApiDocShareDTO> docShares) {
|
public List<ApiDocShareDTO> buildApiShareExtra(List<ApiDocShareDTO> docShares) {
|
||||||
|
List<String> distinctUserIds = docShares.stream().map(ApiDocShareDTO::getCreateUser).distinct().toList();
|
||||||
|
Map<String, String> userMap = userToolService.getUserMapByIds(distinctUserIds);
|
||||||
docShares.forEach(docShare -> {
|
docShares.forEach(docShare -> {
|
||||||
docShare.setDeadline(calculateDeadline(docShare.getInvalidTime(), docShare.getInvalidUnit(), docShare.getCreateTime()));
|
docShare.setDeadline(calculateDeadline(docShare.getInvalidTime(), docShare.getInvalidUnit(), docShare.getCreateTime()));
|
||||||
docShare.setInvalid(docShare.getDeadline() != null && docShare.getDeadline() < System.currentTimeMillis());
|
docShare.setInvalid(docShare.getDeadline() != null && docShare.getDeadline() < System.currentTimeMillis());
|
||||||
docShare.setApiShareNum(countApiShare(docShare));
|
docShare.setApiShareNum(countApiShare(docShare));
|
||||||
|
docShare.setCreateUserName(userMap.get(docShare.getCreateUser()));
|
||||||
});
|
});
|
||||||
return docShares;
|
return docShares;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import io.metersphere.system.dto.taskhub.response.TaskStatisticsResponse;
|
||||||
import io.metersphere.system.log.annotation.Log;
|
import io.metersphere.system.log.annotation.Log;
|
||||||
import io.metersphere.system.log.constants.OperationLogModule;
|
import io.metersphere.system.log.constants.OperationLogModule;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.security.CheckOwner;
|
|
||||||
import io.metersphere.system.service.BaseTaskHubLogService;
|
import io.metersphere.system.service.BaseTaskHubLogService;
|
||||||
import io.metersphere.system.service.BaseTaskHubService;
|
import io.metersphere.system.service.BaseTaskHubService;
|
||||||
import io.metersphere.system.utils.PageUtils;
|
import io.metersphere.system.utils.PageUtils;
|
||||||
|
|
|
@ -25,6 +25,8 @@ public class BatchExecTaskReportDTO {
|
||||||
private String triggerMode;
|
private String triggerMode;
|
||||||
@Schema(description = "创建人")
|
@Schema(description = "创建人")
|
||||||
private String createUser;
|
private String createUser;
|
||||||
|
@Schema(description = "创建人名称")
|
||||||
|
private String createUserName;
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
private Long createTime;
|
private Long createTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,12 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<sql id="queryBatchWhereCondition">
|
||||||
|
<include refid="batchFilters">
|
||||||
|
<property name="filter" value="request.filter"/>
|
||||||
|
</include>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<sql id="filters">
|
<sql id="filters">
|
||||||
<if test="${filter} != null and ${filter}.size() > 0">
|
<if test="${filter} != null and ${filter}.size() > 0">
|
||||||
<foreach collection="${filter}.entrySet()" index="key" item="values">
|
<foreach collection="${filter}.entrySet()" index="key" item="values">
|
||||||
|
@ -110,6 +116,31 @@
|
||||||
</if>
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<sql id="batchFilters">
|
||||||
|
<if test="${filter} != null and ${filter}.size() > 0">
|
||||||
|
<foreach collection="${filter}.entrySet()" index="key" item="values">
|
||||||
|
<if test="values != null and values.size() > 0">
|
||||||
|
<choose>
|
||||||
|
<!-- 状态 -->
|
||||||
|
<when test="key=='status'">
|
||||||
|
and r.status in
|
||||||
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
|
</when>
|
||||||
|
<!-- 执行结果 -->
|
||||||
|
<when test="key=='result'">
|
||||||
|
and r.result in
|
||||||
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
|
</when>
|
||||||
|
<!-- 执行方式 -->
|
||||||
|
<when test="key=='triggerMode'">
|
||||||
|
and r.trigger_mode in
|
||||||
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<select id="getResourcePoolsByTaskIds" resultType="io.metersphere.system.domain.ExecTaskItem">
|
<select id="getResourcePoolsByTaskIds" resultType="io.metersphere.system.domain.ExecTaskItem">
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -233,5 +264,6 @@
|
||||||
from exec_task_item eti join api_report_relate_task arrt on arrt.task_resource_id = eti.id
|
from exec_task_item eti join api_report_relate_task arrt on arrt.task_resource_id = eti.id
|
||||||
join ${tableName} r on arrt.report_id = r.id and r.deleted = 0
|
join ${tableName} r on arrt.report_id = r.id and r.deleted = 0
|
||||||
where eti.task_id = #{request.taskId}
|
where eti.task_id = #{request.taskId}
|
||||||
|
<include refid="queryBatchWhereCondition"/>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -119,6 +119,8 @@ public class BaseTaskHubService {
|
||||||
private OperationLogService operationLogService;
|
private OperationLogService operationLogService;
|
||||||
@Resource
|
@Resource
|
||||||
ApiScheduleNoticeService apiScheduleNoticeService;
|
ApiScheduleNoticeService apiScheduleNoticeService;
|
||||||
|
@Resource
|
||||||
|
private UserToolService userToolService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -862,10 +864,18 @@ public class BaseTaskHubService {
|
||||||
* @return 执行任务报告集合
|
* @return 执行任务报告集合
|
||||||
*/
|
*/
|
||||||
public List<BatchExecTaskReportDTO> listBatchTaskReport(BatchExecTaskPageRequest request) {
|
public List<BatchExecTaskReportDTO> listBatchTaskReport(BatchExecTaskPageRequest request) {
|
||||||
|
List<BatchExecTaskReportDTO> batchReportList;
|
||||||
if (StringUtils.equals(ExecTaskType.API_CASE_BATCH.name(), request.getBatchType())) {
|
if (StringUtils.equals(ExecTaskType.API_CASE_BATCH.name(), request.getBatchType())) {
|
||||||
return extExecTaskItemMapper.list(request, "api_report");
|
batchReportList = extExecTaskItemMapper.list(request, "api_report");
|
||||||
} else {
|
} else {
|
||||||
return extExecTaskItemMapper.list(request, "api_scenario_report");
|
batchReportList = extExecTaskItemMapper.list(request, "api_scenario_report");
|
||||||
}
|
}
|
||||||
|
if (CollectionUtils.isEmpty(batchReportList)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<String> userIds = batchReportList.stream().map(BatchExecTaskReportDTO::getCreateUser).toList();
|
||||||
|
Map<String, String> userMap = userToolService.getUserMapByIds(userIds);
|
||||||
|
batchReportList.forEach(item -> item.setCreateUserName(userMap.get(item.getCreateUser())));
|
||||||
|
return batchReportList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue