From a10bb33c5921d83f9d462a325d4abaab6a6ba6cb Mon Sep 17 00:00:00 2001 From: zhc077 <565291854@qq.com> Date: Tue, 16 Jul 2024 17:04:41 +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-=E9=A6=96=E9=A1=B5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserHomePageController.java | 38 +++ .../homepage/service/UserHomePageService.java | 12 + .../service/UserHomePageServiceImpl.java | 237 ++++++++++++++++++ .../demo/homepage/vo/HomePageCompVo.java | 57 +++++ .../demo/homepage/vo/Last5YearDataVo.java | 35 +++ 5 files changed, 379 insertions(+) create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/controller/UserHomePageController.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageService.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageServiceImpl.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/HomePageCompVo.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/Last5YearDataVo.java diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/controller/UserHomePageController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/controller/UserHomePageController.java new file mode 100644 index 00000000..736391a5 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/controller/UserHomePageController.java @@ -0,0 +1,38 @@ +package org.jeecg.modules.demo.homepage.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.demo.homepage.service.UserHomePageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * @Description: 用户登录首页 + * @Author: Z.H.C + * @CreateTime: 2024-07-16 09:20 + * @Version: 1.0 + */ +@Api(tags = "河南机电比赛系统-用户登录首页") +@RestController +@RequestMapping("/user/login/homepage") +@Slf4j +public class UserHomePageController { + + @Autowired + private UserHomePageService homePageService; + + @ApiOperation(value = "河南机电-学校首页", notes = "河南机电-学校首页") + @GetMapping(value = "/school") + public Result composite(HttpServletRequest req) { + Map result = homePageService.homePage4School(); + return Result.ok(result); + } + +} 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 new file mode 100644 index 00000000..b587f754 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageService.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.demo.homepage.service; + +import java.util.List; +import java.util.Map; + +public interface UserHomePageService { + + Map homePage4Depart(String departId); + + Map homePage4School(); + +} 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 new file mode 100644 index 00000000..52956670 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageServiceImpl.java @@ -0,0 +1,237 @@ +package org.jeecg.modules.demo.homepage.service; + +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.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; +import org.jeecg.modules.demo.annualCompPoint.service.IAnnualCompPointService; +import org.jeecg.modules.demo.annualScore.entity.DepartCompTotalScore; +import org.jeecg.modules.demo.annualScore.entity.PersonalCompScore; +import org.jeecg.modules.demo.annualScore.service.IDepartCompTotalScoreService; +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; +import org.jeecg.modules.demo.annualcompetitionprojectregistration.entity.AnnualCompetitionProjectRegistration; +import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.IAnnualCompetitionProjectRegistrationService; +import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.ITeamManagementService; +import org.jeecg.modules.demo.comp.entity.Comp; +import org.jeecg.modules.demo.comp.service.ICompService; +import org.jeecg.modules.demo.homepage.vo.HomePageCompVo; +import org.jeecg.modules.demo.projectlevel.entity.Projectlevel; +import org.jeecg.modules.demo.projectlevel.service.IProjectlevelService; +import org.jeecg.modules.system.entity.SysDepart; +import org.jeecg.modules.system.service.ISysDepartService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description: TODO + * @Author: Z.H.C + * @CreateTime: 2024-07-16 09:28 + * @Version: 1.0 + */ +@Service +public class UserHomePageServiceImpl implements UserHomePageService { + + @Autowired + private IAnnualCompPointService iAnnualCompPointService; + + @Autowired + private IAnnualCompService iAnnualCompService; + + @Autowired + private ICompService iCompService; + + // @Autowired +// private ICompTypeService iCompTypeService; +// + @Autowired + private ISysDepartService iSysDepartService; + + @Autowired + private IDepartCompTotalScoreService iDepartCompTotalScoreService; + + @Autowired + private IAnnualCompetitionProjectRegistrationService iAnnualCompetitionProjectRegistrationService; + + @Autowired + private ITeamManagementService iTeamManagementService; + +// @Autowired +// private IAwardPersionService iAwardPersionService; +// +// @Autowired +// private ISysUserService iSysUserService; + + @Autowired + private IPersonalCompTotalScoreService iPersonalCompTotalScoreService; + + @Autowired + private IPersonalCompScoreService iPersonalCompScoreService; + + @Autowired + private IDepartAbilityEvaluationService iDepartAbilityEvaluationService; + + @Autowired + private IPersonalAbilityEvaluationService iPersonalAbilityEvaluationService; + + @Autowired + private IPersonalAbilityEvaluationCollectService iPersonalAbilityEvaluationCollectService; + + @Autowired + private IAnnualService iAnnualService; + + @Autowired + private IProjectlevelService iProjectlevelService; + + + @Override + public Map homePage4Depart(String departId) { + return null; + } + + @Override + public Map homePage4School() { + + Map resultMap = new LinkedHashMap<>(); + + int currentYear = DateUtils.getCurrentYear(); + //当前年度 + Annual annual = iAnnualService.getOne(new LambdaQueryWrapper().eq(Annual::getAnnualName, currentYear + "")); + + List annualCompList = iAnnualCompService.list(new LambdaQueryWrapper() + .eq(AnnualComp::getAnnualid, annual.getId())); + + Set compIds = Optional.ofNullable(annualCompList).orElse(new LinkedList<>()).stream().map(obj -> obj.getId()).collect(Collectors.toSet()); + List annualCompPointList = iAnnualCompPointService.list(new LambdaQueryWrapper().in(AnnualCompPoint::getAnnualCompId, compIds)); + + //未评奖的项目为进行中 + 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); + } + + Set annualCompPointIds = Optional.ofNullable(annualCompPointList).orElse(new ArrayList<>()).stream().map(annualCompPoint -> annualCompPoint.getId()).collect(Collectors.toSet()); + if (!ObjectUtils.isEmpty(annualCompPointIds)) { + //报名表,只存本次的报名编号和项目id + List annualCompetitionProjectRegistrationList = iAnnualCompetitionProjectRegistrationService + .list(new LambdaQueryWrapper() + .in(AnnualCompetitionProjectRegistration::getAnnualCompid, annualCompPointIds) + .eq(AnnualCompetitionProjectRegistration::getEntryFormat, "1")); + countMap.put("本年度参加比赛队伍数", annualCompetitionProjectRegistrationList.size()); + } + resultMap.putAll(countMap); + + + 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())); + 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(); + vo.setAnnualId(bo.getId()); + vo.setValue(val); + vo.setCapacityId(key); + vo.setCapacityName(departAbilityEvaluationList.get(0).getCapacityName()); + vos.add(vo); + }); + abilityResultMap.put(bo.getAnnualName(), vos); + abilityList.add(abilityResultMap); + }); + resultMap.put("近2年能力分析", abilityList); + + + 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()); + 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); + + + List scoreList4Depart = new LinkedList<>(); + List departCompTotalScoreList = iDepartCompTotalScoreService.list(new LambdaQueryWrapper() + .eq(DepartCompTotalScore::getAnnualId, annual.getId())); + Map> departCompTotalScoresMap = Optional.ofNullable(departCompTotalScoreList).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(DepartCompTotalScore::getDepet)); + Optional.ofNullable(departCompTotalScoresMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { + double sum = value.stream().mapToDouble(obj -> obj.getScore()).sum(); + HomePageCompVo vo = new HomePageCompVo(); + SysDepart depart = iSysDepartService.getById(key); + vo.setCompOrganName(depart.getDepartName()); + vo.setTotalScore(sum); + scoreList4Depart.add(vo); + }); + scoreList4Depart.stream().sorted(Comparator.comparing(HomePageCompVo::getTotalScore)).collect(Collectors.toList()); + resultMap.put("本年度全校部门积分排名", scoreList4Depart); + return resultMap; + } + + Map convertProjectLevel(List annualCompPointList) { + Map map = new LinkedHashMap<>(); + Map> objLevelIdsMap = Optional.ofNullable(annualCompPointList).orElse(new LinkedList<>()).stream() + .collect(Collectors.groupingBy(AnnualCompPoint::getObjLevel)); + Optional.ofNullable(objLevelIdsMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { + Map levelMap = new LinkedHashMap<>(); + Projectlevel projectlevel = iProjectlevelService.getById(key); + levelMap.put(projectlevel.getName(), value.size()); + map.putAll(levelMap); + }); + return map; + } + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/HomePageCompVo.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/HomePageCompVo.java new file mode 100644 index 00000000..f160d60d --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/HomePageCompVo.java @@ -0,0 +1,57 @@ +package org.jeecg.modules.demo.homepage.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecg.modules.demo.projectlevel.entity.Projectlevel; + +import java.io.Serializable; + +/** + * @Description: TODO + * @Author: Z.H.C + * @CreateTime: 2023-11-29 15:52 + * @Version: 1.0 + */ +@Data +public class HomePageCompVo implements Serializable { + + @ApiModelProperty(value = "比赛id") + private String compId; + + @ApiModelProperty(value = "年度比赛项目名称") + private String annualCompPointName; + + /** + * 比赛名称 + */ + @ApiModelProperty(value = "比赛名称") + private String compName; + +// @ApiModelProperty(value = "部门id") +// private String compOrganId; + + @ApiModelProperty(value = "部门名称") + private String compOrganName; +// +// @ApiModelProperty(value = "奖项名称") +// private String awardName; +// + @ApiModelProperty(value = "项目总积分") + private double totalScore; +// +// @ApiModelProperty(value = "年度比赛项目数") +// private Integer annualCompPointNumber; +// +// @ApiModelProperty(value = "获取人数") +// private Integer awardNumber; +// +// @ApiModelProperty(value = "获取比率") +// private String awardRatio; +// +// @ApiModelProperty(value = "年度比赛状态") +// private String status; +// +// @ApiModelProperty(value = "比赛级别list") +// private Projectlevel projectLevelList; + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/Last5YearDataVo.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/Last5YearDataVo.java new file mode 100644 index 00000000..737626ea --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/Last5YearDataVo.java @@ -0,0 +1,35 @@ +package org.jeecg.modules.demo.homepage.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description: TODO + * @Author: Z.H.C + * @CreateTime: 2023-11-30 16:08 + * @Version: 1.0 + */ + +@Data +public class Last5YearDataVo implements Serializable { + +// @ApiModelProperty(value = "主键") +// private String id; + + /** + * 比赛名称 + */ +// @ApiModelProperty(value = "比赛名称") +// private String compName; + + @ApiModelProperty(value = "年度") + private String year; + + @ApiModelProperty(value = "比赛数量") + private Integer compCount; + + @ApiModelProperty(value = "参赛人数量") + private Integer personCount; +}