|  | @ -312,6 +312,138 @@ public class UnSettledHISPrescriptionService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询HIS的01表中的审方状态,如果已审方,且未结算,则推送一条模板消息给患者,让医生进行接诊提醒。
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void acceptsRemind() throws Exception{
 | 
	
		
			
				|  |  |         if("xm_ykyy_wx".equals(wechatId)){
 | 
	
		
			
				|  |  |             //获取审核失败5306758
 | 
	
		
			
				|  |  |             JSONArray jsonArray = ykyyEntranceService.getNoUnsettledPrescription();
 | 
	
		
			
				|  |  |             if(jsonArray!=null&&jsonArray.size()>0) {
 | 
	
		
			
				|  |  |                 for (int i = 0; i<jsonArray.size(); i++){
 | 
	
		
			
				|  |  |                     JSONObject json = jsonArray.getJSONObject(i);
 | 
	
		
			
				|  |  |                     String cfsb = json.getString("CFSB");
 | 
	
		
			
				|  |  |                     //查找对应的处方
 | 
	
		
			
				|  |  |                     String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' and status <> 11 ORDER BY w.CREATE_TIME desc";
 | 
	
		
			
				|  |  |                     List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |                     if(pre!=null && pre.size()>0){
 | 
	
		
			
				|  |  |                         String prescriptionId = pre.get(0).get("ID").toString();
 | 
	
		
			
				|  |  |                         String outpatientId=pre.get(0).get("OUTPATIENT_ID").toString();
 | 
	
		
			
				|  |  |                         String doctor = pre.get(0).get("DOCTOR").toString();
 | 
	
		
			
				|  |  |                         String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
 | 
	
		
			
				|  |  |                         //修改处方状态
 | 
	
		
			
				|  |  |                         String updateSql = "update WLYY_PRESCRIPTION set status = 11,check_status=1,check_reason='处方驳回' where id = '"+prescriptionId+"'";
 | 
	
		
			
				|  |  |                         hibenateUtils.updateBySql(updateSql);
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |                         msgObj.put("outpatientid",outpatientId);
 | 
	
		
			
				|  |  |                         msgObj.put("prescriptionId",prescriptionId);
 | 
	
		
			
				|  |  |                         msgObj.put("reason","处方驳回");
 | 
	
		
			
				|  |  |                         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 | 
	
		
			
				|  |  |                         System.out.println("发送诊断消息开始+"+wlyyOutpatientDO.getId());
 | 
	
		
			
				|  |  |                         String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
 | 
	
		
			
				|  |  |                         System.out.println("发送诊断消息成功:"+immsg);
 | 
	
		
			
				|  |  |                         //发送短信提醒
 | 
	
		
			
				|  |  |                         String content = "";
 | 
	
		
			
				|  |  |                         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findByRealOrder(cfsb);
 | 
	
		
			
				|  |  |                         BaseDoctorDO baseDoctorDO = doctorDao.findById(doctor);
 | 
	
		
			
				|  |  |                         ykyySMSService.sendSmsByTempcode("check_failed",wlyyOutpatientDO,prescriptionDO,baseDoctorDO.getMobile());
 | 
	
		
			
				|  |  |                         logger.info("极光推送处方驳回消息");
 | 
	
		
			
				|  |  |                         prescriptionService.wxTempalteJPush("prescription_refuse",wlyyOutpatientDO,null,"","","",prescriptionDO.getId());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //获取已审核未结算的处方
 | 
	
		
			
				|  |  |             JSONArray array = ykyyEntranceService.getUnsettledPrescription();
 | 
	
		
			
				|  |  |             //发送模板
 | 
	
		
			
				|  |  |             if(array!=null&&array.size()>0) {
 | 
	
		
			
				|  |  |                 for (int i = 0; i<array.size(); i++){
 | 
	
		
			
				|  |  |                     JSONObject json = array.getJSONObject(i);
 | 
	
		
			
				|  |  |                     String brid = json.getString("BRID");
 | 
	
		
			
				|  |  |                     String cfsb = json.getString("CFSB");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     //查找居民信息
 | 
	
		
			
				|  |  |                     BasePatientDO patientDO = ykyyEntranceService.findPatientByMapingCode(brid);
 | 
	
		
			
				|  |  |                     if(patientDO!=null){
 | 
	
		
			
				|  |  |                         //查找对应的处方
 | 
	
		
			
				|  |  |                         String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' ORDER BY w.CREATE_TIME desc";
 | 
	
		
			
				|  |  |                         List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |                         if(pre!=null && pre.size()>0){
 | 
	
		
			
				|  |  |                             String outpatientId = pre.get(0).get("OUTPATIENT_ID").toString();
 | 
	
		
			
				|  |  |                             WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 | 
	
		
			
				|  |  |                             String prescriptionId = pre.get(0).get("ID").toString();
 | 
	
		
			
				|  |  |                             String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
 | 
	
		
			
				|  |  |                             //判断是否发送过
 | 
	
		
			
				|  |  |                             String countSql = "SELECT id from WX_PUSH_LOG w WHERE w.RECEIVER = '"+patientDO.getId()
 | 
	
		
			
				|  |  |                                     +"' and w.OPENID = '"+prescriptionId+"' and w.scene = 'djsxxtz' and w.WECHAT_ID='"+wechatId+"'";
 | 
	
		
			
				|  |  |                             List<Map<String, Object>> count = hibenateUtils.createSQLQuery(countSql);
 | 
	
		
			
				|  |  |                             if(count==null || count.size() == 0){
 | 
	
		
			
				|  |  |                                 List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patientDO.getId());
 | 
	
		
			
				|  |  |                                 //修改处方状态
 | 
	
		
			
				|  |  |                                 String updateSql = "update WLYY_PRESCRIPTION set status = 20 where id = '"+prescriptionId+"' and status = 10";
 | 
	
		
			
				|  |  |                                 hibenateUtils.updateBySql(updateSql);
 | 
	
		
			
				|  |  |                                 prescriptionLogService.addPrescriptionLog(prescriptionId,20,2,"system","system","",new Date());
 | 
	
		
			
				|  |  |                                 if(ps.isEmpty()){
 | 
	
		
			
				|  |  |                                     logger.info("该用户"+patientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+patientDO.getId()+"wechatId:"+wechatId);
 | 
	
		
			
				|  |  |                                 }else{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                     ps.stream().forEach(one->{
 | 
	
		
			
				|  |  |                                         WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_unsettled_notice","djsxxtz",1);
 | 
	
		
			
				|  |  |                                         WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
 | 
	
		
			
				|  |  |                                         BeanUtils.copyProperties(config,newConfig);
 | 
	
		
			
				|  |  |                                         newConfig.setFirst(config.getFirst().replace("key1",patientDO.getName()));
 | 
	
		
			
				|  |  |                                         newConfig.setUrl(config.getUrl()+""+outpatientId);
 | 
	
		
			
				|  |  |                                         newConfig.setKeyword3(doctorName);
 | 
	
		
			
				|  |  |                                         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(prescriptionId);
 | 
	
		
			
				|  |  |                                 wxPushLogDO.setReceiver(patientDO.getId());
 | 
	
		
			
				|  |  |                                 wxPushLogDO.setWechatId(wechatId);
 | 
	
		
			
				|  |  |                                 wxPushLogDO.setReceiverName(patientDO.getName());
 | 
	
		
			
				|  |  |                                 wxPushLogDO.setScene("djsxxtz");
 | 
	
		
			
				|  |  |                                 wxPushLogDao.save(wxPushLogDO);
 | 
	
		
			
				|  |  |                                 WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |                                 wlyyPrescriptionDO.setPrescribeTime(new Date());
 | 
	
		
			
				|  |  |                                 wlyyPrescriptionDO.setCheckStatus(0);
 | 
	
		
			
				|  |  |                                 wlyyPrescriptionDO.setCheckReason("审核通过");
 | 
	
		
			
				|  |  |                                 prescriptionDao.save(wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |                                 JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |                                 logger.info("wlyyPrescriptionDO参数入参"+object.toJSONString());
 | 
	
		
			
				|  |  |                                 WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
 | 
	
		
			
				|  |  |                                 List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
 | 
	
		
			
				|  |  |                                 List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
 | 
	
		
			
				|  |  |                                 for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
 | 
	
		
			
				|  |  |                                     JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
 | 
	
		
			
				|  |  |                                     logger.info("wlyyPrescriptionInfoDO参数入参"+jsonObject.toJSONString());
 | 
	
		
			
				|  |  |                                     WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionInfoVO.class);
 | 
	
		
			
				|  |  |                                     wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
 | 
	
		
			
				|  |  |                                 List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
 | 
	
		
			
				|  |  |                                 List<WlyyPrescriptionDiagnosisVO> wlyyPrescriptionDiagnosisVOS = new ArrayList<>();
 | 
	
		
			
				|  |  |                                 for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO:wlyyPrescriptionDiagnosisDOS){
 | 
	
		
			
				|  |  |                                     JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDiagnosisDO);
 | 
	
		
			
				|  |  |                                     logger.info("wlyyPrescriptionDiagnosisDO参数入参"+jsonObject.toJSONString());
 | 
	
		
			
				|  |  |                                     WlyyPrescriptionDiagnosisVO prescriptionDiagnosisVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionDiagnosisVO.class);
 | 
	
		
			
				|  |  |                                     wlyyPrescriptionDiagnosisVOS.add(prescriptionDiagnosisVO);
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 prescriptionVO.setDiagnosisVOs(wlyyPrescriptionDiagnosisVOS);
 | 
	
		
			
				|  |  |                                 imService.pushPrescriptionImMessage(prescriptionVO);
 | 
	
		
			
				|  |  |                                 ykyySMSService.sendSmsByTempcode("check_success_patient",wlyyOutpatientDO,wlyyPrescriptionDO,"");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void updateStatusByPayTime() throws Exception{
 | 
	
		
			
				|  |  |         if("xm_ykyy_wx".equals(wechatId)){
 |