浏览代码

根据名称查和类型查询

zhoutg 6 年之前
父节点
当前提交
4e67b4cc88
共有 1 个文件被更改,包括 100 次插入101 次删除
  1. 100 101
      knowledgeman-service/src/main/java/com/diagbot/facade/ConceptFacade.java

+ 100 - 101
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;
@@ -64,6 +42,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: 术语查询业务层
@@ -262,27 +261,27 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @return libName-标准术语,otherNames-同义词
      */
     public GetConceptInfoDTO getConceptInfoDetail(GetConceptInfoDetailVO getConceptInfoDetailVO) {
-    	GetConceptInfoDTO getConceptInfoDTO = new GetConceptInfoDTO();
-    	
+        GetConceptInfoDTO getConceptInfoDTO = new GetConceptInfoDTO();
+
         QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
         libraryInfoQe.eq("concept_id", getConceptInfoDetailVO.getConceptId());
         List<LibraryInfo> libraryInfoList = libraryinfoFacade.list(libraryInfoQe);
-        
+
         getConceptInfoDTO.setLibName(BeanUtil.listCopyTo(libraryInfoList.stream().filter(i -> i.getIsConcept() != null && i.getIsConcept() == 1).collect(Collectors.toList()), GetConceptInfoDetailDTO.class));
         getConceptInfoDTO.setOtherNames(BeanUtil.listCopyTo(libraryInfoList.stream().filter(i -> i.getIsConcept() == null || i.getIsConcept() == 0).collect(Collectors.toList()), GetConceptInfoDetailDTO.class));
 
         Integer isHasCommon = lexiconFacade.getById(libraryInfoList.get(0).getTypeId()).getIsHasCommon();
-        if(isHasCommon==1){
-        	QueryWrapper<ConceptCommon> conceptCommonQe = new QueryWrapper<>();
+        if (isHasCommon == 1) {
+            QueryWrapper<ConceptCommon> conceptCommonQe = new QueryWrapper<>();
             conceptCommonQe.eq("concept_id", getConceptInfoDetailVO.getConceptId());
             ConceptCommon conceptCommon = conceptCommonFacade.getOne(conceptCommonQe);
-            if(conceptCommon!=null){
-            	getConceptInfoDTO.setSexType(conceptCommon.getSexType());
-            	getConceptInfoDTO.setMinAge(conceptCommon.getMinAge());
-            	getConceptInfoDTO.setMaxAge(conceptCommon.getMaxAge());
+            if (conceptCommon != null) {
+                getConceptInfoDTO.setSexType(conceptCommon.getSexType());
+                getConceptInfoDTO.setMinAge(conceptCommon.getMinAge());
+                getConceptInfoDTO.setMaxAge(conceptCommon.getMaxAge());
             }
         }
-        
+
         return getConceptInfoDTO;
     }
 
@@ -430,17 +429,17 @@ public class ConceptFacade extends ConceptServiceImpl {
         concept.setGmtModified(now);
         concept.setModifier(currentUser);
         updateById(concept);
-        
-        if(lexicon.getIsHasCommon()==1){
-        	QueryWrapper<ConceptCommon> conceptCommonQe = new QueryWrapper<>();
+
+        if (lexicon.getIsHasCommon() == 1) {
+            QueryWrapper<ConceptCommon> conceptCommonQe = new QueryWrapper<>();
             conceptCommonQe.eq("concept_id", conceptId);
             ConceptCommon conceptCommon = conceptCommonFacade.getOne(conceptCommonQe);
-            if(conceptCommon==null){
-            	conceptCommon = new ConceptCommon();
+            if (conceptCommon == null) {
+                conceptCommon = new ConceptCommon();
             }
-            
+
             BeanUtil.copyProperties(addConceptInfoVO, conceptCommon);
-            
+
             conceptCommonFacade.saveOrUpdate(conceptCommon);
         }
 
@@ -683,8 +682,8 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @return 术语列表
      */
     public List<ConceptBaseDTO> getConceptListByType(ConceptTypeVO conceptTypeVO) {
-        if(null == conceptTypeVO
-                || IntegerUtil.isNull(conceptTypeVO.getType())){
+        if (null == conceptTypeVO
+                || IntegerUtil.isNull(conceptTypeVO.getType())) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "类型不能为空");
         }
         List<ConceptBaseDTO> res = ListUtil.newArrayList();
@@ -752,65 +751,65 @@ public class ConceptFacade extends ConceptServiceImpl {
     }
 
 
+    /**
+     * 根据名称和类型获取概念列表Map
+     *
+     * @param conceptExistVO 搜索参数
+     * @return 术语id和术语 Map
+     */
+    public Map<String, Long> getConceptMap(ConceptExistVO conceptExistVO) {
+        // 入参验证
+        if (ListUtil.isEmpty(conceptExistVO.getNameList())) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "名称列表不能为空");
+        }
+
+        if (conceptExistVO.getType() == null) {
+            Integer libType = ParamConvertUtil.conceptConvert2Lib(conceptExistVO.getType());
+            if (libType == null) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "类型不匹配");
+            }
+            conceptExistVO.setLibType(libType);
+        }
 
-	/**
-	 * 根据名称和类型获取概念列表Map
-	 *
-	 * @param conceptExistVO 搜索参数
-	 * @return 术语id和术语 Map
-	 */
-	public Map<String, Long> getConceptMap(ConceptExistVO conceptExistVO) {
-		//入参验证
-		if (ListUtil.isEmpty(conceptExistVO.getNameList())) {
-			throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "名称列表不能为空");
-		}
-
-		if (conceptExistVO.getType() == null) {
-			throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "类型不能为空");
-		}
-		Integer libType = ParamConvertUtil.conceptConvert2Lib(conceptExistVO.getType());
-		if(libType == null) {
-			throw  new CommonException(CommonErrorCode.SERVER_IS_ERROR, "类型不匹配");
-		}
-		conceptExistVO.setLibType(libType);
-		//获取结构
-		List<Concept> concepts
-				= this.getListByNamesAndType(conceptExistVO.getNameList(), conceptExistVO.getLibType());
-
-		//出参封装
-		Map<String, Long> map = new HashMap<>();
-		if (ListUtil.isNotEmpty(concepts)) {
-			map = concepts.stream().collect(Collectors.toMap(r -> r.getLibName(), r -> r.getId()));
-		}
-		return map;
-	}
-
-
-
-	/**
-	 * 根据名称和词性获取概念列表
-	 *
-	 * @param nameList
-	 * @param libType
-	 * @return
-	 */
-	public List<Concept> getListByNamesAndType(List<String> nameList, Integer libType) {
-		QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
-		conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
-				.in("lib_name", nameList)
-				.eq("lib_type", libType);
-		List<Concept> list = this.list(conceptQueryWrapper);
-		return list;
-	}
-
-
-	public List<ConceptBaseDTO> indexFac(IndexVO indexVO) {
-		// 类型转换
-		Integer libType = ParamConvertUtil.conceptConvert2Lib(indexVO.getType());
-		if(libType == null) {
-			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "类型不匹配");
-		}
-		indexVO.setLibType(libType);
-		return this.index(indexVO);
-	}
+        //获取结构
+        List<Concept> concepts
+                = this.getListByNamesAndType(conceptExistVO.getNameList(), conceptExistVO.getLibType());
+
+        //出参封装
+        Map<String, Long> map = new HashMap<>();
+        if (ListUtil.isNotEmpty(concepts)) {
+            map = concepts.stream().collect(Collectors.toMap(r -> r.getLibName(), r -> r.getId()));
+        }
+        return map;
+    }
+
+
+    /**
+     * 根据名称和词性获取概念列表
+     *
+     * @param nameList
+     * @param libType
+     * @return
+     */
+    public List<Concept> getListByNamesAndType(List<String> nameList, Integer libType) {
+        QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
+        conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .in("lib_name", nameList);
+        if (libType != null) {
+            conceptQueryWrapper.eq("lib_type", libType);
+        }
+        List<Concept> list = this.list(conceptQueryWrapper);
+        return list;
+    }
+
+
+    public List<ConceptBaseDTO> indexFac(IndexVO indexVO) {
+        // 类型转换
+        Integer libType = ParamConvertUtil.conceptConvert2Lib(indexVO.getType());
+        if (libType == null) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "类型不匹配");
+        }
+        indexVO.setLibType(libType);
+        return this.index(indexVO);
+    }
 }