Browse Source

流程统计接口

dzx 6 months ago
parent
commit
36598de3e9

+ 53 - 8
src/main/java/com/xjrsoft/module/databoard/controller/DataboardController.java

@@ -7,7 +7,6 @@ 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;
@@ -31,10 +30,14 @@ 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 com.xjrsoft.module.workflow.entity.WorkflowExtra;
+import com.xjrsoft.module.workflow.entity.WorkflowSchema;
+import com.xjrsoft.module.workflow.service.IWorkflowExtraService;
 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.HistoricProcessInstance;
 import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -42,6 +45,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
 import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -55,7 +60,7 @@ import java.util.stream.Collectors;
 */
 @RestController
 @RequestMapping("/databoard" + "/databoard")
-@Api(value = "/dataexpert"  + "/databoard",tags = "数据看板代码")
+@Api(value = "/databoard"  + "/databoard",tags = "数据看板代码")
 @AllArgsConstructor
 public class DataboardController {
 
@@ -64,21 +69,61 @@ public class DataboardController {
     private final IVisitorOutInRecordService visitorService;
     private final IBaseStudentService studentService;
     private final ITeacherbaseManagerService teacherService;
+    private final IWorkflowExtraService extraService;
 
     @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());
+        HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery();
         if(dto.getUserId() != null){
-            historicProcessInstanceQuery.variableValueEquals(WorkflowConstant.PROCESS_START_USER_ID_KEY, dto.getUserId());
+            instanceQuery.variableValueEquals(WorkflowConstant.PROCESS_START_USER_ID_KEY, dto.getUserId());
         }
 
+        List<WorkflowExtra> workflowExtras = extraService.list(
+                new MPJLambdaWrapper<WorkflowExtra>()
+                        .select(WorkflowExtra.class, x -> VoToColumnUtil.fieldsToColumns(WorkflowExtra.class).contains(x.getProperty()))
+                        .leftJoin(WorkflowSchema.class, WorkflowSchema::getId, WorkflowExtra::getSchemaId)
+                        .leftJoin(DictionaryDetail.class, DictionaryDetail::getId, WorkflowSchema::getCategory)
+        );
+
+
         ProcessStatisticsVo result = new ProcessStatisticsVo();
-        result.setAllCount(historicProcessInstanceQuery.list().size());
-        result.setCompleteCount(historicProcessInstanceQuery.finished().list().size());
-        result.setUncompleteCount(historicProcessInstanceQuery.unfinished().list().size());
+        List<HistoricProcessInstance> list = instanceQuery.list();
+        List<WorkflowExtra> allCountList = new ArrayList<>();
+        for (HistoricProcessInstance historicProcessInstance : list) {
+            workflowExtras.stream()
+                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
+                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
+                    .ifPresent(e -> {
+                        allCountList.add(e);
+                    });
+        }
+        result.setAllCount(Long.parseLong(allCountList.size() + ""));
+
+        List<HistoricProcessInstance> finished = historyService.createHistoricProcessInstanceQuery().finished().list();
+        List<WorkflowExtra> completeCountList = new ArrayList<>();
+        for (HistoricProcessInstance historicProcessInstance : finished) {
+            workflowExtras.stream()
+                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
+                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
+                    .ifPresent(e -> {
+                        completeCountList.add(e);
+                    });
+        }
+        result.setCompleteCount(Long.parseLong(completeCountList.size() + ""));
+
+        List<HistoricProcessInstance> unfinished = historyService.createHistoricProcessInstanceQuery().unfinished().list();
+        List<WorkflowExtra> uncompleteCountList = new ArrayList<>();
+        for (HistoricProcessInstance historicProcessInstance : unfinished) {
+            workflowExtras.stream()
+                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
+                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
+                    .ifPresent(e -> {
+                        uncompleteCountList.add(e);
+                    });
+        }
+        result.setUncompleteCount(Long.parseLong(uncompleteCountList.size() + ""));
 
         return RT.ok(result);
     }

+ 367 - 0
src/main/java/com/xjrsoft/module/databoard/controller/DatadetailController.java

@@ -0,0 +1,367 @@
+package com.xjrsoft.module.databoard.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.util.ObjectUtil;
+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.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.StatisticsDetailDto;
+import com.xjrsoft.module.databoard.dto.StatisticsDto;
+import com.xjrsoft.module.databoard.vo.CourseStatisticsVo;
+import com.xjrsoft.module.databoard.vo.DistributionVo;
+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.ProcessStatisticsDetailVo;
+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 com.xjrsoft.module.workflow.entity.WorkflowExtra;
+import com.xjrsoft.module.workflow.entity.WorkflowSchema;
+import com.xjrsoft.module.workflow.service.IWorkflowExtraService;
+import com.xjrsoft.module.workflow.utils.WorkFlowUtil;
+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.HistoricProcessInstance;
+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.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashSet;
+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("/datadetail" + "/datadetail")
+@Api(value = "/datadetail"  + "/datadetail",tags = "数据看板详情代码")
+@AllArgsConstructor
+public class DatadetailController {
+
+    private final HistoryService historyService;
+    private final ICourseTableService courseTableService;
+    private final IVisitorOutInRecordService visitorService;
+    private final IBaseStudentService studentService;
+    private final ITeacherbaseManagerService teacherService;
+    private final IWorkflowExtraService extraService;
+
+    @GetMapping(value = "/process-statistics-detail")
+    @ApiOperation(value="流程统计详情")
+    @SaCheckPermission("databoard:detail")
+    public RT<ProcessStatisticsDetailVo> processStatistics(@Valid StatisticsDetailDto dto){
+        HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery();
+        if(dto.getUserId() != null){
+            instanceQuery.variableValueEquals(WorkflowConstant.PROCESS_START_USER_ID_KEY, dto.getUserId());
+        }
+        if (!ObjectUtil.isNull(dto.getStartDate())) {
+            instanceQuery.startedAfter(WorkFlowUtil.getStartOfDay(dto.getStartDate()));
+        }
+        if (!ObjectUtil.isNull(dto.getEndDate())) {
+            instanceQuery.startedBefore(WorkFlowUtil.getEndOfDay(dto.getEndDate()));
+        }
+
+        List<WorkflowExtra> workflowExtras = extraService.list(
+                new MPJLambdaWrapper<WorkflowExtra>()
+                        .select(WorkflowExtra.class, x -> VoToColumnUtil.fieldsToColumns(WorkflowExtra.class).contains(x.getProperty()))
+                        .leftJoin(WorkflowSchema.class, WorkflowSchema::getId, WorkflowExtra::getSchemaId)
+                        .leftJoin(DictionaryDetail.class, DictionaryDetail::getId, WorkflowSchema::getCategory)
+        );
+
+
+        ProcessStatisticsDetailVo result = new ProcessStatisticsDetailVo();
+        List<HistoricProcessInstance> list = instanceQuery.list();
+        List<WorkflowExtra> allCountList = new ArrayList<>();
+        for (HistoricProcessInstance historicProcessInstance : list) {
+            workflowExtras.stream()
+                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
+                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
+                    .ifPresent(e -> {
+                        allCountList.add(e);
+                    });
+        }
+        result.setAllCount(Long.parseLong(allCountList.size() + ""));
+
+        List<HistoricProcessInstance> finished = historyService.createHistoricProcessInstanceQuery().finished().list();
+        List<WorkflowExtra> completeCountList = new ArrayList<>();
+        for (HistoricProcessInstance historicProcessInstance : finished) {
+            workflowExtras.stream()
+                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
+                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
+                    .ifPresent(e -> {
+                        completeCountList.add(e);
+                    });
+        }
+        result.setCompleteCount(Long.parseLong(completeCountList.size() + ""));
+
+        List<HistoricProcessInstance> unfinished = historyService.createHistoricProcessInstanceQuery().unfinished().list();
+        List<WorkflowExtra> uncompleteCountList = new ArrayList<>();
+        for (HistoricProcessInstance historicProcessInstance : unfinished) {
+            workflowExtras.stream()
+                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
+                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
+                    .ifPresent(e -> {
+                        uncompleteCountList.add(e);
+                    });
+        }
+        result.setUncompleteCount(Long.parseLong(uncompleteCountList.size() + ""));
+
+        Map<String, Long> finishedMap = completeCountList.stream()
+                .collect(Collectors.groupingBy(WorkflowExtra::getSchemaName, Collectors.counting()));
+        Map<String, Long> unfinishedMap = uncompleteCountList.stream()
+                .collect(Collectors.groupingBy(WorkflowExtra::getSchemaName, Collectors.counting()));
+
+        Set<String> itemSet = new HashSet<>();
+        itemSet.addAll(finishedMap.keySet());
+        itemSet.addAll(unfinishedMap.keySet());
+        List<DistributionVo> distributionList = new ArrayList();
+        for (String item : itemSet) {
+            Long uncompleteCount = unfinishedMap.get(item) == null?0L:unfinishedMap.get(item);
+            Long completeCount = finishedMap.get(item) == null?0L:finishedMap.get(item);
+            distributionList.add(
+                    new DistributionVo(){{
+                        setItem(item);
+                        setCompleteCount(completeCount);
+                        setUncompleteCount(uncompleteCount);
+                    }}
+            );
+        }
+        result.setDistributionList(distributionList);
+        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);
+    }
+
+}

+ 27 - 0
src/main/java/com/xjrsoft/module/databoard/dto/StatisticsDetailDto.java

@@ -0,0 +1,27 @@
+package com.xjrsoft.module.databoard.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDate;
+
+
+/**
+* @title: 数据看板-流程统计入参
+* @Author dzx
+* @Date: 2024年8月2日
+* @Version 1.0
+*/
+@Data
+public class StatisticsDetailDto {
+
+    @ApiModelProperty("用户id")
+    private Long userId;
+
+    @ApiModelProperty("查询开始日期")
+    private LocalDate startDate;
+
+    @ApiModelProperty("查询结束日期")
+    private LocalDate endDate;
+
+}

+ 1 - 0
src/main/java/com/xjrsoft/module/databoard/dto/StatisticsDto.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 
+
 /**
 * @title: 数据看板-流程统计入参
 * @Author dzx

+ 29 - 0
src/main/java/com/xjrsoft/module/databoard/vo/DistributionVo.java

@@ -0,0 +1,29 @@
+package com.xjrsoft.module.databoard.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: 数据看板-流程统计出参
+* @Author dzx
+* @Date: 2024年8月2日
+* @Version 1.0
+*/
+@Data
+public class DistributionVo {
+
+    /**
+    * 发起流程总数
+    */
+    @ApiModelProperty("统计项")
+    private String item;
+    /**
+    * 完成总数
+    */
+    @ApiModelProperty("完成数量")
+    private Long completeCount;
+
+    @ApiModelProperty("未完成数量")
+    private Long uncompleteCount;
+
+}

+ 36 - 0
src/main/java/com/xjrsoft/module/databoard/vo/ProcessStatisticsDetailVo.java

@@ -0,0 +1,36 @@
+package com.xjrsoft.module.databoard.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+* @title: 数据看板-流程统计出参
+* @Author dzx
+* @Date: 2024年8月2日
+* @Version 1.0
+*/
+@Data
+public class ProcessStatisticsDetailVo {
+
+    /**
+    * 发起流程总数
+    */
+    @ApiModelProperty("发起流程总数")
+    private Long allCount;
+    /**
+    * 完成总数
+    */
+    @ApiModelProperty("完成总数")
+    private Long completeCount;
+    /**
+    * 未完成总数
+    */
+    @ApiModelProperty("未完成总数")
+    private Long uncompleteCount;
+
+    @ApiModelProperty("未完成总数")
+    List<DistributionVo> distributionList;
+
+}

+ 3 - 3
src/main/java/com/xjrsoft/module/databoard/vo/ProcessStatisticsVo.java

@@ -16,16 +16,16 @@ public class ProcessStatisticsVo {
     * 发起流程总数
     */
     @ApiModelProperty("发起流程总数")
-    private Integer allCount;
+    private Long allCount;
     /**
     * 完成总数
     */
     @ApiModelProperty("完成总数")
-    private Integer completeCount;
+    private Long completeCount;
     /**
     * 未完成总数
     */
     @ApiModelProperty("未完成总数")
-    private Integer uncompleteCount;
+    private Long uncompleteCount;
 
 }

+ 1 - 10
src/main/java/com/xjrsoft/module/workflow/service/impl/WorkflowExecuteServiceImpl.java

@@ -4194,14 +4194,11 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             historicProcessInstanceQuery.unfinished();
         }
 
-        long count = historicProcessInstanceQuery.count();
-//        List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage(Convert.toInt((dto.getLimit() - 1) * dto.getSize()), dto.getSize());
         List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.list();
 
         //获取到所有流程id
         List<String> processIds = historicProcessInstances.stream().map(HistoricProcessInstance::getId).collect(Collectors.toList());
 
-
         List<MonitorPageVo> result = new ArrayList<>(historicProcessInstances.size());
         if (processIds.size() > 0) {
             List<WorkflowExtra> workflowExtras = extraService.list(
@@ -4211,13 +4208,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                             .leftJoin(DictionaryDetail.class, DictionaryDetail::getId, WorkflowSchema::getCategory)
                             .eq(StrUtil.isNotEmpty(dto.getCategory()), DictionaryDetail::getCode, dto.getCategory())
             );
-//            List<WorkflowExtra> workflowExtras = workflowExtraMapper.selectList(
-//                    Wrappers.lambdaQuery(WorkflowExtra.class).in(WorkflowExtra::getProcessId, processIds)
-//            );
-
             for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
-
-
                 //找到当前流程的 任务开始时间 最大值  为当前审批节点
                 workflowExtras.stream()
                         .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
@@ -4256,7 +4247,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
         PageOutput<MonitorPageVo> output = new PageOutput<>();
         output.setCurrentPage(dto.getLimit());
         output.setPageSize(dto.getSize());
-        output.setTotal(Convert.toInt(count));
+        output.setTotal(result.size());
         output.setList(result);
         return output;
     }

+ 25 - 0
src/main/java/com/xjrsoft/module/workflow/utils/WorkFlowUtil.java

@@ -77,7 +77,9 @@ import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
 import org.camunda.bpm.model.xml.instance.ModelElementInstance;
 import org.ssssssss.magicapi.core.service.MagicAPIService;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -1380,6 +1382,17 @@ public class WorkFlowUtil {
         return calendar.getTime();
     }
 
+    /**
+     * 获取一天的开始时间 00:00:00
+     *
+     * @param date 某一天时间
+     * @return 某一天的开始时间, 比如2023-01-01 00:00:00
+     */
+    public static Date getStartOfDay(LocalDate date) {
+        LocalDateTime localDateTime = date.atStartOfDay();
+        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
+    }
+
     /**
      * 获取一天的结束时间 23:59:59
      *
@@ -1395,5 +1408,17 @@ public class WorkFlowUtil {
         calendar.set(Calendar.MILLISECOND, 999);
         return calendar.getTime();
     }
+
+    /**
+     * 获取一天的结束时间 23:59:59
+     *
+     * @param date 某一天时间
+     * @return 某一天的结束时间, 比如2023-01-01 23:59:59
+     */
+    public static Date getEndOfDay(LocalDate date) {
+        LocalDateTime localDateTime = date.plusDays(1).atStartOfDay();
+        LocalDateTime dateTime = localDateTime.plusNanos(-1);
+        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
+    }
 }