Ver Fonte

1.控制台添加领导人查询

wuhp há 1 ano atrás
pai
commit
e8d0d24f22

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

@@ -93,5 +93,9 @@ public class QxFrontlineAgentVo implements Serializable {
     @ApiModelProperty(value = "部门ids")
     private List<String> deptIds;
 
+    @ApiModelProperty(value = "领导人Ids")
+    private List<String> leaderIds;
+
+
 
 }

+ 2 - 0
src/main/java/com/ydtech/modules/admin/model/vo/TaskStatisticsVo.java

@@ -137,5 +137,7 @@ public class TaskStatisticsVo implements Serializable {
 
     @ApiModelProperty("审核时间")
     private String audittime;
+    @ApiModelProperty(value = "管理人Ids")
+    private List<String> leaderIds;
 
 }

+ 45 - 0
src/main/java/com/ydtech/modules/admin/service/impl/TaskStatisticsServiceImpl.java

@@ -44,6 +44,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import static com.baomidou.mybatisplus.extension.toolkit.Db.list;
 
@@ -88,6 +89,16 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
      **/
     @Override
     public IPage<TaskStatisticsDto> queryPage(TaskStatisticsVo taskStatisticsVo) {
+        String leaderId = taskStatisticsVo.getLeaderId();
+        if(com.ydtech.utils.StringUtils.isNotEmpty(leaderId)){
+            //获取领导人下级所有
+            List<String> ids = new ArrayList<>();
+            List<String> userList = this.getUserTreeHx(leaderId, ids);
+            userList.add(leaderId);
+            if(userList.size()>0){
+                taskStatisticsVo.setLeaderIds(userList);
+            }
+        }
         PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
         Page page = new Page(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
         page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
@@ -137,6 +148,19 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
         list.setTotal(total);
         return list;
     }
+
+    private List<String> getUserTreeHx(String leaderId, List<String> ids) {
+
+        List<SysUser> sysUsers = sysUserMapper.selectByLeadId(leaderId);
+        if (!sysUsers.isEmpty()) {
+            ids.addAll(sysUsers.stream().map(SysUser::getId).collect(Collectors.toList()));
+        }
+        for (SysUser sysUser : sysUsers) {
+            this.getUserTreeHx(sysUser.getId(), ids);
+        }
+        return ids;
+    }
+
     /**
      * @description:   保险公司统计查询
      * @author: whp
@@ -206,6 +230,16 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
      **/
     @Override
     public IPage<TaskStatisticsDto> agentStatisticsQueryPage(TaskStatisticsVo taskStatisticsVo) {
+        String leaderId = taskStatisticsVo.getLeaderId();
+        if(com.ydtech.utils.StringUtils.isNotEmpty(leaderId)){
+            //获取领导人下级所有
+            List<String> ids = new ArrayList<>();
+            List<String> userList = this.getUserTreeHx(leaderId, ids);
+            userList.add(leaderId);
+            if(userList.size()>0){
+                taskStatisticsVo.setLeaderIds(userList);
+            }
+        }
 
         PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
         Page page = new Page(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
@@ -346,6 +380,17 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
      **/
     @Override
     public IPage<TaskStatisticsDto> queryPageElectric(TaskStatisticsVo taskStatisticsVo) {
+        String leaderId = taskStatisticsVo.getLeaderId();
+        if(com.ydtech.utils.StringUtils.isNotEmpty(leaderId)){
+            //获取领导人下级所有
+            List<String> ids = new ArrayList<>();
+            List<String> userList = this.getUserTreeHx(leaderId, ids);
+            userList.add(leaderId);
+            if(userList.size()>0){
+                taskStatisticsVo.setLeaderIds(userList);
+            }
+        }
+
         PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
         Page page = new Page(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
         page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询

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

@@ -217,6 +217,17 @@ public class UserReportServiceImpl implements UserReportService {
     @Override
     public HttpResult<PageResult<QxFrontlineAgentDto>> queryQxFrontlineAgent(QxFrontlineAgentVo qxFrontlineAgentVo) {
         try {
+            String leaderId = qxFrontlineAgentVo.getLeaderId();
+            if(StringUtils.isNotEmpty(leaderId)){
+                //获取领导人下级所有
+                List<String> ids = new ArrayList<>();
+                List<String> userList = this.getUserTreeHx(leaderId, ids);
+                userList.add(leaderId);
+                if(userList.size()>0){
+                    qxFrontlineAgentVo.setLeaderIds(userList);
+                }
+            }
+
             PageResult<QxFrontlineAgentDto> resultPage = new PageResult<>();
 
             HashMap<String, String> map = getDateMapByType(qxFrontlineAgentVo.getDays(), qxFrontlineAgentVo.getCreatetimeStart(), qxFrontlineAgentVo.getCreatetimeEnd());
@@ -295,10 +306,33 @@ public class UserReportServiceImpl implements UserReportService {
         }
     }
 
+    private List<String> getUserTreeHx(String leaderId, List<String> ids) {
+
+        List<SysUser> sysUsers = sysUserMapper.selectByLeadId(leaderId);
+        if (!sysUsers.isEmpty()) {
+            ids.addAll(sysUsers.stream().map(SysUser::getId).collect(Collectors.toList()));
+        }
+        for (SysUser sysUser : sysUsers) {
+            this.getUserTreeHx(sysUser.getId(), ids);
+        }
+        return ids;
+    }
+
     @Override
     public HttpResult<HashMap<String, Integer>> getIssueNumber(QxFrontlineAgentVo qxFrontlineAgentVo) {
 
         try {
+            String leaderId = qxFrontlineAgentVo.getLeaderId();
+            if(StringUtils.isNotEmpty(leaderId)){
+                //获取领导人下级所有
+                List<String> ids = new ArrayList<>();
+                List<String> userList = this.getUserTreeHx(leaderId, ids);
+                userList.add(leaderId);
+                if(userList.size()>0){
+                    qxFrontlineAgentVo.setLeaderIds(userList);
+                }
+            }
+
             HashMap<String, Integer> resultMap = new HashMap<>();
             HashMap<String, String> map = getDateMapByType(qxFrontlineAgentVo.getDays(), qxFrontlineAgentVo.getCreatetimeStart(), qxFrontlineAgentVo.getCreatetimeEnd());
             qxFrontlineAgentVo.setCreatetimeStart(map.get("startDate"));
@@ -333,6 +367,7 @@ 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());
@@ -342,6 +377,17 @@ public class UserReportServiceImpl implements UserReportService {
         qxFrontlineAgentVo.setCreatetimeStart(map.get("startDate"));
         qxFrontlineAgentVo.setCreatetimeEnd(map.get("endDate"));
 
+        String leaderId = qxFrontlineAgentVo.getLeaderId();
+        if(StringUtils.isNotEmpty(leaderId)){
+            //获取领导人下级所有
+            List<String> ids = new ArrayList<>();
+            List<String> userList = this.getUserTreeHx(leaderId, ids);
+            userList.add(leaderId);
+            if(userList.size()>0){
+                qxFrontlineAgentVo.setLeaderIds(userList);
+            }
+        }
+
         if (qxFrontlineAgentVo.getManagementSource().equals("1")) {// 渠道
             return  HttpResult.ok(userReportMapper.selectChannelPerson(page,qxFrontlineAgentVo));
         } else if (qxFrontlineAgentVo.getManagementSource().equals("2")) {// 代理人

+ 11 - 2
src/main/resources/mapper/modules/admin/SysUserMapper.xml

@@ -1545,9 +1545,17 @@
             <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 test="vo.leaderId != null and vo.leaderId != ''">-->
+<!--                and su.leader_id   =#{vo.leaderId}-->
+<!--            </if>-->
+
+            <if test="vo.leaderIds != null and vo.leaderIds != '' and vo.leaderIds.size() > 0">
+                AND su.leader_id   in
+                <foreach collection="vo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
+
             <if test="vo.leaderName != null and vo.leaderName != ''">
                 and su.leader_name   =#{vo.leaderName}
             </if>
@@ -1949,6 +1957,7 @@
         <where>
             su.leader_id is not null
             AND su.id not LIKE '%M%'
+            AND su.status  ='1'
              <if test="leaderId !=null and  leaderId !=''">
                and  su.leader_id =#{leaderId}
              </if>

+ 20 - 4
src/main/resources/mapper/modules/console/userReportMapper.xml

@@ -76,9 +76,17 @@
             <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 test="vo.leaderId != null and vo.leaderId != ''">-->
+<!--                and u.leader_id =#{vo.leaderId}-->
+<!--            </if>-->
+
+            <if test="vo.leaderIds != null and vo.leaderIds != '' and vo.leaderIds.size() > 0">
+                AND u.leader_id   in
+                <foreach collection="vo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
+
             <if test="vo.leaderName != null and vo.leaderName != ''">
                 and u.leader_name =#{vo.leaderName}
             </if>
@@ -203,9 +211,17 @@
             <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 test="vo.leaderId != null and vo.leaderId != ''">-->
+<!--                and u.leader_id =#{vo.leaderId}-->
+<!--            </if>-->
+
+            <if test="vo.leaderIds != null and vo.leaderIds != '' and vo.leaderIds.size() > 0">
+                AND u.leader_id   in
+                <foreach collection="vo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
+
             <if test="vo.leaderName != null and vo.leaderName != ''">
                 and u.leader_name =#{vo.leaderName}
             </if>

+ 54 - 8
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -1155,8 +1155,15 @@
             <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
                 and su.name like concat('%',#{taskStatisticsVo.userName},'%')
             </if>
-            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
-                and su.leader_id  =#{taskStatisticsVo.leaderId}
+<!--            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
+<!--                and su.leader_id  =#{taskStatisticsVo.leaderId}-->
+<!--            </if>-->
+
+            <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
+                AND su.leader_id   in
+                <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
              <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
                 and su.id =#{taskStatisticsVo.userId}
@@ -1269,9 +1276,16 @@
             <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
                 and su.name like concat('%',#{taskStatisticsVo.userName},'%')
             </if>
-            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
-                and su.leader_id  =#{taskStatisticsVo.leaderId}
+<!--            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
+<!--                and su.leader_id  =#{taskStatisticsVo.leaderId}-->
+<!--            </if>-->
+            <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
+                AND su.leader_id   in
+                <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
+
              <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
                 and su.id =#{taskStatisticsVo.userId}
             </if>
@@ -1301,6 +1315,13 @@
                 and io.deptid like "${taskStatisticsVo.houseId}%"
             </if>
 
+            <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
+                AND su.leader_id   in
+                <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
             <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
                 AND   DATE_FORMAT( io.createtime, '%Y-%m-%d')   BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
             </if>
@@ -1358,6 +1379,7 @@
         ins_area_company iac
         LEFT JOIN ins_orders io ON io.orderno = iac.orderno
         LEFT JOIN sys_dept sd ON sd.id = io.deptid
+        left join  sys_user su  on su.id = io.userid
         <where>
             sd.management_source = '1'
             <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
@@ -1393,6 +1415,14 @@
                     #{item}
                 </foreach>
             </if>
+
+            <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
+                AND su.leader_id   in
+                <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
             <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
                 AND io.userid  in
                 <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
@@ -1612,8 +1642,16 @@
             <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
                 and su.leader_id  =#{taskStatisticsVo.leaderId}
             </if>
-            <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
-                and su.id =#{taskStatisticsVo.userId}
+<!--        -->
+<!--            <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>-->
+<!--                and su.id =#{taskStatisticsVo.userId}-->
+<!--            </if>-->
+
+            <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
+                AND su.leader_id   in
+                <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
 
             <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
@@ -1687,9 +1725,17 @@
             <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
                 and su.name like concat('%',#{taskStatisticsVo.userName},'%')
             </if>
-            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
-                and su.leader_id  =#{taskStatisticsVo.leaderId}
+<!--            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
+<!--                and su.leader_id  =#{taskStatisticsVo.leaderId}-->
+<!--            </if>-->
+
+            <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
+                AND su.leader_id   in
+                <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
+
             <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
                 and su.id =#{taskStatisticsVo.userId}
             </if>