fix(测试跟踪): 首页遗留缺陷统计总数和占比有统计错误
--bug=1017609 --user=李玉号 【测试跟踪】首页遗留缺陷统计总数和占比有统计错误 https://www.tapd.cn/55049933/s/1292665
This commit is contained in:
parent
b74ce26b67
commit
4a25c0ec0a
|
@ -1,8 +1,9 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
import io.metersphere.base.domain.CustomField;
|
||||
import io.metersphere.base.domain.CustomFieldExample;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.CustomFieldMapper;
|
||||
import io.metersphere.base.mapper.CustomFieldTemplateMapper;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.BaseCustomFieldMapper;
|
||||
import io.metersphere.commons.constants.CustomFieldType;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
|
@ -29,6 +30,11 @@ public class BaseCustomFieldService {
|
|||
@Resource
|
||||
CustomFieldMapper customFieldMapper;
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private CustomFieldTemplateMapper customFieldTemplateMapper;
|
||||
|
||||
public CustomField get(String id) {
|
||||
return customFieldMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
@ -102,13 +108,41 @@ public class BaseCustomFieldService {
|
|||
}
|
||||
|
||||
public CustomField getCustomFieldByName(String projectId, String fieldName) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
if (project == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String issueTemplateId = project.getIssueTemplateId();
|
||||
if (StringUtils.isBlank(issueTemplateId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CustomFieldTemplateExample customFieldTemplateExample = new CustomFieldTemplateExample();
|
||||
customFieldTemplateExample.createCriteria().andTemplateIdEqualTo(issueTemplateId);
|
||||
List<CustomFieldTemplate> customFieldTemplates = customFieldTemplateMapper.selectByExample(customFieldTemplateExample);
|
||||
if (CollectionUtils.isEmpty(customFieldTemplates)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> templateFieldIds = customFieldTemplates
|
||||
.stream()
|
||||
.map(CustomFieldTemplate::getFieldId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
CustomFieldExample example = new CustomFieldExample();
|
||||
example.createCriteria()
|
||||
.andProjectIdEqualTo(projectId)
|
||||
.andNameEqualTo(fieldName);
|
||||
|
||||
List<CustomField> customFields = customFieldMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||
return customFields.get(0);
|
||||
for (CustomField customField : customFields) {
|
||||
if (templateFieldIds.contains(customField.getId())) {
|
||||
return customField;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
example.clear();
|
||||
example.createCriteria()
|
||||
|
|
Loading…
Reference in New Issue