|
@ -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){
|