1、自动补传功能
This commit is contained in:
parent
240ee77768
commit
fea15e6708
20
readme
Normal file
20
readme
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
2023-12
|
||||||
|
核心功能:基站转发、测站解算、结果推送、断点续传
|
||||||
|
待实现和优化的功能:
|
||||||
|
1、自动断点续传:
|
||||||
|
1)增加一个断点续传任务表。当设备上线时检查上次的状态,如果是掉线,则向设备发补传数据指令,并添加一条新的断点续传任务,包括设备号、时间段
|
||||||
|
2)收到最后一条补传消息,则将任务设置为已完成
|
||||||
|
|
||||||
|
2、推送任务:
|
||||||
|
1)按项目号、推送参数ID将在线设备信息打包成若干个List
|
||||||
|
2)根据推送参数ID生成相应的推送对象,含协议、地址、端口、推送格式,传入设备List
|
||||||
|
3)推送对象推送设备最近的解算记录
|
||||||
|
|
||||||
|
3、私有化部署UI优化:
|
||||||
|
1)首页:显示地图和在线/掉线/告警统计,告警信息实时滚动
|
||||||
|
2)告警:告警信息、告警设置
|
||||||
|
3)设备状态:温湿度、延迟仅开发者可见
|
||||||
|
3)配置:组参数配置、解算参数(仅开发者可见)、推送参数、设备参数(可导出excel表)、命令行(仅开发者可见)
|
||||||
|
4)设备消息(仅开发者可见)
|
||||||
|
5)数据分析:解算结果,可导出excel表
|
||||||
|
6)用户设置:用户名、手机号、权限(管理员、普通),内置开发者用户。管理员可以增删改查,普通用户只能查
|
||||||
@ -4,15 +4,39 @@ import org.springframework.cloud.openfeign.FeignClient;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@FeignClient(name="BeidouClient",url = "http://localhost:9901/api")
|
@FeignClient(name="BeidouClient",url = "http://localhost:9901/api")
|
||||||
public interface BeidouClient {
|
public interface BeidouClient {
|
||||||
@PostMapping("/config_ack")
|
@PostMapping("/config_ack")
|
||||||
String onConfigAck(@RequestParam(name = "deviceId") String deviceId, @RequestParam(name = "configAck") String configAck);
|
String onConfigAck(@RequestParam(name = "deviceId") String deviceId,
|
||||||
|
@RequestParam(name = "tenantId") Integer tenantId,
|
||||||
|
@RequestParam(name = "configAck") String configAck);
|
||||||
|
|
||||||
|
@PostMapping("/device_online")
|
||||||
|
String onLine(@RequestParam(name = "deviceId") String deviceId,
|
||||||
|
@RequestParam(name = "tenantId") Integer tenantId,
|
||||||
|
@RequestParam(name = "lastOnlineTime") LocalDateTime lastOnlineTime);
|
||||||
|
|
||||||
@PostMapping("/device_active")
|
@PostMapping("/device_active")
|
||||||
String onDeviceActive(@RequestParam(name = "deviceId") String deviceId);
|
String onDeviceActive(@RequestParam(name = "deviceId") String deviceId,
|
||||||
|
@RequestParam(name = "tenantId") Integer tenantId);
|
||||||
|
|
||||||
@PostMapping("/device_stop")
|
@PostMapping("/device_stop")
|
||||||
String onDeviceStop(@RequestParam(name = "deviceId") String deviceId);
|
String onDeviceStop(@RequestParam(name = "deviceId") String deviceId,
|
||||||
|
@RequestParam(name = "tenantId") Integer tenantId);
|
||||||
|
|
||||||
|
@PostMapping("/gnss_upload")
|
||||||
|
String onGnssUpload(@RequestParam(name = "deviceId") String deviceId,
|
||||||
|
@RequestParam(name = "tenantId") Integer tenantId,
|
||||||
|
@RequestParam(name = "uploadTime") LocalDateTime uploadTime);
|
||||||
|
|
||||||
|
@PostMapping("/gnss_upload_pause")
|
||||||
|
String onGnssUploadPause(@RequestParam(name = "deviceId") String deviceId,
|
||||||
|
@RequestParam(name = "tenantId") Integer tenantId);
|
||||||
|
|
||||||
|
@PostMapping("/gnss_upload_complete")
|
||||||
|
String onGnssUploadComplete(@RequestParam(name = "deviceId") String deviceId,
|
||||||
|
@RequestParam(name = "tenantId") Integer tenantId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ public class GnssStatus {
|
|||||||
public static final short STATE_OFFLINE = 0;
|
public static final short STATE_OFFLINE = 0;
|
||||||
public static final short STATE_ACTIVE = 1;
|
public static final short STATE_ACTIVE = 1;
|
||||||
public static final short STATE_IDLE = 2;
|
public static final short STATE_IDLE = 2;
|
||||||
|
public static final short STATE_UPLOADING = 3;
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
Long id;
|
Long id;
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
package com.imdroid.sideslope.calc;
|
|
||||||
|
|
||||||
import com.imdroid.sideslope.bd.Tilt;
|
|
||||||
import com.imdroid.sideslope.message.D341LocationMessage;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Layton
|
|
||||||
* @date 2023/2/4 19:18
|
|
||||||
*/
|
|
||||||
public interface GNSSCalcService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算单条GNSS数据
|
|
||||||
*
|
|
||||||
* @param message GNSS数据
|
|
||||||
* @param completeWhenIdle 是否根据空闲时间判断本轮结束
|
|
||||||
* @return x,y,z三轴数据
|
|
||||||
*/
|
|
||||||
double[] calcSingle(D341LocationMessage message, boolean completeWhenIdle);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单轮解算结束,计算平滑值
|
|
||||||
*/
|
|
||||||
void calSingleDone(String deviceId, Integer tenantId, LocalDateTime resultTime);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据GNSS数据的中间结果,计算出最终结果
|
|
||||||
*
|
|
||||||
* @param deviceId 设备id
|
|
||||||
* @return x,y,z三轴数据
|
|
||||||
*/
|
|
||||||
//double[] calcResult(String deviceId,double[] b562Xyz, double[] tiltXyz);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据GNSS数据的中间结果,计算Tilt的平均值
|
|
||||||
* @param deviceId 设备id
|
|
||||||
* @return Tilt
|
|
||||||
*/
|
|
||||||
Tilt calcAvgTilt(String deviceId);
|
|
||||||
|
|
||||||
//void cleanTiltByDeviceId(String deviceId);
|
|
||||||
}
|
|
||||||
@ -1,10 +1,13 @@
|
|||||||
package com.imdroid.sideslope.calc;
|
package com.imdroid.sideslope.calc;
|
||||||
|
|
||||||
|
import com.imdroid.secapi.client.BeidouClient;
|
||||||
import com.imdroid.secapi.dto.FwdRecord;
|
import com.imdroid.secapi.dto.FwdRecord;
|
||||||
import com.imdroid.secapi.dto.FwdRecordMapper;
|
import com.imdroid.secapi.dto.FwdRecordMapper;
|
||||||
|
import com.imdroid.secapi.dto.GnssStatus;
|
||||||
import com.imdroid.sideslope.message.BaseMessage;
|
import com.imdroid.sideslope.message.BaseMessage;
|
||||||
import com.imdroid.sideslope.message.D341LocationMessage;
|
import com.imdroid.sideslope.message.D341LocationMessage;
|
||||||
import com.imdroid.sideslope.message.D342LocationMessage;
|
import com.imdroid.sideslope.message.D342LocationMessage;
|
||||||
|
import com.imdroid.sideslope.service.DataPersistService;
|
||||||
import com.imdroid.sideslope.service.GNSSDeviceLocationRecordService;
|
import com.imdroid.sideslope.service.GNSSDeviceLocationRecordService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -24,11 +27,15 @@ public class MultiLineGNSSCalcService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
SingleLineGNSSCalcService calcService;
|
SingleLineGNSSCalcService calcService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private GNSSDeviceLocationRecordService dataPersistService;
|
private GNSSDeviceLocationRecordService locationPersistService;
|
||||||
@Autowired
|
@Autowired
|
||||||
GNSSCalcFilterService gnssCalcFilterService;
|
GNSSCalcFilterService gnssCalcFilterService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FwdRecordMapper fwdRecordMapper;
|
private FwdRecordMapper fwdRecordMapper;
|
||||||
|
@Autowired
|
||||||
|
private BeidouClient beidouClient;
|
||||||
|
@Autowired
|
||||||
|
DataPersistService dataPersistService;
|
||||||
|
|
||||||
public void calc(D342LocationMessage d342Message){
|
public void calc(D342LocationMessage d342Message){
|
||||||
// 如果时间跨度大于1分钟,或者不含d341,则计算平滑值
|
// 如果时间跨度大于1分钟,或者不含d341,则计算平滑值
|
||||||
@ -41,6 +48,14 @@ public class MultiLineGNSSCalcService {
|
|||||||
// 如果序号为0,则创建一条转发记录表
|
// 如果序号为0,则创建一条转发记录表
|
||||||
if(d342Message.getSeq() == 0 && d342Message.getProjectId()!=null){
|
if(d342Message.getSeq() == 0 && d342Message.getProjectId()!=null){
|
||||||
createFwdReord(d342Message);
|
createFwdReord(d342Message);
|
||||||
|
// 产生继续补传通知
|
||||||
|
beidouClient.onGnssUpload(deviceId,d342Message.getTenantId(), msgTime);
|
||||||
|
GnssStatus gnssStatus = dataPersistService.getDeviceState(deviceId);
|
||||||
|
if(gnssStatus!=null){
|
||||||
|
gnssStatus.setUpdatetime(LocalDateTime.now());
|
||||||
|
gnssStatus.setState(GnssStatus.STATE_UPLOADING);
|
||||||
|
dataPersistService.updateDeviceState(gnssStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastDate != null){
|
if(lastDate != null){
|
||||||
@ -63,12 +78,25 @@ public class MultiLineGNSSCalcService {
|
|||||||
calcService.calSingleDone(deviceId, d342Message.getTenantId(),lastDate);
|
calcService.calSingleDone(deviceId, d342Message.getTenantId(),lastDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deviceMap.put(deviceId, msgTime);
|
|
||||||
// 处理每个B562
|
// 处理每个B562
|
||||||
for(BaseMessage message: d342Message.getMessageList()){
|
for(BaseMessage message: d342Message.getMessageList()){
|
||||||
D341LocationMessage d341Message = (D341LocationMessage)message;
|
D341LocationMessage d341Message = (D341LocationMessage)message;
|
||||||
calcService.calcSingle(d341Message, false);
|
calcService.calcSingle(d341Message, false);
|
||||||
dataPersistService.saveRawData(d341Message);
|
locationPersistService.saveRawData(d341Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录最新补传数据的时间
|
||||||
|
if(d341Count>0) deviceMap.put(deviceId, msgTime);
|
||||||
|
else{
|
||||||
|
// 补传完成
|
||||||
|
deviceMap.remove(deviceId);
|
||||||
|
beidouClient.onGnssUploadComplete(deviceId,d342Message.getTenantId());
|
||||||
|
GnssStatus gnssStatus = dataPersistService.getDeviceState(deviceId);
|
||||||
|
if(gnssStatus!=null){
|
||||||
|
gnssStatus.setState(GnssStatus.STATE_IDLE);
|
||||||
|
dataPersistService.updateDeviceState(gnssStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,4 +113,12 @@ public class MultiLineGNSSCalcService {
|
|||||||
fwdRecord.setDevicenum((short) 1);
|
fwdRecord.setDevicenum((short) 1);
|
||||||
fwdRecordMap.put(deviceId, fwdRecord);
|
fwdRecordMap.put(deviceId, fwdRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 周期结束通知
|
||||||
|
* @param deviceId 设备id
|
||||||
|
*/
|
||||||
|
public LocalDateTime getUploadTime(String deviceId){
|
||||||
|
return deviceMap.get(deviceId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,19 +3,16 @@ package com.imdroid.sideslope.calc;
|
|||||||
import com.imdroid.secapi.dto.GnssCalcData;
|
import com.imdroid.secapi.dto.GnssCalcData;
|
||||||
import com.imdroid.sideslope.bd.*;
|
import com.imdroid.sideslope.bd.*;
|
||||||
import com.imdroid.sideslope.message.D341LocationMessage;
|
import com.imdroid.sideslope.message.D341LocationMessage;
|
||||||
import com.imdroid.sideslope.sal.*;
|
|
||||||
import com.imdroid.sideslope.service.WarningService;
|
import com.imdroid.sideslope.service.WarningService;
|
||||||
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;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Layton
|
* @author Layton
|
||||||
* @date 2023/2/4 19:22
|
* @date 2023/2/4 19:22
|
||||||
@ -76,6 +73,7 @@ public class SingleLineGNSSCalcService implements GNSSCalcService {
|
|||||||
@Override
|
@Override
|
||||||
public void calSingleDone(String deviceId, Integer tenantId, LocalDateTime resultTime) {
|
public void calSingleDone(String deviceId, Integer tenantId, LocalDateTime resultTime) {
|
||||||
FocusCalculator1 focusCalculator = calculatorMap.get(deviceId);
|
FocusCalculator1 focusCalculator = calculatorMap.get(deviceId);
|
||||||
|
if(focusCalculator == null) return;
|
||||||
// 1.检查b562有效数,如果过少,产生告警
|
// 1.检查b562有效数,如果过少,产生告警
|
||||||
warningService.checkB562Num(deviceId, tenantId,
|
warningService.checkB562Num(deviceId, tenantId,
|
||||||
focusCalculator.getB562Stat());
|
focusCalculator.getB562Stat());
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class D31xConfigAckMessageExecutor implements Executor<D31xConfigAckMessa
|
|||||||
if(device == null) return null;
|
if(device == null) return null;
|
||||||
message.setTenantId(device.getTenantId());
|
message.setTenantId(device.getTenantId());
|
||||||
// 转发应答
|
// 转发应答
|
||||||
beidouClient.onConfigAck(message.getId(), ByteUtil.bytesToHexString(message.getSrcData()));
|
beidouClient.onConfigAck(message.getId(), device.getTenantId(), ByteUtil.bytesToHexString(message.getSrcData()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.imdroid.sideslope.executor;
|
package com.imdroid.sideslope.executor;
|
||||||
|
|
||||||
import com.imdroid.secapi.client.BeidouClient;
|
import com.imdroid.secapi.client.BeidouClient;
|
||||||
|
import com.imdroid.secapi.dto.GnssStatus;
|
||||||
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
||||||
import com.imdroid.sideslope.sal.DeviceService;
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
import com.imdroid.sideslope.sal.Device;
|
import com.imdroid.sideslope.sal.Device;
|
||||||
@ -33,15 +34,23 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
message.setTenantId(device.getTenantId());
|
message.setTenantId(device.getTenantId());
|
||||||
|
|
||||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||||
|
GnssStatus lastGnssStatus = dataPersistService.getDeviceState(message.getId());
|
||||||
|
if(lastGnssStatus!=null && lastGnssStatus.getState() == GnssStatus.STATE_OFFLINE){
|
||||||
|
beidouClient.onLine(lastGnssStatus.getDeviceid(), lastGnssStatus.getTenantid(), lastGnssStatus.getUpdatetime());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// 通知beidou服务设备上线
|
||||||
|
beidouClient.onDeviceActive(message.getId(), device.getTenantId());
|
||||||
|
}
|
||||||
dataPersistService.saveDeviceState(message);
|
dataPersistService.saveDeviceState(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 通知beidou服务设备上线
|
|
||||||
beidouClient.onDeviceActive(message.getId());
|
|
||||||
// 存储最新设备状态信息到数据库中
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getMessageType() {
|
public Class<?> getMessageType() {
|
||||||
return D3F0SelfCheckMessage.class;
|
return D3F0SelfCheckMessage.class;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.imdroid.sideslope.executor;
|
package com.imdroid.sideslope.executor;
|
||||||
|
|
||||||
import com.imdroid.secapi.client.BeidouClient;
|
import com.imdroid.secapi.client.BeidouClient;
|
||||||
|
import com.imdroid.sideslope.calc.MultiLineGNSSCalcService;
|
||||||
import com.imdroid.sideslope.message.D3F2StopIndicationMessage;
|
import com.imdroid.sideslope.message.D3F2StopIndicationMessage;
|
||||||
import com.imdroid.sideslope.sal.Device;
|
import com.imdroid.sideslope.sal.Device;
|
||||||
import com.imdroid.sideslope.sal.DeviceService;
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止指示消息处理器
|
* 停止指示消息处理器
|
||||||
@ -26,22 +28,29 @@ public class D3F2StopIndicationMessageExecutor implements Executor<D3F2StopIndic
|
|||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private BeidouClient beidouClient;
|
private BeidouClient beidouClient;
|
||||||
|
@Autowired
|
||||||
|
MultiLineGNSSCalcService multiLineGNSSCalcService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void execute(D3F2StopIndicationMessage message) {
|
public Void execute(D3F2StopIndicationMessage message) {
|
||||||
// 补齐tenantId
|
// 补齐tenantId
|
||||||
Device device = deviceService.findByDeviceId(message.getId());
|
String deviceId = message.getId();
|
||||||
|
Device device = deviceService.findByDeviceId(deviceId);
|
||||||
if(device == null) return null;
|
if(device == null) return null;
|
||||||
message.setTenantId(device.getTenantId());
|
message.setTenantId(device.getTenantId());
|
||||||
|
|
||||||
|
LocalDateTime uploadTime = multiLineGNSSCalcService.getUploadTime(device.getDeviceId());
|
||||||
|
|
||||||
// 储设备收发字节数统计信息
|
// 储设备收发字节数统计信息
|
||||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||||
dataPersistService.saveDeviceTrxStat(message);
|
dataPersistService.saveDeviceTrxStat(message, (uploadTime!=null));
|
||||||
});
|
});
|
||||||
|
|
||||||
// 通知beidou服务设备休眠
|
// 通知beidou服务设备休眠
|
||||||
beidouClient.onDeviceStop(message.getId());
|
beidouClient.onDeviceStop(deviceId,device.getTenantId());
|
||||||
|
if(uploadTime!=null){
|
||||||
|
beidouClient.onGnssUpload(deviceId,device.getTenantId(),uploadTime);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.imdroid.sideslope.service;
|
package com.imdroid.sideslope.service;
|
||||||
|
|
||||||
|
import com.imdroid.secapi.dto.GnssStatus;
|
||||||
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
||||||
import com.imdroid.sideslope.message.D3F2StopIndicationMessage;
|
import com.imdroid.sideslope.message.D3F2StopIndicationMessage;
|
||||||
|
|
||||||
@ -13,8 +14,10 @@ import com.imdroid.sideslope.message.D3F2StopIndicationMessage;
|
|||||||
*/
|
*/
|
||||||
public interface DataPersistService {
|
public interface DataPersistService {
|
||||||
|
|
||||||
|
GnssStatus getDeviceState(String deviceId);
|
||||||
|
void updateDeviceState(GnssStatus gnssStatus);
|
||||||
void saveDeviceState(D3F0SelfCheckMessage d3F0SelfCheckMessage);
|
void saveDeviceState(D3F0SelfCheckMessage d3F0SelfCheckMessage);
|
||||||
|
|
||||||
void saveDeviceTrxStat(D3F2StopIndicationMessage d3F2StopIndicationMessage);
|
void saveDeviceTrxStat(D3F2StopIndicationMessage d3F2StopIndicationMessage,boolean isUploading);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,16 @@ public class DataPersistServiceImpl implements DataPersistService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
WarningService warningService;
|
WarningService warningService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GnssStatus getDeviceState(String deviceId)
|
||||||
|
{
|
||||||
|
return deviceStateRepository.getByDeviceId(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDeviceState(GnssStatus gnssStatus){
|
||||||
|
deviceStateRepository.updateById(gnssStatus);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void saveDeviceState(D3F0SelfCheckMessage message) {
|
public void saveDeviceState(D3F0SelfCheckMessage message) {
|
||||||
try {
|
try {
|
||||||
@ -72,7 +82,7 @@ public class DataPersistServiceImpl implements DataPersistService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveDeviceTrxStat(D3F2StopIndicationMessage message) {
|
public void saveDeviceTrxStat(D3F2StopIndicationMessage message, boolean isUploading) {
|
||||||
try {
|
try {
|
||||||
// 添加到trxmsg里
|
// 添加到trxmsg里
|
||||||
GnssTrxMsg trxMsg = message.getTrxMsg();
|
GnssTrxMsg trxMsg = message.getTrxMsg();
|
||||||
@ -90,7 +100,7 @@ public class DataPersistServiceImpl implements DataPersistService {
|
|||||||
deviceState.setRxbytes(rxbytes);
|
deviceState.setRxbytes(rxbytes);
|
||||||
deviceState.setD3xxbytes(d3xxbytes);
|
deviceState.setD3xxbytes(d3xxbytes);
|
||||||
deviceState.setB562bytes(b562bytes);*/
|
deviceState.setB562bytes(b562bytes);*/
|
||||||
deviceState.setState(GnssStatus.STATE_IDLE);
|
deviceState.setState(isUploading?GnssStatus.STATE_UPLOADING:GnssStatus.STATE_IDLE);
|
||||||
deviceStateRepository.updateById(deviceState);
|
deviceStateRepository.updateById(deviceState);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -22,11 +22,13 @@ public class APIController extends BasicController{
|
|||||||
GnssGroupMapper groupMapper;
|
GnssGroupMapper groupMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
GnssMsgMapper msgMapper;
|
GnssMsgMapper msgMapper;
|
||||||
|
@Autowired
|
||||||
|
GnssStatusMapper gnssStatusMapper;
|
||||||
|
|
||||||
/****** config ack *******/
|
/****** config ack *******/
|
||||||
@PostMapping(value = "/api/config_ack")
|
@PostMapping(value = "/api/config_ack")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String onConfigAck(String deviceId, String configAck) {
|
public String onConfigAck(String deviceId, Integer tenantId, String configAck) {
|
||||||
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
||||||
if(device == null) return null;
|
if(device == null) return null;
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ public class APIController extends BasicController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
saveMsg(deviceId, device.getTenantid(),msgType, configAck);
|
saveMsg(deviceId, tenantId,msgType, configAck);
|
||||||
|
|
||||||
// 命令行显示
|
// 命令行显示
|
||||||
String rxInfo = "RX "+ dateFormat.format(System.currentTimeMillis())+
|
String rxInfo = "RX "+ dateFormat.format(System.currentTimeMillis())+
|
||||||
@ -59,10 +61,40 @@ public class APIController extends BasicController{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****** device active *******/
|
||||||
|
@PostMapping(value = "/api/device_online")
|
||||||
|
@ResponseBody
|
||||||
|
public String onLine(String deviceId, Integer tenantId, LocalDateTime lastOnlineTime) {
|
||||||
|
|
||||||
|
onDeviceActive(deviceId,tenantId);
|
||||||
|
|
||||||
|
// 检查上次是否离线,如果是则启动补传
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
Short len = 15;
|
||||||
|
String uploadCmd = "D31A" + HexUtil.Short2HexString(len) +
|
||||||
|
HexUtil.Int2HexString(Integer.parseInt(deviceId)) +
|
||||||
|
"0F"
|
||||||
|
+ HexUtil.Byte2HexString((byte) (lastOnlineTime.getYear() - 2000))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (lastOnlineTime.getMonthValue()))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (lastOnlineTime.getDayOfMonth()))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (lastOnlineTime.getHour()))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (lastOnlineTime.getMinute()))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (now.getYear() - 2000))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (now.getMonthValue()))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (now.getDayOfMonth()))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (now.getHour()))
|
||||||
|
+ HexUtil.Byte2HexString((byte) (now.getMinute()));
|
||||||
|
rtcmClient.config(deviceId, uploadCmd);
|
||||||
|
// 保存
|
||||||
|
saveMsg(deviceId, tenantId,0xD31A, uploadCmd);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/****** device active *******/
|
/****** device active *******/
|
||||||
@PostMapping(value = "/api/device_active")
|
@PostMapping(value = "/api/device_active")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String onDeviceActive(String deviceId) {
|
public String onDeviceActive(String deviceId, Integer tenantId) {
|
||||||
|
|
||||||
// 检查有没有待配置的参数
|
// 检查有没有待配置的参数
|
||||||
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
||||||
@ -73,7 +105,7 @@ public class APIController extends BasicController{
|
|||||||
if(config != null){
|
if(config != null){
|
||||||
rtcmClient.config(deviceId, config);
|
rtcmClient.config(deviceId, config);
|
||||||
// 保存
|
// 保存
|
||||||
saveMsg(deviceId, device.getTenantid(),0xd311, config);
|
saveMsg(deviceId, tenantId,0xd311, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,11 +116,33 @@ public class APIController extends BasicController{
|
|||||||
/****** device stop *******/
|
/****** device stop *******/
|
||||||
@PostMapping(value = "/api/device_stop")
|
@PostMapping(value = "/api/device_stop")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String onDeviceStop(String deviceId) {
|
public String onDeviceStop(String deviceId, Integer tenantId) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****** gnss upload *******/
|
||||||
|
@PostMapping(value = "/api/gnss_upload")
|
||||||
|
@ResponseBody
|
||||||
|
public String onGnssUpload(String deviceId, Integer tenantId,LocalDateTime uploadTime) {
|
||||||
|
saveMsg(deviceId, tenantId,0xd342, "gnss data upload from "+uploadTime);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/api/gnss_upload_pause")
|
||||||
|
@ResponseBody
|
||||||
|
public String onGnssUploadPause(String deviceId, Integer tenantId) {
|
||||||
|
saveMsg(deviceId, tenantId,0xd342, "gnss data upload pause");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/api/gnss_upload_complete")
|
||||||
|
@ResponseBody
|
||||||
|
public String onGnssUploadComplete(String deviceId, Integer tenantId) {
|
||||||
|
saveMsg(deviceId, tenantId,0xd342, "gnss data upload completely");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
void saveMsg(String deviceId, int tenantId, int msgType, String content){
|
void saveMsg(String deviceId, int tenantId, int msgType, String content){
|
||||||
GnssMsg gnssMsg = new GnssMsg();
|
GnssMsg gnssMsg = new GnssMsg();
|
||||||
gnssMsg.setCreatetime(LocalDateTime.now());
|
gnssMsg.setCreatetime(LocalDateTime.now());
|
||||||
|
|||||||
@ -133,6 +133,8 @@
|
|||||||
<span class="layui-badge layui-bg-gray">掉线</span>
|
<span class="layui-badge layui-bg-gray">掉线</span>
|
||||||
{{# } else if(d.state == 1){ }}
|
{{# } else if(d.state == 1){ }}
|
||||||
<span class="layui-badge layui-bg-green">工作</span>
|
<span class="layui-badge layui-bg-green">工作</span>
|
||||||
|
{{# } else if(d.state == 3){ }}
|
||||||
|
<span class="layui-badge layui-bg-orange">补传</span>
|
||||||
{{# } else { }}
|
{{# } else { }}
|
||||||
<span class="layui-badge layui-bg-blue">休眠</span>
|
<span class="layui-badge layui-bg-blue">休眠</span>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user