高德热力图数据
This commit is contained in:
parent
ffdc01ef74
commit
bf6038a5ef
|
@ -50,7 +50,10 @@ public class GaodeController {
|
|||
@ApiImplicitParam(name = "page", value = "页码", required = false, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "size", value = "页码大小", required = false, dataType = "Integer")
|
||||
})
|
||||
public Result crowflowList(Integer page, Integer size, String start, String end, Integer cValue) {
|
||||
public Result crowflowList(Integer page, Integer size,
|
||||
String start, String end,
|
||||
Integer cValue,
|
||||
Boolean needAreaData) {
|
||||
|
||||
LambdaQueryWrapper<CrowdFlow> queryWrapper = new QueryWrapper<CrowdFlow>().lambda();
|
||||
if (start != null) {
|
||||
|
@ -63,6 +66,13 @@ public class GaodeController {
|
|||
queryWrapper.gt(CrowdFlow::getCnt, cValue);
|
||||
}
|
||||
|
||||
if (needAreaData == null || needAreaData == false) {
|
||||
queryWrapper.select(CrowdFlow::getId,
|
||||
CrowdFlow::getCaptureTime,
|
||||
CrowdFlow::getCnt,
|
||||
CrowdFlow::getVisitCnt);
|
||||
}
|
||||
|
||||
Page<CrowdFlow> flowPage = new Page<>();
|
||||
flowPage.addOrder(OrderItem.desc("id"));
|
||||
if (page != null && page > 0) {
|
||||
|
@ -83,16 +93,18 @@ public class GaodeController {
|
|||
* @param date 格式yyyyMMddHHmm 202211261700
|
||||
*/
|
||||
@GetMapping("fetchGaodeData")
|
||||
public void fetchGaodeDataByHand(String date) {
|
||||
public void fetchGaodeDataByHand(String date) throws InterruptedException {
|
||||
Date currentDate = new Date();
|
||||
if (date != null) {
|
||||
currentDate = DateUtil.parse(date, "yyyyMMddHHmm");
|
||||
}
|
||||
Integer cnt = _fetchGaodeData(currentDate, "total_flow");
|
||||
Thread.sleep(1 * 1000);
|
||||
Integer visitCnt = _fetchGaodeData(currentDate, "visit_flow");
|
||||
|
||||
Thread.sleep(1 * 1000);
|
||||
String total_flow = _fetchGaodeHotData(currentDate, "total_flow");
|
||||
System.out.println(total_flow);
|
||||
Thread.sleep(1 * 1000);
|
||||
String visit_flow = _fetchGaodeHotData(currentDate, "visit_flow");
|
||||
LambdaQueryWrapper<CrowdFlow> queryWrapper = new QueryWrapper<CrowdFlow>().lambda()
|
||||
.eq(CrowdFlow::getCaptureTime, currentDate);
|
||||
CrowdFlow entity = crowdFlowMapper.selectOne(queryWrapper);
|
||||
|
@ -102,9 +114,11 @@ public class GaodeController {
|
|||
crowdFlow.setCnt(cnt);
|
||||
crowdFlow.setVisitCnt(visitCnt);
|
||||
crowdFlowMapper.insert(crowdFlow);
|
||||
}else if (cnt != entity.getCnt() || visitCnt != entity.getVisitCnt()){
|
||||
}else {
|
||||
entity.setCnt(cnt);
|
||||
entity.setVisitCnt(visitCnt);
|
||||
entity.setTotalAreaData(total_flow);
|
||||
entity.setVisitAreaData(visit_flow);
|
||||
crowdFlowMapper.updateById(entity);
|
||||
}
|
||||
}
|
||||
|
@ -124,15 +138,22 @@ public class GaodeController {
|
|||
crowdFlowPage = crowdFlowMapper.selectPage(flowPage, null);
|
||||
List<CrowdFlow> crowdFlows = crowdFlowPage.getRecords();
|
||||
for (CrowdFlow crowdFlow : crowdFlows) {
|
||||
//限流策略, 每秒不超过3次。每分钟不超过100次,每小时不超过1000次
|
||||
Integer cnt = _fetchGaodeData(crowdFlow.getCaptureTime(), "total_flow");
|
||||
Thread.sleep(3 * 1000);
|
||||
Integer visitCnt = _fetchGaodeData(crowdFlow.getCaptureTime(), "visit_flow");
|
||||
//接口有限流,调一会就不通了,延时一会
|
||||
Thread.sleep(4 * 1000);
|
||||
if (crowdFlow.getVisitCnt() != visitCnt) {
|
||||
crowdFlow.setVisitCnt(visitCnt);
|
||||
}
|
||||
if (crowdFlow.getCnt() != cnt) {
|
||||
Thread.sleep(3 * 1000);
|
||||
String total_flow = _fetchGaodeHotData(crowdFlow.getCaptureTime(), "total_flow");
|
||||
Thread.sleep(3 * 1000);
|
||||
String visit_flow = _fetchGaodeHotData(crowdFlow.getCaptureTime(), "visit_flow");
|
||||
if (crowdFlow.getVisitCnt() != visitCnt || crowdFlow.getCnt() != cnt ||
|
||||
crowdFlow.getVisitAreaData() == null ||
|
||||
crowdFlow.getTotalAreaData() == null) {
|
||||
crowdFlow.setCnt(cnt);
|
||||
crowdFlow.setVisitCnt(visitCnt);
|
||||
crowdFlow.setTotalAreaData(total_flow);
|
||||
crowdFlow.setVisitAreaData(visit_flow);
|
||||
crowdFlowMapper.updateById(crowdFlow);
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +211,8 @@ public class GaodeController {
|
|||
|
||||
parame.put("appname","dz-qingdao-chengguan");
|
||||
parame.put("apiid","484");
|
||||
parame.put("areaId","WY00017X7U");
|
||||
// parame.put("areaId","WY00017X7U");
|
||||
parame.put("areaId","WY00017X7V");
|
||||
parame.put("timeType","15m");
|
||||
parame.put("flowType", flowType);
|
||||
String ds = DateUtil.format(currentDate, "yyyyMMddHHmm");
|
||||
|
@ -212,7 +234,7 @@ public class GaodeController {
|
|||
Map data = (Map) forObject.get("data");
|
||||
if (data != null) {
|
||||
Map indexData = (Map) data.get("index_data");
|
||||
Map analysis = (Map) indexData.get("analysis");
|
||||
Map analysis = (Map) indexData.get("query");
|
||||
if (analysis != null && analysis.get("area_data") != null) {
|
||||
return JSON.toJSONString(analysis.get("area_data"));
|
||||
}
|
||||
|
@ -233,7 +255,6 @@ public class GaodeController {
|
|||
@Scheduled(cron = "0 0/15 * * * ?")
|
||||
public void fetchGaodeData() {
|
||||
|
||||
System.out.println(Thread.currentThread().getName());
|
||||
DateTime dateTime = DateUtil.date().setField(DateField.MILLISECOND, 0);
|
||||
DateTime currentDate = DateUtil.offsetMinute(dateTime, -15);
|
||||
|
||||
|
@ -246,10 +267,15 @@ public class GaodeController {
|
|||
if (visitCnt == null) {
|
||||
visitCnt = 0;
|
||||
}
|
||||
|
||||
String total_flow = _fetchGaodeHotData(currentDate, "total_flow");
|
||||
String visit_flow = _fetchGaodeHotData(currentDate, "visit_flow");
|
||||
CrowdFlow crowdFlow = new CrowdFlow();
|
||||
crowdFlow.setCaptureTime(currentDate);
|
||||
crowdFlow.setCnt(cnt);
|
||||
crowdFlow.setVisitCnt(visitCnt);
|
||||
crowdFlow.setVisitAreaData(visit_flow);
|
||||
crowdFlow.setTotalAreaData(total_flow);
|
||||
crowdFlowMapper.insert(crowdFlow);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,8 +21,24 @@ public class CrowdFlow {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date captureTime;
|
||||
|
||||
/**
|
||||
* 总人数
|
||||
*/
|
||||
private Integer cnt;
|
||||
|
||||
/**
|
||||
* 访客总人数
|
||||
*/
|
||||
private Integer visitCnt;
|
||||
|
||||
/**
|
||||
* 区域总热力数据
|
||||
*/
|
||||
private String totalAreaData;
|
||||
|
||||
/**
|
||||
* 区域访客热力数据
|
||||
*/
|
||||
private String visitAreaData;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue