Commit 57e36b3b by 徐高华

test

parent 8a69d1a2
...@@ -39,29 +39,29 @@ public class QwTimesUtils { ...@@ -39,29 +39,29 @@ public class QwTimesUtils {
QwTimesUtils.enterpriseService = enterpriseService; QwTimesUtils.enterpriseService = enterpriseService;
} }
public static boolean isLimit(String wxEnterpriseId, String enterpriseId, QwInterfaceLimitEnum obj) { public static boolean isLimit(String wxEnterpriseId, String enterpriseId, QwInterfaceLimitEnum qwInterface) {
QwLimitTimesBO setTimeBO = getSettingTimes(wxEnterpriseId, obj); QwLimitTimesBO setTimeBO = getSettingTimes(wxEnterpriseId, qwInterface);
logger.info("获取配置次数={},wxEnterpriseId={}", JSON.toJSONString(setTimeBO), wxEnterpriseId); logger.info("获取配置次数={},wxEnterpriseId={}", JSON.toJSONString(setTimeBO), wxEnterpriseId);
// 先判断月 // 先判断月
String interfaceName = obj.getName(); String interfaceName = qwInterface.getName();
Date now = new Date(); Date now = new Date();
String dateStr = getDateStr(now); String dateStr = getDateStr(now);
String keyMonth = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 6)); String keyMonth = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 6));
boolean monthResult = timesCheck(1, keyMonth, obj, wxEnterpriseId, enterpriseId, now, setTimeBO); boolean monthResult = timesCheck(1, keyMonth, qwInterface, wxEnterpriseId, enterpriseId, now, setTimeBO);
if (monthResult) { if (monthResult) {
logger.info("月达到限制={}", keyMonth); logger.info("月达到限制={}", keyMonth);
return true; return true;
} }
// 天 // 天
String keyDay = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 8)); String keyDay = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 8));
boolean dayResult = timesCheck(2, keyDay, obj, wxEnterpriseId, enterpriseId, now, setTimeBO); boolean dayResult = timesCheck(2, keyDay, qwInterface, wxEnterpriseId, enterpriseId, now, setTimeBO);
if (dayResult) { if (dayResult) {
logger.info("天达到限制={}", keyDay); logger.info("天达到限制={}", keyDay);
return true; return true;
} }
// 小时 // 小时
String keyHour = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 10)); String keyHour = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 10));
boolean hourResult = timesCheck(3, keyHour, obj, wxEnterpriseId, enterpriseId, now, setTimeBO); boolean hourResult = timesCheck(3, keyHour, qwInterface, wxEnterpriseId, enterpriseId, now, setTimeBO);
if (hourResult) { if (hourResult) {
logger.info("小时达到限制={}", keyHour); logger.info("小时达到限制={}", keyHour);
return true; return true;
...@@ -69,8 +69,8 @@ public class QwTimesUtils { ...@@ -69,8 +69,8 @@ public class QwTimesUtils {
return false; return false;
} }
private static boolean timesCheck(int type, String cacheKey, QwInterfaceLimitEnum obj, String wxEnterpriseId, private static boolean timesCheck(int type, String cacheKey, QwInterfaceLimitEnum qwInterface,
String enterpriseId, Date now, QwLimitTimesBO setTimeBO) { String wxEnterpriseId, String enterpriseId, Date now, QwLimitTimesBO setTimeBO) {
Integer doneTimes = RedisUtil.getCache(cacheKey, Integer.class); Integer doneTimes = RedisUtil.getCache(cacheKey, Integer.class);
logger.info("获取已调次数={},cacheKey={}", doneTimes, cacheKey); logger.info("获取已调次数={},cacheKey={}", doneTimes, cacheKey);
if (null == doneTimes) { if (null == doneTimes) {
...@@ -90,18 +90,18 @@ public class QwTimesUtils { ...@@ -90,18 +90,18 @@ public class QwTimesUtils {
default: default:
break; break;
} }
sendAlert(type, doneTimes, setTimes, obj, enterpriseId, now); sendAlert(type, doneTimes, setTimes, qwInterface, enterpriseId, now);
if (doneTimes >= setTimes) { if (doneTimes >= setTimes) {
return true; return true;
} }
return false; return false;
} }
private static QwLimitTimesBO getSettingTimes(String wxEnterpriseId, QwInterfaceLimitEnum obj) { private static QwLimitTimesBO getSettingTimes(String wxEnterpriseId, QwInterfaceLimitEnum qwInterface) {
String key = String.format("%s_%s", obj.getName(), wxEnterpriseId); String key = String.format("%s_%s", qwInterface.getName(), wxEnterpriseId);
QwLimitTimesBO times = getTimes(key); QwLimitTimesBO times = getTimes(key);
if (null == times) { if (null == times) {
return getTimes(obj.getName()); return getTimes(qwInterface.getName());
} }
return times; return times;
} }
...@@ -112,16 +112,13 @@ public class QwTimesUtils { ...@@ -112,16 +112,13 @@ public class QwTimesUtils {
ServiceResponse<Map<String, Object>> resp = customSettingApiService.getDetail("tab_gic_map", ServiceResponse<Map<String, Object>> resp = customSettingApiService.getDetail("tab_gic_map",
searchParamMap.toJSONString()); searchParamMap.toJSONString());
if (resp.isSuccess() && null != resp.getResult()) { if (resp.isSuccess() && null != resp.getResult()) {
QwLimitTimesBO times = new QwLimitTimesBO(); return JSON.parseObject(resp.getResult().get("value").toString(), QwLimitTimesBO.class);
times = JSON.parseObject(resp.getResult().get("value").toString(), QwLimitTimesBO.class);
logger.info("获取默认配置次数={},{}", times, key);
return times;
} }
return null; return null;
} }
private static void sendAlert(int type, int doneTimes, int setTimes, QwInterfaceLimitEnum obj, String enterpriseId, private static void sendAlert(int type, int doneTimes, int setTimes, QwInterfaceLimitEnum qwInterface,
Date now) { String enterpriseId, Date now) {
// 调用次数达上线 // 调用次数达上线
String time = null; String time = null;
String title = "已达上限"; String title = "已达上限";
...@@ -163,7 +160,7 @@ public class QwTimesUtils { ...@@ -163,7 +160,7 @@ public class QwTimesUtils {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId); EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId);
String brandName = enterpriseDTO.getBrandName(); String brandName = enterpriseDTO.getBrandName();
// 达到上限时文案 // 达到上限时文案
String msg = String.format("告警【%s】%s调用在【%s】%s", brandName, obj.getRemark(), time, title); String msg = String.format("告警【%s】%s调用在【%s】%s", brandName, qwInterface.getRemark(), time, title);
DingUtils.send(msg, false); DingUtils.send(msg, false);
} }
} }
......
...@@ -19,6 +19,7 @@ import com.gic.haoban.manage.api.dto.hm.HmWelcomeRelationDTO; ...@@ -19,6 +19,7 @@ import com.gic.haoban.manage.api.dto.hm.HmWelcomeRelationDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmPageRelationQDTO; import com.gic.haoban.manage.api.dto.qdto.hm.HmPageRelationQDTO;
import com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeRelationQDTO; import com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeRelationQDTO;
import com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType; import com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType;
import com.gic.haoban.manage.api.service.QwFriendApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService; import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService; import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
...@@ -48,10 +49,15 @@ public class HmPageServiceTest { ...@@ -48,10 +49,15 @@ public class HmPageServiceTest {
private WxEnterpriseApiService wxEnterpriseApiService ; private WxEnterpriseApiService wxEnterpriseApiService ;
@Autowired @Autowired
private ExternalClerkRelatedService externalClerkRelatedService ; private ExternalClerkRelatedService externalClerkRelatedService ;
@Autowired
private QwFriendApiService qwFriendApiService ;
@Test @Test
public void test(){ public void test(){
System.out
.println( this.qwFriendApiService.getPendingIdByUnionid("ff8080815dacd3a2015dacd3ef5c0000", "orXl9t9gIRbvfIoDPfrPf7jHYHmU", "o0Yvd006OXKv71RIu8SbXA5mT7Zk"));
this.externalClerkRelatedService.repairExternalUserId("218a8a6c2ca14e28a1053f541be0e49d,ca66a01b79474c40b3e7c7f93daf1a3b"); this.externalClerkRelatedService.repairExternalUserId("218a8a6c2ca14e28a1053f541be0e49d,ca66a01b79474c40b3e7c7f93daf1a3b");
// this.wxEnterpriseApiService.stopHaoban("ff80808182c3a46b0182c3a4ea7d0000"); // this.wxEnterpriseApiService.stopHaoban("ff80808182c3a46b0182c3a4ea7d0000");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment