流量计增加加入各类接口

This commit is contained in:
zhangyue 2026-07-30 16:59:10 +08:00
parent 5bd104ffaf
commit 539d28c944
2 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.appmana.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
@ -14,6 +15,7 @@ import org.jeecg.common.constant.enums.DeviceDeployEnum;
import org.jeecg.common.constant.enums.ScreenIndexSummaryEnum;
import org.jeecg.common.dto.CommonDTO;
import org.jeecg.common.entity.*;
import org.jeecg.common.util.CommonToolUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.common.vo.*;
import org.jeecg.common.vo.statistic.ScreenIndexSummaryDetailVo;
@ -518,7 +520,7 @@ public class BigScreenController {
if(StringUtils.isBlank(screenSummaryVo.getSummrayMode())){//不传模式默认为天数据
screenSummaryVo.setSummrayMode(IotConstants.month_days);
}
String key = CacheConstants.BS_INDEX_STATISTIC_CACHE+tenantId +":"+screenSummaryVo.getSummrayMode();
String key = CacheConstants.BS_INDEX_STATISTIC_CACHE + tenantId +":"+ CommonToolUtils.generateUniqueMD5(BeanUtil.beanToMap(screenSummaryVo, false, true));
String cache = oConvertUtils.getString(redisTemplate.opsForValue().get(key));
if(StringUtils.isNotBlank(cache)){
results = JSONArray.parseArray(cache,ScreenIndexSummaryDetailVo.class);

View File

@ -1,6 +1,8 @@
package org.jeecg.common.util;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import org.jeecg.common.constant.ToolConstant;
import org.jeecg.common.vo.statistic.CommonStatisticResultVo;
import org.jeecg.common.vo.statistic.CommonStatisticVo;
@ -12,6 +14,7 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.YearMonth;
@ -305,4 +308,20 @@ public class CommonToolUtils {
}
return map;
}
// 将Map转为JSON再取MD5
public static String generateUniqueMD5(Map<String, Object> map) {
// 1. 使用 TreeMap 自动按键名排序保证顺序一致性
// 注意如果 map 本身可能为 null需增加非空判断
TreeMap<String, Object> sortedMap = new TreeMap<>(map);
// 2. 使用 Hutool JSONUtil 将有序 Map 转为 JSON 字符串
// JSONUtil.toJsonStr 可以很好地处理各种对象类型[citation:10]
String jsonStr = JSONUtil.toJsonStr(sortedMap);
// 3. 使用 Hutool SecureUtil 直接计算 MD5[citation:9]
// SecureUtil.md5() 方法有多种重载直接传入字符串即可
return SecureUtil.md5(jsonStr);
}
}