package cn.cslg.pas.service.common; import cn.cslg.pas.common.core.base.PatentDictionary; import cn.cslg.pas.common.core.base.RedisConf; import cn.cslg.pas.common.dto.QueryFieldsDTO; import cn.cslg.pas.common.dto.patentCount.AddPatentCountDTO; import cn.cslg.pas.common.dto.patentCount.GetAllPatentCountDTO; import cn.cslg.pas.common.dto.patentCount.GetTabelColumDTO; import cn.cslg.pas.common.model.cronModel.PersonnelVO; import cn.cslg.pas.common.utils.*; import cn.cslg.pas.common.dto.AddSelfFieldDTO; import cn.cslg.pas.common.vo.QueryFiledVO; import cn.cslg.pas.common.vo.QueryFieldsVO; import cn.cslg.pas.common.vo.PersonSelfFieldVO; import cn.cslg.pas.common.vo.business.AllCustomFieldVO; import cn.cslg.pas.common.vo.patentCount.GetAllPatentCountVO; import cn.cslg.pas.domain.business.CustomField; import cn.cslg.pas.domain.business.ReportProject; import cn.cslg.pas.exception.UnLoginException; import cn.cslg.pas.exception.XiaoShiException; import cn.cslg.pas.service.business.CommonService; import cn.cslg.pas.service.business.CustomFieldService; import cn.cslg.pas.service.business.ReportProjectService; import cn.hutool.crypto.SecureUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @Service public class PersonFieldService { @Autowired private RedisUtil redisUtil; @Autowired private CacheUtils cacheUtils; @Autowired private LoginUtils loginUtils; @Autowired private CustomFieldService customFieldService; @Autowired private ReportProjectService reportProjectService; public List getCustomField(String tableName, Integer projectId) { //根据登录人id和type查询 PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String key = ""; if (projectId == null) { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId); } else { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId); } String json = redisUtil.get(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key); //如果查到 if (StringUtils.isNotEmpty(json)) { return JsonUtils.jsonToList(json, PersonSelfFieldVO.class); } String fieldJson = ""; //如果没查询到,则获取所有栏位添加到redis里 try { fieldJson = CommonService.readJsonFile(tableName + ".json"); } catch (Exception e) { throw new XiaoShiException("不存在此表"); } List fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class); if (fieldVOS == null) { throw new XiaoShiException("不存在此表"); } fieldVOS = fieldVOS.stream().filter(item -> item.getIfShow().equals(true)).collect(Collectors.toList()); if (fieldVOS == null || fieldVOS.size() == 0) { throw new XiaoShiException("表中无字段"); } fieldVOS.forEach(item -> { item.setCreateType(1); }); //当tableName是patent时 if (PatentDictionary.NAME.equals(tableName)) { //获得所有自定义字段 List allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId); if (allCustomFieldVOS.size() != 0) { } } //装载顺序 Integer order = 0; for (PersonSelfFieldVO item : fieldVOS) { item.setOrder(order); if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) { item.setIfHidden(true); } else { item.setIfHidden(false); } order++; } //保存到redis redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS)); return fieldVOS; } public List setCustomField(AddSelfFieldDTO addSelfFieldDTO) { PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String key = SecureUtil.md5(addSelfFieldDTO.getTableName() + RedisConf.SYMBOL_COLON + userId); String fieldJson = CommonService.readJsonFile(addSelfFieldDTO.getTableName() + ".json"); List fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class); fieldVOS = fieldVOS.stream().filter(item -> item.getIfShow().equals(true)).collect(Collectors.toList()); for (PersonSelfFieldVO item : fieldVOS) { PersonSelfFieldVO temVO = addSelfFieldDTO.getValue().stream().filter(tem -> tem.getValue().equals(item.getValue())).findFirst().orElse(null); if (temVO == null) { item.setIfHidden(true); } else { item.setIfHidden(temVO.getIfHidden()); } } Integer order = 0; for (PersonSelfFieldVO item : fieldVOS) { item.setOrder(order); order++; } redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS)); return fieldVOS; } /** * 获得查询的栏位 * * @param queryFieldsDTOs * @return */ public List getQueryFields(List queryFieldsDTOs) { List queryFieldsVOS = new ArrayList<>(); queryFieldsDTOs.forEach(item -> { String json = null; try { json = CommonService.readJsonFile(item.getTableName() + ".json"); } catch (Exception e) { } Boolean flag = true; if (json != null) { QueryFieldsVO queryFieldsVO = new QueryFieldsVO(); queryFieldsVO.setTableName(item.getTableName()); List queryConditions = JSON.parseArray(json, QueryFiledVO.class); //过滤出可查询的字段 List queryFiledVOList = queryConditions.stream().filter(i -> flag.equals(i.getIfSearch()) || flag.equals(i.getIfGroup())).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(queryFiledVOList)) { queryFiledVOList.forEach(field -> { field.setGroup("nos"); }); } //当是专利的配置时 if (item.getTableName().trim().equals(PatentDictionary.NAME) && item.getProjectId() != null) { //根据专题库id 查询所有自定义字段 List allCustomFieldVOS = customFieldService.getAllProjectCustomField(item.getProjectId()); //遍历装载 List queryFiledVOS = new ArrayList<>(); allCustomFieldVOS.forEach(i -> { QueryFiledVO queryFieldsVO1 = new QueryFiledVO(); //装载名称 queryFieldsVO1.setName(i.getName()); //装载类型 Integer type = i.getType(); queryFieldsVO1.setFiledType(type); switch (type) { case 0: //装载组别 queryFieldsVO1.setGroup("customField"); queryFieldsVO1.setType("Integer"); break; case 1: queryFieldsVO1.setGroup("customField"); queryFieldsVO1.setType("DateTime"); break; case 2: queryFieldsVO1.setGroup("customField"); queryFieldsVO1.setType("String"); break; case 4: case 5: queryFieldsVO1.setGroup("customField"); queryFieldsVO1.setType("Array"); break; case 6: queryFieldsVO1.setGroup("customField"); queryFieldsVO1.setType("tree"); break; case 7: queryFieldsVO1.setGroup("product"); queryFieldsVO1.setType("tree"); break; case 8: queryFieldsVO1.setGroup("productCategory"); queryFieldsVO1.setType("tree"); break; case 9: queryFieldsVO1.setGroup("technical"); queryFieldsVO1.setType("tree"); break; } //装载id queryFieldsVO1.setField(i.getId().toString()); queryFieldsVO1.setIfSearch(true); queryFieldsVO1.setIfGroup(false); queryFiledVOS.add(queryFieldsVO1); }); queryFiledVOList.addAll(queryFiledVOS); } queryFieldsVO.setConditionDTOList(queryFiledVOList); queryFieldsVOS.add(queryFieldsVO); } }); return queryFieldsVOS; } /** * 查询表格显示栏位 * * @param getTabelColumDTO * @return */ public List getTableColumns(GetTabelColumDTO getTabelColumDTO) { Integer projectId = getTabelColumDTO.getProjectId(); Integer taskId = getTabelColumDTO.getTaskId(); String tableName = getTabelColumDTO.getTableName(); Integer productId = getTabelColumDTO.getProductId(); //根据登录人id和type查询 PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String key = ""; if (projectId == null) { if (productId != null) { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId); } else { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId); } } else { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId); } String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key; String json = redisUtil.get(redisKey); String fieldJson = ""; //如果查到 List reFieldVos = new ArrayList<>(); if (StringUtils.isNotEmpty(json)) { reFieldVos = JsonUtils.jsonToList(json, PersonSelfFieldVO.class); } try { fieldJson = CommonService.readJsonFile(tableName + ".json"); } catch (Exception e) { throw new XiaoShiException("不存在此表"); } List fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class); if (fieldVOS == null) { throw new XiaoShiException("不存在此表"); } Boolean flag = true; fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfShow())).collect(Collectors.toList()); if (fieldVOS == null || fieldVOS.size() == 0) { throw new XiaoShiException("表中无字段"); } //当tableName是patent时 if (PatentDictionary.NAME.equals(tableName) && projectId != null && projectId != 0) { //获得所有自定义字段 List allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId); AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO(); allCustomFieldVO.setName("标签"); allCustomFieldVO.setId(0); allCustomFieldVO.setType(10); allCustomFieldVOS.add(allCustomFieldVO); if (allCustomFieldVOS.size() != 0) { for (AllCustomFieldVO item : allCustomFieldVOS) { PersonSelfFieldVO personSelfFieldVO = new PersonSelfFieldVO(); personSelfFieldVO.setIfHidden(true); personSelfFieldVO.setName(item.getName()); personSelfFieldVO.setType(item.getType().toString()); personSelfFieldVO.setValue(item.getId().toString()); personSelfFieldVO.setIfPersonal(true); personSelfFieldVO.setIfSort(false); personSelfFieldVO.setDefaultHidden(true); fieldVOS.add(personSelfFieldVO); } } } //装载顺序 for (PersonSelfFieldVO item : fieldVOS) { PersonSelfFieldVO personSelfFieldVO = reFieldVos.stream().filter(t -> t.getValue().equals(item.getValue()) && t.getType().equals(item.getType())).findFirst().orElse(null); if (personSelfFieldVO == null) { if (StringUtils.isNotEmpty(json)) { item.setIfHidden(true); } else { if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) { item.setIfHidden(true); } else { item.setIfHidden(false); } } reFieldVos.add(item); } } return reFieldVos; } /** * 获得表格导出栏位 * @param getTabelColumDTO * @return */ public List getTableExportColumns(GetTabelColumDTO getTabelColumDTO) { Integer projectId = getTabelColumDTO.getProjectId(); String tableName = getTabelColumDTO.getTableName(); Integer productId = getTabelColumDTO.getProductId(); //根据登录人id和type查询 PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String key = ""; if (projectId == null) { if (productId != null) { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId); } else { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId); } } else { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId); } String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key; String json = redisUtil.get(redisKey); String fieldJson = ""; //如果查到 List reFieldVos = new ArrayList<>(); if (StringUtils.isNotEmpty(json)) { reFieldVos = JsonUtils.jsonToList(json, PersonSelfFieldVO.class); } try { fieldJson = CommonService.readJsonFile(tableName + ".json"); } catch (Exception e) { throw new XiaoShiException("不存在此表"); } List fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class); if (fieldVOS == null) { throw new XiaoShiException("不存在此表"); } Boolean flag = true; fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIsExport())).collect(Collectors.toList()); if (CollectionUtils.isEmpty(fieldVOS)) { throw new XiaoShiException("表中无字段"); } //当tableName是patent时 if (PatentDictionary.NAME.equals(tableName) && projectId != null && projectId != 0) { //获得所有自定义字段 List allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId); AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO(); allCustomFieldVO.setName("标签"); allCustomFieldVO.setId(0); allCustomFieldVO.setType(10); allCustomFieldVOS.add(allCustomFieldVO); if (!CollectionUtils.isEmpty(allCustomFieldVOS)) { for (AllCustomFieldVO item : allCustomFieldVOS) { PersonSelfFieldVO personSelfFieldVO = new PersonSelfFieldVO(); personSelfFieldVO.setIfHidden(true); personSelfFieldVO.setName(item.getName()); personSelfFieldVO.setType(item.getType().toString()); personSelfFieldVO.setValue(item.getId().toString()); personSelfFieldVO.setIfPersonal(true); personSelfFieldVO.setIfSort(false); personSelfFieldVO.setDefaultHidden(true); fieldVOS.add(personSelfFieldVO); } } } //装载顺序 for (PersonSelfFieldVO item : fieldVOS) { PersonSelfFieldVO personSelfFieldVO = reFieldVos.stream().filter(t -> t.getValue().equals(item.getValue()) && t.getType().equals(item.getType())).findFirst().orElse(null); if (personSelfFieldVO == null) { if (StringUtils.isNotEmpty(json)) { item.setIfHidden(true); } else { if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) { item.setIfHidden(true); } else { item.setIfHidden(false); } } reFieldVos.add(item); } } return reFieldVos; } public List setTableColumns(AddSelfFieldDTO addSelfFieldDTO) { PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String tableName = addSelfFieldDTO.getTableName(); Integer projectId = addSelfFieldDTO.getProjectId(); Integer productId = addSelfFieldDTO.getProductId(); List personSelfFieldVOS = addSelfFieldDTO.getValue(); personSelfFieldVOS = personSelfFieldVOS.stream().filter(item -> item.getIfHidden() != null && item.getIfHidden().equals(false)).collect(Collectors.toList()); String key = ""; if (projectId == null) { if (productId != null) { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId); } else { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId); } } else { key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId); } String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key; redisUtil.set(redisKey, JsonUtils.objectToJson(personSelfFieldVOS)); return personSelfFieldVOS; } /** * 查询所有的统计字段 * * @param getAllPatentCountDTO * @return */ public List getAllCountColumns(GetAllPatentCountDTO getAllPatentCountDTO) { Integer taskId = getAllPatentCountDTO.getTaskId(); Integer projectId = getAllPatentCountDTO.getProjectId(); String fieldJson = ""; //如果没查询到,则获取所有栏位添加到redis里 try { fieldJson = CommonService.readJsonFile(PatentDictionary.NAME + ".json"); } catch (Exception e) { throw new XiaoShiException("不存在此表"); } Boolean flag = true; List fieldVOS = JSON.parseArray(fieldJson, GetAllPatentCountVO.class); fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfStats())).collect(Collectors.toList()); fieldVOS.forEach(item -> item.setFiledKind(-1)); //当专题库id或者报告id不为null时 if (taskId != null || projectId != null) { List allCustomFieldVOS = new ArrayList<>(); if (taskId != null) { allCustomFieldVOS = customFieldService.getAllTaskCustomField(taskId); } else { allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId); } if (allCustomFieldVOS != null && allCustomFieldVOS.size() != 0) { //遍历查询出的自定义字段进行装载 for (AllCustomFieldVO allCustomFieldVO : allCustomFieldVOS) { GetAllPatentCountVO getAllPatentCountVO = new GetAllPatentCountVO(); //装载自定义字段的栏位值 getAllPatentCountVO.setValue(allCustomFieldVO.getId().toString()); //装载自定义栏位名 getAllPatentCountVO.setName(allCustomFieldVO.getName()); //装载栏位类型 if (allCustomFieldVO.getType() <= 6) { getAllPatentCountVO.setFiledKind(0); switch (allCustomFieldVO.getType()) { case 0: getAllPatentCountVO.setType("Integer"); break; case 1: getAllPatentCountVO.setType("DateTime"); break; case 2: getAllPatentCountVO.setType("String"); break; case 4: case 5: getAllPatentCountVO.setType("Array"); break; case 6: getAllPatentCountVO.setType("tree"); break; } } else { getAllPatentCountVO.setFiledKind(allCustomFieldVO.getType()); getAllPatentCountVO.setType("tree"); } fieldVOS.add(getAllPatentCountVO); } } } return fieldVOS; } /** * 查询显示的统计栏位 * * @param getAllPatentCountDTO * @return */ public List getShowCountColumns(GetAllPatentCountDTO getAllPatentCountDTO) { Integer taskId = getAllPatentCountDTO.getTaskId(); Integer projectId = getAllPatentCountDTO.getProjectId(); //根据登录人id和type查询 PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String key = ""; if (taskId != null) { key = SecureUtil.md5(RedisConf.TASK_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + taskId); } else { key = SecureUtil.md5(RedisConf.PROJECT_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId); } String json = redisUtil.get(RedisConf.FIELD_COUNT + RedisConf.SYMBOL_COLON + key); //如果查到 if (StringUtils.isNotEmpty(json)) { return JsonUtils.jsonToList(json, GetAllPatentCountVO.class); } String fieldJson = ""; //如果没查询到,则获取所有栏位添加到redis里 try { fieldJson = CommonService.readJsonFile(PatentDictionary.NAME + ".json"); } catch (Exception e) { throw new XiaoShiException("不存在此表"); } Boolean flag = true; //查询栏位 LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); queryWrapper.eq(CustomField::getProjectId,projectId) .eq(CustomField::getName,"监控周期") .eq(CustomField::getType,4); CustomField customField =customFieldService.getOne(queryWrapper,false); List fieldVOS =new ArrayList<>(); if(customField!=null){ GetAllPatentCountVO getAllPatentCountVO =new GetAllPatentCountVO(); getAllPatentCountVO.setType("Array"); getAllPatentCountVO.setValue(customField.getId().toString()); getAllPatentCountVO.setName(customField.getName()); getAllPatentCountVO.setFiledKind(0); fieldVOS.add(getAllPatentCountVO); } List fieldVOS2 = JSON.parseArray(fieldJson, GetAllPatentCountVO.class); fieldVOS2 = fieldVOS2.stream().filter(item -> flag.equals(item.getIfStats()) && flag.equals(item.getDefaultShowStats())).collect(Collectors.toList()); fieldVOS2.forEach(item -> item.setFiledKind(-1)); fieldVOS.addAll(fieldVOS2); redisUtil.set(RedisConf.FIELD_COUNT + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS)); return fieldVOS; } /** * 查询显示的统计栏位 * * @param addPatentCountDTO * @return */ public List setShowCountColumns(AddPatentCountDTO addPatentCountDTO) { Integer taskId = addPatentCountDTO.getTaskId(); Integer projectId = addPatentCountDTO.getProjectId(); //根据登录人id和type查询 PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String key = ""; if (taskId != null) { key = SecureUtil.md5(RedisConf.TASK_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + taskId); } else { key = SecureUtil.md5(RedisConf.PROJECT_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId); } Boolean flag = true; List fieldVOS = addPatentCountDTO.getValue(); redisUtil.set(RedisConf.FIELD_COUNT + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS)); return fieldVOS; } /** * 查询证据组合表头 * * @param getTabelColumDTO * @return */ public List getEvidenceReasonTableColumns(GetTabelColumDTO getTabelColumDTO) { Integer projectId = getTabelColumDTO.getProjectId(); String tableName = getTabelColumDTO.getTableName(); if (tableName == null||tableName.equals("")) { tableName = "evidenceReason"; } //根据登录人id和type查询 PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String key = ""; key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.EVIDENCE_REASON + RedisConf.SYMBOL_COLON + projectId); String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key; String json = redisUtil.get(redisKey); String fieldJson = ""; //如果查到 List reFieldVos = new ArrayList<>(); if (StringUtils.isNotEmpty(json)) { reFieldVos = JsonUtils.jsonToList(json, PersonSelfFieldVO.class); } try { fieldJson = CommonService.readJsonFile(tableName + ".json"); } catch (Exception e) { throw new XiaoShiException("不存在此表"); } List fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class); if (fieldVOS == null) { throw new XiaoShiException("不存在此表"); } Boolean flag = true; LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); queryWrapper.eq(ReportProject::getProjectId,projectId); ReportProject reportProject =reportProjectService.getOne(queryWrapper,false); if(reportProject.getIfSecondInvalid()!=null&&reportProject.getIfSecondInvalid()) { fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfShow()) || item.getType().equals("second")).collect(Collectors.toList()); } else { fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfShow())).collect(Collectors.toList()); } if (fieldVOS == null || fieldVOS.size() == 0) { throw new XiaoShiException("表中无字段"); } //装载顺序 for (PersonSelfFieldVO item : fieldVOS) { if (StringUtils.isNotEmpty(json)) { PersonSelfFieldVO personSelfFieldVO = reFieldVos.stream().filter(t -> t.getValue().equals(item.getValue()) && t.getName().equals(item.getName())).findFirst().orElse(null); if (personSelfFieldVO == null) { item.setIfHidden(true); reFieldVos.add(item); } } else { if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) { item.setIfHidden(true); } else { item.setIfHidden(false); } reFieldVos.add(item); } } return reFieldVos; } public List setEvidenceReasonTableColumns(AddSelfFieldDTO addSelfFieldDTO) { PersonnelVO personnelVO = new PersonnelVO(); personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); String userId = personnelVO.getId(); String tableName = addSelfFieldDTO.getTableName(); if (tableName == null||tableName.equals("")) { tableName = "evidenceReason"; } Integer projectId = addSelfFieldDTO.getProjectId(); List personSelfFieldVOS = addSelfFieldDTO.getValue(); personSelfFieldVOS = personSelfFieldVOS.stream().filter(item -> item.getIfHidden() != null && item.getIfHidden().equals(false)).collect(Collectors.toList()); String key = ""; key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.EVIDENCE_REASON + RedisConf.SYMBOL_COLON + projectId); String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key; redisUtil.set(redisKey, JsonUtils.objectToJson(personSelfFieldVOS)); return personSelfFieldVOS; } }