Commit 68a17b47 by 袁伟铭

修改

parent 41ef0355
......@@ -14,7 +14,9 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
......@@ -53,13 +55,20 @@ public class CjStatsService {
List<Map<String, Object>> returnData = new ArrayList<>();
List<StatsVo> disabledLevelStats = cjStatsDao.getDisabledLevelStats(vo);
disabledLevelStats = disabledLevelStats.stream()
.filter(statsVo -> "1".equals(statsVo.getType()) || "2".equals(statsVo.getType()) || "3".equals(statsVo.getType()) || "4".equals(statsVo.getType()))
.collect(Collectors.toList());
int totalNum = disabledLevelStats.stream()
.map(StatsVo::getNum)
.reduce(Integer::sum).orElse(0);
for (StatsVo statsVo : disabledLevelStats) {
if (!"1".equals(statsVo.getType()) && !"2".equals(statsVo.getType()) && !"3".equals(statsVo.getType()) && !"4".equals(statsVo.getType())) {
continue;
}
Map<String, Object> data = new HashMap<>();
data.put("level", statsVo.getType() + "级残疾");
data.put("num", "总数" + statsVo.getNum());
data.put("level", statsVo.getType());
data.put("num", statsVo.getNum());
data.put("percentage", BigDecimal.valueOf(statsVo.getNum()).divide(BigDecimal.valueOf(totalNum), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).intValue());
returnData.add(data);
}
......
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