From 1d938aec08aef036d32eb0c13613e9a50dde492f Mon Sep 17 00:00:00 2001 From: zhc077 <565291854@qq.com> Date: Wed, 31 Jul 2024 11:13:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E9=A1=B9=E6=AF=94=E8=B5=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9=207.31?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CompSystemBigScreenServiceImpl.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 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);