diff --git a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java index 55273f58..28ca271b 100644 --- a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java +++ b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java @@ -780,12 +780,12 @@ public class DateUtils extends PropertyEditorSupport { * @author: z.h.c * @date: 23/11/30 15:38 */ - public static List getLast4Year() { + public static List getLastxYear(int lastYear) { Calendar calendar = Calendar.getInstance(); // 创建Calendar对象并初始化为当前时间 int currentYear = calendar.get(Calendar.YEAR); List years = new LinkedList<>(); years.add(currentYear); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < lastYear-1; i++) { calendar.add(Calendar.YEAR, -1); // 将日期向前移动一年 int previousYear = calendar.get(Calendar.YEAR); // 获取上一年的年份 years.add(previousYear); @@ -795,7 +795,7 @@ public class DateUtils extends PropertyEditorSupport { public static void main(String[] args) { - List last4Year = getLast4Year(); + List last4Year = getLastxYear(1); last4Year.forEach(y->{ System.out.println(y); }); 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 6f2b86ed..02c129c3 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 @@ -11,7 +11,9 @@ import org.jeecg.modules.demo.annual.entity.Annual; import org.jeecg.modules.demo.annual.service.IAnnualService; import org.jeecg.modules.demo.annualCompPoint.entity.AnnualCompPoint; import org.jeecg.modules.demo.annualCompPoint.service.IAnnualCompPointService; +import org.jeecg.modules.demo.annualScore.entity.PersonalCompScore; import org.jeecg.modules.demo.annualScore.entity.PersonalCompTotalScore; +import org.jeecg.modules.demo.annualScore.service.IPersonalCompScoreService; import org.jeecg.modules.demo.annualScore.service.IPersonalCompTotalScoreService; import org.jeecg.modules.demo.annualcomp.entity.AnnualComp; import org.jeecg.modules.demo.annualcomp.service.IAnnualCompService; @@ -75,6 +77,9 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic @Autowired private IPersonalCompTotalScoreService iPersonalCompTotalScoreService; + @Autowired + private IPersonalCompScoreService iPersonalCompScoreService; + @Autowired private IDepartAbilityEvaluationService iDepartAbilityEvaluationService; @@ -118,19 +123,19 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic compCounts.put("pointCount", pointCount); //总报名数数 Long count = iAnnualCompetitionProjectRegistrationService.count(); - //学生人数 Long personCount = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper() .eq(AnnualCompetitionProjectRegistration::getEntryFormat, "0")); + //学生人数 compCounts.put("personCompCount", personCount); - //队伍数 Long teamCount = count - personCount; + //队伍数 compCounts.put("teamCompCount", teamCount); resultMap.put("compCounts", compCounts); List departAbilityEvaluations = iDepartAbilityEvaluationService.list(); resultMap.put("departAbilityEvaluation", departAbilityEvaluations); - List years = DateUtils.getLast4Year(); + List years = DateUtils.getLastxYear(5); List annualList = iAnnualService.list(new LambdaQueryWrapper().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName)); List last5YearDataVos = new LinkedList<>(); Optional.ofNullable(annualList).orElse(new LinkedList<>()).stream().forEach(annual -> { @@ -182,8 +187,26 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic AnnualCompPoint annualCompPoint = iAnnualCompPointService.getById(award.getAnnualCompP()); award.setAnnualCompPname(annualCompPoint.getObjName()); }); + studentInfoMap.put("awardList", awardPersions); - studentInfoMap.put("studentAwardList", awardPersions); + List> last4YearData = new LinkedList<>(); + List years = DateUtils.getLastxYear(4); + List annualList = iAnnualService.list(new LambdaQueryWrapper().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName)); + annualList.forEach(annual -> { + AtomicReference baseScore = new AtomicReference<>(BigDecimal.ZERO); + Map yearData = new LinkedHashMap<>(); + yearData.put("year", annual.getAnnualName()); + List compScoreList = iPersonalCompScoreService.list(new LambdaQueryWrapper() + .eq(PersonalCompScore::getWorkOn, person.getWorkOn()) + .eq(PersonalCompScore::getAnnualId, annual.getId())); + if (!ObjectUtils.isEmpty(compScoreList)) { + double sum = compScoreList.stream().mapToDouble(PersonalCompScore::getScore).sum(); + baseScore.getAndUpdate(val -> val.add(new BigDecimal(sum))); + } + yearData.put("score", baseScore); + last4YearData.add(yearData); + }); + studentInfoMap.put("last4YearData", last4YearData); studentInfoMap.put("workNo", person.getWorkOn()); studentInfoMap.put("name", sysUser.getRealname()); studentInfoMap.put("major", "软件工程");