|
@@ -0,0 +1,290 @@
|
|
|
+package com.xjrsoft.module.databoard.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
+import com.xjrsoft.common.enums.StudyStatusEnum;
|
|
|
+import com.xjrsoft.common.enums.WorkflowIsRecycleType;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.courseTable.entity.CourseTable;
|
|
|
+import com.xjrsoft.module.courseTable.service.ICourseTableService;
|
|
|
+import com.xjrsoft.module.databoard.dto.StatisticsDto;
|
|
|
+import com.xjrsoft.module.databoard.vo.CourseStatisticsVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.HealthStatisticsVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.MeetingStatisticsVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.PersonStatisticsVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.ProcessStatisticsVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.VisitorStatisticsVo;
|
|
|
+import com.xjrsoft.module.outint.entity.VisitorOutInRecord;
|
|
|
+import com.xjrsoft.module.outint.service.IVisitorOutInRecordService;
|
|
|
+import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentService;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
|
|
|
+import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
+import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
|
+import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
+import com.xjrsoft.module.teacher.service.ITeacherbaseManagerService;
|
|
|
+import com.xjrsoft.module.teacher.vo.XjrUserPageVo;
|
|
|
+import com.xjrsoft.module.workflow.constant.WorkflowConstant;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.camunda.bpm.engine.HistoryService;
|
|
|
+import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 数据看板代码
|
|
|
+* @Date: 2024年8月2日
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/databoard" + "/databoard")
|
|
|
+@Api(value = "/dataexpert" + "/databoard",tags = "数据看板代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class DataboardController {
|
|
|
+
|
|
|
+ private final HistoryService historyService;
|
|
|
+ private final ICourseTableService courseTableService;
|
|
|
+ private final IVisitorOutInRecordService visitorService;
|
|
|
+ private final IBaseStudentService studentService;
|
|
|
+ private final ITeacherbaseManagerService teacherService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/process-statistics")
|
|
|
+ @ApiOperation(value="流程统计")
|
|
|
+ @SaCheckPermission("databoard:detail")
|
|
|
+ public RT<ProcessStatisticsVo> processStatistics(@Valid StatisticsDto dto){
|
|
|
+ HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
|
|
|
+ .variableValueEquals(WorkflowConstant.PROCESS_ISRECYCLE_FLAG_KEY, WorkflowIsRecycleType.NO.getCode());
|
|
|
+ if(dto.getUserId() != null){
|
|
|
+ historicProcessInstanceQuery.variableValueEquals(WorkflowConstant.PROCESS_START_USER_ID_KEY, dto.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ ProcessStatisticsVo result = new ProcessStatisticsVo();
|
|
|
+ result.setAllCount(historicProcessInstanceQuery.list().size());
|
|
|
+ result.setCompleteCount(historicProcessInstanceQuery.finished().list().size());
|
|
|
+ result.setUncompleteCount(historicProcessInstanceQuery.unfinished().list().size());
|
|
|
+
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/meeting-statistics")
|
|
|
+ @ApiOperation(value="会议统计")
|
|
|
+ @SaCheckPermission("databoard:detail")
|
|
|
+ public RT<MeetingStatisticsVo> meetingStatistics(@Valid StatisticsDto dto){
|
|
|
+ String sql = "SELECT id, (SELECT COUNT(*) FROM xjr_user WHERE FIND_IN_SET(id, meeting_apply_participants)) AS person_count FROM wf_meeting_apply";
|
|
|
+ List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+ MeetingStatisticsVo result = new MeetingStatisticsVo();
|
|
|
+ result.setAllCount(list.size());
|
|
|
+ int personCount = 0;
|
|
|
+ for (Map<String, Object> objectMap : list) {
|
|
|
+ personCount += (Long)objectMap.get("person_count");
|
|
|
+ }
|
|
|
+ result.setPersonCount(personCount);
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/course-statistics")
|
|
|
+ @ApiOperation(value="课表统计")
|
|
|
+ @SaCheckPermission("databoard:detail")
|
|
|
+ public RT<CourseStatisticsVo> courseStatistics(@Valid StatisticsDto dto){
|
|
|
+ List<CourseTable> list = courseTableService.list(
|
|
|
+ new QueryWrapper<CourseTable>().lambda()
|
|
|
+ .eq(CourseTable::getScheduleDate, new Date())
|
|
|
+ );
|
|
|
+ CourseStatisticsVo result = new CourseStatisticsVo();
|
|
|
+ result.setAllCount(list.size());
|
|
|
+ int teacherCount = 0, noTeacherCount = 0;
|
|
|
+ for (CourseTable courseTable : list) {
|
|
|
+ if(courseTable.getTimePeriod() != null && courseTable.getTeacherId() != 0){
|
|
|
+ teacherCount ++;
|
|
|
+ }else{
|
|
|
+ noTeacherCount ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.setTeacherCount(teacherCount);
|
|
|
+ result.setNoTeacherCount(noTeacherCount);
|
|
|
+
|
|
|
+ String sql = "SELECT * FROM wf_course_adjust WHERE STATUS = 1 AND exchange_date = NOW() and adjust_type = 'course_adjust'";
|
|
|
+ long adjustCount = SqlRunnerAdapter.db().selectCount(sql);
|
|
|
+ result.setAdjustCount(Integer.parseInt(adjustCount + ""));
|
|
|
+
|
|
|
+ sql = "SELECT * FROM wf_course_adjust WHERE STATUS = 1 AND exchange_date = NOW() and adjust_type = 'course_exchange'";
|
|
|
+ long exchangeCount = SqlRunnerAdapter.db().selectCount(sql);
|
|
|
+ result.setReplaceCount(Integer.parseInt(exchangeCount + ""));
|
|
|
+
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/visitor-statistics")
|
|
|
+ @ApiOperation(value="访客统计")
|
|
|
+ @SaCheckPermission("databoard:detail")
|
|
|
+ public RT<VisitorStatisticsVo> visitorStatistics(@Valid StatisticsDto dto){
|
|
|
+ List<VisitorOutInRecord> list = visitorService.list(
|
|
|
+ new QueryWrapper<VisitorOutInRecord>().lambda()
|
|
|
+ .eq(VisitorOutInRecord::getDeleteMark, DeleteMark.DELETED.getCode())
|
|
|
+ );
|
|
|
+ VisitorStatisticsVo result = new VisitorStatisticsVo();
|
|
|
+ result.setAllCount(list.size());
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ int todayCount = 0;
|
|
|
+ for (VisitorOutInRecord record : list) {
|
|
|
+ if(today.equals(record.getRecordTime().toLocalDate())){
|
|
|
+ todayCount ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.setTodayCount(todayCount);
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/person-statistics")
|
|
|
+ @ApiOperation(value="全校师生数据概览")
|
|
|
+ @SaCheckPermission("databoard:detail")
|
|
|
+ public RT<PersonStatisticsVo> personStatistics(@Valid StatisticsDto dto){
|
|
|
+
|
|
|
+ List<BaseStudentUserPageVo> studentList = studentService.getStudentList(new BaseStudentUserPageDto());
|
|
|
+
|
|
|
+ PersonStatisticsVo result = new PersonStatisticsVo();
|
|
|
+ result.setStudentCount(studentList.size());
|
|
|
+
|
|
|
+ Set<String> studentMaleSet = studentList.stream()
|
|
|
+ .filter(x -> (x.getGenderCn() != null && x.getGenderCn().equals(GenderDictionaryEnum.MALE.getCode())))
|
|
|
+ .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setStudentMaleCount(studentMaleSet.size());
|
|
|
+
|
|
|
+ Set<String> studentFemaleSet = studentList.stream()
|
|
|
+ .filter(x -> (x.getGenderCn() != null && x.getGenderCn().equals(GenderDictionaryEnum.FEMALE.getCode())))
|
|
|
+ .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setStudentFemaleCount(studentFemaleSet.size());
|
|
|
+
|
|
|
+ Set<String> studentStayMaleSet = studentList.stream()
|
|
|
+ .filter(x -> (
|
|
|
+ x.getGenderCn() != null
|
|
|
+ && x.getGenderCn().equals(GenderDictionaryEnum.MALE.getCode())
|
|
|
+ && x.getStduyStatusCn() != null
|
|
|
+ && x.getStduyStatusCn().equals(StudyStatusEnum.InResidence.getCode())
|
|
|
+ ))
|
|
|
+ .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setStudentStayMaleCount(studentStayMaleSet.size());
|
|
|
+
|
|
|
+ Set<String> studentNotStayMaleSet = studentList.stream()
|
|
|
+ .filter(x -> (
|
|
|
+ x.getGenderCn() != null
|
|
|
+ && x.getGenderCn().equals(GenderDictionaryEnum.MALE.getCode())
|
|
|
+ && x.getStduyStatusCn() != null
|
|
|
+ && x.getStduyStatusCn().equals(StudyStatusEnum.AttendDaySchool.getCode())
|
|
|
+ ))
|
|
|
+ .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setStudentNotStayMaleCount(studentNotStayMaleSet.size());
|
|
|
+
|
|
|
+ Set<String> studentStayFemaleSet = studentList.stream()
|
|
|
+ .filter(x -> (
|
|
|
+ x.getGenderCn() != null
|
|
|
+ && x.getGenderCn().equals(GenderDictionaryEnum.FEMALE.getCode())
|
|
|
+ && x.getStduyStatusCn() != null
|
|
|
+ && x.getStduyStatusCn().equals(StudyStatusEnum.InResidence.getCode())
|
|
|
+ ))
|
|
|
+ .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setStudentStayFemaleCount(studentStayFemaleSet.size());
|
|
|
+
|
|
|
+ Set<String> studentNotStayFemaleSet = studentList.stream()
|
|
|
+ .filter(x -> (
|
|
|
+ x.getGenderCn() != null
|
|
|
+ && x.getGenderCn().equals(GenderDictionaryEnum.FEMALE.getCode())
|
|
|
+ && x.getStduyStatusCn() != null
|
|
|
+ && x.getStduyStatusCn().equals(StudyStatusEnum.AttendDaySchool.getCode())
|
|
|
+ ))
|
|
|
+ .map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setStudentNotStayFemaleCount(studentNotStayFemaleSet.size());
|
|
|
+
|
|
|
+ MPJLambdaWrapper<XjrUser> queryWrapper = MPJWrappers.<XjrUser>lambdaJoin()
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .orderByDesc(XjrUser::getId)
|
|
|
+ .select(XjrUser::getId)
|
|
|
+ .select(XjrUser.class,x -> VoToColumnUtil.fieldsToColumns(XjrUserPageVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(BaseTeacher.class,BaseTeacher::getUserId,XjrUser::getId)
|
|
|
+ .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode,BaseTeacher::getJobState, ext->ext.selectAs(DictionaryDetail::getName, XjrUserPageVo::getJobState))
|
|
|
+ .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode,XjrUser::getCredentialType,ext->ext.selectAs(DictionaryDetail::getName, XjrUserPageVo::getCredentialType))
|
|
|
+ .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode,BaseTeacher::getEmployWay,ext->ext.selectAs(DictionaryDetail::getName, XjrUserPageVo::getEmployWay))
|
|
|
+
|
|
|
+ .selectAsClass(BaseTeacher.class, XjrUserPageVo.class);
|
|
|
+
|
|
|
+ List<XjrUserPageVo> teacherList = teacherService.selectJoinList(XjrUserPageVo.class, queryWrapper);
|
|
|
+ result.setTeacherCount(teacherList.size());
|
|
|
+
|
|
|
+ Set<String> teacherMaleSet = teacherList.stream()
|
|
|
+ .filter(x -> (x.getGender() != null && x.getGender().equals(GenderDictionaryEnum.MALE.getCode())))
|
|
|
+ .map(XjrUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setTeacherMaleCount(teacherMaleSet.size());
|
|
|
+
|
|
|
+ Set<String> teacherFemaleSet = teacherList.stream()
|
|
|
+ .filter(x -> (x.getGender() != null && x.getGender().equals(GenderDictionaryEnum.FEMALE.getCode())))
|
|
|
+ .map(XjrUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setTeacherFemaleCount(teacherFemaleSet.size());
|
|
|
+
|
|
|
+ Set<String> teacherSet1 = teacherList.stream()
|
|
|
+ .filter(x -> (x.getEmployWay() != null && x.getEmployWay().equals("FB1601")))
|
|
|
+ .map(XjrUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setTeacherCount1(teacherSet1.size());
|
|
|
+ Set<String> teacherSet2 = teacherList.stream()
|
|
|
+ .filter(x -> (x.getEmployWay() != null && x.getEmployWay().equals("FB1602")))
|
|
|
+ .map(XjrUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setTeacherCount2(teacherSet2.size());
|
|
|
+ Set<String> teacherSet3 = teacherList.stream()
|
|
|
+ .filter(x -> (x.getEmployWay() != null && x.getEmployWay().equals("FB1606")))
|
|
|
+ .map(XjrUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setTeacherCount3(teacherSet3.size());
|
|
|
+ Set<String> teacherSet4 = teacherList.stream()
|
|
|
+ .filter(x -> (x.getEmployWay() != null && x.getEmployWay().equals("FB1609")))
|
|
|
+ .map(XjrUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setTeacherCount4(teacherSet4.size());
|
|
|
+ Set<String> teacherSet5 = teacherList.stream()
|
|
|
+ .filter(x -> (x.getEmployWay() != null && x.getEmployWay().equals("FB1608")))
|
|
|
+ .map(XjrUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ result.setTeacherCount5(teacherSet5.size());
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/health-statistics")
|
|
|
+ @ApiOperation(value="学生健康统计")
|
|
|
+ @SaCheckPermission("databoard:detail")
|
|
|
+ public RT<HealthStatisticsVo> healthStatistics(@Valid StatisticsDto dto){
|
|
|
+ String sql = "SELECT gender,COUNT(*) AS a_count FROM student_infection WHERE status = 1 GROUP BY gender";
|
|
|
+ List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+ HealthStatisticsVo result = new HealthStatisticsVo();
|
|
|
+ for (Map<String, Object> objectMap : list) {
|
|
|
+ if(GenderDictionaryEnum.FEMALE.getCode().equals(objectMap.get("gender").toString())){
|
|
|
+ result.setInfectionFemaleCount(Integer.parseInt(objectMap.get("a_count").toString()));
|
|
|
+ }if(GenderDictionaryEnum.MALE.getCode().equals(objectMap.get("gender").toString())){
|
|
|
+ result.setInfectionMaleCount(Integer.parseInt(objectMap.get("a_count").toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sql = "SELECT gender,COUNT(*) AS a_count FROM student_psychological WHERE status = 1 GROUP BY gender";
|
|
|
+ list = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+ for (Map<String, Object> objectMap : list) {
|
|
|
+ if(GenderDictionaryEnum.FEMALE.getCode().equals(objectMap.get("gender").toString())){
|
|
|
+ result.setInfectionFemaleCount(Integer.parseInt(objectMap.get("a_count").toString()));
|
|
|
+ }if(GenderDictionaryEnum.MALE.getCode().equals(objectMap.get("gender").toString())){
|
|
|
+ result.setPsychologicalMaleCount(Integer.parseInt(objectMap.get("a_count").toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|