| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- package com.ydtech.modules.admin.controller;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.modules.admin.constants.SystemType;
- import com.ydtech.modules.admin.model.SysUser;
- import com.ydtech.modules.admin.model.dto.*;
- import com.ydtech.modules.admin.model.po.SysPcAddressHistory;
- import com.ydtech.modules.admin.model.po.SysPcAddress;
- import com.ydtech.modules.admin.model.vo.KztUserDeptTreeDto;
- import com.ydtech.modules.admin.model.vo.PcAddressHistoryInfoVo;
- import com.ydtech.modules.admin.model.vo.RegionInfoVo;
- import com.ydtech.modules.admin.service.SysPcAddressHistoryService;
- 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;
- @RestController
- @RequestMapping("/sys/ipAddr")
- @RequiredArgsConstructor
- @Api(tags = "PC登录地址")
- public class SysPcAddressController extends BaseController{
- private final SysPcAddressService sysPcAddressService;
- private final SysUserService sysUserService;
- private final SysPcAddressHistoryService sysPcAddressHistoryService;
- @PostMapping("/queryPosition")
- @ApiOperation(value = "查询所有用户的位置列表")
- public HttpResult<List<SysPcAddress>> queryPosition(@RequestBody SysPcAddressDto sysPcAddressDto) {
- return HttpResult.ok("success", this.sysPcAddressService.getEveryone(sysPcAddressDto));
- }
- @PostMapping("/queryPositionList")
- @ApiOperation(value = "查询单个用户的所有位置")
- public HttpResult<BasePageResult<SysPcAddressHistory>> queryPositionList(@RequestBody SysGeographyPositionPageDto sysGeographyPositionPageDto) {
- if (sysGeographyPositionPageDto.getPageNum() == 0) {
- sysGeographyPositionPageDto.setPageNum(1);
- }
- if (sysGeographyPositionPageDto.getPageSize() == 0) {
- sysGeographyPositionPageDto.setPageSize(10);
- }
- return HttpResult.ok("success", this.sysPcAddressHistoryService.queryPositionList(sysGeographyPositionPageDto));
- }
- @PostMapping(value = "/saveIpInfo")
- @ApiOperation(value = "保存登录用户位置信息")
- public HttpResult saveIpInfo(@RequestBody IpInfoDto ipInfoDto) {
- SysUser user = BaseController.getUser();
- if (SystemType.ST_1.getCode().equals(ipInfoDto.getSystemType())) {
- try {
- // 保存登录信息
- sysPcAddressService.saveSysPcAddress(ipInfoDto,user);
- }catch (Exception e){}
- }
- return HttpResult.ok("保存成功");
- }
- /**
- * pc地址范围查询
- */
- @PostMapping("/locations")
- @ApiOperation(value = "pc地址范围查询")
- public HttpResult<List<SysPcAddress>> getLocationsWithinRadius(@RequestBody AdressRangeDto adressRangeDto) {
- return HttpResult.ok("success",sysPcAddressService.findLocationsWithinRadius(adressRangeDto));
- }
- @PostMapping("/queryPcNum")
- @ApiOperation(value = "人员数量概览")
- public HttpResult<SysPcAddressNumVo> queryPcNum(@RequestBody SysPcAddressDto sysPcAddressDto) {
- return HttpResult.ok("success", this.sysPcAddressService.queryPcNum(sysPcAddressDto));
- }
- @PostMapping("/queryRegionInfo")
- @ApiOperation(value = "区域人员概览")
- public HttpResult<List<RegionInfoVo>> queryRegionInfo(@RequestBody SysPcAddressDto sysPcAddressDto) {
- return HttpResult.ok("success", this.sysPcAddressService.queryRegionInfo(sysPcAddressDto));
- }
- @PostMapping("/queryPcAddressInfo")
- @ApiOperation(value = "查询同一经纬度人员信息")
- public HttpResult<BasePageResult<SysPcAddress>> queryPcAddressInfo(@RequestBody PcAddressInfoDto addressInfoDto) {
- if (addressInfoDto.getPageNum() == 0) {
- addressInfoDto.setPageNum(1);
- }
- if (addressInfoDto.getPageSize() == 0) {
- addressInfoDto.setPageSize(10);
- }
- 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 = "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(startTime,endTime,source));
- }
- @GetMapping("/getOnlinePeople")
- @ApiOperation(value = "PC在线用户")
- public HttpResult<List<SysPcAddress>> getOnlinePeople() {
- return HttpResult.ok("success", this.sysPcAddressService.getOnlinePeople());
- }
- @ApiOperation(value = "pc用户数机构数")
- @PostMapping(value = "/getUserDeptTree")
- public HttpResult<KztUserDeptTreeDto> getUserDeptTree() {
- return HttpResult.ok(sysPcAddressService.getUserDeptTree());
- }
- }
|