commit
f3428404a2
|
@ -30,16 +30,15 @@ public class MqttConsumerConfig {
|
|||
String content = "Message from MqttPublishSample";
|
||||
int qos = 2;
|
||||
String broker = "tcp://123.57.152.124:1883";
|
||||
String clientId = "xyr1";
|
||||
String clientId = "xyr123456789";
|
||||
|
||||
@PostConstruct
|
||||
public String connect() {
|
||||
final String vin= "";
|
||||
public void connect() {
|
||||
try {
|
||||
MqttClient sampleClient = new MqttClient(broker, clientId, new MemoryPersistence());
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
//是否清空session
|
||||
connOpts.setCleanSession(true);
|
||||
connOpts.setCleanSession(false);
|
||||
System.out.println("Connecting to broker: " + broker);
|
||||
//连接
|
||||
sampleClient.connect(connOpts);
|
||||
|
@ -75,6 +74,6 @@ public class MqttConsumerConfig {
|
|||
me.printStackTrace();
|
||||
}
|
||||
|
||||
return vin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ProcessData {
|
|||
|
||||
public static JSONObject DataConversion(String jsonVin ) {
|
||||
String vin = DataParseUtil.dataParsing(jsonVin);
|
||||
|
||||
System.out.println("车辆转换的vin是:"+vin);
|
||||
Result<Long> byTemplateId = remoteMessageValueService.findByTemplateId(vin);
|
||||
|
||||
Long templateId = byTemplateId.getData();
|
||||
|
|
|
@ -1,32 +1,35 @@
|
|||
package com.muyu.parse.uitl;
|
||||
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author xie ya ru
|
||||
* @Date 2024/9/28 16:48
|
||||
* @注释
|
||||
*/
|
||||
|
||||
@Log4j2
|
||||
public class DataParseUtil {
|
||||
public static final Integer STARTPOSITION = 0;
|
||||
public static final Integer STARTPOSITION = 1;
|
||||
|
||||
public static final Integer ENDPOSITION = 18;
|
||||
|
||||
public static final Integer INDEX = 16;
|
||||
public static String dataParsing(String jsonVin){
|
||||
jsonVin = jsonVin.substring(STARTPOSITION,ENDPOSITION);
|
||||
StringBuilder asciiString = new StringBuilder();
|
||||
String[] split = jsonVin.split(" ");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
//十六进制转换为十进制
|
||||
int decimal = Integer.parseInt(split[i],INDEX);
|
||||
//将十进制整数转换为字符
|
||||
char character =(char)decimal;
|
||||
//添加字符到ASCII 字符串
|
||||
asciiString.append(character);
|
||||
|
||||
//根据空格切割数据
|
||||
String[] hexArray = jsonVin.split(" ");
|
||||
StringBuilder result = new StringBuilder();
|
||||
//遍历十六进制数据转换为字符
|
||||
for (String hex : hexArray) {
|
||||
int decimal = Integer.parseInt(hex, INDEX);
|
||||
result.append((char) decimal);
|
||||
}
|
||||
System.out.println(asciiString.toString());
|
||||
return asciiString.toString();
|
||||
//取出车辆VIN码
|
||||
String vehicleVin = result.substring(STARTPOSITION, ENDPOSITION);
|
||||
log.info("车辆VIN码: " + vehicleVin);
|
||||
return vehicleVin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9705
|
||||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 123.57.152.124:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: xyr
|
||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||
# Spring
|
||||
spring:
|
||||
amqp:
|
||||
deserialization:
|
||||
trust:
|
||||
all: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: cloud-parse
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: ${nacos.addr}
|
||||
# nacos用户名
|
||||
username: ${nacos.user-name}
|
||||
# nacos密码
|
||||
password: ${nacos.password}
|
||||
# 命名空间
|
||||
namespace: ${nacos.namespace}
|
||||
config:
|
||||
# 服务注册地址
|
||||
server-addr: ${nacos.addr}
|
||||
# nacos用户名
|
||||
username: ${nacos.user-name}
|
||||
# nacos密码
|
||||
password: ${nacos.password}
|
||||
# 命名空间
|
||||
namespace: ${nacos.namespace}
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
# 系统共享配置
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# 系统环境Config共享配置
|
||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# # xxl-job 配置文件
|
||||
# - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.muyu.system.mapper: DEBUG
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9703
|
||||
#server:
|
||||
# port: 9703
|
||||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
|
|
Loading…
Reference in New Issue