| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.yeshi.fanli.exception.SMSException;
|
| | |
|
| | | /**
|
| | | * 紧急告警
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class EmergencyUtil {
|
| | |
|
| | | static Map<String, Long> emergentTimeMap = new HashMap<>();
|
| | |
|
| | | public static void baoJin(String key, String name, String[] phones) {
|
| | | if (emergentTimeMap.get(key) == null || System.currentTimeMillis() - emergentTimeMap.get(key) > 1000 * 60 * 2)// 2分钟报警一次
|
| | | {
|
| | | emergentTimeMap.put(key, System.currentTimeMillis());
|
| | | // 发送短信
|
| | | for (String phone : phones) {
|
| | | try {
|
| | | TencentSMSUtil.sendSingleMsg(phone, Constant.smsConfig.getServiceEmergency()
|
| | | .replace("[签名]", Constant.smsConfig.getSmsSign()).replace("[服务名字]", name));
|
| | | } catch (SMSException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.util; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.yeshi.fanli.exception.config.SMSException; |
| | | |
| | | /** |
| | | * 紧急告警 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class EmergencyUtil { |
| | | |
| | | static Map<String, Long> emergentTimeMap = new HashMap<>(); |
| | | |
| | | public static void baoJin(String key, String name, String[] phones) { |
| | | if (emergentTimeMap.get(key) == null || System.currentTimeMillis() - emergentTimeMap.get(key) > 1000 * 60 * 10)// 10分钟报警一次 |
| | | { |
| | | emergentTimeMap.put(key, System.currentTimeMillis()); |
| | | // 发送短信 |
| | | for (String phone : phones) { |
| | | try { |
| | | TencentSMSUtil.sendSingleMsg(phone, Constant.smsConfig.getServiceEmergency() |
| | | .replace("[签名]", Constant.smsConfig.getSmsSign()).replace("[服务名字]", name)); |
| | | } catch (SMSException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |