1、修改ICCID获取的bug

2、增加参数一致性检查的接口
This commit is contained in:
weidong 2025-03-29 23:47:55 +08:00
parent ca793492b5
commit 9b4f7f434c
5 changed files with 37 additions and 33 deletions

View File

@ -20,7 +20,8 @@ public interface BeidouClient {
@PostMapping("/device_active")
String onDeviceActive(@RequestParam(name = "deviceId") String deviceId,
@RequestParam(name = "tenantId") Integer tenantId);
@RequestParam(name = "tenantId") Integer tenantId,
@RequestParam(name = "lastOnlineTime") LocalDateTime lastOnlineTime);
@PostMapping("/device_stop")
String onDeviceStop(@RequestParam(name = "deviceId") String deviceId,

View File

@ -109,7 +109,7 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
ThreadManager.getFixedThreadPool().submit(() -> {
// 通知上线
try {
beidouClient.onDeviceActive(deviceBs.getDeviceId(), deviceBs.getTenantId());
beidouClient.onDeviceActive(deviceBs.getDeviceId(), deviceBs.getTenantId(),lastCycleDevice.getLastRxTime());
} catch (Exception e) {
logger.error(e.toString());
}

View File

@ -64,7 +64,7 @@ public class D341LocationMessageExecutor implements Executor<D341LocationMessage
ThreadManager.getFixedThreadPool().submit(() -> {
// 通知上线
try {
beidouClient.onDeviceActive(device.getDeviceId(), device.getTenantId());
beidouClient.onDeviceActive(device.getDeviceId(), device.getTenantId(),lastCycleDevice.getLastRxTime());
} catch (Exception e) {
}

View File

@ -41,8 +41,6 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
@Autowired
private DataPersistService dataPersistService;
@Autowired
private GnssDeviceMapper gnssDeviceMapper;
@Autowired
GnssMsgMapper msgMapper;
@Autowired
@ -68,8 +66,6 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
device.updateRx(message.getHeader(),message.getLen(),1);
ThreadManager.getFixedThreadPool().submit(() -> {
// 检查是否需要更新设备的 ICCID
checkAndAskICCID(device);
// 检查是否需要对设备的F9P进行冷启动操作
if(device.getDeviceType() == Device.DEVICE_ROVER){
if(device.getModel() == GnssDevice.MODEL_G505){
@ -86,7 +82,8 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
beidouClient.onLine(lastGnssStatus.getDeviceid(),
lastGnssStatus.getTenantid(), lastGnssStatus.getUpdatetime());
} else {
beidouClient.onDeviceActive(message.getId(), device.getTenantId());
beidouClient.onDeviceActive(message.getId(), device.getTenantId(),
(lastGnssStatus==null)?null:lastGnssStatus.getUpdatetime());
}
}
catch (Exception e){
@ -183,28 +180,6 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
rtcmClient.config(device.getDeviceId(), sendCmd);
}
void checkAndAskICCID(Device device){
// 如果设备的 ICCID 存在那么就不用发送 "AT+ICCID" 指令
if(device.getIccid() != null && !device.getIccid().trim().isEmpty()){
GnssDevice gnssDevice = gnssDeviceMapper.queryByDeviceId(device.getDeviceId());
if(gnssDevice.getIccid() != null && !gnssDevice.getIccid().trim().isEmpty()){
// 状态和流量查询更新需要 1-2 小时期间 DataPersistService 更新可能不及时
// 若是数据库的设备已经更新了 iccid 将它同步到 DataPersistService 缓存中
device.setIccid(gnssDevice.getIccid());
}
return;
}
String sendCmd = "AT+ICCID";
int msgType = 0xD310 + 10; // DTU
short len = (short) (sendCmd.length() + 5);
sendCmd = Integer.toHexString(msgType) + HexUtil.Short2HexString(len)+
HexUtil.Int2HexString(Integer.parseInt(device.getDeviceId()))+
"01"+HexUtil.String2HexString(sendCmd);
rtcmClient.config(device.getDeviceId(),sendCmd);
// TODO 将这个消息写到 msg 表中
logger.info(sendCmd);
}
private void checkAndResetBTGnss(Device device){
if(device.getNoFixedAndFloatResult()>0 &&device.getAbnormalD341Num()>10){
if(isBaseStationFwd(device)) startBTResetTask(device);

View File

@ -14,6 +14,7 @@ import java.time.LocalDateTime;
@Controller
public class APIController extends BasicController{
final String getWorkCycleCmd = "d3120005009034D301";
SimpleDateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
@Autowired
RtcmClient rtcmClient;
@ -46,6 +47,9 @@ public class APIController extends BasicController{
deviceMapper.updateById(device);
}
}
else if(msgType == 0xd312){
// 一致性检查
}
// 保存, debug 01 02上来的原始数据不保存
if(msgType != 0xd313 || configAck.length()<100) {
@ -80,7 +84,7 @@ public class APIController extends BasicController{
@PostMapping(value = "/api/device_online")
@ResponseBody
public String onLine(String deviceId, Integer tenantId, LocalDateTime lastOnlineTime) {
onDeviceActive(deviceId,tenantId);
onDeviceActive(deviceId,tenantId,lastOnlineTime);
// 检查是否自动补传
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
@ -114,11 +118,13 @@ public class APIController extends BasicController{
/****** device active *******/
@PostMapping(value = "/api/device_active")
@ResponseBody
public String onDeviceActive(String deviceId, Integer tenantId) {
public String onDeviceActive(String deviceId, Integer tenantId, LocalDateTime lastOnlineTime) {
// 检查有没有待配置的参数
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
if(device!=null && !device.getSyn()){
if(device == null) return null;
if(!device.getSyn()){
GnssGroup gnssGroup = groupMapper.selectById(device.getGroup_id());
if(gnssGroup != null){
String config = gnssGroup.getConfigCmd(device);
@ -145,9 +151,31 @@ public class APIController extends BasicController{
saveMsg(deviceId, tenantId,cacheCmd.getMsgtype(), cacheCmd.getCmd(), true);
}
// 检查参数一致性
if(lastOnlineTime!=null){
if(lastOnlineTime.isBefore(LocalDateTime.now().minusMinutes(50))){
rtcmClient.config(deviceId, getWorkCycleCmd);
}
}
// 检查iccid
checkAndAskICCID(device);
return null;
}
void checkAndAskICCID(GnssDevice device){
if(device.getIccid() == null) {
String sendCmd = "AT+ICCID";
int msgType = 0xD310 + 10; // DTU
short len = (short) (sendCmd.length() + 5);
sendCmd = Integer.toHexString(msgType) + HexUtil.Short2HexString(len) +
HexUtil.Int2HexString(Integer.parseInt(device.getDeviceid())) +
"01" + HexUtil.String2HexString(sendCmd);
rtcmClient.config(device.getDeviceid(), sendCmd);
}
}
/****** device stop *******/
@PostMapping(value = "/api/device_stop")
@ResponseBody