From 3e39169a3054ff530543a8ef44265efea6c6ef1c Mon Sep 17 00:00:00 2001 From: yitonglei Date: Thu, 19 May 2022 10:46:08 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9getPassengerNum?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E5=B0=86=E5=8F=82=E6=95=B0longitude?= =?UTF-8?q?=E3=80=81latitude=E3=80=81raidus=E8=AE=BE=E7=BD=AE=E4=B8=BA?= =?UTF-8?q?=E9=9D=9E=E5=BF=85=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitormanage/controller/Controller.java | 14 +++++++------- .../monitormanage/controller/SJZTController.java | 2 +- .../service/PassengerFlowService.java | 12 ++++++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java index 8c0c70e..29f38af 100644 --- a/src/main/java/com/hisense/monitormanage/controller/Controller.java +++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java @@ -411,16 +411,16 @@ public class Controller { @GetMapping("getPassengerNum") @ApiOperation("查询游客总数,根据经纬度和半径米、timeId从表中查询") @ApiImplicitParams({ - @ApiImplicitParam(name = "longitude", value = "经度", paramType = "query",required = true,dataType ="double"), - @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "query",required = true,dataType ="double"), - @ApiImplicitParam(name = "raidus", value = "半径,米", paramType = "query",required = true,dataType ="Integer"), + @ApiImplicitParam(name = "longitude", value = "经度", paramType = "query",required = false,dataType ="double"), + @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "query",required = false,dataType ="double"), + @ApiImplicitParam(name = "raidus", value = "半径,米", paramType = "query",required = false,dataType ="Integer"), @ApiImplicitParam(name = "timeId", value = "时间点,202205101600", paramType = "query",required = true,dataType ="string"), }) public Result getPassengerNum( - @RequestParam(value="longitude") double longitude, - @RequestParam(value="latitude") double latitude, - @RequestParam(value="raidus") Integer raidus, - @RequestParam(value="timeId") String timeId + @RequestParam(value="longitude",required = false,defaultValue = "0.00") double longitude, + @RequestParam(value="latitude",required = false,defaultValue = "0.00") double latitude, + @RequestParam(value="raidus",required = false,defaultValue = "0") Integer raidus, + @RequestParam(value="timeId",required = true) String timeId ){ return Result.success(passengerFlowService.passengerNums(longitude,latitude,raidus,timeId)); } diff --git a/src/main/java/com/hisense/monitormanage/controller/SJZTController.java b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java index 81e967b..a0707ee 100644 --- a/src/main/java/com/hisense/monitormanage/controller/SJZTController.java +++ b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java @@ -46,7 +46,7 @@ public class SJZTController { } @PostMapping("upStream") - @ApiOperation("案件上报,调用接口上报") + @ApiOperation("案件上报,调用接口上报,暂时未测试") public Result upStream(@ApiParam(value="data,直接以json字符串的形式传递",required = true) @RequestBody String data){ System.out.println("案件上报,调用接口上报"); return sjztService.upStream(JSONObject.parseObject(data)); diff --git a/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java b/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java index e870503..5298a68 100644 --- a/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java +++ b/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java @@ -15,6 +15,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.DigestUtils; +import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; import java.nio.charset.StandardCharsets; @@ -179,13 +180,16 @@ public class PassengerFlowService { } } - //根据半径,一个经纬度和hour_id查询游客总数 + //根据半径,一个经纬度和timeId查询游客总数 public JSONObject passengerNums(double longitude, double latitude, Integer raidus,String timeId){ - double[] points = LongLatUtil.getAround(longitude,latitude,raidus); QueryWrapper wrapper = new QueryWrapper<>(); + if(Double.doubleToLongBits(longitude) == Double.doubleToLongBits(0.00) || Double.doubleToLongBits(latitude) == Double.doubleToLongBits(0.00)){ + wrapper.eq("time_id",timeId); + }else{ + double[] points = LongLatUtil.getAround(longitude,latitude,raidus); + wrapper.eq("time_id",timeId).between("longitude",points[0],points[2]).between("latitude",points[1],points[3]); + } - - wrapper.eq("time_id",timeId).between("longitude",points[0],points[2]).between("latitude",points[1],points[3]); int allCount = 0; int localCount = 0; int nonLocalCount = 0;