Ver código fonte

历史人员

helixiao 1 ano atrás
pai
commit
f03d731799
17 arquivos alterados com 593 adições e 83 exclusões
  1. 52 2
      src/main/java/com/ydtech/modules/admin/controller/SysPcAddressController.java
  2. 51 6
      src/main/java/com/ydtech/modules/admin/controller/websocket/SysGeographyPositionController.java
  3. 14 1
      src/main/java/com/ydtech/modules/admin/dao/SysGeographyPositionRecordMapper.java
  4. 12 2
      src/main/java/com/ydtech/modules/admin/dao/SysPcAddressHistoryMapper.java
  5. 18 0
      src/main/java/com/ydtech/modules/admin/model/SysGeographyPositionRecord.java
  6. 6 0
      src/main/java/com/ydtech/modules/admin/model/dto/PcAddressInfoDto.java
  7. 3 0
      src/main/java/com/ydtech/modules/admin/model/po/SysPcAddress.java
  8. 3 0
      src/main/java/com/ydtech/modules/admin/model/po/SysPcAddressHistory.java
  9. 21 0
      src/main/java/com/ydtech/modules/admin/model/vo/AppGeographyHistoryInfoVo.java
  10. 5 1
      src/main/java/com/ydtech/modules/admin/model/vo/PcAddressHistoryInfoVo.java
  11. 6 0
      src/main/java/com/ydtech/modules/admin/model/vo/SysGeographyPositionInfoVo.java
  12. 3 5
      src/main/java/com/ydtech/modules/admin/service/SysGeographyPositionService.java
  13. 4 2
      src/main/java/com/ydtech/modules/admin/service/SysPcAddressService.java
  14. 89 16
      src/main/java/com/ydtech/modules/admin/service/impl/SysGeographyPositionServiceImpl.java
  15. 75 23
      src/main/java/com/ydtech/modules/admin/service/impl/SysPcAddressServiceImpl.java
  16. 116 14
      src/main/resources/mapper/modules/admin/SysGeographyPositionRecordMapper.xml
  17. 115 11
      src/main/resources/mapper/modules/admin/SysPcAddressHistoryMapper.xml

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

@@ -14,11 +14,13 @@ import com.ydtech.modules.admin.service.SysPcAddressService;
 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 io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -101,11 +103,59 @@ public class SysPcAddressController extends BaseController{
         return HttpResult.ok("success", this.sysPcAddressService.queryPcAddressInfo(addressInfoDto));
     }
 
+    @PostMapping("/queryPcAddressHistoryInfo")
+    @ApiOperation(value = "历史人员:同一经纬度人员信息")
+    public HttpResult<BasePageResult<SysPcAddressHistory>> queryPcAddressHistoryInfo(@RequestBody PcAddressInfoDto addressInfoDto) {
+        if (addressInfoDto.getPageNum() == 0) {
+            addressInfoDto.setPageNum(1);
+        }
+        if (addressInfoDto.getPageSize() == 0) {
+            addressInfoDto.setPageSize(10);
+        }
+        String startTime = addressInfoDto.getStartTime();
+        String endTime = addressInfoDto.getEndTime();
+        Date date = new Date();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        if (StringUtils.isEmpty(startTime)) {
+            addressInfoDto.setStartTime(simpleDateFormat.format(date));
+        }else {
+            startTime = addressInfoDto.getStartTime() + " 00:00:01";
+
+
+            Date parse = null;
+            try {
+                parse = simpleDateFormat.parse(startTime);
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+            addressInfoDto.setStartTime(simpleDateFormat.format(parse));
+        }
+        if (StringUtils.isEmpty(endTime)) {
+            addressInfoDto.setEndTime(simpleDateFormat.format(date));
+        }else {
+            endTime = endTime + " 23:59:59";
+            Date parse = null;
+            try {
+                parse = simpleDateFormat.parse(endTime);
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+            addressInfoDto.setEndTime(simpleDateFormat.format(parse));
+        }
+
+        return HttpResult.ok("success", this.sysPcAddressService.queryPcAddressHistoryInfo(addressInfoDto));
+    }
+
+
+
+
     @GetMapping("/getPcAddress")
     @ApiOperation(value = "历史在线人数")
-    public HttpResult<PcAddressHistoryInfoVo> getPcAddress(@RequestParam(value = "dates",required = false) String dates) {
+    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) {
 
-        return HttpResult.ok("success", this.sysPcAddressService.getPcAddress(dates));
+        return HttpResult.ok("success", this.sysPcAddressService.getPcAddress(startTime,endTime,source));
     }
 
     @GetMapping("/getOnlinePeople")

+ 51 - 6
src/main/java/com/ydtech/modules/admin/controller/websocket/SysGeographyPositionController.java

@@ -5,17 +5,17 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.model.SysGeographyPosition;
 import com.ydtech.modules.admin.model.SysGeographyPositionRecord;
 import com.ydtech.modules.admin.model.dto.*;
-import com.ydtech.modules.admin.model.vo.PcAddressHistoryInfoVo;
-import com.ydtech.modules.admin.model.vo.RegionInfoVo;
-import com.ydtech.modules.admin.model.vo.SysGeographyPositionInfoVo;
-import com.ydtech.modules.admin.model.vo.SysGeographyPositionVo;
+import com.ydtech.modules.admin.model.vo.*;
 import com.ydtech.modules.admin.service.SysGeographyPositionService;
 import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.utils.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -77,11 +77,56 @@ public class SysGeographyPositionController {
         return HttpResult.ok("success", this.sysGeographyPositionService.queryPcAddressInfo(addressInfoDto));
     }
 
+    @PostMapping("/queryGeographyRecord")
+    @ApiOperation(value = "历史人员:查询同一经纬度人员信息")
+    public HttpResult<BasePageResult<SysGeographyPositionInfoVo>> queryGeographyRecord(@RequestBody PcAddressInfoDto addressInfoDto) {
+        if (addressInfoDto.getPageNum() == 0) {
+            addressInfoDto.setPageNum(1);
+        }
+        if (addressInfoDto.getPageSize() == 0) {
+            addressInfoDto.setPageSize(10);
+        }
+        String startTime = addressInfoDto.getStartTime();
+        String endTime = addressInfoDto.getEndTime();
+        Date date = new Date();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        if (StringUtils.isEmpty(startTime)) {
+            addressInfoDto.setStartTime(simpleDateFormat.format(date));
+        }else {
+            startTime = addressInfoDto.getStartTime() + " 00:00:01";
+
+
+            Date parse = null;
+            try {
+                parse = simpleDateFormat.parse(startTime);
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+            addressInfoDto.setStartTime(simpleDateFormat.format(parse));
+        }
+        if (StringUtils.isEmpty(endTime)) {
+            addressInfoDto.setEndTime(simpleDateFormat.format(date));
+        }else {
+            endTime = endTime + " 23:59:59";
+            Date parse = null;
+            try {
+                parse = simpleDateFormat.parse(endTime);
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+            addressInfoDto.setEndTime(simpleDateFormat.format(parse));
+        }
+
+        return HttpResult.ok("success", this.sysGeographyPositionService.queryGeographyRecord(addressInfoDto));
+    }
+
     @GetMapping("/getGeographyPosition")
     @ApiOperation(value = "历史在线人数")
-    public HttpResult<PcAddressHistoryInfoVo> getGeographyPosition(@RequestParam(value = "dates",required = false) String dates) {
+    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) {
 
-        return HttpResult.ok("success", this.sysGeographyPositionService.getGeographyPosition(dates));
+        return HttpResult.ok("success", this.sysGeographyPositionService.getGeographyPosition(startTime,endTime,source));
     }
 
     @GetMapping("/getOnlinePeople")

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

@@ -2,9 +2,14 @@ package com.ydtech.modules.admin.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.modules.admin.model.SysGeographyPositionRecord;
+import com.ydtech.modules.admin.model.dto.PcAddressInfoDto;
 import com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo;
+import com.ydtech.modules.admin.model.vo.SysGeographyPositionInfoVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -18,6 +23,14 @@ import java.util.List;
 public interface SysGeographyPositionRecordMapper extends BaseMapper<SysGeographyPositionRecord> {
 
 
-    List<PcAddressHistoryTimeVo> getGeographyPosition(String dates);
+    List<PcAddressHistoryTimeVo> getGeographyPosition(@Param("dates") String dates, @Param("source")String source);
+
+    List<SysGeographyPositionRecord> getGeographyPositionRecord(@Param("dates") String dates, @Param("source")String source);
+
+    List<PcAddressHistoryTimeVo> getGeographyPositionSection(@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);
+
+    IPage<SysGeographyPositionInfoVo> queryGeographyHistory(Page page, @Param("dto")  PcAddressInfoDto addressInfoDto);
 }
 

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

@@ -1,11 +1,13 @@
 package com.ydtech.modules.admin.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.admin.model.dto.PcAddressInfoDto;
 import com.ydtech.modules.admin.model.po.SysPcAddressHistory;
 import com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo;
 import org.apache.ibatis.annotations.Param;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -16,7 +18,15 @@ import java.util.List;
 */
 public interface SysPcAddressHistoryMapper extends BaseMapper<SysPcAddressHistory> {
 
-    List<PcAddressHistoryTimeVo> getPcAddress(@Param("dates") String dates);
+    List<PcAddressHistoryTimeVo> getPcAddress(@Param("dates") String dates, @Param("source")String source);
+
+    List<SysPcAddressHistory> getPcAddressInfo(@Param("dates") String dates, @Param("source") String source);
+
+    List<PcAddressHistoryTimeVo> getPcAddressSection(@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);
+
+    IPage<SysPcAddressHistory> queryAddressHistory(Page page, @Param("dto") PcAddressInfoDto addressInfoDto);
 }
 
 

+ 18 - 0
src/main/java/com/ydtech/modules/admin/model/SysGeographyPositionRecord.java

@@ -1,6 +1,7 @@
 package com.ydtech.modules.admin.model;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
@@ -62,6 +63,23 @@ public class SysGeographyPositionRecord implements Serializable {
 
     @ApiModelProperty(value = "机构来源")
     private String source;
+    //预留字段,判断调接口使用
+    @TableField(exist = false)
+    private Integer type=2;
+
+    @ApiModelProperty(value = "所属机构")
+    @TableField(exist = false)
+    private String deptName;
+
+    @ApiModelProperty(value = "领导人姓名")
+    @TableField(exist = false)
+    private String leaderName;
+
+
+
+
+
+
 
 }
 

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

@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.model.dto;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 @Data
 @ApiModel(value = "经纬度筛选")
@@ -33,5 +34,10 @@ public class PcAddressInfoDto {
     @ApiModelProperty(value = "每页条数")
     private int pageSize;
 
+    //历史人员信息筛选
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    private String startTime;
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    private String endTime;
 
 }

+ 3 - 0
src/main/java/com/ydtech/modules/admin/model/po/SysPcAddress.java

@@ -88,5 +88,8 @@ public class SysPcAddress implements Serializable {
     @ApiModelProperty(value = "在线状态(0:离线; 1:在线)")
     private Integer status;
 
+    @TableField(exist = false)
+    private Integer type=1;
+
 
 }

+ 3 - 0
src/main/java/com/ydtech/modules/admin/model/po/SysPcAddressHistory.java

@@ -80,4 +80,7 @@ public class SysPcAddressHistory implements Serializable {
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 
+    @TableField(exist = false)
+    private Integer type=2;
+
 }

+ 21 - 0
src/main/java/com/ydtech/modules/admin/model/vo/AppGeographyHistoryInfoVo.java

@@ -0,0 +1,21 @@
+package com.ydtech.modules.admin.model.vo;
+
+import com.ydtech.modules.admin.model.SysGeographyPositionRecord;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+@Data
+@ApiModel(value ="APP历史在线人数")
+public class AppGeographyHistoryInfoVo {
+
+    @ApiModelProperty(value = "历史在线总人数")
+    private Long onlineNum;
+
+    @ApiModelProperty(value = "历史时间点在线人数")
+    List<PcAddressHistoryTimeVo> list;
+
+    @ApiModelProperty(value = "在线人")
+    List<SysGeographyPositionRecord> positionRecordList;
+}

+ 5 - 1
src/main/java/com/ydtech/modules/admin/model/vo/PcAddressHistoryInfoVo.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.admin.model.vo;
 
+import com.ydtech.modules.admin.model.po.SysPcAddressHistory;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -7,7 +8,7 @@ import lombok.Data;
 import java.util.List;
 
 @Data
-@ApiModel(value ="历史在线人数")
+@ApiModel(value ="PC历史在线人数")
 public class PcAddressHistoryInfoVo {
 
     @ApiModelProperty(value = "历史在线总人数")
@@ -16,5 +17,8 @@ public class PcAddressHistoryInfoVo {
     @ApiModelProperty(value = "历史时间点在线人数")
     List<PcAddressHistoryTimeVo> list;
 
+    @ApiModelProperty(value = "在线人")
+    List<SysPcAddressHistory> pcAddressList;
+
 
 }

+ 6 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysGeographyPositionInfoVo.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.admin.model.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.ydtech.modules.admin.model.SysGeographyPosition;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -9,5 +10,10 @@ public class SysGeographyPositionInfoVo extends SysGeographyPosition {
 
     @ApiModelProperty(value = "所属机构")
     private String deptName;
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @TableField(exist = false)
+    private Integer type=1;
 
 }

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

@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.admin.model.SysGeographyPosition;
 import com.ydtech.modules.admin.model.SysGeographyPositionRecord;
 import com.ydtech.modules.admin.model.dto.*;
-import com.ydtech.modules.admin.model.vo.PcAddressHistoryInfoVo;
-import com.ydtech.modules.admin.model.vo.RegionInfoVo;
-import com.ydtech.modules.admin.model.vo.SysGeographyPositionInfoVo;
-import com.ydtech.modules.admin.model.vo.SysGeographyPositionVo;
+import com.ydtech.modules.admin.model.vo.*;
 import com.ydtech.modules.order.entity.BasePageResult;
 
 import java.util.List;
@@ -25,8 +22,9 @@ public interface SysGeographyPositionService extends IService<SysGeographyPositi
     List<SysGeographyPositionInfoVo> findLocationsWithinRadius(AdressRangeDto adressRangeDto);
 
     BasePageResult<SysGeographyPositionInfoVo> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
+    BasePageResult<SysGeographyPositionInfoVo> queryGeographyRecord(PcAddressInfoDto addressInfoDto);
 
-    PcAddressHistoryInfoVo getGeographyPosition(String dates);
+    AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source);
 
     List<SysGeographyPosition> getOnlinePeople();
 

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

@@ -4,11 +4,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.dto.*;
 import com.ydtech.modules.admin.model.po.SysPcAddress;
+import com.ydtech.modules.admin.model.po.SysPcAddressHistory;
 import com.ydtech.modules.admin.model.vo.PcAddressHistoryInfoVo;
 import com.ydtech.modules.admin.model.vo.RegionInfoVo;
 import com.ydtech.modules.order.entity.BasePageResult;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -41,7 +41,9 @@ public interface SysPcAddressService extends IService<SysPcAddress> {
 
     BasePageResult<SysPcAddress> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
 
-    PcAddressHistoryInfoVo getPcAddress(String dates);
+    PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source);
 
     List<SysPcAddress> getOnlinePeople();
+
+    BasePageResult<SysPcAddressHistory> queryPcAddressHistoryInfo(PcAddressInfoDto addressInfoDto);
 }

+ 89 - 16
src/main/java/com/ydtech/modules/admin/service/impl/SysGeographyPositionServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.modules.admin.dao.SysDeptMapper;
@@ -24,6 +25,7 @@ import com.ydtech.utils.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -230,23 +232,94 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     }
 
     @Override
-    public PcAddressHistoryInfoVo getGeographyPosition(String dates) {
-        PcAddressHistoryInfoVo pcAddressHistoryInfoVo = new PcAddressHistoryInfoVo();
-        QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
-        // 指定 COUNT(DISTINCT user_id) 查询
-        queryWrapper.select("COUNT(DISTINCT user_id) AS total").likeRight(StringUtils.isNotEmpty(dates), "create_time", dates)
-                .in("source", Arrays.asList(1, 2));
-        Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
-        Long total = (Long) result.get("total");
-        pcAddressHistoryInfoVo.setOnlineNum(total);
-        if (StringUtils.isNullOrEmpty(dates)) {
-            Date date = new Date();
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-            dates = simpleDateFormat.format(date);
+    public BasePageResult<SysGeographyPositionInfoVo> queryGeographyRecord(PcAddressInfoDto addressInfoDto) {
+        Page page = new Page(addressInfoDto.getPageNum(), addressInfoDto.getPageSize());
+        IPage<SysGeographyPositionInfoVo> 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());
+        }
+
+        return new BasePageResult<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize(), sysGeographyPositionList.getTotal(), sysGeographyPositionList.getPages(),
+                records);
+    }
+
+    @Override
+    public AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source) {
+        AppGeographyHistoryInfoVo appGeographyHistoryInfoVo = new AppGeographyHistoryInfoVo();
+        if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+
+            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))
+                    .eq(StringUtils.isNotEmpty(source),"source",source);;
+            Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
+            Long total = (Long) result.get("total");
+            appGeographyHistoryInfoVo.setOnlineNum(total);
+            if (StringUtils.isNullOrEmpty(startTime)) {
+                Date date = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                startTime = simpleDateFormat.format(date);
+            }
+            List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(startTime,source);
+            appGeographyHistoryInfoVo.setList(geographyPosition);
+
+            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source);
+            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))
+                    .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);
+            appGeographyHistoryInfoVo.setList(geographyPosition);
+
+            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source);
+            for (SysGeographyPositionRecord sysGeographyPositionRecord : sysGeographyPositionRecords) {
+
+                SysUser sysUser = sysUserService.getById(sysGeographyPositionRecord.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;
+                sysGeographyPositionRecord.setDeptName(sysDept.getName());
+
+                SysGeographyPosition sysGeographyPosition = sysGeographyPositionMapper.selectOne(new LambdaQueryWrapper<SysGeographyPosition>()
+                        .eq(SysGeographyPosition::getId,sysGeographyPositionRecord.getUserId()));
+                sysGeographyPositionRecord.setLeaderName(sysGeographyPosition.getLeaderName());
+            }
+            System.out.println("********************" + sysGeographyPositionRecords.size());
+            appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
         }
-        List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(dates);
-        pcAddressHistoryInfoVo.setList(geographyPosition);
-        return pcAddressHistoryInfoVo;
+
+        return appGeographyHistoryInfoVo;
     }
 
     @Override

+ 75 - 23
src/main/java/com/ydtech/modules/admin/service/impl/SysPcAddressServiceImpl.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.service.impl;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.modules.admin.dao.SysDeptMapper;
@@ -28,6 +29,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -95,7 +97,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
-                .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus())
+                .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus())
                 .orderByDesc(SysPcAddress::getOperationTime));
 
         return sysPcAddresses;
@@ -121,27 +123,27 @@ 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"))
-                .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
+                .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)
-                .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
+                .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())
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .eq(SysPcAddress::getSource, 2)
-                .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
+                .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
 
         Long onlineNum = 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"))
-                .eq(sysPcAddressDto.getStatus()==null,SysPcAddress::getStatus, 1)
-                .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
+                .eq(sysPcAddressDto.getStatus() == null, SysPcAddress::getStatus, 1)
+                .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
 
 
         sysPcAddressNumVo.setAllNum(all);
@@ -162,7 +164,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
                 .in(SysPcAddress::getSource, Arrays.asList("1", "2"))
                 .eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
-                .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
+                .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
 
         if (CollectionUtil.isEmpty(sysPcAddresses)) return regionInfoVos;
 
@@ -199,7 +201,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.eq(addressInfoDto.getStatus()!=null, SysPcAddress::getStatus, addressInfoDto.getStatus());
+        wrapper.eq(addressInfoDto.getStatus() != null, SysPcAddress::getStatus, addressInfoDto.getStatus());
         wrapper.orderByDesc(SysPcAddress::getOperationTime);
 
         Page<SysPcAddress> insOrdersPage = page(page, wrapper);
@@ -209,32 +211,82 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     }
 
     @Override
-    public PcAddressHistoryInfoVo getPcAddress(String dates) {
+    public PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source) {
         PcAddressHistoryInfoVo pcAddressHistoryInfoVo = new PcAddressHistoryInfoVo();
-        QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
-        // 指定 COUNT(DISTINCT user_id) 查询
-        queryWrapper.select("COUNT(DISTINCT user_id) AS total").likeRight(StringUtils.isNotEmpty(dates), "operation_time", dates)
-                .in("source", Arrays.asList(1, 2));
-        Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
-        Long total = (Long) result.get("total");
-        pcAddressHistoryInfoVo.setOnlineNum(total);
-        if (StringUtils.isNullOrEmpty(dates)) {
-            Date date = new Date();
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-            dates = simpleDateFormat.format(date);
+        if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+            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))
+                    .eq(StringUtils.isNotEmpty(source),"source",source);
+            Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+            Long total = (Long) result.get("total");
+            pcAddressHistoryInfoVo.setOnlineNum(total);
+            if (StringUtils.isNullOrEmpty(startTime)) {
+                Date date = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                startTime = simpleDateFormat.format(date);
+            }
+
+            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime,source);
+            pcAddressHistoryInfoVo.setList(pcAddress);
+
+            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime,source);
+            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);
+            Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+            Long total = (Long) result.get("total");
+            pcAddressHistoryInfoVo.setOnlineNum(total);
+
+            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime,source);
+
+            pcAddressHistoryInfoVo.setList(pcAddress);
+
+            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime,source);
+            System.out.println("********************" + sysPcAddressHistories.size());
+            pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
         }
-        List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(dates);
-        pcAddressHistoryInfoVo.setList(pcAddress);
 
         return pcAddressHistoryInfoVo;
     }
 
     @Override
     public List<SysPcAddress> getOnlinePeople() {
-        return sysPcAddressMapper.selectList(new LambdaQueryWrapper<SysPcAddress>().eq(SysPcAddress::getStatus,1));
+        return sysPcAddressMapper.selectList(new LambdaQueryWrapper<SysPcAddress>().eq(SysPcAddress::getStatus, 1));
+    }
+
+    @Override
+    public BasePageResult<SysPcAddressHistory> queryPcAddressHistoryInfo(PcAddressInfoDto addressInfoDto) {
+        Page page = new Page(addressInfoDto.getPageNum(), addressInfoDto.getPageSize());
+
+        IPage<SysPcAddressHistory> sysPcAddressHistoryIPage=sysPcAddressHistoryMapper.queryAddressHistory(page,addressInfoDto);
+
+        return new BasePageResult<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize(), sysPcAddressHistoryIPage.getTotal(), sysPcAddressHistoryIPage.getPages(),
+                sysPcAddressHistoryIPage.getRecords());
     }
 
 
+
 }
 
 

+ 116 - 14
src/main/resources/mapper/modules/admin/SysGeographyPositionRecordMapper.xml

@@ -15,25 +15,127 @@
     </resultMap>
 
     <select id="getGeographyPosition" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
-        select spa.time ,COUNT(spa.countNum) as countNum
+        select spa.time ,COUNT(spa.user_id) as countNum
         from(
         SELECT
-        DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time,
-        COUNT( DISTINCT s.user_id) as countNum
+        DISTINCT s.user_id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
         FROM
         sys_geography_position_record s
-        where
-        s.source in (1,2)
-        <if test="dates != null and dates != ''">
-            and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
-        </if>
-        GROUP BY
-        s.create_time
+        <where>
+            <if test="source != null">
+                s.source = #{source}
+            </if>
+            <if test="source == null">
+                s.source in (1,2)
+            </if>
+            <if test="dates != null and dates != ''">
+                and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
+            </if>
+        </where>
         ) as spa
-        GROUP BY
-        spa.time
-        ORDER BY
-        spa.time
+        GROUP BY spa.time
+        ORDER BY spa.time ASC
+
+    </select>
+    <select id="getGeographyPositionRecord" resultType="com.ydtech.modules.admin.model.SysGeographyPositionRecord">
+        SELECT t1.*
+        FROM sys_geography_position_record t1
+        INNER JOIN (
+        SELECT s.user_id, MAX(s.id) AS max_id
+        FROM sys_geography_position_record s
+        <where>
+            <if test="source == null">
+                s.source in (1,2)
+            </if>
+            <if test="source != null">
+                s.source = #{source}
+            </if>
+            <if test="dates != null and dates != ''">
+                and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
+            </if>
+        </where>
+        GROUP BY s.user_id
+        ) t2 ON t1.id = t2.max_id
+        ORDER BY t1.id DESC
+
+    </select>
+    <select id="getGeographyPositionSection" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
+        select spa.time ,COUNT(spa.user_id) as countNum
+        from(
+        SELECT
+        DISTINCT s.user_id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
+        FROM
+        sys_geography_position_record s
+        <where>
+            <if test="source != null">
+                s.source = #{source}
+            </if>
+            <if test="source == null">
+                s.source in (1,2)
+            </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'))
+            </if>
+        </where>
+        ) as spa
+        GROUP BY spa.time
+        ORDER BY spa.time ASC
+
+    </select>
+
+    <select id="getGeographyPositionHistory" resultType="com.ydtech.modules.admin.model.SysGeographyPositionRecord">
+        SELECT t1.*
+        FROM sys_geography_position_record t1
+        INNER JOIN (
+        SELECT s.user_id, MAX(s.id) AS max_id
+        FROM sys_geography_position_record s
+        <where>
+            <if test="source == null">
+                s.source in (1,2)
+            </if>
+            <if test="source != null">
+                s.source = #{source}
+            </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'))
+            </if>
+        </where>
+        GROUP BY s.user_id
+        ) t2 ON t1.id = t2.max_id
+        ORDER BY t1.id DESC
+
+    </select>
+    <select id="queryGeographyHistory" resultType="com.ydtech.modules.admin.model.vo.SysGeographyPositionInfoVo">
+        SELECT t1.*
+        FROM sys_geography_position_record t1
+        INNER JOIN (
+        SELECT user_id, MAX(id) AS max_id
+        FROM sys_geography_position_record
+        <where>
+            <if test="dto.lng != null and dto.lng != ''">
+                and longitude=#{dto.lng}
+            </if>
+            <if test="dto.lat != null and dto.lat != ''">
+                and latitude=#{dto.lat}
+            </if>
+            <if test="dto.source != null">
+                and source=#{dto.source}
+            </if>
+            <if test="dto.source == null">
+                and source in (1,2)
+            </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' ))
+            </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' ) like CONCAT( DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ), '%')
+            </if>
+        </where>
+        GROUP BY user_id) t2 ON t1.id = t2.max_id
+        ORDER BY t1.id DESC
 
     </select>
 

+ 115 - 11
src/main/resources/mapper/modules/admin/SysPcAddressHistoryMapper.xml

@@ -21,26 +21,130 @@
 
 
     <select id="getPcAddress" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
-        select spa.time ,COUNT(spa.countNum) as countNum
+        select spa.time, COUNT(spa.user_id) as countNum
         from(
         SELECT
-             DATE_FORMAT(s.operation_time, '%Y-%m-%d %H' ) as time,
-             COUNT( DISTINCT s.user_id) as countNum
+            DISTINCT s.user_id,DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) as time
              FROM
                  sys_pc_address_history  s
 
-             where
-                s.source in (1,2)
-                <if test="dates != null and dates != ''">
-                 and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
-                </if>
-             GROUP BY
-                s.operation_time
+             <where>
+                 <if test="source != null">
+                     s.source = #{source}
+                 </if>
+                 <if test="source == null">
+                     s.source in (1,2)
+                 </if>
+                 <if test="dates != null and dates != ''">
+                     and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
+                 </if>
+             </where>
              ) as spa
         GROUP BY
             spa.time
         ORDER BY
-            spa.time
+            spa.time ASC
+
+    </select>
+    <select id="getPcAddressSection" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
+        select spa.time, COUNT(spa.user_id) as countNum
+        from(
+        SELECT
+            DISTINCT s.user_id,DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) as time
+        FROM
+            sys_pc_address_history  s
+
+        <where>
+            <if test="source != null ">
+                s.source = #{source}
+            </if>
+            <if test="source == null ">
+                s.source in (1,2)
+            </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>
+        </where>
+        ) as spa
+        GROUP BY
+        spa.time
+        ORDER BY
+        spa.time ASC
+    </select>
+
+    <select id="getPcAddressHistory" resultType="com.ydtech.modules.admin.model.po.SysPcAddressHistory">
+        SELECT t1.*
+        FROM sys_pc_address_history t1
+        INNER JOIN (
+        SELECT s.user_id, MAX(s.id) AS max_id
+        FROM sys_pc_address_history s
+        <where>
+            <if test="source != null ">
+                s.source = #{source}
+            </if>
+            <if test="source == null">
+                s.source in (1,2)
+            </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>
+        </where>
+        GROUP BY s.user_id
+        ) t2 ON t1.id = t2.max_id
+        ORDER BY t1.id DESC
+    </select>
+
+    <select id="getPcAddressInfo" resultType="com.ydtech.modules.admin.model.po.SysPcAddressHistory">
+        SELECT t1.*
+        FROM sys_pc_address_history t1
+                 INNER JOIN (
+            SELECT s.user_id, MAX(s.id) AS max_id
+            FROM sys_pc_address_history s
+            <where>
+                <if test="source == null">
+                    s.source in (1,2)
+                </if>
+                <if test="source != null">
+                    s.source = #{source}
+                </if>
+                <if test="dates != null and dates != ''">
+                    and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
+                </if>
+            </where>
+            GROUP BY s.user_id
+        ) t2 ON t1.id = t2.max_id
+        ORDER BY t1.id DESC
+    </select>
 
+    <select id="queryAddressHistory" resultType="com.ydtech.modules.admin.model.po.SysPcAddressHistory">
+        SELECT t1.*
+        FROM sys_pc_address_history t1
+        INNER JOIN (
+        SELECT user_id, MAX(id) AS max_id
+        FROM sys_pc_address_history
+        <where>
+            <if test="dto.lng != null and dto.lng != ''">
+                and longitude=#{dto.lng}
+            </if>
+            <if test="dto.lat != null and dto.lat != ''">
+                and latitude=#{dto.lat}
+            </if>
+            <if test="dto.source != null">
+                and source=#{dto.source}
+            </if>
+            <if test="dto.source == null">
+                and source in (1,2)
+            </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>
+            <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' ) like CONCAT( DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ), '%' ))
+            </if>
+        </where>
+        GROUP BY user_id) t2 ON t1.id = t2.max_id
+        ORDER BY t1.id DESC
     </select>
+
+
 </mapper>