Commit 7b7662e1 by 谢海旭

【ID1016906】 bug修复:离线报警排除假性离线

1 parent c6564672
......@@ -574,7 +574,10 @@ public class RiskAssessmentService {
}
// 查询离线警情
getOffLinePoint(snList, alarmInfoList, snDeviceNameMap);
AlarmTimeLinePointVo offlinePointVo = getOffLinePoint(snList, snDeviceNameMap);
if (Objects.nonNull(offlinePointVo) && !falseOffline(vehicle.getVin())) {
alarmInfoList.add(offlinePointVo);
}
// 查询警情研判:多种警情
List<AlarmWarnAnalyse> alarmWarnAnalyseList = alarmWarnAnalyseMapper.selectLatestAlarmOfEachType(vehicleId);
......@@ -621,6 +624,41 @@ public class RiskAssessmentService {
}
/**
* 通过车架号判断车辆是否是假性离线
* 假性离线有三种情况
*
* @param vin 车架号
* @return true是假性离线 false不是假性离线
*/
private boolean falseOffline(String vin) {
boolean result = false;
List<String> vinList = Lists.newArrayList(vin);
// 一 获取设备都离线 最后定位点在家庭围栏或者工作地围栏 获取车架通过权限控制 当存在设备都离线的车辆时才进行计算
List<String> fakeOfflineVinList = fakeOfflineVinMapper.getFakeOfflineVinByFence(vinList);
if (CollectionUtils.isNotEmpty(fakeOfflineVinList)) {
result = Boolean.TRUE;
}
// 二 十日内状态反复变化 假性离线
List<FakeOfflineChangeFrequently> changeFrequentlyList = fakeOfflineChangeFrequentlyMapper.listByVin(vinList);
if (CollectionUtils.isNotEmpty(changeFrequentlyList)) {
result = Boolean.TRUE;
}
// 三 获取本部门以及下级部门的白名单
Set<Long> deptIds = organizationApiService.getAllSubOrgIds();
log.info("isFakeOffline userId:" + ShieldContextHolder.getUserId() + ";deptIds:" + JSONUtil.toJsonStr(deptIds));
// 从白名单列表获取白名单设备号及其车架号
List<String> writeListVinList = whitelistSnMapper.getWriteListVinListAndDeptIds(deptIds, vinList);
// 白名单不为空 并且白名单包括车架号
if (CollectionUtils.isNotEmpty(writeListVinList)) {
result = Boolean.TRUE;
}
return result;
}
/**
* 获取最后检测时间节点
*
* @param alarmInfoList
......@@ -685,18 +723,16 @@ public class RiskAssessmentService {
/**
* 获取离线警情
*
* @param snList
* @param alarmInfoList
* @param snList 车辆设备号集合
*/
private void getOffLinePoint(List<String> snList, List<AlarmTimeLinePointVo> alarmInfoList, Map<String, String> snDeviceNameMap) {
private AlarmTimeLinePointVo getOffLinePoint(List<String> snList, Map<String, String> snDeviceNameMap) {
List<DeviceLocation> deviceLocationList = deviceLocationMapper.findLocationListBySnList(snList);
if (CollectionUtils.isEmpty(deviceLocationList)) {
AlarmTimeLinePointVo pointVo = new AlarmTimeLinePointVo();
pointVo.setAlarmLevel(3);
pointVo.setAlarmType("离线报警");
pointVo.setDevice(snDeviceNameMap.get(snList.get(0)));
alarmInfoList.add(pointVo);
return;
return pointVo;
}
// 是否离线判断 前三天时间范围内存在上报记录则不算离线
......@@ -704,12 +740,12 @@ public class RiskAssessmentService {
Date date = DateUtils.addDays(new Date(), -3);
Date lastGpsTime = location.getLastGpsTime();
if (Objects.nonNull(lastGpsTime) && lastGpsTime.compareTo(date) > 0) {
return;
return null;
}
Date lastBsTime = location.getLastBsTime();
if (Objects.nonNull(lastBsTime) && lastBsTime.compareTo(date) > 0) {
return;
return null;
}
}
......@@ -739,8 +775,7 @@ public class RiskAssessmentService {
pointVo.setAlarmType("离线报警");
String sn = deviceLocationList.get(0).getSn();
pointVo.setDevice(snDeviceNameMap.get(sn));
alarmInfoList.add(pointVo);
return;
return pointVo;
}
// 取最近上报时间点
......@@ -763,7 +798,7 @@ public class RiskAssessmentService {
pointVo.setAlarmTime(DateUtil.formatDate(latestTime));
pointVo.setAlarmType("离线报警");
pointVo.setDevice(snDeviceNameMap.get(alarmSn));
alarmInfoList.add(pointVo);
return pointVo;
}
private static List<FinalPositioningExport> customSort(List<FinalPositioningExport> finalPositioningList) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!