|
@ -4657,6 +4657,147 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发送顺丰物流提醒模板消息
|
|
|
* @param outpatientId
|
|
|
*/
|
|
|
public void sendSFWxTemplate(String outpatientId,String prescriptionId,String routeCode){
|
|
|
String contentMsg = "";
|
|
|
String first = "";
|
|
|
String remark = "";
|
|
|
String patientId = "";
|
|
|
String drugName = "";
|
|
|
String remindMsg="";
|
|
|
String patienName = "";
|
|
|
String mailNo ="";
|
|
|
String msgUrl ="";
|
|
|
WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
|
|
|
List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId,1);
|
|
|
if (wlyyOutpatientDO!=null){
|
|
|
patientId = wlyyOutpatientDO.getConsumer();
|
|
|
}
|
|
|
if (wlyyPrescriptionInfoDOS!=null&&wlyyPrescriptionInfoDOS.size()>0){
|
|
|
drugName = wlyyPrescriptionInfoDOS.get(0).getDrugName();
|
|
|
}
|
|
|
List<WlyyPrescriptionExpressageDO> wlyyPrescriptionExpressageDOS =prescriptionExpressageDao.findByOutpatientId(outpatientId);
|
|
|
if (wlyyPrescriptionExpressageDOS!=null&&wlyyPrescriptionExpressageDOS.size()>0){
|
|
|
mailNo = wlyyPrescriptionExpressageDOS.get(0).getMailno();
|
|
|
}
|
|
|
switch (routeCode) {
|
|
|
case "50":
|
|
|
remindMsg = "已发出";
|
|
|
break;
|
|
|
case "204":
|
|
|
remindMsg = "已在派件";
|
|
|
break;
|
|
|
case "80":
|
|
|
remindMsg = "已签收";
|
|
|
break;
|
|
|
case "8000":
|
|
|
remindMsg = "已签收";
|
|
|
break;
|
|
|
}
|
|
|
BasePatientDO basePatientDO = basePatientDao.findById(patientId);
|
|
|
if (basePatientDO!=null){
|
|
|
patienName = basePatientDO.getName();
|
|
|
}
|
|
|
if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
|
|
|
List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
|
|
|
if (StringUtils.isNotEmpty(outpatientId)){
|
|
|
ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId, patientId);
|
|
|
}
|
|
|
if (ps.isEmpty()) {
|
|
|
logger.info("该用户" + wlyyOutpatientDO.getConsumerName() + "没有openid,无法推送模版消息,用户ID:" + wlyyOutpatientDO.getPatient() + "wechatId:" + wechatId);
|
|
|
return;
|
|
|
}
|
|
|
WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
|
|
|
String scene = "sfxxtx";
|
|
|
WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_sf_msg_notice", scene, 1);
|
|
|
BeanUtils.copyProperties(config, newConfig);
|
|
|
|
|
|
newConfig.setFirst(config.getFirst().replace("key1",remindMsg));
|
|
|
newConfig.setKeyword1(config.getKeyword1().replace("key1",patienName).replace("key2",drugName));
|
|
|
newConfig.setKeyword2("顺丰快递");
|
|
|
newConfig.setKeyword3(mailNo);
|
|
|
newConfig.setKeyword4(remindMsg);
|
|
|
newConfig.setRemark(config.getRemark());
|
|
|
newConfig.setUrl(newConfig.getUrl().replace("key1",outpatientId).replace("key2",prescriptionId));
|
|
|
logger.info("=======setUrl========" + newConfig.getUrl());
|
|
|
WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
|
|
|
for (BasePatientWechatDo one : ps) {
|
|
|
logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newConfig));
|
|
|
try {
|
|
|
logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
|
|
|
weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newConfig);
|
|
|
logger.info("发送成功");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
logger.info("发送失败,error="+e.getMessage());
|
|
|
}
|
|
|
|
|
|
//保存发送模板记录,
|
|
|
WxPushLogDO wxPushLogDO = new WxPushLogDO();
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
wxPushLogDO.setOpenid(one.getOpenid());
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getConsumer());
|
|
|
wxPushLogDO.setWechatId(wechatId);
|
|
|
wxPushLogDO.setReceiverName(wlyyOutpatientDO.getConsumerName());
|
|
|
wxPushLogDO.setScene(scene);
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
}
|
|
|
}else {
|
|
|
first = "您好,您的处方订单物流"+remindMsg;
|
|
|
contentMsg = "患者"+patienName+"的处方药品订单,"+drugName+"等,当前"+remindMsg+"。物流方:「顺丰快递」,物流单号:"+mailNo+"。";
|
|
|
logger.info("推送物流模板消息参数first:"+first+"====contentMsg:"+contentMsg);
|
|
|
msgUrl="/ims-wx/index.html#/returnVisit/logistics?outpatientId="+outpatientId+"&prescriptionCode="+prescriptionId;
|
|
|
String responseMsg = "";
|
|
|
if ("xm_xzzx_wx".equalsIgnoreCase(wechatId)) {
|
|
|
//String prefix="https://www.xmheart.com";
|
|
|
String prefix = "https://ih.xmheart.com/hlwyy";
|
|
|
if(StringUtils.isNotEmpty(outpatientId)){
|
|
|
responseMsg = xzzxEntranceService.sendMes(wechatId,
|
|
|
basePatientDO.getId(),
|
|
|
basePatientDO.getIdcard(),
|
|
|
first,
|
|
|
contentMsg,
|
|
|
remark,
|
|
|
prefix+msgUrl);
|
|
|
}
|
|
|
logger.info("url="+prefix+msgUrl);
|
|
|
String msg="first:"+first+"contentMsg:"+contentMsg+"remark:"+remark;
|
|
|
logger.info("发送的信息="+msg);
|
|
|
logger.info("心脏模板消息发送返回结果:"+responseMsg);
|
|
|
} else if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)) {
|
|
|
String prefix = "https://hlwyy.xmzsh.com";
|
|
|
if (StringUtils.isNotEmpty(outpatientId)) {
|
|
|
responseMsg = entranceService.ehospitalNotice(
|
|
|
patienName,
|
|
|
basePatientDO.getIdcard(),
|
|
|
basePatientDO.getMobile(),
|
|
|
first,
|
|
|
prefix + msgUrl,
|
|
|
contentMsg,
|
|
|
remark
|
|
|
);
|
|
|
logger.info("中山发送模板消息返回结果="+responseMsg);
|
|
|
System.out.println("结束发送模板消息");
|
|
|
}
|
|
|
}
|
|
|
//保存发送模板记录,
|
|
|
WxPushLogDO wxPushLogDO = new WxPushLogDO();
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getConsumer());
|
|
|
wxPushLogDO.setWechatId(wechatId);
|
|
|
wxPushLogDO.setReceiverName(wlyyOutpatientDO.getConsumerName());
|
|
|
wxPushLogDO.setRequest(first+contentMsg+msgUrl);
|
|
|
wxPushLogDO.setResponse(responseMsg);
|
|
|
wxPushLogDO.setTempName("顺丰推送的物流消息");
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<WlyyHospitalSysDictDO> findCancelReasonList() {
|
|
|
return sysDictDao.findByDictName("PatientCancel");
|