You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					75 lines
				
				2.9 KiB
			
		
		
			
		
	
	
					75 lines
				
				2.9 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								//package com.ynxbd.wx.remove.util;//package com.ynxbd.wx.utils;
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//import com.ynxbd.wx.wxfactory.WxCacheHelper;
							 | 
						||
| 
								 | 
							
								//import lombok.extern.slf4j.Slf4j;
							 | 
						||
| 
								 | 
							
								//import org.apache.commons.lang3.StringUtils;
							 | 
						||
| 
								 | 
							
								//import weixin.popular.api.MessageAPI;
							 | 
						||
| 
								 | 
							
								//import weixin.popular.bean.message.massmessage.MassMPnewsMessage;
							 | 
						||
| 
								 | 
							
								//import weixin.popular.bean.message.massmessage.MassTextMessage;
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//import java.text.SimpleDateFormat;
							 | 
						||
| 
								 | 
							
								//import java.util.Date;
							 | 
						||
| 
								 | 
							
								//import java.util.HashSet;
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//@Slf4j
							 | 
						||
| 
								 | 
							
								//public class CommonUtil {
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//    /**
							 | 
						||
| 
								 | 
							
								//     * 推送消息
							 | 
						||
| 
								 | 
							
								//     */
							 | 
						||
| 
								 | 
							
								//    public static void sendText(String openid, String name, String patientId, String pushInfo) {
							 | 
						||
| 
								 | 
							
								//        if (StringUtils.isEmpty(openid) || StringUtils.isEmpty(patientId) || StringUtils.isEmpty(pushInfo)) {
							 | 
						||
| 
								 | 
							
								//            return;
							 | 
						||
| 
								 | 
							
								//        }
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//        try {
							 | 
						||
| 
								 | 
							
								//            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//            MassTextMessage textMessage = new MassTextMessage("日期:" + format.format(new Date())
							 | 
						||
| 
								 | 
							
								//                    + "\nID:" + patientId
							 | 
						||
| 
								 | 
							
								//                    + "\n患者:" + name
							 | 
						||
| 
								 | 
							
								//                    + "\n内容:" + pushInfo);
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//            textMessage.setTouser(new HashSet<>());
							 | 
						||
| 
								 | 
							
								//            textMessage.getTouser().add(openid);
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//            String accessToken = WxCacheHelper.getAccessToken();
							 | 
						||
| 
								 | 
							
								//            MessageAPI.messageMassSend(WxCacheHelper.getAccessToken(), textMessage);
							 | 
						||
| 
								 | 
							
								//            MessageAPI.messageMassPreview(accessToken, textMessage.convert());
							 | 
						||
| 
								 | 
							
								//        } catch (Exception e) {
							 | 
						||
| 
								 | 
							
								//            log.info("[消息推送]失败:openid={}, patientId={}, pushInfo={}, errMessage={}", openid, patientId, pushInfo, e.getMessage());
							 | 
						||
| 
								 | 
							
								//        }
							 | 
						||
| 
								 | 
							
								//    }
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//    /**
							 | 
						||
| 
								 | 
							
								//     * 推送消息
							 | 
						||
| 
								 | 
							
								//     */
							 | 
						||
| 
								 | 
							
								//    public static void sendImgText(String openid, String name, String patientId, String pushInfo) {
							 | 
						||
| 
								 | 
							
								//        if (StringUtils.isEmpty(openid) || StringUtils.isEmpty(patientId) || StringUtils.isEmpty(pushInfo)) {
							 | 
						||
| 
								 | 
							
								//            return;
							 | 
						||
| 
								 | 
							
								//        }
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//        try {
							 | 
						||
| 
								 | 
							
								//            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//            MassMPnewsMessage message = new MassMPnewsMessage("media_id");
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								////            MassTextMessage textMessage = new MassTextMessage("日期:" + format.format(new Date())
							 | 
						||
| 
								 | 
							
								////                    + "\nID:" + patientId
							 | 
						||
| 
								 | 
							
								////                    + "\n患者:" + name
							 | 
						||
| 
								 | 
							
								////                    + "\n内容:" + pushInfo);
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								////            message.setTouser(new HashSet<>());
							 | 
						||
| 
								 | 
							
								////            message.getTouser().add(openid);
							 | 
						||
| 
								 | 
							
								////
							 | 
						||
| 
								 | 
							
								////            String accessToken = WxCacheHelper.getAccessToken();
							 | 
						||
| 
								 | 
							
								////            MessageAPI.messageMassSend(WxCacheHelper.getAccessToken(), textMessage);
							 | 
						||
| 
								 | 
							
								////            MessageAPI.messageMassPreview(accessToken, textMessage.convert());
							 | 
						||
| 
								 | 
							
								//        } catch (Exception e) {
							 | 
						||
| 
								 | 
							
								//            log.info("[消息推送]失败:openid={}, patientId={}, pushInfo={}, errMessage={}", openid, patientId, pushInfo, e.getMessage());
							 | 
						||
| 
								 | 
							
								//        }
							 | 
						||
| 
								 | 
							
								//    }
							 | 
						||
| 
								 | 
							
								//}
							 |