LAPTOP-KB9HII50\70708 2 vuotta sitten
vanhempi
commit
6bbb1cbf36

+ 29 - 17
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/message/DoctorSendUnreadJob.java

@ -1,6 +1,8 @@
package com.yihu.jw.care.job.message;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.common.MobileUtils;
import org.apache.commons.lang3.StringUtils;
@ -12,6 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@ -27,33 +30,42 @@ public class DoctorSendUnreadJob implements Job {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private MessageUtil messageUtil;
    @Resource
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    private static Logger logger = LoggerFactory.getLogger(DoctorSendUnreadJob.class);
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("DoctorSendUnreadJob start.....");
        String sql = " select id,name,mobile from base_doctor where del=1 and mobile is not null  ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:list){
            String mobile = tmp.get("mobile").toString();
            String doctorId = tmp.get("id").toString();
            if (StringUtils.isNotBlank(mobile)){
                if (MobileUtils.checkCellphone(mobile)){
                    String doctorName = tmp.get("name").toString();
                    Integer unReadCount = imUtil.SessionsUnreadMessageCountByUserId(doctorId);
                    try {
                        if (unReadCount>0){
                            messageUtil.sendTXYSJson("974597",mobile,doctorName,unReadCount+"");
        try {
            WlyyHospitalSysDictDO dictDO = wlyyHospitalSysDictDao.findById("DoctorSendUnreadJob");
            if(dictDO!=null&&"1".equals(dictDO.getDictCode())){
                logger.info("DoctorSendUnreadJob start.....");
                String sql = " select id,name,mobile from base_doctor where del=1 and mobile is not null  ";
                List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
                for (Map<String,Object> tmp:list){
                    String mobile = tmp.get("mobile").toString();
                    String doctorId = tmp.get("id").toString();
                    if (StringUtils.isNotBlank(mobile)){
                        if (MobileUtils.checkCellphone(mobile)){
                            String doctorName = tmp.get("name").toString();
                            Integer unReadCount = imUtil.SessionsUnreadMessageCountByUserId(doctorId);
                            try {
                                if (unReadCount>0){
                                    messageUtil.sendTXYSJson("974597",mobile,doctorName,unReadCount+"");
                                }
                            }catch (Exception e){
                                e.printStackTrace();
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
                logger.info("DoctorSendUnreadJob end.....");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        logger.info("DoctorSendUnreadJob end.....");
    }
}

+ 31 - 29
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/message/PatientSendUnreadJob.java

@ -6,8 +6,6 @@ import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@ -17,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -44,37 +41,42 @@ public class PatientSendUnreadJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("PatientSendUnreadJob start.....");
        String sql = "select p.id,p.name,wc.openId from base_patient p INNER JOIN base_patient_wechat wc " +
                " on p.id = wc.patient_id where p.del=1  and wc.wechat_id = '"+wxId+"' GROUP BY p.id ORDER BY wc.create_time desc  ;  ";
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(sql);
        for (Map<String,Object>tmp:patientList) {
            try {
                String patientId = tmp.get("id").toString();
                Integer unreadCount = imUtil.SessionsUnreadMessageCountByUserId(patientId);
                String name = tmp.get("name").toString();
                String openId = tmp.get("openId").toString();
                if (StringUtils.isNotBlank(openId)) {
                    sql = "select t2.id from base_patient_family_member t1,base_patient t2 " +
                            " where t2.id in (select family_member from base_patient_family_member where patient = '" + patientId + "' ) " +
                            " and t1.patient = '" + patientId + "' and t1.family_member = t2.id ";
                    List<String> familys = jdbcTemplate.queryForList(sql, String.class);
                    for (String family : familys) {
                        if (patientId.equals(family)) {
                            continue;
                        }
        try {
            logger.info("PatientSendUnreadJob start.....");
            String sql = "select p.id,p.name,wc.openId from base_patient p INNER JOIN base_patient_wechat wc " +
                    " on p.id = wc.patient_id where p.del=1  and wc.wechat_id = '"+wxId+"' GROUP BY p.id ORDER BY wc.create_time desc  ;  ";
            List<Map<String,Object>> patientList = jdbcTemplate.queryForList(sql);
            for (Map<String,Object>tmp:patientList) {
                try {
                    String patientId = tmp.get("id").toString();
                    Integer unreadCount = imUtil.SessionsUnreadMessageCountByUserId(patientId);
                    String name = tmp.get("name").toString();
                    String openId = tmp.get("openId").toString();
                    if (StringUtils.isNotBlank(openId)) {
                        sql = "select t2.id from base_patient_family_member t1,base_patient t2 " +
                                " where t2.id in (select family_member from base_patient_family_member where patient = '" + patientId + "' ) " +
                                " and t1.patient = '" + patientId + "' and t1.family_member = t2.id ";
                        List<String> familys = jdbcTemplate.queryForList(sql, String.class);
                        for (String family : familys) {
                            if (patientId.equals(family)) {
                                continue;
                            }
                        unreadCount += imUtil.SessionsUnreadMessageCountByUserId(family);
                            unreadCount += imUtil.SessionsUnreadMessageCountByUserId(family);
                        }
                    }
                    if (unreadCount > 0) {//发送模板
                        String first = ""+name+"您好,您与您的家庭成员共有"+unreadCount+"条消息未回复,请及时处理";
                        sendPatientUnreadWXTemplate(openId,first,"template_process_feedback","jobfsjmwd");
                    }
                } catch (Exception e) {
                }
                if (unreadCount > 0) {//发送模板
                    String first = ""+name+"您好,您与您的家庭成员共有"+unreadCount+"条消息未回复,请及时处理";
                    sendPatientUnreadWXTemplate(openId,first,"template_process_feedback","jobfsjmwd");
                }
            } catch (Exception e) {
            }
            logger.info("PatientSendUnreadJob end.....");
        }catch (Exception e){
            e.printStackTrace();
        }
        logger.info("PatientSendUnreadJob end.....");
    }
    public void sendPatientUnreadWXTemplate(String openid,String first,String templateName,String scene){