|
@ -9,6 +9,7 @@ import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.ImUtill;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
@ -42,6 +43,11 @@ public class DoctorFeldsherTemplateService extends BaseService {
|
|
|
private WeiXinOpenIdUtils weiXinOpenIdUtils;
|
|
|
@Autowired
|
|
|
private ImUtill imUtill;
|
|
|
@Autowired
|
|
|
private WeiXinTempMsgSendUtils weiXinTempMsgSendUtils;
|
|
|
|
|
|
@Value("${wechat.message.template_consult_notice}")
|
|
|
private String templateId;
|
|
|
@Value("${server.server_url}")
|
|
|
private String server_url;
|
|
|
|
|
@ -91,159 +97,6 @@ public class DoctorFeldsherTemplateService extends BaseService {
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发送给医生的模板消息提醒
|
|
|
*
|
|
|
* @param patientCode 居民code
|
|
|
* @param doctorCode 医生code
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void sendDoctorTemplate(String patientCode, String doctorCode, int type) throws Exception {
|
|
|
int num = 0;
|
|
|
int num1 = 0;
|
|
|
int num2 = 0;
|
|
|
int num3 = 0;
|
|
|
int num4 = 0;
|
|
|
int num5 = 0;
|
|
|
int num6 = 0;
|
|
|
Date date = new Date();
|
|
|
Date date1 = new Date();
|
|
|
String content1 = "";
|
|
|
String contetn2 = "";
|
|
|
|
|
|
Patient people = patientDao.findByCode(patientCode);
|
|
|
String patientOpenId = people.getOpenid();
|
|
|
String patientName = people.getName();
|
|
|
int patientSex = people.getSex();
|
|
|
|
|
|
Doctor doctor = doctorDao.findByCode(doctorCode);
|
|
|
String doctorName = doctor.getName();
|
|
|
String doctorOpenId = doctor.getOpenid();
|
|
|
|
|
|
|
|
|
//使用微信应用宝跳转APP的功能。点击后跳转APP消息页。
|
|
|
String url = "";
|
|
|
String first = "";
|
|
|
String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
JSONObject sendJson = new JSONObject();
|
|
|
switch (type) {
|
|
|
case 1:
|
|
|
first = doctorName + "医生您好,你有一条新的签约申请待处理";
|
|
|
sendJson.put("keyword1", patientName);
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 2:
|
|
|
first = doctorName + "医生,您的签约居民" + patientName + "有" + num + "条未读的体征异常消息";
|
|
|
sendJson.put("keyword1", patientName);
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 3:
|
|
|
first = doctorName + "医生您好。" + date + "新增1个签约居民待分配健管师,截至目前共有 " + num1 + " 人待处理";
|
|
|
sendJson.put("keyword1", "分配健管师");
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 4:
|
|
|
first = "您今日有" + num3 + "个随访计划待处理";
|
|
|
sendJson.put("keyword1", patientName);
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 5:
|
|
|
first = doctorName + "医生您好,有患者向您发起咨询";
|
|
|
sendJson.put("keyword1", patientName);
|
|
|
sendJson.put("keyword2", patientSex == 1 ? "男" : "女");
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 6:
|
|
|
first = "居民" + patientName + "的健康咨询有新的回复";
|
|
|
sendJson.put("keyword1", content1);
|
|
|
sendJson.put("keyword2", contetn2);
|
|
|
sendJson.put("keyword3", doctorName);
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 7:
|
|
|
first = doctorName + "医生您好。您的签约居民" + patientName + "申请线上续方,请尽快审核";
|
|
|
sendJson.put("keyword1", "续方审核");
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 8:
|
|
|
first = doctorName + "医生您好。" + date1 +
|
|
|
"新增1个续方订单待分配配送员,目前共" + num4 +
|
|
|
"人待分配,一个尽快分配";
|
|
|
sendJson.put("keyword1", "分配配送员");
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 9:
|
|
|
first = doctorName + "医生您好。您有一个您有1个续方申请处方开立失败";
|
|
|
sendJson.put("keyword1", doctorName);
|
|
|
sendJson.put("keyword2", patientName);
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 10:
|
|
|
first = doctorName + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证";
|
|
|
sendJson.put("keyword1", "续方审核CA认证");
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
case 11:
|
|
|
first = doctorName + "医生您好,你有一条新的续签申请待处理";
|
|
|
sendJson.put("keyword1", patientName);
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 拼装医生助手 医生类模板消息并发送
|
|
|
*
|
|
@ -260,19 +113,15 @@ public class DoctorFeldsherTemplateService extends BaseService {
|
|
|
String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
|
|
|
String url = server_url + "wx_doctor/html/home/html/jumpApp.html";
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
JSONObject sendJson = new JSONObject();
|
|
|
|
|
|
Doctor doctor = doctorDao.findByCode(doctorCode);
|
|
|
String doctorName = doctor.getName();
|
|
|
String doctorOpenId = doctor.getOpenid();
|
|
|
|
|
|
String first = businessType;
|
|
|
sendJson.put("keyword1", content);
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, doctorOpenId, doctorName, sendJson);
|
|
|
JSONObject sendJson = weiXinTempMsgSendUtils.packageTemplate(businessType, remark, content, dateFormat.format(new Date()));
|
|
|
Boolean flag = weiXinTempMsgSendUtils.sendTemplateMessage(templateId, doctorOpenId, url, sendJson);
|
|
|
logger.info("send wechat message param : " + doctorOpenId+" =======> "+content);
|
|
|
logger.info("send wechat message retuen : " + flag+" =======> "+flag);
|
|
|
logger.info("sendJson: " + sendJson);
|
|
|
return true;
|
|
|
} catch (Exception e) {
|