From 62a447d89331aee1feae7724c7616aa1bb2cfe79 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 16 十月 2024 14:28:37 +0800 Subject: [PATCH] 将CMQ替换为rabbitmq --- fanli/src/main/java/com/yeshi/fanli/service/impl/monitor/BusinessEmergent110ServiceImpl.java | 254 +++++++++++++++++++++++++------------------------- 1 files changed, 127 insertions(+), 127 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/monitor/BusinessEmergent110ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/monitor/BusinessEmergent110ServiceImpl.java index f7b57af..ba7aefa 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/monitor/BusinessEmergent110ServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/monitor/BusinessEmergent110ServiceImpl.java @@ -1,127 +1,127 @@ -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 com.yeshi.fanli.entity.SystemEnum; -import com.yeshi.fanli.util.SystemInfoUtil; -import org.springframework.stereotype.Service; - -import com.yeshi.fanli.entity.system.ConfigKeyEnum; -import com.yeshi.fanli.service.inter.config.ConfigService; -import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service; -import com.yeshi.fanli.util.EmergencyUtil; -import com.yeshi.fanli.util.StringUtil; - -@Service -public class BusinessEmergent110ServiceImpl implements BusinessEmergent110Service { - - String[] phones = new String[] { "18581318252", "15025351808" }; - - private static Map<String, List<String>> map = new HashMap<>(); - private static long shareTime = 0L; - - @Resource - private ConfigService configService; - - @Override - public void shareTaoBaoGoodsError(String identifyCode, SystemEnum system) { - 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.getValue(ConfigKeyEnum.canSendEmergencyMsg.getKey(),system))) - EmergencyUtil.baoJin(key, "鏉挎牀蹇渷銆愬垎浜禋銆�", phones); - } - } - - @Override - public void buyTaoBaoGoodsError(String identifyCode,SystemEnum system) { - // 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.getValue(ConfigKeyEnum.canSendEmergencyMsg.getKey(),system))) - EmergencyUtil.baoJin(key, "鏉挎牀蹇渷銆愰鍒歌繑鍒┿��", phones); - } - } - - @Override - public void taoBaoAPPKeyLimitError(String appKey, String identifyCode, SystemEnum system) { - // 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.getValue(ConfigKeyEnum.canSendEmergencyMsg.getKey(),system))) - EmergencyUtil.baoJin(key, "娣樺疂APPKey璇锋眰闄愬埗銆�" + appKey + "銆�", phones); - } - } - - @Override - public void tljNoMoney(String account, SystemEnum system) { - String key = "monitor-error-tlj-no-money-" + StringUtil.Md5(account); - EmergencyUtil.baoJin(key, String.format("娣樼ぜ閲戣处鎴蜂綑棰濅笉瓒炽�愯处鍙�:%s銆�", account), phones); - } - -} +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 com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.util.SystemInfoUtil; +import org.springframework.stereotype.Service; + +import com.yeshi.fanli.entity.system.ConfigKeyEnum; +import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service; +import com.yeshi.fanli.util.EmergencyUtil; +import com.yeshi.fanli.util.StringUtil; + +@Service +public class BusinessEmergent110ServiceImpl implements BusinessEmergent110Service { + + String[] phones = new String[] { "18581318252", "15025351808" }; + + private static Map<String, List<String>> map = new HashMap<>(); + private static long shareTime = 0L; + + @Resource + private ConfigService configService; + + @Override + public void shareTaoBaoGoodsError(String identifyCode, SystemEnum system) { + 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.getValue(ConfigKeyEnum.canSendEmergencyMsg.getKey(),system))) + EmergencyUtil.baoJin(key, "鏉挎牀蹇渷銆愬垎浜禋銆�", phones); + } + } + + @Override + public void buyTaoBaoGoodsError(String identifyCode,SystemEnum system) { + // 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.getValue(ConfigKeyEnum.canSendEmergencyMsg.getKey(),system))) + EmergencyUtil.baoJin(key, "鏉挎牀蹇渷銆愰鍒歌繑鍒┿��", phones); + } + } + + @Override + public void taoBaoAPPKeyLimitError(String appKey, String identifyCode, SystemEnum system) { + // 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.getValue(ConfigKeyEnum.canSendEmergencyMsg.getKey(),system))) + EmergencyUtil.baoJin(key, "娣樺疂APPKey璇锋眰闄愬埗銆�" + appKey + "銆�", phones); + } + } + + @Override + public void tljNoMoney(String account, SystemEnum system) { + String key = "monitor-error-tlj-no-money-" + StringUtil.Md5(account); + EmergencyUtil.baoJin(key, String.format("娣樼ぜ閲戣处鎴蜂綑棰濅笉瓒炽�愯处鍙�:%s銆�", account), phones); + } + +} -- Gitblit v1.8.0