fix: 复制测试计划报错
This commit is contained in:
parent
33cd145d14
commit
fddaebdef6
|
@ -1263,9 +1263,12 @@ public class TestPlanService {
|
|||
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
|
||||
testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(sourcePlanId);
|
||||
List<TestPlanTestCase> testPlanTestCases = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample);
|
||||
|
||||
try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH)) {
|
||||
TestPlanTestCaseMapper testCaseMapper = sqlSession.getMapper(TestPlanTestCaseMapper.class);
|
||||
testPlanTestCases.forEach(testCase -> {
|
||||
if (!CollectionUtils.isEmpty(testPlanTestCases)) {
|
||||
Long nextTestCaseOrder = ServiceUtils.getNextOrder(targetPlanId, extTestPlanTestCaseMapper::getLastOrder);
|
||||
for (TestPlanTestCase testCase : testPlanTestCases) {
|
||||
TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs();
|
||||
testPlanTestCase.setId(UUID.randomUUID().toString());
|
||||
testPlanTestCase.setPlanId(targetPlanId);
|
||||
|
@ -1276,15 +1279,20 @@ public class TestPlanService {
|
|||
testPlanTestCase.setUpdateTime(System.currentTimeMillis());
|
||||
testPlanTestCase.setCreateUser(SessionUtils.getUserId());
|
||||
testPlanTestCase.setRemark(testCase.getRemark());
|
||||
testPlanTestCase.setOrder(nextTestCaseOrder);
|
||||
nextTestCaseOrder += 5000;
|
||||
testCaseMapper.insert(testPlanTestCase);
|
||||
});
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
|
||||
TestPlanApiCaseExample testPlanApiCaseExample = new TestPlanApiCaseExample();
|
||||
testPlanApiCaseExample.createCriteria().andTestPlanIdEqualTo(sourcePlanId);
|
||||
List<TestPlanApiCase> testPlanApiCases = testPlanApiCaseMapper.selectByExample(testPlanApiCaseExample);
|
||||
TestPlanApiCaseMapper apiCaseMapper = sqlSession.getMapper(TestPlanApiCaseMapper.class);
|
||||
testPlanApiCases.forEach(apiCase -> {
|
||||
if (!CollectionUtils.isEmpty(testPlanApiCases)) {
|
||||
Long nextApiOrder = ServiceUtils.getNextOrder(targetPlanId, extTestPlanApiCaseMapper::getLastOrder);
|
||||
for (TestPlanApiCase apiCase : testPlanApiCases) {
|
||||
TestPlanApiCase api = new TestPlanApiCase();
|
||||
api.setId(UUID.randomUUID().toString());
|
||||
api.setTestPlanId(targetPlanId);
|
||||
|
@ -1293,15 +1301,20 @@ public class TestPlanService {
|
|||
api.setCreateTime(System.currentTimeMillis());
|
||||
api.setUpdateTime(System.currentTimeMillis());
|
||||
api.setCreateUser(SessionUtils.getUserId());
|
||||
api.setOrder(nextApiOrder);
|
||||
nextApiOrder += 5000;
|
||||
apiCaseMapper.insert(api);
|
||||
});
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
|
||||
TestPlanApiScenarioExample testPlanApiScenarioExample = new TestPlanApiScenarioExample();
|
||||
testPlanApiScenarioExample.createCriteria().andTestPlanIdEqualTo(sourcePlanId);
|
||||
List<TestPlanApiScenario> apiScenarios = testPlanApiScenarioMapper.selectByExampleWithBLOBs(testPlanApiScenarioExample);
|
||||
TestPlanApiScenarioMapper apiScenarioMapper = sqlSession.getMapper(TestPlanApiScenarioMapper.class);
|
||||
apiScenarios.forEach(apiScenario -> {
|
||||
if (!CollectionUtils.isEmpty(apiScenarios)) {
|
||||
Long nextScenarioOrder = ServiceUtils.getNextOrder(targetPlanId, extTestPlanScenarioCaseMapper::getLastOrder);
|
||||
for (TestPlanApiScenario apiScenario : apiScenarios) {
|
||||
TestPlanApiScenario planScenario = new TestPlanApiScenario();
|
||||
planScenario.setId(UUID.randomUUID().toString());
|
||||
planScenario.setTestPlanId(targetPlanId);
|
||||
|
@ -1310,15 +1323,20 @@ public class TestPlanService {
|
|||
planScenario.setCreateTime(System.currentTimeMillis());
|
||||
planScenario.setUpdateTime(System.currentTimeMillis());
|
||||
planScenario.setCreateUser(SessionUtils.getUserId());
|
||||
planScenario.setOrder(nextScenarioOrder);
|
||||
nextScenarioOrder += 5000;
|
||||
apiScenarioMapper.insert(planScenario);
|
||||
});
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
|
||||
TestPlanLoadCaseExample example = new TestPlanLoadCaseExample();
|
||||
example.createCriteria().andTestPlanIdEqualTo(sourcePlanId);
|
||||
List<TestPlanLoadCase> loadCases = testPlanLoadCaseMapper.selectByExample(example);
|
||||
TestPlanLoadCaseMapper mapper = sqlSession.getMapper(TestPlanLoadCaseMapper.class);
|
||||
loadCases.forEach(loadCase -> {
|
||||
if (!CollectionUtils.isEmpty(loadCases)) {
|
||||
Long nextLoadOrder = ServiceUtils.getNextOrder(targetPlanId, extTestPlanLoadCaseMapper::getLastOrder);
|
||||
for (TestPlanLoadCase loadCase : loadCases) {
|
||||
TestPlanLoadCase load = new TestPlanLoadCase();
|
||||
load.setId(UUID.randomUUID().toString());
|
||||
load.setTestPlanId(targetPlanId);
|
||||
|
@ -1326,8 +1344,11 @@ public class TestPlanService {
|
|||
load.setCreateTime(System.currentTimeMillis());
|
||||
load.setUpdateTime(System.currentTimeMillis());
|
||||
load.setCreateUser(SessionUtils.getUserId());
|
||||
load.setOrder(nextLoadOrder);
|
||||
mapper.insert(load);
|
||||
});
|
||||
nextLoadOrder += 5000;
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue