dzx hai 6 meses
pai
achega
4707f224e4

+ 158 - 3
src/main/java/com/xjrsoft/module/databoard/controller/DatadetailController.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.databoard.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.util.ObjectUtil;
+import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.GenderDictionaryEnum;
 import com.xjrsoft.common.model.result.RT;
@@ -12,8 +13,14 @@ 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.ItemCountVo;
 import com.xjrsoft.module.databoard.vo.ProcessStatisticsDetailVo;
+import com.xjrsoft.module.databoard.vo.TeacherStatisticsDetailVo;
 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;
@@ -30,7 +37,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.Duration;
+import java.time.LocalDate;
+import java.time.Period;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.HashSet;
@@ -52,10 +63,10 @@ public class DatadetailController {
 
     private final HistoryService historyService;
     private final IWorkflowExtraService extraService;
-
+    private final ITeacherbaseManagerService teacherService;
     @GetMapping(value = "/process-statistics")
     @ApiOperation(value="流程统计详情")
-    @SaCheckPermission("databoard:detail")
+    @SaCheckPermission("datadetail:detail")
     public RT<ProcessStatisticsDetailVo> processStatistics(@Valid StatisticsDetailDto dto){
         HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery();
         if(dto.getUserId() != null){
@@ -185,7 +196,7 @@ public class DatadetailController {
 
     @GetMapping(value = "/health-statistics")
     @ApiOperation(value="学生健康统计")
-    @SaCheckPermission("databoard:detail")
+    @SaCheckPermission("datadetail:detail")
     public RT<HealthStatisticsDetailVo> healthStatistics(@Valid StatisticsDetailDto 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);
@@ -272,4 +283,148 @@ public class DatadetailController {
         return RT.ok(result);
     }
 
+
+    @GetMapping(value = "/person-statistics")
+    @ApiOperation(value="教职工详情数据统计")
+    @SaCheckPermission("datadetail:detail")
+    public RT<TeacherStatisticsDetailVo> teahcerStatistics(@Valid StatisticsDetailDto dto) throws ParseException {
+        String sql = "SELECT IFNULL(t2.name,'未填写') AS item ,COUNT(*) AS count FROM base_teacher_education t1" +
+                " LEFT JOIN xjr_dictionary_detail t2 ON t1.education  = t2.code" +
+                " WHERE t1.delete_mark = 0 GROUP BY t2.name";
+        List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
+        TeacherStatisticsDetailVo result = new TeacherStatisticsDetailVo();
+        List<ItemCountVo> educationList = new ArrayList<>();
+        for (Map<String, Object> objectMap : list) {
+            educationList.add(
+                    new ItemCountVo(){{
+                        setItem(objectMap.get("item").toString());
+                        setCount(Integer.parseInt(objectMap.get("count").toString()));
+                    }}
+            );
+        }
+        result.setEducationList(educationList);
+
+        sql = "SELECT IFNULL(t3.name,'未填写') AS item ,COUNT(*) AS COUNT FROM xjr_user t1" +
+            " INNER JOIN base_teacher t2 ON t1.id = t2.user_id" +
+            " LEFT JOIN xjr_dictionary_detail t3 ON t1.gender  = t3.code AND t3.item_id = 2023000000000000004" +
+            " WHERE t1.delete_mark = 0 GROUP BY t3.name";
+        list = SqlRunnerAdapter.db().selectList(sql);
+        List<ItemCountVo> genderList = new ArrayList<>();
+        for (Map<String, Object> objectMap : list) {
+            genderList.add(
+                    new ItemCountVo(){{
+                        setItem(objectMap.get("item").toString());
+                        setCount(Integer.parseInt(objectMap.get("count").toString()));
+                    }}
+            );
+        }
+        result.setGenderList(genderList);
+
+        sql = "SELECT IFNULL(t3.name,'未填写') AS item ,COUNT(*) AS COUNT FROM xjr_user t1" +
+            " INNER JOIN base_teacher t2 ON t1.id = t2.user_id" +
+            " LEFT JOIN xjr_dictionary_detail t3 ON t2.employ_way  = t3.code AND t3.item_id = 2023000000000000016" +
+            " WHERE t1.delete_mark = 0 GROUP BY t3.name";
+        list = SqlRunnerAdapter.db().selectList(sql);
+        List<ItemCountVo> employList = new ArrayList<>();
+        for (Map<String, Object> objectMap : list) {
+            genderList.add(
+                    new ItemCountVo(){{
+                        setItem(objectMap.get("item").toString());
+                        setCount(Integer.parseInt(objectMap.get("count").toString()));
+                    }}
+            );
+        }
+        result.setEmployList(employList);
+
+        sql = "SELECT IFNULL(t4.name,'未填写') AS item ,COUNT(*) AS COUNT FROM xjr_user t1" +
+            " INNER JOIN base_teacher t2 ON t1.id = t2.user_id" +
+            " LEFT JOIN xjr_user_dept_relation t3 ON t1.id  = t3.user_id" +
+            " LEFT JOIN xjr_department t4 ON t3.dept_id = t4.id" +
+            " WHERE t1.delete_mark = 0 AND t4.is_major = 1 GROUP BY t4.name";
+
+        list = SqlRunnerAdapter.db().selectList(sql);
+        List<ItemCountVo> deptList = new ArrayList<>();
+        for (Map<String, Object> objectMap : list) {
+            genderList.add(
+                    new ItemCountVo(){{
+                        setItem(objectMap.get("item").toString());
+                        setCount(Integer.parseInt(objectMap.get("count").toString()));
+                    }}
+            );
+        }
+        result.setDeptList(deptList);
+
+        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);
+        List<String> idCardList = teacherList.stream().map(XjrUserPageVo::getCredentialNumber).collect(Collectors.toList());
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        LocalDate currentDate = LocalDate.now();
+        int age20 = 0;
+        int age30 = 0;
+        int age40 = 0;
+        int age50 = 0;
+        int age60 = 0;
+        for (String idCard : idCardList) {
+            String birthdayStr = idCard.substring(6, 14);
+            java.util.Date date = sdf.parse(birthdayStr);
+
+            // 将Date对象转换为LocalDate对象
+            LocalDate birthDate = date.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDate();
+            Period ageObj = Period.between(birthDate, currentDate);
+            int age = ageObj.getYears();
+            if(age >= 20 && age <= 29){
+                age20 ++;
+            }else if(age >= 30 && age <= 39){
+                age30 ++;
+            }else if(age >= 40 && age <= 49){
+                age40 ++;
+            }else if(age >= 50 && age <= 59){
+                age50 ++;
+            }else if(age >= 60){
+                age60 ++;
+            }
+        }
+
+        List<ItemCountVo> ageList = new ArrayList<>();
+        ItemCountVo itemCountVo = new ItemCountVo();
+        itemCountVo.setItem("20-29岁");
+        itemCountVo.setCount(age20);
+        ageList.add(itemCountVo);
+
+        itemCountVo = new ItemCountVo();
+        itemCountVo.setItem("30-39岁");
+        itemCountVo.setCount(age30);
+        ageList.add(itemCountVo);
+
+        itemCountVo = new ItemCountVo();
+        itemCountVo.setItem("40-49岁");
+        itemCountVo.setCount(age40);
+        ageList.add(itemCountVo);
+
+        itemCountVo = new ItemCountVo();
+        itemCountVo.setItem("50-59岁");
+        itemCountVo.setCount(age50);
+        ageList.add(itemCountVo);
+
+        itemCountVo = new ItemCountVo();
+        itemCountVo.setItem("60岁以上");
+        itemCountVo.setCount(age60);
+        ageList.add(itemCountVo);
+
+        result.setAgeList(ageList);
+
+        return RT.ok(result);
+    }
+
 }

+ 33 - 0
src/main/java/com/xjrsoft/module/databoard/vo/TeacherStatisticsDetailVo.java

@@ -0,0 +1,33 @@
+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 TeacherStatisticsDetailVo {
+
+
+    @ApiModelProperty("学历占比数据")
+    private List<ItemCountVo> educationList;
+
+    @ApiModelProperty("性别占比数据")
+    private List<ItemCountVo> genderList;
+
+    @ApiModelProperty("聘用占比数据")
+    private List<ItemCountVo> employList;
+
+    @ApiModelProperty("年龄占比数据")
+    private List<ItemCountVo> ageList;
+
+    @ApiModelProperty("部门统计数据")
+    private List<ItemCountVo> deptList;
+
+}

+ 3 - 0
src/main/java/com/xjrsoft/module/student/vo/BaseStudentDevelopmentVo.java

@@ -79,6 +79,9 @@ public class BaseStudentDevelopmentVo {
     */
     @ApiModelProperty("就业单位规模(xjr_dictionary_item[company_scale])")
     private String companyScaleCn;
+
+    @ApiModelProperty("就业单位规模(xjr_dictionary_item[company_scale])")
+    private String companyScale;
     /**
     * 是否对口(1:是 0:否)
     */

+ 1 - 1
src/main/resources/mapper/student/BaseStudentDevelopmentMapper.xml

@@ -8,7 +8,7 @@
                t1.is_company_coop,t1.work_company,t7.name AS company_industry,t8.name AS company_nature,t2.name AS company_scale_cn,t1.is_matching,
                t1.money,t1.work_date,t1.work_city,t3.name AS culture_type_cn,t4.name AS ascending_channels_cn,
                t1.school,t1.admission_major,t1.score,t5.name AS ascending_arrangement_cn,t6.name AS unemployed_type_cn,t1.remark,t1.enroll_type,
-               t1.culture_type,t1.ascending_channels,t1.unemployed_type
+               t1.culture_type,t1.ascending_channels,t1.unemployed_type,t1.company_scale
         FROM base_student_development t1
                  LEFT JOIN xjr_dictionary_detail t2 ON t1.company_scale = t2.code
                  LEFT JOIN xjr_dictionary_detail t3 ON t1.culture_type = t3.code