فهرست منبع

Merge branch 'master' into 122run

gaodm 4 سال پیش
والد
کامیت
9294d8c68f
28فایلهای تغییر یافته به همراه1647 افزوده شده و 131 حذف شده
  1. 7 2
      cdssman-service/src/main/java/com/diagbot/entity/DeptConfig.java
  2. 153 11
      cdssman-service/src/main/java/com/diagbot/facade/DeptConfigFacade.java
  3. 139 10
      cdssman-service/src/main/java/com/diagbot/facade/DiseaseConfigFacade.java
  4. 151 12
      cdssman-service/src/main/java/com/diagbot/facade/DrugConfigFacade.java
  5. 162 16
      cdssman-service/src/main/java/com/diagbot/facade/LisConfigFacade.java
  6. 136 10
      cdssman-service/src/main/java/com/diagbot/facade/OperationConfigFacade.java
  7. 138 10
      cdssman-service/src/main/java/com/diagbot/facade/PacsConfigFacade.java
  8. 119 0
      cdssman-service/src/main/java/com/diagbot/facade/PlanDefaultFacade.java
  9. 139 10
      cdssman-service/src/main/java/com/diagbot/facade/TransfusionConfigFacade.java
  10. 17 0
      cdssman-service/src/main/java/com/diagbot/vo/PlanDefaultVO.java
  11. 27 0
      cdssman-service/src/main/java/com/diagbot/web/DeptConfigController.java
  12. 27 0
      cdssman-service/src/main/java/com/diagbot/web/DiseaseConfigController.java
  13. 27 0
      cdssman-service/src/main/java/com/diagbot/web/DrugConfigController.java
  14. 27 0
      cdssman-service/src/main/java/com/diagbot/web/LisConfigController.java
  15. 28 0
      cdssman-service/src/main/java/com/diagbot/web/OperationConfigController.java
  16. 27 0
      cdssman-service/src/main/java/com/diagbot/web/PacsConfigController.java
  17. 38 0
      cdssman-service/src/main/java/com/diagbot/web/PlanDefaultController.java
  18. 27 0
      cdssman-service/src/main/java/com/diagbot/web/TransfusionConfigController.java
  19. 2 16
      cdssman-service/src/main/resources/mapper/ConceptInfoMapper.xml
  20. 9 2
      common/src/main/java/com/diagbot/dto/RespDTO.java
  21. 4 0
      common/src/main/java/com/diagbot/exception/CommonErrorCode.java
  22. 3 0
      mrman-service/src/main/java/com/diagbot/dto/QcTypeDTO.java
  23. 5 0
      mrman-service/src/main/java/com/diagbot/entity/QcType.java
  24. 187 25
      mrman-service/src/main/java/com/diagbot/facade/QcTypeFacade.java
  25. 20 0
      mrman-service/src/main/java/com/diagbot/vo/CancelTypeVO.java
  26. 2 0
      mrman-service/src/main/java/com/diagbot/vo/QcTypeSaveVO.java
  27. 25 6
      mrman-service/src/main/java/com/diagbot/web/QcTypeController.java
  28. 1 1
      mrman-service/src/main/resources/mapper/QcCasesEntryMapper.xml

+ 7 - 2
cdssman-service/src/main/java/com/diagbot/entity/DeptConfig.java

@@ -4,11 +4,16 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import org.bouncycastle.math.ec.custom.sec.SecT113Field;
 
 import javax.validation.constraints.NotBlank;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import java.util.function.Predicate;
 
 /**
  * <p>
@@ -201,13 +206,13 @@ public class DeptConfig implements Serializable {
                 && Objects.equals(isDeleted, deptConfig.isDeleted)
                 && Objects.equals(hospitalId, deptConfig.hospitalId)
                 && Objects.equals(hisName, deptConfig.hisName)
-                && Objects.equals(hisCode, deptConfig.hisCode)
+                //&& Objects.equals(hisCode, deptConfig.hisCode)
                 && Objects.equals(uniqueName, deptConfig.uniqueName)
                 && Objects.equals(uniqueCode, deptConfig.uniqueCode);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(id, isDeleted, hospitalId, hisName, hisCode, uniqueName, uniqueCode);
+        return Objects.hash(id, isDeleted, hospitalId, hisName, uniqueName, uniqueCode);
     }
 }

+ 153 - 11
cdssman-service/src/main/java/com/diagbot/facade/DeptConfigFacade.java

@@ -27,6 +27,7 @@ import com.diagbot.vo.HospitalIdVO;
 import com.diagbot.vo.IdListVO;
 import com.diagbot.vo.IdVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -63,6 +64,13 @@ public class DeptConfigFacade {
                 .eq("hospital_id", deptConfig.getHospitalId())
                 .eq("his_name", deptConfig.getHisName())
                 .eq("unique_name", deptConfig.getUniqueName());
+       /* if (StringUtil.isNotBlank(deptConfig.getHisCode())) {
+            queryWrapper.eq("his_code", deptConfig.getHisCode());
+        } else {
+            queryWrapper.and(i -> i.isNull("his_code")
+                    .or()
+                    .eq("his_code", ""));
+        }*/
         DeptConfig oldRecord = deptConfigService.getOne(queryWrapper, false);
         if (deptConfig.getId() == null
                 && oldRecord != null) {
@@ -92,6 +100,13 @@ public class DeptConfigFacade {
                 .eq("hospital_id", deptConfig.getHospitalId())
                 .eq("his_name", deptConfig.getHisName())
                 .eq("unique_name", deptConfig.getUniqueName());
+        /*if (StringUtil.isNotBlank(deptConfig.getHisCode())) {
+            queryWrapper.eq("his_code", deptConfig.getHisCode());
+        } else {
+            queryWrapper.and(i -> i.isNull("his_code")
+                    .or()
+                    .eq("his_code", ""));
+        }*/
         DeptConfig oldRecord = deptConfigService.getOne(queryWrapper, false);
         if (deptConfig.getId() == null
                 && oldRecord != null) {
@@ -157,14 +172,15 @@ public class DeptConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(hospitalId, null, null);
         deptConfigList.forEach(deptConfig -> {
             deptConfig.setModifier(userId);
             deptConfig.setGmtModified(now);
             if (deptConfig.getId() == null) {
-                if (configMap.containsKey(deptConfig.getHisName())) {
-                    deleteIds.add(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
+                if (configMap.containsKey(deptConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
                 }
                 deptConfig.setCreator(userId);
                 deptConfig.setGmtCreate(now);
@@ -295,15 +311,16 @@ public class DeptConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(Long.valueOf(hospitalId), null, null);
         deptConfigList.forEach(deptConfig -> {
             deptConfig.setHospitalId(hospitalId);
             deptConfig.setModifier(userId);
             deptConfig.setGmtModified(now);
             if (deptConfig.getId() == null) {
-                if (configMap.containsKey(deptConfig.getHisName())) {
-                    deleteIds.add(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
+                if (configMap.containsKey(deptConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
                 }
                 deptConfig.setCreator(userId);
                 deptConfig.setGmtCreate(now);
@@ -332,7 +349,7 @@ public class DeptConfigFacade {
         }
         if (ListUtil.isNotEmpty(errorNumList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计入空行)标准术语与数据库术语不匹配:"
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
                             + errorNumList.stream().collect(Collectors.joining("、"))
                             + "。导入取消,请修改后再试。");
         }
@@ -351,7 +368,6 @@ public class DeptConfigFacade {
         return true;
     }
 
-
     /**
      * 获取映射关系-公表名
      *
@@ -360,8 +376,8 @@ public class DeptConfigFacade {
      * @param uniqueNames
      * @return
      */
-    public Map<String, Map<String, Long>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
-        Map<String, Map<String, Long>> retMap = new HashMap<>();
+    public Map<String, Map<String, List<Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
         QueryWrapper<DeptConfig> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("hospital_id", hospitalId);
@@ -378,7 +394,12 @@ public class DeptConfigFacade {
         Map<String, List<DeptConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
         for (Map.Entry<String, List<DeptConfig>> entry : configMap.entrySet()) {
             if (ListUtil.isNotEmpty(entry.getValue())) {
-                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "uniqueName", "id"));
+                Map<String, List<DeptConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<DeptConfig>> subEntry : subMap.entrySet()) {
+                    subIdMap.put(subEntry.getKey(), subEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                }
+                retMap.put(entry.getKey(), subIdMap);
             }
         }
         return retMap;
@@ -419,4 +440,125 @@ public class DeptConfigFacade {
         String fileName = "科室映射模板.xls";
         ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", DeptConfig.class, fileName, response, 12.8f);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file, HttpServletResponse response) {
+        List<DeptConfig> originList = ExcelUtils.importExcel(file, 0, 1, DeptConfig.class);
+        List<DeptConfig> retList = dataProcess(originList);
+        String fileName = "科室关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", DeptConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<DeptConfig> originList = ExcelUtils.importExcel(file, 0, 1, DeptConfig.class);
+        List<DeptConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<DeptConfig> dataProcess(List<DeptConfig> originList) {
+        List<DeptConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<DeptConfig>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<DeptConfig>> entry : allMap.entrySet()) {
+                if (ListUtil.isNotEmpty(entry.getValue())) {
+                    precUniqueName.addAll(entry.getValue().stream().map(i -> i.getUniqueName()).collect(Collectors.toList()));
+                }
+            }
+        }
+        precUniqueName = precUniqueName.stream().distinct().collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(precUniqueName);
+        conceptVO.setType(ConceptTypeEnum.Dept.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (DeptConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<DeptConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (DeptConfig item : items) {
+                        if (uniqueNames.contains(item.getUniqueName())) {
+                            item.setHisCode(originItem.getHisCode());
+                            retList.add(item);
+                            flag = true;
+                        }
+                    }
+                    if (!flag) {
+                        retList.add(originItem);
+                    }
+                } else {
+                    retList.add(originItem);
+                }
+            }
+        }
+
+        retList = retList.stream()
+                .distinct()
+                .collect(Collectors.toList());
+        return retList;
+    }
+
+    /**
+     * 获取所有医院映射数据
+     *
+     * @return
+     */
+    public Map<String, List<DeptConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<DeptConfig>> retMap = new HashMap<>();
+        QueryWrapper<DeptConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<DeptConfig> records = deptConfigService.list(queryWrapper);
+
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? "" : record.getUniqueCode());
+        });
+
+        records = records
+                .stream()
+                .filter(record -> record.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
+                .distinct()
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        retMap = EntityUtil.makeEntityListMap(records, "hisName");
+
+        return retMap;
+    }
 }

+ 139 - 10
cdssman-service/src/main/java/com/diagbot/facade/DiseaseConfigFacade.java

@@ -26,6 +26,7 @@ import com.diagbot.vo.HospitalIdVO;
 import com.diagbot.vo.IdListVO;
 import com.diagbot.vo.IdVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -155,14 +156,15 @@ public class DiseaseConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(hospitalId, null, null);
         diseaseConfigList.forEach(diseaseConfig -> {
             diseaseConfig.setModifier(userId);
             diseaseConfig.setGmtModified(now);
             if (diseaseConfig.getId() == null) {
-                if (configMap.containsKey(diseaseConfig.getHisName())) {
-                    deleteIds.add(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
+                if (configMap.containsKey(diseaseConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
                 }
                 diseaseConfig.setCreator(userId);
                 diseaseConfig.setGmtCreate(now);
@@ -283,15 +285,16 @@ public class DiseaseConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(Long.valueOf(hospitalId), null, null);
         diseaseConfigList.forEach(diseaseConfig -> {
             diseaseConfig.setHospitalId(Long.valueOf(hospitalId));
             diseaseConfig.setModifier(userId);
             diseaseConfig.setGmtModified(now);
             if (diseaseConfig.getId() == null) {
-                if (configMap.containsKey(diseaseConfig.getHisName())) {
-                    deleteIds.add(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
+                if (configMap.containsKey(diseaseConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
                 }
                 diseaseConfig.setCreator(userId);
                 diseaseConfig.setGmtCreate(now);
@@ -320,7 +323,7 @@ public class DiseaseConfigFacade {
         }
         if (ListUtil.isNotEmpty(errorNumList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计入空行)标准术语与数据库术语不匹配:"
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
                             + errorNumList.stream().collect(Collectors.joining("、"))
                             + "。导入取消,请修改后再试。");
         }
@@ -347,8 +350,8 @@ public class DiseaseConfigFacade {
      * @param uniqueNames
      * @return
      */
-    public Map<String, Map<String, Long>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
-        Map<String, Map<String, Long>> retMap = new HashMap<>();
+    public Map<String, Map<String, List<Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
         QueryWrapper<DiseaseConfig> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("hospital_id", hospitalId);
@@ -365,7 +368,12 @@ public class DiseaseConfigFacade {
         Map<String, List<DiseaseConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
         for (Map.Entry<String, List<DiseaseConfig>> entry : configMap.entrySet()) {
             if (ListUtil.isNotEmpty(entry.getValue())) {
-                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "uniqueName", "id"));
+                Map<String, List<DiseaseConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<DiseaseConfig>> subEntry : subMap.entrySet()) {
+                    subIdMap.put(subEntry.getKey(), subEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                }
+                retMap.put(entry.getKey(), subIdMap);
             }
         }
         return retMap;
@@ -406,4 +414,125 @@ public class DiseaseConfigFacade {
         String fileName = "疾病映射模板.xls";
         ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", DiseaseConfig.class, fileName, response, 12.8f);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file, HttpServletResponse response) {
+        List<DiseaseConfig> originList = ExcelUtils.importExcel(file, 0, 1, DiseaseConfig.class);
+        List<DiseaseConfig> retList = dataProcess(originList);
+
+        String fileName = "诊断关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", DiseaseConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<DiseaseConfig> originList = ExcelUtils.importExcel(file, 0, 1, DiseaseConfig.class);
+        List<DiseaseConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<DiseaseConfig> dataProcess(List<DiseaseConfig> originList) {
+        List<DiseaseConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<DiseaseConfig>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<DiseaseConfig>> entry : allMap.entrySet()) {
+                if (ListUtil.isNotEmpty(entry.getValue())) {
+                    precUniqueName.addAll(entry.getValue().stream().map(i -> i.getUniqueName()).collect(Collectors.toList()));
+                }
+            }
+        }
+        precUniqueName = precUniqueName.stream().distinct().collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(precUniqueName);
+        conceptVO.setType(ConceptTypeEnum.Disease.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (DiseaseConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<DiseaseConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (DiseaseConfig item : items) {
+                        if (uniqueNames.contains(item.getUniqueName())) {
+                            retList.add(item);
+                            flag = true;
+                        }
+                    }
+                    if (!flag) {
+                        retList.add(originItem);
+                    }
+                } else {
+                    retList.add(originItem);
+                }
+            }
+        }
+
+        retList = retList.stream()
+                .distinct()
+                .collect(Collectors.toList());
+        return retList;
+    }
+
+    /**
+     * 获取所有医院映射数据
+     *
+     * @return
+     */
+    public Map<String, List<DiseaseConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<DiseaseConfig>> retMap = new HashMap<>();
+        QueryWrapper<DiseaseConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<DiseaseConfig> records = diseaseConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setIcdCode(StringUtils.isBlank(record.getIcdCode()) ? null : record.getIcdCode());
+        });
+
+        records = records
+                .stream()
+                .filter(record -> record.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
+                .distinct()
+                .collect(Collectors.toList());
+
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        retMap = EntityUtil.makeEntityListMap(records, "hisName");
+
+        return retMap;
+    }
 }

+ 151 - 12
cdssman-service/src/main/java/com/diagbot/facade/DrugConfigFacade.java

@@ -28,6 +28,7 @@ import com.diagbot.vo.HospitalIdVO;
 import com.diagbot.vo.IdListVO;
 import com.diagbot.vo.IdVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -184,7 +185,7 @@ public class DrugConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Map<String, Long>>> configMap
+        Map<String, Map<String, Map<String, List<Long>>>> configMap
                 = getConfigMap(hospitalId, hisNames, uniqueNames);
         drugConfigList.forEach(drugConfig -> {
             drugConfig.setHospitalId(Long.valueOf(hospitalId));
@@ -194,8 +195,8 @@ public class DrugConfigFacade {
             if (drugConfig.getId() == null) {
                 if (configMap.get(drugConfig.getHisName()) != null
                         && configMap.get(drugConfig.getHisName()).get(form) != null
-                        && configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()) != null) {
-                    deleteIds.add(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()));
+                        && ListUtil.isNotEmpty(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()));
                 }
                 drugConfig.setCreator(userId);
                 drugConfig.setGmtCreate(now);
@@ -352,7 +353,7 @@ public class DrugConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Map<String, Long>>> configMap
+        Map<String, Map<String, Map<String, List<Long>>>> configMap
                 = getConfigMap(Long.valueOf(hospitalId), hisNames, uniqueNames);
         drugConfigList.forEach(drugConfig -> {
             drugConfig.setHospitalId(Long.valueOf(hospitalId));
@@ -362,8 +363,8 @@ public class DrugConfigFacade {
             if (drugConfig.getId() == null) {
                 if (configMap.get(drugConfig.getHisName()) != null
                         && configMap.get(drugConfig.getHisName()).get(form) != null
-                        && configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()) != null) {
-                    deleteIds.add(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()));
+                        && ListUtil.isNotEmpty(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()));
                 }
                 drugConfig.setCreator(userId);
                 drugConfig.setGmtCreate(now);
@@ -388,7 +389,7 @@ public class DrugConfigFacade {
         }
         if (ListUtil.isNotEmpty(errorNumList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计入空行)标准术语与数据库术语不匹配:"
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
                             + errorNumList.stream().collect(Collectors.joining("、"))
                             + "。导入取消,请修改后再试。");
         }
@@ -415,8 +416,8 @@ public class DrugConfigFacade {
      * @param uniqueNames
      * @return Map<hisName,Map<form,Map<uniqueName,id>>>
      */
-    public Map<String, Map<String,Map<String, Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
-        Map<String, Map<String, Map<String, Long>>> retMap = new HashMap<>();
+    public Map<String, Map<String,Map<String, List<Long>>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Map<String, List<Long>>>> retMap = new HashMap<>();
         QueryWrapper<DrugConfig> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("hospital_id", hospitalId);
@@ -433,7 +434,7 @@ public class DrugConfigFacade {
         Map<String, List<DrugConfig>> hisNameMap = EntityUtil.makeEntityListMap(records, "hisName");
         for (Map.Entry<String, List<DrugConfig>> entry : hisNameMap.entrySet()) {
             if (ListUtil.isNotEmpty(entry.getValue())) {
-                Map<String, Map<String, Long>> formMap = new HashMap<>();
+                Map<String, Map<String, List<Long>>> formMap = new HashMap<>();
                 entry.getValue().forEach(i -> {
                     if (StringUtil.isBlank(i.getForm())) {
                         i.setForm("");
@@ -443,8 +444,12 @@ public class DrugConfigFacade {
                         = EntityUtil.makeEntityListMap(entry.getValue(), "form");
                 for (Map.Entry<String, List<DrugConfig>> subEntry : subMap.entrySet()) {
                     if (ListUtil.isNotEmpty(subEntry.getValue())) {
-                        formMap.put(subEntry.getKey(),
-                                EntityUtil.makeMapWithKeyValue(subEntry.getValue(), "uniqueName", "id"));
+                        Map<String, List<DrugConfig>> thirdMap = EntityUtil.makeEntityListMap(subEntry.getValue(), "uniqueName");
+                        Map<String, List<Long>> idMap = new HashMap<>();
+                        for (Map.Entry<String, List<DrugConfig>> thirdEntry : thirdMap.entrySet()) {
+                            idMap.put(thirdEntry.getKey(), thirdEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                        }
+                        formMap.put(subEntry.getKey(), idMap);
                     }
                 }
                 retMap.put(entry.getKey(), formMap);
@@ -634,4 +639,138 @@ public class DrugConfigFacade {
         from += "]";
         return from;
     }
+
+    /**
+     * 导入数据预匹配
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file,HttpServletResponse response) {
+        List<DrugConfig> originList = ExcelUtils.importExcel(file, 1, 1, DrugConfig.class);
+        List<DrugConfig> retList = dataProcess(originList);
+
+        String fileName = "药品关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, getFrom(), "sheet1", DrugConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<DrugConfig> originList = ExcelUtils.importExcel(file, 1, 1, DrugConfig.class);
+        List<DrugConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<DrugConfig> dataProcess(List<DrugConfig> originList) {
+        List<DrugConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<DrugConfig>> allMap = getAll(hisNameList);
+
+        //药品剂型
+        List<DictionaryInfoDTO> dicTypeMappingList = dictionaryFacade.getListByGroupType(9);
+        List<String> formList = dicTypeMappingList.stream()
+                .filter(i -> StringUtil.isNotBlank(i.getName()))
+                .map(i -> i.getName())
+                .distinct()
+                .collect(Collectors.toList());
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<DrugConfig>> entry : allMap.entrySet()) {
+                if (ListUtil.isNotEmpty(entry.getValue())) {
+                    precUniqueName.addAll(entry.getValue().stream().map(i -> i.getUniqueName()).collect(Collectors.toList()));
+                }
+            }
+        }
+        precUniqueName = precUniqueName.stream().distinct().collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(precUniqueName);
+        conceptVO.setType(ConceptTypeEnum.Drug.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (DrugConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<DrugConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (DrugConfig item : items) {
+                        if (uniqueNames.contains(item.getUniqueName())) {
+                            if (!formList.contains(item.getForm())) {
+                                item.setForm("");
+                            }
+                            retList.add(item);
+                            flag = true;
+                        }
+                    }
+                    if (!flag) {
+                        if (!formList.contains(originItem.getForm())) {
+                            originItem.setForm("");
+                        }
+                        retList.add(originItem);
+                    }
+                } else {
+                    retList.add(originItem);
+                }
+            }
+        }
+
+        retList = retList.stream()
+                .distinct()
+                .collect(Collectors.toList());
+
+        return retList;
+    }
+
+    /**
+     * 获取所有医院映射数据
+     * @return
+     */
+    public Map<String,List<DrugConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<DrugConfig>> retMap = new HashMap<>();
+        QueryWrapper<DrugConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<DrugConfig> records = drugConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? "" : record.getUniqueCode());
+            record.setForm(StringUtils.isBlank(record.getForm()) ? null : record.getForm());
+        });
+
+        records = records
+                .stream()
+                .filter(record -> record.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
+                .distinct()
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        retMap = EntityUtil.makeEntityListMap(records, "hisName");
+
+        return retMap;
+    }
 }

+ 162 - 16
cdssman-service/src/main/java/com/diagbot/facade/LisConfigFacade.java

@@ -27,6 +27,7 @@ import com.diagbot.vo.IdVO;
 import com.diagbot.vo.LisConfigListVO;
 import com.diagbot.vo.LisConfigPageVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -172,7 +173,7 @@ public class LisConfigFacade{
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Map<String, Long>>> configMap
+        Map<String, Map<String, Map<String, List<Long>>>> configMap
                 = getConfigMap(hosptialId, null, null);
         lisConfigList.forEach(lisConfig -> {
             lisConfig.setModifier(userId);
@@ -181,12 +182,12 @@ public class LisConfigFacade{
                 if (configMap.containsKey(lisConfig.getHisName())) {
                     if (lisConfig.getHisDetailName() == null
                             && configMap.get(lisConfig.getHisName()).containsKey("")) {
-                        if (configMap.get(lisConfig.getHisName()).get("").containsKey(lisConfig.getUniqueName())) {
-                            deleteIds.add(configMap.get(lisConfig.getHisName()).get("").get(lisConfig.getUniqueName()));
+                        if (ListUtil.isNotEmpty(configMap.get(lisConfig.getHisName()).get("").get(lisConfig.getUniqueName()))) {
+                            deleteIds.addAll(configMap.get(lisConfig.getHisName()).get("").get(lisConfig.getUniqueName()));
                         }
                     } else if (configMap.get(lisConfig.getHisName()).containsKey(lisConfig.getHisDetailName())) {
-                        if (configMap.get(lisConfig.getHisName()).get(lisConfig.getHisDetailName()).containsKey(lisConfig.getUniqueName())) {
-                            deleteIds.add(configMap
+                        if (ListUtil.isNotEmpty(configMap.get(lisConfig.getHisName()).get(lisConfig.getHisDetailName()).get(lisConfig.getUniqueName()))) {
+                            deleteIds.addAll(configMap
                                     .get(lisConfig.getHisName())
                                     .get(lisConfig.getHisDetailName())
                                     .get(lisConfig.getUniqueName()));
@@ -301,6 +302,9 @@ public class LisConfigFacade{
             if (StringUtil.isNotBlank(lisConfigList.get(i).getHisName())) {
                 lisConfigList.get(i).setHisName(lisConfigList.get(i).getHisName().trim());
             }
+            if (StringUtil.isNotBlank(lisConfigList.get(i).getHisDetailName())) {
+                lisConfigList.get(i).setHisDetailName(lisConfigList.get(i).getHisDetailName().trim());
+            }
             if (StringUtil.isNotBlank(lisConfigList.get(i).getUniqueName())) {
                 lisConfigList.get(i).setUniqueName(lisConfigList.get(i).getUniqueName().trim());
             }
@@ -329,7 +333,7 @@ public class LisConfigFacade{
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Map<String, Long>>> configMap
+        Map<String, Map<String, Map<String, List<Long>>>> configMap
                 = getConfigMap(Long.valueOf(hospitalId), hisNames, uniqueNames);
         lisConfigList.forEach(lisConfig -> {
             lisConfig.setHospitalId(Long.valueOf(hospitalId));
@@ -339,12 +343,12 @@ public class LisConfigFacade{
                 if (configMap.containsKey(lisConfig.getHisName())) {
                     if (lisConfig.getHisDetailName() == null
                             && configMap.get(lisConfig.getHisName()).containsKey("")) {
-                        if (configMap.get(lisConfig.getHisName()).get("").containsKey(lisConfig.getUniqueName())) {
-                            deleteIds.add(configMap.get(lisConfig.getHisName()).get("").get(lisConfig.getUniqueName()));
+                        if (ListUtil.isNotEmpty(configMap.get(lisConfig.getHisName()).get("").get(lisConfig.getUniqueName()))) {
+                            deleteIds.addAll(configMap.get(lisConfig.getHisName()).get("").get(lisConfig.getUniqueName()));
                         }
                     } else if (configMap.get(lisConfig.getHisName()).containsKey(lisConfig.getHisDetailName())) {
-                        if (configMap.get(lisConfig.getHisName()).get(lisConfig.getHisDetailName()).containsKey(lisConfig.getUniqueName())) {
-                            deleteIds.add(configMap
+                        if (ListUtil.isNotEmpty(configMap.get(lisConfig.getHisName()).get(lisConfig.getHisDetailName()).get(lisConfig.getUniqueName()))) {
+                            deleteIds.addAll(configMap
                                     .get(lisConfig.getHisName())
                                     .get(lisConfig.getHisDetailName())
                                     .get(lisConfig.getUniqueName()));
@@ -379,7 +383,7 @@ public class LisConfigFacade{
         }
         if (ListUtil.isNotEmpty(errorNumList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计入空行)标准术语与数据库术语不匹配:"
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
                             + errorNumList.stream().collect(Collectors.joining("、"))
                             + "。导入取消,请修改后再试。");
         }
@@ -407,8 +411,8 @@ public class LisConfigFacade{
      * @param uniqueNames
      * @return
      */
-    public Map<String, Map<String, Map<String, Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
-        Map<String, Map<String, Map<String, Long>>> retMap = new HashMap<>();
+    public Map<String, Map<String, Map<String, List<Long>>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Map<String, List<Long>>>> retMap = new HashMap<>();
         QueryWrapper<LisConfig> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("hospital_id", hospitalId);
@@ -432,14 +436,18 @@ public class LisConfigFacade{
         Map<String, List<LisConfig>> hisNameMap = EntityUtil.makeEntityListMap(records, "hisName");
         for (Map.Entry<String, List<LisConfig>> entry : hisNameMap.entrySet()) {
             if (ListUtil.isNotEmpty(entry.getValue())) {
-                Map<String, Map<String, Long>> detailNameMap = new HashMap<>();
+                Map<String, Map<String, List<Long>>> detailNameMap = new HashMap<>();
                 //his名称映射到标准词,1:n
                 Map<String, List<LisConfig>> hisDetailNameMap
                         = EntityUtil.makeEntityListMap(entry.getValue(), "hisDetailName");
                 for (Map.Entry<String, List<LisConfig>> detailEntry : hisDetailNameMap.entrySet()) {
                     if (ListUtil.isNotEmpty(detailEntry.getValue())) {
-                        detailNameMap.put(detailEntry.getKey(),
-                                EntityUtil.makeMapWithKeyValue(detailEntry.getValue(), "uniqueName", "id"));
+                        Map<String, List<LisConfig>> thirdMap = EntityUtil.makeEntityListMap(detailEntry.getValue(), "uniqueName");
+                        Map<String, List<Long>> idMap = new HashMap<>();
+                        for (Map.Entry<String, List<LisConfig>> thirdEntry : thirdMap.entrySet()) {
+                            idMap.put(thirdEntry.getKey(), thirdEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                        }
+                        detailNameMap.put(detailEntry.getKey(), idMap);
                     }
                 }
                 retMap.put(entry.getKey(), detailNameMap);
@@ -483,4 +491,142 @@ public class LisConfigFacade{
         String fileName = "检验映射模板.xls";
         ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", LisConfig.class, fileName, response, 12.8f);
     }
+
+    /**
+     * 导入数据预匹配
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file,HttpServletResponse response) {
+        List<LisConfig> originList = ExcelUtils.importExcel(file, 0, 1, LisConfig.class);
+        List<LisConfig> retList = dataProcess(originList);
+
+        String fileName = "检验关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", LisConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<LisConfig> originList = ExcelUtils.importExcel(file, 0, 1, LisConfig.class);
+        List<LisConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<LisConfig> dataProcess(List<LisConfig> originList) {
+        List<LisConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, Map<String, List<LisConfig>>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+            if(StringUtil.isNotBlank(item.getHisDetailName())) {
+                item.setHisDetailName(item.getHisDetailName().trim());
+            }
+        });
+
+        //标准术语校验
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, Map<String, List<LisConfig>>> entry : allMap.entrySet()) {
+                for (Map.Entry<String, List<LisConfig>> subEntry : entry.getValue().entrySet()) {
+                    if (ListUtil.isNotEmpty(subEntry.getValue())) {
+                        precUniqueName.addAll(subEntry.getValue().stream().map(i -> i.getUniqueName()).collect(Collectors.toList()));
+                    }
+                }
+            }
+        }
+        precUniqueName = precUniqueName.stream().distinct().collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(precUniqueName);
+        conceptVO.setType(ConceptTypeEnum.LisPack.getKey());
+        RespDTO<List<String>> respLisPackDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respLisPackDTO, "标准术语校验失败");
+        List<String> lisPackNames = respLisPackDTO.data;
+        conceptVO.setType(ConceptTypeEnum.Lis.getKey());
+        RespDTO<List<String>> respLisDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respLisDTO, "标准术语校验失败");
+        List<String> lisNames = respLisDTO.data;
+
+        if (ListUtil.isNotEmpty(originList)) {
+            for (LisConfig originItem : originList) {
+                if (StringUtils.isBlank(originItem.getHisDetailName())) {
+                    originItem.setHisDetailName("");
+                }
+                if (allMap.containsKey(originItem.getHisName())
+                        && allMap.get(originItem.getHisName()).containsKey(originItem.getHisDetailName())) {
+                    List<LisConfig> items = allMap.get(originItem.getHisName()).get(originItem.getHisDetailName());
+                    boolean flag = false;
+                    for (LisConfig item : items) {
+                        if (lisPackNames.contains(item.getUniqueName())
+                                || lisNames.contains(item.getUniqueName())) {
+                            retList.add(item);
+                            flag = true;
+                        }
+                    }
+                    if (!flag) {
+                        retList.add(originItem);
+                    }
+                } else {
+                    retList.add(originItem);
+                }
+            }
+        }
+
+        retList = retList.stream()
+                .distinct()
+                .collect(Collectors.toList());
+        return retList;
+    }
+
+    /**
+     * 获取所有医院映射数据
+     * @return
+     */
+    public Map<String,Map<String,List<LisConfig>>>  getAll(List<String> hisNameList) {
+        Map<String, Map<String, List<LisConfig>>> retMap = new HashMap<>();
+        QueryWrapper<LisConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<LisConfig> records = lisConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setHisDetailName(StringUtils.isBlank(record.getHisDetailName()) ? "" : record.getHisDetailName());
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? "" : record.getUniqueCode());
+        });
+
+        records = records
+                .stream()
+                .filter(record -> record.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
+                .distinct()
+                .collect(Collectors.toList());
+
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        Map<String, List<LisConfig>> hisNameMap = EntityUtil.makeEntityListMap(records, "hisName");
+
+        for (Map.Entry<String, List<LisConfig>> entry : hisNameMap.entrySet()) {
+            retMap.put(entry.getKey(),
+                    EntityUtil.makeEntityListMap(entry.getValue(), "hisDetailName"));
+        }
+        return retMap;
+    }
 }

+ 136 - 10
cdssman-service/src/main/java/com/diagbot/facade/OperationConfigFacade.java

@@ -27,6 +27,7 @@ import com.diagbot.vo.IdVO;
 import com.diagbot.vo.OperationConfigListVO;
 import com.diagbot.vo.OperationConfigPageVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -159,14 +160,15 @@ public class OperationConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(hospitalId, null, null);
         operationConfigList.forEach(operationConfig -> {
             operationConfig.setModifier(userId);
             operationConfig.setGmtModified(now);
             if (operationConfig.getId() == null) {
-                if (configMap.containsKey(operationConfig.getHisName())) {
-                    deleteIds.add(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
+                if (configMap.containsKey(operationConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
                 }
                 operationConfig.setCreator(userId);
                 operationConfig.setGmtCreate(now);
@@ -292,15 +294,16 @@ public class OperationConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(Long.valueOf(hospitalId), null, null);
         operationConfigList.forEach(operationConfig -> {
             operationConfig.setHospitalId(Long.valueOf(hospitalId));
             operationConfig.setModifier(userId);
             operationConfig.setGmtModified(now);
             if (operationConfig.getId() == null) {
-                if (configMap.containsKey(operationConfig.getHisName())) {
-                    deleteIds.add(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
+                if (configMap.containsKey(operationConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
                 }
                 operationConfig.setCreator(userId);
                 operationConfig.setGmtCreate(now);
@@ -329,7 +332,7 @@ public class OperationConfigFacade {
         }
         if (ListUtil.isNotEmpty(errorNumList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计入空行)标准术语与数据库术语不匹配:"
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
                             + errorNumList.stream().collect(Collectors.joining("、"))
                             + "。导入取消,请修改后再试。");
         }
@@ -356,8 +359,8 @@ public class OperationConfigFacade {
      * @param uniqueNames
      * @return
      */
-    public Map<String, Map<String, Long>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
-        Map<String, Map<String, Long>> retMap = new HashMap<>();
+    public Map<String, Map<String, List<Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
         QueryWrapper<OperationConfig> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("hospital_id", hospitalId);
@@ -374,7 +377,12 @@ public class OperationConfigFacade {
         Map<String, List<OperationConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
         for (Map.Entry<String, List<OperationConfig>> entry : configMap.entrySet()) {
             if (ListUtil.isNotEmpty(entry.getValue())) {
-                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "uniqueName", "id"));
+                Map<String, List<OperationConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<OperationConfig>> subEntry : subMap.entrySet()) {
+                    subIdMap.put(subEntry.getKey(), subEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                }
+                retMap.put(entry.getKey(), subIdMap);
             }
         }
         return retMap;
@@ -415,4 +423,122 @@ public class OperationConfigFacade {
         String fileName = "手术映射模板.xls";
         ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", OperationConfig.class, fileName, response, 12.8f);
     }
+
+    /**
+     * 导入数据预匹配
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file,HttpServletResponse response) {
+        List<OperationConfig> originList = ExcelUtils.importExcel(file, 0, 1, OperationConfig.class);
+        List<OperationConfig> retList = dataProcess(originList);
+
+        String fileName = "手术和操作关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", OperationConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<OperationConfig> originList = ExcelUtils.importExcel(file, 0, 1, OperationConfig.class);
+        List<OperationConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<OperationConfig> dataProcess(List<OperationConfig> originList) {
+        List<OperationConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<OperationConfig>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<OperationConfig>> entry : allMap.entrySet()) {
+                if (ListUtil.isNotEmpty(entry.getValue())) {
+                    precUniqueName.addAll(entry.getValue().stream().map(i -> i.getUniqueName()).collect(Collectors.toList()));
+                }
+            }
+        }
+        precUniqueName = precUniqueName.stream().distinct().collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(precUniqueName);
+        conceptVO.setType(ConceptTypeEnum.Opeartion.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (OperationConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<OperationConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (OperationConfig item : items) {
+                        if (uniqueNames.contains(item.getUniqueName())) {
+                            retList.add(item);
+                            flag = true;
+                        }
+                    }
+                    if (!flag) {
+                        retList.add(originItem);
+                    }
+                } else {
+                    retList.add(originItem);
+                }
+            }
+        }
+
+        retList = retList.stream()
+                .distinct()
+                .collect(Collectors.toList());
+        return retList;
+    }
+
+    /**
+     * 获取所有医院映射数据
+     * @return
+     */
+    public Map<String,List<OperationConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<OperationConfig>> retMap = new HashMap<>();
+        QueryWrapper<OperationConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<OperationConfig> records = operationConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? "" : record.getUniqueCode());
+        });
+
+        records = records
+                .stream()
+                .filter(record -> record.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
+                .distinct()
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        retMap = EntityUtil.makeEntityListMap(records, "hisName");
+
+        return retMap;
+    }
 }

+ 138 - 10
cdssman-service/src/main/java/com/diagbot/facade/PacsConfigFacade.java

@@ -27,6 +27,7 @@ import com.diagbot.vo.IdVO;
 import com.diagbot.vo.PacsConfigListVO;
 import com.diagbot.vo.PacsConfigPageVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -157,14 +158,15 @@ public class PacsConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(hospitalId, null, null);
         pacsConfigList.forEach(pacsConfig -> {
             pacsConfig.setModifier(userId);
             pacsConfig.setGmtModified(now);
             if (pacsConfig.getId() == null) {
-                if (configMap.containsKey(pacsConfig.getHisName())) {
-                    deleteIds.add(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
+                if (configMap.containsKey(pacsConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
                 }
                 pacsConfig.setCreator(userId);
                 pacsConfig.setGmtCreate(now);
@@ -290,15 +292,16 @@ public class PacsConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(Long.valueOf(hospitalId), null, null);
         pacsConfigList.forEach(pacsConfig -> {
             pacsConfig.setHospitalId(Long.valueOf(hospitalId));
             pacsConfig.setModifier(userId);
             pacsConfig.setGmtModified(now);
             if (pacsConfig.getId() == null) {
-                if (configMap.containsKey(pacsConfig.getHisName())) {
-                    deleteIds.add(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
+                if (configMap.containsKey(pacsConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
                 }
                 pacsConfig.setCreator(userId);
                 pacsConfig.setGmtCreate(now);
@@ -327,7 +330,7 @@ public class PacsConfigFacade {
         }
         if (ListUtil.isNotEmpty(errorNumList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计入空行)标准术语与数据库术语不匹配:"
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
                             + errorNumList.stream().collect(Collectors.joining("、"))
                             + "。导入取消,请修改后再试。");
         }
@@ -354,8 +357,8 @@ public class PacsConfigFacade {
      * @param uniqueNames
      * @return
      */
-    public Map<String, Map<String, Long>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
-        Map<String, Map<String, Long>> retMap = new HashMap<>();
+    public Map<String, Map<String, List<Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
         QueryWrapper<PacsConfig> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("hospital_id", hospitalId);
@@ -372,7 +375,12 @@ public class PacsConfigFacade {
         Map<String, List<PacsConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
         for (Map.Entry<String, List<PacsConfig>> entry : configMap.entrySet()) {
             if (ListUtil.isNotEmpty(entry.getValue())) {
-                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "uniqueName", "id"));
+                Map<String, List<PacsConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<PacsConfig>> subEntry : subMap.entrySet()) {
+                    subIdMap.put(subEntry.getKey(), subEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                }
+                retMap.put(entry.getKey(), subIdMap);
             }
         }
         return retMap;
@@ -413,4 +421,124 @@ public class PacsConfigFacade {
         String fileName = "检查映射模板.xls";
         ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", PacsConfig.class, fileName, response, 12.8f);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file, HttpServletResponse response) {
+        List<PacsConfig> originList = ExcelUtils.importExcel(file, 0, 1, PacsConfig.class);
+        List<PacsConfig> retList = dataProcess(originList);
+
+        String fileName = "检查关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", PacsConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<PacsConfig> originList = ExcelUtils.importExcel(file, 0, 1, PacsConfig.class);
+        List<PacsConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<PacsConfig> dataProcess(List<PacsConfig> originList) {
+        List<PacsConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<PacsConfig>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<PacsConfig>> entry : allMap.entrySet()) {
+                if (ListUtil.isNotEmpty(entry.getValue())) {
+                    precUniqueName.addAll(entry.getValue().stream().map(i -> i.getUniqueName()).collect(Collectors.toList()));
+                }
+            }
+        }
+        precUniqueName = precUniqueName.stream().distinct().collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(precUniqueName);
+        conceptVO.setType(ConceptTypeEnum.Pacs.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (PacsConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<PacsConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (PacsConfig item : items) {
+                        if (uniqueNames.contains(item.getUniqueName())) {
+                            retList.add(item);
+                            flag = true;
+                        }
+                    }
+                    if (!flag) {
+                        retList.add(originItem);
+                    }
+                } else {
+                    retList.add(originItem);
+                }
+            }
+        }
+
+        retList = retList.stream()
+                .distinct()
+                .collect(Collectors.toList());
+        return retList;
+    }
+
+    /**
+     * 获取所有医院映射数据
+     *
+     * @return
+     */
+    public Map<String, List<PacsConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<PacsConfig>> retMap = new HashMap<>();
+        QueryWrapper<PacsConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<PacsConfig> records = pacsConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? "" : record.getUniqueCode());
+        });
+
+        records = records
+                .stream()
+                .filter(record -> record.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
+                .distinct()
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        retMap = EntityUtil.makeEntityListMap(records, "hisName");
+
+        return retMap;
+    }
 }

+ 119 - 0
cdssman-service/src/main/java/com/diagbot/facade/PlanDefaultFacade.java

@@ -0,0 +1,119 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.dto.PlanDetailDTO;
+import com.diagbot.dto.PlanInfoDefaultDTO;
+import com.diagbot.entity.Plan;
+import com.diagbot.entity.PlanDetail;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.HospitalSetVO;
+import com.diagbot.vo.PlanDefaultVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2020-11-20 9:32
+ */
+@Component
+public class PlanDefaultFacade {
+    @Autowired
+    PlanDetailFacade planDetailFacade;
+    @Autowired
+    PlanFacade planFacade;
+
+    public Boolean addDefaultPlans(PlanDefaultVO planDefaultVO) {
+        boolean res = false;
+        Date now = DateUtil.now();
+        List<String> planCode = Arrays.asList("plan_default","patientia","info","chief","symptom","other","vital","lis","pacs","diag","doc_advice");
+        if(ListUtil.isEmpty(planCode)){
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "方案编码不能为空!");
+        }
+        for (String str:planCode) {
+            PlanInfoDefaultDTO data = new PlanInfoDefaultDTO();
+            QueryWrapper<Plan> planFand = new QueryWrapper<>();
+            planFand.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("plan_code", str)
+                    .eq("hospital_id", -1L);
+            Plan plan = planFacade.getOne(planFand, false);
+            BeanUtil.copyProperties(plan, data);
+            List<Long> planId = new ArrayList<>();
+            planId.add(plan.getId());
+            HospitalSetVO hospitalSetVO = new HospitalSetVO();
+            hospitalSetVO.setHospitalId(-1L);
+            hospitalSetVO.setPlanId(planId);
+            List<PlanDetailDTO> sysSetInfoData = planDetailFacade.getSysSetInfoData(hospitalSetVO);
+            data.setPlanDetailDefault(sysSetInfoData);
+            //先效验改医院下是否存在该方案
+            int countTow = planFacade.count(new QueryWrapper<Plan>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("hospital_id", planDefaultVO.getHospitalId())
+                    .eq("plan_code", str));
+            if (countTow > 0) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, str+"该方案编码已存在");
+            }
+            //保存方案配置
+            if (plan != null) {
+                Plan planDefault = new Plan();
+                planDefault.setHospitalId(planDefaultVO.getHospitalId());
+                planDefault.setPlanCode(plan.getPlanCode());
+                planDefault.setPlanName(plan.getPlanName());
+                planDefault.setPlanStatus(1);
+                planDefault.setRemark("0");
+                planDefault.setModifier("-1");
+                planDefault.setCreator("-1");
+                planDefault.setGmtModified(now);
+                planDefault.setGmtCreate(now);
+                res = planFacade.save(planDefault);
+                if (res) {
+                    Long planIdDetail = planDefault.getId();
+                    List<PlanDetailDTO> PlanDetailDefault = new ArrayList<>();
+                    for (PlanDetailDTO dataDetail : sysSetInfoData) {
+                        //先保存父类
+                        PlanDetail planDetailParent = new PlanDetail();
+                        planDetailParent.setParentId(-1L);
+                        planDetailParent.setPlanId(planIdDetail);
+                        planDetailParent.setName(dataDetail.getName());
+                        planDetailParent.setCode(dataDetail.getCode());
+                        planDetailParent.setHospitalId(planDefaultVO.getHospitalId());
+                        planDetailParent.setStatus(1);
+                        planDetailParent.setOrderNo(dataDetail.getOrderNo());
+                        planDetailParent.setNumber(dataDetail.getNumber());
+                        res = planDetailFacade.save(planDetailParent);
+                        if (res) {
+                            Long parentIdSub = planDetailParent.getId();
+                            List<PlanDetailDTO> planDetails = dataDetail.getPlanDetails();
+                            if (ListUtil.isNotEmpty(planDetails)) {
+                                for (PlanDetailDTO detail : planDetails) {
+                                    //再保存子类
+                                    PlanDetail planDetailSub = new PlanDetail();
+                                    planDetailSub.setParentId(parentIdSub);
+                                    planDetailSub.setPlanId(planIdDetail);
+                                    planDetailSub.setName(detail.getName());
+                                    planDetailSub.setCode(detail.getCode());
+                                    planDetailSub.setHospitalId(planDefaultVO.getHospitalId());
+                                    planDetailSub.setStatus(1);
+                                    planDetailSub.setOrderNo(detail.getOrderNo());
+                                    planDetailSub.setNumber(detail.getNumber());
+                                    res = planDetailFacade.save(planDetailSub);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return res;
+    }
+}

+ 139 - 10
cdssman-service/src/main/java/com/diagbot/facade/TransfusionConfigFacade.java

@@ -27,6 +27,7 @@ import com.diagbot.vo.IdVO;
 import com.diagbot.vo.TransfusionConfigListVO;
 import com.diagbot.vo.TransfusionConfigPageVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -157,14 +158,15 @@ public class TransfusionConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(hospitalId, null, null);
         transfusionConfigList.forEach(transfusionConfig -> {
             transfusionConfig.setModifier(userId);
             transfusionConfig.setGmtModified(now);
             if (transfusionConfig.getId() == null) {
-                if (configMap.containsKey(transfusionConfig.getHisName())) {
-                    deleteIds.add(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()));
+                if (configMap.containsKey(transfusionConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()));
                 }
                 transfusionConfig.setCreator(userId);
                 transfusionConfig.setGmtCreate(now);
@@ -290,15 +292,16 @@ public class TransfusionConfigFacade {
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
         List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
+        Map<String, Map<String, List<Long>>> configMap
                 = getConfigMap(Long.valueOf(hospitalId), null, null);
         transfusionConfigList.forEach(transfusionConfig -> {
             transfusionConfig.setHospitalId(Long.valueOf(hospitalId));
             transfusionConfig.setModifier(userId);
             transfusionConfig.setGmtModified(now);
             if (transfusionConfig.getId() == null) {
-                if (configMap.containsKey(transfusionConfig.getHisName())) {
-                    deleteIds.add(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()));
+                if (configMap.containsKey(transfusionConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()));
                 }
                 transfusionConfig.setCreator(userId);
                 transfusionConfig.setGmtCreate(now);
@@ -327,7 +330,7 @@ public class TransfusionConfigFacade {
         }
         if (ListUtil.isNotEmpty(errorNumList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计入空行)标准术语与数据库术语不匹配:"
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
                             + errorNumList.stream().collect(Collectors.joining("、"))
                             + "。导入取消,请修改后再试。");
         }
@@ -354,8 +357,8 @@ public class TransfusionConfigFacade {
      * @param uniqueNames
      * @return
      */
-    public Map<String, Map<String, Long>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
-        Map<String, Map<String, Long>> retMap = new HashMap<>();
+    public Map<String, Map<String, List<Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
         QueryWrapper<TransfusionConfig> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("hospital_id", hospitalId);
@@ -372,7 +375,12 @@ public class TransfusionConfigFacade {
         Map<String, List<TransfusionConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
         for (Map.Entry<String, List<TransfusionConfig>> entry : configMap.entrySet()) {
             if (ListUtil.isNotEmpty(entry.getValue())) {
-                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "uniqueName", "id"));
+                Map<String, List<TransfusionConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<TransfusionConfig>> subEntry : subMap.entrySet()) {
+                    subIdMap.put(subEntry.getKey(), subEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                }
+                retMap.put(entry.getKey(), subIdMap);
             }
         }
         return retMap;
@@ -413,4 +421,125 @@ public class TransfusionConfigFacade {
         String fileName = "输血映射模板.xls";
         ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", TransfusionConfig.class, fileName, response, 12.8f);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file, HttpServletResponse response) {
+        List<TransfusionConfig> originList = ExcelUtils.importExcel(file, 0, 1, TransfusionConfig.class);
+        List<TransfusionConfig> retList = dataProcess(originList);
+
+        String fileName = "输血关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", TransfusionConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<TransfusionConfig> originList = ExcelUtils.importExcel(file, 0, 1, TransfusionConfig.class);
+        List<TransfusionConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<TransfusionConfig> dataProcess(List<TransfusionConfig> originList) {
+        List<TransfusionConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<TransfusionConfig>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<TransfusionConfig>> entry : allMap.entrySet()) {
+                if (ListUtil.isNotEmpty(entry.getValue())) {
+                    precUniqueName.addAll(entry.getValue().stream().map(i -> i.getUniqueName()).collect(Collectors.toList()));
+                }
+            }
+        }
+        precUniqueName = precUniqueName.stream().distinct().collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(precUniqueName);
+        conceptVO.setType(ConceptTypeEnum.Transfusion.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (TransfusionConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<TransfusionConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (TransfusionConfig item : items) {
+                        if (uniqueNames.contains(item.getUniqueName())) {
+                            retList.add(item);
+                            flag = true;
+                        }
+                    }
+                    if (!flag) {
+                        retList.add(originItem);
+                    }
+                } else {
+                    retList.add(originItem);
+                }
+            }
+        }
+
+        retList = retList.stream()
+                .distinct()
+                .collect(Collectors.toList());
+
+        return retList;
+    }
+
+    /**
+     * 获取所有医院映射数据
+     *
+     * @return
+     */
+    public Map<String, List<TransfusionConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<TransfusionConfig>> retMap = new HashMap<>();
+        QueryWrapper<TransfusionConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<TransfusionConfig> records = transfusionConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? "" : record.getUniqueCode());
+        });
+
+        records = records
+                .stream()
+                .filter(record -> record.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
+                .distinct()
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        retMap = EntityUtil.makeEntityListMap(records, "hisName");
+
+        return retMap;
+    }
 }

+ 17 - 0
cdssman-service/src/main/java/com/diagbot/vo/PlanDefaultVO.java

@@ -0,0 +1,17 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2020-11-20 9:35
+ */
+@Setter
+@Getter
+public class PlanDefaultVO {
+    private Long hospitalId;
+}

+ 27 - 0
cdssman-service/src/main/java/com/diagbot/web/DeptConfigController.java

@@ -190,4 +190,31 @@ public class DeptConfigController {
     public void exportExcelModule(HttpServletResponse response) {
         deptConfigFacade.exportExcelModule(response);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据预匹配[by:zhaops]",
+            notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
+        deptConfigFacade.precDataMatch(file, response);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据验证[by:zhaops]",
+            notes = "")
+    @PostMapping("/dataVerify")
+    @SysLogger("dataVerify")
+    public RespDTO<Boolean> dataVerify(@RequestParam("file") MultipartFile file) {
+        Boolean data = deptConfigFacade.dataVerify(file);
+        return RespDTO.onSuc(data);
+    }
 }

+ 27 - 0
cdssman-service/src/main/java/com/diagbot/web/DiseaseConfigController.java

@@ -189,4 +189,31 @@ public class DiseaseConfigController {
     public void exportExcelModule(HttpServletResponse response) {
         diseaseConfigFacade.exportExcelModule(response);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据预匹配[by:zhaops]",
+            notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
+        diseaseConfigFacade.precDataMatch(file, response);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据验证[by:zhaops]",
+            notes = "")
+    @PostMapping("/dataVerify")
+    @SysLogger("dataVerify")
+    public RespDTO<Boolean> dataVerify(@RequestParam("file") MultipartFile file) {
+        Boolean data = diseaseConfigFacade.dataVerify(file);
+        return RespDTO.onSuc(data);
+    }
 }

+ 27 - 0
cdssman-service/src/main/java/com/diagbot/web/DrugConfigController.java

@@ -190,4 +190,31 @@ public class DrugConfigController {
     public void exportExcelModule(HttpServletResponse response) {
         drugConfigFacade.exportExcelModule(response);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据预匹配[by:zhaops]",
+            notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
+        drugConfigFacade.precDataMatch(file, response);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据验证[by:zhaops]",
+            notes = "")
+    @PostMapping("/dataVerify")
+    @SysLogger("dataVerify")
+    public RespDTO<Boolean> dataVerify(@RequestParam("file") MultipartFile file) {
+        Boolean data = drugConfigFacade.dataVerify(file);
+        return RespDTO.onSuc(data);
+    }
 }

+ 27 - 0
cdssman-service/src/main/java/com/diagbot/web/LisConfigController.java

@@ -188,4 +188,31 @@ public class LisConfigController {
     public void exportExcelModule(HttpServletResponse response) {
         lisConfigFacade.exportExcelModule(response);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据预匹配[by:zhaops]",
+            notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
+        lisConfigFacade.precDataMatch(file, response);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据验证[by:zhaops]",
+            notes = "")
+    @PostMapping("/dataVerify")
+    @SysLogger("dataVerify")
+    public RespDTO<Boolean> dataVerify(@RequestParam("file") MultipartFile file) {
+        Boolean data = lisConfigFacade.dataVerify(file);
+        return RespDTO.onSuc(data);
+    }
 }

+ 28 - 0
cdssman-service/src/main/java/com/diagbot/web/OperationConfigController.java

@@ -190,4 +190,32 @@ public class OperationConfigController {
     public void exportExcelModule(HttpServletResponse response) {
         operationConfigFacade.exportExcelModule(response);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据预匹配[by:zhaops]",
+            notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
+        operationConfigFacade.precDataMatch(file, response);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据验证[by:zhaops]",
+            notes = "")
+    @PostMapping("/dataVerify")
+    @SysLogger("dataVerify")
+    public RespDTO<Boolean> dataVerify(@RequestParam("file") MultipartFile file) {
+        Boolean data = operationConfigFacade.dataVerify(file);
+        return RespDTO.onSuc(data);
+    }
+
 }

+ 27 - 0
cdssman-service/src/main/java/com/diagbot/web/PacsConfigController.java

@@ -191,4 +191,31 @@ public class PacsConfigController {
     public void exportExcelModule(HttpServletResponse response) {
         pacsConfigFacade.exportExcelModule(response);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据预匹配[by:zhaops]",
+            notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
+        pacsConfigFacade.precDataMatch(file, response);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据验证[by:zhaops]",
+            notes = "")
+    @PostMapping("/dataVerify")
+    @SysLogger("dataVerify")
+    public RespDTO<Boolean> dataVerify(@RequestParam("file") MultipartFile file) {
+        Boolean data = pacsConfigFacade.dataVerify(file);
+        return RespDTO.onSuc(data);
+    }
 }

+ 38 - 0
cdssman-service/src/main/java/com/diagbot/web/PlanDefaultController.java

@@ -0,0 +1,38 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.PlanDefaultFacade;
+import com.diagbot.vo.PlanDefaultVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+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.RestController;
+
+import javax.validation.Valid;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2020-11-20 9:29
+ */
+@RestController
+@RequestMapping("/sys/plan")
+@Api(value = "一键添加方案配置信息API", tags = { "一键添加方案配置信息API" })
+@SuppressWarnings("unchecked")
+public class PlanDefaultController {
+    @Autowired
+    PlanDefaultFacade planDefaultFacade;
+
+    @ApiOperation(value = "一键添加方案配置信息[by:wangfeng]", notes = "一键添加方案配置信息")
+    @PostMapping("/addDefaultPlans")
+    @SysLogger("addDefaultPlans")
+    @Transactional
+    public RespDTO<Boolean> addDefaultPlans(@Valid @RequestBody PlanDefaultVO planDefaultVO) {
+        return RespDTO.onSuc(planDefaultFacade.addDefaultPlans(planDefaultVO));
+    }
+}

+ 27 - 0
cdssman-service/src/main/java/com/diagbot/web/TransfusionConfigController.java

@@ -186,4 +186,31 @@ public class TransfusionConfigController {
     public void exportExcelModule(HttpServletResponse response) {
         transfusionConfigFacade.exportExcelModule(response);
     }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据预匹配[by:zhaops]",
+            notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
+        transfusionConfigFacade.precDataMatch(file, response);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @return
+     */
+    @ApiOperation(value = "导入数据验证[by:zhaops]",
+            notes = "")
+    @PostMapping("/dataVerify")
+    @SysLogger("dataVerify")
+    public RespDTO<Boolean> dataVerify(@RequestParam("file") MultipartFile file) {
+        Boolean data = transfusionConfigFacade.dataVerify(file);
+        return RespDTO.onSuc(data);
+    }
 }

+ 2 - 16
cdssman-service/src/main/resources/mapper/ConceptInfoMapper.xml

@@ -18,18 +18,6 @@
 
     <!-- 分页查询 -->
     <select id="getPage" resultType="com.diagbot.dto.ConceptInfoDTO">
-        SELECT
-        t1.id,
-        t1.NAME,
-        t1.clinicalPathwayName,
-        t1.noticeName,
-        t1.type,
-        t1.status,
-        t1.title,
-        t1.gmtModified,
-        t2.linkman AS modifier
-        FROM
-        (
         SELECT
         a.id,
         a.NAME,
@@ -58,11 +46,9 @@
         </if>
         GROUP BY
         a.id
-        ) t1
-        LEFT JOIN sys_user t2 ON t1.modifier = t2.id
         ORDER BY
-        t1.status DESC,
-        t1.gmtModified DESC
+        a.status DESC,
+        a.gmt_modified DESC
     </select>
 
 </mapper>

+ 9 - 2
common/src/main/java/com/diagbot/dto/RespDTO.java

@@ -20,6 +20,13 @@ public class RespDTO<T> implements Serializable {
         return resp;
     }
 
+    public static RespDTO onSucBoth(String code,String msg,Object data) {
+        RespDTO resp = new RespDTO();
+        resp.code = code;
+        resp.msg = msg;
+        resp.data = data;
+        return resp;
+    }
     public static RespDTO onError(String errMsg) {
         RespDTO resp = new RespDTO();
         resp.code = "-1";
@@ -30,8 +37,8 @@ public class RespDTO<T> implements Serializable {
     @Override
     public String toString() {
         return "RespDTO{" +
-                "code=" + code +
-                ", error='" + msg + '\'' +
+                "code='" + code + '\'' +
+                ", msg='" + msg + '\'' +
                 ", data=" + data +
                 '}';
     }

+ 4 - 0
common/src/main/java/com/diagbot/exception/CommonErrorCode.java

@@ -12,6 +12,9 @@ public enum CommonErrorCode implements ErrorCode {
     OK("0", "操作成功"),
     FAIL("00000001", "操作失败"),
     RPC_ERROR("00000002", "远程调度失败"),
+    CHECK_CONNECTION("00000005","是否解除绑定"),
+    SAVE_SUCCESSFUL("00000007","添加成功"),
+    ALTER_SUCCESSFUL("00000009","修改成功"),
     PARAM_ERROR("00029999", "%s"), //参数错误
     NOT_EXISTS("00020001", "该数据不存在!"),
     INSERT_DATA_FAILED("00020002", "数据库写入失败!"),
@@ -34,6 +37,7 @@ public enum CommonErrorCode implements ErrorCode {
     NOTVALID_ERROR("20020007", "该产品未在有效服务期内,无法使用"),
     EXPIRE_ERROR("20020008", "该产品已超出有效服务期,无法使用");
 
+
     private String code;
     private String msg;
 

+ 3 - 0
mrman-service/src/main/java/com/diagbot/dto/QcTypeDTO.java

@@ -3,6 +3,7 @@ package com.diagbot.dto;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -22,4 +23,6 @@ public class QcTypeDTO {
     private String name;
     // 质控类型和质控条目对应关系
     private Map<String, List<QcCasesEntrySimpleDTO>> entryMap;
+    // 已选择质控类型列表
+    private List<QcTypeSimpDTO> qcTypeSimpDTOList = new ArrayList<>();
 }

+ 5 - 0
mrman-service/src/main/java/com/diagbot/entity/QcType.java

@@ -31,6 +31,11 @@ public class QcType implements Serializable {
      */
     private Long hospitalId;
 
+    /**
+     * 质控父id
+     */
+    private Long parentTypeId;
+
     /**
      * 质控类型名称
      */

+ 187 - 25
mrman-service/src/main/java/com/diagbot/facade/QcTypeFacade.java

@@ -4,12 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.UserServiceClient;
-import com.diagbot.dto.QcCasesEntrySimpleDTO;
-import com.diagbot.dto.QcTypeDTO;
-import com.diagbot.dto.QcTypePageDTO;
-import com.diagbot.entity.CommonParam;
-import com.diagbot.entity.QcType;
-import com.diagbot.entity.QcTypeCasesEntry;
+import com.diagbot.dto.*;
+import com.diagbot.entity.*;
 import com.diagbot.enums.InsertOrUpdateEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
@@ -21,22 +17,17 @@ import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.UserUtils;
-import com.diagbot.vo.DeleteQcTypeVO;
-import com.diagbot.vo.QcEntryHospitalVO;
-import com.diagbot.vo.QcTypeCasesEntryVO;
-import com.diagbot.vo.QcTypeIndexVO;
-import com.diagbot.vo.QcTypePageVO;
-import com.diagbot.vo.QcTypeSaveVO;
-import com.diagbot.vo.QcTypeVO;
+import com.diagbot.vo.*;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.RequestBody;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
+
 
 /**
  * @Description:
@@ -56,18 +47,127 @@ public class QcTypeFacade extends QcTypeServiceImpl {
     QcCacesEntryFacade qcCacesEntryFacade;
     @Autowired
     QcTypeCasesEntryFacade qcTypeCasesEntryFacade;
+    @Autowired
+    CasesEntryHospitalFacade casesEntryHospitalFacade;
+
+
+    /**
+     * 关联质控条目检索
+     *
+     * @param qcTypeVO
+     */
+    public RespDTO<List<QcType>>  indexData(QcTypeVO qcTypeVO) {
+        List<QcType> list = new ArrayList<>();
+        Set<Long> parTypeIdSet = new HashSet<>();
+        List<QcType> parTypelist = this.list(new QueryWrapper<QcType>()
+                        .eq("hospital_id", qcTypeVO.getHospitalId())
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .isNotNull("parent_type_id")
+                        .orderByAsc("name"));
+
+        if(ListUtil.isNotEmpty(parTypelist)){
+            parTypelist.forEach(qcType -> {
+                parTypeIdSet.add(qcType.getParentTypeId());
+            });
+        };
+
+            QueryWrapper<QcType> qcTypeQueryWrapper = new QueryWrapper<>();
+            qcTypeQueryWrapper.eq("hospital_id", qcTypeVO.getHospitalId());
+            qcTypeQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
+            if(!CollectionUtils.isEmpty(parTypeIdSet)){
+                qcTypeQueryWrapper.notIn("id",parTypeIdSet);
+            }
+            qcTypeQueryWrapper.isNull("parent_type_id");
+        //修改 非此判断为新增
+        if(null != qcTypeVO.getId()) {
+            qcTypeQueryWrapper.ne("id", qcTypeVO.getId());
+        }
+            qcTypeQueryWrapper.orderByAsc("name");
+            list = this.list(qcTypeQueryWrapper);
+        return RespDTO.onSuc(list);
+    }
+    /**
+     * 判断质控类型是否关联
+     *
+     * @param cancelTypeVO
+     */
+    public RespDTO getOrCancel(CancelTypeVO cancelTypeVO) {
+        //修改和删除都会触发操作
+        //子类判断关联关系
+         QcType qcType = this.getOne(new QueryWrapper<QcType>()
+                .eq("hospital_id", cancelTypeVO.getHospitalId())
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("id", cancelTypeVO.getId()));
+        //父类判断关联关系
+         List<QcType> parentList= this.list(new QueryWrapper<QcType>()
+                .eq("hospital_id", cancelTypeVO.getHospitalId())
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("parent_type_id", cancelTypeVO.getId()));
+        if (cancelTypeVO.getId() != null&& null == cancelTypeVO.getCancel()) {
+        //子类存在关联  一对一给出提示
+            if (null != qcType.getParentTypeId()) {
+                QcType qcTypeMain= this.getOne(new QueryWrapper<QcType>()
+                        .eq("hospital_id", cancelTypeVO.getHospitalId())
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq("id", qcType.getParentTypeId()));
+                RespDTO respDTO = new RespDTO();
+                respDTO.code = "00000005";
+                respDTO.msg = "该质控类型已被" + "\"" + qcTypeMain.getName() + "\"" + "类型绑定,需先将其解绑";
+               return respDTO;
+               //父类存在关联  一对多给出提示
+            }else if(ListUtil.isNotEmpty(parentList)&&1==cancelTypeVO.getOper()){
+                RespDTO respDTO = new RespDTO();
+                respDTO.code = "00000005";
+                respDTO.msg = "该质控类型存在绑定的子类型,需先将其解绑";
+                return respDTO;
+            }
+    
+        }
+        //删除关联状态
+        if(cancelTypeVO.getCancel() != null && 1 == cancelTypeVO.getCancel()){
+            //子类存在关联  一对一删除
+            if (null != qcType.getParentTypeId()) {
+                this.update(new UpdateWrapper<QcType>()
+                        .eq("hospital_id", cancelTypeVO.getHospitalId())
+                        .eq("id", cancelTypeVO.getId())
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .set("parent_type_id", null)
+                );
+        //父类存在关联  一对多删除
+            }else if(ListUtil.isNotEmpty(parentList)){
+                this.update(new UpdateWrapper<QcType>()
+                        .eq("hospital_id", cancelTypeVO.getHospitalId())
+                        .eq("parent_type_id", cancelTypeVO.getId())
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .set("parent_type_id", null)
+                );
+            }
+            RespDTO respDTO = new RespDTO();
+            respDTO.code = "0";
+            respDTO.msg = "解绑成功";
+            return respDTO;
+
+        }
+            return new RespDTO();
+    }
+
 
     /**
      * 保存
      *
      * @param qcTypeSaveVO
      */
-    public void saveOrUpdate(QcTypeSaveVO qcTypeSaveVO) {
-        CommonParam param = initCommonParam();
-        // 保存主表
-        saveQcType(qcTypeSaveVO, param);
-        // 保存质控类型和质控条目映射关系
-        saveQcTypeCasesEntry(qcTypeSaveVO, param);
+    public RespDTO saveOrUpdate(QcTypeSaveVO qcTypeSaveVO) {
+            //初始化参数
+            CommonParam param = initCommonParam();
+            // 保存主表
+            saveQcType(qcTypeSaveVO, param);
+            // 保存质控类型和质控条目映射关系
+            saveQcTypeCasesEntry(qcTypeSaveVO, param);
+            //质控类型进行关联
+            getTypeConnections(qcTypeSaveVO, param);
+        return RespDTO.onSuc("保存成功");
+
     }
 
     /**
@@ -136,6 +236,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
             param.setInsertOrUpdate(InsertOrUpdateEnum.Update.getKey());
         }
         BeanUtil.copyProperties(qcTypeSaveVO, qcType);
+        //判断相同名称类型的质控id是否存在
         List<QcType> qcTypeList = this.list(new QueryWrapper<QcType>()
                 .eq("name", qcTypeSaveVO.getName())
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
@@ -177,6 +278,56 @@ public class QcTypeFacade extends QcTypeServiceImpl {
         return res;
     }
 
+    /**
+     * 质控类型维护关联
+     * @param qcTypeSaveVO,param
+     * @return
+     */
+    public void getTypeConnections(QcTypeSaveVO qcTypeSaveVO, CommonParam param) {
+        QcTypeVO qcTypeVO  = new QcTypeVO();
+        BeanUtil.copyProperties(qcTypeSaveVO, qcTypeVO);
+        List<Long> connectionIds = qcTypeSaveVO.getTypeIdList();
+        List<QcTypeCasesEntryVO> list = qcTypeSaveVO.getQcTypeCasesEntryVOList();
+        //修改操作
+        if(null !=qcTypeSaveVO.getId()){
+                //删除父类id
+                this.update(new UpdateWrapper<QcType>()
+                        .eq("hospital_id", qcTypeVO.getHospitalId())
+                        .eq("parent_type_id",qcTypeVO.getId())
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .set("parent_type_id",null)
+                );
+            }
+        if(ListUtil.isNotEmpty(connectionIds)){
+            for (Long id : connectionIds) {
+                //删除绑定质控id所有case_entry_id
+                qcTypeCasesEntryFacade.remove(new QueryWrapper<QcTypeCasesEntry>()
+                        .eq("type_id", id)
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                );
+                //该医院质控id下的质控条目case_entry_id与主关联的保持一致
+                list.forEach(qcTypeCasesEntryVO->{
+                                QcTypeCasesEntry qcTypeCaseEntry = new QcTypeCasesEntry();
+                                qcTypeCaseEntry.setCaseEntryId(qcTypeCasesEntryVO.getCaseEntryId());
+                                qcTypeCaseEntry.setTypeId(id);
+                                qcTypeCaseEntry.setGmtCreate(param.getNow());
+                                qcTypeCaseEntry.setGmtModified(param.getNow());
+                                qcTypeCaseEntry.setCreator(param.getPerson());
+                                qcTypeCaseEntry.setModifier(param.getPerson());
+                                qcTypeCasesEntryFacade.save(qcTypeCaseEntry);
+                            }
+                );
+                    //设置父质控id
+                     this.update(new UpdateWrapper<QcType>()
+                        .eq("hospital_id", qcTypeSaveVO.getHospitalId())
+                        .eq("id", id)
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .set("parent_type_id",qcTypeVO.getId())
+                     );
+            }
+        }
+    }
+
     /**
      * 新增时质控条目分组信息
      *
@@ -215,6 +366,17 @@ public class QcTypeFacade extends QcTypeServiceImpl {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "当前质控类型不存在或已删除【id=" + qcTypeVO.getId() + "】");
         }
+        List<QcType> qcTypeList = this.list(new QueryWrapper<QcType>()
+                .eq("parent_type_id", qcTypeVO.getId())
+                .eq("is_deleted", "N"));
+        List<QcTypeSimpDTO> qcTypeSimpDTOList = new ArrayList<>();
+        qcTypeList.forEach( qcTypeOne->{
+            QcTypeSimpDTO qcTypeSimpDTO = new QcTypeSimpDTO();
+            qcTypeSimpDTO.setId(qcTypeOne.getId());
+            qcTypeSimpDTO.setName(qcTypeOne.getName());
+            qcTypeSimpDTOList.add(qcTypeSimpDTO);
+        } );
+        qcTypeDTO.setQcTypeSimpDTOList(qcTypeSimpDTOList);
         BeanUtil.copyProperties(qcType, qcTypeDTO);
         List<QcCasesEntrySimpleDTO> list = qcTypeCasesEntryFacade.getByTypeIdFac(qcTypeVO);
         Map<String, List<QcCasesEntrySimpleDTO>> entryMap = EntityUtil.makeEntityListMap(list, "modeName");
@@ -228,7 +390,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
      * @param deleteQcTypeVO
      * @return
      */
-    public Boolean deleteByIdsFac(DeleteQcTypeVO deleteQcTypeVO) {
+    public RespDTO deleteByIdsFac(DeleteQcTypeVO deleteQcTypeVO) {
         Date now = DateUtil.now();
         String person = UserUtils.getCurrentPrincipleID();
         // 更新主表
@@ -246,7 +408,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
                     .in("type_id", deleteQcTypeVO.getIds())
             );
         }
-        return true;
+        return  RespDTO.onSuc("删除成功");
     }
 
 }

+ 20 - 0
mrman-service/src/main/java/com/diagbot/vo/CancelTypeVO.java

@@ -0,0 +1,20 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: zhoutg
+ * @time: 2018/8/6 10:16
+ */
+@Getter
+@Setter
+public class CancelTypeVO {
+    private Long id;
+    private Long hospitalId;
+    //是否解除相关质控类型绑定(0-不解除 1-解除)
+    private Integer cancel = 0;
+    //操作标示(0-修改 1-删除)
+    private Integer oper = 1;
+}

+ 2 - 0
mrman-service/src/main/java/com/diagbot/vo/QcTypeSaveVO.java

@@ -21,4 +21,6 @@ public class QcTypeSaveVO {
     private String name;
     // 质控类型和质控条目关联信息
     private List<QcTypeCasesEntryVO> qcTypeCasesEntryVOList = new ArrayList<>();
+    // 需要关联的质控类型id列表
+    private List<Long> typeIdList;
 }

+ 25 - 6
mrman-service/src/main/java/com/diagbot/web/QcTypeController.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.QcTypeDTO;
 import com.diagbot.dto.QcTypePageDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.QcQuestionInfo;
+import com.diagbot.entity.QcType;
 import com.diagbot.facade.QcTypeFacade;
 import com.diagbot.vo.*;
 import io.swagger.annotations.Api;
@@ -44,11 +45,30 @@ public class QcTypeController {
     @PostMapping("/saveOrUpdate")
     @SysLogger("saveOrUpdate")
     @Transactional
-    public RespDTO<Boolean> saveOrUpdate(@RequestBody QcTypeSaveVO qcTypeSaveVO) {
-        qcTypeFacade.saveOrUpdate(qcTypeSaveVO);
-        return RespDTO.onSuc(true);
+    public RespDTO saveOrUpdate(@RequestBody QcTypeSaveVO qcTypeSaveVO) {
+        return qcTypeFacade.saveOrUpdate(qcTypeSaveVO);
     }
 
+    @ApiOperation(value = "关联质控条目检索[by:cy]",
+            notes =  "id: 质控类型<br>" +
+                     "hospitalId: 医院id;")
+    @PostMapping("/indexData")
+    @SysLogger("indexData")
+    public RespDTO<List<QcType>> indexData(@RequestBody QcTypeVO qcTypeVO) {
+
+        return  qcTypeFacade.indexData(qcTypeVO);}
+
+    @ApiOperation(value = "判断质控类型是否关联[by:cy]",
+            notes = "id: 质控类型<br>" +
+                    "hospitalId: 医院id<br>" +
+                    "cancel: 是否解绑;")
+    @PostMapping("/getOrCancel")
+    @SysLogger("getOrCancel")
+    @Transactional
+    public RespDTO getOrCancel(@RequestBody CancelTypeVO cancelTypeVO) {
+
+        return qcTypeFacade.getOrCancel(cancelTypeVO);
+    }
 
     @ApiOperation(value = "分页列表[by:zhoutg]",
             notes = "    // 名称\n" +
@@ -90,9 +110,8 @@ public class QcTypeController {
     @PostMapping("/delete")
     @SysLogger("delete")
     @Transactional
-    public RespDTO<Boolean> delete(@Valid @RequestBody DeleteQcTypeVO deleteQcTypeVO) {
-        qcTypeFacade.deleteByIdsFac(deleteQcTypeVO);
-        return RespDTO.onSuc(true);
+    public RespDTO delete(@Valid @RequestBody DeleteQcTypeVO deleteQcTypeVO) {
+        return  qcTypeFacade.deleteByIdsFac(deleteQcTypeVO);
     }
 
     @ApiOperation(value = "根据id返回内容[by:zhoutg]",

+ 1 - 1
mrman-service/src/main/resources/mapper/QcCasesEntryMapper.xml

@@ -151,7 +151,7 @@
     
     <select id="getEntryByHospital" resultType="com.diagbot.dto.QcCasesEntrySimpleDTO">
         SELECT
-            t1.`name`, t1.id, t3.`name` mode_name, t2.is_used, 1 as sel
+            t1.`name`, t1.id, t3.`name` mode_name, t2.is_used,t2.is_used_run, 1 as sel
         FROM
             qc_cases_entry t1,
             qc_cases_entry_hospital t2,