package com.ydtech.modules.admin.controller.websocket; 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.*; import com.ydtech.modules.admin.service.SysGeographyPositionService; import com.ydtech.modules.base.controller.BaseController; import com.ydtech.modules.order.entity.BasePageResult; import com.ydtech.utils.StringUtils; import io.swagger.annotations.Api; 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; @RestController @RequestMapping("/geography") @Api(tags = "APP地理经纬度") public class SysGeographyPositionController extends BaseController { @Resource private SysGeographyPositionService sysGeographyPositionService; @PostMapping("/queryPosition") @ApiOperation(value = "查询所有用户的位置列表") public HttpResult queryPosition(@RequestBody SysGeographyPositionDto sysGeographyPositionDto) { return HttpResult.ok("success", this.sysGeographyPositionService.queryPosition(sysGeographyPositionDto)); } @PostMapping("/queryPositionList") @ApiOperation(value = "查询单个用户的所有位置") public HttpResult> queryPositionList(@RequestBody SysGeographyPositionPageDto sysGeographyPositionPageDto) { if (sysGeographyPositionPageDto.getPageNum() == 0) { sysGeographyPositionPageDto.setPageNum(1); } if (sysGeographyPositionPageDto.getPageSize() == 0) { sysGeographyPositionPageDto.setPageSize(10); } return HttpResult.ok("success", this.sysGeographyPositionService.queryPositionList(sysGeographyPositionPageDto)); } @PostMapping("/queryPcNum") @ApiOperation(value = "人员数量概览") public HttpResult queryPcNum(@RequestBody SysGeographyPositionDto sysGeographyPositionDto) { return HttpResult.ok("success", this.sysGeographyPositionService.queryPcNum(sysGeographyPositionDto)); } @PostMapping("/queryRegionInfo") @ApiOperation(value = "区域人员概览") public HttpResult> queryRegionInfo(@RequestBody SysGeographyPositionDto sysGeographyPositionDto) { return HttpResult.ok("success", this.sysGeographyPositionService.queryRegionInfo(sysGeographyPositionDto)); } @PostMapping("/locations") @ApiOperation(value = "APP地址范围查询") public HttpResult> getLocationsWithinRadius(@RequestBody AdressRangeDto adressRangeDto) { return HttpResult.ok("success",sysGeographyPositionService.findLocationsWithinRadius(adressRangeDto)); } @PostMapping("/queryGeographyInfo") @ApiOperation(value = "查询同一经纬度人员信息") public HttpResult> queryPcAddressInfo(@RequestBody PcAddressInfoDto addressInfoDto) { if (addressInfoDto.getPageNum() == 0) { addressInfoDto.setPageNum(1); } if (addressInfoDto.getPageSize() == 0) { addressInfoDto.setPageSize(10); } return HttpResult.ok("success", this.sysGeographyPositionService.queryPcAddressInfo(addressInfoDto)); } @PostMapping("/queryGeographyRecord") @ApiOperation(value = "历史人员:查询同一经纬度人员信息") public HttpResult> 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 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(startTime,endTime,source)); } @GetMapping("/getOnlinePeople") @ApiOperation(value = "APP在线用户") public HttpResult> getOnlinePeople() { return HttpResult.ok("success", this.sysGeographyPositionService.getOnlinePeople()); } }