Parcourir la source

合伙人APP功能调整

helixiao il y a 1 an
Parent
commit
cf08c285a9

+ 14 - 14
src/main/java/com/ydtech/modules/admin/controller/APPPartnerController.java

@@ -31,7 +31,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP首页信息")
     public HttpResult<AppPartnerNumVo> getHomePage(@RequestParam("type") Integer type) {
 
-        return HttpResult.ok(this.sysPartnerService.getHomePage(type));
+        return HttpResult.ok("success", this.sysPartnerService.getHomePage(type));
     }
 
 
@@ -44,7 +44,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP个人信息")
     public HttpResult<AppUserInfoVo> getUserInfo(@RequestParam("type") Integer type) {
 
-        return HttpResult.ok(this.sysPartnerService.getUserInfo(type));
+        return HttpResult.ok("success",this.sysPartnerService.getUserInfo(type));
     }
 
     /**
@@ -56,7 +56,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP账户金额")
     public HttpResult<SysPartnerAccount> getFee() {
 
-        return HttpResult.ok(this.sysPartnerService.getFee());
+        return HttpResult.ok("success",this.sysPartnerService.getFee());
     }
 
 
@@ -69,7 +69,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP登陆人下的每个等级合伙人统计信息")
     public HttpResult<List<AppSysPartnerVo>> partnerInfo(@RequestBody PartnerInfoDto partnerInfoDto) {
 
-        return HttpResult.ok(this.sysPartnerService.partnerInfo(partnerInfoDto));
+        return HttpResult.ok("success",this.sysPartnerService.partnerInfo(partnerInfoDto));
     }
 
     /**
@@ -79,7 +79,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "合伙人工作室详情")
     public HttpResult<PartnerLeaderInfoVo> partnerLeaderInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
 
-        return HttpResult.ok(this.sysPartnerService.partnerLeaderInfo(partnerGradeInfo));
+        return HttpResult.ok("success",this.sysPartnerService.partnerLeaderInfo(partnerGradeInfo));
     }
 
 
@@ -91,7 +91,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "筛选合伙人详情")
     public HttpResult<FilterPartnerInfoVo> queryFilterPartnerInfo(@RequestBody FilterPartnerInfoDto filterPartnerInfoDto) {
 
-        return HttpResult.ok(this.sysPartnerService.queryFilterPartnerInfo(filterPartnerInfoDto));
+        return HttpResult.ok("success",this.sysPartnerService.queryFilterPartnerInfo(filterPartnerInfoDto));
     }
 
     /**
@@ -103,7 +103,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "等级合伙人详情")
     public HttpResult<PartnerInfoFreeVo> queryPartnerInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
 
-        return HttpResult.ok(this.sysPartnerService.queryPartnerInfo(partnerGradeInfo));
+        return HttpResult.ok("success",this.sysPartnerService.queryPartnerInfo(partnerGradeInfo));
     }
 
 
@@ -114,14 +114,14 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "查看机构下团队信息")
     public HttpResult<APPPartnerInfoFreeVo> getTeamInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
 
-        return HttpResult.ok(this.sysPartnerService.getTeamInfo(partnerGradeInfo));
+        return HttpResult.ok("success",this.sysPartnerService.getTeamInfo(partnerGradeInfo));
     }
 
     @PostMapping("/getTeamUserInfo")
     @ApiOperation(value = "查看团队下人员信息")
     public HttpResult<TeamUserInfosFreeVo> getTeamUserInfo(@RequestBody TeamUserInfosDto teamUserInfosDto) {
 
-        return HttpResult.ok(this.sysPartnerService.getTeamUserInfo(teamUserInfosDto));
+        return HttpResult.ok("success",this.sysPartnerService.getTeamUserInfo(teamUserInfosDto));
     }
 
     /**
@@ -137,7 +137,7 @@ public class APPPartnerController extends BaseController {
             commissionInfoDto.setPageSize(10);
         }
 
-        return HttpResult.ok(this.sysPartnerService.getCommissionInfo(commissionInfoDto));
+        return HttpResult.ok("success",this.sysPartnerService.getCommissionInfo(commissionInfoDto));
     }
     /**
      *  app工作室新增人员统计
@@ -146,7 +146,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "app工作室新增人员统计")
     public HttpResult<CountUserVo> getCountUser(@RequestBody CountUserDto countUserDto) {
 
-        return HttpResult.ok(this.sysPartnerService.getCountUser(countUserDto));
+        return HttpResult.ok("success",this.sysPartnerService.getCountUser(countUserDto));
     }
     /**
      *  app合伙人新增人员统计
@@ -155,7 +155,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "app合伙人新增人员统计")
     public HttpResult<PartnerCountVo> getPartnerCount(@RequestBody PartnerCountDto partnerCountDto) {
 
-        return HttpResult.ok(this.sysPartnerService.getPartnerCount(partnerCountDto));
+        return HttpResult.ok("success",this.sysPartnerService.getPartnerCount(partnerCountDto));
     }
     /**
      * 新增人员占比分析
@@ -164,7 +164,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "新增人员占比分析")
     public HttpResult<PartnerProportionVo> getPartnerProportion(@RequestBody PartnerCountDto partnerCountDto) {
 
-        return HttpResult.ok(this.sysPartnerService.getPartnerProportion(partnerCountDto));
+        return HttpResult.ok("success",this.sysPartnerService.getPartnerProportion(partnerCountDto));
     }
 
     /**
@@ -174,7 +174,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "排行榜")
     public HttpResult<List<LevelPartnerVo>> getLevelPartner(@RequestParam("type") @ApiParam("等级:1、2、3、4、5") Integer type) {
 
-        return HttpResult.ok(this.sysPartnerService.getLevelPartner(type));
+        return HttpResult.ok("success",this.sysPartnerService.getLevelPartner(type));
     }
 
 

+ 4 - 2
src/main/java/com/ydtech/modules/admin/controller/SysPcAddressController.java

@@ -154,9 +154,11 @@ public class SysPcAddressController extends BaseController{
     @ApiOperation(value = "历史在线人数")
     public HttpResult<PcAddressHistoryInfoVo> getPcAddress(@RequestParam(value = "startTime",required = false) String startTime,
                                                            @RequestParam(value = "endTime",required = false) String endTime,
-                                                           @RequestParam(value = "source",required = false) String source) {
+                                                           @RequestParam(value = "source",required = false) String source,
+                                                           @RequestParam(value = "queryId",required = false) String queryId,
+                                                           @RequestParam(value = "type") Integer type) {
 
-        return HttpResult.ok("success", this.sysPcAddressService.getPcAddress(startTime,endTime,source));
+        return HttpResult.ok("success", this.sysPcAddressService.getPcAddress(startTime,endTime,source,queryId,type));
     }
 
     @GetMapping("/getOnlinePeople")

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

@@ -125,9 +125,11 @@ public class SysGeographyPositionController extends BaseController {
     @ApiOperation(value = "历史在线人数")
     public HttpResult<AppGeographyHistoryInfoVo> getGeographyPosition(@RequestParam(value = "startTime",required = false) String startTime,
                                                                       @RequestParam(value = "endTime",required = false) String endTime,
-                                                                      @RequestParam(value = "source",required = false) String source) {
+                                                                      @RequestParam(value = "source",required = false) String source,
+                                                                      @RequestParam(value = "queryId",required = false) String queryId,
+                                                                      @RequestParam(value = "type") Integer type) {
 
-        return HttpResult.ok("success", this.sysGeographyPositionService.getGeographyPosition(startTime,endTime,source));
+        return HttpResult.ok("success", this.sysGeographyPositionService.getGeographyPosition(startTime,endTime,source,queryId,type));
     }
 
     @GetMapping("/getOnlinePeople")

+ 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,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getGeographyPosition(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
-    List<SysGeographyPositionRecord> getGeographyPositionRecord(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect);
+    List<SysGeographyPositionRecord> getGeographyPositionRecord(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
-    List<PcAddressHistoryTimeVo> getGeographyPositionSection(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getGeographyPositionSection(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
-    List<SysGeographyPositionRecord> getGeographyPositionHistory(@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,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
     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,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getPcAddress(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
-    List<SysPcAddressHistory> getPcAddressInfo(@Param("dates") String dates, @Param("source") String source,@Param("collect") List<String> collect);
+    List<SysPcAddressHistory> getPcAddressInfo(@Param("dates") String dates, @Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
-    List<PcAddressHistoryTimeVo> getPcAddressSection(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getPcAddressSection(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
-    List<SysPcAddressHistory> getPcAddressHistory(@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,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
     IPage<SysPcAddressHistory> queryAddressHistory(Page page, @Param("dto") PcAddressInfoDto addressInfoDto);
 }

+ 11 - 0
src/main/java/com/ydtech/modules/admin/model/PartnerInfoVo.java

@@ -14,6 +14,17 @@ public class PartnerInfoVo {
     private String userId;
     @ApiModelProperty(value = "合伙人Name")
     private String userName;
+    /**
+     * 机构id
+     */
+    @ApiModelProperty(value = "机构id")
+    private String deptId;
+    /**
+     * 机构name
+     */
+    @ApiModelProperty(value = "机构name")
+    private String deptName;
+
     @ApiModelProperty(value = "推荐人Name")
     private String suggestName;
 

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

@@ -2,7 +2,9 @@ package com.ydtech.modules.admin.model;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
 
@@ -13,6 +15,8 @@ import java.io.Serializable;
  * @since 2024-10-21 10:02:25
  */
 @Data
+@NoArgsConstructor
+@AllArgsConstructor
 public class SysProportionConfig implements Serializable {
     private static final long serialVersionUID = -52994380963075044L;
     /**

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

@@ -24,7 +24,7 @@ public interface SysGeographyPositionService extends IService<SysGeographyPositi
     BasePageResult<SysGeographyPositionInfoVo> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
     BasePageResult<SysGeographyPositionInfoVo> queryGeographyRecord(PcAddressInfoDto addressInfoDto);
 
-    AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source);
+    AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source,String queryId,Integer type);
 
     List<SysGeographyPosition> getOnlinePeople();
 

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

@@ -42,7 +42,7 @@ public interface SysPcAddressService extends IService<SysPcAddress> {
 
     BasePageResult<SysPcAddress> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
 
-    PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source);
+    PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source,String queryId,Integer type);
 
     List<SysPcAddress> getOnlinePeople();
 

+ 190 - 52
src/main/java/com/ydtech/modules/admin/service/impl/SysGeographyPositionServiceImpl.java

@@ -599,7 +599,7 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     }
 
     @Override
-    public AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source) {
+    public AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source,String queryId,Integer type) {
         AppGeographyHistoryInfoVo appGeographyHistoryInfoVo = new AppGeographyHistoryInfoVo();
         //admin 可看所有,其他下只能看下面管理的人员
         String userId = BaseController.getUserId();
@@ -614,64 +614,202 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
             collect.addAll(idList);
 
         }
+        if (type == 1) {
+            //机构
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                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)
+                        .likeRight(StringUtils.isNotEmpty(queryId),"user_id",queryId)
+                        .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,collect,queryId);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect,queryId);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
 
-        if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+            }else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                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,collect,queryId);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect,queryId);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+            }
 
-            if (StringUtils.isNullOrEmpty(startTime)) {
-                Date date = new Date();
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                startTime = simpleDateFormat.format(date);
+        }else if (type == 2) {
+            //人员id
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, queryId).ne(SysUser::getStatus, 0));
+            List<String> collect1 = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) {
+                return appGeographyHistoryInfoVo;
             }
-            QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
-            // 指定 COUNT(DISTINCT user_id) 查询
-            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,collect);
-            appGeographyHistoryInfoVo.setList(geographyPosition);
-
-            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect);
-            extracted(sysGeographyPositionRecords);
-            System.out.println("********************" + sysGeographyPositionRecords.size());
-            appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+            List<String> idList = queryList(collect1, ids);
+            collect.addAll(idList);
+            List<String> collect2 = collect.stream().distinct().collect(Collectors.toList());
 
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "create_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect2), "user_id", collect2)
+                        .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,collect2,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect2,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+
+            }else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .between("create_time", startTime, endTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect2), "user_id", collect2)
+                        .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,collect2,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect2,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
 
-        }else {
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            startTime = startTime + " 00:00:01";
-            endTime = endTime + " 23:59:59";
-            try {
-                Date parse = simpleDateFormat.parse(startTime);
-                Date parse1 = simpleDateFormat.parse(endTime);
-                startTime = simpleDateFormat.format(parse);
-                endTime = simpleDateFormat.format(parse1);
-
-            } catch (ParseException e) {
-                throw new RuntimeException(e);
             }
-            QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
-            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,collect);
-            appGeographyHistoryInfoVo.setList(geographyPosition);
-
-            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect);
-            extracted(sysGeographyPositionRecords);
-            System.out.println("********************" + sysGeographyPositionRecords.size());
-            appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
 
+
+
+        }else {
+
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                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,collect,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+
+            }else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                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,collect,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+            }
         }
 
         return appGeographyHistoryInfoVo;

+ 105 - 244
src/main/java/com/ydtech/modules/admin/service/impl/SysPartnerServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.aop.exception.DescribeException;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.*;
 import com.ydtech.modules.admin.model.*;
 import com.ydtech.modules.admin.model.dto.*;
@@ -16,8 +17,9 @@ import com.ydtech.modules.admin.model.vo.*;
 import com.ydtech.modules.admin.service.SysAgencyLeaderService;
 import com.ydtech.modules.admin.service.SysPartnerService;
 import com.ydtech.modules.admin.service.SysPremiumDetailsService;
-import com.ydtech.modules.admin.service.SysUserService;
 import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.esm.dao.EsmUserReferrerMapper;
+import com.ydtech.modules.esm.model.EsmUserReferrer;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.utils.StringUtils;
 import org.springframework.stereotype.Service;
@@ -26,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -73,6 +76,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
 
     @Resource
     private SysProportionConfigMapper sysProportionConfigMapper;
+    @Resource
+    private EsmUserReferrerMapper esmUserReferrerMapper;
+
 
 
     @Override
@@ -176,6 +182,11 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         sysPartner.setType(sysPartnerDto.getLevel());
         boolean b = false;
         b = sysPartnerMapper.insert(sysPartner) > 0;
+        //一级合伙人添加默认比例
+        if (sysPartnerDto.getLevel() == 1) {
+            SysProportionConfig sysProportionConfig = new SysProportionConfig(null,sysPartner.getUserId(),"0.5","0.1","0.1","0.1","0.1","0.1");
+            sysProportionConfigMapper.insert(sysProportionConfig);
+        }
         if (sysPartnerDto.getSuggestId() != null) {
             SysPartner sysPartner1 = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
                     .eq(SysPartner::getDelFlag, 1).eq(SysPartner::getUserId, sysPartnerDto.getSuggestId()));
@@ -668,7 +679,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             }
             appPartnerInfo.setTeamManNum(deptManNum);
             appPartnerInfo.setUserIds(userIdList);
-
+            if (CollectionUtil.isEmpty(userIdList)) continue;
             //查团队的保费
             List<SysPremiumDetails> sysPremiumDetails = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
                     .in(SysPremiumDetails::getUserId, userIdList)
@@ -697,6 +708,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 ids.addAll(list);
             }
         }
+        if (CollectionUtil.isEmpty(ids)) return appPartnerInfoFreeVo;
 
         List<SysPremiumDetails> sysPremiumDetails = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
                 .in(SysPremiumDetails::getUserId, ids)
@@ -882,8 +894,8 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 BigDecimal sumPremium = sysPremiumDetails.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal extractFee = sysPremiumDetails.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
 
-//                appSysPartnerVo.setSumPremium(sumPremium);
-//                appSysPartnerVo.setExtractFee(extractFee);
+                appSysPartnerVo.setSumPremium(sumPremium);
+                appSysPartnerVo.setExtractFee(extractFee);
                 //二级以下团队的总人数
                 List<SysRelationPerson> sysRelationPersonList = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                         .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
@@ -912,26 +924,16 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                         }
                     }
                 }
-//                appSysPartnerVo.setTeamManNum(deptManNum);
-
-                List<String> list = new ArrayList<>();
-                if (partnerType == 1) {
-                    //一级获取登陆人的之际工作室
-                    list.add(userId);
-                } else {
-
-                    //获取上一级合伙人,查询工作室数量
-                    List<SysPartner> sysPartners = listMap.get(partnerType - 1);
-                    if (sysPartners != null) {
-                        //上一级直接推荐的工作室数量
-                        List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                        list.addAll(list1);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        appSysPartnerVo.setTeamManNum(deptManNum);
-
-                        appSysPartnerVo.setNumber(appSysPartnerVo.getPartnerNumber());
-                    }
+                appSysPartnerVo.setTeamManNum(deptManNum);
+                List<SysRelationPerson> sysRelationPersons = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
+                        .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
+                        .eq(SysRelationPerson::getDelFlag, 1)
+                        .eq(SysRelationPerson::getSource, 0)
+                        .eq(SysRelationPerson::getType, 1));
+                appSysPartnerVo.setWorkNumber(sysRelationPersons.size());
+                if (sysRelationPersons.size() > 0) {
+                    List<String> list1 = sysRelationPersons.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
+                    appSysPartnerVo.setLeaderIds(list1);
                 }
 
                 //每一级存入map
@@ -972,7 +974,8 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                         .eq(SysPremiumDetails::getStatus, 1));
                 BigDecimal sumPremium = sysPremiumDetails.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal extractFee = sysPremiumDetails.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
-
+                appSysPartnerVo.setSumPremium(sumPremium);
+                appSysPartnerVo.setExtractFee(extractFee);
                 //同等级合伙人团队的总人数:
                 List<SysRelationPerson> sysRelationPersonList = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                         .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
@@ -1001,197 +1004,25 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                         }
                     }
                 }
+                appSysPartnerVo.setTeamManNum(deptManNum);
 
-                List<String> list = new ArrayList<>();
-//                int type = sysPartner.getType();
-                if (type == 1) {
-                    if (i == 2) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-                } else if (type == 2) {
-                    if (i == 3) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-
-                } else if (type == 3) {
-                    if (i == 4) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-
-                        //获取上一级合伙人,查询工作室数量
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-
-                } else if (type == 4) {
-                    if (i == 5) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-
+                List<SysRelationPerson> sysRelationPersons = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
+                        .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
+                        .eq(SysRelationPerson::getDelFlag, 1)
+                        .eq(SysRelationPerson::getSource, 0)
+                        .eq(SysRelationPerson::getType, 1));
+                appSysPartnerVo.setWorkNumber(sysRelationPersons.size());
+                if (sysRelationPersons.size() > 0) {
+                    List<String> list1 = sysRelationPersons.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
+                    appSysPartnerVo.setLeaderIds(list1);
                 }
                 //每一级存入map
-                appSysPartnerVos.add(appSysPartnerVo);
-            } else {
-                //无合伙人,查看上一级的直接工作室
-                List<String> list = new ArrayList<>();
-                AppSysPartnerVo appSysPartnerVo = new AppSysPartnerVo();
-                appSysPartnerVo.setPartnerType(i);
-                if (type == 1) {
-                    if (i == 2) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                } else if (type == 2) {
-                    if (i == 3) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                } else if (type == 3) {
-                    if (i == 4) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                } else if (type == 4) {
-                    if (i == 5) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                }
-
                 appSysPartnerVos.add(appSysPartnerVo);
             }
         }
         return appSysPartnerVos;
     }
 
-    private void extractedLeader(PartnerInfoDto partnerInfoDto, Map<Integer, List<SysPartner>> listMap, int i, AppSysPartnerVo appSysPartnerVo, BigDecimal sumPremium, BigDecimal extractFee, int deptManNum, List<String> list) {
-        //获取上一级合伙人,查询工作室数量
-        List<SysPartner> sysPartners = listMap.get(i - 1);
-        if (sysPartners != null) {
-            //上一级直接推荐的工作室数量
-            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-            list.addAll(list1);
-            extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-        } else {
-            appSysPartnerVo.setTeamManNum(deptManNum);
-            appSysPartnerVo.setNumber(Optional.ofNullable(appSysPartnerVo.getPartnerNumber()).orElse(0));
-        }
-    }
-
-    private void extracted(PartnerInfoDto partnerInfoDto, AppSysPartnerVo appSysPartnerVo, BigDecimal sumPremium, BigDecimal extractFee, int deptManNum, List<String> list) {
-        List<SysRelationPerson> sysRelationPersons = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
-                .in(CollectionUtil.isNotEmpty(list), SysRelationPerson::getSuggestId, list)
-                .eq(SysRelationPerson::getDelFlag, 1)
-                .eq(SysRelationPerson::getSource, 0)
-                .eq(SysRelationPerson::getType, 1));
-        appSysPartnerVo.setWorkNumber(sysRelationPersons.size());
-        if (sysRelationPersons.size() > 0) {
-
-            List<String> list1 = sysRelationPersons.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
-            appSysPartnerVo.setLeaderIds(list1);
-            //直接工作室保费
-            List<SysPremiumDetails> sysPremiumDetails1 = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
-                    .in(CollectionUtil.isNotEmpty(list1), SysPremiumDetails::getUserId, list1)
-                    .between(StringUtils.isNotEmpty(partnerInfoDto.getBeginTime()) && StringUtils.isNotEmpty(partnerInfoDto.getEndTime()),
-                            SysPremiumDetails::getCreateTime, partnerInfoDto.getBeginTime(), partnerInfoDto.getEndTime())
-                    .eq(partnerInfoDto.getIndustrySector() != null, SysPremiumDetails::getIndustrySector, partnerInfoDto.getIndustrySector())
-                    .eq(SysPremiumDetails::getStatus, 1));
-            if (sysPremiumDetails1.size() > 0) {
-
-                BigDecimal sumPremium1 = sysPremiumDetails1.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
-                BigDecimal extractFee1 = sysPremiumDetails1.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-                appSysPartnerVo.setSumPremium(sumPremium.add(sumPremium1));
-                appSysPartnerVo.setExtractFee(extractFee.add(extractFee1));
-            } else {
-                appSysPartnerVo.setSumPremium(sumPremium);
-                appSysPartnerVo.setExtractFee(extractFee);
-            }
-            int leaderManNum = 0;
-            //直接工作室总
-            List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
-                    .in(CollectionUtil.isNotEmpty(list1), SysAgencyLeader::getUserId, list1).eq(SysAgencyLeader::getDelFlag, 1));
-
-            if (leaderList.size() > 0) {
-                for (SysAgencyLeader sysAgencyLeader : leaderList) {
-                    //获取机构下的团队
-                    List<SysDept> sysDeptList = sysDeptMapper.selectList(new LambdaQueryWrapper<SysDept>()
-                            .likeRight(SysDept::getId, sysAgencyLeader.getDeptId())
-                            .isNull(SysDept::getComlevel).eq(SysDept::getDelFlag, 0)
-                            .eq(SysDept::getManagementSource, sysAgencyLeader.getSource()));
-                    if (sysDeptList.size() > 0) {
-                        for (SysDept sysDept : sysDeptList) {
-                            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
-                                    .likeRight(SysUser::getId, sysDept.getId()).ne(SysUser::getStatus, 0));
-                            leaderManNum = leaderManNum + sysUsers.size();
-
-                        }
-                    }
-                }
-            }
-
-            appSysPartnerVo.setTeamManNum(deptManNum + leaderManNum);
-            Integer partnerNumber = Optional.ofNullable(appSysPartnerVo.getPartnerNumber()).orElse(0);
-            Integer workNumber = Optional.ofNullable(appSysPartnerVo.getWorkNumber()).orElse(0);
-            appSysPartnerVo.setNumber(partnerNumber + workNumber);
-        }
-    }
-
     @Override
     public PartnerInfoFreeVo queryPartnerInfo(PartnerGradeInfo partnerGradeInfo) {
         PartnerInfoFreeVo partnerInfoFreeVo = new PartnerInfoFreeVo();
@@ -1260,7 +1091,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                     partnerInfoVo.setLeaderIds(collects);
                     partnerInfoVo.setWorkNumber(collects.size());
 
-                    //合伙人下所有工作室数
+                    //合伙人下所有工作室数 核算总代理人数
                     List<SysRelationPerson> sysRelationPersonList2 = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                             .eq(SysRelationPerson::getSuggestId, userId)
                             .eq(SysRelationPerson::getDelFlag, 1)
@@ -1425,10 +1256,10 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             TeamUserInfosVo teamUserInfosVo = new TeamUserInfosVo();
             teamUserInfosVo.setUserId(sysUser.getId());
             teamUserInfosVo.setUserName(sysUser.getName());
-            String leaderId = sysUser.getLeaderId();
-            if (StringUtils.isNotEmpty(leaderId)) {
-                teamUserInfosVo.setLeaderId(sysUser.getLeaderId());
-                SysUser sysUser1 = sysUserMapper.selectById(sysUser.getLeaderId());
+            EsmUserReferrer esmUserReferrer = esmUserReferrerMapper.selectById(sysUser.getId());
+            if (esmUserReferrer != null) {
+                teamUserInfosVo.setLeaderId(esmUserReferrer.getReferrerId());
+                SysUser sysUser1 = sysUserMapper.selectById(esmUserReferrer.getReferrerId());
                 teamUserInfosVo.setLeaderName(sysUser1.getName());
             }
 
@@ -1613,7 +1444,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             partnerInfoVo.setUserName(sysUser.getName());
             SysUser sysUser1 = sysUserMapper.selectById(sysAgencyLeader.getSuggestId());
             partnerInfoVo.setSuggestName(sysUser1.getName());
-
+            partnerInfoVo.setDeptId(sysAgencyLeader.getDeptId());
+            SysDept sysDept1 = sysDeptMapper.selectById(sysAgencyLeader.getDeptId());
+            partnerInfoVo.setDeptName(sysDept1.getName());
             //费用
             List<SysPremiumDetails> sysPremiumDetail = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
                     .eq(SysPremiumDetails::getUserId, userId)
@@ -1739,9 +1572,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         String startTime1 = countUserDto.getBeginTime();
         String endTime1 = countUserDto.getEndTime();
 
-        int deptSum=0;
-        int deptManSum=0;
-        List<String> deptIds =new ArrayList<>();
+        int deptSum = 0;
+        int deptManSum = 0;
+        List<String> deptIds = new ArrayList<>();
         //查工作室下的团队
         SysAgencyLeader sysAgencyLeader = sysAgencyLeaderMapper.selectOne(new LambdaQueryWrapper<SysAgencyLeader>()
                 .eq(SysAgencyLeader::getDelFlag, 1).in(SysAgencyLeader::getUserId, userId));
@@ -1779,10 +1612,10 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                     if (s.equals(s1)) {
                         //查一天的数据
                         countUserNumVoList = sysPartnerMapper.queryDeptByTimes(deptIds, countUserDto);
-                    }else {
+                    } else {
                         countUserNumVoList = sysPartnerMapper.queryDeptByTime(deptIds, countUserDto);
                     }
-                }else {
+                } else {
                     countUserNumVoList = sysPartnerMapper.queryDeptByTime(deptIds, countUserDto);
                 }
 
@@ -1792,10 +1625,10 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                     String s1 = endTime1.split(" ")[0];
                     if (s.equals(s1)) {
                         countUserNumVoList = sysPartnerMapper.queryUserByTimes(deptIds, countUserDto);
-                    }else {
+                    } else {
                         countUserNumVoList = sysPartnerMapper.queryUserByTime(deptIds, countUserDto);
                     }
-                }else {
+                } else {
                     countUserNumVoList = sysPartnerMapper.queryUserByTime(deptIds, countUserDto);
                 }
 
@@ -1814,7 +1647,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         SysPartner sysPartner = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
         int type = sysPartner.getType();
-        partnerCountDto.setType(type+partnerCountDto.getType());
+        partnerCountDto.setType(type + partnerCountDto.getType());
         //查询登陆人下所有合伙人
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryPartnerById(userId, partnerCountDto);
         if (CollectionUtil.isEmpty(sysPartnerList)) return partnerCountVo;
@@ -1835,7 +1668,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<SysPartner> fourPartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 4).collect(Collectors.toList());
             partnerCountVo.setFourPartnerNum(fourPartners.size());
 
-        }else if (type == 2) {
+        } else if (type == 2) {
             //1
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             partnerCountVo.setOnePartnerNum(onePartners.size());
@@ -1846,7 +1679,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<SysPartner> threePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 3).collect(Collectors.toList());
             partnerCountVo.setThreePartnerNum(threePartners.size());
 
-        }else if (type == 3) {
+        } else if (type == 3) {
             //1
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             partnerCountVo.setOnePartnerNum(onePartners.size());
@@ -1854,7 +1687,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<SysPartner> twoPartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 2).collect(Collectors.toList());
             partnerCountVo.setTwoPartnerNum(twoPartners.size());
 
-        }else if (type == 4) {
+        } else if (type == 4) {
             //1
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             partnerCountVo.setOnePartnerNum(onePartners.size());
@@ -1869,9 +1702,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<String> collect = sysRelationPersonList.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
             //查工作室下的团队
             List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
-                    .eq(SysAgencyLeader::getDelFlag,1).in(SysAgencyLeader::getUserId,collect));
-            int deptSum=0;
-            int deptManSum=0;
+                    .eq(SysAgencyLeader::getDelFlag, 1).in(SysAgencyLeader::getUserId, collect));
+            int deptSum = 0;
+            int deptManSum = 0;
 
             for (SysAgencyLeader sysAgencyLeader : leaderList) {
                 //根据机构id查下面团队
@@ -1909,7 +1742,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             if (s.equals(s1)) {
                 //查一天的数据
                 countUserNumVoList = sysPartnerMapper.queryPartnerByTimes(userId, partnerCountDto);
-            }else {
+            } else {
                 countUserNumVoList = sysPartnerMapper.queryPartnerByTime(userId, partnerCountDto);
             }
 
@@ -1930,27 +1763,55 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
         int level = sysPartner.getType() + partnerCountDto.getType();
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryByLoginId(userId);
+        List<SysPartner> collectNum;
+        List<SysPartner> collectSum;
+        try {
+            if (StringUtils.isNotEmpty(partnerCountDto.getBeginTime())) {
+                SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+                Date parse = simpleDateFormat1.parse(partnerCountDto.getBeginTime());
+                Date parse1 = simpleDateFormat1.parse(partnerCountDto.getEndTime());
+                collectNum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getCreateTime().after(parse)
+                                && SysPartner.getCreateTime().before(parse1) && SysPartner.getType() == level)
+                        .collect(Collectors.toList());
+
+                collectSum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == level)
+                        .collect(Collectors.toList());
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                Date date = new Date();
+                String format = simpleDateFormat.format(date);
+                String start = format + " 00:00:01";
+                String end = format + " 23:59:59";
+                SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+                Date parse = simpleDateFormat1.parse(start);
+                Date parse1 = simpleDateFormat1.parse(end);
+                collectNum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getCreateTime().after(parse)
+                                && SysPartner.getCreateTime().before(parse1) && SysPartner.getType() == level)
+                        .collect(Collectors.toList());
+
+                collectSum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == level)
+                        .collect(Collectors.toList());
 
-        List<SysPartner> collectNum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getCreateTime().after(new Date(partnerCountDto.getBeginTime()))
-                        && SysPartner.getCreateTime().before(new Date(partnerCountDto.getEndTime())) && SysPartner.getType()==level)
-                .collect(Collectors.toList());
-
-        List<SysPartner> collectSum = sysPartnerList.stream().filter(SysPartner ->SysPartner.getType()==level)
-                .collect(Collectors.toList());
+            }
+        } catch (Exception e) {
+            throw new SystemException("系统繁忙,请联系管理员");
+        }
 
-        partnerProportionVo.setNewNum(collectNum.size());
-        partnerProportionVo.setNumber(collectSum.size());
+        partnerProportionVo.setNewNum(Optional.ofNullable(collectNum.size()).orElse(0));
+        partnerProportionVo.setNumber(Optional.ofNullable(collectSum.size()).orElse(0));
         if (CollectionUtil.isNotEmpty(collectSum)) {
             int i = collectSum.size() - collectNum.size();
             partnerProportionVo.setOldNum(i);
         }
         if (CollectionUtil.isNotEmpty(collectNum)) {
-            double v = (float)collectNum.size() / (float) collectSum.size() * 100;
+            double v = (float) collectNum.size() / (float) collectSum.size() * 100;
             partnerProportionVo.setNewProportion(v);
         }
         int oldNum = partnerProportionVo.getOldNum();
         if (oldNum != 0) {
-            double v = (float)oldNum / (float) collectSum.size() * 100;
+            double v = (float) oldNum / (float) collectSum.size() * 100;
             partnerProportionVo.setOldProportion(v);
         }
 
@@ -1963,11 +1824,11 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         String userId = BaseController.getUserId();
         SysPartner sysPartner = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
-        int level = sysPartner.getType() +type;
+        int level = sysPartner.getType() + type;
 
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryByLoginId(userId);
 
-        List<SysPartner> collect = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType()==level)
+        List<SysPartner> collect = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == level)
                 .collect(Collectors.toList());
         if (CollectionUtil.isEmpty(collect)) return partnerVoList;
 
@@ -1986,9 +1847,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 List<String> collects = sysRelationPersonList.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
                 //查工作室下的团队
                 List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
-                        .eq(SysAgencyLeader::getDelFlag,1).in(SysAgencyLeader::getUserId,collects));
-                int deptSum=0;
-                int deptManSum=0;
+                        .eq(SysAgencyLeader::getDelFlag, 1).in(SysAgencyLeader::getUserId, collects));
+                int deptSum = 0;
+                int deptManSum = 0;
                 for (SysAgencyLeader sysAgencyLeader : leaderList) {
                     //根据机构id查下面团队
                     List<SysDept> sysDeptList = sysDeptMapper.selectList(new LambdaQueryWrapper<SysDept>()
@@ -2009,7 +1870,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
 
                 levelPartnerVo.setDeptManNum(deptManSum);
 
-            }else {
+            } else {
                 levelPartnerVo.setDeptManNum(0);
             }
 

+ 189 - 54
src/main/java/com/ydtech/modules/admin/service/impl/SysPcAddressServiceImpl.java

@@ -392,7 +392,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     }
 
     @Override
-    public PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source) {
+    public PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source,String queryId,Integer type) {
         PcAddressHistoryInfoVo pcAddressHistoryInfoVo = new PcAddressHistoryInfoVo();
         //admin 看所有,其他人看自己下属的人员信息
         String userId = BaseController.getUserId();
@@ -406,65 +406,200 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             List<String> idList = queryList(collect, ids);
             collect.addAll(idList);
         }
+        if (type == 1) {
+            //带机构查
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                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)
+                        .likeRight(StringUtils.isNotEmpty(queryId),"user_id",queryId)
+                        .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, collect,queryId);
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect,queryId);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
 
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                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)
+                        .likeRight(StringUtils.isNotEmpty(queryId),"user_id",queryId)
+                        .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, collect,queryId);
+
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect,queryId);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+            }
 
-        if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
-            if (StringUtils.isNullOrEmpty(startTime)) {
-                Date date = new Date();
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                startTime = simpleDateFormat.format(date);
+        }else if (type == 2) {
+            //带用户查
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, queryId).ne(SysUser::getStatus, 0));
+            List<String> collect1 = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) {
+                return pcAddressHistoryInfoVo;
             }
-            QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
-            // 指定 COUNT(DISTINCT user_id) 查询
-            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, collect);
-            pcAddressHistoryInfoVo.setList(pcAddress);
-
-            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect);
-            extracted(sysPcAddressHistories);
-            System.out.println("********************" + sysPcAddressHistories.size());
-            pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+            List<String> idList = queryList(collect1, ids);
+            collect.addAll(idList);
+            List<String> collect2 = collect.stream().distinct().collect(Collectors.toList());
 
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "operation_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect2), "user_id", collect2)
+                        .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, collect2,null);
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect2,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
 
-        } else {
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            startTime = startTime + " 00:00:01";
-            endTime = endTime + " 23:59:59";
-            try {
-                Date parse = simpleDateFormat.parse(startTime);
-                Date parse1 = simpleDateFormat.parse(endTime);
-                startTime = simpleDateFormat.format(parse);
-                endTime = simpleDateFormat.format(parse1);
-
-            } catch (ParseException e) {
-                throw new RuntimeException(e);
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                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(CollectionUtil.isNotEmpty(collect2), "user_id", collect2);
+                Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                pcAddressHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime, source, collect2,null);
+
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect2,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+            }
+
+
+        }else {
+            //正常查
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                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, collect,null);
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+
+
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                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(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, collect,null);
+
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
             }
-            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(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, collect);
-
-            pcAddressHistoryInfoVo.setList(pcAddress);
-
-            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect);
-            extracted(sysPcAddressHistories);
-            System.out.println("********************" + sysPcAddressHistories.size());
-            pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
         }
 
         return pcAddressHistoryInfoVo;

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

@@ -34,6 +34,9 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </if>
             <if test="dates != null and dates != ''">
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
             </if>
@@ -62,6 +65,9 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </if>
             <if test="dates != null and dates != ''">
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
             </if>

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

@@ -41,6 +41,9 @@
                          #{item}
                      </foreach>
                  </if>
+                 <if test="queryId != null and queryId != ''">
+                     and user_id like concat(#{dto.queryId},'%')
+                 </if>
                  <if test="dates != null and dates != ''">
                      and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                  </if>
@@ -73,6 +76,9 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </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>
@@ -103,6 +109,9 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </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>
@@ -131,6 +140,9 @@
                         #{item}
                     </foreach>
                 </if>
+                <if test="queryId != null and queryId != ''">
+                    and user_id like concat(#{dto.queryId},'%')
+                </if>
                 <if test="dates != null and dates != ''">
                     and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                 </if>