fix(测试计划): 修复归档模式下测试计划状态自动统计算法的缺陷

--bug=1042760 --user=宋天阳 【测试计划】计划组列表-删除已归档子计划-计划组状态更新为未开始 https://www.tapd.cn/55049933/s/1533068
This commit is contained in:
Jianguo-Genius 2024-06-20 17:54:36 +08:00 committed by Craftsman
parent 89915f4064
commit 363b668b05
5 changed files with 31 additions and 16 deletions

View File

@ -154,7 +154,8 @@ public class OperationLogModule {
public static final String BUG_MANAGEMENT_RECYCLE = "BUG_MANAGEMENT_BUG_RECYCLE";
//测试计划
public static final String TEST_PLAN = "TEST_PLAN";
public static final String TEST_PLAN_INDEX = "TEST_PLAN_INDEX";
public static final String TEST_PLAN_TEST_PLAN = "TEST_PLAN_PLAN";
public static final String TEST_PLAN_TEST_PLAN_GROUP = "TEST_PLAN_GROUP";
public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE";
public static final String TEST_PLAN_REPORT = "TEST_PLAN_REPORT_TEST_PLAN";
public static final String TEST_PLAN_GROUP_REPORT = "TEST_PLAN_REPORT_TEST_PLAN_GROUP";

View File

@ -53,6 +53,12 @@
and tpc.test_plan_id = #{testPlanId}
</select>
<select id="selectDefaultCollectionId" resultType="java.lang.String">
SELECT id FROM test_plan_collection WHERE test_plan_id = #{testPlanId} AND parent_id!='NONE' and type = #{type}
SELECT id
FROM test_plan_collection
WHERE test_plan_id = #{testPlanId}
AND parent_id != 'NONE'
and type = #{type}
ORDER BY pos
limit 1
</select>
</mapper>

View File

@ -170,7 +170,7 @@ public class TestPlanBatchOperationService extends TestPlanBaseUtilsService {
throw new MSException(Translator.get("test_plan.group.error"));
}
pos = testPlanGroupService.getNextOrder(targetId);
moduleId = group.getId();
moduleId = group.getModuleId();
}
groupId = targetId;
} else {

View File

@ -7,6 +7,7 @@ import io.metersphere.plan.mapper.TestPlanMapper;
import io.metersphere.project.domain.Project;
import io.metersphere.project.mapper.ProjectMapper;
import io.metersphere.sdk.constants.HttpMethodConstants;
import io.metersphere.sdk.constants.TestPlanConstants;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.dto.LogInsertModule;
@ -30,7 +31,6 @@ import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class)
public class TestPlanLogService {
private String logModule = OperationLogModule.TEST_PLAN_INDEX;
@Resource
private ProjectMapper projectMapper;
@ -46,7 +46,7 @@ public class TestPlanLogService {
.projectId(project.getId())
.organizationId(project.getOrganizationId())
.type(OperationLogType.UPDATE.name())
.module(logModule)
.module(getLogModule(testPlan))
.sourceId(testPlan.getId())
.content(Translator.get("test_plan_schedule") + ":" + testPlan.getName())
.build().getLogDTO();
@ -67,7 +67,7 @@ public class TestPlanLogService {
.projectId(module.getProjectId())
.organizationId(project.getOrganizationId())
.type(OperationLogType.ADD.name())
.module(logModule)
.module(getLogModule(module))
.method(requestMethod)
.path(requestUrl)
.sourceId(module.getId())
@ -94,7 +94,7 @@ public class TestPlanLogService {
.projectId(projectId)
.organizationId(project.getOrganizationId())
.type(OperationLogType.UPDATE.name())
.module(logModule)
.module(getLogModule(newTestPlan))
.method(requestMethod)
.path(requestUrl)
.sourceId(newTestPlan.getId())
@ -120,7 +120,7 @@ public class TestPlanLogService {
.projectId(deleteTestPlan.getProjectId())
.organizationId(project.getOrganizationId())
.type(OperationLogType.DELETE.name())
.module(logModule)
.module(getLogModule(deleteTestPlan))
.method(requestMethod)
.path(requestUrl)
.sourceId(deleteTestPlan.getId())
@ -145,7 +145,7 @@ public class TestPlanLogService {
testPlan.getId(),
null,
OperationLogType.ARCHIVED.name(),
logModule,
getLogModule(testPlan),
testPlan.getName());
dto.setPath("/test-plan/archived");
dto.setMethod(HttpMethodConstants.GET.name());
@ -164,8 +164,8 @@ public class TestPlanLogService {
project.getOrganizationId(),
testPlan.getId(),
operator,
OperationLogType.COPY.name(),
logModule,
OperationLogType.ADD.name(),
getLogModule(testPlan),
testPlan.getName());
dto.setPath("/test-plan/copy");
dto.setMethod(HttpMethodConstants.POST.name());
@ -192,7 +192,7 @@ public class TestPlanLogService {
.projectId(plan.getProjectId())
.organizationId(project.getOrganizationId())
.type(requestType)
.module(logModule)
.module(getLogModule(plan))
.method(requestMethod)
.path(requestUrl)
.sourceId(plan.getId())
@ -228,7 +228,7 @@ public class TestPlanLogService {
testPlan.getId(),
null,
OperationLogType.UPDATE.name(),
logModule,
getLogModule(testPlan),
testPlan.getName());
dto.setPath("/test-plan/batch-edit");
dto.setMethod(HttpMethodConstants.POST.name());
@ -246,7 +246,7 @@ public class TestPlanLogService {
.projectId(testPlan.getProjectId())
.organizationId(project.getOrganizationId())
.type(OperationLogType.UPDATE.name())
.module(logModule)
.module(getLogModule(testPlan))
.method(logInsertModule.getRequestMethod())
.path(logInsertModule.getRequestUrl())
.sourceId(moveId)
@ -256,4 +256,11 @@ public class TestPlanLogService {
operationLogService.add(dto);
}
private String getLogModule(TestPlan testPlan) {
if (StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_TYPE_PLAN)) {
return OperationLogModule.TEST_PLAN_TEST_PLAN;
} else {
return OperationLogModule.TEST_PLAN_TEST_PLAN_GROUP;
}
}
}

View File

@ -840,10 +840,11 @@ public class TestPlanService extends TestPlanBaseUtilsService {
groupStatus = TestPlanConstants.TEST_PLAN_STATUS_UNDERWAY;
}
}
TestPlanExample testPlanExample = new TestPlanExample();
testPlanExample.createCriteria().andIdEqualTo(testPlanGroupId).andStatusNotEqualTo(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED);
TestPlan updateGroupPlan = new TestPlan();
updateGroupPlan.setId(testPlanGroupId);
updateGroupPlan.setStatus(groupStatus);
testPlanMapper.updateByPrimaryKeySelective(updateGroupPlan);
testPlanMapper.updateByExampleSelective(updateGroupPlan, testPlanExample);
if (StringUtils.equalsIgnoreCase(updateGroupPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_COMPLETED)) {
extTestPlanMapper.setActualEndTime(testPlanGroupId, System.currentTimeMillis());
}