Bladeren bron

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

trick9191 7 jaren geleden
bovenliggende
commit
cd72755f6e

+ 16 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java

@ -3,6 +3,10 @@ package com.yihu.wlyy.redis;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.util.HttpUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPubSub;
import redis.clients.jedis.JedisPubSub;
@ -16,6 +20,8 @@ public class RedisMsgPubSubListener extends JedisPubSub {
    @Autowired
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    private PrescriptionInfoService prescriptionInfoService;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
    @Override
    @Override
    public void unsubscribe() {
    public void unsubscribe() {
        super.unsubscribe();
        super.unsubscribe();
@ -48,8 +54,16 @@ public class RedisMsgPubSubListener extends JedisPubSub {
    @Override
    @Override
    public void onMessage(String channel, String message) {
    public void onMessage(String channel, String message) {
        System.out.println("channel:" + channel + "receives message :" + message);
        logger.info("redis_onMessage...");
        //this.unsubscribe();
        //this.unsubscribe();
        JSONObject json = new JSONObject(message);
        String title =  json.getString("title");
        if("redisAddPrescription".equals(title)){
            logger.info(json.toString());
            //审核消息发送
            prescriptionInfoService.onMesSquareState(message);
        }
    }
    }
    @Override
    @Override
@ -59,7 +73,7 @@ public class RedisMsgPubSubListener extends JedisPubSub {
    @Override
    @Override
    public void onSubscribe(String channel, int subscribedChannels) {
    public void onSubscribe(String channel, int subscribedChannels) {
        System.out.println("channel:" + channel + "is been subscribed:" + subscribedChannels);
        //System.out.println("channel:" + channel + "is been subscribed:" + subscribedChannels);
    }
    }
    @Override
    @Override

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.prescription;
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
import org.json.JSONObject;
import org.json.JSONObject;
@ -17,6 +18,8 @@ import com.yihu.wlyy.util.ImUtill;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
@ -55,10 +58,10 @@ public class PrescriptionInfoService extends BaseService {
    @Autowired
    @Autowired
    private PrescriptionNoticesService prescriptionNoticesService;
    private PrescriptionNoticesService prescriptionNoticesService;
    @Autowired
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private ImUtill imUtill;
    private ImUtill imUtill;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
    /**
    /**
     * 获取处方下的详细药品
     * 获取处方下的详细药品
     * @param prescriptionCode
     * @param prescriptionCode
@ -659,13 +662,20 @@ public class PrescriptionInfoService extends BaseService {
    }
    }
    //
    //
    public int onMesSquareState(String mes){
    public int onMesSquareState(String mes){
        JSONObject json = new JSONObject(mes);
        Integer state = json.getInt("state");
        String code = json.getString("prescription");
        Prescription prescription = prescriptionDao.findByCode(code);
        Patient p = patientDao.findByCode(prescription.getPatient());
        if(state!=null&&state==1){
            //prescriptionNoticesService.sendMessages(weiXinAccessTokenUtils.getAccessToken(),prescription.getDoctor(),p.getCode());
        try{
            JSONObject json = new JSONObject(mes);
            Integer state = json.getInt("state");
            String code = json.getString("prescription");
            Prescription prescription = prescriptionDao.findByCode(code);
            Patient p = patientDao.findByCode(prescription.getPatient());
            if(state!=null&&state==1){
                prescriptionNoticesService.sendMessages(p.getOpenid(),p.getName(),prescription.getDoctorName(),null,1,1,"/html/prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode()+ "&toName=" + p.getName() +"&code="+prescription.getCode());
            }else{
                prescriptionNoticesService.sendMessages(p.getOpenid(),p.getName(),prescription.getDoctorName(),null,1,2,"/html/prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode()+ "&toName=" + p.getName() +"&code="+prescription.getCode());
            }
            return 1;
        }catch (Exception e){
            logger.error("续方消息发送失败!",e);
        }
        }
        return 0;
        return 0;
    }
    }