Browse Source

Merge remote-tracking branch 'origin/dev/mapping20210603' into dev/mapping20210603

wangfeng 4 years ago
parent
commit
9116cf757f

+ 1 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -143,6 +143,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 //.antMatchers("/tran/tcmsyndromeConfig/exportExcel").permitAll()
                 .antMatchers("/tran/tcmsyndromeConfig/exportExcelModule").permitAll()
                 .antMatchers("/tran/mappingConfig/getPage").permitAll()
+                .antMatchers("/tran/mappingConfig/precDataMatch").permitAll()
                 //.antMatchers("/tran/hospitalInfo/saveRecord").permitAll()
                 .antMatchers("/tran/hospitalInfo/getHospitalInfo").permitAll()
                 .antMatchers("/tran/hospitalInfo/getAllHospitalInfo").permitAll()

+ 1 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -186,6 +186,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 // || matchers("/tran/tcmsyndromeConfig/exportExcel", request)
                 || matchers("/tran/tcmsyndromeConfig/exportExcelModule", request)
                 || matchers("/tran/mappingConfig/getPage", request)
+                || matchers("/tran/mappingConfig/precDataMatch", request)
                 //|| matchers("/tran/hospitalInfo/saveRecord", request)
                 || matchers("/tran/hospitalInfo/getHospitalInfo", request)
                 || matchers("/tran/hospitalInfo/getAllHospitalInfo", request)

+ 2 - 0
src/main/java/com/diagbot/dto/IndexBatchDTO.java

@@ -14,4 +14,6 @@ public class IndexBatchDTO {
     private Long id;
     private String name;
     private String code;
+    private String synonyms;
+    private Integer type;
 }

+ 7 - 1
src/main/java/com/diagbot/entity/wrapper/MappingConfigWrapper.java

@@ -1,12 +1,18 @@
 package com.diagbot.entity.wrapper;
 
 import com.diagbot.entity.MappingConfig;
+import lombok.Getter;
+import lombok.Setter;
 
 /**
  * @Description:
  * @Author:zhaops
  * @time: 2021/6/10 19:27
  */
+@Getter
+@Setter
 public class MappingConfigWrapper extends MappingConfig {
     private String uniqueName;
-}
+    private String form;
+    private String code;
+}

+ 66 - 0
src/main/java/com/diagbot/enums/MatchSourceEnum.java

@@ -0,0 +1,66 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/6/15 13:20
+ */
+public enum MatchSourceEnum implements KeyedNamed {
+    StandWord(1, "标准词"),
+    SynonymsWord(2, "同义词"),
+    Code(3,"编码"),
+    History(4,"历史数据"),
+    SimilarWord(5,"相似词");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    MatchSourceEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static MatchSourceEnum getEnum(int key) {
+        for (MatchSourceEnum item : MatchSourceEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static MatchSourceEnum getEnum(String name) {
+        for (MatchSourceEnum item : MatchSourceEnum.values()) {
+            if (item.name.equals(name)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        MatchSourceEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    public static Integer getKey(String name) {
+        MatchSourceEnum item = getEnum(name);
+        return item != null ? item.key : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}

+ 341 - 15
src/main/java/com/diagbot/facade/MappingConfigFacade.java

@@ -1,6 +1,10 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.client.CdssCoreClient;
+import com.diagbot.dto.IndexBatchDTO;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.AnesthesiaConfig;
 import com.diagbot.entity.DeptConfig;
 import com.diagbot.entity.DiseaseConfig;
@@ -15,21 +19,34 @@ import com.diagbot.entity.TcmdiseaseConfig;
 import com.diagbot.entity.TcmsyndromeConfig;
 import com.diagbot.entity.TransfusionConfig;
 import com.diagbot.entity.wrapper.MappingConfigWrapper;
+import com.diagbot.enums.ConceptTypeEnum;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.MatchSourceEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.MappingConfigServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ExcelUtils;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
+import com.diagbot.util.StringUtil;
 import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.ConceptVO;
 import com.diagbot.vo.MappingConfigPageVO;
 import com.google.common.collect.Lists;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description:
@@ -38,6 +55,8 @@ import java.util.List;
  */
 @Component
 public class MappingConfigFacade extends MappingConfigServiceImpl {
+    @Autowired
+    private CdssCoreClient cdssCoreClient;
 
     /**
      * 分页查询
@@ -92,58 +111,69 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
         switch (type) {
             case 1:
                 fileName = "检验" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", LisConfig.class, fileName, response, 12.8f);
+                List<LisConfig> lisConfigList = BeanUtil.listCopyTo(list, LisConfig.class);
+                ExcelUtils.exportExcel(lisConfigList, null, "sheet1", LisConfig.class, fileName, response, 12.8f);
                 break;
             case 3:
                 fileName = "检查" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", PacsConfig.class, fileName, response, 12.8f);
+                List<PacsConfig> pacsConfigList = BeanUtil.listCopyTo(list, PacsConfig.class);
+                ExcelUtils.exportExcel(pacsConfigList, null, "sheet1", PacsConfig.class, fileName, response, 12.8f);
                 break;
             case 4:
                 fileName = "诊断" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", DiseaseConfig.class, fileName, response, 12.8f);
+                List<DiseaseConfig> diseaseConfigList = BeanUtil.listCopyTo(list, DiseaseConfig.class);
+                ExcelUtils.exportExcel(diseaseConfigList, null, "sheet1", DiseaseConfig.class, fileName, response, 12.8f);
                 break;
             case 5:
                 fileName = "药品" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", DrugConfig.class, fileName, response, 12.8f);
+                List<DrugConfig> drugConfigList = BeanUtil.listCopyTo(list, DrugConfig.class);
+                ExcelUtils.exportExcel(drugConfigList, null, "sheet1", DrugConfig.class, fileName, response, 12.8f);
                 break;
             case 6:
                 fileName = "手术和操作" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", OperationConfig.class, fileName, response, 12.8f);
+                List<OperationConfig> operationConfigList = BeanUtil.listCopyTo(list, OperationConfig.class);
+                ExcelUtils.exportExcel(operationConfigList, null, "sheet1", OperationConfig.class, fileName, response, 12.8f);
                 break;
             case 7:
                 fileName = "科室" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", DeptConfig.class, fileName, response, 12.8f);
+                List<DeptConfig> deptConfigList = BeanUtil.listCopyTo(list, DeptConfig.class);
+                ExcelUtils.exportExcel(deptConfigList, null, "sheet1", DeptConfig.class, fileName, response, 12.8f);
                 break;
             case 8:
                 fileName = "输血" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", TransfusionConfig.class, fileName, response, 12.8f);
+                List<TransfusionConfig> transfusionConfigList = BeanUtil.listCopyTo(list, TransfusionConfig.class);
+                ExcelUtils.exportExcel(transfusionConfigList, null, "sheet1", TransfusionConfig.class, fileName, response, 12.8f);
                 break;
             case 10:
                 fileName = "量表" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", ScaleConfig.class, fileName, response, 12.8f);
+                List<ScaleConfig> scaleConfigList = BeanUtil.listCopyTo(list, ScaleConfig.class);
+                ExcelUtils.exportExcel(scaleConfigList, null, "sheet1", ScaleConfig.class, fileName, response, 12.8f);
                 break;
             case 11:
                 fileName = "护理" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", NurseConfig.class, fileName, response, 12.8f);
+                List<NurseConfig> nurseConfigList = BeanUtil.listCopyTo(list, NurseConfig.class);
+                ExcelUtils.exportExcel(nurseConfigList, null, "sheet1", NurseConfig.class, fileName, response, 12.8f);
                 break;
             case 12:
                 fileName = "中医疾病" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", TcmdiseaseConfig.class, fileName, response, 12.8f);
+                List<TcmdiseaseConfig> tcmdiseaseConfigList = BeanUtil.listCopyTo(list, TcmdiseaseConfig.class);
+                ExcelUtils.exportExcel(tcmdiseaseConfigList, null, "sheet1", TcmdiseaseConfig.class, fileName, response, 12.8f);
                 break;
             case 13:
                 fileName = "中医证候" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", TcmsyndromeConfig.class, fileName, response, 12.8f);
+                List<TcmsyndromeConfig> tcmsyndromeConfigList = BeanUtil.listCopyTo(list, TcmsyndromeConfig.class);
+                ExcelUtils.exportExcel(tcmsyndromeConfigList, null, "sheet1", TcmsyndromeConfig.class, fileName, response, 12.8f);
                 break;
             case 14:
                 fileName = "麻醉" + fileName;
-                ExcelUtils.exportExcel(list, null, "sheet1", AnesthesiaConfig.class, fileName, response, 12.8f);
+                List<AnesthesiaConfig> anesthesiaConfigList = BeanUtil.listCopyTo(list, AnesthesiaConfig.class);
+                ExcelUtils.exportExcel(anesthesiaConfigList, null, "sheet1", AnesthesiaConfig.class, fileName, response, 12.8f);
                 break;
             default:
                 break;
         }
     }
 
-
     /**
      * 导入数据预匹配
      *
@@ -153,7 +183,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
      */
     public void precDataMatch(MultipartFile file, Integer type, HttpServletResponse response) {
         List<MappingConfigWrapper> originList = readImportData(file, type);
-        List<MappingConfigWrapper> retList = dataProcess(originList);
+        List<MappingConfigWrapper> retList = dataProcess(originList, type);
         exportExcel(response, retList, type, "关联数据(预匹配)");
     }
 
@@ -227,10 +257,306 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
      * @param originList
      * @return
      */
-    public List<MappingConfigWrapper> dataProcess(List<MappingConfigWrapper> originList) {
+    public List<MappingConfigWrapper> dataProcess(List<MappingConfigWrapper> originList, Integer type) {
         List<MappingConfigWrapper> retList = Lists.newLinkedList();
+        List<MappingConfigWrapper> standardList = Lists.newLinkedList();
+        List<MappingConfigWrapper> synonymsList = Lists.newLinkedList();
+        List<MappingConfigWrapper> codeList = Lists.newLinkedList();
+        List<MappingConfigWrapper> historyList = Lists.newLinkedList();
+
+        //数据完整性校验
+        for (MappingConfigWrapper item : originList) {
+            if (StringUtil.isNotBlank(item.getHisName())) {
+                item.setHisName(item.getHisName().trim());
+            } else {
+                continue;
+            }
+            if (StringUtil.isNotBlank(item.getHisDetailName())) {
+                item.setHisDetailName(item.getHisDetailName().trim());
+            }
+            if (StringUtil.isNotBlank(item.getHisCode())) {
+                item.setHisCode(item.getHisCode().trim());
+            }
+            item.setUniqueName("");
+            standardList.add(item);
+        }
+
+        if (ListUtil.isEmpty(standardList)) {
+            return retList;
+        }
+
+        //标准词匹配
+        List<String> nameList = standardList.stream()
+                .filter(i -> StringUtil.isBlank(i.getHisDetailName()))
+                .map(MappingConfigWrapper::getHisName)
+                .distinct()
+                .collect(Collectors.toList());
+        List<String> subNameList = standardList.stream()
+                .filter(i -> StringUtil.isNotBlank(i.getHisDetailName()))
+                .map(MappingConfigWrapper::getHisDetailName)
+                .distinct()
+                .collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
+        conceptVO.setType(type);
+        conceptVO.setNames(nameList);
+        RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        conceptVO.setType(ConceptTypeEnum.Lis.getKey());
+        conceptVO.setNames(subNameList);
+        RespDTO<List<IndexBatchDTO>> subRespDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(subRespDTO, "标准术语校验失败");
+        Map<String, IndexBatchDTO> nameMap = new HashMap<>();
+        Map<String, IndexBatchDTO> subNameMap = new HashMap<>();
+        if (ListUtil.isNotEmpty(respDTO.data)) {
+            nameMap = respDTO.data.stream().collect(Collectors.toMap(IndexBatchDTO::getName, v -> v));
+        }
+        if (ListUtil.isNotEmpty(subRespDTO.data)) {
+            subNameMap = subRespDTO.data.stream().collect(Collectors.toMap(IndexBatchDTO::getName, v -> v));
+        }
+        for (MappingConfigWrapper item : standardList) {
+            IndexBatchDTO index = null;
+            if (type.equals(ConceptTypeEnum.LisPack.getKey()) && StringUtil.isNotBlank(item.getHisDetailName())) {
+                if (subNameMap.containsKey(item.getHisDetailName())) {
+                    index = subNameMap.get(item.getHisDetailName());
+                }
+            } else {
+                if (nameMap.containsKey(item.getHisName())) {
+                    index = nameMap.get(item.getHisName());
+                }
+            }
+
+            if (index == null) {
+                continue;
+            }
+            item.setUniqueName(index.getName());
+            item.setConceptId(index.getId());
+            item.setCode(index.getCode());
+            item.setIsMatch(1);
+            item.setSource(MatchSourceEnum.StandWord.getKey());
+        }
+
+        //同义词匹配
+        List<String> synonymsNameList = standardList.stream()
+                .filter(i -> i.getConceptId() == null && StringUtil.isBlank(i.getHisDetailName()))
+                .map(MappingConfigWrapper::getHisName)
+                .distinct()
+                .collect(Collectors.toList());
+        List<String> synonymsSubNameList = standardList.stream()
+                .filter(i -> i.getConceptId() == null && StringUtil.isNotBlank(i.getHisDetailName()))
+                .map(MappingConfigWrapper::getHisDetailName)
+                .distinct()
+                .collect(Collectors.toList());
+        conceptVO.setSource(MatchSourceEnum.SynonymsWord.getKey());
+        conceptVO.setType(type);
+        conceptVO.setNames(synonymsNameList);
+        respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        conceptVO.setType(ConceptTypeEnum.Lis.getKey());
+        conceptVO.setNames(synonymsSubNameList);
+        subRespDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(subRespDTO, "标准术语校验失败");
+        Map<String, List<IndexBatchDTO>> synonymsNameMap = new HashMap<>();
+        Map<String, List<IndexBatchDTO>> synonymsSubNameMap = new HashMap<>();
+        if (ListUtil.isNotEmpty(respDTO.data)) {
+            synonymsNameMap = respDTO.data.stream().collect(Collectors.groupingBy(IndexBatchDTO::getSynonyms));
+        }
+        if (ListUtil.isNotEmpty(subRespDTO.data)) {
+            synonymsSubNameMap = subRespDTO.data.stream().collect(Collectors.groupingBy(IndexBatchDTO::getSynonyms));
+        }
+        for (MappingConfigWrapper item : standardList) {
+            if (item.getIsMatch() != null && item.getIsMatch().equals(1)) {
+                synonymsList.add(item);
+                continue;
+            }
+            List<IndexBatchDTO> indexList = Lists.newLinkedList();
+            if (type.equals(ConceptTypeEnum.LisPack.getKey()) && StringUtil.isNotBlank(item.getHisDetailName())) {
+                if (synonymsSubNameMap.containsKey(item.getHisDetailName())) {
+                    indexList = synonymsSubNameMap.get(item.getHisDetailName());
+                }
+            } else {
+                if (synonymsNameMap.containsKey(item.getHisName())) {
+                    indexList = synonymsNameMap.get(item.getHisName());
+                }
+            }
+            for (IndexBatchDTO index : indexList) {
+                MappingConfigWrapper synonymsItem = new MappingConfigWrapper();
+                BeanUtils.copyProperties(item, synonymsItem);
+                synonymsItem.setUniqueName(index.getName());
+                synonymsItem.setConceptId(index.getId());
+                synonymsItem.setCode(index.getCode());
+                synonymsItem.setIsMatch(1);
+                synonymsItem.setSource(MatchSourceEnum.SynonymsWord.getKey());
+                synonymsList.add(synonymsItem);
+            }
+        }
+
+        //todo 编码匹配
+        if (type.equals(ConceptTypeEnum.Disease.getKey())
+                || type.equals(ConceptTypeEnum.Operation.getKey())
+                || type.equals(ConceptTypeEnum.Tcmdisease.getKey())
+                || type.equals(ConceptTypeEnum.Tcmsyndrome.getKey())) {
+            List<String> codes = synonymsList.stream()
+                    .filter(i -> StringUtil.isNotBlank(i.getCode()))
+                    .map(MappingConfigWrapper::getCode)
+                    .distinct()
+                    .collect(Collectors.toList());
+            if (ListUtil.isEmpty(codes)) {
+                codeList = BeanUtil.listCopyTo(synonymsList, MappingConfigWrapper.class);
+            } else {
+                conceptVO.setSource(MatchSourceEnum.Code.getKey());
+                conceptVO.setType(type);
+                conceptVO.setNames(codes);
+                respDTO = cdssCoreClient.getConceptNames(conceptVO);
+                RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+                Map<String, List<IndexBatchDTO>> codeMap = new HashMap<>();
+                if (ListUtil.isNotEmpty(respDTO.data)) {
+                    codeMap = respDTO.data.stream().collect(Collectors.groupingBy(IndexBatchDTO::getCode));
+                }
+                for (MappingConfigWrapper item : synonymsList) {
+                    if (item.getIsMatch() != null && item.getIsMatch().equals(1)) {
+                        codeList.add(item);
+                        continue;
+                    }
+                    if (StringUtil.isNotBlank(item.getCode()) && codeMap.containsKey(item.getCode())) {
+                        List<IndexBatchDTO> indexList = codeMap.get(item.getCode());
+                        for (IndexBatchDTO index : indexList) {
+                            MappingConfigWrapper codeItem = new MappingConfigWrapper();
+                            BeanUtils.copyProperties(item, codeItem);
+                            codeItem.setUniqueName(index.getName());
+                            codeItem.setConceptId(index.getId());
+                            codeItem.setCode(index.getCode());
+                            codeItem.setIsMatch(1);
+                            codeItem.setSource(MatchSourceEnum.Code.getKey());
+                            codeList.add(codeItem);
+                        }
+                    } else {
+                        codeList.add(item);
+                        continue;
+                    }
+                }
+            }
+        }
+
+        //todo 历史匹配
+        List<String> hisNames = codeList.stream()
+                .filter(i -> i.getIsMatch() == null)
+                .map(MappingConfigWrapper::getHisName)
+                .distinct()
+                .collect(Collectors.toList());
+        if (ListUtil.isNotEmpty(hisNames)) {
+            Map<String, Map<String, List<String>>> configMap = groupByHisNameWithName(hisNames, type, null);
+
+            for (MappingConfigWrapper item : codeList) {
+                if (item.getIsMatch() != null && item.getIsMatch().equals(1)) {
+                    retList.add(item);
+                }
+                if (configMap.containsKey(item.getHisName())) {
+                    Map<String, List<String>> subMap = configMap.get(item.getHisName());
+                    for (Map.Entry<String, List<String>> subEntry : subMap.entrySet()) {
+                        for (String name : subEntry.getValue()) {
+                            MappingConfigWrapper historyItem = new MappingConfigWrapper();
+                            BeanUtils.copyProperties(item, historyItem);
+                            historyItem.setHisDetailName(subEntry.getKey());
+                            historyItem.setUniqueName(name);
+                            historyItem.setIsMatch(1);
+                            historyItem.setSource(MatchSourceEnum.History.getKey());
+                            retList.add(historyItem);
+                        }
+                    }
+                }
+            }
+        } else {
+            retList = BeanUtil.listCopyTo(codeList, MappingConfigWrapper.class);
+        }
 
         return retList;
     }
 
+    /**
+     * 根据医院名称分组-返回id
+     *
+     * @param hisNames
+     * @param type
+     * @return
+     */
+    public Map<String, Map<String, List<Long>>> groupByHisNameWithId(List<String> hisNames, Integer type, Long hospitalId) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
+        QueryWrapper<MappingConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("type", type);
+        if (hospitalId != null) {
+            queryWrapper.eq("hospital_id", hospitalId);
+        }
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        List<MappingConfig> list = this.list(queryWrapper);
+
+        if (ListUtil.isEmpty(list)) {
+            return retMap;
+        }
+
+        for (MappingConfig item : list) {
+            if (StringUtil.isBlank(item.getHisDetailName())) {
+                item.setHisDetailName("");
+            }
+        }
+
+        Map<String, List<MappingConfig>> hisMap = list.stream().collect(Collectors.groupingBy(MappingConfig::getHisName));
+        for (Map.Entry<String, List<MappingConfig>> entry : hisMap.entrySet()) {
+            retMap.put(entry.getKey(), entry.getValue().stream().collect(Collectors.toMap(MappingConfig::getHisDetailName,
+                    v -> {
+                        List<Long> ids = Lists.newArrayList();
+                        ids.add(v.getConceptId());
+                        return ids;
+                    })));
+        }
+
+        return retMap;
+    }
+
+    /**
+     * 根据医院名称分组-返回名称
+     *
+     * @param hisNames
+     * @param type
+     * @param hospitalId
+     * @return
+     */
+    public Map<String, Map<String, List<String>>> groupByHisNameWithName(List<String> hisNames, Integer type, Long hospitalId) {
+        Map<String, Map<String, List<String>>> retMap = new HashMap<>();
+        Map<String, Map<String, List<Long>>> idMap = groupByHisNameWithId(hisNames, type, hospitalId);
+
+        List<Long> ids = idMap.values().stream()
+                .map(i -> i.keySet())
+                .flatMap(Collection::stream)
+                .map(Long::valueOf)
+                .distinct()
+                .collect(Collectors.toList());
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setSource(-1);
+        conceptVO.setType(type);
+        conceptVO.setIds(ids);
+        RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<IndexBatchDTO> indexList = respDTO.data;
+        if (ListUtil.isNotEmpty(indexList)) {
+            Map<Long, List<IndexBatchDTO>> indexMap
+                    = indexList.stream().collect(Collectors.groupingBy(IndexBatchDTO::getId));
+            for (Map.Entry<String, Map<String, List<Long>>> entry : idMap.entrySet()) {
+                Map<String, List<String>> subMap = new HashMap<>();
+                for (Map.Entry<String, List<Long>> subEntry : entry.getValue().entrySet()) {
+                    List<String> nameList = Lists.newArrayList();
+                    subEntry.getValue().forEach(id -> {
+                        nameList.addAll(indexMap.get(id).stream().map(IndexBatchDTO::getName).collect(Collectors.toList()));
+                    });
+                    subMap.put(subEntry.getKey(), nameList);
+                }
+                retMap.put(entry.getKey(), subMap);
+            }
+        }
+        return retMap;
+    }
 }

+ 8 - 2
src/main/java/com/diagbot/vo/ConceptVO.java

@@ -14,7 +14,13 @@ import java.util.List;
 @Getter
 @Setter
 public class ConceptVO {
-    List<String> names;
+    private List<Long> ids;
+    private List<String> names;
     @NotNull(message = "请输入术语类型")
-    Integer type;
+    private Integer type;
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @NotNull(message = "请指定数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)")
+    private Integer source;
 }

+ 19 - 0
src/main/java/com/diagbot/web/MappingConfigController.java

@@ -8,12 +8,16 @@ import com.diagbot.facade.MappingConfigFacade;
 import com.diagbot.vo.MappingConfigPageVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
 /**
@@ -42,4 +46,19 @@ public class MappingConfigController {
         IPage<MappingConfig> data = mappingConfigFacade.getPage(mappingConfigPageVO);
         return RespDTO.onSuc(data);
     }
+
+    /**
+     * 预匹配
+     *
+     * @param file
+     * @param response
+     * @param type
+     * @return
+     */
+    @ApiOperation(value = "预匹配[by:zhaops]", notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response, @RequestParam("type") Integer type) {
+        mappingConfigFacade.precDataMatch(file, type, response);
+    }
 }