Explorar o código

1、中医疾病关联维护
2、中医证候关联维护
3、中医疾病、中医证候术语检索
4、关联关系导入增加同步锁

zhaops %!s(int64=4) %!d(string=hai) anos
pai
achega
66d519f702
Modificáronse 34 ficheiros con 2662 adicións e 471 borrados
  1. 2 0
      cdssman-service/src/main/java/com/diagbot/dto/ConceptMappingDTO.java
  2. 8 0
      cdssman-service/src/main/java/com/diagbot/dto/RetrievalDTO.java
  3. 23 0
      cdssman-service/src/main/java/com/diagbot/dto/TcmdiseaseInfoDTO.java
  4. 23 0
      cdssman-service/src/main/java/com/diagbot/dto/TcmsyndromeInfoDTO.java
  5. 199 0
      cdssman-service/src/main/java/com/diagbot/entity/TcmdiseaseConfig.java
  6. 199 0
      cdssman-service/src/main/java/com/diagbot/entity/TcmsyndromeConfig.java
  7. 3 1
      cdssman-service/src/main/java/com/diagbot/enums/ConceptTypeEnum.java
  8. 52 50
      cdssman-service/src/main/java/com/diagbot/facade/DeptConfigFacade.java
  9. 52 50
      cdssman-service/src/main/java/com/diagbot/facade/DiseaseConfigFacade.java
  10. 50 48
      cdssman-service/src/main/java/com/diagbot/facade/DrugConfigFacade.java
  11. 46 1
      cdssman-service/src/main/java/com/diagbot/facade/HospitalInfoFacade.java
  12. 71 70
      cdssman-service/src/main/java/com/diagbot/facade/LisConfigFacade.java
  13. 52 50
      cdssman-service/src/main/java/com/diagbot/facade/NurseConfigFacade.java
  14. 52 50
      cdssman-service/src/main/java/com/diagbot/facade/OperationConfigFacade.java
  15. 52 50
      cdssman-service/src/main/java/com/diagbot/facade/PacsConfigFacade.java
  16. 52 50
      cdssman-service/src/main/java/com/diagbot/facade/ScaleConfigFacade.java
  17. 588 0
      cdssman-service/src/main/java/com/diagbot/facade/TcmdiseaseConfigFacade.java
  18. 588 0
      cdssman-service/src/main/java/com/diagbot/facade/TcmsyndromeConfigFacade.java
  19. 52 50
      cdssman-service/src/main/java/com/diagbot/facade/TransfusionConfigFacade.java
  20. 35 0
      cdssman-service/src/main/java/com/diagbot/mapper/TcmdiseaseConfigMapper.java
  21. 35 0
      cdssman-service/src/main/java/com/diagbot/mapper/TcmsyndromeConfigMapper.java
  22. 35 0
      cdssman-service/src/main/java/com/diagbot/service/TcmdiseaseConfigService.java
  23. 35 0
      cdssman-service/src/main/java/com/diagbot/service/TcmsyndromeConfigService.java
  24. 46 0
      cdssman-service/src/main/java/com/diagbot/service/impl/TcmdiseaseConfigServiceImpl.java
  25. 45 0
      cdssman-service/src/main/java/com/diagbot/service/impl/TcmsyndromeConfigServiceImpl.java
  26. 18 0
      cdssman-service/src/main/java/com/diagbot/vo/TcmdiseaseConfigListVO.java
  27. 38 0
      cdssman-service/src/main/java/com/diagbot/vo/TcmdiseaseConfigPageVO.java
  28. 18 0
      cdssman-service/src/main/java/com/diagbot/vo/TcmsyndromeConfigListVO.java
  29. 38 0
      cdssman-service/src/main/java/com/diagbot/vo/TcmsyndromeConfigPageVO.java
  30. 20 0
      cdssman-service/src/main/java/com/diagbot/web/TcmdiseaseConfigController.java
  31. 20 0
      cdssman-service/src/main/java/com/diagbot/web/TcmsyndromeConfigController.java
  32. 5 1
      cdssman-service/src/main/resources/mapper/HospitalInfoMapper.xml
  33. 55 0
      cdssman-service/src/main/resources/mapper/TcmdiseaseConfigMapper.xml
  34. 55 0
      cdssman-service/src/main/resources/mapper/TcmsyndromeConfigMapper.xml

+ 2 - 0
cdssman-service/src/main/java/com/diagbot/dto/ConceptMappingDTO.java

@@ -23,4 +23,6 @@ public class ConceptMappingDTO {
     private Integer transfusionNum = 0;
     private Integer scaleNum = 0;
     private Integer nurseNum = 0;
+    private Integer tcmdiseaseNum = 0;
+    private Integer tcmsyndromeNum = 0;
 }

+ 8 - 0
cdssman-service/src/main/java/com/diagbot/dto/RetrievalDTO.java

@@ -53,4 +53,12 @@ public class RetrievalDTO {
      * 护理
      */
     private List<NurseInfoDTO> nursenames;
+    /**
+     * 中医诊断
+     */
+    private List<TcmdiseaseInfoDTO> tcmdiseaseNames;
+    /**
+     * 中医证候
+     */
+    private List<TcmsyndromeInfoDTO> tcmsyndromeNames;
 }

+ 23 - 0
cdssman-service/src/main/java/com/diagbot/dto/TcmdiseaseInfoDTO.java

@@ -0,0 +1,23 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/13 15:37
+ */
+@Getter
+@Setter
+public class TcmdiseaseInfoDTO {
+    /**
+     * 疾病名称
+     */
+    private String name;
+
+    /**
+     * 编码
+     */
+    private String code;
+}

+ 23 - 0
cdssman-service/src/main/java/com/diagbot/dto/TcmsyndromeInfoDTO.java

@@ -0,0 +1,23 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/13 15:43
+ */
+@Getter
+@Setter
+public class TcmsyndromeInfoDTO {
+    /**
+     * 疾病名称
+     */
+    private String name;
+
+    /**
+     * 编码
+     */
+    private String code;
+}

+ 199 - 0
cdssman-service/src/main/java/com/diagbot/entity/TcmdiseaseConfig.java

@@ -0,0 +1,199 @@
+package com.diagbot.entity;
+
+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 javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ * <p>
+ * 中医疾病映射表
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+@TableName("tran_tcmdisease_config")
+public class TcmdiseaseConfig implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 医院id
+     */
+    private Long hospitalId;
+
+    /**
+     * 医院项目名称
+     */
+    @Excel(name = "中医疾病名称", width = 40, orderNum = "1", isImportField = "true")
+    @NotBlank(message = "请输入医院中医疾病名称")
+    private String hisName;
+
+    /**
+     * 标准名称
+     */
+    @Excel(name = "标准中医疾病名称", width = 40, orderNum = "3", isImportField = "true")
+    @NotBlank(message = "请输入标准中医疾病名称")
+    private String uniqueName;
+
+    /**
+     * 标准编码
+     */
+    @Excel(name = "中医疾病代码", width = 40, orderNum = "2", isImportField = "true")
+    private String uniqueCode;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+
+    public Date getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(Date gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+
+    public Date getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(Date gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+
+    public Long getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Long hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public String getHisName() {
+        return hisName;
+    }
+
+    public void setHisName(String hisName) {
+        this.hisName = hisName;
+    }
+
+    public String getUniqueName() {
+        return uniqueName;
+    }
+
+    public void setUniqueName(String uniqueName) {
+        this.uniqueName = uniqueName;
+    }
+
+    public String getUniqueCode() {
+        return uniqueCode;
+    }
+
+    public void setUniqueCode(String uniqueCode) {
+        this.uniqueCode = uniqueCode;
+    }
+
+    @Override
+    public String toString() {
+        return "TcmdiseaseConfig{" +
+                "id=" + id +
+                ", isDeleted=" + isDeleted +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", creator=" + creator +
+                ", modifier=" + modifier +
+                ", hospitalId=" + hospitalId +
+                ", hisName=" + hisName +
+                ", uniqueName=" + uniqueName +
+                ", uniqueCode=" + uniqueCode +
+                "}";
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TcmdiseaseConfig tcmdiseaseConfig = (TcmdiseaseConfig) o;
+        return Objects.equals(id, tcmdiseaseConfig.id)
+                && Objects.equals(isDeleted, tcmdiseaseConfig.isDeleted)
+                && Objects.equals(hospitalId, tcmdiseaseConfig.hospitalId)
+                && Objects.equals(hisName, tcmdiseaseConfig.hisName)
+                && Objects.equals(uniqueName, tcmdiseaseConfig.uniqueName)
+                && Objects.equals(uniqueCode, tcmdiseaseConfig.uniqueCode);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, isDeleted, hospitalId, hisName, uniqueName, uniqueCode);
+    }
+}

+ 199 - 0
cdssman-service/src/main/java/com/diagbot/entity/TcmsyndromeConfig.java

@@ -0,0 +1,199 @@
+package com.diagbot.entity;
+
+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 javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ * <p>
+ * 中医证候映射表
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+@TableName("tran_tcmsyndrome_config")
+public class TcmsyndromeConfig implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 医院id
+     */
+    private Long hospitalId;
+
+    /**
+     * 医院项目名称
+     */
+    @Excel(name = "医院中医证候名称", width = 40, orderNum = "1", isImportField = "true")
+    @NotBlank(message = "请输入医院中医证候名称")
+    private String hisName;
+
+    /**
+     * 标准名称
+     */
+    @Excel(name = "标准中医证候名称", width = 40, orderNum = "3", isImportField = "true")
+    @NotBlank(message = "请输入标准中医证候名称")
+    private String uniqueName;
+
+    /**
+     * 标准编码
+     */
+    @Excel(name = "中医证候代码", width = 40, orderNum = "2", isImportField = "true")
+    private String uniqueCode;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+
+    public Date getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(Date gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+
+    public Date getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(Date gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+
+    public Long getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Long hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public String getHisName() {
+        return hisName;
+    }
+
+    public void setHisName(String hisName) {
+        this.hisName = hisName;
+    }
+
+    public String getUniqueName() {
+        return uniqueName;
+    }
+
+    public void setUniqueName(String uniqueName) {
+        this.uniqueName = uniqueName;
+    }
+
+    public String getUniqueCode() {
+        return uniqueCode;
+    }
+
+    public void setUniqueCode(String uniqueCode) {
+        this.uniqueCode = uniqueCode;
+    }
+
+    @Override
+    public String toString() {
+        return "TcmsyndromeConfig{" +
+                "id=" + id +
+                ", isDeleted=" + isDeleted +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", creator=" + creator +
+                ", modifier=" + modifier +
+                ", hospitalId=" + hospitalId +
+                ", hisName=" + hisName +
+                ", uniqueName=" + uniqueName +
+                ", uniqueCode=" + uniqueCode +
+                "}";
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TcmsyndromeConfig tcmsyndromeConfig = (TcmsyndromeConfig) o;
+        return Objects.equals(id, tcmsyndromeConfig.id)
+                && Objects.equals(isDeleted, tcmsyndromeConfig.isDeleted)
+                && Objects.equals(hospitalId, tcmsyndromeConfig.hospitalId)
+                && Objects.equals(hisName, tcmsyndromeConfig.hisName)
+                && Objects.equals(uniqueName, tcmsyndromeConfig.uniqueName)
+                && Objects.equals(uniqueCode, tcmsyndromeConfig.uniqueCode);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, isDeleted, hospitalId, hisName, uniqueName, uniqueCode);
+    }
+}

+ 3 - 1
cdssman-service/src/main/java/com/diagbot/enums/ConceptTypeEnum.java

@@ -18,7 +18,9 @@ public enum ConceptTypeEnum implements KeyedNamed {
     Dept(7, "科室"),
     Transfusion(8, "输血"),
     Scale(10, "量表"),
-    Nurse(11, "护理");
+    Nurse(11, "护理"),
+    Tcmdisease(12,"中医疾病"),
+    Tcmsyndrome(13,"中医证候");
 
     @Setter
     private int key;

+ 52 - 50
cdssman-service/src/main/java/com/diagbot/facade/DeptConfigFacade.java

@@ -310,61 +310,63 @@ public class DeptConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        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())
-                        && ListUtil.isNotEmpty(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            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())
+                            && ListUtil.isNotEmpty(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()))) {
+                        deleteIds.addAll(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
+                    }
+                    deptConfig.setCreator(userId);
+                    deptConfig.setGmtCreate(now);
+                }
+                if (deptConfig.getIsDeleted() == null) {
+                    deptConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            List<String> uniqueNames = deptConfigList.stream()
+                    .map(i -> i.getUniqueName())
+                    .distinct()
+                    .collect(Collectors.toList());
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Dept.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < deptConfigList.size(); i++) {
+                if (!names.contains(deptConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
                 }
-                deptConfig.setCreator(userId);
-                deptConfig.setGmtCreate(now);
             }
-            if (deptConfig.getIsDeleted() == null) {
-                deptConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        List<String> uniqueNames = deptConfigList.stream()
-                .map(i -> i.getUniqueName())
-                .distinct()
-                .collect(Collectors.toList());
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Dept.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < deptConfigList.size(); i++) {
-            if (!names.contains(deptConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
-            }
+            //重复数据过滤
+            deptConfigList = deptConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            deptConfigService.saveOrUpdateBatch(deptConfigList);
         }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
-
-        //重复数据过滤
-        deptConfigList = deptConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
-
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        deptConfigService.saveOrUpdateBatch(deptConfigList);
         return true;
     }
 

+ 52 - 50
cdssman-service/src/main/java/com/diagbot/facade/DiseaseConfigFacade.java

@@ -284,61 +284,63 @@ public class DiseaseConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        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())
-                        && ListUtil.isNotEmpty(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            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())
+                            && ListUtil.isNotEmpty(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()))) {
+                        deleteIds.addAll(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
+                    }
+                    diseaseConfig.setCreator(userId);
+                    diseaseConfig.setGmtCreate(now);
+                }
+                if (diseaseConfig.getIsDeleted() == null) {
+                    diseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            List<String> uniqueNames = diseaseConfigList.stream()
+                    .map(i -> i.getUniqueName())
+                    .distinct()
+                    .collect(Collectors.toList());
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Disease.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < diseaseConfigList.size(); i++) {
+                if (!names.contains(diseaseConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
                 }
-                diseaseConfig.setCreator(userId);
-                diseaseConfig.setGmtCreate(now);
             }
-            if (diseaseConfig.getIsDeleted() == null) {
-                diseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        List<String> uniqueNames = diseaseConfigList.stream()
-                .map(i -> i.getUniqueName())
-                .distinct()
-                .collect(Collectors.toList());
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Disease.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < diseaseConfigList.size(); i++) {
-            if (!names.contains(diseaseConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
-            }
+            //重复数据过滤
+            diseaseConfigList = diseaseConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            diseaseConfigService.saveOrUpdateBatch(diseaseConfigList);
         }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
-
-        //重复数据过滤
-        diseaseConfigList = diseaseConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
-
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        diseaseConfigService.saveOrUpdateBatch(diseaseConfigList);
         return true;
     }
 

+ 50 - 48
cdssman-service/src/main/java/com/diagbot/facade/DrugConfigFacade.java

@@ -352,59 +352,61 @@ public class DrugConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Map<String, List<Long>>>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), hisNames, uniqueNames);
-        drugConfigList.forEach(drugConfig -> {
-            drugConfig.setHospitalId(Long.valueOf(hospitalId));
-            drugConfig.setModifier(userId);
-            drugConfig.setGmtModified(now);
-            String form = StringUtil.isBlank(drugConfig.getForm()) ? "" : drugConfig.getForm();
-            if (drugConfig.getId() == null) {
-                if (configMap.get(drugConfig.getHisName()) != null
-                        && configMap.get(drugConfig.getHisName()).get(form) != null
-                        && ListUtil.isNotEmpty(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(drugConfig.getHisName()).get(form).get(drugConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            Map<String, Map<String, Map<String, List<Long>>>> configMap
+                    = getConfigMap(Long.valueOf(hospitalId), hisNames, uniqueNames);
+            drugConfigList.forEach(drugConfig -> {
+                drugConfig.setHospitalId(Long.valueOf(hospitalId));
+                drugConfig.setModifier(userId);
+                drugConfig.setGmtModified(now);
+                String form = StringUtil.isBlank(drugConfig.getForm()) ? "" : drugConfig.getForm();
+                if (drugConfig.getId() == null) {
+                    if (configMap.get(drugConfig.getHisName()) != null
+                            && configMap.get(drugConfig.getHisName()).get(form) != null
+                            && 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);
                 }
-                drugConfig.setCreator(userId);
-                drugConfig.setGmtCreate(now);
-            }
-            if (drugConfig.getIsDeleted() == null) {
-                drugConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-            }
-        });
+                if (drugConfig.getIsDeleted() == null) {
+                    drugConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Drug.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < drugConfigList.size(); i++) {
-            if (!names.contains(drugConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Drug.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < drugConfigList.size(); i++) {
+                if (!names.contains(drugConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
+                }
+            }
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
 
-        //重复数据过滤
-        drugConfigList = drugConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
+            //重复数据过滤
+            drugConfigList = drugConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
 
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        drugConfigService.saveOrUpdateBatch(drugConfigList);
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            drugConfigService.saveOrUpdateBatch(drugConfigList);
+        }
         return true;
     }
 

+ 46 - 1
cdssman-service/src/main/java/com/diagbot/facade/HospitalInfoFacade.java

@@ -9,9 +9,13 @@ import com.diagbot.entity.DiseaseConfig;
 import com.diagbot.entity.DrugConfig;
 import com.diagbot.entity.HospitalInfo;
 import com.diagbot.entity.LisConfig;
+import com.diagbot.entity.NurseConfig;
 import com.diagbot.entity.OperationConfig;
 import com.diagbot.entity.PacsConfig;
 import com.diagbot.entity.Plan;
+import com.diagbot.entity.ScaleConfig;
+import com.diagbot.entity.TcmdiseaseConfig;
+import com.diagbot.entity.TcmsyndromeConfig;
 import com.diagbot.entity.TransfusionConfig;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
@@ -21,8 +25,12 @@ import com.diagbot.service.DiseaseConfigService;
 import com.diagbot.service.DrugConfigService;
 import com.diagbot.service.HospitalInfoService;
 import com.diagbot.service.LisConfigService;
+import com.diagbot.service.NurseConfigService;
 import com.diagbot.service.OperationConfigService;
 import com.diagbot.service.PacsConfigService;
+import com.diagbot.service.ScaleConfigService;
+import com.diagbot.service.TcmdiseaseConfigService;
+import com.diagbot.service.TcmsyndromeConfigService;
 import com.diagbot.service.TransfusionConfigService;
 import com.diagbot.service.impl.HospitalInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
@@ -72,6 +80,14 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
     @Autowired
     private TransfusionConfigService transfusionConfigService;
     @Autowired
+    private ScaleConfigService scaleConfigService;
+    @Autowired
+    private NurseConfigService nurseConfigService;
+    @Autowired
+    private TcmdiseaseConfigService tcmdiseaseConfigService;
+    @Autowired
+    private TcmsyndromeConfigService tcmsyndromeConfigService;
+    @Autowired
     private PlanFacade planFacade;
 
     public List<HospitalInfoDTO> getHospitalInfo() {
@@ -232,6 +248,34 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
         if (ListUtil.isNotEmpty(transfusionConfigList)) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
         }
+        List<ScaleConfig> scaleConfigList
+                = scaleConfigService.list(new QueryWrapper<ScaleConfig>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", idVO.getId()));
+        if (ListUtil.isNotEmpty(scaleConfigList)) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
+        }
+        List<NurseConfig> nurseConfigList
+                = nurseConfigService.list(new QueryWrapper<NurseConfig>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", idVO.getId()));
+        if (ListUtil.isNotEmpty(nurseConfigList)) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
+        }
+        List<TcmdiseaseConfig> tcmdiseaseConfigList
+                = tcmdiseaseConfigService.list(new QueryWrapper<TcmdiseaseConfig>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", idVO.getId()));
+        if (ListUtil.isNotEmpty(tcmdiseaseConfigList)) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
+        }
+        List<TcmsyndromeConfig> tcmsyndromeConfigList
+                = tcmsyndromeConfigService.list(new QueryWrapper<TcmsyndromeConfig>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", idVO.getId()));
+        if (ListUtil.isNotEmpty(tcmsyndromeConfigList)) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
+        }
         List<Plan> planList
                 = planFacade.list(new QueryWrapper<Plan>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
@@ -281,6 +325,7 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
      * @param hospitalInfoPageVO
      * @return
      */
+    @Override
     public IPage<DiseaseConfig> getPage(HospitalInfoPageVO hospitalInfoPageVO) {
         return hospitalInfoService.getPage(hospitalInfoPageVO);
     }
@@ -330,4 +375,4 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
         this.update(updateWrapper);
         return true;
     }
-}
+}

+ 71 - 70
cdssman-service/src/main/java/com/diagbot/facade/LisConfigFacade.java

@@ -161,14 +161,14 @@ public class LisConfigFacade{
         //过滤套餐或公表名为空的数据,hospitalId不允许为空
         lisConfigList = lisConfigList
                 .stream()
-                .filter(i->i.getHospitalId()!=null)
+                .filter(i -> i.getHospitalId() != null)
                 .filter(i -> StringUtil.isNotBlank(i.getHisName()))
                 .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
                 .collect(Collectors.toList());
-        if(ListUtil.isEmpty(lisConfigList)){
+        if (ListUtil.isEmpty(lisConfigList)) {
             return false;
         }
-        Long hosptialId=lisConfigList.get(0).getHospitalId();
+        Long hosptialId = lisConfigList.get(0).getHospitalId();
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
@@ -205,7 +205,6 @@ public class LisConfigFacade{
         IdListVO idListVO = new IdListVO();
         idListVO.setIds(deleteIds);
         deleteRecords(idListVO);
-
         lisConfigService.saveOrUpdateBatch(lisConfigList);
         return true;
     }
@@ -332,80 +331,82 @@ public class LisConfigFacade{
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Map<String, List<Long>>>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), hisNames, uniqueNames);
-        lisConfigList.forEach(lisConfig -> {
-            lisConfig.setHospitalId(Long.valueOf(hospitalId));
-            lisConfig.setModifier(userId);
-            lisConfig.setGmtModified(now);
-            if (lisConfig.getId() == null) {
-                if (configMap.containsKey(lisConfig.getHisName())) {
-                    if (lisConfig.getHisDetailName() == null
-                            && configMap.get(lisConfig.getHisName()).containsKey("")) {
-                        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 (ListUtil.isNotEmpty(configMap.get(lisConfig.getHisName()).get(lisConfig.getHisDetailName()).get(lisConfig.getUniqueName()))) {
-                            deleteIds.addAll(configMap
-                                    .get(lisConfig.getHisName())
-                                    .get(lisConfig.getHisDetailName())
-                                    .get(lisConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            Map<String, Map<String, Map<String, List<Long>>>> configMap
+                    = getConfigMap(Long.valueOf(hospitalId), hisNames, uniqueNames);
+            lisConfigList.forEach(lisConfig -> {
+                lisConfig.setHospitalId(Long.valueOf(hospitalId));
+                lisConfig.setModifier(userId);
+                lisConfig.setGmtModified(now);
+                if (lisConfig.getId() == null) {
+                    if (configMap.containsKey(lisConfig.getHisName())) {
+                        if (lisConfig.getHisDetailName() == null
+                                && configMap.get(lisConfig.getHisName()).containsKey("")) {
+                            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 (ListUtil.isNotEmpty(configMap.get(lisConfig.getHisName()).get(lisConfig.getHisDetailName()).get(lisConfig.getUniqueName()))) {
+                                deleteIds.addAll(configMap
+                                        .get(lisConfig.getHisName())
+                                        .get(lisConfig.getHisDetailName())
+                                        .get(lisConfig.getUniqueName()));
+                            }
                         }
                     }
+                    lisConfig.setCreator(userId);
+                    lisConfig.setGmtCreate(now);
                 }
-                lisConfig.setCreator(userId);
-                lisConfig.setGmtCreate(now);
-            }
-            if (lisConfig.getIsDeleted() == null) {
-                lisConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-            }
-        });
-
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        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;
-        for (int i = 0; i < lisConfigList.size(); i++) {
-            if (StringUtil.isBlank(lisConfigList.get(i).getHisDetailName())) {
-                //检验套餐对应套餐
-                if (!lisPackNames.contains(lisConfigList.get(i).getUniqueName())) {
-                    errorNumList.add(String.valueOf(i + 2));
+                if (lisConfig.getIsDeleted() == null) {
+                    lisConfig.setIsDeleted(IsDeleteEnum.N.getKey());
                 }
-            } else {
-                //检验细项对应细项
-                if (!lisNames.contains(lisConfigList.get(i).getUniqueName())) {
-                    errorNumList.add(String.valueOf(i + 2));
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            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;
+            for (int i = 0; i < lisConfigList.size(); i++) {
+                if (StringUtil.isBlank(lisConfigList.get(i).getHisDetailName())) {
+                    //检验套餐对应套餐
+                    if (!lisPackNames.contains(lisConfigList.get(i).getUniqueName())) {
+                        errorNumList.add(String.valueOf(i + 2));
+                    }
+                } else {
+                    //检验细项对应细项
+                    if (!lisNames.contains(lisConfigList.get(i).getUniqueName())) {
+                        errorNumList.add(String.valueOf(i + 2));
+                    }
                 }
             }
-        }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
+            }
 
-        //重复数据过滤
-        lisConfigList = lisConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
+            //重复数据过滤
+            lisConfigList = lisConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
 
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        lisConfigService.saveOrUpdateBatch(lisConfigList);
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            lisConfigService.saveOrUpdateBatch(lisConfigList);
+        }
         return true;
     }
 

+ 52 - 50
cdssman-service/src/main/java/com/diagbot/facade/NurseConfigFacade.java

@@ -293,61 +293,63 @@ public class NurseConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, List<Long>>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), null, null);
-        nurseConfigList.forEach(nurseConfig -> {
-            nurseConfig.setHospitalId(Long.valueOf(hospitalId));
-            nurseConfig.setModifier(userId);
-            nurseConfig.setGmtModified(now);
-            if (nurseConfig.getId() == null) {
-                if (configMap.containsKey(nurseConfig.getHisName())
-                        && ListUtil.isNotEmpty(configMap.get(nurseConfig.getHisName()).get(nurseConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(nurseConfig.getHisName()).get(nurseConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            Map<String, Map<String, List<Long>>> configMap
+                    = getConfigMap(Long.valueOf(hospitalId), null, null);
+            nurseConfigList.forEach(nurseConfig -> {
+                nurseConfig.setHospitalId(Long.valueOf(hospitalId));
+                nurseConfig.setModifier(userId);
+                nurseConfig.setGmtModified(now);
+                if (nurseConfig.getId() == null) {
+                    if (configMap.containsKey(nurseConfig.getHisName())
+                            && ListUtil.isNotEmpty(configMap.get(nurseConfig.getHisName()).get(nurseConfig.getUniqueName()))) {
+                        deleteIds.addAll(configMap.get(nurseConfig.getHisName()).get(nurseConfig.getUniqueName()));
+                    }
+                    nurseConfig.setCreator(userId);
+                    nurseConfig.setGmtCreate(now);
+                }
+                if (nurseConfig.getIsDeleted() == null) {
+                    nurseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            List<String> uniqueNames = nurseConfigList.stream()
+                    .map(i -> i.getUniqueName())
+                    .distinct()
+                    .collect(Collectors.toList());
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Nurse.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < nurseConfigList.size(); i++) {
+                if (!names.contains(nurseConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
                 }
-                nurseConfig.setCreator(userId);
-                nurseConfig.setGmtCreate(now);
             }
-            if (nurseConfig.getIsDeleted() == null) {
-                nurseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        List<String> uniqueNames = nurseConfigList.stream()
-                .map(i -> i.getUniqueName())
-                .distinct()
-                .collect(Collectors.toList());
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Nurse.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < nurseConfigList.size(); i++) {
-            if (!names.contains(nurseConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
-            }
+            //重复数据过滤
+            nurseConfigList = nurseConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            nurseConfigService.saveOrUpdateBatch(nurseConfigList);
         }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
-
-        //重复数据过滤
-        nurseConfigList = nurseConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
-
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        nurseConfigService.saveOrUpdateBatch(nurseConfigList);
         return true;
     }
 

+ 52 - 50
cdssman-service/src/main/java/com/diagbot/facade/OperationConfigFacade.java

@@ -293,61 +293,63 @@ public class OperationConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        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())
-                        && ListUtil.isNotEmpty(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            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())
+                            && ListUtil.isNotEmpty(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()))) {
+                        deleteIds.addAll(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
+                    }
+                    operationConfig.setCreator(userId);
+                    operationConfig.setGmtCreate(now);
+                }
+                if (operationConfig.getIsDeleted() == null) {
+                    operationConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            List<String> uniqueNames = operationConfigList.stream()
+                    .map(i -> i.getUniqueName())
+                    .distinct()
+                    .collect(Collectors.toList());
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Operation.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < operationConfigList.size(); i++) {
+                if (!names.contains(operationConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
                 }
-                operationConfig.setCreator(userId);
-                operationConfig.setGmtCreate(now);
             }
-            if (operationConfig.getIsDeleted() == null) {
-                operationConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        List<String> uniqueNames = operationConfigList.stream()
-                .map(i -> i.getUniqueName())
-                .distinct()
-                .collect(Collectors.toList());
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Operation.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < operationConfigList.size(); i++) {
-            if (!names.contains(operationConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
-            }
+            //重复数据过滤
+            operationConfigList = operationConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            operationConfigService.saveOrUpdateBatch(operationConfigList);
         }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
-
-        //重复数据过滤
-        operationConfigList = operationConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
-
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        operationConfigService.saveOrUpdateBatch(operationConfigList);
         return true;
     }
 

+ 52 - 50
cdssman-service/src/main/java/com/diagbot/facade/PacsConfigFacade.java

@@ -291,61 +291,63 @@ public class PacsConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        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())
-                        && ListUtil.isNotEmpty(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            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())
+                            && ListUtil.isNotEmpty(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()))) {
+                        deleteIds.addAll(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
+                    }
+                    pacsConfig.setCreator(userId);
+                    pacsConfig.setGmtCreate(now);
+                }
+                if (pacsConfig.getIsDeleted() == null) {
+                    pacsConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            List<String> uniqueNames = pacsConfigList.stream()
+                    .map(i -> i.getUniqueName())
+                    .distinct()
+                    .collect(Collectors.toList());
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Pacs.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < pacsConfigList.size(); i++) {
+                if (!names.contains(pacsConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
                 }
-                pacsConfig.setCreator(userId);
-                pacsConfig.setGmtCreate(now);
             }
-            if (pacsConfig.getIsDeleted() == null) {
-                pacsConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        List<String> uniqueNames = pacsConfigList.stream()
-                .map(i -> i.getUniqueName())
-                .distinct()
-                .collect(Collectors.toList());
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Pacs.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < pacsConfigList.size(); i++) {
-            if (!names.contains(pacsConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
-            }
+            //重复数据过滤
+            pacsConfigList = pacsConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            pacsConfigService.saveOrUpdateBatch(pacsConfigList);
         }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
-
-        //重复数据过滤
-        pacsConfigList = pacsConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
-
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        pacsConfigService.saveOrUpdateBatch(pacsConfigList);
         return true;
     }
 

+ 52 - 50
cdssman-service/src/main/java/com/diagbot/facade/ScaleConfigFacade.java

@@ -293,61 +293,63 @@ public class ScaleConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, List<Long>>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), null, null);
-        scaleConfigList.forEach(scaleConfig -> {
-            scaleConfig.setHospitalId(Long.valueOf(hospitalId));
-            scaleConfig.setModifier(userId);
-            scaleConfig.setGmtModified(now);
-            if (scaleConfig.getId() == null) {
-                if (configMap.containsKey(scaleConfig.getHisName())
-                        && ListUtil.isNotEmpty(configMap.get(scaleConfig.getHisName()).get(scaleConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(scaleConfig.getHisName()).get(scaleConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            Map<String, Map<String, List<Long>>> configMap
+                    = getConfigMap(Long.valueOf(hospitalId), null, null);
+            scaleConfigList.forEach(scaleConfig -> {
+                scaleConfig.setHospitalId(Long.valueOf(hospitalId));
+                scaleConfig.setModifier(userId);
+                scaleConfig.setGmtModified(now);
+                if (scaleConfig.getId() == null) {
+                    if (configMap.containsKey(scaleConfig.getHisName())
+                            && ListUtil.isNotEmpty(configMap.get(scaleConfig.getHisName()).get(scaleConfig.getUniqueName()))) {
+                        deleteIds.addAll(configMap.get(scaleConfig.getHisName()).get(scaleConfig.getUniqueName()));
+                    }
+                    scaleConfig.setCreator(userId);
+                    scaleConfig.setGmtCreate(now);
+                }
+                if (scaleConfig.getIsDeleted() == null) {
+                    scaleConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            List<String> uniqueNames = scaleConfigList.stream()
+                    .map(i -> i.getUniqueName())
+                    .distinct()
+                    .collect(Collectors.toList());
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Scale.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < scaleConfigList.size(); i++) {
+                if (!names.contains(scaleConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
                 }
-                scaleConfig.setCreator(userId);
-                scaleConfig.setGmtCreate(now);
             }
-            if (scaleConfig.getIsDeleted() == null) {
-                scaleConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        List<String> uniqueNames = scaleConfigList.stream()
-                .map(i -> i.getUniqueName())
-                .distinct()
-                .collect(Collectors.toList());
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Scale.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < scaleConfigList.size(); i++) {
-            if (!names.contains(scaleConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
-            }
+            //重复数据过滤
+            scaleConfigList = scaleConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            scaleConfigService.saveOrUpdateBatch(scaleConfigList);
         }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
-
-        //重复数据过滤
-        scaleConfigList = scaleConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
-
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        scaleConfigService.saveOrUpdateBatch(scaleConfigList);
         return true;
     }
 

+ 588 - 0
cdssman-service/src/main/java/com/diagbot/facade/TcmdiseaseConfigFacade.java

@@ -0,0 +1,588 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.client.CdssCoreClient;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.TcmdiseaseConfig;
+import com.diagbot.enums.ConceptTypeEnum;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.TcmdiseaseConfigService;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.EntityUtil;
+import com.diagbot.util.ExcelUtils;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.util.UserUtils;
+import com.diagbot.vo.ConceptVO;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.HospitalIdVO;
+import com.diagbot.vo.IdListVO;
+import com.diagbot.vo.IdVO;
+import com.diagbot.vo.TcmdiseaseConfigListVO;
+import com.diagbot.vo.TcmdiseaseConfigPageVO;
+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;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/14 11:04
+ */
+@Component
+public class TcmdiseaseConfigFacade {
+    @Autowired
+    private TcmdiseaseConfigService tcmdiseaseConfigService;
+    @Autowired
+    private CdssCoreClient cdssCoreClient;
+
+    /**
+     * 判断是否已存在
+     *
+     * @param tcmdiseaseConfig
+     * @return
+     */
+    public Boolean isExistRecord(TcmdiseaseConfig tcmdiseaseConfig) {
+        QueryWrapper<TcmdiseaseConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", tcmdiseaseConfig.getHospitalId())
+                .eq("his_name", tcmdiseaseConfig.getHisName())
+                .eq("unique_name", tcmdiseaseConfig.getUniqueName());
+        TcmdiseaseConfig oldRecord = tcmdiseaseConfigService.getOne(queryWrapper, false);
+        if (tcmdiseaseConfig.getId() == null
+                && oldRecord != null) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        if (tcmdiseaseConfig.getId() != null
+                && oldRecord != null
+                && !tcmdiseaseConfig.getId().equals(oldRecord.getId())) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        return false;
+    }
+
+    /**
+     * 保存记录-单条
+     *
+     * @param tcmdiseaseConfig
+     * @return
+     */
+    public Boolean saveOrUpdateRecord(TcmdiseaseConfig tcmdiseaseConfig) {
+        String userId = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+        tcmdiseaseConfig.setModifier(userId);
+        tcmdiseaseConfig.setGmtModified(now);
+        QueryWrapper<TcmdiseaseConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", tcmdiseaseConfig.getHospitalId())
+                .eq("his_name", tcmdiseaseConfig.getHisName())
+                .eq("unique_name", tcmdiseaseConfig.getUniqueName());
+        TcmdiseaseConfig oldRecord = tcmdiseaseConfigService.getOne(queryWrapper, false);
+        if (tcmdiseaseConfig.getId() == null
+                && oldRecord != null) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        if (tcmdiseaseConfig.getId() != null
+                && oldRecord != null
+                && !tcmdiseaseConfig.getId().equals(oldRecord.getId())) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        //新增数据
+        if (tcmdiseaseConfig.getId() == null) {
+            tcmdiseaseConfig.setCreator(userId);
+            tcmdiseaseConfig.setGmtCreate(now);
+        }
+        if (tcmdiseaseConfig.getIsDeleted() == null) {
+            tcmdiseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+        }
+        tcmdiseaseConfigService.saveOrUpdate(tcmdiseaseConfig);
+        return true;
+    }
+
+    /**
+     * 保存记录-批量
+     *
+     * @param tcmdiseaseConfigListVO
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(TcmdiseaseConfigListVO tcmdiseaseConfigListVO) {
+        if (ListUtil.isEmpty(tcmdiseaseConfigListVO.getTcmdiseaseConfigList())) {
+            return false;
+        }
+        return saveOrUpdateRecords(tcmdiseaseConfigListVO.getTcmdiseaseConfigList());
+    }
+
+    /**
+     * 批量保存
+     *
+     * @param tcmdiseaseConfigList
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(List<TcmdiseaseConfig> tcmdiseaseConfigList) {
+        if (ListUtil.isEmpty(tcmdiseaseConfigList)) {
+            return false;
+        }
+        String userId = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+
+        //数据不完整的不保存
+        //过滤外部名称或公表名为空的数据
+        tcmdiseaseConfigList = tcmdiseaseConfigList
+                .stream()
+                .filter(i -> i.getHospitalId() != null)
+                .filter(i -> StringUtil.isNotBlank(i.getHisName()))
+                .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(tcmdiseaseConfigList)) {
+            return false;
+        }
+        Long hospitalId = tcmdiseaseConfigList.get(0).getHospitalId();
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, List<Long>>> configMap
+                = getConfigMap(hospitalId, null, null);
+        tcmdiseaseConfigList.forEach(tcmdiseaseConfig -> {
+            tcmdiseaseConfig.setModifier(userId);
+            tcmdiseaseConfig.setGmtModified(now);
+            if (tcmdiseaseConfig.getId() == null) {
+                if (configMap.containsKey(tcmdiseaseConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(tcmdiseaseConfig.getHisName()).get(tcmdiseaseConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(tcmdiseaseConfig.getHisName()).get(tcmdiseaseConfig.getUniqueName()));
+                }
+                tcmdiseaseConfig.setCreator(userId);
+                tcmdiseaseConfig.setGmtCreate(now);
+            }
+            if (tcmdiseaseConfig.getIsDeleted() == null) {
+                tcmdiseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        tcmdiseaseConfigService.saveOrUpdateBatch(tcmdiseaseConfigList);
+        return true;
+    }
+
+    /**
+     * 删除记录-单条
+     *
+     * @param idVO
+     * @return
+     */
+    public Boolean deleteRecord(IdVO idVO) {
+        tcmdiseaseConfigService.removeById(idVO.getId());
+        return true;
+    }
+
+    /**
+     * 删除记录-批量
+     *
+     * @param idListVO
+     * @return
+     */
+    public Boolean deleteRecords(IdListVO idListVO) {
+        if (ListUtil.isEmpty(idListVO.getIds())) {
+            return false;
+        }
+        tcmdiseaseConfigService.removeByIds(idListVO.getIds());
+        return true;
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param tcmdiseaseConfigPageVO
+     * @return
+     */
+    public IPage<TcmdiseaseConfig> getPage(TcmdiseaseConfigPageVO tcmdiseaseConfigPageVO) {
+        return tcmdiseaseConfigService.getPage(tcmdiseaseConfigPageVO);
+    }
+
+    /**
+     * 数据导入
+     *
+     * @param file
+     * @param hospitalIdVO
+     */
+    public void importExcel(MultipartFile file, HospitalIdVO hospitalIdVO) {
+        List<TcmdiseaseConfig> tcmdiseaseConfigList = ExcelUtils.importExcel(file, 0, 1, TcmdiseaseConfig.class);
+        if (ListUtil.isNotEmpty(tcmdiseaseConfigList)) {
+            tcmdiseaseConfigList.forEach(tcmdiseaseConfig -> {
+                tcmdiseaseConfig.setHospitalId(hospitalIdVO.getHospitalId());
+            });
+            importExcelRecords(tcmdiseaseConfigList, hospitalIdVO);
+        } else {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
+        }
+    }
+
+    /**
+     * 数据导入
+     *
+     * @param tcmdiseaseConfigList
+     * @return
+     */
+    public Boolean importExcelRecords(List<TcmdiseaseConfig> tcmdiseaseConfigList, HospitalIdVO hospitalIdVO) {
+        Long hospitalId = hospitalIdVO.getHospitalId();
+        String userId = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+
+        //1、数据完整性校验
+        //2、去除前后空格
+        //过滤空数据,保留重复数据,方便计行
+        tcmdiseaseConfigList = tcmdiseaseConfigList.stream()
+                .filter(i -> StringUtil.isNotBlank(i.getHisName())
+                        || StringUtil.isNotBlank(i.getUniqueCode())
+                        || StringUtil.isNotBlank(i.getUniqueName()))
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(tcmdiseaseConfigList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
+        }
+        List<String> emptyNumList = Lists.newLinkedList();
+        for (int i = 0; i < tcmdiseaseConfigList.size(); i++) {
+            if (StringUtil.isBlank(tcmdiseaseConfigList.get(i).getHisName())
+                    || StringUtil.isBlank(tcmdiseaseConfigList.get(i).getUniqueName())) {
+                emptyNumList.add(String.valueOf(i + 2));
+            }
+            if (StringUtil.isNotBlank(tcmdiseaseConfigList.get(i).getHisName())) {
+                tcmdiseaseConfigList.get(i).setHisName(tcmdiseaseConfigList.get(i).getHisName().trim());
+            }
+            if (StringUtil.isNotBlank(tcmdiseaseConfigList.get(i).getUniqueName())) {
+                tcmdiseaseConfigList.get(i).setUniqueName(tcmdiseaseConfigList.get(i).getUniqueName().trim());
+            }
+            if (StringUtil.isNotBlank(tcmdiseaseConfigList.get(i).getUniqueCode())) {
+                tcmdiseaseConfigList.get(i).setUniqueCode(tcmdiseaseConfigList.get(i).getUniqueCode().trim());
+            } else {
+                tcmdiseaseConfigList.get(i).setUniqueCode(null);
+            }
+        }
+
+        if (ListUtil.isNotEmpty(emptyNumList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "以下行数(不计入空行)存在不完整数据:"
+                    + emptyNumList.stream().collect(Collectors.joining("、"))
+                    + "。导入取消,请修改后再试。\n");
+        }
+
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, List<Long>>> configMap
+                = getConfigMap(Long.valueOf(hospitalId), null, null);
+        tcmdiseaseConfigList.forEach(tcmdiseaseConfig -> {
+            tcmdiseaseConfig.setHospitalId(Long.valueOf(hospitalId));
+            tcmdiseaseConfig.setModifier(userId);
+            tcmdiseaseConfig.setGmtModified(now);
+            if (tcmdiseaseConfig.getId() == null) {
+                if (configMap.containsKey(tcmdiseaseConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(tcmdiseaseConfig.getHisName()).get(tcmdiseaseConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(tcmdiseaseConfig.getHisName()).get(tcmdiseaseConfig.getUniqueName()));
+                }
+                tcmdiseaseConfig.setCreator(userId);
+                tcmdiseaseConfig.setGmtCreate(now);
+            }
+            if (tcmdiseaseConfig.getIsDeleted() == null) {
+                tcmdiseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+
+        //标准术语校验
+        List<String> errorNumList = Lists.newLinkedList();
+        List<String> uniqueNames = tcmdiseaseConfigList.stream()
+                .map(i -> i.getUniqueName())
+                .distinct()
+                .collect(Collectors.toList());
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(uniqueNames);
+        conceptVO.setType(ConceptTypeEnum.Tcmdisease.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> names = respDTO.data;
+        for (int i = 0; i < tcmdiseaseConfigList.size(); i++) {
+            if (!names.contains(tcmdiseaseConfigList.get(i).getUniqueName())) {
+                errorNumList.add(String.valueOf(i + 2));
+            }
+        }
+        if (ListUtil.isNotEmpty(errorNumList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
+                            + errorNumList.stream().collect(Collectors.joining("、"))
+                            + "。导入取消,请修改后再试。");
+        }
+
+        //重复数据过滤
+        tcmdiseaseConfigList = tcmdiseaseConfigList
+                .stream()
+                .distinct()
+                .collect(Collectors.toList());
+
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        tcmdiseaseConfigService.saveOrUpdateBatch(tcmdiseaseConfigList);
+        return true;
+    }
+
+    /**
+     * 获取映射关系-公表名
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    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<TcmdiseaseConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<TcmdiseaseConfig> records = tcmdiseaseConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        Map<String, List<TcmdiseaseConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
+        for (Map.Entry<String, List<TcmdiseaseConfig>> entry : configMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                Map<String, List<TcmdiseaseConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<TcmdiseaseConfig>> 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;
+    }
+
+    /**
+     * 获取映射关系-公表名
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    public Map<String, Map<String, List<Long>>> getUniqueConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
+        QueryWrapper<TcmdiseaseConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<TcmdiseaseConfig> records = tcmdiseaseConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        Map<String, List<TcmdiseaseConfig>> configMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<TcmdiseaseConfig>> entry : configMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                Map<String, List<TcmdiseaseConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "hisName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<TcmdiseaseConfig>> 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;
+    }
+
+    /**
+     * 数据导出
+     *
+     * @param response
+     * @param hospitalIdVO
+     */
+    public void exportExcel(HttpServletResponse response, HospitalIdVO hospitalIdVO) {
+        QueryWrapper<TcmdiseaseConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalIdVO.getHospitalId())
+                .orderByDesc("gmt_modified");
+        List<TcmdiseaseConfig> records = tcmdiseaseConfigService.list(queryWrapper);
+        String fileName = "中医疾病映射.xls";
+        ExcelUtils.exportExcel(records, null, "sheet1", TcmdiseaseConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    public IPage<HosRelationNumDTO> getRelationNumPage(HosRelationNumPageVO hosRelationNumPageVO) {
+        return tcmdiseaseConfigService.getRelationNumPage(hosRelationNumPageVO);
+    }
+
+    /**
+     * 数据导入模板导出
+     *
+     * @param response
+     */
+    public void exportExcelModule(HttpServletResponse response) {
+        String fileName = "中医疾病映射模板.xls";
+        ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", TcmdiseaseConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file, HttpServletResponse response) {
+        List<TcmdiseaseConfig> originList = ExcelUtils.importExcel(file, 0, 1, TcmdiseaseConfig.class);
+        List<TcmdiseaseConfig> retList = dataProcess(originList);
+
+        String fileName = "中医疾病关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", TcmdiseaseConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<TcmdiseaseConfig> originList = ExcelUtils.importExcel(file, 0, 1, TcmdiseaseConfig.class);
+        List<TcmdiseaseConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<TcmdiseaseConfig> dataProcess(List<TcmdiseaseConfig> originList) {
+        List<TcmdiseaseConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<TcmdiseaseConfig>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<TcmdiseaseConfig>> 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.Tcmdisease.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (TcmdiseaseConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<TcmdiseaseConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (TcmdiseaseConfig 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<TcmdiseaseConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<TcmdiseaseConfig>> retMap = new HashMap<>();
+        QueryWrapper<TcmdiseaseConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<TcmdiseaseConfig> records = tcmdiseaseConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? null : record.getUniqueName());
+        });
+
+        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;
+    }
+
+    /**
+     * 查找指定医院映射关系
+     *
+     * @param hospitalId
+     * @return
+     */
+    public List<TcmdiseaseConfig> getListByHospitalId(Long hospitalId) {
+        QueryWrapper<TcmdiseaseConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        return tcmdiseaseConfigService.list(queryWrapper);
+    }
+}

+ 588 - 0
cdssman-service/src/main/java/com/diagbot/facade/TcmsyndromeConfigFacade.java

@@ -0,0 +1,588 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.client.CdssCoreClient;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.TcmsyndromeConfig;
+import com.diagbot.enums.ConceptTypeEnum;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.TcmsyndromeConfigService;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.EntityUtil;
+import com.diagbot.util.ExcelUtils;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.util.UserUtils;
+import com.diagbot.vo.ConceptVO;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.HospitalIdVO;
+import com.diagbot.vo.IdListVO;
+import com.diagbot.vo.IdVO;
+import com.diagbot.vo.TcmsyndromeConfigListVO;
+import com.diagbot.vo.TcmsyndromeConfigPageVO;
+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;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/14 11:04
+ */
+@Component
+public class TcmsyndromeConfigFacade {
+    @Autowired
+    private TcmsyndromeConfigService tcmsyndromeConfigService;
+    @Autowired
+    private CdssCoreClient cdssCoreClient;
+
+    /**
+     * 判断是否已存在
+     *
+     * @param tcmsyndromeConfig
+     * @return
+     */
+    public Boolean isExistRecord(TcmsyndromeConfig tcmsyndromeConfig) {
+        QueryWrapper<TcmsyndromeConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", tcmsyndromeConfig.getHospitalId())
+                .eq("his_name", tcmsyndromeConfig.getHisName())
+                .eq("unique_name", tcmsyndromeConfig.getUniqueName());
+        TcmsyndromeConfig oldRecord = tcmsyndromeConfigService.getOne(queryWrapper, false);
+        if (tcmsyndromeConfig.getId() == null
+                && oldRecord != null) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        if (tcmsyndromeConfig.getId() != null
+                && oldRecord != null
+                && !tcmsyndromeConfig.getId().equals(oldRecord.getId())) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        return false;
+    }
+
+    /**
+     * 保存记录-单条
+     *
+     * @param tcmsyndromeConfig
+     * @return
+     */
+    public Boolean saveOrUpdateRecord(TcmsyndromeConfig tcmsyndromeConfig) {
+        String userId = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+        tcmsyndromeConfig.setModifier(userId);
+        tcmsyndromeConfig.setGmtModified(now);
+        QueryWrapper<TcmsyndromeConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", tcmsyndromeConfig.getHospitalId())
+                .eq("his_name", tcmsyndromeConfig.getHisName())
+                .eq("unique_name", tcmsyndromeConfig.getUniqueName());
+        TcmsyndromeConfig oldRecord = tcmsyndromeConfigService.getOne(queryWrapper, false);
+        if (tcmsyndromeConfig.getId() == null
+                && oldRecord != null) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        if (tcmsyndromeConfig.getId() != null
+                && oldRecord != null
+                && !tcmsyndromeConfig.getId().equals(oldRecord.getId())) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        //新增数据
+        if (tcmsyndromeConfig.getId() == null) {
+            tcmsyndromeConfig.setCreator(userId);
+            tcmsyndromeConfig.setGmtCreate(now);
+        }
+        if (tcmsyndromeConfig.getIsDeleted() == null) {
+            tcmsyndromeConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+        }
+        tcmsyndromeConfigService.saveOrUpdate(tcmsyndromeConfig);
+        return true;
+    }
+
+    /**
+     * 保存记录-批量
+     *
+     * @param tcmsyndromeConfigListVO
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(TcmsyndromeConfigListVO tcmsyndromeConfigListVO) {
+        if (ListUtil.isEmpty(tcmsyndromeConfigListVO.getTcmsyndromeConfigList())) {
+            return false;
+        }
+        return saveOrUpdateRecords(tcmsyndromeConfigListVO.getTcmsyndromeConfigList());
+    }
+
+    /**
+     * 批量保存
+     *
+     * @param tcmsyndromeConfigList
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(List<TcmsyndromeConfig> tcmsyndromeConfigList) {
+        if (ListUtil.isEmpty(tcmsyndromeConfigList)) {
+            return false;
+        }
+        String userId = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+
+        //数据不完整的不保存
+        //过滤外部名称或公表名为空的数据
+        tcmsyndromeConfigList = tcmsyndromeConfigList
+                .stream()
+                .filter(i -> i.getHospitalId() != null)
+                .filter(i -> StringUtil.isNotBlank(i.getHisName()))
+                .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(tcmsyndromeConfigList)) {
+            return false;
+        }
+        Long hospitalId = tcmsyndromeConfigList.get(0).getHospitalId();
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, List<Long>>> configMap
+                = getConfigMap(hospitalId, null, null);
+        tcmsyndromeConfigList.forEach(tcmsyndromeConfig -> {
+            tcmsyndromeConfig.setModifier(userId);
+            tcmsyndromeConfig.setGmtModified(now);
+            if (tcmsyndromeConfig.getId() == null) {
+                if (configMap.containsKey(tcmsyndromeConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(tcmsyndromeConfig.getHisName()).get(tcmsyndromeConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(tcmsyndromeConfig.getHisName()).get(tcmsyndromeConfig.getUniqueName()));
+                }
+                tcmsyndromeConfig.setCreator(userId);
+                tcmsyndromeConfig.setGmtCreate(now);
+            }
+            if (tcmsyndromeConfig.getIsDeleted() == null) {
+                tcmsyndromeConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        tcmsyndromeConfigService.saveOrUpdateBatch(tcmsyndromeConfigList);
+        return true;
+    }
+
+    /**
+     * 删除记录-单条
+     *
+     * @param idVO
+     * @return
+     */
+    public Boolean deleteRecord(IdVO idVO) {
+        tcmsyndromeConfigService.removeById(idVO.getId());
+        return true;
+    }
+
+    /**
+     * 删除记录-批量
+     *
+     * @param idListVO
+     * @return
+     */
+    public Boolean deleteRecords(IdListVO idListVO) {
+        if (ListUtil.isEmpty(idListVO.getIds())) {
+            return false;
+        }
+        tcmsyndromeConfigService.removeByIds(idListVO.getIds());
+        return true;
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param tcmsyndromeConfigPageVO
+     * @return
+     */
+    public IPage<TcmsyndromeConfig> getPage(TcmsyndromeConfigPageVO tcmsyndromeConfigPageVO) {
+        return tcmsyndromeConfigService.getPage(tcmsyndromeConfigPageVO);
+    }
+
+    /**
+     * 数据导入
+     *
+     * @param file
+     * @param hospitalIdVO
+     */
+    public void importExcel(MultipartFile file, HospitalIdVO hospitalIdVO) {
+        List<TcmsyndromeConfig> tcmsyndromeConfigList = ExcelUtils.importExcel(file, 0, 1, TcmsyndromeConfig.class);
+        if (ListUtil.isNotEmpty(tcmsyndromeConfigList)) {
+            tcmsyndromeConfigList.forEach(tcmsyndromeConfig -> {
+                tcmsyndromeConfig.setHospitalId(hospitalIdVO.getHospitalId());
+            });
+            importExcelRecords(tcmsyndromeConfigList, hospitalIdVO);
+        } else {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
+        }
+    }
+
+    /**
+     * 数据导入
+     *
+     * @param tcmsyndromeConfigList
+     * @return
+     */
+    public Boolean importExcelRecords(List<TcmsyndromeConfig> tcmsyndromeConfigList, HospitalIdVO hospitalIdVO) {
+        Long hospitalId = hospitalIdVO.getHospitalId();
+        String userId = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+
+        //1、数据完整性校验
+        //2、去除前后空格
+        //过滤空数据,保留重复数据,方便计行
+        tcmsyndromeConfigList = tcmsyndromeConfigList.stream()
+                .filter(i -> StringUtil.isNotBlank(i.getHisName())
+                        || StringUtil.isNotBlank(i.getUniqueCode())
+                        || StringUtil.isNotBlank(i.getUniqueName()))
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(tcmsyndromeConfigList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
+        }
+        List<String> emptyNumList = Lists.newLinkedList();
+        for (int i = 0; i < tcmsyndromeConfigList.size(); i++) {
+            if (StringUtil.isBlank(tcmsyndromeConfigList.get(i).getHisName())
+                    || StringUtil.isBlank(tcmsyndromeConfigList.get(i).getUniqueName())) {
+                emptyNumList.add(String.valueOf(i + 2));
+            }
+            if (StringUtil.isNotBlank(tcmsyndromeConfigList.get(i).getHisName())) {
+                tcmsyndromeConfigList.get(i).setHisName(tcmsyndromeConfigList.get(i).getHisName().trim());
+            }
+            if (StringUtil.isNotBlank(tcmsyndromeConfigList.get(i).getUniqueName())) {
+                tcmsyndromeConfigList.get(i).setUniqueName(tcmsyndromeConfigList.get(i).getUniqueName().trim());
+            }
+            if (StringUtil.isNotBlank(tcmsyndromeConfigList.get(i).getUniqueCode())) {
+                tcmsyndromeConfigList.get(i).setUniqueCode(tcmsyndromeConfigList.get(i).getUniqueCode().trim());
+            } else {
+                tcmsyndromeConfigList.get(i).setUniqueCode(null);
+            }
+        }
+
+        if (ListUtil.isNotEmpty(emptyNumList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "以下行数(不计入空行)存在不完整数据:"
+                    + emptyNumList.stream().collect(Collectors.joining("、"))
+                    + "。导入取消,请修改后再试。\n");
+        }
+
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, List<Long>>> configMap
+                = getConfigMap(Long.valueOf(hospitalId), null, null);
+        tcmsyndromeConfigList.forEach(tcmsyndromeConfig -> {
+            tcmsyndromeConfig.setHospitalId(Long.valueOf(hospitalId));
+            tcmsyndromeConfig.setModifier(userId);
+            tcmsyndromeConfig.setGmtModified(now);
+            if (tcmsyndromeConfig.getId() == null) {
+                if (configMap.containsKey(tcmsyndromeConfig.getHisName())
+                        && ListUtil.isNotEmpty(configMap.get(tcmsyndromeConfig.getHisName()).get(tcmsyndromeConfig.getUniqueName()))) {
+                    deleteIds.addAll(configMap.get(tcmsyndromeConfig.getHisName()).get(tcmsyndromeConfig.getUniqueName()));
+                }
+                tcmsyndromeConfig.setCreator(userId);
+                tcmsyndromeConfig.setGmtCreate(now);
+            }
+            if (tcmsyndromeConfig.getIsDeleted() == null) {
+                tcmsyndromeConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+
+        //标准术语校验
+        List<String> errorNumList = Lists.newLinkedList();
+        List<String> uniqueNames = tcmsyndromeConfigList.stream()
+                .map(i -> i.getUniqueName())
+                .distinct()
+                .collect(Collectors.toList());
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setNames(uniqueNames);
+        conceptVO.setType(ConceptTypeEnum.Tcmsyndrome.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> names = respDTO.data;
+        for (int i = 0; i < tcmsyndromeConfigList.size(); i++) {
+            if (!names.contains(tcmsyndromeConfigList.get(i).getUniqueName())) {
+                errorNumList.add(String.valueOf(i + 2));
+            }
+        }
+        if (ListUtil.isNotEmpty(errorNumList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                    "以下行数(不计空行)标准术语在数据库中不存在:"
+                            + errorNumList.stream().collect(Collectors.joining("、"))
+                            + "。导入取消,请修改后再试。");
+        }
+
+        //重复数据过滤
+        tcmsyndromeConfigList = tcmsyndromeConfigList
+                .stream()
+                .distinct()
+                .collect(Collectors.toList());
+
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        tcmsyndromeConfigService.saveOrUpdateBatch(tcmsyndromeConfigList);
+        return true;
+    }
+
+    /**
+     * 获取映射关系-公表名
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    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<TcmsyndromeConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<TcmsyndromeConfig> records = tcmsyndromeConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        Map<String, List<TcmsyndromeConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
+        for (Map.Entry<String, List<TcmsyndromeConfig>> entry : configMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                Map<String, List<TcmsyndromeConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<TcmsyndromeConfig>> 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;
+    }
+
+    /**
+     * 获取映射关系-公表名
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    public Map<String, Map<String, List<Long>>> getUniqueConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
+        QueryWrapper<TcmsyndromeConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<TcmsyndromeConfig> records = tcmsyndromeConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        Map<String, List<TcmsyndromeConfig>> configMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<TcmsyndromeConfig>> entry : configMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                Map<String, List<TcmsyndromeConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "hisName");
+                Map<String, List<Long>> subIdMap = new HashMap<>();
+                for (Map.Entry<String, List<TcmsyndromeConfig>> 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;
+    }
+
+    /**
+     * 数据导出
+     *
+     * @param response
+     * @param hospitalIdVO
+     */
+    public void exportExcel(HttpServletResponse response, HospitalIdVO hospitalIdVO) {
+        QueryWrapper<TcmsyndromeConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalIdVO.getHospitalId())
+                .orderByDesc("gmt_modified");
+        List<TcmsyndromeConfig> records = tcmsyndromeConfigService.list(queryWrapper);
+        String fileName = "中医证候映射.xls";
+        ExcelUtils.exportExcel(records, null, "sheet1", TcmsyndromeConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    public IPage<HosRelationNumDTO> getRelationNumPage(HosRelationNumPageVO hosRelationNumPageVO) {
+        return tcmsyndromeConfigService.getRelationNumPage(hosRelationNumPageVO);
+    }
+
+    /**
+     * 数据导入模板导出
+     *
+     * @param response
+     */
+    public void exportExcelModule(HttpServletResponse response) {
+        String fileName = "中医证候映射模板.xls";
+        ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", TcmsyndromeConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据预匹配
+     *
+     * @param file
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file, HttpServletResponse response) {
+        List<TcmsyndromeConfig> originList = ExcelUtils.importExcel(file, 0, 1, TcmsyndromeConfig.class);
+        List<TcmsyndromeConfig> retList = dataProcess(originList);
+
+        String fileName = "中医证候关联数据(预匹配).xls";
+        ExcelUtils.exportExcel(retList, null, "sheet1", TcmsyndromeConfig.class, fileName, response, 12.8f);
+    }
+
+    /**
+     * 导入数据验证
+     *
+     * @param file
+     * @return
+     */
+    public Boolean dataVerify(MultipartFile file) {
+        List<TcmsyndromeConfig> originList = ExcelUtils.importExcel(file, 0, 1, TcmsyndromeConfig.class);
+        List<TcmsyndromeConfig> retList = dataProcess(originList);
+        return true;
+    }
+
+    /**
+     * 数据处理
+     *
+     * @param originList
+     * @return
+     */
+    public List<TcmsyndromeConfig> dataProcess(List<TcmsyndromeConfig> originList) {
+        List<TcmsyndromeConfig> retList = Lists.newLinkedList();
+        List<String> hisNameList = originList.stream().map(i -> i.getHisName()).distinct().collect(Collectors.toList());
+        Map<String, List<TcmsyndromeConfig>> allMap = getAll(hisNameList);
+
+        //去除空格
+        originList.forEach(item -> {
+            item.setHisName(item.getHisName().trim());
+        });
+
+        //获取标准术语
+        List<String> precUniqueName = Lists.newArrayList();
+        if (allMap != null) {
+            for (Map.Entry<String, List<TcmsyndromeConfig>> 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.Tcmsyndrome.getKey());
+        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+        List<String> uniqueNames = respDTO.data;
+        if (ListUtil.isNotEmpty(originList)) {
+            for (TcmsyndromeConfig originItem : originList) {
+                if (allMap.containsKey(originItem.getHisName())) {
+                    List<TcmsyndromeConfig> items = allMap.get(originItem.getHisName());
+                    boolean flag = false;
+                    for (TcmsyndromeConfig 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<TcmsyndromeConfig>> getAll(List<String> hisNameList) {
+        Map<String, List<TcmsyndromeConfig>> retMap = new HashMap<>();
+        QueryWrapper<TcmsyndromeConfig> queryWrapper = new QueryWrapper<>();
+        if (ListUtil.isNotEmpty(hisNameList)) {
+            queryWrapper.in("his_name", hisNameList);
+        }
+        List<TcmsyndromeConfig> records = tcmsyndromeConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+        records.forEach(record -> {
+            record.setHospitalId(null);
+            record.setId(null);
+            record.setUniqueCode(StringUtils.isBlank(record.getUniqueCode()) ? null : record.getUniqueName());
+        });
+
+        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;
+    }
+
+    /**
+     * 查找指定医院映射关系
+     *
+     * @param hospitalId
+     * @return
+     */
+    public List<TcmsyndromeConfig> getListByHospitalId(Long hospitalId) {
+        QueryWrapper<TcmsyndromeConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        return tcmsyndromeConfigService.list(queryWrapper);
+    }
+}

+ 52 - 50
cdssman-service/src/main/java/com/diagbot/facade/TransfusionConfigFacade.java

@@ -291,61 +291,63 @@ public class TransfusionConfigFacade {
 
         // 验证数据是否已存在,已存在的先删除
         // 没id的删除重新插入,有id的更新
-        List<Long> deleteIds = Lists.newLinkedList();
-        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())
-                        && ListUtil.isNotEmpty(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()))) {
-                    deleteIds.addAll(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()));
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            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())
+                            && ListUtil.isNotEmpty(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()))) {
+                        deleteIds.addAll(configMap.get(transfusionConfig.getHisName()).get(transfusionConfig.getUniqueName()));
+                    }
+                    transfusionConfig.setCreator(userId);
+                    transfusionConfig.setGmtCreate(now);
+                }
+                if (transfusionConfig.getIsDeleted() == null) {
+                    transfusionConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+                }
+            });
+
+            //标准术语校验
+            List<String> errorNumList = Lists.newLinkedList();
+            List<String> uniqueNames = transfusionConfigList.stream()
+                    .map(i -> i.getUniqueName())
+                    .distinct()
+                    .collect(Collectors.toList());
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setType(ConceptTypeEnum.Transfusion.getKey());
+            RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+            List<String> names = respDTO.data;
+            for (int i = 0; i < transfusionConfigList.size(); i++) {
+                if (!names.contains(transfusionConfigList.get(i).getUniqueName())) {
+                    errorNumList.add(String.valueOf(i + 2));
                 }
-                transfusionConfig.setCreator(userId);
-                transfusionConfig.setGmtCreate(now);
             }
-            if (transfusionConfig.getIsDeleted() == null) {
-                transfusionConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            if (ListUtil.isNotEmpty(errorNumList)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                        "以下行数(不计空行)标准术语在数据库中不存在:"
+                                + errorNumList.stream().collect(Collectors.joining("、"))
+                                + "。导入取消,请修改后再试。");
             }
-        });
 
-        //标准术语校验
-        List<String> errorNumList = Lists.newLinkedList();
-        List<String> uniqueNames = transfusionConfigList.stream()
-                .map(i -> i.getUniqueName())
-                .distinct()
-                .collect(Collectors.toList());
-        ConceptVO conceptVO = new ConceptVO();
-        conceptVO.setNames(uniqueNames);
-        conceptVO.setType(ConceptTypeEnum.Transfusion.getKey());
-        RespDTO<List<String>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
-        RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
-        List<String> names = respDTO.data;
-        for (int i = 0; i < transfusionConfigList.size(); i++) {
-            if (!names.contains(transfusionConfigList.get(i).getUniqueName())) {
-                errorNumList.add(String.valueOf(i + 2));
-            }
+            //重复数据过滤
+            transfusionConfigList = transfusionConfigList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            transfusionConfigService.saveOrUpdateBatch(transfusionConfigList);
         }
-        if (ListUtil.isNotEmpty(errorNumList)) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
-                    "以下行数(不计空行)标准术语在数据库中不存在:"
-                            + errorNumList.stream().collect(Collectors.joining("、"))
-                            + "。导入取消,请修改后再试。");
-        }
-
-        //重复数据过滤
-        transfusionConfigList = transfusionConfigList
-                .stream()
-                .distinct()
-                .collect(Collectors.toList());
-
-        //删除已存在映射关系
-        IdListVO idListVO = new IdListVO();
-        idListVO.setIds(deleteIds);
-        deleteRecords(idListVO);
-        transfusionConfigService.saveOrUpdateBatch(transfusionConfigList);
         return true;
     }
 

+ 35 - 0
cdssman-service/src/main/java/com/diagbot/mapper/TcmdiseaseConfigMapper.java

@@ -0,0 +1,35 @@
+package com.diagbot.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.entity.TcmdiseaseConfig;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.TcmdiseaseConfigPageVO;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 中医疾病映射表 Mapper 接口
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+public interface TcmdiseaseConfigMapper extends BaseMapper<TcmdiseaseConfig> {
+    /**
+     * 分页查询
+     *
+     * @param tcmdiseaseConfigPageVO
+     * @return
+     */
+    IPage<TcmdiseaseConfig> getPage(@Param("tcmdiseaseConfigPageVO") TcmdiseaseConfigPageVO tcmdiseaseConfigPageVO);
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    IPage<HosRelationNumDTO> getRelationNumPage(@Param("hosRelationNumPageVO") HosRelationNumPageVO hosRelationNumPageVO);
+}

+ 35 - 0
cdssman-service/src/main/java/com/diagbot/mapper/TcmsyndromeConfigMapper.java

@@ -0,0 +1,35 @@
+package com.diagbot.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.entity.TcmsyndromeConfig;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.TcmsyndromeConfigPageVO;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 中医证候映射表 Mapper 接口
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+public interface TcmsyndromeConfigMapper extends BaseMapper<TcmsyndromeConfig> {
+    /**
+     * 分页查询
+     *
+     * @param tcmsyndromeConfigPageVO
+     * @return
+     */
+    IPage<TcmsyndromeConfig> getPage(@Param("tcmsyndromeConfigPageVO") TcmsyndromeConfigPageVO tcmsyndromeConfigPageVO);
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    IPage<HosRelationNumDTO> getRelationNumPage(@Param("hosRelationNumPageVO") HosRelationNumPageVO hosRelationNumPageVO);
+}

+ 35 - 0
cdssman-service/src/main/java/com/diagbot/service/TcmdiseaseConfigService.java

@@ -0,0 +1,35 @@
+package com.diagbot.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.entity.TcmdiseaseConfig;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.TcmdiseaseConfigPageVO;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 中医疾病映射表 服务类
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+public interface TcmdiseaseConfigService extends IService<TcmdiseaseConfig> {
+    /**
+     * 分页查询
+     *
+     * @param tcmdiseaseConfigPageVO
+     * @return
+     */
+    IPage<TcmdiseaseConfig> getPage(@Param("tcmdiseaseConfigPageVO") TcmdiseaseConfigPageVO tcmdiseaseConfigPageVO);
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    IPage<HosRelationNumDTO> getRelationNumPage(@Param("hosRelationNumPageVO") HosRelationNumPageVO hosRelationNumPageVO);
+}

+ 35 - 0
cdssman-service/src/main/java/com/diagbot/service/TcmsyndromeConfigService.java

@@ -0,0 +1,35 @@
+package com.diagbot.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.entity.TcmsyndromeConfig;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.TcmsyndromeConfigPageVO;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 中医证候映射表 服务类
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+public interface TcmsyndromeConfigService extends IService<TcmsyndromeConfig> {
+    /**
+     * 分页查询
+     *
+     * @param tcmsyndromeConfigPageVO
+     * @return
+     */
+    IPage<TcmsyndromeConfig> getPage(@Param("tcmsyndromeConfigPageVO") TcmsyndromeConfigPageVO tcmsyndromeConfigPageVO);
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    IPage<HosRelationNumDTO> getRelationNumPage(@Param("hosRelationNumPageVO") HosRelationNumPageVO hosRelationNumPageVO);
+}

+ 46 - 0
cdssman-service/src/main/java/com/diagbot/service/impl/TcmdiseaseConfigServiceImpl.java

@@ -0,0 +1,46 @@
+package com.diagbot.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.entity.TcmdiseaseConfig;
+import com.diagbot.mapper.TcmdiseaseConfigMapper;
+import com.diagbot.service.TcmdiseaseConfigService;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.TcmdiseaseConfigPageVO;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 中医疾病映射表 服务实现类
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+@Service
+public class TcmdiseaseConfigServiceImpl extends ServiceImpl<TcmdiseaseConfigMapper, TcmdiseaseConfig> implements TcmdiseaseConfigService {
+
+    /**
+     * 分页查询
+     *
+     * @param tcmdiseaseConfigPageVO
+     * @return
+     */
+    @Override
+    public IPage<TcmdiseaseConfig> getPage(@Param("tcmdiseaseConfigPageVO") TcmdiseaseConfigPageVO tcmdiseaseConfigPageVO) {
+        return baseMapper.getPage(tcmdiseaseConfigPageVO);
+    }
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    @Override
+    public IPage<HosRelationNumDTO> getRelationNumPage(@Param("hosRelationNumPageVO") HosRelationNumPageVO hosRelationNumPageVO) {
+        return baseMapper.getRelationNumPage(hosRelationNumPageVO);
+    }
+}

+ 45 - 0
cdssman-service/src/main/java/com/diagbot/service/impl/TcmsyndromeConfigServiceImpl.java

@@ -0,0 +1,45 @@
+package com.diagbot.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.HosRelationNumDTO;
+import com.diagbot.entity.TcmsyndromeConfig;
+import com.diagbot.mapper.TcmsyndromeConfigMapper;
+import com.diagbot.service.TcmsyndromeConfigService;
+import com.diagbot.vo.HosRelationNumPageVO;
+import com.diagbot.vo.TcmsyndromeConfigPageVO;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 中医证候映射表 服务实现类
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+@Service
+public class TcmsyndromeConfigServiceImpl extends ServiceImpl<TcmsyndromeConfigMapper, TcmsyndromeConfig> implements TcmsyndromeConfigService {
+    /**
+     * 分页查询
+     *
+     * @param tcmsyndromeConfigPageVO
+     * @return
+     */
+    @Override
+    public IPage<TcmsyndromeConfig> getPage(@Param("tcmsyndromeConfigPageVO") TcmsyndromeConfigPageVO tcmsyndromeConfigPageVO) {
+        return baseMapper.getPage(tcmsyndromeConfigPageVO);
+    }
+
+    /**
+     * 各医院映射关系数列表
+     *
+     * @param hosRelationNumPageVO
+     * @return
+     */
+    @Override
+    public IPage<HosRelationNumDTO> getRelationNumPage(@Param("hosRelationNumPageVO") HosRelationNumPageVO hosRelationNumPageVO) {
+        return baseMapper.getRelationNumPage(hosRelationNumPageVO);
+    }
+}

+ 18 - 0
cdssman-service/src/main/java/com/diagbot/vo/TcmdiseaseConfigListVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import com.diagbot.entity.TcmdiseaseConfig;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/13 15:20
+ */
+@Getter
+@Setter
+public class TcmdiseaseConfigListVO {
+    private List<TcmdiseaseConfig> tcmdiseaseConfigList;
+}

+ 38 - 0
cdssman-service/src/main/java/com/diagbot/vo/TcmdiseaseConfigPageVO.java

@@ -0,0 +1,38 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/13 15:21
+ */
+@Getter
+@Setter
+public class TcmdiseaseConfigPageVO extends Page {
+    /**
+     * 医院id
+     */
+    @NotNull(message = "请输入医院id")
+    private Long hospitalId;
+
+    /**
+     * his大项名称
+     */
+    private String hisName;
+
+    /**
+     * 标准名
+     */
+    private String uniqueName;
+
+    /**
+     * 标准编码
+     */
+    private String uniqueCode;
+}

+ 18 - 0
cdssman-service/src/main/java/com/diagbot/vo/TcmsyndromeConfigListVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import com.diagbot.entity.TcmsyndromeConfig;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/14 9:28
+ */
+@Getter
+@Setter
+public class TcmsyndromeConfigListVO {
+    private List<TcmsyndromeConfig> tcmsyndromeConfigList;
+}

+ 38 - 0
cdssman-service/src/main/java/com/diagbot/vo/TcmsyndromeConfigPageVO.java

@@ -0,0 +1,38 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/5/14 9:28
+ */
+@Getter
+@Setter
+public class TcmsyndromeConfigPageVO extends Page {
+    /**
+     * 医院id
+     */
+    @NotNull(message = "请输入医院id")
+    private Long hospitalId;
+
+    /**
+     * his大项名称
+     */
+    private String hisName;
+
+    /**
+     * 标准名
+     */
+    private String uniqueName;
+
+    /**
+     * 标准编码
+     */
+    private String uniqueCode;
+}

+ 20 - 0
cdssman-service/src/main/java/com/diagbot/web/TcmdiseaseConfigController.java

@@ -0,0 +1,20 @@
+package com.diagbot.web;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 中医疾病映射表 前端控制器
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+@Controller
+@RequestMapping("/tcmdiseaseConfig")
+public class TcmdiseaseConfigController {
+
+}

+ 20 - 0
cdssman-service/src/main/java/com/diagbot/web/TcmsyndromeConfigController.java

@@ -0,0 +1,20 @@
+package com.diagbot.web;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 中医证候映射表 前端控制器
+ * </p>
+ *
+ * @author zhaops
+ * @since 2021-05-13
+ */
+@Controller
+@RequestMapping("/tcmsyndromeConfig")
+public class TcmsyndromeConfigController {
+
+}

+ 5 - 1
cdssman-service/src/main/resources/mapper/HospitalInfoMapper.xml

@@ -60,7 +60,9 @@
         g.num AS operationNum,
         h.num AS transfusionNum,
         i.num AS scaleNum,
-        j.num AS nurseNum
+        j.num AS nurseNum,
+        k.num AS tcmdiseaseNum,
+        l.num AS tcmsyndromeNum
         FROM
         tran_hospital_info a
         LEFT JOIN ( SELECT hospital_id, count(*) AS num FROM tran_lis_config WHERE is_deleted = 'N' GROUP BY hospital_id ) b ON a.id = b.hospital_id
@@ -72,6 +74,8 @@
         LEFT JOIN ( SELECT hospital_id, count(*) AS num FROM tran_transfusion_config WHERE is_deleted = 'N' GROUP BY hospital_id ) h ON a.id = h.hospital_id
         LEFT JOIN ( SELECT hospital_id, count(*) AS num FROM tran_scale_config WHERE is_deleted = 'N' GROUP BY hospital_id ) i ON a.id = i.hospital_id
         LEFT JOIN ( SELECT hospital_id, count(*) AS num FROM tran_nurse_config WHERE is_deleted = 'N' GROUP BY hospital_id ) j ON a.id = j.hospital_id
+        LEFT JOIN ( SELECT hospital_id, count(*) AS num FROM tran_tcmdisease_config WHERE is_deleted = 'N' GROUP BY hospital_id ) k ON a.id = k.hospital_id
+        LEFT JOIN ( SELECT hospital_id, count(*) AS num FROM tran_tcmsyndrome_config WHERE is_deleted = 'N' GROUP BY hospital_id ) l ON a.id = l.hospital_id
         WHERE
         a.is_deleted = 'N'
         <if test="hospitalInfoPageVO.name!=null and hospitalInfoPageVO.name!=''">

+ 55 - 0
cdssman-service/src/main/resources/mapper/TcmdiseaseConfigMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.TcmdiseaseConfigMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.TcmdiseaseConfig">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="his_name" property="hisName" />
+        <result column="unique_name" property="uniqueName" />
+        <result column="unique_code" property="uniqueCode" />
+    </resultMap>
+
+    <!-- 分页查询 -->
+    <select id="getPage" resultType="com.diagbot.entity.TcmdiseaseConfig">
+        select a.*
+        from tran_tcmdisease_config a
+        where a.is_deleted='N'
+        <if test="tcmdiseaseConfigPageVO.hospitalId!=null">
+            and a.hospital_id=#{tcmdiseaseConfigPageVO.hospitalId}
+        </if>
+        <if test="tcmdiseaseConfigPageVO.hisName!=null and tcmdiseaseConfigPageVO.hisName!=''">
+            and a.his_name like concat("%",#{tcmdiseaseConfigPageVO.hisName},"%")
+        </if>
+        <if test="tcmdiseaseConfigPageVO.uniqueName!=null and tcmdiseaseConfigPageVO.uniqueName!=''">
+            and a.unique_name like concat("%",#{tcmdiseaseConfigPageVO.uniqueName},"%")
+        </if>
+        <if test="tcmdiseaseConfigPageVO.uniqueCode!=null and tcmdiseaseConfigPageVO.uniqueCode!=''">
+            and a.unique_code like concat("%",#{tcmdiseaseConfigPageVO.uniqueCode},"%")
+        </if>
+        order by a.gmt_modified desc
+    </select>
+
+    <!-- 各医院映射关系数列表 -->
+    <select id="getRelationNumPage" resultType="com.diagbot.dto.HosRelationNumDTO">
+        SELECT
+        a.id,
+        a.NAME,
+        sum( b.id IS NOT NULL ) AS num
+        FROM
+        tran_hospital_info a
+        LEFT JOIN tran_tcmdisease_config b ON a.id = b.hospital_id
+        AND b.is_deleted = 'N'
+        WHERE
+        a.is_deleted = 'N'
+        GROUP BY
+        a.id
+    </select>
+
+</mapper>

+ 55 - 0
cdssman-service/src/main/resources/mapper/TcmsyndromeConfigMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.TcmsyndromeConfigMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.TcmsyndromeConfig">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="his_name" property="hisName" />
+        <result column="unique_name" property="uniqueName" />
+        <result column="unique_code" property="uniqueCode" />
+    </resultMap>
+
+    <!-- 分页查询 -->
+    <select id="getPage" resultType="com.diagbot.entity.TcmsyndromeConfig">
+        select a.*
+        from tran_tcmsyndrome_config a
+        where a.is_deleted='N'
+        <if test="tcmsyndromeConfigPageVO.hospitalId!=null">
+            and a.hospital_id=#{tcmsyndromeConfigPageVO.hospitalId}
+        </if>
+        <if test="tcmsyndromeConfigPageVO.hisName!=null and tcmsyndromeConfigPageVO.hisName!=''">
+            and a.his_name like concat("%",#{tcmsyndromeConfigPageVO.hisName},"%")
+        </if>
+        <if test="tcmsyndromeConfigPageVO.uniqueName!=null and tcmsyndromeConfigPageVO.uniqueName!=''">
+            and a.unique_name like concat("%",#{tcmsyndromeConfigPageVO.uniqueName},"%")
+        </if>
+        <if test="tcmsyndromeConfigPageVO.uniqueCode!=null and tcmsyndromeConfigPageVO.uniqueCode!=''">
+            and a.unique_code like concat("%",#{tcmsyndromeConfigPageVO.uniqueCode},"%")
+        </if>
+        order by a.gmt_modified desc
+    </select>
+
+    <!-- 各医院映射关系数列表 -->
+    <select id="getRelationNumPage" resultType="com.diagbot.dto.HosRelationNumDTO">
+        SELECT
+        a.id,
+        a.NAME,
+        sum( b.id IS NOT NULL ) AS num
+        FROM
+        tran_hospital_info a
+        LEFT JOIN tran_tcmsyndrome_config b ON a.id = b.hospital_id
+        AND b.is_deleted = 'N'
+        WHERE
+        a.is_deleted = 'N'
+        GROUP BY
+        a.id
+    </select>
+
+</mapper>