PersonFieldService.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. package cn.cslg.pas.service.common;
  2. import cn.cslg.pas.common.core.base.PatentDictionary;
  3. import cn.cslg.pas.common.core.base.RedisConf;
  4. import cn.cslg.pas.common.dto.QueryFieldsDTO;
  5. import cn.cslg.pas.common.dto.patentCount.AddPatentCountDTO;
  6. import cn.cslg.pas.common.dto.patentCount.GetAllPatentCountDTO;
  7. import cn.cslg.pas.common.dto.patentCount.GetTabelColumDTO;
  8. import cn.cslg.pas.common.model.cronModel.PersonnelVO;
  9. import cn.cslg.pas.common.utils.*;
  10. import cn.cslg.pas.common.dto.AddSelfFieldDTO;
  11. import cn.cslg.pas.common.vo.QueryFiledVO;
  12. import cn.cslg.pas.common.vo.QueryFieldsVO;
  13. import cn.cslg.pas.common.vo.PersonSelfFieldVO;
  14. import cn.cslg.pas.common.vo.business.AllCustomFieldVO;
  15. import cn.cslg.pas.common.vo.patentCount.GetAllPatentCountVO;
  16. import cn.cslg.pas.domain.business.ReportProject;
  17. import cn.cslg.pas.exception.UnLoginException;
  18. import cn.cslg.pas.exception.XiaoShiException;
  19. import cn.cslg.pas.service.business.CommonService;
  20. import cn.cslg.pas.service.business.CustomFieldService;
  21. import cn.cslg.pas.service.business.ReportProjectService;
  22. import cn.hutool.crypto.SecureUtil;
  23. import com.alibaba.fastjson.JSON;
  24. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.stereotype.Service;
  27. import org.springframework.util.CollectionUtils;
  28. import java.util.ArrayList;
  29. import java.util.Comparator;
  30. import java.util.List;
  31. import java.util.stream.Collectors;
  32. @Service
  33. public class PersonFieldService {
  34. @Autowired
  35. private RedisUtil redisUtil;
  36. @Autowired
  37. private CacheUtils cacheUtils;
  38. @Autowired
  39. private LoginUtils loginUtils;
  40. @Autowired
  41. private CustomFieldService customFieldService;
  42. @Autowired
  43. private ReportProjectService reportProjectService;
  44. public List<PersonSelfFieldVO> getCustomField(String tableName, Integer projectId) {
  45. //根据登录人id和type查询
  46. PersonnelVO personnelVO = new PersonnelVO();
  47. try {
  48. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  49. } catch (Exception e) {
  50. throw new UnLoginException("未登录");
  51. }
  52. String userId = personnelVO.getId();
  53. String key = "";
  54. if (projectId == null) {
  55. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
  56. } else {
  57. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId);
  58. }
  59. String json = redisUtil.get(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key);
  60. //如果查到
  61. if (StringUtils.isNotEmpty(json)) {
  62. return JsonUtils.jsonToList(json, PersonSelfFieldVO.class);
  63. }
  64. String fieldJson = "";
  65. //如果没查询到,则获取所有栏位添加到redis里
  66. try {
  67. fieldJson = CommonService.readJsonFile(tableName + ".json");
  68. } catch (Exception e) {
  69. throw new XiaoShiException("不存在此表");
  70. }
  71. List<PersonSelfFieldVO> fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class);
  72. if (fieldVOS == null) {
  73. throw new XiaoShiException("不存在此表");
  74. }
  75. fieldVOS = fieldVOS.stream().filter(item -> item.getIfShow().equals(true)).collect(Collectors.toList());
  76. if (fieldVOS == null || fieldVOS.size() == 0) {
  77. throw new XiaoShiException("表中无字段");
  78. }
  79. fieldVOS.forEach(item -> {
  80. item.setCreateType(1);
  81. });
  82. //当tableName是patent时
  83. if (PatentDictionary.NAME.equals(tableName)) {
  84. //获得所有自定义字段
  85. List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId);
  86. if (allCustomFieldVOS.size() != 0) {
  87. }
  88. }
  89. //装载顺序
  90. Integer order = 0;
  91. for (PersonSelfFieldVO item : fieldVOS) {
  92. item.setOrder(order);
  93. if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) {
  94. item.setIfHidden(true);
  95. } else {
  96. item.setIfHidden(false);
  97. }
  98. order++;
  99. }
  100. //保存到redis
  101. redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
  102. return fieldVOS;
  103. }
  104. public List<PersonSelfFieldVO> setCustomField(AddSelfFieldDTO addSelfFieldDTO) {
  105. PersonnelVO personnelVO = new PersonnelVO();
  106. try {
  107. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  108. } catch (Exception e) {
  109. throw new UnLoginException("未登录");
  110. }
  111. String userId = personnelVO.getId();
  112. String key = SecureUtil.md5(addSelfFieldDTO.getTableName() + RedisConf.SYMBOL_COLON + userId);
  113. String fieldJson = CommonService.readJsonFile(addSelfFieldDTO.getTableName() + ".json");
  114. List<PersonSelfFieldVO> fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class);
  115. fieldVOS = fieldVOS.stream().filter(item -> item.getIfShow().equals(true)).collect(Collectors.toList());
  116. for (PersonSelfFieldVO item : fieldVOS) {
  117. PersonSelfFieldVO temVO = addSelfFieldDTO.getValue().stream().filter(tem -> tem.getValue().equals(item.getValue())).findFirst().orElse(null);
  118. if (temVO == null) {
  119. item.setIfHidden(true);
  120. } else {
  121. item.setIfHidden(temVO.getIfHidden());
  122. }
  123. }
  124. Integer order = 0;
  125. for (PersonSelfFieldVO item : fieldVOS) {
  126. item.setOrder(order);
  127. order++;
  128. }
  129. redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
  130. return fieldVOS;
  131. }
  132. /**
  133. * 获得查询的栏位
  134. *
  135. * @param queryFieldsDTOs
  136. * @return
  137. */
  138. public List<QueryFieldsVO> getQueryFields(List<QueryFieldsDTO> queryFieldsDTOs) {
  139. List<QueryFieldsVO> queryFieldsVOS = new ArrayList<>();
  140. queryFieldsDTOs.forEach(item -> {
  141. String json = null;
  142. try {
  143. json = CommonService.readJsonFile(item.getTableName() + ".json");
  144. } catch (Exception e) {
  145. }
  146. Boolean flag = true;
  147. if (json != null) {
  148. QueryFieldsVO queryFieldsVO = new QueryFieldsVO();
  149. queryFieldsVO.setTableName(item.getTableName());
  150. List<QueryFiledVO> queryConditions = JSON.parseArray(json, QueryFiledVO.class);
  151. //过滤出可查询的字段
  152. List<QueryFiledVO> queryFiledVOList = queryConditions.stream().filter(i -> flag.equals(i.getIfSearch()) || flag.equals(i.getIfGroup())).collect(Collectors.toList());
  153. if (!CollectionUtils.isEmpty(queryFiledVOList)) {
  154. queryFiledVOList.forEach(field -> {
  155. field.setGroup("nos");
  156. });
  157. }
  158. //当是专利的配置时
  159. if (item.getTableName().trim().equals(PatentDictionary.NAME) && item.getProjectId() != null) {
  160. //根据专题库id 查询所有自定义字段
  161. List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(item.getProjectId());
  162. //遍历装载
  163. List<QueryFiledVO> queryFiledVOS = new ArrayList<>();
  164. allCustomFieldVOS.forEach(i -> {
  165. QueryFiledVO queryFieldsVO1 = new QueryFiledVO();
  166. //装载名称
  167. queryFieldsVO1.setName(i.getName());
  168. //装载类型
  169. Integer type = i.getType();
  170. queryFieldsVO1.setFiledType(type);
  171. switch (type) {
  172. case 0:
  173. //装载组别
  174. queryFieldsVO1.setGroup("customField");
  175. queryFieldsVO1.setType("Integer");
  176. break;
  177. case 1:
  178. queryFieldsVO1.setGroup("customField");
  179. queryFieldsVO1.setType("DateTime");
  180. break;
  181. case 2:
  182. queryFieldsVO1.setGroup("customField");
  183. queryFieldsVO1.setType("String");
  184. break;
  185. case 4:
  186. case 5:
  187. queryFieldsVO1.setGroup("customField");
  188. queryFieldsVO1.setType("Array");
  189. break;
  190. case 6:
  191. queryFieldsVO1.setGroup("customField");
  192. queryFieldsVO1.setType("tree");
  193. break;
  194. case 7:
  195. queryFieldsVO1.setGroup("product");
  196. queryFieldsVO1.setType("tree");
  197. break;
  198. case 8:
  199. queryFieldsVO1.setGroup("productCategory");
  200. queryFieldsVO1.setType("tree");
  201. break;
  202. case 9:
  203. queryFieldsVO1.setGroup("technical");
  204. queryFieldsVO1.setType("tree");
  205. break;
  206. }
  207. //装载id
  208. queryFieldsVO1.setField(i.getId().toString());
  209. queryFieldsVO1.setIfSearch(true);
  210. queryFieldsVO1.setIfGroup(false);
  211. queryFiledVOS.add(queryFieldsVO1);
  212. });
  213. queryFiledVOList.addAll(queryFiledVOS);
  214. }
  215. queryFieldsVO.setConditionDTOList(queryFiledVOList);
  216. queryFieldsVOS.add(queryFieldsVO);
  217. }
  218. });
  219. return queryFieldsVOS;
  220. }
  221. /**
  222. * 查询表格显示栏位
  223. *
  224. * @param getTabelColumDTO
  225. * @return
  226. */
  227. public List<PersonSelfFieldVO> getTableColumns(GetTabelColumDTO getTabelColumDTO) {
  228. Integer projectId = getTabelColumDTO.getProjectId();
  229. Integer taskId = getTabelColumDTO.getTaskId();
  230. String tableName = getTabelColumDTO.getTableName();
  231. Integer productId = getTabelColumDTO.getProductId();
  232. //根据登录人id和type查询
  233. PersonnelVO personnelVO = new PersonnelVO();
  234. try {
  235. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  236. } catch (Exception e) {
  237. throw new UnLoginException("未登录");
  238. }
  239. String userId = personnelVO.getId();
  240. String key = "";
  241. if (projectId == null) {
  242. if (productId != null) {
  243. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId);
  244. } else {
  245. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
  246. }
  247. } else {
  248. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId);
  249. }
  250. String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
  251. String json = redisUtil.get(redisKey);
  252. String fieldJson = "";
  253. //如果查到
  254. List<PersonSelfFieldVO> reFieldVos = new ArrayList<>();
  255. if (StringUtils.isNotEmpty(json)) {
  256. reFieldVos = JsonUtils.jsonToList(json, PersonSelfFieldVO.class);
  257. }
  258. try {
  259. fieldJson = CommonService.readJsonFile(tableName + ".json");
  260. } catch (Exception e) {
  261. throw new XiaoShiException("不存在此表");
  262. }
  263. List<PersonSelfFieldVO> fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class);
  264. if (fieldVOS == null) {
  265. throw new XiaoShiException("不存在此表");
  266. }
  267. Boolean flag = true;
  268. fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfShow())).collect(Collectors.toList());
  269. if (fieldVOS == null || fieldVOS.size() == 0) {
  270. throw new XiaoShiException("表中无字段");
  271. }
  272. //当tableName是patent时
  273. if (PatentDictionary.NAME.equals(tableName) && projectId != null && projectId != 0) {
  274. //获得所有自定义字段
  275. List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId);
  276. AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
  277. allCustomFieldVO.setName("标签");
  278. allCustomFieldVO.setId(0);
  279. allCustomFieldVO.setType(10);
  280. allCustomFieldVOS.add(allCustomFieldVO);
  281. if (allCustomFieldVOS.size() != 0) {
  282. for (AllCustomFieldVO item : allCustomFieldVOS) {
  283. PersonSelfFieldVO personSelfFieldVO = new PersonSelfFieldVO();
  284. personSelfFieldVO.setIfHidden(true);
  285. personSelfFieldVO.setName(item.getName());
  286. personSelfFieldVO.setType(item.getType().toString());
  287. personSelfFieldVO.setValue(item.getId().toString());
  288. personSelfFieldVO.setIfPersonal(true);
  289. personSelfFieldVO.setDefaultHidden(true);
  290. fieldVOS.add(personSelfFieldVO);
  291. }
  292. }
  293. }
  294. //装载顺序
  295. for (PersonSelfFieldVO item : fieldVOS) {
  296. PersonSelfFieldVO personSelfFieldVO = reFieldVos.stream().filter(t -> t.getValue().equals(item.getValue()) && t.getType().equals(item.getType())).findFirst().orElse(null);
  297. if (personSelfFieldVO == null) {
  298. if (StringUtils.isNotEmpty(json)) {
  299. item.setIfHidden(true);
  300. } else {
  301. if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) {
  302. item.setIfHidden(true);
  303. } else {
  304. item.setIfHidden(false);
  305. }
  306. }
  307. reFieldVos.add(item);
  308. }
  309. }
  310. return reFieldVos;
  311. }
  312. public List<PersonSelfFieldVO> setTableColumns(AddSelfFieldDTO addSelfFieldDTO) {
  313. PersonnelVO personnelVO = new PersonnelVO();
  314. try {
  315. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  316. } catch (Exception e) {
  317. throw new UnLoginException("未登录");
  318. }
  319. String userId = personnelVO.getId();
  320. String tableName = addSelfFieldDTO.getTableName();
  321. Integer projectId = addSelfFieldDTO.getProjectId();
  322. Integer productId = addSelfFieldDTO.getProductId();
  323. List<PersonSelfFieldVO> personSelfFieldVOS = addSelfFieldDTO.getValue();
  324. personSelfFieldVOS = personSelfFieldVOS.stream().filter(item -> item.getIfHidden() != null && item.getIfHidden().equals(false)).collect(Collectors.toList());
  325. String key = "";
  326. if (projectId == null) {
  327. if (productId != null) {
  328. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId);
  329. } else {
  330. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
  331. }
  332. } else {
  333. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId);
  334. }
  335. String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
  336. redisUtil.set(redisKey, JsonUtils.objectToJson(personSelfFieldVOS));
  337. return personSelfFieldVOS;
  338. }
  339. /**
  340. * 查询所有的统计字段
  341. *
  342. * @param getAllPatentCountDTO
  343. * @return
  344. */
  345. public List<GetAllPatentCountVO> getAllCountColumns(GetAllPatentCountDTO getAllPatentCountDTO) {
  346. Integer taskId = getAllPatentCountDTO.getTaskId();
  347. Integer projectId = getAllPatentCountDTO.getProjectId();
  348. String fieldJson = "";
  349. //如果没查询到,则获取所有栏位添加到redis里
  350. try {
  351. fieldJson = CommonService.readJsonFile(PatentDictionary.NAME + ".json");
  352. } catch (Exception e) {
  353. throw new XiaoShiException("不存在此表");
  354. }
  355. Boolean flag = true;
  356. List<GetAllPatentCountVO> fieldVOS = JSON.parseArray(fieldJson, GetAllPatentCountVO.class);
  357. fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfStats())).collect(Collectors.toList());
  358. fieldVOS.forEach(item -> item.setFiledKind(-1));
  359. //当专题库id或者报告id不为null时
  360. if (taskId != null || projectId != null) {
  361. List<AllCustomFieldVO> allCustomFieldVOS = new ArrayList<>();
  362. if (taskId != null) {
  363. allCustomFieldVOS = customFieldService.getAllTaskCustomField(taskId);
  364. } else {
  365. allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId);
  366. }
  367. if (allCustomFieldVOS != null && allCustomFieldVOS.size() != 0) {
  368. //遍历查询出的自定义字段进行装载
  369. for (AllCustomFieldVO allCustomFieldVO : allCustomFieldVOS) {
  370. GetAllPatentCountVO getAllPatentCountVO = new GetAllPatentCountVO();
  371. //装载自定义字段的栏位值
  372. getAllPatentCountVO.setValue(allCustomFieldVO.getId().toString());
  373. //装载自定义栏位名
  374. getAllPatentCountVO.setName(allCustomFieldVO.getName());
  375. //装载栏位类型
  376. if (allCustomFieldVO.getType() <= 6) {
  377. getAllPatentCountVO.setFiledKind(0);
  378. switch (allCustomFieldVO.getType()) {
  379. case 0:
  380. getAllPatentCountVO.setType("Integer");
  381. break;
  382. case 1:
  383. getAllPatentCountVO.setType("DateTime");
  384. break;
  385. case 2:
  386. getAllPatentCountVO.setType("String");
  387. break;
  388. case 4:
  389. case 5:
  390. getAllPatentCountVO.setType("Array");
  391. break;
  392. case 6:
  393. getAllPatentCountVO.setType("tree");
  394. }
  395. } else {
  396. getAllPatentCountVO.setFiledKind(allCustomFieldVO.getType());
  397. getAllPatentCountVO.setType("tree");
  398. }
  399. fieldVOS.add(getAllPatentCountVO);
  400. }
  401. }
  402. }
  403. return fieldVOS;
  404. }
  405. /**
  406. * 查询显示的统计栏位
  407. *
  408. * @param getAllPatentCountDTO
  409. * @return
  410. */
  411. public List<GetAllPatentCountVO> getShowCountColumns(GetAllPatentCountDTO getAllPatentCountDTO) {
  412. Integer taskId = getAllPatentCountDTO.getTaskId();
  413. Integer projectId = getAllPatentCountDTO.getProjectId();
  414. //根据登录人id和type查询
  415. PersonnelVO personnelVO = new PersonnelVO();
  416. try {
  417. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  418. } catch (Exception e) {
  419. throw new UnLoginException("未登录");
  420. }
  421. String userId = personnelVO.getId();
  422. String key = "";
  423. if (taskId != null) {
  424. key = SecureUtil.md5(RedisConf.TASK_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + taskId);
  425. } else {
  426. key = SecureUtil.md5(RedisConf.PROJECT_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId);
  427. }
  428. String json = redisUtil.get(RedisConf.FIELD_COUNT + RedisConf.SYMBOL_COLON + key);
  429. //如果查到
  430. if (StringUtils.isNotEmpty(json)) {
  431. return JsonUtils.jsonToList(json, GetAllPatentCountVO.class);
  432. }
  433. String fieldJson = "";
  434. //如果没查询到,则获取所有栏位添加到redis里
  435. try {
  436. fieldJson = CommonService.readJsonFile(PatentDictionary.NAME + ".json");
  437. } catch (Exception e) {
  438. throw new XiaoShiException("不存在此表");
  439. }
  440. Boolean flag = true;
  441. List<GetAllPatentCountVO> fieldVOS = JSON.parseArray(fieldJson, GetAllPatentCountVO.class);
  442. fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfStats()) && flag.equals(item.getDefaultShowStats())).collect(Collectors.toList());
  443. fieldVOS.forEach(item -> item.setFiledKind(-1));
  444. redisUtil.set(RedisConf.FIELD_COUNT + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
  445. return fieldVOS;
  446. }
  447. /**
  448. * 查询显示的统计栏位
  449. *
  450. * @param addPatentCountDTO
  451. * @return
  452. */
  453. public List<GetAllPatentCountVO> setShowCountColumns(AddPatentCountDTO addPatentCountDTO) {
  454. Integer taskId = addPatentCountDTO.getTaskId();
  455. Integer projectId = addPatentCountDTO.getProjectId();
  456. //根据登录人id和type查询
  457. PersonnelVO personnelVO = new PersonnelVO();
  458. try {
  459. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  460. } catch (Exception e) {
  461. throw new UnLoginException("未登录");
  462. }
  463. String userId = personnelVO.getId();
  464. String key = "";
  465. if (taskId != null) {
  466. key = SecureUtil.md5(RedisConf.TASK_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + taskId);
  467. } else {
  468. key = SecureUtil.md5(RedisConf.PROJECT_FIELD_COUNT + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId);
  469. }
  470. Boolean flag = true;
  471. List<GetAllPatentCountVO> fieldVOS = addPatentCountDTO.getValue();
  472. redisUtil.set(RedisConf.FIELD_COUNT + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
  473. return fieldVOS;
  474. }
  475. /**
  476. * 查询证据组合表头
  477. *
  478. * @param getTabelColumDTO
  479. * @return
  480. */
  481. public List<PersonSelfFieldVO> getEvidenceReasonTableColumns(GetTabelColumDTO getTabelColumDTO) {
  482. Integer projectId = getTabelColumDTO.getProjectId();
  483. String tableName = getTabelColumDTO.getTableName();
  484. if (tableName == null||tableName.equals("")) {
  485. tableName = "evidenceReason";
  486. }
  487. //根据登录人id和type查询
  488. PersonnelVO personnelVO = new PersonnelVO();
  489. try {
  490. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  491. } catch (Exception e) {
  492. throw new UnLoginException("未登录");
  493. }
  494. String userId = personnelVO.getId();
  495. String key = "";
  496. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.EVIDENCE_REASON + RedisConf.SYMBOL_COLON + projectId);
  497. String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
  498. String json = redisUtil.get(redisKey);
  499. String fieldJson = "";
  500. //如果查到
  501. List<PersonSelfFieldVO> reFieldVos = new ArrayList<>();
  502. if (StringUtils.isNotEmpty(json)) {
  503. reFieldVos = JsonUtils.jsonToList(json, PersonSelfFieldVO.class);
  504. }
  505. try {
  506. fieldJson = CommonService.readJsonFile(tableName + ".json");
  507. } catch (Exception e) {
  508. throw new XiaoShiException("不存在此表");
  509. }
  510. List<PersonSelfFieldVO> fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class);
  511. if (fieldVOS == null) {
  512. throw new XiaoShiException("不存在此表");
  513. }
  514. Boolean flag = true;
  515. LambdaQueryWrapper<ReportProject> queryWrapper =new LambdaQueryWrapper<>();
  516. queryWrapper.eq(ReportProject::getProjectId,projectId);
  517. ReportProject reportProject =reportProjectService.getOne(queryWrapper,false);
  518. if(reportProject.getIfSecondInvalid()!=null&&reportProject.getIfSecondInvalid())
  519. {
  520. fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfShow()) || item.getType().equals("second")).collect(Collectors.toList());
  521. }
  522. else {
  523. fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfShow())).collect(Collectors.toList());
  524. }
  525. if (fieldVOS == null || fieldVOS.size() == 0) {
  526. throw new XiaoShiException("表中无字段");
  527. }
  528. //装载顺序
  529. for (PersonSelfFieldVO item : fieldVOS) {
  530. if (StringUtils.isNotEmpty(json)) {
  531. PersonSelfFieldVO personSelfFieldVO = reFieldVos.stream().filter(t -> t.getValue().equals(item.getValue()) && t.getName().equals(item.getName())).findFirst().orElse(null);
  532. if (personSelfFieldVO == null) {
  533. item.setIfHidden(true);
  534. reFieldVos.add(item);
  535. }
  536. } else {
  537. if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) {
  538. item.setIfHidden(true);
  539. } else {
  540. item.setIfHidden(false);
  541. }
  542. reFieldVos.add(item);
  543. }
  544. }
  545. return reFieldVos;
  546. }
  547. public List<PersonSelfFieldVO> setEvidenceReasonTableColumns(AddSelfFieldDTO addSelfFieldDTO) {
  548. PersonnelVO personnelVO = new PersonnelVO();
  549. try {
  550. personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  551. } catch (Exception e) {
  552. throw new UnLoginException("未登录");
  553. }
  554. String userId = personnelVO.getId();
  555. String tableName = addSelfFieldDTO.getTableName();
  556. if (tableName == null||tableName.equals("")) {
  557. tableName = "evidenceReason";
  558. }
  559. Integer projectId = addSelfFieldDTO.getProjectId();
  560. List<PersonSelfFieldVO> personSelfFieldVOS = addSelfFieldDTO.getValue();
  561. personSelfFieldVOS = personSelfFieldVOS.stream().filter(item -> item.getIfHidden() != null && item.getIfHidden().equals(false)).collect(Collectors.toList());
  562. String key = "";
  563. key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.EVIDENCE_REASON + RedisConf.SYMBOL_COLON + projectId);
  564. String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
  565. redisUtil.set(redisKey, JsonUtils.objectToJson(personSelfFieldVOS));
  566. return personSelfFieldVOS;
  567. }
  568. }