package com.yeshi.fanli.service.impl.monitor;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
|
import com.yeshi.fanli.service.inter.config.ConfigService;
|
import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
import com.yeshi.fanli.util.EmergencyUtil;
|
|
@Service
|
public class BusinessEmergent110ServiceImpl implements BusinessEmergent110Service {
|
|
String[] phones = new String[] { "18581318252", "15025351808", "18696787365" };
|
|
private static Map<String, List<String>> map = new HashMap<>();
|
private static long shareTime = 0L;
|
|
@Resource
|
private ConfigService configService;
|
|
@Override
|
public void shareTaoBaoGoodsError(String identifyCode) {
|
String key = "monitor-error-share-tb";
|
int timeM = 5;
|
int limitCount = 5;
|
// 5分钟内错误 5次触发报警
|
|
List<String> stList = map.get(key);
|
if (stList == null) {
|
stList = new ArrayList<>();
|
map.put(key, stList);
|
}
|
if (System.currentTimeMillis() - shareTime > 1000 * 60 * timeM) {
|
stList.clear();
|
shareTime = System.currentTimeMillis();
|
}
|
boolean exist = false;
|
for (String code : stList)
|
if (identifyCode.equalsIgnoreCase(code)) {
|
exist = true;
|
break;
|
}
|
if (!exist)
|
stList.add(identifyCode);
|
if (stList.size() >= limitCount) {// 触发报警
|
if ("1".equalsIgnoreCase(configService.get("can_send_emergency_msg")))
|
EmergencyUtil.baoJin(key, "返利券【分享赚】", phones);
|
}
|
}
|
|
@Override
|
public void buyTaoBaoGoodsError(String identifyCode) {
|
// 5分钟内错误 3次触发报警
|
String key = "monitor-error-buy-tb";
|
int timeM = 5;
|
int limitCount = 5;
|
// 5分钟内错误 5次触发报警
|
List<String> stList = map.get(key);
|
if (stList == null) {
|
stList = new ArrayList<>();
|
map.put(key, stList);
|
}
|
if (System.currentTimeMillis() - shareTime > 1000 * 60 * timeM) {
|
stList.clear();
|
shareTime = System.currentTimeMillis();
|
}
|
boolean exist = false;
|
for (String code : stList)
|
if (identifyCode.equalsIgnoreCase(code)) {
|
exist = true;
|
break;
|
}
|
if (!exist)
|
stList.add(identifyCode);
|
if (stList.size() >= limitCount) {// 触发报警
|
if ("1".equalsIgnoreCase(configService.get("can_send_emergency_msg")))
|
EmergencyUtil.baoJin(key, "返利券【领券返利】", phones);
|
}
|
}
|
|
@Override
|
public void taoBaoAPPKeyLimitError(String appKey, String identifyCode) {
|
// 2分钟内错误 3次触发报警
|
String key = "monitor-error-tb-app-limit-" + appKey;
|
int timeM = 2;
|
int limitCount = 3;
|
// 5分钟内错误 5次触发报警
|
List<String> stList = map.get(key);
|
if (stList == null) {
|
stList = new ArrayList<>();
|
map.put(key, stList);
|
}
|
if (System.currentTimeMillis() - shareTime > 1000 * 60 * timeM) {
|
stList.clear();
|
shareTime = System.currentTimeMillis();
|
}
|
boolean exist = false;
|
for (String code : stList)
|
if (identifyCode.equalsIgnoreCase(code)) {
|
exist = true;
|
break;
|
}
|
if (!exist)
|
stList.add(identifyCode);
|
if (stList.size() >= limitCount) {// 触发报警
|
if ("1".equalsIgnoreCase(configService.get("can_send_emergency_msg")))
|
EmergencyUtil.baoJin(key, "淘宝APPKey请求限制【" + appKey + "】", phones);
|
}
|
}
|
|
}
|