gaodm 6 vuotta sitten
vanhempi
commit
e237d8be94
1 muutettua tiedostoa jossa 121 lisäystä ja 125 poistoa
  1. 121 125
      knowledgeman-service/src/main/java/com/diagbot/facade/ConceptFacade.java

+ 121 - 125
knowledgeman-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -1,27 +1,5 @@
 package com.diagbot.facade;
 
-import java.io.InputStream;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import org.apache.commons.lang.time.DateFormatUtils;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
-import org.springframework.web.multipart.MultipartFile;
-
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.UserServiceClient;
@@ -69,6 +47,27 @@ import com.diagbot.vo.GetAllLisConceptVO;
 import com.diagbot.vo.GetConceptInfoDetailVO;
 import com.diagbot.vo.IndexVO;
 import com.diagbot.vo.RemoveConceptInfoVO;
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.InputStream;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 术语查询业务层
@@ -80,10 +79,6 @@ public class ConceptFacade extends ConceptServiceImpl {
 
     @Autowired
     private LibraryInfoFacade libraryinfoFacade;
-    //    @Autowired
-    //    private LibraryDetailFacade libraryDetailFacade;
-//    @Autowired
-//    private MedicalFacade medicalFacade;
     @Autowired
     private RelationFacade relationFacade;
     @Autowired
@@ -103,27 +98,27 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @return
      */
     public List<GetAllLisConceptDTO> getAllLisConcept(GetAllLisConceptVO getAllLisConceptVO) {
-    	List<GetAllLisConceptDTO> getAllLisConceptDTOList = new ArrayList<>();
-    	
-    	QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
-    	conceptQe.eq("is_deleted", "N");
-    	conceptQe.eq("lib_type", 46);
-    	conceptQe.like(StringUtil.isNotEmpty(getAllLisConceptVO.getConceptName()),"lib_name", getAllLisConceptVO.getConceptName());
-    	List<Concept> conceptList = list(conceptQe);
-    	
-    	conceptList.forEach(i->{
-    		if(getAllLisConceptVO.getExcludedConceptNames()!=null
-    				&&getAllLisConceptVO.getExcludedConceptNames().contains(i.getLibName())){
-    			return;
-    		}
-    		GetAllLisConceptDTO getAllLisConceptDTO = new GetAllLisConceptDTO();
-    		getAllLisConceptDTO.setConceptId(i.getId());
-    		getAllLisConceptDTO.setConceptName(i.getLibName());
-    		getAllLisConceptDTOList.add(getAllLisConceptDTO);
-    	});
-    	
+        List<GetAllLisConceptDTO> getAllLisConceptDTOList = new ArrayList<>();
+
+        QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
+        conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
+        conceptQe.eq("lib_type", LexiconTypeEnum.LIS_TABLES.getKey());
+        conceptQe.like(StringUtil.isNotEmpty(getAllLisConceptVO.getConceptName()), "lib_name", getAllLisConceptVO.getConceptName());
+        List<Concept> conceptList = list(conceptQe);
+
+        conceptList.forEach(i -> {
+            if (getAllLisConceptVO.getExcludedConceptNames() != null
+                    && getAllLisConceptVO.getExcludedConceptNames().contains(i.getLibName())) {
+                return;
+            }
+            GetAllLisConceptDTO getAllLisConceptDTO = new GetAllLisConceptDTO();
+            getAllLisConceptDTO.setConceptId(i.getId());
+            getAllLisConceptDTO.setConceptName(i.getLibName());
+            getAllLisConceptDTOList.add(getAllLisConceptDTO);
+        });
+
         //return this.baseMapper.getAllLisConcept(getAllLisConceptVO);
-    	return getAllLisConceptDTOList;
+        return getAllLisConceptDTOList;
     }
 
     /**
@@ -134,15 +129,15 @@ public class ConceptFacade extends ConceptServiceImpl {
      */
     public List<GetAllConceptDTO> getAllConcept(GetAllConceptVO getAllConceptVO) {
         QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
-        libraryInfoQe.eq("is_deleted", "N");
-        libraryInfoQe.eq(getAllConceptVO.getIsConcept() != null,"is_concept", getAllConceptVO.getIsConcept());
-        libraryInfoQe.like(StringUtil.isNotBlank(getAllConceptVO.getName()),"name", getAllConceptVO.getName());
+        libraryInfoQe.eq("is_deleted", IsDeleteEnum.N.getKey());
+        libraryInfoQe.eq(getAllConceptVO.getIsConcept() != null, "is_concept", getAllConceptVO.getIsConcept());
+        libraryInfoQe.like(StringUtil.isNotBlank(getAllConceptVO.getName()), "name", getAllConceptVO.getName());
         List<LibraryInfo> libraryInfoList = libraryinfoFacade.list(libraryInfoQe);
 
         //过滤掉非概念术语
         if (getAllConceptVO.getIsConcept() != null && getAllConceptVO.getIsConcept() == 1) {
             QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
-            conceptQe.eq("is_deleted", "N");
+            conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
             conceptQe.in("id", libraryInfoList.stream().map(i -> i.getConceptId()).distinct().collect(Collectors.toList()));
             Map<Long, Concept> conceptMap = list(conceptQe).stream().collect(Collectors.toMap(Concept::getId, i -> i));
             libraryInfoList.forEach(i -> {
@@ -175,7 +170,7 @@ public class ConceptFacade extends ConceptServiceImpl {
 
         return getAllConceptDTOList;
     }
-    
+
     /**
      * 获取所有概念(术语关系维护时筛选使用)
      *
@@ -183,46 +178,46 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @return
      */
     public List<GetAllForRelationDTO> getAllForRelation(GetAllForRelationVO getAllForRelationVO) {
-    	List<GetAllForRelationDTO> retList = new ArrayList<>();
-    	
-    	QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
-    	conceptQe.eq("is_deleted", "N");
-    	conceptQe.like(StringUtil.isNotEmpty(getAllForRelationVO.getName()),"lib_name", getAllForRelationVO.getName());
-    	conceptQe.eq(getAllForRelationVO.getTypeId()!=null,"lib_type", getAllForRelationVO.getTypeId());
-    	List<Concept> conceptList = list(conceptQe);
-    	
-    	Map<Long,Long> reCouMap = new HashMap<>();
-    	if(getAllForRelationVO.getRelationPosition()!=3){
-    		if(getAllForRelationVO.getRelationId()==null){
-    			throw new CommonException(CommonErrorCode.RPC_ERROR, "关系类型id必传!");
-    		}
-    		
-    		List<Long> conceptIdList = conceptList.stream().map(i->i.getId()).collect(Collectors.toList());
-    		QueryWrapper<Relation> relationQe = new QueryWrapper<>();
-    		relationQe.eq("relation_id", getAllForRelationVO.getRelationId());
-    		if(getAllForRelationVO.getRelationPosition()==1){
-    			relationQe.in("start_id", conceptIdList);
-    			relationQe.eq(getAllForRelationVO.getRelationConceptId()!=null,"end_id", getAllForRelationVO.getRelationConceptId());
-    			reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getStartId,Collectors.counting()));
-    		}else{
-    			relationQe.in("end_id", conceptIdList);
-    			relationQe.eq(getAllForRelationVO.getRelationConceptId()!=null,"start_id", getAllForRelationVO.getRelationConceptId());
-    			reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getEndId,Collectors.counting()));
-    		}
-    	}
-    	
-    	for(Concept i : conceptList){
-    		if(reCouMap.get(i.getId())!=null
-    				||(getAllForRelationVO.getExcludedConceptIds()!=null&&getAllForRelationVO.getExcludedConceptIds().contains(i.getId()))){
-    			continue;
-    		}
-    		GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
-    		getAllForRelationDTO.setConceptId(i.getId());
-    		getAllForRelationDTO.setConceptName(i.getLibName());
-    		retList.add(getAllForRelationDTO);
-    	}
-    	
-    	return retList;
+        List<GetAllForRelationDTO> retList = new ArrayList<>();
+
+        QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
+        conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
+        conceptQe.like(StringUtil.isNotEmpty(getAllForRelationVO.getName()), "lib_name", getAllForRelationVO.getName());
+        conceptQe.eq(getAllForRelationVO.getTypeId() != null, "lib_type", getAllForRelationVO.getTypeId());
+        List<Concept> conceptList = list(conceptQe);
+
+        Map<Long, Long> reCouMap = new HashMap<>();
+        if (getAllForRelationVO.getRelationPosition() != 3) {
+            if (getAllForRelationVO.getRelationId() == null) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "关系类型id必传!");
+            }
+
+            List<Long> conceptIdList = conceptList.stream().map(i -> i.getId()).collect(Collectors.toList());
+            QueryWrapper<Relation> relationQe = new QueryWrapper<>();
+            relationQe.eq("relation_id", getAllForRelationVO.getRelationId());
+            if (getAllForRelationVO.getRelationPosition() == 1) {
+                relationQe.in("start_id", conceptIdList);
+                relationQe.eq(getAllForRelationVO.getRelationConceptId() != null, "end_id", getAllForRelationVO.getRelationConceptId());
+                reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getStartId, Collectors.counting()));
+            } else {
+                relationQe.in("end_id", conceptIdList);
+                relationQe.eq(getAllForRelationVO.getRelationConceptId() != null, "start_id", getAllForRelationVO.getRelationConceptId());
+                reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getEndId, Collectors.counting()));
+            }
+        }
+
+        for (Concept i : conceptList) {
+            if (reCouMap.get(i.getId()) != null
+                    || (getAllForRelationVO.getExcludedConceptIds() != null && getAllForRelationVO.getExcludedConceptIds().contains(i.getId()))) {
+                continue;
+            }
+            GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
+            getAllForRelationDTO.setConceptId(i.getId());
+            getAllForRelationDTO.setConceptName(i.getLibName());
+            retList.add(getAllForRelationDTO);
+        }
+
+        return retList;
     }
 
     /**
@@ -232,7 +227,7 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @return
      */
     public IPage<GetAllInformationDTO> getAllInformation(GetAllInformationVO getAllInformationVO) {
-    	IPage<GetAllInformationDTO> ipage = this.baseMapper.getAllInformation(getAllInformationVO);
+        IPage<GetAllInformationDTO> ipage = this.baseMapper.getAllInformation(getAllInformationVO);
         if (ipage.getRecords().size() > 0) {
             List<String> ids = ipage.getRecords().stream().map(i -> i.getOperName()).distinct().collect(Collectors.toList());
             RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
@@ -306,11 +301,11 @@ public class ConceptFacade extends ConceptServiceImpl {
             throw new CommonException(CommonErrorCode.NOT_EXISTS);
         }
         if (concept.getIsDeleted().equals(removeConceptInfoVO.getIsDeleted())) {
-            if (removeConceptInfoVO.getIsDeleted().equals("Y")) {
-                throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已删除!");
+            if (removeConceptInfoVO.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
+                throw new CommonException(CommonErrorCode.NOT_EXISTS, "该数据已删除!");
             }
-            if (removeConceptInfoVO.getIsDeleted().equals("N")) {
-                throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已恢复!");
+            if (removeConceptInfoVO.getIsDeleted().equals(IsDeleteEnum.N.getKey())) {
+                throw new CommonException(CommonErrorCode.IS_EXISTS, "该数据已恢复!");
             }
         }
 
@@ -330,7 +325,7 @@ public class ConceptFacade extends ConceptServiceImpl {
      */
     public GetConceptInfoDTO getConceptInfoDetail(GetConceptInfoDetailVO getConceptInfoDetailVO) {
         GetConceptInfoDTO getConceptInfoDTO = new GetConceptInfoDTO();
-        
+
         Concept concept = this.getById(getConceptInfoDetailVO.getConceptId());
         if (concept == null) {
             throw new CommonException(CommonErrorCode.NOT_EXISTS);
@@ -339,8 +334,8 @@ public class ConceptFacade extends ConceptServiceImpl {
         QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
         libraryInfoQe.eq("concept_id", getConceptInfoDetailVO.getConceptId());
         List<GetConceptInfoDetailDTO> getConceptInfoDetailDTOList = BeanUtil.listCopyTo(libraryinfoFacade.list(libraryInfoQe), GetConceptInfoDetailDTO.class);
-        getConceptInfoDetailDTOList.forEach(i->{
-        	i.setType(LexiconTypeEnum.getName(i.getTypeId().intValue()));
+        getConceptInfoDetailDTOList.forEach(i -> {
+            i.setType(LexiconTypeEnum.getName(i.getTypeId().intValue()));
         });
 
         getConceptInfoDTO.setLibName(getConceptInfoDetailDTOList.stream().filter(i -> i.getIsConcept() != null && i.getIsConcept() == 1).collect(Collectors.toList()));
@@ -380,9 +375,9 @@ public class ConceptFacade extends ConceptServiceImpl {
                 throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "无法输入纯数字或者纯字符,请输入正确数据!");
             }
         }
-        
-        if(addConceptInfoVO.getMaxAge()<addConceptInfoVO.getMinAge()){
-        	throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "症状发生的最小年龄大于症状发生的最大年龄!");
+
+        if (addConceptInfoVO.getMaxAge() < addConceptInfoVO.getMinAge()) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "症状发生的最小年龄大于症状发生的最大年龄!");
         }
 
         if (addConceptInfoVO.getDetailList().stream().distinct().count() != addConceptInfoVO.getDetailList().size()) {
@@ -391,17 +386,17 @@ public class ConceptFacade extends ConceptServiceImpl {
 
         List<AddConceptInfoDetailVO> addConceptInfoDetailVOMainList = addConceptInfoVO.getDetailList().stream().filter(i -> i.getIsConcept() == 1).collect(Collectors.toList());
         if (addConceptInfoDetailVOMainList.size() == 0) {
-            throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "无标准术语!");
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, lineNumStr + "无标准术语!");
         }
         if (addConceptInfoDetailVOMainList.size() > 1) {
-            throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "标准术语只能有一个!");
+            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, lineNumStr + "标准术语只能有一个!");
         }
 
         QueryWrapper<Lexicon> lexiconQe = new QueryWrapper<>();
         lexiconQe.eq("name", addConceptInfoVO.getType());
         Lexicon lexicon = lexiconFacade.getOne(lexiconQe);
         if (lexicon == null) {
-            throw new CommonException(CommonErrorCode.RPC_ERROR, lineNumStr + "数据有误,该类型信息在数据库中不存在!");
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, lineNumStr + "数据有误,该类型信息在数据库中不存在!");
         }
 
         List<LibraryInfo> saveOrUpdateLibraryInfoList = new ArrayList<>();
@@ -530,7 +525,7 @@ public class ConceptFacade extends ConceptServiceImpl {
 
         return true;
     }
-    
+
     /**
      * 医学术语命名excel文件导入
      *
@@ -561,7 +556,7 @@ public class ConceptFacade extends ConceptServiceImpl {
 
                             Sheet sheet = wb.getSheetAt(0);
                             int count = 0;
-                            String libName, libType, otherNames, remark,sexType,minAge,maxAge;
+                            String libName, libType, otherNames, remark, sexType, minAge, maxAge;
                             String regEx = "[0-9]+|[`~·!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]+";
                             String regExAge = "[0-9]|[1-9][0-9]|1[0-9]{2}|200";
                             for (Row row : sheet) {
@@ -595,18 +590,18 @@ public class ConceptFacade extends ConceptServiceImpl {
                                     sbf.append("第" + count + "行导入错误,说明最大可输入120个字;").append("<br/>");
                                     continue;
                                 }
-                                if(StringUtil.isNotEmpty(sexType)&&!sexType.matches("男|女|通用")){
-                                	sbf.append("第" + count + "行导入错误,性别须是男、女或者通用;").append("<br/>");
+                                if (StringUtil.isNotEmpty(sexType) && !sexType.matches("男|女|通用")) {
+                                    sbf.append("第" + count + "行导入错误,性别须是男、女或者通用;").append("<br/>");
                                 }
-                                if((StringUtil.isNotEmpty(minAge)&&!minAge.matches(regExAge))
-                                		||(StringUtil.isNotEmpty(maxAge)&&!maxAge.matches(regExAge))){
-                                	 sbf.append("第" + count + "行导入错误,年龄须是0-200;").append("<br/>");
-                                     continue;
+                                if ((StringUtil.isNotEmpty(minAge) && !minAge.matches(regExAge))
+                                        || (StringUtil.isNotEmpty(maxAge) && !maxAge.matches(regExAge))) {
+                                    sbf.append("第" + count + "行导入错误,年龄须是0-200;").append("<br/>");
+                                    continue;
                                 }
-                                if(StringUtil.isNotEmpty(minAge)
-                                		&&StringUtil.isNotEmpty(maxAge)
-                                		&&Integer.parseInt(minAge)>Integer.parseInt(maxAge)){
-                                	sbf.append("第" + count + "行导入错误,症状发生的最小年龄大于症状发生的最大年龄;").append("<br/>");
+                                if (StringUtil.isNotEmpty(minAge)
+                                        && StringUtil.isNotEmpty(maxAge)
+                                        && Integer.parseInt(minAge) > Integer.parseInt(maxAge)) {
+                                    sbf.append("第" + count + "行导入错误,症状发生的最小年龄大于症状发生的最大年龄;").append("<br/>");
                                     continue;
                                 }
 
@@ -616,12 +611,12 @@ public class ConceptFacade extends ConceptServiceImpl {
                                 addConceptInfoVO.setType(libType);
                                 addConceptInfoVO.setMinAge(Integer.parseInt(minAge));
                                 addConceptInfoVO.setMaxAge(Integer.parseInt(maxAge));
-                                if(sexType.equals("男")){
-                                	addConceptInfoVO.setSexType(1);
-                                }else if(sexType.equals("女")){
-                                	addConceptInfoVO.setSexType(2);
-                                }else{
-                                	addConceptInfoVO.setSexType(3);
+                                if (sexType.equals("男")) {
+                                    addConceptInfoVO.setSexType(1);
+                                } else if (sexType.equals("女")) {
+                                    addConceptInfoVO.setSexType(2);
+                                } else {
+                                    addConceptInfoVO.setSexType(3);
                                 }
                                 List<AddConceptInfoDetailVO> detailList = new ArrayList<>();
                                 for (String nm : otherNames.split(",")) {
@@ -782,7 +777,7 @@ public class ConceptFacade extends ConceptServiceImpl {
     public List<Concept> getListByIds(List<Long> ids) {
         QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
         conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
-        if (ids.size() == 1){
+        if (ids.size() == 1) {
             conceptQueryWrapper.eq("id", ids.get(0));
         } else {
             conceptQueryWrapper.in("id", ids);
@@ -893,7 +888,7 @@ public class ConceptFacade extends ConceptServiceImpl {
                 = this.getListByNamesAndType(conceptExistVO.getNameList(), conceptExistVO.getLibType());
         Map<String, List<Concept>> map1 = EntityUtil.makeEntityListMap(concepts, "libName");
         Map<String, List<Integer>> typeMap = new HashMap<>();
-        for(String key : map1.keySet()) {
+        for (String key : map1.keySet()) {
             List<Concept> list = map1.get(key);
             List<Integer> typeList = new ArrayList<>();
             if (ListUtil.isNotEmpty(list)) {
@@ -935,6 +930,7 @@ public class ConceptFacade extends ConceptServiceImpl {
         indexVO.setLibType(libType);
         return this.index(indexVO);
     }
+
     /**
      * 根据概念Id列表获取概念列表Map
      *