fix(测试跟踪): 测试计划批量执行功能用例后,功能用例没有对应的变更记录
--bug=1028162 --user=陈建星 【测试跟踪】测试计划关联功能用例-批量编辑执行结果-功能用例变更记录没内容 https://www.tapd.cn/55049933/s/1398419
This commit is contained in:
parent
9e9369d716
commit
3e80901b0e
|
@ -170,4 +170,6 @@ public interface ExtTestCaseMapper {
|
||||||
void clearLatestVersion(@Param("refId") String refId);
|
void clearLatestVersion(@Param("refId") String refId);
|
||||||
|
|
||||||
List<TestCaseTest> getTestCaseRelateList(@Param("testCaseId") String testCaseId);
|
List<TestCaseTest> getTestCaseRelateList(@Param("testCaseId") String testCaseId);
|
||||||
|
|
||||||
|
List<TestCase> getTestCaseForLastResultLog(@Param("ids") List<String> ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1469,7 +1469,14 @@
|
||||||
SET latest = 0
|
SET latest = 0
|
||||||
where ref_id = #{refId}
|
where ref_id = #{refId}
|
||||||
</update>
|
</update>
|
||||||
|
<select id="getTestCaseForLastResultLog" resultType="io.metersphere.base.domain.TestCase">
|
||||||
|
select tc.id, tc.name, tc.last_execute_result
|
||||||
|
from test_case tc where tc.id in
|
||||||
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
and (tc.status is null or tc.status != 'Trash')
|
||||||
|
</select>
|
||||||
<select id="getTestCaseRelateList" resultType="io.metersphere.base.domain.TestCaseTest" parameterType="java.lang.String">
|
<select id="getTestCaseRelateList" resultType="io.metersphere.base.domain.TestCaseTest" parameterType="java.lang.String">
|
||||||
SELECT
|
SELECT
|
||||||
test_case_test.test_case_id as testCaseId,
|
test_case_test.test_case_id as testCaseId,
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class TestPlanTestCaseController {
|
||||||
|
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
|
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
|
||||||
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanTestCase.id)", content = "#msClass.getLogDetails(#testPlanTestCase.id)", msClass = TestPlanTestCaseService.class)
|
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanTestCase.id)", content = "#msClass.getLogDetails(#testPlanTestCase.id)", msClass = TestPlanTestCaseService.class)
|
||||||
public void editTestCase(@RequestBody TestPlanFuncCaseEditRequest testPlanTestCase) {
|
public void editTestCase(@RequestBody TestPlanFuncCaseEditRequest testPlanTestCase) {
|
||||||
testPlanTestCaseService.editTestCase(testPlanTestCase);
|
testPlanTestCaseService.editTestCase(testPlanTestCase);
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,7 +481,6 @@ public class TestPlanTestCaseService {
|
||||||
TestPlanTestCaseWithBLOBs planTestCaseWithBLOBs = testPlanTestCaseMapper.selectByPrimaryKey(id);
|
TestPlanTestCaseWithBLOBs planTestCaseWithBLOBs = testPlanTestCaseMapper.selectByPrimaryKey(id);
|
||||||
if (planTestCaseWithBLOBs != null) {
|
if (planTestCaseWithBLOBs != null) {
|
||||||
TestCase testCase = testCaseMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getCaseId());
|
TestCase testCase = testCaseMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getCaseId());
|
||||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getPlanId());
|
|
||||||
List<DetailColumn> columns = new LinkedList<>();
|
List<DetailColumn> columns = new LinkedList<>();
|
||||||
DetailColumn executeStatusColumn = new DetailColumn("状态", "lastExecuteResult", StatusReference.statusMap.get(testCase.getLastExecuteResult()), null);
|
DetailColumn executeStatusColumn = new DetailColumn("状态", "lastExecuteResult", StatusReference.statusMap.get(testCase.getLastExecuteResult()), null);
|
||||||
columns.add(executeStatusColumn);
|
columns.add(executeStatusColumn);
|
||||||
|
|
|
@ -27,9 +27,11 @@ import io.metersphere.excel.listener.TestCasePretreatmentListener;
|
||||||
import io.metersphere.excel.utils.EasyExcelExporter;
|
import io.metersphere.excel.utils.EasyExcelExporter;
|
||||||
import io.metersphere.excel.utils.ExcelImportType;
|
import io.metersphere.excel.utils.ExcelImportType;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
|
import io.metersphere.log.service.OperatingLogService;
|
||||||
import io.metersphere.log.utils.ReflexObjectUtil;
|
import io.metersphere.log.utils.ReflexObjectUtil;
|
||||||
import io.metersphere.log.vo.DetailColumn;
|
import io.metersphere.log.vo.DetailColumn;
|
||||||
import io.metersphere.log.vo.OperatingLogDetails;
|
import io.metersphere.log.vo.OperatingLogDetails;
|
||||||
|
import io.metersphere.log.vo.StatusReference;
|
||||||
import io.metersphere.log.vo.track.TestCaseReference;
|
import io.metersphere.log.vo.track.TestCaseReference;
|
||||||
import io.metersphere.plan.service.TestPlanService;
|
import io.metersphere.plan.service.TestPlanService;
|
||||||
import io.metersphere.plan.service.TestPlanTestCaseService;
|
import io.metersphere.plan.service.TestPlanTestCaseService;
|
||||||
|
@ -190,6 +192,8 @@ public class TestCaseService {
|
||||||
private ExtTestAnalysisMapper extTestAnalysisMapper;
|
private ExtTestAnalysisMapper extTestAnalysisMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PlatformPluginService platformPluginService;
|
private PlatformPluginService platformPluginService;
|
||||||
|
@Resource
|
||||||
|
private OperatingLogService operatingLogService;
|
||||||
|
|
||||||
private ThreadLocal<Integer> importCreateNum = new ThreadLocal<>();
|
private ThreadLocal<Integer> importCreateNum = new ThreadLocal<>();
|
||||||
|
|
||||||
|
@ -268,6 +272,7 @@ public class TestCaseService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用例变更时,调用插件的需求变更的方法
|
* 用例变更时,调用插件的需求变更的方法
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param type
|
* @param type
|
||||||
* @param project
|
* @param project
|
||||||
|
@ -3001,6 +3006,7 @@ public class TestCaseService {
|
||||||
|
|
||||||
public void updateLastExecuteStatus(List<String> ids, String status) {
|
public void updateLastExecuteStatus(List<String> ids, String status) {
|
||||||
if (CollectionUtils.isNotEmpty(ids) && StringUtils.isNotBlank(status)) {
|
if (CollectionUtils.isNotEmpty(ids) && StringUtils.isNotBlank(status)) {
|
||||||
|
addBatchLastExecuteResultChangeLog(ids, status);
|
||||||
TestCaseExample example = new TestCaseExample();
|
TestCaseExample example = new TestCaseExample();
|
||||||
example.createCriteria().andIdIn(ids);
|
example.createCriteria().andIdIn(ids);
|
||||||
TestCaseWithBLOBs testCase = new TestCaseWithBLOBs();
|
TestCaseWithBLOBs testCase = new TestCaseWithBLOBs();
|
||||||
|
@ -3009,6 +3015,42 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试计划功能用例页面和脑图页面批量修改执行结果时记录下操作日志,用例的变更日志需要查看
|
||||||
|
* @param ids
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
public void addBatchLastExecuteResultChangeLog(List<String> ids, String status) {
|
||||||
|
TestCaseExample testCaseExample = new TestCaseExample();
|
||||||
|
testCaseExample.createCriteria().andIdIn(ids);
|
||||||
|
List<TestCase> testCases = extTestCaseMapper.getTestCaseForLastResultLog(ids);
|
||||||
|
testCases.forEach(testCase -> {
|
||||||
|
try {
|
||||||
|
OperatingLogWithBLOBs log = new OperatingLogWithBLOBs();
|
||||||
|
log.setOperTitle(testCase.getName());
|
||||||
|
log.setOperContent(testCase.getName());
|
||||||
|
log.setId(UUID.randomUUID().toString());
|
||||||
|
log.setOperType(OperLogConstants.UPDATE.name());
|
||||||
|
log.setOperModule(OperLogModule.TRACK_TEST_PLAN);
|
||||||
|
log.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
|
List<DetailColumn> columns = new LinkedList<>();
|
||||||
|
DetailColumn executeStatusColumn = new DetailColumn("状态", "lastExecuteResult",
|
||||||
|
StatusReference.statusMap.get(testCase.getLastExecuteResult()), StatusReference.statusMap.get(status));
|
||||||
|
columns.add(executeStatusColumn);
|
||||||
|
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(testCase.getId()), testCase.getProjectId(), testCase.getName(),
|
||||||
|
SessionUtils.getUserId(), columns);
|
||||||
|
log.setOperContent(JSON.toJSONString(details));
|
||||||
|
log.setOperTime(System.currentTimeMillis());
|
||||||
|
log.setCreateUser(SessionUtils.getUserId());
|
||||||
|
log.setOperUser(SessionUtils.getUserId());
|
||||||
|
log.setSourceId(testCase.getId());
|
||||||
|
operatingLogService.create(log, log.getSourceId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void updateLastExecuteStatus(String id, String status) {
|
public void updateLastExecuteStatus(String id, String status) {
|
||||||
if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(status)) {
|
if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(status)) {
|
||||||
this.updateLastExecuteStatus(Arrays.asList(id), status);
|
this.updateLastExecuteStatus(Arrays.asList(id), status);
|
||||||
|
|
Loading…
Reference in New Issue