diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageService.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageService.java index 63dbe981..d32a32e1 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageService.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageService.java @@ -5,10 +5,10 @@ import java.util.Map; public interface UserHomePageService { - Map homePage4Depart(String departId); + Map homePage4Depart(String orgCode); Map homePage4School(); Map report4School(); - Map report4Depart(); + Map report4Depart(String orgCode); } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageServiceImpl.java index 58b474c8..3820a46f 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageServiceImpl.java @@ -107,6 +107,8 @@ public class UserHomePageServiceImpl implements UserHomePageService { @Autowired private IProjectlevelService iProjectlevelService; + final String BASE_PARENT_ID = "1693446350597038081"; + @Override public Map homePage4Depart(String orgCode) { @@ -516,7 +518,6 @@ public class UserHomePageServiceImpl implements UserHomePageService { List> canSaiList = new LinkedList<>(); List> huoJiangList = new LinkedList<>(); //二级部门 - final String BASE_PARENT_ID = "1693446350597038081"; List departList = iSysDepartService.list(new LambdaQueryWrapper().eq(SysDepart::getParentId, BASE_PARENT_ID)); Optional.ofNullable(departList).orElse(new LinkedList<>()).stream().forEach(depart -> { List pointList4Depart = convertPoint4Depart(depart); @@ -525,19 +526,19 @@ public class UserHomePageServiceImpl implements UserHomePageService { departMap.put("部门名称", depart.getDepartName()); //报名列表 List registrationList = iAnnualCompetitionProjectRegistrationService.list(new LambdaQueryWrapper() - .in(AnnualCompetitionProjectRegistration::getAnnualCompid, pointIds4Depart)); + .in(!ObjectUtils.isEmpty(pointIds4Depart), AnnualCompetitionProjectRegistration::getAnnualCompid, pointIds4Depart)); if (!ObjectUtils.isEmpty(registrationList)) { //报名编号 Set enrollCodes = Optional.ofNullable(registrationList).orElse(new LinkedList<>()).stream().map(bo -> bo.getEnrollCode()).collect(Collectors.toSet()); Long count = iTeamManagementService.count(new LambdaQueryWrapper().in(TeamManagement::getEnrollCode, enrollCodes)); - departMap.put("参加比赛数", count); + departMap.put("比赛总人数", count); //个人赛报名数 List registrationList4Stu = registrationList.stream().filter(b -> b.getEntryFormat().equals("0")).collect(Collectors.toList()); - Set enrollCodes4Stu = Optional.ofNullable(registrationList).orElse(new LinkedList<>()).stream().map(bo -> bo.getEnrollCode()).collect(Collectors.toSet()); - Long count4Stu = iTeamManagementService.count(new LambdaQueryWrapper().in(TeamManagement::getEnrollCode, enrollCodes4Stu)); + Set enrollCodes4Stu = Optional.ofNullable(registrationList4Stu).orElse(new LinkedList<>()).stream().map(bo -> bo.getEnrollCode()).collect(Collectors.toSet()); + Long count4Stu = iTeamManagementService.count(new LambdaQueryWrapper().in(!ObjectUtils.isEmpty(enrollCodes4Stu), TeamManagement::getEnrollCode, enrollCodes4Stu)); //学生人数 - departMap.put("参加学生数", count4Stu); - departMap.put("队伍数", registrationList.size() - registrationList4Stu.size()); + departMap.put("个人赛人数", count4Stu); + departMap.put("团队赛人数", count - count4Stu); } canSaiList.add(departMap); @@ -549,9 +550,7 @@ public class UserHomePageServiceImpl implements UserHomePageService { .collect(Collectors.groupingBy(AwardPersion::getAwardname)); //遍历分组后的结果 Optional.ofNullable(awardNameMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { - Map awardTypeMap2 = new HashMap<>(); - awardTypeMap2.put(key, value.size()); - departHuoJiangMap.putAll(awardTypeMap2); + departHuoJiangMap.put(depart.getDepartName() + "-" + key, value.size()); }); huoJiangList.add(departHuoJiangMap); }); @@ -587,14 +586,243 @@ public class UserHomePageServiceImpl implements UserHomePageService { private List convertPoint4Depart(SysDepart depart) { List compList = iCompService.list(new LambdaQueryWrapper().eq(Comp::getCompOrgan, depart.getId())); Set compIds = Optional.ofNullable(compList).orElse(new ArrayList<>()).stream().map(comp -> comp.getId()).collect(Collectors.toSet()); - List annualCompList = iAnnualCompService.list(new LambdaQueryWrapper().in(!ObjectUtils.isEmpty(compIds),AnnualComp::getCompid, compIds)); + List annualCompList = iAnnualCompService.list(new LambdaQueryWrapper().in(!ObjectUtils.isEmpty(compIds), AnnualComp::getCompid, compIds)); Set annualCompIds = Optional.ofNullable(annualCompList).orElse(new ArrayList<>()).stream().map(annualComp -> annualComp.getId()).collect(Collectors.toSet()); - return iAnnualCompPointService.list(new LambdaQueryWrapper().in(!ObjectUtils.isEmpty(annualCompIds),AnnualCompPoint::getAnnualCompId, annualCompIds)); + return iAnnualCompPointService.list(new LambdaQueryWrapper().in(!ObjectUtils.isEmpty(annualCompIds), AnnualCompPoint::getAnnualCompId, annualCompIds)); } @Override - public Map report4Depart() { - return null; + public Map report4Depart(String orgCode) { + + Assert.notNull(orgCode, "部门编号不能为空"); + Map resultMap = new LinkedHashMap<>(); + SysDepart sysDepart = iSysDepartService.getOne(new LambdaQueryWrapper().eq(SysDepart::getOrgCode, orgCode)); + if (ObjectUtil.isNull(sysDepart)) { + throw new JeecgBootException("部门不存在"); + } + + String departId = sysDepart.getParentId(); + int currentYear = DateUtils.getCurrentYear(); + //当前年度 + Annual annual = iAnnualService.getOne(new LambdaQueryWrapper().eq(Annual::getAnnualName, currentYear + "")); + List compList = iCompService.list(new LambdaQueryWrapper().eq(Comp::getCompOrgan, departId)); + Set compIds = Optional.ofNullable(compList).orElse(new LinkedList<>()).stream().map(obj -> obj.getId()).collect(Collectors.toSet()); + + List annualCompList = iAnnualCompService.list(new LambdaQueryWrapper() + .eq(AnnualComp::getAnnualid, annual.getId()) + .in(AnnualComp::getCompid, compIds)); + + Set annualCompIds = Optional.ofNullable(annualCompList).orElse(new LinkedList<>()).stream().map(obj -> obj.getId()).collect(Collectors.toSet()); + List annualCompPointList = iAnnualCompPointService.list(new LambdaQueryWrapper().in(AnnualCompPoint::getAnnualCompId, annualCompIds)); + //该部门,当前年,所有项目id + Set annualCompPointIds = Optional.ofNullable(annualCompPointList).orElse(new ArrayList<>()).stream().map(annualCompPoint -> annualCompPoint.getId()).collect(Collectors.toSet()); + + //未评奖的项目为进行中 + List pj0PointList = Optional.ofNullable(annualCompPointList).orElse(new LinkedList<>()).stream().filter(bo -> "0".equals(bo.getIsPj())).collect(Collectors.toList()); + Map countMap = this.convertProjectLevel(annualCompPointList); + countMap.put("本年度已开展比赛项目数", annualCompPointList.size()); + countMap.put("本年度参加比赛队伍数", 0); + countMap.put("正在进行的比赛数", pj0PointList.size()); + int donePointCount = annualCompPointList.size() - pj0PointList.size(); + countMap.put("已完成的比赛", donePointCount); + countMap.put("未完成的比赛", pj0PointList.size()); + if (donePointCount > 0) { + DecimalFormat decimalFormat = new DecimalFormat(); + decimalFormat.setMaximumFractionDigits(2); // 保留两位小数 + decimalFormat.setRoundingMode(RoundingMode.HALF_UP); // 设置具体的进位机制 + double val = ComputeUtils.div2(donePointCount, annualCompPointList.size()); + countMap.put("已完成比赛比率", val); + } else { + countMap.put("已完成比赛比率", 0); + } + + List evaluationCollects = iPersonalAbilityEvaluationCollectService + .list(new LambdaQueryWrapper() + .eq(PersonalAbilityEvaluationCollect::getDepetId, departId) + .orderByDesc(PersonalAbilityEvaluationCollect::getCreateTime) + .last(" limit 60")); + resultMap.put("前60名学生能力值", evaluationCollects); + + List vos = new LinkedList<>(); + Map> capacityIdListMap = Optional.ofNullable(evaluationCollects).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(PersonalAbilityEvaluationCollect::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()); + PersonalAbilityEvaluationCollect vo = new PersonalAbilityEvaluationCollect(); + vo.setValue(val); + vo.setCapacityId(key); + vo.setCapacityName(departAbilityEvaluationList.get(0).getCapacityName()); + vos.add(vo); + }); + resultMap.put("前60名学生能力平均值", vos); + + List> abilityList = new LinkedList<>(); + List years = DateUtils.getLastxYear(2); + List annualList = iAnnualService.list(new LambdaQueryWrapper().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName)); + Optional.ofNullable(annualList).orElse(new LinkedList<>()).stream().forEach(bo -> { + Map abilityResultMap = new LinkedHashMap<>(); + List departAbilityEvaluations = iDepartAbilityEvaluationService.list(new LambdaQueryWrapper() + .eq(DepartAbilityEvaluation::getAnnualId, bo.getId()) + .eq(DepartAbilityEvaluation::getDepetId, departId)); + List voList = new LinkedList<>(); + Map> capacityIdListMap2 = Optional.ofNullable(departAbilityEvaluations).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(DepartAbilityEvaluation::getCapacityId)); + //遍历分组后的结果 + Optional.ofNullable(capacityIdListMap2).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(); + vo.setAnnualId(bo.getId()); + vo.setValue(val); + vo.setCapacityId(key); + vo.setCapacityName(departAbilityEvaluationList.get(0).getCapacityName()); + voList.add(vo); + }); + abilityResultMap.put(bo.getAnnualName(), voList); + abilityList.add(abilityResultMap); + }); + resultMap.put("近2年能力分析", abilityList); + + resultMap.put("部门比赛类型占比", convertCompType(compList)); + + List pointList = iAnnualCompPointService.list(new LambdaQueryWrapper() + .eq(AnnualCompPoint::getRequireApply, "Y") + .in(AnnualCompPoint::getAnnualCompId, annualCompPointIds)); + List compVoList = new LinkedList<>(); + Optional.ofNullable(pointList).orElse(new LinkedList<>()).stream().forEach(p -> { + ReportCompVo compVo = new ReportCompVo(); + BeanUtils.copyProperties(p, compVo); + compVo.setPointName(p.getObjName()); + + AnnualComp annualComp = iAnnualCompService.getById(p.getAnnualCompId()); + if (!ObjectUtils.isEmpty(annualComp)) { + Comp comp = iCompService.getById(annualComp.getCompid()); + compVo.setCompName(comp.getCompName()); + CompType compType = iCompTypeService.getById(comp.getCompTypeId()); + compVo.setTypeName(compType.getTypeName()); + Projectlevel projectlevel = iProjectlevelService.getById(p.getObjLevel()); + compVo.setProjectLevel(projectlevel.getName()); + } + List list = iAnnualCompetitionProjectRegistrationService.list(new LambdaQueryWrapper() + .eq(AnnualCompetitionProjectRegistration::getAnnualCompid, p.getId())); + if (!ObjectUtils.isEmpty(list)) { + Set entryFormats = list.stream().map(bo -> bo.getEnrollCode()).collect(Collectors.toSet()); + Long count = iTeamManagementService.count(new LambdaQueryWrapper().in(TeamManagement::getEnrollCode, entryFormats)); + compVo.setNumber(count.intValue()); + } + compVoList.add(compVo); + }); + resultMap.put("学生参赛情况", compVoList); + + List awardPersionList = iAwardPersionService.list(new LambdaQueryWrapper().in(AwardPersion::getAnnualCompP, annualCompPointIds)); + Map> awardIdListMap = Optional.ofNullable(awardPersionList).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(AwardPersion::getAwardname)); + Map awardTypeMap = new LinkedHashMap<>(); + + //遍历分组后的结果 + Optional.ofNullable(awardIdListMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { + awardTypeMap.put(key, value.size()); + }); + resultMap.put("比赛获奖占比", awardTypeMap); + + + List awareVos = new ArrayList<>(); + Optional.ofNullable(awardPersionList).orElse(new LinkedList<>()).stream().forEach(p -> { + ReportCompVo compVo = new ReportCompVo(); + compVo.setStuName(p.getStudentname()); + AnnualCompPoint point = iAnnualCompPointService.getById(p.getAnnualCompP()); + if (!ObjectUtils.isEmpty(point)) { + compVo.setPointName(point.getObjName()); + Projectlevel projectlevel = iProjectlevelService.getById(point.getObjLevel()); + compVo.setProjectLevel(projectlevel.getName()); + } + AnnualComp annualComp = iAnnualCompService.getById(p.getAnnalComp()); + if (!ObjectUtils.isEmpty(annualComp)) { + Comp comp = iCompService.getById(annualComp.getCompid()); + compVo.setCompName(comp.getCompName()); + CompType compType = iCompTypeService.getById(comp.getCompTypeId()); + compVo.setTypeName(compType.getTypeName()); + } + awareVos.add(compVo); + }); + resultMap.put("比赛获奖情况列表", awareVos); + + + List> canSaiList = new LinkedList<>(); + List> huoJiangList = new LinkedList<>(); + List pointList4Depart = convertPoint4Depart(sysDepart); + Set pointIds4Depart = Optional.ofNullable(pointList4Depart).orElse(new ArrayList<>()).stream().map(obj -> obj.getId()).collect(Collectors.toSet()); + Map departMap = new LinkedHashMap<>(); + departMap.put("部门名称", sysDepart.getDepartName()); + //报名列表 + List registrationList = iAnnualCompetitionProjectRegistrationService.list(new LambdaQueryWrapper() + .in(AnnualCompetitionProjectRegistration::getAnnualCompid, pointIds4Depart)); + if (!ObjectUtils.isEmpty(registrationList)) { + //报名编号 + Set enrollCodes = Optional.ofNullable(registrationList).orElse(new LinkedList<>()).stream().map(bo -> bo.getEnrollCode()).collect(Collectors.toSet()); + Long count = iTeamManagementService.count(new LambdaQueryWrapper().in(TeamManagement::getEnrollCode, enrollCodes)); + departMap.put("比赛总人数", count); + //个人赛报名数 + List registrationList4Stu = registrationList.stream().filter(b -> b.getEntryFormat().equals("0")).collect(Collectors.toList()); + Set enrollCodes4Stu = Optional.ofNullable(registrationList4Stu).orElse(new LinkedList<>()).stream().map(bo -> bo.getEnrollCode()).collect(Collectors.toSet()); + Long count4Stu = iTeamManagementService.count(new LambdaQueryWrapper().in(!ObjectUtils.isEmpty(enrollCodes4Stu), TeamManagement::getEnrollCode, enrollCodes4Stu)); + //学生人数 + departMap.put("个人赛人数", count4Stu); + departMap.put("团队赛人数", count - count4Stu); + } + canSaiList.add(departMap); + resultMap.put("部门参赛情况列表", canSaiList); + + List awardPersionList4Depart = iAwardPersionService.list(new LambdaQueryWrapper().eq(AwardPersion::getAnnualCompP, pointIds4Depart)); + Map departHuoJiangMap = new LinkedHashMap<>(); + departHuoJiangMap.put("部门名称", sysDepart.getDepartName()); + departHuoJiangMap.put("获取人数", awardPersionList4Depart.size()); + Map> awardNameMap = Optional.ofNullable(awardPersionList4Depart).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(AwardPersion::getAwardname)); + //遍历分组后的结果 + Map awardTypeMap2 = new HashMap<>(); +// AtomicInteger huoJiangCount = new AtomicInteger(); + Optional.ofNullable(awardNameMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { + departHuoJiangMap.put(key, value.size()); +// huoJiangCount.addAndGet(value.size()); + }); +// awardTypeMap2.put("获奖人数", huoJiangCount.get()); +// huoJiangList.add(awardTypeMap2); + resultMap.put("部门获奖情况列表", departHuoJiangMap); + + /*List scoreList4Point = new LinkedList<>(); + List personalCompScores = iPersonalCompScoreService.list(new LambdaQueryWrapper().eq(PersonalCompScore::getAnnualCompP, annualCompPointIds)); + Map> AnnualCompPointIdsMap = Optional.ofNullable(personalCompScores).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(PersonalCompScore::getAnnualCompP)); + Optional.ofNullable(AnnualCompPointIdsMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { + double sum = value.stream().mapToDouble(obj -> obj.getScore()).sum(); + HomePageCompVo vo = new HomePageCompVo(); + AnnualCompPoint point = iAnnualCompPointService.getById(key); + vo.setAnnualCompPointName(point.getObjName()); + vo.setAnnualCompPointId(key); + AnnualComp annualComp = iAnnualCompService.getById(point.getAnnualCompId()); + if (!ObjectUtils.isEmpty(annualComp)) { + Comp comp = iCompService.getById(annualComp.getCompid()); + if (!ObjectUtils.isEmpty(comp)) { + vo.setCompName(comp.getCompName()); + } + } + vo.setTotalScore(sum); + scoreList4Point.add(vo); + }); + scoreList4Point.stream().sorted(Comparator.comparing(HomePageCompVo::getTotalScore)).collect(Collectors.toList()); + resultMap.put("比赛学生积分况分析", scoreList4Point);*/ + return resultMap; } Map convertProjectLevel(List annualCompPointList) {