浏览代码

获取质控条目

gaodm 5 年之前
父节点
当前提交
04fc7f7895

+ 75 - 0
src/main/java/com/diagbot/config/RedisConfigurer.java

@@ -5,25 +5,37 @@ import com.fasterxml.jackson.annotation.PropertyAccessor;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cache.CacheManager;
 import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.KeyGenerator;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
 import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
 import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
 import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
 import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
 import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 
 import java.time.Duration;
 
 @Configuration
+@EnableCaching
 @Slf4j
 public class RedisConfigurer extends CachingConfigurerSupport {
 
+    @Value("${spring.redis.database.cache}")
+    private String databaseCache;
     @Value("${spring.redis.database.token}")
     private String databaseMr;
     @Value("${spring.redis.host}")
@@ -43,6 +55,10 @@ public class RedisConfigurer extends CachingConfigurerSupport {
     @Value("${spring.redis.lettuce.pool.min-idle}")
     private int minIdle;
 
+    @Autowired
+    @Qualifier("factoryForCache")
+    private LettuceConnectionFactory lettuceConnectionFactory;
+
     @Bean
     public GenericObjectPoolConfig getRedisConfig() {
         GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
@@ -53,6 +69,45 @@ public class RedisConfigurer extends CachingConfigurerSupport {
         return poolConfig;
     }
 
+    @Bean
+    @Override
+    public CacheManager cacheManager() {
+        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
+                // 设置 key为string序列化
+                .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
+                // 设置value为json序列化
+                .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(getSerializer()))
+                // 不缓存空值
+                .disableCachingNullValues();
+        RedisCacheManager cacheManager = RedisCacheManager.builder(lettuceConnectionFactory)
+                .cacheDefaults(redisCacheConfiguration)
+                .transactionAware()
+                .build();
+        cacheManager.afterPropertiesSet();
+        log.info("RedisCacheManager config success");
+        return cacheManager;
+    }
+
+    @Bean(name = "springSessionDefaultRedisSerializer")
+    public GenericJackson2JsonRedisSerializer getGenericJackson2JsonRedisSerializer() {
+        return new GenericJackson2JsonRedisSerializer();
+    }
+
+    /**
+     * 缓存使用的redis
+     *
+     * @return
+     */
+    @Bean("factoryForCache")
+    @Primary
+    public LettuceConnectionFactory redisConnectionFactory() {
+        return getRedisConnectionFactory(Integer.valueOf(databaseCache));
+    }
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate() {
+        return getRedisTemplate(lettuceConnectionFactory);
+    }
 
     private Jackson2JsonRedisSerializer getSerializer() {
         Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
@@ -63,6 +118,26 @@ public class RedisConfigurer extends CachingConfigurerSupport {
         return jackson2JsonRedisSerializer;
     }
 
+    @Bean
+    @Override
+    public KeyGenerator keyGenerator() {
+        //  设置自动key的生成规则,配置spring boot的注解,进行方法级别的缓存
+        // 使用:进行分割,可以很多显示出层级关系
+        // 这里其实就是new了一个KeyGenerator对象
+        return (target, method, params) -> {
+            StringBuilder sb = new StringBuilder();
+            sb.append(target.getClass().getName());
+            sb.append(":");
+            sb.append(method.getName());
+            for (Object obj : params) {
+                sb.append(":" + String.valueOf(obj));
+            }
+            String rsToUse = String.valueOf(sb);
+            log.info("自动生成Redis Key -> [{}]", rsToUse);
+            return rsToUse;
+        };
+    }
+
     /**
      * Token使用的redis
      *

+ 16 - 2
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -3,6 +3,7 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.QcServiceClient;
+import com.diagbot.dto.AlgorithmDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.OutputInfo;
 import com.diagbot.dto.QcCasesEntryDTO;
@@ -18,9 +19,12 @@ import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.AlgorithmVO;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
 import com.diagbot.vo.MedrecVo;
+import com.diagbot.vo.QcResultAlgQueryVO;
+import com.diagbot.vo.QcResultAlgVO;
 import com.diagbot.vo.QueryVo;
 import com.diagbot.vo.RecordContentVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,6 +63,8 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     MedicalRecordFacade medicalRecordFacade;
     @Autowired
     BasHospitalInfoFacade basHospitalInfoFacade;
+    @Autowired
+    private AlgorithmFacade algorithmFacade;
 
     public IPage<BehospitalInfoDTO> pageFac(BehospitalPageVO behospitalPageVO) {
 
@@ -156,8 +162,16 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
 
         //  调用质控接口
         Response<OutputInfo> response = qcServiceClient.extract(queryVo);
-
-        // 评分,保存
+        //根据质控结果获取质控条目
+        QcResultAlgQueryVO qcResultAlgQueryVO = new QcResultAlgQueryVO();
+        qcResultAlgQueryVO.setHospitalId(hospitalId);
+        List<QcResultAlgVO> qcResultAlgVOList = qcCasesEntryFacade.getQcResultAlgVO(qcResultAlgQueryVO);
+        // 评分
+        AlgorithmVO algorithmVO = new AlgorithmVO();
+        algorithmVO.setType(0);
+        algorithmVO.setQcResultAlgVOList(qcResultAlgVOList);
+        AlgorithmDTO algorithmDTO = algorithmFacade.getAlgorithmRes(algorithmVO);
+        // TODO 保存
 
 
         return null;

+ 4 - 0
src/main/java/com/diagbot/mapper/QcCasesEntryMapper.java

@@ -4,6 +4,8 @@ import com.diagbot.dto.QcCasesEntryDTO;
 import com.diagbot.entity.QcCasesEntry;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.diagbot.vo.AnalyzeVO;
+import com.diagbot.vo.QcResultAlgQueryVO;
+import com.diagbot.vo.QcResultAlgVO;
 
 import java.util.List;
 
@@ -17,4 +19,6 @@ import java.util.List;
  */
 public interface QcCasesEntryMapper extends BaseMapper<QcCasesEntry> {
     List<QcCasesEntryDTO> getQcCasesEntry(AnalyzeVO analyzeVO);
+
+    List<QcResultAlgVO> getQcResultAlgVO(QcResultAlgQueryVO qcResultAlgQueryVO);
 }

+ 4 - 0
src/main/java/com/diagbot/service/QcCasesEntryService.java

@@ -4,6 +4,8 @@ import com.diagbot.dto.QcCasesEntryDTO;
 import com.diagbot.entity.QcCasesEntry;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.vo.AnalyzeVO;
+import com.diagbot.vo.QcResultAlgQueryVO;
+import com.diagbot.vo.QcResultAlgVO;
 
 import java.util.List;
 
@@ -17,4 +19,6 @@ import java.util.List;
  */
 public interface QcCasesEntryService extends IService<QcCasesEntry> {
     List<QcCasesEntryDTO> getQcCasesEntry(AnalyzeVO analyzeVO);
+
+    List<QcResultAlgVO> getQcResultAlgVO(QcResultAlgQueryVO qcResultAlgQueryVO);
 }

+ 7 - 0
src/main/java/com/diagbot/service/impl/QcCasesEntryServiceImpl.java

@@ -6,6 +6,8 @@ import com.diagbot.mapper.QcCasesEntryMapper;
 import com.diagbot.service.QcCasesEntryService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.vo.AnalyzeVO;
+import com.diagbot.vo.QcResultAlgQueryVO;
+import com.diagbot.vo.QcResultAlgVO;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -24,4 +26,9 @@ public class QcCasesEntryServiceImpl extends ServiceImpl<QcCasesEntryMapper, QcC
     public List<QcCasesEntryDTO> getQcCasesEntry(AnalyzeVO analyzeVO){
         return baseMapper.getQcCasesEntry(analyzeVO);
     }
+
+    @Override
+    public List<QcResultAlgVO> getQcResultAlgVO(QcResultAlgQueryVO qcResultAlgQueryVO){
+        return baseMapper.getQcResultAlgVO(qcResultAlgQueryVO);
+    }
 }

+ 20 - 0
src/main/java/com/diagbot/vo/QcResultAlgQueryVO.java

@@ -0,0 +1,20 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @description:
+ * @author: zhoutg
+ * @time: 2020/4/13 18:31
+ */
+@Getter
+@Setter
+public class QcResultAlgQueryVO {
+    //医院ID
+    private Long hospitalId;
+    //有问题的编码
+    private List<String> codeList;
+}

+ 2 - 0
src/main/java/com/diagbot/vo/QcResultAlgVO.java

@@ -23,6 +23,8 @@ public class QcResultAlgVO {
     private Long casesEntryId;
     //条目分值
     private BigDecimal score;
+    //条目提示信息
+    private String msg;
     //单项否决(1-单项否决 0-非)
     private Integer isReject;
 }

+ 1 - 0
src/main/resources/application-dev.yml

@@ -108,6 +108,7 @@ spring:
   #redis
   redis:
     database:
+      cache: 8 # cache索引
       token: 8 # Token索引
     host: 192.168.2.236  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)

+ 1 - 0
src/main/resources/application-local.yml

@@ -108,6 +108,7 @@ spring:
   #redis
   redis:
     database:
+      cache: 8 # cache索引
       token: 8 # Token索引
     host: 192.168.2.236  #Redis服务器地址
     port: 6378 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)

+ 1 - 0
src/main/resources/application-pre.yml

@@ -108,6 +108,7 @@ spring:
   #redis
   redis:
     database:
+      cache: 8 # cache索引
       token: 8 # Token索引
     host: 192.168.2.121  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)

+ 1 - 0
src/main/resources/application-pro.yml

@@ -108,6 +108,7 @@ spring:
   #redis
   redis:
     database:
+      cache: 8 # cache索引
       token: 8 # Token索引
     host: 192.168.2.122  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)

+ 1 - 0
src/main/resources/application-test.yml

@@ -108,6 +108,7 @@ spring:
   #redis
   redis:
     database:
+      cache: 8 # cache索引
       token: 8 # Token索引
     host: 192.168.2.241  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)

+ 33 - 0
src/main/resources/mapper/QcCasesEntryMapper.xml

@@ -53,4 +53,37 @@
             AND t1.behospital_code =  #{behospitalCode}
         </if>
 	</select>
+
+    <select id="getQcResultAlgVO" parameterType="com.diagbot.vo.QcResultAlgQueryVO" resultType="com.diagbot.vo.QcResultAlgVO">
+        SELECT DISTINCT
+            t4.cases_id AS casesId,
+            t4.score AS casesScore,
+            t1.cases_entry_id AS casesEntryId,
+            t1.score AS score,
+            t1.msg AS msg,
+            t1.is_reject AS isReject
+        FROM
+            qc_cases_entry_hospital t1,
+            qc_cases_entry t2,
+            qc_cases t3,
+            qc_cases_hospital t4
+        WHERE
+            t1.cases_entry_id = t2.id
+        AND t2.cases_id = t3.id
+        AND t3.id = t4.cases_id
+        AND t1.is_deleted = 'N'
+        AND t2.is_deleted = 'N'
+        AND t3.is_deleted = 'N'
+        AND t4.is_deleted = 'N'
+        <if test="hospitalId != null and hospitalId != ''">
+            AND t1.hospital_id = #{hospitalId}
+            AND t4.hospital_id = #{hospitalId}
+        </if>
+        <if test="codeList != null and codeList.size() > 0">
+            AND t2.`code` IN
+            <foreach collection="codeList" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
 </mapper>