fix(测试跟踪): 测试计划报告缺陷列表状态显示有误
--bug=1016730 --user=陈建星 【测试跟踪】github #17830,缺陷管理将缺陷变更状态之后,在测试计划报告中关联的缺陷状态未发生改变。 https://www.tapd.cn/55049933/s/1243631
This commit is contained in:
parent
2c7dcec1bf
commit
1f1b96fb52
|
@ -284,6 +284,24 @@ public class CustomFieldService {
|
|||
.collect(Collectors.toMap(i -> i.getName() + i.getScene(), i -> i));
|
||||
}
|
||||
|
||||
public CustomField getCustomFieldByName(String projectId, String fieldName) {
|
||||
CustomFieldExample example = new CustomFieldExample();
|
||||
example.createCriteria()
|
||||
.andProjectIdEqualTo(projectId)
|
||||
.andNameEqualTo(fieldName);
|
||||
List<CustomField> customFields = customFieldMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||
return customFields.get(0);
|
||||
} else {
|
||||
example.clear();
|
||||
example.createCriteria()
|
||||
.andGlobalEqualTo(true)
|
||||
.andNameEqualTo(fieldName);
|
||||
customFields = customFieldMapper.selectByExample(example);
|
||||
return CollectionUtils.isNotEmpty(customFields) ? customFields.get(0) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getIssueSystemCustomFieldByName(String fieldName, String projectId, List<String> resourceIds) {
|
||||
if (CollectionUtils.isEmpty(resourceIds)) {
|
||||
return null;
|
||||
|
|
|
@ -14,6 +14,7 @@ import io.metersphere.commons.exception.MSException;
|
|||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.controller.request.IntegrationRequest;
|
||||
import io.metersphere.dto.CustomFieldDao;
|
||||
import io.metersphere.dto.CustomFieldOption;
|
||||
import io.metersphere.dto.IssueTemplateDao;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.log.utils.ReflexObjectUtil;
|
||||
|
@ -730,9 +731,43 @@ public class IssuesService {
|
|||
IssuesRequest issueRequest = new IssuesRequest();
|
||||
issueRequest.setPlanId(planId);
|
||||
List<IssuesDao> planIssues = extIssuesMapper.getPlanIssues(issueRequest);
|
||||
|
||||
buildCustomField(planIssues);
|
||||
|
||||
replaceStatus(planIssues, planId);
|
||||
|
||||
return disconnectIssue(planIssues);
|
||||
}
|
||||
|
||||
private void replaceStatus(List<IssuesDao> planIssues, String planId) {
|
||||
TestPlanWithBLOBs testPlan = testPlanService.get(planId);
|
||||
CustomField customField = customFieldService.getCustomFieldByName(testPlan.getProjectId(), SystemCustomField.ISSUE_STATUS);
|
||||
planIssues.forEach(issue -> {
|
||||
List<CustomFieldDao> fields = issue.getFields();
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
for (CustomFieldDao field : fields) {
|
||||
if (field.getId().equals(customField.getId())) {
|
||||
List<CustomFieldOption> options = JSONObject.parseArray(customField.getOptions(), CustomFieldOption.class);
|
||||
for (CustomFieldOption option : options) {
|
||||
String value = field.getValue();
|
||||
if (value != null) {
|
||||
value = (String) JSONObject.parse(value);
|
||||
}
|
||||
if (StringUtils.equals(option.getValue(), value)) {
|
||||
if (option.getSystem()) {
|
||||
issue.setStatus(option.getValue());
|
||||
} else {
|
||||
issue.setStatus(option.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<IssuesDao> disconnectIssue(List<IssuesDao> issues) {
|
||||
Set<String> ids = new HashSet<>(issues.size());
|
||||
Iterator<IssuesDao> iterator = issues.iterator();
|
||||
|
|
Loading…
Reference in New Issue