Compare commits
11 Commits
422ffa1f32
...
73c2c159e8
Author | SHA1 | Date |
---|---|---|
|
73c2c159e8 | |
|
0bbf40741c | |
|
8d5e46108f | |
|
6c16191d90 | |
|
08aec277e6 | |
|
757f51a2dd | |
|
5b499eb8c3 | |
|
c3aee00eff | |
|
c884fc9a19 | |
|
a3f5055ef2 | |
|
143176fd5a |
|
@ -17,4 +17,87 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mqttx依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- RabbitMQ依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Kafka依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.kafka</groupId>
|
||||||
|
<artifactId>spring-kafka</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.couplet.analyze.msg;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/4/2 8:39
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableFeignClients(basePackages = "com.couplet.**")
|
||||||
|
public class CoupletMsgApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CoupletMsgApplication.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.couplet.analyze.msg.contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: kafka常量类
|
||||||
|
* @Date 2023/8/25 18:47
|
||||||
|
*/
|
||||||
|
public class MsgContent {
|
||||||
|
|
||||||
|
public static final String BROKER_URL = "tcp://111.229.33.194:1883";
|
||||||
|
|
||||||
|
public static final String CLIENT_ID = "mqttx_32dcaf76";
|
||||||
|
}
|
|
@ -0,0 +1,263 @@
|
||||||
|
package com.couplet.analyze.msg.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/4/2 15:26
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CoupletMsgData {
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIN 车辆编码
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文创建时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维度
|
||||||
|
*/
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 速度
|
||||||
|
*/
|
||||||
|
private String speed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 里程
|
||||||
|
*/
|
||||||
|
private BigDecimal mileage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总电压
|
||||||
|
*/
|
||||||
|
private String voltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总电流
|
||||||
|
*/
|
||||||
|
private String current;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绝缘电阻
|
||||||
|
*/
|
||||||
|
private String resistance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 档位 P:停车 D:运行
|
||||||
|
*/
|
||||||
|
private String gear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加速踏板行驶值
|
||||||
|
*/
|
||||||
|
private String accelerationPedal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 制动踏板行驶值
|
||||||
|
*/
|
||||||
|
private String brakePedal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 燃料消耗率
|
||||||
|
*/
|
||||||
|
private String fuelConsumptionRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机控制器温度
|
||||||
|
*/
|
||||||
|
private String motorControllerTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机转速
|
||||||
|
*/
|
||||||
|
private String motorSpeed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机转矩
|
||||||
|
*/
|
||||||
|
private String motorTorque;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机温度
|
||||||
|
*/
|
||||||
|
private String motorTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机电压
|
||||||
|
*/
|
||||||
|
private String motorVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机电流
|
||||||
|
*/
|
||||||
|
private String motorCurrent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池剩余电量SOC
|
||||||
|
*/
|
||||||
|
private BigDecimal remainingBattery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前状态允许的最大反馈功率
|
||||||
|
*/
|
||||||
|
private String maximumFeedbackPower;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前状态允许的最大放电功率
|
||||||
|
*/
|
||||||
|
private String maximumDischargePower;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BMS自检计数器
|
||||||
|
*/
|
||||||
|
private String selfCheckCounter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池充放电电流
|
||||||
|
*/
|
||||||
|
private String totalBatteryCurrent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池负载端电压V3
|
||||||
|
*/
|
||||||
|
private String totalBatteryVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次最大电压
|
||||||
|
*/
|
||||||
|
private String singleBatteryMaxVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单体电池最低电压
|
||||||
|
*/
|
||||||
|
private String singleBatteryMinVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单体电池最高温度
|
||||||
|
*/
|
||||||
|
private String singleBatteryMaxTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单体电池最低温度
|
||||||
|
*/
|
||||||
|
private String singleBatteryMinTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池可用容量
|
||||||
|
*/
|
||||||
|
private String availableBatteryCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int vehicleStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int chargingStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int operatingStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SOC 状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int socStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可充电储能装置工作状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int chargingEnergyStorageStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 驱动电机状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int driveMotorStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定位是否有效 1:有效 0:无效
|
||||||
|
*/
|
||||||
|
private int positionStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAS(汽车防盗系统)状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int easStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTC(电动加热器)状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int ptcStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EPS(电动助力系统)状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int epsStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ABS(防抱死)状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int absStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MCU(电机/逆变器)状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int mcuStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池加热状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int heatingStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池当前状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int batteryStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池保温状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int batteryInsulationStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCDC(电力交换系统) 状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int dcdcStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CHG(充电机)状态 1:正常 0:故障
|
||||||
|
*/
|
||||||
|
private int chgStatus;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.couplet.analyze.msg.model;
|
||||||
|
|
||||||
|
import com.couplet.analyze.msg.service.CoupletMsgService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/4/2 15:41
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ModelMessage {
|
||||||
|
|
||||||
|
@Scheduled(cron = "0/5 * * * * ?")
|
||||||
|
public void startMsg() {
|
||||||
|
// try {
|
||||||
|
// new MqttClient()
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.couplet.analyze.msg.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/4/2 16:44
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public interface CoupletMsgService {
|
||||||
|
}
|
|
@ -1,382 +0,0 @@
|
||||||
package com.couplet.msg.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DongXiaoDong
|
|
||||||
* @version 1.0
|
|
||||||
* @date 2024/3/31 16:01
|
|
||||||
* @description
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class MsgData {
|
|
||||||
/**
|
|
||||||
* VIN
|
|
||||||
*/
|
|
||||||
private String vin;
|
|
||||||
/**
|
|
||||||
* 行驶路线
|
|
||||||
*/
|
|
||||||
private String drivingRoute;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 经度
|
|
||||||
*/
|
|
||||||
private String longitude;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 维度
|
|
||||||
*/
|
|
||||||
private String latitude;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 速度
|
|
||||||
*/
|
|
||||||
private String speed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 里程
|
|
||||||
*/
|
|
||||||
private BigDecimal mileage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总电压
|
|
||||||
*/
|
|
||||||
private String voltage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总电流
|
|
||||||
*/
|
|
||||||
private String current;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 绝缘电阻
|
|
||||||
*/
|
|
||||||
private String resistance;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 档位
|
|
||||||
*/
|
|
||||||
private String gear = "P";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加速踏板行程值
|
|
||||||
*/
|
|
||||||
private String accelerationPedal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 制动踏板行程值
|
|
||||||
*/
|
|
||||||
private String brakePedal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 燃料消耗率
|
|
||||||
*/
|
|
||||||
private String fuelConsumptionRate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电机控制器温度
|
|
||||||
*/
|
|
||||||
private String motorControllerTemperature;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电机转速
|
|
||||||
*/
|
|
||||||
private String motorSpeed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电机转矩
|
|
||||||
*/
|
|
||||||
private String motorTorque;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电机温度
|
|
||||||
*/
|
|
||||||
private String motorTemperature;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电机电压
|
|
||||||
*/
|
|
||||||
private String motorVoltage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电机电流
|
|
||||||
*/
|
|
||||||
private String motorCurrent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动力电池剩余电量SOC
|
|
||||||
*/
|
|
||||||
private BigDecimal remainingBattery;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电池总容量
|
|
||||||
*/
|
|
||||||
private BigDecimal batteryLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前状态允许的最大反馈功率
|
|
||||||
*/
|
|
||||||
private String maximumFeedbackPower;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前状态允许最大放电功率
|
|
||||||
*/
|
|
||||||
private String maximumDischargePower;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BMS自检计数器
|
|
||||||
*/
|
|
||||||
private String selfCheckCounter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动力电池充放电电流
|
|
||||||
*/
|
|
||||||
private String totalBatteryCurrent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动力电池负载端总电压V3
|
|
||||||
*/
|
|
||||||
private String totalBatteryVoltage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单次最大电压
|
|
||||||
*/
|
|
||||||
private String singleBatteryMaxVoltage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单体电池最低电压
|
|
||||||
*/
|
|
||||||
private String singleBatteryMinVoltage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单体电池最高温度
|
|
||||||
*/
|
|
||||||
private String singleBatteryMaxTemperature;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单体电池最低温度
|
|
||||||
*/
|
|
||||||
private String singleBatteryMinTemperature;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动力电池可用容量
|
|
||||||
*/
|
|
||||||
private String availableBatteryCapacity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆状态
|
|
||||||
*/
|
|
||||||
private int vehicleStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 充电状态
|
|
||||||
*/
|
|
||||||
private int chargingStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 运行状态
|
|
||||||
*/
|
|
||||||
private int operatingStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SOC
|
|
||||||
*/
|
|
||||||
private int socStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 可充电储能装置工作状态
|
|
||||||
*/
|
|
||||||
private int chargingEnergyStorageStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 驱动电机状态
|
|
||||||
*/
|
|
||||||
private int driveMotorStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定位是否有效
|
|
||||||
*/
|
|
||||||
private int positionStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAS(汽车防盗系统)状态
|
|
||||||
*/
|
|
||||||
private int easStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PTC(电动加热器)状态
|
|
||||||
*/
|
|
||||||
private int ptcStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EPS(电动助力系统)状态
|
|
||||||
*/
|
|
||||||
private int epsStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ABS(防抱死)状态
|
|
||||||
*/
|
|
||||||
private int absStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MCU(电机/逆变器)状态
|
|
||||||
*/
|
|
||||||
private int mcuStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动力电池加热状态
|
|
||||||
*/
|
|
||||||
private int heatingStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动力电池当前状态
|
|
||||||
*/
|
|
||||||
private int batteryStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动力电池保温状态
|
|
||||||
*/
|
|
||||||
private int batteryInsulationStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DCDC(电力交换系统)状态
|
|
||||||
*/
|
|
||||||
private int dcdcStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CHG(充电机)状态
|
|
||||||
*/
|
|
||||||
private int chgStatus = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆状态 报文
|
|
||||||
*/
|
|
||||||
private String vehicleStatusMsg;
|
|
||||||
/**
|
|
||||||
* 智能硬件 报文
|
|
||||||
*/
|
|
||||||
private String smartHardwareMsg;
|
|
||||||
/**
|
|
||||||
* 电池报文
|
|
||||||
*/
|
|
||||||
private String batteryMsg;
|
|
||||||
|
|
||||||
public String getMsg(){
|
|
||||||
//第一位VIN
|
|
||||||
return vin +
|
|
||||||
// 当前时间戳
|
|
||||||
System.currentTimeMillis() +
|
|
||||||
//第二位经度 longitude latitude
|
|
||||||
getValue(longitude, 11) +
|
|
||||||
//第三位维度 longitude latitude
|
|
||||||
getValue(latitude, 10) +
|
|
||||||
//车速
|
|
||||||
getValue(speed, 6) +
|
|
||||||
//总里程
|
|
||||||
getValue(mileage == null ? "" : mileage.toString(), 11) +
|
|
||||||
// 总电压
|
|
||||||
getValue(voltage, 6) +
|
|
||||||
//总电流
|
|
||||||
getValue(current, 5) +
|
|
||||||
//绝缘电阻 79 - 87
|
|
||||||
getValue(resistance, 9) +
|
|
||||||
//档位
|
|
||||||
(gear == null ? "D" : gear) +
|
|
||||||
// 加速踏板行程值
|
|
||||||
getValue(accelerationPedal, 2) +
|
|
||||||
// 制动踏板行程值
|
|
||||||
getValue(brakePedal, 2) +
|
|
||||||
// 燃料消耗率
|
|
||||||
getValue(fuelConsumptionRate, 5) +
|
|
||||||
//电机控制器温度
|
|
||||||
getValue(motorControllerTemperature, 6) +
|
|
||||||
//电机转速
|
|
||||||
getValue(motorSpeed, 5) +
|
|
||||||
//点击转矩
|
|
||||||
getValue(motorTorque, 4) +
|
|
||||||
//电机温度
|
|
||||||
getValue(motorTemperature, 6) +
|
|
||||||
//电机电压
|
|
||||||
getValue(motorVoltage, 5) +
|
|
||||||
//电机电流
|
|
||||||
getValue(motorCurrent, 8) +
|
|
||||||
//动力电池剩余电量SOC
|
|
||||||
getValue(remainingBattery == null ? "" : remainingBattery.toString(), 6) +
|
|
||||||
//当前状态允许的最大反馈功率
|
|
||||||
getValue(maximumFeedbackPower, 6) +
|
|
||||||
//当前状态允许最大放电功率
|
|
||||||
getValue(maximumDischargePower, 6) +
|
|
||||||
//BMS自检计数器
|
|
||||||
getValue(selfCheckCounter, 2) +
|
|
||||||
//动力电池充放电电流
|
|
||||||
getValue(totalBatteryCurrent, 5) +
|
|
||||||
//动力电池负载端总电压V3
|
|
||||||
getValue(totalBatteryVoltage, 6) +
|
|
||||||
//单次最大电压
|
|
||||||
getValue(singleBatteryMaxVoltage, 4) +
|
|
||||||
//单体电池最低电压
|
|
||||||
getValue(singleBatteryMinVoltage, 4) +
|
|
||||||
//单体电池最高温度
|
|
||||||
getValue(singleBatteryMaxTemperature, 6) +
|
|
||||||
//单体电池最低温度
|
|
||||||
getValue(singleBatteryMinTemperature, 6) +
|
|
||||||
//动力电池可用容量
|
|
||||||
getValue(availableBatteryCapacity, 6) +
|
|
||||||
//车辆状态
|
|
||||||
vehicleStatus +
|
|
||||||
//充电状态
|
|
||||||
chargingStatus +
|
|
||||||
//运行状态
|
|
||||||
operatingStatus +
|
|
||||||
//SOC
|
|
||||||
socStatus +
|
|
||||||
//可充电储能装置工作状态
|
|
||||||
chargingEnergyStorageStatus +
|
|
||||||
//驱动电机状态
|
|
||||||
driveMotorStatus +
|
|
||||||
//定位是否有效
|
|
||||||
positionStatus +
|
|
||||||
//EAS
|
|
||||||
easStatus +
|
|
||||||
//PTC
|
|
||||||
ptcStatus +
|
|
||||||
//EPS
|
|
||||||
epsStatus +
|
|
||||||
//ABS
|
|
||||||
absStatus +
|
|
||||||
//MCU
|
|
||||||
mcuStatus +
|
|
||||||
//动力电池加热状态
|
|
||||||
heatingStatus +
|
|
||||||
//动力电池当前状态
|
|
||||||
batteryStatus +
|
|
||||||
//动力电池保温状态
|
|
||||||
batteryInsulationStatus +
|
|
||||||
//DCDC
|
|
||||||
dcdcStatus +
|
|
||||||
//CHG
|
|
||||||
chgStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue(String val , int valLength){
|
|
||||||
if(val == null){
|
|
||||||
val = "";
|
|
||||||
}
|
|
||||||
int length = val.length();
|
|
||||||
if (length > valLength){
|
|
||||||
return val.substring( 0 , valLength);
|
|
||||||
}
|
|
||||||
val = val + "0".repeat(valLength - length);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -86,5 +86,10 @@
|
||||||
<artifactId>couplet-common-swagger</artifactId>
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.kafka</groupId>
|
||||||
|
<artifactId>spring-kafka</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -96,6 +96,12 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Kafka依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.kafka</groupId>
|
||||||
|
<artifactId>spring-kafka</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
||||||
public String exchangeName;
|
public String exchangeName;
|
||||||
|
|
||||||
//路由键
|
//路由键
|
||||||
@Value(("${mq.routingKey}"))
|
@Value("${mq.routingKey}")
|
||||||
public String routingKey;
|
public String routingKey;
|
||||||
|
|
||||||
private RabbitTemplate rabbitTemplate;
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
@ -69,7 +69,7 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
||||||
* @Param: []
|
* @Param: []
|
||||||
* @Return: 返回一个配置好的DirectExchange实例。
|
* @Return: 返回一个配置好的DirectExchange实例。
|
||||||
**/
|
**/
|
||||||
@Bean("exchange")
|
@Bean
|
||||||
public DirectExchange directExchange() {
|
public DirectExchange directExchange() {
|
||||||
return new DirectExchange(exchangeName);
|
return new DirectExchange(exchangeName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
package com.couplet.mq.controller;
|
package com.couplet.mq.controller;
|
||||||
|
|
||||||
import com.couplet.common.core.utils.uuid.IdUtils;
|
import com.couplet.common.core.utils.uuid.IdUtils;
|
||||||
import com.couplet.mq.config.RabbitMQConfig;
|
import com.couplet.mq.domain.User;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ProjectName: five-groups-couplet
|
* @ProjectName: five-groups-couplet
|
||||||
|
@ -21,17 +19,37 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@RequestMapping("/mq")
|
@RequestMapping("/mq")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MqController {
|
public class MqController {
|
||||||
|
// 通过注入的方式获取队列名、交换机名和路由键
|
||||||
|
//队列名
|
||||||
|
@Value("${mq.queueName}")
|
||||||
|
public String queueName;
|
||||||
|
|
||||||
|
//交换机
|
||||||
|
@Value("${mq.exchangeName}")
|
||||||
|
public String exchangeName;
|
||||||
|
|
||||||
|
//路由键
|
||||||
|
@Value("${mq.routingKey}")
|
||||||
|
public String routingKey;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RabbitTemplate rabbitTemplate;
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
@GetMapping("/receive/{data}")
|
/*
|
||||||
public void receive(@PathVariable("data") String data) {
|
* @Author: LiuYunHu
|
||||||
//创建配置类对象,用于获取配置值
|
* @Date: 2024/4/1 19:58
|
||||||
RabbitMQConfig config = new RabbitMQConfig();
|
* @Description: 消息发送者
|
||||||
|
* @Param: [data]
|
||||||
rabbitTemplate.convertAndSend(config.exchangeName, config.routingKey, data , message -> {
|
* @Return: void
|
||||||
|
**/
|
||||||
|
@PostMapping("/sout")
|
||||||
|
//接收json字符串
|
||||||
|
public void sout(@RequestBody User param) {
|
||||||
|
rabbitTemplate.convertAndSend(exchangeName, routingKey, param, message -> {
|
||||||
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
||||||
return message;
|
return message;
|
||||||
}, new CorrelationData(IdUtils.randomUUID()));
|
}, new CorrelationData(IdUtils.randomUUID())
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
package com.couplet.mq.domain;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ProjectName: five-groups-couplet
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @CreateTime: 2024/3/29
|
|
||||||
* @Description: 测试 参数类
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class Test implements Serializable {
|
|
||||||
public String data;
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.couplet.mq.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/4/1
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class User {
|
||||||
|
private String name;
|
||||||
|
private Integer age;
|
||||||
|
private String sex;
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.couplet.mq.service;
|
package com.couplet.mq.service;
|
||||||
|
|
||||||
|
import com.couplet.mq.domain.User;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
|
@ -18,53 +19,146 @@ import java.util.concurrent.TimeUnit;
|
||||||
* @CreateTime: 2024/3/28
|
* @CreateTime: 2024/3/28
|
||||||
* @Description: MQ消费者类
|
* @Description: MQ消费者类
|
||||||
*/
|
*/
|
||||||
@RabbitListener(queues = "${mq.queueName}")
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@RabbitListener(queues = "${mq.queueName}")
|
||||||
public class Consumer {
|
public class Consumer {
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private StringRedisTemplate redis;
|
||||||
|
|
||||||
|
/* 线程池执行
|
||||||
|
|
||||||
|
//创建一个定长线程池
|
||||||
|
private final Executor executor = Executors.newFixedThreadPool(5);
|
||||||
|
|
||||||
|
@Async
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void receive(String data, Channel channel, Message message) throws IOException {
|
public void process(User param, Channel channel, Message message) {
|
||||||
log.info("消费者接受到数据:{}", data);
|
executor.execute(() -> {
|
||||||
|
try {
|
||||||
|
handleMessage(param, channel, message);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("处理消息失败:{}", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理信息的方法
|
||||||
|
private void handleMessage(User param, Channel channel, Message message) throws IOException {
|
||||||
|
log.info("消费者收到消息为:{},{}" + param, message.getMessageProperties().getDeliveryTag());
|
||||||
|
|
||||||
//获取信息的标记
|
|
||||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
|
|
||||||
//获取到消息的id
|
|
||||||
String messageId = message.getMessageProperties().getMessageId();
|
String messageId = message.getMessageProperties().getMessageId();
|
||||||
|
|
||||||
Long add = redisTemplate.opsForSet().add("set:" + messageId, "set:" + messageId);
|
if (!redis.hasKey("value:" + messageId)) {
|
||||||
|
redis.opsForValue().set("value:" + messageId, "" + deliveryTag, 5, TimeUnit.MINUTES);
|
||||||
if (!redisTemplate.hasKey("value:" + messageId)) {
|
|
||||||
redisTemplate.opsForValue().set("value:" + messageId, String.valueOf(deliveryTag), 10, TimeUnit.MINUTES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1 添加成功新数据 0已有重复值,不允许再添加
|
||||||
|
Long add = redis.opsForSet().add("set:" + messageId, "set:" + messageId);
|
||||||
|
//过期时间
|
||||||
|
redis.expire("set:" + messageId, 5, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (add == 1) {
|
if (add == 1) {
|
||||||
log.info("---------------消费者开始消费---------------");
|
//第一次 消费
|
||||||
|
System.out.println("*****************************");
|
||||||
|
System.out.println("消费者收到消息:" + param);
|
||||||
|
System.out.println("*****************************");
|
||||||
|
log.info("消费结束");
|
||||||
|
|
||||||
System.out.println(data);
|
channel.basicAck(deliveryTag, false);
|
||||||
|
|
||||||
log.info("---------------消费者结束消费---------------");
|
} else {
|
||||||
}else {
|
//重复消费
|
||||||
log.error("重复消费!");
|
log.error("重复消费");
|
||||||
channel.basicReject(deliveryTag, false);
|
channel.basicReject(deliveryTag, false);
|
||||||
|
|
||||||
|
//删除缓存
|
||||||
|
redis.opsForSet().remove("set:" + messageId, "set:" + messageId);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
String s = redisTemplate.opsForValue().get("value:" + messageId);
|
} catch (Exception e) {
|
||||||
|
log.error("消息没有成功消费!");
|
||||||
|
|
||||||
|
String s = redis.opsForValue().get("value:" + messageId);
|
||||||
|
|
||||||
long oldTag = Long.parseLong(s);
|
long oldTag = Long.parseLong(s);
|
||||||
|
|
||||||
if ((oldTag + 2) != deliveryTag) {
|
if (deliveryTag == (oldTag + 2)) {
|
||||||
log.info("重新入队!");
|
log.error("确实消费不了,不入队了!");
|
||||||
channel.basicNack(deliveryTag, false, true);
|
|
||||||
}else {
|
|
||||||
log.error("三次无法消费,不再入队!");
|
|
||||||
channel.basicNack(deliveryTag, false, false);
|
channel.basicNack(deliveryTag, false, false);
|
||||||
|
} else {
|
||||||
|
log.info("消息消费失败,重新入队");
|
||||||
|
channel.basicNack(deliveryTag, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
@RabbitHandler
|
||||||
|
public void process(User param, Channel channel, Message message) throws IOException {
|
||||||
|
log.info("消费者收到消息为:{},{}" + param, message.getMessageProperties().getDeliveryTag());
|
||||||
|
|
||||||
|
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
|
String messageId = message.getMessageProperties().getMessageId();
|
||||||
|
|
||||||
|
if (!redis.hasKey("value:" + messageId)) {
|
||||||
|
redis.opsForValue().set("value:" + messageId, "" + deliveryTag, 5, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1 添加成功新数据 0已有重复值,不允许再添加
|
||||||
|
Long add = redis.opsForSet().add("set:" + messageId, "set:" + messageId);
|
||||||
|
//过期时间
|
||||||
|
redis.expire("set:" + messageId, 5, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (add == 1) {
|
||||||
|
//第一次 消费
|
||||||
|
System.out.println("*****************************");
|
||||||
|
System.out.println("消费者收到消息:" + param);
|
||||||
|
System.out.println("*****************************");
|
||||||
|
log.info("消费结束");
|
||||||
|
|
||||||
|
//确认消费
|
||||||
|
channel.basicAck(deliveryTag, false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//重复消费
|
||||||
|
log.error("重复消费");
|
||||||
|
//拒绝消费
|
||||||
|
channel.basicReject(deliveryTag, false);
|
||||||
|
|
||||||
|
//删除缓存
|
||||||
|
redis.opsForSet().remove("set:" + messageId, "set:" + messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("消息没有成功消费!");
|
||||||
|
|
||||||
|
String s = redis.opsForValue().get("value:" + messageId);
|
||||||
|
|
||||||
|
long oldTag = Long.parseLong(s);
|
||||||
|
|
||||||
|
if (deliveryTag == (oldTag + 2)) {
|
||||||
|
log.error("确实消费不了,不入队了!");
|
||||||
|
|
||||||
|
|
||||||
|
//拒绝消费
|
||||||
|
channel.basicNack(deliveryTag, false, false);
|
||||||
|
} else {
|
||||||
|
log.info("消息消费失败,重新入队");
|
||||||
|
//重新入队
|
||||||
|
channel.basicNack(deliveryTag, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
package com.couplet.mq.service;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.eclipse.paho.client.mqttv3.*;
|
|
||||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ProjectName: five-groups-couplet
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @CreateTime: 2024/3/28
|
|
||||||
* @Description: mqtt客户端
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class MqttListen {
|
|
||||||
/*
|
|
||||||
* 路径
|
|
||||||
* */
|
|
||||||
@Value("${mqtt.server.broker}")
|
|
||||||
private String BROKER;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 主题
|
|
||||||
* */
|
|
||||||
@Value("${mqtt.server.topic}")
|
|
||||||
private String TOPIC;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 客户端id
|
|
||||||
* */
|
|
||||||
@Value("${mqtt.server.clientid}")
|
|
||||||
private String CLIENTID;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 用户名
|
|
||||||
* */
|
|
||||||
@Value("${mqtt.server.username}")
|
|
||||||
private String USERNAME;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 密码
|
|
||||||
* */
|
|
||||||
@Value("${mqtt.server.password}")
|
|
||||||
private String PASSWORD;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* qos
|
|
||||||
* */
|
|
||||||
@Value("${mqtt.server.qos}")
|
|
||||||
private Integer QOS;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void connect() {
|
|
||||||
System.out.println("监听者启动");
|
|
||||||
try {
|
|
||||||
|
|
||||||
MqttClient client = new MqttClient(BROKER, CLIENTID, new MemoryPersistence());
|
|
||||||
MqttConnectOptions options = new MqttConnectOptions();
|
|
||||||
options.setUserName(USERNAME);
|
|
||||||
options.setPassword(PASSWORD.toCharArray());
|
|
||||||
|
|
||||||
//连接超时
|
|
||||||
options.setConnectionTimeout(60);
|
|
||||||
|
|
||||||
//心跳
|
|
||||||
options.setKeepAliveInterval(60);
|
|
||||||
|
|
||||||
log.info("连接到:"+BROKER);
|
|
||||||
|
|
||||||
client.connect(options);
|
|
||||||
log.info("连接成功");
|
|
||||||
|
|
||||||
//设置回调
|
|
||||||
client.setCallback(new MqttCallback() {
|
|
||||||
@Override
|
|
||||||
public void connectionLost(Throwable throwable) {
|
|
||||||
log.error("连接断开:" + throwable.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void messageArrived(String topic, MqttMessage message) {
|
|
||||||
log.info("消息到达");
|
|
||||||
log.info("接收消息主题:" + topic);
|
|
||||||
log.info("接收消息Qos:" + message.getQos());
|
|
||||||
log.info("接收消息内容:" + new String(message.getPayload()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deliveryComplete(IMqttDeliveryToken token) {
|
|
||||||
log.info("消息发送成功----------" + token.isComplete());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
client.subscribe(TOPIC, QOS);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (MqttException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1 @@
|
||||||
|
com.couplet.mq.config.RabbitMQConfig
|
|
@ -34,7 +34,8 @@ logging:
|
||||||
# 订阅端配置
|
# 订阅端配置
|
||||||
mqtt:
|
mqtt:
|
||||||
server:
|
server:
|
||||||
broker: tcp://115.159.47.13:1883
|
broker: tcp://8.130.181.16:1883
|
||||||
|
# broker: tcp://115.159.47.13:1883
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
clientid: mqttx
|
clientid: mqttx
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>couplet-modules-online</artifactId>
|
||||||
|
|
||||||
|
<!-- <properties>-->
|
||||||
|
<!-- <maven.compiler.source>17</maven.compiler.source>-->
|
||||||
|
<!-- <maven.compiler.target>17</maven.compiler.target>-->
|
||||||
|
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
|
||||||
|
<!-- </properties>-->
|
||||||
|
|
||||||
|
<description>
|
||||||
|
couplet-modules-online车辆上线的模块
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mqttx依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.5</version>
|
||||||
|
</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>
|
||||||
|
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.couplet.online;
|
||||||
|
|
||||||
|
import com.couplet.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: Default (Template) Project
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/4/1
|
||||||
|
* @Description: 车辆上线的模块启动类
|
||||||
|
*/
|
||||||
|
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class OnlineApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(OnlineApplication.class);
|
||||||
|
System.out.println("车辆上线模块启动成功");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.couplet.online.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/4/1
|
||||||
|
* @Description: 车辆上线控制器
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/online")
|
||||||
|
public class OnlineController {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.couplet.online.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/4/1
|
||||||
|
* @Description: 车辆上线mapper
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Component
|
||||||
|
public interface OnlineMapper {
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.couplet.online.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/4/1
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface OnlineService {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.couplet.online.service.impl;
|
||||||
|
|
||||||
|
import com.couplet.online.service.OnlineService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/4/1
|
||||||
|
* @Description: 车辆上线service层
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class OnlineServiceImpl implements OnlineService {
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.couplet.online.utils;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/4/1
|
||||||
|
* @Description: mqtt监听者
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class MqttMonitor {
|
||||||
|
/*
|
||||||
|
* 路径
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.broker}")
|
||||||
|
private String broker;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 主题
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.topic}")
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 客户端id
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.clientId}")
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 用户名
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.username}")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 密码
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.password}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 遗嘱消息qos
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.qos}")
|
||||||
|
private Integer qos;
|
||||||
|
|
||||||
|
|
||||||
|
//随项目启动而执行这个方法
|
||||||
|
@PostConstruct
|
||||||
|
public void connect() {
|
||||||
|
log.info("mqtt监听者启动");
|
||||||
|
try {
|
||||||
|
MqttClient client = new MqttClient(broker, clientId, new MemoryPersistence());
|
||||||
|
|
||||||
|
MqttConnectOptions options = new MqttConnectOptions();
|
||||||
|
options.setUserName(userName);
|
||||||
|
options.setPassword(password.toCharArray());
|
||||||
|
|
||||||
|
//连接超时
|
||||||
|
options.setConnectionTimeout(10);
|
||||||
|
|
||||||
|
//心跳时间
|
||||||
|
options.setKeepAliveInterval(60);
|
||||||
|
|
||||||
|
log.info("mqtt监听者启动成功,连接到:{}", broker);
|
||||||
|
|
||||||
|
client.connect(options);
|
||||||
|
log.info("连接成功!");
|
||||||
|
|
||||||
|
//设置回调
|
||||||
|
client.setCallback(new MqttCallback() {
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
log.error("连接丢失:{}", throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String topic, MqttMessage mqttMessage) {
|
||||||
|
// log.info("消息已送达");
|
||||||
|
// log.info("接收消息主题:{}",topic);
|
||||||
|
// log.info("接收消息qos:{}", mqttMessage.getQos());
|
||||||
|
|
||||||
|
//接收到的原始报文
|
||||||
|
String message = new String(mqttMessage.getPayload());
|
||||||
|
|
||||||
|
log.info("接收消息原始内容:{}", message);
|
||||||
|
|
||||||
|
//去除空格 得到16进制字符串
|
||||||
|
String replaced = message.replaceAll(" ", "");
|
||||||
|
log.info("接收消息剪切后内容:{}", replaced);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||||
|
log.info("消息发送成功!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.subscribe(topic, qos);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (MqttException e) {
|
||||||
|
log.error("mqtt监听者启动失败,{}", e.getMessage());
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
||||||
|
_______ _ _ _________ _ _______
|
||||||
|
( ___ )( ( /|( \ \__ __/( ( /|( ____ \
|
||||||
|
| ( ) || \ ( || ( ) ( | \ ( || ( \/
|
||||||
|
| | | || \ | || | | | | \ | || (__
|
||||||
|
| | | || (\ \) || | | | | (\ \) || __)
|
||||||
|
| | | || | \ || | | | | | \ || (
|
||||||
|
| (___) || ) \ || (____/\___) (___| ) \ || (____/\
|
||||||
|
(_______)|/ )_)(_______/\_______/|/ )_)(_______/
|
|
@ -0,0 +1,43 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9616
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: couplet-online
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.couplet.system.mapper: DEBUG
|
||||||
|
|
||||||
|
# 订阅端配置
|
||||||
|
mqtt:
|
||||||
|
server:
|
||||||
|
broker: tcp://115.159.47.13:1883
|
||||||
|
username:
|
||||||
|
password:
|
||||||
|
clientId: lyh
|
||||||
|
qos: 0
|
||||||
|
topic: test
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/couplet-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<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.couplet" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?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.couplet.online.mapper.OnlineMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -190,7 +190,11 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
//雪花算法生成随机数
|
//雪花算法生成随机数
|
||||||
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
long randomId = idGenerator.nextId();
|
long randomId = idGenerator.nextId();
|
||||||
String vin = "VIN" + randomId;
|
//转成字符串,便于切割
|
||||||
|
String vin = "" + randomId;
|
||||||
|
|
||||||
|
//切割,只留后17位
|
||||||
|
vin = vin.substring(vin.length() - 17);
|
||||||
|
|
||||||
|
|
||||||
//创建入参对象
|
//创建入参对象
|
||||||
|
|
|
@ -14,7 +14,20 @@ public class IdTest {
|
||||||
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
|
|
||||||
long l = idGenerator.nextId();
|
long l = idGenerator.nextId();
|
||||||
|
String s = "VIN" + l;
|
||||||
System.out.println(l);
|
System.out.println(l);
|
||||||
|
System.out.println(s);
|
||||||
|
System.out.println("剪切前长度:" + s.length());
|
||||||
|
|
||||||
|
|
||||||
|
String last17 = s.substring(s.length() - 17);
|
||||||
|
System.out.println("剪切后:"+last17+" 长度:"+last17.length());
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("----------------------");
|
||||||
|
|
||||||
|
String s1 = "1224069209961664512";
|
||||||
|
String substring = s1.substring(s1.length() - 17);
|
||||||
|
System.out.println(substring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.couplet.common.core.annotation.Excel;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongXiaoDong
|
* @author DongXiaoDong
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
|
@ -23,12 +25,14 @@ public class CoupletTroubleCode {
|
||||||
*/
|
*/
|
||||||
@TableId(value = "trouble_id",type = IdType.AUTO)
|
@TableId(value = "trouble_id",type = IdType.AUTO)
|
||||||
@Excel(name = "故障码主键", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "故障码主键", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
@NotEmpty(message = "故障码主键不能为空")
|
||||||
private Integer troubleId;
|
private Integer troubleId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障码
|
* 故障码
|
||||||
*/
|
*/
|
||||||
@Excel(name = "故障码")
|
@Excel(name = "故障码")
|
||||||
|
@NotEmpty(message = "故障码不能为空")
|
||||||
private String troubleCode;
|
private String troubleCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,11 +57,13 @@ public class CoupletTroubleCode {
|
||||||
* 故障类型Id
|
* 故障类型Id
|
||||||
*/
|
*/
|
||||||
@Excel(name = "故障类型Id")
|
@Excel(name = "故障类型Id")
|
||||||
|
@NotEmpty(message = "故障类型Id不能为空")
|
||||||
private Integer typeId;
|
private Integer typeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障等级Id
|
* 故障等级Id
|
||||||
*/
|
*/
|
||||||
@Excel(name = "故障等级Id")
|
@Excel(name = "故障等级Id")
|
||||||
|
@NotEmpty(message = "故障等级Id不能为空")
|
||||||
private Integer gradeId;
|
private Integer gradeId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.couplet.msg.domain;
|
package com.couplet.trouble.domain;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -12,14 +13,14 @@ import java.util.Date;
|
||||||
/**
|
/**
|
||||||
* @author DongXiaoDong
|
* @author DongXiaoDong
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2024/3/31 21:18
|
* @date 2024/4/2 15:14
|
||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class TroubleLog {
|
public class CoupletTroubleLog {
|
||||||
/**
|
/**
|
||||||
* 故障记录Id
|
* 故障记录Id
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +32,7 @@ public class TroubleLog {
|
||||||
private String troubleLogCode;
|
private String troubleLogCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障记录车辆VIN
|
* 故障码VIN
|
||||||
*/
|
*/
|
||||||
private String troubleLogVin;
|
private String troubleLogVin;
|
||||||
|
|
||||||
|
@ -48,4 +49,5 @@ public class TroubleLog {
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date troubleLogEndTime;
|
private Date troubleLogEndTime;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,52 +0,0 @@
|
||||||
package com.couplet.trouble.domain.req;
|
|
||||||
|
|
||||||
import com.couplet.common.core.annotation.Excel;
|
|
||||||
import com.couplet.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DongXiaoDong
|
|
||||||
* @version 1.0
|
|
||||||
* @date 2024/3/26 22:32
|
|
||||||
* @description
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class TroubleAddReq {
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障码")
|
|
||||||
private String troubleCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障位
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障位")
|
|
||||||
private String troublePosition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障值
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障值")
|
|
||||||
private String troubleValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障标签
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障标签")
|
|
||||||
private String troubleTag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障类型Id
|
|
||||||
*/
|
|
||||||
private Integer troubleTypeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障等级Id
|
|
||||||
*/
|
|
||||||
private Integer troubleGradeId;
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package com.couplet.trouble.domain.req;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.couplet.common.core.annotation.Excel;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DongXiaoDong
|
|
||||||
* @version 1.0
|
|
||||||
* @date 2024/3/26 22:32
|
|
||||||
* @description
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class TroubleUpdReq {
|
|
||||||
/**
|
|
||||||
* 主键id
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障码主键", cellType = Excel.ColumnType.NUMERIC)
|
|
||||||
@TableId(value = "trouble_id",type = IdType.AUTO)
|
|
||||||
private Integer troubleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障码")
|
|
||||||
private String troubleCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障位
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障位")
|
|
||||||
private String troublePosition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障值
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障值")
|
|
||||||
private String troubleValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障标签
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障标签")
|
|
||||||
private String troubleTag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障类型Id
|
|
||||||
*/
|
|
||||||
private Integer troubleTypeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障等级Id
|
|
||||||
*/
|
|
||||||
private Integer troubleGradeId;
|
|
||||||
}
|
|
|
@ -19,32 +19,6 @@
|
||||||
LEFT JOIN couplet_trouble_grade g on t.grade_id = g.grade_id
|
LEFT JOIN couplet_trouble_grade g on t.grade_id = g.grade_id
|
||||||
LEFT JOIN couplet_trouble_type y on t.type_id= y.type_id
|
LEFT JOIN couplet_trouble_type y on t.type_id= y.type_id
|
||||||
</sql>
|
</sql>
|
||||||
<!-- <insert id="addTrouble">-->
|
|
||||||
<!-- insert into couplet_trouble_code (trouble_code,trouble_position,trouble_value,trouble_tag,trouble_type_id,trouble_grade_id)-->
|
|
||||||
<!-- values (#{troubleCode},#{troublePosition},#{troubleValue},#{troubleTag},#{troubleTypeId},#{troubleGradeId})-->
|
|
||||||
<!-- </insert>-->
|
|
||||||
<!-- <update id="updateTrouble">-->
|
|
||||||
<!-- update couplet_trouble_code set-->
|
|
||||||
<!-- trouble_code = #{troubleCode},-->
|
|
||||||
<!-- trouble_position = #{troublePosition},-->
|
|
||||||
<!-- trouble_value = #{troubleValue},-->
|
|
||||||
<!-- trouble_tag = #{troubleTag},-->
|
|
||||||
<!-- trouble_type_id = #{troubleTypeId},-->
|
|
||||||
<!-- trouble_grade_id = #{troubleGradeId}-->
|
|
||||||
<!-- where trouble_id = #{troubleId}-->
|
|
||||||
<!-- </update>-->
|
|
||||||
<!-- <update id="updateTrouble" parameterType="com.couplet.trouble.domain.req.TroubleUpdReq">-->
|
|
||||||
<!-- update dxd_trouble_code-->
|
|
||||||
<!-- <set>-->
|
|
||||||
<!-- <if test="troubleCode != null and troubleCode != ''">trouble_code = #{troubleCode},</if>-->
|
|
||||||
<!-- <if test="troublePosition != null and troublePosition != ''">trouble_position = #{troublePosition},</if>-->
|
|
||||||
<!-- <if test="troubleTag != null and troubleTag != ''">trouble_tag = #{troubleTag},</if>-->
|
|
||||||
<!-- <if test="troubleTypeId != null">trouble_typeId = #{troubleTypeId},</if>-->
|
|
||||||
<!-- <if test="troubleValue != null and troubleValue != ''">trouble_value = #{troubleValue},</if>-->
|
|
||||||
<!-- <if test="troubleGradeId != null">trouble_gradeId = #{troubleGradeId},</if>-->
|
|
||||||
<!-- </set>-->
|
|
||||||
<!-- where trouble_id = #{troubleId}-->
|
|
||||||
<!-- </update>-->
|
|
||||||
|
|
||||||
<select id="selectTroubleList" parameterType="com.couplet.trouble.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
|
<select id="selectTroubleList" parameterType="com.couplet.trouble.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
|
||||||
<include refid="selectTroubleVo"/>
|
<include refid="selectTroubleVo"/>
|
||||||
|
@ -64,23 +38,4 @@
|
||||||
select * from couplet_trouble_grade
|
select * from couplet_trouble_grade
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- <insert id="addTrouble" parameterType="com.couplet.trouble.domain.req.TroubleAddReq">-->
|
|
||||||
<!-- insert into dxd_trouble_code(-->
|
|
||||||
<!-- <if test="troubleCode != null and troubleCode != ''">trouble_code,</if>-->
|
|
||||||
<!-- <if test="troublePosition != null and troublePosition != ''">trouble_position,</if>-->
|
|
||||||
<!-- <if test="troubleTag != null and troubleTag != ''">trouble_tag,</if>-->
|
|
||||||
<!-- <if test="troubleTypeId != null">trouble_typeId,</if>-->
|
|
||||||
<!-- <if test="troubleValue != null and troubleValue != ''">trouble_value,</if>-->
|
|
||||||
<!-- <if test="troubleGradeId != null">trouble_gradeId</if>-->
|
|
||||||
<!-- )values(-->
|
|
||||||
<!-- <if test="troubleCode != null and troubleCode != ''">#{troubleCode},</if>-->
|
|
||||||
<!-- <if test="troublePosition != null and troublePosition != ''">#{troublePosition},</if>-->
|
|
||||||
<!-- <if test="troubleTag != null and troubleTag != ''">#{troubleTag},</if>-->
|
|
||||||
<!-- <if test="troubleTypeId != null">#{troubleTypeId},</if>-->
|
|
||||||
<!-- <if test="troubleValue != null and troubleValue != ''">#{troubleValue},</if>-->
|
|
||||||
<!-- <if test="troubleGradeId != null">#{troubleGradeId},</if>-->
|
|
||||||
<!-- )-->
|
|
||||||
<!-- </insert>-->
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<module>couplet-modules-vehicle</module>
|
<module>couplet-modules-vehicle</module>
|
||||||
<module>couplet-modules-mq</module>
|
<module>couplet-modules-mq</module>
|
||||||
<module>couplet-enterprisemanagement</module>
|
<module>couplet-enterprisemanagement</module>
|
||||||
|
<module>couplet-modules-onLine</module>
|
||||||
<module>couplet-analyze</module>
|
<module>couplet-analyze</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue