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 28b0bcfc..a3c2c50e 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 @@ -489,10 +489,11 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic //比赛数 last5YearDataVo.setCompCount(1); - AnnualCompPoint annualCompPoint = iAnnualCompPointService.getOne(new LambdaQueryWrapper().eq(AnnualCompPoint::getAnnualCompId, ac.getId())); - if (!ObjectUtils.isEmpty(annualCompPoint)) { + List annualCompPoints = iAnnualCompPointService.list(new LambdaQueryWrapper().eq(AnnualCompPoint::getAnnualCompId, ac.getId())); + if (!ObjectUtils.isEmpty(annualCompPoints)) { + Set pids = annualCompPoints.stream().map(e -> e.getId()).collect(Collectors.toSet()); long personCount4CompTemp = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper(). - eq(AnnualCompetitionProjectRegistration::getAnnualCompid, annualCompPoint.getId())); + in(AnnualCompetitionProjectRegistration::getAnnualCompid, pids)); personCount4Comp.getAndUpdate(val -> val.add(new BigDecimal(personCount4CompTemp))); last5YearDataVo.setPersonCount(personCount4Comp.get().intValue()); } @@ -667,6 +668,9 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic List> last4YearData = new LinkedList<>(); List years = DateUtils.getLastxYear(4); List annualList = iAnnualService.list(new LambdaQueryWrapper().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName)); + DecimalFormat decimalFormat = new DecimalFormat(); + decimalFormat.setMaximumFractionDigits(2); // 保留两位小数 + decimalFormat.setRoundingMode(RoundingMode.HALF_UP); // 设置具体的进位机制 annualList.forEach(annual -> { AtomicReference baseScore = new AtomicReference<>(BigDecimal.ZERO); Map yearData = new LinkedHashMap<>(); @@ -678,7 +682,7 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic double sum = compScoreList.stream().mapToDouble(PersonalCompScore::getScore).sum(); baseScore.getAndUpdate(val -> val.add(new BigDecimal(sum))); } - yearData.put("score", baseScore); + yearData.put("score", decimalFormat.format(baseScore.get())); last4YearData.add(yearData); }); studentInfoMap.put("last4YearData", last4YearData);