|
|
@ -1,5 +1,6 @@ |
|
|
|
package org.jeecg.modules.demo.homepage.service; |
|
|
|
package org.jeecg.modules.demo.homepage.service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import org.jeecg.common.util.ComputeUtils; |
|
|
|
import org.jeecg.common.util.ComputeUtils; |
|
|
|
import org.jeecg.common.util.DateUtils; |
|
|
|
import org.jeecg.common.util.DateUtils; |
|
|
@ -30,6 +31,7 @@ import org.jeecg.modules.system.entity.SysDepart; |
|
|
|
import org.jeecg.modules.system.service.ISysDepartService; |
|
|
|
import org.jeecg.modules.system.service.ISysDepartService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
@ -67,8 +69,8 @@ public class UserHomePageServiceImpl implements UserHomePageService { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IAnnualCompetitionProjectRegistrationService iAnnualCompetitionProjectRegistrationService; |
|
|
|
private IAnnualCompetitionProjectRegistrationService iAnnualCompetitionProjectRegistrationService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
// @Autowired
|
|
|
|
private ITeamManagementService iTeamManagementService; |
|
|
|
// private ITeamManagementService iTeamManagementService;
|
|
|
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
|
// @Autowired
|
|
|
|
// private IAwardPersionService iAwardPersionService;
|
|
|
|
// private IAwardPersionService iAwardPersionService;
|
|
|
@ -85,11 +87,11 @@ public class UserHomePageServiceImpl implements UserHomePageService { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IDepartAbilityEvaluationService iDepartAbilityEvaluationService; |
|
|
|
private IDepartAbilityEvaluationService iDepartAbilityEvaluationService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
// @Autowired
|
|
|
|
private IPersonalAbilityEvaluationService iPersonalAbilityEvaluationService; |
|
|
|
// private IPersonalAbilityEvaluationService iPersonalAbilityEvaluationService;
|
|
|
|
|
|
|
|
//
|
|
|
|
@Autowired |
|
|
|
// @Autowired
|
|
|
|
private IPersonalAbilityEvaluationCollectService iPersonalAbilityEvaluationCollectService; |
|
|
|
// private IPersonalAbilityEvaluationCollectService iPersonalAbilityEvaluationCollectService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IAnnualService iAnnualService; |
|
|
|
private IAnnualService iAnnualService; |
|
|
@ -100,14 +102,132 @@ public class UserHomePageServiceImpl implements UserHomePageService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> homePage4Depart(String departId) { |
|
|
|
public Map<String, Object> homePage4Depart(String departId) { |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(departId, "部门id不能为空"); |
|
|
|
|
|
|
|
Map<String, Object> resultMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
int currentYear = DateUtils.getCurrentYear(); |
|
|
|
|
|
|
|
//当前年度
|
|
|
|
|
|
|
|
Annual annual = iAnnualService.getOne(new LambdaQueryWrapper<Annual>().eq(Annual::getAnnualName, currentYear + "")); |
|
|
|
|
|
|
|
List<Comp> compList = iCompService.list(new LambdaQueryWrapper<Comp>().eq(Comp::getCompOrgan, departId)); |
|
|
|
|
|
|
|
Set<String> compIds = Optional.ofNullable(compList).orElse(new LinkedList<>()).stream().map(obj -> obj.getId()).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
List<AnnualComp> annualCompList = new ArrayList<>(); |
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(compIds)) { |
|
|
|
|
|
|
|
annualCompList = iAnnualCompService.list(new LambdaQueryWrapper<AnnualComp>() |
|
|
|
|
|
|
|
.eq(AnnualComp::getAnnualid, annual.getId()) |
|
|
|
|
|
|
|
.in(AnnualComp::getCompid, compIds)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Set<String> annualCompIds = 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, annualCompIds)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//未评奖的项目为进行中
|
|
|
|
|
|
|
|
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()) |
|
|
|
|
|
|
|
.eq(DepartAbilityEvaluation::getDepetId, departId)); |
|
|
|
|
|
|
|
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> scoreList4Student = new LinkedList<>(); |
|
|
|
|
|
|
|
List<PersonalCompScore> personalCompScoreList = iPersonalCompScoreService.list(new LambdaQueryWrapper<PersonalCompScore>() |
|
|
|
|
|
|
|
.eq(PersonalCompScore::getAnnualId, annual.getId()) |
|
|
|
|
|
|
|
.eq(PersonalCompScore::getDepet, departId) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
Map<String, List<PersonalCompScore>> workNosMap = Optional.ofNullable(personalCompScoreList).orElse(new LinkedList<>()).stream() |
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(PersonalCompScore::getWorkOn)); |
|
|
|
|
|
|
|
Optional.ofNullable(workNosMap).orElse(new LinkedHashMap<>()).forEach((key, value) -> { |
|
|
|
|
|
|
|
double sum = value.stream().mapToDouble(obj -> obj.getScore()).sum(); |
|
|
|
|
|
|
|
HomePageCompVo vo = new HomePageCompVo(); |
|
|
|
|
|
|
|
vo.setWorkNo(key); |
|
|
|
|
|
|
|
vo.setStuName(value.get(0).getName()); |
|
|
|
|
|
|
|
vo.setTotalScore(sum); |
|
|
|
|
|
|
|
scoreList4Student.add(vo); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
scoreList4Student.stream().sorted(Comparator.comparing(HomePageCompVo::getTotalScore)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
resultMap.put("本年度部门学生积分排名", scoreList4Student); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> homePage4School() { |
|
|
|
public Map<String, Object> homePage4School() { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> resultMap = new LinkedHashMap<>(); |
|
|
|
Map<String, Object> resultMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
int currentYear = DateUtils.getCurrentYear(); |
|
|
|
int currentYear = DateUtils.getCurrentYear(); |
|
|
|
//当前年度
|
|
|
|
//当前年度
|
|
|
|
Annual annual = iAnnualService.getOne(new LambdaQueryWrapper<Annual>().eq(Annual::getAnnualName, currentYear + "")); |
|
|
|
Annual annual = iAnnualService.getOne(new LambdaQueryWrapper<Annual>().eq(Annual::getAnnualName, currentYear + "")); |
|
|
@ -189,6 +309,7 @@ public class UserHomePageServiceImpl implements UserHomePageService { |
|
|
|
HomePageCompVo vo = new HomePageCompVo(); |
|
|
|
HomePageCompVo vo = new HomePageCompVo(); |
|
|
|
AnnualCompPoint point = iAnnualCompPointService.getById(key); |
|
|
|
AnnualCompPoint point = iAnnualCompPointService.getById(key); |
|
|
|
vo.setAnnualCompPointName(point.getObjName()); |
|
|
|
vo.setAnnualCompPointName(point.getObjName()); |
|
|
|
|
|
|
|
vo.setAnnualCompPointId(key); |
|
|
|
AnnualComp annualComp = iAnnualCompService.getById(point.getAnnualCompId()); |
|
|
|
AnnualComp annualComp = iAnnualCompService.getById(point.getAnnualCompId()); |
|
|
|
if (!ObjectUtils.isEmpty(annualComp)) { |
|
|
|
if (!ObjectUtils.isEmpty(annualComp)) { |
|
|
|
Comp comp = iCompService.getById(annualComp.getCompid()); |
|
|
|
Comp comp = iCompService.getById(annualComp.getCompid()); |
|
|
@ -212,6 +333,7 @@ public class UserHomePageServiceImpl implements UserHomePageService { |
|
|
|
double sum = value.stream().mapToDouble(obj -> obj.getScore()).sum(); |
|
|
|
double sum = value.stream().mapToDouble(obj -> obj.getScore()).sum(); |
|
|
|
HomePageCompVo vo = new HomePageCompVo(); |
|
|
|
HomePageCompVo vo = new HomePageCompVo(); |
|
|
|
SysDepart depart = iSysDepartService.getById(key); |
|
|
|
SysDepart depart = iSysDepartService.getById(key); |
|
|
|
|
|
|
|
vo.setDepartId(key); |
|
|
|
vo.setCompOrganName(depart.getDepartName()); |
|
|
|
vo.setCompOrganName(depart.getDepartName()); |
|
|
|
vo.setTotalScore(sum); |
|
|
|
vo.setTotalScore(sum); |
|
|
|
scoreList4Depart.add(vo); |
|
|
|
scoreList4Depart.add(vo); |
|
|
|