Просмотр исходного кода

用户数据统计数据修改

hxl13994548489 2 лет назад
Родитель
Сommit
a61a4723f3

+ 3 - 2
src/main/java/com/ydtech/modules/admin/controller/UserReportConroller.java

@@ -5,6 +5,7 @@ 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.model.report.user.QianLineQDPersonnelReportDto;
 import com.ydtech.modules.admin.service.SysDeptService;
 import com.ydtech.modules.admin.service.UserReportService;
 import io.swagger.annotations.Api;
@@ -130,10 +131,10 @@ public class UserReportConroller {
      */
     @GetMapping("queryQXQDReportData")
     @ApiOperation(value = "查询前线人员渠道统计数据")
-    public HttpResult<List<QianLineDLPersonnelReportDto>> queryQXQDReportData(String deptId) {
+    public HttpResult<List<QianLineQDPersonnelReportDto>> queryQXQDReportData(String deptId) {
 
         try{
-            List<QianLineDLPersonnelReportDto> list = userReportService.queryQXQDReportData(deptId);
+            List<QianLineQDPersonnelReportDto> list = userReportService.queryQXQDReportData(deptId);
             return HttpResult.ok("查询数据成功", list);
         }catch (Exception e){
             return HttpResult.error("查询错误"+e.getMessage());

+ 60 - 3
src/main/java/com/ydtech/modules/admin/dao/SysUserMapper.java

@@ -10,6 +10,7 @@ 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.report.user.QianLineQDPersonnelReportDto;
 import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
 import com.ydtech.modules.admin.model.vo.SysUserVO;
 import com.ydtech.modules.admin.model.vo.SysUserVOExt;
@@ -307,7 +308,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      *  @Date: 2024/6/28 9:34
      *  @Description: 通过机构查询统计数据
      */
-    HashMap<String, Integer> findSumCountAndAvgAge(@Param("deptId") String deptId);
+    HashMap<String, String> findSumCountAndAvgAge(@Param("deptId") String deptId);
     /**
      *  @version
      *  @author: hxl
@@ -321,14 +322,70 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      *  @Date: 2024/6/28 10:35
      *  @Description: 查询团队长的总人数和平均年龄
      */
-    HashMap<String, Integer> findQXTDSumCountAndAvgAge(@Param("deptId") String deptId);
+    HashMap<String, String> 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);
+    HashMap<String, String> findQXDLSumCountAndAvgAge(@Param("deptId") String deptId,@Param("type") String type);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 16:39
+     *  @Description: 查询团队长区域分布
+     */
+    List<ReportDto> findQXTDAreaSumCount(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 16:43
+     *  @Description:  查询代理人的区域分布
+     */
+    List<ReportDto> findQXDLAreaSumCount(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 16:47
+     *  @Description: 查询团队张的性别分布
+     */
+    List<ReportDto> findQXTDSexSumCount(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 16:54
+     *  @Description: 查询代理人的性别分布
+     */
+    List<ReportDto> findQXDLSexSumCount(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 16:56
+     *  @Description: 团队长维护人分布
+     */
+    List<ReportDto> findQXTDWhSumCount(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 17:04
+     *  @Description: 代理人维护人分布
+     */
+    List<ReportDto> findQXDLWhSumCount(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 17:11
+     *  @Description:  查询渠道数据
+     */
+    List<QianLineQDPersonnelReportDto> queryQXQDReportData(@Param("deptId") String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 17:41
+     *  @Description:  查询该机构下的代理人
+     */
+    List<SysUser> findQXDLUserList(@Param("deptId") String deptId, @Param("type") String type);
 }
 
 

+ 42 - 0
src/main/java/com/ydtech/modules/admin/model/report/user/DLPersonDto.java

@@ -0,0 +1,42 @@
+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/7/5 17:43
+ *  @Description: 代理人对象
+ */
+@Data
+@ApiModel("下三级代理人对象")
+public class DLPersonDto {
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @ApiModelProperty(value = "用户名称")
+    private String userName;
+
+    @ApiModelProperty(value = "一级代理")
+    private String levelFirstName;
+
+    @ApiModelProperty(value = "二级代理")
+    private String levelSecondName;
+
+    @ApiModelProperty(value = "三级代理")
+    private String  levelThridName;
+
+    public DLPersonDto() {
+    }
+
+    public DLPersonDto(String userId, String userName, String levelFirstName, String levelSecondName, String levelThridName) {
+        this.userId = userId;
+        this.userName = userName;
+        this.levelFirstName = levelFirstName;
+        this.levelSecondName = levelSecondName;
+        this.levelThridName = levelThridName;
+    }
+}

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

@@ -33,13 +33,13 @@ public class HouLinePersonnelReportDto {
      * 人数
      */
     @ApiModelProperty(value = "人数")
-    private Integer sumCount;
+    private String  sumCount;
 
     /***
      * 平均年龄
      */
     @ApiModelProperty(value = "平均年龄")
-    private Integer avgAge;
+    private String  avgAge;
 
     /***
      * 学历分布
@@ -60,7 +60,7 @@ public class HouLinePersonnelReportDto {
     public HouLinePersonnelReportDto() {
     }
 
-    public HouLinePersonnelReportDto(String deptId, String deptName, Integer sumCount, Integer avgAge, List<ReportDto> eductionList, List<ReportDto> specialityList, List<ReportDto> titleList) {
+    public HouLinePersonnelReportDto(String deptId, String deptName, String sumCount, String  avgAge, List<ReportDto> eductionList, List<ReportDto> specialityList, List<ReportDto> titleList) {
         this.deptId = deptId;
         this.deptName = deptName;
         this.sumCount = sumCount;

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

@@ -27,13 +27,13 @@ public class QianLineDDPersonnelReportDto {
      * 人数
      */
     @ApiModelProperty(value = "人数")
-    private Integer sumCount;
+    private String sumCount;
 
     /***
      * 平均年龄
      */
     @ApiModelProperty(value = "平均年龄")
-    private Integer avgAge;
+    private String avgAge;
 
     /***
      * 学历分布
@@ -54,7 +54,7 @@ public class QianLineDDPersonnelReportDto {
     public QianLineDDPersonnelReportDto() {
     }
 
-    public QianLineDDPersonnelReportDto(String typeName, Integer sumCount, Integer avgAge, List<ReportDto> areaList, List<ReportDto> sexList, List<ReportDto> whrList) {
+    public QianLineDDPersonnelReportDto(String typeName, String sumCount, String avgAge, List<ReportDto> areaList, List<ReportDto> sexList, List<ReportDto> whrList) {
         this.typeName = typeName;
         this.sumCount = sumCount;
         this.avgAge = avgAge;

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

@@ -27,13 +27,13 @@ public class QianLineDLPersonnelReportDto {
      * 人数
      */
     @ApiModelProperty(value = "人数")
-    private Integer sumCount;
+    private String sumCount;
 
     /***
      * 平均年龄
      */
     @ApiModelProperty(value = "平均年龄")
-    private Integer avgAge;
+    private String  avgAge;
 
     /***
      * 学历分布
@@ -54,12 +54,12 @@ public class QianLineDLPersonnelReportDto {
      * 组织树下单独代理人下三级
      */
     @ApiModelProperty(value = "组织树下单独代理人下三级")
-    private  List<ReportDto>   levelList=new ArrayList<>();
+    private  List<DLPersonDto>   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) {
+    public QianLineDLPersonnelReportDto(String typeName, String  sumCount, String  avgAge, List<ReportDto> areaList, List<ReportDto> sexList, List<ReportDto> whrList, List<DLPersonDto> levelList) {
         this.typeName = typeName;
         this.sumCount = sumCount;
         this.avgAge = avgAge;

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

@@ -19,6 +19,12 @@ public class QianLineQDPersonnelReportDto {
      */
     @ApiModelProperty(value = "前线类型")
     private String typeName;
+
+    /***
+     * 用户名称
+     */
+    @ApiModelProperty(value = "用户名称")
+    private String userName;
     /***
      * 渠道类型
      */

+ 2 - 1
src/main/java/com/ydtech/modules/admin/service/UserReportService.java

@@ -4,6 +4,7 @@ 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 com.ydtech.modules.admin.model.report.user.QianLineQDPersonnelReportDto;
 
 import java.util.List;
 
@@ -34,7 +35,7 @@ public interface UserReportService {
      *  @Date: 2024/6/28 10:32
      *  @Description: 查询后线代理人统计数据
      */
-    List<QianLineDLPersonnelReportDto> queryQXQDReportData(String deptId);
+    List<QianLineQDPersonnelReportDto> queryQXQDReportData(String deptId);
     /**
      *  @version
      *  @author: hxl

+ 62 - 22
src/main/java/com/ydtech/modules/admin/service/impl/UserReportServiceImpl.java

@@ -1,12 +1,12 @@
 package com.ydtech.modules.admin.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.SysUser;
 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.model.report.user.*;
 import com.ydtech.modules.admin.service.UserReportService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -42,12 +42,12 @@ public class UserReportServiceImpl implements UserReportService {
 
         SysDept sysDept = sysDeptMapper.selectById(deptId);
         //查询总数和平均年龄
-        HashMap<String,Integer> map= sysUserMapper.findSumCountAndAvgAge(deptId);
+        HashMap<String, String> map= sysUserMapper.findSumCountAndAvgAge(deptId);
         //查询学历分布
         List<ReportDto>  edutionList= sysUserMapper.findEducationSumCount(deptId);
-
+        // todo   缺少专业、职称字段 是否添加
         HouLinePersonnelReportDto  houLinePersonnelReportDto =new HouLinePersonnelReportDto(
-                sysDept.getId(),sysDept.getName(),map.get("sumCount"),map.get("avgAge"),edutionList,
+                sysDept.getId(),sysDept.getName(),  String.valueOf(map.get("sumCount")), String.valueOf(map.get("avgAge")),edutionList,
                 new ArrayList<ReportDto>(),new ArrayList<ReportDto>()
         );
         return houLinePersonnelReportDto;
@@ -61,39 +61,79 @@ public class UserReportServiceImpl implements UserReportService {
     @Override
     public QianLineDDPersonnelReportDto queryQXTDReportData(String deptId) {
         //查询总数和平均年龄
-        HashMap<String,Integer> map= sysUserMapper.findQXTDSumCountAndAvgAge(deptId);
-
-
-
-        return null;
+        HashMap<String,String> map= sysUserMapper.findQXTDSumCountAndAvgAge(deptId);
+        //查询团队长的区域位置
+        List<ReportDto>  areaList = sysUserMapper.findQXTDAreaSumCount(deptId);
+        //查询性别分布
+        List<ReportDto>  sexList = sysUserMapper.findQXTDSexSumCount(deptId);
+        //维护人分布
+        List<ReportDto>  whList = sysUserMapper.findQXTDWhSumCount(deptId);
+        return new QianLineDDPersonnelReportDto("团队长", String.valueOf(map.get("sumCount")), String.valueOf(map.get("avgAge")),
+                areaList,sexList,whList);
     }
     /**
      *  @version
      *  @author: hxl
      *  @Date: 2024/6/28 10:37
-     *  @Description: 查询代理人数据
+     *  @Description: 查询渠道数据
      */
     @Override
-    public List<QianLineDLPersonnelReportDto> queryQXQDReportData(String deptId) {
-        HashMap<String,Integer> map= sysUserMapper.findQXDLSumCountAndAvgAge(deptId,"2");
-
-        return null;
+    public List<QianLineQDPersonnelReportDto> queryQXQDReportData(String deptId) {
+        // todo   渠道类型无法确定,需要后续确定
+        List<QianLineQDPersonnelReportDto> list= sysUserMapper.queryQXQDReportData(deptId);
+        return list;
     }
     /**
      *  @version
      *  @author: hxl
      *  @Date: 2024/6/28 10:38
-     *  @Description: 查询渠道
+     *  @Description: 查询代理人
      */
     @Override
     public QianLineDLPersonnelReportDto queryQXDLReportData(String deptId) {
         //查询总数和平均年龄
-        HashMap<String,Integer> map= sysUserMapper.findQXDLSumCountAndAvgAge(deptId,"1");
-
-
-
-        return null;
+        HashMap<String,String> map= sysUserMapper.findQXDLSumCountAndAvgAge(deptId,"2");
+        //查询代理人的区域位置
+        List<ReportDto>  areaList = sysUserMapper.findQXDLAreaSumCount(deptId);
+        //查询性别分布
+        List<ReportDto>  sexList = sysUserMapper.findQXDLSexSumCount(deptId);
+        //维护人分布
+        List<ReportDto>  whList = sysUserMapper.findQXDLWhSumCount(deptId);
+        //查询当前人的下三级机构
+        List<SysUser>   levelList =sysUserMapper.findQXDLUserList(deptId,"2");
+        List<DLPersonDto>  list=new ArrayList<>();
+        if(levelList !=null && levelList.size()>0){
+            for(SysUser sysUser: levelList){
+                SysUser level1 = getBottomByUserId(sysUser.getId());
+                SysUser level2=null;
+                SysUser level3=null;
+                if(level1!=null){
+                   level2 = getBottomByUserId(sysUser.getId());
+                }
+                if(level2!=null){
+                    level3 = getBottomByUserId(sysUser.getId());
+                }
+                DLPersonDto dLPersonDto =new DLPersonDto(sysUser.getId(), sysUser.getName(), level1==null?"":level1.getName(), level2==null?"":level2.getName(), level3==null?"":level3.getName());
+                list.add(dLPersonDto);
+            }
+        }
+        return new QianLineDLPersonnelReportDto("团队长", String.valueOf(map.get("sumCount")), String.valueOf(map.get("avgAge")),
+                areaList,sexList,whList,list);
     }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/7/5 18:04
+     *  @Description:  通过领导人id查询数据
+     */
+    public  SysUser getBottomByUserId(String userId){
+        LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(SysUser::getLeaderId, userId);
+        lqw.eq(SysUser::getStatus,1);
+        SysUser user =sysUserMapper.selectOne(lqw);
+        return user;
+    }
+
 }
 
 

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

@@ -1113,4 +1113,138 @@
             su.dept_id LIKE CONCAT(#{deptId}, '%' )
           AND dept.management_source = #{type}
     </select>
+    <select id="findQXTDAreaSumCount" resultType="com.ydtech.modules.admin.model.dto.ReportDto">
+        SELECT
+            sa.area_cname AS NAME,
+            count( 0 ) AS count
+        FROM
+            sys_user su
+                LEFT JOIN sys_user_role ro ON su.id = ro.user_id
+                LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING( LPAD( su.id, 8, 0 ), 3, 8 )
+        WHERE
+            su.dept_id LIKE CONCAT( #{deptId}, '%' )
+          AND ro.role_id=21
+          AND sa.area_cname IS NOT NULL
+        GROUP BY
+            sa.area_cname
+    </select>
+    <select id="findQXDLAreaSumCount" resultType="com.ydtech.modules.admin.model.dto.ReportDto">
+        SELECT
+            sa.area_cname AS NAME,
+            count( 0 ) AS count
+        FROM
+            sys_user su
+                LEFT JOIN sys_dept sd ON su.dept_id = sd.id
+                LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING( LPAD( su.id, 8, 0 ), 3, 8 )
+        WHERE
+          sd.management_source = 2
+          AND sd.del_flag = '0'
+          AND su.STATUS = 1
+          AND sa.area_cname IS NOT NULL
+        GROUP BY
+            sa.area_cname
+    </select>
+    <select id="findQXTDSexSumCount" resultType="com.ydtech.modules.admin.model.dto.ReportDto">
+        SELECT
+            CASE
+                WHEN
+                    uinfo.sex = 'M' THEN
+                    '男'
+                WHEN uinfo.sex = 'F' THEN
+                    '女' ELSE ''
+                END AS NAME,
+            count( 0 ) AS count
+        FROM
+            sys_user su
+            LEFT JOIN sys_user_info uinfo ON su.id = uinfo.id
+            LEFT JOIN sys_user_role ro ON su.id = ro.user_id
+        WHERE
+            su.dept_id LIKE CONCAT(#{deptId}, '%' )
+          AND ro.role_id = 21
+          AND uinfo.sex IS NOT NULL
+        GROUP BY
+            uinfo.sex
+    </select>
+    <select id="findQXDLSexSumCount" resultType="com.ydtech.modules.admin.model.dto.ReportDto">
+        SELECT
+            CASE
+                WHEN
+                    uinfo.sex = 'M' THEN
+                    '男'
+                WHEN uinfo.sex = 'F' THEN
+                    '女' ELSE ''
+                END AS NAME,
+            count( 0 ) AS count
+        FROM
+            sys_user su
+            LEFT JOIN sys_user_info uinfo ON uinfo.id = su.id
+            LEFT JOIN sys_dept sd ON su.dept_id = sd.id
+        WHERE
+            sd.management_source = 2
+          AND sd.del_flag = '0'
+          AND su.STATUS = 1
+          AND uinfo.sex IS NOT NULL
+        GROUP BY
+            uinfo.sex
+    </select>
+    <select id="findQXTDWhSumCount" resultType="com.ydtech.modules.admin.model.dto.ReportDto">
+        SELECT
+            su.leader_name as name,
+            count( 0 ) AS count
+        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
+          AND su.leader_name IS NOT NULL
+        GROUP BY
+            su.leader_name
+    </select>
+    <select id="findQXDLWhSumCount" resultType="com.ydtech.modules.admin.model.dto.ReportDto">
+        SELECT
+            su.leader_name as name,
+            count( 0 ) AS count
+        FROM
+            sys_user su
+            LEFT JOIN sys_dept sd ON su.dept_id = sd.id
+        WHERE
+            sd.management_source = 2
+          AND sd.del_flag = '0'
+          AND su.STATUS = 1
+          AND su.leader_name IS NOT NULL
+        GROUP BY
+            su.leader_name
+    </select>
+    <select id="queryQXQDReportData"
+            resultType="com.ydtech.modules.admin.model.report.user.QianLineQDPersonnelReportDto">
+        SELECT
+            su.name as userName,
+            su.leader_name as leadName,
+           "渠道" as  typeName,
+           ""  as  qdType
+        FROM
+            sys_user su
+            LEFT JOIN sys_dept sd ON su.dept_id = sd.id
+        WHERE
+            sd.management_source = 1
+          AND sd.del_flag = '0'
+          AND su.STATUS = 1
+          and su.leader_name is not null
+    </select>
+    <select id="findQXDLUserList" resultType="com.ydtech.modules.admin.model.SysUser">
+        SELECT
+           su.id as id,
+           su.name as name
+        FROM
+            sys_user su
+            LEFT JOIN sys_dept sd ON su.dept_id = sd.id
+        WHERE
+            sd.management_source = 2
+          AND sd.del_flag = '0'
+          AND su.STATUS = 1
+          AND su.leader_name IS NOT NULL
+        GROUP BY
+            su.leader_name
+    </select>
 </mapper>