From 07d81f3ce8a1abe5ddb445b1a85862b4ae532c01 Mon Sep 17 00:00:00 2001 From: zhc077 <565291854@qq.com> Date: Mon, 8 Jul 2024 10:48:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=B3=E5=8D=97=E6=9C=BA=E7=94=B5=E8=81=8C?= =?UTF-8?q?=E4=B8=9A=E5=AD=A6=E9=99=A2-=E5=8D=95=E9=A1=B9=E6=AF=94?= =?UTF-8?q?=E8=B5=9B=E5=A4=A7=E5=B1=8F=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompSystemBigScreenServiceImpl.java | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java index 9d0d2efe..8541f866 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java @@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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; import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluationCollect; import org.jeecg.modules.demo.abilityEvaluation.service.IDepartAbilityEvaluationService; import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluationCollectService; +import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluationService; import org.jeecg.modules.demo.annual.entity.Annual; import org.jeecg.modules.demo.annual.service.IAnnualService; import org.jeecg.modules.demo.annualCompPoint.entity.AnnualCompPoint; @@ -85,6 +87,9 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic @Autowired private IDepartAbilityEvaluationService iDepartAbilityEvaluationService; + @Autowired + private IPersonalAbilityEvaluationService iPersonalAbilityEvaluationService; + @Autowired private IPersonalAbilityEvaluationCollectService iPersonalAbilityEvaluationCollectService; @@ -114,7 +119,6 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic List annualCompList = this.getAnnualCompList(comp); //年度比赛列表 resultMap.put("annualCompList", annualCompList); -// List annualCompList = iAnnualCompService.list(new LambdaQueryWrapper().eq(AnnualComp::getCompid, compId)); //年度比赛ids @@ -137,13 +141,15 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic resultMap.put("awardList", awardPersionList); - //TODO - List personalCompScoreList = iPersonalCompTotalScoreService.list(new LambdaQueryWrapper() -// .eq(PersonalCompTotalScore::getDepet, departId) + List personalCompScoreList = iPersonalCompScoreService.list(new LambdaQueryWrapper().in(PersonalCompScore::getAnnualCompId, annualCompIds)); + //参加该比赛的所有学生学号 + Set workNos = Optional.ofNullable(personalCompScoreList).orElse(new ArrayList<>()).stream().map(personalCompScore -> personalCompScore.getWorkOn()).collect(Collectors.toSet()); + List personalCompTotalScoreList = iPersonalCompTotalScoreService.list(new LambdaQueryWrapper() + .in(PersonalCompTotalScore::getWorkOn, workNos) .orderByDesc(PersonalCompTotalScore::getScore) .last("limit 50")); //学生积分排名 - resultMap.put("studentScore", personalCompScoreList); + resultMap.put("studentScore", personalCompTotalScoreList); Map compCounts = new LinkedHashMap<>(); @@ -170,29 +176,29 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic resultMap.put("compCounts", compCounts); - //TODO -// List departAbilityEvaluations = iDepartAbilityEvaluationService.list(new LambdaQueryWrapper() -// .eq(DepartAbilityEvaluation::getDepetId, departId)); -// List vos = new LinkedList<>(); -// Map> capacityIdListMap = Optional.ofNullable(departAbilityEvaluations).orElse(new LinkedList<>()).stream() -// .collect(Collectors.groupingBy(DepartAbilityEvaluation::getCapacityId)); -// //遍历分组后的结果 -// Optional.ofNullable(capacityIdListMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { -// List 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(); + List personalAbilityEvaluationList = iPersonalAbilityEvaluationService.list(new LambdaQueryWrapper() + .in(PersonalAbilityEvaluation::getAnnualCompId, annualCompIds) + .in(PersonalAbilityEvaluation::getWorkOn, workNos) + ); + List vos = new LinkedList<>(); + Map> capacityIdListMap = Optional.ofNullable(personalAbilityEvaluationList).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(PersonalAbilityEvaluation::getCapacityId)); + //遍历分组后的结果 + Optional.ofNullable(capacityIdListMap).orElse(new LinkedHashMap<>()).forEach((key, obj) -> { + double sum = obj.stream().mapToDouble(bo -> bo.getValue()).sum(); + DecimalFormat decimalFormat = new DecimalFormat(); + decimalFormat.setMaximumFractionDigits(2); // 保留两位小数 + decimalFormat.setRoundingMode(RoundingMode.HALF_UP); // 设置具体的进位机制 + double val = ComputeUtils.div2(sum, obj.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", vos); + vo.setValue(val); + vo.setCapacityId(key); + vo.setCapacityName(obj.get(0).getCapacityName()); + vos.add(vo); + }); + //单项比赛能力评估 + resultMap.put("comAbilityEvaluation", vos); List years = DateUtils.getLastxYear(5);