代码提交
parent
537a07ae34
commit
a56cf16c23
|
@ -23,6 +23,7 @@
|
||||||
<artifactId>car-business-common</artifactId>
|
<artifactId>car-business-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
package com.god.base.server.consumer;
|
//package com.god.base.server.consumer;
|
||||||
|
//
|
||||||
import lombok.extern.java.Log;
|
//import lombok.extern.java.Log;
|
||||||
import lombok.extern.log4j.Log4j;
|
//import lombok.extern.log4j.Log4j;
|
||||||
import lombok.extern.log4j.Log4j2;
|
//import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
//import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListeners;
|
//import org.springframework.amqp.rabbit.annotation.RabbitListeners;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import javax.annotation.Resource;
|
//import javax.annotation.Resource;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Description:
|
// * Description:
|
||||||
*
|
// *
|
||||||
* @Author: sun-cool-boy
|
// * @Author: sun-cool-boy
|
||||||
* @Date: 2023/11/29
|
// * @Date: 2023/11/29
|
||||||
* @info:
|
// * @info:
|
||||||
*/
|
// */
|
||||||
@Component
|
//@Component
|
||||||
@Log4j2
|
//@Log4j2
|
||||||
public class RabbitConsumer {
|
//public class RabbitConsumer {
|
||||||
|
//
|
||||||
@RabbitListener(queuesToDeclare = {@Queue("OUT_FENCE")})
|
// @RabbitListener(queuesToDeclare = {@Queue("OUT_FENCE")})
|
||||||
public void one(String msg){
|
// public void one(String msg){
|
||||||
log.info("监听到消息:{} , 队列名:{}",msg,"OUT_FENCE");
|
// log.info("监听到消息:{} , 队列名:{}",msg,"OUT_FENCE");
|
||||||
System.out.println(msg);
|
// System.out.println(msg);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queuesToDeclare = {@Queue("IN_FENCE")})
|
// @RabbitListener(queuesToDeclare = {@Queue("IN_FENCE")})
|
||||||
public void two(String msg){
|
// public void two(String msg){
|
||||||
log.info("监听到消息:{} , 队列名:{}",msg,"IN_FENCE");
|
// log.info("监听到消息:{} , 队列名:{}",msg,"IN_FENCE");
|
||||||
System.out.println(msg);
|
// System.out.println(msg);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.god.base.server.controller;
|
||||||
|
|
||||||
|
import com.god.base.server.service.RealTimeTrajectoryServer;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.god.common.core.domain.Result;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* @Author: sun-cool-boy
|
||||||
|
* @Date: 2023/11/30
|
||||||
|
* @info: 车辆实时轨迹事件绑定或解绑
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class RealTimeTrajectoryController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RealTimeTrajectoryServer realTimeTrajectoryServer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定实时轨迹事件
|
||||||
|
* @param vin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/addTrajectoryEvent")
|
||||||
|
public Result addRealTimeTrajectoryEvent(@RequestParam String vin){
|
||||||
|
return realTimeTrajectoryServer.addRealTimeTrajectoryEvent(vin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解绑实时轨迹事件
|
||||||
|
* @param vin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/delTrajectoryEvent")
|
||||||
|
public Result delRealTimeTrajectoryEvent(@RequestParam String vin){
|
||||||
|
return realTimeTrajectoryServer.delRealTimeTrajectoryEvent(vin);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.god.base.server.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.god.common.core.domain.Result;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* @Author: sun-cool-boy
|
||||||
|
* @Date: 2023/11/30
|
||||||
|
* @info: 实时轨迹业务类
|
||||||
|
*/
|
||||||
|
public interface RealTimeTrajectoryServer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为当前车辆绑定实时轨迹事件
|
||||||
|
* @param vin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Result addRealTimeTrajectoryEvent(String vin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为当前车辆绑定实时轨迹删除事件
|
||||||
|
* @param vin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Result delRealTimeTrajectoryEvent(String vin);
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.god.base.server.service.impl;
|
||||||
|
|
||||||
|
import com.god.common.core.domain.Result;
|
||||||
|
import com.god.common.redis.service.RedisService;
|
||||||
|
import com.god.base.server.service.RealTimeTrajectoryServer;
|
||||||
|
import io.swagger.v3.oas.annotations.servers.Server;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* @Author: sun-cool-boy
|
||||||
|
* @Date: 2023/11/30
|
||||||
|
* @info: 实时轨迹业务实现类
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Service
|
||||||
|
public class RealTimeTrajectoryServerImpl implements RealTimeTrajectoryServer{
|
||||||
|
|
||||||
|
public static final String EVENT = "event";//事件存储前缀
|
||||||
|
public static final String REAL_TIME_TRAJECTORY = "RealTimeTrajectory";//实时轨迹事件
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为当前车辆绑定实时轨迹事件
|
||||||
|
* @param vin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result addRealTimeTrajectoryEvent(String vin) {
|
||||||
|
//拿到 vin对应的绑定事件
|
||||||
|
List<Object> cacheList = redisService.getCacheList(EVENT + vin);
|
||||||
|
//类型转换成String
|
||||||
|
List<String> list = cacheList
|
||||||
|
.stream()
|
||||||
|
.map(String::valueOf).
|
||||||
|
toList();
|
||||||
|
//添加该事件
|
||||||
|
list.add(REAL_TIME_TRAJECTORY);
|
||||||
|
//重新存入
|
||||||
|
long l = redisService.setCacheList(EVENT + vin, cacheList);
|
||||||
|
return l > cacheList.size() ? Result.success():Result.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除当前车辆实时轨迹事件
|
||||||
|
* @param vin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result delRealTimeTrajectoryEvent(String vin) {
|
||||||
|
List<String> list = redisService.getCacheList(EVENT + vin)
|
||||||
|
.stream()
|
||||||
|
.filter(obj -> !REAL_TIME_TRAJECTORY.equals(String.valueOf(obj)))
|
||||||
|
.map(String::valueOf)
|
||||||
|
.toList();
|
||||||
|
long l = redisService.setCacheList(EVENT + vin, list);
|
||||||
|
return l > 0 ?Result.success():Result.error();
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ public class FenceAlgorithm {
|
||||||
* @param pts
|
* @param pts
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean computeFence(Point2D.Double point, List<Point2D.Double> pts){
|
public boolean computeFence(Point2D.Double point, List<Point2D.Double> pts){
|
||||||
//围栏顶点坐标数
|
//围栏顶点坐标数
|
||||||
int fenceSize = pts.size();
|
int fenceSize = pts.size();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue