Quellcode durchsuchen

登录人员查看数据过滤

helixiao vor 1 Jahr
Ursprung
Commit
3dbe69f8a1

+ 2 - 1
src/main/java/com/ydtech/modules/admin/controller/websocket/SysGeographyPositionController.java

@@ -7,6 +7,7 @@ import com.ydtech.modules.admin.model.SysGeographyPositionRecord;
 import com.ydtech.modules.admin.model.dto.*;
 import com.ydtech.modules.admin.model.vo.*;
 import com.ydtech.modules.admin.service.SysGeographyPositionService;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.utils.StringUtils;
 import io.swagger.annotations.Api;
@@ -22,7 +23,7 @@ import java.util.List;
 @RestController
 @RequestMapping("/geography")
 @Api(tags = "APP地理经纬度")
-public class SysGeographyPositionController {
+public class SysGeographyPositionController extends BaseController {
 
     @Resource
     private SysGeographyPositionService sysGeographyPositionService;

+ 4 - 4
src/main/java/com/ydtech/modules/admin/dao/SysGeographyPositionRecordMapper.java

@@ -23,13 +23,13 @@ import java.util.List;
 public interface SysGeographyPositionRecordMapper extends BaseMapper<SysGeographyPositionRecord> {
 
 
-    List<PcAddressHistoryTimeVo> getGeographyPosition(@Param("dates") String dates, @Param("source")String source);
+    List<PcAddressHistoryTimeVo> getGeographyPosition(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect);
 
-    List<SysGeographyPositionRecord> getGeographyPositionRecord(@Param("dates") String dates, @Param("source")String source);
+    List<SysGeographyPositionRecord> getGeographyPositionRecord(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect);
 
-    List<PcAddressHistoryTimeVo> getGeographyPositionSection(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source);
+    List<PcAddressHistoryTimeVo> getGeographyPositionSection(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect);
 
-    List<SysGeographyPositionRecord> getGeographyPositionHistory(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source);
+    List<SysGeographyPositionRecord> getGeographyPositionHistory(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect);
 
     IPage<SysGeographyPositionInfoVo> queryGeographyHistory(Page page, @Param("dto")  PcAddressInfoDto addressInfoDto);
 }

+ 4 - 4
src/main/java/com/ydtech/modules/admin/dao/SysPcAddressHistoryMapper.java

@@ -18,13 +18,13 @@ import java.util.List;
 */
 public interface SysPcAddressHistoryMapper extends BaseMapper<SysPcAddressHistory> {
 
-    List<PcAddressHistoryTimeVo> getPcAddress(@Param("dates") String dates, @Param("source")String source);
+    List<PcAddressHistoryTimeVo> getPcAddress(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect);
 
-    List<SysPcAddressHistory> getPcAddressInfo(@Param("dates") String dates, @Param("source") String source);
+    List<SysPcAddressHistory> getPcAddressInfo(@Param("dates") String dates, @Param("source") String source,@Param("collect") List<String> collect);
 
-    List<PcAddressHistoryTimeVo> getPcAddressSection(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source);
+    List<PcAddressHistoryTimeVo> getPcAddressSection(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect);
 
-    List<SysPcAddressHistory> getPcAddressHistory(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source);
+    List<SysPcAddressHistory> getPcAddressHistory(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect);
 
     IPage<SysPcAddressHistory> queryAddressHistory(Page page, @Param("dto") PcAddressInfoDto addressInfoDto);
 }

+ 8 - 0
src/main/java/com/ydtech/modules/admin/model/dto/PcAddressInfoDto.java

@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.util.List;
+
 @Data
 @ApiModel(value = "经纬度筛选")
 public class PcAddressInfoDto {
@@ -46,5 +48,11 @@ public class PcAddressInfoDto {
     @ApiModelProperty("类型:1。机构 2.用户")
     private Integer type;
 
+    @ApiModelProperty("用户下属id集合")
+    private List<String> collectIds;
+
+    @ApiModelProperty("用户树单个用户查询的下属id集合")
+    private List<String> collect;
+
 
 }

+ 175 - 21
src/main/java/com/ydtech/modules/admin/service/impl/SysGeographyPositionServiceImpl.java

@@ -22,6 +22,7 @@ import com.ydtech.modules.admin.service.GeoService;
 import com.ydtech.modules.admin.service.SysGeographyPositionRecordService;
 import com.ydtech.modules.admin.service.SysGeographyPositionService;
 import com.ydtech.modules.admin.service.SysUserService;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.utils.StringUtils;
 import org.springframework.stereotype.Service;
@@ -59,6 +60,18 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     @Override
     public SysGeographyPositionVo queryPosition(SysGeographyPositionDto sysGeographyPositionDto) {
         SysGeographyPositionVo sysGeographyPositionVo = new SysGeographyPositionVo();
+        String userId = BaseController.getUserId();
+        List<String> collectIds = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            List<String> arrayList = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, userId).ne(SysUser::getStatus, 0));
+            collectIds = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collectIds.size() == 0) return sysGeographyPositionVo;
+            List<String> idList = queryList(collectIds, arrayList);
+            collectIds.addAll(idList);
+
+        }
         // 类型:1。机构 2.用户
         Integer type = sysGeographyPositionDto.getType();
 
@@ -68,6 +81,7 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                     .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
+                    .in(CollectionUtil.isNotEmpty(collectIds), SysGeographyPosition::getId, collectIds)
                     .likeRight(StringUtils.isNotEmpty(sysGeographyPositionDto.getQueryId()), SysGeographyPosition::getId, sysGeographyPositionDto.getQueryId())
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
                     .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus())
@@ -106,6 +120,7 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                     .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
                     .in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect)
+                    .in(CollectionUtil.isNotEmpty(collectIds), SysGeographyPosition::getId, collectIds)
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
                     .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus())
                     .orderByDesc(SysGeographyPosition::getCreateTime));
@@ -130,12 +145,12 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
 
 
         }else {
-
             List<SysGeographyPosition> list = sysGeographyPositionMapper.selectList(new LambdaQueryWrapper<SysGeographyPosition>()
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                     .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
+                    .in(CollectionUtil.isNotEmpty(collectIds), SysGeographyPosition::getId, collectIds)
                     .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
                     .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus())
                     .orderByDesc(SysGeographyPosition::getCreateTime));
@@ -296,29 +311,46 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     public SysPcAddressNumVo queryPcNum(SysGeographyPositionDto sysGeographyPositionDto) {
         SysPcAddressNumVo sysPcAddressNumVo = new SysPcAddressNumVo();
 
+        String userId = BaseController.getUserId();
+        List<String> collect = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, userId).ne(SysUser::getStatus, 0));
+            collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) return sysPcAddressNumVo;
+            List<String> idList = queryList(collect, ids);
+            collect.addAll(idList);
+
+        }
+
         Long all = sysGeographyPositionMapper.selectCount(new LambdaQueryWrapper<SysGeographyPosition>()
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                 .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
+                .in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect)
                 .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus()));
         Long channelNum = sysGeographyPositionMapper.selectCount(new LambdaQueryWrapper<SysGeographyPosition>()
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                 .eq(SysGeographyPosition::getSource, 1)
+                .in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect)
                 .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus()));
         Long proxyNum = sysGeographyPositionMapper.selectCount(new LambdaQueryWrapper<SysGeographyPosition>()
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                 .eq(SysGeographyPosition::getSource, 2)
+                .in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect)
                 .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus()));
         Long onlineNum = sysGeographyPositionMapper.selectCount(new LambdaQueryWrapper<SysGeographyPosition>()
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                 .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
+                .in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect)
                 .eq(sysGeographyPositionDto.getStatus() == null, SysGeographyPosition::getStatus, 1)
                 .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus()));
         sysPcAddressNumVo.setAllNum(all);
@@ -333,12 +365,27 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     @Override
     public List<RegionInfoVo> queryRegionInfo(SysGeographyPositionDto sysGeographyPositionDto) {
         List<RegionInfoVo> regionInfoVos = new ArrayList<>();
+        //admin 可看所有,其他下只能看下面管理的人员
+        String userId = BaseController.getUserId();
+        List<String> collect = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, userId).ne(SysUser::getStatus, 0));
+            collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) return regionInfoVos;
+            List<String> idList = queryList(collect, ids);
+            collect.addAll(idList);
+
+        }
+
         //全部:null  渠道:1 代理:2
         List<SysGeographyPosition> sysGeographyPositionList = sysGeographyPositionMapper.selectList(new LambdaQueryWrapper<SysGeographyPosition>()
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
                 .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
+                .in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect)
                 .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
                 .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus()));
 
@@ -396,23 +443,75 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     @Override
     public BasePageResult<SysGeographyPositionInfoVo> queryPcAddressInfo(PcAddressInfoDto addressInfoDto) {
         Page<SysGeographyPosition> page = new Page<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize());
+        //admin 可看所有,其他下只能看下面管理的人员
+        String userId = BaseController.getUserId();
+        List<String> collectIds = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, userId).ne(SysUser::getStatus, 0));
+            collectIds = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collectIds.size() > 0) {
+                List<String> idList = queryList(collectIds, ids);
+                collectIds.addAll(idList);
+            }
 
-        LambdaQueryWrapper<SysGeographyPosition> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLng()), SysGeographyPosition::getLongitude, addressInfoDto.getLng());
-        wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysGeographyPosition::getLatitude, addressInfoDto.getLat());
-        wrapper.in(SysGeographyPosition::getSource, Arrays.asList("1", "2"));
-        wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysGeographyPosition::getSource, addressInfoDto.getSource());
-        wrapper.orderByDesc(SysGeographyPosition::getCreateTime);
+        }
+        Page<SysGeographyPosition> insOrdersPage = null;
+        Integer type = addressInfoDto.getType();
+        if (type == 1) {
+            LambdaQueryWrapper<SysGeographyPosition> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLng()), SysGeographyPosition::getLongitude, addressInfoDto.getLng());
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysGeographyPosition::getLatitude, addressInfoDto.getLat());
+            wrapper.in(SysGeographyPosition::getSource, Arrays.asList("1", "2"));
+            wrapper.in(CollectionUtil.isNotEmpty(collectIds), SysGeographyPosition::getId, collectIds);
+            wrapper.likeRight(StringUtils.isNotEmpty(addressInfoDto.getQueryId()), SysGeographyPosition::getId, addressInfoDto.getQueryId());
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysGeographyPosition::getSource, addressInfoDto.getSource());
+            wrapper.orderByDesc(SysGeographyPosition::getCreateTime);
+            insOrdersPage = page(page, wrapper);
+
+        }else if (type == 2) {
+            //查询人员下属管理所有人员
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, addressInfoDto.getQueryId()).ne(SysUser::getStatus, 0));
+            List<String> collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() > 0) {
+                List<String> idList = queryList(collect, ids);
+                collect.addAll(idList);
+            }
+
+            LambdaQueryWrapper<SysGeographyPosition> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLng()), SysGeographyPosition::getLongitude, addressInfoDto.getLng());
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysGeographyPosition::getLatitude, addressInfoDto.getLat());
+            wrapper.in(SysGeographyPosition::getSource, Arrays.asList("1", "2"));
+            wrapper.in(CollectionUtil.isNotEmpty(collectIds), SysGeographyPosition::getId, collectIds);
+            wrapper.in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect);
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysGeographyPosition::getSource, addressInfoDto.getSource());
+            wrapper.orderByDesc(SysGeographyPosition::getCreateTime);
+            insOrdersPage = page(page, wrapper);
+
+        }else {
+
+            LambdaQueryWrapper<SysGeographyPosition> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLng()), SysGeographyPosition::getLongitude, addressInfoDto.getLng());
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysGeographyPosition::getLatitude, addressInfoDto.getLat());
+            wrapper.in(SysGeographyPosition::getSource, Arrays.asList("1", "2"));
+            wrapper.in(CollectionUtil.isNotEmpty(collectIds), SysGeographyPosition::getId, collectIds);
+            wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysGeographyPosition::getSource, addressInfoDto.getSource());
+            wrapper.orderByDesc(SysGeographyPosition::getCreateTime);
+
+            insOrdersPage = page(page, wrapper);
+        }
 
-        Page<SysGeographyPosition> insOrdersPage = page(page, wrapper);
         List<SysGeographyPosition> records = insOrdersPage.getRecords();
 
         List<SysGeographyPositionInfoVo> sysGeographyPositionList = BeanUtil.copyToList(records, SysGeographyPositionInfoVo.class);
         //填充机构名
         for (SysGeographyPositionInfoVo sysGeographyPositionInfoVo : sysGeographyPositionList) {
             SysUser sysUser = sysUserService.getById(sysGeographyPositionInfoVo.getId());
-            sysGeographyPositionInfoVo.setLeaderName(sysUser.getLeaderName());
             if (sysUser == null) continue;
+            sysGeographyPositionInfoVo.setLeaderName(sysUser.getLeaderName());
             SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
                     .eq(SysDept::getId, sysUser.getDeptId()).eq(SysDept::getDelFlag, 0));
             if (sysDept == null) continue;
@@ -429,16 +528,54 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     @Override
     public BasePageResult<SysGeographyPositionInfoVo> queryGeographyRecord(PcAddressInfoDto addressInfoDto) {
         Page page = new Page(addressInfoDto.getPageNum(), addressInfoDto.getPageSize());
-        IPage<SysGeographyPositionInfoVo> sysGeographyPositionList = sysGeographyPositionRecordMapper.queryGeographyHistory(page,addressInfoDto);
+        IPage<SysGeographyPositionInfoVo> sysGeographyPositionList =null;
+        //登陆人的下属id
+        String userId = BaseController.getUserId();
+        List<String> collectIds =new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            //admin看所有人
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, BaseController.getUserId()).ne(SysUser::getStatus, 0));
+            collectIds = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collectIds .size()==0)  return new BasePageResult<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize(), 0l, 0l, null);
+            List<String> idList = queryList(collectIds, ids);
+            collectIds.addAll(idList);
+
+        }
+        addressInfoDto.setCollectIds(collectIds);
+        // 类型:1。机构树 2.用户树 0:默认查询
+        Integer type = addressInfoDto.getType();
+        if (type == 1) {
+            sysGeographyPositionList = sysGeographyPositionRecordMapper.queryGeographyHistory(page,addressInfoDto);
+
+        }else if (type == 2) {
+
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, addressInfoDto.getQueryId()).ne(SysUser::getStatus, 0));
+            List<String>  collect= sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size()>0) {
+                List<String> idList = queryList(collect, ids);
+                collect.addAll(idList);
+            }
+            addressInfoDto.setQueryId(null);
+            addressInfoDto.setCollect(collect);
+
+            sysGeographyPositionList = sysGeographyPositionRecordMapper.queryGeographyHistory(page,addressInfoDto);
+        }else {
+
+            sysGeographyPositionList = sysGeographyPositionRecordMapper.queryGeographyHistory(page,addressInfoDto);
+        }
+
         List<SysGeographyPositionInfoVo> records = sysGeographyPositionList.getRecords();
         //填充机构名
         for (SysGeographyPositionInfoVo sysGeographyPositionInfoVo : records) {
             SysUser sysUser = sysUserService.getById(sysGeographyPositionInfoVo.getUserId());
             if (sysUser == null) continue;
-            SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
-                    .eq(SysDept::getId, sysUser.getDeptId()).eq(SysDept::getDelFlag, 0));
-            if (sysDept == null) continue;
-            sysGeographyPositionInfoVo.setDeptName(sysDept.getName());
+            String deptName = getDeptName(sysUser.getDeptId());
+//            sysGeographyPositionInfoVo.setDeptName(sysDept.getName());
+            sysGeographyPositionInfoVo.setDeptName(deptName);
         }
 
         return new BasePageResult<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize(), sysGeographyPositionList.getTotal(), sysGeographyPositionList.getPages(),
@@ -448,6 +585,20 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     @Override
     public AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source) {
         AppGeographyHistoryInfoVo appGeographyHistoryInfoVo = new AppGeographyHistoryInfoVo();
+        //admin 可看所有,其他下只能看下面管理的人员
+        String userId = BaseController.getUserId();
+        List<String> collect = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, userId).ne(SysUser::getStatus, 0));
+            collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) return appGeographyHistoryInfoVo;
+            List<String> idList = queryList(collect, ids);
+            collect.addAll(idList);
+
+        }
+
         if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
 
             if (StringUtils.isNullOrEmpty(startTime)) {
@@ -460,14 +611,15 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
             queryWrapper.select("COUNT(DISTINCT user_id) AS total")
                     .likeRight(StringUtils.isNotEmpty(startTime), "create_time", startTime)
                     .in("source", Arrays.asList(1, 2))
+                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
                     .eq(StringUtils.isNotEmpty(source),"source",source);;
             Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
             Long total = (Long) result.get("total");
             appGeographyHistoryInfoVo.setOnlineNum(total);
-            List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(startTime,source);
+            List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(startTime,source,collect);
             appGeographyHistoryInfoVo.setList(geographyPosition);
 
-            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source);
+            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect);
             extracted(sysGeographyPositionRecords);
             System.out.println("********************" + sysGeographyPositionRecords.size());
             appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
@@ -490,15 +642,16 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
             queryWrapper.select("COUNT(DISTINCT user_id) AS total")
                     .between("create_time", startTime, endTime)
                     .in("source", Arrays.asList(1, 2))
+                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
                     .eq(StringUtils.isNotEmpty(source),"source",source);;
             Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
             Long total = (Long) result.get("total");
             appGeographyHistoryInfoVo.setOnlineNum(total);
 
-            List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPositionSection(startTime,endTime,source);
+            List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPositionSection(startTime,endTime,source,collect);
             appGeographyHistoryInfoVo.setList(geographyPosition);
 
-            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source);
+            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect);
             extracted(sysGeographyPositionRecords);
             System.out.println("********************" + sysGeographyPositionRecords.size());
             appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
@@ -514,9 +667,10 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
             SysUser sysUser = sysUserService.getById(sysGeographyPositionRecord.getUserId());
             if (sysUser == null) continue;
             sysGeographyPositionRecord.setLeaderName(sysUser.getLeaderName());
-            SysDept sysDept = sysDeptMapper.selectById(sysUser.getDeptId());
-            if (sysDept == null) continue;
-            sysGeographyPositionRecord.setDeptName(sysDept.getName());
+//            SysDept sysDept = sysDeptMapper.selectById(sysUser.getDeptId());
+//            if (sysDept == null) continue;
+            String deptName = getDeptName(sysUser.getDeptId());
+            sysGeographyPositionRecord.setDeptName(deptName);
 
 
         }

+ 154 - 42
src/main/java/com/ydtech/modules/admin/service/impl/SysPcAddressServiceImpl.java

@@ -94,6 +94,19 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     @Override
     public List<SysPcAddress> getEveryone(SysPcAddressDto sysPcAddressDto) {
         List<SysPcAddress> sysPcAddresses = null;
+        List<String> arrayList = new ArrayList<>();
+        List<String> collectIds = new ArrayList<>();
+        //admin看所有
+        if (!"admin".equals(BaseController.getUserId())) {
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, BaseController.getUserId()).ne(SysUser::getStatus, 0));
+            collectIds = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collectIds.size() > 0) {
+                List<String> idList = queryList(collectIds, arrayList);
+                collectIds.addAll(idList);
+            }
+
+        }
         // 类型:1。机构 2.用户
         if (sysPcAddressDto.getType() == 1) {
 
@@ -102,37 +115,41 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                     .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
+                    .in(CollectionUtil.isNotEmpty(collectIds), SysPcAddress::getUserId, collectIds)
                     .likeRight(StringUtils.isNotEmpty(sysPcAddressDto.getQueryId()), SysPcAddress::getUserId, sysPcAddressDto.getQueryId())
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
                     .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus())
                     .orderByDesc(SysPcAddress::getOperationTime));
 
         } else if (sysPcAddressDto.getType() == 2) {
+            List<String> ids = new ArrayList<>();
             List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
                     .eq(SysUser::getLeaderId, sysPcAddressDto.getQueryId()).ne(SysUser::getStatus, 0));
             List<String> collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
-            List<String> ids = new ArrayList<>();
-            List<String> idList = queryList(collect, ids);
-            collect.addAll(idList);
             if (collect.size() == 0) {
                 return sysPcAddresses;
             }
+            List<String> idList = queryList(collect, ids);
+            collect.addAll(idList);
             sysPcAddresses = sysPcAddressMapper.selectList(new LambdaQueryWrapper<SysPcAddress>()
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                     .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
+                    .in(CollectionUtil.isNotEmpty(collectIds), SysPcAddress::getUserId, collectIds)
                     .in(CollectionUtil.isNotEmpty(collect), SysPcAddress::getUserId, collect)
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
                     .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus())
                     .orderByDesc(SysPcAddress::getOperationTime));
 
         } else {
+
             sysPcAddresses = sysPcAddressMapper.selectList(new LambdaQueryWrapper<SysPcAddress>()
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                     .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
+                    .in(CollectionUtil.isNotEmpty(collectIds), SysPcAddress::getUserId, collectIds)
                     .eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
                     .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus())
                     .orderByDesc(SysPcAddress::getOperationTime));
@@ -148,19 +165,6 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     }
 
     private List<String> queryList(List<String> collect, List<String> ids) {
-//        if (collect.size() > 0) {
-//            for (String id : collect) {
-//                List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
-//                        .eq(SysUser::getLeaderId, id).ne(SysUser::getStatus, 0));
-//                if (sysUsers.size() > 0) {
-//                    List<String> list = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
-//                    ids.addAll(list);
-//                    queryList(list, ids);
-//
-//                }
-//            }
-//
-//        }
         int size = collect.size();
         if (size > 0) {
             List<String> strings = new ArrayList<>();
@@ -197,23 +201,37 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     @Override
     public SysPcAddressNumVo queryPcNum(SysPcAddressDto sysPcAddressDto) {
         SysPcAddressNumVo sysPcAddressNumVo = new SysPcAddressNumVo();
-
+        String userId = BaseController.getUserId();
+        List<String> collect = new ArrayList<>();
+        //admin看所有人
+        if (!"admin".equals(userId)) {
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, BaseController.getUserId()).ne(SysUser::getStatus, 0));
+            collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) return sysPcAddressNumVo;
+            List<String> idList = queryList(collect, ids);
+            collect.addAll(idList);
+        }
         //区域数量统计
         Long all = sysPcAddressMapper.selectCount(new LambdaQueryWrapper<SysPcAddress>()
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
+                .in(CollectionUtil.isNotEmpty(collect), SysPcAddress::getUserId, collect)
                 .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
         Long channelNum = sysPcAddressMapper.selectCount(new LambdaQueryWrapper<SysPcAddress>()
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .eq(SysPcAddress::getSource, 1)
+                .in(CollectionUtil.isNotEmpty(collect), SysPcAddress::getUserId, collect)
                 .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
         Long proxyNum = sysPcAddressMapper.selectCount(new LambdaQueryWrapper<SysPcAddress>()
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
+                .in(CollectionUtil.isNotEmpty(collect), SysPcAddress::getUserId, collect)
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .eq(SysPcAddress::getSource, 2)
                 .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
@@ -223,6 +241,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
+                .in(CollectionUtil.isNotEmpty(collect), SysPcAddress::getUserId, collect)
                 .eq(sysPcAddressDto.getStatus() == null, SysPcAddress::getStatus, 1)
                 .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
 
@@ -238,12 +257,28 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     @Override
     public List<RegionInfoVo> queryRegionInfo(SysPcAddressDto sysPcAddressDto) {
         List<RegionInfoVo> regionInfoVos = new ArrayList<>();
+        //admin 看所有,其他人看自己下属的人员信息
+        String userId = BaseController.getUserId();
+        List<String> collect = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+
+            //admin看所有人
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, BaseController.getUserId()).ne(SysUser::getStatus, 0));
+            collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) return regionInfoVos;
+            List<String> idList = queryList(collect, ids);
+            collect.addAll(idList);
+        }
+
         //全部:null   渠道:1 代理:2
         List<SysPcAddress> sysPcAddresses = sysPcAddressMapper.selectList(new LambdaQueryWrapper<SysPcAddress>()
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
+                .in(CollectionUtil.isNotEmpty(collect), SysPcAddress::getUserId, collect)
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
                 .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
 
@@ -276,6 +311,19 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     @Override
     public BasePageResult<SysPcAddress> queryPcAddressInfo(PcAddressInfoDto addressInfoDto) {
         Page<SysPcAddress> page = new Page<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize());
+        List<String> arrayList = new ArrayList<>();
+        List<String> collectIds = new ArrayList<>();
+        //admin看所有
+        if (!"admin".equals(BaseController.getUserId())) {
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, BaseController.getUserId()).ne(SysUser::getStatus, 0));
+            collectIds = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collectIds.size() > 0) {
+                List<String> idList = queryList(collectIds, arrayList);
+                collectIds.addAll(idList);
+            }
+
+        }
         Page<SysPcAddress> insOrdersPage = null;
         // 类型:1。机构 2.用户
         if (addressInfoDto.getType() == 1) {
@@ -284,6 +332,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysPcAddress::getLatitude, addressInfoDto.getLat());
             wrapper.in(SysPcAddress::getSource, Arrays.asList("1", "2"));
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysPcAddress::getSource, addressInfoDto.getSource());
+            wrapper.in(CollectionUtil.isNotEmpty(collectIds), SysPcAddress::getUserId, collectIds);
             wrapper.likeRight(StringUtils.isNotEmpty(addressInfoDto.getQueryId()), SysPcAddress::getUserId, addressInfoDto.getQueryId());
             wrapper.eq(addressInfoDto.getStatus() != null, SysPcAddress::getStatus, addressInfoDto.getStatus());
             wrapper.orderByDesc(SysPcAddress::getOperationTime);
@@ -295,7 +344,8 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
                     .eq(SysUser::getLeaderId, addressInfoDto.getQueryId()).ne(SysUser::getStatus, 0));
             List<String> collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
-            if (collect.size() == 0) return new BasePageResult<>(addressInfoDto.getPageNum(), page.getSize(), insOrdersPage.getTotal(), page.getPages(),
+            if (collect.size() == 0)
+                return new BasePageResult<>(addressInfoDto.getPageNum(), page.getSize(), insOrdersPage.getTotal(), page.getPages(),
                         insOrdersPage.getRecords());
 
             List<String> idList = queryList(collect, ids);
@@ -305,6 +355,8 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLng()), SysPcAddress::getLongitude, addressInfoDto.getLng());
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysPcAddress::getLatitude, addressInfoDto.getLat());
             wrapper.in(SysPcAddress::getSource, Arrays.asList("1", "2"));
+            wrapper.in(CollectionUtil.isNotEmpty(collectIds), SysPcAddress::getUserId, collectIds);
+            wrapper.in(CollectionUtil.isNotEmpty(collect), SysPcAddress::getUserId, collect);
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysPcAddress::getSource, addressInfoDto.getSource());
             wrapper.eq(addressInfoDto.getStatus() != null, SysPcAddress::getStatus, addressInfoDto.getStatus());
             wrapper.orderByDesc(SysPcAddress::getOperationTime);
@@ -316,6 +368,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLng()), SysPcAddress::getLongitude, addressInfoDto.getLng());
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysPcAddress::getLatitude, addressInfoDto.getLat());
             wrapper.in(SysPcAddress::getSource, Arrays.asList("1", "2"));
+            wrapper.in(CollectionUtil.isNotEmpty(collectIds), SysPcAddress::getUserId, collectIds);
             wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysPcAddress::getSource, addressInfoDto.getSource());
             wrapper.eq(addressInfoDto.getStatus() != null, SysPcAddress::getStatus, addressInfoDto.getStatus());
             wrapper.orderByDesc(SysPcAddress::getOperationTime);
@@ -330,6 +383,20 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     @Override
     public PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source) {
         PcAddressHistoryInfoVo pcAddressHistoryInfoVo = new PcAddressHistoryInfoVo();
+        //admin 看所有,其他人看自己下属的人员信息
+        String userId = BaseController.getUserId();
+        List<String> collect = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            //admin看所有人
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, BaseController.getUserId()).ne(SysUser::getStatus, 0));
+            collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            List<String> idList = queryList(collect, ids);
+            collect.addAll(idList);
+        }
+
+
         if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
             if (StringUtils.isNullOrEmpty(startTime)) {
                 Date date = new Date();
@@ -341,15 +408,16 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             queryWrapper.select("COUNT(DISTINCT user_id) AS total")
                     .likeRight(StringUtils.isNotEmpty(startTime), "operation_time", startTime)
                     .in("source", Arrays.asList(1, 2))
+                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
                     .eq(StringUtils.isNotEmpty(source), "source", source);
             Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
             Long total = (Long) result.get("total");
             pcAddressHistoryInfoVo.setOnlineNum(total);
 
-            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime, source);
+            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime, source, collect);
             pcAddressHistoryInfoVo.setList(pcAddress);
 
-            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source);
+            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect);
             extracted(sysPcAddressHistories);
             System.out.println("********************" + sysPcAddressHistories.size());
             pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
@@ -371,16 +439,18 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
             // 指定 COUNT(DISTINCT user_id) 查询
             queryWrapper.select("COUNT(DISTINCT user_id) AS total").between("operation_time", startTime, endTime)
-                    .in("source", Arrays.asList(1, 2)).eq(StringUtils.isNotEmpty(source), "source", source);
+                    .in("source", Arrays.asList(1, 2))
+                    .eq(StringUtils.isNotEmpty(source), "source", source)
+                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect);
             Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
             Long total = (Long) result.get("total");
             pcAddressHistoryInfoVo.setOnlineNum(total);
 
-            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime, source);
+            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime, source, collect);
 
             pcAddressHistoryInfoVo.setList(pcAddress);
 
-            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source);
+            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect);
             extracted(sysPcAddressHistories);
             System.out.println("********************" + sysPcAddressHistories.size());
             pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
@@ -411,8 +481,46 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     @Override
     public BasePageResult<SysPcAddressHistory> queryPcAddressHistoryInfo(PcAddressInfoDto addressInfoDto) {
         Page page = new Page(addressInfoDto.getPageNum(), addressInfoDto.getPageSize());
+        IPage<SysPcAddressHistory> sysPcAddressHistoryIPage = null;
+        //登陆人的下属id
+        String userId = BaseController.getUserId();
+        List<String> collectIds = new ArrayList<>();
+        if (!"admin".equals(userId)) {
+            //admin看所有人
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, BaseController.getUserId()).ne(SysUser::getStatus, 0));
+            collectIds = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collectIds.size() == 0)
+                return new BasePageResult<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize(), 0l, 0l, null);
+            List<String> idList = queryList(collectIds, ids);
+            collectIds.addAll(idList);
+        }
+        addressInfoDto.setCollectIds(collectIds);
+        // 类型:1。机构树 2.用户树 0:默认查询
+        Integer type = addressInfoDto.getType();
+        if (type == 1) {
+
+            sysPcAddressHistoryIPage = sysPcAddressHistoryMapper.queryAddressHistory(page, addressInfoDto);
+        } else if (type == 2) {
+
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, addressInfoDto.getQueryId()).ne(SysUser::getStatus, 0));
+            List<String> collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() > 0) {
+                List<String> idList = queryList(collect, ids);
+                collect.addAll(idList);
+            }
+            addressInfoDto.setQueryId("");
+            addressInfoDto.setCollect(collect);
+            sysPcAddressHistoryIPage = sysPcAddressHistoryMapper.queryAddressHistory(page, addressInfoDto);
+
+        } else {
+
+            sysPcAddressHistoryIPage = sysPcAddressHistoryMapper.queryAddressHistory(page, addressInfoDto);
+        }
 
-        IPage<SysPcAddressHistory> sysPcAddressHistoryIPage = sysPcAddressHistoryMapper.queryAddressHistory(page, addressInfoDto);
 
         return new BasePageResult<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize(), sysPcAddressHistoryIPage.getTotal(), sysPcAddressHistoryIPage.getPages(),
                 sysPcAddressHistoryIPage.getRecords());
@@ -439,7 +547,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
         List<SysDeptTreeVo> resultDeptList = this.getFiveLevelDeptKzt(byUserId);
         kztUserDeptTreeDto.setDeptList(resultDeptList);
         if (!userId.contains("M")) {
-            if (sysDeptList1.size()==0) {
+            if (sysDeptList1.size() == 0) {
                 List<SysUser> resultList = this.getUserTreeHx(byUserId);
                 kztUserDeptTreeDto.setUserList(resultList);
             }
@@ -547,7 +655,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
         queryWrapper.isNotNull("leader_id");
         List<SysUser> userList = null;
         List<SysUser> users = sysUserMapper.selectList(queryWrapper);
-        if (users.size()>0) {
+        if (users.size() > 0) {
             //排除前线员工
             userList = users.stream().filter(SysUser -> !SysUser.getId().contains("M")).collect(Collectors.toList());
             //填充所属机构名称
@@ -569,11 +677,15 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
         }
         // 递归构建用户树结构
         buildUserTree(topUsers, userList);
+        //登陆人员无下属不展示
+//        SysUser sysUser1 = topUsers.get(0);
+//        if (sysUser1.getChildren().size() == 0) {
+//            return new ArrayList<>();
+//        }
         return topUsers;
     }
 
 
-
     private void buildUserTree(List<SysUser> topUsers, List<SysUser> users) {
         for (SysUser user : topUsers) {
             List<SysUser> children = new ArrayList<>();
@@ -596,70 +708,70 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             SysDept sysDept5 = sysDeptMapper.selectById(sysDept.getParentId());
             if (sysDept5 == null) {
                 stringBuilder.append(sysDept.getName());
-            }else {
+            } else {
                 SysDept sysDept4 = sysDeptMapper.selectById(sysDept5.getParentId());
                 if (sysDept4 == null) {
                     stringBuilder.append(sysDept5.getName()).append("-").append(sysDept.getName());
-                }else {
+                } else {
                     SysDept sysDept3 = sysDeptMapper.selectById(sysDept4.getParentId());
                     if (sysDept3 == null) {
                         stringBuilder.append(sysDept4.getName())
                                 .append("-").append(sysDept5.getName()).append("-").append(sysDept.getName());
-                    }else {
+                    } else {
                         SysDept sysDept2 = sysDeptMapper.selectById(sysDept3.getParentId());
                         if (sysDept2 == null) {
                             stringBuilder.append(sysDept3.getName()).append("-").append(sysDept4.getName())
                                     .append("-").append(sysDept5.getName()).append("-").append(sysDept.getName());
-                        }else {
+                        } else {
                             stringBuilder.append(sysDept2.getName()).append("-").append(sysDept3.getName())
                                     .append("-").append(sysDept4.getName()).append("-").append(sysDept5.getName()).append("-").append(sysDept.getName());
                         }
                     }
                 }
             }
-        }else if (sysDept.getComlevel().equals("5")) {
+        } else if (sysDept.getComlevel().equals("5")) {
             SysDept sysDept4 = sysDeptMapper.selectById(sysDept.getParentId());
             if (sysDept4 == null) {
                 stringBuilder.append(sysDept.getName());
-            }else {
+            } else {
                 SysDept sysDept3 = sysDeptMapper.selectById(sysDept4.getParentId());
                 if (sysDept3 == null) {
                     stringBuilder.append(sysDept4.getName()).append("-").append(sysDept.getName());
-                }else {
+                } else {
                     SysDept sysDept2 = sysDeptMapper.selectById(sysDept3.getParentId());
                     if (sysDept2 == null) {
                         stringBuilder.append(sysDept3.getName()).append("-").append(sysDept4.getName()).append("-").append(sysDept.getName());
-                    }else {
+                    } else {
                         stringBuilder.append(sysDept2.getName()).append("-").append(sysDept3.getName()).append("-").append(sysDept4.getName()).append("-").append(sysDept.getName());
                     }
                 }
             }
-        }else if (sysDept.getComlevel().equals("4")) {
+        } else if (sysDept.getComlevel().equals("4")) {
             SysDept sysDept3 = sysDeptMapper.selectById(sysDept.getParentId());
             if (sysDept3 == null) {
                 stringBuilder.append(sysDept.getName());
-            }else {
+            } else {
                 SysDept sysDept2 = sysDeptMapper.selectById(sysDept3.getParentId());
                 if (sysDept2 == null) {
                     stringBuilder.append(sysDept3.getName()).append("-").append(sysDept.getName());
-                }else {
+                } else {
                     stringBuilder.append(sysDept2.getName()).append("-").append(sysDept3.getName()).append("-").append(sysDept.getName());
                 }
             }
-        }else if (sysDept.getComlevel().equals("3")) {
+        } else if (sysDept.getComlevel().equals("3")) {
             SysDept sysDept2 = sysDeptMapper.selectById(sysDept.getParentId());
             if (sysDept2 == null) {
                 stringBuilder.append(sysDept.getName());
-            }else {
+            } else {
                 stringBuilder.append(sysDept2.getName()).append("-").append(sysDept.getName());
             }
 
-        }else if (sysDept.getComlevel().equals("2")) {
+        } else if (sysDept.getComlevel().equals("2")) {
             stringBuilder.append(sysDept.getName());
         }
         String s = stringBuilder.toString();
         if (s.contains("总部-")) {
-            stringBuilder.replace(0,3,"");
+            stringBuilder.replace(0, 3, "");
         }
 
 

+ 39 - 0
src/main/resources/mapper/modules/admin/SysGeographyPositionRecordMapper.xml

@@ -28,6 +28,12 @@
             <if test="source == null">
                 s.source in (1,2)
             </if>
+            <if test="collect !=null and collect.size()>0">
+                AND s.user_id  in
+                <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="dates != null and dates != ''">
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
             </if>
@@ -50,6 +56,12 @@
             <if test="source != null">
                 s.source = #{source}
             </if>
+            <if test="collect !=null and collect.size()>0">
+                AND s.user_id  in
+                <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="dates != null and dates != ''">
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
             </if>
@@ -73,6 +85,12 @@
             <if test="source == null">
                 s.source in (1,2)
             </if>
+            <if test="collect !=null and collect.size()>0">
+                AND s.user_id  in
+                <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 and (DATE_FORMAT(s.create_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and
                 DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
@@ -97,6 +115,12 @@
             <if test="source != null">
                 s.source = #{source}
             </if>
+            <if test="collect !=null and collect.size()>0">
+                AND s.user_id  in
+                <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 and (DATE_FORMAT(s.create_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and
                 DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
@@ -126,6 +150,21 @@
             <if test="dto.source == null">
                 and source in (1,2)
             </if>
+            <if test="dto.queryId != null and dto.queryId != ''">
+                and user_id like concat( #{dto.queryId},'%')
+            </if>
+            <if test="dto.collectIds !=null and dto.collectIds.size()>0">
+                and user_id  in
+                <foreach collection="dto.collectIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="dto.collect !=null and dto.collect.size()>0">
+                and user_id  in
+                <foreach collection="dto.collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''and dto.startTime != dto.endTime">
                 and (DATE_FORMAT(create_time, '%Y-%m-%d' ) between DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ) and
                 DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d' ))

+ 42 - 0
src/main/resources/mapper/modules/admin/SysPcAddressHistoryMapper.xml

@@ -35,6 +35,12 @@
                  <if test="source == null">
                      s.source in (1,2)
                  </if>
+                 <if test="collect !=null and collect.size()>0">
+                     AND s.user_id  in
+                     <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                         #{item}
+                     </foreach>
+                 </if>
                  <if test="dates != null and dates != ''">
                      and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                  </if>
@@ -61,6 +67,12 @@
             <if test="source == null ">
                 s.source in (1,2)
             </if>
+            <if test="collect !=null and collect.size()>0">
+                AND s.user_id  in
+                <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 and (DATE_FORMAT(s.operation_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
             </if>
@@ -85,6 +97,12 @@
             <if test="source == null">
                 s.source in (1,2)
             </if>
+            <if test="collect !=null and collect.size()>0">
+                AND s.user_id  in
+                <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 and (DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) between DATE_FORMAT( #{startTime}, '%Y-%m-%d' ) and DATE_FORMAT( #{endTime}, '%Y-%m-%d' ))
             </if>
@@ -107,6 +125,12 @@
                 <if test="source != null">
                     s.source = #{source}
                 </if>
+                <if test="collect !=null and collect.size()>0">
+                    AND s.user_id  in
+                    <foreach collection="collect" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </if>
                 <if test="dates != null and dates != ''">
                     and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                 </if>
@@ -135,6 +159,23 @@
             <if test="dto.source == null">
                 and source in (1,2)
             </if>
+
+            <if test="dto.collectIds !=null and dto.collectIds.size()>0">
+                and user_id  in
+                <foreach collection="dto.collectIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="dto.collect !=null and dto.collect.size()>0">
+                and user_id  in
+                <foreach collection="dto.collect" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="dto.queryId != null and dto.queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </if>
             <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''and dto.startTime != dto.endTime">
                 and (DATE_FORMAT(operation_time, '%Y-%m-%d' ) between DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ) and DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d' ))
             </if>
@@ -147,4 +188,5 @@
     </select>
 
 
+
 </mapper>