SysPcAddressController.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. package com.ydtech.modules.admin.controller;
  2. import com.ydtech.core.page.HttpResult;
  3. import com.ydtech.modules.admin.constants.SystemType;
  4. import com.ydtech.modules.admin.model.SysUser;
  5. import com.ydtech.modules.admin.model.dto.*;
  6. import com.ydtech.modules.admin.model.po.SysPcAddressHistory;
  7. import com.ydtech.modules.admin.model.po.SysPcAddress;
  8. import com.ydtech.modules.admin.model.vo.KztUserDeptTreeDto;
  9. import com.ydtech.modules.admin.model.vo.PcAddressHistoryInfoVo;
  10. import com.ydtech.modules.admin.model.vo.RegionInfoVo;
  11. import com.ydtech.modules.admin.service.SysPcAddressHistoryService;
  12. import com.ydtech.modules.admin.service.SysPcAddressService;
  13. import com.ydtech.modules.admin.service.SysUserService;
  14. import com.ydtech.modules.base.controller.BaseController;
  15. import com.ydtech.modules.order.entity.BasePageResult;
  16. import com.ydtech.utils.StringUtils;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiOperation;
  19. import lombok.RequiredArgsConstructor;
  20. import org.springframework.web.bind.annotation.*;
  21. import java.text.ParseException;
  22. import java.text.SimpleDateFormat;
  23. import java.util.Date;
  24. import java.util.List;
  25. @RestController
  26. @RequestMapping("/sys/ipAddr")
  27. @RequiredArgsConstructor
  28. @Api(tags = "PC登录地址")
  29. public class SysPcAddressController extends BaseController{
  30. private final SysPcAddressService sysPcAddressService;
  31. private final SysUserService sysUserService;
  32. private final SysPcAddressHistoryService sysPcAddressHistoryService;
  33. @PostMapping("/queryPosition")
  34. @ApiOperation(value = "查询所有用户的位置列表")
  35. public HttpResult<List<SysPcAddress>> queryPosition(@RequestBody SysPcAddressDto sysPcAddressDto) {
  36. return HttpResult.ok("success", this.sysPcAddressService.getEveryone(sysPcAddressDto));
  37. }
  38. @PostMapping("/queryPositionList")
  39. @ApiOperation(value = "查询单个用户的所有位置")
  40. public HttpResult<BasePageResult<SysPcAddressHistory>> queryPositionList(@RequestBody SysGeographyPositionPageDto sysGeographyPositionPageDto) {
  41. if (sysGeographyPositionPageDto.getPageNum() == 0) {
  42. sysGeographyPositionPageDto.setPageNum(1);
  43. }
  44. if (sysGeographyPositionPageDto.getPageSize() == 0) {
  45. sysGeographyPositionPageDto.setPageSize(10);
  46. }
  47. return HttpResult.ok("success", this.sysPcAddressHistoryService.queryPositionList(sysGeographyPositionPageDto));
  48. }
  49. @PostMapping(value = "/saveIpInfo")
  50. @ApiOperation(value = "保存登录用户位置信息")
  51. public HttpResult saveIpInfo(@RequestBody IpInfoDto ipInfoDto) {
  52. SysUser user = BaseController.getUser();
  53. if (SystemType.ST_1.getCode().equals(ipInfoDto.getSystemType())) {
  54. try {
  55. // 保存登录信息
  56. sysPcAddressService.saveSysPcAddress(ipInfoDto,user);
  57. }catch (Exception e){}
  58. }
  59. return HttpResult.ok("保存成功");
  60. }
  61. /**
  62. * pc地址范围查询
  63. */
  64. @PostMapping("/locations")
  65. @ApiOperation(value = "pc地址范围查询")
  66. public HttpResult<List<SysPcAddress>> getLocationsWithinRadius(@RequestBody AdressRangeDto adressRangeDto) {
  67. return HttpResult.ok("success",sysPcAddressService.findLocationsWithinRadius(adressRangeDto));
  68. }
  69. @PostMapping("/queryPcNum")
  70. @ApiOperation(value = "人员数量概览")
  71. public HttpResult<SysPcAddressNumVo> queryPcNum(@RequestBody SysPcAddressDto sysPcAddressDto) {
  72. return HttpResult.ok("success", this.sysPcAddressService.queryPcNum(sysPcAddressDto));
  73. }
  74. @PostMapping("/queryRegionInfo")
  75. @ApiOperation(value = "区域人员概览")
  76. public HttpResult<List<RegionInfoVo>> queryRegionInfo(@RequestBody SysPcAddressDto sysPcAddressDto) {
  77. return HttpResult.ok("success", this.sysPcAddressService.queryRegionInfo(sysPcAddressDto));
  78. }
  79. @PostMapping("/queryPcAddressInfo")
  80. @ApiOperation(value = "查询同一经纬度人员信息")
  81. public HttpResult<BasePageResult<SysPcAddress>> queryPcAddressInfo(@RequestBody PcAddressInfoDto addressInfoDto) {
  82. if (addressInfoDto.getPageNum() == 0) {
  83. addressInfoDto.setPageNum(1);
  84. }
  85. if (addressInfoDto.getPageSize() == 0) {
  86. addressInfoDto.setPageSize(10);
  87. }
  88. return HttpResult.ok("success", this.sysPcAddressService.queryPcAddressInfo(addressInfoDto));
  89. }
  90. @PostMapping("/queryPcAddressHistoryInfo")
  91. @ApiOperation(value = "历史人员:同一经纬度人员信息")
  92. public HttpResult<BasePageResult<SysPcAddressHistory>> queryPcAddressHistoryInfo(@RequestBody PcAddressInfoDto addressInfoDto) {
  93. if (addressInfoDto.getPageNum() == 0) {
  94. addressInfoDto.setPageNum(1);
  95. }
  96. if (addressInfoDto.getPageSize() == 0) {
  97. addressInfoDto.setPageSize(10);
  98. }
  99. String startTime = addressInfoDto.getStartTime();
  100. String endTime = addressInfoDto.getEndTime();
  101. Date date = new Date();
  102. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  103. if (StringUtils.isEmpty(startTime)) {
  104. addressInfoDto.setStartTime(simpleDateFormat.format(date));
  105. }else {
  106. startTime = addressInfoDto.getStartTime() + " 00:00:01";
  107. Date parse = null;
  108. try {
  109. parse = simpleDateFormat.parse(startTime);
  110. } catch (ParseException e) {
  111. throw new RuntimeException(e);
  112. }
  113. addressInfoDto.setStartTime(simpleDateFormat.format(parse));
  114. }
  115. if (StringUtils.isEmpty(endTime)) {
  116. addressInfoDto.setEndTime(simpleDateFormat.format(date));
  117. }else {
  118. endTime = endTime + " 23:59:59";
  119. Date parse = null;
  120. try {
  121. parse = simpleDateFormat.parse(endTime);
  122. } catch (ParseException e) {
  123. throw new RuntimeException(e);
  124. }
  125. addressInfoDto.setEndTime(simpleDateFormat.format(parse));
  126. }
  127. return HttpResult.ok("success", this.sysPcAddressService.queryPcAddressHistoryInfo(addressInfoDto));
  128. }
  129. @GetMapping("/getPcAddress")
  130. @ApiOperation(value = "历史在线人数")
  131. public HttpResult<PcAddressHistoryInfoVo> getPcAddress(@RequestParam(value = "startTime",required = false) String startTime,
  132. @RequestParam(value = "endTime",required = false) String endTime,
  133. @RequestParam(value = "source",required = false) String source) {
  134. return HttpResult.ok("success", this.sysPcAddressService.getPcAddress(startTime,endTime,source));
  135. }
  136. @GetMapping("/getOnlinePeople")
  137. @ApiOperation(value = "PC在线用户")
  138. public HttpResult<List<SysPcAddress>> getOnlinePeople() {
  139. return HttpResult.ok("success", this.sysPcAddressService.getOnlinePeople());
  140. }
  141. @ApiOperation(value = "pc用户数机构数")
  142. @PostMapping(value = "/getUserDeptTree")
  143. public HttpResult<KztUserDeptTreeDto> getUserDeptTree() {
  144. return HttpResult.ok(sysPcAddressService.getUserDeptTree());
  145. }
  146. }