Преглед изворни кода

Merge branch 'dev' of http://192.168.2.236:10080/louhr/qc into dev

louhr пре 5 година
родитељ
комит
73f901d72b

+ 4 - 1
kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java

@@ -5,6 +5,7 @@ import com.lantone.qc.kernel.client.CRFServiceClient;
 import com.lantone.qc.kernel.client.SimilarityServiceClient;
 import com.lantone.qc.kernel.structure.ai.AIAnalyze;
 import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.kernel.util.RedisUtil;
 import com.lantone.qc.pub.exception.AIException;
 import com.lantone.qc.pub.exception.CatalogueException;
 import com.lantone.qc.pub.model.InputInfo;
@@ -26,11 +27,13 @@ import java.util.Map;
 public class QCAnalysis {
     @Autowired
     CRFServiceClient crfServiceClient;
-
+    @Autowired
+    private RedisUtil redisUtil;
     @Autowired
     SimilarityServiceClient similarityServiceClient;
 
     public OutputInfo anlysis(QueryVo queryVo) throws AIException, CatalogueException, Exception {
+        redisUtil.getHospitalIdThreadLocal().set(queryVo.getHospitalId());
         OutputInfo outputInfo = new OutputInfo();
         InputInfo inputInfo = TransDispatch.trans(queryVo);
         inputInfo.setInputCatalogueMap(queryVo.getInputCatalogueMap());

+ 139 - 106
kernel/src/main/java/com/lantone/qc/kernel/util/CacheUtil.java

@@ -1,27 +1,23 @@
 package com.lantone.qc.kernel.util;
 
-
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.lantone.qc.nlp.participle.cfg.Configuration;
 import com.lantone.qc.nlp.participle.cfg.DefaultConfig;
 import com.lantone.qc.pub.util.FastJsonUtils;
-import com.lantone.qc.pub.util.FileUtil;
+import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.comsis.ModuleMappingUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.stereotype.Component;
-import org.springframework.util.ResourceUtils;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -37,43 +33,51 @@ import java.util.Set;
  * @Author : 楼辉荣
  * @Date: 2020-03-11 11:42
  */
+@Slf4j
 @Component
 public class CacheUtil implements ApplicationRunner {
-    Logger logger = LoggerFactory.getLogger(DefaultConfig.class);
+    private Configuration configuration = new DefaultConfig();
     @Autowired
     private RedisUtil redisUtil;
-
     @Value("${qc.hospital_id}")
-    private String hospitalId;
+    private String hospitalIds;
 
     public void run(ApplicationArguments var1) {
-        try {
-            this.loadModuleMappingInfo();//加载页面模板映射信息
-            this.putConceptDiagPropertyMap();//疾病相关信息放入缓存 包括疾病是否是慢病、传染病、常见症状、同义词
-            this.putHospitalDiagMap();//医院疾病信息
-            this.putHospitalDiagHuaZMap();//医院华卓映射
-            this.putLantoneDiagHuaZMap();//朗通华卓映射
-            this.putClinicBodyPartMap();//症状需要部位描述词典放入redis缓存
-            this.putHospitalDoctorInfoMap();//症状需要部位描述词典放入redis缓存
-        } catch (Exception e) {
-            logger.error("缓存文件读取错误。。。");
+        if (StringUtil.isBlank(hospitalIds)) {
+            return;
         }
+        for (String i : hospitalIds.split(",")) {
+            if (StringUtil.isBlank(i)) {
+                continue;
+            }
+            redisUtil.getHospitalCache().put(i, Maps.newHashMap());
+            this.loadModuleMappingInfo(i);//加载页面模板映射信息
+            this.putConceptDiagPropertyMap(i);//疾病相关信息放入缓存 包括疾病是否是慢病、传染病、常见症状、同义词
+            this.putHospitalDiagMap(i);//医院疾病信息
+            this.putHospitalDiagHuaZMap(i);//医院华卓映射
+            this.putLantoneDiagHuaZMap(i);//朗通华卓映射
+            this.putClinicBodyPartMap(i);//症状需要部位描述词典放入redis缓存
+            this.putHospitalDoctorInfoMap(i);//症状需要部位描述词典放入redis缓存
+        }
+        log.info("缓存加载完成!");
     }
 
     /**
      * 加载页面模板映射信息
+     *
+     * @param hospitalId
      */
-    private void loadModuleMappingInfo() {
+    private void loadModuleMappingInfo(String hospitalId) {
         List<String> xmlDataTypeHospitalIds = Lists.newArrayList("1", "3");
         try {
             InputStream stream = getClass().getClassLoader().getResourceAsStream("cache/" + hospitalId + "/module_mapping.json");
-            File targetFile = new File("module_mapping.json");
+            File targetFile = new File("cache/" + hospitalId + "/module_mapping.json");
             FileUtils.copyInputStreamToFile(stream, targetFile);
             String mappingMsg = FileUtils.readFileToString(targetFile);
-//            logger.error("模板数据:"+mappingMsg);
+            //            logger.error("模板数据:"+mappingMsg);
 
-//            String path = ResourceUtils.getURL("classpath:").getPath() + "cache/" + hospitalId + "/module_mapping.json";
-//            String mappingMsg = FileUtil.fileRead(path);
+            //            String path = ResourceUtils.getURL("classpath:").getPath() + "cache/" + hospitalId + "/module_mapping.json";
+            //            String mappingMsg = FileUtil.fileRead(path);
             if (xmlDataTypeHospitalIds.contains(hospitalId)) {
                 Map<String, Long> mapKeysModuleInfoIdMap = (Map) FastJsonUtils.getJsonToMap(mappingMsg);
                 Map<Set<String>, String> xmlDataTypeModuleInfo = Maps.newHashMap();
@@ -88,131 +92,160 @@ public class CacheUtil implements ApplicationRunner {
                     });
                     xmlDataTypeModuleInfo.put(Sets.newLinkedHashSet(list), entry.getValue() + "");
                 }
-//                mapKeysModuleInfoIdMap.keySet().forEach(mapKeys -> {
-//                    xmlDataTypeModuleInfo.put(Sets.newLinkedHashSet(Arrays.asList(mapKeys.split(","))), mapKeysModuleInfoIdMap.get(mapKeys) + "");
-//                });
-                ModuleMappingUtil.xmlDataTypeModuleInfo = xmlDataTypeModuleInfo;
+                //                mapKeysModuleInfoIdMap.keySet().forEach(mapKeys -> {
+                //                    xmlDataTypeModuleInfo.put(Sets.newLinkedHashSet(Arrays.asList(mapKeys.split(","))), mapKeysModuleInfoIdMap.get(mapKeys) + "");
+                //                });
+                ModuleMappingUtil.xmlDataTypeModuleInfo.put(hospitalId, xmlDataTypeModuleInfo);
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
         }
     }
 
     /**
      * 疾病相关信息放入缓存
      * 包括疾病是否是慢病、传染病、常见症状、同义词
+     *
+     * @param hospitalId
      */
-    public void putConceptDiagPropertyMap() throws Exception {
-        Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_diag_properties.dict");
-
-        Map<String, Map<String, Object>> diagMap = new HashMap<>();
-        for (String line : lines) {
-            String[] line_arr = line.split("\\|", -1);
-            if (line_arr.length == 5) {
-                List<String> synonymsList = new ArrayList<>();
-                List<String> symptomsList = new ArrayList<>();
-                if (StringUtils.isNotEmpty(line_arr[3])) {
-                    line_arr[3] = line_arr[3].trim();
-                    synonymsList = java.util.Arrays.asList(line_arr[3].split(","));
-                }
-                if (StringUtils.isNotEmpty(line_arr[4])) {
-                    line_arr[4] = line_arr[4].trim();
-                    symptomsList = java.util.Arrays.asList(line_arr[4].split(","));
+    public void putConceptDiagPropertyMap(String hospitalId) {
+        try {
+            List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_diag_properties.dict");
+
+            Map<String, Map<String, Object>> diagMap = new HashMap<>();
+            for (String line : lines) {
+                String[] line_arr = line.split("\\|", -1);
+                if (line_arr.length == 5) {
+                    List<String> synonymsList = new ArrayList<>();
+                    List<String> symptomsList = new ArrayList<>();
+                    if (StringUtils.isNotEmpty(line_arr[3])) {
+                        line_arr[3] = line_arr[3].trim();
+                        synonymsList = java.util.Arrays.asList(line_arr[3].split(","));
+                    }
+                    if (StringUtils.isNotEmpty(line_arr[4])) {
+                        line_arr[4] = line_arr[4].trim();
+                        symptomsList = java.util.Arrays.asList(line_arr[4].split(","));
+                    }
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("infectious", line_arr[2].trim());
+                    map.put("chronic", line_arr[1].trim());
+                    map.put("synonyms", synonymsList);
+                    map.put("symptoms", symptomsList);
+                    diagMap.put(line_arr[0], map);
                 }
-                Map<String, Object> map = new HashMap<>();
-                map.put("infectious", line_arr[2].trim());
-                map.put("chronic", line_arr[1].trim());
-                map.put("synonyms", synonymsList);
-                map.put("symptoms", symptomsList);
-                diagMap.put(line_arr[0], map);
             }
+            redisUtil.setValByHospitalId(hospitalId, KernelConstants.CONCEPT_DIAG_PROPERTY_MAP, diagMap);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
         }
-        redisUtil.setJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP, diagMap);
     }
 
     /**
      * 医院医生信息
      *
-     * @throws Exception
+     * @param hospitalId
      */
-    public void putHospitalDoctorInfoMap() throws Exception {
-        Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_doctor_info.dict");
-
-        Map<String, Map<String, Object>> hospitalDoctorMap = new HashMap<>();
-        for (String line : lines) {
-            String[] line_arr = line.split("\\|", -1);
-            if (line_arr.length == 4) {
-                Map<String, Object> map = new HashMap<>();
-                map.put("doctorName", line_arr[0]);
-                map.put("deptName", line_arr[1]);
-                map.put("professor", line_arr[2]);
-                map.put("occup", line_arr[3]);
-                hospitalDoctorMap.put(line_arr[0], map);
+    public void putHospitalDoctorInfoMap(String hospitalId) {
+        try {
+            List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_doctor_info.dict");
+
+            Map<String, Map<String, Object>> hospitalDoctorMap = new HashMap<>();
+            for (String line : lines) {
+                String[] line_arr = line.split("\\|", -1);
+                if (line_arr.length == 4) {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("doctorName", line_arr[0]);
+                    map.put("deptName", line_arr[1]);
+                    map.put("professor", line_arr[2]);
+                    map.put("occup", line_arr[3]);
+                    hospitalDoctorMap.put(line_arr[0], map);
+                }
             }
+            redisUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DOCTOR_MAP, hospitalDoctorMap);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
         }
-        redisUtil.setJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP, hospitalDoctorMap);
     }
 
     /**
      * 医院疾病信息放入redis缓存
+     *
+     * @param hospitalId
      */
-    public void putHospitalDiagMap() throws Exception {
-        Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
-        Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
-        for (String line : lines) {
-            Map<String, String> detail = new HashMap<>();
-            detail.put("name", line.trim());
-            detail.put("icd10", "A001");
-            hospitalDiagMap.put(line, detail);
+    public void putHospitalDiagMap(String hospitalId) {
+        try {
+            List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
+            Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
+            for (String line : lines) {
+                Map<String, String> detail = new HashMap<>();
+                detail.put("name", line.trim());
+                detail.put("icd10", "A001");
+                hospitalDiagMap.put(line, detail);
+            }
+            redisUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DIAG_MAP, hospitalDiagMap);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
         }
-        redisUtil.setJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP, hospitalDiagMap);
     }
 
     /**
      * 医院和华卓映射疾病信息放入redis缓存
+     *
+     * @param hospitalId
      */
-    public void putHospitalDiagHuaZMap() throws Exception {
-        Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
-        Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
-        for (String line : lines) {
-            Map<String, String> detail = new HashMap<>();
-            detail.put("name", line.trim());
-            detail.put("icd10", "A001");
-            hospitalDiagMap.put(line, detail);
+    public void putHospitalDiagHuaZMap(String hospitalId) {
+        try {
+            List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
+            Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
+            for (String line : lines) {
+                Map<String, String> detail = new HashMap<>();
+                detail.put("name", line.trim());
+                detail.put("icd10", "A001");
+                hospitalDiagMap.put(line, detail);
+            }
+            redisUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DIAG_HUAZ_MAP, hospitalDiagMap);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
         }
-        redisUtil.setJsonStringValue(KernelConstants.HOSPITAL_DIAG_HUAZ_MAP, hospitalDiagMap);
     }
 
     /**
      * 医院和华卓映射疾病信息放入redis缓存
+     *
+     * @param hospitalId
      */
-    public void putLantoneDiagHuaZMap() throws Exception {
-        Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
-        Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
-        for (String line : lines) {
-            Map<String, String> detail = new HashMap<>();
-            detail.put("name", line.trim());
-            detail.put("icd10", "A001");
-            hospitalDiagMap.put(line, detail);
+    public void putLantoneDiagHuaZMap(String hospitalId) {
+        try {
+            List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
+            Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
+            for (String line : lines) {
+                Map<String, String> detail = new HashMap<>();
+                detail.put("name", line.trim());
+                detail.put("icd10", "A001");
+                hospitalDiagMap.put(line, detail);
+            }
+            redisUtil.setValByHospitalId(hospitalId, KernelConstants.LANTONE_DIAG_HUAZ_MAP, hospitalDiagMap);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
         }
-        redisUtil.setJsonStringValue(KernelConstants.LANTONE_DIAG_HUAZ_MAP, hospitalDiagMap);
     }
 
     /**
      * 症状需要部位描述词典放入redis缓存
+     *
+     * @param hospitalId
      */
-    public void putClinicBodyPartMap() throws Exception {
-        Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_clinic_bodypart_properties.dict");
-        List<String> clinicBodyPartList = new ArrayList<>();
-        for (String line : lines) {
-            clinicBodyPartList.add(line);
+    public void putClinicBodyPartMap(String hospitalId) {
+        try {
+            List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_clinic_bodypart_properties.dict");
+            List<String> clinicBodyPartList = new ArrayList<>();
+            for (String line : lines) {
+                clinicBodyPartList.add(line);
+            }
+            redisUtil.setValByHospitalId(hospitalId, KernelConstants.CONCEPT_CLINIC_BODYPART_PROPERTIES_LIST, clinicBodyPartList);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
         }
-        redisUtil.setJsonStringValue(KernelConstants.CONCEPT_CLINIC_BODYPART_PROPERTIES_LIST, clinicBodyPartList);
     }
+
 }

+ 25 - 586
kernel/src/main/java/com/lantone/qc/kernel/util/RedisUtil.java

@@ -1,16 +1,10 @@
 package com.lantone.qc.kernel.util;
 
-import com.lantone.qc.pub.util.FastJsonUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
+import com.google.common.collect.Maps;
+import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
 
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
 
 /**
  * @Description:
@@ -19,600 +13,45 @@ import java.util.concurrent.TimeUnit;
  */
 @Component
 public final class RedisUtil {
+    private final Map<String, Map<String, Object>> hospitalCache = Maps.newHashMap();
+    private final ThreadLocal<String> hospitalIdThreadLocal = new ThreadLocal<>();
 
-    @Autowired
-    private RedisTemplate<String, Object> redisTemplate;
-
-    public static Map<String, Object> static_map = new HashMap<>();
-
-    // =============================common============================
-
-    /**
-     * 指定缓存失效时间
-     *
-     * @param key  键
-     * @param time 时间(秒)
-     * @return
-     */
-    private boolean expire(String key, long time) {
-        try {
-            if (time > 0) {
-                redisTemplate.expire(key, time, TimeUnit.SECONDS);
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 根据key 获取过期时间
-     *
-     * @param key 键 不能为null
-     * @return 时间(秒) 返回0代表为永久有效
-     */
-    private long getExpire(String key) {
-        return redisTemplate.getExpire(key, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 判断key是否存在
-     *
-     * @param key 键
-     * @return true 存在 false不存在
-     */
-    private boolean hasKey(String key) {
-        try {
-            return redisTemplate.hasKey(key);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 删除缓存
-     *
-     * @param key 可以传一个值 或多个
-     */
-    @SuppressWarnings("unchecked")
-    private void del(String... key) {
-        if (key != null && key.length > 0) {
-            if (key.length == 1) {
-                redisTemplate.delete(key[0]);
-            } else {
-                redisTemplate.delete(CollectionUtils.arrayToList(key));
-            }
-        }
-    }
-
-    // ============================String=============================
-
-    /**
-     * 普通缓存获取
-     *
-     * @param key 键
-     * @return 值
-     */
-    public Object get(String key) {
-        return key == null ? null : redisTemplate.opsForValue().get(key);
-    }
-
-    /**
-     * 普通缓存放入
-     *
-     * @param key   键
-     * @param value 值
-     * @return true成功 false失败
-     */
-    public boolean set(String key, Object value) {
-        try {
-            redisTemplate.opsForValue().set(key, value);
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-
-    }
-
-    /**
-     * 普通缓存放入并设置时间
-     *
-     * @param key   键
-     * @param value 值
-     * @param time  时间(秒) time要大于0 如果time小于等于0 将设置无限期
-     * @return true成功 false 失败
-     */
-    public boolean set(String key, Object value, long time) {
-        try {
-            if (time > 0) {
-                redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
-            } else {
-                set(key, value);
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 递增
-     *
-     * @param key   键
-     * @param delta 要增加几(大于0)
-     * @return
-     */
-    private long incr(String key, long delta) {
-        if (delta < 0) {
-            throw new RuntimeException("递增因子必须大于0");
-        }
-        return redisTemplate.opsForValue().increment(key, delta);
-    }
-
-    /**
-     * 递减
-     *
-     * @param key   键
-     * @param delta 要减少几(小于0)
-     * @return
-     */
-    private long decr(String key, long delta) {
-        if (delta < 0) {
-            throw new RuntimeException("递减因子必须大于0");
-        }
-        return redisTemplate.opsForValue().increment(key, -delta);
-    }
-
-    // ================================Map=================================
-
-    /**
-     * HashGet
-     *
-     * @param key  键 不能为null
-     * @param item 项 不能为null
-     * @return 值
-     */
-    private Object hget(String key, String item) {
-        return redisTemplate.opsForHash().get(key, item);
-    }
-
-    /**
-     * 获取hashKey对应的所有键值
-     *
-     * @param key 键
-     * @return 对应的多个键值
-     */
-    private Map<Object, Object> hmget(String key) {
-        return redisTemplate.opsForHash().entries(key);
-    }
-
-    /**
-     * HashSet
-     *
-     * @param key 键
-     * @param map 对应多个键值
-     * @return true 成功 false 失败
-     */
-    private boolean hmset(String key, Map<String, Object> map) {
-        try {
-            redisTemplate.opsForHash().putAll(key, map);
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * HashSet 并设置时间
-     *
-     * @param key  键
-     * @param map  对应多个键值
-     * @param time 时间(秒)
-     * @return true成功 false失败
-     */
-    private boolean hmset(String key, Map<String, Object> map, long time) {
-        try {
-            redisTemplate.opsForHash().putAll(key, map);
-            if (time > 0) {
-                expire(key, time);
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 向一张hash表中放入数据,如果不存在将创建
-     *
-     * @param key   键
-     * @param item  项
-     * @param value 值
-     * @return true 成功 false失败
-     */
-    private boolean hset(String key, String item, Object value) {
-        try {
-            redisTemplate.opsForHash().put(key, item, value);
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 向一张hash表中放入数据,如果不存在将创建
-     *
-     * @param key   键
-     * @param item  项
-     * @param value 值
-     * @param time  时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
-     * @return true 成功 false失败
-     */
-    private boolean hset(String key, String item, Object value, long time) {
-        try {
-            redisTemplate.opsForHash().put(key, item, value);
-            if (time > 0) {
-                expire(key, time);
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 删除hash表中的值
-     *
-     * @param key  键 不能为null
-     * @param item 项 可以使多个 不能为null
-     */
-    private void hdel(String key, Object... item) {
-        redisTemplate.opsForHash().delete(key, item);
-    }
-
-    /**
-     * 判断hash表中是否有该项的值
-     *
-     * @param key  键 不能为null
-     * @param item 项 不能为null
-     * @return true 存在 false不存在
-     */
-    private boolean hHasKey(String key, String item) {
-        return redisTemplate.opsForHash().hasKey(key, item);
-    }
-
-    /**
-     * hash递增 如果不存在,就会创建一个 并把新增后的值返回
-     *
-     * @param key  键
-     * @param item 项
-     * @param by   要增加几(大于0)
-     * @return
-     */
-    private double hincr(String key, String item, double by) {
-        return redisTemplate.opsForHash().increment(key, item, by);
-    }
-
-    /**
-     * hash递减
-     *
-     * @param key  键
-     * @param item 项
-     * @param by   要减少记(小于0)
-     * @return
-     */
-    private double hdecr(String key, String item, double by) {
-        return redisTemplate.opsForHash().increment(key, item, -by);
-    }
-
-    // ============================set=============================
-
-    /**
-     * 根据key获取Set中的所有值
-     *
-     * @param key 键
-     * @return
-     */
-    private Set<Object> sGet(String key) {
-        try {
-            return redisTemplate.opsForSet().members(key);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-
-    /**
-     * 根据value从一个set中查询,是否存在
-     *
-     * @param key   键
-     * @param value 值
-     * @return true 存在 false不存在
-     */
-    private boolean sHasKey(String key, Object value) {
-        try {
-            return redisTemplate.opsForSet().isMember(key, value);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 将数据放入set缓存
-     *
-     * @param key    键
-     * @param values 值 可以是多个
-     * @return 成功个数
-     */
-    private long sSet(String key, Object... values) {
-        try {
-            return redisTemplate.opsForSet().add(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return 0;
-        }
-    }
-
-    /**
-     * 将set数据放入缓存
-     *
-     * @param key    键
-     * @param time   时间(秒)
-     * @param values 值 可以是多个
-     * @return 成功个数
-     */
-    private long sSetAndTime(String key, long time, Object... values) {
-        try {
-            Long count = redisTemplate.opsForSet().add(key, values);
-            if (time > 0) {
-                expire(key, time);
-            }
-            return count;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return 0;
-        }
-    }
-
-    /**
-     * 获取set缓存的长度
-     *
-     * @param key 键
-     * @return
-     */
-    private long sGetSetSize(String key) {
-        try {
-            return redisTemplate.opsForSet().size(key);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return 0;
-        }
-    }
-
-    /**
-     * 移除值为value的
-     *
-     * @param key    键
-     * @param values 值 可以是多个
-     * @return 移除的个数
-     */
-    private long setRemove(String key, Object... values) {
-        try {
-            Long count = redisTemplate.opsForSet().remove(key, values);
-            return count;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return 0;
-        }
+    public <T> T getJsonStringValue(String key) {
+        return getValByHospitalId(hospitalIdThreadLocal.get(), key);
     }
-    // ===============================list=================================
 
-    /**
-     * 获取list缓存的内容
-     *
-     * @param key   键
-     * @param start 开始
-     * @param end   结束 0 到 -1代表所有值
-     * @return
-     */
-    private List<Object> lGet(String key, long start, long end) {
-        try {
-            return redisTemplate.opsForList().range(key, start, end);
-        } catch (Exception e) {
-            e.printStackTrace();
+    public <T> T getValByHospitalId(String hospitalId, String key) {
+        if (StringUtil.isBlank(hospitalId)) {
             return null;
         }
-    }
-
-    /**
-     * 获取list缓存的长度
-     *
-     * @param key 键
-     * @return
-     */
-    private long lGetListSize(String key) {
-        try {
-            return redisTemplate.opsForList().size(key);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return 0;
-        }
-    }
-
-    /**
-     * 通过索引 获取list中的值
-     *
-     * @param key   键
-     * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
-     * @return
-     */
-    private Object lGetIndex(String key, long index) {
-        try {
-            return redisTemplate.opsForList().index(key, index);
-        } catch (Exception e) {
-            e.printStackTrace();
+        Map<String, Object> map = hospitalCache.get(hospitalId);
+        if (map == null) {
             return null;
         }
+        return (T) map.get(key);
     }
 
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @return
-     */
-    private boolean lSet(String key, Object value) {
-        try {
-            redisTemplate.opsForList().rightPush(key, value);
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @param time  时间(秒)
-     * @return
-     */
-    private boolean lSet(String key, Object value, long time) {
-        try {
-            redisTemplate.opsForList().rightPush(key, value);
-            if (time > 0) {
-                expire(key, time);
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @return
-     */
-    private boolean lSet(String key, List<Object> value) {
-        try {
-            redisTemplate.opsForList().rightPushAll(key, value);
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @param time  时间(秒)
-     * @return
-     */
-    private boolean lSet(String key, List<Object> value, long time) {
-        try {
-            redisTemplate.opsForList().rightPushAll(key, value);
-            if (time > 0) {
-                expire(key, time);
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
+    public <T> void setJsonStringValue(String key, Object value) {
+        setValByHospitalId(hospitalIdThreadLocal.get(), key, value);
     }
 
-    /**
-     * 根据索引修改list中的某条数据
-     *
-     * @param key   键
-     * @param index 索引
-     * @param value 值
-     * @return
-     */
-    private boolean lUpdateIndex(String key, long index, Object value) {
-        try {
-            redisTemplate.opsForList().set(key, index, value);
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
+    public <T> void setValByHospitalId(String hospitalId, String key, Object value) {
+        if (StringUtil.isBlank(hospitalId)) {
+            return;
         }
-    }
-
-    /**
-     * 移除N个值为value
-     *
-     * @param key   键
-     * @param count 移除多少个
-     * @param value 值
-     * @return 移除的个数
-     */
-    private long lRemove(String key, long count, Object value) {
-        try {
-            Long remove = redisTemplate.opsForList().remove(key, count, value);
-            return remove;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return 0;
+        Map<String, Object> map = hospitalCache.get(hospitalId);
+        if (map == null) {
+            return;
         }
+        map.put(key, value);
     }
 
-    /**
-     * 获取---value为json字符串
-     *
-     * @param key
-     * @param <T>
-     * @return
-     */
-    public <T> T getJsonStringValue(String key) {
-        try {
-//            Object valObj = get(key);
-//            if (valObj != null && valObj.getClass().getName().indexOf("String") > -1) {
-//                return (T) FastJsonUtils.getJsonToBean(valObj.toString(), Object.class);
-//            }
-//            return null;
-            return (T)static_map.get(key);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return null;
-        }
+    public ThreadLocal<String> getHospitalIdThreadLocal() {
+        return hospitalIdThreadLocal;
     }
 
-    /**
-     * 插入---value为json字符串
-     *
-     * @param key
-     * @param value
-     */
-    public <T> void setJsonStringValue(String key, Object value) {
-        try {
-            static_map.put(key, value);
-//            set(key, FastJsonUtils.getBeanToJson(value));
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
+    public Map<String, Map<String, Object>> getHospitalCache() {
+        return hospitalCache;
     }
 
-
-}
-
+}

+ 1 - 1
kernel/src/main/resources/application.yml

@@ -25,7 +25,7 @@ spring:
         max-idle: 8
 
 qc:
-  hospital_id: 3
+  hospital_id: 1,3
 
 CRF:
   url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict

Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
kernel/src/main/resources/cache/1/module_mapping.json


+ 2 - 0
public/src/main/java/com/lantone/qc/pub/model/vo/QueryVo.java

@@ -23,4 +23,6 @@ public class QueryVo extends TokenVO {
 
     private String cid;
 
+    private String hospitalId;
+
 }

+ 2 - 0
trans/src/main/java/com/lantone/qc/trans/TransDispatch.java

@@ -2,6 +2,7 @@ package com.lantone.qc.trans;
 
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.vo.QueryVo;
+import com.lantone.qc.trans.comsis.ModuleMappingUtil;
 import lombok.extern.slf4j.Slf4j;
 
 /**
@@ -14,6 +15,7 @@ public class TransDispatch {
 
     public static InputInfo trans(QueryVo queryVo) {
         try {
+            ModuleMappingUtil.hospitalIdThreadLocal.set(queryVo.getHospitalId());
             String classPath = "com.lantone.qc.trans."
                     + queryVo.getCid()
                     + "."

+ 4 - 74
trans/src/main/java/com/lantone/qc/trans/changx/ChangxBeHospitalizedDocTrans.java

@@ -3,6 +3,7 @@ package com.lantone.qc.trans.changx;
 import com.google.common.collect.Lists;
 import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
 import com.lantone.qc.pub.model.vo.MedrecVo;
+import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.ModelDocTrans;
 import com.lantone.qc.trans.changx.util.CxXmlUtil;
 import com.lantone.qc.trans.comsis.ModelDocGenerate;
@@ -37,8 +38,10 @@ public class ChangxBeHospitalizedDocTrans extends ModelDocTrans {
                 + sourceMap.get("四肢脊柱检查") + "。"
                 + sourceMap.get("神经系统检查") + "。"
                 + sourceMap.get("其他说明") + "。";
-        sourceMap.put("体格检查(二)", tgjc);
         Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
+        if (StringUtil.isNotBlank(tgjc)) {
+            structureMap.put("专科体格检查", tgjc);
+        }
         BeHospitalizedDoc beHospitalizedDoc = ModelDocGenerate.beHospitalizedDocGen(structureMap);
         beHospitalizedDoc.setText(content);
         beHospitalizedDoc.setPageData((Map) sourceMap);
@@ -47,85 +50,12 @@ public class ChangxBeHospitalizedDocTrans extends ModelDocTrans {
 
     private List<String> keyContrasts = Lists.newArrayList(
             "姓名++++患者姓名=姓名",
-            "性别=",
-            "病区++++病区名称=",
-            "床号=",
-            "病案号++++住院号=",
-            "病人姓名++++患者姓名=",
-            "职业=",
-            "工作单位++++工作单位地址=",
-            "年龄=",
             "出生地++++出生地(住院)=出生地",
-            "出生日期=",
-            "户口地址=",
             "婚姻状况++++婚姻=婚姻",
             "联系电话=电话",
-            "民族=",
-            "入院日期=",
             "供史者++++病史叙述者=病史陈述者",
-            "记录日期=",
-            "主诉=",
-            "现病史=",
-            "既往史=",
-            "目前使用的药物=",
-            "成瘾药物=",
-            "个人史=",
-            "月经史=",
             "婚育史:=婚育史",
-            "家族史=",
-            "辅助检查=",
-            "体重指数++++体重指数(BMI)=",
-            "++++复选框=",
-            "营养风险评分=",
-            "请营养科会诊=",
-            "ADL评分分级=",
-            "康复科会诊++++康复科会诊1=",
-            "康复科会诊++++康复科会诊2=",
-            "++++心理评估1=",
-            "++++心理评估2=",
-            "++++心理卫生科会诊1=",
-            "++++心理卫生科会诊2=",
-            "Caprini评估++++=",
-            "出血风险=",
-            "初步诊断=",
-            "需求评估=",
-            "预期目标=",
-            "诊疗计划=",
-            "治疗监测计划=",
-            "签名++++=",
-            "签名时间=",
-            "补充诊断=",
-            "修正诊断=",
-            "签名时间++++补充诊断签名时间=",
-            "签名时间++++修正签名时间=",
-            "一般情况=",
-            "皮肤情况=",
-            "淋巴=",
-            "头部检查=",
-            "颈部=",
-            "胸部检查=",
-            "肺部检查=",
-            "心脏检查=",
-            "血管=",
-            "腹部检查=",
             "外生殖器++++外生殖器文本框=",
-            "直肠肛门=",
-            "四肢脊柱检查=",
-            "神经系统检查=",
-            "其他说明=",
-            "体格检查=",
-            "体格检查(二)=专科体格检查",
-            "++++复选框10=",
-            "小计++++=",
-            "++++复选框11=",
-            "其他风险因素=",
-            "++++复选框8=",
-            "类型++++VTE类型=",
-            "++++复选框9=",
-            "++++无需VTE预防=",
-            "其他++++抗凝药物禁忌其他=",
-            "++++物理预防复选框=",
-            "其他++++物理预防其他=",
             "职业++++首页职业新=职业"
     );
 

+ 15 - 33
trans/src/main/java/com/lantone/qc/trans/changx/ChangxDifficultCaseDiscussDocTrans.java

@@ -3,8 +3,11 @@ package com.lantone.qc.trans.changx;
 import com.google.common.collect.Lists;
 import com.lantone.qc.pub.model.doc.DifficultCaseDiscussDoc;
 import com.lantone.qc.pub.model.vo.MedrecVo;
+import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.ModelDocTrans;
+import com.lantone.qc.trans.changx.util.CxXmlUtil;
 import com.lantone.qc.trans.comsis.ModelDocGenerate;
+import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import com.lantone.qc.trans.comsis.Preproc;
 
 import java.util.List;
@@ -28,47 +31,24 @@ public class ChangxDifficultCaseDiscussDocTrans extends ModelDocTrans {
     }
 
     private DifficultCaseDiscussDoc getDifficultCaseDiscussDoc(String content) {
-        Map<String, String> pageData = Preproc.extract_doc_pub(true, pageDataTitles, content);
-        pageData.put("病程记录内容",
-                pageData.get("病程记录内容")
-                        .replace(pageData.get("病程记录时间"), "")
-                        .replace(pageData.get("病程记录名称"), "")
-        );
+        Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
 
-        List<String> targetTitles = Lists.newArrayList();
-        sourceTitles.forEach(sourceTitle -> {
-            String targetTitle = "";
-            for (int index = 0; index < sourceTitle.length(); index++) {
-                if (index == sourceTitle.length() - 1) {
-                    targetTitle += sourceTitle.substring(index, index + 1);
-                } else {
-                    targetTitle += sourceTitle.substring(index, index + 1) + "[\\s\\p{Zs}]*";
-                }
-            }
-            targetTitles.add(targetTitle);
-        });
-
-        Map<String, String> sourceMap = Preproc.extract_doc_pub(true, targetTitles, content);
-        sourceMap.put("记录时间", sourceMap.get("病程记录时间"));
+        String text = CxXmlUtil.getTextByNodePath(content, "//DocObjContent/Region/Content_Text");
+        if (StringUtil.isBlank(text)) {
+            text = CxXmlUtil.getTextByNodePath(content, "//DocObjContent/Region");
+        }
+        Map<String, String> cutWordMap = Preproc.getCutWordMap(true, sourceTitles, text);
+        cutWordMap.putAll(structureMap);
 
-        DifficultCaseDiscussDoc difficultCaseDiscussDoc = ModelDocGenerate.difficultCaseDiscussDocGen(sourceMap);
+        DifficultCaseDiscussDoc difficultCaseDiscussDoc = ModelDocGenerate.difficultCaseDiscussDocGen(cutWordMap);
         difficultCaseDiscussDoc.setText(content);
-        difficultCaseDiscussDoc.setPageData((Map) pageData);
+        difficultCaseDiscussDoc.setPageData((Map) xmlNodeValueMap);
 
         return difficultCaseDiscussDoc;
     }
 
-    private List<String> pageDataTitles = Lists.newArrayList(
-            "病程记录时间",
-            "病程记录名称",
-            "病程记录内容",
-            "记录医师"
-    );
-
     private List<String> sourceTitles = Lists.newArrayList(
-            "病程记录时间",
-            "病程记录名称",
-            "病程记录内容",
             "记录时间",
             "记录医师",
             "入院时间",
@@ -82,4 +62,6 @@ public class ChangxDifficultCaseDiscussDocTrans extends ModelDocTrans {
             "结论"
     );
 
+    private List<String> keyContrasts = Lists.newArrayList();
+
 }

+ 55 - 26
trans/src/main/java/com/lantone/qc/trans/changx/ChangxDocTrans.java

@@ -21,7 +21,7 @@ public class ChangxDocTrans extends DocTrans {
     protected InputInfo extract(QueryVo queryVo) {
         InputInfo inputInfo = new InputInfo();
         for (MedrecVo i : queryVo.getMedrec()) {
-             if (i.getTitle().equals("会诊单")) {
+            if (i.getTitle().equals("会诊单")) {
                 ChangxConsultationDocTrans consultationDocTrans = new ChangxConsultationDocTrans();
                 inputInfo.setConsultationDocs(consultationDocTrans.extract(i));
             }
@@ -61,10 +61,10 @@ public class ChangxDocTrans extends DocTrans {
                 ChangxDeathRecordDocTrans deathRecordDocTrans = new ChangxDeathRecordDocTrans();
                 inputInfo.setDeathRecordDoc(deathRecordDocTrans.extract(i));
             }
-            //            if (i.getTitle().equals("疑难病例讨论记录")) {
-            //                ChangxDifficultCaseDiscussDocTrans difficultCaseDiscussDocTrans = new ChangxDifficultCaseDiscussDocTrans();
-            //                inputInfo.setDifficultCaseDiscussDocs(difficultCaseDiscussDocTrans.extract(i));
-            //            }
+            if (i.getTitle().equals("疑难病例讨论记录")) {
+                ChangxDifficultCaseDiscussDocTrans difficultCaseDiscussDocTrans = new ChangxDifficultCaseDiscussDocTrans();
+                inputInfo.setDifficultCaseDiscussDocs(difficultCaseDiscussDocTrans.extract(i));
+            }
             if (i.getTitle().equals("医嘱信息")) {
                 ChangxDoctorAdviceDocTrans doctorAdviceDocTrans = new ChangxDoctorAdviceDocTrans();
                 inputInfo.setDoctorAdviceDocs(doctorAdviceDocTrans.extract(i));
@@ -109,14 +109,18 @@ public class ChangxDocTrans extends DocTrans {
                 ChangxThreeLevelWardDocTrans threeLevelWardDocTrans = new ChangxThreeLevelWardDocTrans();
                 inputInfo.setThreeLevelWardDocs(threeLevelWardDocTrans.extract(i));
             }
-            if (i.getTitle().equals("知情同意书")) {
-                ChangxInformedConsentDocTrans informedConsentDocTrans = new ChangxInformedConsentDocTrans();
-                inputInfo.setInformedConsentDoc(informedConsentDocTrans.extract(i));
-            }
-            if (i.getTitle().equals("谈话告知书")) {
-                ChangxNoticeOfConversationDocTrans noticeOfConversationDocTrans = new ChangxNoticeOfConversationDocTrans();
-                inputInfo.setNoticeOfConversationDoc(noticeOfConversationDocTrans.extract(i));
+            if (i.getTitle().equals("病理检验送检单")) {
+                ChangxPathologyShipDocTrans pathologyShipDocTrans = new ChangxPathologyShipDocTrans();
+                inputInfo.setPathologyShipDocs(pathologyShipDocTrans.extract(i));
             }
+            //            if (i.getTitle().equals("知情同意书")) {
+            //                ChangxInformedConsentDocTrans informedConsentDocTrans = new ChangxInformedConsentDocTrans();
+            //                inputInfo.setInformedConsentDoc(informedConsentDocTrans.extract(i));
+            //            }
+            //            if (i.getTitle().equals("谈话告知书")) {
+            //                ChangxNoticeOfConversationDocTrans noticeOfConversationDocTrans = new ChangxNoticeOfConversationDocTrans();
+            //                inputInfo.setNoticeOfConversationDoc(noticeOfConversationDocTrans.extract(i));
+            //            }
         }
         pageDataHandle(inputInfo);
         return inputInfo;
@@ -154,12 +158,12 @@ public class ChangxDocTrans extends DocTrans {
         if (ListUtil.isNotEmpty(inputInfo.getCriticallyIllNoticeDocs())) {
             inputInfo.getPageData().put("病危通知书", inputInfo.getCriticallyIllNoticeDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
         }
-        //        if (ListUtil.isNotEmpty(inputInfo.getDifficultCaseDiscussDocs())) {
-        //            inputInfo.getPageData().put("疑难病例讨论记录", inputInfo.getDifficultCaseDiscussDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
-        //        }
-        if (ListUtil.isNotEmpty(inputInfo.getDoctorAdviceDocs())) {
-            inputInfo.getPageData().put("医嘱信息", inputInfo.getDoctorAdviceDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
+        if (ListUtil.isNotEmpty(inputInfo.getDifficultCaseDiscussDocs())) {
+            inputInfo.getPageData().put("疑难病例讨论记录", inputInfo.getDifficultCaseDiscussDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
         }
+        //        if (ListUtil.isNotEmpty(inputInfo.getDoctorAdviceDocs())) {
+        //            inputInfo.getPageData().put("医嘱信息", inputInfo.getDoctorAdviceDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
+        //        }
         //        if (ListUtil.isNotEmpty(inputInfo.getDutyShiftSystemDocs())) {
         //            inputInfo.getPageData().put("值班交接制度", inputInfo.getDutyShiftSystemDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
         //        }
@@ -173,7 +177,10 @@ public class ChangxDocTrans extends DocTrans {
             inputInfo.getPageData().put("阶段小结", inputInfo.getStagesSummaryDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
         }
         if (ListUtil.isNotEmpty(inputInfo.getThreeLevelWardDocs())) {
-            inputInfo.getPageData().put("查房记录", inputInfo.getThreeLevelWardDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
+            inputInfo.getPageData().put("查房记录", inputInfo.getThreeLevelWardDocs().get(0).getAllDoctorWradDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
+        }
+        if (ListUtil.isNotEmpty(inputInfo.getPathologyShipDocs())) {
+            inputInfo.getPageData().put("病理检验送检单", inputInfo.getPathologyShipDocs().stream().map(i -> i.getPageData()).collect(Collectors.toList()));
         }
 
         if (ListUtil.isNotEmpty(inputInfo.getConsultationDocs())) {
@@ -227,14 +234,14 @@ public class ChangxDocTrans extends DocTrans {
                             .map(operationDoc -> operationDoc.getPreoperativeDiscussionDoc().getPageData())
                             .collect(Collectors.toList())
             );
-            inputInfo.getPageData().put(
-                    "手术知情同意书",
-                    inputInfo.getOperationDocs()
-                            .stream()
-                            .filter(operationDoc -> operationDoc != null && operationDoc.getOperationInformedConsentDoc() != null)
-                            .map(operationDoc -> operationDoc.getOperationInformedConsentDoc().getPageData())
-                            .collect(Collectors.toList())
-            );
+            //            inputInfo.getPageData().put(
+            //                    "手术知情同意书",
+            //                    inputInfo.getOperationDocs()
+            //                            .stream()
+            //                            .filter(operationDoc -> operationDoc != null && operationDoc.getOperationInformedConsentDoc() != null)
+            //                            .map(operationDoc -> operationDoc.getOperationInformedConsentDoc().getPageData())
+            //                            .collect(Collectors.toList())
+            //            );
             inputInfo.getPageData().put(
                     "手术安全核查表",
                     inputInfo.getOperationDocs()
@@ -244,6 +251,28 @@ public class ChangxDocTrans extends DocTrans {
                             .collect(Collectors.toList())
             );
         }
+        if (inputInfo.getTransferRecordDocs() != null) {
+            if (ListUtil.isNotEmpty(inputInfo.getTransferRecordDocs().getTransferIntoDocs())) {
+                inputInfo.getPageData().put(
+                        "转入记录",
+                        inputInfo.getTransferRecordDocs().getTransferIntoDocs()
+                                .stream()
+                                .filter(i -> i != null)
+                                .map(i -> i.getPageData())
+                                .collect(Collectors.toList())
+                );
+            }
+            if (ListUtil.isNotEmpty(inputInfo.getTransferRecordDocs().getTransferOutDocs())) {
+                inputInfo.getPageData().put(
+                        "转出记录",
+                        inputInfo.getTransferRecordDocs().getTransferOutDocs()
+                                .stream()
+                                .filter(i -> i != null)
+                                .map(i -> i.getPageData())
+                                .collect(Collectors.toList())
+                );
+            }
+        }
     }
 
 }

+ 3 - 26
trans/src/main/java/com/lantone/qc/trans/changx/ChangxFirstCourseRecordDocTrans.java

@@ -8,6 +8,7 @@ import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.ModelDocTrans;
 import com.lantone.qc.trans.changx.util.CxXmlUtil;
 import com.lantone.qc.trans.comsis.ModelDocGenerate;
+import com.lantone.qc.trans.comsis.ModuleMappingUtil;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import com.lantone.qc.trans.comsis.Preproc;
 
@@ -34,6 +35,7 @@ public class ChangxFirstCourseRecordDocTrans extends ModelDocTrans {
         Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(cutWordMap, keyContrasts);
         FirstCourseRecordDoc firstCourseRecordDoc = ModelDocGenerate.firstCourseRecordDocGen(structureMap);
         firstCourseRecordDoc.setText(text);
+        xmlNodeValueMap.put("mode_id", ModuleMappingUtil.getXmlDataTypeModuleId(xmlNodeValueMap));
         firstCourseRecordDoc.setPageData((Map) xmlNodeValueMap);
         return firstCourseRecordDoc;
     }
@@ -72,32 +74,7 @@ public class ChangxFirstCourseRecordDocTrans extends ModelDocTrans {
 
     private List<String> keyContrasts = Lists.newArrayList(
             "记录日期=记录时间",
-            "姓名++++患者姓名=",
-            "性别=",
-            "年龄=",
-            "职业=",
-            "主诉=",
-            "入院日期=",
-            "现病史=",
-            "既往史=",
-            "体格检查=",
-            "辅助检查++++检查=",
-            "初步诊断=",
-            "体温=",
-            "脉搏++++第一次脉搏=",
-            "呼吸++++第一次呼吸=",
-            "血压++++第一次血压=",
-            "专科检查=",
-            "辅助检查=",
-            "鉴别诊断=",
-            "需求评估=",
-            "预期目标=",
-            "诊疗计划=",
-            "治疗监测计划=",
-            "签名++++=记录医师",
-            "签名时间=",
-            "诊断依据=",
-            "病例特点="
+            "签名++++=记录医师"
     );
 
 }

+ 42 - 0
trans/src/main/java/com/lantone/qc/trans/changx/ChangxPathologyShipDocTrans.java

@@ -0,0 +1,42 @@
+package com.lantone.qc.trans.changx;
+
+import com.google.common.collect.Lists;
+import com.lantone.qc.pub.model.doc.PathologyShipDoc;
+import com.lantone.qc.pub.model.vo.MedrecVo;
+import com.lantone.qc.trans.ModelDocTrans;
+import com.lantone.qc.trans.changx.util.CxXmlUtil;
+import com.lantone.qc.trans.comsis.OrdinaryAssistant;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName : PathologyShipDocTrans
+ * @Description : 病理检验送检单
+ * @Author : 楼辉荣
+ * @Date: 2020-04-19 17:49
+ */
+public class ChangxPathologyShipDocTrans extends ModelDocTrans {
+    @Override
+    public List<PathologyShipDoc> extract(MedrecVo medrecVo) {
+        List<PathologyShipDoc> retList = Lists.newArrayList();
+        List<String> contents = (List) medrecVo.getContent().get("content");
+        contents.forEach(content -> {
+            retList.add(getPathologyShipDoc(content));
+        });
+        return retList;
+    }
+
+    private PathologyShipDoc getPathologyShipDoc(String content) {
+        Map<String, String> sourceMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
+
+        PathologyShipDoc pathologyShipDoc = new PathologyShipDoc();
+        pathologyShipDoc.setStructureMap(structureMap);
+        pathologyShipDoc.setPageData((Map) structureMap);
+        return pathologyShipDoc;
+    }
+
+    private List<String> keyContrasts = Lists.newArrayList();
+
+}

+ 6 - 1
trans/src/main/java/com/lantone/qc/trans/changx/util/CxXmlUtil.java

@@ -23,7 +23,12 @@ public class CxXmlUtil {
             String helpTip, controlName, contentText, key;
             Element contentTextElement;
             Document doc = DocumentHelper.parseText(content);
-            Element rootElement = (Element) doc.selectNodes(nodePath).get(0);
+            Element rootElement = null;
+            if (doc.selectNodes("//DocObjContent//Region").size() == 0) {
+                rootElement = (Element) doc.selectNodes("//DocObjContent").get(0);
+            } else {
+                rootElement = (Element) doc.selectNodes("//DocObjContent//Region").get(0);
+            }
             List<Element> sonElements = rootElement.elements();
             for (Element sonElement : sonElements) {
                 helpTip = sonElement.attributeValue("HelpTip");

+ 5 - 10
trans/src/main/java/com/lantone/qc/trans/comsis/ModuleMappingUtil.java

@@ -17,10 +17,12 @@ import java.util.Set;
  */
 public class ModuleMappingUtil {
 
-    public static Map<Set<String>, String> xmlDataTypeModuleInfo = Maps.newLinkedHashMap();
+    public static final Map<String, Map<Set<String>, String>> xmlDataTypeModuleInfo = Maps.newHashMap();
+    public static final ThreadLocal<String> hospitalIdThreadLocal = new ThreadLocal<>();
 
     public static String getXmlDataTypeModuleId(Map<String, String> sourceMap) {
-        if (MapUtils.isEmpty(sourceMap)) {
+        if (MapUtils.isEmpty(sourceMap)
+                || MapUtils.isEmpty(xmlDataTypeModuleInfo.get(hospitalIdThreadLocal.get()))) {
             return null;
         }
         Set<String> set = sourceMap.keySet();
@@ -32,14 +34,7 @@ public class ModuleMappingUtil {
             }
         });
         set = Sets.newLinkedHashSet(list);
-        //                if (set.size() == 335) {
-        //                    System.out.println(" ");
-        //                    for (Map.Entry<Set<String>, String> entry : xmlDataTypeModuleInfo.entrySet()) {
-        //                        System.out.println(StringUtils.join(entry.getKey(), ","));
-        //                    }
-        //                    System.out.println(StringUtils.join(set, ","));
-        //                }
-        return xmlDataTypeModuleInfo.get(set);
+        return xmlDataTypeModuleInfo.get(hospitalIdThreadLocal.get()).get(set);
     }
 
 }

+ 1 - 0
trans/src/main/java/com/lantone/qc/trans/comsis/OrdinaryAssistant.java

@@ -21,6 +21,7 @@ public class OrdinaryAssistant {
         String modeId = ModuleMappingUtil.getXmlDataTypeModuleId(sourceMap);
         if (StringUtil.isNotBlank(modeId)) {
             retMap.put("mode_id", modeId);
+            sourceMap.put("mode_id", modeId);
         }
         Map<String, String> sourceMap_ = MapUtil.copyMap((Map) sourceMap);
         String[] arry = null;