refactor(用例管理): 评审历史查询增加废弃字段的条件

This commit is contained in:
guoyuqi 2024-02-02 11:32:25 +08:00 committed by f2c-ci-robot[bot]
parent b7a3a7348c
commit c7b0e9f8f7
9 changed files with 128 additions and 38 deletions

View File

@ -43,6 +43,10 @@ public class CaseReviewHistory implements Serializable {
@Schema(description = "操作时间") @Schema(description = "操作时间")
private Long createTime; private Long createTime;
@Schema(description = "是否是废弃的评审记录0-否1-是", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{case_review_history.abandoned.not_blank}", groups = {Created.class})
private Boolean abandoned;
@Schema(description = "评审意见") @Schema(description = "评审意见")
private byte[] content; private byte[] content;
@ -57,6 +61,7 @@ public class CaseReviewHistory implements Serializable {
notifier("notifier", "notifier", "VARCHAR", false), notifier("notifier", "notifier", "VARCHAR", false),
createUser("create_user", "createUser", "VARCHAR", false), createUser("create_user", "createUser", "VARCHAR", false),
createTime("create_time", "createTime", "BIGINT", false), createTime("create_time", "createTime", "BIGINT", false),
abandoned("abandoned", "abandoned", "BIT", false),
content("content", "content", "LONGVARBINARY", false); content("content", "content", "LONGVARBINARY", false);
private static final String BEGINNING_DELIMITER = "`"; private static final String BEGINNING_DELIMITER = "`";

View File

@ -643,6 +643,66 @@ public class CaseReviewHistoryExample {
addCriterion("create_time not between", value1, value2, "createTime"); addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andAbandonedIsNull() {
addCriterion("abandoned is null");
return (Criteria) this;
}
public Criteria andAbandonedIsNotNull() {
addCriterion("abandoned is not null");
return (Criteria) this;
}
public Criteria andAbandonedEqualTo(Boolean value) {
addCriterion("abandoned =", value, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedNotEqualTo(Boolean value) {
addCriterion("abandoned <>", value, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedGreaterThan(Boolean value) {
addCriterion("abandoned >", value, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedGreaterThanOrEqualTo(Boolean value) {
addCriterion("abandoned >=", value, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedLessThan(Boolean value) {
addCriterion("abandoned <", value, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedLessThanOrEqualTo(Boolean value) {
addCriterion("abandoned <=", value, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedIn(List<Boolean> values) {
addCriterion("abandoned in", values, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedNotIn(List<Boolean> values) {
addCriterion("abandoned not in", values, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedBetween(Boolean value1, Boolean value2) {
addCriterion("abandoned between", value1, value2, "abandoned");
return (Criteria) this;
}
public Criteria andAbandonedNotBetween(Boolean value1, Boolean value2) {
addCriterion("abandoned not between", value1, value2, "abandoned");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -10,6 +10,7 @@
<result column="notifier" jdbcType="VARCHAR" property="notifier" /> <result column="notifier" jdbcType="VARCHAR" property="notifier" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" /> <result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="abandoned" jdbcType="BIT" property="abandoned" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.functional.domain.CaseReviewHistory"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.functional.domain.CaseReviewHistory">
<result column="content" jdbcType="LONGVARBINARY" property="content" /> <result column="content" jdbcType="LONGVARBINARY" property="content" />
@ -73,7 +74,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, review_id, case_id, `status`, deleted, notifier, create_user, create_time id, review_id, case_id, `status`, deleted, notifier, create_user, create_time, abandoned
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
content content
@ -129,12 +130,12 @@
<insert id="insert" parameterType="io.metersphere.functional.domain.CaseReviewHistory"> <insert id="insert" parameterType="io.metersphere.functional.domain.CaseReviewHistory">
insert into case_review_history (id, review_id, case_id, insert into case_review_history (id, review_id, case_id,
`status`, deleted, notifier, `status`, deleted, notifier,
create_user, create_time, content create_user, create_time, abandoned,
) content)
values (#{id,jdbcType=VARCHAR}, #{reviewId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{reviewId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}, #{notifier,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}, #{notifier,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{content,jdbcType=LONGVARBINARY} #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{abandoned,jdbcType=BIT},
) #{content,jdbcType=LONGVARBINARY})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.functional.domain.CaseReviewHistory"> <insert id="insertSelective" parameterType="io.metersphere.functional.domain.CaseReviewHistory">
insert into case_review_history insert into case_review_history
@ -163,6 +164,9 @@
<if test="createTime != null"> <if test="createTime != null">
create_time, create_time,
</if> </if>
<if test="abandoned != null">
abandoned,
</if>
<if test="content != null"> <if test="content != null">
content, content,
</if> </if>
@ -192,6 +196,9 @@
<if test="createTime != null"> <if test="createTime != null">
#{createTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT},
</if> </if>
<if test="abandoned != null">
#{abandoned,jdbcType=BIT},
</if>
<if test="content != null"> <if test="content != null">
#{content,jdbcType=LONGVARBINARY}, #{content,jdbcType=LONGVARBINARY},
</if> </if>
@ -230,6 +237,9 @@
<if test="record.createTime != null"> <if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
</if> </if>
<if test="record.abandoned != null">
abandoned = #{record.abandoned,jdbcType=BIT},
</if>
<if test="record.content != null"> <if test="record.content != null">
content = #{record.content,jdbcType=LONGVARBINARY}, content = #{record.content,jdbcType=LONGVARBINARY},
</if> </if>
@ -248,6 +258,7 @@
notifier = #{record.notifier,jdbcType=VARCHAR}, notifier = #{record.notifier,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
abandoned = #{record.abandoned,jdbcType=BIT},
content = #{record.content,jdbcType=LONGVARBINARY} content = #{record.content,jdbcType=LONGVARBINARY}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -262,7 +273,8 @@
deleted = #{record.deleted,jdbcType=BIT}, deleted = #{record.deleted,jdbcType=BIT},
notifier = #{record.notifier,jdbcType=VARCHAR}, notifier = #{record.notifier,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT} create_time = #{record.createTime,jdbcType=BIGINT},
abandoned = #{record.abandoned,jdbcType=BIT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -291,6 +303,9 @@
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
</if> </if>
<if test="abandoned != null">
abandoned = #{abandoned,jdbcType=BIT},
</if>
<if test="content != null"> <if test="content != null">
content = #{content,jdbcType=LONGVARBINARY}, content = #{content,jdbcType=LONGVARBINARY},
</if> </if>
@ -306,6 +321,7 @@
notifier = #{notifier,jdbcType=VARCHAR}, notifier = #{notifier,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
abandoned = #{abandoned,jdbcType=BIT},
content = #{content,jdbcType=LONGVARBINARY} content = #{content,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -317,19 +333,20 @@
deleted = #{deleted,jdbcType=BIT}, deleted = #{deleted,jdbcType=BIT},
notifier = #{notifier,jdbcType=VARCHAR}, notifier = #{notifier,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT} create_time = #{createTime,jdbcType=BIGINT},
abandoned = #{abandoned,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">
insert into case_review_history insert into case_review_history
(id, review_id, case_id, `status`, deleted, notifier, create_user, create_time, content (id, review_id, case_id, `status`, deleted, notifier, create_user, create_time, abandoned,
) content)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.reviewId,jdbcType=VARCHAR}, #{item.caseId,jdbcType=VARCHAR}, (#{item.id,jdbcType=VARCHAR}, #{item.reviewId,jdbcType=VARCHAR}, #{item.caseId,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.notifier,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.notifier,jdbcType=VARCHAR},
#{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.content,jdbcType=LONGVARBINARY} #{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.abandoned,jdbcType=BIT},
) #{item.content,jdbcType=LONGVARBINARY})
</foreach> </foreach>
</insert> </insert>
<insert id="batchInsertSelective" parameterType="map"> <insert id="batchInsertSelective" parameterType="map">
@ -366,6 +383,9 @@
<if test="'create_time'.toString() == column.value"> <if test="'create_time'.toString() == column.value">
#{item.createTime,jdbcType=BIGINT} #{item.createTime,jdbcType=BIGINT}
</if> </if>
<if test="'abandoned'.toString() == column.value">
#{item.abandoned,jdbcType=BIT}
</if>
<if test="'content'.toString() == column.value"> <if test="'content'.toString() == column.value">
#{item.content,jdbcType=LONGVARBINARY} #{item.content,jdbcType=LONGVARBINARY}
</if> </if>

View File

@ -301,6 +301,8 @@ CREATE INDEX idx_case_id ON case_review_functional_case (case_id);
CREATE INDEX idx_review_id ON case_review_functional_case (review_id); CREATE INDEX idx_review_id ON case_review_functional_case (review_id);
CREATE INDEX idx_status ON case_review_functional_case (status); CREATE INDEX idx_status ON case_review_functional_case (status);
CREATE INDEX idx_pos ON case_review_functional_case (pos); CREATE INDEX idx_pos ON case_review_functional_case (pos);
CREATE UNIQUE INDEX idx_case_id_review_id ON case_review_functional_case(review_id,case_id);
CREATE TABLE IF NOT EXISTS case_review_functional_case_archive CREATE TABLE IF NOT EXISTS case_review_functional_case_archive
@ -352,6 +354,7 @@ CREATE TABLE IF NOT EXISTS case_review_history
`content` LONGBLOB COMMENT '评审意见', `content` LONGBLOB COMMENT '评审意见',
`status` VARCHAR(64) NOT NULL COMMENT '评审结果:通过/不通过/建议', `status` VARCHAR(64) NOT NULL COMMENT '评审结果:通过/不通过/建议',
`deleted` BIT(1) NOT NULL DEFAULT 0 COMMENT '是否是取消关联或评审被删除的0-否1-是' , `deleted` BIT(1) NOT NULL DEFAULT 0 COMMENT '是否是取消关联或评审被删除的0-否1-是' ,
`abandoned` BIT(1) NOT NULL DEFAULT 0 COMMENT '是否是废弃的评审记录0-否1-是' ,
`notifier` VARCHAR(1000) COMMENT '通知人', `notifier` VARCHAR(1000) COMMENT '通知人',
`create_user` VARCHAR(50) NOT NULL COMMENT '操作人', `create_user` VARCHAR(50) NOT NULL COMMENT '操作人',
`create_time` BIGINT NOT NULL COMMENT '操作时间', `create_time` BIGINT NOT NULL COMMENT '操作时间',
@ -366,6 +369,7 @@ CREATE INDEX idx_review_id ON case_review_history (review_id);
CREATE INDEX idx_review_id_case_id ON case_review_history (review_id, case_id); CREATE INDEX idx_review_id_case_id ON case_review_history (review_id, case_id);
CREATE INDEX idx_status ON case_review_history (status); CREATE INDEX idx_status ON case_review_history (status);
CREATE INDEX idx_deleted ON case_review_history(deleted); CREATE INDEX idx_deleted ON case_review_history(deleted);
CREATE INDEX idx_abandoned ON case_review_history(abandoned);
CREATE TABLE IF NOT EXISTS case_review_module CREATE TABLE IF NOT EXISTS case_review_module

View File

@ -22,6 +22,7 @@
<if test="reviewId != null and reviewId != ''"> <if test="reviewId != null and reviewId != ''">
and ch.review_id = #{reviewId} and ch.review_id = #{reviewId}
</if> </if>
and ch.abandoned = false
</select> </select>
<update id="updateDelete"> <update id="updateDelete">

View File

@ -329,7 +329,7 @@ public class CaseReviewFunctionalCaseService {
} }
List<String> caseIds = caseReviewFunctionalCaseList.stream().map(CaseReviewFunctionalCase::getCaseId).toList(); List<String> caseIds = caseReviewFunctionalCaseList.stream().map(CaseReviewFunctionalCase::getCaseId).toList();
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample(); CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andCaseIdIn(caseIds).andReviewIdEqualTo(reviewId).andDeletedEqualTo(false); caseReviewHistoryExample.createCriteria().andCaseIdIn(caseIds).andReviewIdEqualTo(reviewId).andDeletedEqualTo(false).andAbandonedEqualTo(false);
List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Map<String, List<CaseReviewHistory>> caseHistoryMap = caseReviewHistories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCaseId, Collectors.toList())); Map<String, List<CaseReviewHistory>> caseHistoryMap = caseReviewHistories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCaseId, Collectors.toList()));
@ -456,6 +456,7 @@ public class CaseReviewFunctionalCaseService {
caseReviewHistory.setCaseId(caseId); caseReviewHistory.setCaseId(caseId);
caseReviewHistory.setStatus(request.getStatus()); caseReviewHistory.setStatus(request.getStatus());
caseReviewHistory.setDeleted(false); caseReviewHistory.setDeleted(false);
caseReviewHistory.setAbandoned(false);
if (StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) { if (StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) {
if (StringUtils.isBlank(request.getContent())) { if (StringUtils.isBlank(request.getContent())) {
throw new MSException(Translator.get("case_review_content.not.exist")); throw new MSException(Translator.get("case_review_content.not.exist"));
@ -499,7 +500,7 @@ public class CaseReviewFunctionalCaseService {
Map<String, List<CaseReviewFunctionalCaseUser>> newReviewersMap = newReviewers.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCaseUser::getCaseId)); Map<String, List<CaseReviewFunctionalCaseUser>> newReviewersMap = newReviewers.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCaseUser::getCaseId));
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample(); CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andCaseIdIn(caseIds).andReviewIdEqualTo(request.getReviewId()).andDeletedEqualTo(false); caseReviewHistoryExample.createCriteria().andCaseIdIn(caseIds).andReviewIdEqualTo(request.getReviewId()).andDeletedEqualTo(false).andAbandonedEqualTo(false);
List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Map<String, List<CaseReviewHistory>> caseHistoryMap = caseReviewHistories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCaseId, Collectors.toList())); Map<String, List<CaseReviewHistory>> caseHistoryMap = caseReviewHistories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCaseId, Collectors.toList()));

View File

@ -78,16 +78,16 @@ public class ReviewFunctionalCaseService {
} }
CaseReviewHistory caseReviewHistory = buildReviewHistory(request, userId); CaseReviewHistory caseReviewHistory = buildReviewHistory(request, userId);
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample(); CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andCaseIdEqualTo(request.getCaseId()).andReviewIdEqualTo(request.getReviewId()).andDeletedEqualTo(false); caseReviewHistoryExample.createCriteria().andCaseIdEqualTo(request.getCaseId()).andReviewIdEqualTo(request.getReviewId()).andDeletedEqualTo(false).andAbandonedEqualTo(false);
List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Map<String, List<CaseReviewHistory>> hasReviewedUserMap = caseReviewHistories.stream().sorted(Comparator.comparingLong(CaseReviewHistory::getCreateTime).reversed()).collect(Collectors.groupingBy(CaseReviewHistory::getCreateUser, Collectors.toList())); Map<String, List<CaseReviewHistory>> hasReviewedUserMap = caseReviewHistories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCreateUser));
if (hasReviewedUserMap.get(userId) == null) { if (hasReviewedUserMap.get(userId) == null) {
List<CaseReviewHistory> caseReviewHistoryList = new ArrayList<>(); List<CaseReviewHistory> caseReviewHistoryList = new ArrayList<>();
caseReviewHistoryList.add(caseReviewHistory); caseReviewHistoryList.add(caseReviewHistory);
hasReviewedUserMap.put(userId, caseReviewHistoryList); hasReviewedUserMap.put(userId, caseReviewHistoryList);
} }
//根据评审规则更新用例评审和功能用例关系表中的状态 1.单人评审直接更新评审结果 2.多人评审需要计算 //根据评审规则更新用例评审和功能用例关系表中的状态 1.单人评审直接更新评审结果 2.多人评审需要计算
String functionalCaseStatus = getFunctionalCaseStatus(request, hasReviewedUserMap, isAdmin); String functionalCaseStatus = getFunctionalCaseStatus(request, hasReviewedUserMap, isAdmin, caseReviewFunctionalCaseUsers.size());
extCaseReviewFunctionalCaseMapper.updateStatus(caseId, reviewId, functionalCaseStatus); extCaseReviewFunctionalCaseMapper.updateStatus(caseId, reviewId, functionalCaseStatus);
caseReviewHistoryMapper.insert(caseReviewHistory); caseReviewHistoryMapper.insert(caseReviewHistory);
@ -127,7 +127,7 @@ public class ReviewFunctionalCaseService {
* @param request 评审规则 * @param request 评审规则
* @return 功能用例的评审结果 * @return 功能用例的评审结果
*/ */
private String getFunctionalCaseStatus(ReviewFunctionalCaseRequest request, Map<String, List<CaseReviewHistory>> hasReviewedUserMap, boolean isAdmin) { private String getFunctionalCaseStatus(ReviewFunctionalCaseRequest request, Map<String, List<CaseReviewHistory>> hasReviewedUserMap, boolean isAdmin, int reviewerNum) {
String functionalCaseStatus; String functionalCaseStatus;
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(request.getReviewId()).andCaseIdEqualTo(request.getCaseId()); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(request.getReviewId()).andCaseIdEqualTo(request.getCaseId());
@ -144,22 +144,20 @@ public class ReviewFunctionalCaseService {
return status; return status;
} }
//根据用例ID 查询所有评审人 再查所有评审人最后一次的评审结果只有通过/不通过算结果 //根据用例ID 查询所有评审人 再查所有评审人最后一次的评审结果只有通过/不通过算结果
CaseReviewFunctionalCaseUserExample caseReviewFunctionalCaseUserExample = new CaseReviewFunctionalCaseUserExample();
caseReviewFunctionalCaseUserExample.createCriteria().andReviewIdEqualTo(request.getReviewId()).andCaseIdEqualTo(request.getCaseId());
long reviewerNum = caseReviewFunctionalCaseUserMapper.countByExample(caseReviewFunctionalCaseUserExample);
AtomicInteger passCount = new AtomicInteger(); AtomicInteger passCount = new AtomicInteger();
AtomicInteger unPassCount = new AtomicInteger(); AtomicInteger unPassCount = new AtomicInteger();
hasReviewedUserMap.forEach((k, v) -> { hasReviewedUserMap.forEach((k, v) -> {
if (StringUtils.equalsIgnoreCase(v.get(0).getStatus(), FunctionalCaseReviewStatus.PASS.toString())) { List<CaseReviewHistory> list = v.stream().sorted(Comparator.comparing(CaseReviewHistory::getCreateTime).reversed()).toList();
if (StringUtils.equalsIgnoreCase(list.get(0).getStatus(), FunctionalCaseReviewStatus.PASS.toString())) {
passCount.set(passCount.get() + 1); passCount.set(passCount.get() + 1);
} }
if (StringUtils.equalsIgnoreCase(v.get(0).getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) { if (StringUtils.equalsIgnoreCase(list.get(0).getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) {
unPassCount.set(unPassCount.get() + 1); unPassCount.set(unPassCount.get() + 1);
} }
}); });
if (unPassCount.get() > 0) { if (unPassCount.get() > 0) {
functionalCaseStatus = FunctionalCaseReviewStatus.UN_PASS.toString(); functionalCaseStatus = FunctionalCaseReviewStatus.UN_PASS.toString();
} else if ((int) reviewerNum > hasReviewedUserMap.size()) { } else if (reviewerNum > hasReviewedUserMap.size()) {
functionalCaseStatus = FunctionalCaseReviewStatus.UNDER_REVIEWED.toString(); functionalCaseStatus = FunctionalCaseReviewStatus.UNDER_REVIEWED.toString();
} else { } else {
//检查是否全部是通过全是才是PASS,否则是评审中 //检查是否全部是通过全是才是PASS,否则是评审中
@ -187,6 +185,7 @@ public class ReviewFunctionalCaseService {
caseReviewHistory.setCaseId(request.getCaseId()); caseReviewHistory.setCaseId(request.getCaseId());
caseReviewHistory.setStatus(request.getStatus()); caseReviewHistory.setStatus(request.getStatus());
caseReviewHistory.setDeleted(false); caseReviewHistory.setDeleted(false);
caseReviewHistory.setAbandoned(false);
if (StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) { if (StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) {
if (StringUtils.isBlank(request.getContent())) { if (StringUtils.isBlank(request.getContent())) {
throw new MSException(Translator.get("case_review_content.not.exist")); throw new MSException(Translator.get("case_review_content.not.exist"));

View File

@ -101,7 +101,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString()); reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest); this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest);
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample(); CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTest"); caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTest").andAbandonedEqualTo(false);
List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Assertions.assertEquals(1, caseReviewHistories.size()); Assertions.assertEquals(1, caseReviewHistories.size());
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
@ -119,7 +119,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString()); reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest); this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest);
caseReviewHistoryExample = new CaseReviewHistoryExample(); caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne"); caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne").andAbandonedEqualTo(false);
caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Assertions.assertEquals(1, caseReviewHistories.size()); Assertions.assertEquals(1, caseReviewHistories.size());
caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
@ -138,7 +138,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString()); reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest); this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest);
caseReviewHistoryExample = new CaseReviewHistoryExample(); caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne"); caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne").andAbandonedEqualTo(false);
caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Assertions.assertEquals(2, caseReviewHistories.size()); Assertions.assertEquals(2, caseReviewHistories.size());
caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
@ -195,7 +195,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest); this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest);
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample(); CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestTwo"); caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestTwo").andAbandonedEqualTo(false);
List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Assertions.assertEquals(1, caseReviewHistories.size()); Assertions.assertEquals(1, caseReviewHistories.size());
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
@ -244,7 +244,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString()); reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest); this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest);
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample(); CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestThree"); caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestThree").andAbandonedEqualTo(false);
List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Assertions.assertEquals(1, caseReviewHistories.size()); Assertions.assertEquals(1, caseReviewHistories.size());
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
@ -262,7 +262,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString()); reviewFunctionalCaseRequest.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest); this.requestPostWithOk(SAVE_REVIEW, reviewFunctionalCaseRequest);
caseReviewHistoryExample = new CaseReviewHistoryExample(); caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestFour"); caseReviewHistoryExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestFour").andAbandonedEqualTo(false);
caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample); caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Assertions.assertEquals(1, caseReviewHistories.size()); Assertions.assertEquals(1, caseReviewHistories.size());
caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();

View File

@ -122,15 +122,15 @@ VALUE (UUID(), 'multiple_review_admin', 'admin', 'system',
'system', UNIX_TIMESTAMP() * 1000, 'system', UNIX_TIMESTAMP() * 1000,
'admin'); 'admin');
INSERT INTO case_review_history(id, review_id, case_id, content, status, deleted, notifier, create_user, create_time) INSERT INTO case_review_history(id, review_id, case_id, content, status, deleted, abandoned, notifier, create_user, create_time)
VALUES ('wx_history', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), VALUES ('wx_history', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', b'0', NULL, 'admin', 1669174143999),
('wx_histor_1', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), ('wx_histor_1', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', b'0', NULL, 'admin', 1669174143999),
('wx_history_2', 'wx_review_id_3', 'wx_case_id_3', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), ('wx_history_2', 'wx_review_id_3', 'wx_case_id_3', NULL, 'PASS', b'0', b'0', NULL, 'admin', 1669174143999),
('wx_history_3', 'wx_review_id_4', 'wx_case_id_4', NULL, 'PASS', b'0', NULL, 'A', 1669174143999), ('wx_history_3', 'wx_review_id_4', 'wx_case_id_4', NULL, 'PASS', b'0', b'0', NULL, 'A', 1669174143999),
('wx_history_4', 'wx_review_id_4', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), ('wx_history_4', 'wx_review_id_4', 'wx_case_id_1', NULL, 'PASS', b'0', b'0', NULL, 'admin', 1669174143999),
('wx_history_5', 'wx_review_id_4', 'wx_case_id_2', NULL, 'UN_PASS', b'0', NULL, 'admin', 1669174143999), ('wx_history_5', 'wx_review_id_4', 'wx_case_id_2', NULL, 'UN_PASS', b'0', b'0', NULL, 'admin', 1669174143999),
('wx_history_6', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'PASS', b'0', NULL, 'gyq_case_review', 1669174143999), ('wx_history_6', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'PASS', b'0', b'0', NULL, 'gyq_case_review', 1669174143999),
('wx_history_7', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'UN_PASS', b'0', NULL, 'GGG', 1669174143999); ('wx_history_7', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'UN_PASS', b'0', b'0', NULL, 'GGG', 1669174143999);
INSERT INTO case_review_user(review_id, user_id) INSERT INTO case_review_user(review_id, user_id)
VALUES ('wx_review_id_4', 'admin') VALUES ('wx_review_id_4', 'admin')