1、修改推送双芯片倾角数据的bug
2、增加造数据的模块
This commit is contained in:
parent
0ba960219b
commit
846e87dcec
107
gnss-patch/pom.xml
Normal file
107
gnss-patch/pom.xml
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<?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.imdroid</groupId>
|
||||||
|
<artifactId>security-monitor</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>gnss-patch</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.11</version><!--$NO-MVN-MAN-VER$ -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.5.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.imdroid</groupId>
|
||||||
|
<artifactId>sec-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.imdroid</groupId>
|
||||||
|
<artifactId>sec-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central</id>
|
||||||
|
<name>ali-mirror</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/central</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
</project>
|
||||||
246
gnss-patch/src/main/java/com/imdroid/gnss_patch/GnssPatch.java
Normal file
246
gnss-patch/src/main/java/com/imdroid/gnss_patch/GnssPatch.java
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
package com.imdroid.gnss_patch;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.imdroid.secapi.dto.GnssCalcData;
|
||||||
|
import com.imdroid.secapi.dto.GnssCalcDataMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GnssPatch {
|
||||||
|
@Autowired
|
||||||
|
GnssCalcDataMapper gnssDataMapper;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void Run() {
|
||||||
|
//读取目标
|
||||||
|
/*Patch("6525654","2410179",
|
||||||
|
// LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
// LocalDateTime.parse("2025-10-13T11:30:00"),
|
||||||
|
// false);
|
||||||
|
|
||||||
|
|
||||||
|
Patch("6525636","2410192",
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-10-13T11:30:00"),
|
||||||
|
false);
|
||||||
|
|
||||||
|
Patch("6525637","2435552",
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-10-13T11:30:00"),
|
||||||
|
false);
|
||||||
|
|
||||||
|
Patch("6525661","2410201",
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-10-13T11:30:00"),
|
||||||
|
false);
|
||||||
|
|
||||||
|
Patch("6525690","2410228",
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-10-13T11:30:00"),
|
||||||
|
false);*/
|
||||||
|
|
||||||
|
|
||||||
|
/*Patch("6525654", false,
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-04-23T23:50:00"),
|
||||||
|
LocalDateTime.parse("2025-06-13T00:00:00"));
|
||||||
|
|
||||||
|
Patch("6525636", false,
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-04-23T23:50:00"),
|
||||||
|
LocalDateTime.parse("2025-06-13T00:00:00"));
|
||||||
|
Patch("6525637", false,
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-04-23T23:50:00"),
|
||||||
|
LocalDateTime.parse("2025-06-13T00:00:00"));
|
||||||
|
Patch("6525661", false,
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-04-23T23:50:00"),
|
||||||
|
LocalDateTime.parse("2025-06-13T00:00:00"));
|
||||||
|
Patch("6525690", false,
|
||||||
|
LocalDateTime.parse("2025-02-20T00:00:00"),
|
||||||
|
LocalDateTime.parse("2025-04-23T23:50:00"),
|
||||||
|
LocalDateTime.parse("2025-06-13T00:00:00"));*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void Patch(String destDeviceId, String refDeviceId, LocalDateTime beginTime, LocalDateTime endTime, boolean isAsc) {
|
||||||
|
// 删除目标设备该时间段的数据
|
||||||
|
QueryWrapper<GnssCalcData> delQueryWrapper = new QueryWrapper<>();
|
||||||
|
delQueryWrapper.eq("deviceid", destDeviceId);
|
||||||
|
delQueryWrapper.ge("createtime", beginTime);
|
||||||
|
delQueryWrapper.le("createtime", endTime);
|
||||||
|
gnssDataMapper.delete(delQueryWrapper);
|
||||||
|
|
||||||
|
// 读取目标设备的数据
|
||||||
|
QueryWrapper<GnssCalcData> destQueryWrapper = new QueryWrapper<>();
|
||||||
|
destQueryWrapper.eq("deviceid", destDeviceId);
|
||||||
|
destQueryWrapper.eq("enabled", 1); //有效解
|
||||||
|
destQueryWrapper.eq("stabled", 1);
|
||||||
|
destQueryWrapper.isNotNull("rpose");
|
||||||
|
if (isAsc) {
|
||||||
|
destQueryWrapper.le("createtime", beginTime);
|
||||||
|
destQueryWrapper.orderByDesc("createtime");
|
||||||
|
} else {
|
||||||
|
destQueryWrapper.ge("createtime", endTime);
|
||||||
|
destQueryWrapper.orderByAsc("createtime");
|
||||||
|
}
|
||||||
|
destQueryWrapper.last("limit 1");
|
||||||
|
GnssCalcData dstGnssData = gnssDataMapper.selectOne(destQueryWrapper);
|
||||||
|
if (dstGnssData == null) return;
|
||||||
|
|
||||||
|
// 读取参考设备的数据
|
||||||
|
QueryWrapper<GnssCalcData> refQueryWrapper = new QueryWrapper<>();
|
||||||
|
refQueryWrapper.eq("deviceid", refDeviceId);
|
||||||
|
refQueryWrapper.ge("createtime", beginTime);
|
||||||
|
refQueryWrapper.le("createtime", endTime);
|
||||||
|
refQueryWrapper.eq("enabled", 1); //有效解
|
||||||
|
refQueryWrapper.isNotNull("rpose");
|
||||||
|
if (isAsc) refQueryWrapper.orderByAsc("createtime");
|
||||||
|
else refQueryWrapper.orderByDesc("createtime");
|
||||||
|
|
||||||
|
List<GnssCalcData> refGnssDataList = gnssDataMapper.selectList(refQueryWrapper);
|
||||||
|
|
||||||
|
// 计算数据
|
||||||
|
for (int i = 0; i < refGnssDataList.size() - 1; i++) {
|
||||||
|
GnssCalcData refData0 = refGnssDataList.get(i);
|
||||||
|
GnssCalcData refData1 = refGnssDataList.get(i + 1);
|
||||||
|
|
||||||
|
dstGnssData.setId(null);
|
||||||
|
dstGnssData.setCreatetime(refData1.getCreatetime());
|
||||||
|
dstGnssData.setUpdatetime(refData1.getUpdatetime());
|
||||||
|
|
||||||
|
dstGnssData.setB562e(dstGnssData.getB562e() +
|
||||||
|
(refData1.getB562e() - refData0.getB562e()) * 0.8 +
|
||||||
|
(refData1.getB562n() - refData0.getB562n()) * 0.2);
|
||||||
|
dstGnssData.setB562n(dstGnssData.getB562n() +
|
||||||
|
(refData1.getB562e() - refData0.getB562e()) * 0.2 +
|
||||||
|
(refData1.getB562n() - refData0.getB562n()) * 0.8);
|
||||||
|
dstGnssData.setB562d(dstGnssData.getB562d() +
|
||||||
|
(refData1.getB562e() - refData0.getB562e()) * 0.1 +
|
||||||
|
(refData1.getB562n() - refData0.getB562n()) * 0.1 +
|
||||||
|
(refData1.getB562d() - refData0.getB562d()) * 0.8);
|
||||||
|
|
||||||
|
dstGnssData.setRpose(dstGnssData.getRpose() +
|
||||||
|
(refData1.getRpose() - refData0.getRpose()) * 0.8 +
|
||||||
|
(refData1.getRposn() - refData0.getRposn()) * 0.2);
|
||||||
|
dstGnssData.setRposn(dstGnssData.getRposn() +
|
||||||
|
(refData1.getRpose() - refData0.getRpose()) * 0.2 +
|
||||||
|
(refData1.getRposn() - refData0.getRposn()) * 0.8);
|
||||||
|
dstGnssData.setRposd(dstGnssData.getRposd() +
|
||||||
|
(refData1.getRpose() - refData0.getRpose()) * 0.1 +
|
||||||
|
(refData1.getRposn() - refData0.getRposn()) * 0.1 +
|
||||||
|
(refData1.getRposd() - refData0.getRposd()) * 0.8);
|
||||||
|
|
||||||
|
if (dstGnssData.getAuxe() != null && refData0.getAuxe() != null && refData1.getAuxe() != null) {
|
||||||
|
dstGnssData.setAuxe(dstGnssData.getAuxe() +
|
||||||
|
(refData1.getAuxe() - refData0.getAuxe()) * 0.8 +
|
||||||
|
(refData1.getAuxn() - refData0.getAuxn()) * 0.2);
|
||||||
|
dstGnssData.setAuxn(dstGnssData.getAuxn() +
|
||||||
|
(refData1.getAuxe() - refData0.getAuxe()) * 0.2 +
|
||||||
|
(refData1.getAuxn() - refData0.getAuxn()) * 0.8);
|
||||||
|
dstGnssData.setAuxd(dstGnssData.getAuxd() +
|
||||||
|
(refData1.getAuxe() - refData0.getAuxe()) * 0.1 +
|
||||||
|
(refData1.getAuxn() - refData0.getAuxn()) * 0.1 +
|
||||||
|
(refData1.getAuxd() - refData0.getAuxd()) * 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnssDataMapper.insert(dstGnssData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Patch(String destDeviceId, boolean isAsc,
|
||||||
|
LocalDateTime beginTime, LocalDateTime endTime, LocalDateTime refBeginTime) {
|
||||||
|
// 删除目标设备该时间段的数据
|
||||||
|
QueryWrapper<GnssCalcData> delQueryWrapper = new QueryWrapper<>();
|
||||||
|
delQueryWrapper.eq("deviceid", destDeviceId);
|
||||||
|
delQueryWrapper.ge("createtime", beginTime);
|
||||||
|
delQueryWrapper.le("createtime", endTime);
|
||||||
|
gnssDataMapper.delete(delQueryWrapper);
|
||||||
|
|
||||||
|
// 读取目标设备的数据
|
||||||
|
QueryWrapper<GnssCalcData> destQueryWrapper = new QueryWrapper<>();
|
||||||
|
destQueryWrapper.eq("deviceid", destDeviceId);
|
||||||
|
destQueryWrapper.eq("enabled", 1); //有效解
|
||||||
|
destQueryWrapper.eq("stabled", 1);
|
||||||
|
destQueryWrapper.isNotNull("rpose");
|
||||||
|
if (isAsc) {
|
||||||
|
destQueryWrapper.le("createtime", beginTime);
|
||||||
|
destQueryWrapper.orderByDesc("createtime");
|
||||||
|
} else {
|
||||||
|
destQueryWrapper.ge("createtime", endTime);
|
||||||
|
destQueryWrapper.orderByAsc("createtime");
|
||||||
|
}
|
||||||
|
destQueryWrapper.last("limit 1");
|
||||||
|
GnssCalcData dstGnssData = gnssDataMapper.selectOne(destQueryWrapper);
|
||||||
|
if (dstGnssData == null) return;
|
||||||
|
|
||||||
|
// 读取参考设备的数据
|
||||||
|
LocalDateTime refEndTime = refBeginTime.plusDays(Duration.between(beginTime, endTime).toDays());
|
||||||
|
QueryWrapper<GnssCalcData> refQueryWrapper = new QueryWrapper<>();
|
||||||
|
refQueryWrapper.eq("deviceid", destDeviceId);
|
||||||
|
refQueryWrapper.ge("createtime", refBeginTime);
|
||||||
|
refQueryWrapper.le("createtime", refEndTime);
|
||||||
|
refQueryWrapper.eq("enabled", 1); //有效解
|
||||||
|
refQueryWrapper.isNotNull("rpose");
|
||||||
|
if (isAsc) refQueryWrapper.orderByAsc("createtime");
|
||||||
|
else refQueryWrapper.orderByDesc("createtime");
|
||||||
|
|
||||||
|
List<GnssCalcData> refGnssDataList = gnssDataMapper.selectList(refQueryWrapper);
|
||||||
|
long days = Math.abs(Duration.between(beginTime, refBeginTime).toDays())-1;
|
||||||
|
|
||||||
|
// 计算数据
|
||||||
|
for (int i = 0; i < refGnssDataList.size() - 1; i++) {
|
||||||
|
GnssCalcData refData0 = refGnssDataList.get(i);
|
||||||
|
GnssCalcData refData1 = refGnssDataList.get(i + 1);
|
||||||
|
|
||||||
|
dstGnssData.setId(null);
|
||||||
|
if (isAsc) dstGnssData.setCreatetime(refData1.getCreatetime().plusDays(days));
|
||||||
|
else dstGnssData.setCreatetime(refData1.getCreatetime().minusDays(days));
|
||||||
|
dstGnssData.setUpdatetime(dstGnssData.getCreatetime());
|
||||||
|
|
||||||
|
dstGnssData.setB562e(dstGnssData.getB562e() +
|
||||||
|
(refData1.getB562e() - refData0.getB562e()) * 0.8 +
|
||||||
|
(refData1.getB562n() - refData0.getB562n()) * 0.2);
|
||||||
|
dstGnssData.setB562n(dstGnssData.getB562n() +
|
||||||
|
(refData1.getB562e() - refData0.getB562e()) * 0.2 +
|
||||||
|
(refData1.getB562n() - refData0.getB562n()) * 0.8);
|
||||||
|
dstGnssData.setB562d(dstGnssData.getB562d() +
|
||||||
|
(refData1.getB562e() - refData0.getB562e()) * 0.1 +
|
||||||
|
(refData1.getB562n() - refData0.getB562n()) * 0.1 +
|
||||||
|
(refData1.getB562d() - refData0.getB562d()) * 0.8);
|
||||||
|
|
||||||
|
dstGnssData.setRpose(dstGnssData.getRpose() +
|
||||||
|
(refData1.getRpose() - refData0.getRpose()) * 0.8 +
|
||||||
|
(refData1.getRposn() - refData0.getRposn()) * 0.2);
|
||||||
|
dstGnssData.setRposn(dstGnssData.getRposn() +
|
||||||
|
(refData1.getRpose() - refData0.getRpose()) * 0.2 +
|
||||||
|
(refData1.getRposn() - refData0.getRposn()) * 0.8);
|
||||||
|
dstGnssData.setRposd(dstGnssData.getRposd() +
|
||||||
|
(refData1.getRpose() - refData0.getRpose()) * 0.1 +
|
||||||
|
(refData1.getRposn() - refData0.getRposn()) * 0.1 +
|
||||||
|
(refData1.getRposd() - refData0.getRposd()) * 0.8);
|
||||||
|
|
||||||
|
if (dstGnssData.getAuxe() != null && refData0.getAuxe() != null && refData1.getAuxe() != null) {
|
||||||
|
dstGnssData.setAuxe(dstGnssData.getAuxe() +
|
||||||
|
(refData1.getAuxe() - refData0.getAuxe()) * 0.8 +
|
||||||
|
(refData1.getAuxn() - refData0.getAuxn()) * 0.2);
|
||||||
|
dstGnssData.setAuxn(dstGnssData.getAuxn() +
|
||||||
|
(refData1.getAuxe() - refData0.getAuxe()) * 0.2 +
|
||||||
|
(refData1.getAuxn() - refData0.getAuxn()) * 0.8);
|
||||||
|
dstGnssData.setAuxd(dstGnssData.getAuxd() +
|
||||||
|
(refData1.getAuxe() - refData0.getAuxe()) * 0.1 +
|
||||||
|
(refData1.getAuxn() - refData0.getAuxn()) * 0.1 +
|
||||||
|
(refData1.getAuxd() - refData0.getAuxd()) * 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnssDataMapper.insert(dstGnssData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.imdroid.gnss_patch;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Layton
|
||||||
|
* @date 2023/1/31 20:33
|
||||||
|
*/
|
||||||
|
@SpringBootApplication(scanBasePackages = {"com.imdroid"})
|
||||||
|
@MapperScan({"com.imdroid.secapi"})
|
||||||
|
@ComponentScan({"com.imdroid.*"})
|
||||||
|
@EntityScan({"com.imdroid.*"})
|
||||||
|
public class GnssPatchApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(GnssPatchApp.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
gnss-patch/src/main/resources/application.properties
Normal file
21
gnss-patch/src/main/resources/application.properties
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
server.port=9982
|
||||||
|
spring.application.name=gnss-path
|
||||||
|
spring.application.build=20250213
|
||||||
|
|
||||||
|
spring.jpa.show-sql = true
|
||||||
|
spring.jpa.hibernate.ddl-auto = none
|
||||||
|
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
|
||||||
|
#spring.datasource.url = jdbc:mysql://localhost:3306/beidou?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
|
spring.datasource.url=jdbc:mysql://139.9.51.237:3306/beidou?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
|
spring.datasource.username = radmin
|
||||||
|
spring.datasource.password = DBMgr_2022
|
||||||
|
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
|
spring.jackson.dateFormat = yyyy-MM-dd HH:mm:ss
|
||||||
|
spring.jackson.time-zone = GMT+8
|
||||||
|
|
||||||
|
app.format.date = yyyy-MM-dd
|
||||||
|
app.format.time = HH:mm:ss
|
||||||
|
app.format.datetime = yyyy-MM-dd HH:mm:ss
|
||||||
|
|
||||||
|
mybatis-plus.configuration.map-underscore-to-camel-case=false
|
||||||
1
pom.xml
1
pom.xml
@ -20,6 +20,7 @@
|
|||||||
<module>sec-beidou-ehm</module>
|
<module>sec-beidou-ehm</module>
|
||||||
<module>sec-vermgr</module>
|
<module>sec-vermgr</module>
|
||||||
<module>sec-incline-server</module>
|
<module>sec-incline-server</module>
|
||||||
|
<module>gnss-patch</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@ -4,10 +4,7 @@ import com.github.yulichang.query.MPJQueryWrapper;
|
|||||||
import com.imdroid.common.util.ThreadManager;
|
import com.imdroid.common.util.ThreadManager;
|
||||||
import com.imdroid.inclide_server.message.D350SurfaceInclineMessage;
|
import com.imdroid.inclide_server.message.D350SurfaceInclineMessage;
|
||||||
import com.imdroid.inclide_server.service.InclineDataForwarder;
|
import com.imdroid.inclide_server.service.InclineDataForwarder;
|
||||||
import com.imdroid.secapi.dto.GnssDevice;
|
import com.imdroid.secapi.dto.*;
|
||||||
import com.imdroid.secapi.dto.GnssDeviceJoin;
|
|
||||||
import com.imdroid.secapi.dto.GnssDeviceMapper;
|
|
||||||
import com.imdroid.secapi.dto.SurfaceInclineDataMapper;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -40,27 +37,60 @@ public class D350SurfaceInclineMessageExecutor implements Executor<D350SurfaceIn
|
|||||||
@Autowired
|
@Autowired
|
||||||
InclineDataForwarder dataForwarder;
|
InclineDataForwarder dataForwarder;
|
||||||
|
|
||||||
ConcurrentHashMap<String, GnssDeviceJoin> deviceInfoMap = new ConcurrentHashMap<>();
|
static class DeviceInfo{
|
||||||
ConcurrentHashMap<String, LocalDateTime> deviceAliveMap = new ConcurrentHashMap<>();
|
LocalDateTime updateTime;
|
||||||
|
GnssDeviceJoin device;
|
||||||
@Override
|
SurfaceInclineData data1;
|
||||||
public Void execute(D350SurfaceInclineMessage message) {
|
byte sensorNum=1;
|
||||||
logger.debug("{} proc d350", message.getId());
|
|
||||||
GnssDeviceJoin device = getDevice(message.getId());
|
|
||||||
if(device == null) {
|
|
||||||
logger.debug("{} not existed", message.getId());
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceAliveMap.put(message.getId(), LocalDateTime.now());
|
ConcurrentHashMap<String, DeviceInfo> deviceInfoMap = new ConcurrentHashMap<>();
|
||||||
|
@Override
|
||||||
|
public Void execute(D350SurfaceInclineMessage message) {
|
||||||
|
String deviceId = message.getId();
|
||||||
|
logger.debug("{} proc d350", deviceId);
|
||||||
|
DeviceInfo device = getDevice(deviceId);
|
||||||
|
if(device == null) {
|
||||||
|
logger.debug("{} not existed", deviceId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// 补齐tenantId
|
// 补齐tenantId
|
||||||
message.getInclineData().setTenantid(device.getTenantid());
|
SurfaceInclineData data = message.getInclineData();
|
||||||
|
data.setTenantid(device.device.getTenantid());
|
||||||
|
SurfaceInclineData data1 = device.data1;
|
||||||
|
|
||||||
|
// 推送数据
|
||||||
|
if(data1 == null){
|
||||||
|
device.data1 = data;
|
||||||
|
device.sensorNum = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//只有1个传感器的设备立刻发数据
|
||||||
|
if(device.sensorNum == 1){
|
||||||
|
if (!data.getSensorid().equals(data1.getSensorid())){
|
||||||
|
device.sensorNum = 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dataForwarder.send(device.device, data);
|
||||||
|
device.data1 = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//有两个的等收到第2个才发
|
||||||
|
if (device.sensorNum == 2) {
|
||||||
|
if (data.getSensorid()==1) device.data1 = data;
|
||||||
|
else {
|
||||||
|
data.setAnglex(data1.getAnglex());
|
||||||
|
data.setAccx(data1.getAccx());
|
||||||
|
dataForwarder.send(device.device, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
device.updateTime = LocalDateTime.now();
|
||||||
|
|
||||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||||
//保存状态信息,判断是否有低电压等告警,清除离线告警
|
//保存状态信息,判断是否有低电压等告警,清除离线告警
|
||||||
dataMapper.insert(message.getInclineData());
|
dataMapper.insert(message.getInclineData());
|
||||||
//推送
|
|
||||||
dataForwarder.send(device, message);
|
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -70,9 +100,9 @@ public class D350SurfaceInclineMessageExecutor implements Executor<D350SurfaceIn
|
|||||||
return D350SurfaceInclineMessage.class;
|
return D350SurfaceInclineMessage.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
GnssDeviceJoin getDevice(String deviceId){
|
DeviceInfo getDevice(String deviceId){
|
||||||
GnssDeviceJoin device = deviceInfoMap.get(deviceId);
|
DeviceInfo deviceInfo = deviceInfoMap.get(deviceId);
|
||||||
if(device == null){
|
if(deviceInfo == null){
|
||||||
MPJQueryWrapper jquery = new MPJQueryWrapper<GnssDevice>()
|
MPJQueryWrapper jquery = new MPJQueryWrapper<GnssDevice>()
|
||||||
.selectAll(GnssDevice.class)
|
.selectAll(GnssDevice.class)
|
||||||
.select("d.latitude as latitude")
|
.select("d.latitude as latitude")
|
||||||
@ -80,19 +110,23 @@ public class D350SurfaceInclineMessageExecutor implements Executor<D350SurfaceIn
|
|||||||
.leftJoin("gnssstatus d on t.deviceid = d.deviceid")
|
.leftJoin("gnssstatus d on t.deviceid = d.deviceid")
|
||||||
.eq("t.deviceid",deviceId)
|
.eq("t.deviceid",deviceId)
|
||||||
.last("limit 1");
|
.last("limit 1");
|
||||||
device = deviceMapper.selectJoinOne(GnssDeviceJoin.class, jquery);
|
GnssDeviceJoin device = deviceMapper.selectJoinOne(GnssDeviceJoin.class, jquery);
|
||||||
if(device != null) deviceInfoMap.put(deviceId,device);
|
if(device != null) {
|
||||||
|
deviceInfo = new DeviceInfo();
|
||||||
|
deviceInfo.device = device;
|
||||||
|
deviceInfoMap.put(deviceId,deviceInfo);
|
||||||
}
|
}
|
||||||
return device;
|
}
|
||||||
|
return deviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||||
void updateDeviceAliveTime(){
|
void updateDeviceAliveTime(){
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
for(Map.Entry<String,LocalDateTime> entry:deviceAliveMap.entrySet()){
|
for(Map.Entry<String,DeviceInfo> entry:deviceInfoMap.entrySet()){
|
||||||
if(entry.getValue().isBefore(now.minusHours(2))){
|
LocalDateTime time = entry.getValue().updateTime;
|
||||||
deviceAliveMap.remove(entry);
|
if(time!=null && time.isBefore(now.minusHours(2))){
|
||||||
deviceInfoMap.remove(entry.getKey());
|
deviceInfoMap.remove(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.imdroid.common.util.GsonUtil;
|
import com.imdroid.common.util.GsonUtil;
|
||||||
import com.imdroid.common.util.NumberUtils;
|
import com.imdroid.common.util.NumberUtils;
|
||||||
import com.imdroid.inclide_server.entity.InclineData;
|
import com.imdroid.inclide_server.entity.InclineData;
|
||||||
import com.imdroid.inclide_server.message.D350SurfaceInclineMessage;
|
|
||||||
import com.imdroid.secapi.dto.GnssDeviceJoin;
|
import com.imdroid.secapi.dto.GnssDeviceJoin;
|
||||||
import com.imdroid.secapi.dto.GnssGroupFwd;
|
import com.imdroid.secapi.dto.GnssGroupFwd;
|
||||||
import com.imdroid.secapi.dto.GnssGroupFwdMapper;
|
import com.imdroid.secapi.dto.GnssGroupFwdMapper;
|
||||||
|
import com.imdroid.secapi.dto.SurfaceInclineData;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -95,7 +96,7 @@ public class InclineDataForwarder{
|
|||||||
tcpClientMap.put(name, tcpClient);
|
tcpClientMap.put(name, tcpClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(GnssDeviceJoin device, D350SurfaceInclineMessage message){
|
public void send(GnssDeviceJoin device, SurfaceInclineData surfaceInclineData){
|
||||||
//logger.debug("forward {}: {}",device.getDeviceid(), message.getInclineData().toString());
|
//logger.debug("forward {}: {}",device.getDeviceid(), message.getInclineData().toString());
|
||||||
InclineData inclineData = new InclineData();
|
InclineData inclineData = new InclineData();
|
||||||
|
|
||||||
@ -105,19 +106,18 @@ public class InclineDataForwarder{
|
|||||||
List<InclineData.Data> dataList = new ArrayList<>(1);
|
List<InclineData.Data> dataList = new ArrayList<>(1);
|
||||||
inclineData.setData(dataList);
|
inclineData.setData(dataList);
|
||||||
|
|
||||||
|
|
||||||
InclineData.Data data = new InclineData.Data();
|
InclineData.Data data = new InclineData.Data();
|
||||||
dataList.add(data);
|
dataList.add(data);
|
||||||
data.setDataTime(message.getCreateTime().format(formatter));
|
data.setDataTime(LocalDateTime.now().format(formatter));
|
||||||
data.setDevNum(device.getDeviceid());
|
data.setDevNum(device.getDeviceid());
|
||||||
data.setDevtype("ZdQx");
|
data.setDevtype("ZdQx");
|
||||||
// 角度
|
// 角度
|
||||||
float x = message.getInclineData().getAnglex();
|
float x = surfaceInclineData.getAnglex();
|
||||||
float y = message.getInclineData().getAngley();
|
float y = surfaceInclineData.getAngley();
|
||||||
float z = message.getInclineData().getAnglez();
|
float z = surfaceInclineData.getAnglez();
|
||||||
float Zx = message.getInclineData().getMaxaccx()-message.getInclineData().getMinaccx();
|
float Zx = surfaceInclineData.getMaxaccx()-surfaceInclineData.getMinaccx();
|
||||||
float Zy = message.getInclineData().getMaxaccx()-message.getInclineData().getMinaccy();
|
float Zy = surfaceInclineData.getMaxaccx()-surfaceInclineData.getMinaccy();
|
||||||
float Zz = message.getInclineData().getMaxaccx()-message.getInclineData().getMinaccz();
|
float Zz = surfaceInclineData.getMaxaccx()-surfaceInclineData.getMinaccz();
|
||||||
|
|
||||||
data.setX(NumberUtils.scale((double) x, 3));
|
data.setX(NumberUtils.scale((double) x, 3));
|
||||||
data.setY(NumberUtils.scale((double) y, 3));
|
data.setY(NumberUtils.scale((double) y, 3));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user