feat():redis配置以及redisService
parent
020466a782
commit
cddc395cb9
|
@ -5,7 +5,7 @@ import org.springframework.boot.SpringApplication;
|
|||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 车辆模拟启动类
|
||||
* @date 2023/11/9
|
||||
|
|
|
@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Saisai.Liu
|
||||
* @Author: Mobai
|
||||
* @date: 2023/12/2
|
||||
* @Description: 分页集合
|
||||
* @Version: 1.0
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.math.BigDecimal;
|
|||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 系统常量
|
||||
* @date 2023/11/15
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 异常类
|
||||
* @date 2023/11/15
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description index页跳转
|
||||
* @date 2023/12/1
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 用户控制层
|
||||
* @date 2023/11/9
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 车辆一键操作控制层
|
||||
* @date 2023/12/6
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.math.BigDecimal;
|
|||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 车辆信息
|
||||
* @date 2023/11/9
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 任务执行模型
|
||||
* @date 2023/12/4
|
||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 一键执行任务结果集
|
||||
* @date 2023/12/5
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.muyu.domain.Vehicle;
|
|||
* 车辆 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @since 2022-07-05
|
||||
*/
|
||||
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
/**
|
||||
* @ClassName Custom
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Author Mobai
|
||||
* @Date 2024/5/26 15:25
|
||||
*/
|
||||
public class Custom {
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.muyu.domain.resp.UnifiedTaskResp;
|
|||
import com.muyu.domain.resp.VehicleInstanceResp;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 车辆实例业务层
|
||||
* @date 2023/11/22
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.muyu.domain.Vehicle;
|
|||
* 车辆 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @since 2022-07-05
|
||||
*/
|
||||
public interface VehicleService extends IService<Vehicle> {
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.service;
|
|||
import com.muyu.domain.resp.UnifiedTaskResp;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 一键设置业务层
|
||||
* @date 2023/12/6
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.stream.Stream;
|
|||
* 车辆 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @since 2022-07-05
|
||||
*/
|
||||
@Log4j2
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 车辆实例业务实现层
|
||||
* @date 2023/11/22
|
||||
|
@ -128,13 +128,12 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
|||
MqttProperties mqttProperties = MqttProperties.builder()
|
||||
.broker("tcp://"+mqttServerModel.getBroker()+":1883")
|
||||
.topic(mqttServerModel.getTopic())
|
||||
.clientId(vin)
|
||||
.clientId(vin+"-"+mqttServerModel.getBroker())
|
||||
.username(connectionReq.getUserName())
|
||||
.password(vin + connectionReq.getTimestamp() + connectionReq.getNonce())
|
||||
.build();
|
||||
vehicleInstance.setMqttProperties(mqttProperties);
|
||||
vehicleInstance.initClient();
|
||||
redisService.setValue(vin, mqttServerModel.getBroker());
|
||||
log.info("vin[{}],上线成功", vin);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 一键设置业务实现层
|
||||
* @date 2023/12/6
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.utils;
|
||||
|
||||
import com.muyu.domain.Vehicle;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ConversionUtil {
|
||||
|
@ -29,12 +31,108 @@ public class ConversionUtil {
|
|||
// System.out.println(strToSixteen);
|
||||
// System.out.println(strToSixteen.replace(" ", "").length());
|
||||
|
||||
String hexStr = "3C3F786D6C2076657273696F6E3D22312E30223F3E0D0A3C6D6F6E69746F72526F6F7420747970653D22706172616D223E3C73796E6368726F6E697A65537970746F6D206576656E743D22302220696E697469616C3D2274727565223E3C416374696F6E5F4543473E3C52687974686D3E53696E75733C2F52687974686D3E3C48523E38303C2F48523E3C454D443E4E6F204368616E67653C2F454D443E3C436F6E647563743E303C2F436F6E647563743E3C2F416374696F6E5F4543473E3C416374696F6E5F4F7361742076616C75653D2239342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F425020697352656C617469766550657263656E743D2266616C7365223E3C536872696E6B2076616C75653D22313230222F3E3C537472657463682076616C75653D223830222F3E3C2F416374696F6E5F42503E3C416374696F6E5F5265737020627265617468547970653D224E6F726D616C222076616C75653D2231342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F6574434F322076616C75653D2233342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F54656D70657261747572652076616C75653D2233352E32222F3E3C416374696F6E5F4356502076616C75653D22362E30222F3E3C416374696F6E5F5041504469612076616C75653D223130222F3E3C416374696F6E5F5041505379732076616C75653D223235222F3E3C416374696F6E5F57502076616C75653D2239222F3E3C2F73796E6368726F6E697A65537970746F6D3E3C2F6D6F6E69746F72526F6F743E0D0A";
|
||||
// String hexStr = "3C3F786D6C2076657273696F6E3D22312E30223F3E0D0A3C6D6F6E69746F72526F6F7420747970653D22706172616D223E3C73796E6368726F6E697A65537970746F6D206576656E743D22302220696E697469616C3D2274727565223E3C416374696F6E5F4543473E3C52687974686D3E53696E75733C2F52687974686D3E3C48523E38303C2F48523E3C454D443E4E6F204368616E67653C2F454D443E3C436F6E647563743E303C2F436F6E647563743E3C2F416374696F6E5F4543473E3C416374696F6E5F4F7361742076616C75653D2239342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F425020697352656C617469766550657263656E743D2266616C7365223E3C536872696E6B2076616C75653D22313230222F3E3C537472657463682076616C75653D223830222F3E3C2F416374696F6E5F42503E3C416374696F6E5F5265737020627265617468547970653D224E6F726D616C222076616C75653D2231342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F6574434F322076616C75653D2233342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F54656D70657261747572652076616C75653D2233352E32222F3E3C416374696F6E5F4356502076616C75653D22362E30222F3E3C416374696F6E5F5041504469612076616C75653D223130222F3E3C416374696F6E5F5041505379732076616C75653D223235222F3E3C416374696F6E5F57502076616C75653D2239222F3E3C2F73796E6368726F6E697A65537970746F6D3E3C2F6D6F6E69746F72526F6F743E0D0A";
|
||||
String hexStr = "7E 56 49 4e 31 32 33 34 35 36 37 38 39 44 49 4a 45 34 31 37 31 37 35 39 31 33 35 33 30 37 34 31 31 36 2e 37 32 31 34 31 37 30 33 39 2e 35 32 38 37 34 33 30 33 36 2e 30 30 30 32 36 2e 36 32 36 30 30 30 30 30 32 36 32 30 30 30 32 38 30 30 30 32 36 39 31 30 30 30 30 30 44 34 30 38 30 31 31 2e 32 30 37 30 30 30 30 30 37 36 32 32 32 35 37 37 30 31 33 39 30 30 30 31 35 31 30 30 31 33 37 38 35 30 30 30 34 34 37 37 30 2e 31 34 30 30 30 30 37 39 30 30 30 30 30 30 35 30 30 30 30 35 39 36 30 30 30 33 30 30 30 34 30 30 30 35 30 30 30 30 30 32 35 30 30 30 30 32 30 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 26 7E";
|
||||
String hexStringToString = hexStringToString(hexStr);
|
||||
System.out.println(hexStr);
|
||||
System.out.println(hexStr.length());
|
||||
System.out.println(hexStringToString);
|
||||
System.out.println(hexStringToString.length());
|
||||
String substring = hexStringToString.substring(1, hexStringToString.length() - 2);
|
||||
String vin = substring.substring(0, 17); // 车辆vin
|
||||
String timestamp = substring.substring(17, 30); // 时间戳
|
||||
String longitude = substring.substring(30, 40); // 经度
|
||||
String latitude = substring.substring(40, 50); // 纬度
|
||||
String speed = substring.substring(50, 55); // 速度
|
||||
String mileage = substring.substring(55, 65); // 总里程
|
||||
String voltage = substring.substring(49, 53); // 总电压
|
||||
String current = substring.substring(53, 57); // 总电流
|
||||
String resistance = substring.substring(57, 61); // 绝缘电阻
|
||||
String gear = substring.substring(61, 62); // 档位
|
||||
String accelerationPedal = substring.substring(62, 63); // 加速踏板行程值
|
||||
String brakePedal = substring.substring(63, 64); // 制动踏板行程值
|
||||
String fuelConsumptionRate = substring.substring(64, 65); // 燃油消耗率
|
||||
String motorControllerTemperature = substring.substring(65, 67); // 电机控制器温度
|
||||
String motorSpeed = substring.substring(67, 69); // 电机转速
|
||||
String motoTorque = substring.substring(69, 71); //电机转矩
|
||||
String motorTemperature = substring.substring(71, 73); // 电机温度
|
||||
String motorVoltage = substring.substring(73, 75); // 电机电压
|
||||
String motorCurrent = substring.substring(75, 77); // 电机电流
|
||||
String remainingBattery = substring.substring(77, 79); // 动力电池剩余电量SOC
|
||||
String maximumFeedbackPower = substring.substring(79, 81); // 当前状态允许的最大反馈功率
|
||||
String maximumDischargePower = substring.substring(81, 83); // 当前状态允许的最大放电功率
|
||||
String selfCheckCounter = substring.substring(83,88); // 动力电池放电电流
|
||||
String totalBatteryVoltage = substring.substring(88, 90); // 动力电池负载端总电压V3
|
||||
String singleBatteryMaxVoltage = substring.substring(90, 92); // 单次最大电压
|
||||
String singleBatteryMinVoltage = substring.substring(92, 94); // 单次最低电压
|
||||
String singleBatteryMaxTemperature = substring.substring(94, 96); // 单体电池最高温度
|
||||
String singleBatteryMinTemperature = substring.substring(96, 98); // 单体电池最低温度
|
||||
String availableBatteryCapacity = substring.substring(98, 100); // 动力电池可用容量
|
||||
String vehicleStatus = substring.substring(100, 101); // 车辆状态
|
||||
String chargingStatus = substring.substring(101, 102); // 充电状态
|
||||
String operatingStatus = substring.substring(102, 103); // 运行状态
|
||||
String chargingEnergyStorageStatus = substring.substring(103, 104); // SOC
|
||||
String driveMotorStatus = substring.substring(104, 105); // 可充电储能装置工作状态
|
||||
String positionStatus = substring.substring(104, 105); // 定位是否有效
|
||||
String easStatus = substring.substring(104, 105); // EAS(汽车防盗系统)状态
|
||||
String ptcStatus = substring.substring(104, 105); // PTC(主动安全系统)状态
|
||||
String epsStatus = substring.substring(104, 105); // EPS(电动助力系统)状态
|
||||
String absStatus = substring.substring(104, 105); // ABS(防抱死)状态
|
||||
String mcuStatus = substring.substring(104, 105); // MCU(电机/逆变器)状态
|
||||
String heatingStatus = substring.substring(104, 105); // 动力电池加热状态
|
||||
String batteryStatus = substring.substring(104, 105); // 动力电池当前状态
|
||||
String batteryInsulationStatus = substring.substring(104, 105); // 动力电池保温状态
|
||||
String dcdcStatus = substring.substring(104, 105); // DCDC(电力交换系统)状态
|
||||
String chgStatus = substring.substring(104, 105); // CHG(充电机)状态
|
||||
|
||||
Vehicle vehicle = new Vehicle();
|
||||
System.out.println(
|
||||
vin+"n\t"+
|
||||
timestamp+"n\t"+
|
||||
longitude+"n\t"+
|
||||
latitude+"n\t"+
|
||||
speed+"n\t"+
|
||||
mileage+"n\t"+
|
||||
voltage+"n\t"+
|
||||
current+"n\t"+
|
||||
resistance+"n\t"+
|
||||
gear+"n\t"+
|
||||
accelerationPedal+"n\t"+
|
||||
brakePedal+"n\t"+
|
||||
fuelConsumptionRate+"n\t"+
|
||||
motorControllerTemperature+"n\t"+
|
||||
motorSpeed+"n\t"+
|
||||
motoTorque+"n\t"+
|
||||
motorTemperature+"n\t"+
|
||||
motorVoltage+"n\t"+
|
||||
motorCurrent+"n\t"+
|
||||
remainingBattery+"n\t"+
|
||||
maximumFeedbackPower+"n\t"+
|
||||
maximumDischargePower+"n\t"+
|
||||
selfCheckCounter+"n\t"+
|
||||
totalBatteryVoltage+"n\t"+
|
||||
singleBatteryMaxVoltage+"n\t"+
|
||||
singleBatteryMinVoltage+"n\t"+
|
||||
singleBatteryMaxTemperature+"n\t"+
|
||||
singleBatteryMinTemperature+"n\t"+
|
||||
availableBatteryCapacity+"n\t"+
|
||||
vehicleStatus+"\n\t"+
|
||||
chargingStatus+"\n\t"+
|
||||
operatingStatus+"\n\t"+
|
||||
chargingEnergyStorageStatus+"\n\t"+
|
||||
driveMotorStatus+"\n\t"+
|
||||
positionStatus+"\n\t"+
|
||||
easStatus+"\n\t"+
|
||||
ptcStatus+"\n\t"+
|
||||
epsStatus+"\n\t"+
|
||||
absStatus+"\n\t"+
|
||||
mcuStatus+"\n\t"+
|
||||
heatingStatus+"\n\t"+
|
||||
batteryStatus+"\n\t"+
|
||||
batteryInsulationStatus+"\n\t"+
|
||||
dcdcStatus+"\n\t"+
|
||||
chgStatus+"\n\t"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,10 +3,7 @@ package com.muyu.utils;
|
|||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -24,6 +21,8 @@ public class RedisService {
|
|||
@Autowired
|
||||
public RedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
public StringRedisTemplate stringRedisTemplate;
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
|
@ -261,6 +260,6 @@ public class RedisService {
|
|||
}
|
||||
|
||||
public void setValue(String vin, String broker) {
|
||||
redisTemplate.opsForValue().set(vin,broker);
|
||||
stringRedisTemplate.opsForValue().set(vin,broker);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import static com.muyu.common.SystemConstant.*;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 车辆实例
|
||||
* @date 2023/11/16
|
||||
|
|
|
@ -17,7 +17,7 @@ import javax.annotation.PreDestroy;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description 配置
|
||||
* @date 2023/11/9
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Saisai.Liu
|
||||
* @author Mobai
|
||||
* @version 1.0
|
||||
* @description Mqtt配置类
|
||||
* @date 2023/11/8
|
||||
|
|
Loading…
Reference in New Issue