瀏覽代碼

Merge branch 'dev' of wangjun/wlyy2.0 into dev

wangzhinan 4 年之前
父節點
當前提交
50ed61547a

+ 55 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -3513,12 +3513,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "9");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", "");
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", cancelRemark);
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "16");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", "");
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", cancelRemark);
                }
                data.put("msg", msg);
                messageDO.setData(data.toString());
@ -3960,13 +3960,41 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if ("prescriptionPayRemind".equalsIgnoreCase(titelType)){
                return;
            }
            List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
            if (StringUtils.isNotEmpty(outpatientId)){
                ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getPatient());
            }
            if (consultTeam!=null){
                ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, consultTeam.getPatient());
            }
            if (ps.isEmpty()) {
                logger.info("该用户" + outpatientDO.getPatientName() + "没有openid,无法推送模版消息,用户ID:" + outpatientDO.getPatient() + "wechatId:" + wxId);
                return;
            }
            String scene = "";
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            if ("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
            if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
                scene = "zsysqxts";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getPatientName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊")+"取消原因为:"+remindMsg);
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊")+"取消原因为:"+remindMsg);
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3( doctorDO.getFee());
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("中山医院消息模板推送 医生拒诊开始");
            }else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)){
                scene = "hzsjgctx";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getPatientName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
@ -3977,7 +4005,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                newConfig.setKeyword3( doctorDO.getFee());
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("中山医院消息模板推送 医生拒诊开始");
                logger.info("中山医院消息模板推送 候诊时间过长开始");
            }
            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(outpatientDO.getPatient());
                wxPushLogDO.setWechatId(wechatId);
                wxPushLogDO.setReceiverName(outpatientDO.getPatientName());
                wxPushLogDO.setScene(scene);
                wxPushLogDao.save(wxPushLogDO);
            }
            String responseMsg="";
            String prefix="https://hlwyy.xmzsh.com";