ConceptFacade.java 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444
  1. package com.diagbot.facade;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.diagbot.client.ICSSManServiceClient;
  6. import com.diagbot.client.UserServiceClient;
  7. import com.diagbot.dto.ConceptBaseDTO;
  8. import com.diagbot.dto.ConceptRes;
  9. import com.diagbot.dto.GetAllConceptDTO;
  10. import com.diagbot.dto.GetAllForRelationDTO;
  11. import com.diagbot.dto.GetAllInformationDTO;
  12. import com.diagbot.dto.GetAllLisConceptDTO;
  13. import com.diagbot.dto.GetConceptInfoDTO;
  14. import com.diagbot.dto.GetConceptInfoDetailDTO;
  15. import com.diagbot.dto.RespDTO;
  16. import com.diagbot.entity.Concept;
  17. import com.diagbot.entity.ConceptCommon;
  18. import com.diagbot.entity.Lexicon;
  19. import com.diagbot.entity.LibraryInfo;
  20. import com.diagbot.entity.QuestionInfo;
  21. import com.diagbot.entity.Relation;
  22. import com.diagbot.entity.wrapper.ConceptWrapper;
  23. import com.diagbot.enums.IsDeleteEnum;
  24. import com.diagbot.enums.LexiconRSTypeEnum;
  25. import com.diagbot.enums.LexiconTypeEnum;
  26. import com.diagbot.exception.CommonErrorCode;
  27. import com.diagbot.exception.CommonException;
  28. import com.diagbot.service.ConceptCommonService;
  29. import com.diagbot.service.ConceptService;
  30. import com.diagbot.service.LibraryInfoService;
  31. import com.diagbot.service.impl.ConceptServiceImpl;
  32. import com.diagbot.util.BeanUtil;
  33. import com.diagbot.util.Cn2SpellUtil;
  34. import com.diagbot.util.DateUtil;
  35. import com.diagbot.util.EntityUtil;
  36. import com.diagbot.util.IntegerUtil;
  37. import com.diagbot.util.ListUtil;
  38. import com.diagbot.util.ParamConvertUtil;
  39. import com.diagbot.util.RespDTOUtil;
  40. import com.diagbot.util.SqlExecuteUtil;
  41. import com.diagbot.util.StringUtil;
  42. import com.diagbot.util.UserUtils;
  43. import com.diagbot.vo.AddConceptInfoDetailVO;
  44. import com.diagbot.vo.AddConceptInfoVO;
  45. import com.diagbot.vo.ConceptExistVO;
  46. import com.diagbot.vo.ConceptSearchVO;
  47. import com.diagbot.vo.ConceptTypeVO;
  48. import com.diagbot.vo.GetAllConceptVO;
  49. import com.diagbot.vo.GetAllForRelationVO;
  50. import com.diagbot.vo.GetAllInformationVO;
  51. import com.diagbot.vo.GetAllLisConceptVO;
  52. import com.diagbot.vo.GetConceptInfoDetailVO;
  53. import com.diagbot.vo.GetConceptPacInfosVO;
  54. import com.diagbot.vo.IdListVO;
  55. import com.diagbot.vo.IndexLexiconVO;
  56. import com.diagbot.vo.IndexVO;
  57. import com.diagbot.vo.KLQuestionVO;
  58. import com.diagbot.vo.RemoveConceptInfoVO;
  59. import com.google.common.collect.Lists;
  60. import org.apache.commons.lang.time.DateFormatUtils;
  61. import org.apache.poi.hssf.usermodel.HSSFDateUtil;
  62. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  63. import org.apache.poi.ss.usermodel.Cell;
  64. import org.apache.poi.ss.usermodel.Row;
  65. import org.apache.poi.ss.usermodel.Sheet;
  66. import org.apache.poi.ss.usermodel.Workbook;
  67. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  68. import org.springframework.beans.factory.annotation.Autowired;
  69. import org.springframework.beans.factory.annotation.Qualifier;
  70. import org.springframework.stereotype.Component;
  71. import org.springframework.web.multipart.MultipartFile;
  72. import java.io.InputStream;
  73. import java.text.DecimalFormat;
  74. import java.util.ArrayList;
  75. import java.util.Date;
  76. import java.util.HashMap;
  77. import java.util.List;
  78. import java.util.Map;
  79. import java.util.stream.Collectors;
  80. /**
  81. * @Description: 术语查询业务层
  82. * @author: Weixuan Huang
  83. * @time: 2019/1/14 16:17
  84. */
  85. @Component
  86. public class ConceptFacade extends ConceptServiceImpl {
  87. @Autowired
  88. private LibraryInfoFacade libraryinfoFacade;
  89. @Autowired
  90. private RelationFacade relationFacade;
  91. @Autowired
  92. @Qualifier("libraryInfoServiceImpl")
  93. private LibraryInfoService libraryInfoService;
  94. @Autowired
  95. @Qualifier("conceptServiceImpl")
  96. private ConceptService conceptService;
  97. @Autowired
  98. @Qualifier("conceptCommonServiceImpl")
  99. private ConceptCommonService conceptCommonService;
  100. @Autowired
  101. private UserServiceClient userServiceClient;
  102. @Autowired
  103. private LexiconFacade lexiconFacade;
  104. @Autowired
  105. private ConceptCommonFacade conceptCommonFacade;
  106. @Autowired
  107. private LisMappingFacade lisMappingFacade;
  108. @Autowired
  109. private ICSSManServiceClient icssManServiceClient;
  110. /**
  111. * 获取所有化验公表项
  112. *
  113. * @param getAllLisConceptVO
  114. * @return
  115. */
  116. public List<GetAllLisConceptDTO> getAllLisConcept(GetAllLisConceptVO getAllLisConceptVO) {
  117. List<GetAllLisConceptDTO> getAllLisConceptDTOList = new ArrayList<>();
  118. QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
  119. conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
  120. conceptQe.eq("lib_type", LexiconTypeEnum.LIS_TABLES.getKey());
  121. conceptQe.like(StringUtil.isNotEmpty(getAllLisConceptVO.getConceptName()), "lib_name", getAllLisConceptVO.getConceptName());
  122. List<Concept> conceptList = list(conceptQe);
  123. conceptList.forEach(i -> {
  124. if (getAllLisConceptVO.getExcludedConceptNames() != null
  125. && getAllLisConceptVO.getExcludedConceptNames().contains(i.getLibName())) {
  126. return;
  127. }
  128. GetAllLisConceptDTO getAllLisConceptDTO = new GetAllLisConceptDTO();
  129. getAllLisConceptDTO.setConceptId(i.getId());
  130. getAllLisConceptDTO.setConceptName(i.getLibName());
  131. getAllLisConceptDTOList.add(getAllLisConceptDTO);
  132. });
  133. //return this.baseMapper.getAllLisConcept(getAllLisConceptVO);
  134. return getAllLisConceptDTOList;
  135. }
  136. /**
  137. * 获取所有医学术语命名
  138. *
  139. * @param getAllConceptVO
  140. * @return
  141. */
  142. public List<GetAllConceptDTO> getAllConcept(GetAllConceptVO getAllConceptVO) {
  143. List<GetAllConceptDTO> getAllConceptDTOList = Lists.newArrayList();
  144. if (StringUtil.isBlank(getAllConceptVO.getName())) {
  145. return getAllConceptDTOList;
  146. }
  147. QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
  148. libraryInfoQe.eq("is_deleted", IsDeleteEnum.N.getKey());
  149. libraryInfoQe.eq(getAllConceptVO.getIsConcept() != null, "is_concept", getAllConceptVO.getIsConcept());
  150. libraryInfoQe.like("name", getAllConceptVO.getName());
  151. List<LibraryInfo> libraryInfoList = libraryinfoFacade.list(libraryInfoQe);
  152. //过滤掉非概念术语
  153. if (getAllConceptVO.getIsConcept() != null && getAllConceptVO.getIsConcept() == 1) {
  154. QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
  155. conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
  156. conceptQe.in("id", libraryInfoList.stream().map(i -> i.getConceptId()).distinct().collect(Collectors.toList()));
  157. Map<Long, Concept> conceptMap = list(conceptQe).stream().collect(Collectors.toMap(Concept::getId, i -> i));
  158. libraryInfoList.forEach(i -> {
  159. if (conceptMap.get(i.getConceptId()) == null || conceptMap.get(i.getConceptId()).getLibId().intValue() != i.getId().intValue()
  160. || (getAllConceptVO.getExcludedConceptIds() != null && getAllConceptVO.getExcludedConceptIds().contains(i.getConceptId()))) {
  161. i.setIsDeleted(IsDeleteEnum.Y.getKey());
  162. }
  163. });
  164. libraryInfoList = libraryInfoList.stream().filter(i -> i.getIsDeleted().equals(IsDeleteEnum.N.getKey())).collect(Collectors.toList());
  165. }
  166. /*//添加过术语医学属性的过滤掉
  167. if (getAllConceptVO.getIsMedical() != null && getAllConceptVO.getIsMedical() == 1) {
  168. QueryWrapper<Medical> medicalQe = new QueryWrapper<>();
  169. medicalQe.eq("is_deleted", "N");
  170. medicalQe.in("concept_id", libraryInfoList.stream().map(i -> i.getConceptId()).collect(Collectors.toList()));
  171. Map<Long, Medical> medicalMap = medicalFacade.list(medicalQe).stream().collect(Collectors.toMap(Medical::getConceptId, i -> i));
  172. libraryInfoList = libraryInfoList.stream().filter(i -> {
  173. if (medicalMap.get(i.getConceptId()) == null) {
  174. return true;
  175. } else {
  176. return false;
  177. }
  178. }).collect(Collectors.toList());
  179. }*/
  180. getAllConceptDTOList = BeanUtil.listCopyTo(libraryInfoList, GetAllConceptDTO.class);
  181. getAllConceptDTOList.forEach(i -> {
  182. i.setType(LexiconTypeEnum.getName(i.getTypeId().intValue()));
  183. i.setNameAndType(i.getName() + "(" + i.getType() + ")");
  184. });
  185. return getAllConceptDTOList;
  186. }
  187. /**
  188. * 获取所有概念(术语关系维护时筛选使用)
  189. *
  190. * @param getAllForRelationVO
  191. * @return
  192. */
  193. public List<GetAllForRelationDTO> getAllForRelation(GetAllForRelationVO getAllForRelationVO) {
  194. List<GetAllForRelationDTO> retList = Lists.newArrayList();
  195. if(StringUtil.isNotBlank(getAllForRelationVO.getName())||getAllForRelationVO.getTypeId()!=null){
  196. QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
  197. conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
  198. conceptQe.like(StringUtil.isNotBlank(getAllForRelationVO.getName()),"lib_name", getAllForRelationVO.getName());
  199. conceptQe.eq(getAllForRelationVO.getTypeId()!=null,"lib_type", getAllForRelationVO.getTypeId());
  200. List<Concept> conceptList = list(conceptQe);
  201. if(ListUtil.isNotEmpty(conceptList)){
  202. Map<Long, Long> reCouMap = new HashMap<>();
  203. if (getAllForRelationVO.getRelationPosition() != 3) {
  204. if (getAllForRelationVO.getRelationId() == null) {
  205. throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "关系类型id必传!");
  206. }
  207. List<Long> conceptIdList = conceptList.stream().map(i -> i.getId()).collect(Collectors.toList());
  208. QueryWrapper<Relation> relationQe = new QueryWrapper<>();
  209. relationQe.eq("relation_id", getAllForRelationVO.getRelationId());
  210. List<Long> relationConceptIdList = Lists.newArrayList();
  211. if(getAllForRelationVO.getRelationTypeId() != null){
  212. QueryWrapper<Concept> conceptQe1 = new QueryWrapper<>();
  213. conceptQe1.eq("lib_type", getAllForRelationVO.getRelationTypeId());
  214. relationConceptIdList = list(conceptQe1).stream().map(i->i.getId()).collect(Collectors.toList());
  215. }
  216. if(getAllForRelationVO.getRelationConceptId() != null){
  217. relationConceptIdList.add(getAllForRelationVO.getRelationConceptId());
  218. }
  219. if(ListUtil.isNotEmpty(relationConceptIdList)){
  220. if (getAllForRelationVO.getRelationPosition() == 1) {
  221. relationQe.in("start_id", conceptIdList);
  222. relationQe.in("end_id", relationConceptIdList);
  223. reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getStartId, Collectors.counting()));
  224. }else{
  225. relationQe.in("end_id", conceptIdList);
  226. relationQe.in("start_id", relationConceptIdList);
  227. reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getEndId, Collectors.counting()));
  228. }
  229. }
  230. }
  231. for (Concept i : conceptList) {
  232. if (reCouMap.get(i.getId()) != null
  233. || (getAllForRelationVO.getExcludedConceptIds() != null && getAllForRelationVO.getExcludedConceptIds().contains(i.getId()))
  234. || (getAllForRelationVO.getRelationConceptId() != null && getAllForRelationVO.getRelationConceptId() == i.getId())) {
  235. continue;
  236. }
  237. GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
  238. getAllForRelationDTO.setConceptId(i.getId());
  239. getAllForRelationDTO.setConceptName(i.getLibName());
  240. getAllForRelationDTO.setConceptNameType(i.getLibName()+"("+LexiconTypeEnum.getName(i.getLibType().intValue())+")");
  241. retList.add(getAllForRelationDTO);
  242. }
  243. }
  244. }
  245. return retList;
  246. }
  247. /**
  248. * 获取医学术语命名列表
  249. *
  250. * @param getAllInformationVO
  251. * @return
  252. */
  253. public IPage<GetAllInformationDTO> getAllInformation(GetAllInformationVO getAllInformationVO) {
  254. Page<GetAllInformationDTO> getAllInformationDTOPage = new Page<>();
  255. Page<Concept> conceptPage = new Page<>(getAllInformationVO.getCurrent(), getAllInformationVO.getSize());
  256. QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
  257. if (StringUtil.isNotBlank(getAllInformationVO.getLibName())) {
  258. QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<>();
  259. libraryInfoQe.eq("is_deleted", IsDeleteEnum.N.getKey());
  260. libraryInfoQe.like("name", getAllInformationVO.getLibName());
  261. libraryInfoQe.eq(StringUtil.isNotBlank(getAllInformationVO.getType()), "type_id", LexiconTypeEnum.getKey(getAllInformationVO.getType()));
  262. List<Long> conceptIdList = libraryinfoFacade.list(libraryInfoQe).stream().map(i -> i.getConceptId()).distinct().collect(Collectors.toList());
  263. if (ListUtil.isNotEmpty(conceptIdList)) {
  264. conceptQe.in("id", conceptIdList);
  265. } else {
  266. conceptQe.eq("id", -999999999);
  267. }
  268. }
  269. conceptQe.like(StringUtil.isNotBlank(getAllInformationVO.getName()), "lib_name", getAllInformationVO.getName());
  270. conceptQe.eq(StringUtil.isNotBlank(getAllInformationVO.getType()), "lib_type", LexiconTypeEnum.getKey(getAllInformationVO.getType()));
  271. conceptQe.eq(StringUtil.isNotBlank(getAllInformationVO.getIsDeleted()), "is_deleted", getAllInformationVO.getIsDeleted());
  272. conceptQe.orderByDesc("sort_deleted");
  273. conceptQe.orderByDesc("gmt_modified");
  274. conceptQe.orderByDesc("id");
  275. IPage<Concept> iPage = this.page(conceptPage, conceptQe);
  276. BeanUtil.copyProperties(iPage, getAllInformationDTOPage);
  277. if (ListUtil.isNotEmpty(iPage.getRecords())) {
  278. List<GetAllInformationDTO> getAllInformationDTOList = Lists.newArrayList();
  279. List<Long> conceptIds = iPage.getRecords().stream().map(i -> i.getId()).collect(Collectors.toList());
  280. QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<>();
  281. libraryInfoQe.eq("is_deleted", IsDeleteEnum.N.getKey());
  282. libraryInfoQe.in("concept_id", conceptIds);
  283. Map<Long, List<LibraryInfo>> libraryInfoListMap = libraryinfoFacade.list(libraryInfoQe).stream().collect(Collectors.groupingBy(LibraryInfo::getConceptId));
  284. List<String> userIds = iPage.getRecords().stream().map(i -> i.getModifier()).distinct().collect(Collectors.toList());
  285. RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(userIds);
  286. RespDTOUtil.respNGDealCover(respDTO, "获取用户信息失败");
  287. iPage.getRecords().forEach(i -> {
  288. GetAllInformationDTO getAllInformationDTO = new GetAllInformationDTO();
  289. getAllInformationDTO.setConceptId(i.getId());
  290. getAllInformationDTO.setLibName(i.getLibName());
  291. getAllInformationDTO.setLibType(LexiconTypeEnum.getName(i.getLibType().intValue()));
  292. getAllInformationDTO.setIsDeleted(i.getIsDeleted());
  293. getAllInformationDTO.setOperName(respDTO.data.get(i.getModifier()));
  294. getAllInformationDTO.setOperTime(i.getGmtModified());
  295. if (libraryInfoListMap.get(i.getId()) != null) {
  296. getAllInformationDTO.setOtherNames(libraryInfoListMap.get(i.getId()).stream().sorted((a, b) -> b.getIsConcept() - a.getIsConcept()).map(k -> k.getName()).collect(Collectors.joining("、")));
  297. }
  298. getAllInformationDTOList.add(getAllInformationDTO);
  299. });
  300. getAllInformationDTOPage.setRecords(getAllInformationDTOList);
  301. }
  302. return getAllInformationDTOPage;
  303. }
  304. /**
  305. * 医学术语命名删除或者恢复
  306. *
  307. * @param removeConceptInfoVO
  308. * @return
  309. */
  310. public Boolean removeConceptInfo(RemoveConceptInfoVO removeConceptInfoVO) {
  311. /*StringBuffer sbf = new StringBuffer();
  312. QueryWrapper<Medical> medicalQe = new QueryWrapper<Medical>();
  313. medicalQe.eq("is_deleted", "N");
  314. medicalQe.eq("concept_id", removeConceptInfoVO.getConceptId());
  315. if(medicalFacade.list(medicalQe).size()>0){
  316. sbf.append("请先解除医学属性关联 ");
  317. }
  318. QueryWrapper<Relation> relationQe = new QueryWrapper<Relation>();
  319. relationQe.eq("is_deleted", "N");
  320. relationQe.and(i->i.eq("start_id", removeConceptInfoVO.getConceptId()).or().eq("end_id", removeConceptInfoVO.getConceptId()));
  321. if(relationFacade.list(relationQe).size()>0){
  322. sbf.append("请先解除术语关系关联 ");
  323. }
  324. QueryWrapper<ConceptDetail> libraryDetailQe = new QueryWrapper<ConceptDetail>();
  325. libraryDetailQe.eq("is_deleted", "N");
  326. libraryDetailQe.eq("concept_id", removeConceptInfoVO.getConceptId());
  327. if(libraryDetailFacade.list(libraryDetailQe).size()>0){
  328. sbf.append("请先解除医学静态知识关联 ");
  329. }
  330. if(sbf.length()>0){
  331. throw new CommonException(CommonErrorCode.RPC_ERROR,sbf.toString());
  332. }*/
  333. String currentUser = UserUtils.getCurrentPrincipleID();
  334. Date now = DateUtil.now();
  335. /*QueryWrapper<LibraryInfo> libraryInfoQe1 = new QueryWrapper<>();
  336. libraryInfoQe1.eq("concept_id", removeConceptInfoVO.getConceptId());
  337. libraryInfoQe1.eq("is_concept", 0);
  338. libraryinfoFacade.remove(libraryInfoQe1);
  339. QueryWrapper<LibraryInfo> libraryInfoQe2 = new QueryWrapper<>();
  340. libraryInfoQe2.eq("concept_id", removeConceptInfoVO.getConceptId());
  341. LibraryInfo libraryInfo = new LibraryInfo();
  342. libraryInfo.setIsDeleted("Y");
  343. libraryInfo.setGmtModified(now);
  344. libraryInfo.setModifier(currentUser);
  345. libraryinfoFacade.update(libraryInfo, libraryInfoQe2);*/
  346. /*Concept concept = new Concept();
  347. concept.setId(removeConceptInfoVO.getConceptId());
  348. concept.setIsDeleted("Y");
  349. concept.setModifier(currentUser);
  350. concept.setGmtModified(now);
  351. this.updateById(concept);*/
  352. Concept concept = this.getById(removeConceptInfoVO.getConceptId());
  353. if (concept == null) {
  354. throw new CommonException(CommonErrorCode.NOT_EXISTS);
  355. }
  356. if (concept.getIsDeleted().equals(removeConceptInfoVO.getIsDeleted())) {
  357. if (removeConceptInfoVO.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
  358. throw new CommonException(CommonErrorCode.NOT_EXISTS, "该数据已删除!");
  359. }
  360. if (removeConceptInfoVO.getIsDeleted().equals(IsDeleteEnum.N.getKey())) {
  361. throw new CommonException(CommonErrorCode.IS_EXISTS, "该数据已恢复!");
  362. }
  363. }
  364. //清理缓存
  365. this.cacheClearByConceptId(concept.getId());
  366. concept.setIsDeleted(removeConceptInfoVO.getIsDeleted());
  367. concept.setModifier(currentUser);
  368. concept.setGmtModified(now);
  369. this.updateById(concept);
  370. return true;
  371. }
  372. /**
  373. * 获取医学术语命名详情
  374. *
  375. * @param getConceptInfoDetailVO
  376. * @return libName-标准术语,otherNames-同义词
  377. */
  378. public GetConceptInfoDTO getConceptInfoDetail(GetConceptInfoDetailVO getConceptInfoDetailVO) {
  379. GetConceptInfoDTO getConceptInfoDTO = new GetConceptInfoDTO();
  380. Concept concept = this.getById(getConceptInfoDetailVO.getConceptId());
  381. if (concept == null) {
  382. throw new CommonException(CommonErrorCode.NOT_EXISTS);
  383. }
  384. QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
  385. libraryInfoQe.eq("concept_id", getConceptInfoDetailVO.getConceptId());
  386. List<GetConceptInfoDetailDTO> getConceptInfoDetailDTOList = BeanUtil.listCopyTo(libraryinfoFacade.list(libraryInfoQe), GetConceptInfoDetailDTO.class);
  387. getConceptInfoDetailDTOList.forEach(i -> {
  388. i.setType(LexiconTypeEnum.getName(i.getTypeId().intValue()));
  389. });
  390. getConceptInfoDTO.setLibName(getConceptInfoDetailDTOList.stream().filter(i -> i.getIsConcept() != null && i.getIsConcept() == 1).collect(Collectors.toList()));
  391. getConceptInfoDTO.setOtherNames(getConceptInfoDetailDTOList.stream().filter(i -> i.getIsConcept() == null || i.getIsConcept() == 0).collect(Collectors.toList()));
  392. Integer isHasCommon = lexiconFacade.getById(concept.getLibType()).getIsHasCommon();
  393. getConceptInfoDTO.setIsHasCommon(isHasCommon);
  394. if (isHasCommon == 1) {
  395. QueryWrapper<ConceptCommon> conceptCommonQe = new QueryWrapper<>();
  396. conceptCommonQe.eq("concept_id", getConceptInfoDetailVO.getConceptId());
  397. ConceptCommon conceptCommon = conceptCommonFacade.getOne(conceptCommonQe);
  398. if (conceptCommon != null) {
  399. getConceptInfoDTO.setSexType(conceptCommon.getSexType());
  400. getConceptInfoDTO.setMinAge(conceptCommon.getMinAge());
  401. getConceptInfoDTO.setMaxAge(conceptCommon.getMaxAge());
  402. }
  403. }
  404. return getConceptInfoDTO;
  405. }
  406. /**
  407. * 医学术语命名添加或者编辑
  408. *
  409. * @param addConceptInfoVO
  410. * @return
  411. */
  412. public Boolean addConceptInfo(AddConceptInfoVO addConceptInfoVO) {
  413. String lineNumStr = "";
  414. if (addConceptInfoVO.getLineNum() != null) {
  415. lineNumStr = "第" + addConceptInfoVO.getLineNum() + "行";
  416. }
  417. //String regEx = "[0-9]+|[`~·!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]+";
  418. String regEx = "[0-9]+";
  419. for (AddConceptInfoDetailVO i : addConceptInfoVO.getDetailList()) {
  420. if (i.getName().matches(regEx)) {
  421. //throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "无法输入纯数字或者纯字符,请输入正确数据!");
  422. throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "无法输入纯数字,请输入正确数据!");
  423. }
  424. }
  425. if (addConceptInfoVO.getMaxAge() < addConceptInfoVO.getMinAge()) {
  426. throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "症状发生的最小年龄大于症状发生的最大年龄!");
  427. }
  428. if (addConceptInfoVO.getDetailList().stream().distinct().count() != addConceptInfoVO.getDetailList().size()) {
  429. throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "存在重复数据!");
  430. }
  431. List<AddConceptInfoDetailVO> addConceptInfoDetailVOMainList = addConceptInfoVO.getDetailList().stream().filter(i -> i.getIsConcept() == 1).collect(Collectors.toList());
  432. if (addConceptInfoDetailVOMainList.size() == 0) {
  433. throw new CommonException(CommonErrorCode.PARAM_IS_NULL, lineNumStr + "无标准术语!");
  434. }
  435. if (addConceptInfoDetailVOMainList.size() > 1) {
  436. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, lineNumStr + "标准术语只能有一个!");
  437. }
  438. QueryWrapper<Lexicon> lexiconQe = new QueryWrapper<>();
  439. lexiconQe.eq("name", addConceptInfoVO.getType());
  440. Lexicon lexicon = lexiconFacade.getOne(lexiconQe);
  441. if (lexicon == null) {
  442. throw new CommonException(CommonErrorCode.NOT_EXISTS, lineNumStr + "数据有误,该类型信息在数据库中不存在!");
  443. }
  444. List<LibraryInfo> saveOrUpdateLibraryInfoList = new ArrayList<>();
  445. AddConceptInfoDetailVO addConceptInfoDetailVOMain = addConceptInfoDetailVOMainList.get(0);//提交过来的标准术语
  446. //查询当前添加的术语是否已经在数据库中
  447. QueryWrapper<LibraryInfo> libraryInfoQe1 = new QueryWrapper<>();
  448. libraryInfoQe1.eq("type_id", lexicon.getId());
  449. libraryInfoQe1.in("name", addConceptInfoVO.getDetailList().stream().map(i -> i.getName()).collect(Collectors.toList()));
  450. List<LibraryInfo> libraryInfoList = libraryinfoFacade.list(libraryInfoQe1);
  451. String currentUser = UserUtils.getCurrentPrincipleID();
  452. Date now = DateUtil.now();
  453. Map<String, LibraryInfo> libraryInfoMap = libraryInfoList.stream().collect(Collectors.toMap(LibraryInfo::getName, i -> i));
  454. LibraryInfo libraryInfoMain = libraryInfoMap.get(addConceptInfoDetailVOMain.getName());
  455. Concept concept = new Concept();
  456. Long conceptId = null;
  457. if (libraryInfoMain == null) {
  458. libraryInfoMain = new LibraryInfo();
  459. BeanUtil.copyProperties(addConceptInfoDetailVOMain, libraryInfoMain);
  460. libraryInfoMain.setGmtCreate(now);
  461. libraryInfoMain.setCreator(currentUser);
  462. libraryInfoMain.setTypeId(lexicon.getId());
  463. libraryinfoFacade.save(libraryInfoMain);
  464. concept.setLibId(libraryInfoMain.getId());
  465. concept.setLibName(addConceptInfoDetailVOMain.getName());
  466. concept.setLibType(lexicon.getId());
  467. concept.setGmtCreate(now);
  468. concept.setCreator(currentUser);
  469. concept.setId(addConceptInfoVO.getConceptId());
  470. saveOrUpdate(concept);
  471. conceptId = concept.getId();
  472. } else {
  473. conceptId = libraryInfoMain.getConceptId();
  474. int ckConceptId = conceptId.intValue();
  475. concept = getById(conceptId);
  476. //如果标准词之前作为同义词被其他占用的情况
  477. if (libraryInfoMain.getIsConcept() == 1) {
  478. //新增操作时,已经建立的标准词提示
  479. if (addConceptInfoVO.getLineNum() == null && addConceptInfoVO.getConceptId() == null) {
  480. if (concept.getIsDeleted().equals("N")) {
  481. throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已经建立!");
  482. } else {
  483. throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已经建立且处于已删除状态,可前往列表中恢复该条数据!");
  484. }
  485. } else if (addConceptInfoVO.getConceptId().intValue() != ckConceptId) {
  486. throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "标准术语已被占用!");
  487. }
  488. } else if (addConceptInfoVO.getLineNum() == null && addConceptInfoVO.getConceptId() == null && concept != null
  489. || libraryInfoList.stream().filter(i -> i.getConceptId().intValue() == ckConceptId).count() == 1) {
  490. throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "标准术语已作为同义词被占用!");
  491. }
  492. }
  493. //先删除概念下的同义词,后续再插入
  494. QueryWrapper<LibraryInfo> libraryInfoQe2 = new QueryWrapper<>();
  495. libraryInfoQe2.eq("concept_id", conceptId);
  496. libraryInfoQe2.ne("id", libraryInfoMain.getId());
  497. libraryinfoFacade.remove(libraryInfoQe2);
  498. StringBuffer sbf = new StringBuffer();
  499. for (AddConceptInfoDetailVO i : addConceptInfoVO.getDetailList()) {
  500. if (i.getIsConcept() == 1) {
  501. continue;
  502. }
  503. LibraryInfo libraryInfo = libraryInfoMap.get(i.getName());
  504. if (libraryInfo == null) {
  505. libraryInfo = new LibraryInfo();
  506. libraryInfo.setGmtCreate(now);
  507. libraryInfo.setCreator(currentUser);
  508. } else if (libraryInfo.getConceptId().intValue() != conceptId.intValue()) {
  509. sbf.append(i.getName()).append(" ");
  510. continue;
  511. }
  512. libraryInfo.setName(i.getName());
  513. libraryInfo.setSpell(i.getSpell());
  514. libraryInfo.setRemark(i.getRemark());
  515. saveOrUpdateLibraryInfoList.add(libraryInfo);
  516. }
  517. if (sbf.length() > 0) {
  518. sbf.append("已被占用");
  519. throw new CommonException(CommonErrorCode.RPC_ERROR, sbf.toString());
  520. }
  521. for (LibraryInfo i : saveOrUpdateLibraryInfoList) {
  522. i.setId(null);
  523. i.setConceptId(conceptId);
  524. i.setTypeId(lexicon.getId());
  525. i.setIsConcept(0);
  526. i.setGmtModified(now);
  527. i.setModifier(currentUser);
  528. }
  529. libraryInfoMain.setIsConcept(1);
  530. libraryInfoMain.setRemark(addConceptInfoDetailVOMain.getRemark());
  531. libraryInfoMain.setSpell(addConceptInfoDetailVOMain.getSpell());
  532. libraryInfoMain.setConceptId(conceptId);
  533. libraryInfoMain.setGmtModified(now);
  534. libraryInfoMain.setModifier(currentUser);
  535. saveOrUpdateLibraryInfoList.add(libraryInfoMain);
  536. libraryInfoService.saveOrUpdateBatch(saveOrUpdateLibraryInfoList);
  537. //清理原名称对应标签缓存
  538. this.cacheClearByConceptId(conceptId);
  539. concept.setId(conceptId);
  540. concept.setLibId(libraryInfoMain.getId());
  541. concept.setLibName(libraryInfoMain.getName());
  542. concept.setLibType(libraryInfoMain.getTypeId());
  543. concept.setGmtModified(now);
  544. concept.setModifier(currentUser);
  545. updateById(concept);
  546. if (lexicon.getIsHasCommon() == 1) {
  547. QueryWrapper<ConceptCommon> conceptCommonQe = new QueryWrapper<>();
  548. conceptCommonQe.eq("concept_id", conceptId);
  549. ConceptCommon conceptCommon = conceptCommonFacade.getOne(conceptCommonQe);
  550. if (conceptCommon == null) {
  551. conceptCommon = new ConceptCommon();
  552. conceptCommon.setGmtCreate(now);
  553. conceptCommon.setCreator(currentUser);
  554. }
  555. BeanUtil.copyProperties(addConceptInfoVO, conceptCommon);
  556. conceptCommon.setConceptId(conceptId);
  557. conceptCommon.setGmtModified(now);
  558. conceptCommon.setModifier(currentUser);
  559. conceptCommonFacade.saveOrUpdate(conceptCommon);
  560. }
  561. return true;
  562. }
  563. /**
  564. * 医学术语命名excel文件导入
  565. *
  566. * @param file
  567. * @return
  568. */
  569. public Boolean conceptInfoExcelIm(MultipartFile file) {
  570. List<AddConceptInfoVO> addConceptInfoVOList = new ArrayList<>();
  571. StringBuffer sbf = new StringBuffer();
  572. InputStream inputStream = null;
  573. Workbook wb = null;
  574. try {
  575. if (!file.isEmpty()) {
  576. inputStream = file.getInputStream();
  577. if (inputStream.available() > 512000) {
  578. sbf.append("文件最大支持500KB!").append("<br/>");
  579. } else {
  580. String fileName = file.getOriginalFilename();
  581. if (fileName.lastIndexOf(".") != -1) {
  582. String type = fileName.substring(fileName.lastIndexOf("."));
  583. if (type.equals(".xls")) {
  584. wb = new HSSFWorkbook(inputStream);
  585. } else if (type.equals(".xlsx")) {
  586. wb = new XSSFWorkbook(inputStream);
  587. }
  588. if (wb != null) {
  589. Sheet sheet = wb.getSheetAt(0);
  590. int count = 0;
  591. String libName, libType, otherNames, remark, sexType, minAge, maxAge;
  592. //String regEx = "[0-9]+|[`~·!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]+";
  593. String regEx = "[0-9]+";
  594. String regExAge = "[0-9]|[1-9][0-9]|1[0-9]{2}|200";
  595. for (Row row : sheet) {
  596. count++;
  597. if (row == null) {
  598. continue;
  599. }
  600. // if (count == 1) {
  601. // title_1 = getValue(row.getCell(0)).trim().replace(" ", "");
  602. // title_2 = getValue(row.getCell(1)).trim().replace(" ", "");
  603. // title_3 = getValue(row.getCell(2)).trim().replace(" ", "");
  604. // title_4 = getValue(row.getCell(3)).trim().replace(" ", "");
  605. // continue;
  606. // }
  607. libName = getValue(row.getCell(0)).trim().replace(" ", "");
  608. libType = getValue(row.getCell(1)).trim().replace(" ", "");
  609. otherNames = getValue(row.getCell(2)).trim().replace(" ", "");
  610. remark = getValue(row.getCell(3)).trim().replace(" ", "");
  611. sexType = getValue(row.getCell(4)).trim().replace(" ", "");
  612. minAge = getValue(row.getCell(5)).trim().replace(" ", "");
  613. maxAge = getValue(row.getCell(6)).trim().replace(" ", "");
  614. if (count == 1) {
  615. //当前行是第一行时,libName、libType、otherNames、remark、sexType、minAge、maxAge是标题
  616. if (libName.indexOf("标准术语") == -1
  617. || libType.indexOf("类型") == -1
  618. || otherNames.indexOf("术语同义词") == -1
  619. || remark.indexOf("标准术语说明") == -1
  620. || sexType.indexOf("性别") == -1
  621. || minAge.indexOf("最小年龄") == -1
  622. || maxAge.indexOf("最大年龄") == -1) {
  623. sbf.append("导入数据不正确,请选择正确数据导入!").append("<br/>");
  624. break;
  625. } else {
  626. continue;
  627. }
  628. }
  629. if (StringUtil.isEmpty(libName) && StringUtil.isEmpty(libType)
  630. && StringUtil.isEmpty(otherNames) && StringUtil.isEmpty(remark)) {
  631. continue;
  632. }
  633. if (StringUtil.isEmpty(libName) || StringUtil.isEmpty(libType) || StringUtil.isEmpty(otherNames)) {
  634. sbf.append("第" + count + "行数据不完整;").append("<br/>");
  635. continue;
  636. }
  637. if (StringUtil.isNotEmpty(remark) && remark.length() > 120) {
  638. sbf.append("第" + count + "行导入错误,说明最大可输入120个字;").append("<br/>");
  639. continue;
  640. }
  641. if (StringUtil.isNotEmpty(sexType) && !sexType.matches("男|女|通用")) {
  642. sbf.append("第" + count + "行导入错误,性别须是男、女或者通用;").append("<br/>");
  643. }
  644. if ((StringUtil.isNotEmpty(minAge) && !minAge.matches(regExAge))
  645. || (StringUtil.isNotEmpty(maxAge) && !maxAge.matches(regExAge))) {
  646. sbf.append("第" + count + "行导入错误,年龄须是0-200;").append("<br/>");
  647. continue;
  648. }
  649. if (StringUtil.isNotEmpty(minAge)
  650. && StringUtil.isNotEmpty(maxAge)
  651. && Integer.parseInt(minAge) > Integer.parseInt(maxAge)) {
  652. sbf.append("第" + count + "行导入错误,症状发生的最小年龄大于症状发生的最大年龄;").append("<br/>");
  653. continue;
  654. }
  655. AddConceptInfoVO addConceptInfoVO = new AddConceptInfoVO();
  656. addConceptInfoVO.setLineNum(count);
  657. addConceptInfoVO.setName(libName);
  658. addConceptInfoVO.setType(libType);
  659. addConceptInfoVO.setMinAge(StringUtil.isEmpty(minAge) ? 0 : Integer.parseInt(minAge));
  660. addConceptInfoVO.setMaxAge(StringUtil.isEmpty(minAge) ? 200 : Integer.parseInt(maxAge));
  661. if (sexType.equals("男")) {
  662. addConceptInfoVO.setSexType(1);
  663. } else if (sexType.equals("女")) {
  664. addConceptInfoVO.setSexType(2);
  665. } else {
  666. addConceptInfoVO.setSexType(3);
  667. }
  668. List<AddConceptInfoDetailVO> detailList = new ArrayList<>();
  669. for (String nm : otherNames.split(",")) {
  670. if (StringUtil.isBlank(nm)) {
  671. continue;
  672. }
  673. if (nm.matches(regEx)) {
  674. sbf.append("第" + count + "行无法导入,导入数据无法为纯数字;").append("<br/>");
  675. break;
  676. }
  677. if (nm.length() > 30) {
  678. sbf.append("第" + count + "行导入错误,标准词和同义词最大字数不可超过30个字;").append("<br/>");
  679. break;
  680. }
  681. AddConceptInfoDetailVO addConceptInfoDetailVO = new AddConceptInfoDetailVO();
  682. addConceptInfoDetailVO.setName(nm);
  683. addConceptInfoDetailVO.setType(libType);
  684. addConceptInfoDetailVO.setSpell(Cn2SpellUtil.converterToFirstSpell(nm));
  685. if (libName.equals(nm)) {
  686. addConceptInfoDetailVO.setIsConcept(1);
  687. addConceptInfoDetailVO.setRemark(remark);
  688. } else {
  689. addConceptInfoDetailVO.setIsConcept(0);
  690. }
  691. detailList.add(addConceptInfoDetailVO);
  692. }
  693. addConceptInfoVO.setDetailList(detailList);
  694. addConceptInfoVOList.add(addConceptInfoVO);
  695. }
  696. } else {
  697. sbf.append("非excel文件无法解析!").append("<br/>");
  698. }
  699. } else {
  700. sbf.append("未知文件无法解析!").append("<br/>");
  701. }
  702. }
  703. } else {
  704. sbf.append("无文件上传!").append("<br/>");
  705. }
  706. } catch (Exception e) {
  707. sbf.append("解析失败!").append("<br/>");
  708. } finally {
  709. try {
  710. if (wb != null) {
  711. wb.close();
  712. }
  713. if (inputStream != null) {
  714. inputStream.close();
  715. }
  716. } catch (Exception e) {
  717. }
  718. }
  719. /*****************excel文件本身问题提醒************************/
  720. if (sbf.length() > 0) {
  721. throw new CommonException(CommonErrorCode.RPC_ERROR, sbf.toString());
  722. }
  723. // /**********************非规范的excel导入提醒*****************************************/
  724. // if (title_1.indexOf("标准术语") == -1
  725. // || title_2.indexOf("类型") == -1
  726. // || title_3.indexOf("术语同义词") == -1
  727. // || title_4.indexOf("标准术语说明") == -1) {
  728. // throw new CommonException(CommonErrorCode.RPC_ERROR, "导入数据不正确,请选择正确数据导入!");
  729. // }
  730. /****************************导入空文件************************/
  731. if (addConceptInfoVOList.size() == 0) {
  732. throw new CommonException(CommonErrorCode.RPC_ERROR, "导入数据不能为空!");
  733. }
  734. if (addConceptInfoVOList.size() > 5000) {
  735. throw new CommonException(CommonErrorCode.RPC_ERROR, "当前数据导入失败,单次导入最多可支持5千条数据导入");
  736. }
  737. /****************excel文件中所有术语存在重复提示---名字和类型一样即重复***********************/
  738. List<AddConceptInfoDetailVO> addConceptInfoDetailVOList = new ArrayList<>();
  739. addConceptInfoVOList.forEach(i -> {
  740. addConceptInfoDetailVOList.addAll(i.getDetailList());
  741. });
  742. Map<String, List<AddConceptInfoDetailVO>> addConceptInfoDetailVOListMap = addConceptInfoDetailVOList.stream().collect(Collectors.groupingBy(AddConceptInfoDetailVO::getName));
  743. for (String key : addConceptInfoDetailVOListMap.keySet()) {
  744. if (addConceptInfoDetailVOListMap.get(key).size() > 1 && addConceptInfoDetailVOListMap.get(key).stream().map(i -> i.getType()).distinct().count() == 1) {
  745. sbf.append(key).append(" ");
  746. }
  747. }
  748. if (sbf.length() > 0) {
  749. sbf.append("数据重复,请修改导入数据!");
  750. throw new CommonException(CommonErrorCode.RPC_ERROR, sbf.toString());
  751. }
  752. /*
  753. * 原来的
  754. * addConceptInfoVOList.forEach(i -> {
  755. addConceptInfo(i);
  756. });*/
  757. ////优化后
  758. QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<>();
  759. libraryInfoQe.in("name", addConceptInfoDetailVOList.stream().map(i -> i.getName()).distinct().collect(Collectors.toList()));
  760. Map<String, List<LibraryInfo>> libraryInfoListMap = libraryinfoFacade.list(libraryInfoQe).stream().collect(Collectors.groupingBy(LibraryInfo::getName));
  761. Map<String, Lexicon> lexiconMap = lexiconFacade.list().stream().collect(Collectors.toMap(Lexicon::getName, i -> i));
  762. String ckmsg = null;
  763. for (AddConceptInfoVO addConceptInfoVO : addConceptInfoVOList) {
  764. ckmsg = checkImConceptInfo(addConceptInfoVO, libraryInfoListMap, lexiconMap);
  765. if (StringUtil.isNotBlank(ckmsg)) {
  766. sbf.append("第").append(addConceptInfoVO.getLineNum()).append("行").append(ckmsg).append("<br/>");
  767. }
  768. }
  769. if (sbf.length() > 0) {
  770. throw new CommonException(CommonErrorCode.RPC_ERROR, sbf.toString());
  771. }
  772. saveAddConceptInfoVOList(addConceptInfoVOList);
  773. return true;
  774. }
  775. /**
  776. * 导入数据插入更新前校验
  777. *
  778. * @param addConceptInfoVO
  779. * @param libraryInfoListAllMap
  780. * @param lexiconMap
  781. * @return
  782. */
  783. public String checkImConceptInfo(AddConceptInfoVO addConceptInfoVO, Map<String, List<LibraryInfo>> libraryInfoListAllMap, Map<String, Lexicon> lexiconMap) {
  784. String currentUser = UserUtils.getCurrentPrincipleID();
  785. Date now = DateUtil.now();
  786. Concept concept = new Concept();
  787. ConceptCommon conceptCommon = null;
  788. List<LibraryInfo> libraryInfoList = Lists.newArrayList();
  789. List<AddConceptInfoDetailVO> addConceptInfoDetailVOMainList = addConceptInfoVO.getDetailList().stream().filter(i -> i.getIsConcept() == 1).collect(Collectors.toList());
  790. if (addConceptInfoDetailVOMainList.size() == 0) {
  791. return "同义词中缺少标准词本体!";
  792. }
  793. if (addConceptInfoDetailVOMainList.size() > 1) {
  794. return "标准术语只能有一个!";
  795. }
  796. Lexicon lexicon = lexiconMap.get(addConceptInfoVO.getType());
  797. if (lexicon == null) {
  798. return "数据有误,该类型信息在数据库中不存在!";
  799. }
  800. Long typeId = lexicon.getId();
  801. concept.setLibType(typeId);
  802. concept.setGmtModified(now);
  803. concept.setModifier(currentUser);
  804. if (lexicon.getIsHasCommon() == 1) {
  805. conceptCommon = new ConceptCommon();
  806. conceptCommon.setSexType(addConceptInfoVO.getSexType());
  807. conceptCommon.setMinAge(addConceptInfoVO.getMinAge());
  808. conceptCommon.setMaxAge(addConceptInfoVO.getMaxAge());
  809. conceptCommon.setGmtModified(now);
  810. conceptCommon.setModifier(currentUser);
  811. }
  812. List<LibraryInfo> extLibraryInfoList = Lists.newArrayList();
  813. addConceptInfoVO.getDetailList().forEach(a -> {
  814. List<LibraryInfo> libraryInfoListAll = libraryInfoListAllMap.get(a.getName());
  815. if (ListUtil.isNotEmpty(libraryInfoListAll)) {
  816. libraryInfoListAll = libraryInfoListAll.stream().filter(b -> b.getTypeId().intValue() == typeId.intValue()).collect(Collectors.toList());
  817. if (ListUtil.isNotEmpty(libraryInfoListAll)) {
  818. extLibraryInfoList.add(libraryInfoListAll.get(0));
  819. }
  820. }
  821. });
  822. Map<String, LibraryInfo> extLibraryInfoMap = extLibraryInfoList.stream().collect(Collectors.toMap(LibraryInfo::getName, i -> i));
  823. LibraryInfo libraryInfoMain = extLibraryInfoMap.get(addConceptInfoDetailVOMainList.get(0).getName());
  824. Long conceptId = null;
  825. if (libraryInfoMain == null) {
  826. conceptId = -9999l;
  827. concept.setGmtCreate(now);
  828. concept.setCreator(currentUser);
  829. if (conceptCommon != null) {
  830. conceptCommon.setGmtCreate(now);
  831. conceptCommon.setCreator(currentUser);
  832. }
  833. } else {
  834. conceptId = libraryInfoMain.getConceptId();
  835. concept.setId(conceptId);
  836. addConceptInfoVO.setConceptId(conceptId);
  837. if (libraryInfoMain.getIsConcept() != 1 && extLibraryInfoList.stream().filter(i -> i.getConceptId().intValue() == libraryInfoMain.getConceptId().intValue()).count() == 1) {
  838. return "标准术语已作为同义词被占用!";
  839. }
  840. }
  841. StringBuffer sbf = new StringBuffer();
  842. for (AddConceptInfoDetailVO i : addConceptInfoVO.getDetailList()) {
  843. LibraryInfo libraryInfo = extLibraryInfoMap.get(i.getName());
  844. if (libraryInfo == null) {
  845. libraryInfo = new LibraryInfo();
  846. libraryInfo.setTypeId(typeId);
  847. libraryInfo.setGmtCreate(now);
  848. libraryInfo.setCreator(currentUser);
  849. } else if (libraryInfo.getConceptId().intValue() != conceptId.intValue()) {
  850. sbf.append(i.getName()).append(" ");
  851. continue;
  852. }
  853. BeanUtil.copyProperties(i, libraryInfo);
  854. libraryInfo.setId(null);
  855. libraryInfo.setConceptId(conceptId);
  856. libraryInfo.setGmtModified(now);
  857. libraryInfo.setModifier(currentUser);
  858. if (i.getIsConcept() == 1) {
  859. libraryInfoList.add(0, libraryInfo);
  860. } else {
  861. libraryInfoList.add(libraryInfo);
  862. }
  863. }
  864. if (sbf.length() > 0) {
  865. sbf.append("已被占用");
  866. return sbf.toString();
  867. }
  868. addConceptInfoVO.setConcept(concept);
  869. addConceptInfoVO.setConceptCommon(conceptCommon);
  870. addConceptInfoVO.setLibraryInfoList(libraryInfoList);
  871. return null;
  872. }
  873. /**
  874. * 导入数据插入更新
  875. *
  876. * @param addConceptInfoVOList
  877. */
  878. private void saveAddConceptInfoVOList(List<AddConceptInfoVO> addConceptInfoVOList) {
  879. List<Long> conceptIds = addConceptInfoVOList.stream().filter(i -> i.getConceptId() != null).map(i -> i.getConceptId()).collect(Collectors.toList());
  880. if (ListUtil.isNotEmpty(conceptIds)) {
  881. QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<>();
  882. libraryInfoQe.in("concept_id", conceptIds);
  883. libraryinfoFacade.remove(libraryInfoQe);
  884. }
  885. List<LibraryInfo> saveLibraryInfoList = Lists.newArrayList();
  886. addConceptInfoVOList.forEach(i -> {
  887. saveLibraryInfoList.addAll(i.getLibraryInfoList());
  888. });
  889. libraryInfoService.saveBatch(saveLibraryInfoList);
  890. List<Concept> saveOrUpdateConceptList = Lists.newArrayList();
  891. addConceptInfoVOList.forEach(i -> {
  892. i.getConcept().setLibId(i.getLibraryInfoList().get(0).getId());
  893. i.getConcept().setLibName(i.getLibraryInfoList().get(0).getName());
  894. saveOrUpdateConceptList.add(i.getConcept());
  895. });
  896. //删除标签缓存
  897. List<Long> saveConceptIds = saveOrUpdateConceptList.stream().map(i -> i.getId()).filter(j -> j != null).distinct().collect(Collectors.toList());
  898. this.cacheClearByConceptIds(saveConceptIds);
  899. conceptService.saveOrUpdateBatch(saveOrUpdateConceptList);
  900. List<LibraryInfo> updateLibraryInfoList = Lists.newArrayList();
  901. addConceptInfoVOList.forEach(i -> {
  902. if (i.getConceptId() == null) {
  903. i.getLibraryInfoList().forEach(j -> {
  904. j.setConceptId(i.getConcept().getId());
  905. });
  906. updateLibraryInfoList.addAll(i.getLibraryInfoList());
  907. }
  908. });
  909. if (ListUtil.isNotEmpty(updateLibraryInfoList)) {
  910. libraryInfoService.updateBatchById(updateLibraryInfoList);
  911. }
  912. List<ConceptCommon> saveOrUpdateConceptCommonList = Lists.newArrayList();
  913. Map<Long, ConceptCommon> conceptCommonMap = null;
  914. if (ListUtil.isNotEmpty(conceptIds)) {
  915. QueryWrapper<ConceptCommon> conceptCommonQe = new QueryWrapper<>();
  916. conceptCommonQe.in("concept_id", conceptIds);
  917. conceptCommonMap = conceptCommonFacade.list(conceptCommonQe).stream().collect(Collectors.toMap(ConceptCommon::getConceptId, i -> i));
  918. }
  919. for (AddConceptInfoVO i : addConceptInfoVOList) {
  920. if (i.getConceptCommon() != null) {
  921. if (i.getConceptId() != null && conceptCommonMap != null && conceptCommonMap.containsKey(i.getConceptId())) {
  922. i.getConceptCommon().setId(conceptCommonMap.get(i.getConceptId()).getId());
  923. }
  924. i.getConceptCommon().setConceptId(i.getConcept().getId());
  925. saveOrUpdateConceptCommonList.add(i.getConceptCommon());
  926. }
  927. }
  928. if (ListUtil.isNotEmpty(saveOrUpdateConceptCommonList)) {
  929. conceptCommonService.saveOrUpdateBatch(saveOrUpdateConceptCommonList);
  930. }
  931. }
  932. @SuppressWarnings("deprecation")
  933. private String getValue(Cell cell) {
  934. try {
  935. Object obj = null;
  936. switch (cell.getCellTypeEnum()) {
  937. case BOOLEAN:
  938. obj = cell.getBooleanCellValue();
  939. break;
  940. case ERROR:
  941. obj = cell.getErrorCellValue();
  942. break;
  943. case NUMERIC:
  944. if (HSSFDateUtil.isCellDateFormatted(cell)) {
  945. Date date = cell.getDateCellValue();
  946. obj = DateFormatUtils.format(date, "yyyy-MM-dd");
  947. } else {
  948. obj = cell.getNumericCellValue();
  949. DecimalFormat df = new DecimalFormat("0");
  950. obj = df.format(obj);
  951. }
  952. break;
  953. case STRING:
  954. obj = cell.getStringCellValue();
  955. break;
  956. default:
  957. break;
  958. }
  959. return obj.toString();
  960. } catch (Exception e) {
  961. return "";
  962. }
  963. }
  964. /**
  965. * 根据概念Id列表获取概念列表Map
  966. *
  967. * @param conceptSearchVO 搜索参数
  968. * @return 术语id和术语 Map
  969. */
  970. public Map<Long, String> getConceptMap(ConceptSearchVO conceptSearchVO) {
  971. //入参验证
  972. if (ListUtil.isEmpty(conceptSearchVO.getConceptIds())) {
  973. throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "术语列表不能为空");
  974. }
  975. //获取结构
  976. List<Concept> concepts
  977. = this.getListByIds(conceptSearchVO.getConceptIds());
  978. //出参封装
  979. Map<Long, String> map = new HashMap<>();
  980. if (ListUtil.isNotEmpty(concepts)) {
  981. map = concepts.stream().collect(Collectors.toMap(r -> r.getId(), r -> r.getLibName()));
  982. }
  983. return map;
  984. }
  985. /**
  986. * 根据概念Id列表获取概念列表
  987. *
  988. * @param ids
  989. * @return
  990. */
  991. public List<Concept> getListByIds(List<Long> ids) {
  992. QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
  993. conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
  994. if (ids.size() == 1) {
  995. conceptQueryWrapper.eq("id", ids.get(0));
  996. } else {
  997. conceptQueryWrapper.in("id", ids);
  998. }
  999. List<Concept> list = this.list(conceptQueryWrapper);
  1000. return list;
  1001. }
  1002. /**
  1003. * 根据类型获取术语列表(科室、辅检、慢病)
  1004. *
  1005. * @param conceptTypeVO 类型
  1006. * @return 术语列表
  1007. */
  1008. public List<ConceptBaseDTO> getConceptListByType(ConceptTypeVO conceptTypeVO) {
  1009. if (null == conceptTypeVO
  1010. || IntegerUtil.isNull(conceptTypeVO.getType())) {
  1011. throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "类型不能为空");
  1012. }
  1013. List<ConceptBaseDTO> res = ListUtil.newArrayList();
  1014. switch (conceptTypeVO.getType()) {
  1015. case 1:
  1016. res = getConceptByType(LexiconTypeEnum.DEPARTMENT.getKey());
  1017. break;
  1018. case 2:
  1019. res = getConceptByType(LexiconTypeEnum.PACS_ITEMS.getKey());
  1020. break;
  1021. case 3:
  1022. res = getConceptChronic();
  1023. break;
  1024. default:
  1025. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "类型超出范围以外");
  1026. }
  1027. return res;
  1028. }
  1029. /**
  1030. * 获取慢病列表
  1031. *
  1032. * @return 慢病列表
  1033. */
  1034. private List<ConceptBaseDTO> getConceptChronic() {
  1035. ConceptWrapper conceptWrapper = new ConceptWrapper();
  1036. conceptWrapper.setStartType(LexiconTypeEnum.DIAGNOSIS.getKey());
  1037. conceptWrapper.setRelationType(LexiconRSTypeEnum.INCLUDE_OF.getKey());
  1038. conceptWrapper.setEndName("慢病");
  1039. List<ConceptRes> list = this.getConcept(conceptWrapper);
  1040. List<ConceptBaseDTO> res = ListUtil.newArrayList();
  1041. if (ListUtil.isNotEmpty(list)) {
  1042. for (ConceptRes concept : list) {
  1043. ConceptBaseDTO conceptBaseDTO = new ConceptBaseDTO();
  1044. conceptBaseDTO.setConceptId(concept.getStartId());
  1045. conceptBaseDTO.setName(concept.getStartName());
  1046. res.add(conceptBaseDTO);
  1047. }
  1048. }
  1049. return res;
  1050. }
  1051. /**
  1052. * 根据类型获取术语列表(科室、辅检)
  1053. *
  1054. * @param libType
  1055. * @return
  1056. */
  1057. private List<ConceptBaseDTO> getConceptByType(Integer libType) {
  1058. QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
  1059. conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
  1060. .in("lib_Type", libType);
  1061. List<Concept> list = this.list(conceptQueryWrapper);
  1062. List<ConceptBaseDTO> res = ListUtil.newArrayList();
  1063. if (ListUtil.isNotEmpty(list)) {
  1064. for (Concept concept : list) {
  1065. ConceptBaseDTO conceptBaseDTO = new ConceptBaseDTO();
  1066. conceptBaseDTO.setConceptId(concept.getId());
  1067. conceptBaseDTO.setName(concept.getLibName());
  1068. res.add(conceptBaseDTO);
  1069. }
  1070. }
  1071. return res;
  1072. }
  1073. /**
  1074. * 根据名称和类型获取概念列表Map
  1075. *
  1076. * @param conceptExistVO 搜索参数
  1077. * @return 术语id和术语 Map
  1078. */
  1079. public Map<String, List<Integer>> getConceptMap(ConceptExistVO conceptExistVO) {
  1080. // 入参验证
  1081. if (ListUtil.isEmpty(conceptExistVO.getNameList())) {
  1082. throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "名称列表不能为空");
  1083. }
  1084. if (conceptExistVO.getType() != null) {
  1085. // 如果是化验明细项,直接赋值
  1086. if (conceptExistVO.getIsLisDetail() == true) {
  1087. conceptExistVO.setLibType(LexiconTypeEnum.LIS_DETAILS.getKey());
  1088. } else {
  1089. Integer libType = ParamConvertUtil.conceptConvert2Lib(conceptExistVO.getType());
  1090. if (libType == null) {
  1091. throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "类型不匹配");
  1092. }
  1093. conceptExistVO.setLibType(libType);
  1094. }
  1095. }
  1096. //获取结构
  1097. List<Concept> concepts
  1098. = this.getListByNamesAndType(conceptExistVO.getNameList(), conceptExistVO.getLibType());
  1099. Map<String, List<Concept>> map1 = EntityUtil.makeEntityListMap(concepts, "libName");
  1100. Map<String, List<Integer>> typeMap = new HashMap<>();
  1101. for (String key : map1.keySet()) {
  1102. List<Concept> list = map1.get(key);
  1103. List<Integer> typeList = new ArrayList<>();
  1104. if (ListUtil.isNotEmpty(list)) {
  1105. for (Concept c : list) {
  1106. Integer type = ParamConvertUtil.libConvert2Concept(c.getLibType().intValue());
  1107. if (type != null) {
  1108. typeList.add(type);
  1109. }
  1110. }
  1111. typeMap.put(key, typeList);
  1112. }
  1113. }
  1114. return typeMap;
  1115. }
  1116. /**
  1117. * 根据名称和词性获取概念列表
  1118. *
  1119. * @param nameList
  1120. * @param libType
  1121. * @return
  1122. */
  1123. public List<Concept> getListByNamesAndType(List<String> nameList, Integer libType) {
  1124. QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
  1125. conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
  1126. .in("lib_name", nameList);
  1127. if (libType != null) {
  1128. conceptQueryWrapper.eq("lib_type", libType);
  1129. }
  1130. List<Concept> list = this.list(conceptQueryWrapper);
  1131. return list;
  1132. }
  1133. public List<ConceptBaseDTO> indexFac(IndexVO indexVO) {
  1134. // 类型转换
  1135. Integer libType = ParamConvertUtil.conceptConvert2Lib(indexVO.getType());
  1136. if (libType == null) {
  1137. throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "类型不匹配");
  1138. }
  1139. indexVO.setLibType(libType);
  1140. return this.index(indexVO);
  1141. }
  1142. public List<ConceptBaseDTO> indexByLexiconFac(IndexLexiconVO indexLexiconVO) {
  1143. return this.indexByLexicon(indexLexiconVO);
  1144. }
  1145. /**
  1146. * 根据概念Id列表获取概念列表Map
  1147. *
  1148. * @param conceptSearchVO 搜索参数
  1149. * @return 术语id和术语 Map
  1150. */
  1151. public Map<Long, String> getConceptNameMap(ConceptSearchVO conceptSearchVO) {
  1152. //入参验证
  1153. if (ListUtil.isEmpty(conceptSearchVO.getConceptIds())) {
  1154. throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "术语列表不能为空");
  1155. }
  1156. //获取结构
  1157. List<Concept> concepts
  1158. = this.getListByIds(conceptSearchVO.getConceptIds());
  1159. //出参封装
  1160. Map<Long, String> map = new HashMap<>();
  1161. if (ListUtil.isNotEmpty(concepts)) {
  1162. map = concepts.stream().collect(Collectors.toMap(r -> r.getId(), r -> r.getLibName()));
  1163. }
  1164. return map;
  1165. }
  1166. public Boolean piyinUp() {
  1167. Boolean res = false;
  1168. QueryWrapper<LibraryInfo> libraryInfoQueryWrapper = new QueryWrapper<>();
  1169. libraryInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
  1170. .isNull("spell");
  1171. List<LibraryInfo> list = libraryInfoService.list(libraryInfoQueryWrapper);
  1172. if (ListUtil.isNotEmpty(list)) {
  1173. Date now = DateUtil.now();
  1174. for (LibraryInfo libraryInfo : list) {
  1175. libraryInfo.setSpell(Cn2SpellUtil.converterToFirstSpell(libraryInfo.getName()));
  1176. libraryInfo.setGmtModified(now);
  1177. }
  1178. List<List<LibraryInfo>> listList = SqlExecuteUtil.divideList(list, 200);
  1179. int i = 0;
  1180. for (List<LibraryInfo> libraryInfoList : listList) {
  1181. res = libraryInfoService.updateBatchById(libraryInfoList);
  1182. i++;
  1183. }
  1184. System.out.println("批量更新拼音" + i + "次!");
  1185. }
  1186. return res;
  1187. }
  1188. /**
  1189. * 模板维护辅检检索
  1190. *
  1191. * @param getConceptPacInfosVO
  1192. * @return
  1193. */
  1194. public List<ConceptBaseDTO> getConceptPacInfos(GetConceptPacInfosVO getConceptPacInfosVO) {
  1195. QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
  1196. conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
  1197. .eq("lib_type", LexiconTypeEnum.PACS_ITEMS.getKey())
  1198. .like("lib_name", getConceptPacInfosVO.getInputStr());
  1199. List<Concept> list = this.list(conceptQueryWrapper);
  1200. List<ConceptBaseDTO> res = ListUtil.newArrayList();
  1201. if (ListUtil.isNotEmpty(list)) {
  1202. for (Concept concept : list) {
  1203. ConceptBaseDTO conceptBaseDTO = new ConceptBaseDTO();
  1204. conceptBaseDTO.setConceptId(concept.getId());
  1205. conceptBaseDTO.setName(concept.getLibName());
  1206. res.add(conceptBaseDTO);
  1207. }
  1208. }
  1209. return res;
  1210. }
  1211. /**
  1212. * 筛选符合类型的概念id
  1213. * @param libTypeId
  1214. * @param sourceConceptIds
  1215. * @return
  1216. */
  1217. public List<Long> getCompatibleTypeConceptIds(Long libTypeId,List<Long> sourceConceptIds){
  1218. if(libTypeId==null||ListUtil.isEmpty(sourceConceptIds)){
  1219. return null;
  1220. }
  1221. QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
  1222. conceptQe.in("id", sourceConceptIds);
  1223. conceptQe.eq("lib_type", libTypeId);
  1224. return list(conceptQe).stream().map(i->i.getId()).collect(Collectors.toList());
  1225. }
  1226. }
  1227. /**
  1228. * 删除缓存(化验相关)
  1229. *
  1230. * @param conceptId
  1231. * @return
  1232. */
  1233. public Boolean cacheClearByConceptId(Long conceptId) {
  1234. Concept concept = this.getById(conceptId);
  1235. List<String> names = Lists.newArrayList();
  1236. names.add(concept.getLibName());
  1237. List<String> mealNames = Lists.newArrayList();
  1238. if (concept.getLibType().equals(Long.valueOf(LexiconTypeEnum.LIS_TABLES.getKey()))) {
  1239. mealNames = lisMappingFacade.getMealNameByUniqueNames(names);
  1240. } else if (concept.getLibType().equals(Long.valueOf(LexiconTypeEnum.LIS_PACKAGE.getKey()))) {
  1241. mealNames.add(concept.getLibName());
  1242. } else if (concept.getLibType().equals(Long.valueOf(LexiconTypeEnum.LIS_DETAILS.getKey()))) {
  1243. mealNames = lisMappingFacade.getMealNameByItemNames(names);
  1244. } else {
  1245. return true;
  1246. }
  1247. if (ListUtil.isNotEmpty(mealNames)) {
  1248. KLQuestionVO klQuestionVO = new KLQuestionVO();
  1249. klQuestionVO.setTagNames(mealNames);
  1250. klQuestionVO.setNames(mealNames);
  1251. klQuestionVO.setType(5);
  1252. List<Integer> tagTypes = Lists.newArrayList();
  1253. tagTypes.add(7);
  1254. klQuestionVO.setTagType(tagTypes);
  1255. RespDTO<List<QuestionInfo>> respDTO = icssManServiceClient.indexForkl(klQuestionVO);
  1256. if (RespDTOUtil.respIsOK(respDTO)) {
  1257. List<QuestionInfo> questionInfoList = respDTO.data;
  1258. if (ListUtil.isNotEmpty(questionInfoList)) {
  1259. IdListVO idListVO = new IdListVO();
  1260. List<Long> idList = questionInfoList.stream().map(i -> i.getId()).collect(Collectors.toList());
  1261. idListVO.setIdList(idList);
  1262. RespDTO<Boolean> cacheRespDTO = icssManServiceClient.clearCache(idListVO);
  1263. }
  1264. }
  1265. }
  1266. return true;
  1267. }
  1268. /**
  1269. * 批量删除化验相关标签缓存
  1270. *
  1271. * @param conceptIds
  1272. * @return
  1273. */
  1274. public Boolean cacheClearByConceptIds(List<Long> conceptIds) {
  1275. List<Concept> concepts = this.getListByIds(conceptIds);
  1276. List<String> mealNames = Lists.newArrayList();
  1277. List<Concept> mealConcepts = concepts.stream().filter(i -> i.getLibType().equals(Long.valueOf(LexiconTypeEnum.LIS_PACKAGE.getKey()))).collect(Collectors.toList());
  1278. mealNames.addAll(mealConcepts.stream().map(i -> i.getLibName()).filter(j -> j != null).distinct().collect(Collectors.toList()));
  1279. List<Concept> itemConcepts = concepts.stream().filter(i -> i.getLibType().equals(Long.valueOf(LexiconTypeEnum.LIS_DETAILS.getKey()))).collect(Collectors.toList());
  1280. List<String> itemNames = itemConcepts.stream().map(i -> i.getLibName()).filter(j -> j != null).distinct().collect(Collectors.toList());
  1281. mealNames.addAll(lisMappingFacade.getMealNameByItemNames(itemNames));
  1282. List<Concept> uniqueConcepts = concepts.stream().filter(i -> i.getLibType().equals(Long.valueOf(LexiconTypeEnum.LIS_TABLES.getKey()))).collect(Collectors.toList());
  1283. List<String> uniqueNames = uniqueConcepts.stream().map(i -> i.getLibName()).filter(j -> j != null).distinct().collect(Collectors.toList());
  1284. mealNames.addAll(lisMappingFacade.getMealNameByUniqueNames(uniqueNames));
  1285. mealNames = mealNames.stream().filter(i -> StringUtil.isNotBlank(i)).distinct().collect(Collectors.toList());
  1286. if (ListUtil.isNotEmpty(mealNames)) {
  1287. KLQuestionVO klQuestionVO = new KLQuestionVO();
  1288. klQuestionVO.setTagNames(mealNames);
  1289. klQuestionVO.setNames(mealNames);
  1290. klQuestionVO.setType(5);
  1291. List<Integer> tagTypes = Lists.newArrayList();
  1292. tagTypes.add(7);
  1293. klQuestionVO.setTagType(tagTypes);
  1294. RespDTO<List<QuestionInfo>> respDTO = icssManServiceClient.indexForkl(klQuestionVO);
  1295. if (RespDTOUtil.respIsOK(respDTO)) {
  1296. List<QuestionInfo> questionInfoList = respDTO.data;
  1297. if (ListUtil.isNotEmpty(questionInfoList)) {
  1298. IdListVO idListVO = new IdListVO();
  1299. List<Long> idList = questionInfoList.stream().map(i -> i.getId()).collect(Collectors.toList());
  1300. idListVO.setIdList(idList);
  1301. RespDTO<Boolean> cacheRespDTO = icssManServiceClient.clearCache(idListVO);
  1302. }
  1303. }
  1304. }
  1305. return true;
  1306. }
  1307. }