forked from wangjiadong/comp
parent
f6a39b0c63
commit
a10bb33c59
5 changed files with 379 additions and 0 deletions
@ -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<String, Object> result = homePageService.homePage4School(); |
||||
return Result.ok(result); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
package org.jeecg.modules.demo.homepage.service; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface UserHomePageService { |
||||
|
||||
Map<String, Object> homePage4Depart(String departId); |
||||
|
||||
Map<String, Object> homePage4School(); |
||||
|
||||
} |
@ -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<String, Object> homePage4Depart(String departId) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public Map<String, Object> homePage4School() { |
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>(); |
||||
|
||||
int currentYear = DateUtils.getCurrentYear(); |
||||
//当前年度
|
||||
Annual annual = iAnnualService.getOne(new LambdaQueryWrapper<Annual>().eq(Annual::getAnnualName, currentYear + "")); |
||||
|
||||
List<AnnualComp> annualCompList = iAnnualCompService.list(new LambdaQueryWrapper<AnnualComp>() |
||||
.eq(AnnualComp::getAnnualid, annual.getId())); |
||||
|
||||
Set<String> compIds = Optional.ofNullable(annualCompList).orElse(new LinkedList<>()).stream().map(obj -> obj.getId()).collect(Collectors.toSet()); |
||||
List<AnnualCompPoint> annualCompPointList = iAnnualCompPointService.list(new LambdaQueryWrapper<AnnualCompPoint>().in(AnnualCompPoint::getAnnualCompId, compIds)); |
||||
|
||||
//未评奖的项目为进行中
|
||||
List<AnnualCompPoint> pj0PointList = Optional.ofNullable(annualCompPointList).orElse(new LinkedList<>()).stream().filter(bo -> "0".equals(bo.getIsPj())).collect(Collectors.toList()); |
||||
Map<String, Object> 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<String> annualCompPointIds = Optional.ofNullable(annualCompPointList).orElse(new ArrayList<>()).stream().map(annualCompPoint -> annualCompPoint.getId()).collect(Collectors.toSet()); |
||||
if (!ObjectUtils.isEmpty(annualCompPointIds)) { |
||||
//报名表,只存本次的报名编号和项目id
|
||||
List<AnnualCompetitionProjectRegistration> annualCompetitionProjectRegistrationList = iAnnualCompetitionProjectRegistrationService |
||||
.list(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>() |
||||
.in(AnnualCompetitionProjectRegistration::getAnnualCompid, annualCompPointIds) |
||||
.eq(AnnualCompetitionProjectRegistration::getEntryFormat, "1")); |
||||
countMap.put("本年度参加比赛队伍数", annualCompetitionProjectRegistrationList.size()); |
||||
} |
||||
resultMap.putAll(countMap); |
||||
|
||||
|
||||
List<Map<String, Object>> abilityList = new LinkedList<>(); |
||||
List<Integer> years = DateUtils.getLastxYear(2); |
||||
List<Annual> annualList = iAnnualService.list(new LambdaQueryWrapper<Annual>().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName)); |
||||
Optional.ofNullable(annualList).orElse(new LinkedList<>()).stream().forEach(bo -> { |
||||
Map<String, Object> abilityResultMap = new LinkedHashMap<>(); |
||||
List<DepartAbilityEvaluation> departAbilityEvaluations = iDepartAbilityEvaluationService.list(new LambdaQueryWrapper<DepartAbilityEvaluation>() |
||||
.eq(DepartAbilityEvaluation::getAnnualId, bo.getId())); |
||||
List<DepartAbilityEvaluation> vos = new LinkedList<>(); |
||||
Map<String, List<DepartAbilityEvaluation>> capacityIdListMap = Optional.ofNullable(departAbilityEvaluations).orElse(new LinkedList<>()).stream() |
||||
.collect(Collectors.groupingBy(DepartAbilityEvaluation::getCapacityId)); |
||||
//遍历分组后的结果
|
||||
Optional.ofNullable(capacityIdListMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { |
||||
List<DepartAbilityEvaluation> 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<HomePageCompVo> scoreList4Point = new LinkedList<>(); |
||||
List<PersonalCompScore> personalCompScores = iPersonalCompScoreService.list(new LambdaQueryWrapper<PersonalCompScore>().eq(PersonalCompScore::getAnnualCompP, annualCompPointIds)); |
||||
Map<String, List<PersonalCompScore>> 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<HomePageCompVo> scoreList4Depart = new LinkedList<>(); |
||||
List<DepartCompTotalScore> departCompTotalScoreList = iDepartCompTotalScoreService.list(new LambdaQueryWrapper<DepartCompTotalScore>() |
||||
.eq(DepartCompTotalScore::getAnnualId, annual.getId())); |
||||
Map<String, List<DepartCompTotalScore>> 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<String, Object> convertProjectLevel(List<AnnualCompPoint> annualCompPointList) { |
||||
Map<String, Object> map = new LinkedHashMap<>(); |
||||
Map<String, List<AnnualCompPoint>> objLevelIdsMap = Optional.ofNullable(annualCompPointList).orElse(new LinkedList<>()).stream() |
||||
.collect(Collectors.groupingBy(AnnualCompPoint::getObjLevel)); |
||||
Optional.ofNullable(objLevelIdsMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { |
||||
Map<String, Object> levelMap = new LinkedHashMap<>(); |
||||
Projectlevel projectlevel = iProjectlevelService.getById(key); |
||||
levelMap.put(projectlevel.getName(), value.size()); |
||||
map.putAll(levelMap); |
||||
}); |
||||
return map; |
||||
} |
||||
|
||||
} |
@ -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;
|
||||
|
||||
} |
@ -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; |
||||
} |
Loading…
Reference in new issue