Merge pull request 'server_2024_3_26_jiangcan' (#7) from server_2024_3_26_jiangcan into master
Reviewed-on: #7server_2024_4_2_liyuan
commit
a9afd4d5bd
6
pom.xml
6
pom.xml
|
@ -208,6 +208,12 @@
|
||||||
<version>${zhilian.version}</version>
|
<version>${zhilian.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-resolver</artifactId>
|
||||||
|
<version>${zhilian.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 智联业务模块 -->
|
<!-- 智联业务模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zhilian</groupId>
|
<groupId>com.zhilian</groupId>
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<module>zhilian-common-datascope</module>
|
<module>zhilian-common-datascope</module>
|
||||||
<module>zhilian-common-datasource</module>
|
<module>zhilian-common-datasource</module>
|
||||||
<module>zhilian-common-system</module>
|
<module>zhilian-common-system</module>
|
||||||
|
<module>zhilian-common-resolver</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>zhilian-common</artifactId>
|
<artifactId>zhilian-common</artifactId>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.zhilian.common.core.web.page;
|
||||||
|
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 列表返回结果集
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PageResult<T> implements Serializable {
|
||||||
|
/**
|
||||||
|
* 总条数
|
||||||
|
*/
|
||||||
|
private long total;
|
||||||
|
/**
|
||||||
|
* 结果集合
|
||||||
|
*/
|
||||||
|
private List<T> list;
|
||||||
|
public PageResult() {
|
||||||
|
}
|
||||||
|
public PageResult(long total, List<T> list) {
|
||||||
|
this.total = total;
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
public static <T> PageResult<T> toPageResult(long total, List<T> list){
|
||||||
|
return new PageResult(total , list);
|
||||||
|
}
|
||||||
|
public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
|
||||||
|
return Result.success(PageResult.toPageResult(total,list));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>zhilian-common-resolver</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>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,263 @@
|
||||||
|
package com.zhilian.common.resolver.domain;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ResolverReportData
|
||||||
|
* @Description 解析报文数据
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/4/1 11:49
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class ResolverReportData {
|
||||||
|
/**
|
||||||
|
* 主键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,115 @@
|
||||||
|
package com.zhilian.common.resolver.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ResolverReportInfo
|
||||||
|
* @Description 报文实体类
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/26 21:47
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("resolver_report_info")
|
||||||
|
public class ResolverReportInfo extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 报文id
|
||||||
|
*/
|
||||||
|
private Long reportId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆编码
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆在线时间
|
||||||
|
*/
|
||||||
|
private Date onlineTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆下线时间
|
||||||
|
*/
|
||||||
|
private Date downLineTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维度
|
||||||
|
*/
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电池剩余电量
|
||||||
|
*/
|
||||||
|
private BigDecimal remainingBattery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电池电量
|
||||||
|
*/
|
||||||
|
private BigDecimal batteryLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总里程
|
||||||
|
*/
|
||||||
|
private BigDecimal totalMileage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前是否在线: 1在线 0:不在线
|
||||||
|
*/
|
||||||
|
private int isOnline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆是否发生故障: 1是 0:否
|
||||||
|
*/
|
||||||
|
private int isBreakDown;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆故障是否解决: 1是 0:否
|
||||||
|
*/
|
||||||
|
private int isSolve;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆是否延迟:1是 0:否
|
||||||
|
*/
|
||||||
|
private int isDelay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆是否重复: 1是 0:否
|
||||||
|
*/
|
||||||
|
private int isRepeat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆状态: 1行驶中 0:停止
|
||||||
|
*/
|
||||||
|
private int status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应企业id
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否展示 1展示 0:不展示
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
private String createBy;
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.zhilian.common.resolver.domain.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
/**
|
||||||
|
* @ClassName ReportByEsReq
|
||||||
|
* @Description es查询报文请求参数
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/27 23:47
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportByEsReq {
|
||||||
|
/**
|
||||||
|
* 当前页码
|
||||||
|
*/
|
||||||
|
private Integer pageNum=1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示条数
|
||||||
|
*/
|
||||||
|
private Integer pageSize=3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆编号
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
package com.zhilian.common.resolver.domain.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
/**
|
||||||
|
* @ClassName ReportByEsResp
|
||||||
|
* @Description ES 查询返回报文
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/27 23:48
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportByEsResp {
|
||||||
|
/**
|
||||||
|
* 报文id
|
||||||
|
*/
|
||||||
|
private Long reportId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆编码
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆在线时间
|
||||||
|
*/
|
||||||
|
private Date onlineTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆下线时间
|
||||||
|
*/
|
||||||
|
private Date downLineTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维度
|
||||||
|
*/
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电池剩余电量
|
||||||
|
*/
|
||||||
|
private BigDecimal remainingBattery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电池电量
|
||||||
|
*/
|
||||||
|
private BigDecimal batteryLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总里程
|
||||||
|
*/
|
||||||
|
private BigDecimal totalMileage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前是否在线: 1在线 0:不在线
|
||||||
|
*/
|
||||||
|
private int isOnline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆是否发生故障: 1是 0:否
|
||||||
|
*/
|
||||||
|
private int isBreakDown;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆故障是否解决: 1是 0:否
|
||||||
|
*/
|
||||||
|
private int isSolve;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆是否延迟:1是 0:否
|
||||||
|
*/
|
||||||
|
private int isDelay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆是否重复: 1是 0:否
|
||||||
|
*/
|
||||||
|
private int isRepeat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆状态: 1行驶中 0:停止
|
||||||
|
*/
|
||||||
|
private int status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应企业id
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否展示 1展示 0:不展示
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
private String createBy;
|
||||||
|
private String remark;
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
#com.zhilian.common.system.remote.factory.RemoteUserFallbackFactory
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
@ -34,6 +36,7 @@ spring:
|
||||||
ds1:
|
ds1:
|
||||||
nacos:
|
nacos:
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
dataId: sentinel-zhilian-gateway
|
dataId: sentinel-zhilian-gateway
|
||||||
groupId: DEFAULT_GROUP
|
groupId: DEFAULT_GROUP
|
||||||
data-type: json
|
data-type: json
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.zhilian.business;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class zhilianOnLineApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(zhilianOnLineApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.zhilian.manager;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class zhilianMangerApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(zhilianMangerApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<artifactId>zhilian-online</artifactId>
|
<artifactId>zhilian-online</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -117,4 +119,4 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.zhilian;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class ZhiLianOnLineApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ZhiLianOnLineApplication.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.zhilian.online;
|
||||||
|
|
||||||
|
public class aa {
|
||||||
|
}
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -11,12 +11,6 @@
|
||||||
|
|
||||||
<artifactId>zhilian-resolver</artifactId>
|
<artifactId>zhilian-resolver</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>
|
<description>
|
||||||
zhilian-resolver 处理模块
|
zhilian-resolver 处理模块
|
||||||
</description>
|
</description>
|
||||||
|
@ -66,6 +60,11 @@
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- zhilian Common Log -->
|
<!-- zhilian Common Log -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zhilian</groupId>
|
<groupId>com.zhilian</groupId>
|
||||||
|
@ -78,6 +77,46 @@
|
||||||
<artifactId>zhilian-common-swagger</artifactId>
|
<artifactId>zhilian-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- zhilian Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- zhilian Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- zhilian Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-resolver</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mqtt -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -105,4 +144,4 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.zhilian.resolver;
|
||||||
|
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableScheduling
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@MapperScan({"com.zhilian.resolver.mapper", "com.zhilian.resolver.resolverReport"})
|
||||||
|
@SpringBootApplication
|
||||||
|
public class ZhiLianResolverApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ZhiLianResolverApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.zhilian.resolver.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.http.HttpHost;
|
||||||
|
import org.elasticsearch.client.RestClient;
|
||||||
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "es")
|
||||||
|
@Data
|
||||||
|
public class InitEsRes {
|
||||||
|
private String host;
|
||||||
|
private int port;
|
||||||
|
private String scheme;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestHighLevelClient restHighLevelClient(){
|
||||||
|
return new RestHighLevelClient(
|
||||||
|
RestClient.builder(new HttpHost(host,port,scheme))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.zhilian.resolver.controller;
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import com.zhilian.common.core.web.page.PageResult;
|
||||||
|
import com.zhilian.common.log.annotation.Log;
|
||||||
|
import com.zhilian.common.log.enums.BusinessType;
|
||||||
|
import com.zhilian.common.resolver.domain.req.ReportByEsReq;
|
||||||
|
import com.zhilian.common.resolver.domain.resp.ReportByEsResp;
|
||||||
|
import com.zhilian.resolver.service.ReportByEsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
/**
|
||||||
|
* @ClassName ReportByElasticSearchController
|
||||||
|
* @Description es获取报文数据
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/27 23:54
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/es")
|
||||||
|
public class ReportByElasticSearchController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description ReportByEsService业务层
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/28 22:08
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private ReportByEsService reportByEsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description es获取报文数据
|
||||||
|
* @Param [roomRequest]
|
||||||
|
* @return com.zhilian.common.result.Result<com.zhilian.common.result.PageResult<com.zhilian.common.result.RoomResponse>>
|
||||||
|
**/
|
||||||
|
@Log(title = "es获取报文数据", businessType = BusinessType.OTHER)
|
||||||
|
@PostMapping("/queryReportByEs")
|
||||||
|
public Result<PageResult<ReportByEsResp>> queryReportByEs(@RequestBody ReportByEsReq reportByEsReq){
|
||||||
|
Result<PageResult<ReportByEsResp>> result=reportByEsService.queryReportByEs(reportByEsReq);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.zhilian.resolver.controller;
|
||||||
|
|
||||||
|
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.resolver.domain.ResolverReportInfo;
|
||||||
|
import com.zhilian.resolver.service.ResolverReportInfoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ReportController
|
||||||
|
* @Description 报文控制层
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/26 22:13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/report")
|
||||||
|
public class ResolverReportInfoController extends BaseController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 注入报文服务层
|
||||||
|
* @Autowired reportService
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private ResolverReportInfoService reportService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 查询报文列表
|
||||||
|
* @Param [report]
|
||||||
|
* @Return Result<TableDataInfo<ResolverReportInfo>>
|
||||||
|
*/
|
||||||
|
@Log(title = "报文信息", businessType = BusinessType.OTHER)
|
||||||
|
//// @RequiresPermissions("resolver:report:list")
|
||||||
|
@GetMapping("/queryReports")
|
||||||
|
public Result<TableDataInfo<ResolverReportInfo>> list (ResolverReportInfo report) {
|
||||||
|
startPage();
|
||||||
|
List<ResolverReportInfo> list = reportService.pageQuery(report);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.zhilian.resolver.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ReportByEsMapper {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.zhilian.resolver.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||||
|
import com.zhilian.common.resolver.domain.ResolverReportInfo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ResolverReportInfoMapper extends BaseMapper<ResolverReportInfo> {
|
||||||
|
|
||||||
|
// void saveDataToDatabase(ResolverReportData resolverReportData);
|
||||||
|
|
||||||
|
void reportMapper(ResolverReportData vehicleData);
|
||||||
|
}
|
|
@ -0,0 +1,373 @@
|
||||||
|
package com.zhilian.resolver.resolverReport;
|
||||||
|
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||||
|
import com.zhilian.resolver.service.ResolverReportInfoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ResolverMqttMsg
|
||||||
|
* @Description mqtt获取报文数据 解析并同步到数据库
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/4/2 14:17
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ResolverMqttMsg {
|
||||||
|
@Autowired
|
||||||
|
private ResolverReportInfoService resolverReportInfoService;
|
||||||
|
private static final String BROKER_URL = "tcp://111.229.33.194:1883";
|
||||||
|
private static final String CLIENT_ID = "mqttx_53f082e9";
|
||||||
|
@Autowired
|
||||||
|
public ResolverMqttMsg(ResolverReportInfoService resolverReportInfoService) {
|
||||||
|
this.resolverReportInfoService = resolverReportInfoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0/5 * * * * ?")
|
||||||
|
public void start() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
MqttClient mqttClient = new MqttClient(BROKER_URL, CLIENT_ID);
|
||||||
|
|
||||||
|
MqttConnectOptions options = new MqttConnectOptions();
|
||||||
|
|
||||||
|
options.setCleanSession(true);
|
||||||
|
mqttClient.connect(options);
|
||||||
|
|
||||||
|
mqttClient.setCallback(new MqttCallback() {
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
log.error("Mqtt[{}-{}]连接断开:[{}]", CLIENT_ID, BROKER_URL, throwable.getMessage(), throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||||
|
// 打印接收到的消息和主题
|
||||||
|
log.info("主题='{}':消息内容={}", topic, new String(message.getPayload()));
|
||||||
|
String str = hexStringToString(new String(message.getPayload()));
|
||||||
|
List<ResolverReportData> vehicleDataList = parseVehicleData(str);
|
||||||
|
|
||||||
|
for (ResolverReportData vehicleData : vehicleDataList) {
|
||||||
|
log.info("解析到车辆数据:{}", vehicleData);
|
||||||
|
resolverReportInfoService.saveDataToDatabase(vehicleData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken token) {
|
||||||
|
log.info("消息已成功投递:{}",token);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mqttClient.subscribe("cartest",0);
|
||||||
|
|
||||||
|
Thread.sleep(1000*60*10);
|
||||||
|
|
||||||
|
// mqttClient.disconnect();
|
||||||
|
} catch (MqttException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 16进制转换成为string类型字符串
|
||||||
|
*
|
||||||
|
* @param s
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String hexStringToString(String s) {
|
||||||
|
if (s == null || s.equals("")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
s = s.replace(" ", "");
|
||||||
|
byte[] baKeyword = new byte[s.length() / 2];
|
||||||
|
for (int i = 0; i < baKeyword.length; i++) {
|
||||||
|
try {
|
||||||
|
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
s = new String(baKeyword, StandardCharsets.UTF_8);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
private static List<ResolverReportData> parseVehicleData(String str) {
|
||||||
|
List<ResolverReportData> vehicleDataList = new ArrayList<>();
|
||||||
|
ResolverReportData vehicleData = new ResolverReportData();
|
||||||
|
|
||||||
|
vehicleData.setVin(str.substring(1,18));
|
||||||
|
|
||||||
|
log.info("vin=="+vehicleData.getVin());
|
||||||
|
|
||||||
|
//时间
|
||||||
|
String tim =str.substring(18,31);
|
||||||
|
long timestamp = Long.parseLong(tim);
|
||||||
|
|
||||||
|
Date date = new Date(timestamp);
|
||||||
|
vehicleData.setCreateTime(date);
|
||||||
|
|
||||||
|
//经度
|
||||||
|
String lt = str.substring(31,42);
|
||||||
|
// 如果末尾是零,则舍去
|
||||||
|
int endIndex = lt.length() - 1;
|
||||||
|
while (lt.charAt(endIndex) == '0'){
|
||||||
|
endIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
|
String longitude = lt.substring(0, endIndex + 1);
|
||||||
|
vehicleData.setLongitude(longitude);
|
||||||
|
|
||||||
|
//维度
|
||||||
|
String latitudeIndex =str.substring(42,52);
|
||||||
|
int endIndexT = latitudeIndex.length() - 1;
|
||||||
|
while (latitudeIndex.charAt(endIndexT) == '0'){
|
||||||
|
endIndexT--;
|
||||||
|
}
|
||||||
|
|
||||||
|
String latitude = latitudeIndex.substring(0, endIndexT + 1);
|
||||||
|
vehicleData.setLatitude(latitude);
|
||||||
|
|
||||||
|
//速度speed
|
||||||
|
String speed =str.substring(52,58);
|
||||||
|
vehicleData.setSpeed(speed);
|
||||||
|
|
||||||
|
//里程
|
||||||
|
BigDecimal mileage= new BigDecimal(str.substring(58,69));
|
||||||
|
mileage=mileage.stripTrailingZeros();
|
||||||
|
vehicleData.setMileage(mileage);
|
||||||
|
|
||||||
|
//总电压
|
||||||
|
String voltage =str.substring(69,75);
|
||||||
|
while (voltage.endsWith("0")) {
|
||||||
|
voltage = voltage.substring(0, voltage.length() - 1); // 去除末尾的零
|
||||||
|
}
|
||||||
|
vehicleData.setVoltage(voltage);
|
||||||
|
|
||||||
|
//总电流
|
||||||
|
String current =str.substring(75,80);
|
||||||
|
while (current.endsWith("0")){
|
||||||
|
current=current.substring(0,current.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setCurrent(current);
|
||||||
|
|
||||||
|
//绝缘电阻 resistance
|
||||||
|
String res =str.substring(80,89);
|
||||||
|
String resistance = res.substring(0, 5);
|
||||||
|
vehicleData.setResistance(resistance);
|
||||||
|
|
||||||
|
//档位
|
||||||
|
String gear =str.substring(89,90);
|
||||||
|
vehicleData.setGear(gear);
|
||||||
|
|
||||||
|
//accelerationPedal 加速踏板行程值
|
||||||
|
String accelerationPedal =str.substring(90,91);
|
||||||
|
vehicleData.setAccelerationPedal(accelerationPedal);
|
||||||
|
|
||||||
|
//brakePedal 制动踏板行程值
|
||||||
|
String brakePedal =str.substring(92,93);
|
||||||
|
vehicleData.setBrakePedal(brakePedal);
|
||||||
|
|
||||||
|
//fuelConsumptionRate 燃料消耗率
|
||||||
|
String fuelConsumptionRate =str.substring(94,99);
|
||||||
|
vehicleData.setFuelConsumptionRate(fuelConsumptionRate);
|
||||||
|
|
||||||
|
//motorControllerTemperature 电机控制器温度
|
||||||
|
String motorControllerTemperature =str.substring(99,105);
|
||||||
|
while (motorControllerTemperature.endsWith("0")){
|
||||||
|
motorControllerTemperature=motorControllerTemperature.substring(0,motorControllerTemperature.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setMotorControllerTemperature(motorControllerTemperature);
|
||||||
|
|
||||||
|
//motorSpeed 电机转速
|
||||||
|
String motorSpeed =str.substring(105,110);
|
||||||
|
vehicleData.setMotorSpeed(motorSpeed);
|
||||||
|
|
||||||
|
//motorTorque 电机转矩
|
||||||
|
String motorTorque =str.substring(110,114);
|
||||||
|
while (motorTorque.endsWith("0")){
|
||||||
|
motorTorque=motorTorque.substring(0,motorTorque.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setMotorTorque(motorTorque);
|
||||||
|
|
||||||
|
//motorTemperature 电机温度
|
||||||
|
String motorTemperature =str.substring(114,120);
|
||||||
|
while (motorTemperature.endsWith("0")){
|
||||||
|
motorTemperature=motorTemperature.substring(0,motorTemperature.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setMotorTemperature(motorTemperature);
|
||||||
|
|
||||||
|
//motorVoltage 电机电压
|
||||||
|
String motorVoltage =str.substring(120,125);
|
||||||
|
while (motorVoltage.endsWith("0")){
|
||||||
|
motorVoltage=motorVoltage.substring(0,motorVoltage.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setMotorVoltage(motorVoltage);
|
||||||
|
|
||||||
|
//motorCurrent 电机电流
|
||||||
|
String motorCurrent =str.substring(125,133);
|
||||||
|
while (motorCurrent.endsWith("0")){
|
||||||
|
motorCurrent=motorCurrent.substring(0,motorCurrent.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setMotorCurrent(motorCurrent);
|
||||||
|
|
||||||
|
//remainingBattery 动力电池剩余电量SOC
|
||||||
|
BigDecimal remainingBattery = new BigDecimal(str.substring(133,138));
|
||||||
|
vehicleData.setRemainingBattery(remainingBattery);
|
||||||
|
|
||||||
|
//maximumFeedbackPower 当前状态允许的最大反馈功率
|
||||||
|
String maximumFeedbackPower =str.substring(139,144);
|
||||||
|
while (maximumFeedbackPower.endsWith("0")){
|
||||||
|
maximumFeedbackPower=maximumFeedbackPower.substring(0,maximumFeedbackPower.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setMaximumFeedbackPower(maximumFeedbackPower);
|
||||||
|
|
||||||
|
//maximumDischargePower 当前状态允许最大放电功率
|
||||||
|
String maximumDischargePower =str.substring(145,151);
|
||||||
|
while (maximumDischargePower.endsWith("0")){
|
||||||
|
maximumDischargePower=maximumDischargePower.substring(0,maximumDischargePower.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setMaximumDischargePower(maximumDischargePower);
|
||||||
|
|
||||||
|
//selfCheckCounter BMS自检计数器
|
||||||
|
String selfCheckCounter =str.substring(151,153);
|
||||||
|
String selfCheckCounterReplace = selfCheckCounter.replace("0", "");
|
||||||
|
vehicleData.setSelfCheckCounter(selfCheckCounterReplace);
|
||||||
|
|
||||||
|
//totalBatteryCurrent 动力电池充放电电流
|
||||||
|
String totalBatteryCurrent =str.substring(153,158);
|
||||||
|
while (totalBatteryCurrent.endsWith("0")){
|
||||||
|
totalBatteryCurrent=totalBatteryCurrent.substring(0,totalBatteryCurrent.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setTotalBatteryCurrent(totalBatteryCurrent);
|
||||||
|
|
||||||
|
//totalBatteryVoltage 动力电池负载端总电压V3
|
||||||
|
String totalBatteryVoltage =str.substring(158,164);
|
||||||
|
while (totalBatteryVoltage.endsWith("0")){
|
||||||
|
totalBatteryVoltage=totalBatteryVoltage.substring(0,totalBatteryVoltage.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setTotalBatteryVoltage(totalBatteryVoltage);
|
||||||
|
|
||||||
|
//singleBatteryMaxVoltage 单次最大电压
|
||||||
|
String singleBatteryMaxVoltage =str.substring(164,168);
|
||||||
|
while (singleBatteryMaxVoltage.endsWith("0")){
|
||||||
|
singleBatteryMaxVoltage=singleBatteryMaxVoltage.substring(0,singleBatteryMaxVoltage.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setSingleBatteryMaxVoltage(singleBatteryMaxVoltage);
|
||||||
|
|
||||||
|
//singleBatteryMinVoltage 单体电池最低电压
|
||||||
|
String singleBatteryMinVoltage =str.substring(168,172);
|
||||||
|
while (singleBatteryMinVoltage.endsWith("0")){
|
||||||
|
singleBatteryMinVoltage=singleBatteryMinVoltage.substring(0,singleBatteryMinVoltage.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
vehicleData.setSingleBatteryMinVoltage(singleBatteryMinVoltage);
|
||||||
|
|
||||||
|
//singleBatteryMaxTemperature 单体电池最高温度
|
||||||
|
String singleBatteryMaxTemperature =str.substring(172,178);
|
||||||
|
while (singleBatteryMaxTemperature.endsWith("0")){
|
||||||
|
singleBatteryMaxTemperature=singleBatteryMaxTemperature.substring(0,singleBatteryMaxTemperature.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setSingleBatteryMaxTemperature(singleBatteryMaxTemperature);
|
||||||
|
|
||||||
|
//singleBatteryMinTemperature 单体电池最低温度
|
||||||
|
String singleBatteryMinTemperature =str.substring(178,184);
|
||||||
|
while (singleBatteryMinTemperature.endsWith("0")){
|
||||||
|
singleBatteryMinTemperature=singleBatteryMinTemperature.substring(0,singleBatteryMinTemperature.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setSingleBatteryMinTemperature(singleBatteryMinTemperature);
|
||||||
|
|
||||||
|
//availableBatteryCapacity 可用电池容量
|
||||||
|
String availableBatteryCapacity =str.substring(184,190);
|
||||||
|
while (availableBatteryCapacity.endsWith("0")){
|
||||||
|
availableBatteryCapacity=availableBatteryCapacity.substring(0,availableBatteryCapacity.length()-1);
|
||||||
|
}
|
||||||
|
vehicleData.setAvailableBatteryCapacity(availableBatteryCapacity);
|
||||||
|
|
||||||
|
//vehicleStatus 车辆状态
|
||||||
|
int vehicleStatus = Integer.parseInt(str.substring(190,191));
|
||||||
|
vehicleData.setVehicleStatus(vehicleStatus);
|
||||||
|
|
||||||
|
//chargingStatus 充电状态
|
||||||
|
int chargingStatus = Integer.parseInt(str.substring(191,192));
|
||||||
|
vehicleData.setChargingStatus(chargingStatus);
|
||||||
|
|
||||||
|
//operatingStatus 运行状态
|
||||||
|
int operatingStatus = Integer.parseInt(str.substring(192,193));
|
||||||
|
vehicleData.setOperatingStatus(operatingStatus);
|
||||||
|
|
||||||
|
//socStatus SOC
|
||||||
|
int socStatus = Integer.parseInt(str.substring(193,194));
|
||||||
|
vehicleData.setSocStatus(socStatus);
|
||||||
|
|
||||||
|
//chargingEnergyStorageStatus 可充电储能装置工作状态
|
||||||
|
int chargingEnergyStorageStatus = Integer.parseInt(str.substring(194,195));
|
||||||
|
vehicleData.setChargingEnergyStorageStatus(chargingEnergyStorageStatus);
|
||||||
|
|
||||||
|
//driveMotorStatus 驱动电机状态
|
||||||
|
int driveMotorStatus = Integer.parseInt(str.substring(195,196));
|
||||||
|
vehicleData.setDriveMotorStatus(driveMotorStatus);
|
||||||
|
|
||||||
|
//positionStatus 定位是否有效
|
||||||
|
int positionStatus = Integer.parseInt(str.substring(196,197));
|
||||||
|
vehicleData.setPositionStatus(positionStatus);
|
||||||
|
|
||||||
|
//easStatus EAS(汽车防盗系统)状态
|
||||||
|
int easStatus = Integer.parseInt(str.substring(197,198));
|
||||||
|
vehicleData.setEasStatus(easStatus);
|
||||||
|
|
||||||
|
//ptcStatus PTC(电动加热器)状态
|
||||||
|
int ptcStatus = Integer.parseInt(str.substring(198,199));
|
||||||
|
vehicleData.setPtcStatus(ptcStatus);
|
||||||
|
|
||||||
|
//epsStatus
|
||||||
|
int epsStatus = Integer.parseInt(str.substring(199,200));
|
||||||
|
vehicleData.setEpsStatus(epsStatus);
|
||||||
|
|
||||||
|
//absStatus EPS(电动助力系统)状态
|
||||||
|
int absStatus = Integer.parseInt(str.substring(200,201));
|
||||||
|
vehicleData.setAbsStatus(absStatus);
|
||||||
|
|
||||||
|
//mcuStatus MCU(电机/逆变器)状态
|
||||||
|
int mcuStatus = Integer.parseInt(str.substring(201,202));
|
||||||
|
vehicleData.setMcuStatus(mcuStatus);
|
||||||
|
|
||||||
|
//heatingStatus 动力电池加热状态
|
||||||
|
int heatingStatus = Integer.parseInt(str.substring(202,203));
|
||||||
|
vehicleData.setHeatingStatus(heatingStatus);
|
||||||
|
|
||||||
|
//batteryStatus 动力电池当前状态
|
||||||
|
int batteryStatus = Integer.parseInt(str.substring(203,204));
|
||||||
|
vehicleData.setBatteryStatus(batteryStatus);
|
||||||
|
|
||||||
|
//batteryInsulationStatus 动力电池保温状态
|
||||||
|
int batteryInsulationStatus = Integer.parseInt(str.substring(204,205));
|
||||||
|
vehicleData.setBatteryInsulationStatus(batteryInsulationStatus);
|
||||||
|
|
||||||
|
//dcdcStatus DCDC(电力交换系统)状态
|
||||||
|
int dcdcStatus = Integer.parseInt(str.substring(205,206));
|
||||||
|
vehicleData.setDcdcStatus(dcdcStatus);
|
||||||
|
|
||||||
|
//chgStatus CHG(充电机)状态
|
||||||
|
int chgStatus = Integer.parseInt(str.substring(206,207));
|
||||||
|
vehicleData.setChgStatus(chgStatus);
|
||||||
|
|
||||||
|
vehicleDataList.add(vehicleData);
|
||||||
|
|
||||||
|
return vehicleDataList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.zhilian.resolver.service;
|
||||||
|
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import com.zhilian.common.core.web.page.PageResult;
|
||||||
|
import com.zhilian.common.resolver.domain.req.ReportByEsReq;
|
||||||
|
import com.zhilian.common.resolver.domain.resp.ReportByEsResp;
|
||||||
|
/**
|
||||||
|
* @ClassName ReportByEsService
|
||||||
|
* @Description ES 查询报文 业务层
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/28 0:03
|
||||||
|
*/
|
||||||
|
public interface ReportByEsService {
|
||||||
|
/**
|
||||||
|
* @Description: 查询报文
|
||||||
|
* @Param: [reportByEsReq]
|
||||||
|
* @return: Result<PageResult<ReportByEsResp>>
|
||||||
|
*/
|
||||||
|
Result<PageResult<ReportByEsResp>> queryReportByEs(ReportByEsReq reportByEsReq);
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.zhilian.resolver.service;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||||
|
import com.zhilian.common.resolver.domain.ResolverReportInfo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ReportService
|
||||||
|
* @Description 报文业务层
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/26 22:30
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public interface ResolverReportInfoService extends IService<ResolverReportInfo> {
|
||||||
|
|
||||||
|
List<ResolverReportInfo> pageQuery(ResolverReportInfo report);
|
||||||
|
|
||||||
|
void saveDataToDatabase(ResolverReportData vehicleData);
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.zhilian.resolver.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import com.zhilian.common.core.utils.StringUtils;
|
||||||
|
import com.zhilian.common.core.web.page.PageResult;
|
||||||
|
import com.zhilian.common.resolver.domain.req.ReportByEsReq;
|
||||||
|
import com.zhilian.common.resolver.domain.resp.ReportByEsResp;
|
||||||
|
import com.zhilian.resolver.service.ReportByEsService;
|
||||||
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
|
import org.elasticsearch.client.RequestOptions;
|
||||||
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
|
import org.elasticsearch.common.text.Text;
|
||||||
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
import org.elasticsearch.search.SearchHit;
|
||||||
|
import org.elasticsearch.search.SearchHits;
|
||||||
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
|
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||||
|
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ReportByEsServiceImpl
|
||||||
|
* @Description ES 查询报文业务实现层
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/28 0:03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ReportByEsServiceImpl implements ReportByEsService {
|
||||||
|
/**
|
||||||
|
* @Description RestHighLevelClient
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/28 22:10
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private RestHighLevelClient restHighLevelClient;
|
||||||
|
|
||||||
|
public static final String INDEX_REPORT = "report";
|
||||||
|
@Override
|
||||||
|
public Result<PageResult<ReportByEsResp>> queryReportByEs(ReportByEsReq reportByEsReq) {
|
||||||
|
long total = 0;
|
||||||
|
ArrayList<ReportByEsResp> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
SearchRequest searchRequest = new SearchRequest(INDEX_REPORT);
|
||||||
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||||
|
if (StringUtils.isNotEmpty(reportByEsReq.getVin())) {
|
||||||
|
boolQuery.must(QueryBuilders.matchQuery("vin", reportByEsReq.getVin()));
|
||||||
|
}
|
||||||
|
|
||||||
|
searchSourceBuilder.query(boolQuery);
|
||||||
|
searchSourceBuilder.from((reportByEsReq.getPageNum() - 1) * reportByEsReq.getPageSize());
|
||||||
|
searchSourceBuilder.size(reportByEsReq.getPageSize());
|
||||||
|
|
||||||
|
searchSourceBuilder.highlighter(new HighlightBuilder()
|
||||||
|
.field("vin")
|
||||||
|
.preTags("<font color='red'>")
|
||||||
|
.postTags("</font>"));
|
||||||
|
searchRequest.source(searchSourceBuilder);
|
||||||
|
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
||||||
|
SearchHits searchHits = searchResponse.getHits();
|
||||||
|
total = searchHits.getTotalHits().value;
|
||||||
|
|
||||||
|
SearchHit[] hits = searchHits.getHits();
|
||||||
|
for (SearchHit hit : hits) {
|
||||||
|
String sourceAsString = hit.getSourceAsString();
|
||||||
|
ReportByEsResp reportByEsResp = JSONObject.parseObject(sourceAsString, ReportByEsResp.class);
|
||||||
|
reportByEsResp.setReportId(Long.parseLong(hit.getId()));
|
||||||
|
|
||||||
|
Map<String, HighlightField> highlightFields = hit.getHighlightFields();
|
||||||
|
if (highlightFields != null) {
|
||||||
|
HighlightField highlightField = highlightFields.get("vin");
|
||||||
|
if (highlightField != null) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Text fragment : highlightField.getFragments()) {
|
||||||
|
sb.append(fragment);
|
||||||
|
System.out.println("打印" + fragment);
|
||||||
|
}
|
||||||
|
reportByEsResp.setVin(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.add(reportByEsResp);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return PageResult.toResult(total, list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
package com.zhilian.resolver.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.zhilian.common.core.utils.StringUtils;
|
||||||
|
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||||
|
import com.zhilian.common.resolver.domain.ResolverReportInfo;
|
||||||
|
import com.zhilian.resolver.mapper.ResolverReportInfoMapper;
|
||||||
|
import com.zhilian.resolver.service.ResolverReportInfoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||||
|
import org.elasticsearch.action.bulk.BulkRequest;
|
||||||
|
import org.elasticsearch.action.bulk.BulkResponse;
|
||||||
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
|
import org.elasticsearch.client.RequestOptions;
|
||||||
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
|
import org.elasticsearch.xcontent.XContentType;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ReportServiceImpl
|
||||||
|
* @Description 报文业务实现层
|
||||||
|
* @Author Can.J
|
||||||
|
* @Date 2024/3/26 22:31
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class ResolverReportInfoServiceImpl extends ServiceImpl<ResolverReportInfoMapper, ResolverReportInfo> implements ResolverReportInfoService {
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate<String,Object> redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RestHighLevelClient restHighLevelClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResolverReportInfoMapper reportMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询报文数据
|
||||||
|
* @param report
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ResolverReportInfo> pageQuery(ResolverReportInfo report) {
|
||||||
|
List<ResolverReportInfo> resultList;
|
||||||
|
//redis中查询
|
||||||
|
log.info("从redis查询数据");
|
||||||
|
String cacheKey=generateCacheKey(report);
|
||||||
|
resultList =(List<ResolverReportInfo>) redisTemplate.opsForValue().get(cacheKey);
|
||||||
|
if(resultList==null){
|
||||||
|
//如果redis中不存在,则从数据库中查询
|
||||||
|
log.info("从数据库查询数据");
|
||||||
|
LambdaQueryWrapper<ResolverReportInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(report.getVin())){
|
||||||
|
queryWrapper.like(ResolverReportInfo::getVin,report.getVin());
|
||||||
|
}
|
||||||
|
//status int类型 精确查询
|
||||||
|
if(Objects.nonNull(report.getStatus())){
|
||||||
|
queryWrapper.eq(ResolverReportInfo::getStatus,report.getStatus());
|
||||||
|
}
|
||||||
|
queryWrapper.eq(ResolverReportInfo::getIsDelete, 1); // 添加 isDelete == 1 的条件
|
||||||
|
resultList =this.list(queryWrapper);
|
||||||
|
|
||||||
|
// 将从数据库中获取的数据存入 Redis,设置过期时间10分钟
|
||||||
|
redisTemplate.opsForValue().set(cacheKey,resultList, Duration.ofMinutes(10));
|
||||||
|
|
||||||
|
//查询结果从数据库获取之后,将其批量写入Elasticsearch
|
||||||
|
try {
|
||||||
|
bulkInsert(resultList);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("报文数据同步ES错误",e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveDataToDatabase(ResolverReportData vehicleData) {
|
||||||
|
reportMapper.reportMapper(vehicleData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成缓存的key
|
||||||
|
* @param report
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String generateCacheKey(ResolverReportInfo report) {
|
||||||
|
return "report_"+report.getVin();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bulkInsert(List<ResolverReportInfo> reports) throws IOException {
|
||||||
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
|
reports.forEach(report -> {
|
||||||
|
// 创建一个索引请求,指定索引名称和文档ID
|
||||||
|
IndexRequest indexRequest = new IndexRequest("report");
|
||||||
|
indexRequest.id(report.getReportId().toString());
|
||||||
|
// 将对象转换为JSON字符串
|
||||||
|
String jsonString = JSON.toJSONString(report);
|
||||||
|
// 将JSON字符串设置为索引请求的文档内容
|
||||||
|
indexRequest.source(jsonString, XContentType.JSON);
|
||||||
|
// 将索引请求添加到批量请求中
|
||||||
|
bulkRequest.add(indexRequest);
|
||||||
|
});
|
||||||
|
BulkResponse bulkResponse = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
|
||||||
|
if(bulkResponse.hasFailures()){
|
||||||
|
//处理失败的情况
|
||||||
|
for (BulkItemResponse item : bulkResponse.getItems()) {
|
||||||
|
if(item.isFailed()){
|
||||||
|
log.error("报文数据同步到ES失败:{}",item.getFailureMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
log.info("报文同步ES成功:{}条",reports.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,10 @@ server:
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
redis:
|
||||||
|
host: 10.10.25.3
|
||||||
|
port: 6379
|
||||||
|
password: fffdev
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: zhilian-resolver
|
name: zhilian-resolver
|
||||||
|
@ -15,11 +19,24 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
es:
|
||||||
|
host: 111.229.33.194
|
||||||
|
port: 9200
|
||||||
|
scheme: http
|
||||||
|
# 服务器配置
|
||||||
|
#mqtt:
|
||||||
|
# server:
|
||||||
|
# broker-url: tcp://111.229.33.194:1883
|
||||||
|
# client-id: mqttx_53f082e9
|
||||||
|
# topic: cartest
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?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.zhilian.resolver.mapper.ReportByEsMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?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.zhilian.resolver.mapper.ResolverReportInfoMapper">
|
||||||
|
|
||||||
|
<insert id="reportMapper">
|
||||||
|
INSERT INTO `vehicle-resolver`.`resolver_report_data`
|
||||||
|
(`vin`, `create_time`, `longitude`, `latitude`,
|
||||||
|
`speed`, `mileage`, `voltage`, `current`, `resistance`, `gear`,
|
||||||
|
`acceleration_pedal`, `fuel_consumption_rate`,
|
||||||
|
`motor_controller_temperature`, `motor_speed`,
|
||||||
|
`motor_torque`, `motor_temperature`, `motor_voltage`,
|
||||||
|
`motor_current`, `remaining_battery`, `maximum_feedback_power`,
|
||||||
|
`maximum_discharge_power`, `self_check_counter`,
|
||||||
|
`total_battery_current`, `total_battery_voltage`,
|
||||||
|
`single_battery_max_voltage`, `single_battery_min_voltage`,
|
||||||
|
`single_battery_max_temperature`, `single_battery_min_temperature`,
|
||||||
|
`available_battery_capacity`, `vehicle_status`, `charging_status`,
|
||||||
|
`operatingStatus`, `soc_status`, `charging_energy_storage_status`,
|
||||||
|
`drive_motor_status`, `position_status`, `eas_status`, `ptc_status`,
|
||||||
|
`eps_status`, `abs_status`, `mcu_status`, `heating_status`, `battery_status`,
|
||||||
|
`battery_insulation_status`, `dcdc_status`, `chg_status`, `brake_pedal`)
|
||||||
|
VALUES (#{vin},
|
||||||
|
#{createTime},
|
||||||
|
#{longitude},
|
||||||
|
#{latitude},
|
||||||
|
#{speed},
|
||||||
|
#{mileage},
|
||||||
|
#{voltage},
|
||||||
|
#{current},
|
||||||
|
#{resistance},
|
||||||
|
#{gear},
|
||||||
|
#{accelerationPedal},
|
||||||
|
#{fuelConsumptionRate},
|
||||||
|
#{motorControllerTemperature},
|
||||||
|
#{motorSpeed},
|
||||||
|
#{motorTorque},
|
||||||
|
#{motorTemperature},
|
||||||
|
#{motorVoltage},
|
||||||
|
#{motorCurrent},
|
||||||
|
#{remainingBattery},
|
||||||
|
#{maximumFeedbackPower},
|
||||||
|
#{maximumDischargePower},
|
||||||
|
#{selfCheckCounter},
|
||||||
|
#{totalBatteryCurrent},
|
||||||
|
#{totalBatteryVoltage},
|
||||||
|
#{singleBatteryMaxVoltage},
|
||||||
|
#{singleBatteryMinVoltage},
|
||||||
|
#{singleBatteryMaxTemperature},
|
||||||
|
#{singleBatteryMinTemperature},
|
||||||
|
#{availableBatteryCapacity},
|
||||||
|
#{vehicleStatus},
|
||||||
|
#{chargingStatus},
|
||||||
|
#{operatingStatus},
|
||||||
|
#{socStatus},
|
||||||
|
#{chargingEnergyStorageStatus},
|
||||||
|
#{driveMotorStatus},
|
||||||
|
#{positionStatus},
|
||||||
|
#{easStatus},
|
||||||
|
#{ptcStatus},
|
||||||
|
#{epsStatus},
|
||||||
|
#{absStatus},
|
||||||
|
#{mcuStatus},
|
||||||
|
#{heatingStatus},
|
||||||
|
#{batteryStatus},
|
||||||
|
#{batteryInsulationStatus},
|
||||||
|
#{dcdcStatus},
|
||||||
|
#{chgStatus},
|
||||||
|
#{brakePedal}
|
||||||
|
);
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 10.10.25.2:8848
|
server-addr: 10.10.25.2:8848
|
||||||
|
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
Loading…
Reference in New Issue