|  | @ -15,8 +15,7 @@ import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.org.BaseOrgDO;
 |  | import com.yihu.jw.entity.base.org.BaseOrgDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 |  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
 |  | import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.wx.WxWechatDO;
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.entity.base.wx.*;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
 |  | import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
 |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
 | 
												
											
												
													
														
															|  | @ -72,11 +71,15 @@ import com.yihu.jw.rm.iot.IotRequestMapping;
 | 
												
													
														
															|  | import com.yihu.jw.util.common.IdCardUtil;
 |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
												
													
														
															|  | import com.yihu.jw.util.common.LatitudeUtils;
 |  | import com.yihu.jw.util.common.LatitudeUtils;
 | 
												
													
														
															|  | import com.yihu.jw.util.date.DateUtil;
 |  | import com.yihu.jw.util.date.DateUtil;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
 | 
												
													
														
															|  | import com.yihu.jw.utils.StringUtil;
 |  | import com.yihu.jw.utils.StringUtil;
 | 
												
													
														
															|  | import com.yihu.jw.utils.WebserviceUtil;
 |  | import com.yihu.jw.utils.WebserviceUtil;
 | 
												
													
														
															|  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
												
													
														
															|  | import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 |  | import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
												
													
														
															|  | import com.yihu.jw.wechat.dao.WechatDao;
 |  | import com.yihu.jw.wechat.dao.WechatDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.wechat.dao.WxPushLogDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.wechat.service.WxAccessTokenService;
 | 
												
													
														
															|  | import com.yihu.mysql.query.BaseJpaService;
 |  | import com.yihu.mysql.query.BaseJpaService;
 | 
												
													
														
															|  | import com.yihu.utils.security.MD5;
 |  | import com.yihu.utils.security.MD5;
 | 
												
													
														
															|  | import com.ylzinfo.ehc.EhcHandler;
 |  | import com.ylzinfo.ehc.EhcHandler;
 | 
												
											
												
													
														
															|  | @ -94,6 +97,7 @@ import org.jsoup.nodes.Document;
 | 
												
													
														
															|  | import org.jsoup.select.Elements;
 |  | import org.jsoup.select.Elements;
 | 
												
													
														
															|  | import org.slf4j.Logger;
 |  | import org.slf4j.Logger;
 | 
												
													
														
															|  | import org.slf4j.LoggerFactory;
 |  | import org.slf4j.LoggerFactory;
 | 
												
													
														
															|  | 
 |  | import org.springframework.beans.BeanUtils;
 | 
												
													
														
															|  | import org.springframework.beans.factory.annotation.Autowired;
 |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
												
													
														
															|  | import org.springframework.beans.factory.annotation.Value;
 |  | import org.springframework.beans.factory.annotation.Value;
 | 
												
													
														
															|  | import org.springframework.data.redis.core.StringRedisTemplate;
 |  | import org.springframework.data.redis.core.StringRedisTemplate;
 | 
												
											
												
													
														
															|  | @ -224,6 +228,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
												
													
														
															|  |     private WechatDao wechatDao;
 |  |     private WechatDao wechatDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private BasePatientWechatDao patientWechatDao;
 |  |     private BasePatientWechatDao patientWechatDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private WxTemplateConfigDao wxTemplateConfigDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private WxAccessTokenService wxAccessTokenService;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private WeixinMessagePushUtils weixinMessagePushUtils;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private BasePatientWechatDao basePatientWechatDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private WxPushLogDao wxPushLogDao;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Value("${demo.flag}")
 |  |     @Value("${demo.flag}")
 | 
												
											
												
													
														
															|  | @ -3267,10 +3281,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
												
													
														
															|  |                 if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
 |  |                 if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
 | 
												
													
														
															|  |                     data.put("type","9");
 |  |                     data.put("type","9");
 | 
												
													
														
															|  |                    msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个图文复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
 |  |                    msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个图文复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
 | 
												
													
														
															|  | 
 |  | //                   sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"9");
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |                 if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
 |  |                 if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
 | 
												
													
														
															|  |                     data.put("type","16");
 |  |                     data.put("type","16");
 | 
												
													
														
															|  |                     msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个视频复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
 |  |                     msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个视频复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
 | 
												
													
														
															|  | 
 |  | //                    sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"16");
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |                 data.put("msg",msg);
 |  |                 data.put("msg",msg);
 | 
												
													
														
															|  |                 messageDO.setData(data.toString());
 |  |                 messageDO.setData(data.toString());
 | 
												
											
												
													
														
															|  | @ -3309,6 +3325,48 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
												
													
														
															|  |         return  rs;
 |  |         return  rs;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void sendWxTemplateMsg(String wxId,WlyyOutpatientDO outpatientDO,String type){
 | 
												
													
														
															|  | 
 |  |         List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getPatient());
 | 
												
													
														
															|  | 
 |  |         if(ps.isEmpty()){
 | 
												
													
														
															|  | 
 |  |             logger.info("该用户"+outpatientDO.getPatientName()+"没有openid,无法推送模版消息,用户ID:"+outpatientDO.getPatient()+"wechatId:"+wxId);
 | 
												
													
														
															|  | 
 |  |             return;
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
 | 
												
													
														
															|  | 
 |  |             ps.stream().forEach(one->{
 | 
												
													
														
															|  | 
 |  |                 BaseDoctorDO doctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
 | 
												
													
														
															|  | 
 |  |                 WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_doctor_notice","ysqxjz",1);
 | 
												
													
														
															|  | 
 |  |                 WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
 | 
												
													
														
															|  | 
 |  |                 BeanUtils.copyProperties(config,newConfig);
 | 
												
													
														
															|  | 
 |  |                 newConfig.setFirst(config.getFirst().replace("key1",outpatientDO.getPatientName()));
 | 
												
													
														
															|  | 
 |  |                 if ("9".equals(type)){
 | 
												
													
														
															|  | 
 |  |                     newConfig.setFirst(newConfig.getFirst().replace("key2","图文复诊"));
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |                 if ("16".equals(type)){
 | 
												
													
														
															|  | 
 |  |                     newConfig.setFirst(newConfig.getFirst().replace("key2","视频复诊"));
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |                 newConfig.setUrl(config.getUrl()+""+outpatientDO.getId());
 | 
												
													
														
															|  | 
 |  |                 newConfig.setKeyword1(config.getKeyword1()+outpatientDO.getHospitalName());
 | 
												
													
														
															|  | 
 |  |                 newConfig.setKeyword2(config.getKeyword2()+outpatientDO.getDoctorName());
 | 
												
													
														
															|  | 
 |  |                 newConfig.setKeyword3(config.getKeyword3()+doctorDO.getFee());
 | 
												
													
														
															|  | 
 |  |                 WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
 | 
												
													
														
															|  | 
 |  |                 logger.info("=======setUrl========"+newConfig.getUrl());
 | 
												
													
														
															|  | 
 |  |                 weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(),one.getOpenid(),newConfig);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |                 //保存发送模板记录,
 | 
												
													
														
															|  | 
 |  |                 WxPushLogDO wxPushLogDO = new WxPushLogDO();
 | 
												
													
														
															|  | 
 |  |                 wxPushLogDO.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  |                 wxPushLogDO.setOpenid(one.getOpenid());
 | 
												
													
														
															|  | 
 |  |                 wxPushLogDO.setReceiver(outpatientDO.getPatient());
 | 
												
													
														
															|  | 
 |  |                 wxPushLogDO.setWechatId(wechatId);
 | 
												
													
														
															|  | 
 |  |                 wxPushLogDO.setReceiverName(outpatientDO.getPatientName());
 | 
												
													
														
															|  | 
 |  |                 wxPushLogDO.setScene("ysqxjz");
 | 
												
													
														
															|  | 
 |  |                 wxPushLogDao.save(wxPushLogDO);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             });
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public List<WlyyHospitalSysDictDO> findCancelReasonList(){
 |  |     public List<WlyyHospitalSysDictDO> findCancelReasonList(){
 | 
												
													
														
															|  |         return sysDictDao.findByDictName("PatientCancel");
 |  |         return sysDictDao.findByDictName("PatientCancel");
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
											
												
													
														
															|  | @ -4811,6 +4869,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient){
 |  |     public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient){
 | 
												
													
														
															|  |         SystemMessageDO systemMessageDO = new SystemMessageDO();
 |  |         SystemMessageDO systemMessageDO = new SystemMessageDO();
 | 
												
													
														
															|  | 
 |  |         String msg="";
 | 
												
													
														
															|  | 
 |  |         JSONObject data = new JSONObject();
 | 
												
													
														
															|  |         try{
 |  |         try{
 | 
												
													
														
															|  |             //1.在线复诊2.协同门诊
 |  |             //1.在线复诊2.协同门诊
 | 
												
													
														
															|  |             if("2".equals(outpatient.getOutpatientType())){
 |  |             if("2".equals(outpatient.getOutpatientType())){
 | 
												
											
												
													
														
															|  | @ -4826,27 +4886,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
												
													
														
															|  |                     systemMessageDO.setTitle("视频复诊预约成功");
 |  |                     systemMessageDO.setTitle("视频复诊预约成功");
 | 
												
													
														
															|  |                     systemMessageDO.setType("2");
 |  |                     systemMessageDO.setType("2");
 | 
												
													
														
															|  |                     saveInquirySystemMessage(outpatient);
 |  |                     saveInquirySystemMessage(outpatient);
 | 
												
													
														
															|  | 
 |  |                     msg="您的视频复诊已预约成功。\n" +
 | 
												
													
														
															|  | 
 |  |                             "预计"+outpatient.getDoctorName()+"医生将于"+outpatient.getRegisterDate()+" 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
 | 
												
													
														
															|  | 
 |  |                     systemMessageDO.setReceiver(outpatient.getDoctor());
 | 
												
													
														
															|  | 
 |  |                     systemMessageDO.setReceiverName(outpatient.getDoctorName());
 | 
												
													
														
															|  | 
 |  |                     systemMessageDO.setRelationCode(outpatient.getId());
 | 
												
													
														
															|  | 
 |  |                     systemMessageDO.setSender(outpatient.getPatient());
 | 
												
													
														
															|  | 
 |  |                     systemMessageDO.setSenderName(outpatient.getPatientName());
 | 
												
													
														
															|  | 
 |  |                     systemMessageDO.setRelationCode(outpatient.getId());
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |                     data.put("name",outpatient.getPatientName());
 | 
												
													
														
															|  | 
 |  |                     data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
 | 
												
													
														
															|  | 
 |  |                     data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
 | 
												
													
														
															|  | 
 |  |                     data.put("question",outpatient.getDescription());
 | 
												
													
														
															|  | 
 |  |                     data.put("msg",msg);
 | 
												
													
														
															|  | 
 |  |                     systemMessageDO.setData(data.toString());
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |                     systemMessageService.saveMessage(systemMessageDO);
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |             systemMessageDO.setReceiver(outpatient.getDoctor());
 |  | 
 | 
												
													
														
															|  |             systemMessageDO.setReceiverName(outpatient.getDoctorName());
 |  | 
 | 
												
													
														
															|  |             systemMessageDO.setRelationCode(outpatient.getId());
 |  | 
 | 
												
													
														
															|  |             systemMessageDO.setSender(outpatient.getPatient());
 |  | 
 | 
												
													
														
															|  |             systemMessageDO.setSenderName(outpatient.getPatientName());
 |  | 
 | 
												
													
														
															|  |             systemMessageDO.setRelationCode(outpatient.getId());
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             JSONObject data = new JSONObject();
 |  | 
 | 
												
													
														
															|  |             data.put("name",outpatient.getPatientName());
 |  | 
 | 
												
													
														
															|  |             data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
 |  | 
 | 
												
													
														
															|  |             data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
 |  | 
 | 
												
													
														
															|  |             data.put("question",outpatient.getDescription());
 |  | 
 | 
												
													
														
															|  |             String msg="您的视频复诊已预约成功。\n" +
 |  | 
 | 
												
													
														
															|  |                     "预计"+outpatient.getDoctorName()+"医生将于"+outpatient.getRegisterDate()+" 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
 |  | 
 | 
												
													
														
															|  |             data.put("msg",msg);
 |  | 
 | 
												
													
														
															|  |             systemMessageDO.setData(data.toString());
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             systemMessageService.saveMessage(systemMessageDO);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
 |  |             BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
 | 
												
													
														
															|  |             if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 |  |             if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
												
											
												
													
														
															|  | @ -6541,8 +6600,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
												
													
														
															|  |         String uid = userAgent.getUID();
 |  |         String uid = userAgent.getUID();
 | 
												
													
														
															|  |         StringBuffer sql = new StringBuffer("select a.* from wlyy_prescription a,wlyy_prescription_info b where a.patient_code ='");
 |  |         StringBuffer sql = new StringBuffer("select a.* from wlyy_prescription a,wlyy_prescription_info b where a.patient_code ='");
 | 
												
													
														
															|  |         StringBuffer countSql = new StringBuffer("select COUNT(a.id) count from wlyy_prescription a,wlyy_prescription_info b  where a.patient_code ='");
 |  |         StringBuffer countSql = new StringBuffer("select COUNT(a.id) count from wlyy_prescription a,wlyy_prescription_info b  where a.patient_code ='");
 | 
												
													
														
															|  |         sql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id");
 |  | 
 | 
												
													
														
															|  |         countSql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id ");
 |  | 
 | 
												
													
														
															|  | 
 |  |         sql.append(uid).append("' AND a.id = b.prescription_id");
 | 
												
													
														
															|  | 
 |  |         countSql.append(uid).append("' AND a.id = b.prescription_id ");
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (StringUtils.isNotEmpty(keyName)){
 |  |         if (StringUtils.isNotEmpty(keyName)){
 | 
												
													
														
															|  |             sql.append(" AND (" +
 |  |             sql.append(" AND (" +
 | 
												
											
												
													
														
															|  | @ -6565,6 +6624,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
												
													
														
															|  |             status= status.substring(1, status.length() - 1);
 |  |             status= status.substring(1, status.length() - 1);
 | 
												
													
														
															|  |             sql.append(" AND a.status IN(").append(status).append(")");
 |  |             sql.append(" AND a.status IN(").append(status).append(")");
 | 
												
													
														
															|  |             countSql.append(" AND a.status IN(").append(status).append(")");
 |  |             countSql.append(" AND a.status IN(").append(status).append(")");
 | 
												
													
														
															|  | 
 |  |         }else {
 | 
												
													
														
															|  | 
 |  |             sql.append("  and a.status IN(20,21,30,31,32,100,101)");
 | 
												
													
														
															|  | 
 |  |             countSql.append(" and a.status IN(20,21,30,31,32,100,101) ");
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         sql.append(" order by a.prescribe_time limit ").append((page-1)*size).append(",").append(size);
 |  |         sql.append(" order by a.prescribe_time limit ").append((page-1)*size).append(",").append(size);
 | 
												
													
														
															|  |         List<WlyyPrescriptionDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionDO.class));
 |  |         List<WlyyPrescriptionDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionDO.class));
 |