Browse Source

代码修改

liubing 4 years ago
parent
commit
88609d854f

+ 13 - 87
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorOrderService.java

@ -529,17 +529,11 @@ public class DoorOrderService {
        // 获取微信模板
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {
            String patientName=patient.getName()==null?"":patient.getName();
            String doctorName=doorServiceOrder.getDoctorName()!=null? doorServiceOrder.getDoctorName() : "";
            JSONObject json = new JSONObject();
            if(consult != null) {
                String consultStr =  consult.getId();
                json.put("consult", consult.getId());
            }
            String first = patientName+",您好!您的上门预约服务已由【"+doctorName+"】医生接单了";
            logger.info("上门服务已接单推送前");
            //url + json.getString("url") + "?openid=" + openid + "&consult=" + json.getString("consult")
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyjjd",patient.getOpenid(),first,null,null,DateUtil.dateToStrShort(new Date()),"上门服务已接单");
            logger.info("上门服务已接单推送前");
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyjjd",patient.getOpenid(),null,doorServiceOrder.getPatient(),doorServiceOrder.getDoctor(),30,json);
        }catch (Exception e){
            logger.error(e.getMessage());
        }
@ -971,34 +965,10 @@ public class DoorOrderService {
        // 获取微信模板 smfwdwk-上门服务待付款
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {//·
            String first = "key1预约上门服务医生已完成服务。为提高服务质量,诚邀您对本次服务医生进行评分";
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
            WlyyDoorCommentDO wlyyDoorCommentDO = doorCommentDao.selectCommentDoctor(patient.getId(),orderId);
            JSONObject json = new JSONObject();
            String finish="";
            if(wlyyDoorCommentDO!=null){
                finish = "0";
            }else {
                finish = "1";
            }
            //url:url + json.getString("url")+"?openid=" + openid + "&id=" + json.getString("id")+ "&finish=" + finish)
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",patient.getOpenid(),first,null,null,DateUtil.dateToStrShort(new Date()),"服务医生评分");
/*            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwyspf");
            String first = templateConfig.getFirst();
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", first);
            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
            json.put("keyword2", "服务医生评分");
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            json.put("id",orderId);
            //json.put("consult",consult.getCode());
            WlyyDoorCommentDO wlyyDoorCommentDO = this.DoorCommentDao.selectCommentDoctor(patient.getCode(),orderId);
            String finish="";
            if(wlyyDoorCommentDO!=null){
                finish = "0";
                json.put("finish",finish);
@ -1006,7 +976,8 @@ public class DoorOrderService {
                finish = "1";
                json.put("finish",finish);
            }
            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);*/
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",patient.getOpenid(),null,patient.getId(),one.getDoctor(),31,json);
        }catch (Exception e){
            logger.error(e.getMessage());
        }
@ -1053,40 +1024,10 @@ public class DoorOrderService {
        // 获取微信模板  fwyspf-服务医生评分
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {
            String first = "key1预约上门服务医生已完成服务。为提高服务质量,诚邀您对本次服务医生进行评分";
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
            WlyyDoorCommentDO wlyyDoorCommentDO = doorCommentDao.selectCommentDoctor(patient.getId(),orderId);
            JSONObject json = new JSONObject();
            String finish="";
            if(wlyyDoorCommentDO!=null){
                finish = "0";
            }else {
                finish = "1";
            }
            //url:url + json.getString("url")+"?openid=" + openid + "&id=" + json.getString("id")+ "&finish=" + finish)
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",patient.getOpenid(),first,null,null,DateUtil.dateToStrShort(new Date()),"服务医生评分");
        }catch (Exception e){
            logger.error(e.getMessage());
        }
/*        try {
         WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwyspf");
            String first = templateConfig.getFirst();
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
            String keyword1 = templateConfig.getKeyword1();
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", first);
            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
            json.put("keyword2", "服务医生评分");
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            json.put("id",orderId);
            //json.put("consult",consult.getCode());
            WlyyDoorCommentDO wlyyDoorCommentDO = this.DoorCommentDao.selectCommentDoctor(patient.getCode(),orderId);
            String finish="";
            if(wlyyDoorCommentDO!=null){
                finish = "0";
                json.put("finish",finish);
@ -1094,10 +1035,10 @@ public class DoorOrderService {
                finish = "1";
                json.put("finish",finish);
            }
            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",patient.getOpenid(),null,patient.getId(),one.getDoctor(),31,json);
        }catch (Exception e){
            logger.error(e.getMessage());
        }*/
        }
        return this.getDoorServiceOrderById(orderId, level);
    }
@ -1416,26 +1357,11 @@ public class DoorOrderService {
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        Integer status = 0;
        try{
            String first = "您的预约服务的服务项目已变更,请及时确认";
            first = first.replace("key1",(patient.getName()==null?"":patient.getName()));
            first = first .replace("key2", null != order.getDoctorName() ? order.getDoctorName() : "");
            String consultStr = consult.getId();
//            url1 + json.getString("url")+"?openid=" + openid + "&consult=" + json.getString("consult") + "&status=" + json.getInt("status")
//            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",patient.getOpenid(),first,null,null,DateUtil.dateToStrShort(new Date()),"服务项目变更确认");
            /* WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwxmbgtz");
            String first = templateConfig.getFirst();
            first = first.replace("key1",(patient.getName()==null?"":patient.getName()));
            first = first .replace("key2", null != order.getDoctorName() ? order.getDoctorName() : "");
            String keyword1 = templateConfig.getKeyword1();
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", first);
            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
            json.put("keyword2", "服务项目变更确认");
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            json.put("consult",consult.getCode());
            JSONObject json = new JSONObject();
            json.put("consult",consult.getId());
            json.put("status",status);
           //messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwxmbgtz",patient.getOpenid(),null,null,null,32,json);
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 32, patient.getOpenid(), patient.getName(), json);*/
        }catch (Exception e) {

+ 2 - 27
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorServiceApplicationService.java

@ -588,33 +588,8 @@ public class DoorServiceApplicationService {
            first = first.replace("key1",(patient.getName()==null?"":patient.getName()));
            first = first.replace("key2", (wlyyDoorServiceApplicationDo1.getPatientName() == null ? "" : wlyyDoorServiceApplicationDo1.getPatientName()));
            wlyyDoorServiceApplicationDo1.getAuditorName();
//            String urlStr= json.getString("url");
//            boolean status = urlStr.contains("openid=");
//            if(!status){
//                urlStr=json.getString("url")+"?openid=" + openid;
//            }
//            temp.setUrl(url + urlStr )
            messageUtil.putTemplateWxMessage(wxId,"template_doctor_audit",scene,patient.getOpenid(),first,null,null,null,wlyyDoorServiceApplicationDo1.getAuditorName());
/*            Patient patient = patientDao.findByCode(wlyyDoorServiceApplicationDo1.getProxyPatient());
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_audit",scene);
            if(null==templateConfig){
                throw new Exception("微信模板不存在!请确认");
            }
            String first = templateConfig.getFirst();
            first = first.replace("key1",(patient.getName()==null?"":patient.getName()));
            first = first.replace("key2", (wlyyDoorServiceApplicationDo1.getPatientName() == null ? "" : wlyyDoorServiceApplicationDo1.getPatientName()));
            String remark = templateConfig.getRemark();
            String keyword1 = templateConfig.getKeyword1();
            JSONObject sendJson = new JSONObject();
            sendJson.put("keyword1", keyword1);
            sendJson.put("keyword2", wlyyDoorServiceApplicationDo1.getAuditorName());
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            //带参数的模板跳转链接
            sendJson.put("url", templateConfig.getUrl());
            pushMsgTask.sendWeixinMessage(weiXinAccessTokenUtils.getAccessToken(), 19, patient.getOpenid(), wlyyDoorServiceApplicationDo1.getProxyPatientName(), sendJson);*/
            messageUtil.putTemplateWxMessage(wxId,"template_doctor_audit",scene,patient.getOpenid(),first,wlyyDoorServiceApplicationDo1.getProxyPatient(),null,19,null,null,wlyyDoorServiceApplicationDo1.getAuditorName());
        }
        return wlyyDoorServiceApplicationDo1;

+ 15 - 23
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/WlyyDoorServiceOrderService.java

@ -1454,22 +1454,14 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        String first = "key1,您好,您的上门预约服务已退回,点击查看原因";
        BasePatientDO patient = patientDao.findById(orderDO.getPatient());
        first  = first.replace("key1", null != patient.getName() ? patient.getName() : "");
//        if(consult != null) {
//            json.put("consult", consult.getCode());
//        }else {
//            json.put("id", orderDO.getId());
//        }
//        if(json.has("consult")) {
//            temp.setUrl(url + json.getString("url") + "?openid=" + openid + "&consult=" + json.getString("consult"));
//        }else if (json.has("id")){
//            temp.setUrl(url + json.getString("url") + "?openid=" + openid + "&id=" + json.getString("id"));
//        }else if(json.has("relationCode")){
//            temp.setUrl(url + json.getString("url") + "?openid=" + openid );
//        }else if(json.has("resultCode")){
//            temp.setUrl(url + json.getString("url") + "?resultCode=" + json.getString("resultCode"));
//        }
        JSONObject json = new JSONObject();
        if(consult != null) {
            json.put("consult", consult.getId());
        }else {
            json.put("id", orderDO.getId());
        }
        messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",patient.getOpenid(),first,null,null,DateUtil.dateToStrShort(new Date()),"上门预约已取消");
        messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",patient.getOpenid(),first,null,null,30,json,DateUtil.dateToStrShort(new Date()),"上门预约已取消");
/*        Consult consult = consultDao.queryByRelationCode(orderId);
        // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
@ -1510,14 +1502,14 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        BasePatientDO patient = patientDao.findById(orderDO.getPatient());
        String first="key1,您好,您的上门预约服务已退回,点击查看原因";
        first = first.replace("key1", null != patient.getName() ? patient.getName() : "");
//        json.put("url", "appoint_service/html/appoint-serviceDetail.html?id="+orderId);
//        json.put("remark", templateConfig.getRemark());
//        if(consult != null) {
//            json.put("consult", consult.getCode());
//        }else {
//            json.put("id", orderDO.getId());
//        }
        messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",patient.getOpenid(),first,null,null,DateUtil.dateToStrShort(new Date()),"知情同意书已推送");
        JSONObject json = new JSONObject();
        json.put("url", "appoint_service/html/appoint-serviceDetail.html?id="+orderId);
        if(consult != null) {
            json.put("consult", consult.getId());
        }else {
            json.put("id", orderDO.getId());
        }
        messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",patient.getOpenid(),first,null,null,30,json,DateUtil.dateToStrShort(new Date()),"知情同意书已推送");
/*        BasePatientDO patient = patientDao.findById(orderDO.getPatient());
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","smyyyqx");

+ 66 - 14
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/util/MessageUtil.java

@ -2,14 +2,17 @@ package com.yihu.jw.door.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.netflix.discovery.converters.Auto;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
@ -55,6 +58,8 @@ public class MessageUtil {
    private WxAccessTokenDao wxAccessTokenDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    //发送微信模板消息
    public static String sendMessageUrl = "http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
@ -128,7 +133,8 @@ public class MessageUtil {
        return responseMsg;
    }
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first, String remark, String url, String... keywords) {
    //推送模板消息
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first,String patientId, String doctorId, Integer type,JSONObject josn,String ...keywords) {
        try {
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (wxAccessTokenDO == null) {
@ -136,42 +142,88 @@ public class MessageUtil {
                return;
            }
            WxTemplateConfigDO newConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
            if (newConfig == null) {
                logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
                return;
            }
            if (StringUtils.isNoneBlank(url)) {
                newConfig.setUrl(url);
            logger.info("微信模板推送前");
            String firstStr = newConfig.getFirst();
            if (StringUtils.isNoneBlank(first)){
                newConfig.setFirst(first);
                firstStr = first;
            }
            if (type==30){//反馈通知
                if (scene.equals("smyyyjjd")){
                    BasePatientDO patient = basePatientDao.findById(patientId);
                    BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctorId);
                    firstStr = firstStr.replace("key1",(patient.getName()==null?"":patient.getName()));
                    firstStr = firstStr.replace("key2", null != baseDoctorDO.getName() ? baseDoctorDO.getName() : "");
                    newConfig.setFirst(firstStr);
                    newConfig.setKeyword1(DateUtil.dateToStrShort(new Date()));
                    newConfig.setKeyword2("上门服务已接单");
                }
                //url + json.getString("url") + "?openid=" + openid + "&consult=" + json.getString("consult")
            }
            if (type==31){ //上门服务医生评分
                firstStr = firstStr.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
                newConfig.setFirst(firstStr);
                newConfig.setKeyword1(DateUtil.dateToStrShort(new Date()));
                newConfig.setKeyword2("服务医生评分");
                //url:url + json.getString("url")+"?openid=" + openid + "&id=" + json.getString("id")+ "&finish=" + finish)
            }
            if(type==32){
                newConfig.setKeyword1(DateUtil.dateToStrShort(new Date()));
                newConfig.setKeyword2("服务项目变更确认");
                //url1 + json.getString("url")+"?openid=" + openid + "&consult=" + json.getString("consult") + "&status=" + json.getInt("status")
            }
            if (StringUtils.isNoneBlank(remark)) {
                newConfig.setRemark(remark);
            if (type==19){
//                String urlStr= newConfig.getUrl();
//                boolean status = urlStr.contains("openid=");
//                if(!status){
//                    urlStr=json.getString("url")+"?openid=" + openid;
//                }
//                temp.setUrl(url + urlStr );
            }
            newConfig.setFirst(first);
            int keyLength = keywords.length;
            if (keyLength >= 1) {
                newConfig.setKeyword1(keywords[0]);
               if(StringUtils.isNoneBlank(keywords[0])){
                   newConfig.setKeyword1(keywords[0]);
                }
            }
            if (keyLength >= 2) {
                newConfig.setKeyword1(keywords[1]);
                if(StringUtils.isNoneBlank(keywords[1])){
                    newConfig.setKeyword1(keywords[1]);
                }
            }
            if (keyLength >= 3) {
                newConfig.setKeyword1(keywords[2]);
                if(StringUtils.isNoneBlank(keywords[2])){
                    newConfig.setKeyword1(keywords[2]);
                }
            }
            if (keyLength >= 4) {
                newConfig.setKeyword1(keywords[3]);
                if(StringUtils.isNoneBlank(keywords[3])){
                    newConfig.setKeyword1(keywords[3]);
                }
            }
            if (keyLength >= 5) {
                newConfig.setKeyword1(keywords[4]);
                if(StringUtils.isNoneBlank(keywords[4])){
                    newConfig.setKeyword1(keywords[4]);
                }
            }
            if (keyLength >= 6) {
                newConfig.setKeyword1(keywords[5]);
                if(StringUtils.isNoneBlank(keywords[5])){
                    newConfig.setKeyword1(keywords[5]);
                }
            }
            if (keyLength >= 7) {
                newConfig.setKeyword1(keywords[6]);
                if(StringUtils.isNoneBlank(keywords[6])){
                    newConfig.setKeyword1(keywords[6]);
                }
            }
            //发起微信消息模板推送
            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
            logger.info("微信模板消息推送后");
        } catch (Exception e) {
            logger.info("微信模板推送异常");
            e.printStackTrace();