feature/simcards_checker #2

Merged
admin merged 5 commits from feature/simcards_checker into develop 2025-06-03 08:29:08 +00:00
Showing only changes of commit b011289fdf - Show all commits

View File

@ -30,6 +30,8 @@ public class APIController extends BasicController{
DeviceCacheCmdMapper cacheCmdMapper;
@Autowired
WarningMsgMapper warningMsgMapper;
@Autowired
GnssStatusMapper gnssStatusMapper;
/****** config ack *******/
@PostMapping(value = "/api/config_ack")
@ -151,6 +153,7 @@ public class APIController extends BasicController{
// 保存
saveMsg(deviceId, tenantId,0xD312, uploadCmd, true);
return null;
}
@ -189,10 +192,8 @@ public class APIController extends BasicController{
// 保存
saveMsg(deviceId, tenantId,cacheCmd.getMsgtype(), cacheCmd.getCmd(), true);
}
// 检查iccid
// 设备上线后检查是否需要重新查询更新 ICCID
checkAndAskICCID(device);
return null;
}
@ -244,16 +245,27 @@ public class APIController extends BasicController{
msgMapper.insert(gnssMsg);
}
void checkAndAskICCID(GnssDevice device){
if(device.getIccid() == null || device.getIccid().trim().isEmpty()) {
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);
void checkAndAskICCID(GnssDevice device) {
GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceid());
// 1. 检查设备是否有 ICCID记录 初始化
// 2. 检查设备是否从离线恢复 防止更换 SIM
// 3. 如果两种情况都不满足则不查询 ICCID
boolean isDeviceReconnecting = status != null && status.getState() == GnssStatus.STATE_OFFLINE;
boolean isIccidEmpty = device.getIccid() == null || device.getIccid().trim().isEmpty();
if (!isDeviceReconnecting && !isIccidEmpty) {
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);
}
void updateICCID(GnssDevice device, String dtuAck) {
// 只检查 "ICCID:" 的十六进制部分
@ -262,7 +274,6 @@ public class APIController extends BasicController{
}
String content = HexUtil.HexString2String(dtuAck);
if(content.contains("+ICCID:")){
//System.out.println(content);
String iccid = content.substring(content.indexOf("+ICCID:") + 8).trim();
iccid = iccid.split("\r\n")[0].trim();
device.setIccid(iccid);