Quellcode durchsuchen

1.人员渠道调整

wuhp vor 1 Jahr
Ursprung
Commit
c483f00aae

+ 23 - 0
src/main/java/com/ydtech/modules/admin/controller/personnelStatistics/PersonnelStatisticsController.java

@@ -77,6 +77,29 @@ public class PersonnelStatisticsController {
         return result;
     }
 
+    /**
+     * @version
+     * @author: whp
+     * @Date: 2024/8/07
+     * @Description: 人员统计-前线人员-代理人统计
+     */
+    @PostMapping("queryQxFrontlineAgentNew")
+    @ApiOperation(value = "人员统计-前线人员-代理人统计")
+    public HttpResult<IPage<QxFrontlineAgentDto>> queryQxFrontlineAgentNew(@RequestBody QxFrontlineAgentVo qxFrontlineAgentVo, HttpServletRequest httpServerRequest) {
+        KztGetDeptUtils kztGetDeptUtils = new KztGetDeptUtils();
+        KztGetDeptUtilsDto kztGetDeptUtilsDto = kztGetDeptUtils.KztGetDeptIds(httpServerRequest.getRequestURL().toString());
+        if(ObjectUtils.isNotEmpty(kztGetDeptUtilsDto)){
+            if("1".equals(kztGetDeptUtilsDto.getType())){
+                qxFrontlineAgentVo.setDeptIds(kztGetDeptUtilsDto.getIds());
+            } else if ("2".equals(kztGetDeptUtilsDto.getType())) {
+                qxFrontlineAgentVo.setUserIds(kztGetDeptUtilsDto.getIds());
+            }
+        }
+        HttpResult<IPage<QxFrontlineAgentDto>> result = userReportService.queryQxFrontlineAgentNew(qxFrontlineAgentVo);
+        return result;
+    }
+
+
     /**
      * @version
      * @author: whp

+ 38 - 0
src/main/java/com/ydtech/modules/admin/dao/UserReportMapper.java

@@ -0,0 +1,38 @@
+package com.ydtech.modules.admin.dao;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto;
+import com.ydtech.modules.admin.model.vo.QxFrontlineAgentVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface UserReportMapper {
+    /**
+     *
+     * @param page
+     * @param qxFrontlineAgentVo
+     * @return  渠道统计查询
+     */
+    IPage<QxFrontlineAgentDto> selectChannelPerson(@Param("page") Page page,@Param("vo") QxFrontlineAgentVo qxFrontlineAgentVo);
+
+    /**
+     *
+     * @param page
+     * @param qxFrontlineAgentVo
+     * @return  渠道统计查询
+     */
+    List<QxFrontlineAgentDto> selectChannelPersonOld(@Param("vo") QxFrontlineAgentVo qxFrontlineAgentVo);
+
+    /**
+     *
+     * @param page
+     * @param qxFrontlineAgentVo
+     * @return  代理人统计查询
+     */
+    IPage<QxFrontlineAgentDto> selectAgentPerson(@Param("page") Page page,@Param("vo") QxFrontlineAgentVo qxFrontlineAgentVo);
+
+}

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

@@ -121,6 +121,13 @@ public interface UserReportService {
      */
     HttpResult<HashMap<String, Integer>> getIssueNumber(QxFrontlineAgentVo qxFrontlineAgentVo);
 
+    /**
+     *
+     * @param qxFrontlineAgentVo
+     * @return  人员渠道代理人电销查询
+     */
+    HttpResult<IPage<QxFrontlineAgentDto>> queryQxFrontlineAgentNew(QxFrontlineAgentVo qxFrontlineAgentVo);
+
 }
 
 

+ 27 - 6
src/main/java/com/ydtech/modules/admin/service/impl/UserReportServiceImpl.java

@@ -7,11 +7,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.constants.enums.dict.DictionaryManagement;
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageRequest;
 import com.ydtech.core.page.PageResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.SysDeptMapper;
 import com.ydtech.modules.admin.dao.SysUserMapper;
 import com.ydtech.modules.admin.dao.SysUserRoleMapper;
+import com.ydtech.modules.admin.dao.UserReportMapper;
 import com.ydtech.modules.admin.model.*;
 import com.ydtech.modules.admin.model.dto.*;
 import com.ydtech.modules.admin.model.report.user.*;
@@ -87,6 +89,9 @@ public class UserReportServiceImpl implements UserReportService {
     @Value("${upload.file.url}")
     private String uploadUrl;
 
+    @Autowired
+    private UserReportMapper  userReportMapper;
+
     /**
      *  @version
      *  @author: hxl
@@ -220,7 +225,8 @@ public class UserReportServiceImpl implements UserReportService {
 
             List<QxFrontlineAgentDto> getQxFrontlineAgentList = sysUserMapper.getQxFrontlineAgentList(qxFrontlineAgentVo);
             if (qxFrontlineAgentVo.getManagementSource().equals("1")) {// 渠道
-                this.channelPerson(getQxFrontlineAgentList, qxFrontlineAgentVo);
+                getQxFrontlineAgentList .clear();
+                getQxFrontlineAgentList.addAll(userReportMapper.selectChannelPersonOld(qxFrontlineAgentVo));
             } else if (qxFrontlineAgentVo.getManagementSource().equals("2")) {// 代理人
                 this.agentPerson(getQxFrontlineAgentList, qxFrontlineAgentVo);
             } else if (qxFrontlineAgentVo.getManagementSource().equals("3")) { //电销
@@ -269,11 +275,6 @@ public class UserReportServiceImpl implements UserReportService {
                         }
                     }
                 }
-                qxFrontlineAgentVo.setUserId(dto.getUserId());
-                //预期净利润
-                BigDecimal ExpectNetProfit = insAreaCompanyService.getExpectNetProfit(qxFrontlineAgentVo);
-                dto.setEstimatedProfit(ExpectNetProfit);
-
             }
             resultPage.setContent(qxFrontlineAgentDtos);
             resultPage.setPageNum(qxFrontlineAgentVo.getPageNum());
@@ -321,6 +322,26 @@ public class UserReportServiceImpl implements UserReportService {
 
     }
 
+    @Override
+    public HttpResult<IPage<QxFrontlineAgentDto>> queryQxFrontlineAgentNew(QxFrontlineAgentVo qxFrontlineAgentVo) {
+        PageRequest pageRequest = new PageRequest();
+        pageRequest.setPageNum(qxFrontlineAgentVo.getPageNum());
+        pageRequest.setPageSize(qxFrontlineAgentVo.getPageSize());
+        Page page = PageRequest.buildPageRequest(pageRequest);
+
+        HashMap<String, String> map = getDateMapByType(qxFrontlineAgentVo.getDays(), qxFrontlineAgentVo.getCreatetimeStart(), qxFrontlineAgentVo.getCreatetimeEnd());
+        qxFrontlineAgentVo.setCreatetimeStart(map.get("startDate"));
+        qxFrontlineAgentVo.setCreatetimeEnd(map.get("endDate"));
+
+        if (qxFrontlineAgentVo.getManagementSource().equals("1")) {// 渠道
+            return  HttpResult.ok(userReportMapper.selectChannelPerson(page,qxFrontlineAgentVo));
+        } else if (qxFrontlineAgentVo.getManagementSource().equals("2")) {// 代理人
+            return  HttpResult.ok(userReportMapper.selectAgentPerson(page,qxFrontlineAgentVo));
+
+        }
+        return null;
+    }
+
     @Override
     public HttpResult agentExcel(QxFrontlineAgentVo qxFrontlineAgentVo) {
 //        QxFrontlineAgentExcel

+ 249 - 0
src/main/resources/mapper/modules/console/userReportMapper.xml

@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ydtech.modules.admin.dao.UserReportMapper">
+    <select id="selectChannelPerson" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
+        select
+        d.name as "deptName",
+        u.name as "name",
+        d.id as "deptId",
+        u.id as "userId",
+        u.mobile as "mobile",
+        inf.url as "filePath",
+        sui.sex as "sex",
+        r.role_id AS roleId,
+        f.totalPremium as "totalPremium",
+        f.averagePremium as "averagePremium",
+        IFNULL(f.entranceAllFee,0) -IFNULL(f.exportAllFee,0)  as  "distributionAmount"
+        from sys_user u
+        left join sys_dept d on d.id = u.dept_id
+        left join sys_user_role r on u.id = r.user_id
+        LEFT JOIN ins_upload_files inf on u.head_sculpture =inf.id
+        LEFT JOIN sys_user_info sui on sui .id =u.id
+        left join (select (select user_id
+        from sys_user u
+        left join sys_user_role r on u.id = r.user_id
+        where u.dept_id = sd.id and r.role_id = 21 limit 1) as "userid",
+        sum(jqpremium + sypremium + jypremium) as "totalPremium",
+        ROUND(sum( jqpremium + sypremium + jypremium )/ count( iac.orderno ),2) AS "averagePremium",
+        ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
+        (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
+        ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
+        +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
+        +IFNULL(no_export_supervise_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
+        "exportAllFee"
+        from ins_area_company iac
+        left join ins_orders io on iac.orderno = io.orderno
+        left join sys_dept sd on io.deptid = sd.id
+        LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
+        <where>
+            sd.management_source = '1'
+            and iac.orderstatus = '3'
+            <if test="vo.ids  != null  and  vo.ids.size()>0 ">
+                AND io.userid IN
+                <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="vo.createtimeStart  != null  and  vo.createtimeStart!=''  and vo.createtimeEnd  != null  and  vo.createtimeEnd!=''">
+                AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
+            </if>
+        </where>
+        group by sd.id) as f on f.userid = u.id
+        <where>
+            d.management_source = '1'
+            and r.role_id = 21
+            and u.status = '1'
+            <if test="vo.provinceId != null and vo.provinceId != ''">
+                and d.id like concat('%',#{vo.provinceId},'%')
+            </if>
+            <if test="vo.cityId != null and vo.cityId != ''">
+                and d.id like concat('%',#{vo.cityId},'%')
+            </if>
+            <if test="vo.countyId != null and vo.countyId != ''">
+                and d.id like concat('%',#{vo.countyId},'%')
+            </if>
+            <if test="vo.houseId != null and vo.houseId != ''">
+                and d.id like concat('%',#{vo.houseId},'%')
+            </if>
+            <if test="vo.name != null and vo.name != ''">
+                and u.name =#{vo.name}
+            </if>
+            <if test="vo.userCode != null and vo.userCode != ''">
+                and u.id =#{vo.userCode}
+            </if>
+            <if test="vo.phoneNumber != null and vo.phoneNumber != ''">
+                and u.mobile =#{vo.phoneNumber}
+            </if>
+            <if test="vo.leaderId != null and vo.leaderId != ''">
+                and u.leader_id =#{vo.leaderId}
+            </if>
+            <if test="vo.leaderName != null and vo.leaderName != ''">
+                and u.leader_name =#{vo.leaderName}
+            </if>
+
+            <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
+                AND d.id in
+                <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
+                AND u.id in
+                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        order by f.totalPremium desc
+    </select>
+
+
+
+    <select id="selectChannelPersonOld" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
+        select
+        d.name as "deptName",
+        u.name as "name",
+        d.id as "deptId",
+        u.id as "userId",
+        u.mobile as "mobile",
+        u.leader_name as "leaderName",
+        inf.url as "filePath",
+        sui.sex as "sex",
+        r.role_id AS roleId,
+        IFNULL(f.totalPremium,0) as "totalPremium",
+        IFNULL(f.averagePremium,0) as "averagePremium",
+        IFNULL(IFNULL(f.entranceAllFee,0) -IFNULL(f.exportAllFee,0),0)  as  "estimatedProfit"
+        from sys_user u
+        left join sys_dept d on d.id = u.dept_id
+        left join sys_user_role r on u.id = r.user_id
+        LEFT JOIN ins_upload_files inf on u.head_sculpture =inf.id
+        LEFT JOIN sys_user_info sui on sui .id =u.id
+        left join (select (select user_id
+        from sys_user u
+        left join sys_user_role r on u.id = r.user_id
+        where u.dept_id = sd.id and r.role_id = 21 limit 1) as "userid",
+        sum(jqpremium + sypremium + jypremium) as "totalPremium",
+        ROUND(sum( jqpremium + sypremium + jypremium )/ count( iac.orderno ),2) AS "averagePremium",
+        ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
+        (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
+        ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
+        +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
+        +IFNULL(no_export_supervise_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
+        "exportAllFee"
+        from ins_area_company iac
+        left join ins_orders io on iac.orderno = io.orderno
+        left join sys_dept sd on io.deptid = sd.id
+        LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
+        <where>
+            and iac.orderstatus = '3'
+            <if test="vo.managementSource  != null  and  vo.managementSource!=''">
+                AND  sd.management_source  =#{vo.managementSource}
+            </if>
+            <if test="vo.ids  != null  and  vo.ids.size()>0 ">
+                AND io.userid IN
+                <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="vo.createtimeStart  != null  and  vo.createtimeStart!=''  and vo.createtimeEnd  != null  and  vo.createtimeEnd!=''">
+                AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
+            </if>
+        </where>
+        group by sd.id) as f on f.userid = u.id
+        <where>
+            d.management_source = '1'
+            and r.role_id = 21
+            and u.status = '1'
+            <if test="vo.provinceId != null and vo.provinceId != ''">
+                and d.id like concat('%',#{vo.provinceId},'%')
+            </if>
+            <if test="vo.cityId != null and vo.cityId != ''">
+                and d.id like concat('%',#{vo.cityId},'%')
+            </if>
+            <if test="vo.countyId != null and vo.countyId != ''">
+                and d.id like concat('%',#{vo.countyId},'%')
+            </if>
+            <if test="vo.houseId != null and vo.houseId != ''">
+                and d.id like concat('%',#{vo.houseId},'%')
+            </if>
+            <if test="vo.name != null and vo.name != ''">
+                and u.name =#{vo.name}
+            </if>
+            <if test="vo.userCode != null and vo.userCode != ''">
+                and u.id =#{vo.userCode}
+            </if>
+            <if test="vo.phoneNumber != null and vo.phoneNumber != ''">
+                and u.mobile =#{vo.phoneNumber}
+            </if>
+            <if test="vo.leaderId != null and vo.leaderId != ''">
+                and u.leader_id =#{vo.leaderId}
+            </if>
+            <if test="vo.leaderName != null and vo.leaderName != ''">
+                and u.leader_name =#{vo.leaderName}
+            </if>
+
+            <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
+                AND d.id in
+                <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
+                AND u.id in
+                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        order by f.totalPremium desc
+    </select>
+
+
+    <select id="selectAgentPerson" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
+        select u.id,
+               u.name,
+               f.c,
+               (select count(*) from sys_user where dept_id = u.dept_id) as ucount,
+               (
+                   select count(*) from
+                       (select io1.userid, count(*) count1 from ins_area_company iac1
+                           left join ins_orders io1 on iac1.orderno = io1.orderno
+                        where  iac1.orderstatus = '3' and io1.userid = u.id
+                        group by io1.userid) as f1
+                   where f1.count1 > 0
+               ) as count2
+
+        from sys_user u
+                 left join sys_dept d on d.id = u.dept_id
+                 left join sys_user_role r on u.id = r.user_id
+                 left join (select (select user_id
+                                    from sys_user u
+                                             left join sys_user_role r on u.id = r.user_id
+                                    where u.dept_id = sd.id
+                                      and r.role_id = 21
+                                    limit 1) as                           userid,
+                                   (select u.name
+                                    from sys_user u
+                                             left join sys_user_role r on u.id = r.user_id
+                                    where u.dept_id = sd.id
+                                      and r.role_id = 21
+                                    limit 1) as                           username,
+                                   sd.id,
+                                   sum(jqpremium + sypremium + jypremium) c
+                            from ins_area_company iac
+                                     left join ins_orders io on iac.orderno = io.orderno
+                                     left join sys_dept sd on io.deptid = sd.id
+                            where sd.management_source = '2'
+                              and iac.orderstatus = '3'
+                              and iac.createtime between '2024-10-24 00:00:00' and '2024-10-25 00:00:00'
+                            group by sd.id) as f on f.userid = u.id
+        where d.management_source = '2'
+          and r.role_id = 21
+        order by c desc;
+    </select>
+
+</mapper>