添加功能
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cms.util;
|
||||
|
||||
import com.ruoyi.cms.constant.enums.QueryTimeTypeEnum;
|
||||
import com.ruoyi.cms.domain.vo.HeatmapVo;
|
||||
import com.ruoyi.cms.domain.vo.QueryResultVo;
|
||||
import com.ruoyi.cms.domain.vo.TreadVo;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -102,7 +103,7 @@ public class MathUtil {
|
||||
}
|
||||
long totalCount = 0;
|
||||
for (QueryResultVo dto : list) {
|
||||
totalCount = totalCount + dto.getCount();
|
||||
totalCount = totalCount + Optional.ofNullable(dto.getCount()).orElse(0L);
|
||||
}
|
||||
|
||||
for (QueryResultVo dto : list) {
|
||||
@@ -168,4 +169,26 @@ public class MathUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算占比 - 热力图
|
||||
*
|
||||
* @param list 热力图数据
|
||||
*/
|
||||
public static void calculatePercentageHeatmap(List<HeatmapVo> list) {
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算占比
|
||||
long totalCount = 0;
|
||||
for (HeatmapVo vo : list) {
|
||||
totalCount = totalCount + Optional.ofNullable(vo.getCount()).orElse(0L);
|
||||
}
|
||||
|
||||
for (HeatmapVo vo : list) {
|
||||
vo.setPercentage(calculatePercentage(totalCount, vo.getCount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user