|
@@ -1,14 +1,18 @@
|
|
|
package com.ozs.service.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.ozs.common.constant.Constants;
|
|
|
+import com.ozs.common.core.domain.AjaxResult;
|
|
|
import com.ozs.service.entity.BaseCameraManagement;
|
|
|
+import com.ozs.service.entity.BaseRailwayManagement;
|
|
|
import com.ozs.service.entity.MsgAlarm;
|
|
|
import com.ozs.service.entity.vo.*;
|
|
|
import com.ozs.service.mapper.BaseCameraManagementMapper;
|
|
|
+import com.ozs.service.mapper.BaseRailwayManagementMapper;
|
|
|
import com.ozs.service.mapper.MsgAlarmMapper;
|
|
|
import com.ozs.service.service.MsgAlarmService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -17,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -38,6 +43,9 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
|
|
|
private BaseCameraManagementMapper baseCameraManagementMapper;
|
|
|
@Autowired
|
|
|
private RedisService redisService;
|
|
|
+ @Autowired
|
|
|
+ private BaseRailwayManagementMapper baseRailwayManagementMapper;
|
|
|
+
|
|
|
|
|
|
public IPage listToPage(List list, int pageNum, int pageSize) {
|
|
|
List pageList = new ArrayList<>();
|
|
@@ -225,4 +233,56 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
|
|
|
BaseCameraManagement baseCameraManagement = baseCameraManagementMapper.selectOne(queryWrapper);
|
|
|
return baseCameraManagement;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult alarmStatistics() {
|
|
|
+ int count;
|
|
|
+ int unresolvedCount;
|
|
|
+ //找出所有报警数据
|
|
|
+ List<MsgAlarm> list = this.list();
|
|
|
+ //未解除的报警
|
|
|
+ List<MsgAlarm> alarmList = this.list(new LambdaQueryWrapper<MsgAlarm>()
|
|
|
+ .eq(MsgAlarm::getIsLock, 1));
|
|
|
+ HashMap<String, Integer> map = new HashMap<>();
|
|
|
+ if (!ObjectUtils.isEmpty(list)) {
|
|
|
+ //获取所有报警的相机编码
|
|
|
+ //找出所有报警数据 1=高铁的数量
|
|
|
+ count = (int) list.stream()
|
|
|
+ .map(base -> baseCameraManagementMapper.selectOne(new LambdaQueryWrapper<BaseCameraManagement>()
|
|
|
+ .eq(BaseCameraManagement::getCameraCode, base)))
|
|
|
+ .filter(Objects::nonNull) // 确保 management 不是 null
|
|
|
+ .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
|
|
|
+ .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
|
|
|
+ .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
|
|
|
+ .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
|
|
|
+ .count();
|
|
|
+ //普铁的数量
|
|
|
+ int pu = list.size() - count;
|
|
|
+ map.put("highAlarmCount", count);
|
|
|
+ map.put("puAlarmCount", pu);
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(alarmList)) {
|
|
|
+ //获取所有报警的相机编码
|
|
|
+ //找出所有已解除报警数据 1=高铁的数量
|
|
|
+ unresolvedCount = (int) alarmList.stream()
|
|
|
+ .map(base -> baseCameraManagementMapper.selectOne(new LambdaQueryWrapper<BaseCameraManagement>()
|
|
|
+ .eq(BaseCameraManagement::getCameraCode, base)))
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
|
|
|
+ .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
|
|
|
+ .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
|
|
|
+ .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
|
|
|
+ .count();
|
|
|
+ //普铁的数量
|
|
|
+ int puUnresolvedCount = alarmList.size() - unresolvedCount;
|
|
|
+ map.put("highUnresolvedCount", unresolvedCount);
|
|
|
+ map.put("puUnresolvedCount", puUnresolvedCount);
|
|
|
+ }
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult alarmCountSort() {
|
|
|
+ return AjaxResult.success(baseCameraManagementMapper.alarmCountSort());
|
|
|
+ }
|
|
|
}
|