初始化 车辆解析系统

master
冯凯 2023-11-30 18:41:57 +08:00
commit 0d79359080
23 changed files with 1310 additions and 0 deletions

46
.gitignore vendored 100644
View File

@ -0,0 +1,46 @@
######################################################################
# Build Tools
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar
target/
!.mvn/wrapper/maven-wrapper.jar
######################################################################
# IDE
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### JRebel ###
rebel.xml
### NetBeans ###
nbproject/private/
build/*
nbbuild/
dist/
nbdist/
.nb-gradle/
######################################################################
# Others
*.log
*.xml.versionsBackup
*.swp
!*/build/*.java
!*/build/*.html
!*/build/*.xml

94
pom.xml 100644
View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.parseSystem</groupId>
<artifactId>parseSystem</artifactId>
<version>3.6.3</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.15</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>
<!-- mybatis - plus 依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<version>2.7.15</version>
</dependency>
<!-- SpringBoot Boot Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.7.15</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.32</version>
</dependency>
<dependency>
<groupId>com.dragon</groupId>
<artifactId>dragon-common-redis</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>dragon-release</id>
<name>dragon-releases</name>
<url>http://10.100.1.7:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>dragon-public</id>
<name>dragon-maven</name>
<url>http://10.100.1.7:8081/repository/maven-public/</url>
</repository>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://10.100.1.7:8081/repository/maven-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,24 @@
package com.parseSystem;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/25 15:34
*/
@SpringBootApplication
public class ParseSystemApplication {
/**
*
*
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(ParseSystemApplication.class,args);
}
}

View File

@ -0,0 +1,89 @@
package com.parseSystem.event;
import com.alibaba.fastjson.JSONObject;
import com.dragon.common.redis.service.RedisService;
import com.parseSystem.utils.SpringUtils;
import com.parseSystem.vehicle.VehicleData;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
*
*
* @author
* @version 1.0
* @description:
* @date 2023/11/27 20:54
*/
@Component
@Log4j2
public class EventHandlerService {
@Autowired
private RedisService redisService;
/**
* map
*/
public static final Map<String, List<String>> eventMap=new ConcurrentHashMap<>();
/**
*
* @param vin
* @param eventServiceName
*/
public void registerEvent(String vin,String eventServiceName){
getEventList(vin).add(eventServiceName);
}
/**
*
* @param vin
* @param eventServiceName
*/
public void removeEvent(String vin,String eventServiceName){
getEventList(vin).remove(eventServiceName);
}
/**
*
* @param vehicleData
*/
public void executeEvent(VehicleData vehicleData){
List<String> eventList = getEventList(vehicleData.getVin());
eventList.forEach(eventServiceName -> {
VehicleEventService vehicleEventService = SpringUtils.getBean(eventServiceName);
vehicleEventService.executeEvent(vehicleData);
});
}
/**
*
* @param vin
* @return
*/
public List<String> getEventList(String vin){
List<String> cacheList = redisService.getCacheList("event_VIN123456789");
eventMap.put(vin,cacheList);
List<String> eventList = eventMap.get(vin);
if (eventList==null){
ArrayList<String> list = new ArrayList<>();
eventMap.put(vin,list);
}
return eventList;
}
}

View File

@ -0,0 +1,19 @@
package com.parseSystem.event;
import com.parseSystem.vehicle.VehicleData;
/**
*
*
* @author
* @version 1.0
* @date 2023/11/27 22:45
*/
public interface VehicleEventService {
/**
*
* @param vehicleData
*/
void executeEvent(VehicleData vehicleData);
}

View File

@ -0,0 +1,27 @@
package com.parseSystem.event.impl;
import com.parseSystem.event.EventHandlerService;
import com.parseSystem.event.VehicleEventService;
import com.parseSystem.vehicle.VehicleData;
import org.springframework.stereotype.Service;
/**
*
*
* @author
* @version 1.0
*
* @date 2023/11/27 20:59
*/
@Service("faultEvent")
public class FaultEvent extends EventHandlerService implements VehicleEventService {
/**
*
* @param vehicleData
*/
@Override
public void executeEvent(VehicleData vehicleData) {
System.out.println("你好故障");
}
}

View File

@ -0,0 +1,57 @@
package com.parseSystem.event.impl;
import com.dragon.common.redis.service.RedisService;
import com.parseSystem.event.EventHandlerService;
import com.parseSystem.event.VehicleEventService;
import com.parseSystem.utils.eventRuleJudge.PolygonUtil;
import com.parseSystem.vehicle.VehicleData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
*
*
* @author
* @version 1.0
*
* @date 2023/11/27 20:57
*/
@Service("fenceEvent")
public class FenceEvent extends EventHandlerService implements VehicleEventService {
@Autowired
private RedisService redisService;
/**
*
* @param vehicleData
*/
@Override
public void executeEvent(VehicleData vehicleData) {
String vin = vehicleData.getVin();
List<String> fenceList = redisService.getCacheList("fence_VIN123456789");
Double latitude = Double.valueOf(vehicleData.getLatitude()); //实时纬度
Double longitude = Double.valueOf(vehicleData.getLongitude());
Point2D.Double point = new Point2D.Double();
point.setLocation(longitude,latitude);
List<Point2D.Double> pts = new ArrayList<>();
fenceList.stream().forEach(item -> {
//循环得到每个电子围栏的坐标拼接的一个以;为分割点表示多边形的一个字符串
List<Point2D.Double> locationPts = Arrays.stream(item.split(";"))
.map(s -> s.split(","))
.map(arr -> new Point2D.Double(Double.valueOf(arr[0]), Double.valueOf(arr[1])))
.collect(Collectors.toList());
boolean inPolygon = PolygonUtil.isInPolygon(point, locationPts);
if (inPolygon){
System.out.println("在电子围栏内");
}else{
System.out.println("在电子围栏外");
}
});
}
}

View File

@ -0,0 +1,26 @@
package com.parseSystem.event.impl;
import com.parseSystem.event.EventHandlerService;
import com.parseSystem.event.VehicleEventService;
import com.parseSystem.vehicle.VehicleData;
import org.springframework.stereotype.Service;
/**
*
* @author
* @version 1.0
*
* @date 2023/11/27 20:59
*/
@Service("historyTrackEvent")
public class HistoryTrackEvent extends EventHandlerService implements VehicleEventService {
/**
*
* @param vehicleData
*/
@Override
public void executeEvent(VehicleData vehicleData) {
System.out.println("你好历史轨迹");
}
}

View File

@ -0,0 +1,27 @@
package com.parseSystem.event.impl;
import com.parseSystem.event.EventHandlerService;
import com.parseSystem.event.VehicleEventService;
import com.parseSystem.vehicle.VehicleData;
import org.springframework.stereotype.Service;
/**
*
*
* @author
* @version 1.0
* @description:
* @date 2023/11/27 20:58
*/
@Service("runtimeTraceEvent")
public class RuntimeTraceEvent extends EventHandlerService implements VehicleEventService {
/**
*
* @param vehicleData
*/
@Override
public void executeEvent(VehicleData vehicleData) {
System.out.println("你好实时轨迹");
}
}

View File

@ -0,0 +1,31 @@
package com.parseSystem.kafka.ConsumerConfig;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/25 15:37
*/
@Component
public class KafkaConsumerConfig {
@Bean
public KafkaConsumer<String, String> consumerInit() {
KafkaConsumer<String, String> consumer;
Properties properties = new Properties();
properties.put("bootstrap.servers", "117.72.43.22:9092");
properties.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
properties.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
properties.put("partitioner.class", "com.parseSystem.kafka.ConsumerConfig.MyPartitioner");
consumer = new KafkaConsumer<>(properties);
return consumer;
}
}

View File

@ -0,0 +1,43 @@
package com.parseSystem.kafka.ConsumerConfig;
import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.Cluster;
import org.apache.kafka.common.PartitionInfo;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* @authorfst
* @date2023/11/25
* @aim
*/
@Component
public class MyPartitioner implements Partitioner {
/**
* kafka 3
* @param topic
* @param key key
* @param keyBytes key
* @param value value
* @param valueBytes value
* @param cluster kafka
* @return 3, 0 1 2
*/
public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes, Cluster cluster) {
//获取topic的partitions信息
List<PartitionInfo> partitionInfos = cluster.partitionsForTopic(topic);
int partitionsNum = partitionInfos.size();
// 这里以 key 的哈希值作为分区选择依据
System.out.println("--------------------------------------");
System.out.println(Math.abs(key.hashCode()) % partitionsNum);
return Math.abs(key.hashCode()) % partitionsNum;
}
public void close() {
}
public void configure(Map<String, ?> map) {
}
}

View File

@ -0,0 +1,18 @@
package com.parseSystem.kafka.constant;
import java.security.Provider;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/27 10:27
*/
public class A {
public static void main(String[] args) {
System.out.println("=============启动类加载器================");
Class<A> aClass = A.class;
System.out.println(aClass.getClassLoader().getParent());
}
}

View File

@ -0,0 +1,25 @@
package com.parseSystem.kafka.constant;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* kafka
* @author
* @version 1.0
* @date 2023/11/25 15:36
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class kafkaConstants {
public String topic;
private String partition;
public static final String BOOSTRAP_SERVERS="117.72.43.22:9092";
}

View File

@ -0,0 +1,88 @@
package com.parseSystem.kafka.service;
import com.parseSystem.event.EventHandlerService;
import com.parseSystem.storage.service.StorageDateService;
import com.parseSystem.utils.ParseUtil;
import com.parseSystem.vehicle.VehicleData;
import lombok.extern.log4j.Log4j2;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.time.Duration;
import java.util.Collections;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/25 15:52
*/
@Service
@Log4j2
public class ConsumerService {
// /**
// * 注入kafka消费者
// */
// @Autowired
// private KafkaConsumer<String, String> consumer;
//
// /**
// * 注入事件处理服务
// */
// @Autowired
// private EventHandlerService eventHandlerService;
//
// /**
// * 注入存储服务
// */
// @Autowired
// private StorageDateService storageDateService;
//
// /**
// * 在容器启动后自动执行的初始化方法
// */
// @PostConstruct
// public void consumerInit() {
//
//
//
// TopicPartition topicPartition = new TopicPartition("test", 0);
//
// // 订阅特定分区
// consumer.assign(Collections.singleton(topicPartition));
// //开启线程持续拉取数据
// new Thread(() -> {
// while (true) {
// ConsumerRecords<String, String> records = null;
// try {
// //每个一秒钟拉取一次
// records = consumer.poll(Duration.ofMillis(1000));
// for (ConsumerRecord<String, String> record : records) {
// System.out.println(record.value());
// //解析数据
// String data = ParseUtil.sixteenToStr(record.value());
// //构建数据对象
// VehicleData vehicleData = VehicleData.getBuild(data);
// //存储数据到tiDB
// storageDateService.save(vehicleData);
// System.out.println(vehicleData);
// //调用执行事件
// eventHandlerService.executeEvent(vehicleData);
// }
// } catch (Exception e) {
// log.info("records {}", records);
// log.error(e);
// }
// }
// }).start();
// }
}

View File

@ -0,0 +1,107 @@
package com.parseSystem.rabbitmq;
import com.alibaba.fastjson.JSONObject;
import com.parseSystem.event.EventHandlerService;
import com.parseSystem.kafka.constant.kafkaConstants;
import com.parseSystem.storage.service.StorageDateService;
import com.parseSystem.utils.ParseUtil;
import com.parseSystem.vehicle.VehicleData;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.time.Duration;
import java.util.Collections;
/**
*
*
* @author
* @version 1.0
*
* @date 2023/11/27 22:19
*/
@Component
@Log4j2
public class ListenEventChangeRabbitMq {
@Autowired
private KafkaConsumer<String, String> consumer;
@Autowired
private StorageDateService storageDateService;
@Autowired
private EventHandlerService eventHandlerService;
/**
* RabbitMQ"kafka_top"
*
* @param mesg
* @param message RabbitMQMessage
* @param channel RabbitMQChannel
*/
@RabbitListener(queuesToDeclare = {@Queue(value = "kafka_top")})
public void consumerSubscribe(String mesg, Message message, Channel channel) {
log.info("收到准备订阅主题:" + mesg);
// 将接收到的消息解析为kafkaConstants对象
kafkaConstants kafkaConstants = JSONObject.parseObject(mesg, kafkaConstants.class);
// 创建TopicPartition对象
TopicPartition topicPartition = new TopicPartition(kafkaConstants.getTopic(), Integer.valueOf(kafkaConstants.getPartition()));
try {
// 手动确认接收到的消息
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
// 将消费者订阅的主题设置为"kafka_top"队列的第一个分区
consumer.assign(Collections.singleton(topicPartition));
// 开启线程持续拉取数据
while (true) {
ConsumerRecords<String, String> records = null;
try {
// 每个一秒钟拉取一次数据
records = consumer.poll(Duration.ofMillis(1000));
for (ConsumerRecord<String, String> record : records) {
System.out.println(record.value());
// 解析数据
String data = ParseUtil.sixteenToStr(record.value());
// 构建数据对象
VehicleData vehicleData = VehicleData.getBuild(data);
// 存储数据到tiDB
storageDateService.save(vehicleData);
System.out.println(vehicleData);
// 调用执行事件
eventHandlerService.executeEvent(vehicleData);
}
} catch (Exception e) {
log.info("records {}", records);
log.error(e);
}
}
// 订阅特定分区
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,15 @@
package com.parseSystem.storage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.parseSystem.vehicle.VehicleData;
import org.apache.ibatis.annotations.Mapper;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/28 15:14
*/
@Mapper
public interface StorageDateMapper extends BaseMapper<VehicleData> {
}

View File

@ -0,0 +1,15 @@
package com.parseSystem.storage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.parseSystem.vehicle.VehicleData;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/28 15:13
*/
public interface StorageDateService extends IService<VehicleData> {
}

View File

@ -0,0 +1,21 @@
package com.parseSystem.storage.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.parseSystem.storage.mapper.StorageDateMapper;
import com.parseSystem.storage.service.StorageDateService;
import com.parseSystem.vehicle.VehicleData;
import org.springframework.stereotype.Service;
import java.util.Collection;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/28 15:14
*/
@Service
public class StorageDateServiceImpl extends ServiceImpl<StorageDateMapper, VehicleData> implements StorageDateService {
}

View File

@ -0,0 +1,21 @@
package com.parseSystem.utils;
/**
*
* @author fengkai
* @version 1.0
* @date 2023/11/26 22:11
*/
public class ParseUtil {
public static String sixteenToStr(String s) {
StringBuilder sb = new StringBuilder();
String[] arr = s.split(" ");
int length = arr.length;
for (int i = 0; i < length; i++) {
int ch = Integer.parseInt(arr[i], 16);
sb.append((char) ch);
}
return sb.toString();
}
}

View File

@ -0,0 +1,103 @@
package com.parseSystem.utils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;
/**
* spring 便springbean
*
* @author dragon
*
*/
@Component
public final class SpringUtils implements BeanFactoryPostProcessor {
/**
* Spring
*/
private static ConfigurableListableBeanFactory beanFactory;
/**
*
*
* @param name
* @return Object bean
* @throws BeansException
*/
@SuppressWarnings("unchecked")
public static <T> T getBean(String name) throws BeansException {
return (T) beanFactory.getBean(name);
}
/**
* requiredType
*
* @param clz
* @return
* @throws BeansException
*/
public static <T> T getBean(Class<T> clz) throws BeansException {
T result = (T) beanFactory.getBean(clz);
return result;
}
/**
* BeanFactorybeantrue
*
* @param name
* @return boolean
*/
public static boolean containsBean(String name) {
return beanFactory.containsBean(name);
}
/**
* beansingletonprototype beanNoSuchBeanDefinitionException
*
* @param name
* @return boolean
* @throws NoSuchBeanDefinitionException
*/
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return beanFactory.isSingleton(name);
}
/**
* @param name
* @return Class
* @throws NoSuchBeanDefinitionException
*/
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
return beanFactory.getType(name);
}
/**
* beanbean
*
* @param name
* @return
* @throws NoSuchBeanDefinitionException
*/
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
return beanFactory.getAliases(name);
}
/**
* aop
*
* @param invoker
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T getAopProxy(T invoker) {
return (T) AopContext.currentProxy();
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
SpringUtils.beanFactory = beanFactory;
}
}

View File

@ -0,0 +1,79 @@
package com.parseSystem.utils.eventRuleJudge;
import java.awt.geom.Point2D;
import java.util.List;
/**
*
*/
public class PolygonUtil {
/**
*
* @param point
* @param pts
* @return truefalse
*/
public static boolean isInPolygon(Point2D.Double point, List<Point2D.Double> pts){
int N = pts.size();
boolean boundOrVertex = true;
int intersectCount = 0;//交叉点数量
double precision = 2e-10;//浮点类型计算时候与0比较时候的容差
Point2D.Double p1, p2;//临近顶点
Point2D.Double p = point; //当前点
p1 = pts.get(0);
for (int i = 1; i <= N; i++) {
if(p.equals(p1)){
return boundOrVertex;
}
p2 = pts.get(i % N);
if(p.x < Math.min(p1.x,p2.x) || p.x > Math.max(p1.x, p2.x)){
p1=p2;
continue;
}
//射线穿过算法
if(p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)){
if(p.y <= Math.max(p1.y, p2.y)){
if(p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)){
return boundOrVertex;
}
if(p1.y == p2.y){
if(p1.y == p.y){
return boundOrVertex;
}else{
++intersectCount;
}
}else{
double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y;
if(Math.abs(p.y - xinters) < precision){
return boundOrVertex;
}
if(p.y < xinters){
++intersectCount;
}
}
}
}else{
if(p.x == p2.x && p.y <= p2.y){
Point2D.Double p3 = pts.get((i+1) % N);
if(p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)){
++intersectCount;
intersectCount += 2 ;
}
}
}
p1 = p2;
}
if (intersectCount % 2 ==0){
return false;
}else {
return true;
}
}
}

View File

@ -0,0 +1,308 @@
package com.parseSystem.vehicle;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.math.BigDecimal;
import java.util.Date;
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@TableName("vehicle_data")
public class VehicleData {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* VIN
*/
private String vin;
/**
*
*/
private Date createTime;
/**
*
*/
private String longitude;
/**
*
*/
private String latitude;
/**
*
*/
private String speed;
/**
*
*/
private BigDecimal mileage;
/**
*
*/
private String voltage;
/**
*
*/
private String current;
/**
*
*/
private String resistance;
/**
*
*/
private String gear;
/**
*
*/
private String accelerationPedal;
/**
*
*/
private String brakePedal;
/**
*
*/
private String fuelConsumptionRate;
/**
*
*/
private String motorControllerTemperature;
/**
*
*/
private String motorSpeed;
/**
*
*/
private String motorTorque;
/**
*
*/
private String motorTemperature;
/**
*
*/
private String motorVoltage;
/**
*
*/
private String motorCurrent;
/**
* SOC
*/
private BigDecimal remainingBattery;
/**
*
*/
private String maximumFeedbackPower;
/**
*
*/
private String maximumDischargePower;
/**
* BMS
*/
private String selfCheckCounter;
/**
*
*/
private String totalBatteryCurrent;
/**
* V3
*/
private String totalBatteryVoltage;
/**
*
*/
private String singleBatteryMaxVoltage;
/**
*
*/
private String singleBatteryMinVoltage;
/**
*
*/
private String singleBatteryMaxTemperature;
/**
*
*/
private String singleBatteryMinTemperature;
/**
*
*/
private String availableBatteryCapacity;
/**
*
*/
private int vehicleStatus;
/**
*
*/
private int chargingStatus;
/**
*
*/
private int operatingStatus;
/**
* SOC
*/
private int socStatus;
/**
*
*/
private int chargingEnergyStorageStatus;
/**
*
*/
private int driveMotorStatus;
/**
*
*/
private int positionStatus;
/**
* EAS()
*/
private int easStatus;
/**
* PTC()
*/
private int ptcStatus;
/**
* EPS()
*/
private int epsStatus;
/**
* ABS()
*/
private int absStatus;
/**
* MCU(/)
*/
private int mcuStatus;
/**
*
*/
private int heatingStatus;
/**
*
*/
private int batteryStatus;
/**
*
*/
private int batteryInsulationStatus;
public static VehicleData getBuild(String messages) {
char start = messages.charAt(0);
char end = messages.charAt(messages.length() - 1);
System.out.println(start);
System.out.println(end);
return VehicleData.builder()
.vin(messages.substring(1, 18))
//messages.substring(18, 31)
.createTime(new Date())
.longitude(messages.substring(31, 42))
.latitude(messages.substring(42, 52))
.speed(messages.substring(52, 58))
.mileage(new BigDecimal(messages.substring(58, 69)))
.voltage(messages.substring(69, 75))
.current(messages.substring(75, 80))
.resistance(messages.substring(80, 89))
.gear(messages.substring(89, 90))
.accelerationPedal(messages.substring(90, 92))
.brakePedal(messages.substring(92, 94))
.fuelConsumptionRate(messages.substring(94, 99))
.motorControllerTemperature(messages.substring(99, 105))
.motorSpeed(messages.substring(105, 110))
.motorTorque(messages.substring(110, 114))
.motorTemperature(messages.substring(114, 120))
.motorVoltage(messages.substring(120, 125))
.motorCurrent(messages.substring(125, 133))
.remainingBattery(new BigDecimal(messages.substring(133, 139)))
.maximumFeedbackPower(messages.substring(139, 145))
.maximumDischargePower(messages.substring(145, 151))
.selfCheckCounter(messages.substring(151, 153))
.totalBatteryCurrent(messages.substring(153, 158))
.totalBatteryVoltage(messages.substring(158, 164))
.singleBatteryMaxVoltage(messages.substring(164, 168))
.singleBatteryMinVoltage(messages.substring(168, 172))
.singleBatteryMaxTemperature(messages.substring(172, 178))
.singleBatteryMinTemperature(messages.substring(178, 184))
.availableBatteryCapacity(messages.substring(184, 190))
.vehicleStatus(Integer.valueOf(messages.substring(190, 191)))
.chargingStatus(Integer.valueOf(messages.substring(191, 192)))
.operatingStatus(Integer.valueOf(messages.substring(192, 193)))
.socStatus(Integer.valueOf(messages.substring(193, 194)))
.chargingEnergyStorageStatus(Integer.valueOf(messages.substring(194, 195)))
.driveMotorStatus(Integer.valueOf(messages.substring(195, 196)))
.positionStatus(Integer.valueOf(messages.substring(196, 197)))
.easStatus(Integer.valueOf(messages.substring(197, 198)))
.ptcStatus(Integer.valueOf(messages.substring(198, 199)))
.epsStatus(Integer.valueOf(messages.substring(199, 200)))
.absStatus(Integer.valueOf(messages.substring(200, 201)))
.mcuStatus(Integer.valueOf(messages.substring(201, 202)))
.heatingStatus(Integer.valueOf(messages.substring(202, 203)))
.batteryStatus(Integer.valueOf(messages.substring(203, 204)))
.batteryInsulationStatus(Integer.valueOf(messages.substring(204, 205)))
.build();
}
}

View File

@ -0,0 +1,27 @@
spring:
redis:
host: 10.100.1.2
port: 6379
password:
application:
name: parseSystem
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://117.72.43.22:4000/test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
username: root
password: 123456
rabbitmq:
host: 47.120.38.248
port: 5672
template:
mandatory: true
listener:
simple:
prefetch: 1 # 每次取一条消息消费 消费完成取下一条
acknowledge-mode: manual # 设置消费端手动ack确认
retry:
enabled: true # 支持重试
publisher-confirms: true #确认消息已发送到交换机(Exchange)
publisher-returns: true #确认消息已发送到队列(Queue)
server:
port: 8066