refactor(任务中心): 任务列表查询返回值处理&domain更新

This commit is contained in:
WangXu10 2024-10-15 14:24:06 +08:00 committed by Craftsman
parent 234f41d052
commit 7832a10c02
10 changed files with 338 additions and 34 deletions

View File

@ -148,6 +148,9 @@ public class ApiReport implements Serializable {
@NotNull(message = "{api_report.plan.not_blank}", groups = {Created.class})
private Boolean plan;
@Schema(description = "关联任务id(集合报告)/任务项id")
private String associatedTaskId;
private static final long serialVersionUID = 1L;
public enum Column {
@ -183,7 +186,8 @@ public class ApiReport implements Serializable {
assertionPassRate("assertion_pass_rate", "assertionPassRate", "VARCHAR", false),
scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false),
execStatus("exec_status", "execStatus", "VARCHAR", false),
plan("plan", "plan", "BIT", true);
plan("plan", "plan", "BIT", true),
associatedTaskId("associated_task_id", "associatedTaskId", "VARCHAR", false);
private static final String BEGINNING_DELIMITER = "`";

View File

@ -2273,6 +2273,76 @@ public class ApiReportExample {
addCriterion("`plan` not between", value1, value2, "plan");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNull() {
addCriterion("associated_task_id is null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNotNull() {
addCriterion("associated_task_id is not null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdEqualTo(String value) {
addCriterion("associated_task_id =", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotEqualTo(String value) {
addCriterion("associated_task_id <>", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThan(String value) {
addCriterion("associated_task_id >", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThanOrEqualTo(String value) {
addCriterion("associated_task_id >=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThan(String value) {
addCriterion("associated_task_id <", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThanOrEqualTo(String value) {
addCriterion("associated_task_id <=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLike(String value) {
addCriterion("associated_task_id like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotLike(String value) {
addCriterion("associated_task_id not like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIn(List<String> values) {
addCriterion("associated_task_id in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotIn(List<String> values) {
addCriterion("associated_task_id not in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdBetween(String value1, String value2) {
addCriterion("associated_task_id between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotBetween(String value1, String value2) {
addCriterion("associated_task_id not between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -151,6 +151,9 @@ public class ApiScenarioReport implements Serializable {
@NotNull(message = "{api_scenario_report.plan.not_blank}", groups = {Created.class})
private Boolean plan;
@Schema(description = "关联任务id(集合报告)/任务项id")
private String associatedTaskId;
private static final long serialVersionUID = 1L;
public enum Column {
@ -187,7 +190,8 @@ public class ApiScenarioReport implements Serializable {
scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false),
waitingTime("waiting_time", "waitingTime", "BIGINT", false),
execStatus("exec_status", "execStatus", "VARCHAR", false),
plan("plan", "plan", "BIT", true);
plan("plan", "plan", "BIT", true),
associatedTaskId("associated_task_id", "associatedTaskId", "VARCHAR", false);
private static final String BEGINNING_DELIMITER = "`";

View File

@ -2333,6 +2333,76 @@ public class ApiScenarioReportExample {
addCriterion("`plan` not between", value1, value2, "plan");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNull() {
addCriterion("associated_task_id is null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNotNull() {
addCriterion("associated_task_id is not null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdEqualTo(String value) {
addCriterion("associated_task_id =", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotEqualTo(String value) {
addCriterion("associated_task_id <>", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThan(String value) {
addCriterion("associated_task_id >", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThanOrEqualTo(String value) {
addCriterion("associated_task_id >=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThan(String value) {
addCriterion("associated_task_id <", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThanOrEqualTo(String value) {
addCriterion("associated_task_id <=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLike(String value) {
addCriterion("associated_task_id like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotLike(String value) {
addCriterion("associated_task_id not like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIn(List<String> values) {
addCriterion("associated_task_id in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotIn(List<String> values) {
addCriterion("associated_task_id not in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdBetween(String value1, String value2) {
addCriterion("associated_task_id between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotBetween(String value1, String value2) {
addCriterion("associated_task_id not between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -35,6 +35,7 @@
<result column="script_identifier" jdbcType="VARCHAR" property="scriptIdentifier" />
<result column="exec_status" jdbcType="VARCHAR" property="execStatus" />
<result column="plan" jdbcType="BIT" property="plan" />
<result column="associated_task_id" jdbcType="VARCHAR" property="associatedTaskId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -100,7 +101,7 @@
pool_id, integrated, project_id, environment_id, error_count, fake_error_count, pending_count,
success_count, assertion_count, assertion_success_count, request_error_rate, request_pending_rate,
request_fake_error_rate, request_pass_rate, assertion_pass_rate, script_identifier,
exec_status, `plan`
exec_status, `plan`, associated_task_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiReportExample" resultMap="BaseResultMap">
select
@ -144,7 +145,8 @@
assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate,
request_pass_rate, assertion_pass_rate, script_identifier,
exec_status, `plan`)
exec_status, `plan`, associated_task_id
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{testPlanCaseId,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUser,jdbcType=VARCHAR},
#{deleted,jdbcType=BIT}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT},
@ -156,7 +158,8 @@
#{assertionSuccessCount,jdbcType=BIGINT}, #{requestErrorRate,jdbcType=VARCHAR},
#{requestPendingRate,jdbcType=VARCHAR}, #{requestFakeErrorRate,jdbcType=VARCHAR},
#{requestPassRate,jdbcType=VARCHAR}, #{assertionPassRate,jdbcType=VARCHAR}, #{scriptIdentifier,jdbcType=VARCHAR},
#{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT})
#{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT}, #{associatedTaskId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiReport">
insert into api_report
@ -260,6 +263,9 @@
<if test="plan != null">
`plan`,
</if>
<if test="associatedTaskId != null">
associated_task_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -361,6 +367,9 @@
<if test="plan != null">
#{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
#{associatedTaskId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.api.domain.ApiReportExample" resultType="java.lang.Long">
@ -471,6 +480,9 @@
<if test="record.plan != null">
`plan` = #{record.plan,jdbcType=BIT},
</if>
<if test="record.associatedTaskId != null">
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -510,7 +522,8 @@
assertion_pass_rate = #{record.assertionPassRate,jdbcType=VARCHAR},
script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR},
exec_status = #{record.execStatus,jdbcType=VARCHAR},
`plan` = #{record.plan,jdbcType=BIT}
`plan` = #{record.plan,jdbcType=BIT},
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -614,6 +627,9 @@
<if test="plan != null">
`plan` = #{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -650,7 +666,8 @@
assertion_pass_rate = #{assertionPassRate,jdbcType=VARCHAR},
script_identifier = #{scriptIdentifier,jdbcType=VARCHAR},
exec_status = #{execStatus,jdbcType=VARCHAR},
`plan` = #{plan,jdbcType=BIT}
`plan` = #{plan,jdbcType=BIT},
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
@ -660,7 +677,7 @@
pool_id, integrated, project_id, environment_id, error_count, fake_error_count,
pending_count, success_count, assertion_count, assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate,
script_identifier, exec_status, `plan`)
script_identifier, exec_status, `plan`, associated_task_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanCaseId,jdbcType=VARCHAR},
@ -675,7 +692,7 @@
#{item.requestPendingRate,jdbcType=VARCHAR}, #{item.requestFakeErrorRate,jdbcType=VARCHAR},
#{item.requestPassRate,jdbcType=VARCHAR}, #{item.assertionPassRate,jdbcType=VARCHAR},
#{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.execStatus,jdbcType=VARCHAR},
#{item.plan,jdbcType=BIT})
#{item.plan,jdbcType=BIT}, #{item.associatedTaskId,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -787,6 +804,9 @@
<if test="'plan'.toString() == column.value">
#{item.plan,jdbcType=BIT}
</if>
<if test="'associated_task_id'.toString() == column.value">
#{item.associatedTaskId,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>

View File

@ -36,6 +36,7 @@
<result column="waiting_time" jdbcType="BIGINT" property="waitingTime" />
<result column="exec_status" jdbcType="VARCHAR" property="execStatus" />
<result column="plan" jdbcType="BIT" property="plan" />
<result column="associated_task_id" jdbcType="VARCHAR" property="associatedTaskId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -101,7 +102,7 @@
run_mode, pool_id, integrated, project_id, environment_id, error_count, fake_error_count,
pending_count, success_count, assertion_count, assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate,
script_identifier, waiting_time, exec_status, `plan`
script_identifier, waiting_time, exec_status, `plan`, associated_task_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiScenarioReportExample" resultMap="BaseResultMap">
select
@ -145,8 +146,8 @@
assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate,
request_pass_rate, assertion_pass_rate, script_identifier,
waiting_time, exec_status, `plan`
)
waiting_time, exec_status, `plan`,
associated_task_id)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{testPlanScenarioId,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUser,jdbcType=VARCHAR},
#{deleted,jdbcType=BIT}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT},
@ -158,8 +159,8 @@
#{assertionSuccessCount,jdbcType=BIGINT}, #{requestErrorRate,jdbcType=VARCHAR},
#{requestPendingRate,jdbcType=VARCHAR}, #{requestFakeErrorRate,jdbcType=VARCHAR},
#{requestPassRate,jdbcType=VARCHAR}, #{assertionPassRate,jdbcType=VARCHAR}, #{scriptIdentifier,jdbcType=VARCHAR},
#{waitingTime,jdbcType=BIGINT}, #{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT}
)
#{waitingTime,jdbcType=BIGINT}, #{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT},
#{associatedTaskId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiScenarioReport">
insert into api_scenario_report
@ -266,6 +267,9 @@
<if test="plan != null">
`plan`,
</if>
<if test="associatedTaskId != null">
associated_task_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -370,6 +374,9 @@
<if test="plan != null">
#{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
#{associatedTaskId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.api.domain.ApiScenarioReportExample" resultType="java.lang.Long">
@ -483,6 +490,9 @@
<if test="record.plan != null">
`plan` = #{record.plan,jdbcType=BIT},
</if>
<if test="record.associatedTaskId != null">
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -523,7 +533,8 @@
script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR},
waiting_time = #{record.waitingTime,jdbcType=BIGINT},
exec_status = #{record.execStatus,jdbcType=VARCHAR},
`plan` = #{record.plan,jdbcType=BIT}
`plan` = #{record.plan,jdbcType=BIT},
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -630,6 +641,9 @@
<if test="plan != null">
`plan` = #{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -667,7 +681,8 @@
script_identifier = #{scriptIdentifier,jdbcType=VARCHAR},
waiting_time = #{waitingTime,jdbcType=BIGINT},
exec_status = #{execStatus,jdbcType=VARCHAR},
`plan` = #{plan,jdbcType=BIT}
`plan` = #{plan,jdbcType=BIT},
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
@ -677,7 +692,7 @@
run_mode, pool_id, integrated, project_id, environment_id, error_count, fake_error_count,
pending_count, success_count, assertion_count, assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate,
script_identifier, waiting_time, exec_status, `plan`)
script_identifier, waiting_time, exec_status, `plan`, associated_task_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanScenarioId,jdbcType=VARCHAR},
@ -692,7 +707,8 @@
#{item.requestPendingRate,jdbcType=VARCHAR}, #{item.requestFakeErrorRate,jdbcType=VARCHAR},
#{item.requestPassRate,jdbcType=VARCHAR}, #{item.assertionPassRate,jdbcType=VARCHAR},
#{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.waitingTime,jdbcType=BIGINT},
#{item.execStatus,jdbcType=VARCHAR}, #{item.plan,jdbcType=BIT})
#{item.execStatus,jdbcType=VARCHAR}, #{item.plan,jdbcType=BIT}, #{item.associatedTaskId,jdbcType=VARCHAR}
)
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -807,6 +823,9 @@
<if test="'plan'.toString() == column.value">
#{item.plan,jdbcType=BIT}
</if>
<if test="'associated_task_id'.toString() == column.value">
#{item.associatedTaskId,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>

View File

@ -4,6 +4,7 @@ import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.ArrayList;
@ -71,6 +72,10 @@ public class ExecTask implements Serializable {
@Schema(description = "结束时间")
private Long endTime;
@Schema(description = "是否是集成报告", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{exec_task.integrated.not_blank}", groups = {Created.class})
private Boolean integrated;
private static final long serialVersionUID = 1L;
public enum Column {
@ -88,7 +93,8 @@ public class ExecTask implements Serializable {
createTime("create_time", "createTime", "BIGINT", false),
createUser("create_user", "createUser", "VARCHAR", false),
startTime("start_time", "startTime", "BIGINT", false),
endTime("end_time", "endTime", "BIGINT", false);
endTime("end_time", "endTime", "BIGINT", false),
integrated("integrated", "integrated", "BIT", false);
private static final String BEGINNING_DELIMITER = "`";

View File

@ -1103,6 +1103,66 @@ public class ExecTaskExample {
addCriterion("end_time not between", value1, value2, "endTime");
return (Criteria) this;
}
public Criteria andIntegratedIsNull() {
addCriterion("integrated is null");
return (Criteria) this;
}
public Criteria andIntegratedIsNotNull() {
addCriterion("integrated is not null");
return (Criteria) this;
}
public Criteria andIntegratedEqualTo(Boolean value) {
addCriterion("integrated =", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotEqualTo(Boolean value) {
addCriterion("integrated <>", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedGreaterThan(Boolean value) {
addCriterion("integrated >", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedGreaterThanOrEqualTo(Boolean value) {
addCriterion("integrated >=", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedLessThan(Boolean value) {
addCriterion("integrated <", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedLessThanOrEqualTo(Boolean value) {
addCriterion("integrated <=", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedIn(List<Boolean> values) {
addCriterion("integrated in", values, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotIn(List<Boolean> values) {
addCriterion("integrated not in", values, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedBetween(Boolean value1, Boolean value2) {
addCriterion("integrated between", value1, value2, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotBetween(Boolean value1, Boolean value2) {
addCriterion("integrated not between", value1, value2, "integrated");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -17,6 +17,7 @@
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="start_time" jdbcType="BIGINT" property="startTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="integrated" jdbcType="BIT" property="integrated" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -78,7 +79,7 @@
</sql>
<sql id="Base_Column_List">
id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode,
project_id, organization_id, create_time, create_user, start_time, end_time
project_id, organization_id, create_time, create_user, start_time, end_time, integrated
</sql>
<select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultMap="BaseResultMap">
select
@ -115,14 +116,14 @@
`status`, case_count, `result`,
task_type, resource_id, trigger_mode,
project_id, organization_id, create_time,
create_user, start_time, end_time
)
create_user, start_time, end_time,
integrated)
values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{taskName,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{caseCount,jdbcType=BIGINT}, #{result,jdbcType=VARCHAR},
#{taskType,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{createUser,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}
)
#{createUser,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT},
#{integrated,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.system.domain.ExecTask">
insert into exec_task
@ -172,6 +173,9 @@
<if test="endTime != null">
end_time,
</if>
<if test="integrated != null">
integrated,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -219,6 +223,9 @@
<if test="endTime != null">
#{endTime,jdbcType=BIGINT},
</if>
<if test="integrated != null">
#{integrated,jdbcType=BIT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultType="java.lang.Long">
@ -275,6 +282,9 @@
<if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=BIGINT},
</if>
<if test="record.integrated != null">
integrated = #{record.integrated,jdbcType=BIT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -296,7 +306,8 @@
create_time = #{record.createTime,jdbcType=BIGINT},
create_user = #{record.createUser,jdbcType=VARCHAR},
start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT}
end_time = #{record.endTime,jdbcType=BIGINT},
integrated = #{record.integrated,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -346,6 +357,9 @@
<if test="endTime != null">
end_time = #{endTime,jdbcType=BIGINT},
</if>
<if test="integrated != null">
integrated = #{integrated,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -364,21 +378,23 @@
create_time = #{createTime,jdbcType=BIGINT},
create_user = #{createUser,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT}
end_time = #{endTime,jdbcType=BIGINT},
integrated = #{integrated,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
insert into exec_task
(id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode,
project_id, organization_id, create_time, create_user, start_time, end_time)
project_id, organization_id, create_time, create_user, start_time, end_time, integrated
)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.taskName,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.caseCount,jdbcType=BIGINT}, #{item.result,jdbcType=VARCHAR},
#{item.taskType,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR},
#{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT},
#{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}
)
#{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT},
#{item.integrated,jdbcType=BIT})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -436,6 +452,9 @@
<if test="'end_time'.toString() == column.value">
#{item.endTime,jdbcType=BIGINT}
</if>
<if test="'integrated'.toString() == column.value">
#{item.integrated,jdbcType=BIT}
</if>
</foreach>
)
</foreach>

View File

@ -2,8 +2,11 @@ package io.metersphere.system.service;
import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import io.metersphere.project.domain.Project;
import io.metersphere.project.domain.ProjectExample;
import io.metersphere.project.domain.ProjectTestResourcePool;
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
import io.metersphere.project.mapper.ProjectMapper;
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
import io.metersphere.sdk.constants.ExecStatus;
import io.metersphere.sdk.constants.ResultStatus;
@ -73,6 +76,10 @@ public class BaseTaskHubService {
private ExecTaskMapper execTaskMapper;
@Resource
private ExecTaskItemMapper execTaskItemMapper;
@Resource
private ProjectMapper projectMapper;
@Resource
private OrganizationMapper organizationMapper;
/**
* 系统-获取执行任务列表
@ -89,7 +96,32 @@ public class BaseTaskHubService {
}
private List<TaskHubDTO> getPage(BasePageRequest request, String orgId, String projectId) {
return extExecTaskMapper.selectList(request, orgId, projectId);
List<TaskHubDTO> list = extExecTaskMapper.selectList(request, orgId, projectId);
handleList(list);
return list;
}
private void handleList(List<TaskHubDTO> list) {
if(CollectionUtils.isEmpty(list)){
return;
}
List<String> projectIds = list.stream().map(TaskHubDTO::getProjectId).distinct().toList();
List<String> organizationIds = list.stream().map(TaskHubDTO::getProjectId).distinct().toList();
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andIdIn(projectIds);
List<Project> projectList = projectMapper.selectByExample(projectExample);
Map<String, String> projectMaps = projectList.stream().collect(Collectors.toMap(Project::getId, Project::getName));
OrganizationExample organizationExample = new OrganizationExample();
organizationExample.createCriteria().andIdIn(organizationIds);
List<Organization> organizationList = organizationMapper.selectByExample(organizationExample);
Map<String, String> organizationMaps = organizationList.stream().collect(Collectors.toMap(Organization::getId, Organization::getName));
list.forEach(item -> {
item.setProjectName(projectMaps.getOrDefault(item.getProjectId(), StringUtils.EMPTY));
item.setOrganizationName(organizationMaps.getOrDefault(item.getOrganizationId(), StringUtils.EMPTY));
});
}
@ -236,13 +268,13 @@ public class BaseTaskHubService {
Map<String, List<ExecTaskItem>> taskItems = taskItemList.stream().collect(Collectors.groupingBy(ExecTaskItem::getTaskId));
taskItems.forEach((taskId, items) -> {
//成功数量
long successCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.SUCCESS.name(), item.getStatus())).count();
long successCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.SUCCESS.name(), item.getResult())).count();
//失败数量
long errorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.ERROR.name(), item.getStatus())).count();
long errorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.ERROR.name(), item.getResult())).count();
//误报数量
long fakeErrorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.FAKE_ERROR.name(), item.getStatus())).count();
long fakeErrorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.FAKE_ERROR.name(), item.getResult())).count();
//未执行数量
long pendingCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ExecStatus.PENDING.name(), item.getStatus())).count();
long pendingCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ExecStatus.PENDING.name(), item.getResult())).count();
TaskStatisticsResponse response = new TaskStatisticsResponse();
response.setId(taskId);