Commit 57e36b3b by 徐高华

test

parent 8a69d1a2
......@@ -39,29 +39,29 @@ public class QwTimesUtils {
QwTimesUtils.enterpriseService = enterpriseService;
}
public static boolean isLimit(String wxEnterpriseId, String enterpriseId, QwInterfaceLimitEnum obj) {
QwLimitTimesBO setTimeBO = getSettingTimes(wxEnterpriseId, obj);
public static boolean isLimit(String wxEnterpriseId, String enterpriseId, QwInterfaceLimitEnum qwInterface) {
QwLimitTimesBO setTimeBO = getSettingTimes(wxEnterpriseId, qwInterface);
logger.info("获取配置次数={},wxEnterpriseId={}", JSON.toJSONString(setTimeBO), wxEnterpriseId);
// 先判断月
String interfaceName = obj.getName();
String interfaceName = qwInterface.getName();
Date now = new Date();
String dateStr = getDateStr(now);
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) {
logger.info("月达到限制={}", keyMonth);
return true;
}
// 天
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) {
logger.info("天达到限制={}", keyDay);
return true;
}
// 小时
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) {
logger.info("小时达到限制={}", keyHour);
return true;
......@@ -69,8 +69,8 @@ public class QwTimesUtils {
return false;
}
private static boolean timesCheck(int type, String cacheKey, QwInterfaceLimitEnum obj, String wxEnterpriseId,
String enterpriseId, Date now, QwLimitTimesBO setTimeBO) {
private static boolean timesCheck(int type, String cacheKey, QwInterfaceLimitEnum qwInterface,
String wxEnterpriseId, String enterpriseId, Date now, QwLimitTimesBO setTimeBO) {
Integer doneTimes = RedisUtil.getCache(cacheKey, Integer.class);
logger.info("获取已调次数={},cacheKey={}", doneTimes, cacheKey);
if (null == doneTimes) {
......@@ -90,18 +90,18 @@ public class QwTimesUtils {
default:
break;
}
sendAlert(type, doneTimes, setTimes, obj, enterpriseId, now);
sendAlert(type, doneTimes, setTimes, qwInterface, enterpriseId, now);
if (doneTimes >= setTimes) {
return true;
}
return false;
}
private static QwLimitTimesBO getSettingTimes(String wxEnterpriseId, QwInterfaceLimitEnum obj) {
String key = String.format("%s_%s", obj.getName(), wxEnterpriseId);
private static QwLimitTimesBO getSettingTimes(String wxEnterpriseId, QwInterfaceLimitEnum qwInterface) {
String key = String.format("%s_%s", qwInterface.getName(), wxEnterpriseId);
QwLimitTimesBO times = getTimes(key);
if (null == times) {
return getTimes(obj.getName());
return getTimes(qwInterface.getName());
}
return times;
}
......@@ -112,16 +112,13 @@ public class QwTimesUtils {
ServiceResponse<Map<String, Object>> resp = customSettingApiService.getDetail("tab_gic_map",
searchParamMap.toJSONString());
if (resp.isSuccess() && null != resp.getResult()) {
QwLimitTimesBO times = new QwLimitTimesBO();
times = JSON.parseObject(resp.getResult().get("value").toString(), QwLimitTimesBO.class);
logger.info("获取默认配置次数={},{}", times, key);
return times;
return JSON.parseObject(resp.getResult().get("value").toString(), QwLimitTimesBO.class);
}
return null;
}
private static void sendAlert(int type, int doneTimes, int setTimes, QwInterfaceLimitEnum obj, String enterpriseId,
Date now) {
private static void sendAlert(int type, int doneTimes, int setTimes, QwInterfaceLimitEnum qwInterface,
String enterpriseId, Date now) {
// 调用次数达上线
String time = null;
String title = "已达上限";
......@@ -163,7 +160,7 @@ public class QwTimesUtils {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId);
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);
}
}
......
......@@ -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.welcome.qdto.QueryWelcomeRelationQDTO;
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.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
......@@ -48,10 +49,15 @@ public class HmPageServiceTest {
private WxEnterpriseApiService wxEnterpriseApiService ;
@Autowired
private ExternalClerkRelatedService externalClerkRelatedService ;
@Autowired
private QwFriendApiService qwFriendApiService ;
@Test
public void test(){
System.out
.println( this.qwFriendApiService.getPendingIdByUnionid("ff8080815dacd3a2015dacd3ef5c0000", "orXl9t9gIRbvfIoDPfrPf7jHYHmU", "o0Yvd006OXKv71RIu8SbXA5mT7Zk"));
this.externalClerkRelatedService.repairExternalUserId("218a8a6c2ca14e28a1053f541be0e49d,ca66a01b79474c40b3e7c7f93daf1a3b");
// 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