|
@@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -33,6 +34,7 @@ import java.util.stream.Collectors;
|
|
|
* @author 王岩
|
|
|
* @since 2021-12-16
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class ProjectFieldService extends ServiceImpl<ProjectFieldMapper, ProjectField> {
|
|
@@ -226,28 +228,43 @@ public class ProjectFieldService extends ServiceImpl<ProjectFieldMapper, Project
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getCustomField(Integer projectId) {
|
|
|
+ //创建map用于装载:1.自定义字段(标引/非树类型字段、分类/树类型字段) 2.文件夹 3.数据来源,和返回结果
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
+
|
|
|
+ //创建非树类型字段集合
|
|
|
List<ProjectField> indexs = new ArrayList<>();
|
|
|
+ //创建树类型字段集合
|
|
|
List<Object> classifys = new ArrayList<>();
|
|
|
+
|
|
|
+ //1、自定义字段(标引和分类):根据专题库projectId查询自定义字段表“os_patent_field”列表
|
|
|
List<ProjectField> fieldList = this.getProjectFieldByProjectId(projectId);
|
|
|
+ //根据自定义字段ids(自定义字段列表fieldList过滤出ids集合)查询自定义字段多选关联表“os_patent_field_multiple”列表
|
|
|
List<ProjectFieldOption> optionList = projectFieldOptionService.getFieldOptionList(fieldList.stream().map(ProjectField::getId).collect(Collectors.toList()));
|
|
|
+ //遍历自定义字段列表fieldList,给每个自定义字段装载选项 ↓
|
|
|
fieldList.forEach(item -> {
|
|
|
+ //标引(非树类型字段) -> 装载当前自定义字段id对应的选项(遍历自定义字段多选关联表列表optionList,根据多选的自定义字段id与当前遍历的自定义字段id相同过滤出选项)
|
|
|
if (item.getType() != 6) {
|
|
|
item.setOption(optionList.stream().filter(option -> option.getFieldId().equals(item.getId())).collect(Collectors.toList()));
|
|
|
indexs.add(item);
|
|
|
+ //分类(树类型字段) -> 装载当前自定义字段id对应的树(使用装载树方法)
|
|
|
} else {
|
|
|
item.setOption(JsonUtils.jsonToList(JsonUtils.objectToJson(projectFieldTreeService.getProjectFieldTreeNodeByFieldId(item.getId())), ProjectFieldOption.class));
|
|
|
classifys.add(item);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ //2、文件夹:根据专题库projectId查询文件夹主表“os_portfolio”列表
|
|
|
List<ProjectFolder> folderList = projectFolderService.getProjectFolderOptionByProjectId(projectId);
|
|
|
result.put("index", indexs);
|
|
|
result.put("classify", classifys);
|
|
|
result.put("folder", projectFolderService.getProjectFolderTreeNode(projectId, folderList));
|
|
|
|
|
|
- //数据源名称
|
|
|
+ //3、数据来源(analysisJsonFile()方法 -> 拿到uploadSetting.json文件并按行读取文件字符流,返回整个文件字符串)
|
|
|
String getSettingJson = fileUtils.analysisJsonFile();
|
|
|
+ //将文件字符串转换为数据来源对象UploadSettingVO集合
|
|
|
List<UploadSettingVO> settingJsonList = JsonUtils.jsonToList(getSettingJson, UploadSettingVO.class);
|
|
|
+
|
|
|
+ //手动创建数据来源对象集合dataTypesLst,装载数据
|
|
|
List<ProjectField.dataType> dataTypesLst = new ArrayList<>();
|
|
|
Objects.requireNonNull(settingJsonList).forEach(item -> {
|
|
|
ProjectField.dataType dataType = new ProjectField.dataType();
|
|
@@ -257,6 +274,7 @@ public class ProjectFieldService extends ServiceImpl<ProjectFieldMapper, Project
|
|
|
});
|
|
|
result.put("dataType", dataTypesLst);
|
|
|
|
|
|
+ //返回结果(包含1.自定义字段(标引/非树类型字段、分类/树类型字段) 2.文件夹 3.数据来源)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -315,8 +333,9 @@ public class ProjectFieldService extends ServiceImpl<ProjectFieldMapper, Project
|
|
|
}
|
|
|
return projectField;
|
|
|
}
|
|
|
+
|
|
|
public IPage<ProjectField> getPageList(ProjectFieldVO params) throws IOException {
|
|
|
- PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
//分页查询列表
|
|
|
params.setTenantId(personnelVO.getTenantId());
|
|
|
IPage<ProjectField> pageList = baseMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
|
|
@@ -342,6 +361,7 @@ public class ProjectFieldService extends ServiceImpl<ProjectFieldMapper, Project
|
|
|
|
|
|
return pageList;
|
|
|
}
|
|
|
+
|
|
|
public ProjectField getByProjectIdAndNameAndType(String name, Integer type, Integer projectId) {
|
|
|
LambdaQueryWrapper<ProjectField> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(ProjectField::getName, name);
|