fix:2.测试计划关联完缺陷,缺陷数量没更新,图2 (#4468)
* fix:2.测试计划关联完缺陷,缺陷数量没更新,图2 * fix:删掉无用引入 Co-authored-by: wenyann <wenyan.yang@fit2cloud.com>
This commit is contained in:
parent
8e3a07a142
commit
02fafbd49b
|
@ -481,10 +481,15 @@
|
||||||
issues_count=#{count},
|
issues_count=#{count},
|
||||||
issues = #{issues}
|
issues = #{issues}
|
||||||
</set>
|
</set>
|
||||||
|
where
|
||||||
|
case_id=#{caseId,jdbcType=VARCHAR}
|
||||||
|
<if test="id != null and id != ''">
|
||||||
|
and plan_id=#{id,jdbcType=VARCHAR}
|
||||||
|
</if>
|
||||||
|
|
||||||
where plan_id=#{id,jdbcType=VARCHAR} and case_id=#{caseId,jdbcType=VARCHAR}
|
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<delete id="deleteByTestCaseID" parameterType="java.lang.String">
|
<delete id="deleteByTestCaseID" parameterType="java.lang.String">
|
||||||
delete
|
delete
|
||||||
from test_plan_api_case
|
from test_plan_api_case
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
|
||||||
|
|
||||||
initOperate(apiAutomationService::checkApiScenarioUseUrl, "init.scenario.url");
|
initOperate(apiAutomationService::checkApiScenarioUseUrl, "init.scenario.url");
|
||||||
initOperate(issuesService::syncThirdPartyIssues, "init.issue");
|
initOperate(issuesService::syncThirdPartyIssues, "init.issue");
|
||||||
|
initOperate(issuesService::issuesCount, "init.issueCount");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1 * 60 * 1000);
|
Thread.sleep(1 * 60 * 1000);
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
package io.metersphere.track.controller;
|
package io.metersphere.track.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import io.metersphere.base.domain.IssuesDao;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
||||||
import io.metersphere.commons.constants.OperLogConstants;
|
import io.metersphere.commons.constants.OperLogConstants;
|
||||||
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.log.annotation.MsAuditLog;
|
import io.metersphere.log.annotation.MsAuditLog;
|
||||||
import io.metersphere.track.dto.TestCaseDTO;
|
import io.metersphere.track.dto.TestCaseDTO;
|
||||||
import io.metersphere.track.request.issues.IssuesRelevanceRequest;
|
import io.metersphere.track.request.issues.IssuesRelevanceRequest;
|
||||||
|
import io.metersphere.track.service.IssuesService;
|
||||||
import io.metersphere.track.service.TestCaseIssueService;
|
import io.metersphere.track.service.TestCaseIssueService;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -19,6 +25,10 @@ public class TestCaseIssuesController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestCaseIssueService testCaseIssueService;
|
private TestCaseIssueService testCaseIssueService;
|
||||||
|
@Resource
|
||||||
|
private IssuesService issuesService;
|
||||||
|
@Resource
|
||||||
|
private ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public List<TestCaseDTO> list(@RequestBody IssuesRelevanceRequest request) {
|
public List<TestCaseDTO> list(@RequestBody IssuesRelevanceRequest request) {
|
||||||
|
@ -29,5 +39,19 @@ public class TestCaseIssuesController {
|
||||||
@MsAuditLog(module = "track_test_case", type = OperLogConstants.ASSOCIATE_ISSUE, content = "#msClass.getLogDetails(#request)", msClass = TestCaseIssueService.class)
|
@MsAuditLog(module = "track_test_case", type = OperLogConstants.ASSOCIATE_ISSUE, content = "#msClass.getLogDetails(#request)", msClass = TestCaseIssueService.class)
|
||||||
public void relate(@RequestBody IssuesRelevanceRequest request) {
|
public void relate(@RequestBody IssuesRelevanceRequest request) {
|
||||||
testCaseIssueService.relate(request);
|
testCaseIssueService.relate(request);
|
||||||
|
try {
|
||||||
|
List<IssuesDao> issues = issuesService.getIssues(request.getCaseId());
|
||||||
|
if (org.apache.commons.collections4.CollectionUtils.isEmpty(issues)) {
|
||||||
|
LogUtil.error(request.getCaseId() + "下的缺陷为空");
|
||||||
|
}
|
||||||
|
int issuesCount = issues.size();
|
||||||
|
this.updateIssues(issuesCount, "", request.getCaseId(), JSON.toJSONString(issues));
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error("处理bug数量报错caseId: {}, message: {}", request.getCaseId(), ExceptionUtils.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateIssues(int issuesCount, String id, String caseId, String issues) {
|
||||||
|
extTestPlanTestCaseMapper.update(issuesCount, id, caseId, issues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package io.metersphere.track.service;
|
package io.metersphere.track.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.ExtIssuesMapper;
|
import io.metersphere.base.mapper.ext.ExtIssuesMapper;
|
||||||
|
@ -32,6 +34,7 @@ import io.metersphere.track.request.testcase.IssuesRequest;
|
||||||
import io.metersphere.track.request.testcase.IssuesUpdateRequest;
|
import io.metersphere.track.request.testcase.IssuesUpdateRequest;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -75,6 +78,8 @@ public class IssuesService {
|
||||||
private TestCaseMapper testCaseMapper;
|
private TestCaseMapper testCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private SystemParameterService systemParameterService;
|
private SystemParameterService systemParameterService;
|
||||||
|
@Resource
|
||||||
|
private TestPlanTestCaseService testPlanTestCaseService;
|
||||||
|
|
||||||
public void testAuth(String orgId, String platform) {
|
public void testAuth(String orgId, String platform) {
|
||||||
IssuesRequest issuesRequest = new IssuesRequest();
|
IssuesRequest issuesRequest = new IssuesRequest();
|
||||||
|
@ -88,6 +93,18 @@ public class IssuesService {
|
||||||
platformList.forEach(platform -> {
|
platformList.forEach(platform -> {
|
||||||
platform.addIssue(issuesRequest);
|
platform.addIssue(issuesRequest);
|
||||||
});
|
});
|
||||||
|
issuesRequest.getTestCaseIds().forEach(l -> {
|
||||||
|
try {
|
||||||
|
List<IssuesDao> issues = this.getIssues(l);
|
||||||
|
if (org.apache.commons.collections4.CollectionUtils.isEmpty(issues)) {
|
||||||
|
LogUtil.error(l + "下的缺陷为空");
|
||||||
|
}
|
||||||
|
int issuesCount = issues.size();
|
||||||
|
testPlanTestCaseService.updateIssues(issuesCount, "", l, JSON.toJSONString(issues));
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error("处理bug数量报错caseId: {}, message: {}", l, ExceptionUtils.getStackTrace(e));
|
||||||
|
}
|
||||||
|
});
|
||||||
noticeIssueEven(issuesRequest, "IssuesCreate");
|
noticeIssueEven(issuesRequest, "IssuesCreate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +405,30 @@ public class IssuesService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void issuesCount() {
|
||||||
|
LogUtil.info("测试计划-测试用例同步缺陷信息开始");
|
||||||
|
int pageSize = 100;
|
||||||
|
int pages = 1;
|
||||||
|
for (int i = 0; i < pages; i++) {
|
||||||
|
Page<List<TestPlanTestCase>> page = PageHelper.startPage(i, pageSize, true);
|
||||||
|
List<TestPlanTestCaseWithBLOBs> list = testPlanTestCaseService.listAll();
|
||||||
|
pages = page.getPages();// 替换成真实的值
|
||||||
|
list.forEach(l -> {
|
||||||
|
try {
|
||||||
|
List<IssuesDao> issues = this.getIssues(l.getCaseId());
|
||||||
|
if (org.apache.commons.collections4.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: {}, message: {}", l.getPlanId(), ExceptionUtils.getStackTrace(e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
LogUtil.info("测试计划-测试用例同步缺陷信息结束");
|
||||||
|
}
|
||||||
|
|
||||||
public void syncThirdPartyIssues(String projectId) {
|
public void syncThirdPartyIssues(String projectId) {
|
||||||
if (StringUtils.isNotBlank(projectId)) {
|
if (StringUtils.isNotBlank(projectId)) {
|
||||||
Project project = projectService.getProjectById(projectId);
|
Project project = projectService.getProjectById(projectId);
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class TestCaseIssueService {
|
||||||
@Resource
|
@Resource
|
||||||
private IssuesMapper issuesMapper;
|
private IssuesMapper issuesMapper;
|
||||||
|
|
||||||
|
|
||||||
public void delTestCaseIssues(String testCaseId) {
|
public void delTestCaseIssues(String testCaseId) {
|
||||||
TestCaseIssuesExample example = new TestCaseIssuesExample();
|
TestCaseIssuesExample example = new TestCaseIssuesExample();
|
||||||
example.createCriteria().andTestCaseIdEqualTo(testCaseId);
|
example.createCriteria().andTestCaseIdEqualTo(testCaseId);
|
||||||
|
|
Loading…
Reference in New Issue