feat:实时数据,实时轨迹
parent
640b80bfb7
commit
94a8785e59
|
@ -49,6 +49,12 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rabbitMq 发送消息
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询企业
|
* 查询企业
|
||||||
*
|
*
|
||||||
|
@ -101,7 +107,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
.email(business.getBusinessEmail())
|
.email(business.getBusinessEmail())
|
||||||
.phonenumber(business.getBusinessPhone())
|
.phonenumber(business.getBusinessPhone())
|
||||||
.loginIp("111.229.102.61")
|
.loginIp("111.229.102.61")
|
||||||
.roleId(Long.valueOf(101))
|
.roleId(101L)
|
||||||
.userType(String.valueOf(business.getId()))
|
.userType(String.valueOf(business.getId()))
|
||||||
.build();
|
.build();
|
||||||
Result add = remoteUserService.add(sysUser);
|
Result add = remoteUserService.add(sysUser);
|
||||||
|
@ -137,12 +143,12 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
}
|
}
|
||||||
if (business.getBusinessStates().equals("2")) {
|
if (business.getBusinessStates().equals("2")) {
|
||||||
SysUser sysUser = remoteUserService.userById(business.getId());
|
SysUser sysUser = remoteUserService.userById(business.getId());
|
||||||
sysUser.setRoleId(Long.valueOf(2));
|
sysUser.setRoleId(2L);
|
||||||
remoteUserService.updateById(sysUser);
|
remoteUserService.updateById(sysUser);
|
||||||
Entinfo build = Entinfo.builder()
|
Entinfo build = Entinfo.builder()
|
||||||
.entCode("test_" + business.getId())
|
.entCode("test_" + business.getId())
|
||||||
.ip("192.168.120.128")
|
.ip("192.168.120.128")
|
||||||
.port(Integer.valueOf(3306 + Integer.valueOf(String.valueOf(business.getId())))).build();
|
.port(3306 + Integer.parseInt(String.valueOf(business.getId()))).build();
|
||||||
Entinfo entinfo =entinfoService.selectEntinfo(build);
|
Entinfo entinfo =entinfoService.selectEntinfo(build);
|
||||||
if (entinfo==null){
|
if (entinfo==null){
|
||||||
extracted(business);
|
extracted(business);
|
||||||
|
@ -150,12 +156,8 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RabbitTemplate rabbitTemplate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http URL 链接
|
* http URL 进行创建Mysql Docker
|
||||||
* @param business
|
* @param business
|
||||||
*/
|
*/
|
||||||
private void extracted(Business business) {
|
private void extracted(Business business) {
|
||||||
|
@ -190,23 +192,24 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
new InputStreamReader(httpConn.getInputStream()));
|
new InputStreamReader(httpConn.getInputStream()));
|
||||||
String resultData = br.readLine();
|
String resultData = br.readLine();
|
||||||
System.out.println("从服务端返回结果: " + resultData);
|
System.out.println("从服务端返回结果: " + resultData);
|
||||||
|
Entinfo build = Entinfo.builder()
|
||||||
|
.entCode("test_" + business.getId())
|
||||||
|
.ip("192.168.120.128")
|
||||||
|
.port(3306 + Integer.parseInt(String.valueOf(business.getId()))).build();
|
||||||
|
entinfoService.insertEntinfo(build);
|
||||||
|
rabbitTemplate.convertAndSend("zhiLian-vehicle-exchange",JSON.toJSONString(build),message ->{
|
||||||
|
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
//设置消息延迟时间为5秒
|
||||||
|
message.getMessageProperties().setDelay(5000);
|
||||||
|
return message;
|
||||||
|
} );
|
||||||
// 7.关闭HttpURLConnection连接
|
// 7.关闭HttpURLConnection连接
|
||||||
httpConn.disconnect();
|
httpConn.disconnect();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entinfo build = Entinfo.builder()
|
|
||||||
.entCode("test_" + business.getId())
|
|
||||||
.ip("192.168.120.128")
|
|
||||||
.port(Integer.valueOf(3306 + Integer.valueOf(String.valueOf(business.getId())))).build();
|
|
||||||
entinfoService.insertEntinfo(build);
|
|
||||||
rabbitTemplate.convertAndSend("zhiLian-vehicle-exchange",JSON.toJSONString(build),message ->{
|
|
||||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
|
||||||
//设置消息延迟时间为5秒
|
|
||||||
message.getMessageProperties().setDelay(5000);
|
|
||||||
return message;
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||||
public class IotDBSessionConfig {
|
public class IotDBSessionConfig {
|
||||||
|
|
||||||
private static Session session;
|
private static Session session;
|
||||||
private static final String LOCAL_HOST = "192.168.120.128";
|
private static final String LOCAL_HOST = "10.3.44.51";
|
||||||
@Bean
|
@Bean
|
||||||
public Session getSession() throws IoTDBConnectionException, StatementExecutionException {
|
public Session getSession() throws IoTDBConnectionException, StatementExecutionException {
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.zhiLian.vehicle.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.zhiLian.common.core.domain.Result;
|
||||||
|
import com.zhiLian.common.core.web.controller.BaseController;
|
||||||
|
import com.zhiLian.common.core.web.page.TableDataInfo;
|
||||||
|
import com.zhiLian.common.log.annotation.Log;
|
||||||
|
import com.zhiLian.common.log.enums.BusinessType;
|
||||||
|
import com.zhiLian.common.redis.service.RedisService;
|
||||||
|
import com.zhiLian.vehicle.domain.Vehicle;
|
||||||
|
import com.zhiLian.vehicle.domain.VehicleInfo;
|
||||||
|
import com.zhiLian.vehicle.service.IVehicleService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆录入Controller
|
||||||
|
*
|
||||||
|
* @author BingRui.Hou
|
||||||
|
* @date 2024-05-27
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/vehicleInfo")
|
||||||
|
public class VehicleInfoController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
|
||||||
|
@GetMapping("/list/{vin}")
|
||||||
|
public Result vehicleInfoAllList(@PathVariable String vin){
|
||||||
|
|
||||||
|
String lastElement = redisTemplate.opsForList().index(vin, -1);
|
||||||
|
VehicleInfo vehicleInfo = JSON.parseObject(lastElement, VehicleInfo.class);
|
||||||
|
return Result.success(vehicleInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,20 +45,7 @@ public class ManyDataSource {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteBusinessService remoteBusinessService;
|
private RemoteBusinessService remoteBusinessService;
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// private EntInfoFeign entInfoFeign;
|
|
||||||
|
|
||||||
// @PostConstruct
|
|
||||||
// public void init() {
|
|
||||||
// new Thread(() -> {
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(10000);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }).start();
|
|
||||||
// }
|
|
||||||
|
|
||||||
//调用注解 添加队列名称
|
//调用注解 添加队列名称
|
||||||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
||||||
|
@ -111,27 +98,6 @@ public class ManyDataSource {
|
||||||
}};
|
}};
|
||||||
List<Entinfo> list = remoteBusinessService.listAll();
|
List<Entinfo> list = remoteBusinessService.listAll();
|
||||||
databaseNameList.addAll(list);
|
databaseNameList.addAll(list);
|
||||||
|
|
||||||
// List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
|
||||||
// entinfo.forEach(string -> {
|
|
||||||
// Entinfo entInfo = JSON.parseObject(String.valueOf(string), Entinfo.class);
|
|
||||||
// databaseNameList.add(entInfo);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// List<Entinfo> entinfos = entInfoFeign.listAll();
|
|
||||||
// databaseNameList.addAll(entinfos);
|
|
||||||
|
|
||||||
|
|
||||||
// if(SecurityUtils.getLoginUser() == null){
|
|
||||||
// return databaseNameList;
|
|
||||||
// }else{
|
|
||||||
// Long storeId = SecurityUtils.getLoginUser().getUserid();
|
|
||||||
// SysUser sysUser = remoteUserService.selectByUserId(storeId);
|
|
||||||
// String s = redisService.getCacheObject(String.valueOf(sysUser.getUserType()));
|
|
||||||
// EntInfo entInfo = JSON.parseObject(s, EntInfo.class);
|
|
||||||
// databaseNameList.add(entInfo);
|
|
||||||
// return databaseNameList;
|
|
||||||
// }
|
|
||||||
return databaseNameList;
|
return databaseNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +106,6 @@ public class ManyDataSource {
|
||||||
@Bean
|
@Bean
|
||||||
@Primary
|
@Primary
|
||||||
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||||
|
|
||||||
//查企业
|
//查企业
|
||||||
Map<Object, Object> dataSourceMap = new HashMap<>();
|
Map<Object, Object> dataSourceMap = new HashMap<>();
|
||||||
dataSourceInfoList()
|
dataSourceInfoList()
|
||||||
|
@ -157,6 +122,4 @@ public class ManyDataSource {
|
||||||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||||
return dynamicDataSource;
|
return dynamicDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,15 @@ import org.springframework.stereotype.Component;
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
public class DataSourceAsp {
|
public class DataSourceAsp {
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
@Pointcut("execution(public * com.zhiLian.vehicle.controller.*Controller.*(..))")
|
@Pointcut("execution(public * com.zhiLian.vehicle.controller.*Controller.*(..))")
|
||||||
public void pointcut () {
|
public void pointcut () {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Lazy
|
|
||||||
@Autowired
|
|
||||||
private RemoteUserService remoteUserService;
|
|
||||||
/**
|
/**
|
||||||
* 的每一個方法執行之前 執行的處理
|
* 的每一個方法執行之前 執行的處理
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.sql.SQLException;
|
||||||
@Component
|
@Component
|
||||||
public class DruidDataSourceFactory {
|
public class DruidDataSourceFactory {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 根据传递的数据源信息测试数据库连接
|
* @Description: 根据传递的数据源信息测试数据库连接
|
||||||
* @Author Dongzl
|
* @Author Dongzl
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
package com.zhiLian.vehicle.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆信息
|
||||||
|
* @author YunFei.Du
|
||||||
|
* @date 9:03 2024/6/4
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class VehicleInfo {
|
||||||
|
/**
|
||||||
|
* VIN
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
private Long startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
private String longitude;
|
||||||
|
/**
|
||||||
|
* 纬度
|
||||||
|
*/
|
||||||
|
private String latitude;
|
||||||
|
/**
|
||||||
|
* 速度
|
||||||
|
*/
|
||||||
|
private String speed;
|
||||||
|
/**
|
||||||
|
* 里程
|
||||||
|
*/
|
||||||
|
private String mileage;
|
||||||
|
/**
|
||||||
|
* 总电压
|
||||||
|
*/
|
||||||
|
private String voltage;
|
||||||
|
/**
|
||||||
|
* 总电流
|
||||||
|
*/
|
||||||
|
private String current;
|
||||||
|
/**
|
||||||
|
* 绝缘电阻
|
||||||
|
*/
|
||||||
|
private String resistance;
|
||||||
|
|
||||||
|
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;
|
||||||
|
/**
|
||||||
|
* 电池总容量
|
||||||
|
*/
|
||||||
|
private String 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;
|
||||||
|
/**
|
||||||
|
* 车辆状态
|
||||||
|
*/
|
||||||
|
private String vehicleStatus;
|
||||||
|
/**
|
||||||
|
* 充电状态
|
||||||
|
*/
|
||||||
|
private String chargingStatus;
|
||||||
|
/**
|
||||||
|
* 运行状态
|
||||||
|
*/
|
||||||
|
private String operatingStatus;
|
||||||
|
/**
|
||||||
|
* SOC
|
||||||
|
*/
|
||||||
|
private String socStatus;
|
||||||
|
/**
|
||||||
|
* 可充电储能装置工作状态
|
||||||
|
*/
|
||||||
|
private String chargingEnergyStorageStatus;
|
||||||
|
/**
|
||||||
|
* 驱动电机状态
|
||||||
|
*/
|
||||||
|
private String driveMotorStatus;
|
||||||
|
/**
|
||||||
|
* 定位是否有效
|
||||||
|
*/
|
||||||
|
private String positionStatus;
|
||||||
|
/**
|
||||||
|
* EAS(汽车防盗系统)状态
|
||||||
|
*/
|
||||||
|
private String easStatus;
|
||||||
|
/**
|
||||||
|
* PTC(电动加热器)状态
|
||||||
|
*/
|
||||||
|
private String ptcStatus;
|
||||||
|
/**
|
||||||
|
* EPS(电动助力系统)状态
|
||||||
|
*/
|
||||||
|
private String epsStatus;
|
||||||
|
/**
|
||||||
|
* ABS(防抱死)状态
|
||||||
|
*/
|
||||||
|
private String absStatus;
|
||||||
|
/**
|
||||||
|
* MCU(电机/逆变器)状态
|
||||||
|
*/
|
||||||
|
private String mcuStatus;
|
||||||
|
/**
|
||||||
|
* 动力电池加热状态
|
||||||
|
*/
|
||||||
|
private String heatingStatus;
|
||||||
|
/**
|
||||||
|
* 动力电池当前状态
|
||||||
|
*/
|
||||||
|
private String batteryStatus;
|
||||||
|
/**
|
||||||
|
* 动力电池保温状态
|
||||||
|
*/
|
||||||
|
private String batteryInsulationStatus;
|
||||||
|
/**
|
||||||
|
* DCDC(电力交换系统)状态
|
||||||
|
*/
|
||||||
|
private String dcdcStatus;
|
||||||
|
/**
|
||||||
|
* CHG(充电机)状态
|
||||||
|
*/
|
||||||
|
private String chgStatus;
|
||||||
|
}
|
Loading…
Reference in New Issue