| | |
| | | package org.sxkj.fw.cockpit.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.sxkj.common.utils.HeaderUtils; |
| | | import org.sxkj.fw.area.entity.FwDefenseSceneEntity; |
| | | import org.sxkj.fw.area.param.FwAreaDivideListParam; |
| | | import org.sxkj.fw.area.service.IFwAreaDivideService; |
| | | import org.sxkj.fw.area.service.IFwDefenseSceneService; |
| | | import org.sxkj.fw.area.service.IFwDefenseSceneManageService; |
| | | import org.sxkj.fw.area.vo.FwAreaDivideVO; |
| | | import org.sxkj.fw.area.vo.FwDefenseSceneManageVO; |
| | | import org.sxkj.fw.cockpit.service.ICockpitService; |
| | | import org.sxkj.fw.cockpit.vo.AlarmStatisticsVO; |
| | | import org.sxkj.fw.cockpit.vo.DeviceStatisticsVO; |
| | | import org.sxkj.fw.cockpit.vo.SceneManageStatisticsVO; |
| | | import org.sxkj.fw.common.FwBaseInfo; |
| | | import org.sxkj.fw.detection.entity.FwEffectEvalEntity; |
| | | import org.sxkj.fw.detection.param.FwEffectEvalParam; |
| | | import org.sxkj.fw.detection.service.IFwEffectEvalService; |
| | |
| | | import org.sxkj.fw.record.entity.FwDroneAlarmRecordEntity; |
| | | import org.sxkj.fw.record.service.IFwDroneAlarmRecordService; |
| | | import org.sxkj.fw.record.vo.FwDroneAlarmRecordVO; |
| | | import org.sxkj.system.cache.RegionCache; |
| | | import org.sxkj.system.cache.SysCache; |
| | | import org.sxkj.system.entity.Dept; |
| | | import org.sxkj.system.entity.Region; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | |
| | | @Service |
| | | public class CockpitServiceImpl implements ICockpitService { |
| | | |
| | | @Resource |
| | | private IFwDroneAlarmRecordService fwDroneAlarmRecordService; |
| | | private IFwDroneAlarmRecordService fwDroneAlarmRecordService; |
| | | |
| | | @Resource |
| | | private IFwDeviceService fwDeviceService; |
| | | private IFwDeviceService fwDeviceService; |
| | | |
| | | @Resource |
| | | private IFwEffectEvalService fwEffectEvalService; |
| | | private IFwEffectEvalService fwEffectEvalService; |
| | | |
| | | @Resource |
| | | private IFwAreaDivideService iFwAreaDivideService; |
| | | |
| | | @Resource |
| | | private IFwDefenseSceneManageService iFwDefenseSceneManageService; |
| | | |
| | | @Resource |
| | | private IFwDefenseSceneService iFwDefenseSceneService; |
| | | |
| | | @Override |
| | | public IPage<FwDroneAlarmRecordVO> selectFwDroneAlarmRecordPage(IPage<FwDroneAlarmRecordVO> page, FwDroneAlarmRecordDTO fwDroneAlarmRecord) { |
| | |
| | | |
| | | @Override |
| | | public IPage<CockpitFwDeviceVO> selectCockpitDevicePage(IPage<CockpitFwDeviceVO> page, FwDeviceDTO fwDevice) { |
| | | return fwDeviceService.selectCockpitDevicePage(page, fwDevice); |
| | | Dept dept = SysCache.getDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | Region byCode = RegionCache.getByCode(dept.getAreaCode()); |
| | | fwDevice.setRegionCode(HeaderUtils.formatAreaCode(byCode.getCode())); |
| | | fwDevice.setCurrentDeptId(AuthUtil.getDeptId()); |
| | | IPage<CockpitFwDeviceVO> cockpitFwDeviceVOIPage = fwDeviceService.selectCockpitDevicePage(page, fwDevice); |
| | | return cockpitFwDeviceVOIPage; |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceStatisticsVO> statisticalDeviceType() { |
| | | return fwDeviceService.statisticalDeviceType(); |
| | | Dept dept = SysCache.getDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | Region byCode = RegionCache.getByCode(dept.getAreaCode()); |
| | | return fwDeviceService.statisticalDeviceType(HeaderUtils.formatAreaCode(byCode.getCode()), AuthUtil.getDeptId()); |
| | | } |
| | | |
| | | @Override |
| | | public boolean interferenceAndExpulsion(FwEffectEvalParam fwEffectEvalParam) { |
| | | // 告警记录 |
| | | FwDroneAlarmRecordEntity alarmRecordEntity = fwDroneAlarmRecordService.getById(fwEffectEvalParam.getAlarmRecordId()); |
| | | // 设备信息 |
| | | FwDeviceEntity device = fwDeviceService.getById(alarmRecordEntity.getDeviceId()); |
| | | FwEffectEvalEntity fwEffectEvalEntity = new FwEffectEvalEntity(); |
| | | // 反制效果 |
| | | FwEffectEvalEntity one = fwEffectEvalService.getOne(Wrappers.<FwEffectEvalEntity>lambdaQuery().eq(FwEffectEvalEntity::getAlarmRecordId, fwEffectEvalParam.getAlarmRecordId())); |
| | | FwEffectEvalEntity fwEffectEvalEntity = Optional.ofNullable(one) |
| | | .orElse(new FwEffectEvalEntity()); |
| | | |
| | | // 告警记录相关字段 |
| | | fwEffectEvalEntity.setAlarmRecordId(fwEffectEvalParam.getAlarmRecordId()); |
| | |
| | | |
| | | // 从参数获取反制方式,否则使用告警记录中的值 |
| | | fwEffectEvalEntity.setCounterWay(fwEffectEvalParam.getCounterWay()); |
| | | |
| | | alarmRecordEntity.setCounterWay(fwEffectEvalParam.getCounterWay()); |
| | | // 设备相关字段 |
| | | fwEffectEvalEntity.setDeviceId(alarmRecordEntity.getDeviceId()); |
| | | fwEffectEvalEntity.setDeviceSn(device.getDeviceSn()); |
| | |
| | | fwEffectEvalEntity.setAreaCode(device.getAreaCode()); |
| | | |
| | | // 反制效果及工作模式(从参数获取,否则使用默认值) |
| | | fwEffectEvalEntity.setCounterEffect( "1"); // 1.success/2.fail |
| | | fwEffectEvalEntity.setCounterEffect("1"); // 1.success/2.fail |
| | | fwEffectEvalEntity.setCoverRadiusM(2500); // 覆盖范围(米) |
| | | fwEffectEvalEntity.setWorkMode( "1"); // 1.机动/2.固定 |
| | | |
| | | fwEffectEvalEntity.setWorkMode("1"); // 1.机动/2.固定 |
| | | fwDroneAlarmRecordService.updateById(alarmRecordEntity); |
| | | return fwEffectEvalService.saveOrUpdate(fwEffectEvalEntity); |
| | | } |
| | | |
| | | @Override |
| | | public AlarmStatisticsVO statisticsAlarmsAndDeviceRecords() { |
| | | Dept dept = SysCache.getDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | Region byCode = RegionCache.getByCode(dept.getAreaCode()); |
| | | String regionCode = HeaderUtils.formatAreaCode(byCode.getCode()); |
| | | // 设备统计 |
| | | AlarmStatisticsVO alarmStatisticsVO = fwDeviceService.statisticalDeviceAtt(); |
| | | AlarmStatisticsVO alarmStatisticsVO = fwDeviceService.statisticalDeviceAtt(regionCode, AuthUtil.getDeptId()); |
| | | // 告警统计 |
| | | AlarmStatisticsVO alarmStatistics = fwDroneAlarmRecordService.alarmTypeStatistics(); |
| | | AlarmStatisticsVO alarmStatistics = fwDroneAlarmRecordService.alarmTypeStatistics(regionCode, AuthUtil.getDeptId()); |
| | | alarmStatisticsVO.setHistoryAlarmCount(alarmStatistics.getHistoryAlarmCount()); |
| | | alarmStatisticsVO.setRealTimeAlarmCount(alarmStatistics.getRealTimeAlarmCount()); |
| | | return alarmStatisticsVO; |
| | | } |
| | | |
| | | /** |
| | | * @param effectiveRangeKmIsNotNull |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DeviceStatisticsVO> getDeviceOutStatistics(String effectiveRangeKmIsNotNull) { |
| | | FwDeviceDTO fwDeviceDTO = new FwDeviceDTO(); |
| | | Dept dept = SysCache.getDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | Region byCode = RegionCache.getByCode(dept.getAreaCode()); |
| | | fwDeviceDTO.setCurrentDeptId(AuthUtil.getDeptId()); |
| | | fwDeviceDTO.setRegionCode(HeaderUtils.formatAreaCode(byCode.getCode())); |
| | | return fwDeviceService.getDeviceStatistics(fwDeviceDTO); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param filterTime |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<FwDefenseSceneManageVO> selectFwDefenseSceneManageList(Date filterTime) { |
| | | return iFwDefenseSceneManageService.selectFwDefenseSceneManageList(filterTime); |
| | | } |
| | | |
| | | @Override |
| | | public SceneManageStatisticsVO statisticsSceneManageAndArea(Date filterTime) { |
| | | List<FwDefenseSceneManageVO> sceneManageList = iFwDefenseSceneManageService.selectFwDefenseSceneManageCockpitList(buildFwBaseInfo(), filterTime); |
| | | SceneManageStatisticsVO statisticsVO = new SceneManageStatisticsVO(); |
| | | if (sceneManageList == null || sceneManageList.isEmpty()) { |
| | | statisticsVO.setSceneManageCount(0); |
| | | statisticsVO.setAreaCount(0); |
| | | return statisticsVO; |
| | | } |
| | | |
| | | Map<Long, Long> sceneManageSceneMap = new HashMap<>(); |
| | | for (FwDefenseSceneManageVO sceneManage : sceneManageList) { |
| | | if (sceneManage == null || sceneManage.getId() == null) { |
| | | continue; |
| | | } |
| | | sceneManageSceneMap.putIfAbsent(sceneManage.getId(), sceneManage.getDefenseSceneId()); |
| | | } |
| | | statisticsVO.setSceneManageCount(sceneManageSceneMap.size()); |
| | | |
| | | Set<Long> defenseSceneIds = new HashSet<>(); |
| | | for (Long defenseSceneId : sceneManageSceneMap.values()) { |
| | | if (defenseSceneId != null) { |
| | | defenseSceneIds.add(defenseSceneId); |
| | | } |
| | | } |
| | | if (defenseSceneIds.isEmpty()) { |
| | | statisticsVO.setAreaCount(0); |
| | | return statisticsVO; |
| | | } |
| | | |
| | | List<FwDefenseSceneEntity> defenseScenes = iFwDefenseSceneService.listByIds(defenseSceneIds); |
| | | Map<Long, Integer> sceneAreaCountMap = new HashMap<>(); |
| | | if (defenseScenes != null && !defenseScenes.isEmpty()) { |
| | | for (FwDefenseSceneEntity scene : defenseScenes) { |
| | | if (scene == null || scene.getId() == null) { |
| | | continue; |
| | | } |
| | | sceneAreaCountMap.put(scene.getId(), countAreaDivide(scene.getAreaDivideIds())); |
| | | } |
| | | } |
| | | |
| | | int totalAreaCount = 0; |
| | | for (Long defenseSceneId : sceneManageSceneMap.values()) { |
| | | if (defenseSceneId == null) { |
| | | continue; |
| | | } |
| | | Integer areaCount = sceneAreaCountMap.get(defenseSceneId); |
| | | if (areaCount != null) { |
| | | totalAreaCount += areaCount; |
| | | } |
| | | } |
| | | statisticsVO.setAreaCount(totalAreaCount); |
| | | return statisticsVO; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param filterSelected |
| | | * @param sceneId |
| | | * @param areaTypeKeys |
| | | * @param isSetSceneManage |
| | | * @param flyTime |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<FwAreaDivideVO> selectFwAreaDivideList(Integer filterSelected, Long sceneId, String areaTypeKeys, Integer isSetSceneManage, LocalDateTime flyTime) { |
| | | FwAreaDivideListParam fwAreaDivideListParam = new FwAreaDivideListParam(); |
| | | fwAreaDivideListParam.setFilterSelected(filterSelected); |
| | | fwAreaDivideListParam.setSceneId(sceneId); |
| | | fwAreaDivideListParam.setAreaTypeKeys(areaTypeKeys); |
| | | fwAreaDivideListParam.setIsSetSceneManage(isSetSceneManage); |
| | | fwAreaDivideListParam.setFlyTime(flyTime); |
| | | // 解析区域类型键值列表 |
| | | fwAreaDivideListParam.setAreaTypeKeyList(Func.toStrList(areaTypeKeys)); |
| | | Dept dept = SysCache.getDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | Region byCode = RegionCache.getByCode(dept.getAreaCode()); |
| | | fwAreaDivideListParam.setCurrentDeptId(AuthUtil.getDeptId()); |
| | | fwAreaDivideListParam.setRegionCode(HeaderUtils.formatAreaCode(byCode.getCode())); |
| | | return iFwAreaDivideService.selectFwAreaDivideList(fwAreaDivideListParam); |
| | | } |
| | | |
| | | /** |
| | | * 构建当前部门与区域信息 |
| | | * |
| | | * @return 基础信息 |
| | | */ |
| | | private FwBaseInfo buildFwBaseInfo() { |
| | | FwBaseInfo fwBaseInfo = new FwBaseInfo(); |
| | | Dept dept = SysCache.getDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | Region byCode = RegionCache.getByCode(dept.getAreaCode()); |
| | | fwBaseInfo.setCurrentDeptId(AuthUtil.getDeptId()); |
| | | fwBaseInfo.setRegionCode(HeaderUtils.formatAreaCode(byCode.getCode())); |
| | | return fwBaseInfo; |
| | | } |
| | | |
| | | /** |
| | | * 统计逗号分隔区域ID的数量 |
| | | * |
| | | * @param areaDivideIds 区域ID字符串 |
| | | * @return 区域数量 |
| | | */ |
| | | private int countAreaDivide(String areaDivideIds) { |
| | | if (StringUtil.isBlank(areaDivideIds)) { |
| | | return 0; |
| | | } |
| | | return Func.toLongList(areaDivideIds).size(); |
| | | } |
| | | } |