fix: 非企业版勾选使用jira模板点同步缺陷会报错

This commit is contained in:
chenjianxing 2022-01-12 10:59:13 +08:00
parent ef93c1ee92
commit bf5e92d34f
7 changed files with 42 additions and 14 deletions

View File

@ -512,6 +512,16 @@ public class ProjectService {
return project;
}
public boolean isThirdPartTemplate(String projectId) {
Project project = getProjectById(projectId);
if (project.getThirdPartTemplate() != null && project.getThirdPartTemplate()
&& project.getPlatform().equals(IssuesManagePlatform.Jira.name())) {
return true;
}
return false;
}
public boolean useCustomNum(String projectId) {
Project project = this.getProjectById(projectId);
if (project != null) {

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.constants.CustomFieldType;
import io.metersphere.commons.constants.IssuesManagePlatform;
import io.metersphere.commons.constants.IssuesStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.CustomFieldItemDTO;
@ -21,6 +22,7 @@ import io.metersphere.track.issue.domain.PlatformUser;
import io.metersphere.track.issue.domain.jira.*;
import io.metersphere.track.request.testcase.IssuesRequest;
import io.metersphere.track.request.testcase.IssuesUpdateRequest;
import io.metersphere.track.service.IssuesService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.commonmark.node.Node;
@ -297,7 +299,13 @@ public class JiraPlatform extends AbstractIssuePlatform {
@Override
public void syncIssues(Project project, List<IssuesDao> issues) {
isThirdPartTemplate = isThirdPartTemplate();
super.isThirdPartTemplate = isThirdPartTemplate();
IssuesService issuesService = CommonBeanFactory.getBean(IssuesService.class);
if (project.getThirdPartTemplate()) {
super.defaultCustomFields = issuesService.getCustomFieldsValuesString(getThirdPartTemplate().getCustomFields());
}
issues.forEach(item -> {
try {
IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(item.getId());

View File

@ -442,8 +442,10 @@ public class IssuesService {
IssuesRequest issuesRequest = new IssuesRequest();
issuesRequest.setProjectId(projectId);
issuesRequest.setWorkspaceId(project.getWorkspaceId());
if (!projectService.isThirdPartTemplate(projectId)) {
String defaultCustomFields = getDefaultCustomFields(projectId);
issuesRequest.setDefaultCustomFields(defaultCustomFields);
}
if (CollectionUtils.isNotEmpty(tapdIssues)) {
TapdPlatform tapdPlatform = new TapdPlatform(issuesRequest);
@ -471,6 +473,7 @@ public class IssuesService {
}
}
/**
* 获取默认的自定义字段的取值同步之后更新成第三方平台的值
*

View File

@ -185,6 +185,8 @@ public class TestPlanService {
private ApiTestCaseService apiTestCaseService;
@Resource
private LoadTestMapper loadTestMapper;
@Resource
private ProjectService projectService;
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
if (getTestPlanByName(testPlan.getName()).size() > 0) {
@ -1827,7 +1829,6 @@ public class TestPlanService {
report.setEndTime(testPlan.getActualEndTime());
report.setSummary(testPlan.getReportSummary());
report.setConfig(testPlan.getReportConfig());
IssueTemplateDao template = issueTemplateService.getTemplate(testPlan.getProjectId());
testPlanTestCaseService.calculatePlanReport(planId, report);
issuesService.calculatePlanReport(planId, report);
if (testPlanExecuteReportDTO == null) {
@ -1858,7 +1859,8 @@ public class TestPlanService {
}
report.setName(testPlan.getName());
if (template == null || template.getPlatform().equals("metersphere")) {
Project project = projectService.getProjectById(testPlan.getProjectId());
if (project.getPlatform() != null && project.getPlatform().equals(IssuesManagePlatform.Local.name())) {
report.setIsThirdPartIssue(false);
} else {
report.setIsThirdPartIssue(true);

@ -1 +1 @@
Subproject commit ceffcd883aa519d3f7bfb2641337abaaae4c9295
Subproject commit b0ec4c9d288471d2d9653ca5202ad067c3b380f2

View File

@ -225,6 +225,8 @@ export default {
},
},
activated() {
this.page.result.loading = true;
this.$nextTick(() => {
//
window.addEventListener('resize', this.tableDoLayout);
getProjectMember((data) => {
@ -232,8 +234,10 @@ export default {
});
getIssuePartTemplateWithProject((template) => {
this.initFields(template);
this.page.result.loading = false;
});
this.getIssues();
});
},
computed: {
platformFilters() {

View File

@ -227,6 +227,7 @@ export function getPageInfo(condition) {
result: {},
data: [],
condition: condition ? condition : {},
loading: false
}
}