master
gukaixuan 2023-09-15 20:46:53 +08:00
commit 5222495420
38 changed files with 2954 additions and 0 deletions

46
.gitignore vendored 100644
View File

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

23
Dockerfile 100644
View File

@ -0,0 +1,23 @@
FROM openjdk:17-ea-slim
LABEL authors="Car-two <3079188394@qq.com>"
RUN mkdir /car
# 暴露端口
EXPOSE 3334
# 创建着陆点
WORKDIR "/car"
# 复制新的运行程序
COPY ./ruoyi-tast-server/target/ruoyi-tast-server.jar /car/app.jar
# 挂载持续的目录
VOLUME /car/logs/ruoyi-tast-server
# 运行你的jar包
CMD ["java","-jar","/car/app.jar"]

26
pom.xml 100644
View File

@ -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-tast-common</module>
<module>ruoyi-tast-remote</module>
<module>ruoyi-tast-server</module>
</modules>
<version>3.6.3</version>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-modules-tast</artifactId>
<description>
ruoyi-modules-system系统模块
</description>
</project>

38
ruoyi-tast-common/.gitignore vendored 100644
View File

@ -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

View File

@ -0,0 +1,78 @@
<?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-tast</artifactId>
<version>3.6.3</version>
</parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-tast-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>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- 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>
<!-- 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>
<version>3.6.3</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,65 @@
package com.ruoyi.tast.domain;
import lombok.Data;
@Data
public class Car {
/**
* ID
*/
private Integer carId;
/**
*
*/
private String carName;
/**
* VIN
*/
private String carVin;
/**
*
*/
private Integer typeId;
/**
*
*/
private String typeName;
/**
*
*/
private Integer fenceId;
/**
*
*/
private String fenceName;
/**
*
*/
private String manufacturerName;
/**
*
*/
private String batteryName;
/**
*
*/
private String manufacturerDesc;
/**
*
*/
private String batteryDesc;
/**
* 1线 2线
*/
private Integer carStatus;
/**
*
*/
private Integer firmId;
/**
*
*/
private String firmName;
}

View File

@ -0,0 +1,75 @@
package com.ruoyi.tast.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class ElectronicFenceSetting {
/**
* ID
*/
private Integer fenceId;
/**
*
*/
private Integer firmId;
/**
* :
*/
private String fenceName;
/**
* :
*/
private String address;
/**
* :
*/
private float radius;
/**
* :
*/
private double longitude;
/**
* :
*/
private double latitude;
/**
* :
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date createTime;
/**
*
*/
private String createId;
/**
* :
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date updateTime;
/**
* :
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date endTime;
/**
*
*/
private String updateName;
/**
* : 1 2
*/
private Integer status;
/**
*
*/
private Integer deletion;
}

View File

@ -0,0 +1,202 @@
package com.ruoyi.tast.domain;
import lombok.Data;
/**
*
*/
@Data
public class Exception {
/**
*
*/
private boolean messageException=false;
private long messageExceptionStartTime=0;
private boolean messageAlertSent=false;
/**
* VIN
*/
private boolean vinException = false;
private long vinExceptionStartTime=0;
private boolean vinAlertSent=false;
/**
*
*/
private boolean longitudeException = false;
private long longitudeExceptionStartTime = 0;
private boolean longitudeAlertSent=false;
/**
*
*/
private boolean latitudeException = false;
private long latitudeExceptionStartTime = 0;
private boolean latitudeAlertSent=false;
/**
*
*/
private boolean speedOfaMotorVehicleException = false;
private long speedOfaMotorVehicleExceptionStartTime = 0;
private boolean speedOfaMotorVehicleAlertSent=false;
/**
*
*/
private boolean totalDistanceException = false;
private long totalDistanceExceptionStartTime = 0;
private boolean totalDistanceAlertSent=false;
/**
*
*/
private boolean totalVoltageException = false;
private long totalVoltageExceptionStartTime = 0;
private boolean totalVoltageAlertSent=false;
/**
*
*/
private boolean totalCurrentException = false;
private long totalCurrentExceptionStartTime = 0;
private boolean totalCurrentAlertSent=false;
/**
*
*/
private boolean insulationResistanceException = false;
private long insulationResistanceExceptionStartTime = 0;
private boolean insulationResistanceAlertSent=false;
/**
*
*/
private boolean gearsException = false;
private long gearsExceptionStartTime = 0;
private boolean gearsAlertSent=false;
/**
*
*/
private boolean acceleratorPedalTravelValueException = false;
private long acceleratorPedalTravelValueExceptionStartTime = 0;
private boolean acceleratorPedalTravelValueAlertSent=false;
/**
*
*/
private boolean brakePedalTravelValueException = false;
private long brakePedalTravelValueExceptionStartTime = 0;
private boolean brakePedalTravelValueAlertSent=false;
/**
*
*/
private boolean rateOfFuelConsumptionException = false;
private long rateOfFuelConsumptionExceptionStartTime = 0;
private boolean rateOfFuelConsumptionAlertSent=false;
/**
*
*/
private boolean motorControllerTemperatureException = false;
private long motorControllerTemperatureExceptionStartTime = 0;
private boolean motorControllerTemperatureAlertSent=false;
/**
*
*/
private boolean motorSpeedException = false;
private long motorSpeedExceptionStartTime = 0;
private boolean motorSpeedAlertSent=false;
/**
*
*/
private boolean motorTorqueException = false;
private long motorTorqueExceptionStartTime = 0;
private boolean motorTorqueAlertSent=false;
/**
*
*/
private boolean motorTemperatureException = false;
private long motorTemperatureExceptionStartTime = 0;
private boolean motorTemperatureAlertSent=false;
/**
*
*/
private boolean motorVoltageException = false;
private long motorVoltageExceptionStartTime = 0;
private boolean motorVoltageAlertSent=false;
/**
*
*/
private boolean motorCurrentException = false;
private long motorCurrentExceptionStartTime = 0;
private boolean motorCurrentAlertSent=false;
/**
* SOC
*/
private boolean powerBatteryRemainingSOCException = false;
private long powerBatteryRemainingSOCExceptionStartTime = 0;
private boolean powerBatteryRemainingSOCAlertSent=false;
/**
*
*/
private boolean theMaximumFeedbackPowerAllowedInTheCurrentStateException = false;
private long theMaximumFeedbackPowerAllowedInTheCurrentStateExceptionStartTime = 0;
private boolean theMaximumFeedbackPowerAllowedInTheCurrentStateAlertSent=false;
/**
*
*/
private boolean theCurrentStateAllowsTheMaximumDischargePowerException = false;
private long theCurrentStateAllowsTheMaximumDischargePowerExceptionStartTime = 0;
private boolean theCurrentStateAllowsTheMaximumDischargePowerAlertSent=false;
/**
* BMS
*/
private boolean bmsSelfCheckCounterException = false;
private long bmsSelfCheckCounterExceptionStartTime = 0;
private boolean bmsSelfCheckCounterAlertSent=false;
/**
*
*/
private boolean chargingAndDischargingCurrentOfPowerBatteryException = false;
private long chargingAndDischargingCurrentOfPowerBatteryExceptionStartTime = 0;
private boolean chargingAndDischargingCurrentOfPowerBatteryAlertSent=false;
/**
* V3
*/
private boolean theTotalVoltageAtTheLoadEndOfThePowerBatteryIsV3Exception = false;
private long theTotalVoltageAtTheLoadEndOfThePowerBatteryIsV3ExceptionStartTime = 0;
private boolean theTotalVoltageAtTheLoadEndOfThePowerBatteryIsV3AlertSent=false;
/**
*
*/
private boolean singleMaximumVoltageException = false;
private long singleMaximumVoltageExceptionStartTime = 0;
private boolean singleMaximumVoltageAlertSent=false;
/**
* ABS
*/
private boolean absException = false;
private long absExceptionStartTime = 0;
private boolean absAlertSent = false;
}

View File

@ -0,0 +1,50 @@
package com.ruoyi.tast.domain;
import lombok.Data;
@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;
/**
*
*/
private String createTime;
/**
*
*/
private String updateName;
/**
*
*/
private String updateTime;
}

View File

@ -0,0 +1,33 @@
package com.ruoyi.tast.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class Message implements Serializable {
/**
* VIN
*/
private String vinCode;
/**
*
*/
private String longitude;
/**
*
*/
private String latitude;
/**
*
*/
private Integer monthMalfunction;
/**
*
*/
private Integer dayMalfunction;
}

View File

@ -0,0 +1,11 @@
package com.ruoyi.tast.domain;
import lombok.Data;
@Data
public class Type {
private Integer typeId;
private String typeName;
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.tast.domain;
import lombok.Data;
@Data
public class User {
private Integer userId;
private String userName;
private String userPhone;
private String email;
}

View File

@ -0,0 +1,208 @@
package com.ruoyi.tast.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
public class VehicleMessage implements Serializable {
/**
*
*/
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 Integer soc;
/**
*
*/
private Integer workingCondition;
/**
*
*/
private Integer driveMotorCondition;
/**
*
*/
private Integer whetherTheLocationValid;
/**
* EAS
*/
private Integer eas;
/**
* PTC
*/
private Integer ptc;
/**
* EPS
*/
private Integer eps;
/**
* ABS
*/
private Integer abs;
/**
* MCU
*/
private Integer mcu;
/**
*
*/
private Integer powerBatteryHeatingState;
/**
*
*/
private Integer powerBattery;
/**
*
*/
private Integer powerBatteryInsulationState;
/**
* DCDC
*/
private Integer dcdc;
/**
* CHG
*/
private Integer chg;
/**
*
*/
private String parityBit;
/**
*
*/
private String cutoffBit;
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.tast.result;
/**
* @description:
* @author
*/
public class Constants {
/**
*
*/
public static final Integer SUCCESS = 200;
public static final String SUCCESS_MSG = "操作成功";
/**
*
*/
public static final Integer ERROR = 500;
public static final String ERROR_MSG = "操作异常";
}

View File

@ -0,0 +1,34 @@
package com.ruoyi.tast.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author
* @description:
*/
@Data
public class PageResult<T> implements Serializable {
/**
*
*/
private long total;
/**
*
*/
private List<T> list;
public PageResult() {
}
public PageResult(long total, List<T> list) {
this.total = total;
this.list = list;
}
public static <T> PageResult<T> toPageResult(long total, List<T> list){
return new PageResult(total , list);
}
public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
return Result.success(PageResult.toPageResult(total,list));
}
}

View File

@ -0,0 +1,75 @@
package com.ruoyi.tast.result;
import lombok.Data;
import java.io.Serializable;
/**
* @author
* @description:
*/
@Data
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
public static final int SUCCESS = Constants.SUCCESS;
/**
*
*/
public static final int FAIL = Constants.ERROR;
/**
*
*/
private int code;
/**
*
*/
private String msg;
/**
*
*/
private T data;
public static <T> Result<T> success() {
return restResult(null, SUCCESS, Constants.SUCCESS_MSG);
}
public static <T> Result<T> success(T data) {
return restResult(data, SUCCESS, Constants.SUCCESS_MSG);
}
public static <T> Result<T> success(T data, String msg) {
return restResult(data, SUCCESS, msg);
}
public static <T> Result<T> error() {
return restResult(null, FAIL, Constants.ERROR_MSG);
}
public static <T> Result<T> error(String msg) {
return restResult(null, FAIL, msg);
}
public static <T> Result<T> error(T data) {
return restResult(data, FAIL, Constants.ERROR_MSG);
}
public static <T> Result<T> error(T data, String msg) {
return restResult(data, FAIL, msg);
}
public static <T> Result<T> error(int code, String msg) {
return restResult(null, code, msg);
}
private static <T> Result<T> restResult(T data, int code, String msg) {
Result<T> apiResult = new Result<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
}

38
ruoyi-tast-remote/.gitignore vendored 100644
View File

@ -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

View File

@ -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-tast</artifactId>
<version>3.6.3</version>
</parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-tast-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-tast-common</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</project>

38
ruoyi-tast-server/.gitignore vendored 100644
View File

@ -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

View File

@ -0,0 +1,111 @@
<?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-tast</artifactId>
<version>3.6.3</version>
</parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-tast-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-tast-common</artifactId>
<version>3.6.3</version>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datasource</artifactId>
<version>3.6.3</version>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datascope</artifactId>
<version>3.6.3</version>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-log</artifactId>
<version>3.6.3</version>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-redis</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-file-remote</artifactId>
<version>3.6.3</version>
</dependency>
<!--发送邮件-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!--RabbitMq依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!--websocket-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</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>

View File

@ -0,0 +1,42 @@
package com.ruoyi.tast;
import io.netty.channel.ChannelFuture;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
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;
import java.net.InetSocketAddress;
/**
*
*
* @author ruoyi
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
@EnableRabbit
public class RuoYiSystemApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiSystemApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.tast.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class CommonConfig {
/**
* websocket
* @return
*/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

View File

@ -0,0 +1,33 @@
package com.ruoyi.tast.config;
/**
* redis
*/
public class RedisConstant {
/**
* redis
*/
public static final String CURRENT_INFO="current_info";
/**
* redis
*/
public static final String FAULTS_MESSAGE="faults_message";
/**
* redis
*/
public static final String FAULTS_LOG="faults_LOG";
/**
* redis
*/
public static final String VEHICLE_INFO_TOKEN="vehicle_info_token";
/**
*
*/
public static final String CURRENT_DAY_FAULT="current_day_fault";
/**
*
*/
public static final String CURRENT_MONTH_FAULT="current_month_fault";
}

View File

@ -0,0 +1,117 @@
package com.ruoyi.tast.consumer;
import com.alibaba.fastjson2.JSON;
import com.rabbitmq.client.Channel;
import com.ruoyi.tast.domain.VehicleMessage;
import com.ruoyi.tast.mysingleton.MySingletonHashMap;
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.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Date;
@Component
@Log4j2
public class EmailConsumer {
@Autowired
private JavaMailSender javaMailSender;
// @RabbitListener(queues = "emailQueue")
// public void sendMail(String exceptionMsg1){
// try {
// //构建一个邮箱对象
// SimpleMailMessage emailMessage = new SimpleMailMessage();
// //设置邮件主题
// emailMessage.setSubject("车辆异常报警");
// //设置邮件发送者
// emailMessage.setFrom("3194573917@qq.com");
// //设置发送给谁的,可以多发, 中间用逗号隔开
// emailMessage.setTo("3194573917@qq.com");/*,"3079188394@qq.com","1731931229@qq.com","755401261@qq.com"*/
// //设置邮件发送时间
// emailMessage.setSentDate(new Date());
// //设置邮件正文
// emailMessage.setText("异常信息:"+exceptionMsg1);
// //发送邮件
// javaMailSender.send(emailMessage);
// System.out.println(exceptionMsg1);
//
// }catch (Exception e) {
// // 处理异常情况
// e.printStackTrace();
// throw new RuntimeException(e); // 抛出异常以进行重新投递
// }
//
// }
private boolean absException = false;
private long absExceptionStartTime = 0;
private boolean isAlertSent = false; // 标识是否已发送告警邮件
// MySingletonHashMap singletonHashMap = MySingletonHashMap.getInstance();
// @RabbitListener(queues = "fault_handler_queue")
// public void aaa(String exceptionMsg, Channel channel,Message message){
// log.info("消费者开始消费,信息是:{},队列是:{}",exceptionMsg,"fault_handler_queue");
//
// try {
// VehicleMessage vehicleMessage = JSON.parseObject(exceptionMsg, VehicleMessage.class);
// log.info("消费者消费成功,信息是:{},队列是:{}",exceptionMsg,"fault_handler_queue");
// System.out.println("-------------------"+vehicleMessage);
// singletonHashMap.put(vehicleMessage.getVinCode(),vehicleMessage);
// if (exceptionMsg!=null){
// if (vehicleMessage.getAbs().equals(1)){
// if (absException) {
// // ABS异常已解决重置计时器
// absException = false;
// absExceptionStartTime = 0;
// isAlertSent = false;
// }
// }else {
// log.info("ABS出现异常");
// if (!absException) {
// // ABS异常开始记录开始时间
// absException = true;
// absExceptionStartTime = System.currentTimeMillis();
// }
// }
// if (absException){
// // ABS异常持续中检查是否已经超过10秒
// long duration = System.currentTimeMillis() - absExceptionStartTime;
// if (!isAlertSent && duration >= 10000) {
// // ABS异常持续超过10秒发送告警邮件
// String exceptionMsg1 = "ABS持续异常";
// sendMail(exceptionMsg1);
// isAlertSent = true;// 标记为已发送告警邮件
// }else if (duration < 10000) {
// isAlertSent = false; // 重置标记以便下次超过10秒时再次发送邮件
// }
// }
// }else {
// log.info("消息为空");
// }
//
// channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
// } catch (IOException e) {
//
// try {
// channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
// } catch (IOException ex) {
// log.info("消费者回退失败,信息是:{},队列是:{}",exceptionMsg,"fault_handler_queue");
// throw new RuntimeException(ex);
// }
// throw new RuntimeException(e);
// }
// }
}

View File

@ -0,0 +1,191 @@
package com.ruoyi.tast.controller;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.tast.domain.*;
import com.ruoyi.tast.mysingleton.MySingletonHashMap;
import com.ruoyi.tast.result.Result;
import com.ruoyi.tast.service.CarService;
import com.ruoyi.tast.socket.Websocket;
import lombok.extern.log4j.Log4j2;
import org.checkerframework.checker.units.qual.C;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
@RequestMapping("/car")
@RestController
@Log4j2
public class CarController {
@Autowired
private CarService carService;
@Autowired
private HttpServletRequest request;
/**
*
* @return
*/
@PostMapping("/carList")
public Result<List<Car>> carList(@RequestBody Car car){
log.info("功能名称汽车列表展示请求URI{},请求方式:{}",request.getRequestURI(),request.getMethod());
List<Car> list=carService.carList(car);
Result<List<Car>> result= Result.success(list);
log.info("功能名称汽车列表展示请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
*
* @return
*/
@PostMapping("/findByType")
public Result<List<Type>> findByType(){
log.info("功能名称查询汽车类型下拉框请求URI{},请求方式:{}",request.getRequestURI(),request.getMethod());
List<Type> list=carService.findByType();
Result<List<Type>> result = Result.success(list);
log.info("功能名称查询汽车类型下拉框请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
*
* @return
*/
@PostMapping("/findByFence")
public Result<List<ElectronicFenceSetting>> findByFence(){
log.info("功能名称选择电子围栏请求URI{},请求方式:{}",request.getRequestURI(),request.getMethod());
List<ElectronicFenceSetting> list=carService.findByFence();
Result<List<ElectronicFenceSetting>> result = Result.success(list);
log.info("功能名称选择电子围栏请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
*
* @return
*/
@PostMapping("/findByFirm")
public Result<List<Firm>> findByFirm(){
log.info("功能名称选择企业请求URI{},请求方式:{}",request.getRequestURI(),request.getMethod());
List<Firm> list=carService.findByFirm();
Result<List<Firm>> result = Result.success(list);
log.info("功能名称选择企业请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
*
* @param car
* @return
*/
@PostMapping("/addCar")
public Result addCar(@RequestBody Car car){
log.info("功能名称添加车辆请求URI{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(car));
carService.addCar(car);
Result result=Result.success();
log.info("功能名称添加车辆请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
*
* @param carId
* @return
*/
@PostMapping("/deleteCar/{carId}")
public Result deleteCar(@PathVariable Integer carId){
log.info("功能名称删除汽车请求URI{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),carId);
carService.deleteCar(carId);
Result result=Result.success();
log.info("功能名称删除汽车请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
*
* @param carId
* @return
*/
@PostMapping("/findByCar/{carId}")
public Result<Car> findByCar(@PathVariable Integer carId){
log.info("功能名称编辑车辆信息回显请求URI{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),carId);
Car car=carService.findByCar(carId);
Result<Car> result=Result.success(car);
log.info("功能名称编辑车辆信息回显请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
*
* @param car
* @return
*/
@PostMapping("/updateCar")
public Result updateCar(@RequestBody Car car){
log.info("功能名称修改车辆请求URI{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(car));
carService.updateCar(car);
Result result=Result.success();
log.info("功能名称修改车辆请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
@Autowired
private RabbitTemplate rabbitTemplate;
@PostMapping("/send")
public String sendMail(){
rabbitTemplate.convertAndSend("emailQueue","hello");
System.out.println("发送成功");
return "发送成功";
}
/**
*
* @return
*/
@PostMapping("/report/{vinCode}")
public Result<VehicleMessage> report(@PathVariable String vinCode){
log.info("功能名称获取实时数据请求URI{},请求方式:{}",request.getRequestURI(),request.getMethod());
VehicleMessage vehicleMessage=carService.getcar(vinCode);
Result<VehicleMessage> result=Result.success(vehicleMessage);
// Websocket.sendMessage(String.valueOf(vehicleMessage));
System.out.println("+++++++++++++++++++++++++"+vehicleMessage);
log.info("功能名称获取实时数据请求URI{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
return result;
}
/**
* websocket
* @return
*/
@GetMapping("/send")
public Result<List<Message>> send() {
log.info("功能名称websocket给前台推送消息请求URI{},请求方式:{}", request.getRequestURI(), request.getMethod());
List<Message> messageList = carService.sendCar();
Result<List<Message>> result = Result.success(messageList);
System.out.println("++++++"+messageList.size());
Websocket.sendMessage(String.valueOf(messageList),messageList.size());
log.info("功能名称websocket给前台推送消息请求URI{},请求方式:{},响应结果:{}", request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -0,0 +1,35 @@
//package com.ruoyi.tast.controller;
//
//import io.netty.buffer.Unpooled;
//import io.netty.channel.ChannelInitializer;
//import io.netty.channel.socket.SocketChannel;
//import io.netty.handler.codec.DelimiterBasedFrameDecoder;
//import io.netty.handler.codec.string.StringDecoder;
//import io.netty.handler.codec.string.StringEncoder;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//
//public class MyChannelInitializer extends ChannelInitializer<SocketChannel>{
// private RabbitTemplate rabbitTemplate;
//
// public MyChannelInitializer(RabbitTemplate rabbitTemplate) {
// this.rabbitTemplate = rabbitTemplate;
// }
//
// @Override
// protected void initChannel(SocketChannel channel) throws Exception {
// // 基于换行符号
// channel.pipeline().addLast(new DelimiterBasedFrameDecoder(
// 1024,
// Unpooled.copiedBuffer("#$&*".getBytes()
// )
// ));
// // 解码转String注意调整自己的编码格式GBK、UTF-8
// channel.pipeline().addLast("encoder", new StringEncoder());
// // 解码转String注意调整自己的编码格式GBK、UTF-8
// channel.pipeline().addLast("decoder", new StringDecoder());
// // 在管道中添加我们自己的接收数据实现方法
// channel.pipeline().addLast(new MyServerHandler(rabbitTemplate));
//
// }
//
//}

View File

@ -0,0 +1,730 @@
//package com.ruoyi.tast.controller;
//import com.ruoyi.tast.domain.Message;
//import com.ruoyi.tast.mysingleton.MySingletonHashMap;
//import com.ruoyi.tast.service.CarService;
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.channel.ChannelInboundHandlerAdapter;
//import io.netty.channel.socket.SocketChannel;
//import org.apache.catalina.core.ApplicationContext;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.mail.SimpleMailMessage;
//import org.springframework.mail.javamail.JavaMailSender;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.text.SimpleDateFormat;
//import java.util.*;
//import java.util.concurrent.CompletableFuture;
//import java.util.stream.Collectors;
//
//@Component
//public class MyServerHandler extends ChannelInboundHandlerAdapter{
// private RabbitTemplate rabbitTemplate;
//
// @Autowired
// public MyServerHandler(RabbitTemplate rabbitTemplate) {
// this.rabbitTemplate = rabbitTemplate;
// }
//
// private Logger logger = LoggerFactory.getLogger(MyServerHandler.class);
// /**
// * 当客户端主动链接服务端的链接后,这个通道就是活跃的了。也就是客户端与服务端建立了通信通道并且可以传输数据
// */
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// SocketChannel channel = (SocketChannel) ctx.channel();
// //通知客户端链接建立成功
// System.out.println("====channelActive=====");
// String str = "通知客户端链接建立成功" + " " + new Date() + " " + channel.localAddress().getHostString() + "\r\n";
//
// ctx.writeAndFlush(str+"#$&*");
// }
//
// /**
// * 当客户端主动断开服务端的链接后,这个通道就是不活跃的。也就是说客户端与服务端的关闭了通信通道并且不可以传输数据
// */
// @Override
// public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// logger.info("客户端断开链接{}", ctx.channel().localAddress().toString());
// }
//
//
// private boolean absException = false;
// private long absExceptionStartTime = 0;
// private boolean isAlertSent = false; // 标识是否已发送告警邮件
//// @Autowired
//// private RabbitTemplate rabbitTemplate;
// private CarController carController;
//
// public MyServerHandler() {
// carController = new CarController();
// }
//
// MySingletonHashMap singletonHashMap = MySingletonHashMap.getInstance();
// @Override
// public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// //接收msg消息{与上一章节相比,此处已经不需要自己进行解码}
// logger.info(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " 服务端接收到消息:" + msg);
// //通知客户端链消息发送成功
// String str = "服务端收到:" + new Date() + " " + msg + "\r\n";
// System.out.println("========================================="+str);
//
//
// //空格切割
// String[] msgArray = msg.toString().split(" ");
// List<String> list= Arrays.asList(msgArray);
//
// System.out.println("--------------------"+list);
//
// int size = list.size();
// System.out.println(size);
//
// Message message = new Message();
//
// String string = this.getParsingString(list);
//
//
//
// if (size==208){
//
// CompletableFuture<Void> f1 = CompletableFuture.runAsync(() -> {
// //消息标识
// String string1 = string.substring(0, 13);
// if (string1.length()==13){
// logger.info("消息标识:{}",string1);
// message.setMessageIdentification(string1);
//// cancelTimer("消息标识");
// }else {
// logger.info("消息标识出现异常");
//// if (!exceptionTimers.containsKey("消息标识")) {
//// startTimer("消息标识"); // 开始计时
//// }
// }
// });
//
// CompletableFuture<Void> f2 =CompletableFuture.runAsync(()->{
// //VIN码
// String string2 = string.substring(13, 30);
// if (string2.length()==17){
// logger.info("VIN码:{}",string2);
// message.setVinYard(string2);
// }else {
// logger.info("VIN码出现异常");
// }
// });
//
//
// CompletableFuture<Void> f3 =CompletableFuture.runAsync(()->{
// //经度
// String string3 = string.substring(30, 41);
// if (string3.length()==11){
// logger.info("经度:{}",string3);
// message.setLongitude(string3);
// }else {
// logger.info("经度出现异常");
// }
// });
// CompletableFuture<Void> f4 =CompletableFuture.runAsync(()->{
// //纬度
// String string4 = string.substring(41, 51);
// if (string4.length()==10){
// logger.info("纬度:{}",string4);
// message.setLatitude(string4);
// }else {
// logger.info("维度出现异常");
// }
// });
//
// CompletableFuture<Void> f5 =CompletableFuture.runAsync(()->{
// //车速
// String string5 = string.substring(51, 57);
// if (string5.length()==6){
// logger.info("车速:{}",string5);
// message.setSpeedOfaMotorVehicle(string5);
// }else {
// logger.info("车速出现异常");
// }
// });
//
// CompletableFuture<Void> f6 =CompletableFuture.runAsync(()->{
// //总里程
// String string6 = string.substring(57, 68);
// if (string6.length()==11){
// logger.info("总里程:{}",string6);
// message.setTotalDistance(string6);
// }else {
// logger.info("总里程出现异常");
// }
// });
//
// CompletableFuture<Void> f7 =CompletableFuture.runAsync(()->{
// //总电压
// String string7 = string.substring(68, 74);
// if (string7.length()==6){
// logger.info("总电压:{}",string7);
// message.setTotalVoltage(string7);
// }else {
// logger.info("总电压出现异常");
// }
// });
//
// CompletableFuture<Void> f8 =CompletableFuture.runAsync(()->{
// //总电流
// String string8 = string.substring(74, 79);
// if (string8.length()==5){
// logger.info("总电流:{}",string8);
// message.setTotalCurrent(string8);
// }else {
// logger.info("总电流出现异常");
// }
// });
//
// CompletableFuture<Void> f9 =CompletableFuture.runAsync(()->{
// //绝缘电阻
// String string9 = string.substring(79, 88);
// if (string9.length()==9){
// logger.info("绝缘电阻:{}",string9);
// message.setInsulationResistance(string9);
// }else {
// logger.info("绝缘电阻出现异常");
// }
// });
//
// CompletableFuture<Void> f10 =CompletableFuture.runAsync(()->{
// //档位
// String string10 = string.substring(88, 89);
// if (string10.length()==1){
// logger.info("档位:{}",string10);
// message.setGears(string10);
// }else {
// logger.info("档位出现异常");
// }
// });
//
// CompletableFuture<Void> f11 =CompletableFuture.runAsync(()->{
// //加速踏板行程值
// String string11 = string.substring(89, 91);
// if (string11.length()==2){
// logger.info("加速踏板行程值:{}",string11);
// message.setAcceleratorPedalTravelValue(string11);
// }else {
// logger.info("加速踏板行程值出现异常");
// }
// });
//
// CompletableFuture<Void> f12 =CompletableFuture.runAsync(()->{
// //制动踏板行程值
// String string12 = string.substring(91, 93);
// if (string12.length()==2){
// logger.info("制动踏板行程值:{}",string12);
// message.setBrakePedalTravelValue(string12);
// }else {
// logger.info("制动踏板行程值出现异常");
// }
// });
//
// CompletableFuture<Void> f13 =CompletableFuture.runAsync(()->{
// //燃料消耗率
// String string13 = string.substring(93, 98);
// if (string13.length()==5){
// logger.info("燃料消耗率:{}",string13);
// message.setRateOfFuelConsumption(string13);
// }else {
// logger.info("燃料消耗率出现异常");
// }
// });
//
// CompletableFuture<Void> f14 =CompletableFuture.runAsync(()->{
// //电机控制器温度
// String string14 = string.substring(98, 104);
// if (string14.length()==6){
// logger.info("电机控制器温度:{}",string14);
// message.setMotorControllerTemperature(string14);
// }else {
// logger.info("电机控制器温度出现异常");
// }
// });
//
// CompletableFuture<Void> f15 =CompletableFuture.runAsync(()->{
// //电机转速
// String string15 = string.substring(104, 109);
// if (string15.length()==5){
// logger.info("电机转速:{}",string15);
// message.setMotorSpeed(string15);
// }else {
// logger.info("电机转速出现异常");
// }
// });
//
// CompletableFuture<Void> f16 =CompletableFuture.runAsync(()->{
// //电机转矩
// String string16 = string.substring(109, 113);
// if (string16.length()==4){
// logger.info("电机转矩:{}",string16);
// message.setMotorTorque(string16);
// }else {
// logger.info("电机转矩出现异常");
// }
// });
//
// CompletableFuture<Void> f17 =CompletableFuture.runAsync(()->{
// //电机温度
// String string17 = string.substring(113, 119);
// if (string17.length()==6){
// logger.info("电机温度:{}",string17);
// message.setMotorTemperature(string17);
// }else {
// logger.info("电机温度出现异常");
// }
// });
//
// CompletableFuture<Void> f18 =CompletableFuture.runAsync(()->{
// //电机电压
// String string18 = string.substring(119, 124);
// if (string18.length()==5){
// logger.info("电机电压:{}",string18);
// message.setMotorVoltage(string18);
// }else {
// logger.info("电机电压出现异常");
// }
// });
//
// CompletableFuture<Void> f19 =CompletableFuture.runAsync(()->{
// //电机电流
// String string19 = string.substring(124, 132);
// if (string19.length()==8){
// logger.info("电机电流:{}",string19);
// message.setMotorCurrent(string19);
// }else {
// logger.info("电机电流出现异常");
// }
// });
//
// CompletableFuture<Void> f20 =CompletableFuture.runAsync(()->{
// //动力电池剩余电量SOC
// String string20 = string.substring(132, 138);
// if (string20.length()==6){
// logger.info("动力电池剩余电量SOC:{}",string20);
// message.setPowerBatteryRemainingSOC(string20);
// }else {
// logger.info("动力电池剩余电量SOC出现异常");
// }
// });
//
// CompletableFuture<Void> f21 =CompletableFuture.runAsync(()->{
// //当前状态允许的最大反馈功率
// String string21 = string.substring(138, 144);
// if (string21.length()==6){
// logger.info("当前状态允许的最大反馈功率:{}",string21);
// message.setTheMaximumFeedbackPowerAllowedInTheCurrentState(string21);
// }else {
// logger.info("当前状态允许的最大反馈功率出现异常");
// }
// });
//
// CompletableFuture<Void> f22 =CompletableFuture.runAsync(()->{
// //当前状态允许最大放电功率
// String string22 = string.substring(144, 150);
// if (string22.length()==6){
// logger.info("当前状态允许最大放电功率:{}",string22);
// message.setTheCurrentStateAllowsTheMaximumDischargePower(string22);
// }else {
// logger.info("当前状态允许最大放电功率出现异常");
// }
// });
//
// CompletableFuture<Void> f23 =CompletableFuture.runAsync(()->{
// //BMS自检计数器
// String string23 = string.substring(150, 152);
// if (string23.length()==2){
// logger.info("BMS自检计数器:{}",string23);
// message.setBmsSelfCheckCounter(string23);
// }else {
// logger.info("BMS自检计数器出现异常");
// }
// });
//
// CompletableFuture<Void> f24 =CompletableFuture.runAsync(()->{
// //动力电池充放电电流
// String string24 = string.substring(152, 157);
// if (string24.length()==5){
// logger.info("动力电池充放电电流:{}",string24);
// message.setChargingAndDischargingCurrentOfPowerBattery(string24);
// }else {
// logger.info("动力电池充放电电流出现异常");
// }
// });
//
// CompletableFuture<Void> f25 =CompletableFuture.runAsync(()->{
// //动力电池负载端总电压V3
// String string25 = string.substring(157, 163);
// if (string25.length()==6){
// logger.info("动力电池负载端总电压V3:{}",string25);
// message.setTheTotalVoltageAtTheLoadEndOfThePowerBatteryIsV3(string25);
// }else {
// logger.info("动力电池负载端总电压V3出现异常");
// }
// });
//
// CompletableFuture<Void> f26 =CompletableFuture.runAsync(()->{
// //单次最大电压
// String string26 = string.substring(163, 167);
// if (string26.length()==4){
// logger.info("单次最大电压:{}",string26);
// message.setSingleMaximumVoltage(string26);
// }else {
// logger.info("单次最大电压出现异常");
// }
// });
//
// CompletableFuture<Void> f27 =CompletableFuture.runAsync(()->{
// //单体电池最低电压
// String string27 = string.substring(167, 171);
// if (string27.length()==4){
// logger.info("单体电池最低电压:{}",string27);
// message.setMinimumVoltageOfABattery(string27);
// }else {
// logger.info("单体电池最低电压出现异常");
// }
// });
//
// CompletableFuture<Void> f28 =CompletableFuture.runAsync(()->{
// //单体电池最高温度
// String string28 = string.substring(171, 177);
// if (string28.length()==6){
// logger.info("单体电池最高温度:{}",string28);
// message.setMaximumBatteryTemperature(string28);
// }else {
// logger.info("单体电池最高温度出现异常");
// }
// });
//
// CompletableFuture<Void> f29 =CompletableFuture.runAsync(()->{
// //单体电池最低温度
// String string29 = string.substring(177, 183);
// if (string29.length()==6){
// logger.info("单体电池最低温度:{}",string29);
// message.setMinimumBatteryTemperature(string29);
// }else {
// logger.info("单体电池最低温度出现异常");
// }
// });
//
// CompletableFuture<Void> f30 =CompletableFuture.runAsync(()->{
// //动力电池可用容量
// String string30 = string.substring(183, 189);
// if (string30.length()==6){
// logger.info("动力电池可用容量:{}",string30);
// message.setPowerBatteryAvailableCapacity(string30);
// }else {
// logger.info("动力电池可用容量出现异常");
// }
// });
//
// CompletableFuture<Void> f31 =CompletableFuture.runAsync(()->{
// //车辆状态
// Integer string31 = Integer.valueOf(string.substring(189, 190));
// if (string31.equals(1)){
// logger.info("车辆状态:{}",string31);
// message.setVehicleState(string31);
// }else {
// logger.info("车辆状态出现异常");
// }
// });
//
// CompletableFuture<Void> f32 =CompletableFuture.runAsync(()->{
// //充电状态
// Integer string32 = Integer.valueOf(string.substring(190, 191));
// if (string32.equals(1)){
// logger.info("充电状态:{}",string32);
// message.setStateOfCharge(string32);
// }else {
// logger.info("充电状态出现异常");
// }
// });
//
// CompletableFuture<Void> f33 =CompletableFuture.runAsync(()->{
// //运行状态
// Integer string33 = Integer.valueOf(string.substring(191, 192));
// if (string33.equals(1)){
// logger.info("运行状态:{}",string33);
// message.setRunningStatus(string33);
// }else {
// logger.info("运行状态出现异常");
// }
// });
//
// CompletableFuture<Void> f34 =CompletableFuture.runAsync(()->{
// //SOC
// Integer string34 = Integer.valueOf(string.substring(192, 193));
// if (string34.equals(1)){
// logger.info("SOC:{}",string34);
// message.setSOC(string34);
// }else {
// logger.info("SOC出现异常");
// }
// });
//
// CompletableFuture<Void> f35 =CompletableFuture.runAsync(()->{
// //可充电储能装置工作状态
// Integer string35 = Integer.valueOf(string.substring(193, 194));
// if (string35.equals(1)){
// logger.info("可充电储能装置工作状态:{}",string35);
// message.setWorkingStatusOfRechargeableEnergyStorageDevice(string35);
// }else {
// logger.info("可充电储能装置工作状态出现异常");
// }
// });
//
// CompletableFuture<Void> f36 =CompletableFuture.runAsync(()->{
// //驱动电机状态
// Integer string36 = Integer.valueOf(string.substring(194, 195));
// if (string36.equals(1)){
// logger.info("驱动电机状态:{}",string36);
// message.setDriveMotorCondition(string36);
// }else {
// logger.info("驱动电机状态出现异常");
// }
// });
//
// CompletableFuture<Void> f37 =CompletableFuture.runAsync(()->{
// //定位是否有效
// Integer string37 = Integer.valueOf(string.substring(195, 196));
// if (string37.equals(1)){
// logger.info("定位是否有效:{}",string37);
// message.setWhetherTheLocationIsValid(string37);
// }else {
// logger.info("定位是否有效出现异常");
// }
// });
//
// CompletableFuture<Void> f38 =CompletableFuture.runAsync(()->{
// //EAS
// Integer string38 = Integer.valueOf(string.substring(196, 197));
// if (string38.equals(1)){
// logger.info("EAS:{}",string38);
// message.setEAS(string38);
// }else {
// logger.info("EAS出现异常");
// }
// });
//
// CompletableFuture<Void> f39 =CompletableFuture.runAsync(()->{
// //PTC
// Integer string39 = Integer.valueOf(string.substring(197, 198));
// if (string39.equals(1)){
// logger.info("PTC:{}",string39);
// message.setPTC(string39);
// }else {
// logger.info("PTC出现异常");
// }
// });
//
// CompletableFuture<Void> f40 =CompletableFuture.runAsync(()->{
// //EPS
// Integer string40 = Integer.valueOf(string.substring(198, 199));
// if (string40.equals(1)){
// logger.info("EPS:{}",string40);
// message.setEPS(string40);
// }else {
// logger.info("EPS出现异常");
// }
// });
//
// CompletableFuture<Void> f41 =CompletableFuture.runAsync(()->{
// //ABS
// Integer string41 = Integer.valueOf(string.substring(199, 200));
// if (string41.equals(1)){
// logger.info("ABS:{}",string41);
// message.setABS(string41);
// if (absException) {
// // ABS异常已解决重置计时器
// absException = false;
// absExceptionStartTime = 0;
// isAlertSent = false;
// }
// }else {
// logger.info("ABS出现异常");
// if (!absException) {
// // ABS异常开始记录开始时间
// absException = true;
// absExceptionStartTime = System.currentTimeMillis();
// }
// }
// });
//
// CompletableFuture<Void> f42 =CompletableFuture.runAsync(()->{
// //MCU
// Integer string42 = Integer.valueOf(string.substring(200, 201));
// if (string42.equals(1)){
// logger.info("MCU:{}",string42);
// message.setMCU(string42);
// }else {
// logger.info("MCU出现异常");
// }
// });
//
// CompletableFuture<Void> f43 =CompletableFuture.runAsync(()->{
// //动力电池加热状态
// Integer string43 = Integer.valueOf(string.substring(201, 202));
// if (string43.equals(1)){
// logger.info("动力电池加热状态:{}",string43);
// message.setPowerBatteryHeatingState(string43);
// }else {
// logger.info("动力电池加热状态出现异常");
// }
// });
//
// CompletableFuture<Void> f44 =CompletableFuture.runAsync(()->{
// //动力电池当前状态
// Integer string44 = Integer.valueOf(string.substring(202, 203));
// if (string44.equals(1)){
// logger.info("动力电池当前状态:{}",string44);
// message.setCurrentStatusOfThePowerBattery(string44);
// }else {
// logger.info("动力电池当前状态出现异常");
// }
// });
//
// CompletableFuture<Void> f45 =CompletableFuture.runAsync(()->{
// //动力电池保温状态
// Integer string45 = Integer.valueOf(string.substring(203, 204));
// if (string45.equals(1)){
// logger.info("动力电池保温状态:{}",string45);
// message.setPowerBatteryInsulationState(string45);
// }else {
// logger.info("动力电池保温状态出现异常");
// }
// });
//
// CompletableFuture<Void> f46 =CompletableFuture.runAsync(()->{
// //DCDC
// Integer string46 = Integer.valueOf(string.substring(204, 205));
// if (string46.equals(1)){
// logger.info("DCDC:{}",string46);
// message.setDCDC(string46);
// }else {
// logger.info("DCDC出现异常");
// }
// });
//
// CompletableFuture<Void> f47 =CompletableFuture.runAsync(()->{
// //CHG
// Integer string47 = Integer.valueOf(string.substring(205, 206));
// if (string47.equals(1)){
// logger.info("CHG:{}",string47);
// message.setCHG(string47);
// }else {
// logger.info("CHG出现异常");
// }
// });
//
// CompletableFuture<Void> f48 =CompletableFuture.runAsync(()->{
// //校验位
// String string48 = string.substring(206, 207);
// logger.info("校验位:{}",string48);
// message.setParityBit(string48);
// });
//
// CompletableFuture<Void> f49 =CompletableFuture.runAsync(()->{
// //截止位
// String string49 = string.substring(207, 208);
// logger.info("截止位:{}",string49);
// message.setCutoffBit(string49);
// });
//
//// //MCU
//// String string50 = this.Parsing(list.get(208));
//// logger.info("MCU:{}",string50);
// CompletableFuture.allOf( f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,
// f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,
// f21,f22,f23,f24,f25,f26,f27,f28,f29,f30,
// f31,f32,f33,f34,f35,f36,f37,f38,f39,f40,
// f41,f42,f43,f44,f45,f46,f47,f48,f49).join();
//
// }
//
// if (absException){
// // ABS异常持续中检查是否已经超过10秒
// long duration = System.currentTimeMillis() - absExceptionStartTime;
// if (!isAlertSent && duration >= 10000) {
// // ABS异常持续超过10秒发送告警邮件
// String exceptionMsg = "ABS持续异常";
// rabbitTemplate.convertAndSend("emailQueue",exceptionMsg);
// isAlertSent = true;// 标记为已发送告警邮件
// }else if (duration < 10000) {
// isAlertSent = false; // 重置标记以便下次超过10秒时再次发送邮件
// }
// }
//
// ctx.writeAndFlush(str+"#$&*");
//
// /*singletonHashMap.put(message.getVinYard(),message);*/
//
//// CarController carController = new CarController();
//// carController.report(message);
//
// }
//
// @Autowired
// private JavaMailSender javaMailSender;
//
//
//
// // 发送邮件方法,用于发送异常通知
//// private void sendEmail(String errorMessage) {
//// //构建一个邮箱对象
//// SimpleMailMessage message = new SimpleMailMessage();
//// //设置邮件主题
//// message.setSubject("车辆异常报警");
//// //设置邮件发送者
//// message.setFrom("3194573917@qq.com");
//// //设置发送给谁的,可以多发, 中间用逗号隔开
//// message.setTo("3194573917@qq.com","3079188394@qq.com","1731931229@qq.com","755401261@qq.com");
//// //设置邮件发送时间
//// message.setSentDate(new Date());
//// //设置邮件正文
//// message.setText("异常信息:"+errorMessage);
//// //发送邮件
//// javaMailSender.send(message);
//// }
//
//
//
//
// private String getParsingString(List<String> list) {
// //解析报文
// List<String> msgIdCollect = list.stream().map(s -> {
// String value = Parsing(s);
// return value;
// }).collect(Collectors.toList());
// String s = msgIdCollect.stream().reduce("",(a, b) -> a + b);
// return s;
// }
//
// private String Parsing(String value) {
// //将十六进制字符串hex解析为十进制整数值。
// // 参数16指定要解析的字符串是十六进制格式的。
// int asciiValue = Integer.parseInt(value, 16);
// //我们将解析后的十进制整数值强制转换为一个字符类型。强制转换为char类型将返回对应的ASCII字符。
// char character = (char) asciiValue;
// return String.valueOf(character);
// }
//
// /**
// * 抓住异常,当发生异常的时候,可以做一些相应的处理,比如打印日志、关闭链接
// */
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// ctx.close();
// logger.info("异常信息:\r\n" + cause.getMessage());
// }
//
//
//}

View File

@ -0,0 +1,76 @@
//package com.ruoyi.tast.controller;
//
//import io.netty.bootstrap.ServerBootstrap;
//import io.netty.channel.Channel;
//import io.netty.channel.ChannelFuture;
//import io.netty.channel.ChannelOption;
//import io.netty.channel.EventLoopGroup;
//import io.netty.channel.nio.NioEventLoopGroup;
//import io.netty.channel.socket.nio.NioServerSocketChannel;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.stereotype.Component;
//
//import java.net.InetSocketAddress;
//@Component("nettyServer")
//public class NettyServer {
//
// private Logger logger = LoggerFactory.getLogger(NettyServer.class);
//
// private final EventLoopGroup parentGroup = new NioEventLoopGroup();
// private final EventLoopGroup childGroup = new NioEventLoopGroup();
// private Channel channel;
// private final RabbitTemplate rabbitTemplate;
// public NettyServer(RabbitTemplate rabbitTemplate) {
// this.rabbitTemplate = rabbitTemplate;
// }
//
// /**
// * 绑定端口
// * @param address
// * @return
// */
// public ChannelFuture bind(InetSocketAddress address) {
// ChannelFuture channelFuture = null;
// try {
// ServerBootstrap b = new ServerBootstrap();
// b.group(parentGroup, childGroup)
// .channel(NioServerSocketChannel.class) //非阻塞模式
// .option(ChannelOption.SO_BACKLOG, 128)
// .childHandler(new MyChannelInitializer(rabbitTemplate));
// channelFuture = b.bind(address).syncUninterruptibly();
// channel = channelFuture.channel();
// } catch (Exception e) {
// logger.error(e.getMessage());
// } finally {
// if (null != channelFuture && channelFuture.isSuccess()) {
// logger.info("netty server start done.");
// } else {
// logger.error("netty server start error.");
// }
// }
// return channelFuture;
// }
//
//
// /**
// * 销毁
// */
// public void destroy() {
// if (null == channel) return;
// channel.close();
// parentGroup.shutdownGracefully();
// childGroup.shutdownGracefully();
// }
//
//
// /**
// * 获取通道
// * @return
// */
// public Channel getChannel() {
// return channel;
// }
//
//}

View File

@ -0,0 +1,31 @@
package com.ruoyi.tast.mapper;
import com.ruoyi.tast.domain.Car;
import com.ruoyi.tast.domain.ElectronicFenceSetting;
import com.ruoyi.tast.domain.Firm;
import com.ruoyi.tast.domain.Type;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CarMapper {
List<Car> carList(Car car);
List<Type> findByType();
List<ElectronicFenceSetting> findByFence();
List<Firm> findByFirm();
void addCar(Car car);
void deleteCar(@Param("carId") Integer carId);
Car findByCar(@Param("carId") Integer carId);
void updateCar(Car car);
}

View File

@ -0,0 +1,30 @@
package com.ruoyi.tast.mysingleton;
import com.ruoyi.tast.domain.VehicleMessage;
import java.util.HashMap;
public class MySingletonHashMap {
private static MySingletonHashMap instance; // 保存 HashMap 实例的变量
private HashMap<String, VehicleMessage> hashMap; // 实际保存数据的 HashMap
private MySingletonHashMap() {
hashMap = new HashMap<String, VehicleMessage>();
}
public synchronized static MySingletonHashMap getInstance() {
if (instance == null) { // 如果实例变量为空,则创建一个新的实例
instance = new MySingletonHashMap();
}
return instance;
}
public void put(String key, VehicleMessage value) {
hashMap.put(key, value);
}
public VehicleMessage get(String key) {
return hashMap.get(key);
}
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.tast.service;
import com.ruoyi.tast.domain.*;
import java.util.List;
public interface CarService {
List<Car> carList(Car car);
List<Type> findByType();
List<ElectronicFenceSetting> findByFence();
List<Firm> findByFirm();
void addCar(Car car);
void deleteCar(Integer carId);
Car findByCar(Integer carId);
void updateCar(Car car);
VehicleMessage getcar(String vinCode);
List<Message> sendCar();
}

View File

@ -0,0 +1,107 @@
package com.ruoyi.tast.service.impl;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.tast.config.RedisConstant;
import com.ruoyi.tast.domain.*;
import com.ruoyi.tast.mapper.CarMapper;
import com.ruoyi.tast.service.CarService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
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.Collection;
import java.util.List;
import java.util.Set;
@Service
public class CarServiceImpl implements CarService {
@Autowired
private CarMapper carMapper;
@Autowired
private RabbitTemplate rabbitTemplate;
@Override
public List<Car> carList(Car car) {
return carMapper.carList(car);
}
@Override
public List<Type> findByType() {
return carMapper.findByType();
}
@Override
public List<ElectronicFenceSetting> findByFence() {
return carMapper.findByFence();
}
@Override
public List<Firm> findByFirm() {
return carMapper.findByFirm();
}
@Override
public void addCar(Car car) {
carMapper.addCar(car);
}
@Override
public void deleteCar(Integer carId) {
carMapper.deleteCar(carId);
}
@Override
public Car findByCar(Integer carId) {
return carMapper.findByCar(carId);
}
@Override
public void updateCar(Car car) {
carMapper.updateCar(car);
}
@Autowired
private RedisService redisService;
@Override
public VehicleMessage getcar(String vinCode) {
String s = redisService.getCacheObject("current_info:" + vinCode);
VehicleMessage vehicleMessage = JSON.parseObject(s, VehicleMessage.class);
return vehicleMessage;
}
@Override
public List<Message> sendCar() {
// 获取Redis中所有的键
Set<String> keys = (Set<String>) redisService.keys("current_info:*");
// Integer s = Integer.valueOf(redisTemplate.opsForValue().get(RedisConstant.VEHICLE_INFO_TOKEN + RedisConstant.CURRENT_DAY_FAULT));
// Integer s2 = Integer.valueOf(redisTemplate.opsForValue().get(RedisConstant.VEHICLE_INFO_TOKEN + RedisConstant.CURRENT_MONTH_FAULT));
Integer s = redisService.getCacheObject(RedisConstant.VEHICLE_INFO_TOKEN + RedisConstant.CURRENT_DAY_FAULT);
Integer s2 = redisService.getCacheObject(RedisConstant.VEHICLE_INFO_TOKEN + RedisConstant.CURRENT_MONTH_FAULT);
// 存储所有的值
List<Message> list = new ArrayList<>();
// 遍历每个键并获取对应的值
for (String key : keys) {
String value = redisService.getCacheObject(key);
Message message = JSON.parseObject(value, Message.class);
if (s != null) {
message.setDayMalfunction(s);
}
if (s2 != null) {
message.setMonthMalfunction(s2);
}
list.add(message);
}
return list;
}
}

View File

@ -0,0 +1,76 @@
package com.ruoyi.tast.socket;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint("/websocket/{username}")
@Slf4j
@Component
public class Websocket {
//静态变量,用来记录当前在线连接数。设计为安全的
private static int onlineCount = 0;
//concurrentHashMap分段锁用来存放每个客户端对应的Websocket对象。
private static Map<String, Websocket> clients = new ConcurrentHashMap<String, Websocket>();
//与某个客户端的连接会话,需要通过它来给客户端发送数据
private Session session;
private String username;
/**
*
* @param username
* @param session
*/
@OnOpen
public void onOpen(@PathParam("username") String username, Session session) {
this.username = username;
this.session = session;
Websocket.onlineCount++;
log.info("有一连接进入!当前在线人数为" + onlineCount);
clients.put(username, this);
}
/**
*
*/
@OnClose
public void onClose() {
clients.remove(username);
Websocket.onlineCount--;
log.info("有一连接关闭!当前在线人数为" + onlineCount);
}
/**
*
* @param message
*/
@OnMessage
public void onMessage(String message) {
System.out.println("收到客户端的消息"+message);
}
@OnError
public void onError(Session session, Throwable throwable) {
log.error("WebSocket发生错误" + throwable.getMessage());
}
public static void sendMessage(String message, int size) {
// 向所有连接websocket的客户端发送消息
// 可以修改为对某个客户端发消息
for (Websocket item : clients.values()) {
String fullMessage = message + ", size: " + size; // 将消息内容和size组合起来
try {
item.session.getBasicRemote().sendText(fullMessage);
} catch (IOException e) {
log.error("发送消息出错:" + e.getMessage());
}
}
}
}

View File

@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
__/ | __/ |
|___/ |___/

View File

@ -0,0 +1,52 @@
# Tomcat
server:
port: 3335
netty:
host: 127.0.0.1
port: 7397
# Spring0
spring:
rabbitmq:
host: 10.100.27.4
port: 5672
username: guest
password: guest
application:
# 应用名称
name: ruoyi-tast
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}
# 邮件
mail:
# 邮件服务器地址
host: smtp.qq.com
# 你的邮箱地址
username: 3194573917@qq.com
# 授权码
password: nflrodxlcaczdgfj
# 编码格式
default-encoding: utf-8
# 协议
protocol: smtp
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
port: 587

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="ruoyi-tast" />
<!-- 日志输出格式 -->
<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.yun" 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>

View File

@ -0,0 +1,93 @@
<?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.tast.mapper.CarMapper">
<insert id="addCar">
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},
1,
#{carVin},
#{firmId},
1
)
</insert>
<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_status=1,car_vin=#{carVin},firm_id=#{firmId} where car_id=#{carId}
</update>
<update id="deleteCar">
update car set deletion=2 where car_id=#{carId}
</update>
<select id="carList" resultType="com.ruoyi.tast.domain.Car">
select c.car_id,c.car_name, t.type_name,e.fence_name,c.manufacturer_name,
c.battery_name,c.manufacturer_desc,c.battery_desc,c.car_status,c.car_vin,f.firm_name from car c
left join type t on c.type_id=t.type_id
left join electronic_fence_setting e on c.firm_id=e.fence_id
left join firm f on c.firm_id=f.firm_id
<where>
<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="manufacturerName!=null and ''!=manufacturerName">
and c.manufacturer_name like concat('%',#{manufacturerName},'%')
</if>
<if test="batteryName!=null and ''!=batteryName">
and c.battery_name like concat('%',#{batteryName},'%')
</if>
<if test="manufacturerDesc!=null and ''!=manufacturerDesc">
and c.manufacturer_desc like concat('%',#{manufacturerDesc},'%')
</if>
<if test="batteryDesc!=null and ''!=batteryDesc">
and c.battery_desc like concat('%',#{batteryDesc},'%')
</if>
<if test="carStatus!=null">
and c.car_status = #{carStatus}
</if>
<if test="firmId!=null">
and c.firm_id = #{firmId}
</if>
and c.deletion=1
</where>
</select>
<select id="findByType" resultType="com.ruoyi.tast.domain.Type">
select * from type
</select>
<select id="findByFence" resultType="com.ruoyi.tast.domain.ElectronicFenceSetting">
select fence_id,fence_name from electronic_fence_setting
</select>
<select id="findByFirm" resultType="com.ruoyi.tast.domain.Firm">
select firm_id,firm_name from firm
</select>
<select id="findByCar" resultType="com.ruoyi.tast.domain.Car">
select * from car c
left join type t on c.type_id=t.type_id
left join electronic_fence_setting e on c.firm_id=e.fence_id
left join firm f on c.firm_id=f.firm_id where c.car_id=#{carId}
</select>
</mapper>