Merge remote-tracking branch 'origin/main'

main
王家东 4 months ago
commit a526a8ee18
  1. 1
      jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 8
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/controller/UserHomePageController.java
  3. 140
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/service/UserHomePageServiceImpl.java
  4. 35
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/homepage/vo/HomePageCompVo.java

@ -140,6 +140,7 @@ public class ShiroConfig {
//filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面 //filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
//filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试 //filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
filterChainDefinitionMap.put("/comp/bigScreen/**", "anon");//比赛大屏 filterChainDefinitionMap.put("/comp/bigScreen/**", "anon");//比赛大屏
filterChainDefinitionMap.put("/user/login/homepage/**", "anon");//比赛大屏
filterChainDefinitionMap.put("/admin/inde/inde", "anon");//比赛大屏 filterChainDefinitionMap.put("/admin/inde/inde", "anon");//比赛大屏
//websocket排除 //websocket排除

@ -30,9 +30,15 @@ public class UserHomePageController {
@ApiOperation(value = "河南机电-学校首页", notes = "河南机电-学校首页") @ApiOperation(value = "河南机电-学校首页", notes = "河南机电-学校首页")
@GetMapping(value = "/school") @GetMapping(value = "/school")
public Result composite(HttpServletRequest req) { public Result school(HttpServletRequest req) {
Map<String, Object> result = homePageService.homePage4School(); Map<String, Object> result = homePageService.homePage4School();
return Result.ok(result); return Result.ok(result);
} }
@ApiOperation(value = "河南机电-部门首页", notes = "河南机电-部门首页")
@GetMapping(value = "/depart")
public Result depart(String departId) {
Map<String, Object> result = homePageService.homePage4Depart(departId);
return Result.ok(result);
}
} }

@ -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);

@ -2,7 +2,6 @@ package org.jeecg.modules.demo.homepage.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.jeecg.modules.demo.projectlevel.entity.Projectlevel;
import java.io.Serializable; import java.io.Serializable;
@ -15,8 +14,8 @@ import java.io.Serializable;
@Data @Data
public class HomePageCompVo implements Serializable { public class HomePageCompVo implements Serializable {
@ApiModelProperty(value = "比赛id") @ApiModelProperty(value = "项目id")
private String compId; private String annualCompPointId;
@ApiModelProperty(value = "年度比赛项目名称") @ApiModelProperty(value = "年度比赛项目名称")
private String annualCompPointName; private String annualCompPointName;
@ -27,31 +26,19 @@ public class HomePageCompVo implements Serializable {
@ApiModelProperty(value = "比赛名称") @ApiModelProperty(value = "比赛名称")
private String compName; private String compName;
// @ApiModelProperty(value = "部门id") @ApiModelProperty(value = "学生编号")
// private String compOrganId; private String workNo;
@ApiModelProperty(value = "学生名称")
private String stuName;
@ApiModelProperty(value = "部门名称") @ApiModelProperty(value = "部门名称")
private String compOrganName; private String compOrganName;
//
// @ApiModelProperty(value = "奖项名称") @ApiModelProperty(value = "部门id")
// private String awardName; private String departId;
//
@ApiModelProperty(value = "项目总积分") @ApiModelProperty(value = "项目总积分")
private double totalScore; 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;
} }

Loading…
Cancel
Save