河南机电职业学院-大屏数据统计

dev
zhc077 5 months ago
parent a16880eb5b
commit 9cf09ad9b3
  1. 51
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java

@ -2,6 +2,7 @@ package org.jeecg.modules.demo.bigScreen.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.ComputeUtils;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.demo.abilityEvaluation.entity.DepartAbilityEvaluation;
import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluation;
@ -39,6 +40,8 @@ import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@ -162,8 +165,27 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic
List<DepartAbilityEvaluation> departAbilityEvaluations = iDepartAbilityEvaluationService.list(new LambdaQueryWrapper<DepartAbilityEvaluation>()
.eq(DepartAbilityEvaluation::getDepetId, departId));
List<DepartAbilityEvaluation> vos = new LinkedList<>();
Map<String, List<DepartAbilityEvaluation>> capacityIdListMap = Optional.ofNullable(departAbilityEvaluations).orElse(new LinkedList<>()).stream()
.collect(Collectors.groupingBy(DepartAbilityEvaluation::getCapacityId));
//遍历分组后的结果
Optional.ofNullable(capacityIdListMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> {
List<DepartAbilityEvaluation> departAbilityEvaluationList = value;
double sum = departAbilityEvaluationList.stream().mapToDouble(obj -> obj.getValue()).sum();
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setMaximumFractionDigits(2); // 保留两位小数
decimalFormat.setRoundingMode(RoundingMode.HALF_UP); // 设置具体的进位机制
double val = ComputeUtils.div2(sum, departAbilityEvaluationList.size());
DepartAbilityEvaluation vo = new DepartAbilityEvaluation();
vo.setDepetId(departId);
vo.setValue(val);
vo.setCapacityId(key);
vo.setCapacityName(departAbilityEvaluationList.get(0).getCapacityName());
vos.add(vo);
});
//能力评估
resultMap.put("departAbilityEvaluation", departAbilityEvaluations);
resultMap.put("departAbilityEvaluation", vos);
List<Integer> years = DateUtils.getLastxYear(5);
List<Annual> annualList = iAnnualService.list(new LambdaQueryWrapper<Annual>()
@ -320,13 +342,13 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic
Map<String, Object> compCounts = new LinkedHashMap<>();
Long compCount = iCompService.count();
Long pointCount = iAnnualCompPointService.count();
// Long pointCount = iAnnualCompPointService.count();
//比赛数
compCounts.put("compCount", compCount);
//年度项目比赛数
compCounts.put("pointCount", pointCount);
//总报名数数
Long count = iAnnualCompetitionProjectRegistrationService.count();
//总人数
compCounts.put("pointCount", count);
//人个报名人数
Long personCount = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>()
.eq(AnnualCompetitionProjectRegistration::getEntryFormat, "0"));
//学生人数
@ -337,7 +359,24 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic
resultMap.put("compCounts", compCounts);
List<DepartAbilityEvaluation> departAbilityEvaluations = iDepartAbilityEvaluationService.list();
resultMap.put("abilityEvaluation", departAbilityEvaluations);
List<DepartAbilityEvaluation> vos = new LinkedList<>();
Map<String, List<DepartAbilityEvaluation>> capacityIdListMap = Optional.ofNullable(departAbilityEvaluations).orElse(new LinkedList<>()).stream()
.collect(Collectors.groupingBy(DepartAbilityEvaluation::getCapacityId));
//遍历分组后的结果
Optional.ofNullable(capacityIdListMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> {
List<DepartAbilityEvaluation> departAbilityEvaluationList = value;
double sum = departAbilityEvaluationList.stream().mapToDouble(obj -> obj.getValue()).sum();
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setMaximumFractionDigits(2); // 保留两位小数
decimalFormat.setRoundingMode(RoundingMode.HALF_UP); // 设置具体的进位机制
double val = ComputeUtils.div2(sum, departAbilityEvaluationList.size());
DepartAbilityEvaluation vo = new DepartAbilityEvaluation();
vo.setValue(val);
vo.setCapacityId(key);
vo.setCapacityName(departAbilityEvaluationList.get(0).getCapacityName());
vos.add(vo);
});
resultMap.put("abilityEvaluation", vos);
List<Integer> years = DateUtils.getLastxYear(5);
List<Annual> annualList = iAnnualService.list(new LambdaQueryWrapper<Annual>().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName));

Loading…
Cancel
Save