|
@ -1,9 +1,15 @@
|
|
|
package com.yihu.wlyy.statistics.job.message;
|
|
|
|
|
|
import com.yihu.wlyy.statistics.dao.DoctorDao;
|
|
|
import com.yihu.wlyy.statistics.dao.MessageDao;
|
|
|
import com.yihu.wlyy.statistics.model.doctor.Doctor;
|
|
|
import com.yihu.wlyy.statistics.model.signfamily.Message;
|
|
|
import com.yihu.wlyy.statistics.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.statistics.util.DateUtil;
|
|
|
import com.yihu.wlyy.statistics.util.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;
|
|
@ -15,6 +21,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@ -32,6 +39,12 @@ public class FollowupPlanJob implements Job {
|
|
|
|
|
|
@Autowired
|
|
|
private MessageDao messageDao;
|
|
|
@Value("${doctorAssistant.api}")
|
|
|
private String doctorAssistant;
|
|
|
@Value("${doctorAssistant.target_url}")
|
|
|
private String targetUrl;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
@ -86,6 +99,38 @@ public class FollowupPlanJob implements Job {
|
|
|
PushMsgTask.url= url;
|
|
|
// 推送消息给医生
|
|
|
PushMsgTask.getInstance().put(doctor,"4",title,content,"");
|
|
|
|
|
|
try {
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String hql = "SELECT a.patient_name patientName,a.patient_code patientCode,count(1) amount FROM wlyy_followup a WHERE a.doctor_code = ? " +
|
|
|
" AND a.followup_plan_date BETWEEN ? AND ? AND a. STATUS NOT IN ('0', '1') GROUP BY a.patient_code;";
|
|
|
//获取所有未执行随访计划
|
|
|
List<Map<String, Object>> followups = jdbcTemplate.queryForList(hql,doctor,format.parse(start),format.parse(end));
|
|
|
for (Map<String,Object> followup:followups) {
|
|
|
// 新增发送医生助手模板消息 v1.4.0 by wujunjie
|
|
|
String patientName = String.valueOf(followup.get("patientName"));
|
|
|
String patientCount = String.valueOf(followup.get("amount"));
|
|
|
Doctor doctor1 = doctorDao.findByCode(doctor);
|
|
|
String doctorOpenID = doctor1.getOpenid();
|
|
|
if (StringUtils.isNotEmpty(doctorOpenID)) {
|
|
|
String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("type", "6"));
|
|
|
params.add(new BasicNameValuePair("openId", doctorOpenID));
|
|
|
params.add(new BasicNameValuePair("url", targetUrl));
|
|
|
params.add(new BasicNameValuePair("first", "您今日有"+patientCount+"个随访计划待处理"));
|
|
|
params.add(new BasicNameValuePair("remark", ""));
|
|
|
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
String newDate = formatDate.format(new Date());
|
|
|
String keywords = patientName+ "," + newDate + "," + "请进入手机APP查看";
|
|
|
params.add(new BasicNameValuePair("keywords", keywords));
|
|
|
|
|
|
HttpClientUtil.post(url, params, "UTF-8");
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
messageDao.save(list);
|