Prechádzať zdrojové kódy

wlyy往医生助手推送模板消息

wujunjie 7 rokov pred
rodič
commit
c40ac812fe

+ 10 - 161
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -42,6 +43,11 @@ public class DoctorFeldsherTemplateService extends BaseService {
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private ImUtill imUtill;
    @Autowired
    private WeiXinTempMsgSendUtils weiXinTempMsgSendUtils;
    @Value("${wechat.message.template_consult_notice}")
    private String templateId;
    @Value("${server.server_url}")
    private String server_url;
@ -91,159 +97,6 @@ public class DoctorFeldsherTemplateService extends BaseService {
        logger.info("sendJson: " + sendJson);
    }
    /**
     * 发送给医生的模板消息提醒
     *
     * @param patientCode 居民code
     * @param doctorCode  医生code
     * @throws Exception
     */
    public void sendDoctorTemplate(String patientCode, String doctorCode, int type) throws Exception {
        int num = 0;
        int num1 = 0;
        int num2 = 0;
        int num3 = 0;
        int num4 = 0;
        int num5 = 0;
        int num6 = 0;
        Date date = new Date();
        Date date1 = new Date();
        String content1 = "";
        String contetn2 = "";
        Patient people = patientDao.findByCode(patientCode);
        String patientOpenId = people.getOpenid();
        String patientName = people.getName();
        int patientSex = people.getSex();
        Doctor doctor = doctorDao.findByCode(doctorCode);
        String doctorName = doctor.getName();
        String doctorOpenId = doctor.getOpenid();
        //使用微信应用宝跳转APP的功能。点击后跳转APP消息页。
        String url = "";
        String first = "";
        String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        JSONObject sendJson = new JSONObject();
        switch (type) {
            case 1:
                first = doctorName + "医生您好,你有一条新的签约申请待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 2:
                first = doctorName + "医生,您的签约居民" + patientName + "有" + num + "条未读的体征异常消息";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 3:
                first = doctorName + "医生您好。" + date + "新增1个签约居民待分配健管师,截至目前共有 " + num1 + " 人待处理";
                sendJson.put("keyword1", "分配健管师");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 4:
                first = "您今日有" + num3 + "个随访计划待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 5:
                first = doctorName + "医生您好,有患者向您发起咨询";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", patientSex == 1 ? "男" : "女");
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 6:
                first = "居民" + patientName + "的健康咨询有新的回复";
                sendJson.put("keyword1", content1);
                sendJson.put("keyword2", contetn2);
                sendJson.put("keyword3", doctorName);
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 7:
                first = doctorName + "医生您好。您的签约居民" + patientName + "申请线上续方,请尽快审核";
                sendJson.put("keyword1", "续方审核");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 8:
                first = doctorName + "医生您好。" + date1 +
                        "新增1个续方订单待分配配送员,目前共" + num4 +
                        "人待分配,一个尽快分配";
                sendJson.put("keyword1", "分配配送员");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 9:
                first = doctorName + "医生您好。您有一个您有1个续方申请处方开立失败";
                sendJson.put("keyword1", doctorName);
                sendJson.put("keyword2", patientName);
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 10:
                first = doctorName + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证";
                sendJson.put("keyword1", "续方审核CA认证");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 11:
                first = doctorName + "医生您好,你有一条新的续签申请待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
        }
    }
    /**
     * 拼装医生助手 医生类模板消息并发送
     *
@ -260,19 +113,15 @@ public class DoctorFeldsherTemplateService extends BaseService {
            String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
            String url = server_url + "wx_doctor/html/home/html/jumpApp.html";
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
            JSONObject sendJson = new JSONObject();
            Doctor doctor = doctorDao.findByCode(doctorCode);
            String doctorName = doctor.getName();
            String doctorOpenId = doctor.getOpenid();
            String first = businessType;
            sendJson.put("keyword1", content);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, doctorOpenId, doctorName, sendJson);
            JSONObject sendJson = weiXinTempMsgSendUtils.packageTemplate(businessType, remark, content, dateFormat.format(new Date()));
            Boolean flag = weiXinTempMsgSendUtils.sendTemplateMessage(templateId, doctorOpenId, url, sendJson);
            logger.info("send wechat message param : " + doctorOpenId+" =======> "+content);
            logger.info("send wechat message retuen : " + flag+" =======> "+flag);
            logger.info("sendJson: " + sendJson);
            return true;
        } catch (Exception e) {

+ 60 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorFeldsherTemplateController.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.web.doctor.template;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * 医生健康指导模板
 * <p>
 * Created by Reece on 2017/9/14.
 */
@RestController
@RequestMapping(value = "/doctor/feldsher")
@Api(description = "医生健康指导模板")
public class DoctorFeldsherTemplateController extends BaseController {
    @Autowired
    private DoctorFeldsherTemplateService feldsherTemplateService;
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    /**
     * @param doctorCode   医生code
     * @param sessionId    会话Id
     * @param sessionType  会话类型
     * @param businessType 消息类型
     * @param from         发送者
     * @param content      消息内容
     * @return
     */
    @RequestMapping(value = "/sendDoctorTemplate", method = RequestMethod.GET)
    @ApiOperation(value = "医生助手给医生发送模板消息")
    public String sendDoctorTemplate(@RequestParam @ApiParam(value = "医生code") String doctorCode,
                                     @RequestParam @ApiParam(value = "会话Id", required = false) String sessionId,
                                     @RequestParam @ApiParam(value = "会话类型", required = false) String sessionType,
                                     @RequestParam @ApiParam(value = "消息类型") String businessType,
                                     @RequestParam @ApiParam(value = "发送者", required = false) String from,
                                     @RequestParam @ApiParam(value = "消息内容") String content) {
        try {
            Boolean flag = feldsherTemplateService.sendDoctorTemplate(doctorCode, sessionId, sessionType, businessType, from, content);
            if (flag){
                return write(200, "发送成功!");
            }else {
                return write( -1, "发送失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}

+ 91 - 0
patient-co/patient-co-doctor-assistant/src/main/resources/application-prod-copy.yml

@ -0,0 +1,91 @@
##正式的配置
spring:
  profiles: prod
  datasource:
    wlyy:
      url: jdbc:mysql://59.61.92.90:8079/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: wlyy
      password: jkzlehr@123
    health:
      url: jdbc:mysql://59.61.92.90:8079/device?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: wlyy
      password: jkzlehr@123
  redis:
    host: 120.41.253.95 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr
server:
  server_url: http://www.xmtyw.cn/assistant/
im:
  im_list_get: http://120.41.253.95:3000/
  data_base_name: im
wechat:
  appId: wx088a4d8e8208e6ce
  appSecret: ab3cdd509fb76fd0149e8864c97e8ddb
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fwww.xmtyw.cn%2fassistant
  accId: gh_b0f086d0d2f5
  message:
   ##模板ID
   ##医生追加建议提醒 --签约邀请
   doctor_invitel_template: MQn79bx1ofb6hekhmRIuqLU7KjySJQzaBzrimgqVrzA
   #咨询回复
   template_consult_notice: 0mF_vHj-ILx8EH8DwzmAi7LqzjqYiU9IrSRRmziTZyc
   #签约成功
   template_sign_success: 0D2vYZVRzFz15p9Y_pkZ1DKutDq8UOsks79FXUKS0tA
   #签约失败
   template_sign_failed: My2VNERjJt4NXR4Ibh42pdrP6B6ka8rQxZeWinQh99s
   #健康指导提醒
   template_health_notice: uv31ES_VCmq3tBYtyGmEQvIwU_zh9LDhF3bFpbIUt5g
   #解约提醒
   template_termination:  C0tdXtA_8k-Cy4a1EkzQuI877vqaqAtRkc-e_Gsd7sk
   #预约成功
   template_appoint_success:  FY3Pqa66tHIE1Fv-irbFBPOh5cYP71fkOzfZKH4S-Fo
   #预约取消
   template_appoint_failed:  tldWEb9AN7p_RoHoD8ml0GxWW3V1V_mpEEhp2v6p56s
   #缴费提醒
   template_expenses_remind:  AcrlihhoGbm22A8cdFFDQ4u38ptRw0aiIPf-aGvNxMM
   #健康教育
   template_healthy_article: a5-ZGf-IUUULsuRNoHWQiBMU6pSYhLgPPqV67SjdLRo
   #医生变更
   template_doctor_change:  dtzSHImbPKfwcrjWlJEjAw3lGlvrLjsobSOE8g4adZA
   #问卷调查
   template_doctor_survey:  8ZWKJmoJ7VR7Uk4YS7aa0Z94QzCkxsyTW6R4CHhUJII
   #审核结果通知
   template_doctor_audit:  egrX5Larpkv8opQW67_hwsZoT0OHwwUpE1v7HeU_Jnw
   #服务结果通知
   template_doctor_service:  xhi1LEudiZwJfZylOHuZNo8EiA73GtSshPQv5XOt9Lk
yihu:
  yihu_OpenPlatform_url: http://api.yihu.com.cn/OpenPlatform/cgiBin/1.0/
  yihu_OpenPlatform_appId: 9000276
  yihu_OpenPlatform_secret: 2JGL19AH3JS55MQY6ZOFJE1JZJ1OF23GWV67MCDQV74
fastDFS:
  fastdfs_file_url: http://www.xmtyw.cn/
images:
  path: /var/local/upload/images
  renew_path: /usr/local/tomcat8/webapps/wlyy/images/renew.png
  sign_path: /usr/local/tomcat8/webapps/wlyy/images/familycontract.png
sign:
  check_upload: http://59.61.92.90:8072/wlyy_service
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: sddf
  sf_check_word: PqFN0ADkTwnvXArMhqGxVduag44vyDQ7
pushMes:
# 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription