fix(功能用例): 修复每个人评审结果最终结果显示以及导入提示问题

--bug=1044106 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001044106
--bug=1044485 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001044485
This commit is contained in:
guoyuqi 2024-07-25 19:06:28 +08:00 committed by Craftsman
parent d4bb83ff82
commit 09a76cf9b0
7 changed files with 67 additions and 4 deletions

View File

@ -30,7 +30,7 @@ public class FunctionalCaseExcelDataCn extends FunctionalCaseExcelData {
private String name;
@NotBlank(message = "{cannot_be_null}")
@Length(max = 50)
@Length(max = 100)
@ExcelProperty("所属模块")
@ColumnWidth(30)
private String module;

View File

@ -30,7 +30,7 @@ public class FunctionalCaseExcelDataTw extends FunctionalCaseExcelData {
private String name;
@NotBlank(message = "{cannot_be_null}")
@Length(max = 50)
@Length(max = 100)
@ExcelProperty("所屬模塊")
@ColumnWidth(30)
private String module;

View File

@ -30,7 +30,7 @@ public class FunctionalCaseExcelDataUs extends FunctionalCaseExcelData {
private String name;
@NotBlank(message = "{cannot_be_null}")
@Length(max = 50)
@Length(max = 100)
@ExcelProperty("Module")
@ColumnWidth(30)
private String module;

View File

@ -13,6 +13,9 @@ public interface ExtCaseReviewHistoryMapper {
List<CaseReviewHistoryDTO> list(@Param("caseId") String caseId, @Param("reviewId") String reviewId);
List<CaseReviewHistoryDTO> resultList(@Param("caseId") String caseId, @Param("reviewId") String reviewId);
List<CaseReviewHistoryDTO> getHistoryListWidthAbandoned(@Param("caseId") String caseId, @Param("reviewId") String reviewId);
List<CaseReviewHistoryDTO> getHistoryListWidthCaseId(@Param("caseId") String caseId, @Param("reviewId") String reviewId);

View File

@ -25,6 +25,30 @@
and ch.deleted = false
</select>
<select id="resultList" resultType="io.metersphere.functional.dto.CaseReviewHistoryDTO">
SELECT
ch.id,
ch.review_id,
ch.case_id,
ch.status,
ch.notifier,
ch.create_user,
ch.create_time,
ch.content,
u.name as userName,
ux.avatar as userLogo
FROM
case_review_history ch
left join user u on ch.create_user = u.id
left join user_extend ux on ch.create_user = ux.id
where ch.case_id = #{caseId}
<if test="reviewId != null and reviewId != ''">
and ch.review_id = #{reviewId}
</if>
and ch.status != 'UNDER_REVIEWED'
and ch.deleted = false
</select>
<select id="getHistoryListWidthAbandoned" resultType="io.metersphere.functional.dto.CaseReviewHistoryDTO">
SELECT
ch.id,

View File

@ -50,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -803,7 +804,7 @@ public class CaseReviewFunctionalCaseService {
}
public List<OptionDTO> getUserStatus(String reviewId, String caseId) {
List<CaseReviewHistoryDTO> list = extCaseReviewHistoryMapper.list(caseId, reviewId);
List<CaseReviewHistoryDTO> list = extCaseReviewHistoryMapper.resultList(caseId, reviewId);
Map<String, List<CaseReviewHistoryDTO>> collect = list.stream().sorted(Comparator.comparingLong(CaseReviewHistoryDTO::getCreateTime).reversed()).collect(Collectors.groupingBy(CaseReviewHistoryDTO::getCreateUser, Collectors.toList()));
List<OptionDTO> optionDTOS = new ArrayList<>();
List<CaseReviewFunctionalCaseUser> reviewerList = getReviewerList(reviewId, caseId);
@ -814,10 +815,20 @@ public class CaseReviewFunctionalCaseService {
userExample.createCriteria().andIdIn(reviewerIds);
users = userMapper.selectByExample(userExample);
}
AtomicBoolean hasReReview = new AtomicBoolean(false);
final long[] createTime = {0L};
final long[] reReviewTime = {0L};
collect.forEach((k, v) -> {
OptionDTO optionDTO = new OptionDTO();
optionDTO.setId(v.getFirst().getUserName());
optionDTO.setName(v.getFirst().getStatus());
if (createTime[0] < v.getFirst().getCreateTime()) {
createTime[0] = v.getFirst().getCreateTime();
}
if (StringUtils.equalsIgnoreCase(v.getFirst().getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())) {
reReviewTime[0] = v.getFirst().getCreateTime();
hasReReview.set(true);
}
optionDTOS.add(optionDTO);
});
if (CollectionUtils.isNotEmpty(users)) {
@ -828,6 +839,11 @@ public class CaseReviewFunctionalCaseService {
optionDTOS.add(optionDTO);
});
}
if (hasReReview.get() && reReviewTime[0] >= createTime[0]) {
for (OptionDTO optionDTO : optionDTOS) {
optionDTO.setName(FunctionalCaseReviewStatus.RE_REVIEWED.toString());
}
}
return optionDTOS;
}

View File

@ -43,6 +43,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
public static final String GET_CASE_IDS = "/case/review/detail/get-ids/";
public static final String FUNCTIONAL_CASE_LIST_URL = "/functional/case/page";
public static final String REVIEW_CASE_PAGE = "/case/review/detail/page";
@ -591,6 +592,25 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
ReviewerAndStatusDTO reviewerAndStatusDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), ReviewerAndStatusDTO.class);
System.out.println(reviewerAndStatusDTO);
Assertions.assertTrue(CollectionUtils.isNotEmpty(reviewerAndStatusDTO.getReviewerStatus()));
BatchReviewFunctionalCaseRequest request = new BatchReviewFunctionalCaseRequest();
request.setReviewId("wx_review_id_1");
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
request.setStatus(FunctionalCaseReviewStatus.RE_REVIEWED.toString());
request.setSelectAll(false);
request.setSelectIds(List.of("gyq_test_5"));
request.setContent("测试批量评审通过");
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
result = mockMvc.perform(MockMvcRequestBuilders.get(GET_CASE_REVIEWER_AND_STATUS + "/wx_review_id_1/gyq_case_id_5").header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
reviewerAndStatusDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), ReviewerAndStatusDTO.class);
System.out.println(reviewerAndStatusDTO);
Assertions.assertTrue(CollectionUtils.isNotEmpty(reviewerAndStatusDTO.getReviewerStatus()));
}