比赛大屏-学生个人、院系综合大屏接口 12.1

dev
zhc077 1 year ago
parent 4c461b5552
commit 1348c4d921
  1. 54
      jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 1
      jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  3. 8
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java
  4. 47
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/controller/CompSystemBigScreenController.java
  5. 11
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenService.java
  6. 253
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java
  7. 33
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/CompVo.java
  8. 36
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/Last5YearDataVo.java

@ -8,9 +8,7 @@ import java.sql.Timestamp;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.GregorianCalendar;
/** /**
* 类描述时间操作定义类 * 类描述时间操作定义类
@ -74,6 +72,7 @@ public class DateUtils extends PropertyEditorSupport {
/** /**
* 指定模式的时间格式 * 指定模式的时间格式
*
* @param pattern * @param pattern
* @return * @return
*/ */
@ -211,7 +210,7 @@ public class DateUtils extends PropertyEditorSupport {
/** /**
* 日期转换为字符串 * 日期转换为字符串
* *
* @param date 日期 * @param date 日期
* @param dateSdf 日期格式 * @param dateSdf 日期格式
* @return 字符串 * @return 字符串
*/ */
@ -673,13 +672,14 @@ public class DateUtils extends PropertyEditorSupport {
/** /**
* 将字符串转成时间 * 将字符串转成时间
*
* @param str * @param str
* @return * @return
*/ */
public static Date parseDatetime(String str){ public static Date parseDatetime(String str) {
try { try {
return datetimeFormat.get().parse(str); return datetimeFormat.get().parse(str);
}catch (Exception e){ } catch (Exception e) {
} }
return null; return null;
} }
@ -760,4 +760,46 @@ public class DateUtils extends PropertyEditorSupport {
return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR);
} }
/**
* @description: 获取当前年
* @param: []
* @return: int
* @author: z.h.c
* @date: 23/11/30 15:26
*/
public static int getCurrentYear() {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
return year;
}
/**
* @description: 获取当前年前4年年份列表
* @param: []
* @return: int
* @author: z.h.c
* @date: 23/11/30 15:38
*/
public static List<Integer> getLast4Year() {
Calendar calendar = Calendar.getInstance(); // 创建Calendar对象并初始化为当前时间
int currentYear = calendar.get(Calendar.YEAR);
List<Integer> years = new LinkedList<>();
years.add(currentYear);
for (int i = 0; i < 4; i++) {
calendar.add(Calendar.YEAR, -1); // 将日期向前移动一年
int previousYear = calendar.get(Calendar.YEAR); // 获取上一年的年份
years.add(previousYear);
}
return years;
}
public static void main(String[] args) {
List<Integer> last4Year = getLast4Year();
last4Year.forEach(y->{
System.out.println(y);
});
}
} }

@ -137,6 +137,7 @@ public class ShiroConfig {
//filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试 //filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试
//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");//比赛大屏
//websocket排除 //websocket排除
filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告 filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告

@ -97,4 +97,12 @@ public class AwardPersion implements Serializable {
@Excel(name = "学生学号", width = 15) @Excel(name = "学生学号", width = 15)
@ApiModelProperty(value = "学生学号") @ApiModelProperty(value = "学生学号")
private String studentcode; private String studentcode;
@TableField(exist = false)
@ApiModelProperty(value = "年度比赛项目名称")
private java.lang.String annualCompPname;
@TableField(exist = false)
@ApiModelProperty(value = "负责部门")
private String compOrganName;
} }

@ -0,0 +1,47 @@
package org.jeecg.modules.demo.bigScreen.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.abilityEvaluation.entity.PersonalAbilityEvaluation;
import org.jeecg.modules.demo.bigScreen.service.CompSystemBigScreenService;
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: 2023-11-28 16:45
* @Version: 1.0
*/
@Api(tags = "比赛系统大屏")
@RestController
@RequestMapping("/comp/bigScreen")
@Slf4j
public class CompSystemBigScreenController /*extends JeecgController*/ {
@Autowired
private CompSystemBigScreenService compSystemBigScreenService;
@ApiOperation(value = "院系综合大屏", notes = "院系综合大屏")
@GetMapping(value = "/depart")
public Result bigScreen4Depart(HttpServletRequest req) {
Map<String, Object> result = compSystemBigScreenService.bigScreen4Depart();
return Result.ok(result);
}
@ApiOperation(value = "学生个人能力大屏", notes = "学生个人能力大屏")
@GetMapping(value = "/student")
public Result bigScreen4Student(PersonalAbilityEvaluation personalAbilityEvaluation) {
Map<String, Object> result = compSystemBigScreenService.bigScreen4Student(personalAbilityEvaluation);
return Result.ok(result);
}
}

@ -0,0 +1,11 @@
package org.jeecg.modules.demo.bigScreen.service;
import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluation;
import java.util.Map;
public interface CompSystemBigScreenService {
Map<String, Object> bigScreen4Depart();
Map<String, Object> bigScreen4Student(PersonalAbilityEvaluation personalAbilityEvaluation);
}

@ -0,0 +1,253 @@
package org.jeecg.modules.demo.bigScreen.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.demo.abilityEvaluation.entity.DepartAbilityEvaluation;
import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluation;
import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluationCollect;
import org.jeecg.modules.demo.abilityEvaluation.service.IDepartAbilityEvaluationService;
import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluationCollectService;
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.PersonalCompTotalScore;
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.entity.TeamManagement;
import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.IAnnualCompetitionProjectRegistrationService;
import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.ITeamManagementService;
import org.jeecg.modules.demo.awardpersion.entity.AwardPersion;
import org.jeecg.modules.demo.awardpersion.service.IAwardPersionService;
import org.jeecg.modules.demo.bigScreen.vo.CompVo;
import org.jeecg.modules.demo.bigScreen.vo.Last5YearDataVo;
import org.jeecg.modules.demo.comp.entity.Comp;
import org.jeecg.modules.demo.comp.service.ICompService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* @Description: TODO
* @Author: Z.H.C
* @CreateTime: 2023-11-28 17:00
* @Version: 1.0
*/
@Service
public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenService {
@Autowired
private IAnnualCompPointService iAnnualCompPointService;
@Autowired
private IAnnualCompService iAnnualCompService;
@Autowired
private ICompService iCompService;
@Autowired
private ISysDepartService iSysDepartService;
@Autowired
private IAnnualCompetitionProjectRegistrationService iAnnualCompetitionProjectRegistrationService;
@Autowired
private ITeamManagementService iTeamManagementService;
@Autowired
private IAwardPersionService iAwardPersionService;
@Autowired
private ISysUserService iSysUserService;
@Autowired
private IPersonalCompTotalScoreService iPersonalCompTotalScoreService;
@Autowired
private IDepartAbilityEvaluationService iDepartAbilityEvaluationService;
@Autowired
private IPersonalAbilityEvaluationCollectService iPersonalAbilityEvaluationCollectService;
@Autowired
private IAnnualService iAnnualService;
@Override
public Map<String, Object> bigScreen4Depart() {
Map<String, Object> resultMap = new LinkedHashMap<>();
resultMap.put("compList", this.getCompList());
List<AwardPersion> awardPersionList = iAwardPersionService.list(new LambdaQueryWrapper<AwardPersion>().last("limit 30"));
Optional.ofNullable(awardPersionList).orElse(new LinkedList<>()).forEach(award -> {
// 根据报名编号查询参赛者信息,都是个人赛场景
TeamManagement management = iTeamManagementService.getOne(new LambdaQueryWrapper<TeamManagement>()
.eq(TeamManagement::getEnrollCode, award.getEnrollCode()).last("limit 1"));
if (ObjectUtils.isEmpty(management)) return;
SysUser sysUser = iSysUserService.getById(management.getUserId());
award.setStudentname(sysUser.getRealname());
AnnualCompPoint annualCompPoint = iAnnualCompPointService.getById(award.getAnnualCompP());
award.setAnnualCompPname(annualCompPoint.getObjName());
});
resultMap.put("awardList", awardPersionList);
List<PersonalCompTotalScore> personalCompScoreList = iPersonalCompTotalScoreService.list(new LambdaQueryWrapper<PersonalCompTotalScore>()
.orderByDesc(PersonalCompTotalScore::getScore)
.last("limit 50"));
resultMap.put("studentScore", personalCompScoreList);
Map<String, Object> compCounts = new LinkedHashMap<>();
Long compCount = iCompService.count();
Long pointCount = iAnnualCompPointService.count();
//比赛数
compCounts.put("compCount", compCount);
//年度项目比赛数
compCounts.put("pointCount", pointCount);
//总报名数数
Long count = iAnnualCompetitionProjectRegistrationService.count();
//学生人数
Long personCount = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>()
.eq(AnnualCompetitionProjectRegistration::getEntryFormat, "0"));
compCounts.put("personCompCount", personCount);
//队伍数
Long teamCount = count - personCount;
compCounts.put("teamCompCount", teamCount);
resultMap.put("compCounts", compCounts);
List<DepartAbilityEvaluation> departAbilityEvaluations = iDepartAbilityEvaluationService.list();
resultMap.put("departAbilityEvaluation", departAbilityEvaluations);
List<Integer> years = DateUtils.getLast4Year();
List<Annual> annualList = iAnnualService.list(new LambdaQueryWrapper<Annual>().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName));
List<Last5YearDataVo> last5YearDataVos = new LinkedList<>();
Optional.ofNullable(annualList).orElse(new LinkedList<>()).stream().forEach(annual -> {
Last5YearDataVo last5YearDataVo = new Last5YearDataVo();
last5YearDataVo.setYear(annual.getAnnualName());
AtomicReference<BigDecimal> personCount4Comp = new AtomicReference<>(BigDecimal.ZERO);
List<AnnualComp> annualCompList = iAnnualCompService.list(new LambdaQueryWrapper<AnnualComp>().eq(AnnualComp::getAnnualid, annual.getId()));
//比赛数
last5YearDataVo.setCompCount(annualCompList.size());
if (!ObjectUtils.isEmpty(annualCompList)) {
annualCompList.stream().forEach(ac -> {
AnnualCompPoint annualCompPoint = iAnnualCompPointService.getOne(new LambdaQueryWrapper<AnnualCompPoint>().eq(AnnualCompPoint::getAnnualCompId, ac.getId()));
if (!ObjectUtils.isEmpty(annualCompPoint)) {
long personCount4CompTemp = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>().
eq(AnnualCompetitionProjectRegistration::getAnnualCompid, annualCompPoint.getId()));
personCount4Comp.getAndUpdate(val -> val.add(new BigDecimal(personCount4CompTemp)));
}
});
}
last5YearDataVo.setPersonCount(personCount4Comp.get().intValue());
last5YearDataVos.add(last5YearDataVo);
});
resultMap.put("last5YearData", last5YearDataVos);
return resultMap;
}
@Override
public Map<String, Object> bigScreen4Student(PersonalAbilityEvaluation person) {
Assert.notNull(person.getWorkOn(), "学号不能为空");
Map<String, Object> resultMap = new LinkedHashMap<>();
List<PersonalAbilityEvaluationCollect> personalAbilityEvaluationList = iPersonalAbilityEvaluationCollectService.list(new LambdaQueryWrapper<PersonalAbilityEvaluationCollect>()
.eq(PersonalAbilityEvaluationCollect::getWorkOn, person.getWorkOn()));
resultMap.put("studentAbilityEvaluation", personalAbilityEvaluationList);
Map<String, Object> studentInfoMap = new LinkedHashMap<>();
PersonalCompTotalScore compTotalScore = iPersonalCompTotalScoreService.getOne(new LambdaQueryWrapper<PersonalCompTotalScore>()
.eq(PersonalCompTotalScore::getWorkOn, person.getWorkOn()));
studentInfoMap.put("score", compTotalScore);
SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getWorkNo, person.getWorkOn()));
List<AwardPersion> awardPersions = iAwardPersionService.list(new LambdaQueryWrapper<AwardPersion>()
.eq(AwardPersion::getStudentcode, person.getWorkOn()));
Optional.ofNullable(awardPersions).orElse(new LinkedList<>()).forEach(award -> {
AnnualCompPoint annualCompPoint = iAnnualCompPointService.getById(award.getAnnualCompP());
award.setAnnualCompPname(annualCompPoint.getObjName());
});
studentInfoMap.put("studentAwardList", awardPersions);
studentInfoMap.put("workNo", person.getWorkOn());
studentInfoMap.put("name", sysUser.getRealname());
studentInfoMap.put("major", "软件工程");
studentInfoMap.put("grade", "202*级");
studentInfoMap.put("class", "软工*班");
resultMap.put("studentInfo", studentInfoMap);
List<TeamManagement> studentEnrollCodeList = iTeamManagementService.list(new LambdaQueryWrapper<TeamManagement>()
.eq(TeamManagement::getUserId, sysUser.getId()));
List<String> enrollCodeList = studentEnrollCodeList.stream().map(en -> en.getEnrollCode()).collect(Collectors.toList());
List<AnnualCompetitionProjectRegistration> registrationList = iAnnualCompetitionProjectRegistrationService.list(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>()
.in(AnnualCompetitionProjectRegistration::getEnrollCode, enrollCodeList));
List<CompVo> compVoList = new LinkedList<>();
Optional.ofNullable(registrationList).orElse(new LinkedList<>()).forEach(r -> {
AnnualCompPoint p = iAnnualCompPointService.getById(r.getAnnualCompid());
CompVo compVo = new CompVo();
BeanUtils.copyProperties(p, compVo);
AwardPersion awardPersion = iAwardPersionService.getOne(new LambdaQueryWrapper<AwardPersion>()
.eq(AwardPersion::getEnrollCode, r.getEnrollCode())
.eq(AwardPersion::getAnnualCompP, r.getAnnualCompid())
);
if (ObjectUtils.isEmpty(awardPersion)) {
compVo.setAwardName("--");
} else {
compVo.setAwardName(awardPersion.getAwardname());
}
compVo.setCompName(p.getObjName());
AnnualComp annualComp = iAnnualCompService.getById(p.getAnnualCompId());
if (!ObjectUtils.isEmpty(annualComp)) {
Comp comp = iCompService.getById(annualComp.getCompid());
if (!ObjectUtils.isEmpty(comp)) {
SysDepart sysDepart = iSysDepartService.getById(comp.getCompOrgan());
compVo.setCompOrganName(sysDepart.getDepartName());
}
}
compVoList.add(compVo);
});
resultMap.put("compList", compVoList);
return resultMap;
}
List<CompVo> getCompList() {
List<AnnualCompPoint> annualCompPointList = iAnnualCompPointService.list(new LambdaQueryWrapper<AnnualCompPoint>()
.eq(AnnualCompPoint::getRequireApply, "Y"));
List<CompVo> compVoList = new LinkedList<>();
Optional.ofNullable(annualCompPointList).orElse(new LinkedList<>()).stream().forEach(p -> {
CompVo compVo = new CompVo();
BeanUtils.copyProperties(p, compVo);
Long numberCount = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>()
.eq(AnnualCompetitionProjectRegistration::getAnnualCompid, p.getId()));
compVo.setNumber(numberCount.intValue());
AnnualComp annualComp = iAnnualCompService.getById(p.getAnnualCompId());
if (!ObjectUtils.isEmpty(annualComp)) {
Comp comp = iCompService.getById(annualComp.getCompid());
if (!ObjectUtils.isEmpty(comp)) {
compVo.setCompName(comp.getCompName());
SysDepart sysDepart = iSysDepartService.getById(comp.getCompOrgan());
compVo.setCompOrganName(sysDepart.getDepartName());
}
}
compVoList.add(compVo);
});
return compVoList;
}
}

@ -0,0 +1,33 @@
package org.jeecg.modules.demo.bigScreen.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @Description: TODO
* @Author: Z.H.C
* @CreateTime: 2023-11-29 15:52
* @Version: 1.0
*/
@Data
public class CompVo implements Serializable {
@ApiModelProperty(value = "主键")
private String id;
/**
* 比赛名称
*/
@ApiModelProperty(value = "比赛名称")
private String compName;
@ApiModelProperty(value = "负责部门")
private String compOrganName;
@ApiModelProperty(value = "奖项名称")
private java.lang.String awardName;
private Integer number;
}

@ -0,0 +1,36 @@
package org.jeecg.modules.demo.bigScreen.vo;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
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…
Cancel
Save