diff --git a/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java b/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java index 75f2c21733..e753620e0c 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java @@ -1,5 +1,6 @@ package io.metersphere.job.sechedule; +import com.alibaba.fastjson.JSON; import com.fit2cloud.quartz.anno.QuartzScheduled; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; @@ -34,7 +35,7 @@ public class IssuesJob { try { List issues = issuesService.getIssues(l.getCaseId()); 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) { LogUtil.error("定时任务处理bug数量报错planId: " + l.getPlanId(), e); } diff --git a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java index c01dfd726d..90950b59a0 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -3,14 +3,14 @@ package io.metersphere.track.issue; import com.alibaba.fastjson.JSONArray; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.IssuesMapper; +import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper; +import io.metersphere.base.mapper.WorkspaceMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.commons.exception.MSException; -import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.LogUtil; -import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.IntegrationRequest; import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.dto.UserDTO; @@ -51,10 +51,14 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { protected ResourceService resourceService; protected RestTemplate restTemplateIgnoreSSL; protected UserService userService; - + protected WorkspaceMapper workspaceMapper; + protected ProjectMapper projectMapper; protected String testCaseId; protected String projectId; protected String key; + protected String orgId; + protected String userId; + public String getKey() { return key; @@ -90,16 +94,12 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { this.resourceService = CommonBeanFactory.getBean(ResourceService.class); this.testCaseId = issuesRequest.getTestCaseId(); this.projectId = issuesRequest.getProjectId(); - + this.orgId = issuesRequest.getOrganizationId(); + this.userId = issuesRequest.getUserId(); this.restTemplateIgnoreSSL = restTemplate; } protected String getPlatformConfig(String platform) { - SessionUser user = SessionUtils.getUser(); - String orgId = user.getLastOrganizationId(); -/* - String orgId = "88aceecf-5764-4094-96a9-f82bd52e77ad"; -*/ IntegrationRequest request = new IntegrationRequest(); if (StringUtils.isBlank(orgId)) { MSException.throwException("organization id is null"); diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index 44094f7ae0..9d7a6aa236 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -52,7 +52,7 @@ public class JiraPlatform extends AbstractIssuePlatform { String config = getPlatformConfig(IssuesManagePlatform.Jira.toString()); if (StringUtils.isNotBlank(config)) { 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()) && StringUtils.isNotBlank(userPlatInfo.getJiraPassword())) { jiraConfig.setAccount(userPlatInfo.getJiraAccount()); diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java index 5235715529..b5aeebe612 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java @@ -14,6 +14,7 @@ public class IssuesRequest extends BaseQueryRequest { private String projectId; private String testCaseId; private List tapdUsers; + private String userId; /** * zentao bug 处理人 */ diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index 3ebc42cf62..1de695db1b 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -2,10 +2,7 @@ package io.metersphere.track.service; import com.alibaba.fastjson.JSON; import io.metersphere.base.domain.*; -import io.metersphere.base.mapper.IssueTemplateMapper; -import io.metersphere.base.mapper.IssuesMapper; -import io.metersphere.base.mapper.TestCaseIssuesMapper; -import io.metersphere.base.mapper.WorkspaceMapper; +import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.NoticeConstants; @@ -71,6 +68,8 @@ public class IssuesService { private WorkspaceMapper workspaceMapper; @Resource private IssueTemplateService issueTemplateService; + @Resource + private TestCaseMapper testCaseMapper; public void testAuth(String platform) { AbstractIssuePlatform abstractPlatform = IssueFactory.createPlatform(platform, new IssuesRequest()); @@ -139,6 +138,13 @@ public class IssuesService { issueRequest.setTestCaseId(caseId); ServiceUtils.getDefaultOrder(issueRequest.getOrders()); 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); }