|
@@ -0,0 +1,109 @@
|
|
|
+package com.xjrsoft.module.databoard.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.xjrsoft.common.enums.WorkflowIsRecycleType;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
+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.MeetingStatisticsVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.ProcessStatisticsVo;
|
|
|
+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.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+* @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;
|
|
|
+
|
|
|
+ @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);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|