fix(测试计划,测试用例): 后台任务增加错误处理
This commit is contained in:
parent
b32c31e12e
commit
fff4e782e7
|
@ -10,6 +10,7 @@ import io.metersphere.base.domain.TestPlanTestCaseWithBLOBs;
|
|||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.track.service.IssuesService;
|
||||
import io.metersphere.track.service.TestPlanTestCaseService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -26,6 +27,7 @@ public class IssuesJob {
|
|||
@QuartzScheduled(fixedDelay = 3600 * 1000)
|
||||
// @Scheduled(fixedDelay = 120 * 1000)
|
||||
public void issuesCount() {
|
||||
LogUtil.info("测试计划-测试用例同步缺陷信息开始");
|
||||
int pageSize = 100;
|
||||
int pages = 1;
|
||||
for (int i = 0; i < pages; i++) {
|
||||
|
@ -35,13 +37,17 @@ public class IssuesJob {
|
|||
list.forEach(l -> {
|
||||
try {
|
||||
List<IssuesDao> issues = issuesService.getIssues(l.getCaseId());
|
||||
if (CollectionUtils.isEmpty(issues)) {
|
||||
return;
|
||||
}
|
||||
int issuesCount = issues.size();
|
||||
testPlanTestCaseService.updateIssues(issuesCount, l.getPlanId(), l.getCaseId(), JSON.toJSONString(issues));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("定时任务处理bug数量报错planId: " + l.getPlanId(), ExceptionUtils.getStackTrace(e));
|
||||
LogUtil.error("定时任务处理bug数量报错planId: {}, message: {}", l.getPlanId(), ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
});
|
||||
}
|
||||
LogUtil.info("测试计划-测试用例同步缺陷信息开始");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,6 +145,10 @@ public class IssuesService {
|
|||
issueRequest.setTestCaseId(caseId);
|
||||
ServiceUtils.getDefaultOrder(issueRequest.getOrders());
|
||||
Project project = getProjectByCaseId(caseId);
|
||||
// project 不存在
|
||||
if (project == null) {
|
||||
return null;
|
||||
}
|
||||
String workspaceId = project.getWorkspaceId();
|
||||
Workspace workspace = workspaceMapper.selectByPrimaryKey(workspaceId);
|
||||
TestCase testCase = testCaseMapper.selectByPrimaryKey(caseId);
|
||||
|
@ -229,8 +233,11 @@ public class IssuesService {
|
|||
|
||||
private Project getProjectByCaseId(String testCaseId) {
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
Project project = projectService.getProjectById(testCase.getProjectId());
|
||||
return project;
|
||||
// testCase 不存在
|
||||
if (testCase == null) {
|
||||
return null;
|
||||
}
|
||||
return projectService.getProjectById(testCase.getProjectId());
|
||||
}
|
||||
|
||||
private String getTapdProjectId(String testCaseId) {
|
||||
|
|
Loading…
Reference in New Issue