|
@ -1,6 +1,8 @@
|
|
|
package com.yihu.wlyy.redis;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@ -30,7 +32,8 @@ public class RedisThread implements Runnable {
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
@Autowired
|
|
|
private PrescriptionService prescriptionService;
|
|
|
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
@ -55,7 +58,7 @@ public class RedisThread implements Runnable {
|
|
|
if(StringUtils.isEmpty(message)){
|
|
|
Thread.sleep(1000L);//如果没有读取到记录,等待1秒
|
|
|
}else {
|
|
|
prescriptionService.redisMessage(message);
|
|
|
redisMessage(message);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@ -64,4 +67,25 @@ public class RedisThread implements Runnable {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void redisMessage(String message){
|
|
|
logger.info("redis_onMessage...:"+message);
|
|
|
//this.unsubscribe();
|
|
|
try{
|
|
|
JSONObject json = JSONObject.parseObject(message);
|
|
|
String title = json.getString("title");
|
|
|
if("dispensingComplete".equals(title)){//配药完成
|
|
|
//药品配送完成,提醒取药
|
|
|
String prescriptionCode = json.getString("prescription");
|
|
|
prescriptionService.dispensingComplete(prescriptionCode);
|
|
|
}else if("wechat".equals(title)){
|
|
|
String data = json.getString("value");
|
|
|
pushMsgTask.getQueue().put(new org.json.JSONObject(data));
|
|
|
}else{
|
|
|
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
logger.error("redis_error...",e);
|
|
|
}
|
|
|
}
|
|
|
}
|