diff --git a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java index e063da5d..55273f58 100644 --- a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java +++ b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java @@ -8,9 +8,7 @@ import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; +import java.util.*; /** * 类描述:时间操作定义类 @@ -74,6 +72,7 @@ public class DateUtils extends PropertyEditorSupport { /** * 指定模式的时间格式 + * * @param pattern * @return */ @@ -211,7 +210,7 @@ public class DateUtils extends PropertyEditorSupport { /** * 日期转换为字符串 * - * @param date 日期 + * @param date 日期 * @param dateSdf 日期格式 * @return 字符串 */ @@ -673,13 +672,14 @@ public class DateUtils extends PropertyEditorSupport { /** * 将字符串转成时间 + * * @param str * @return */ - public static Date parseDatetime(String str){ + public static Date parseDatetime(String str) { try { return datetimeFormat.get().parse(str); - }catch (Exception e){ + } catch (Exception e) { } return null; } @@ -760,4 +760,46 @@ public class DateUtils extends PropertyEditorSupport { return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); } -} \ No newline at end of file + /** + * @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 getLast4Year() { + Calendar calendar = Calendar.getInstance(); // 创建Calendar对象并初始化为当前时间 + int currentYear = calendar.get(Calendar.YEAR); + List 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 last4Year = getLast4Year(); + last4Year.forEach(y->{ + System.out.println(y); + }); + } + + +} diff --git a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java index 03944151..6f79ff6b 100644 --- a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java +++ b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java @@ -137,6 +137,7 @@ public class ShiroConfig { //filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试 //filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面 //filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试 + filterChainDefinitionMap.put("/comp/bigScreen/**", "anon");//比赛大屏 //websocket排除 filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告 diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java index e8164fbf..b25349bb 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java @@ -97,4 +97,12 @@ public class AwardPersion implements Serializable { @Excel(name = "学生学号", width = 15) @ApiModelProperty(value = "学生学号") private String studentcode; + + @TableField(exist = false) + @ApiModelProperty(value = "年度比赛项目名称") + private java.lang.String annualCompPname; + + @TableField(exist = false) + @ApiModelProperty(value = "负责部门") + private String compOrganName; } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/controller/CompSystemBigScreenController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/controller/CompSystemBigScreenController.java new file mode 100644 index 00000000..5ee24a31 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/controller/CompSystemBigScreenController.java @@ -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 result = compSystemBigScreenService.bigScreen4Depart(); + return Result.ok(result); + } + + @ApiOperation(value = "学生个人能力大屏", notes = "学生个人能力大屏") + @GetMapping(value = "/student") + public Result bigScreen4Student(PersonalAbilityEvaluation personalAbilityEvaluation) { + Map result = compSystemBigScreenService.bigScreen4Student(personalAbilityEvaluation); + return Result.ok(result); + } + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenService.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenService.java new file mode 100644 index 00000000..e930981b --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenService.java @@ -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 bigScreen4Depart(); + + Map bigScreen4Student(PersonalAbilityEvaluation personalAbilityEvaluation); +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java new file mode 100644 index 00000000..6f2b86ed --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java @@ -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 bigScreen4Depart() { + + Map resultMap = new LinkedHashMap<>(); + + resultMap.put("compList", this.getCompList()); + + List awardPersionList = iAwardPersionService.list(new LambdaQueryWrapper().last("limit 30")); + Optional.ofNullable(awardPersionList).orElse(new LinkedList<>()).forEach(award -> { + // 根据报名编号查询参赛者信息,都是个人赛场景 + TeamManagement management = iTeamManagementService.getOne(new LambdaQueryWrapper() + .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 personalCompScoreList = iPersonalCompTotalScoreService.list(new LambdaQueryWrapper() + .orderByDesc(PersonalCompTotalScore::getScore) + .last("limit 50")); + resultMap.put("studentScore", personalCompScoreList); + + Map 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() + .eq(AnnualCompetitionProjectRegistration::getEntryFormat, "0")); + compCounts.put("personCompCount", personCount); + //队伍数 + Long teamCount = count - personCount; + compCounts.put("teamCompCount", teamCount); + resultMap.put("compCounts", compCounts); + + List departAbilityEvaluations = iDepartAbilityEvaluationService.list(); + resultMap.put("departAbilityEvaluation", departAbilityEvaluations); + + List years = DateUtils.getLast4Year(); + List annualList = iAnnualService.list(new LambdaQueryWrapper().in(Annual::getAnnualName, years).orderByAsc(Annual::getAnnualName)); + List last5YearDataVos = new LinkedList<>(); + Optional.ofNullable(annualList).orElse(new LinkedList<>()).stream().forEach(annual -> { + Last5YearDataVo last5YearDataVo = new Last5YearDataVo(); + last5YearDataVo.setYear(annual.getAnnualName()); + AtomicReference personCount4Comp = new AtomicReference<>(BigDecimal.ZERO); + + List annualCompList = iAnnualCompService.list(new LambdaQueryWrapper().eq(AnnualComp::getAnnualid, annual.getId())); + //比赛数 + last5YearDataVo.setCompCount(annualCompList.size()); + if (!ObjectUtils.isEmpty(annualCompList)) { + annualCompList.stream().forEach(ac -> { + AnnualCompPoint annualCompPoint = iAnnualCompPointService.getOne(new LambdaQueryWrapper().eq(AnnualCompPoint::getAnnualCompId, ac.getId())); + if (!ObjectUtils.isEmpty(annualCompPoint)) { + long personCount4CompTemp = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper(). + 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 bigScreen4Student(PersonalAbilityEvaluation person) { + + Assert.notNull(person.getWorkOn(), "学号不能为空"); + + Map resultMap = new LinkedHashMap<>(); + List personalAbilityEvaluationList = iPersonalAbilityEvaluationCollectService.list(new LambdaQueryWrapper() + .eq(PersonalAbilityEvaluationCollect::getWorkOn, person.getWorkOn())); + resultMap.put("studentAbilityEvaluation", personalAbilityEvaluationList); + + Map studentInfoMap = new LinkedHashMap<>(); + PersonalCompTotalScore compTotalScore = iPersonalCompTotalScoreService.getOne(new LambdaQueryWrapper() + .eq(PersonalCompTotalScore::getWorkOn, person.getWorkOn())); + studentInfoMap.put("score", compTotalScore); + + + SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper().eq(SysUser::getWorkNo, person.getWorkOn())); + List awardPersions = iAwardPersionService.list(new LambdaQueryWrapper() + .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 studentEnrollCodeList = iTeamManagementService.list(new LambdaQueryWrapper() + .eq(TeamManagement::getUserId, sysUser.getId())); + List enrollCodeList = studentEnrollCodeList.stream().map(en -> en.getEnrollCode()).collect(Collectors.toList()); + List registrationList = iAnnualCompetitionProjectRegistrationService.list(new LambdaQueryWrapper() + .in(AnnualCompetitionProjectRegistration::getEnrollCode, enrollCodeList)); + + List 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() + .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 getCompList() { + List annualCompPointList = iAnnualCompPointService.list(new LambdaQueryWrapper() + .eq(AnnualCompPoint::getRequireApply, "Y")); + List 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() + .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; + } +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/CompVo.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/CompVo.java new file mode 100644 index 00000000..73a0f2a6 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/CompVo.java @@ -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; +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/Last5YearDataVo.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/Last5YearDataVo.java new file mode 100644 index 00000000..7ab47ca0 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/vo/Last5YearDataVo.java @@ -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; +}