admin
2019-05-31 4ef5bf9e64a1eb32e18829c0146a94b3b702fb84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 * 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();
                }
            }
        }
    }
 
}