修正 SIM 卡状态和流量查询一些 BUG
1. 修正 schema.sql 中 simcards 关于 msisdn 字段的拼写错误 2. 修正前端页面关于时间显示的格式错误 3. 修正 SimCardsMapper 一些函数 4. 调整日志为 Debug 等级
This commit is contained in:
parent
056e1a5e21
commit
cbbf17b247
@ -23,18 +23,19 @@ public interface SimCardsMapper extends MPJBaseMapper<SimCard>{
|
||||
"WHERE deviceid = #{deviceid}")
|
||||
int updateSimCardInfo(SimCard simCard);
|
||||
|
||||
@Update("UPDATE simcards SET " +
|
||||
"updatetime = #{updatetime}, " +
|
||||
"msisdn = #{msisdn}, " +
|
||||
"status = #{status} " +
|
||||
"WHERE deviceid = #{deviceid}")
|
||||
int updateCardStatusInfo(SimCard simCard);
|
||||
|
||||
@Update("UPDATE simcards SET " +
|
||||
"updatetime = #{updatetime}, " +
|
||||
"remaining = #{remaining}, " +
|
||||
"total = #{total}, " +
|
||||
"used = #{used} " +
|
||||
"WHERE deviceid = #{deviceid}")
|
||||
int updateFlowInfo(SimCard simCard);
|
||||
|
||||
@Update("UPDATE simcards SET " +
|
||||
"updatetime = #{updatetime}, " +
|
||||
"status = #{status} " +
|
||||
"WHERE deviceid = #{deviceid}")
|
||||
int updateStatus(SimCard simCard);
|
||||
int updateCardTrafficInfo(SimCard simCard);
|
||||
}
|
||||
|
||||
|
||||
@ -54,11 +54,11 @@ public class SimStatusChecker {
|
||||
//@Scheduled(cron = "0 */10 * * * ?")
|
||||
private void scheduleSimCardStatusCheck() {
|
||||
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
|
||||
logger.info("当前在线设备数量: {}", onlineDevices.size());
|
||||
logger.debug("当前在线设备数量: {}", onlineDevices.size());
|
||||
|
||||
for (GnssStatusJoin onlineDevice : onlineDevices) {
|
||||
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 3600 );
|
||||
logger.info("- 设备: {}, SIM状态查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
//logger.debug("- 设备: {}, SIM状态查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
|
||||
ThreadManager.getScheduledThreadPool().schedule(
|
||||
() -> checkDeviceSimCardStatus(onlineDevice.getDeviceid()),
|
||||
@ -72,11 +72,11 @@ public class SimStatusChecker {
|
||||
@Scheduled(cron = "0 0 0/2 * * ?")
|
||||
private void scheduleSimCardTrafficCheck() {
|
||||
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
|
||||
logger.info("当前在线设备数量: {}", onlineDevices.size());
|
||||
logger.debug("当前在线设备数量: {}", onlineDevices.size());
|
||||
|
||||
for (GnssStatusJoin onlineDevice : onlineDevices) {
|
||||
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 7200);
|
||||
logger.debug("- 设备: {}, SIM流量查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
//logger.debug("- 设备: {}, SIM流量查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
|
||||
ThreadManager.getScheduledThreadPool().schedule(
|
||||
() -> checkDeviceSimCardTraffic(onlineDevice.getDeviceid()),
|
||||
@ -142,7 +142,7 @@ public class SimStatusChecker {
|
||||
simCard.setMsisdn(info.getMsisdn());
|
||||
simCardsMapper.updateSimCardInfo(simCard);
|
||||
|
||||
logger.info("更新SIM卡基本信息 - imsi: {}, msisdn: {}, iccid: {}",
|
||||
logger.debug("更新SIM卡基本信息 - imsi: {}, msisdn: {}, iccid: {}",
|
||||
info.getImsi(), info.getMsisdn(), info.getIccid());
|
||||
} catch (Exception e) {
|
||||
logger.error("更新设备{}的SIM卡基本信息失败: ", device.getDeviceId(), e);
|
||||
@ -158,15 +158,15 @@ public class SimStatusChecker {
|
||||
CardStatusData status = response.getData();
|
||||
simCard.setUpdatetime(new Date());
|
||||
simCard.setStatus(status.getStatusCode());
|
||||
simCardsMapper.updateSimCardInfo(simCard);
|
||||
simCardsMapper.updateCardStatusInfo(simCard);
|
||||
|
||||
warningService.checkSimCardStatus(device, simCard);
|
||||
|
||||
logger.info("更新SIM卡状态 - Code: {}, 描述: {}",
|
||||
logger.debug("更新SIM卡状态 - Code: {}, 描述: {}",
|
||||
status.getStatusCode(), status.getStatusDesc());
|
||||
} catch (Exception e) {
|
||||
logger.error("更新设备{}的SIM卡状态失败: ", device.getDeviceId(), e);
|
||||
throw e;
|
||||
// throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,11 +188,11 @@ public class SimStatusChecker {
|
||||
simCard.setRemaining(BigDecimal.valueOf(usage.getLeft()));
|
||||
simCard.setUsed(BigDecimal.valueOf(usage.getUsed()));
|
||||
simCard.setTotal(BigDecimal.valueOf(usage.getTotal()));
|
||||
simCardsMapper.updateSimCardInfo(simCard);
|
||||
simCardsMapper.updateCardTrafficInfo(simCard);
|
||||
|
||||
warningService.checkSimCardTraffic(device, simCard);
|
||||
|
||||
logger.info("更新流量信息成功 - deviceId: {}, 剩余: {}MB, 总量: {}MB, 已用: {}MB",
|
||||
logger.debug("更新流量信息成功 - deviceId: {}, 剩余: {}MB, 总量: {}MB, 已用: {}MB",
|
||||
device.getIccid(),
|
||||
simCard.getRemaining(),
|
||||
simCard.getTotal(),
|
||||
@ -200,7 +200,7 @@ public class SimStatusChecker {
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("设备{}更新SIM卡流量失败: ", device.getDeviceId(), e);
|
||||
throw e;
|
||||
//throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -353,7 +353,7 @@ CREATE TABLE IF NOT EXISTS `simcards` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增,唯一',
|
||||
`updatetime` DATETIME DEFAULT NULL COMMENT '最新一次查询接口记录的时间',
|
||||
`iccid` VARCHAR(36) NOT NULL COMMENT 'ICCID号,唯一',
|
||||
`msisd` VARCHAR(20) NOT NULL COMMENT '物联卡号码,SIM号,唯一',
|
||||
`msisdn` VARCHAR(20) NOT NULL COMMENT '物联卡号码,SIM号,唯一',
|
||||
`deviceid` VARCHAR(20) DEFAULT NULL COMMENT '设备ID号',
|
||||
`status` TINYINT DEFAULT -1 COMMENT 'SIM卡状态(-1:未知, 1:待激活, 2:已激活, 3:停机, 4:注销, 5:库存, 6:可测试, 7:失效, 99:号码不存在)',
|
||||
`remaining` DECIMAL(10,2) DEFAULT 0.00 COMMENT '剩余流量,单位为MB,保留两位小数',
|
||||
|
||||
@ -191,7 +191,7 @@
|
||||
{field: 'deviceid', title: '设备号'},
|
||||
{field: 'iccid', title: 'ICCID'},
|
||||
{field: 'msisdn', title: 'SIM 卡号'},
|
||||
{field: 'updatetime', title: '更新时间'},
|
||||
{field: 'updatetime', title: '更新时间',templet: "<div>{{layui.util.toDateString(d.updatetime, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
|
||||
{field: 'status', title: '状态',templet: '#statusTpl'},
|
||||
{field: 'remaining', title: '剩余流量(MB)'},
|
||||
{field: 'used', title: '已使用流量(MB)'},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user