car-collect
commit
6c3d48bd33
|
@ -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
|
|
@ -0,0 +1,22 @@
|
|||
FROM openjdk:17-ea-slim
|
||||
LABEL authors="Car-two <3079188394@qq.com>"
|
||||
|
||||
RUN mkdir /car
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 9455
|
||||
|
||||
# 创建着陆点
|
||||
WORKDIR "/car"
|
||||
|
||||
# 复制新的运行程序
|
||||
COPY ./ruoyi-collect-server/target/ruoyi-collect-server.jar /car/app.jar
|
||||
|
||||
# 挂载持续的目录
|
||||
VOLUME /car/logs/ruoyi-collect-server
|
||||
|
||||
|
||||
# 运行你的jar包
|
||||
CMD ["java","-jar","/car/app.jar"]
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>ruoyi-collect-common</module>
|
||||
<module>ruoyi-collect-remote</module>
|
||||
<module>ruoyi-collect-server</module>
|
||||
<module>ruoyi-vehicle-cache</module>
|
||||
</modules>
|
||||
<version>3.6.3</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>ruoyi-modules-collect</artifactId>
|
||||
|
||||
|
||||
<description>
|
||||
ruoyi-modules-collect系统模块
|
||||
</description>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,97 @@
|
|||
<?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>
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-modules-collect</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-collect-common</artifactId>
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.logstash.logback</groupId>
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>6.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>3.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 邮箱依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,86 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
public class Car {
|
||||
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private Integer carId;
|
||||
/**
|
||||
* 车辆名称
|
||||
*/
|
||||
private String carName;
|
||||
/**
|
||||
* 车辆VIN编码
|
||||
*/
|
||||
private String carVin;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private Integer typeId;
|
||||
/**
|
||||
* 车辆类型名称
|
||||
*/
|
||||
private String typeName;
|
||||
/**
|
||||
* 制造厂商名称
|
||||
*/
|
||||
private String manufacturerName;
|
||||
/**
|
||||
* 电池名称
|
||||
*/
|
||||
private String batteryName;
|
||||
/**
|
||||
* 制造编号
|
||||
*/
|
||||
private String manufacturerDesc;
|
||||
/**
|
||||
* 电池编号
|
||||
*/
|
||||
private String batteryDesc;
|
||||
/**
|
||||
* 汽车状态 1在线1 已离线
|
||||
*/
|
||||
private Integer carStatus;
|
||||
/**
|
||||
* 关联企业
|
||||
*/
|
||||
private Integer firmId;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String firmName;
|
||||
|
||||
/**
|
||||
* 逻辑删除 1显示 2删除
|
||||
*/
|
||||
private Integer deletion;
|
||||
|
||||
/**
|
||||
* 標識選擇數組
|
||||
*/
|
||||
private String identifications;
|
||||
|
||||
/**
|
||||
* 強轉
|
||||
*/
|
||||
private Integer[] identificationIds;
|
||||
|
||||
|
||||
/**
|
||||
* 標識字符串
|
||||
*/
|
||||
private String identificationName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/11 20:44
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class CarBsRecord {
|
||||
/**
|
||||
* 車輛標識主鍵
|
||||
*/
|
||||
private Integer carBsId;
|
||||
|
||||
/**
|
||||
* 標識主鍵
|
||||
*/
|
||||
private Integer identificationId;
|
||||
|
||||
/**
|
||||
* 車輛主鍵
|
||||
*/
|
||||
private Integer carId;
|
||||
|
||||
/**
|
||||
* 標識主鍵
|
||||
*/
|
||||
private Integer carBsStatus;
|
||||
|
||||
/**
|
||||
* 標識選擇數組
|
||||
*/
|
||||
private Integer[] identifications;
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 车辆电子围栏中间表
|
||||
* @author Lff
|
||||
* @Date: 2023/8/22 22:27
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
public class CarFence {
|
||||
/**
|
||||
* 车辆-电子围栏中间表唯一标识:主键
|
||||
*/
|
||||
private Integer fenceMiddleId;
|
||||
/**
|
||||
* 关联围栏
|
||||
*/
|
||||
private Integer fenceId;
|
||||
/**
|
||||
* 车辆标识-状态:驶入驶出
|
||||
*/
|
||||
private Integer carFenceStatus;
|
||||
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private Integer carId;
|
||||
/**
|
||||
* 车辆名称
|
||||
*/
|
||||
private String carName;
|
||||
/**
|
||||
* 车辆VIN编码
|
||||
*/
|
||||
private String carVin;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private Integer typeId;
|
||||
/**
|
||||
* 车辆类型名称
|
||||
*/
|
||||
private String typeName;
|
||||
/**
|
||||
* 制造厂商名称
|
||||
*/
|
||||
private String manufacturerName;
|
||||
/**
|
||||
* 电池名称
|
||||
*/
|
||||
private String batteryName;
|
||||
/**
|
||||
* 制造编号
|
||||
*/
|
||||
private String manufacturerDesc;
|
||||
/**
|
||||
* 电池编号
|
||||
*/
|
||||
private String batteryDesc;
|
||||
/**
|
||||
* 汽车状态 1已离线 2在线
|
||||
*/
|
||||
private Integer carStatus;
|
||||
|
||||
/**
|
||||
* 电子围栏中间表
|
||||
*/
|
||||
private CarFence carFences;
|
||||
|
||||
/**
|
||||
* 电子围栏设置:围栏名称
|
||||
*/
|
||||
private String fenceName;
|
||||
/**
|
||||
* 电子围栏设置:围栏地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏经度/纬度
|
||||
*/
|
||||
private String logLat;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createName;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateName;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏状态 1激活 2未激活
|
||||
*/
|
||||
private Integer fenceStatus;
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/2 9:23
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class CarRecord {
|
||||
/**
|
||||
* 车辆记录表主键
|
||||
*/
|
||||
private Integer recordId;
|
||||
/**
|
||||
* 车辆标识
|
||||
*/
|
||||
private String carVin;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createDate;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endDate;
|
||||
|
||||
|
||||
/**
|
||||
* 开始时间戳
|
||||
*/
|
||||
private String startKey;
|
||||
/**
|
||||
* 结束时间戳
|
||||
*/
|
||||
private String endKey;
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/30 18:49
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class Emp {
|
||||
/**
|
||||
* 员工唯一标识:主键
|
||||
*/
|
||||
private Integer empId;
|
||||
/**
|
||||
* 员工姓名
|
||||
*/
|
||||
private String empName;
|
||||
/**
|
||||
* 员工性别
|
||||
*/
|
||||
private String empSex;
|
||||
/**
|
||||
* 员工手机号
|
||||
*/
|
||||
private String empPhone;
|
||||
/**
|
||||
* 员工邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 绑定企业
|
||||
*/
|
||||
private Integer firmId;
|
||||
/**
|
||||
* 员工状态 0在职 1停用
|
||||
*/
|
||||
private Integer empStatus;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String firmName;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/30 18:52
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class EmpMiddleCar {
|
||||
/**
|
||||
* 员工汽车中间表唯一标识:主键
|
||||
*/
|
||||
private Integer middleId;
|
||||
/**
|
||||
* 绑定员工
|
||||
*/
|
||||
private Integer empId;
|
||||
/**
|
||||
* 绑定汽车
|
||||
*/
|
||||
private Integer carId;
|
||||
/**
|
||||
* 创建人名称
|
||||
*/
|
||||
private String createName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改人名称
|
||||
*/
|
||||
private String updateName;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 逻辑删除 0正常 1删除
|
||||
*/
|
||||
private Integer deletion;
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 电子围栏实体类
|
||||
* @author Lff
|
||||
* @Date: 2023/8/22 16:52
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class Fence {
|
||||
/**
|
||||
* 电子围栏设置:主键ID
|
||||
*/
|
||||
private Integer fenceId;
|
||||
/**
|
||||
* 关联企业
|
||||
*/
|
||||
private Integer firmId;
|
||||
/**
|
||||
* 电子围栏设置:围栏名称
|
||||
*/
|
||||
private String fenceName;
|
||||
/**
|
||||
* 电子围栏设置:围栏地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏经度/纬度
|
||||
*/
|
||||
private String logLat;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createName;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateName;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
/**
|
||||
* 电子围栏设置:电子围栏状态 1激活 2未激活
|
||||
*/
|
||||
private Integer fenceStatus;
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
private Integer deletion;
|
||||
|
||||
private String firmName;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/12 9:32
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class FenceRecord {
|
||||
private Integer recordId;
|
||||
private Integer identificationId;
|
||||
private Integer fenceId;
|
||||
private Integer recordStatus;
|
||||
private Integer firmId;
|
||||
private String fenceName;
|
||||
private String address;
|
||||
private String logLat;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String createName;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
private String updateName;
|
||||
private Integer fenceStatus;
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
@Data
|
||||
public class Firm {
|
||||
|
||||
/**
|
||||
* 企业唯一标识
|
||||
*/
|
||||
private Integer firmId;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String firmName;
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String firmPhone;
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
private String deletion;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String firmState;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String createTime;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateName;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String updateTime;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/11 20:47
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class Identification {
|
||||
/**
|
||||
* 標識主鍵
|
||||
*/
|
||||
private Integer identificationId;
|
||||
|
||||
/**
|
||||
* 標識名稱
|
||||
*/
|
||||
private String identificationName;
|
||||
|
||||
/**
|
||||
* 標識狀態
|
||||
*/
|
||||
private Integer identificationStatus;
|
||||
|
||||
/**
|
||||
* 電子圍欄多選框
|
||||
*/
|
||||
private Integer[] fences;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Type {
|
||||
|
||||
private Integer typeId;
|
||||
private String typeName;
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.ruoyi.collect.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 报文实体类
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VehicleMessage {
|
||||
//消息标识
|
||||
private String identification;
|
||||
//VIN码
|
||||
private String vinCode;
|
||||
//经度
|
||||
private String longitude;
|
||||
//纬度
|
||||
private String latitude;
|
||||
//车速
|
||||
private String speedOfVehicle;
|
||||
//总里程
|
||||
private String TotalMileage;
|
||||
//总电压
|
||||
private String TotalVoltage;
|
||||
//总电流
|
||||
private String combinedCurrent;
|
||||
//绝缘电阻
|
||||
private String InsulationResistance;
|
||||
//档位
|
||||
private String gearPosition;
|
||||
//加速踏板行程值
|
||||
private String acceleratorPedalTravelValue;
|
||||
//制动踏板行程值
|
||||
private String brakePedalTravelValue;
|
||||
//燃料消耗率
|
||||
private String specificFuelConsumption;
|
||||
//电机控制器温度
|
||||
private String motorControllerTemperature;
|
||||
//电机转速
|
||||
private String motorSpeed;
|
||||
//电机转矩
|
||||
private String motorTorque;
|
||||
//电机温度
|
||||
private String motorTemperature;
|
||||
//电机电压
|
||||
private String motorVoltage;
|
||||
//电机电流
|
||||
private String motorCurrent;
|
||||
//动力电池剩余电量SOC
|
||||
private String electricalSoc;
|
||||
//当前状态允许的最大反馈功率
|
||||
private String maximumFeedbackPower;
|
||||
//当前状态允许最大放电功率
|
||||
private String maximumDischargePower;
|
||||
//BMS自检计数器
|
||||
private String bms;
|
||||
//动力电池充放电电流
|
||||
private String batteryCurrent;
|
||||
//动力电池负载端总电压V3
|
||||
private String v3;
|
||||
//单次最大电压
|
||||
private String singleMaximumVoltage;
|
||||
//单体电池最低电压
|
||||
private String minimumVoltageOfBattery;
|
||||
//单体电池最高温度
|
||||
private String maximumBatteryTemperature;
|
||||
//单体电池最低温度
|
||||
private String minimumBatteryTemperature;
|
||||
//动力电池可用容量
|
||||
private String powerBatteryAvailableCapacity;
|
||||
//车辆状态
|
||||
private Integer carStatus;
|
||||
//充电状态
|
||||
private Integer chargingState;
|
||||
//运行状态
|
||||
private Integer runningState;
|
||||
//SOC
|
||||
private String soc;
|
||||
//可充电储能装置工作状态
|
||||
private String workingCondition;
|
||||
//驱动电机状态
|
||||
private String driveMotorCondition;
|
||||
//定位是否有效
|
||||
private String whetherTheLocationValid;
|
||||
//EAS
|
||||
private String eas;
|
||||
//PTC
|
||||
private String ptc;
|
||||
//EPS
|
||||
private String eps;
|
||||
//ABS
|
||||
private String abs;
|
||||
//MCU
|
||||
private String mcu;
|
||||
//动力电池加热状态
|
||||
private String powerBatteryHeatingState;
|
||||
//动力电池当前状态
|
||||
private String powerBattery;
|
||||
//动力电池保温状态
|
||||
private String powerBatteryInsulationState;
|
||||
//DCDC
|
||||
private String dcdc;
|
||||
//CHG
|
||||
private String chg;
|
||||
|
||||
//时间
|
||||
private Long time;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.collect.domain.cache.fence;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 车辆存储围栏类型缓存
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class FenceIdTypeCache {
|
||||
|
||||
/**
|
||||
* 围栏ID
|
||||
*/
|
||||
private String fenceId;
|
||||
|
||||
/**
|
||||
* 围栏类型
|
||||
*/
|
||||
private String fenceType;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.collect.domain.cache.fence;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 电子围栏坐标和类型
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class FenceInfoTypeCache {
|
||||
|
||||
/**
|
||||
* 围栏类型
|
||||
*/
|
||||
private String fenceType;
|
||||
|
||||
/**
|
||||
* 经纬度信息
|
||||
*/
|
||||
private double[][] coordinate;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,29 @@
|
|||
<?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>
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-modules-collect</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-collect-remote</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-collect-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,91 @@
|
|||
<?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>
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-modules-collect</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-collect-server</artifactId>
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-collect-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-file-remote</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-analysis-remote</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,34 @@
|
|||
package com.ruoyi.collect;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
||||
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
public class RuoYiCollectApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(RuoYiCollectApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.ruoyi.collect.cache;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @program: Electronic-fence
|
||||
* @description: 本地缓存
|
||||
* @author: lff
|
||||
* @create: 2023-08-22 21:14
|
||||
**/
|
||||
@Data
|
||||
public class CacheItem {
|
||||
/**
|
||||
* value的值
|
||||
*/
|
||||
private Object value;
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private long expireTime;
|
||||
/**
|
||||
* 访问时间
|
||||
*/
|
||||
private long accessTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return System.currentTimeMillis() - accessTime > expireTime;
|
||||
}
|
||||
|
||||
public void updateAccessTime() {
|
||||
accessTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.ruoyi.collect.cache.service;
|
||||
|
||||
/**
|
||||
* @program: Electronic-fence
|
||||
* @description: 缓存的接口
|
||||
* @author: lff
|
||||
* @create: 2023-08-22 20:49
|
||||
**/
|
||||
public interface CacheService {
|
||||
/**
|
||||
* 添加缓存的方法
|
||||
* @param key
|
||||
* @param value
|
||||
* @param expire
|
||||
*/
|
||||
public void put(Object key,Object value,long expire);
|
||||
|
||||
public void put(Object key,Object value);
|
||||
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Object get(Object key);
|
||||
|
||||
/**
|
||||
* 获取最少使用的缓存
|
||||
* @return
|
||||
*/
|
||||
public Object getKickedKey();
|
||||
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @param key
|
||||
*/
|
||||
public void delekeyValue(Object key);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.ruoyi.collect.cache.service.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
import com.ruoyi.collect.cache.CacheItem;
|
||||
import com.ruoyi.collect.cache.service.CacheService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @program: Electronic-fence
|
||||
* @description: 缓存接口的实现
|
||||
* @author: lff
|
||||
* @create: 2023-08-22 20:52
|
||||
**/
|
||||
@Service
|
||||
public class CacheServiceImpl implements CacheService {
|
||||
|
||||
private Map<Object, CacheItem> cache;
|
||||
|
||||
public CacheServiceImpl() {
|
||||
this.cache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加缓存项
|
||||
* @param key
|
||||
* @param value
|
||||
* @param expire
|
||||
*/
|
||||
@Override
|
||||
public void put(Object key, Object value, long expire) {
|
||||
CacheItem item = new CacheItem();
|
||||
CacheItem cacheItem = new CacheItem();
|
||||
cacheItem.setValue(value);
|
||||
cacheItem.setExpireTime(expire);
|
||||
cache.put(key, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Object key, Object value) {
|
||||
CacheItem item = new CacheItem();
|
||||
item.setValue(value);
|
||||
cache.put(key, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过key获取缓存项
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object get(Object key) {
|
||||
CacheItem item = cache.get(key);
|
||||
if (item != null && !item.isExpired()) {
|
||||
item.updateAccessTime();
|
||||
return item.getValue();
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清除已过期的缓存项
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getKickedKey() {
|
||||
for (Map.Entry<Object, CacheItem> entry : cache.entrySet()) {
|
||||
if (entry.getValue().isExpired()) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Key以及对应的值
|
||||
* @param key
|
||||
*/
|
||||
@Override
|
||||
public void delekeyValue(Object key) {
|
||||
cache.remove(key);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package com.ruoyi.collect.config;
|
||||
|
||||
import org.apache.kafka.clients.admin.AdminClientConfig;
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
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.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.common.TopicPartition;
|
||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/19 11:32
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
public class ConsumeTest {
|
||||
|
||||
public void startKafkaProduct() {
|
||||
Properties properties = new Properties();
|
||||
|
||||
properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "43.142.96.146:9092");
|
||||
|
||||
properties.put("group-id","topic-test");
|
||||
|
||||
|
||||
properties.put("enable.auto.commit","true");
|
||||
|
||||
properties.put("auto.commit.interval.ms","1000");
|
||||
|
||||
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
|
||||
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(properties);
|
||||
|
||||
consumer.subscribe(Arrays.asList("topic-test"));
|
||||
|
||||
while (true){
|
||||
ConsumerRecords<String, String> poll = consumer.poll(Duration.ofSeconds(5));
|
||||
|
||||
for (ConsumerRecord<String, String> stringStringConsumerRecord : poll) {
|
||||
String topic = stringStringConsumerRecord.topic();
|
||||
long offset = stringStringConsumerRecord.offset();
|
||||
String key = stringStringConsumerRecord.key();
|
||||
|
||||
String value = stringStringConsumerRecord.value();
|
||||
|
||||
System.out.println("消费者消费的信息是:"+value+",key是:"+key+",偏移量是:"+offset+",分区是:"+topic);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Properties properties = new Properties();
|
||||
|
||||
properties.put("bootstrap.servers", "43.142.96.146:9092");
|
||||
|
||||
properties.put("group.id","test");
|
||||
|
||||
properties.put("auto.commit.interval.ms","1000");
|
||||
|
||||
//序列化(建议使用Json,这种序列化方式可以无需额外配置传输实体类)
|
||||
properties.put("key.deserializer", StringDeserializer.class.getName());
|
||||
|
||||
properties.put("value.deserializer", StringDeserializer.class.getName());
|
||||
|
||||
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(properties);
|
||||
|
||||
TopicPartition test = new TopicPartition("test", 1);
|
||||
consumer.assign(Collections.singleton(test));
|
||||
while (true){
|
||||
ConsumerRecords<String, String> poll = consumer.poll(Duration.ofSeconds(5));
|
||||
for (ConsumerRecord<String, String> stringStringConsumerRecord : poll) {
|
||||
|
||||
String topic = stringStringConsumerRecord.topic();
|
||||
|
||||
long offset = stringStringConsumerRecord.offset();
|
||||
|
||||
String key = stringStringConsumerRecord.key();
|
||||
|
||||
String value = stringStringConsumerRecord.value();
|
||||
|
||||
System.out.println("消费者消费的信息是:"+value+",key是:"+key+",偏移量是:"+offset+",分区是:"+topic);
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.collect.config;
|
||||
|
||||
import org.apache.kafka.clients.admin.AdminClientConfig;
|
||||
import org.apache.kafka.clients.admin.NewTopic;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.kafka.core.KafkaAdmin;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/18 15:35
|
||||
* @Description:
|
||||
*/
|
||||
@Configuration
|
||||
public class KafkaTopic {
|
||||
@Bean
|
||||
public KafkaAdmin kafkaAdmin() {
|
||||
Map<String, Object> configs = new HashMap<>();
|
||||
configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "43.142.96.146:9092");
|
||||
return new KafkaAdmin(configs);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NewTopic topic1() {
|
||||
return new NewTopic("qaq", 50, (short) 1);
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public NewTopic topic2() {
|
||||
// return new NewTopic("test", 100, (short) 1);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.ruoyi.collect.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.kafka.clients.admin.AdminClientConfig;
|
||||
import org.apache.kafka.clients.producer.*;
|
||||
import org.apache.kafka.common.header.internals.RecordHeader;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/19 11:17
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
public class ProductTest {
|
||||
public void startKafka(){
|
||||
Properties properties = new Properties();
|
||||
|
||||
|
||||
properties.put("bootstrap.servers", "43.142.96.146:9092");
|
||||
|
||||
properties.put("acks","all");
|
||||
|
||||
|
||||
properties.put("auto.create.topics.enable", "true");
|
||||
|
||||
properties.put("key.serializer", StringSerializer.class.getName());
|
||||
properties.put("value.serializer", StringSerializer.class.getName());
|
||||
|
||||
|
||||
KafkaProducer<String, String> kafkaProducer = new KafkaProducer<>(properties);
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>("topic-test","topic:"+i);
|
||||
//发送消息成功
|
||||
kafkaProducer.send(producerRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Properties properties = new Properties();
|
||||
|
||||
properties.put("bootstrap.servers", "43.142.96.146:9092");
|
||||
|
||||
properties.put("topic","test");
|
||||
properties.put("acks","all");
|
||||
|
||||
properties.put("auto.create.topics.enable",true);
|
||||
|
||||
properties.put("key.serializer", StringSerializer.class.getName());
|
||||
properties.put("value.serializer", StringSerializer.class.getName());
|
||||
|
||||
KafkaProducer<String, String> kafkaProducer = new KafkaProducer<>(properties);
|
||||
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
System.out.println("正在发送第"+i+"条消息------");
|
||||
|
||||
ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>("test", 2,"","topic:"+i);
|
||||
producerRecord.headers().add(new RecordHeader("topicId", "1K3MIzCoT7u2cUDOu_nKpA".getBytes()));
|
||||
//发送消息成功
|
||||
kafkaProducer.send(producerRecord, new Callback() {
|
||||
@Override
|
||||
public void onCompletion(RecordMetadata recordMetadata, Exception e) {
|
||||
if(e!=null){
|
||||
System.out.println("程序异常");
|
||||
}else{
|
||||
String topic = recordMetadata.topic();
|
||||
long offset = recordMetadata.offset();
|
||||
int partition = recordMetadata.partition();
|
||||
System.out.println("生产者,主题是:"+topic+",分区是:"+partition+",偏移量是:"+offset+"---");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
kafkaProducer.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.ruoyi.collect.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.ruoyi.collect.domain.VehicleMessage;
|
||||
import com.ruoyi.collect.service.IElectronicFence;
|
||||
import com.ruoyi.collect.service.impl.ElectronicdFenceimpl;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
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.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/28 9:02
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RabbitmqConsumeMessage {
|
||||
@Autowired
|
||||
private IElectronicFence iElectronicFence;
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
@RabbitListener(queuesToDeclare = {@Queue("fence_handler_queue")})
|
||||
public void fenceHandlerQueue(String msg, Message message, Channel channel){
|
||||
log.info("消费者开始消费:信息是:{},队列是:{}",msg,"fence_handler_queue");
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
Long fenceHandlerQueue = redisTemplate.opsForSet().add("fence_handler_queue", messageId);
|
||||
try {
|
||||
if (fenceHandlerQueue == 1) {
|
||||
VehicleMessage vehicleMessage = JSON.parseObject(msg, VehicleMessage.class);
|
||||
iElectronicFence.electronicFence(vehicleMessage);
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
log.info("消费者消费成功:信息是:{},队列是:{}", msg, "fence_handler_queue");
|
||||
} else {
|
||||
log.info("消息重复消费********");
|
||||
}
|
||||
} catch(IOException e){
|
||||
log.info("消费者消费失败:信息是:{},队列是:{}", msg, "fence_handler_queue");
|
||||
try {
|
||||
//回退消息
|
||||
log.info("消费者消费失败,进行回退:信息是:{},队列是:{}", msg, "fence_handler_queue");
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
} catch (IOException ex) {
|
||||
log.info("消费者回退失败:信息是:{},队列是:{}", msg, "fence_handler_queue");
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.ruoyi.collect.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.ruoyi.collect.domain.VehicleMessage;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
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.data.redis.core.RedisTemplate;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/30 18:29
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RabbitmqConsumeSendEmail {
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
@Autowired
|
||||
private JavaMailSender javaMailSender;
|
||||
@RabbitListener(queuesToDeclare = {@Queue("sendFactorError")})
|
||||
public void sendEmail(String msg, Message message, Channel channel){
|
||||
log.info("消费者开始消费,发送邮件,队列是:{},消息是:{}","sendFactorError",msg);
|
||||
VehicleMessage vehicleMessage = JSON.parseObject(msg, VehicleMessage.class);
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
Long sendFactorError = redisTemplate.opsForSet().add("sendFactorError", messageId);
|
||||
try {
|
||||
if(sendFactorError==1){
|
||||
if(redisTemplate.hasKey("car_"+vehicleMessage.getVinCode())){
|
||||
log.info("邮件已经提示!请稍后。。。");
|
||||
}else{
|
||||
//将第一次报警信息存入缓存当中,如果第一次报警过后
|
||||
System.out.println("发送邮件----------");
|
||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setSubject("通知");
|
||||
helper.setTo("3079188394@qq.com");
|
||||
helper.setText("您的汽车超出了围栏范围***");
|
||||
helper.setFrom("3079188394@qq.com");
|
||||
javaMailSender.send(mimeMessage);
|
||||
log.info("消费者发送邮件成功,队列是:{},信息是:{}","sendFactorError",msg);
|
||||
//消息手动确认
|
||||
|
||||
redisTemplate.opsForValue().set("car_"+vehicleMessage.getVinCode(),"",3, TimeUnit.MINUTES);
|
||||
}
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
|
||||
}else{
|
||||
log.info("消费者重复消费*****队列是:{}","sendFactorError");
|
||||
}//最大异常
|
||||
} catch (Exception e) {
|
||||
log.info("消息消费失败,消息回退,队列是:{},消息是:{}","sendFactorError",msg);
|
||||
try {
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
|
||||
} catch (IOException ex) {
|
||||
log.info("消息回退失败,回退异常!!");
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.ruoyi.collect.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.rabbitmq.client.Channel;
|
||||
|
||||
|
||||
import com.ruoyi.analysis.constants.VehicleConstants;
|
||||
import com.ruoyi.analysis.constants.VehicleStatusEntity;
|
||||
import com.ruoyi.collect.domain.CarRecord;
|
||||
import com.ruoyi.collect.service.CarService;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
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.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/2 9:28
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RabbitmqConsumeStart {
|
||||
@Autowired
|
||||
private CarService carService;
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
@RabbitListener(queuesToDeclare = {@Queue(VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE)})
|
||||
public void getStartCar(String msg, Message message, Channel channel){
|
||||
log.info("消费者开始消费,队列是:{},消息是:{}",VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE,msg);
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
|
||||
Long add = redisTemplate.opsForSet().add(VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE, messageId);
|
||||
|
||||
try {
|
||||
if(add==1){
|
||||
//消费对象
|
||||
VehicleStatusEntity vehicleStatusEntity = JSON.parseObject(msg, VehicleStatusEntity.class);
|
||||
if(vehicleStatusEntity.getStatus()==1){
|
||||
log.info("车辆进行上线操作");
|
||||
carService.startIsCar(vehicleStatusEntity.getVin());
|
||||
|
||||
carService.addRecord(vehicleStatusEntity.getVin(),vehicleStatusEntity.getTimestamp());
|
||||
log.info("消费者消费成功,车辆启动,队列是:{},消息是:{}",VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE,msg);
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
}else{
|
||||
carService.endIsCar(vehicleStatusEntity.getVin());
|
||||
Date date = new Date(vehicleStatusEntity.getTimestamp());
|
||||
if(redisTemplate.hasKey(RedisFinalVariable.RECORD_ID+vehicleStatusEntity.getVin())){
|
||||
String s = redisTemplate.opsForValue().get(RedisFinalVariable.RECORD_ID + vehicleStatusEntity.getVin());
|
||||
CarRecord carRecord = JSON.parseObject(s, CarRecord.class);
|
||||
carRecord.setEndDate(date);
|
||||
carRecord.setEndKey(String.valueOf(vehicleStatusEntity.getTimestamp()));
|
||||
carService.endCarRecord(carRecord);
|
||||
log.info("消费者消费成功,车辆关闭,队列是:{},消息是:{}",VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE,msg);
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
log.info("消费者消费失败,消息重复消费,队列是:{},消息是:{}",VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE,msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
log.info("消费者消费失败,队列是:{},消息是:{}",VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE,msg);
|
||||
//消息回退
|
||||
try {
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
|
||||
} catch (IOException ex) {
|
||||
log.info("消费者回退失败,队列是:{},消息是:{}",VehicleConstants.VEHICLE_STATUS_UPDATE_QUEUE,msg);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.ruoyi.collect.config;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/2 15:42
|
||||
* @Description:
|
||||
*/
|
||||
public class RedisFinalVariable {
|
||||
/**
|
||||
* 记录表id常量
|
||||
*/
|
||||
public static final String RECORD_ID="RECORD_ID";
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.ruoyi.collect.controller;
|
||||
|
||||
import com.ruoyi.collect.domain.Fence;
|
||||
import com.ruoyi.collect.service.BusinessService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 电子围栏区域
|
||||
* @author Lff
|
||||
* @Date: 2023/8/22 17:00
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class BusinessController {
|
||||
@Autowired
|
||||
private BusinessService businessService;
|
||||
|
||||
|
||||
/**
|
||||
* @return 查询电子围栏列表
|
||||
*/
|
||||
@GetMapping("/AllFence")
|
||||
public R<List<Fence>> AllFence(){
|
||||
return businessService.AllFence();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param fenceId
|
||||
* @return 查看电子围栏/回显
|
||||
*/
|
||||
@GetMapping("/echoFence/{fenceId}")
|
||||
public R<Fence> echoFence(@PathVariable Integer fenceId){
|
||||
return businessService.echoFence(fenceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fence
|
||||
* @return 修改电子围栏
|
||||
*/
|
||||
@PostMapping("/updateFence")
|
||||
public R updateFence(@RequestBody Fence fence){
|
||||
return businessService.updateFence(fence);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fenceId
|
||||
* @return 删除电子围栏
|
||||
*/
|
||||
@GetMapping("/deleteFence/{fenceId}")
|
||||
public R deleteFence(@PathVariable Integer fenceId){
|
||||
return businessService.deleteFence(fenceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fenceId
|
||||
* @param fenceStatus
|
||||
* @return 开启/关闭电子围栏
|
||||
*/
|
||||
@GetMapping("/openIsClose")
|
||||
public R openIsClose(@RequestParam Integer fenceId,@RequestParam Integer fenceStatus){
|
||||
return businessService.openIsClose(fenceId,fenceStatus);
|
||||
}
|
||||
|
||||
@PostMapping("/addFence")
|
||||
public R addFence(@RequestBody Fence fence){
|
||||
return businessService.addFence(fence);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
package com.ruoyi.collect.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
import com.ruoyi.analysis.feign.AnalysisRemote;
|
||||
import com.ruoyi.collect.domain.*;
|
||||
import com.ruoyi.collect.service.CarService;
|
||||
import com.ruoyi.collect.service.IElectronicFence;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 汽车增删改查
|
||||
*/
|
||||
|
||||
@RequestMapping("/car")
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class CarController {
|
||||
|
||||
@Autowired
|
||||
private CarService carService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
@Autowired
|
||||
private IElectronicFence iElectronicFence;
|
||||
@Autowired
|
||||
private AnalysisRemote analysisRemote;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 汽车列表展示
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/carList")
|
||||
public R<List<Car>> carList(@RequestBody Car car){
|
||||
log.info("功能名称,汽车列表展示,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
|
||||
R<List<Car>> listR = carService.carList(car);
|
||||
log.info("功能名称,汽车列表展示,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(listR.getData()));
|
||||
return listR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param carVin 车联唯一标识
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/startIsCar")
|
||||
public R startIsCar(@RequestParam String carVin){
|
||||
R r = carService.startIsCar(carVin);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**`
|
||||
* 查询汽车类型下拉框
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/findByType")
|
||||
public R<List<Type>> findByType(){
|
||||
log.info("功能名称,查询汽车类型下拉框,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
|
||||
R<List<Type>> byType = carService.findByType();
|
||||
log.info("功能名称,查询汽车类型下拉框,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(byType.getData()));
|
||||
return byType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择企业
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/findByFirm")
|
||||
public R<List<Firm>> findByFirm(){
|
||||
log.info("功能名称,选择企业,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
|
||||
R<List<Firm>> byFirm = carService.findByFirm();
|
||||
log.info("功能名称,选择企业,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(byFirm.getData()));
|
||||
return byFirm;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加车辆
|
||||
* @param car
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addCar")
|
||||
public R addCar(@RequestBody Car car){
|
||||
log.info("功能名称,添加车辆,请求URI:{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(car));
|
||||
R r = carService.addCar(car);
|
||||
log.info("功能名称,添加车辆,请求URI:{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(r.getData()));
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除汽车
|
||||
* @param carId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/deleteCar/{carId}")
|
||||
public R deleteCar(@PathVariable Integer carId){
|
||||
log.info("功能名称,删除汽车,请求URI:{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),carId);
|
||||
R r = carService.deleteCar(carId);
|
||||
log.info("功能名称,删除汽车,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(r.getData()));
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑车辆信息回显
|
||||
* @param carId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/findByCar/{carId}")
|
||||
public R<Car> findByCar(@PathVariable Integer carId){
|
||||
log.info("功能名称,编辑车辆信息回显,请求URI:{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),carId);
|
||||
R<Car> byCar = carService.findByCar(carId);
|
||||
log.info("功能名称,编辑车辆信息回显,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(byCar.getData()));
|
||||
return byCar;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车辆
|
||||
* @param car
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateCar")
|
||||
public R updateCar(@RequestBody Car car){
|
||||
log.info("功能名称,修改车辆,请求URI:{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(car));
|
||||
R r = carService.updateCar(car);
|
||||
log.info("功能名称,修改车辆,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(r.getData()));
|
||||
return r;
|
||||
}
|
||||
|
||||
@GetMapping("/testCarVin/{carVin}")
|
||||
public R testCarVin(@PathVariable String carVin){
|
||||
VehicleMessage vehicleMessage = new VehicleMessage();
|
||||
vehicleMessage.setVinCode(carVin);
|
||||
// 121.424722,31.244579;121.427309,31.218271;121.482644,31.228524;121.476895,31.250754
|
||||
vehicleMessage.setLatitude("31.607563");
|
||||
vehicleMessage.setLongitude("120.521853");
|
||||
|
||||
iElectronicFence.electronicFence(vehicleMessage);
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
@GetMapping("/showCarRecord")
|
||||
public R<List<CarRecord>> showCarRecord(){
|
||||
return carService.showCarRecord();
|
||||
}
|
||||
|
||||
@GetMapping("/showCarRecordById/{recordId}")
|
||||
public R<CarRecord> showCarRecordById(@PathVariable Integer recordId){
|
||||
return carService.showCarRecordById(recordId);
|
||||
}
|
||||
|
||||
@GetMapping("/queryHistory/{recordId}")
|
||||
public AjaxResult queryHistory(@PathVariable Integer recordId) throws IOException, ParseException, NoSuchFieldException, InvocationTargetException, IllegalAccessException {
|
||||
R<CarRecord> carRecordR = carService.showCarRecordById(recordId);
|
||||
AjaxResult ajaxResult = analysisRemote.queryHistory(carRecordR.getData());
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
@GetMapping("/GetRedis/{carVin}")
|
||||
public R<List<CarFence>> GetRedis(@PathVariable String carVin){
|
||||
List<Object> cacheList = redisService.getCacheList(carVin);
|
||||
|
||||
ArrayList<CarFence> carFences = new ArrayList<>();
|
||||
|
||||
for (Object o : cacheList) {
|
||||
carFences.add((CarFence) o);
|
||||
}
|
||||
return R.ok(carFences);
|
||||
}
|
||||
|
||||
@GetMapping("/addSet")
|
||||
public void addSet(){
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.ruoyi.collect.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.collect.domain.Emp;
|
||||
import com.ruoyi.collect.service.EmpService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/30 18:56
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/emp")
|
||||
@Log4j2
|
||||
public class EmpController {
|
||||
@Autowired
|
||||
private EmpService empService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
@GetMapping("/EmpAll")
|
||||
public R<List<Emp>> EmpAll(){
|
||||
log.info("功能名称:查询员工列表,请求URL:{},请求方法:{}",request.getServletPath(),request.getMethod());
|
||||
|
||||
List<Emp> emps = empService.EmpAll();
|
||||
|
||||
log.info("功能名称:查询员工列表,请求URL:{},请求方法:{},返回结果是:{}",request.getServletPath(),request.getMethod(), JSON.toJSONString(emps));
|
||||
|
||||
return R.ok(emps);
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/addEmp")
|
||||
public R addEmp(@RequestBody Emp emp){
|
||||
log.info("功能名称:添加员工绑定公司信息,请求URL:{},请求方法:{},请求参数:{}",request.getServletPath(),request.getMethod(),emp);
|
||||
|
||||
int i = empService.addEmp(emp);
|
||||
|
||||
if(i>0){
|
||||
return R.ok("添加成功");
|
||||
}else{
|
||||
return R.ok("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/showEmpById/{empId}")
|
||||
public R<List<Emp>> showEmpById(@PathVariable Integer empId){
|
||||
List<Emp> emps = empService.showEmpById(empId);
|
||||
return R.ok(emps);
|
||||
}
|
||||
|
||||
@PostMapping("/updateEmp")
|
||||
public R updateEmp(@RequestBody Emp emp){
|
||||
return empService.updateEmp(emp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.collect.controller;
|
||||
|
||||
import com.ruoyi.collect.domain.Identification;
|
||||
import com.ruoyi.collect.service.IdentificationService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/11 20:50
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/Identification")
|
||||
public class IdentificationController {
|
||||
@Autowired
|
||||
private IdentificationService identificationService;
|
||||
//查詢所有標識
|
||||
@GetMapping("/showIdentification")
|
||||
public R<List<Identification>> showIdentification(){
|
||||
return identificationService.showIdentification();
|
||||
}
|
||||
//添加標識圍欄
|
||||
@PostMapping("/addIdentification")
|
||||
public R addIdentification(@RequestBody Identification identification){
|
||||
return identificationService.addIdentification(identification);
|
||||
}
|
||||
//修改標識圍欄
|
||||
@PostMapping("/updateIdentification")
|
||||
public R updateIdentification(@RequestBody Identification identification){
|
||||
return identificationService.updateIdentification(identification);
|
||||
}
|
||||
//刪除標識
|
||||
@GetMapping("/deleteIdentification/{identificationId}")
|
||||
public R deleteIdentification(@PathVariable Integer identificationId){
|
||||
return identificationService.deleteIdentification(identificationId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package com.ruoyi.collect.controller;
|
||||
|
||||
|
||||
import com.ruoyi.collect.config.ConsumeTest;
|
||||
import com.ruoyi.collect.config.ProductTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/17 21:58
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
public class SendController {
|
||||
|
||||
|
||||
|
||||
// @Transactional
|
||||
// @GetMapping("/aaa")
|
||||
// public void aaa() {
|
||||
//// Properties properties = new Properties();
|
||||
//// properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,"10.100.27.5:9092");
|
||||
////
|
||||
//// AdminClient adminClient = AdminClient.create(properties);
|
||||
//// // props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
|
||||
////
|
||||
//// NewTopic send = new NewTopic("send", 1, (short) 1);
|
||||
////
|
||||
//// adminClient.createTopics(Collections.singleton(send));
|
||||
//
|
||||
// kafkaTemplate.send("dsadasd", "word", "消息1");
|
||||
//
|
||||
// //NewTopic newTopic = new NewTopic("my_topic", 1, (short) 1);
|
||||
// System.out.println("发送成功");
|
||||
// }
|
||||
|
||||
|
||||
@Transactional
|
||||
@GetMapping("/bbb")
|
||||
public void bbb() {
|
||||
// Properties properties = new Properties();
|
||||
// properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,"10.100.27.5:9092");
|
||||
//
|
||||
// AdminClient adminClient = AdminClient.create(properties);
|
||||
// // props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
|
||||
//
|
||||
// NewTopic send = new NewTopic("send", 1, (short) 1);
|
||||
//
|
||||
// adminClient.createTopics(Collections.singleton(send));
|
||||
//开启消费者
|
||||
|
||||
|
||||
ProductTest productTest = new ProductTest();
|
||||
|
||||
productTest.startKafka();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@GetMapping("/ccc")
|
||||
public void ccc() {
|
||||
// Properties properties = new Properties();
|
||||
// properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,"10.100.27.5:9092");
|
||||
//
|
||||
// AdminClient adminClient = AdminClient.create(properties);
|
||||
// // props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
|
||||
//
|
||||
// NewTopic send = new NewTopic("send", 1, (short) 1);
|
||||
//
|
||||
// adminClient.createTopics(Collections.singleton(send));
|
||||
//开启消费者
|
||||
|
||||
ConsumeTest consumeTest = new ConsumeTest();
|
||||
consumeTest.startKafkaProduct();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.collect.mapper;
|
||||
|
||||
import com.ruoyi.collect.domain.Fence;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/22 17:00
|
||||
* @Description:
|
||||
*/
|
||||
@Repository
|
||||
public interface BusinessMapper {
|
||||
|
||||
List<Fence> AllFence();
|
||||
|
||||
Fence echoFence(@Param("fenceId") Integer fenceId);
|
||||
|
||||
int updateFence(Fence fence);
|
||||
|
||||
int deleteFence(@Param("fenceId") Integer fenceId);
|
||||
|
||||
int openIsClose(@Param("fenceId") Integer fenceId, @Param("fenceStatus") Integer fenceStatus);
|
||||
|
||||
int addFence(Fence fence);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.ruoyi.collect.mapper;
|
||||
|
||||
|
||||
import com.ruoyi.collect.domain.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CarMapper {
|
||||
|
||||
|
||||
List<Car> carList(Car car);
|
||||
|
||||
List<Type> findByType();
|
||||
|
||||
|
||||
List<Firm> findByFirm();
|
||||
|
||||
int addCar(Car car);
|
||||
|
||||
int deleteCar(@Param("carId") Integer carId);
|
||||
|
||||
Car findByCar(@Param("carVin") String carVin);
|
||||
|
||||
int updateCar(Car car);
|
||||
|
||||
void startIsCar(@Param("carVin") String carVin);
|
||||
|
||||
List<CarRecord> showCarRecord();
|
||||
|
||||
void endCar(@Param("carVin") String vin);
|
||||
|
||||
int addRecord(CarRecord carRecord);
|
||||
|
||||
void endCarRecord(CarRecord carRecord);
|
||||
|
||||
Car fendByCarId(@Param("carId") Integer carId);
|
||||
|
||||
CarRecord showCarRecordById(@Param("recordId") Integer recordId);
|
||||
|
||||
int addIdentificationRecord(@Param("carId") Integer carId, @Param("identificationId") Integer identificationId);
|
||||
|
||||
int deleteCarIdentification(@Param("carId") Integer carId);
|
||||
|
||||
List<Identification> showCarBsRecord(@Param("carId") Integer carId);
|
||||
|
||||
List<FenceRecord> showFence(@Param("identificationId") Integer identificationId);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.collect.mapper;
|
||||
|
||||
import com.ruoyi.collect.domain.Emp;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/30 18:56
|
||||
* @Description:
|
||||
*/
|
||||
@Repository
|
||||
public interface EmpMapper {
|
||||
List<Emp> EmpAll();
|
||||
|
||||
int addEmp(Emp emp);
|
||||
|
||||
List<Emp> showEmpById(@Param("empId") Integer empId);
|
||||
|
||||
int updateEmp(Emp emp);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.collect.mapper;
|
||||
|
||||
import com.ruoyi.collect.domain.Identification;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/11 20:50
|
||||
* @Description:
|
||||
*/
|
||||
@Repository
|
||||
public interface IdentificationMapper {
|
||||
List<Identification> showIdentification();
|
||||
|
||||
int addIdentification(Identification identification);
|
||||
|
||||
int addFenceRecord(@Param("identificationId") Integer identificationId, @Param("fence") Integer fence);
|
||||
|
||||
int deleteIdentification(@Param("identificationId") Integer identificationId);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.ruoyi.collect.service;
|
||||
|
||||
import com.ruoyi.collect.domain.Fence;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/22 17:00
|
||||
* @Description:
|
||||
*/
|
||||
public interface BusinessService {
|
||||
R<List<Fence>> AllFence();
|
||||
|
||||
R<Fence> echoFence(Integer fenceId);
|
||||
|
||||
R updateFence(Fence fence);
|
||||
|
||||
R deleteFence(Integer fenceId);
|
||||
|
||||
R openIsClose(Integer fenceId, Integer fenceStatus);
|
||||
|
||||
R addFence(Fence fence);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.collect.service;
|
||||
|
||||
|
||||
import com.ruoyi.collect.domain.*;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface CarService {
|
||||
R<List<Car>> carList(Car car);
|
||||
|
||||
R<List<Type>> findByType();
|
||||
|
||||
R<List<Firm>> findByFirm();
|
||||
|
||||
R addCar(Car car);
|
||||
|
||||
R deleteCar(Integer carId);
|
||||
|
||||
R<Car> findByCar(Integer carId);
|
||||
|
||||
R updateCar(Car car);
|
||||
|
||||
R startIsCar(String carVin);
|
||||
|
||||
|
||||
R<List<CarRecord>> showCarRecord();
|
||||
|
||||
void addRecord(String vin, Long datetime);
|
||||
|
||||
void endIsCar(String vin);
|
||||
|
||||
void endCarRecord(CarRecord carRecord);
|
||||
|
||||
R<CarRecord> showCarRecordById(Integer recordId);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.collect.service;
|
||||
|
||||
import com.ruoyi.collect.domain.Emp;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/30 18:55
|
||||
* @Description:
|
||||
*/
|
||||
public interface EmpService {
|
||||
List<Emp> EmpAll();
|
||||
|
||||
int addEmp(Emp emp);
|
||||
|
||||
List<Emp> showEmpById(Integer empId);
|
||||
|
||||
R updateEmp(Emp emp);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.ruoyi.collect.service;
|
||||
|
||||
|
||||
import com.ruoyi.collect.domain.VehicleMessage;
|
||||
|
||||
/**
|
||||
* @program: lemon-fence
|
||||
* @description: 电子围栏判断接口
|
||||
* @author: Mr.Gong
|
||||
* @create: 2023-08-23 14:06
|
||||
**/
|
||||
public interface IElectronicFence {
|
||||
/**
|
||||
* 调用此接口 判断围栏内外 传入汽车报文的对象
|
||||
* @param messages
|
||||
* @return
|
||||
*/
|
||||
public void electronicFence(VehicleMessage messages);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.collect.service;
|
||||
|
||||
import com.ruoyi.collect.domain.Identification;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/11 20:50
|
||||
* @Description:
|
||||
*/
|
||||
public interface IdentificationService {
|
||||
R<List<Identification>> showIdentification();
|
||||
|
||||
R addIdentification(Identification identification);
|
||||
|
||||
R updateIdentification(Identification identification);
|
||||
|
||||
R deleteIdentification(Integer identificationId);
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.ruoyi.collect.service.impl;
|
||||
|
||||
import com.ruoyi.collect.domain.Fence;
|
||||
import com.ruoyi.collect.mapper.BusinessMapper;
|
||||
import com.ruoyi.collect.service.BusinessService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/22 17:00
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
public class BusinessServiceImpl implements BusinessService {
|
||||
@Autowired
|
||||
private BusinessMapper businessMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public R<List<Fence>> AllFence() {
|
||||
List<Fence> fences = businessMapper.AllFence();
|
||||
return R.ok(fences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Fence> echoFence(Integer fenceId) {
|
||||
//查询电子围栏,根据主键唯一标识去查询
|
||||
Fence fence = businessMapper.echoFence(fenceId);
|
||||
return R.ok(fence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R updateFence(Fence fence) {
|
||||
//修改电子围栏
|
||||
fence.setUpdateTime(new Date());
|
||||
int i = businessMapper.updateFence(fence);
|
||||
if(i>0){
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
return R.ok("修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R deleteFence(Integer fenceId) {
|
||||
int i = businessMapper.deleteFence(fenceId);
|
||||
if(i>0){
|
||||
return R.ok("删除成功");
|
||||
}
|
||||
return R.ok("删除失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R openIsClose(Integer fenceId, Integer fenceStatus) {
|
||||
int i = businessMapper.openIsClose(fenceId, fenceStatus);
|
||||
|
||||
if(i>0){
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
return R.ok("修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R addFence(Fence fence) {
|
||||
fence.setCreateTime(new Date());
|
||||
int i = businessMapper.addFence(fence);
|
||||
if(i>0){
|
||||
return R.ok("添加成功");
|
||||
}
|
||||
return R.ok("添加失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
package com.ruoyi.collect.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.collect.cache.service.CacheService;
|
||||
import com.ruoyi.collect.config.RedisFinalVariable;
|
||||
import com.ruoyi.collect.domain.*;
|
||||
import com.ruoyi.collect.mapper.CarMapper;
|
||||
import com.ruoyi.collect.service.CarService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.commons.beanutils.ConvertUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public class CarServiceImpl implements CarService {
|
||||
|
||||
@Autowired
|
||||
private CarMapper carMapper;
|
||||
@Autowired
|
||||
private CacheService cacheService;
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public R<List<Car>> carList(Car car) {
|
||||
List<Car> cars = carMapper.carList(car);
|
||||
return R.ok(cars);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<Type>> findByType() {
|
||||
List<Type> byType = carMapper.findByType();
|
||||
return R.ok(byType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<Firm>> findByFirm() {
|
||||
List<Firm> byFirm = carMapper.findByFirm();
|
||||
return R.ok(byFirm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R addCar(Car car) {
|
||||
int i = carMapper.addCar(car);
|
||||
if(i>0){
|
||||
//添加標識中间表
|
||||
int aa=0;
|
||||
for (Integer identificationId : car.getIdentificationIds()) {
|
||||
aa = carMapper.addIdentificationRecord(car.getCarId(),identificationId);
|
||||
}
|
||||
if(aa>0){
|
||||
return R.ok("添加成功");
|
||||
}
|
||||
}
|
||||
return R.ok("添加失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R deleteCar(Integer carId) {
|
||||
Car byCar = carMapper.fendByCarId(carId);
|
||||
int i = carMapper.deleteCar(carId);
|
||||
if(i>0){
|
||||
carMapper.deleteCarIdentification(byCar.getCarId());//删除该车辆的电子围栏
|
||||
return R.ok("删除成功");
|
||||
}
|
||||
return R.ok("删除失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Car> findByCar(Integer carId) {
|
||||
Car byCar = carMapper.fendByCarId(carId);
|
||||
String[] split = byCar.getIdentifications().split(",");
|
||||
Integer[] convert = (Integer[]) ConvertUtils.convert(split, Integer.class);
|
||||
byCar.setIdentificationIds(convert);
|
||||
return R.ok(byCar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R updateCar(Car car) {
|
||||
int i = carMapper.updateCar(car);
|
||||
if(i>0){
|
||||
//修改该车辆的电子围栏
|
||||
//先根据vin删除之前的电子围栏
|
||||
int i1 = carMapper.deleteCarIdentification(car.getCarId());
|
||||
for (Integer identificationId : car.getIdentificationIds()) {
|
||||
carMapper.addIdentificationRecord(car.getCarId(),identificationId);
|
||||
}
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
return R.ok("修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R startIsCar(String carVin) {
|
||||
//查询车辆信息
|
||||
Car byCar = carMapper.findByCar(carVin);
|
||||
//车辆上线
|
||||
carMapper.startIsCar(carVin);
|
||||
//查询车辆标识
|
||||
List<Identification> identifications = carMapper.showCarBsRecord(byCar.getCarId());
|
||||
|
||||
ArrayList<FenceRecord> fenceRecords = new ArrayList<>();
|
||||
|
||||
for (Identification identification : identifications) {
|
||||
List<FenceRecord> fenceRecords1 = carMapper.showFence(identification.getIdentificationId());
|
||||
fenceRecords.addAll(fenceRecords1);
|
||||
}
|
||||
//将车辆标识存入缓存当中
|
||||
cacheService.put(byCar.getCarVin(),fenceRecords);
|
||||
if(redisService.hasKey(byCar.getCarVin())){
|
||||
redisService.deleteObject(byCar.getCarVin());
|
||||
redisService.setCacheList(byCar.getCarVin(),fenceRecords);
|
||||
}else{
|
||||
redisService.setCacheList(byCar.getCarVin(),fenceRecords);
|
||||
}
|
||||
return R.ok("启动成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public R<List<CarRecord>> showCarRecord() {
|
||||
List<CarRecord> carRecords = carMapper.showCarRecord();
|
||||
return R.ok(carRecords);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecord(String vin, Long datetime) {
|
||||
CarRecord carRecord = new CarRecord();
|
||||
carRecord.setCarVin(vin);
|
||||
carRecord.setCreateDate(new Date(datetime));
|
||||
carRecord.setStartKey(String.valueOf(datetime));
|
||||
int i = carMapper.addRecord(carRecord);
|
||||
if(i>0){
|
||||
// redisTemplate.opsForValue().set(RedisFinalVariable.RECORD_ID+vin,JSON.toJSONString(carRecord));
|
||||
redisService.setCacheObject(RedisFinalVariable.RECORD_ID+vin,JSON.toJSONString(carRecord));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endIsCar(String vin) {
|
||||
carMapper.endCar(vin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endCarRecord(CarRecord carRecord) {
|
||||
carMapper.endCarRecord(carRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<CarRecord> showCarRecordById(Integer recordId) {
|
||||
CarRecord carRecord = carMapper.showCarRecordById(recordId);
|
||||
return R.ok(carRecord);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package com.ruoyi.collect.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.collect.cache.CacheItem;
|
||||
import com.ruoyi.collect.cache.service.CacheService;
|
||||
import com.ruoyi.collect.domain.CarFence;
|
||||
import com.ruoyi.collect.domain.FenceRecord;
|
||||
import com.ruoyi.collect.domain.VehicleMessage;
|
||||
import com.ruoyi.collect.service.CarService;
|
||||
import com.ruoyi.collect.service.IElectronicFence;
|
||||
import com.ruoyi.collect.utils.FenceUtils;
|
||||
import com.ruoyi.collect.utils.Latitudelongitude;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @program: lemon-fence
|
||||
* @description: 实现电子围栏判断接口
|
||||
* @author: lff
|
||||
* @create: 2023-08-23 14:36
|
||||
**/
|
||||
@Service
|
||||
public class ElectronicdFenceimpl implements IElectronicFence {
|
||||
@Autowired
|
||||
private CacheService cacheService;
|
||||
@Autowired
|
||||
private JavaMailSender javaMailSender;
|
||||
@Autowired
|
||||
private CarService carService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
@Override
|
||||
public void electronicFence(VehicleMessage messages) {
|
||||
//获取纬度坐标
|
||||
double latitude = Double.parseDouble(messages.getLatitude());
|
||||
//获取经度坐标
|
||||
double longitude = Double.parseDouble(messages.getLongitude());
|
||||
|
||||
ArrayList<FenceRecord> carFences = new ArrayList<>();
|
||||
//从本地缓存中获取该车辆的所有电子围栏信息
|
||||
CacheItem o = (CacheItem) cacheService.get(messages.getVinCode());
|
||||
|
||||
if(o!=null){
|
||||
List<FenceRecord> value = (List<FenceRecord>) o.getValue();
|
||||
//一级缓存中如果有车辆围栏信息,直接从一级缓存中将数据取出,没有的话才会去二级缓存
|
||||
carFences.addAll(value);
|
||||
}else{
|
||||
//二级缓存
|
||||
// List<String> range = redisTemplate.opsForList().range(messages.getVinCode(), 0, -1);
|
||||
List<Object> cacheList = redisService.getCacheList(messages.getVinCode());
|
||||
for (Object s : cacheList) {
|
||||
carFences.add((FenceRecord) s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//循环集合
|
||||
|
||||
carFences.stream().forEach(item -> {
|
||||
//判断电子围栏的类型
|
||||
//驶入则判断是否在电子围栏内
|
||||
if(item.getRecordStatus()==1){
|
||||
//调用方法判断
|
||||
//获取到车辆的经度和纬度
|
||||
Latitudelongitude latitudelongitude = new Latitudelongitude();
|
||||
latitudelongitude.setLatitude(latitude);
|
||||
latitudelongitude.setLongitude(longitude);
|
||||
|
||||
String logLat = item.getLogLat();
|
||||
//调用方法实现切割经度纬度
|
||||
ArrayList<Latitudelongitude> latitudelongitudes = getList(logLat);
|
||||
|
||||
Boolean isfence = FenceUtils.isfence(latitudelongitude, latitudelongitudes);
|
||||
//如果在 则代表车辆驶入围栏内 返回的是true 则发送警报
|
||||
if(isfence){
|
||||
System.out.println("正常");
|
||||
}else{//如果不在 则代表车辆依旧在电子围栏外 返回的是false 则显示正常
|
||||
// try {
|
||||
// MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||
// MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||
// helper.setSubject("通知");
|
||||
// helper.setText("您的车辆已经超出围栏!!!");
|
||||
// helper.setFrom("3079188394@qq.com");
|
||||
// helper.setTo("3079188394@qq.com");
|
||||
// javaMailSender.send(mimeMessage);
|
||||
// } catch (MessagingException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
rabbitTemplate.convertAndSend("sendFactorError",JSON.toJSONString(messages),message -> {
|
||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString().replaceAll("-",""));
|
||||
return message;
|
||||
});
|
||||
System.out.println("实现报警");
|
||||
}
|
||||
}else if(item.getRecordStatus()==2){//驶入则判断是否在电子围栏内
|
||||
//调用方法
|
||||
Latitudelongitude latitudelongitude = new Latitudelongitude();
|
||||
latitudelongitude.setLatitude(latitude);
|
||||
latitudelongitude.setLongitude(longitude);
|
||||
|
||||
String logLat = item.getLogLat();
|
||||
//调用方法实现切割经度纬度
|
||||
ArrayList<Latitudelongitude> latitudelongitudes = getList(logLat);
|
||||
Boolean isfence = FenceUtils.isfence(latitudelongitude, latitudelongitudes);
|
||||
|
||||
//如果在 则代表车辆依旧在围栏内 返回的是true 则显示正常
|
||||
if(isfence){
|
||||
System.out.println("正常");
|
||||
}else{//如果不在 则代表车辆驶出电子围栏 返回的是true 则显示报警
|
||||
System.out.println("实现报警");
|
||||
rabbitTemplate.convertAndSend("sendFactorError",JSON.toJSONString(messages),message -> {
|
||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString().replaceAll("-",""));
|
||||
return message;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// private static boolean check(Point2D.Double point, List<Point2D.Double> polygon) {
|
||||
// //创建一个GeneralPath对象,用于绘制闭合图形和操作路径。
|
||||
// GeneralPath peneralPath = new GeneralPath();
|
||||
// //创建一个Poin2D的first变量 获取集合中的第一个坐标并赋值给first变量
|
||||
// Point2D.Double first = polygon.get(0);
|
||||
// // 通过移动到指定坐标(以双精度指定),将一个点添加到路径中 作为操作路径的起始点
|
||||
// peneralPath.moveTo(first.x, first.y);
|
||||
// //从多边形列表中移除第一个坐标点对象 因为第一个坐标已经在操作路径当中
|
||||
// polygon.remove(0);
|
||||
// //遍历多边形列表中的剩余点
|
||||
// for (Point2D.Double pol : polygon) {
|
||||
// peneralPath.lineTo(pol.x, pol.y);
|
||||
// }
|
||||
// // 循环结束后的最后一个坐标通过lineTo的方式 移动到起始点 形成一个通用路径 包含围栏所有节点的坐标点 通过通用路径形成了闭环图形
|
||||
// peneralPath.lineTo(first.x, first.y);
|
||||
// peneralPath.closePath();//创建完成后 关闭路径
|
||||
// // 测试指定的 Point2D 是否在 Shape 的边界内。
|
||||
// return peneralPath.contains(point);
|
||||
// }
|
||||
|
||||
public ArrayList<Latitudelongitude> getList(String logLat){
|
||||
//切割出经度
|
||||
//121.357205,31.309392;121.647537,31.191832;121.39515,31.120632
|
||||
//121.357205,31.309392 121.647537,31.191832 121.39515,31.120632
|
||||
String[] split = logLat.split(";");
|
||||
int count=0;//定数器实现切割判断经度纬度
|
||||
ArrayList<String> log = new ArrayList<>();
|
||||
ArrayList<String> lal = new ArrayList<>();
|
||||
for (String s : split) {
|
||||
String[] split1 = s.split(",");
|
||||
for (String s1 : split1) {
|
||||
count++;//每次循环计数器加1
|
||||
if(count%2!=0){//计数器不是2的倍数代表经度
|
||||
log.add(s1);
|
||||
}else{ //计数器是2的倍数 代表是纬度
|
||||
lal.add(s1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<Latitudelongitude> latitudelongitudes = new ArrayList<>();
|
||||
for (int i = 0; i < log.size(); i++) {
|
||||
Latitudelongitude latitudelongitude1 = new Latitudelongitude();
|
||||
latitudelongitude1.setLongitude(Double.parseDouble(log.get(i)));
|
||||
latitudelongitude1.setLatitude(Double.parseDouble(lal.get(i)));
|
||||
latitudelongitudes.add(latitudelongitude1);
|
||||
}
|
||||
return latitudelongitudes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.ruoyi.collect.service.impl;
|
||||
|
||||
import com.ruoyi.collect.domain.Emp;
|
||||
import com.ruoyi.collect.mapper.EmpMapper;
|
||||
import com.ruoyi.collect.service.EmpService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/8/30 18:55
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
public class EmpServiceImpl implements EmpService {
|
||||
@Autowired
|
||||
private EmpMapper empMapper;
|
||||
|
||||
@Override
|
||||
public List<Emp> EmpAll() {
|
||||
//查询员工列表
|
||||
List<Emp> emps = empMapper.EmpAll();
|
||||
|
||||
return emps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addEmp(Emp emp) {
|
||||
return empMapper.addEmp(emp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Emp> showEmpById(Integer empId) {
|
||||
List<Emp> emps = empMapper.showEmpById(empId);
|
||||
return emps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R updateEmp(Emp emp) {
|
||||
int i = empMapper.updateEmp(emp);
|
||||
if(i>0){
|
||||
return R.ok("修改成功");
|
||||
}else{
|
||||
return R.ok("修改失败");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.ruoyi.collect.service.impl;
|
||||
|
||||
import com.ruoyi.collect.domain.Identification;
|
||||
import com.ruoyi.collect.mapper.IdentificationMapper;
|
||||
import com.ruoyi.collect.service.IdentificationService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lff
|
||||
* @Date: 2023/9/11 20:50
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
public class IdentificationServiceImpl implements IdentificationService {
|
||||
@Autowired
|
||||
private IdentificationMapper identificationMapper;
|
||||
@Override
|
||||
public R<List<Identification>> showIdentification() {
|
||||
List<Identification> identifications = identificationMapper.showIdentification();
|
||||
return R.ok(identifications);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R addIdentification(Identification identification) {
|
||||
//添加標識表
|
||||
int i = identificationMapper.addIdentification(identification);
|
||||
if(i>0){
|
||||
int i1=0;
|
||||
for (Integer fence : identification.getFences()) {
|
||||
i1 = identificationMapper.addFenceRecord(identification.getIdentificationId(), fence);
|
||||
}
|
||||
if(i1>0){
|
||||
return R.ok("添加成功");
|
||||
}
|
||||
}
|
||||
return R.ok("添加失敗");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R updateIdentification(Identification identification) {
|
||||
//修改標識
|
||||
int i = identificationMapper.deleteIdentification(identification.getIdentificationId());
|
||||
if(i>0){
|
||||
int i1=0;
|
||||
for (Integer fence : identification.getFences()) {
|
||||
i1 = identificationMapper.addFenceRecord(identification.getIdentificationId(), fence);
|
||||
}
|
||||
if(i1>0){
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
}
|
||||
return R.ok("修改失敗");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R deleteIdentification(Integer identificationId) {
|
||||
int i = identificationMapper.deleteIdentification(identificationId);
|
||||
if(i>0){
|
||||
return R.ok("刪除成功");
|
||||
}
|
||||
return R.ok("刪除失敗");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.ruoyi.collect.utils;
|
||||
|
||||
|
||||
|
||||
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FenceUtils {
|
||||
|
||||
/**
|
||||
* 此方法获取获取参数进行处理
|
||||
* @param latitudelongitude 需要判断的点位纵横坐标
|
||||
* @param list 区域各定点的纵横坐标
|
||||
* @return Boolean 是否存在于多变形内
|
||||
*/
|
||||
public static Boolean isfence(Latitudelongitude latitudelongitude, List<Latitudelongitude> list){
|
||||
//经度坐标
|
||||
List<Double> lons = new ArrayList<>();
|
||||
//维度坐标
|
||||
List<Double> lats = new ArrayList<>();
|
||||
//车辆经度
|
||||
double plon= latitudelongitude.getLongitude();
|
||||
//车辆维度
|
||||
double plat= latitudelongitude.getLatitude();
|
||||
//围栏坐标点集合
|
||||
list.stream().forEach(item->{
|
||||
lons.add(item.getLongitude());
|
||||
lats.add(item.getLatitude());
|
||||
});
|
||||
return isInPolygon(plon,plat,lons,lats);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isInPolygon(double pointLon,double pointLat, List<Double> lons,List<Double> lats){
|
||||
|
||||
//获取车辆坐标 转换成点
|
||||
Point2D.Double point=new Point2D.Double(pointLon,pointLat);
|
||||
//创建一个点集合
|
||||
ArrayList<Point2D.Double> points = new ArrayList<>();
|
||||
double polygonPoint_x=0.0;
|
||||
double polygonPoint_y=0.0;
|
||||
//116.00,25.00 114.00,53.00
|
||||
for (int i = 0; i < lons.size(); i++) {
|
||||
polygonPoint_x=lons.get(i);
|
||||
polygonPoint_y=lats.get(i);
|
||||
Point2D.Double polygonPoint=new Point2D.Double(polygonPoint_x,polygonPoint_y);
|
||||
points.add(polygonPoint);
|
||||
}
|
||||
//判断当前坐标点和围栏的关系
|
||||
return verdict(point, points);
|
||||
}
|
||||
|
||||
private static boolean verdict(Point2D.Double point, ArrayList<Point2D.Double> points) {
|
||||
//verdict
|
||||
//创建一个GenralPath对象
|
||||
GeneralPath generalPath = new GeneralPath();
|
||||
//创建第一个临近点
|
||||
Point2D.Double p1= points.get(0);
|
||||
//通过移动到指定坐标,将一个点添加到路径中,作为操作第一个点
|
||||
generalPath.moveTo(p1.x,p1.y);
|
||||
//从多边形列表一处第一个坐标点
|
||||
//points.remove(0);
|
||||
//判断其他多边形的其他点
|
||||
for (Point2D.Double pp : points) {
|
||||
generalPath.lineTo(pp.x,pp.y);
|
||||
}
|
||||
//循环结束后的最后一个坐标 行程闭环
|
||||
generalPath.lineTo(p1.x,p1.y);
|
||||
//创建完成,关闭路径
|
||||
generalPath.closePath();
|
||||
//测试指定的点 是否在边界内
|
||||
return generalPath.contains(point);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.ruoyi.collect.utils;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Latitudelongitude {
|
||||
public double longitude;
|
||||
public double Latitude;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.ruoyi.collect.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Text {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//车辆坐标 121.477937,31.238281(内) ===========================
|
||||
Latitudelongitude indoor = new Latitudelongitude();
|
||||
//纬度坐标
|
||||
indoor.setLatitude(121.477937);
|
||||
//经度坐标
|
||||
indoor.setLongitude(31.238281);
|
||||
//车辆坐标 120.521853,31.607563(外)===========================
|
||||
Latitudelongitude outdoor = new Latitudelongitude();
|
||||
//纬度坐标
|
||||
outdoor.setLatitude(120.521853);
|
||||
//经度坐标
|
||||
outdoor.setLongitude(31.607563);
|
||||
|
||||
//121.357205,31.309392;121.647537,31.191832;121.39515,31.120632
|
||||
// ===============================在多边形坐标点集合===================================
|
||||
List<Latitudelongitude> latitudelongitudes = new ArrayList<>();
|
||||
//121.357205,31.309392 121.647537,31.191832 121.39515,31.120632
|
||||
Latitudelongitude l1 = new Latitudelongitude();
|
||||
//纬度坐标
|
||||
|
||||
l1.setLatitude(121.357205);
|
||||
//经度坐标
|
||||
l1.setLongitude(31.309392);
|
||||
Latitudelongitude l2 = new Latitudelongitude();
|
||||
//纬度坐标
|
||||
l2.setLatitude(121.647537);
|
||||
//经度坐标
|
||||
l2.setLongitude(31.191832);
|
||||
Latitudelongitude l3 = new Latitudelongitude();
|
||||
//纬度坐标
|
||||
l3.setLatitude(121.39515);
|
||||
//经度坐标
|
||||
l3.setLongitude(31.120632);
|
||||
latitudelongitudes.add(l1);
|
||||
latitudelongitudes.add(l2);
|
||||
latitudelongitudes.add(l3);
|
||||
|
||||
for (Latitudelongitude latitudelongitude1 : latitudelongitudes) {
|
||||
System.out.println("坐标点:"+latitudelongitude1);
|
||||
}
|
||||
Boolean isfence = FenceUtils.isfence(outdoor, latitudelongitudes);
|
||||
if (isfence==true){
|
||||
System.out.println("在电子围栏内部");
|
||||
}else {
|
||||
|
||||
System.out.println("在电子围栏外部");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
_ _
|
||||
(_) | |
|
||||
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
|
||||
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
|
||||
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|
||||
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
|
||||
__/ | __/ |
|
||||
|___/ |___/
|
|
@ -0,0 +1,47 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 3336
|
||||
# Spring
|
||||
spring:
|
||||
rabbitmq:
|
||||
host: 10.100.27.4
|
||||
port: 5672
|
||||
username: guest
|
||||
password: guest
|
||||
virtualHost: /
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||
acknowledge-mode: manual # 设置消费端手动ack确认
|
||||
retry:
|
||||
enabled: true # 是否支持重试
|
||||
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
|
||||
publisher-returns: true #确认消息已发送到队列(Queue)
|
||||
|
||||
mail:
|
||||
host: smtp.qq.com
|
||||
port: 587
|
||||
username: 3079188394@qq.com
|
||||
password: olztxtpchenrdfdi
|
||||
application:
|
||||
# 应用名称
|
||||
name: ruoyi-collect
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.100.27.4:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.100.27.4:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
kafka:
|
||||
bootstrap-servers: 43.142.96.146:9092,43.142.96.146:9093,43.142.96.146:9094
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/ruoyi-collect" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.ruoyi" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.collect.mapper.BusinessMapper">
|
||||
<insert id="addFence">
|
||||
insert into electronic_fence_setting (
|
||||
firm_id,
|
||||
fence_name,
|
||||
address,
|
||||
log_lat,
|
||||
create_time,
|
||||
create_name,
|
||||
update_time,
|
||||
end_time,
|
||||
update_name,
|
||||
deletion,
|
||||
fence_status
|
||||
)
|
||||
values (
|
||||
#{firmId},
|
||||
#{fenceName},
|
||||
#{address},
|
||||
null,
|
||||
#{createTime},
|
||||
#{createName},
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
1,
|
||||
1
|
||||
)
|
||||
</insert>
|
||||
<update id="updateFence">
|
||||
update electronic_fence_setting set
|
||||
firm_id=#{firmId},fence_name=#{fenceName},address=#{address},
|
||||
log_lat=#{logLat},create_time=#{createTime},create_name=#{createName},
|
||||
update_time=#{updateTime},end_time=#{endTime},update_name=#{updateName},fence_status=#{fenceStatus}
|
||||
where fence_id=#{fenceId}
|
||||
</update>
|
||||
<update id="deleteFence">
|
||||
update electronic_fence_setting set deletion=2 where fence_id=#{fenceId}
|
||||
</update>
|
||||
<update id="openIsClose">
|
||||
update electronic_fence_setting set fence_status=#{fenceStatus} where fence_id=#{fenceId}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="AllFence" resultType="com.ruoyi.collect.domain.Fence">
|
||||
select * from electronic_fence_setting f left join firm m on f.firm_id=m.firm_id where f.deletion=1 and f.fence_status=1
|
||||
</select>
|
||||
<select id="echoFence" resultType="com.ruoyi.collect.domain.Fence">
|
||||
select * from electronic_fence_setting where fence_id = #{fenceId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,149 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.collect.mapper.CarMapper">
|
||||
<insert id="addCar" keyProperty="carId" useGeneratedKeys="true">
|
||||
insert into car(
|
||||
car_id,
|
||||
car_name,
|
||||
type_id,
|
||||
manufacturer_name,
|
||||
battery_name,
|
||||
manufacturer_desc,
|
||||
battery_desc,
|
||||
car_status,
|
||||
car_vin,
|
||||
firm_id,
|
||||
deletion
|
||||
) values(
|
||||
0,
|
||||
#{carName},
|
||||
#{typeId},
|
||||
#{manufacturerName},
|
||||
#{batteryName},
|
||||
#{manufacturerDesc},
|
||||
#{batteryDesc},
|
||||
0,
|
||||
#{carVin},
|
||||
#{firmId},
|
||||
1
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="addRecord" useGeneratedKeys="true" keyProperty="recordId">
|
||||
insert into car_record (car_vin,create_date,start_key) values (#{carVin},#{createDate},#{startKey})
|
||||
</insert>
|
||||
<insert id="addIdentificationRecord">
|
||||
insert into car_bs_record values (null,#{identificationId},#{carId},1)
|
||||
</insert>
|
||||
<update id="deleteCar">
|
||||
update car set deletion=2 where car_id=#{carId}
|
||||
</update>
|
||||
<update id="updateCar">
|
||||
update car set car_name=#{carName},type_id=#{typeId},
|
||||
manufacturer_name=#{manufacturerName},
|
||||
battery_name=#{batteryName},manufacturer_desc=#{manufacturerDesc},
|
||||
battery_desc=#{batteryDesc},
|
||||
car_vin=#{carVin},firm_id=#{firmId}
|
||||
where car_id=#{carId}
|
||||
</update>
|
||||
<update id="startIsCar">
|
||||
update car set car_status=1 where car_vin=#{carVin}
|
||||
</update>
|
||||
<update id="endCar">
|
||||
update car set car_status=0 where car_vin=#{carVin}
|
||||
</update>
|
||||
<update id="endCarRecord">
|
||||
update car_record set end_date=#{endDate},end_key=#{endKey} where record_id=#{recordId}
|
||||
</update>
|
||||
<delete id="deleteCarIdentification">
|
||||
delete from car_bs_record where car_id=#{carId}
|
||||
</delete>
|
||||
|
||||
|
||||
<resultMap id="selectCar" type="com.ruoyi.collect.domain.Car">
|
||||
<id property="carId" column="car_id"/>
|
||||
<result property="carName" column="car_name"/>
|
||||
<result property="carVin" column="car_vin"/>
|
||||
<result property="typeId" column="type_id"/>
|
||||
<result property="typeName" column="type_name"/>
|
||||
<result property="manufacturerName" column="manufacturer_name"/>
|
||||
<result property="batteryName" column="battery_name"/>
|
||||
<result property="manufacturerDesc" column="manufacturer_desc"/>
|
||||
<result property="batteryDesc" column="battery_desc"/>
|
||||
<result property="carStatus" column="car_status"/>
|
||||
<result property="firmId" column="firm_id"/>
|
||||
<result property="firmName" column="firm_name"/>
|
||||
<result property="deletion" column="deletion"/>
|
||||
<result property="identificationName" column="identification_name"/>
|
||||
<result property="identifications" column="identifications"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="carList" resultMap="selectCar">
|
||||
select c.*,t.type_name,f.firm_name,GROUP_CONCAT(b.identification_id) as identifications, GROUP_CONCAT(e.identification_name) as identification_name
|
||||
from car_bs_record b left join car c
|
||||
on b.car_id=c.car_id left join identification e
|
||||
on b.identification_id=e.identification_id left join type t
|
||||
on c.type_id=t.type_id left join firm f
|
||||
on c.firm_id=f.firm_id
|
||||
<where>
|
||||
c.deletion=1
|
||||
<if test="carName!=null and ''!=carName">
|
||||
and c.car_name like concat('%',#{carName},'%')
|
||||
</if>
|
||||
<if test="carVin!=null and ''!=carVin">
|
||||
and c.car_vin = #{carVin}
|
||||
</if>
|
||||
<if test="typeId!=null">
|
||||
and c.type_id=#{typeId}
|
||||
</if>
|
||||
<if test="carStatus!=null">
|
||||
and c.car_status = #{carStatus}
|
||||
</if>
|
||||
<if test="firmId!=null">
|
||||
and c.firm_id = #{firmId}
|
||||
</if>
|
||||
</where>
|
||||
group by c.car_id
|
||||
</select>
|
||||
<select id="findByType" resultType="com.ruoyi.collect.domain.Type">
|
||||
select *from type
|
||||
</select>
|
||||
<select id="findByFirm" resultType="com.ruoyi.collect.domain.Firm">
|
||||
select * from firm
|
||||
</select>
|
||||
<select id="findByCar" resultType="com.ruoyi.collect.domain.Car">
|
||||
select * from car where car_vin=#{carVin}
|
||||
</select>
|
||||
|
||||
<select id="showCarRecord" resultType="com.ruoyi.collect.domain.CarRecord">
|
||||
select * from car_record
|
||||
</select>
|
||||
<select id="fendByCarId" resultType="com.ruoyi.collect.domain.Car">
|
||||
select c.*,t.type_name,f.firm_name,GROUP_CONCAT(b.identification_id) as identifications, GROUP_CONCAT(e.identification_name) as identification_name
|
||||
from car_bs_record b left join car c
|
||||
on b.car_id=c.car_id left join identification e
|
||||
on b.identification_id=e.identification_id left join type t
|
||||
on c.type_id=t.type_id left join firm f
|
||||
on c.firm_id=f.firm_id
|
||||
where c.car_id=#{carId}
|
||||
group by c.car_id
|
||||
</select>
|
||||
<select id="showCarRecordById" resultType="com.ruoyi.collect.domain.CarRecord">
|
||||
select * from car_record where record_id=#{recordId}
|
||||
</select>
|
||||
<select id="showCarBsRecord" resultType="com.ruoyi.collect.domain.Identification">
|
||||
select e.identification_id,e.identification_name,e.identification_status from car_bs_record b left join car c
|
||||
on b.car_id=c.car_id left join identification e
|
||||
on b.identification_id=e.identification_id left join type t
|
||||
on c.type_id=t.type_id left join firm f
|
||||
on c.firm_id=f.firm_id
|
||||
where c.car_id=#{carId}
|
||||
</select>
|
||||
<select id="showFence" resultType="com.ruoyi.collect.domain.FenceRecord">
|
||||
select * from fence_record f left join electronic_fence_setting e
|
||||
on f.fence_id=e.fence_id
|
||||
where identification_id=#{identificationId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.collect.mapper.EmpMapper">
|
||||
<insert id="addEmp">
|
||||
insert into f_emp (emp_name,emp_sex,emp_phone,email,firm_id,emp_status)
|
||||
values (#{empName},#{empSex},#{empPhone},#{email},#{firmId},1)
|
||||
</insert>
|
||||
<update id="updateEmp">
|
||||
update f_emp set emp_name=#{empName},emp_sex=#{empSex},emp_phone=#{empPhone},email=#{email},firm_id=#{firmId} where emp_id=#{empId}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="EmpAll" resultType="com.ruoyi.collect.domain.Emp">
|
||||
select * from f_emp e left join firm f
|
||||
on e.firm_id=f.firm_id
|
||||
</select>
|
||||
<select id="showEmpById" resultType="com.ruoyi.collect.domain.Emp">
|
||||
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.collect.mapper.IdentificationMapper">
|
||||
<insert id="addIdentification" useGeneratedKeys="true" keyProperty="identificationId">
|
||||
insert into identification values (null,#{identificationName},1)
|
||||
</insert>
|
||||
<insert id="addFenceRecord">
|
||||
insert into fence_record values (null,#{identificationId},#{fence},1)
|
||||
</insert>
|
||||
<delete id="deleteIdentification">
|
||||
delete from fence_record where identification_id=#{identificationId}
|
||||
</delete>
|
||||
<select id="showIdentification" resultType="com.ruoyi.collect.domain.Identification">
|
||||
select * from identification
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,25 @@
|
|||
<?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>
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-modules-collect</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.gu</groupId>
|
||||
<artifactId>ruoyi-vehicle-cache</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>ruoyi-business-cache</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,28 @@
|
|||
<?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>
|
||||
<parent>
|
||||
<groupId>com.gu</groupId>
|
||||
<artifactId>ruoyi-vehicle-cache</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ruoyi-business-cache</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-collect-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,31 @@
|
|||
package com.ruoyi.vehicle.cache.fence;
|
||||
|
||||
|
||||
import com.ruoyi.collect.domain.cache.fence.FenceIdTypeCache;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 围栏缓存
|
||||
*/
|
||||
public class FenceCache {
|
||||
|
||||
/**
|
||||
* 车辆和围栏的绑定
|
||||
*/
|
||||
private final static ConcurrentHashMap<String, double[][]> FENCE_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
protected static void put(String vin,double[][] coordinate){
|
||||
FENCE_MAP.put(vin,coordinate);
|
||||
}
|
||||
|
||||
protected static double[][] get(String vin){
|
||||
return FENCE_MAP.get(vin);
|
||||
}
|
||||
|
||||
protected static void remove(String vin){
|
||||
FENCE_MAP.remove(vin);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.ruoyi.vehicle.cache.fence;
|
||||
|
||||
|
||||
import com.ruoyi.collect.domain.cache.fence.FenceIdTypeCache;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 车辆围栏
|
||||
*/
|
||||
public class VehicleFenceCache {
|
||||
|
||||
/**
|
||||
* 车辆和围栏的绑定
|
||||
*/
|
||||
private final static ConcurrentHashMap<String, List<FenceIdTypeCache>> CACHE_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
protected static List<FenceIdTypeCache> getFenceList(String vin) {
|
||||
return CACHE_MAP.get(vin);
|
||||
}
|
||||
|
||||
protected static void setFenceList(String vin,List<FenceIdTypeCache> fenceIdTypeCacheList) {
|
||||
CACHE_MAP.put(vin,fenceIdTypeCacheList);
|
||||
}
|
||||
|
||||
protected static void remove(String vin){
|
||||
CACHE_MAP.remove(vin);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.vehicle.cache.fence;
|
||||
|
||||
import com.ruoyi.collect.domain.cache.fence.FenceIdTypeCache;
|
||||
import com.ruoyi.collect.domain.cache.fence.FenceInfoTypeCache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 围栏车辆缓存
|
||||
*/
|
||||
public class VehicleFenceCacheService {
|
||||
|
||||
public List<FenceInfoTypeCache> get(String vin){
|
||||
List<FenceIdTypeCache> fenceList = VehicleFenceCache.getFenceList(vin);
|
||||
if (fenceList == null || fenceList.size() == 0){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return fenceList.stream().map(fenceIdTypeCache -> FenceInfoTypeCache.builder()
|
||||
.coordinate(FenceCache.get(fenceIdTypeCache.getFenceId()))
|
||||
.fenceType(fenceIdTypeCache.getFenceType())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.ruoyi.vehicle.cache.fence.VehicleFenceCacheService
|
Loading…
Reference in New Issue