fix:定时插入缺陷修改

This commit is contained in:
wenyann 2021-06-29 15:34:44 +08:00 committed by 刘瑞斌
parent eefac4f738
commit 2804488979
5 changed files with 23 additions and 15 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.job.sechedule; package io.metersphere.job.sechedule;
import com.alibaba.fastjson.JSON;
import com.fit2cloud.quartz.anno.QuartzScheduled; import com.fit2cloud.quartz.anno.QuartzScheduled;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
@ -34,7 +35,7 @@ public class IssuesJob {
try { try {
List<IssuesDao> issues = issuesService.getIssues(l.getCaseId()); List<IssuesDao> issues = issuesService.getIssues(l.getCaseId());
int issuesCount = issues.size(); int issuesCount = issues.size();
testPlanTestCaseService.updateIssues(issuesCount, l.getPlanId(), l.getCaseId(), issues.toString()); testPlanTestCaseService.updateIssues(issuesCount, l.getPlanId(), l.getCaseId(), JSON.toJSONString(issues));
} catch (Exception e) { } catch (Exception e) {
LogUtil.error("定时任务处理bug数量报错planId: " + l.getPlanId(), e); LogUtil.error("定时任务处理bug数量报错planId: " + l.getPlanId(), e);
} }

View File

@ -3,14 +3,14 @@ package io.metersphere.track.issue;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.IssuesMapper; import io.metersphere.base.mapper.IssuesMapper;
import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.TestCaseIssuesMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper;
import io.metersphere.base.mapper.WorkspaceMapper;
import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.EncryptUtils;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.IntegrationRequest; import io.metersphere.controller.request.IntegrationRequest;
import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.dto.CustomFieldItemDTO;
import io.metersphere.dto.UserDTO; import io.metersphere.dto.UserDTO;
@ -51,10 +51,14 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
protected ResourceService resourceService; protected ResourceService resourceService;
protected RestTemplate restTemplateIgnoreSSL; protected RestTemplate restTemplateIgnoreSSL;
protected UserService userService; protected UserService userService;
protected WorkspaceMapper workspaceMapper;
protected ProjectMapper projectMapper;
protected String testCaseId; protected String testCaseId;
protected String projectId; protected String projectId;
protected String key; protected String key;
protected String orgId;
protected String userId;
public String getKey() { public String getKey() {
return key; return key;
@ -90,16 +94,12 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
this.resourceService = CommonBeanFactory.getBean(ResourceService.class); this.resourceService = CommonBeanFactory.getBean(ResourceService.class);
this.testCaseId = issuesRequest.getTestCaseId(); this.testCaseId = issuesRequest.getTestCaseId();
this.projectId = issuesRequest.getProjectId(); this.projectId = issuesRequest.getProjectId();
this.orgId = issuesRequest.getOrganizationId();
this.userId = issuesRequest.getUserId();
this.restTemplateIgnoreSSL = restTemplate; this.restTemplateIgnoreSSL = restTemplate;
} }
protected String getPlatformConfig(String platform) { protected String getPlatformConfig(String platform) {
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
/*
String orgId = "88aceecf-5764-4094-96a9-f82bd52e77ad";
*/
IntegrationRequest request = new IntegrationRequest(); IntegrationRequest request = new IntegrationRequest();
if (StringUtils.isBlank(orgId)) { if (StringUtils.isBlank(orgId)) {
MSException.throwException("organization id is null"); MSException.throwException("organization id is null");

View File

@ -52,7 +52,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
String config = getPlatformConfig(IssuesManagePlatform.Jira.toString()); String config = getPlatformConfig(IssuesManagePlatform.Jira.toString());
if (StringUtils.isNotBlank(config)) { if (StringUtils.isNotBlank(config)) {
jiraConfig = JSONObject.parseObject(config, JiraConfig.class); jiraConfig = JSONObject.parseObject(config, JiraConfig.class);
UserDTO.PlatformInfo userPlatInfo = getUserPlatInfo(orgId, SessionUtils.getUserId()); UserDTO.PlatformInfo userPlatInfo = getUserPlatInfo(orgId, userId);
if (userPlatInfo != null && StringUtils.isNotBlank(userPlatInfo.getJiraAccount()) if (userPlatInfo != null && StringUtils.isNotBlank(userPlatInfo.getJiraAccount())
&& StringUtils.isNotBlank(userPlatInfo.getJiraPassword())) { && StringUtils.isNotBlank(userPlatInfo.getJiraPassword())) {
jiraConfig.setAccount(userPlatInfo.getJiraAccount()); jiraConfig.setAccount(userPlatInfo.getJiraAccount());

View File

@ -14,6 +14,7 @@ public class IssuesRequest extends BaseQueryRequest {
private String projectId; private String projectId;
private String testCaseId; private String testCaseId;
private List<String> tapdUsers; private List<String> tapdUsers;
private String userId;
/** /**
* zentao bug 处理人 * zentao bug 处理人
*/ */

View File

@ -2,10 +2,7 @@ package io.metersphere.track.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.IssueTemplateMapper; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.IssuesMapper;
import io.metersphere.base.mapper.TestCaseIssuesMapper;
import io.metersphere.base.mapper.WorkspaceMapper;
import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper;
import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.IssuesManagePlatform;
import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.NoticeConstants;
@ -71,6 +68,8 @@ public class IssuesService {
private WorkspaceMapper workspaceMapper; private WorkspaceMapper workspaceMapper;
@Resource @Resource
private IssueTemplateService issueTemplateService; private IssueTemplateService issueTemplateService;
@Resource
private TestCaseMapper testCaseMapper;
public void testAuth(String platform) { public void testAuth(String platform) {
AbstractIssuePlatform abstractPlatform = IssueFactory.createPlatform(platform, new IssuesRequest()); AbstractIssuePlatform abstractPlatform = IssueFactory.createPlatform(platform, new IssuesRequest());
@ -139,6 +138,13 @@ public class IssuesService {
issueRequest.setTestCaseId(caseId); issueRequest.setTestCaseId(caseId);
ServiceUtils.getDefaultOrder(issueRequest.getOrders()); ServiceUtils.getDefaultOrder(issueRequest.getOrders());
Project project = getProjectByCaseId(caseId); Project project = getProjectByCaseId(caseId);
String workspaceId = project.getWorkspaceId();
Workspace workspace = workspaceMapper.selectByPrimaryKey(workspaceId);
TestCase testCase = testCaseMapper.selectByPrimaryKey(caseId);
String orgId = workspace.getOrganizationId();
String userId = testCase.getMaintainer();
issueRequest.setOrganizationId(orgId);
issueRequest.setUserId(userId);
return getIssuesByProject(issueRequest, project); return getIssuesByProject(issueRequest, project);
} }