diff --git a/framework/sdk-parent/frontend/src/i18n/lang/en-US.js b/framework/sdk-parent/frontend/src/i18n/lang/en-US.js index c0563b53f4..835df0e16f 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/en-US.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/en-US.js @@ -6,6 +6,8 @@ const message = { commons: { pre_page: 'Pre page', next_page: 'Next page', + already_pre_page: 'It\'s already page one', + already_next_page: 'It\'s already last page', table_select_row_count: 'Selected {0} Record', header_custom_select_tips: 'Please customize table header by select field', advance_search_total_suffix: 'results', diff --git a/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js b/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js index 835493920e..334932e2d0 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js @@ -6,6 +6,8 @@ const message = { commons: { pre_page: '上一页', next_page: '下一页', + already_pre_page: '已经是第一页', + already_next_page: '已经是最后一页', table_select_row_count: '已选择 {0} 条', header_custom_select_tips: '请选择列表中要展示的信息', advance_search_total_suffix: '个结果', @@ -892,7 +894,7 @@ const message = { code_segment_desc: '自定义代码片段', test_case_custom_id: '测试用例自定义ID', re_review: '重新提审', - re_review_info: '评审中的用例发生变更,用例状态自动切换为重新提审', + re_review_info: '评审活动中的用例发生变更,用例状态自动切换为重新提审', test_case_custom_id_info: '用例ID默认为系统自增ID', scenario_custom_id: '场景自定义ID', scenario_custom_id_info: '场景用例ID默认为系统自增ID', diff --git a/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js b/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js index b4f3c5da01..06e322a490 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js @@ -6,6 +6,8 @@ const message = { commons: { pre_page: '上一頁', next_page: '下一頁', + already_pre_page: '已經是第一頁', + already_next_page: '已經是最後一頁', table_select_row_count: '已選擇 {0} 條', header_custom_select_tips: '請選擇列表中要展示的信息', advance_search_total_suffix: '個結果', @@ -894,7 +896,7 @@ const message = { scenario_custom_id: '場景自定義ID', scenario_custom_id_info: '場景用例ID默認為系統自增ID', re_review: '重新提審', - re_review_info: '評審中的用例發生變更,用例狀態自動切換為重新提審', + re_review_info: '評審活動中的用例發生變更,用例狀態自動切換為重新提審', version: { name: '版本', read: '查看', diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.java b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.java index 8a3aa1d0dd..36b9edbef3 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.java +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.java @@ -11,7 +11,7 @@ public interface ExtTestCaseReviewTestCaseMapper { List getCaseStatusByReviewIds(@Param("reviewIds") List reviewIds); - List selectForRuleChange(@Param("reviewId") String reviewId); + List selectForReviewChange(@Param("reviewId") String reviewId); List selectForReReview(@Param("caseId") String caseId); } diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.xml b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.xml index 9b8ca204e1..3ee518c277 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.xml +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewTestCaseMapper.xml @@ -15,7 +15,7 @@ #{reviewId} - select id, case_id, status, review_id from test_case_review_test_case where review_id = #{reviewId} and (status = 'Pass' or status = 'UnPass' or status = 'Underway'); diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java index e1120c598f..86eff64c60 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java @@ -27,6 +27,7 @@ import io.metersphere.notice.service.NoticeSendService; import io.metersphere.request.member.QueryMemberRequest; import io.metersphere.request.testreview.*; import io.metersphere.utils.ListUtil; +import jakarta.annotation.Resource; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; @@ -39,8 +40,6 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; -import java.lang.reflect.InvocationTargetException; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -220,14 +219,7 @@ public class TestCaseReviewService { public List getUserByReviewId(TestCaseReview request) { String reviewId = request.getId(); - TestCaseReviewUsersExample testCaseReviewUsersExample = new TestCaseReviewUsersExample(); - testCaseReviewUsersExample.createCriteria().andReviewIdEqualTo(reviewId); - List testCaseReviewUsers = testCaseReviewUsersMapper.selectByExample(testCaseReviewUsersExample); - - List userIds = testCaseReviewUsers - .stream() - .map(TestCaseReviewUsers::getUserId) - .collect(Collectors.toList()); + List userIds = getReviewUserIds(reviewId); UserExample userExample = new UserExample(); UserExample.Criteria criteria = userExample.createCriteria(); @@ -314,10 +306,7 @@ public class TestCaseReviewService { List reviewerIds = testCaseReview.getUserIds(); String id = testCaseReview.getId(); - TestCaseReviewUsersExample testCaseReviewUsersExample = new TestCaseReviewUsersExample(); - testCaseReviewUsersExample.createCriteria().andReviewIdEqualTo(id); - List testCaseReviewUsers = testCaseReviewUsersMapper.selectByExample(testCaseReviewUsersExample); - List dbReviewIds = testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList()); + List dbReviewIds = getReviewUserIds(id); reviewerIds.forEach(reviewerId -> { if (!dbReviewIds.contains(reviewerId)) { @@ -332,18 +321,25 @@ public class TestCaseReviewService { example.createCriteria().andReviewIdEqualTo(id).andUserIdNotIn(reviewerIds); testCaseReviewUsersMapper.deleteByExample(example); // 如果修改了评审人,需要覆盖测试用例评审人 - editCaseReviewUser(reviewerIds, dbReviewIds, id); + editCaseReviewUser(testCaseReview, reviewerIds, dbReviewIds, id); } - private void editCaseReviewUser(List reviewerIds, List dbReviewIds, String id) { + private List getReviewUserIds(String reviewId) { + TestCaseReviewUsersExample testCaseReviewUsersExample = new TestCaseReviewUsersExample(); + testCaseReviewUsersExample.createCriteria().andReviewIdEqualTo(reviewId); + List testCaseReviewUsers = testCaseReviewUsersMapper.selectByExample(testCaseReviewUsersExample); + return testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList()); + } + + private void editCaseReviewUser(SaveTestCaseReviewRequest testCaseReview, List reviewerIds, List dbReviewIds, String id) { boolean equalFlag = ListUtil.equalsList(reviewerIds, dbReviewIds); if (!equalFlag) { TestCaseReviewTestCaseUsersExample testCaseReviewTestCaseUsersExample = new TestCaseReviewTestCaseUsersExample(); testCaseReviewTestCaseUsersExample.createCriteria().andReviewIdEqualTo(id); testCaseReviewTestCaseUsersMapper.deleteByExample(testCaseReviewTestCaseUsersExample); - TestCaseReviewTestCaseExample testCaseReviewTestCaseExample = new TestCaseReviewTestCaseExample(); - testCaseReviewTestCaseExample.createCriteria().andReviewIdEqualTo(id); - List testCaseReviewTestCases = testCaseReviewTestCaseMapper.selectByExample(testCaseReviewTestCaseExample); + + List testCaseReviewTestCases = testReviewTestCaseService.selectForReviewChange(id); + if (CollectionUtils.isNotEmpty(testCaseReviewTestCases)) { testCaseReviewTestCases.forEach(review -> { reviewerIds.forEach(userId -> { @@ -355,6 +351,11 @@ public class TestCaseReviewService { }); }); } + + for (TestCaseReviewTestCase reviewTestCase : testCaseReviewTestCases) { + // 重新计算评审状态 + testReviewTestCaseService.reCalcReviewCaseStatus(testCaseReview.getReviewPassRule(), reviewTestCase); + } } } @@ -697,11 +698,8 @@ public class TestCaseReviewService { List columns = ReflexObjectUtil.getColumns(review, TestCaseReviewReference.testCaseReviewColumns); String reviewId = review.getId(); - TestCaseReviewUsersExample testCaseReviewUsersExample = new TestCaseReviewUsersExample(); - testCaseReviewUsersExample.createCriteria().andReviewIdEqualTo(reviewId); - List testCaseReviewUsers = testCaseReviewUsersMapper.selectByExample(testCaseReviewUsersExample); + List userIds = getReviewUserIds(reviewId); - List userIds = testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList()); UserExample example = new UserExample(); example.createCriteria().andIdIn(userIds); List users = userMapper.selectByExample(example); diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java index 7282adf8df..49425354ae 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java @@ -28,13 +28,13 @@ import io.metersphere.request.testreview.QueryCaseReviewRequest; import io.metersphere.request.testreview.TestCaseReviewTestCaseEditRequest; import io.metersphere.utils.ListUtil; import io.metersphere.xpack.version.service.ProjectVersionService; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; import java.util.*; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -466,6 +466,15 @@ public class TestReviewTestCaseService { testCaseReviewTestCaseUsersMapper.insert(insertData); } } + + + // 修改评审人后重新计算用例的评审状态 + TestCaseReview testReview = testCaseReviewService.getTestReview(request.getReviewId()); + List testCaseReviewTestCases = selectForReviewChange(request.getReviewId()); + for (TestCaseReviewTestCase reviewTestCase : testCaseReviewTestCases) { + // 重新计算评审状态 + reCalcReviewCaseStatus(testReview.getReviewPassRule(), reviewTestCase); + } } } @@ -643,13 +652,17 @@ public class TestReviewTestCaseService { } public void handlePassRuleChange(String originPassRule, TestCaseReview review) { - List reviewTestCases = extTestCaseReviewTestCaseMapper.selectForRuleChange(review.getId()); + List reviewTestCases = selectForReviewChange(review.getId()); for (TestCaseReviewTestCase reviewTestCase : reviewTestCases) { // 如果是已经评审过的用例,则重新计算 updateReviewCaseStatusForRuleChange(originPassRule, reviewTestCase, review.getReviewPassRule()); } } + public List selectForReviewChange(String reviewId) { + return extTestCaseReviewTestCaseMapper.selectForReviewChange(reviewId); + } + public void updateReviewCaseStatusForRuleChange(String originPassRule, TestCaseReviewTestCase reviewTestCase, String reviewPassRule) { List comments = testCaseCommentService.getCaseComments(reviewTestCase.getCaseId(), TestCaseCommentType.REVIEW.name(), reviewTestCase.getReviewId()); @@ -672,6 +685,24 @@ public class TestReviewTestCaseService { updateReviewCaseStatus(reviewTestCase, reviewPassRule, comments, handleStatusChangeFunc); } + /** + * 重新计算用例的评审状态 + * @param reviewPassRule + * @param reviewTestCase + */ + public void reCalcReviewCaseStatus(String reviewPassRule, TestCaseReviewTestCase reviewTestCase) { + List comments = + testCaseCommentService.getCaseComments(reviewTestCase.getCaseId(), TestCaseCommentType.REVIEW.name(), reviewTestCase.getReviewId()); + + comments = filterAgainComments(comments); + + if (CollectionUtils.isEmpty(comments)) { + return; + } + + updateReviewCaseStatus(reviewTestCase, reviewPassRule, comments, null); + } + /** * 将已经评审过的用例改成重新提审状态 * @param caseId diff --git a/test-track/frontend/src/business/review/view/components/TestReviewTestCaseEditOperationBar.vue b/test-track/frontend/src/business/review/view/components/TestReviewTestCaseEditOperationBar.vue index d756549d6f..ab15ad61ee 100644 --- a/test-track/frontend/src/business/review/view/components/TestReviewTestCaseEditOperationBar.vue +++ b/test-track/frontend/src/business/review/view/components/TestReviewTestCaseEditOperationBar.vue @@ -32,7 +32,6 @@
{{ $t('commons.next_page') }} @@ -41,7 +40,6 @@
@@ -126,9 +124,17 @@ export default { }, methods: { handlePre() { + if (this.countNum === 1) { + this.$error(this.$t('commons.already_pre_page')); + return; + } this.$emit('pre'); }, handleNext() { + if (this.countNum >= this.total) { + this.$error(this.$t('commons.already_next_page')); + return; + } this.$emit('next'); }, addComment(comment) { diff --git a/test-track/frontend/src/i18n/lang/en-US.js b/test-track/frontend/src/i18n/lang/en-US.js index 40153664c6..1a13cd003b 100644 --- a/test-track/frontend/src/i18n/lang/en-US.js +++ b/test-track/frontend/src/i18n/lang/en-US.js @@ -73,7 +73,7 @@ const message = { review_pass_rule: 'Review Pass Criteria', review_pass_rule_all: 'All Pass', review_pass_rule_single: 'Single Pass', - update_review_reviewer_tip: "Note: Modifying the reviewer will overwrite the reviewers associated with the use case. Please exercise caution!", + update_review_reviewer_tip: "Note: Modifying the reviewer will overwrite the reviewers associated with the use case, and update the review status of the use case, Please exercise caution!", review_rule_tip: "All pass: Pass only if all reviewers pass <\/br> Single pass: Pass if any reviewers pass", update_review_rule_tip: "Note: Modifying the standard will affect the reviewed use cases, please exercise caution!", review_history: "Review History", diff --git a/test-track/frontend/src/i18n/lang/zh-CN.js b/test-track/frontend/src/i18n/lang/zh-CN.js index 7381a6fc67..fb199463f8 100644 --- a/test-track/frontend/src/i18n/lang/zh-CN.js +++ b/test-track/frontend/src/i18n/lang/zh-CN.js @@ -73,7 +73,7 @@ const message = { review_pass_rule: "评审通过标准", review_pass_rule_all: "全部通过", review_pass_rule_single: "单人通过", - update_review_reviewer_tip: "注:修改评审人,会覆盖已关联用例的评审人,请谨慎操作!", + update_review_reviewer_tip: "注:修改评审人,会覆盖已关联用例的评审人,并且更新用例的评审状态,请谨慎操作!", review_rule_tip: "全部通过:所有评审人都通过才通过<\/br>单人通过:任意评审人通过则通过", update_review_rule_tip: "注:修改通过标准会影响已评审过的用例,请谨慎操作!", review_history: "评审历史", diff --git a/test-track/frontend/src/i18n/lang/zh-TW.js b/test-track/frontend/src/i18n/lang/zh-TW.js index 1a3aa6e234..a48c264c2d 100644 --- a/test-track/frontend/src/i18n/lang/zh-TW.js +++ b/test-track/frontend/src/i18n/lang/zh-TW.js @@ -73,7 +73,7 @@ const message = { review_pass_rule: '評審通過標準', review_pass_rule_all: '全部通過', review_pass_rule_single: '單人通過', - update_review_reviewer_tip: "註:修改評審人,會覆蓋已關聯用例的評審人,請謹慎操作!", + update_review_reviewer_tip: "註:修改評審人,會覆蓋已關聯用例的評審人,並且更新用例的評審狀態,請謹慎操作!", review_rule_tip: "全部通過:所有評審人都通過才通過<\/br>單人通過:任意評審人通過則通過", update_review_rule_tip: "註:修改通過標準會影響已評審過的用例,請謹慎操作!", review_history: "評審歷史",