Browse Source

Merge branch 'dev' of trick9191/patient-co-management into dev

trick9191 7 years ago
parent
commit
6db97531d7

+ 58 - 58
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/config/RedisConfig.java

@ -1,58 +1,58 @@
//package com.yihu.wlyy.statistics.config;
//
//import com.yihu.wlyy.statistics.controller.KeyExpiredListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.data.redis.listener.PatternTopic;
//import org.springframework.data.redis.listener.RedisMessageListenerContainer;
//import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
//import redis.clients.jedis.Jedis;
//import redis.clients.jedis.JedisPool;
//import redis.clients.jedis.JedisPoolConfig;
//
//import javax.annotation.PostConstruct;
//
///**
// * Created by chenweida on 2017/7/31.
// */
//@Configuration
//public class RedisConfig {
//    @Value("${spring.redis.host}")
//    private String host;
//    @Value("${spring.redis.port}")
//    private Integer port;
//    @Value("${spring.redis.password}")
//    private String password;
//    @Bean
//    @ConfigurationProperties(prefix = "spring.redis.pool")
//    JedisPoolConfig jedisPoolConfig() {
//        return new JedisPoolConfig();
//    }
//
//    @Bean
//    JedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
//        System.out.println(jedisPoolConfig);
//        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
//        jedisConnectionFactory.setPoolConfig(jedisPoolConfig);
//        jedisConnectionFactory.setPort(port);
//        jedisConnectionFactory.setHostName(host);
//        jedisConnectionFactory.setPassword(password);
//        return jedisConnectionFactory;
//    }
//
//    @Bean
//    RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
//        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
//        container.setConnectionFactory(connectionFactory);
//        //监听redis过期的生命周期
//        //过期监听的管道默认是__keyevent@0__:expired,艾特后面的0表示第几个是数据库,redis默认的数据库是0~15一共16个数据库。所以如果你存入的数据库是2,那么数据接收的管道就是__keyevent@2__:expired
//        container.addMessageListener(new KeyExpiredListener(connectionFactory), new PatternTopic("__key*__:*"));
//        return container;
//    }
//}
package com.yihu.wlyy.statistics.config;
import com.yihu.wlyy.statistics.controller.KeyExpiredListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import javax.annotation.PostConstruct;
/**
 * Created by chenweida on 2017/7/31.
 */
@Configuration
public class RedisConfig {
    @Value("${spring.redis.host}")
    private String host;
    @Value("${spring.redis.port}")
    private Integer port;
    @Value("${spring.redis.password}")
    private String password;
    @Bean
    @ConfigurationProperties(prefix = "spring.redis.pool")
    JedisPoolConfig jedisPoolConfig() {
        return new JedisPoolConfig();
    }
    @Bean
    JedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
        System.out.println(jedisPoolConfig);
        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
        jedisConnectionFactory.setPoolConfig(jedisPoolConfig);
        jedisConnectionFactory.setPort(port);
        jedisConnectionFactory.setHostName(host);
        jedisConnectionFactory.setPassword(password);
        return jedisConnectionFactory;
    }
    @Bean
    RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        //监听redis过期的生命周期
        //过期监听的管道默认是__keyevent@0__:expired,艾特后面的0表示第几个是数据库,redis默认的数据库是0~15一共16个数据库。所以如果你存入的数据库是2,那么数据接收的管道就是__keyevent@2__:expired
        container.addMessageListener(new KeyExpiredListener(connectionFactory), new PatternTopic("__key*__:*"));
        return container;
    }
}

+ 6 - 6
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/config/war/ServletInitializer.java

@ -7,9 +7,9 @@ import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
 * Created by Administrator on 2016.10.14.
 */
public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}
//public class ServletInitializer extends SpringBootServletInitializer {
//    @Override
//    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//        return application.sources(Application.class);
//    }
//}

+ 36 - 36
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/KeyExpiredListener.java

@ -1,36 +1,36 @@
//package com.yihu.wlyy.statistics.controller;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.connection.Message;
//import org.springframework.data.redis.connection.MessageListener;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//import redis.clients.jedis.JedisPubSub;
//
//import java.util.concurrent.CountDownLatch;
//
///**
// * Created by chenweida on 2017/7/31.
// */
//public class KeyExpiredListener implements MessageListener {
//
//    private static final Logger LOGGER = LoggerFactory.getLogger(KeyExpiredListener.class);
//    private StringRedisTemplate redisTemplate;
//
//    public KeyExpiredListener(RedisConnectionFactory connectionFactory) {
//        redisTemplate = new StringRedisTemplate();
//        redisTemplate.setConnectionFactory(connectionFactory);
//        redisTemplate.afterPropertiesSet();
//    }
//
//    public void onMessage(Message message, byte[] pattern) {
//        String key = message.toString();
//        if (key.contains("cwd")) {
//            LOGGER.info("Received <" + message + ">");
//            LOGGER.info(redisTemplate.getExpire(message.toString()) + "");
//        }
//    }
//}
package com.yihu.wlyy.statistics.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPubSub;
import java.util.concurrent.CountDownLatch;
/**
 * Created by chenweida on 2017/7/31.
 */
public class KeyExpiredListener implements MessageListener {
    private static final Logger LOGGER = LoggerFactory.getLogger(KeyExpiredListener.class);
    private StringRedisTemplate redisTemplate;
    public KeyExpiredListener(RedisConnectionFactory connectionFactory) {
        redisTemplate = new StringRedisTemplate();
        redisTemplate.setConnectionFactory(connectionFactory);
        redisTemplate.afterPropertiesSet();
    }
    public void onMessage(Message message, byte[] pattern) {
        String key = message.toString();
        if (key.contains("cwd")) {
            LOGGER.info("Received <" + message + ">");
            LOGGER.info(redisTemplate.getExpire(message.toString()) + "");
        }
    }
}

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -31,9 +31,9 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**","/statistics/province/**","/statistics/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
//        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**","/statistics/province/**","/statistics/**");
//        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
//        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
        super.addInterceptors(registry);
    }

+ 13 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -87,10 +87,20 @@ public class PrescriptionInfoService extends BaseService {
                //基卫接口
            }else{
                StringBuffer sqlBuffer = new StringBuffer("SELECT p.code,p.create_time AS date,p.status,p.hospital_name As hospital FROM wlyy_prescription p " +
                        "WHERE p.status =? AND p.create_time >=? AND p.create_time <=? AND p.patient=?");
                        "WHERE p.status =? AND p.patient=?");
                List<Object> params = new ArrayList<>();
                params.add(state);
                params.add(patient);
                if(StringUtils.isNotBlank(startDate)){
                    sqlBuffer.append(" AND p.create_time >= ?");
                    params.add(startDate+" 00:00:00");
                }
                if(StringUtils.isNotBlank(endDate)){
                    sqlBuffer.append(" AND p.create_time <= ?");
                    params.add(endDate+" 23:59:59");
                }
                //本地库
                List<Map<String,Object>> rs =jdbcTemplate.queryForList(sqlBuffer.toString(),
                        new Object[]{state,startDate+" 00:00:00",endDate+" 23:59:59",patient});
                List<Map<String,Object>> rs =jdbcTemplate.queryForList(sqlBuffer.toString(),params.toArray());
                return new JSONArray(rs);
            }
        }

+ 26 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -21,6 +21,32 @@ public class PrescriptionInfoController extends BaseController{
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    /**
     * 确认配送 二维码方式
     * 根据处方code获取处方流程
     *
     * @param code wlyy_prescription_dispensary_code的code
     * @return
     */
    @RequestMapping(value = "/expressage", method = RequestMethod.POST)
    @ApiOperation(value = "确认配送")
    @ObserverRequired
    public String expressage(
            @RequestParam(required = true) @ApiParam(value = "wlyy_prescription_dispensary_code的code", name = "code") String code) {
        try {
            Integer status = prescriptionExpressageService.expressage(code, getUID());
            if (status == -1) {
                return error(-1, "编码不存在");
            }
            return write(200, "配送成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
    @RequestMapping(value = "/getPrescriptionFilter", method = RequestMethod.GET)
    @ResponseBody