Selaa lähdekoodia

添加前线、后线人员统计接口的模拟接口框架

hxl13994548489 2 vuotta sitten
vanhempi
commit
ec57fec3cc

+ 142 - 0
src/main/java/com/ydtech/modules/admin/controller/UserReportConroller.java

@@ -0,0 +1,142 @@
+package com.ydtech.modules.admin.controller;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.SysDept;
+import com.ydtech.modules.admin.model.report.user.HouLinePersonnelReportDto;
+import com.ydtech.modules.admin.model.report.user.QianLineDDPersonnelReportDto;
+import com.ydtech.modules.admin.model.report.user.QianLineDLPersonnelReportDto;
+import com.ydtech.modules.admin.service.SysDeptService;
+import com.ydtech.modules.admin.service.UserReportService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 8:36
+ *  @Description:  控制台用户统计
+ */
+@Api(tags = "控制台用户统计")
+@RequestMapping("/userReport")
+@RestController
+public class UserReportConroller {
+
+    @Autowired
+    private SysDeptService sysDeptService;
+
+    @Autowired
+    private UserReportService userReportService;
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 8:36
+     *  @Description:  查询后线人员的机构
+     */
+    @PostMapping("queryHXDeptTree")
+    @ApiOperation(value = "查询后线人员的机构")
+    public HttpResult<List<SysDept>> queryHXDeptTree() {
+
+        try{
+            List<SysDept> result = sysDeptService.queryHXDeptTree();
+            return HttpResult.ok("查询数据成功", result);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 8:36
+     *  @Description:  查询后线人员的机构
+     */
+    @PostMapping("queryQXDeptTree")
+    @ApiOperation(value = "查询前线人员的机构")
+    public HttpResult<List<SysDept>> queryQXDeptTree() {
+        try{
+            List<SysDept> result = sysDeptService.queryQXDeptTree();
+            return HttpResult.ok("查询数据成功", result);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:04
+     *  @Description:  通过后线人员机构查询统计数据
+     */
+    @GetMapping("queryHXReportData")
+    @ApiOperation(value = "查询后线人员统计数据")
+    public HttpResult<HouLinePersonnelReportDto> queryHXReportData(String deptId) {
+
+        try{
+            HouLinePersonnelReportDto houLinePersonnelReportDto = userReportService.queryHXReportData(deptId);
+            return HttpResult.ok("查询数据成功", houLinePersonnelReportDto);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:04
+     *  @Description:  通过前线类型查询统计数据      团队长
+     */
+    @GetMapping("queryQXTDReportData")
+    @ApiOperation(value = "查询前线人员统计数据")
+    public HttpResult<QianLineDDPersonnelReportDto> queryQXTDReportData(String deptId) {
+
+        try{
+            QianLineDDPersonnelReportDto qianLineDDPersonnelReportDto = userReportService.queryQXTDReportData(deptId);
+            return HttpResult.ok("查询数据成功", qianLineDDPersonnelReportDto);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:04
+     *  @Description:  查询前线人员代理统计数据  代理人
+     */
+    @GetMapping("queryQXDLReportData")
+    @ApiOperation(value = "查询前线人员代理统计数据")
+    public HttpResult<QianLineDLPersonnelReportDto> queryQXDLReportData(String deptId){
+
+        try{
+            QianLineDLPersonnelReportDto qianLineDLPersonnelReportDto = userReportService.queryQXDLReportData(deptId);
+            return HttpResult.ok("查询数据成功", qianLineDLPersonnelReportDto);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:04
+     *  @Description:  查询前线人员渠道统计数据
+     */
+    @GetMapping("queryQXQDReportData")
+    @ApiOperation(value = "查询前线人员渠道统计数据")
+    public HttpResult<List<QianLineDLPersonnelReportDto>> queryQXQDReportData(String deptId) {
+
+        try{
+            List<QianLineDLPersonnelReportDto> list = userReportService.queryQXQDReportData(deptId);
+            return HttpResult.ok("查询数据成功", list);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+}

+ 7 - 0
src/main/java/com/ydtech/modules/admin/dao/SysDeptMapper.java

@@ -25,6 +25,13 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
      *  @Description: 获取前线机构列表
      */
     List<SysDept> queryListByQXDept();
+    /**
+     *  @version 
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:24
+     *  @Description:
+     */ 
+    List<SysDept> queryHXDeptTree();
 }
 
 

+ 30 - 0
src/main/java/com/ydtech/modules/admin/dao/SysUserMapper.java

@@ -8,6 +8,7 @@ import com.ydtech.modules.admin.model.QuUserNum;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.dto.QuTeamNumDto;
 import com.ydtech.modules.admin.model.dto.QuUserNumDto;
+import com.ydtech.modules.admin.model.dto.ReportDto;
 import com.ydtech.modules.admin.model.dto.SysUserDto;
 import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
 import com.ydtech.modules.admin.model.vo.SysUserVO;
@@ -17,6 +18,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -297,6 +299,34 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      *  @Description: 查询该部门的渠道团队长
      */
     String findTDZUserIdByDeptId(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:34
+     *  @Description: 通过机构查询统计数据
+     */
+    HashMap<String, Integer> findSumCountAndAvgAge(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:48
+     *  @Description: 查询某个部门的学历分布
+     */
+    List<ReportDto> findEducationSumCount(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:35
+     *  @Description: 查询团队长的总人数和平均年龄
+     */
+    HashMap<String, Integer> findQXTDSumCountAndAvgAge(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:48
+     *  @Description: 查询代理人总数
+     */
+    HashMap<String, Integer> findQXDLSumCountAndAvgAge(@Param("deptId") String deptId,@Param("type") String type);
 }
 
 

+ 23 - 0
src/main/java/com/ydtech/modules/admin/model/dto/ReportDto.java

@@ -0,0 +1,23 @@
+package com.ydtech.modules.admin.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 9:12
+ *  @Description:  报表数据展示
+ */
+@ApiModel("报表数据")
+@Data
+public class ReportDto {
+
+
+    @ApiModelProperty("名称")
+    private String name;
+
+    @ApiModelProperty("数量")
+    private int count;
+}

+ 72 - 0
src/main/java/com/ydtech/modules/admin/model/report/user/HouLinePersonnelReportDto.java

@@ -0,0 +1,72 @@
+package com.ydtech.modules.admin.model.report.user;
+
+import com.ydtech.modules.admin.model.dto.ReportDto;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 9:14
+ *  @Description: 后线人员统计数据
+ */
+@Data
+@ApiModel("后线人员统计数据")
+public class HouLinePersonnelReportDto {
+
+    /***
+     * 机构id
+     */
+    @ApiModelProperty(value = "机构id")
+    private String deptId;
+
+    /***
+     * 机构名称
+     */
+    @ApiModelProperty(value = "机构名称")
+    private String deptName;
+    /***
+     * 人数
+     */
+    @ApiModelProperty(value = "人数")
+    private Integer sumCount;
+
+    /***
+     * 平均年龄
+     */
+    @ApiModelProperty(value = "平均年龄")
+    private Integer avgAge;
+
+    /***
+     * 学历分布
+     */
+    @ApiModelProperty(value = "学历分布")
+    private List<ReportDto>  eductionList=new ArrayList<>();
+    /***
+     * 专业分布
+     */
+    @ApiModelProperty(value = "专业分布")
+    private List<ReportDto>  specialityList=new ArrayList<>();
+    /***
+     * 职称分布
+     */
+    @ApiModelProperty(value = "职称分布")
+    private List<ReportDto>  titleList=new ArrayList<>();
+
+    public HouLinePersonnelReportDto() {
+    }
+
+    public HouLinePersonnelReportDto(String deptId, String deptName, Integer sumCount, Integer avgAge, List<ReportDto> eductionList, List<ReportDto> specialityList, List<ReportDto> titleList) {
+        this.deptId = deptId;
+        this.deptName = deptName;
+        this.sumCount = sumCount;
+        this.avgAge = avgAge;
+        this.eductionList = eductionList;
+        this.specialityList = specialityList;
+        this.titleList = titleList;
+    }
+}

+ 65 - 0
src/main/java/com/ydtech/modules/admin/model/report/user/QianLineDDPersonnelReportDto.java

@@ -0,0 +1,65 @@
+package com.ydtech.modules.admin.model.report.user;
+
+import com.ydtech.modules.admin.model.dto.ReportDto;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 9:14
+ *  @Description: 前线人员团队长统计数据
+ */
+@Data
+@ApiModel("前线人员团队长统计数据")
+public class QianLineDDPersonnelReportDto {
+
+    /***
+     * 机构名称
+     */
+    @ApiModelProperty(value = "前线类型")
+    private String typeName;
+    /***
+     * 人数
+     */
+    @ApiModelProperty(value = "人数")
+    private Integer sumCount;
+
+    /***
+     * 平均年龄
+     */
+    @ApiModelProperty(value = "平均年龄")
+    private Integer avgAge;
+
+    /***
+     * 学历分布
+     */
+    @ApiModelProperty(value = "区域分布")
+    private List<ReportDto>  areaList=new ArrayList<>();
+    /***
+     * 专业分布
+     */
+    @ApiModelProperty(value = "性别分布")
+    private List<ReportDto>  sexList=new ArrayList<>();
+    /***
+     * 职称分布
+     */
+    @ApiModelProperty(value = "维护人分布")
+    private List<ReportDto>  whrList=new ArrayList<>();
+
+    public QianLineDDPersonnelReportDto() {
+    }
+
+    public QianLineDDPersonnelReportDto(String typeName, Integer sumCount, Integer avgAge, List<ReportDto> areaList, List<ReportDto> sexList, List<ReportDto> whrList) {
+        this.typeName = typeName;
+        this.sumCount = sumCount;
+        this.avgAge = avgAge;
+        this.areaList = areaList;
+        this.sexList = sexList;
+        this.whrList = whrList;
+    }
+}

+ 71 - 0
src/main/java/com/ydtech/modules/admin/model/report/user/QianLineDLPersonnelReportDto.java

@@ -0,0 +1,71 @@
+package com.ydtech.modules.admin.model.report.user;
+
+import com.ydtech.modules.admin.model.dto.ReportDto;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 9:14
+ *  @Description: 前线人员代理人统计数据
+ */
+@Data
+@ApiModel("前线人员代理人统计数据")
+public class QianLineDLPersonnelReportDto {
+
+    /***
+     * 机构名称
+     */
+    @ApiModelProperty(value = "前线类型")
+    private String typeName;
+    /***
+     * 人数
+     */
+    @ApiModelProperty(value = "人数")
+    private Integer sumCount;
+
+    /***
+     * 平均年龄
+     */
+    @ApiModelProperty(value = "平均年龄")
+    private Integer avgAge;
+
+    /***
+     * 学历分布
+     */
+    @ApiModelProperty(value = "区域分布")
+    private List<ReportDto>  areaList=new ArrayList<>();
+    /***
+     * 专业分布
+     */
+    @ApiModelProperty(value = "性别分布")
+    private List<ReportDto>  sexList=new ArrayList<>();
+    /***
+     * 职称分布
+     */
+    @ApiModelProperty(value = "维护人分布")
+    private List<ReportDto>  whrList=new ArrayList<>();
+    /***
+     * 组织树下单独代理人下三级
+     */
+    @ApiModelProperty(value = "组织树下单独代理人下三级")
+    private  List<ReportDto>   levelList=new ArrayList<>();
+
+    public QianLineDLPersonnelReportDto() {
+    }
+
+    public QianLineDLPersonnelReportDto(String typeName, Integer sumCount, Integer avgAge, List<ReportDto> areaList, List<ReportDto> sexList, List<ReportDto> whrList, List<ReportDto> levelList) {
+        this.typeName = typeName;
+        this.sumCount = sumCount;
+        this.avgAge = avgAge;
+        this.areaList = areaList;
+        this.sexList = sexList;
+        this.whrList = whrList;
+        this.levelList = levelList;
+    }
+}

+ 44 - 0
src/main/java/com/ydtech/modules/admin/model/report/user/QianLineQDPersonnelReportDto.java

@@ -0,0 +1,44 @@
+package com.ydtech.modules.admin.model.report.user;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 9:14
+ *  @Description: 前线人员团队长统计数据
+ */
+@Data
+@ApiModel("前线人员团队长统计数据")
+public class QianLineQDPersonnelReportDto {
+
+    /***
+     * 机构名称
+     */
+    @ApiModelProperty(value = "前线类型")
+    private String typeName;
+    /***
+     * 渠道类型
+     */
+    @ApiModelProperty(value = "渠道类型")
+    private String qdType;
+
+    /***
+     * 维护人
+     */
+    @ApiModelProperty(value = "维护人")
+    private String leadName;
+
+
+
+    public QianLineQDPersonnelReportDto() {
+    }
+
+    public QianLineQDPersonnelReportDto(String typeName, String qdType, String leadName) {
+        this.typeName = typeName;
+        this.qdType = qdType;
+        this.leadName = leadName;
+    }
+}

+ 14 - 0
src/main/java/com/ydtech/modules/admin/service/SysDeptService.java

@@ -97,6 +97,20 @@ public interface SysDeptService extends IService<SysDept> {
      * @return
      */
     List<SysArea> getListQueryBelongArea(String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 8:40
+     *  @Description: 查询后线机构树
+     */
+    List<SysDept> queryHXDeptTree();
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 8:41
+     *  @Description: 查询前线机构树
+     */
+    List<SysDept> queryQXDeptTree();
 }
 
 

+ 48 - 0
src/main/java/com/ydtech/modules/admin/service/UserReportService.java

@@ -0,0 +1,48 @@
+package com.ydtech.modules.admin.service;
+
+
+import com.ydtech.modules.admin.model.report.user.HouLinePersonnelReportDto;
+import com.ydtech.modules.admin.model.report.user.QianLineDDPersonnelReportDto;
+import com.ydtech.modules.admin.model.report.user.QianLineDLPersonnelReportDto;
+
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 9:24
+ *  @Description:  用户统计的service
+ */
+public interface UserReportService {
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:21
+     *  @Description: 前线人员数据统计
+     */
+    HouLinePersonnelReportDto queryHXReportData(String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:30
+     *  @Description:  查询后线团队长统计数据
+     */
+    QianLineDDPersonnelReportDto queryQXTDReportData(String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:32
+     *  @Description: 查询后线代理人统计数据
+     */
+    List<QianLineDLPersonnelReportDto> queryQXQDReportData(String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:33
+     *  @Description:  查询后线代理人统计数据
+     */
+    QianLineDLPersonnelReportDto queryQXDLReportData(String deptId);
+}
+
+
+

+ 50 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptServiceImpl.java

@@ -492,6 +492,56 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         }
         return sysAreas;
     }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 8:43
+     *  @Description:  查询后线机构树
+     */
+    @Override
+    public List<SysDept> queryHXDeptTree() {
+        //所有的后线机构
+        List<SysDept> sysDeptsHX = sysDeptMapper.queryHXDeptTree();
+        //查询后线中顶级的数据
+        List<SysDept> resultList =new ArrayList<SysDept>();
+        List<SysDept> sysDeptTop = sysDeptsHX.stream().filter(item ->"99".equals(item.getId())).collect(Collectors.toList());
+        for (SysDept dept : sysDeptTop) {
+            resultList.add(buildDeptTree(dept,sysDeptsHX));
+        }
+        return resultList;
+    }
+    /**
+     * 递归构建树形结构
+     */
+    private SysDept buildDeptTree(SysDept dept, List<SysDept> deptList){
+        for (SysDept d : deptList) {
+            if (dept.getId().equals(d.getParentId())) {
+                if (null == dept.getChildren()) {
+                    dept.setChildren(new ArrayList<SysDept>());
+                }
+                //递归调用
+                dept.getChildren().add(buildDeptTree(d, deptList));
+            }
+        }
+        return dept;
+    }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 8:42
+     *  @Description: 查询前线机构树
+     */
+    @Override
+    public List<SysDept> queryQXDeptTree() {
+        List<SysDept> sysDeptAll = sysDeptMapper.queryListByQXDept();
+        //查询后线中顶级的数据
+        List<SysDept> resultList =new ArrayList<SysDept>();
+        List<SysDept> sysDeptTop = sysDeptAll.stream().filter(item ->"3".equals(item.getComlevel())).collect(Collectors.toList());
+        for (SysDept dept : sysDeptTop) {
+            resultList.add(buildDeptTree(dept,sysDeptAll));
+        }
+        return sysDeptMapper.queryListByQXDept();
+    }
 
 }
 

+ 100 - 0
src/main/java/com/ydtech/modules/admin/service/impl/UserReportServiceImpl.java

@@ -0,0 +1,100 @@
+package com.ydtech.modules.admin.service.impl;
+
+import com.ydtech.modules.admin.dao.SysDeptMapper;
+import com.ydtech.modules.admin.dao.SysUserMapper;
+import com.ydtech.modules.admin.model.SysDept;
+import com.ydtech.modules.admin.model.dto.ReportDto;
+import com.ydtech.modules.admin.model.report.user.HouLinePersonnelReportDto;
+import com.ydtech.modules.admin.model.report.user.QianLineDDPersonnelReportDto;
+import com.ydtech.modules.admin.model.report.user.QianLineDLPersonnelReportDto;
+import com.ydtech.modules.admin.service.UserReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/28 9:27
+ *  @Description:  用户统计报表
+ */
+@Service
+public class UserReportServiceImpl implements UserReportService {
+
+    @Autowired
+    private SysDeptMapper sysDeptMapper;
+
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 9:27
+     *  @Description:前线用户数据统计
+     */
+    @Override
+    public HouLinePersonnelReportDto queryHXReportData(String deptId) {
+
+
+        SysDept sysDept = sysDeptMapper.selectById(deptId);
+        //查询总数和平均年龄
+        HashMap<String,Integer> map= sysUserMapper.findSumCountAndAvgAge(deptId);
+        //查询学历分布
+        List<ReportDto>  edutionList= sysUserMapper.findEducationSumCount(deptId);
+
+        HouLinePersonnelReportDto  houLinePersonnelReportDto =new HouLinePersonnelReportDto(
+                sysDept.getId(),sysDept.getName(),map.get("sumCount"),map.get("avgAge"),edutionList,
+                new ArrayList<ReportDto>(),new ArrayList<ReportDto>()
+        );
+        return houLinePersonnelReportDto;
+    }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:37
+     *  @Description: 查询团队长数据
+     */
+    @Override
+    public QianLineDDPersonnelReportDto queryQXTDReportData(String deptId) {
+        //查询总数和平均年龄
+        HashMap<String,Integer> map= sysUserMapper.findQXTDSumCountAndAvgAge(deptId);
+
+
+
+        return null;
+    }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:37
+     *  @Description: 查询代理人数据
+     */
+    @Override
+    public List<QianLineDLPersonnelReportDto> queryQXQDReportData(String deptId) {
+        HashMap<String,Integer> map= sysUserMapper.findQXDLSumCountAndAvgAge(deptId,"2");
+
+        return null;
+    }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/28 10:38
+     *  @Description: 查询渠道
+     */
+    @Override
+    public QianLineDLPersonnelReportDto queryQXDLReportData(String deptId) {
+        //查询总数和平均年龄
+        HashMap<String,Integer> map= sysUserMapper.findQXDLSumCountAndAvgAge(deptId,"1");
+
+
+
+        return null;
+    }
+}
+
+
+

+ 18 - 2
src/main/resources/mapper/modules/admin/SysDeptMapper.xml

@@ -93,8 +93,24 @@
         WHERE
             ( sd.comlevel = 3 )
            OR  ( sd.comlevel = 4 )
-           OR ( sd.comlevel > 4 AND id LIKE '%M%' )
-           OR ( sd.comlevel > 4 AND id LIKE '%D%' )
+           OR ( sd.comlevel > 4 AND sd.id LIKE '%M%' )
+           OR ( sd.comlevel > 4 AND sd.id LIKE '%D%' )
+           OR ( sd.id LIKE '%M%' )
         ORDER BY comlevel
     </select>
+    <select id="queryHXDeptTree" resultType="com.ydtech.modules.admin.model.SysDept">
+        SELECT
+        sd.id AS id,
+        sd.NAME AS NAME,
+        sd.parent_id AS parentId,
+        sd.comlevel AS comlevel,
+        FALSE AS flag
+        FROM
+        sys_dept sd
+        WHERE
+        ( sd.comlevel &lt; 4 )
+        OR ( sd.id LIKE '%D%' AND sd.id NOT LIKE '%M%' )
+        ORDER BY
+        id
+    </select>
 </mapper>

+ 63 - 0
src/main/resources/mapper/modules/admin/SysUserMapper.xml

@@ -998,4 +998,67 @@
             su.dept_id =  #{deptId}
           AND t4.id = 21
     </select>
+
+    <select id="findSumCountAndAvgAge" resultType="java.util.HashMap">
+        SELECT
+            count( su.id ) AS sumCount,
+            FLOOR(
+                    avg(
+                            TIMESTAMPDIFF(
+                                YEAR,
+                                    STR_TO_DATE( SUBSTRING( su.identity, 7, 8 ), '%Y%m%d' ),
+                                    CURDATE()))) AS avgAge
+        FROM
+            sys_user su
+        WHERE
+            su.dept_id LIKE CONCAT( #{deptId}, '%' )
+          AND su.identity IS NOT NULL
+
+    </select>
+
+    <select id="findEducationSumCount" resultType="com.ydtech.modules.admin.model.dto.ReportDto">
+        SELECT
+            uinfo.education AS NAME,
+            count( uinfo.education ) AS count
+        FROM
+            sys_user su
+            LEFT JOIN sys_user_info uinfo ON su.id = uinfo.id
+        WHERE
+            su.dept_id LIKE CONCAT( #{deptId}, '%' )
+          AND uinfo.education IS NOT NULL
+        GROUP BY
+            uinfo.education
+    </select>
+    <select id="findQXTDSumCountAndAvgAge" resultType="java.util.HashMap">
+        SELECT
+            count( su.id ) AS sumCount,
+            FLOOR(
+                    avg(
+                            TIMESTAMPDIFF(
+                                YEAR,
+                                    STR_TO_DATE( SUBSTRING( su.identity, 7, 8 ), '%Y%m%d' ),
+                                    CURDATE()))) AS avgAge
+        FROM
+            sys_user su
+                LEFT JOIN sys_user_role  ro  ON su.id = ro.user_id
+        WHERE
+            su.dept_id LIKE CONCAT( #{deptId}, '%' )
+          AND ro.role_id=21
+    </select>
+    <select id="findQXDLSumCountAndAvgAge" resultType="java.util.HashMap">
+        SELECT
+            count( su.id ) AS sumCount,
+            FLOOR(
+                    avg(
+                            TIMESTAMPDIFF(
+                                YEAR,
+                                    STR_TO_DATE( SUBSTRING( su.identity, 7, 8 ), '%Y%m%d' ),
+                                    CURDATE()))) AS avgAge
+        FROM
+            sys_user su
+                LEFT JOIN sys_dept dept ON su.dept_id = dept.id
+        WHERE
+            su.dept_id LIKE CONCAT(#{deptId}, '%' )
+          AND dept.management_source = #{type}
+    </select>
 </mapper>