|  | @ -7,7 +7,6 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.im.ConsultTeamDo;
 |  | import com.yihu.jw.entity.base.im.ConsultTeamDo;
 | 
												
													
														
															|  | 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.wx.*;
 |  | import com.yihu.jw.entity.base.wx.*;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 |  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 | 
												
											
												
													
														
															|  | @ -138,7 +137,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |      * @param session_id 会话ID
 |  |      * @param session_id 会话ID
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     public String sendWeTempMesMiniProgram(String sender_id, String sender_name, String reciver_id, String reciver_name,String session_id)throws Exception {
 |  |     public String sendWeTempMesMiniProgram(String sender_id, String sender_name, String reciver_id, String reciver_name,String session_id)throws Exception {
 | 
												
													
														
															|  |         BasePatientDO basePatientDO = basePatientDao.findById(reciver_id);
 |  | 
 | 
												
													
														
															|  | 
 |  |         BasePatientDO basePatientDO = basePatientDao.findById(reciver_id).orElse(null);
 | 
												
													
														
															|  |         if(basePatientDO!=null){
 |  |         if(basePatientDO!=null){
 | 
												
													
														
															|  |             List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,reciver_id);
 |  |             List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,reciver_id);
 | 
												
													
														
															|  |             if(ps.isEmpty()){
 |  |             if(ps.isEmpty()){
 | 
												
											
												
													
														
															|  | @ -207,14 +206,14 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                         msgObj.put("outpatientid",outpatientId);
 |  |                         msgObj.put("outpatientid",outpatientId);
 | 
												
													
														
															|  |                         msgObj.put("prescriptionId",prescriptionId);
 |  |                         msgObj.put("prescriptionId",prescriptionId);
 | 
												
													
														
															|  |                         msgObj.put("reason","处方驳回");
 |  |                         msgObj.put("reason","处方驳回");
 | 
												
													
														
															|  |                         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 |  | 
 | 
												
													
														
															|  | 
 |  |                         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).orElse(null);
 | 
												
													
														
															|  |                         System.out.println("发送诊断消息开始+"+wlyyOutpatientDO.getId());
 |  |                         System.out.println("发送诊断消息开始+"+wlyyOutpatientDO.getId());
 | 
												
													
														
															|  |                         String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
 |  |                         String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
 | 
												
													
														
															|  |                         System.out.println("发送诊断消息成功:"+immsg);
 |  |                         System.out.println("发送诊断消息成功:"+immsg);
 | 
												
													
														
															|  |                         //发送短信提醒
 |  |                         //发送短信提醒
 | 
												
													
														
															|  |                         String content = "";
 |  |                         String content = "";
 | 
												
													
														
															|  |                         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findByRealOrder(cfsb);
 |  |                         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findByRealOrder(cfsb);
 | 
												
													
														
															|  |                         BaseDoctorDO baseDoctorDO = doctorDao.findById(doctor);
 |  | 
 | 
												
													
														
															|  | 
 |  |                         BaseDoctorDO baseDoctorDO = doctorDao.findById(doctor).orElse(null);
 | 
												
													
														
															|  |                         ykyySMSService.sendSmsByTempcode("check_failed",wlyyOutpatientDO,prescriptionDO,baseDoctorDO.getMobile());
 |  |                         ykyySMSService.sendSmsByTempcode("check_failed",wlyyOutpatientDO,prescriptionDO,baseDoctorDO.getMobile());
 | 
												
													
														
															|  |                         logger.info("极光推送处方驳回消息");
 |  |                         logger.info("极光推送处方驳回消息");
 | 
												
													
														
															|  |                        prescriptionService.wxTempalteJPush("prescription_refuse",wlyyOutpatientDO,null,"","","",prescriptionDO.getId());
 |  |                        prescriptionService.wxTempalteJPush("prescription_refuse",wlyyOutpatientDO,null,"","","",prescriptionDO.getId());
 | 
												
											
												
													
														
															|  | @ -239,7 +238,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                         List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 |  |                         List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 | 
												
													
														
															|  |                         if(pre!=null && pre.size()>0){
 |  |                         if(pre!=null && pre.size()>0){
 | 
												
													
														
															|  |                             String outpatientId = pre.get(0).get("OUTPATIENT_ID").toString();
 |  |                             String outpatientId = pre.get(0).get("OUTPATIENT_ID").toString();
 | 
												
													
														
															|  |                             WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 |  | 
 | 
												
													
														
															|  | 
 |  |                             WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).orElse(null);
 | 
												
													
														
															|  |                             String prescriptionId = pre.get(0).get("ID").toString();
 |  |                             String prescriptionId = pre.get(0).get("ID").toString();
 | 
												
													
														
															|  |                             String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
 |  |                             String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
 | 
												
													
														
															|  |                             //判断是否发送过
 |  |                             //判断是否发送过
 | 
												
											
												
													
														
															|  | @ -281,7 +280,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                                 wxPushLogDO.setReceiverName(patientDO.getName());
 |  |                                 wxPushLogDO.setReceiverName(patientDO.getName());
 | 
												
													
														
															|  |                                 wxPushLogDO.setScene("djsxxtz");
 |  |                                 wxPushLogDO.setScene("djsxxtz");
 | 
												
													
														
															|  |                                 wxPushLogDao.save(wxPushLogDO);
 |  |                                 wxPushLogDao.save(wxPushLogDO);
 | 
												
													
														
															|  |                                 WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
 |  | 
 | 
												
													
														
															|  | 
 |  |                                 WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).orElse(null);
 | 
												
													
														
															|  |                                 wlyyPrescriptionDO.setPrescribeTime(new Date());
 |  |                                 wlyyPrescriptionDO.setPrescribeTime(new Date());
 | 
												
													
														
															|  |                                 wlyyPrescriptionDO.setCheckStatus(2);
 |  |                                 wlyyPrescriptionDO.setCheckStatus(2);
 | 
												
													
														
															|  |                                 wlyyPrescriptionDO.setCheckReason("审核通过");
 |  |                                 wlyyPrescriptionDO.setCheckReason("审核通过");
 | 
												
											
												
													
														
															|  | @ -330,7 +329,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                     List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 |  |                     List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 | 
												
													
														
															|  |                     if(pre!=null && pre.size()>0){
 |  |                     if(pre!=null && pre.size()>0){
 | 
												
													
														
															|  |                         String prescriptionId = pre.get(0).get("ID").toString();
 |  |                         String prescriptionId = pre.get(0).get("ID").toString();
 | 
												
													
														
															|  |                         WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
 |  | 
 | 
												
													
														
															|  | 
 |  |                         WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).orElse(null);
 | 
												
													
														
															|  |                         logger.info(sprq+yfrq);
 |  |                         logger.info(sprq+yfrq);
 | 
												
													
														
															|  |                         if (StringUtils.isNoneBlank(sprq)){
 |  |                         if (StringUtils.isNoneBlank(sprq)){
 | 
												
													
														
															|  |                             logger.info("111111111111");
 |  |                             logger.info("111111111111");
 | 
												
											
												
													
														
															|  | @ -374,14 +373,14 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                         msgObj.put("outpatientid",outpatientId);
 |  |                         msgObj.put("outpatientid",outpatientId);
 | 
												
													
														
															|  |                         msgObj.put("prescriptionId",prescriptionId);
 |  |                         msgObj.put("prescriptionId",prescriptionId);
 | 
												
													
														
															|  |                         msgObj.put("reason","处方驳回");
 |  |                         msgObj.put("reason","处方驳回");
 | 
												
													
														
															|  |                         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 |  | 
 | 
												
													
														
															|  | 
 |  |                         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).orElse(null);
 | 
												
													
														
															|  |                         System.out.println("发送诊断消息开始+"+wlyyOutpatientDO.getId());
 |  |                         System.out.println("发送诊断消息开始+"+wlyyOutpatientDO.getId());
 | 
												
													
														
															|  |                         String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
 |  |                         String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
 | 
												
													
														
															|  |                         System.out.println("发送诊断消息成功:"+immsg);
 |  |                         System.out.println("发送诊断消息成功:"+immsg);
 | 
												
													
														
															|  |                         //发送短信提醒
 |  |                         //发送短信提醒
 | 
												
													
														
															|  |                         String content = "";
 |  |                         String content = "";
 | 
												
													
														
															|  |                         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findByRealOrder(cfsb);
 |  |                         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findByRealOrder(cfsb);
 | 
												
													
														
															|  |                         BaseDoctorDO baseDoctorDO = doctorDao.findById(doctor);
 |  | 
 | 
												
													
														
															|  | 
 |  |                         BaseDoctorDO baseDoctorDO = doctorDao.findById(doctor).orElse(null);
 | 
												
													
														
															|  |                         ykyySMSService.sendSmsByTempcode("check_failed",wlyyOutpatientDO,prescriptionDO,baseDoctorDO.getMobile());
 |  |                         ykyySMSService.sendSmsByTempcode("check_failed",wlyyOutpatientDO,prescriptionDO,baseDoctorDO.getMobile());
 | 
												
													
														
															|  |                         logger.info("极光推送处方驳回消息");
 |  |                         logger.info("极光推送处方驳回消息");
 | 
												
													
														
															|  |                         prescriptionService.wxTempalteJPush("prescription_refuse",wlyyOutpatientDO,null,"","","",prescriptionDO.getId());
 |  |                         prescriptionService.wxTempalteJPush("prescription_refuse",wlyyOutpatientDO,null,"","","",prescriptionDO.getId());
 | 
												
											
												
													
														
															|  | @ -406,7 +405,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                         List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 |  |                         List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 | 
												
													
														
															|  |                         if(pre!=null && pre.size()>0){
 |  |                         if(pre!=null && pre.size()>0){
 | 
												
													
														
															|  |                             String outpatientId = pre.get(0).get("OUTPATIENT_ID").toString();
 |  |                             String outpatientId = pre.get(0).get("OUTPATIENT_ID").toString();
 | 
												
													
														
															|  |                             WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 |  | 
 | 
												
													
														
															|  | 
 |  |                             WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).orElse(null);
 | 
												
													
														
															|  |                             String prescriptionId = pre.get(0).get("ID").toString();
 |  |                             String prescriptionId = pre.get(0).get("ID").toString();
 | 
												
													
														
															|  |                             String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
 |  |                             String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
 | 
												
													
														
															|  |                             //判断是否发送过
 |  |                             //判断是否发送过
 | 
												
											
												
													
														
															|  | @ -448,7 +447,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                                 wxPushLogDO.setReceiverName(patientDO.getName());
 |  |                                 wxPushLogDO.setReceiverName(patientDO.getName());
 | 
												
													
														
															|  |                                 wxPushLogDO.setScene("djsxxtz");
 |  |                                 wxPushLogDO.setScene("djsxxtz");
 | 
												
													
														
															|  |                                 wxPushLogDao.save(wxPushLogDO);
 |  |                                 wxPushLogDao.save(wxPushLogDO);
 | 
												
													
														
															|  |                                 WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
 |  | 
 | 
												
													
														
															|  | 
 |  |                                 WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).orElse(null);
 | 
												
													
														
															|  |                                 wlyyPrescriptionDO.setPrescribeTime(new Date());
 |  |                                 wlyyPrescriptionDO.setPrescribeTime(new Date());
 | 
												
													
														
															|  |                                 wlyyPrescriptionDO.setCheckStatus(0);
 |  |                                 wlyyPrescriptionDO.setCheckStatus(0);
 | 
												
													
														
															|  |                                 wlyyPrescriptionDO.setCheckReason("审核通过");
 |  |                                 wlyyPrescriptionDO.setCheckReason("审核通过");
 | 
												
											
												
													
														
															|  | @ -487,7 +486,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public void updateStatusByPayTime() throws Exception{
 |  |     public void updateStatusByPayTime() throws Exception{
 | 
												
													
														
															|  |         if("xm_ykyy_wx".equals(wechatId)){
 |  |         if("xm_ykyy_wx".equals(wechatId)){
 | 
												
													
														
															|  |             WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("PAY_TIME");
 |  | 
 | 
												
													
														
															|  | 
 |  |             WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("PAY_TIME").orElse(null);
 | 
												
													
														
															|  |             if (wlyyHospitalSysDictDO!=null){
 |  |             if (wlyyHospitalSysDictDO!=null){
 | 
												
													
														
															|  |                 String remind = wlyyHospitalSysDictDO.getDictValue();
 |  |                 String remind = wlyyHospitalSysDictDO.getDictValue();
 | 
												
													
														
															|  |                 String close = wlyyHospitalSysDictDO.getDictCode();
 |  |                 String close = wlyyHospitalSysDictDO.getDictCode();
 | 
												
											
												
													
														
															|  | @ -508,7 +507,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                             consultTeamDo.setStatus(-1);
 |  |                             consultTeamDo.setStatus(-1);
 | 
												
													
														
															|  |                             consultTeamOrderDao.save(consultTeamDo);
 |  |                             consultTeamOrderDao.save(consultTeamDo);
 | 
												
													
														
															|  |                         }else if (orderCategory.equalsIgnoreCase("2")){
 |  |                         }else if (orderCategory.equalsIgnoreCase("2")){
 | 
												
													
														
															|  |                             WlyyOutpatientDO outpatientDO = outpatientDao.findById(relationCode);
 |  | 
 | 
												
													
														
															|  | 
 |  |                             WlyyOutpatientDO outpatientDO = outpatientDao.findById(relationCode).orElse(null);
 | 
												
													
														
															|  |                             outpatientDO.setStatus("-1");
 |  |                             outpatientDO.setStatus("-1");
 | 
												
													
														
															|  |                             outpatientDao.save(outpatientDO);
 |  |                             outpatientDao.save(outpatientDO);
 | 
												
													
														
															|  |                         }
 |  |                         }
 | 
												
											
												
													
														
															|  | @ -535,8 +534,8 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                                 +"' and w.OPENID = '"+relationCode+"' and w.scene = 'zxzfts' and w.WECHAT_ID='"+wechatId+"'";
 |  |                                 +"' and w.OPENID = '"+relationCode+"' and w.scene = 'zxzfts' and w.WECHAT_ID='"+wechatId+"'";
 | 
												
													
														
															|  |                         List<Map<String, Object>> count = hibenateUtils.createSQLQuery(countSql);
 |  |                         List<Map<String, Object>> count = hibenateUtils.createSQLQuery(countSql);
 | 
												
													
														
															|  |                         if(count==null || count.size() == 0){
 |  |                         if(count==null || count.size() == 0){
 | 
												
													
														
															|  |                             BasePatientDO patientDO = basePatientDao.findById(patient);
 |  | 
 | 
												
													
														
															|  |                             BaseDoctorDO doctorDO = doctorDao.findById(doctor);
 |  | 
 | 
												
													
														
															|  | 
 |  |                             BasePatientDO patientDO = basePatientDao.findById(patient).orElse(null);
 | 
												
													
														
															|  | 
 |  |                             BaseDoctorDO doctorDO = doctorDao.findById(doctor).orElse(null);
 | 
												
													
														
															|  |                             List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
 |  |                             List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
 | 
												
													
														
															|  |                             if(ps.isEmpty()){
 |  |                             if(ps.isEmpty()){
 | 
												
													
														
															|  |                                 logger.info("该用户"+patientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+patientDO.getId()+"wechatId:"+wechatId);
 |  |                                 logger.info("该用户"+patientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+patientDO.getId()+"wechatId:"+wechatId);
 | 
												
											
												
													
														
															|  | @ -630,7 +629,7 @@ public class UnSettledHISPrescriptionService {
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             wxTemplateDao.save(savelist);
 |  | 
 | 
												
													
														
															|  | 
 |  |             wxTemplateDao.saveAll(savelist);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
 |  |         return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
 | 
												
													
														
															|  | 
 |  | 
 |