fix(测试跟踪):用例评审状态显示错误,用例评审状态显示和测试用例评审结果不一致

This commit is contained in:
WangXu10 2023-03-07 11:48:12 +08:00 committed by jianxing
parent 00f7bebc2e
commit ebe086fc0d
8 changed files with 57 additions and 8 deletions

View File

@ -26,4 +26,6 @@ public interface ExtTestCaseReviewMapper {
* @return Review ID * @return Review ID
*/ */
int checkIsHave(@Param("reviewId") String reviewId, @Param("projectIds") Set<String> projectIds); int checkIsHave(@Param("reviewId") String reviewId, @Param("projectIds") Set<String> projectIds);
String selectStatusById(@Param("id") String id);
} }

View File

@ -192,4 +192,13 @@
</foreach> </foreach>
</if>) as temp </if>) as temp
</select> </select>
<select id="selectStatusById" resultType="java.lang.String">
SELECT
`status`
FROM
test_case_review
WHERE
id = #{id}
</select>
</mapper> </mapper>

View File

@ -329,9 +329,12 @@
</select> </select>
<select id="getStatusByReviewId" resultType="java.lang.String"> <select id="getStatusByReviewId" resultType="java.lang.String">
select review_status SELECT
from test_case status
where id in (select case_id from test_case_review_test_case where review_id = #{reviewId}); FROM
test_case_review_test_case
WHERE
review_id = #{reviewId} and is_del = 0;
</select> </select>
<select id="findRelateTestReviewId" resultType="java.lang.String"> <select id="findRelateTestReviewId" resultType="java.lang.String">

View File

@ -104,4 +104,9 @@ public class TestReviewTestCaseController {
testReviewTestCaseService.updateOrder(request); testReviewTestCaseService.updateOrder(request);
} }
@GetMapping("/auto-check/{caseId}")
public void autoCheck(@PathVariable String caseId) {
testReviewTestCaseService.checkStatus(caseId);
}
} }

View File

@ -549,14 +549,16 @@ public class TestCaseReviewService {
} }
public void editTestReviewStatus(String reviewId) { public void editTestReviewStatus(String reviewId) {
String status = extTestCaseReviewMapper.selectStatusById(reviewId);
if (StringUtils.equalsAnyIgnoreCase(status, TestCaseReviewStatus.Completed.name(), TestCaseReviewStatus.Finished.name())){
return;
}
List<String> statusList = extTestReviewCaseMapper.getStatusByReviewId(reviewId); List<String> statusList = extTestReviewCaseMapper.getStatusByReviewId(reviewId);
TestCaseReview testCaseReview = new TestCaseReview(); TestCaseReview testCaseReview = new TestCaseReview();
testCaseReview.setId(reviewId); testCaseReview.setId(reviewId);
if (statusList.contains(TestReviewCaseStatus.Prepare.name()) || statusList.contains(TestReviewCaseStatus.Again.name()) || if (statusList.contains(TestReviewCaseStatus.Underway.name()) || statusList.contains(TestReviewCaseStatus.Again.name()) ) {
statusList.contains(TestReviewCaseStatus.Underway.name()) || statusList.contains(TestReviewCaseStatus.Rereview.name())) {
testCaseReview.setStatus(TestCaseReviewStatus.Underway.name());
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
return; return;
} }
if (statusList.contains(TestReviewCaseStatus.UnPass.name())) { if (statusList.contains(TestReviewCaseStatus.UnPass.name())) {

View File

@ -5,6 +5,7 @@ import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestCaseReviewTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestCaseReviewTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.constants.TestCaseReviewStatus; import io.metersphere.commons.constants.TestCaseReviewStatus;
import io.metersphere.commons.constants.TestPlanStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
@ -747,4 +748,19 @@ public class TestReviewTestCaseService {
public List<TestCaseReviewTestCase> selectForReviewerChange(String reviewId) { public List<TestCaseReviewTestCase> selectForReviewerChange(String reviewId) {
return extTestCaseReviewTestCaseMapper.selectForReviewerChange(reviewId); return extTestCaseReviewTestCaseMapper.selectForReviewerChange(reviewId);
} }
/**
* 检查执行结果自动更新计划状态
* @param caseId
*/
public void checkStatus(String caseId) {
TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(caseId);
if (testCaseReview.getEndTime() != null && testCaseReview.getEndTime() < System.currentTimeMillis()) {
TestCaseReviewExample example = new TestCaseReviewExample();
example.createCriteria().andIdEqualTo(caseId);
TestCaseReview review = new TestCaseReview();
review.setStatus(TestPlanStatus.Finished.name());
testCaseReviewMapper.updateByExampleSelective(review,example);
}
}
} }

View File

@ -272,3 +272,7 @@ export function saveCaseRelevanceLoad(caseId, param) {
export function checkProjectPermission(projectId) { export function checkProjectPermission(projectId) {
return get(BASE_URL + "check/permission/" + projectId); return get(BASE_URL + "check/permission/" + projectId);
} }
export function testCaseAutoCheck(caseId) {
return get(`/test/review/case/auto-check/${caseId}`);
}

View File

@ -195,7 +195,7 @@ import MsTable from "metersphere-frontend/src/components/table/MsTable";
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn"; import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
import MsTableHeaderSelectPopover from "metersphere-frontend/src/components/table/MsTableHeaderSelectPopover"; import MsTableHeaderSelectPopover from "metersphere-frontend/src/components/table/MsTableHeaderSelectPopover";
import HeaderLabelOperate from "metersphere-frontend/src/components/head/HeaderLabelOperate"; import HeaderLabelOperate from "metersphere-frontend/src/components/head/HeaderLabelOperate";
import {editTestReviewTestCaseOrder, getTestReviewTestCase} from "@/api/testCase"; import {editTestReviewTestCaseOrder, getTestReviewTestCase,testCaseAutoCheck} from "@/api/testCase";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token"; import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {hasLicense} from "metersphere-frontend/src/utils/permission"; import {hasLicense} from "metersphere-frontend/src/utils/permission";
import TestCaseReviewStatusTableItem from "@/business/common/tableItems/TestCaseReviewStatusTableItem"; import TestCaseReviewStatusTableItem from "@/business/common/tableItems/TestCaseReviewStatusTableItem";
@ -404,6 +404,7 @@ export default {
this.$refs.headerCustom.open(list); this.$refs.headerCustom.open(list);
}, },
initTableData(callback) { initTableData(callback) {
this.autoCheckStatus();
initCondition(this.condition, this.condition.selectAll); initCondition(this.condition, this.condition.selectAll);
if (this.reviewId) { if (this.reviewId) {
this.condition.reviewId = this.reviewId; this.condition.reviewId = this.reviewId;
@ -435,6 +436,13 @@ export default {
this.getNexPageData(); this.getNexPageData();
} }
}, },
autoCheckStatus() {
//
if (!this.reviewId) {
return;
}
testCaseAutoCheck(this.reviewId);
},
getNexPageData() { getNexPageData() {
getTestReviewTestCase(this.currentPage * this.pageSize + 1, 1, this.condition) getTestReviewTestCase(this.currentPage * this.pageSize + 1, 1, this.condition)
.then((response) => { .then((response) => {