소스 검색

Merge branch 'dev-1.2' into dev

rengb 5 년 전
부모
커밋
028fe1799f
35개의 변경된 파일815개의 추가작업 그리고 131개의 파일을 삭제
  1. 10 0
      dbanaly/pom.xml
  2. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/web/config/RedisConfig.java
  3. 4 4
      dbanaly/src/main/java/com/lantone/qc/dbanaly/lt/facade/ModelHospitalFacade.java
  4. 639 28
      dbanaly/src/main/java/com/lantone/qc/dbanaly/util/RedisUtil.java
  5. 57 0
      dbanaly/src/main/java/com/lantone/qc/dbanaly/util/SpecialStorageUtil.java
  6. 12 0
      dbanaly/src/main/resources/application-db.yml
  7. 0 4
      kernel/pom.xml
  8. 4 3
      kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java
  9. 4 4
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0002.java
  10. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0011.java
  11. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0012.java
  12. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0015.java
  13. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0019.java
  14. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0494.java
  15. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/deathrecord/DEAR0338.java
  16. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC0096.java
  17. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0147.java
  18. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0508.java
  19. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0094.java
  20. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0128.java
  21. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java
  22. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/FirstCourseRecordAI.java
  23. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/LeaveHospitalAI.java
  24. 20 7
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/ModelAI.java
  25. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/OperationAI.java
  26. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/ThreeLevelWardAI.java
  27. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcess.java
  28. 9 9
      kernel/src/main/java/com/lantone/qc/kernel/util/CacheUtil.java
  29. 5 5
      kernel/src/main/java/com/lantone/qc/kernel/util/CatalogueUtil.java
  30. 4 4
      kernel/src/main/java/com/lantone/qc/kernel/util/DiagEnhancer.java
  31. 0 12
      kernel/src/main/resources/application.yml
  32. 1 0
      public/src/main/java/com/lantone/qc/pub/model/InputInfo.java
  33. 2 0
      public/src/main/java/com/lantone/qc/pub/model/vo/QueryVo.java
  34. 0 7
      trans/src/main/java/com/lantone/qc/trans/changx/ChangxDocTrans.java
  35. 3 3
      trans/src/main/java/com/lantone/qc/trans/changx/ChangxThreeLevelWardDocTrans.java

+ 10 - 0
dbanaly/pom.xml

@@ -73,6 +73,16 @@
             <artifactId>spring-web</artifactId>
             <version>5.1.4.RELEASE</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+            <version>2.1.2.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+            <version>2.6.0</version>
+        </dependency>
     </dependencies>
 
     <!-- 私有仓库 -->

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/web/config/RedisConfig.java

@@ -1,4 +1,4 @@
-package com.lantone.qc.kernel.web.config;
+package com.lantone.qc.dbanaly.config;
 
 /**
  * @Description:

+ 4 - 4
dbanaly/src/main/java/com/lantone/qc/dbanaly/lt/facade/ModelHospitalFacade.java

@@ -3,7 +3,7 @@ package com.lantone.qc.dbanaly.lt.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.lantone.qc.dbanaly.lt.entity.ModelHospital;
 import com.lantone.qc.dbanaly.lt.service.impl.ModelHospitalServiceImpl;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,10 +21,10 @@ import java.util.stream.Collectors;
 public class ModelHospitalFacade extends ModelHospitalServiceImpl {
 
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
 
     public List<String> getRecTitles(long hospitalId, long modelId) {
-        List<String> recTitles = redisUtil.getJsonStringValue("recTitles");
+        List<String> recTitles = specialStorageUtil.getJsonStringValue("recTitles");
         if (ListUtil.isEmpty(recTitles)) {
             QueryWrapper<ModelHospital> qcModelHospitalQe = new QueryWrapper<>();
             qcModelHospitalQe.eq("hospital_id", hospitalId);
@@ -36,7 +36,7 @@ public class ModelHospitalFacade extends ModelHospitalServiceImpl {
                     .filter(i -> StringUtil.isNotBlank(i))
                     .distinct()
                     .collect(Collectors.toList());
-            redisUtil.setJsonStringValue("recTitles", recTitles);
+            specialStorageUtil.setJsonStringValue("recTitles", recTitles);
         }
         return recTitles;
     }

+ 639 - 28
dbanaly/src/main/java/com/lantone/qc/dbanaly/util/RedisUtil.java

@@ -1,57 +1,668 @@
 package com.lantone.qc.dbanaly.util;
 
-import com.google.common.collect.Maps;
-import com.lantone.qc.pub.util.StringUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 /**
- * @Description:
- * @author: rengb
- * @time: 2020/3/6 17:21
+ * @author 王赛超 基于spring和redis的redisTemplate工具类 针对所有的hash 都是以h开头的方法 针对所有的Set 都是以s开头的方法 不含通用方法 针对所有的List 都是以l开头的方法
  */
 @Component
-public final class RedisUtil {
-    private final Map<String, Map<String, Object>> hospitalCache = Maps.newHashMap();
-    private final ThreadLocal<String> hospitalIdThreadLocal = new ThreadLocal<>();
+@Slf4j
+public class RedisUtil {
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
 
-    public <T> T getJsonStringValue(String key) {
-        return getValByHospitalId(hospitalIdThreadLocal.get(), key);
+    // =============================common============================
+
+    /**
+     * 指定缓存失效时间
+     *
+     * @param key  键
+     * @param time 时间(秒)
+     * @return
+     */
+    public boolean expire(String key, long time) {
+        try {
+            if (time > 0) {
+                redisTemplate.expire(key, time, TimeUnit.SECONDS);
+            }
+            return true;
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 根据key 获取过期时间
+     *
+     * @param key 键 不能为null
+     * @return 时间(秒) 返回0代表为永久有效
+     */
+    public long getExpire(String key) {
+        return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 判断key是否存在
+     *
+     * @param key 键
+     * @return true 存在 false不存在
+     */
+    public boolean hasKey(String key) {
+        try {
+            return redisTemplate.hasKey(key);
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 删除缓存
+     *
+     * @param key 可以传一个值 或多个
+     */
+    @SuppressWarnings("unchecked")
+    public 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) {
+            log.error(key, e);
+            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) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 递增 适用场景: https://blog.csdn.net/y_y_y_k_k_k_k/article/details/79218254 高并发生成订单号,秒杀类的业务逻辑等。。
+     *
+     * @param key 键
+     * @return
+     */
+    public long incr(String key, long delta) {
+        if (delta < 0) {
+            throw new RuntimeException("递增因子必须大于0");
+        }
+        return redisTemplate.opsForValue().increment(key, delta);
+    }
+
+    /**
+     * 递减
+     *
+     * @param key 键
+     * @return
+     */
+    public 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 值
+     */
+    public Object hget(String key, String item) {
+        return redisTemplate.opsForHash().get(key, item);
+    }
+
+    /**
+     * 获取hashKey对应的所有键值
+     *
+     * @param key 键
+     * @return 对应的多个键值
+     */
+    public Map<Object, Object> hmget(String key) {
+        return redisTemplate.opsForHash().entries(key);
+    }
+
+    /**
+     * HashSet
+     *
+     * @param key 键
+     * @param map 对应多个键值
+     * @return true 成功 false 失败
+     */
+    public boolean hmset(String key, Map<String, Object> map) {
+        try {
+            redisTemplate.opsForHash().putAll(key, map);
+            return true;
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * HashSet 并设置时间
+     *
+     * @param key  键
+     * @param map  对应多个键值
+     * @param time 时间(秒)
+     * @return true成功 false失败
+     */
+    public 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) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @return true 成功 false失败
+     */
+    public boolean hset(String key, String item, Object value) {
+        try {
+            redisTemplate.opsForHash().put(key, item, value);
+            return true;
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @param time  时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
+     * @return true 成功 false失败
+     */
+    public 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) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 删除hash表中的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 可以使多个 不能为null
+     */
+    public void hdel(String key, Object... item) {
+        redisTemplate.opsForHash().delete(key, item);
+    }
+
+    /**
+     * 判断hash表中是否有该项的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 不能为null
+     * @return true 存在 false不存在
+     */
+    public boolean hHasKey(String key, String item) {
+        return redisTemplate.opsForHash().hasKey(key, item);
+    }
+
+    /**
+     * hash递增 如果不存在,就会创建一个 并把新增后的值返回
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要增加几(大于0)
+     * @return
+     */
+    public double hincr(String key, String item, double by) {
+        return redisTemplate.opsForHash().increment(key, item, by);
+    }
+
+    /**
+     * hash递减
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要减少记(小于0)
+     * @return
+     */
+    public double hdecr(String key, String item, double by) {
+        return redisTemplate.opsForHash().increment(key, item, -by);
+    }
+
+    // ============================set=============================
+
+    /**
+     * 根据key获取Set中的所有值
+     *
+     * @param key 键
+     * @return
+     */
+    public Set<Object> sGet(String key) {
+        try {
+            return redisTemplate.opsForSet().members(key);
+        } catch (Exception e) {
+            log.error(key, e);
+            return null;
+        }
+    }
+
+    /**
+     * 根据value从一个set中查询,是否存在
+     *
+     * @param key   键
+     * @param value 值
+     * @return true 存在 false不存在
+     */
+    public boolean sHasKey(String key, Object value) {
+        try {
+            return redisTemplate.opsForSet().isMember(key, value);
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 将数据放入set缓存
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+    public long sSet(String key, Object... values) {
+        try {
+            return redisTemplate.opsForSet().add(key, values);
+        } catch (Exception e) {
+            log.error(key, e);
+            return 0;
+        }
+    }
+
+    /**
+     * 将set数据放入缓存
+     *
+     * @param key    键
+     * @param time   时间(秒)
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+    public 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) {
+            log.error(key, e);
+            return 0;
+        }
+    }
+
+    /**
+     * 获取set缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+    public long sGetSetSize(String key) {
+        try {
+            return redisTemplate.opsForSet().size(key);
+        } catch (Exception e) {
+            log.error(key, e);
+            return 0;
+        }
+    }
+
+    /**
+     * 移除值为value的
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 移除的个数
+     */
+    public long setRemove(String key, Object... values) {
+        try {
+            Long count = redisTemplate.opsForSet().remove(key, values);
+            return count;
+        } catch (Exception e) {
+            log.error(key, e);
+            return 0;
+        }
+    }
+
+    // ============================zset=============================
+
+    /**
+     * 根据key获取Set中的所有值
+     *
+     * @param key 键
+     * @return
+     */
+    public Set<Object> zSGet(String key) {
+        try {
+            return redisTemplate.opsForSet().members(key);
+        } catch (Exception e) {
+            log.error(key, e);
+            return null;
+        }
+    }
+
+    /**
+     * 根据value从一个set中查询,是否存在
+     *
+     * @param key   键
+     * @param value 值
+     * @return true 存在 false不存在
+     */
+    public boolean zSHasKey(String key, Object value) {
+        try {
+            return redisTemplate.opsForSet().isMember(key, value);
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    public Boolean zSSet(String key, Object value, double score) {
+        try {
+            return redisTemplate.opsForZSet().add(key, value, 2);
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 将set数据放入缓存
+     *
+     * @param key    键
+     * @param time   时间(秒)
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+    public long zSSetAndTime(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) {
+            log.error(key, e);
+            return 0;
+        }
+    }
+
+    /**
+     * 获取set缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+    public long zSGetSetSize(String key) {
+        try {
+            return redisTemplate.opsForSet().size(key);
+        } catch (Exception e) {
+            log.error(key, e);
+            return 0;
+        }
+    }
+
+    /**
+     * 移除值为value的
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 移除的个数
+     */
+    public long zSetRemove(String key, Object... values) {
+        try {
+            Long count = redisTemplate.opsForSet().remove(key, values);
+            return count;
+        } catch (Exception e) {
+            log.error(key, e);
+            return 0;
+        }
     }
+    // ===============================list=================================
 
-    public <T> T getValByHospitalId(String hospitalId, String key) {
-        if (StringUtil.isBlank(hospitalId)) {
+    /**
+     * 获取list缓存的内容
+     *
+     * @param key   键
+     * @param start 开始 0 是第一个元素
+     * @param end   结束 -1代表所有值
+     * @return
+     * @取出来的元素 总数 end-start+1
+     */
+    public List<Object> lGet(String key, long start, long end) {
+        try {
+            return redisTemplate.opsForList().range(key, start, end);
+        } catch (Exception e) {
+            log.error(key, e);
             return null;
         }
-        Map<String, Object> map = hospitalCache.get(hospitalId);
-        if (map == null) {
+    }
+
+    /**
+     * 获取list缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+    public long lGetListSize(String key) {
+        try {
+            return redisTemplate.opsForList().size(key);
+        } catch (Exception e) {
+            log.error(key, e);
+            return 0;
+        }
+    }
+
+    /**
+     * 通过索引 获取list中的值
+     *
+     * @param key   键
+     * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
+     * @return
+     */
+    public Object lGetIndex(String key, long index) {
+        try {
+            return redisTemplate.opsForList().index(key, index);
+        } catch (Exception e) {
+            log.error(key, e);
             return null;
         }
-        return (T) map.get(key);
     }
 
-    public <T> void setJsonStringValue(String key, Object value) {
-        setValByHospitalId(hospitalIdThreadLocal.get(), key, value);
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+    public boolean lSet(String key, Object value) {
+        try {
+            redisTemplate.opsForList().rightPush(key, value);
+            return true;
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
     }
 
-    public <T> void setValByHospitalId(String hospitalId, String key, Object value) {
-        if (StringUtil.isBlank(hospitalId)) {
-            return;
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+    public 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) {
+            log.error(key, e);
+            return false;
         }
-        Map<String, Object> map = hospitalCache.get(hospitalId);
-        if (map == null) {
-            return;
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+    public boolean lSet(String key, List<Object> value) {
+        try {
+            redisTemplate.opsForList().rightPushAll(key, value);
+            return true;
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+    public 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) {
+            log.error(key, e);
+            return false;
         }
-        map.put(key, value);
     }
 
-    public ThreadLocal<String> getHospitalIdThreadLocal() {
-        return hospitalIdThreadLocal;
+    /**
+     * 根据索引修改list中的某条数据
+     *
+     * @param key   键
+     * @param index 索引
+     * @param value 值
+     * @return
+     */
+    public boolean lUpdateIndex(String key, long index, Object value) {
+        try {
+            redisTemplate.opsForList().set(key, index, value);
+            return true;
+        } catch (Exception e) {
+            log.error(key, e);
+            return false;
+        }
     }
 
-    public Map<String, Map<String, Object>> getHospitalCache() {
-        return hospitalCache;
+    /**
+     * 移除N个值为value
+     *
+     * @param key   键
+     * @param count 移除多少个
+     * @param value 值
+     * @return 移除的个数
+     */
+    public long lRemove(String key, long count, Object value) {
+        try {
+            Long remove = redisTemplate.opsForList().remove(key, count, value);
+            return remove;
+        } catch (Exception e) {
+            log.error(key, e);
+            return 0;
+        }
     }
 
 }

+ 57 - 0
dbanaly/src/main/java/com/lantone/qc/dbanaly/util/SpecialStorageUtil.java

@@ -0,0 +1,57 @@
+package com.lantone.qc.dbanaly.util;
+
+import com.google.common.collect.Maps;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2020/3/6 17:21
+ */
+@Component
+public final class SpecialStorageUtil {
+    private final Map<String, Map<String, Object>> hospitalCache = Maps.newHashMap();
+    private final ThreadLocal<String> hospitalIdThreadLocal = new ThreadLocal<>();
+
+    public <T> T getJsonStringValue(String key) {
+        return getValByHospitalId(hospitalIdThreadLocal.get(), key);
+    }
+
+    public <T> T getValByHospitalId(String hospitalId, String key) {
+        if (StringUtil.isBlank(hospitalId)) {
+            return null;
+        }
+        Map<String, Object> map = hospitalCache.get(hospitalId);
+        if (map == null) {
+            return null;
+        }
+        return (T) map.get(key);
+    }
+
+    public <T> void setJsonStringValue(String key, Object value) {
+        setValByHospitalId(hospitalIdThreadLocal.get(), key, value);
+    }
+
+    public <T> void setValByHospitalId(String hospitalId, String key, Object value) {
+        if (StringUtil.isBlank(hospitalId)) {
+            return;
+        }
+        Map<String, Object> map = hospitalCache.get(hospitalId);
+        if (map == null) {
+            return;
+        }
+        map.put(key, value);
+    }
+
+    public ThreadLocal<String> getHospitalIdThreadLocal() {
+        return hospitalIdThreadLocal;
+    }
+
+    public Map<String, Map<String, Object>> getHospitalCache() {
+        return hospitalCache;
+    }
+
+}

+ 12 - 0
dbanaly/src/main/resources/application-db.yml

@@ -24,6 +24,18 @@ spring:
         filters: stat
         connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
         use-global-data-source-stat: true
+  redis:
+    database: 10
+    host: 192.168.2.246
+    port: 6379
+    password:
+    timeout: 2000
+    lettuce:
+      pool:
+        max-active: 8
+        min-idle: 0
+        max-wait: -1ms
+        max-idle: 8
 
 mybatis-plus:
   type-aliases-package: com.lantone.qc.dbanaly.lt.entity

+ 0 - 4
kernel/pom.xml

@@ -79,10 +79,6 @@
             <artifactId>spring-cloud-starter-openfeign</artifactId>
             <version>2.1.0.RELEASE</version>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-redis</artifactId>
-        </dependency>
 
         <dependency>
             <groupId>net.sourceforge.jexcelapi</groupId>

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

@@ -5,7 +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.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.exception.AIException;
 import com.lantone.qc.pub.exception.CatalogueException;
 import com.lantone.qc.pub.model.InputInfo;
@@ -28,14 +28,15 @@ public class QCAnalysis {
     @Autowired
     CRFServiceClient crfServiceClient;
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
     @Autowired
     SimilarityServiceClient similarityServiceClient;
 
     public OutputInfo anlysis(QueryVo queryVo) throws AIException, CatalogueException, Exception {
-        redisUtil.getHospitalIdThreadLocal().set(queryVo.getHospitalId());
+        specialStorageUtil.getHospitalIdThreadLocal().set(queryVo.getHospitalId());
         OutputInfo outputInfo = new OutputInfo();
         InputInfo inputInfo = TransDispatch.trans(queryVo);
+        inputInfo.setUseCrfCache(queryVo.isUseCrfCache());
         inputInfo.setInputCatalogueMap(queryVo.getInputCatalogueMap());
         AIAnalyze aiAnalyze = new AIAnalyze(crfServiceClient, similarityServiceClient);
         try {

+ 4 - 4
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0002.java

@@ -5,7 +5,7 @@ import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.client.ChiefPresentSimilarityServiceClient;
 import com.lantone.qc.kernel.structure.ai.ModelAI;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
@@ -30,7 +30,7 @@ import java.util.Map;
 @Component
 public class BEH0002 extends QCCatalogue {
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
     @Autowired
     ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
 
@@ -69,12 +69,12 @@ public class BEH0002 extends QCCatalogue {
             String firstHDiag = diags.get(0).getHospitalDiagName();
             String mainDiag = StringUtil.isBlank(firstHDiag) ? firstDiag : firstHDiag;
             List<String> symptoms = null;
-            //Map<String, String> hostpital_standDiag = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
+            //Map<String, String> hostpital_standDiag = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
             //if (!hostpital_standDiag.containsKey(mainDiag)) {
             //    status.set("0");
             //    return;
             //}
-            Map<String, Map<String, Object>> diagMap = redisUtil.getJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP);
+            Map<String, Map<String, Object>> diagMap = specialStorageUtil.getJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP);
             Map<String, Object> map = (Map<String, Object>) diagMap.get(mainDiag);
             if (map != null && map.size() > 0) {
                 symptoms = (List<String>) map.get("symptoms");

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0011.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.behospitalized;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Diag;
@@ -25,13 +25,13 @@ import java.util.stream.Collectors;
 @Component
 public class BEH0011 extends QCCatalogue {
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         if(inputInfo.getBeHospitalizedDoc() == null){
             status.set("0");
             return;
         }
-        Map<String, Map<String, Object>> diagMap = redisUtil.getJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP);
+        Map<String, Map<String, Object>> diagMap = specialStorageUtil.getJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP);
         String initDiagText = CatalogueUtil.removeSpecialChar(inputInfo.getBeHospitalizedDoc().getInitialDiagLabel().getText());
         List<Diag> diags = inputInfo.getBeHospitalizedDoc().getPastLabel().getDiags().stream().filter(diag -> diag.getNegative() == null).collect(Collectors.toList());
         if(StringUtils.isNotEmpty(initDiagText)){

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0012.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Diag;
@@ -26,7 +26,7 @@ import java.util.Map;
 public class BEH0012 extends QCCatalogue {
     private static String[] strings = { "2型糖尿病" };
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         if (inputInfo.getBeHospitalizedDoc() == null) {
@@ -34,7 +34,7 @@ public class BEH0012 extends QCCatalogue {
             return;
         }
         List<String> diags_out = new ArrayList<>();
-        Map<String, String> hostpital_standDiag = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
+        Map<String, String> hostpital_standDiag = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
         List<Diag> diags = inputInfo.getBeHospitalizedDoc().getInitialDiagLabel().getDiags();
         if (diags != null && diags.size() > 0) {
             for (Diag diag : diags) {

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0015.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.BodyPart;
@@ -22,13 +22,13 @@ import java.util.List;
 @Component
 public class BEH0015 extends QCCatalogue {
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
         if(inputInfo.getBeHospitalizedDoc() == null){
             return;
         }
-        List<String> clinicalList = (List<String>) redisUtil.getJsonStringValue(KernelConstants.CONCEPT_CLINIC_BODYPART_PROPERTIES_LIST);
+        List<String> clinicalList = (List<String>) specialStorageUtil.getJsonStringValue(KernelConstants.CONCEPT_CLINIC_BODYPART_PROPERTIES_LIST);
         List<Clinical> clinicals = inputInfo.getBeHospitalizedDoc().getPresentLabel().getClinicals();
         if(clinicals.size()>0){
             Clinical clinical = clinicals.get(0);

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0019.java

@@ -1,7 +1,7 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Clinical;
@@ -22,7 +22,7 @@ import java.util.List;
 @Component
 public class BEH0019 extends QCCatalogue {
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         if(inputInfo.getBeHospitalizedDoc() == null){
             status.set("0");

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0494.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.util.SpringContextUtil;
@@ -29,8 +29,8 @@ public class BEH0494 extends QCCatalogue {
             doctorName = inputInfo.getBeHospitalizedDoc().getStructureMap().get("签名");
         }
         if (StringUtils.isNotEmpty(doctorName)) {
-            RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
-            Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+            SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
+            Map<String, Object> surgeon = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
             if (surgeon == null) {
                 return;
             }

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/deathrecord/DEAR0338.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.deathrecord;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.util.StringUtil;
@@ -20,7 +20,7 @@ import java.util.Map;
 @Component
 public class DEAR0338 extends QCCatalogue {
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         if (inputInfo.getDeathRecordDoc() == null) {
@@ -37,7 +37,7 @@ public class DEAR0338 extends QCCatalogue {
     }
 
     private boolean findDirectorDoctor(String recordDoctor) {
-        Map<String, Map<String, Object>> hospitalDoctorMap = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+        Map<String, Map<String, Object>> hospitalDoctorMap = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
         if (hospitalDoctorMap == null) {
             return false;
         }

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC0096.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.firstcourserecord;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
@@ -24,14 +24,14 @@ import java.util.Map;
 @Component
 public class FIRC0096 extends QCCatalogue {
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         if(inputInfo.getFirstCourseRecordDoc() == null){
             status.set("0");
             return;
         }
         List<String> diags_out = new ArrayList<>();
-        Map<String, String> hostpital_standDiag = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
+        Map<String, String> hostpital_standDiag = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
         FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
         if(firstCourseRecordDoc != null){
             DiagLabel initialDiagLabel = firstCourseRecordDoc.getInitialDiagLabel();

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0147.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.leavehospital;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.DeathRecordDoc;
@@ -27,7 +27,7 @@ import java.util.Map;
 public class LEA0147 extends QCCatalogue {
 
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
 
     @Override
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
@@ -41,7 +41,7 @@ public class LEA0147 extends QCCatalogue {
             DiagLabel leaveDiagLabel = leaveHospitalDoc.getLeaveDiagLabel();
             if (leaveDiagLabel != null) {
                 List<Diag> diags = leaveDiagLabel.getDiags();
-                Map<String, Map<String, String>> hospitalDiagMap = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
+                Map<String, Map<String, String>> hospitalDiagMap = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
                 if (ListUtil.isNotEmpty(diags) && hospitalDiagMap != null) {
                     List<String> diagnames = new ArrayList<>();
                     for (Diag dg : diags) {

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0508.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.leavehospital;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
@@ -34,8 +34,8 @@ public class LEA0508 extends QCCatalogue {
             status.set("0");
             return;
         }
-        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
-        Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
+        Map<String, Object> surgeon = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
         if (surgeon == null) {
             status.set("0");
             return;

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0094.java

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.catalogue.threelevelward;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
@@ -36,8 +36,8 @@ public class THR0094 extends QCCatalogue {
         }
 
 
-        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
-        Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
+        Map<String, Object> surgeon = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
         if (surgeon == null) {
             status.set("0");
             return;

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0128.java

@@ -3,7 +3,7 @@ package com.lantone.qc.kernel.catalogue.threelevelward;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
@@ -29,7 +29,7 @@ import java.util.Map;
 @Component
 public class THR0128 extends QCCatalogue {
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
@@ -163,7 +163,7 @@ public class THR0128 extends QCCatalogue {
         if (firstCourseRecordDoc == null) {
             return false;
         }
-        Map<String, Map<String, Object>> hospitalDoctorMap = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+        Map<String, Map<String, Object>> hospitalDoctorMap = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
         String doctorSign = firstCourseRecordDoc.getStructureMap().get("医师签名");
         if (hospitalDoctorMap == null || StringUtil.isBlank(doctorSign)) {
             return false;

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -144,7 +144,7 @@ public class BeHospitalizedAI extends ModelAI {
                 }
                 putContent(crfContent, medicalTextType.get(6), supple_diag_text, Content.supple_diag);
             }
-            JSONObject midData = loadAI(crfContent, crfServiceClient);
+            JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);
             //处理主诉
             if (beHospitalizedDoc.getChiefLabel().isCrfLabel()) {
                 putChiefCrfData(midData.getJSONObject(Content.chief), inputInfo);

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/FirstCourseRecordAI.java

@@ -109,7 +109,7 @@ public class FirstCourseRecordAI extends ModelAI {
                 //                }
             }
 
-            JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
+            JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
             //if (midData.containsKey(Content.case_feature)) {
             //  putCaseCharacteristicCrfData(midData.getJSONObject(Content.case_feature), inputInfo);//处理病历特点
             //}

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/LeaveHospitalAI.java

@@ -57,7 +57,7 @@ public class LeaveHospitalAI extends ModelAI {
                 }
             }
         }
-        JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
+        JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
         if (midData.containsKey(Content.discharge)) {
             putDischargeCrfData(midData.getJSONObject(Content.discharge), inputInfo);//出院小结
         }

+ 20 - 7
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/ModelAI.java

@@ -3,6 +3,7 @@ package com.lantone.qc.kernel.structure.ai;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.kernel.client.CRFServiceClient;
 import com.lantone.qc.kernel.client.ChiefPresentSimilarityServiceClient;
 import com.lantone.qc.kernel.client.SimilarityServiceClient;
@@ -12,6 +13,7 @@ import com.lantone.qc.pub.model.entity.ChiefPresentAnnotation;
 import com.lantone.qc.pub.model.vo.CRFVo;
 import com.lantone.qc.pub.model.vo.ChiefPresentSimilarityVo;
 import com.lantone.qc.pub.model.vo.SimilarityVo;
+import com.lantone.qc.pub.util.SpringContextUtil;
 import com.lantone.qc.pub.util.StringUtil;
 
 import java.util.List;
@@ -30,12 +32,23 @@ public class ModelAI {
      * @param crfServiceClient
      * @return
      */
-    protected JSONObject loadAI(JSONArray crfContent, CRFServiceClient crfServiceClient) {
-        //存储CRF完整所需结构数据
-        CRFVo crfVo = new CRFVo();
-        crfVo.setData(crfContent);
-        //获取CRF模型返回数据
-        JSONArray data = getAnnotation(crfServiceClient, crfVo).getData();
+    protected JSONObject loadAI(boolean useCrfCache, String behospitalCode, JSONArray crfContent, CRFServiceClient crfServiceClient) {
+        JSONArray data = null;
+        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
+        String classname = this.getClass().getName();
+        if (useCrfCache) {
+            data = (JSONArray) redisUtil.hget(behospitalCode, classname);
+        }
+        if (data == null) {
+            //存储CRF完整所需结构数据
+            CRFVo crfVo = new CRFVo();
+            crfVo.setData(crfContent);
+            //获取CRF模型返回数据
+            data = getAnnotation(crfServiceClient, crfVo).getData();
+            if (data != null) {
+                redisUtil.hset(behospitalCode, classname, data, 86400);
+            }
+        }
         JSONObject midData = getOutputs(data);
         return midData;
     }
@@ -189,7 +202,7 @@ public class ModelAI {
      * @return
      */
     public JSONArray loadChiefPresentSimilarAI(String string1, List<String> string2, boolean directionCheck
-            ,String modelName, ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient) {
+            , String modelName, ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient) {
         //存储CRF完整所需结构数据
         ChiefPresentSimilarityVo similarityVo = new ChiefPresentSimilarityVo();
         JSONObject data = new JSONObject();

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/OperationAI.java

@@ -41,7 +41,7 @@ public class OperationAI extends ModelAI {
             putContent(crfContent, medicalTextType.get(0), operationDiscussionDoc.getText(), Content.operation_Discussion + i);
         }
 
-        JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
+        JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
 
         for (int i = 0; i < operationDocs.size(); i++) {
             if (midData.get(Content.operation_Discussion + i) == null) {

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/ThreeLevelWardAI.java

@@ -87,7 +87,7 @@ public class ThreeLevelWardAI extends ModelAI {
             }
         }
 
-        JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
+        JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
 
         //主治医师首次查房记录模型输出
         if (midData.get(Content.attend) != null) {

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcess.java

@@ -6,7 +6,7 @@ import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
 import com.lantone.qc.kernel.structure.ai.model.Lemma;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.kernel.structure.ai.model.Relation;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.entity.Negative;
 import com.lantone.qc.pub.model.entity.PD;
 import org.apache.commons.beanutils.BeanUtils;
@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
 @Component
 public class EntityProcess {
     @Autowired
-    RedisUtil redisUtil;
+    SpecialStorageUtil specialStorageUtil;
     /**
      * 树形结构存储三元组关系,返回传入实体类型为节点的所有关联实体对象
      * @param aiOut
@@ -239,7 +239,7 @@ public class EntityProcess {
 //     * @param diag
 //     */
 //    protected void setDiag(Lemma lemma, Diag diag) {
-//        Map<String, String> diagRedisMap = (Map<String, String>)redisUtil.get(KernelConstants.CONCEPT_DIAG_HOSPITAL_REFLECT);
+//        Map<String, String> diagRedisMap = (Map<String, String>)specialStorageUtil.get(KernelConstants.CONCEPT_DIAG_HOSPITAL_REFLECT);
 //        diag.setHospitalDiagName(lemma.getText());
 //        diag.setName(lemma.getText());//存放医院原始疾病名称
 //        diag.setName(diagRedisMap.get(lemma.getText()) == null ? "" : diagRedisMap.get(lemma.getText()));//映射到我们的标准疾病名称

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

@@ -2,7 +2,7 @@ package com.lantone.qc.kernel.util;
 
 import com.google.common.collect.Maps;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.nlp.participle.cfg.Configuration;
 import com.lantone.qc.nlp.participle.cfg.DefaultConfig;
 import com.lantone.qc.pub.util.StringUtil;
@@ -30,7 +30,7 @@ import java.util.Map;
 public class CacheUtil implements ApplicationRunner {
     private Configuration configuration = new DefaultConfig();
     @Autowired
-    private RedisUtil redisUtil;
+    private SpecialStorageUtil specialStorageUtil;
     @Value("${qc.hospital_id}")
     private String hospitalIds;
 
@@ -42,7 +42,7 @@ public class CacheUtil implements ApplicationRunner {
             if (StringUtil.isBlank(i)) {
                 continue;
             }
-            redisUtil.getHospitalCache().put(i, Maps.newHashMap());
+            specialStorageUtil.getHospitalCache().put(i, Maps.newHashMap());
             this.putConceptDiagPropertyMap(i);//疾病相关信息放入缓存 包括疾病是否是慢病、传染病、常见症状、同义词
             this.putHospitalDiagMap(i);//医院疾病信息
             this.putHospitalDiagHuaZMap(i);//医院华卓映射
@@ -85,7 +85,7 @@ public class CacheUtil implements ApplicationRunner {
                     diagMap.put(line_arr[0], map);
                 }
             }
-            redisUtil.setValByHospitalId(hospitalId, KernelConstants.CONCEPT_DIAG_PROPERTY_MAP, diagMap);
+            specialStorageUtil.setValByHospitalId(hospitalId, KernelConstants.CONCEPT_DIAG_PROPERTY_MAP, diagMap);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -112,7 +112,7 @@ public class CacheUtil implements ApplicationRunner {
                     hospitalDoctorMap.put(line_arr[0], map);
                 }
             }
-            redisUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DOCTOR_MAP, hospitalDoctorMap);
+            specialStorageUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DOCTOR_MAP, hospitalDoctorMap);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -133,7 +133,7 @@ public class CacheUtil implements ApplicationRunner {
                 detail.put("icd10", "A001");
                 hospitalDiagMap.put(line, detail);
             }
-            redisUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DIAG_MAP, hospitalDiagMap);
+            specialStorageUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DIAG_MAP, hospitalDiagMap);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -154,7 +154,7 @@ public class CacheUtil implements ApplicationRunner {
                 detail.put("icd10", "A001");
                 hospitalDiagMap.put(line, detail);
             }
-            redisUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DIAG_HUAZ_MAP, hospitalDiagMap);
+            specialStorageUtil.setValByHospitalId(hospitalId, KernelConstants.HOSPITAL_DIAG_HUAZ_MAP, hospitalDiagMap);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -175,7 +175,7 @@ public class CacheUtil implements ApplicationRunner {
                 detail.put("icd10", "A001");
                 hospitalDiagMap.put(line, detail);
             }
-            redisUtil.setValByHospitalId(hospitalId, KernelConstants.LANTONE_DIAG_HUAZ_MAP, hospitalDiagMap);
+            specialStorageUtil.setValByHospitalId(hospitalId, KernelConstants.LANTONE_DIAG_HUAZ_MAP, hospitalDiagMap);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -193,7 +193,7 @@ public class CacheUtil implements ApplicationRunner {
             for (String line : lines) {
                 clinicBodyPartList.add(line);
             }
-            redisUtil.setValByHospitalId(hospitalId, KernelConstants.CONCEPT_CLINIC_BODYPART_PROPERTIES_LIST, clinicBodyPartList);
+            specialStorageUtil.setValByHospitalId(hospitalId, KernelConstants.CONCEPT_CLINIC_BODYPART_PROPERTIES_LIST, clinicBodyPartList);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }

+ 5 - 5
kernel/src/main/java/com/lantone/qc/kernel/util/CatalogueUtil.java

@@ -3,7 +3,7 @@ package com.lantone.qc.kernel.util;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.pub.model.doc.DoctorAdviceDoc;
 import com.lantone.qc.pub.model.doc.operation.OperationDoc;
@@ -116,8 +116,8 @@ public class CatalogueUtil {
         if (ListUtil.isEmpty(diags) || StringUtil.isBlank(nature) || StringUtil.isBlank(natureValue)) {
             return null;
         }
-        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
-        Map<String, Map<String, String>> conceptDiagPropertyMap = redisUtil.getJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP);
+        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
+        Map<String, Map<String, String>> conceptDiagPropertyMap = specialStorageUtil.getJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP);
         if (conceptDiagPropertyMap == null) {
             return null;
         }
@@ -424,8 +424,8 @@ public class CatalogueUtil {
      */
     public static String getDoctorTitle(List<OperationDoc> operationDocs, Date recordDate, String findTitle) {
         String title = "";
-        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
-        Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
+        Map<String, Object> surgeon = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
         if (surgeon == null) {
             return title;
         }

+ 4 - 4
kernel/src/main/java/com/lantone/qc/kernel/util/DiagEnhancer.java

@@ -1,7 +1,7 @@
 package com.lantone.qc.kernel.util;
 
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.entity.Diag;
 import com.lantone.qc.pub.util.SpringContextUtil;
 import com.lantone.qc.pub.util.StringUtil;
@@ -18,9 +18,9 @@ public class DiagEnhancer {
     public static Diag create(String hospitalDiagName) {
         Diag diag = new Diag();
         diag.setHospitalDiagName(hospitalDiagName);
-        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
-        Map<String, Map<String, String>> hospitalDiagHuazMap = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_HUAZ_MAP);
-        Map<String, Map<String, String>> lantoneDiagHuazMap = redisUtil.getJsonStringValue(KernelConstants.LANTONE_DIAG_HUAZ_MAP);
+        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
+        Map<String, Map<String, String>> hospitalDiagHuazMap = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_HUAZ_MAP);
+        Map<String, Map<String, String>> lantoneDiagHuazMap = specialStorageUtil.getJsonStringValue(KernelConstants.LANTONE_DIAG_HUAZ_MAP);
         if (hospitalDiagHuazMap != null && lantoneDiagHuazMap != null) {
             Map<String, String> huazDiagMap = hospitalDiagHuazMap.get(hospitalDiagName);
             if (huazDiagMap != null) {

+ 0 - 12
kernel/src/main/resources/application.yml

@@ -11,18 +11,6 @@ spring:
       force: true
       charset: UTF-8
       enabled: true
-  redis:
-    database: 0
-    host: 192.168.2.246
-    port: 6379
-    password:
-    timeout: 2000
-    jedis:
-      pool:
-        max-active: 8
-        min-idle: 0
-        max-wait: -1ms
-        max-idle: 8
   profiles:
     active: db
 

+ 1 - 0
public/src/main/java/com/lantone/qc/pub/model/InputInfo.java

@@ -91,6 +91,7 @@ public class InputInfo {
     private List<DailyCourseRecordDoc> dailyCourseRecordDocs = Lists.newArrayList();
     //住院病历信息
     private MedicalRecordInfoDoc medicalRecordInfoDoc;
+    private boolean useCrfCache;
 
     //新增记录
     public <T> void addDoc(List<T> list, T obj) {

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

@@ -25,4 +25,6 @@ public class QueryVo extends TokenVO {
 
     private String hospitalId;
 
+    private boolean useCrfCache;
+
 }

+ 0 - 7
trans/src/main/java/com/lantone/qc/trans/changx/ChangxDocTrans.java

@@ -1,20 +1,13 @@
 package com.lantone.qc.trans.changx;
 
 import com.google.common.collect.Lists;
-import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
-import com.lantone.qc.pub.model.doc.operation.OperationDoc;
-import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
 import com.lantone.qc.pub.model.vo.MedrecVo;
 import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.pub.util.ListUtil;
-import com.lantone.qc.pub.util.SpringContextUtil;
-import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.DocTrans;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 
-import java.util.Calendar;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;

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

@@ -5,7 +5,7 @@ import com.google.common.collect.Maps;
 import com.lantone.qc.dbanaly.facade.changx.CxXmlUtil;
 import com.lantone.qc.dbanaly.lt.facade.ModelHospitalFacade;
 import com.lantone.qc.dbanaly.util.KernelConstants;
-import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
 import com.lantone.qc.pub.model.doc.operation.OperationDoc;
 import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
@@ -229,8 +229,8 @@ public class ChangxThreeLevelWardDocTrans extends ModelDocTrans {
      */
     public static String getDoctorTitle(List<OperationDoc> operationDocs, Date recordDate, String findTitle) {
         String title = "";
-        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
-        Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
+        Map<String, Object> surgeon = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
         if (surgeon == null) {
             return title;
         }