feat:危机值推送

master
李进才 1 year ago
parent 9f105b674c
commit 31d05eacd4
  1. 31
      src/main/java/com/ynxbd/push/controller/BusinessController.java
  2. 3
      src/main/java/com/ynxbd/push/entity/type/MessageTypeEnum.java
  3. 4
      src/main/java/com/ynxbd/push/entity/type/OrganizeTypeEnum.java
  4. 7
      src/main/java/com/ynxbd/push/helper/BusinessHelper.java
  5. 2
      src/main/java/com/ynxbd/push/helper/DesEncryptHelper.java
  6. 60
      src/main/java/com/ynxbd/push/helper/MessageApiHelper.java
  7. 3
      src/main/java/com/ynxbd/push/helper/TemplateSelectHelper.java
  8. 4
      src/main/java/com/ynxbd/push/httpRequest/tencent/WeChatDataRequest.java
  9. 28
      src/main/java/com/ynxbd/push/rabbit/receive/RabbitReceiver.java
  10. 8
      src/main/resources/weChat.ini

@ -122,10 +122,36 @@ public class BusinessController {
return ResponseResult.JOIN_QUEUE.toMessResult();
}
@PostMapping("cvms")
@ResponseBody
public MessageSendResult cvms(String content, String patientId, String url, String organizeName, String IdCard, String buttonName,String deptCode){
log.info("进入接口-[危机值推送接口]-医院通知/新版本待定,content-{},patientId-{},url-{},organizeName-{},IdCard-{},buttonName-{},deptCode-{}", content, patientId, url, organizeName, IdCard,buttonName,deptCode);
MessageSendResult check = BusinessHelper.ParamsCheck(organizeName, patientId, null, deptCode);
if (!check.getErrcode().equals("0")) {
return check;
}
if (content == null) {
log.info("[危机值推送接口]-医院通知/新版本待定, 必填字段为空");
return ResponseResult.PARAMETER_IS_NULL.toMessResult();
}
Map<String, String> message = new HashMap<>();
message.put("tip", MessageTypeEnum.CVMS.CODE);
message.put("organizeName", organizeName);
message.put("buttonName",buttonName);
message.put("patientId", patientId);
message.put("deptCode", deptCode);
message.put("IdCard", IdCard);
message.put("content", content);
message.put("url", url == null ? "" : url);
rabbitSender.TipSend(message);
return ResponseResult.JOIN_QUEUE.toMessResult();
}
@PostMapping("universal")
@ResponseBody
public MessageSendResult universal(String content, String patientId, String url, String organizeName, String IdCard, String doctorCode) {
log.info("进入接口-[通用推送接口]-绑定通知,content-{},patientId-{},url-{},organizeName-{},IdCard-{},doctorCode-{}", content, patientId, url, organizeName, IdCard, doctorCode);
public MessageSendResult universal(String content, String patientId, String url, String organizeName, String IdCard, String doctorCode,String buttonName) {
log.info("进入接口-[通用推送接口]-绑定通知,content-{},patientId-{},url-{},organizeName-{},IdCard-{},doctorCode-{},buttonName-{}", content, patientId, url, organizeName, IdCard, doctorCode,buttonName);
MessageSendResult check = BusinessHelper.ParamsCheck(organizeName, patientId, null, doctorCode);
if (!check.getErrcode().equals("0")) {
return check;
@ -137,6 +163,7 @@ public class BusinessController {
Map<String, String> message = new HashMap<>();
message.put("tip", MessageTypeEnum.UNIVERSAL.CODE);
message.put("organizeName", organizeName);
message.put("buttonName",buttonName);
message.put("patientId", patientId);
message.put("doctorCode", doctorCode);
message.put("IdCard", IdCard);

@ -16,8 +16,11 @@ public enum MessageTypeEnum {
TREAT_PLAN("treatPlan","诊疗计划提醒"),
UNIVERSAL("Universal","通用模版推送-绑定通知"),
CVMS("CVMS","危机值推送"),
COMMON("COMMON","COMMON");
public final String CODE;
public final String MESSAGE;

@ -15,7 +15,9 @@ public enum OrganizeTypeEnum {
CVMS("D7FAEFB46E8F5FEF","危机值管理系统","新八达危机值管理系统"),
HONGHE01("","深圳市理邦精密仪器股份有限公司","智慧产科系统");
HONGHE01("","深圳市理邦精密仪器股份有限公司","智慧产科系统"),
WEI_XIN("4B80803106B38A5F","xbd_wx","公司内部对接使用,微信方对接");
public final String CODE;
public final String NAME;

@ -11,6 +11,13 @@ import weixin.popular.bean.message.MessageSendResult;
*/
public class BusinessHelper {
/**
*
* @param organizeName
* @param patientId
* @param idCard
* @param doctorCode 有时候也会传deptCode验证
*/
public static MessageSendResult ParamsCheck(String organizeName, String patientId, String idCard, String doctorCode) {
MessageSendResult messageSendResult = new MessageSendResult();
if (patientId == null && idCard == null && doctorCode == null) {

@ -74,7 +74,7 @@ public class DesEncryptHelper {
public static void main(String[] args) {
String test = "昨日门诊:3697人次;非核酸门诊:2302人次;在院:1377人;入院:224人;出院:191人;危重:0人;手术:61人次;微创手术:16人次;四级手术:6人次;\\\\r\\\\n今年截至昨日门诊:794298人次;非核酸门诊:423528人次;出院:32130人;实际开放床:1224张;病床使用率:91.512;手术:8816人次,占比:28;四级手术占比:19.01;微创手术占比:17.35;";
System.out.println(test.replaceAll("\\\\\\\\r", "\\\\r"));
System.out.println(DesEncryptHelper.enCode("xbd_CVMS", KEY));
System.out.println(DesEncryptHelper.enCode("xbd_wx", KEY));
System.out.println(DesEncryptHelper.deCode("C23A7500D2C35F9A85B72795B86F02AFD62A5ECBD06DC050DF47EFA26AA846E3E3FF998FFA576283C021712DD1CAA7EEF74898A8CDFE9ABA8C06C1851574CB802FA096B4B0D8ED791559DEEDFE0BD497AC5365E6370223EF3D706F0BC2427619C762C77B776510D566A36F439CB579A5C55674435F0D800BC44B3299BF484B716D121601D32E26E2", KEY));
System.out.println("---");

@ -65,6 +65,9 @@ public class MessageApiHelper {
* @return
*/
public static MessageSendResult templateMessageSend(SendMessageTemplate template) {
if(template.getCode()==null){
template.setCode("");
}
MessageSendResult messageSendResult = templateMessage(template);
log.info("消息发送状态:腾讯返回-{},messageId-{},openId-{}", messageSendResult.getErrcode(), template.getMessage_id(), template.getOpenId());
return messageSendResult;
@ -180,9 +183,13 @@ public class MessageApiHelper {
}
String reportTemplateId = WeChatDataRequest.getTemplateId(title);
if ("绑定通知".equals(title) && reportTemplateId == null) {
reportTemplateId = WeChatDataRequest.getTemplateId("医院通知");
title = "医院通知";
reportTemplateId = WeChatDataRequest.getTemplateId(title);
}
if (IniConfig.getInstance("templateVersion") == null) {
if(reportTemplateId==null){
log.error("获取模版Id失败,messageId-{},title-{}",messageId,title);
}
if (IniConfig.getInstance("templateVersion") == null) { // 老版本默认参数用keyword关键字
code = "";
}
if (doctorCode != null) {
@ -244,7 +251,54 @@ public class MessageApiHelper {
.openId(openId)
.url(url)
.build();
return templateMessageSend(sendMessageTemplate);
MessageSendResult messageSendResult = templateMessageSend(sendMessageTemplate);
log.info("[{}]{}患者消息推送,推送结果代码-{},推送结果-{}", title, DesEncryptHelper.deCode(organizeName), messageSendResult.getErrcode(), messageSendResult.getErrmsg());
return ResponseResult.JOIN_QUEUE.toMessResult();
}
public static MessageSendResult TemplateMessageForDeptCode(String organizeName, String code, String idCard, String title, String patientId, String deptCode, String first, String keyword1, String keyword2, String keyword3, String keyword4, String keyword5, String remark, String url, String messageId) {
if (patientId == null && idCard == null && deptCode == null) {
log.info("[{}]参数无效", title);
return ResponseResult.PARAMETER_IS_NULL.toMessResult();
}
if (DesEncryptHelper.deCode(organizeName).equals("error:null")) {
log.info("[{}]组织机构代码无效,organizeName-{}", title, organizeName);
return ResponseResult.ORGANIZE_IS_NULL.toMessResult();
}
String reportTemplateId = WeChatDataRequest.getTemplateId(title);
if (reportTemplateId == null) {
log.error("获取模版Id失败,messageId-{},title-{}", messageId, title);
}
if (IniConfig.getInstance("templateVersion") == null) { // 老版本默认参数用keyword关键字
code = "";
}
List<String> allDoctorOpenIdList = WeChatDataRequest.getAllOpenIdForDeptCode(deptCode);
if(allDoctorOpenIdList.isEmpty()){
log.error("获取科室人员openId出错,deptCode-{}",deptCode);
return ResponseResult.NOT_FIND_DATA.toMessResult();
}
for (String interfaceOpenId : allDoctorOpenIdList) {
String openId = AesCodeHelper.deCode(interfaceOpenId);
SendMessageTemplate sendMessageTemplate = SendMessageTemplate.builder()
.template_id(reportTemplateId)
.first(first)
.code(code)
.message_id(messageId)
.keyword1(keyword1)
.keyword2(keyword2)
.keyword3(keyword3)
.keyword4(keyword4)
.keyword5(keyword5)
.remark(remark)
.openId(openId)
.url(url)
.build();
MessageSendResult messageSendResult = templateMessageSend(sendMessageTemplate);
log.info("[{}]{}医生账号消息推送,推送结果代码-{},推送结果-{}", title, DesEncryptHelper.deCode(organizeName), messageSendResult.getErrcode(), messageSendResult.getErrmsg());
}
return ResponseResult.JOIN_QUEUE.toMessResult();
}
/**

@ -9,6 +9,9 @@ import com.ynxbd.push.entity.tencent.SendMessageTemplate;
public class TemplateSelectHelper {
public static String select(SendMessageTemplate sendMessageTemplate) throws JsonProcessingException {
String jsonString = null;
if(sendMessageTemplate.getCode()==null){
sendMessageTemplate.setCode("");
}
switch (sendMessageTemplate.getCode()) {
case "1":
jsonString = TemplateJsonStringHelper.get1(sendMessageTemplate);

@ -46,6 +46,10 @@ public class WeChatDataRequest {
return RequestHelper.get("http://127.0.0.1:9090/micro/msg_push/doctorOpenIds?doctCode="+doctorCode, null, WeChatResponse.class).getData();
}
public static List<String> getAllOpenIdForDeptCode(String deptCode){
return RequestHelper.get("http://127.0.0.1:9090/micro/msg_push/deptOpenIds?deptCode="+deptCode, null, WeChatResponse.class).getData();
}
public static WeChatAllDoctorResponse getAllOpenIdForDoctorCode() {
return RequestHelper.get("http://127.0.0.1:9090/micro/msg_push/doctorOpenIdTree", null, WeChatAllDoctorResponse.class);
}

@ -77,7 +77,9 @@ public class RabbitReceiver {
case COMMON:
commonRetry(receiveMessage);
break;
case CVMS:
cvms(receiveMessage);
break;
default:
log.info("未找到消息类型进行推送,类型-{}", tip);
break;
@ -179,6 +181,24 @@ public class RabbitReceiver {
retry(MessageApiHelper.TemplateMessageForCode(organizeName, code, null, "诊疗计划提醒", patientId, null, title, name, planTime, content, null, null, remark, url, messageId), receiveMessage);
}
private void cvms(Map<String, String> receiveMessage) {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern("yyyy-MM-dd");
Date date = new Date();
String organizeName = receiveMessage.get("organizeName");
String code = receiveMessage.get("tip");
String messageId = receiveMessage.get("message_id");
String patientId = receiveMessage.get("patientId");
String content = receiveMessage.get("content");
String url = receiveMessage.get("url");
String IdCard = receiveMessage.get("IdCard");
String deptCode = receiveMessage.get("deptCode");
url = IniConfig.getInstance("domain") + "wx/" + IniConfig.getInstance("weChatUIPath") + "push-universal.html?patientId=" + ("".equals(patientId)||patientId==null ? "": Base64.getEncoder().encodeToString(patientId.getBytes())) + "&content=" + Base64.getEncoder().encodeToString(UriUtils.encode(content, StandardCharsets.UTF_8.toString()).getBytes()) + "&time=" + Base64.getEncoder().encodeToString(sdf.format(date).getBytes()) + "&url=" + ("".equals(url)||url==null?"":Base64.getEncoder().encodeToString(UriUtils.encode(url, StandardCharsets.UTF_8.toString()).getBytes()));
retry(MessageApiHelper.TemplateMessageForDeptCode(organizeName, code, IdCard, "医院通知", patientId, deptCode, null, sdf.format(date), content, null, null, null, null, url, messageId), receiveMessage);
}
private void universal(Map<String, String> receiveMessage) {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern("yyyy-MM-dd");
@ -190,13 +210,15 @@ public class RabbitReceiver {
String content = receiveMessage.get("content");
String url = receiveMessage.get("url");
String IdCard = receiveMessage.get("IdCard");
String buttonName = receiveMessage.get("buttonName");
String doctorCode = receiveMessage.get("doctorCode");
String viewUrl;
if (!"".equals(url)) {
if (!"".equals(url)&&("".equals(buttonName)||buttonName==null)) {
viewUrl = url;
} else {
viewUrl = IniConfig.getInstance("domain") + "wx/" + IniConfig.getInstance("weChatUIPath") + "push-universal.html?patientId=" + ("".equals(patientId) ? Base64.getEncoder().encodeToString(patientId.getBytes()) : "") + "&content=" + Base64.getEncoder().encodeToString(UriUtils.encode(content, StandardCharsets.UTF_8.toString()).getBytes()) + "&time=" + Base64.getEncoder().encodeToString(sdf.format(date).getBytes());
viewUrl = IniConfig.getInstance("domain") + "wx/" + IniConfig.getInstance("weChatUIPath") + "push-universal.html?patientId=" + ("".equals(patientId)||patientId==null ? "": Base64.getEncoder().encodeToString(patientId.getBytes())) + "&content=" + Base64.getEncoder().encodeToString(UriUtils.encode(content, StandardCharsets.UTF_8.toString()).getBytes()) + "&time=" + Base64.getEncoder().encodeToString(sdf.format(date).getBytes()) + "&url=" + ("".equals(url)||url==null?"":Base64.getEncoder().encodeToString(UriUtils.encode(url, StandardCharsets.UTF_8.toString()).getBytes())) + "&buttonName=" + ("".equals(buttonName)||buttonName==null?"":Base64.getEncoder().encodeToString(UriUtils.encode(buttonName, StandardCharsets.UTF_8.toString()).getBytes()));
}
log.info("[通用消息推送] 转换链接打印 messageId-{}, url-{}",messageId, viewUrl);
if (IniConfig.getInstance("templateVersion") != null) {
content = content.substring(0, 16) + "……";
}

@ -46,7 +46,7 @@ leaderTime = 0 00 08 * * ?
domain = http://www.ysxrmyy901.com/
token_url= http://www.ysxrmyy901.com/wx/api/getWxAccessToken.do
templateVersion = new
weChatUIPath = /
weChatUIPath =
[192.168.0.228]
@ -139,7 +139,7 @@ leaderUrl = 200.200.200.105:8080
leaderTime = 0 05 08 * * ?
domain = http://www.ysxrmyy901.com/
templateVersion = new
weChatUIPath = /
weChatUIPath =
[192.168.10.8]
@ -147,9 +147,9 @@ name = 宁蒗县人民医院
weChatUrl = http://www.nlxrmyy.cn/wx/
leaderTemplateId = X0iIY4uKZC_feYKD1RfrgIwXM9E0ryHdqs4xVrC00DY
leaderUrl = 192.168.10.43:8080
leaderTime = 0 05 08 * * ?
leaderTime = 0 00 06 * * ?
domain = http://www.nlxrmyy.cn/
templateVersion = new
weChatUIPath = /
weChatUIPath =

Loading…
Cancel
Save