commit 5222495420fee04e52fcf986ab3353705cc0edb3
Author: gukaixuan <1>
Date: Fri Sep 15 20:46:53 2023 +0800
car-tast
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..09bdfea
--- /dev/null
+++ b/.gitignore
@@ -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
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..fdc1364
--- /dev/null
+++ b/Dockerfile
@@ -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"]
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..01dfdb0
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,26 @@
+
+
+
+ com.ruoyi
+ ruoyi
+ 3.6.3
+
+ pom
+
+ ruoyi-tast-common
+ ruoyi-tast-remote
+ ruoyi-tast-server
+
+ 3.6.3
+ 4.0.0
+
+ ruoyi-modules-tast
+
+
+ ruoyi-modules-system系统模块
+
+
+
+
diff --git a/ruoyi-tast-common/.gitignore b/ruoyi-tast-common/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/ruoyi-tast-common/.gitignore
@@ -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
\ No newline at end of file
diff --git a/ruoyi-tast-common/pom.xml b/ruoyi-tast-common/pom.xml
new file mode 100644
index 0000000..4c9e234
--- /dev/null
+++ b/ruoyi-tast-common/pom.xml
@@ -0,0 +1,78 @@
+
+
+ 4.0.0
+
+ com.ruoyi
+ ruoyi-modules-tast
+ 3.6.3
+
+
+ com.ruoyi
+ ruoyi-tast-common
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ net.logstash.logback
+ logstash-logback-encoder
+ 6.6
+
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ ${swagger.fox.version}
+
+
+
+
+ com.mysql
+ mysql-connector-j
+
+
+
+ com.ruoyi
+ ruoyi-common-core
+ 3.6.3
+
+
+
+
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Car.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Car.java
new file mode 100644
index 0000000..906bfe0
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Car.java
@@ -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;
+
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/ElectronicFenceSetting.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/ElectronicFenceSetting.java
new file mode 100644
index 0000000..9b2da28
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/ElectronicFenceSetting.java
@@ -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;
+
+
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Exception.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Exception.java
new file mode 100644
index 0000000..d5a7a59
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Exception.java
@@ -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;
+
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Firm.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Firm.java
new file mode 100644
index 0000000..ad617c8
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Firm.java
@@ -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;
+
+
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Message.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Message.java
new file mode 100644
index 0000000..9e05bea
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Message.java
@@ -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;
+
+
+
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Type.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Type.java
new file mode 100644
index 0000000..0e36d2c
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/Type.java
@@ -0,0 +1,11 @@
+package com.ruoyi.tast.domain;
+
+import lombok.Data;
+
+@Data
+public class Type {
+
+ private Integer typeId;
+ private String typeName;
+
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/User.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/User.java
new file mode 100644
index 0000000..7e07978
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/User.java
@@ -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;
+
+
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/VehicleMessage.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/VehicleMessage.java
new file mode 100644
index 0000000..7604558
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/domain/VehicleMessage.java
@@ -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;
+}
+
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/Constants.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/Constants.java
new file mode 100644
index 0000000..ec0191d
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/Constants.java
@@ -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 = "操作异常";
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/PageResult.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/PageResult.java
new file mode 100644
index 0000000..0f69eff
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/PageResult.java
@@ -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 implements Serializable {
+ /**
+ * 总条数
+ */
+ private long total;
+ /**
+ * 结果集合
+ */
+ private List list;
+ public PageResult() {
+ }
+ public PageResult(long total, List list) {
+ this.total = total;
+ this.list = list;
+ }
+ public static PageResult toPageResult(long total, List list){
+ return new PageResult(total , list);
+ }
+ public static Result> toResult(long total, List list){
+ return Result.success(PageResult.toPageResult(total,list));
+ }
+}
diff --git a/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/Result.java b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/Result.java
new file mode 100644
index 0000000..ffc982f
--- /dev/null
+++ b/ruoyi-tast-common/src/main/java/com/ruoyi/tast/result/Result.java
@@ -0,0 +1,75 @@
+package com.ruoyi.tast.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author
+ * @description: 响应信息主体
+ */
+@Data
+public class Result 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 Result success() {
+ return restResult(null, SUCCESS, Constants.SUCCESS_MSG);
+ }
+
+ public static Result success(T data) {
+ return restResult(data, SUCCESS, Constants.SUCCESS_MSG);
+ }
+
+ public static Result success(T data, String msg) {
+ return restResult(data, SUCCESS, msg);
+ }
+
+ public static Result error() {
+ return restResult(null, FAIL, Constants.ERROR_MSG);
+ }
+
+ public static Result error(String msg) {
+ return restResult(null, FAIL, msg);
+ }
+
+ public static Result error(T data) {
+ return restResult(data, FAIL, Constants.ERROR_MSG);
+ }
+
+ public static Result error(T data, String msg) {
+ return restResult(data, FAIL, msg);
+ }
+
+ public static Result error(int code, String msg) {
+ return restResult(null, code, msg);
+ }
+
+ private static Result restResult(T data, int code, String msg) {
+ Result apiResult = new Result<>();
+ apiResult.setCode(code);
+ apiResult.setData(data);
+ apiResult.setMsg(msg);
+ return apiResult;
+ }
+}
diff --git a/ruoyi-tast-remote/.gitignore b/ruoyi-tast-remote/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/ruoyi-tast-remote/.gitignore
@@ -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
\ No newline at end of file
diff --git a/ruoyi-tast-remote/pom.xml b/ruoyi-tast-remote/pom.xml
new file mode 100644
index 0000000..567203f
--- /dev/null
+++ b/ruoyi-tast-remote/pom.xml
@@ -0,0 +1,29 @@
+
+
+ 4.0.0
+
+ com.ruoyi
+ ruoyi-modules-tast
+ 3.6.3
+
+
+ com.ruoyi
+ ruoyi-tast-remote
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ com.ruoyi
+ ruoyi-tast-common
+ 3.6.3
+
+
+
+
\ No newline at end of file
diff --git a/ruoyi-tast-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-tast-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..e69de29
diff --git a/ruoyi-tast-server/.gitignore b/ruoyi-tast-server/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/ruoyi-tast-server/.gitignore
@@ -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
\ No newline at end of file
diff --git a/ruoyi-tast-server/pom.xml b/ruoyi-tast-server/pom.xml
new file mode 100644
index 0000000..6b96130
--- /dev/null
+++ b/ruoyi-tast-server/pom.xml
@@ -0,0 +1,111 @@
+
+
+ 4.0.0
+
+ com.ruoyi
+ ruoyi-modules-tast
+ 3.6.3
+
+
+ com.ruoyi
+ ruoyi-tast-server
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+
+ com.ruoyi
+ ruoyi-tast-common
+ 3.6.3
+
+
+
+
+ com.ruoyi
+ ruoyi-common-datasource
+ 3.6.3
+
+
+
+
+ com.ruoyi
+ ruoyi-common-datascope
+ 3.6.3
+
+
+
+
+ com.ruoyi
+ ruoyi-common-log
+ 3.6.3
+
+
+
+ com.ruoyi
+ ruoyi-common-swagger
+ 3.6.3
+
+
+
+ com.ruoyi
+ ruoyi-common-redis
+ 3.6.3
+
+
+
+ com.ruoyi
+ ruoyi-file-remote
+ 3.6.3
+
+
+
+ org.springframework.boot
+ spring-boot-starter-mail
+
+
+
+ org.springframework.boot
+ spring-boot-starter-amqp
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+
+
+
+
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/RuoYiSystemApplication.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/RuoYiSystemApplication.java
new file mode 100644
index 0000000..b3db176
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/RuoYiSystemApplication.java
@@ -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" +
+ " ''-' `'-' `-..-' ");
+ }
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/config/CommonConfig.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/config/CommonConfig.java
new file mode 100644
index 0000000..707df60
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/config/CommonConfig.java
@@ -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();
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/config/RedisConstant.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/config/RedisConstant.java
new file mode 100644
index 0000000..0e82060
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/config/RedisConstant.java
@@ -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";
+
+
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/consumer/EmailConsumer.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/consumer/EmailConsumer.java
new file mode 100644
index 0000000..c28ce99
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/consumer/EmailConsumer.java
@@ -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);
+// }
+// }
+
+
+
+
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/CarController.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/CarController.java
new file mode 100644
index 0000000..ccf2e9f
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/CarController.java
@@ -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> carList(@RequestBody Car car){
+ log.info("功能名称,汽车列表展示,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
+ List list=carService.carList(car);
+ Result> result= Result.success(list);
+ log.info("功能名称,汽车列表展示,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
+ return result;
+ }
+
+ /**
+ * 查询汽车类型下拉框
+ * @return
+ */
+ @PostMapping("/findByType")
+ public Result> findByType(){
+ log.info("功能名称,查询汽车类型下拉框,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
+ List list=carService.findByType();
+ Result> result = Result.success(list);
+ log.info("功能名称,查询汽车类型下拉框,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
+ return result;
+ }
+
+ /**
+ * 选择电子围栏
+ * @return
+ */
+ @PostMapping("/findByFence")
+ public Result> findByFence(){
+ log.info("功能名称,选择电子围栏,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
+ List list=carService.findByFence();
+ Result> result = Result.success(list);
+ log.info("功能名称,选择电子围栏,请求URI:{},请求方式:{},响应结果:{}",request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result));
+ return result;
+ }
+
+ /**
+ * 选择企业
+ * @return
+ */
+ @PostMapping("/findByFirm")
+ public Result> findByFirm(){
+ log.info("功能名称,选择企业,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
+ List list=carService.findByFirm();
+ Result> 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 findByCar(@PathVariable Integer carId){
+ log.info("功能名称,编辑车辆信息回显,请求URI:{},请求方式:{},请求参数:{}",request.getRequestURI(),request.getMethod(),carId);
+ Car car=carService.findByCar(carId);
+ Result 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 report(@PathVariable String vinCode){
+ log.info("功能名称,获取实时数据,请求URI:{},请求方式:{}",request.getRequestURI(),request.getMethod());
+
+ VehicleMessage vehicleMessage=carService.getcar(vinCode);
+
+ Result 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> send() {
+ log.info("功能名称,websocket给前台推送消息,请求URI:{},请求方式:{}", request.getRequestURI(), request.getMethod());
+ List messageList = carService.sendCar();
+
+ Result> 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;
+ }
+
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/MyChannelInitializer.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/MyChannelInitializer.java
new file mode 100644
index 0000000..7ef33cf
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/MyChannelInitializer.java
@@ -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{
+// 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));
+//
+// }
+//
+//}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/MyServerHandler.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/MyServerHandler.java
new file mode 100644
index 0000000..ee23eec
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/MyServerHandler.java
@@ -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 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 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 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 f3 =CompletableFuture.runAsync(()->{
+// //经度
+// String string3 = string.substring(30, 41);
+// if (string3.length()==11){
+// logger.info("经度:{}",string3);
+// message.setLongitude(string3);
+// }else {
+// logger.info("经度出现异常");
+// }
+// });
+// CompletableFuture f4 =CompletableFuture.runAsync(()->{
+// //纬度
+// String string4 = string.substring(41, 51);
+// if (string4.length()==10){
+// logger.info("纬度:{}",string4);
+// message.setLatitude(string4);
+// }else {
+// logger.info("维度出现异常");
+// }
+// });
+//
+// CompletableFuture f5 =CompletableFuture.runAsync(()->{
+// //车速
+// String string5 = string.substring(51, 57);
+// if (string5.length()==6){
+// logger.info("车速:{}",string5);
+// message.setSpeedOfaMotorVehicle(string5);
+// }else {
+// logger.info("车速出现异常");
+// }
+// });
+//
+// CompletableFuture f6 =CompletableFuture.runAsync(()->{
+// //总里程
+// String string6 = string.substring(57, 68);
+// if (string6.length()==11){
+// logger.info("总里程:{}",string6);
+// message.setTotalDistance(string6);
+// }else {
+// logger.info("总里程出现异常");
+// }
+// });
+//
+// CompletableFuture f7 =CompletableFuture.runAsync(()->{
+// //总电压
+// String string7 = string.substring(68, 74);
+// if (string7.length()==6){
+// logger.info("总电压:{}",string7);
+// message.setTotalVoltage(string7);
+// }else {
+// logger.info("总电压出现异常");
+// }
+// });
+//
+// CompletableFuture f8 =CompletableFuture.runAsync(()->{
+// //总电流
+// String string8 = string.substring(74, 79);
+// if (string8.length()==5){
+// logger.info("总电流:{}",string8);
+// message.setTotalCurrent(string8);
+// }else {
+// logger.info("总电流出现异常");
+// }
+// });
+//
+// CompletableFuture f9 =CompletableFuture.runAsync(()->{
+// //绝缘电阻
+// String string9 = string.substring(79, 88);
+// if (string9.length()==9){
+// logger.info("绝缘电阻:{}",string9);
+// message.setInsulationResistance(string9);
+// }else {
+// logger.info("绝缘电阻出现异常");
+// }
+// });
+//
+// CompletableFuture f10 =CompletableFuture.runAsync(()->{
+// //档位
+// String string10 = string.substring(88, 89);
+// if (string10.length()==1){
+// logger.info("档位:{}",string10);
+// message.setGears(string10);
+// }else {
+// logger.info("档位出现异常");
+// }
+// });
+//
+// CompletableFuture f11 =CompletableFuture.runAsync(()->{
+// //加速踏板行程值
+// String string11 = string.substring(89, 91);
+// if (string11.length()==2){
+// logger.info("加速踏板行程值:{}",string11);
+// message.setAcceleratorPedalTravelValue(string11);
+// }else {
+// logger.info("加速踏板行程值出现异常");
+// }
+// });
+//
+// CompletableFuture f12 =CompletableFuture.runAsync(()->{
+// //制动踏板行程值
+// String string12 = string.substring(91, 93);
+// if (string12.length()==2){
+// logger.info("制动踏板行程值:{}",string12);
+// message.setBrakePedalTravelValue(string12);
+// }else {
+// logger.info("制动踏板行程值出现异常");
+// }
+// });
+//
+// CompletableFuture f13 =CompletableFuture.runAsync(()->{
+// //燃料消耗率
+// String string13 = string.substring(93, 98);
+// if (string13.length()==5){
+// logger.info("燃料消耗率:{}",string13);
+// message.setRateOfFuelConsumption(string13);
+// }else {
+// logger.info("燃料消耗率出现异常");
+// }
+// });
+//
+// CompletableFuture f14 =CompletableFuture.runAsync(()->{
+// //电机控制器温度
+// String string14 = string.substring(98, 104);
+// if (string14.length()==6){
+// logger.info("电机控制器温度:{}",string14);
+// message.setMotorControllerTemperature(string14);
+// }else {
+// logger.info("电机控制器温度出现异常");
+// }
+// });
+//
+// CompletableFuture f15 =CompletableFuture.runAsync(()->{
+// //电机转速
+// String string15 = string.substring(104, 109);
+// if (string15.length()==5){
+// logger.info("电机转速:{}",string15);
+// message.setMotorSpeed(string15);
+// }else {
+// logger.info("电机转速出现异常");
+// }
+// });
+//
+// CompletableFuture f16 =CompletableFuture.runAsync(()->{
+// //电机转矩
+// String string16 = string.substring(109, 113);
+// if (string16.length()==4){
+// logger.info("电机转矩:{}",string16);
+// message.setMotorTorque(string16);
+// }else {
+// logger.info("电机转矩出现异常");
+// }
+// });
+//
+// CompletableFuture f17 =CompletableFuture.runAsync(()->{
+// //电机温度
+// String string17 = string.substring(113, 119);
+// if (string17.length()==6){
+// logger.info("电机温度:{}",string17);
+// message.setMotorTemperature(string17);
+// }else {
+// logger.info("电机温度出现异常");
+// }
+// });
+//
+// CompletableFuture f18 =CompletableFuture.runAsync(()->{
+// //电机电压
+// String string18 = string.substring(119, 124);
+// if (string18.length()==5){
+// logger.info("电机电压:{}",string18);
+// message.setMotorVoltage(string18);
+// }else {
+// logger.info("电机电压出现异常");
+// }
+// });
+//
+// CompletableFuture f19 =CompletableFuture.runAsync(()->{
+// //电机电流
+// String string19 = string.substring(124, 132);
+// if (string19.length()==8){
+// logger.info("电机电流:{}",string19);
+// message.setMotorCurrent(string19);
+// }else {
+// logger.info("电机电流出现异常");
+// }
+// });
+//
+// CompletableFuture 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 f21 =CompletableFuture.runAsync(()->{
+// //当前状态允许的最大反馈功率
+// String string21 = string.substring(138, 144);
+// if (string21.length()==6){
+// logger.info("当前状态允许的最大反馈功率:{}",string21);
+// message.setTheMaximumFeedbackPowerAllowedInTheCurrentState(string21);
+// }else {
+// logger.info("当前状态允许的最大反馈功率出现异常");
+// }
+// });
+//
+// CompletableFuture f22 =CompletableFuture.runAsync(()->{
+// //当前状态允许最大放电功率
+// String string22 = string.substring(144, 150);
+// if (string22.length()==6){
+// logger.info("当前状态允许最大放电功率:{}",string22);
+// message.setTheCurrentStateAllowsTheMaximumDischargePower(string22);
+// }else {
+// logger.info("当前状态允许最大放电功率出现异常");
+// }
+// });
+//
+// CompletableFuture 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 f24 =CompletableFuture.runAsync(()->{
+// //动力电池充放电电流
+// String string24 = string.substring(152, 157);
+// if (string24.length()==5){
+// logger.info("动力电池充放电电流:{}",string24);
+// message.setChargingAndDischargingCurrentOfPowerBattery(string24);
+// }else {
+// logger.info("动力电池充放电电流出现异常");
+// }
+// });
+//
+// CompletableFuture 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 f26 =CompletableFuture.runAsync(()->{
+// //单次最大电压
+// String string26 = string.substring(163, 167);
+// if (string26.length()==4){
+// logger.info("单次最大电压:{}",string26);
+// message.setSingleMaximumVoltage(string26);
+// }else {
+// logger.info("单次最大电压出现异常");
+// }
+// });
+//
+// CompletableFuture f27 =CompletableFuture.runAsync(()->{
+// //单体电池最低电压
+// String string27 = string.substring(167, 171);
+// if (string27.length()==4){
+// logger.info("单体电池最低电压:{}",string27);
+// message.setMinimumVoltageOfABattery(string27);
+// }else {
+// logger.info("单体电池最低电压出现异常");
+// }
+// });
+//
+// CompletableFuture f28 =CompletableFuture.runAsync(()->{
+// //单体电池最高温度
+// String string28 = string.substring(171, 177);
+// if (string28.length()==6){
+// logger.info("单体电池最高温度:{}",string28);
+// message.setMaximumBatteryTemperature(string28);
+// }else {
+// logger.info("单体电池最高温度出现异常");
+// }
+// });
+//
+// CompletableFuture f29 =CompletableFuture.runAsync(()->{
+// //单体电池最低温度
+// String string29 = string.substring(177, 183);
+// if (string29.length()==6){
+// logger.info("单体电池最低温度:{}",string29);
+// message.setMinimumBatteryTemperature(string29);
+// }else {
+// logger.info("单体电池最低温度出现异常");
+// }
+// });
+//
+// CompletableFuture f30 =CompletableFuture.runAsync(()->{
+// //动力电池可用容量
+// String string30 = string.substring(183, 189);
+// if (string30.length()==6){
+// logger.info("动力电池可用容量:{}",string30);
+// message.setPowerBatteryAvailableCapacity(string30);
+// }else {
+// logger.info("动力电池可用容量出现异常");
+// }
+// });
+//
+// CompletableFuture 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 f48 =CompletableFuture.runAsync(()->{
+// //校验位
+// String string48 = string.substring(206, 207);
+// logger.info("校验位:{}",string48);
+// message.setParityBit(string48);
+// });
+//
+// CompletableFuture 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 list) {
+// //解析报文
+// List 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());
+// }
+//
+//
+//}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/NettyServer.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/NettyServer.java
new file mode 100644
index 0000000..8f3a830
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/controller/NettyServer.java
@@ -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;
+// }
+//
+//}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/mapper/CarMapper.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/mapper/CarMapper.java
new file mode 100644
index 0000000..c4cd1a8
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/mapper/CarMapper.java
@@ -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 carList(Car car);
+
+ List findByType();
+
+ List findByFence();
+
+ List findByFirm();
+
+ void addCar(Car car);
+
+ void deleteCar(@Param("carId") Integer carId);
+
+ Car findByCar(@Param("carId") Integer carId);
+
+ void updateCar(Car car);
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/mysingleton/MySingletonHashMap.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/mysingleton/MySingletonHashMap.java
new file mode 100644
index 0000000..417d16a
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/mysingleton/MySingletonHashMap.java
@@ -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 hashMap; // 实际保存数据的 HashMap
+
+ private MySingletonHashMap() {
+ hashMap = new HashMap();
+ }
+
+ 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);
+ }
+
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/service/CarService.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/service/CarService.java
new file mode 100644
index 0000000..b93cf86
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/service/CarService.java
@@ -0,0 +1,27 @@
+package com.ruoyi.tast.service;
+
+import com.ruoyi.tast.domain.*;
+
+import java.util.List;
+
+public interface CarService {
+ List carList(Car car);
+
+ List findByType();
+
+ List findByFence();
+
+ List findByFirm();
+
+ void addCar(Car car);
+
+ void deleteCar(Integer carId);
+
+ Car findByCar(Integer carId);
+
+ void updateCar(Car car);
+
+ VehicleMessage getcar(String vinCode);
+
+ List sendCar();
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/service/impl/CarServiceImpl.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/service/impl/CarServiceImpl.java
new file mode 100644
index 0000000..f5c51f5
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/service/impl/CarServiceImpl.java
@@ -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 carList(Car car) {
+ return carMapper.carList(car);
+ }
+
+ @Override
+ public List findByType() {
+ return carMapper.findByType();
+ }
+
+ @Override
+ public List findByFence() {
+ return carMapper.findByFence();
+ }
+
+ @Override
+ public List 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 sendCar() {
+ // 获取Redis中所有的键
+
+ Set keys = (Set) 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 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;
+ }
+
+}
diff --git a/ruoyi-tast-server/src/main/java/com/ruoyi/tast/socket/Websocket.java b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/socket/Websocket.java
new file mode 100644
index 0000000..d090389
--- /dev/null
+++ b/ruoyi-tast-server/src/main/java/com/ruoyi/tast/socket/Websocket.java
@@ -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 clients = new ConcurrentHashMap();
+ //与某个客户端的连接会话,需要通过它来给客户端发送数据
+ 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());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-tast-server/src/main/resources/banner.txt b/ruoyi-tast-server/src/main/resources/banner.txt
new file mode 100644
index 0000000..fbd45f5
--- /dev/null
+++ b/ruoyi-tast-server/src/main/resources/banner.txt
@@ -0,0 +1,10 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}
+ _ _
+ (_) | |
+ _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
+| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
+| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
+|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
+ __/ | __/ |
+ |___/ |___/
\ No newline at end of file
diff --git a/ruoyi-tast-server/src/main/resources/bootstrap.yml b/ruoyi-tast-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..9cb8425
--- /dev/null
+++ b/ruoyi-tast-server/src/main/resources/bootstrap.yml
@@ -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
diff --git a/ruoyi-tast-server/src/main/resources/logback.xml b/ruoyi-tast-server/src/main/resources/logback.xml
new file mode 100644
index 0000000..8617958
--- /dev/null
+++ b/ruoyi-tast-server/src/main/resources/logback.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+ ${log.pattern}
+
+
+
+
+
+ ${log.path}/info.log
+
+
+
+ ${log.path}/info.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ INFO
+
+ ACCEPT
+
+ DENY
+
+
+
+
+ ${log.path}/error.log
+
+
+
+ ${log.path}/error.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ ERROR
+
+ ACCEPT
+
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ruoyi-tast-server/src/main/resources/mapper/tast/CarMapper.xml b/ruoyi-tast-server/src/main/resources/mapper/tast/CarMapper.xml
new file mode 100644
index 0000000..0a8d496
--- /dev/null
+++ b/ruoyi-tast-server/src/main/resources/mapper/tast/CarMapper.xml
@@ -0,0 +1,93 @@
+
+
+
+
+ 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
+ )
+
+
+ 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 car set deletion=2 where car_id=#{carId}
+
+
+
+
+
+
+
+
+