From 00634964fe56c428e6a07c146fdef9b0b14bd557 Mon Sep 17 00:00:00 2001 From: weidong Date: Sat, 22 Feb 2025 17:07:42 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=BB=A4=E6=B3=A2=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E8=B7=B3=E5=8F=98=E9=97=A8=E9=99=90=E5=8F=AF=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E6=9A=82=E5=81=9C=E8=87=AA=E5=8A=A8=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/imdroid/secapi/dto/WarningCfg.java | 12 ++- .../sideslope/service/WarningService.java | 1 - .../sideslope/service/WarningServiceImpl.java | 98 ++++++++++++++++++- .../beidou/controller/WarningController.java | 4 + 4 files changed, 107 insertions(+), 8 deletions(-) diff --git a/sec-api/src/main/java/com/imdroid/secapi/dto/WarningCfg.java b/sec-api/src/main/java/com/imdroid/secapi/dto/WarningCfg.java index 375d97a4..a0711628 100644 --- a/sec-api/src/main/java/com/imdroid/secapi/dto/WarningCfg.java +++ b/sec-api/src/main/java/com/imdroid/secapi/dto/WarningCfg.java @@ -42,8 +42,14 @@ public class WarningCfg { public static final String TYPE_NAME_CONT_INVALID_RESULT = "长时间无有效解"; public static final int TYPE_INCLINE = 0x400; public static final String TYPE_NAME_INCLINE = "异常倾斜"; - public static final int TYPE_JUMP = 0x800; - public static final String TYPE_NAME_JUMP = "滤波结果跳变"; + public static final int TYPE_SIM_STATUS_ABNORMAL = 0x800; + public static final String TYPE_NAME_SIM_STATUS_ABNORMAL = "流量卡状态异常"; + public static final int TYPE_SIM_LOW_TRAFFIC = 0x1000; + public static final String TYPE_NAME_SIM_LOW_TRAFFIC = "流量卡流量不足"; + public static final int TYPE_XY_JUMP = 0x2000; + public static final String TYPE_NAME_XY_JUMP = "滤波结果水平跳变"; + public static final int TYPE_Z_JUMP = 0x4000; + public static final String TYPE_NAME_Z_JUMP = "滤波结果高程跳变"; // warning level definition public static final short LEVEL_0 = 0; //正常 @@ -70,6 +76,8 @@ public class WarningCfg { if((code & TYPE_NO_FIXED_RESULT) !=0) warningInfo.add(TYPE_NAME_NO_FIXED_RESULT); if((code & TYPE_CONT_INVALID_RESULT) !=0) warningInfo.add(TYPE_NAME_CONT_INVALID_RESULT); if((code & TYPE_INCLINE) !=0) warningInfo.add(TYPE_NAME_INCLINE); + if((code & TYPE_SIM_STATUS_ABNORMAL) !=0) warningInfo.add(TYPE_NAME_SIM_STATUS_ABNORMAL); + if((code & TYPE_SIM_LOW_TRAFFIC) !=0) warningInfo.add(TYPE_NAME_SIM_LOW_TRAFFIC); return warningInfo; } } diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningService.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningService.java index 63e81d4a..40be0eca 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningService.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningService.java @@ -3,7 +3,6 @@ package com.imdroid.sideslope.service; import com.imdroid.secapi.dto.GnssCalcData; import com.imdroid.secapi.dto.GnssStatus; import com.imdroid.secapi.dto.GnssStatusMsg; -import com.imdroid.secapi.dto.GnssTrxMsg; import com.imdroid.sideslope.sal.Device; public interface WarningService { diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java index d9b3a969..e4f594e3 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java @@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.Duration; import java.time.LocalDateTime; import java.util.List; @@ -259,7 +261,80 @@ public class WarningServiceImpl implements WarningService { } } } +/* + // 检查SIM卡状态 + public void checkSimCardStatus(Device device, SimCard simCard) { + GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceId()); + if (status == null) return; + boolean isUpdated = false; + + // 检查SIM卡状态是否异常(停机、注销、失效) + if (simCard.getStatus() == SimCard.STATUS_SUSPENDED || + simCard.getStatus() == SimCard.STATUS_CANCELLED || + simCard.getStatus() == SimCard.STATUS_INVALID) { + + String statusDesc; + switch(simCard.getStatus()) { + case SimCard.STATUS_SUSPENDED: + statusDesc = "停机"; + break; + case SimCard.STATUS_CANCELLED: + statusDesc = "注销"; + break; + case SimCard.STATUS_INVALID: + statusDesc = "失效"; + break; + default: + statusDesc = "未知状态"; + } + + if (check(status, WarningCfg.TYPE_SIM_STATUS_ABNORMAL, + WarningCfg.TYPE_NAME_SIM_STATUS_ABNORMAL, false, + simCard.getStatus(), null, + "SIM卡状态: " + statusDesc)) { + isUpdated = true; + } + } else if (simCard.getStatus() == SimCard.STATUS_ACTIVATED) { + // 状态正常(已激活),清除告警 + if ((status.getWarningcode() & WarningCfg.TYPE_SIM_STATUS_ABNORMAL) != 0) { + clearWarning(status, WarningCfg.TYPE_SIM_STATUS_ABNORMAL); + isUpdated = true; + } + } + + if (isUpdated) { + status.setWarning(getWarningLevel(status.getWarningcode())); + gnssStatusMapper.updateById(status); + } + } + + public void checkSimCardTraffic(Device device, SimCard simCard) { + GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceId()); + if (status == null) return; + + boolean isUpdated = false; + + BigDecimal usedPercentage = simCard.getUsed() + .divide(simCard.getTotal(), 4, RoundingMode.HALF_UP) + .multiply(BigDecimal.valueOf(100)); + + // 检查流量使用情况 + if (check(status, WarningCfg.TYPE_SIM_LOW_TRAFFIC, + WarningCfg.TYPE_NAME_SIM_LOW_TRAFFIC, + false, // 大于等于流量门限值,那么就报警 + usedPercentage.intValue(), + null, + String.format("流量已使用 %.2f%%", usedPercentage.doubleValue()))) { + isUpdated = true; + } + + if (isUpdated) { + status.setWarning(getWarningLevel(status.getWarningcode())); + gnssStatusMapper.updateById(status); + } + } +*/ public void generate_warning_logs(String device_id,int warning_type,String warning_type_name){ // 连续无固定解 和 掉电 警告 if (warning_type == WarningCfg.TYPE_NO_FIXED_RESULT || warning_type == WarningCfg.TYPE_LOW_VOLTAGE) { @@ -286,9 +361,22 @@ public class WarningServiceImpl implements WarningService { @Override public void checkFilteredResultJump(double[] latestRpos, GnssCalcData locationRecord){ - if(Math.abs(locationRecord.getRpose()-latestRpos[0])>2 || - Math.abs(locationRecord.getRposn()-latestRpos[1])>2 || - Math.abs(locationRecord.getRposd()-latestRpos[2])>4){ + int[] warningValuesXY = cfgMap.get(WarningCfg.TYPE_XY_JUMP); + int[] warningValuesZ = cfgMap.get(WarningCfg.TYPE_Z_JUMP); + int warningCode = 0; + if(warningValuesXY!=null){ + if(Math.abs(locationRecord.getRpose()-latestRpos[0])>warningValuesXY[1] || + Math.abs(locationRecord.getRposn()-latestRpos[1])>warningValuesXY[1]){ + warningCode = WarningCfg.TYPE_XY_JUMP; + } + } + if(warningCode==0 && warningValuesZ!=null){ + if(Math.abs(locationRecord.getRposd()-latestRpos[2])>warningValuesZ[1]){ + warningCode = WarningCfg.TYPE_Z_JUMP; + } + } + + if(warningCode!=0){ // 停止推送 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("deviceid",locationRecord.getDeviceid()); @@ -300,13 +388,13 @@ public class WarningServiceImpl implements WarningService { !unFwdGroupName.equals(device.getFwd_group_id())){ device.setFwd_group_id(unFwdGroupName); device.setFwd_group_id2(unFwdGroupName); - deviceMapper.updateById(device); + //deviceMapper.updateById(device); // 产生告警 WarningMsg warningMsg = new WarningMsg(); warningMsg.setDeviceid(device.getDeviceid()); warningMsg.setTenantid(device.getTenantid()); warningMsg.setCreatetime(LocalDateTime.now()); - warningMsg.setCode(WarningCfg.TYPE_JUMP); + warningMsg.setCode(warningCode); warningMsg.setLevel(WarningCfg.LEVEL_2); double deltaE = locationRecord.getRpose()-latestRpos[0]; double deltaN = locationRecord.getRposn()-latestRpos[1]; diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/WarningController.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/WarningController.java index bc9a36b8..6ed44109 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/controller/WarningController.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/WarningController.java @@ -47,6 +47,10 @@ public class WarningController extends BasicController implements CommonExcelSer warningMap.put(WarningCfg.TYPE_LOW_RSSI, WarningCfg.TYPE_NAME_LOW_RSSI); warningMap.put(WarningCfg.TYPE_RX_MUCH_UNKNOWN, WarningCfg.TYPE_NAME_RX_MUCH_UNKNOWN); warningMap.put(WarningCfg.TYPE_INCLINE, WarningCfg.TYPE_NAME_INCLINE); + warningMap.put(WarningCfg.TYPE_SIM_LOW_TRAFFIC, WarningCfg.TYPE_NAME_SIM_LOW_TRAFFIC); + warningMap.put(WarningCfg.TYPE_SIM_STATUS_ABNORMAL, WarningCfg.TYPE_NAME_SIM_STATUS_ABNORMAL); + warningMap.put(WarningCfg.TYPE_XY_JUMP, WarningCfg.TYPE_NAME_XY_JUMP); + warningMap.put(WarningCfg.TYPE_Z_JUMP, WarningCfg.TYPE_NAME_Z_JUMP); } /**** 推送页面 *****/