1、修改getPassengerNum方法,将参数longitude、latitude、raidus设置为非必传

This commit is contained in:
yitonglei 2022-05-19 10:46:08 +08:00
parent b6c70b0b0e
commit 3e39169a30
3 changed files with 16 additions and 12 deletions

View File

@ -411,16 +411,16 @@ public class Controller {
@GetMapping("getPassengerNum") @GetMapping("getPassengerNum")
@ApiOperation("查询游客总数根据经纬度和半径米、timeId从表中查询") @ApiOperation("查询游客总数根据经纬度和半径米、timeId从表中查询")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "longitude", value = "经度", paramType = "query",required = true,dataType ="double"), @ApiImplicitParam(name = "longitude", value = "经度", paramType = "query",required = false,dataType ="double"),
@ApiImplicitParam(name = "latitude", value = "纬度", paramType = "query",required = true,dataType ="double"), @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "query",required = false,dataType ="double"),
@ApiImplicitParam(name = "raidus", value = "半径,米", paramType = "query",required = true,dataType ="Integer"), @ApiImplicitParam(name = "raidus", value = "半径,米", paramType = "query",required = false,dataType ="Integer"),
@ApiImplicitParam(name = "timeId", value = "时间点202205101600", paramType = "query",required = true,dataType ="string"), @ApiImplicitParam(name = "timeId", value = "时间点202205101600", paramType = "query",required = true,dataType ="string"),
}) })
public Result getPassengerNum( public Result getPassengerNum(
@RequestParam(value="longitude") double longitude, @RequestParam(value="longitude",required = false,defaultValue = "0.00") double longitude,
@RequestParam(value="latitude") double latitude, @RequestParam(value="latitude",required = false,defaultValue = "0.00") double latitude,
@RequestParam(value="raidus") Integer raidus, @RequestParam(value="raidus",required = false,defaultValue = "0") Integer raidus,
@RequestParam(value="timeId") String timeId @RequestParam(value="timeId",required = true) String timeId
){ ){
return Result.success(passengerFlowService.passengerNums(longitude,latitude,raidus,timeId)); return Result.success(passengerFlowService.passengerNums(longitude,latitude,raidus,timeId));
} }

View File

@ -46,7 +46,7 @@ public class SJZTController {
} }
@PostMapping("upStream") @PostMapping("upStream")
@ApiOperation("案件上报,调用接口上报") @ApiOperation("案件上报,调用接口上报,暂时未测试")
public Result upStream(@ApiParam(value="data,直接以json字符串的形式传递",required = true) @RequestBody String data){ public Result upStream(@ApiParam(value="data,直接以json字符串的形式传递",required = true) @RequestBody String data){
System.out.println("案件上报,调用接口上报"); System.out.println("案件上报,调用接口上报");
return sjztService.upStream(JSONObject.parseObject(data)); return sjztService.upStream(JSONObject.parseObject(data));

View File

@ -15,6 +15,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.nio.charset.StandardCharsets; 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){ public JSONObject passengerNums(double longitude, double latitude, Integer raidus,String timeId){
double[] points = LongLatUtil.getAround(longitude,latitude,raidus);
QueryWrapper<PassengerFlow> wrapper = new QueryWrapper<>(); QueryWrapper<PassengerFlow> 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 allCount = 0;
int localCount = 0; int localCount = 0;
int nonLocalCount = 0; int nonLocalCount = 0;