Przeglądaj źródła

1、术语关联维护

zhaops 4 lat temu
rodzic
commit
8d633cd2c9

+ 11 - 0
src/main/java/com/diagbot/entity/AnesthesiaConfig.java

@@ -33,4 +33,15 @@ public class AnesthesiaConfig {
     @NotBlank(message = "请输入标准麻醉名称")
     private String uniqueName;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
 }

+ 28 - 0
src/main/java/com/diagbot/entity/DeptConfig.java

@@ -86,6 +86,18 @@ public class DeptConfig implements Serializable {
     //@Excel(name = "对应项编码", width = 40, orderNum = "3")
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
     public Long getId() {
         return id;
     }
@@ -174,6 +186,22 @@ public class DeptConfig implements Serializable {
         this.uniqueCode = uniqueCode;
     }
 
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     @Override
     public String toString() {
         return "DeptConfig{" +

+ 2 - 2
src/main/java/com/diagbot/entity/DiseaseConfig.java

@@ -83,13 +83,13 @@ public class DiseaseConfig implements Serializable {
     /**
      * 是否匹配(0-未匹配、1-已匹配)
      */
-    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = {"未匹配_0,已匹配_1,_null"},isImportField = "true")
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
     private Integer isMatch;
 
     /**
      * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
      */
-    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = {"标准词_1,同义词_2,编码_3,历史数据_4,相似词_5,数据迁移_99,_null"},isImportField = "true")
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
     private Integer source;
 
     public Long getId() {

+ 2 - 2
src/main/java/com/diagbot/entity/DrugConfig.java

@@ -95,13 +95,13 @@ public class DrugConfig implements Serializable {
     /**
      * 是否匹配(0-未匹配、1-已匹配)
      */
-    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1", "_null" })
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
     private Integer isMatch;
 
     /**
      * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
      */
-    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" })
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
     private Integer source;
 
     public Long getId() {

+ 28 - 0
src/main/java/com/diagbot/entity/LisConfig.java

@@ -91,6 +91,18 @@ public class LisConfig implements Serializable {
     //@Excel(name = "对应项目编码", width = 40, orderNum = "3")
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
     public Long getId() {
         return id;
     }
@@ -179,6 +191,22 @@ public class LisConfig implements Serializable {
         this.uniqueCode = uniqueCode;
     }
 
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     @Override
     public String toString() {
         return "LisConfig{" +

+ 43 - 0
src/main/java/com/diagbot/entity/MappingConfig.java

@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.diagbot.util.StringUtil;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.Objects;
 
 /**
  * <p>
@@ -254,4 +256,45 @@ public class MappingConfig implements Serializable {
                 ", remark=" + remark +
                 "}";
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        MappingConfig mappingConfig = (MappingConfig) o;
+        return Objects.equals(id, mappingConfig.id)
+                && Objects.equals(isDeleted, mappingConfig.isDeleted)
+                && Objects.equals(hospitalId, mappingConfig.hospitalId)
+                && Objects.equals(type, mappingConfig.type)
+                && Objects.equals(hisName, mappingConfig.hisName)
+                && Objects.equals(hisCode, mappingConfig.hisCode)
+                && Objects.equals(hisDetailName, mappingConfig.hisDetailName)
+                && Objects.equals(conceptId, mappingConfig.conceptId)
+                && Objects.equals(formConceptId, mappingConfig.formConceptId)
+                && Objects.equals(isMatch, mappingConfig.isMatch)
+                //&& Objects.equals(source, mappingConfig.source)
+                ;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, isDeleted, hospitalId, type, hisName, hisCode, hisDetailName, conceptId, formConceptId, isMatch);
+    }
+
+    public static boolean nonNull(MappingConfig o) {
+        return !(o == null
+                || (o.hospitalId == null
+                && o.type == null
+                && StringUtil.isBlank(o.hisName)
+                && StringUtil.isBlank(o.hisCode)
+                && StringUtil.isBlank(o.hisDetailName)
+                && o.conceptId == null
+                && o.formConceptId == null
+                && o.isMatch == null
+                && o.source == null));
+    }
 }

+ 28 - 0
src/main/java/com/diagbot/entity/NurseConfig.java

@@ -79,6 +79,18 @@ public class NurseConfig implements Serializable {
      */
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
     public Long getId() {
         return id;
     }
@@ -159,6 +171,22 @@ public class NurseConfig implements Serializable {
         this.uniqueCode = uniqueCode;
     }
 
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     @Override
     public String toString() {
         return "NurseConfig{" +

+ 28 - 0
src/main/java/com/diagbot/entity/OperationConfig.java

@@ -80,6 +80,34 @@ public class OperationConfig implements Serializable {
     //@Excel(name = "对应项编码", width = 40, orderNum = "2")
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     public Long getId() {
         return id;
     }

+ 2 - 2
src/main/java/com/diagbot/entity/PacsConfig.java

@@ -83,13 +83,13 @@ public class PacsConfig implements Serializable {
     /**
      * 是否匹配(0-未匹配、1-已匹配)
      */
-    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = {"未匹配_0","已匹配_1","_null"})
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
     private Integer isMatch;
 
     /**
      * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
      */
-    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = {"标准词_1","同义词_2","编码_3","历史数据_4","相似词_5","数据迁移_99","_null"})
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
     private Integer source;
 
     public Long getId() {

+ 28 - 0
src/main/java/com/diagbot/entity/ScaleConfig.java

@@ -79,6 +79,18 @@ public class ScaleConfig implements Serializable {
      */
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
     public Long getId() {
         return id;
     }
@@ -159,6 +171,22 @@ public class ScaleConfig implements Serializable {
         this.uniqueCode = uniqueCode;
     }
 
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     @Override
     public String toString() {
         return "ScaleConfig{" +

+ 28 - 0
src/main/java/com/diagbot/entity/TcmdiseaseConfig.java

@@ -80,6 +80,18 @@ public class TcmdiseaseConfig implements Serializable {
     @Excel(name = "中医疾病代码", width = 40, orderNum = "2", isImportField = "true")
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
     public Long getId() {
         return id;
     }
@@ -160,6 +172,22 @@ public class TcmdiseaseConfig implements Serializable {
         this.uniqueCode = uniqueCode;
     }
 
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     @Override
     public String toString() {
         return "TcmdiseaseConfig{" +

+ 28 - 0
src/main/java/com/diagbot/entity/TcmsyndromeConfig.java

@@ -80,6 +80,18 @@ public class TcmsyndromeConfig implements Serializable {
     @Excel(name = "中医证候代码", width = 40, orderNum = "2", isImportField = "true")
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
     public Long getId() {
         return id;
     }
@@ -160,6 +172,22 @@ public class TcmsyndromeConfig implements Serializable {
         this.uniqueCode = uniqueCode;
     }
 
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     @Override
     public String toString() {
         return "TcmsyndromeConfig{" +

+ 28 - 0
src/main/java/com/diagbot/entity/TransfusionConfig.java

@@ -80,6 +80,18 @@ public class TransfusionConfig implements Serializable {
     //@Excel(name = "对应项编码", width = 40, orderNum = "2")
     private String uniqueCode;
 
+    /**
+     * 是否匹配(0-未匹配、1-已匹配)
+     */
+    @Excel(name = "是否匹配", width = 20, orderNum = "4", replace = { "未匹配_0", "已匹配_1" }, isImportField = "true")
+    private Integer isMatch;
+
+    /**
+     * 数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)
+     */
+    @Excel(name = "数据来源", width = 20, orderNum = "5", replace = { "标准词_1", "同义词_2", "编码_3", "历史数据_4", "相似词_5", "数据迁移_99", "_null" }, isImportField = "true")
+    private Integer source;
+
     public Long getId() {
         return id;
     }
@@ -160,6 +172,22 @@ public class TransfusionConfig implements Serializable {
         this.uniqueCode = uniqueCode;
     }
 
+    public Integer getIsMatch() {
+        return isMatch;
+    }
+
+    public void setIsMatch(Integer isMatch) {
+        this.isMatch = isMatch;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
     @Override
     public String toString() {
         return "TransfusionConfig{" +

+ 32 - 0
src/main/java/com/diagbot/entity/wrapper/MappingConfigWrapper.java

@@ -1,9 +1,12 @@
 package com.diagbot.entity.wrapper;
 
 import com.diagbot.entity.MappingConfig;
+import com.diagbot.util.StringUtil;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Objects;
+
 /**
  * @Description:
  * @Author:zhaops
@@ -15,4 +18,33 @@ public class MappingConfigWrapper extends MappingConfig {
     private String uniqueName;
     private String form;
     private String code;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        MappingConfigWrapper mappingConfigWrapper = (MappingConfigWrapper) o;
+        return super.equals(o)
+                && Objects.equals(uniqueName, mappingConfigWrapper.uniqueName)
+                && Objects.equals(form, mappingConfigWrapper.form)
+                && Objects.equals(code, mappingConfigWrapper.code);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(uniqueName, form, code) + super.hashCode();
+    }
+
+    public static boolean nonNull(MappingConfigWrapper o) {
+        return !(o == null
+                || (StringUtil.isBlank(o.uniqueName)
+                && StringUtil.isBlank(o.form)
+                && StringUtil.isBlank(o.code)
+                || MappingConfig.nonNull(o)
+        ));
+    }
 }

+ 605 - 41
src/main/java/com/diagbot/facade/MappingConfigFacade.java

@@ -1,6 +1,7 @@
 package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.CdssCoreClient;
 import com.diagbot.dto.IndexBatchDTO;
@@ -24,8 +25,10 @@ import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.MatchSourceEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
+import com.diagbot.service.MappingConfigService;
 import com.diagbot.service.impl.MappingConfigServiceImpl;
 import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
 import com.diagbot.util.ExcelUtils;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
@@ -33,20 +36,27 @@ import com.diagbot.util.StringUtil;
 import com.diagbot.util.SysUserUtils;
 import com.diagbot.vo.ConceptVO;
 import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.IdListVO;
+import com.diagbot.vo.IdVO;
 import com.diagbot.vo.MappingConfigPageVO;
+import com.diagbot.vo.MappingConfigVO;
 import com.google.common.collect.Lists;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 /**
@@ -56,8 +66,14 @@ import java.util.stream.Collectors;
  */
 @Component
 public class MappingConfigFacade extends MappingConfigServiceImpl {
+
+    private static Pattern pattern = Pattern.compile("\\s*|\t|\r|\n");
+
     @Autowired
     private CdssCoreClient cdssCoreClient;
+    @Autowired
+    @Qualifier("mappingConfigServiceImpl")
+    private MappingConfigService mappingConfigService;
 
     /**
      * 分页查询
@@ -111,41 +127,12 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
 
         //todo conceptId转标准词
         List<MappingConfigWrapper> records = page.getRecords();
-        ConceptVO conceptVO = new ConceptVO();
-        List<Long> ids = Lists.newArrayList();
-        ids.addAll(records.stream().map(MappingConfigWrapper::getConceptId).collect(Collectors.toList()));
-        ids.addAll(records.stream().filter(i -> i.getFormConceptId() != null)
-                .map(MappingConfigWrapper::getFormConceptId).collect(Collectors.toList()));
-        conceptVO.setIds(ids);
-        RespDTO<List<IndexBatchDTO>> resultRespDTO = cdssCoreClient.getConceptNames(conceptVO);
-        if (RespDTOUtil.respIsOK(resultRespDTO) && ListUtil.isNotEmpty(resultRespDTO.data)) {
-            Map<Long, String> conceptMap
-                    = resultRespDTO.data.stream().collect(Collectors.toMap(IndexBatchDTO::getId, IndexBatchDTO::getName));
-            for (MappingConfigWrapper record : records) {
-                if (conceptMap.containsKey(record.getConceptId())) {
-                    record.setUniqueName(conceptMap.get(record.getConceptId()));
-                }
-                if (record.getFormConceptId() != null && conceptMap.containsKey(record.getFormConceptId())) {
-                    record.setForm(conceptMap.get(record.getFormConceptId()));
-                }
-            }
-            page.setRecords(records);
-        }
+        records = addNames(records);
+        page.setRecords(records);
 
         return page;
     }
 
-    /**
-     * 导入模板下载
-     *
-     * @param response
-     */
-    public void exportExcelModule(HttpServletResponse response, Integer type) {
-        if (type == null) {
-            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入数据类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医诊断、13-中医证候、14-麻醉");
-        }
-        exportExcel(response, new ArrayList<>(), type, "导入模板");
-    }
 
     /**
      * 导出文件
@@ -175,7 +162,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
             case 5:
                 fileName = "药品" + fileName;
                 List<DrugConfig> drugConfigList = BeanUtil.listCopyTo(list, DrugConfig.class);
-                ExcelUtils.exportExcel(drugConfigList, null, "sheet1", DrugConfig.class, fileName, response, 12.8f);
+                ExcelUtils.exportExcel(drugConfigList, getForm(), "sheet1", DrugConfig.class, fileName, response, 12.8f);
                 break;
             case 6:
                 fileName = "手术和操作" + fileName;
@@ -223,16 +210,57 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
     }
 
     /**
-     * 导入数据预匹配
+     * 剂型说明
+     *
+     * @return
+     */
+    private String getForm() {
+        String form = "药品模板——药品剂型填写说明[不填";
+        //药品剂型
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
+        conceptVO.setType(ConceptTypeEnum.Form.getKey());
+        RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        if (RespDTOUtil.respIsOK(respDTO)) {
+            String formList = respDTO.data.stream()
+                    .map(i -> i.getName())
+                    .distinct()
+                    .collect(Collectors.joining("、"));
+            if (StringUtil.isNotBlank(formList)) {
+                form += "、" + formList;
+            }
+        }
+        form += "]";
+        return form;
+    }
+
+    /**
+     * 导入模板下载
      *
-     * @param file
-     * @param type
      * @param response
      */
-    public void precDataMatch(MultipartFile file, Integer type, HttpServletResponse response) {
-        List<MappingConfigWrapper> originList = readImportData(file, type);
-        List<MappingConfigWrapper> retList = dataProcess(originList, type);
-        exportExcel(response, retList, type, "关联数据(预匹配)");
+    public void exportExcelModule(HttpServletResponse response, MappingConfigVO mappingConfigVO) {
+        exportExcel(response, new ArrayList<>(), mappingConfigVO.getType(), "导入模板");
+    }
+
+    /**
+     * 数据导出
+     *
+     * @param response
+     */
+    public void exportExcel(HttpServletResponse response, MappingConfigVO mappingConfigVO) {
+        if (mappingConfigVO.getHospitalId() == null) {
+            mappingConfigVO.setHospitalId(Long.valueOf(SysUserUtils.getCurrentHospitalID()));
+        }
+        QueryWrapper<MappingConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", mappingConfigVO.getHospitalId())
+                .eq("type", mappingConfigVO.getType())
+                .orderByDesc("gmt_modified");
+        List<MappingConfig> records = this.list(queryWrapper);
+        List<MappingConfigWrapper> exportList = BeanUtil.listCopyTo(records, MappingConfigWrapper.class);
+        exportList = addNames(exportList);
+        exportExcel(response, exportList, mappingConfigVO.getType(), "映射");
     }
 
     /**
@@ -300,12 +328,25 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
     }
 
     /**
-     * 数据处理
+     * 导入数据预匹配
+     *
+     * @param file
+     * @param type
+     * @param response
+     */
+    public void precDataMatch(MultipartFile file, Integer type, HttpServletResponse response) {
+        List<MappingConfigWrapper> originList = readImportData(file, type);
+        List<MappingConfigWrapper> retList = precDataProcess(originList, type);
+        exportExcel(response, retList, type, "关联数据(预匹配)");
+    }
+
+    /**
+     * 预匹配数据处理
      *
      * @param originList
      * @return
      */
-    public List<MappingConfigWrapper> dataProcess(List<MappingConfigWrapper> originList, Integer type) {
+    public List<MappingConfigWrapper> precDataProcess(List<MappingConfigWrapper> originList, Integer type) {
         List<MappingConfigWrapper> retList = Lists.newLinkedList();
         List<MappingConfigWrapper> dataList = Lists.newLinkedList();
         List<MappingConfigWrapper> standardList = Lists.newLinkedList();
@@ -550,9 +591,491 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
         } else {
             retList = BeanUtil.listCopyTo(codeList, MappingConfigWrapper.class);
         }
+
+        for (MappingConfigWrapper item : retList) {
+            if (item.getIsMatch() == null) {
+                item.setIsMatch(0);
+            }
+        }
         return retList;
     }
 
+    /**
+     * 数据导入
+     *
+     * @param file
+     * @param hospitalId
+     * @param type
+     */
+    public void importExcel(MultipartFile file, Long hospitalId, Integer type, String userId) {
+        if (hospitalId == null) {
+            hospitalId = Long.valueOf(SysUserUtils.getCurrentHospitalID());
+        }
+        if (StringUtil.isBlank(userId)) {
+            userId = SysUserUtils.getCurrentPrincipleID();
+        }
+        List<MappingConfigWrapper> originList = readImportData(file, type);
+        if (ListUtil.isEmpty(originList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
+        }
+        importDataProcess(originList, hospitalId, type, userId);
+    }
+
+    /**
+     * 导入数据处理
+     *
+     * @param originList
+     * @param hospitalId
+     * @param type
+     */
+    public boolean importDataProcess(List<MappingConfigWrapper> originList, Long hospitalId, Integer type, String userId) {
+        List<MappingConfigWrapper> tempList = Lists.newLinkedList();
+
+        Date now = DateUtil.now();
+
+        //过滤空数据,保留重复数据,方便计行
+        //去除空格、回车、换行符、制表符
+        originList = originList.stream()
+                .filter(MappingConfigWrapper::nonNull)
+                .collect(Collectors.toList());
+        if (ListUtil.isEmpty(originList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
+        }
+        List<Integer> emptyNumList = Lists.newLinkedList();
+        Integer rowId = 1;
+        for (MappingConfigWrapper item : originList) {
+            if (StringUtil.isBlank(item.getHisName())) {
+                if (type.equals(ConceptTypeEnum.Drug.getKey())) {
+                    emptyNumList.add(rowId + 2);
+                } else {
+                    emptyNumList.add(rowId + 1);
+                }
+            } else {
+                item.setHisName(pattern.matcher(item.getHisName()).replaceAll(""));
+            }
+            if (StringUtil.isNotBlank(item.getHisCode())) {
+                item.setHisCode(pattern.matcher(item.getHisCode()).replaceAll(""));
+            } else {
+                item.setHisCode("");
+            }
+            if (StringUtil.isNotBlank(item.getHisDetailName())) {
+                item.setHisDetailName(pattern.matcher(item.getHisDetailName()).replaceAll(""));
+            } else {
+                item.setHisDetailName("");
+            }
+            if (StringUtil.isNotBlank(item.getUniqueName())) {
+                item.setUniqueName(pattern.matcher(item.getUniqueName()).replaceAll(""));
+                item.setIsMatch(1);
+            } else {
+                item.setUniqueName("");
+                item.setIsMatch(0);
+            }
+            if (StringUtil.isNotBlank(item.getForm())) {
+                item.setForm(pattern.matcher(item.getForm()).replaceAll(""));
+            } else {
+                item.setForm("");
+            }
+            if (StringUtil.isNotBlank(item.getCode())) {
+                item.setCode(pattern.matcher(item.getCode()).replaceAll(""));
+            } else {
+                item.setCode("");
+            }
+        }
+
+        //医院术语名称不允许为空
+        if (ListUtil.isNotEmpty(emptyNumList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "以下行数(不计入空行)存在不完整数据:"
+                    + emptyNumList.stream().map(Object::toString)
+                    .collect(Collectors.joining("、"))
+                    + "。导入取消,请修改后再试。\n");
+        }
+
+        List<String> hisNames = originList
+                .stream()
+                .map(i -> i.getHisName())
+                .collect(Collectors.toList());
+
+        originList = originList.stream().distinct().collect(Collectors.toList());
+        List<MappingConfigWrapper> matchList
+                = originList.stream().filter(i -> StringUtil.isNotBlank(i.getUniqueName())).collect(Collectors.toList());
+        Map<String, List<MappingConfigWrapper>> matchMap
+                = matchList.stream().collect(Collectors.groupingBy(i -> i.getHisName() + "_"
+                + i.getHisCode() + "_"
+                + i.getHisDetailName()));
+        Map<String, List<MappingConfigWrapper>> fullMatchMap = matchList.stream()
+                .collect(Collectors.groupingBy(i -> i.getHisName() + "_"
+                        + i.getHisCode() + "_"
+                        + i.getHisDetailName() + "_"
+                        + i.getUniqueName() + "_"
+                        + i.getForm()));
+        List<MappingConfigWrapper> unMatchList
+                = originList.stream().filter(i -> StringUtil.isBlank(i.getUniqueName())).collect(Collectors.toList());
+        Map<String, List<MappingConfigWrapper>> unMatchMap
+                = unMatchList.stream().collect(Collectors.groupingBy(i -> i.getHisName() + "_"
+                + i.getHisCode() + "_"
+                + i.getHisDetailName()));
+        Iterator<MappingConfigWrapper> it = unMatchList.iterator();
+        while (it.hasNext()) {
+            MappingConfigWrapper item = it.next();
+            String matchKey = item.getHisName() + "_"
+                    + item.getHisCode() + "_"
+                    + item.getHisDetailName();
+            if (matchMap.containsKey(matchKey)) {
+                it.remove();
+            }
+        }
+        tempList.addAll(matchList);
+        tempList.addAll(unMatchList);
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        synchronized (this) {
+            List<Long> deleteIds = Lists.newLinkedList();
+            List<MappingConfig> existList = this.list(new QueryWrapper<MappingConfig>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("hospital_id", hospitalId)
+                    .eq("type", type)
+                    .in("his_name", hisNames));
+
+            if (ListUtil.isEmpty(existList)) {
+                List<MappingConfigWrapper> existWrapperList = BeanUtil.listCopyTo(existList, MappingConfigWrapper.class);
+                existWrapperList = addNames(existWrapperList);
+                for (MappingConfigWrapper item : existWrapperList) {
+                    if (StringUtil.isBlank(item.getHisDetailName())) {
+                        item.setHisDetailName("");
+                    }
+                    if (StringUtil.isBlank(item.getUniqueName())) {
+                        item.getUniqueName();
+                    }
+                    if (StringUtil.isBlank(item.getForm())) {
+                        item.setForm("");
+                    }
+                    if (StringUtil.isBlank(item.getHisCode())) {
+                        item.setHisCode("");
+                    }
+                }
+
+                List<MappingConfigWrapper> db_matchList
+                        = existWrapperList.stream().filter(i -> i.getIsMatch().equals(1)).collect(Collectors.toList());
+                Map<String, List<MappingConfigWrapper>> db_matchMap
+                        = db_matchList.stream().collect(Collectors.groupingBy(i -> i.getHisName() + "_"
+                        + i.getHisCode() + "_"
+                        + i.getHisDetailName()));
+                List<MappingConfigWrapper> db_unMatchList
+                        = existWrapperList.stream().filter(i -> i.getIsMatch().equals(0)).collect(Collectors.toList());
+                Map<String, List<MappingConfigWrapper>> db_unMatchMap
+                        = db_unMatchList.stream().collect(Collectors.groupingBy(i -> i.getHisName() + "_"
+                        + i.getHisCode() + "_"
+                        + i.getHisDetailName()));
+
+                for (MappingConfigWrapper item : db_matchList) {
+                    String matchKey = item.getHisName() + "_"
+                            + item.getHisCode() + "_"
+                            + item.getHisDetailName() + "_"
+                            + item.getUniqueName() + "_"
+                            + item.getForm();
+                    if (fullMatchMap.containsKey(matchKey)) {
+                        deleteIds.add(item.getId());
+                    }
+                }
+                for (MappingConfigWrapper item : db_unMatchList) {
+                    String matchKey = item.getHisName() + "_"
+                            + item.getHisCode() + "_"
+                            + item.getHisDetailName();
+                    if (matchMap.containsKey(matchKey)
+                            || db_matchMap.containsKey(matchKey)
+                            || unMatchMap.containsKey(matchKey)) {
+                        deleteIds.add(item.getId());
+                    }
+                }
+            }
+            //标准术语校验
+            ConceptVO conceptVO = new ConceptVO();
+            conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
+            if (type.equals(ConceptTypeEnum.LisPack.getKey())) {
+                conceptVO.setType(ConceptTypeEnum.LisPack.getKey());
+                conceptVO.setNames(tempList.stream()
+                        .filter(i -> StringUtil.isBlank(i.getHisDetailName())
+                                && StringUtil.isNotBlank(i.getUniqueName()))
+                        .map(MappingConfigWrapper::getUniqueName)
+                        .distinct()
+                        .collect(Collectors.toList()));
+                RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+                RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+                Map<String, List<Long>> packMap = respDTO.data.stream()
+                        .collect(Collectors.groupingBy(IndexBatchDTO::getName,
+                                Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
+                conceptVO.setType(ConceptTypeEnum.Lis.getKey());
+                conceptVO.setNames(tempList.stream()
+                        .filter(i -> StringUtil.isNotBlank(i.getHisDetailName())
+                                && StringUtil.isNotBlank(i.getUniqueName()))
+                        .map(MappingConfigWrapper::getUniqueName)
+                        .distinct()
+                        .collect(Collectors.toList()));
+                respDTO = cdssCoreClient.getConceptNames(conceptVO);
+                RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
+                Map<String, List<Long>> lisMap = respDTO.data.stream()
+                        .collect(Collectors.groupingBy(IndexBatchDTO::getName,
+                                Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
+
+                for (MappingConfigWrapper item : tempList) {
+                    if (StringUtil.isBlank(item.getUniqueName())) {
+                        continue;
+                    }
+                    if (StringUtil.isBlank(item.getHisDetailName())) {
+                        if (packMap.containsKey(item.getUniqueName())) {
+                            item.setConceptId(packMap.get(item.getUniqueName()).get(0));
+                            item.setIsMatch(1);
+                        } else {
+                            item.setIsMatch(0);
+                        }
+                    } else {
+                        if (lisMap.containsKey(item.getUniqueName())) {
+                            item.setConceptId(lisMap.get(item.getUniqueName()).get(0));
+                            item.setIsMatch(1);
+                        } else {
+                            item.setIsMatch(0);
+                        }
+                    }
+
+                }
+            } else {
+                conceptVO.setType(type);
+                conceptVO.setNames(tempList.stream()
+                        .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
+                        .map(MappingConfigWrapper::getUniqueName)
+                        .distinct()
+                        .collect(Collectors.toList()));
+                RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+                if (RespDTOUtil.respIsOK(respDTO)) {
+                    Map<String, List<Long>> map = respDTO.data.stream()
+                            .collect(Collectors.groupingBy(IndexBatchDTO::getName,
+                                    Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
+                    for (MappingConfigWrapper item : tempList) {
+                        if (StringUtil.isBlank(item.getUniqueName())) {
+                            continue;
+                        }
+                        if (map.containsKey(item.getUniqueName())) {
+                            item.setConceptId(map.get(item.getUniqueName()).get(0));
+                            item.setIsMatch(1);
+                        } else {
+                            item.setIsMatch(0);
+                        }
+                    }
+                }
+            }
+
+            //剂型校验
+            if (type.equals(ConceptTypeEnum.Drug)) {
+                conceptVO.setType(ConceptTypeEnum.Form.getKey());
+                conceptVO.setNames(tempList.stream()
+                        .filter(i -> StringUtil.isNotBlank(i.getForm()))
+                        .map(MappingConfigWrapper::getForm)
+                        .distinct()
+                        .collect(Collectors.toList()));
+                RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+                if (RespDTOUtil.respIsOK(respDTO)) {
+                    Map<String, List<Long>> formMap = respDTO.data.stream()
+                            .collect(Collectors.groupingBy(IndexBatchDTO::getName,
+                                    Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
+                    for (MappingConfigWrapper item : tempList) {
+                        if (StringUtil.isBlank(item.getForm())) {
+                            continue;
+                        }
+                        if (formMap.containsKey(item.getForm())) {
+                            item.setFormConceptId(formMap.get(item.getForm()).get(0));
+                        }
+                    }
+                }
+            }
+
+            //重复数据过滤
+            tempList = tempList
+                    .stream()
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            for (MappingConfigWrapper item : tempList) {
+                item.setCreator(userId);
+                item.setGmtCreate(now);
+                item.setModifier(userId);
+                item.setGmtModified(now);
+            }
+
+            //删除已存在映射关系
+            IdListVO idListVO = new IdListVO();
+            idListVO.setIds(deleteIds);
+            deleteRecords(idListVO);
+            List<MappingConfig> saveList = BeanUtil.listCopyTo(tempList, MappingConfig.class);
+            mappingConfigService.saveOrUpdateBatch(saveList);
+        }
+        return true;
+    }
+
+    /**
+     * 删除记录-单条
+     *
+     * @param idVO
+     * @return
+     */
+    public Boolean deleteRecord(IdVO idVO) {
+        UpdateWrapper<MappingConfig> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.eq("id", idVO.getId())
+                .set("is_deleted", IsDeleteEnum.Y.getKey());
+        mappingConfigService.removeById(idVO.getId());
+        return true;
+    }
+
+    /**
+     * 删除记录-批量
+     *
+     * @param idListVO
+     * @return
+     */
+    public Boolean deleteRecords(IdListVO idListVO) {
+        if (ListUtil.isEmpty(idListVO.getIds())) {
+            return false;
+        }
+        UpdateWrapper<MappingConfig> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.in("id", idListVO.getIds())
+                .set("is_deleted", IsDeleteEnum.Y.getKey());
+        mappingConfigService.removeByIds(idListVO.getIds());
+        return true;
+    }
+
+    /**
+     * 获取记录-单条
+     *
+     * @param idVO
+     * @return
+     */
+    public MappingConfigWrapper getRecord(IdVO idVO) {
+        MappingConfig item = this.getById(idVO.getId());
+        MappingConfigWrapper itemWrapper = new MappingConfigWrapper();
+        BeanUtils.copyProperties(item, itemWrapper);
+        List<MappingConfigWrapper> retList = Lists.newArrayList();
+        retList.add(itemWrapper);
+        addNames(retList);
+
+        return retList.get(0);
+    }
+
+    /**
+     * 判断是否已存在
+     *
+     * @param mappingConfig
+     * @return
+     */
+    public Boolean isExistRecord(MappingConfig mappingConfig) {
+        if (mappingConfig.getType() == null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入请输入术语类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医诊断、13-中医证候、14-麻醉");
+        }
+        if (mappingConfig.getHospitalId() == null) {
+            mappingConfig.setHospitalId(Long.valueOf(SysUserUtils.getCurrentHospitalID()));
+        }
+        QueryWrapper<MappingConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", mappingConfig.getHospitalId())
+                .eq("type", mappingConfig.getType())
+                .eq("his_name", mappingConfig.getHisName())
+                .eq("concept_id", mappingConfig.getConceptId());
+        if (StringUtil.isBlank(mappingConfig.getHisDetailName())) {
+            queryWrapper.and(i -> i.isNull("his_detail_name")
+                    .or()
+                    .eq("his_detail_name", ""));
+        } else {
+            queryWrapper
+                    .eq("his_detail_name", mappingConfig.getHisDetailName());
+        }
+        if (mappingConfig.getFormConceptId() != null) {
+            queryWrapper.eq("form_concept_id", mappingConfig.getFormConceptId());
+        }
+        MappingConfig oldRecord = this.getOne(queryWrapper, false);
+        if (mappingConfig.getId() == null
+                && oldRecord != null) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        if (mappingConfig.getId() != null
+                && oldRecord != null
+                && !mappingConfig.getId().equals(oldRecord.getId())) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        return false;
+    }
+
+    /**
+     * 保存记录-单条
+     *
+     * @param mappingConfig
+     * @return
+     */
+    public Boolean saveOrUpdateRecord(MappingConfig mappingConfig) {
+        if (mappingConfig.getType() == null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入请输入术语类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医诊断、13-中医证候、14-麻醉");
+        }
+        if (mappingConfig.getHospitalId() == null) {
+            mappingConfig.setHospitalId(Long.valueOf(SysUserUtils.getCurrentHospitalID()));
+        }
+        String userId = "";
+        if (StringUtil.isBlank(mappingConfig.getModifier())) {
+            userId = SysUserUtils.getCurrentPrincipleID();
+        }
+        Date now = DateUtil.now();
+        mappingConfig.setModifier(userId);
+        mappingConfig.setGmtModified(now);
+        QueryWrapper<MappingConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", mappingConfig.getHospitalId())
+                .eq("type", mappingConfig.getType())
+                .eq("his_name", mappingConfig.getHisName())
+                .eq("concept_id", mappingConfig.getConceptId());
+        if (StringUtil.isBlank(mappingConfig.getHisDetailName())) {
+            queryWrapper.and(i -> i.isNull("his_detail_name")
+                    .or()
+                    .eq("his_detail_name", ""));
+        } else {
+            queryWrapper.eq("his_detail_name", mappingConfig.getHisDetailName());
+        }
+        MappingConfig oldRecord = this.getOne(queryWrapper, false);
+        if (mappingConfig.getId() == null
+                && oldRecord != null) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        if (mappingConfig.getId() != null
+                && oldRecord != null
+                && !mappingConfig.getId().equals(oldRecord.getId())) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该条关联已存在,无法保存");
+        }
+        //新增数据
+        if (mappingConfig.getId() == null) {
+            mappingConfig.setCreator(userId);
+            mappingConfig.setGmtCreate(now);
+        }
+        if (mappingConfig.getIsDeleted() == null) {
+            mappingConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+        }
+
+        //删除未匹配的关系
+        QueryWrapper<MappingConfig> qwUnMaptch = new QueryWrapper<>();
+        qwUnMaptch.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", mappingConfig.getHospitalId())
+                .eq("type", mappingConfig.getType())
+                .eq("his_name", mappingConfig.getHisName())
+                .eq("concept_id", null);
+        if (StringUtil.isBlank(mappingConfig.getHisDetailName())) {
+            qwUnMaptch.and(i -> i.isNull("his_detail_name")
+                    .or()
+                    .eq("his_detail_name", ""));
+        } else {
+            qwUnMaptch.eq("his_detail_name", mappingConfig.getHisDetailName());
+        }
+        this.remove(qwUnMaptch);
+
+        this.saveOrUpdate(mappingConfig);
+        return true;
+    }
+
+
     /**
      * 根据医院名称分组-返回id
      *
@@ -673,4 +1196,45 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
         }
         return retMap;
     }
+
+    /**
+     * 返回结果添加标准术语,药品剂型
+     *
+     * @param list
+     * @return
+     */
+    public List<MappingConfigWrapper> addNames(List<MappingConfigWrapper> list) {
+        if (ListUtil.isEmpty(list)) {
+            return list;
+        }
+
+        List<Long> ids = Lists.newArrayList();
+        ids.addAll(list.stream()
+                .filter(i -> i.getConceptId() != null)
+                .map(MappingConfigWrapper::getConceptId)
+                .collect(Collectors.toList()));
+        ids.addAll(list.stream()
+                .filter(i -> i.getFormConceptId() != null)
+                .map(MappingConfigWrapper::getFormConceptId)
+                .collect(Collectors.toList()));
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setSource(-1);
+        conceptVO.setIds(ids);
+        RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        if (RespDTOUtil.respIsOK(respDTO)) {
+            Map<Long, IndexBatchDTO> conceptMap
+                    = respDTO.data.stream().collect(Collectors.toMap(IndexBatchDTO::getId, v -> v));
+            for (MappingConfigWrapper record : list) {
+                if (record.getConceptId() != null && conceptMap.containsKey(record.getConceptId())) {
+                    record.setUniqueName(conceptMap.get(record.getConceptId()).getName());
+                    record.setCode(conceptMap.get(record.getConceptId()).getCode());
+                }
+                if (record.getFormConceptId() != null && conceptMap.containsKey(record.getFormConceptId())) {
+                    record.setForm(conceptMap.get(record.getFormConceptId()).getName());
+                }
+            }
+        }
+        return list;
+    }
 }

+ 19 - 0
src/main/java/com/diagbot/vo/MappingConfigVO.java

@@ -0,0 +1,19 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/6/17 10:30
+ */
+@Getter
+@Setter
+public class MappingConfigVO {
+    private Long hospitalId;
+    @NotNull(message = "请输入术语类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医诊断、13-中医证候、14-麻醉")
+    private Integer type;
+}

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

@@ -3,12 +3,17 @@ package com.diagbot.web;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.MappingConfig;
 import com.diagbot.entity.wrapper.MappingConfigWrapper;
 import com.diagbot.facade.MappingConfigFacade;
+import com.diagbot.vo.IdListVO;
+import com.diagbot.vo.IdVO;
 import com.diagbot.vo.MappingConfigPageVO;
+import com.diagbot.vo.MappingConfigVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -32,12 +37,47 @@ public class MappingConfigController {
     @Autowired
     private MappingConfigFacade mappingConfigFacade;
 
-    /**
-     * 分页查询
-     *
-     * @param mappingConfigPageVO
-     * @return
-     */
+
+    @ApiOperation(value = "数据导入模板导出[by:zhaops]",
+            notes = "")
+    @PostMapping("/exportExcelModule")
+    @SysLogger("exportExcelModule")
+    public void exportExcelModule(HttpServletResponse response, @RequestBody @Valid MappingConfigVO mappingConfigVO) {
+        mappingConfigFacade.exportExcelModule(response, mappingConfigVO);
+    }
+
+
+    @ApiOperation(value = "预匹配[by:zhaops]", notes = "")
+    @PostMapping("/precDataMatch")
+    @SysLogger("precDataMatch")
+    public void precDataMatch(@RequestParam("file") MultipartFile file,
+                              HttpServletResponse response,
+                              @RequestParam("type") Integer type) {
+        mappingConfigFacade.precDataMatch(file, type, response);
+    }
+
+
+    @ApiOperation(value = "数据导入[by:zhaops]",
+            notes = "")
+    @PostMapping("/importExcel")
+    @SysLogger("importExcel")
+    @Transactional
+    public void importExcel(@RequestParam("file") MultipartFile file,
+                            @RequestParam("hospitalId") Long hospitalId,
+                            @RequestParam("type") Integer type,
+                            @RequestParam("uesrId") String userId) {
+        mappingConfigFacade.importExcel(file, hospitalId, type, userId);
+    }
+
+
+    @ApiOperation(value = "数据导出[by:zhaops]",
+            notes = "")
+    @PostMapping("/exportExcel")
+    @SysLogger("exportExcel")
+    public void exportExcel(HttpServletResponse response, @RequestBody @Valid MappingConfigVO mappingConfigVO) {
+        mappingConfigFacade.exportExcel(response, mappingConfigVO);
+    }
+
     @ApiOperation(value = "分页查询[by:zhaops]", notes = "")
     @PostMapping("/getPage")
     @SysLogger("getPage")
@@ -46,18 +86,48 @@ public class MappingConfigController {
         return RespDTO.onSuc(data);
     }
 
-    /**
-     * 预匹配
-     *
-     * @param file
-     * @param response
-     * @param type
-     * @return
-     */
-    @ApiOperation(value = "预匹配[by:zhaops]", notes = "")
-    @PostMapping("/precDataMatch")
-    @SysLogger("precDataMatch")
-    public void precDataMatch(@RequestParam("file") MultipartFile file, HttpServletResponse response, @RequestParam("type") Integer type) {
-        mappingConfigFacade.precDataMatch(file, type, response);
+
+    @ApiOperation(value = "获取映射关系[by:zhaops]", notes = "")
+    @PostMapping("/getRecord")
+    @SysLogger("getRecord")
+    @Transactional
+    public RespDTO<MappingConfigWrapper> getRecord(@RequestBody @Valid IdVO idVO) {
+        MappingConfigWrapper data = mappingConfigFacade.getRecord(idVO);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "映射关系是否已存在[by:zhaops]", notes = "")
+    @PostMapping("/isExistRecord")
+    @SysLogger("isExistRecord")
+    public RespDTO<Boolean> isExistRecord(@RequestBody @Valid MappingConfig mappingConfig) {
+        Boolean data = mappingConfigFacade.isExistRecord(mappingConfig);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "保存或修改映射关系[by:zhaops]", notes = "")
+    @PostMapping("/saveOrUpdateRecord")
+    @SysLogger("saveOrUpdateRecord")
+    @Transactional
+    public RespDTO<Boolean> saveOrUpdateRecord(@RequestBody @Valid MappingConfig mappingConfig) {
+        Boolean data = mappingConfigFacade.saveOrUpdateRecord(mappingConfig);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "删除映射关系[by:zhaops]", notes = "")
+    @PostMapping("/deleteRecord")
+    @SysLogger("deleteRecord")
+    @Transactional
+    public RespDTO<Boolean> deleteRecord(@RequestBody @Valid IdVO idVO) {
+        Boolean data = mappingConfigFacade.deleteRecord(idVO);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "批量删除映射关系[by:zhaops]", notes = "")
+    @PostMapping("/deleteRecords")
+    @SysLogger("deleteRecords")
+    @Transactional
+    public RespDTO<Boolean> deleteRecords(@RequestBody @Valid IdListVO idListVO) {
+        Boolean data = mappingConfigFacade.deleteRecords(idListVO);
+        return RespDTO.onSuc(data);
     }
 }