Browse Source

1.控制台人员代理人金额排序 添加查询条件 是否出单

wuhp 1 year ago
parent
commit
b56f0b5c8a

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

@@ -2,6 +2,7 @@ package com.ydtech.modules.admin.controller.personnelStatistics;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageResult;
 import com.ydtech.modules.admin.model.dto.EsmUserReferrerDTO;
 import com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto;
 import com.ydtech.modules.admin.model.dto.TeamManagementDto;
@@ -63,7 +64,7 @@ public class PersonnelStatisticsController {
      */
     @PostMapping("queryQxFrontlineAgent")
     @ApiOperation(value = "人员统计-前线人员-代理人统计")
-    public HttpResult<IPage<QxFrontlineAgentDto>> queryQxFrontlineAgent(@RequestBody QxFrontlineAgentVo qxFrontlineAgentVo, HttpServletRequest httpServerRequest) {
+    public HttpResult<PageResult<QxFrontlineAgentDto>> queryQxFrontlineAgent(@RequestBody QxFrontlineAgentVo qxFrontlineAgentVo, HttpServletRequest httpServerRequest) {
         KztGetDeptUtils kztGetDeptUtils = new KztGetDeptUtils();
         KztGetDeptUtilsDto kztGetDeptUtilsDto = kztGetDeptUtils.KztGetDeptIds(httpServerRequest.getRequestURL().toString());
         if(ObjectUtils.isNotEmpty(kztGetDeptUtilsDto)){
@@ -73,7 +74,7 @@ public class PersonnelStatisticsController {
                 qxFrontlineAgentVo.setUserIds(kztGetDeptUtilsDto.getIds());
             }
         }
-        HttpResult<IPage<QxFrontlineAgentDto>> result = userReportService.queryQxFrontlineAgent(qxFrontlineAgentVo);
+        HttpResult<PageResult<QxFrontlineAgentDto>> result = userReportService.queryQxFrontlineAgent(qxFrontlineAgentVo);
         return result;
     }
 

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

@@ -513,6 +513,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
     List<SysUser> selectByLeadId(String userId);
 
     List<SysUser> querySourceId(String id);
+
+    List<QxFrontlineAgentDto> getQxFrontlineAgentList(@Param("vo") QxFrontlineAgentVo qxFrontlineAgentVo);
+
 }
 
 

+ 3 - 0
src/main/java/com/ydtech/modules/admin/model/dto/QxFrontlineAgentDto.java

@@ -126,6 +126,9 @@ public class QxFrontlineAgentDto implements Serializable {
     @ApiModelProperty(value = "用户ids")
     private List<String> userIds;
 
+    @ApiModelProperty(value = "是否出单 0  不出单  1 出单")
+    private String outThere;
+
     private Integer totalManpowerNum;
 
     private Double totalPremiumNum;

+ 3 - 0
src/main/java/com/ydtech/modules/admin/model/vo/QxFrontlineAgentVo.java

@@ -81,6 +81,9 @@ public class QxFrontlineAgentVo implements Serializable {
     @ApiModelProperty(value = "月份")
     private String month;
 
+    @ApiModelProperty(value = "是否出单 0  不出单  1 出单")
+    private String outThere;
+
     @ApiModelProperty(value = "层级类型  0 汇总  1.本人  2. 一级团队 3. 二级团队  4 三级团队  5 临时团队")
     private String type;
 

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

@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageResult;
 import com.ydtech.modules.admin.model.dto.EsmUserReferrerDTO;
 import com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto;
 import com.ydtech.modules.admin.model.dto.TeamManagementDto;
@@ -65,7 +66,7 @@ public interface UserReportService {
      *  @Date: 2024/8/07
      *  @Description:  人员统计-前线人员-代理人统计
      */
-    HttpResult<IPage<QxFrontlineAgentDto>> queryQxFrontlineAgent(QxFrontlineAgentVo qxFrontlineAgentVo);
+    HttpResult<PageResult<QxFrontlineAgentDto>> queryQxFrontlineAgent(QxFrontlineAgentVo qxFrontlineAgentVo);
     /**
      *  @version
      *  @author: whp

+ 78 - 51
src/main/java/com/ydtech/modules/admin/service/impl/UserReportServiceImpl.java

@@ -7,6 +7,7 @@ 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.PageResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.SysDeptMapper;
 import com.ydtech.modules.admin.dao.SysUserMapper;
@@ -200,23 +201,69 @@ public class UserReportServiceImpl implements UserReportService {
      *  @Description:  人员统计-前线人员-代理人统计
      */
     @Override
-    public HttpResult<IPage<QxFrontlineAgentDto>> queryQxFrontlineAgent(QxFrontlineAgentVo qxFrontlineAgentVo) {
+    public HttpResult<PageResult<QxFrontlineAgentDto>> queryQxFrontlineAgent(QxFrontlineAgentVo qxFrontlineAgentVo) {
         try {
+            PageResult<QxFrontlineAgentDto> resultPage = new PageResult<>();
+
             HashMap<String, String> map = getDateMapByType(qxFrontlineAgentVo.getDays(), qxFrontlineAgentVo.getCreatetimeStart(), qxFrontlineAgentVo.getCreatetimeEnd());
             qxFrontlineAgentVo.setCreatetimeStart(map.get("startDate"));
             qxFrontlineAgentVo.setCreatetimeEnd(map.get("endDate"));
-            PageVo<SettlementDocumentaryFeesSumEntity> pageVo = new PageVo<>();
-            Page page = new Page(qxFrontlineAgentVo.getPageNum(), qxFrontlineAgentVo.getPageSize());
-            pageVo.setPageNum(qxFrontlineAgentVo.getPageNum());
-            pageVo.setPageSize(qxFrontlineAgentVo.getPageSize());
-            IPage<QxFrontlineAgentDto> sysUserListPage = sysUserMapper.queryQxFrontlineAgent(page, qxFrontlineAgentVo);
-            List<QxFrontlineAgentDto> sysUserList = sysUserListPage.getRecords();
-            if(qxFrontlineAgentVo.getManagementSource().equals("1")){// 渠道
-                this.channelPerson(sysUserList,qxFrontlineAgentVo);
-            }else if (qxFrontlineAgentVo.getManagementSource().equals("2")){// 代理人
-                this.agentPerson(sysUserList,qxFrontlineAgentVo);
+
+            List<QxFrontlineAgentDto> getQxFrontlineAgentList = sysUserMapper.getQxFrontlineAgentList(qxFrontlineAgentVo);
+            if (qxFrontlineAgentVo.getManagementSource().equals("1")) {// 渠道
+                this.channelPerson(getQxFrontlineAgentList, qxFrontlineAgentVo);
+            } else if (qxFrontlineAgentVo.getManagementSource().equals("2")) {// 代理人
+                this.agentPerson(getQxFrontlineAgentList, qxFrontlineAgentVo);
+            }
+
+            if (StringUtils.isNotEmpty(qxFrontlineAgentVo.getOutThere())) {
+                if ("1".equals(qxFrontlineAgentVo.getOutThere())) {
+                    getQxFrontlineAgentList = getQxFrontlineAgentList.stream()
+                            .filter(agent -> new BigDecimal(agent.getTotalPremium()).compareTo(BigDecimal.ZERO) > 0)
+                            .collect(Collectors.toList());
+                } else {
+                    getQxFrontlineAgentList = getQxFrontlineAgentList.stream()
+                            .filter(agent -> new BigDecimal(agent.getTotalPremium()).compareTo(BigDecimal.ZERO) == 0)
+                            .collect(Collectors.toList());
+                }
+            }
+            resultPage.setTotalSize(getQxFrontlineAgentList.size());
+
+            getQxFrontlineAgentList.sort((dto1, dto2) -> {
+                BigDecimal premium1 = new BigDecimal(dto1.getTotalPremium());
+                BigDecimal premium2 = new BigDecimal(dto2.getTotalPremium());
+                return premium2.compareTo(premium1); // 降序排序
+            });
+
+            int fromIndex = (qxFrontlineAgentVo.getPageNum() - 1) * qxFrontlineAgentVo.getPageSize();  //创建分页数据
+            int toIndex = Math.min(fromIndex + qxFrontlineAgentVo.getPageSize(), getQxFrontlineAgentList.size());
+            List<QxFrontlineAgentDto> qxFrontlineAgentDtos = getQxFrontlineAgentList.subList(fromIndex, toIndex);
+            for (QxFrontlineAgentDto dto : qxFrontlineAgentDtos) {
+                String deptId = dto.getDeptId();
+                if(StringUtils.isNotEmpty(deptId)){
+                    int length = deptId.length();
+                    if (length > 0) {
+                        if (length > 10) {
+                            String substring = deptId.substring(0, 6);
+                            String substring1 = deptId.substring(0, 8);
+                            String province = deptId.substring(0, 4);
+                            String storeDept = deptId.substring(0, 11);
+                            SysDept cityName = sysDeptService.getById(substring);
+                            SysDept districtName = sysDeptService.getById(substring1);
+                            SysDept provinceName = sysDeptService.getById(province);
+                            SysDept storeDeptEntity = sysDeptService.getById(storeDept);
+                            String deptName = dto.getDeptName();
+                            String a = provinceName.getName()+"-"+cityName.getName()+"-"+districtName.getName()+"-"+storeDeptEntity.getName()+"-"+deptName;
+                            dto.setDeptName(a);
+                        }
+                    }
+                }
             }
-            return HttpResult.ok(sysUserListPage);
+            resultPage.setContent(qxFrontlineAgentDtos);
+            resultPage.setPageNum(qxFrontlineAgentVo.getPageNum());
+            resultPage.setPageSize(qxFrontlineAgentVo.getPageSize());
+            resultPage.setTotalPages(qxFrontlineAgentDtos.size());
+            return HttpResult.ok(resultPage);
         } catch (Exception e) {
             e.printStackTrace();
             return HttpResult.error("查询异常");
@@ -285,25 +332,25 @@ public class UserReportServiceImpl implements UserReportService {
             userItem.setTotalPremium(orderManpower.getTotalPremium());
             //单均保费
             userItem.setAveragePremium(orderManpower.getAveragePremium());
-            String deptId = userItem.getDeptId();
-            if(StringUtils.isNotEmpty(deptId)){
-                int length = deptId.length();
-                if (length > 0) {
-                    if (length > 10) {
-                        String substring = deptId.substring(0, 6);
-                        String substring1 = deptId.substring(0, 8);
-                        String province = deptId.substring(0, 4);
-                        String storeDept = deptId.substring(0, 11);
-                        SysDept cityName = sysDeptService.getById(substring);
-                        SysDept districtName = sysDeptService.getById(substring1);
-                        SysDept provinceName = sysDeptService.getById(province);
-                        SysDept storeDeptEntity = sysDeptService.getById(storeDept);
-                        String deptName = userItem.getDeptName();
-                        String a = provinceName.getName()+"-"+cityName.getName()+"-"+districtName.getName()+"-"+storeDeptEntity.getName()+"-"+deptName;
-                        userItem.setDeptName(a);
-                    }
-                }
-            }
+//            String deptId = userItem.getDeptId();
+//            if(StringUtils.isNotEmpty(deptId)){
+//                int length = deptId.length();
+//                if (length > 0) {
+//                    if (length > 10) {
+//                        String substring = deptId.substring(0, 6);
+//                        String substring1 = deptId.substring(0, 8);
+//                        String province = deptId.substring(0, 4);
+//                        String storeDept = deptId.substring(0, 11);
+//                        SysDept cityName = sysDeptService.getById(substring);
+//                        SysDept districtName = sysDeptService.getById(substring1);
+//                        SysDept provinceName = sysDeptService.getById(province);
+//                        SysDept storeDeptEntity = sysDeptService.getById(storeDept);
+//                        String deptName = userItem.getDeptName();
+//                        String a = provinceName.getName()+"-"+cityName.getName()+"-"+districtName.getName()+"-"+storeDeptEntity.getName()+"-"+deptName;
+//                        userItem.setDeptName(a);
+//                    }
+//                }
+//            }
         }
     }
 
@@ -334,26 +381,6 @@ public class UserReportServiceImpl implements UserReportService {
                 item.setAveragePremium(taskStatisticsDto.getAveragePremium());
                 item.setTotalPremium(taskStatisticsDto.getTotalPremium());
             }
-            String deptId = item.getDeptId();
-            if(StringUtils.isNotEmpty(deptId)){
-                int length = deptId.length();
-                if (length > 0) {
-                    if (length > 10) {
-                        String substring = deptId.substring(0, 6);
-                        String substring1 = deptId.substring(0, 8);
-                        String province = deptId.substring(0, 4);
-                        String storeDept = deptId.substring(0, 11);
-                        SysDept cityName = sysDeptService.getById(substring);
-                        SysDept districtName = sysDeptService.getById(substring1);
-                        SysDept provinceName = sysDeptService.getById(province);
-                        SysDept storeDeptEntity = sysDeptService.getById(storeDept);
-                        String deptName = item.getDeptName();
-                        String a = provinceName.getName()+"-"+cityName.getName()+"-"+districtName.getName()+"-"+storeDeptEntity.getName()+"-"+deptName;
-                        item.setDeptName(a);
-
-                    }
-                }
-            }
         }
     }
 

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

@@ -1425,6 +1425,85 @@
         </where>
     </select>
 
+    <select id="getQxFrontlineAgentList" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
+        SELECT
+        sd.name as "deptName",
+        su.name as "name",
+        sd.id as "deptId",
+        su.id  as "userId",
+        su.mobile as "mobile",
+        su.dept_id  as "deptId",
+        inf.url  as "filePath",
+        sul.name as "leaderName",
+        sui.sex as "sex",
+        sur.role_id AS roleId
+        FROM
+        sys_user su
+        LEFT JOIN sys_dept sd ON sd.id = su.dept_id
+        LEFT JOIN  ins_upload_files   inf on  su.head_sculpture  =inf.id
+        LEFT JOIN sys_user_role sur ON sur.user_id = su.id
+        LEFT JOIN sys_user sul  on  sul.id=su.leader_id
+        LEFT JOIN sys_user_info  sui  on  sui .id =su.id
+        <where>
+            su.id  LIKE '%M%'
+            and su.status = '1'
+            <if test="vo.managementSource != null  and  vo.managementSource!='' ">
+                AND sd.management_source =#{vo.managementSource}
+            </if>
+            <choose>
+                <when  test='vo.managementSource == "2"'>
+                    and (sur.role_id = 20  or  sur.role_id = 21)
+                </when>
+                <when  test='vo.managementSource == "1"'>
+                    and (sur.role_id = 19  or  sur.role_id = 21)
+                </when>
+                <otherwise>
+                </otherwise>
+            </choose>
+            <if test="vo.provinceId != null and vo.provinceId != ''">
+                and sd.id like  concat('%',#{vo.provinceId},'%')
+            </if>
+            <if test="vo.cityId != null and vo.cityId != ''">
+                and sd.id like concat('%',#{vo.cityId},'%')
+            </if>
+            <if test="vo.countyId != null and vo.countyId != ''">
+                and sd.id like concat('%',#{vo.countyId},'%')
+            </if>
+            <if test="vo.houseId != null and vo.houseId != ''">
+                and sd.id like concat('%',#{vo.houseId},'%')
+            </if>
+            <if test="vo.name != null and vo.name != ''">
+                and su.name   =#{vo.name}
+            </if>
+            <if test="vo.userCode != null and vo.userCode != ''">
+                and su.id   =#{vo.userCode}
+            </if>
+            <if test="vo.phoneNumber != null and vo.phoneNumber != ''">
+                and su.mobile   =#{vo.phoneNumber}
+            </if>
+            <if test="vo.leaderId != null and vo.leaderId != ''">
+                and su.leader_id   =#{vo.leaderId}
+            </if>
+            <if test="vo.leaderName != null and vo.leaderName != ''">
+                and su.leader_name   =#{vo.leaderName}
+            </if>
+
+            <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
+                AND sd.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 su.id  in
+                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
     <select id="getByIdsList" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
         SELECT
         su.name as "name",

+ 12 - 0
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -1647,6 +1647,18 @@
         GROUP BY
         io.userid
         ) a
+        <where>
+            <if test="vo.outThere  != null  and  vo.outThere!=''">
+                <choose>
+                    <when test=" vo.outThere == 0">
+                        AND IFNULL(a.orderAmount,0) = 0
+                    </when>
+                    <when test="vo.outThere == 1">
+                        AND IFNULL(a.orderAmount,0) > 0
+                    </when>
+                </choose>
+            </if>
+        </where>
         order by  sum( a.orderAmount ) desc
     </select>