|
|
|
package com.ynxbd.wx.config;
|
|
|
|
|
|
|
|
import com.ynxbd.common.bean.Patient;
|
|
|
|
import com.ynxbd.common.bean.enums.MerchantEnum;
|
|
|
|
import com.ynxbd.common.bean.pay.Recipe;
|
|
|
|
import com.ynxbd.common.bean.pay.Register;
|
|
|
|
import com.ynxbd.common.dao.PatientDao;
|
|
|
|
import com.ynxbd.common.helper.ProperHelper;
|
|
|
|
import com.ynxbd.common.helper.http.OkHttpHelper;
|
|
|
|
import com.ynxbd.wx.pwe.PWEHelper;
|
|
|
|
import com.ynxbd.wx.utils.DesEncryptHelper;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import okhttp3.FormBody;
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
public class MessagePushConfig {
|
|
|
|
private MessagePushConfig() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final String ORGANIZENAME;
|
|
|
|
|
|
|
|
// 挂号导航是否开启功能=====================================
|
|
|
|
public static final boolean REG_NAVIGATE_IS_ENABLE;
|
|
|
|
// 挂号导航请求链接
|
|
|
|
public static final String REG_NAVIGATE_URL;
|
|
|
|
|
|
|
|
// 挂号成功DateTime是否开启功能==================================
|
|
|
|
public static final boolean REG_IS_ENABLE;
|
|
|
|
// 挂号请求链接
|
|
|
|
public static final String REG_URL;
|
|
|
|
|
|
|
|
// 是否开启功能============================================
|
|
|
|
public static final boolean REG_CANCEL_IS_ENABLE;
|
|
|
|
// 消息推送链接
|
|
|
|
public static final String REG_CANCEL_URL;
|
|
|
|
|
|
|
|
public static final String OBS_DOCUMENT;
|
|
|
|
|
|
|
|
// 是否开启功能============================================
|
|
|
|
public static final boolean RECIPE_IS_ENABLE;
|
|
|
|
|
|
|
|
public static final String REG_AI_URL;
|
|
|
|
public static final boolean REG_AI_IS_ENABLE;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 消息推送主链接
|
|
|
|
*/
|
|
|
|
public static final String HOST_URL;
|
|
|
|
|
|
|
|
// 消息推送链接
|
|
|
|
public static final String RECIPE_URL;
|
|
|
|
|
|
|
|
static {
|
|
|
|
ProperHelper config = new ProperHelper().read("message-push.properties");
|
|
|
|
|
|
|
|
ORGANIZENAME = "4B80803106B38A5F";
|
|
|
|
|
|
|
|
REG_NAVIGATE_IS_ENABLE = config.getBoolean("msg.reg.navigate.is_enable", false);
|
|
|
|
REG_NAVIGATE_URL = config.getString("msg.reg.navigate.url");
|
|
|
|
//
|
|
|
|
REG_IS_ENABLE = config.getBoolean("msg.reg.is_enable", false);
|
|
|
|
REG_URL = config.getString("msg.reg.url");
|
|
|
|
OBS_DOCUMENT = config.getString("msg.obs.document");
|
|
|
|
//
|
|
|
|
REG_CANCEL_IS_ENABLE = config.getBoolean("msg.reg.cancel.is_enable", false);
|
|
|
|
REG_CANCEL_URL = config.getString("msg.reg.cancel.url");
|
|
|
|
HOST_URL = config.getString("msg.host.url");
|
|
|
|
//
|
|
|
|
RECIPE_IS_ENABLE = config.getBoolean("msg.recipe.is_enable", false);
|
|
|
|
RECIPE_URL = config.getString("msg.recipe.url");
|
|
|
|
|
|
|
|
REG_AI_IS_ENABLE = config.getBoolean("msg.ai.is_enable",false);
|
|
|
|
REG_AI_URL = config.getString("msg.ai.url");
|
|
|
|
|
|
|
|
if (REG_CANCEL_URL == null) {
|
|
|
|
log.error("【消息推送】配置文件message-push.properties读取失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 挂号导航推送
|
|
|
|
*
|
|
|
|
* @param reg 挂号信息
|
|
|
|
*/
|
|
|
|
public static void regNavigatePush(MerchantEnum merchantEnum, Register reg) {
|
|
|
|
try {
|
|
|
|
if (!merchantEnum.equals(MerchantEnum.WX)
|
|
|
|
|| !REG_NAVIGATE_IS_ENABLE || ObjectUtils.isEmpty(REG_NAVIGATE_URL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String openid = reg.getOpenid();
|
|
|
|
String patientId = reg.getPatientId();
|
|
|
|
String regDate = reg.getRegDate(); // 挂号日期
|
|
|
|
String begTime = reg.getBegTime(); // 开始时间
|
|
|
|
String endTime = reg.getEndTime(); // 结束时间
|
|
|
|
String doctName = reg.getDoctName();
|
|
|
|
String deptName = reg.getDeptName();
|
|
|
|
String deptCode = reg.getDeptCode();
|
|
|
|
if (openid == null || patientId == null) {
|
|
|
|
log.warn("[推送]挂号导航通知失败,参数缺失~openid={}, patientId={}", openid, patientId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
|
|
|
|
if (patient == null) {
|
|
|
|
log.warn("[推送]挂号导航通知失败,患者信息不存在~");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info("[挂号导航]开始推送 openid={}, patientId={}", openid, patientId);
|
|
|
|
|
|
|
|
String time = (ObjectUtils.isEmpty(begTime) || ObjectUtils.isEmpty(endTime)) ? "" : (" " + begTime + "-" + endTime);
|
|
|
|
|
|
|
|
OkHttpHelper.getAsync(REG_NAVIGATE_URL, params -> {
|
|
|
|
params.put("patientName", patient.getName() + " ID:" + patientId);
|
|
|
|
params.put("content", "就诊时间:" + regDate + time);
|
|
|
|
params.put("deptName", deptName);
|
|
|
|
params.put("deptCode", deptCode);
|
|
|
|
params.put("openId", DesEncryptHelper.enCode(openid));
|
|
|
|
});
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.warn("[推送]挂号导航通知失败 {}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 挂号推送
|
|
|
|
*/
|
|
|
|
public static void regPush(MerchantEnum merchantEnum, Register reg) {
|
|
|
|
try {
|
|
|
|
if (!merchantEnum.equals(MerchantEnum.WX)
|
|
|
|
|| !REG_IS_ENABLE || reg == null || ObjectUtils.isEmpty(REG_URL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info("[推送]挂号通知...");
|
|
|
|
String openid = reg.getOpenid();
|
|
|
|
String patientId = reg.getPatientId();
|
|
|
|
String regDate = reg.getRegDate(); // 挂号日期
|
|
|
|
String begTime = reg.getBegTime(); // 开始时间
|
|
|
|
String endTime = reg.getEndTime(); // 结束时间
|
|
|
|
String doctName = reg.getDoctName();
|
|
|
|
String deptName = reg.getDeptName();
|
|
|
|
String deptCode = reg.getDeptCode();
|
|
|
|
String tradeNo = reg.getTradeNo();
|
|
|
|
if (openid == null || patientId == null) {
|
|
|
|
log.warn("[推送]挂号通知失败,参数缺失~openid={}, patientId={}", openid, patientId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
|
|
|
|
if (patient == null) {
|
|
|
|
log.warn("[推送]挂号通知失败,患者信息不存在");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String time = (ObjectUtils.isEmpty(begTime) || ObjectUtils.isEmpty(endTime)) ? "" : (" " + begTime + "-" + endTime);
|
|
|
|
|
|
|
|
|
|
|
|
OkHttpHelper.getAsync(REG_URL, params -> {
|
|
|
|
params.put("openId", DesEncryptHelper.enCode(openid));
|
|
|
|
params.put("patientName", patient.getName() + " ID:" + patientId);
|
|
|
|
params.put("deptName", deptName);
|
|
|
|
params.put("doctor", doctName + "(" + regDate + time + ")"); // 医生姓名
|
|
|
|
params.put("sex", patient.getSex()); // 医生姓名
|
|
|
|
params.put("seq", ""); // HIS交易流水号
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.warn("[推送]挂号通知 {}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AI诊疗推送
|
|
|
|
* @param merchantEnum
|
|
|
|
* @param reg
|
|
|
|
*/
|
|
|
|
public static void regAI(MerchantEnum merchantEnum,Register reg){
|
|
|
|
try {
|
|
|
|
if (!merchantEnum.equals(MerchantEnum.WX)
|
|
|
|
|| !REG_AI_IS_ENABLE || reg == null || ObjectUtils.isEmpty(REG_AI_URL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info("[推送]AI智能问诊推送...");
|
|
|
|
String patientId = reg.getPatientId();
|
|
|
|
if ( patientId == null) {
|
|
|
|
log.warn("[推送]AI智能问诊推送通知失败,参数缺失~ patientId= null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String url = PWEHelper.getH5PWEUrl(reg.getOutTradeNo(),reg.getOpenid());
|
|
|
|
if(url==null||"".equals(url)){
|
|
|
|
log.warn("[推送][推送]AI智能问诊推送通知失败,问诊获取参数为空 outTradeNo-{}",reg.getOutTradeNo());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestBody requestBody = new FormBody.Builder()
|
|
|
|
.add("patientId",patientId)
|
|
|
|
.add("content","为了帮助医生更全面地了解您的身体情况,请花2分钟时间填写病情信息,以便医生提前了解病症,为您提供更好的诊疗服务。")
|
|
|
|
.add("url", url)
|
|
|
|
.add("organizeName",ORGANIZENAME)
|
|
|
|
.build();
|
|
|
|
OkHttpHelper.post(OBS_DOCUMENT, requestBody);
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.warn("[推送]AI智能问诊推送通知错误-{}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AI诊疗推送
|
|
|
|
* @param patientId
|
|
|
|
*/
|
|
|
|
public static void regAIReport(String patientId,String outTradeNo,String openId){
|
|
|
|
try {
|
|
|
|
if (!REG_AI_IS_ENABLE || ObjectUtils.isEmpty(REG_AI_URL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log.info("[推送]AI问诊报告推送...");
|
|
|
|
if ( patientId == null) {
|
|
|
|
log.warn("[推送]AI问诊报告推送通知失败,参数缺失~ patientId= null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
String url = PWEHelper.getH5PWEUrl(outTradeNo,openId);
|
|
|
|
if(url==null||"".equals(url)){
|
|
|
|
log.warn("[推送]AI问诊报告推送通知失败,问诊获取参数为空 outTradeNo-{}",outTradeNo);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestBody requestBody = new FormBody.Builder()
|
|
|
|
.add("patientId",patientId)
|
|
|
|
.add("content","您好,您的预问诊报告可以查看啦")
|
|
|
|
.add("url", url)
|
|
|
|
.add("organizeName",ORGANIZENAME)
|
|
|
|
.build();
|
|
|
|
OkHttpHelper.post(OBS_DOCUMENT, requestBody);
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.warn("[推送]AI问诊报告推送通知错误-{}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 红河州医院产科建党推送
|
|
|
|
* @param merchantEnum
|
|
|
|
* @param reg
|
|
|
|
*/
|
|
|
|
public static void regObsDocument(MerchantEnum merchantEnum, Register reg){
|
|
|
|
try {
|
|
|
|
if (!merchantEnum.equals(MerchantEnum.WX)
|
|
|
|
|| reg == null || ObjectUtils.isEmpty(OBS_DOCUMENT)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info("[推送]产科建档推送通知...");
|
|
|
|
String patientId = reg.getPatientId();
|
|
|
|
if ( patientId == null) {
|
|
|
|
log.warn("[推送]产科建档推送通知失败,参数缺失~ patientId= null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestBody requestBody = new FormBody.Builder()
|
|
|
|
.add("patientId",patientId)
|
|
|
|
.add("content","[孕产建档提示]尊敬的孕妈妈您好!为了向您提供更好的服务,请点击下方链接完成孕产建档,若您已建档请忽略!")
|
|
|
|
.add("url","https://zhck.hhzyy.com:10082/wxapp/")
|
|
|
|
.add("organizeName",ORGANIZENAME)
|
|
|
|
.add("buttonName","进入产科建档系统")
|
|
|
|
.build();
|
|
|
|
OkHttpHelper.post(OBS_DOCUMENT, requestBody);
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.warn("[推送]产科建档推送通知错误-{}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 取消预约推送
|
|
|
|
*/
|
|
|
|
public static void regCancelPush(MerchantEnum merchantEnum, Register reg) {
|
|
|
|
try {
|
|
|
|
if (!merchantEnum.equals(MerchantEnum.WX)
|
|
|
|
|| !REG_CANCEL_IS_ENABLE || reg == null || ObjectUtils.isEmpty(REG_CANCEL_URL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log.info("[推送]取消预约...");
|
|
|
|
String openid = reg.getOpenid();
|
|
|
|
String patientId = reg.getPatientId();
|
|
|
|
String regDate = reg.getRegDate(); // 挂号日期
|
|
|
|
String begTime = reg.getBegTime(); // 开始时间
|
|
|
|
String endTime = reg.getEndTime(); // 结束时间
|
|
|
|
String doctName = reg.getDoctName();
|
|
|
|
String deptName = reg.getDeptName();
|
|
|
|
String deptCode = reg.getDeptCode();
|
|
|
|
String tradeNo = reg.getTradeNo();
|
|
|
|
if (openid == null || patientId == null) {
|
|
|
|
log.warn("[推送]取消预约通知失败,参数缺失~openid={}, patientId={}", openid, patientId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
|
|
|
|
if (patient == null) {
|
|
|
|
log.info("[推送]取消预约通知失败,患者信息不存在~");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String time = (ObjectUtils.isEmpty(begTime) || ObjectUtils.isEmpty(endTime)) ? "" : (" " + begTime + "-" + endTime);
|
|
|
|
|
|
|
|
OkHttpHelper.getAsync(REG_CANCEL_URL, params -> {
|
|
|
|
params.put("openId", DesEncryptHelper.enCode(openid));
|
|
|
|
params.put("patientName", patient.getName() + " ID:" + patientId);
|
|
|
|
params.put("deptName", deptName);
|
|
|
|
params.put("treatTime", regDate + time); // 就诊时间
|
|
|
|
params.put("seq", "");
|
|
|
|
params.put("doctor", doctName); // 医生姓名
|
|
|
|
params.put("sex", patient.getSex()); // 性别
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.warn("[推送]取消预约通知失败 {}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 缴费成功推送
|
|
|
|
*/
|
|
|
|
public static void recipePush(List<Recipe> recipeList, String treatNum, String patientId, String openid, String tip) {
|
|
|
|
try {
|
|
|
|
if (!RECIPE_IS_ENABLE || ObjectUtils.isEmpty(RECIPE_URL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(treatNum) || ObjectUtils.isEmpty(patientId) || ObjectUtils.isEmpty(openid)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
Recipe recipe;
|
|
|
|
for (int i = 0; i < recipeList.size(); i++) {
|
|
|
|
recipe = recipeList.get(i);
|
|
|
|
if (recipe != null) {
|
|
|
|
sb.append(recipe.getRecipeId());
|
|
|
|
if ((i + 1) != recipeList.size()) {
|
|
|
|
sb.append("、");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
|
|
|
|
if (patient == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
OkHttpHelper.getAsync(RECIPE_URL, params -> {
|
|
|
|
params.put("openId", DesEncryptHelper.enCode(openid));
|
|
|
|
params.put("patientName", patient.getName() + " ID:" + patientId);
|
|
|
|
params.put("content", tip);
|
|
|
|
params.put("treatNum", treatNum);
|
|
|
|
params.put("recipeIds", sb.toString());
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.warn("[推送]缴费信息通知失败 {}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|