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