|
|
@@ -1,6 +1,7 @@
|
|
|
package com.xjrsoft.module.databoard.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
@@ -23,11 +24,13 @@ import com.xjrsoft.module.databoard.vo.DistributionVo;
|
|
|
import com.xjrsoft.module.databoard.vo.DurationVo;
|
|
|
import com.xjrsoft.module.databoard.vo.HealthItemCountVo;
|
|
|
import com.xjrsoft.module.databoard.vo.HealthStatisticsDetailVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.ItemCount2Vo;
|
|
|
import com.xjrsoft.module.databoard.vo.ItemCountAmountVo;
|
|
|
import com.xjrsoft.module.databoard.vo.ItemCountRatioVo;
|
|
|
import com.xjrsoft.module.databoard.vo.ItemCountVo;
|
|
|
import com.xjrsoft.module.databoard.vo.ItemDoubleVo;
|
|
|
import com.xjrsoft.module.databoard.vo.ProcessStatisticsDetailVo;
|
|
|
+import com.xjrsoft.module.databoard.vo.RoomStatisticsDetailVo;
|
|
|
import com.xjrsoft.module.databoard.vo.StudnetStatisticsDetailVo;
|
|
|
import com.xjrsoft.module.databoard.vo.SubscriptionStatisticsDetailVo;
|
|
|
import com.xjrsoft.module.databoard.vo.TeacherChangeStatisticsDetailVo;
|
|
|
@@ -52,7 +55,6 @@ import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.camunda.bpm.engine.history.HistoricProcessInstance;
|
|
|
-import org.camunda.bpm.engine.history.JobState;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -889,4 +891,58 @@ public class DatadetailController {
|
|
|
return RT.ok(result);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/room-statistics")
|
|
|
+ @ApiOperation(value = "寝室统计")
|
|
|
+ @SaCheckPermission("databoard:detail")
|
|
|
+ @XjrLog(value = "寝室统计", saveResponseData = true)
|
|
|
+ public RT<RoomStatisticsDetailVo> roomStatistics(@Valid StatisticsDetailDto dto) {
|
|
|
+ RoomStatisticsDetailVo result = new RoomStatisticsDetailVo();
|
|
|
+ String sql = "SELECT t2.id, t3.user_id,t4.name AS grade_name, t6.name AS dept_name,t7.gender FROM room t1" +
|
|
|
+ " INNER JOIN room_bed t2 ON t1.id = t2.room_id" +
|
|
|
+ " LEFT JOIN base_student_school_roll t3 ON t2.student_user_id = t3.user_id" +
|
|
|
+ " LEFT JOIN base_grade t4 ON t3.grade_id = t4.id AND t4.status = 1" +
|
|
|
+ " LEFT JOIN base_class t5 ON t3.class_id = t5.id" +
|
|
|
+ " LEFT JOIN xjr_department t6 ON t5.org_id = t6.id" +
|
|
|
+ " LEFT JOIN xjr_user t7 ON t3.user_id = t7.id" +
|
|
|
+ " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0";
|
|
|
+ List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+
|
|
|
+ Integer allCount = list.size();
|
|
|
+ long emptyCount = list.stream().filter(x -> ObjectUtil.isNull(x.get("user_id"))).count();
|
|
|
+ BigDecimal emptyRatio = BigDecimal.valueOf(emptyCount).divide(BigDecimal.valueOf(allCount), 4, RoundingMode.HALF_UP);
|
|
|
+ result.setEmptyRatio(emptyRatio.doubleValue() + "");
|
|
|
+
|
|
|
+ long notEmptyCount = list.stream().filter(x -> ObjectUtil.isNotNull(x.get("user_id"))).count();
|
|
|
+ BigDecimal notEmptyRatio = BigDecimal.valueOf(notEmptyCount).divide(BigDecimal.valueOf(allCount), 4, RoundingMode.HALF_UP);
|
|
|
+ result.setNotEmptyRatio(notEmptyRatio.doubleValue() + "");
|
|
|
+
|
|
|
+ Map<String, List<Map<String, Object>>> gradeMap = list.stream().filter(x -> ObjectUtil.isNotNull(x.get("user_id"))).collect(Collectors.groupingBy(x -> x.get("grade_name").toString()));
|
|
|
+ List<ItemCount2Vo> gradeList = new ArrayList<>();
|
|
|
+ for (String gradeName : gradeMap.keySet()) {
|
|
|
+ List<Map<String, Object>> gradeDataList = gradeMap.get(gradeName);
|
|
|
+ Map<String, Long> genderMap = gradeDataList.stream().collect(Collectors.groupingBy(x -> x.get("gender").toString(), Collectors.counting()));
|
|
|
+ ItemCount2Vo gradeVo = new ItemCount2Vo();
|
|
|
+ gradeVo.setItem(gradeName);
|
|
|
+ gradeVo.setCount(genderMap.get(GenderDictionaryEnum.MALE.getCode()).intValue());
|
|
|
+ gradeVo.setCount2(genderMap.get(GenderDictionaryEnum.FEMALE.getCode()).intValue());
|
|
|
+ gradeList.add(gradeVo);
|
|
|
+ }
|
|
|
+ Collections.reverse(gradeList);
|
|
|
+ result.setGradeList(gradeList);
|
|
|
+
|
|
|
+ Map<String, List<Map<String, Object>>> deptMap = list.stream().filter(x -> ObjectUtil.isNotNull(x.get("user_id"))).collect(Collectors.groupingBy(x -> x.get("dept_name").toString()));
|
|
|
+ List<ItemCount2Vo> deptList = new ArrayList<>();
|
|
|
+ for (String deptName : deptMap.keySet()) {
|
|
|
+ List<Map<String, Object>> deptDataList = gradeMap.get(deptName);
|
|
|
+ Map<String, Long> genderMap = deptDataList.stream().collect(Collectors.groupingBy(x -> x.get("gender").toString(), Collectors.counting()));
|
|
|
+ ItemCount2Vo deptVo = new ItemCount2Vo();
|
|
|
+ deptVo.setItem(deptName);
|
|
|
+ deptVo.setCount(genderMap.get(GenderDictionaryEnum.MALE.getCode()).intValue());
|
|
|
+ deptVo.setCount2(genderMap.get(GenderDictionaryEnum.FEMALE.getCode()).intValue());
|
|
|
+ deptList.add(deptVo);
|
|
|
+ }
|
|
|
+ result.setDeptList(deptList);
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
}
|