|
@ -5,9 +5,12 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
|
|
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
|
|
|
|
import com.yihu.jw.entity.base.wx.WxPushLogDO;
|
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
|
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
import com.yihu.jw.hospital.prescription.dao.WlyyInspectionDao;
|
|
import com.yihu.jw.hospital.prescription.dao.WlyyInspectionDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
|
|
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
|
|
@ -15,6 +18,7 @@ import com.yihu.jw.sms.util.ykyy.client.SmsClient;
|
|
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
|
|
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
|
import com.yihu.jw.wechat.dao.WxPushLogDao;
|
|
import com.yihu.utils.network.HttpResponse;
|
|
import com.yihu.utils.network.HttpResponse;
|
|
import com.yihu.utils.network.HttpUtils;
|
|
import com.yihu.utils.network.HttpUtils;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
@ -24,6 +28,7 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@ -45,6 +50,10 @@ public class YkyySMSService {
|
|
private WlyyInspectionDao inspectionDao;
|
|
private WlyyInspectionDao inspectionDao;
|
|
@Autowired
|
|
@Autowired
|
|
private BasePatientDao basePatientDao;
|
|
private BasePatientDao basePatientDao;
|
|
|
|
@Autowired
|
|
|
|
private WxPushLogDao wxPushLogDao;
|
|
|
|
@Autowired
|
|
|
|
private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送短信验证码
|
|
* 发送短信验证码
|
|
@ -61,6 +70,21 @@ public class YkyySMSService {
|
|
String content="";
|
|
String content="";
|
|
String sex = "先生/女士";
|
|
String sex = "先生/女士";
|
|
String mobile = "";
|
|
String mobile = "";
|
|
|
|
//由于审方情况比较特殊单独标记下
|
|
|
|
WxPushLogDO wxPushLogDO = null;
|
|
|
|
WxPushLogDO wxPushLogDODoctor = null;
|
|
|
|
//新增字典判断是否发送短信
|
|
|
|
String sendMesControl = "1";//1 开启发送短信 0 关闭
|
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("ykSmsControl");
|
|
|
|
if (wlyyHospitalSysDictDO!=null){
|
|
|
|
sendMesControl = wlyyHospitalSysDictDO.getDictValue();
|
|
|
|
}
|
|
|
|
if("check_failed".equalsIgnoreCase(temlateCode)){
|
|
|
|
wxPushLogDO = wxPushLogDao.findByTempNameAndOpenidAndReceiver(temlateCode,wlyyOutpatientDO.getId(),wlyyOutpatientDO.getPatient());
|
|
|
|
wxPushLogDODoctor = wxPushLogDao.findByTempNameAndOpenidAndReceiver(temlateCode,wlyyOutpatientDO.getId(),wlyyOutpatientDO.getDoctor());
|
|
|
|
}else {
|
|
|
|
wxPushLogDO = wxPushLogDao.findByTempNameAndOpenid(temlateCode,wlyyOutpatientDO.getId());
|
|
|
|
}
|
|
if (wlyyOutpatientDO!=null){
|
|
if (wlyyOutpatientDO!=null){
|
|
if (StringUtils.isNoneBlank(wlyyOutpatientDO.getIdcard())){
|
|
if (StringUtils.isNoneBlank(wlyyOutpatientDO.getIdcard())){
|
|
String sexNo = IdCardUtil.getSexForIdcard_new(wlyyOutpatientDO.getIdcard());
|
|
String sexNo = IdCardUtil.getSexForIdcard_new(wlyyOutpatientDO.getIdcard());
|
|
@ -84,48 +108,115 @@ public class YkyySMSService {
|
|
if (smsTemplateDO!=null){
|
|
if (smsTemplateDO!=null){
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}", DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}", DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
|
|
.replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);
|
|
.replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
}
|
|
}
|
|
}
|
|
}else if ("outpatient_remind".equalsIgnoreCase(temlateCode)){//患者发起复诊给医生发送消息
|
|
}else if ("outpatient_remind".equalsIgnoreCase(temlateCode)){//患者发起复诊给医生发送消息
|
|
smsTemplateDO = smsTemplateDao.findByClientId("outpatient_remind");
|
|
smsTemplateDO = smsTemplateDao.findByClientId("outpatient_remind");
|
|
if (smsTemplateDO!=null){
|
|
if (smsTemplateDO!=null){
|
|
if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
|
|
if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
|
|
content = smsTemplateDO.getContent();
|
|
content = smsTemplateDO.getContent();
|
|
ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getDoctor());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
}
|
|
}else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
|
|
}else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
|
|
content = smsTemplateDO.getContent().replace("图文","视频");
|
|
content = smsTemplateDO.getContent().replace("图文","视频");
|
|
ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getDoctor());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}else if ("message_remind_paitent".equalsIgnoreCase(temlateCode)){//医生发消息发送短信提醒
|
|
}else if ("message_remind_paitent".equalsIgnoreCase(temlateCode)){//医生发消息发送短信提醒
|
|
content = smsTemplateDO.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
smsTemplateDO = smsTemplateDao.findByClientId("message_remind_paitent");
|
|
|
|
if (smsTemplateDO!=null){
|
|
|
|
content = smsTemplateDO.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
}
|
|
|
|
}
|
|
}else if ("oneself_pick".equalsIgnoreCase(temlateCode)){//病人自取
|
|
}else if ("oneself_pick".equalsIgnoreCase(temlateCode)){//病人自取
|
|
smsTemplateDO = smsTemplateDao.findByClientId("oneself_pick");
|
|
smsTemplateDO = smsTemplateDao.findByClientId("oneself_pick");
|
|
if (smsTemplateDO!=null){
|
|
if (smsTemplateDO!=null){
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime())).replace("{{门诊号码}}",wlyyOutpatientDO.getRealOrder())
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime())).replace("{{门诊号码}}",wlyyOutpatientDO.getRealOrder())
|
|
.replace("{{性别}}",sex);;
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
.replace("{{性别}}",sex);
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
}
|
|
}
|
|
}
|
|
}else if("check_failed".equalsIgnoreCase(temlateCode)){//处方审核失败
|
|
}else if("check_failed".equalsIgnoreCase(temlateCode)){//处方审核失败
|
|
smsTemplateDO = smsTemplateDao.findByClientId("check_failed_patient");
|
|
smsTemplateDO = smsTemplateDao.findByClientId("check_failed_patient");
|
|
if (smsTemplateDO!=null){
|
|
if (smsTemplateDO!=null){
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
}
|
|
}
|
|
}
|
|
SmsTemplateDO smsTemplateDO1 = smsTemplateDao.findByClientId("check_failed_doctor");
|
|
SmsTemplateDO smsTemplateDO1 = smsTemplateDao.findByClientId("check_failed_doctor");
|
|
if (smsTemplateDO1!=null){
|
|
if (smsTemplateDO1!=null){
|
|
String contentDoctor = smsTemplateDO1.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
|
|
String contentDoctor = smsTemplateDO1.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
|
|
.replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder());
|
|
.replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder());
|
|
ykyySendSMS(doctorMobile,smsTemplateDO1.getHeader()+contentDoctor);
|
|
|
|
|
|
if (wxPushLogDODoctor==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getDoctor());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
ykyySendSMS(doctorMobile,smsTemplateDO1.getHeader()+contentDoctor);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}else if ("check_success_patient".equalsIgnoreCase(temlateCode)){//处方审核通过
|
|
}else if ("check_success_patient".equalsIgnoreCase(temlateCode)){//处方审核通过
|
|
smsTemplateDO = smsTemplateDao.findByClientId("check_success_patient");
|
|
smsTemplateDO = smsTemplateDao.findByClientId("check_success_patient");
|
|
if (smsTemplateDO!=null&&wlyyOutpatientDO!=null){
|
|
if (smsTemplateDO!=null&&wlyyOutpatientDO!=null){
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
}
|
|
}
|
|
}
|
|
}else if ("inspection_remind".equalsIgnoreCase(temlateCode)){//处方审核通过
|
|
}else if ("inspection_remind".equalsIgnoreCase(temlateCode)){//处方审核通过
|
|
smsTemplateDO = smsTemplateDao.findByClientId("inspection_remind");
|
|
smsTemplateDO = smsTemplateDao.findByClientId("inspection_remind");
|
|
@ -165,7 +256,15 @@ public class YkyySMSService {
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",createTime).replace("{{门诊号码}}",mzhm)
|
|
content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",createTime).replace("{{门诊号码}}",mzhm)
|
|
.replace("{{社保卡号}}","【到收费处,凭此条短信中的门诊号码换卡充值预缴金做检查】").replace("{{性别}}",sex);;
|
|
.replace("{{社保卡号}}","【到收费处,凭此条短信中的门诊号码换卡充值预缴金做检查】").replace("{{性别}}",sex);;
|
|
}
|
|
}
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
|
|
if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
|
|
|
|
wxPushLogDO = new WxPushLogDO();
|
|
|
|
wxPushLogDO.setTempName(temlateCode);
|
|
|
|
wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
|
|
|
|
wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
|
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
logger.info("发送后:temlateCode"+temlateCode+"==mobile:"+mobile+"content"+content+"doctorMobile"+doctorMobile);
|
|
logger.info("发送后:temlateCode"+temlateCode+"==mobile:"+mobile+"content"+content+"doctorMobile"+doctorMobile);
|