|
@ -3,6 +3,7 @@ package org.dromara.business.service.impl; |
|
|
import cn.hutool.core.collection.ListUtil; |
|
|
import cn.hutool.core.collection.ListUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
import org.dromara.business.domain.BusinessAlert; |
|
|
import org.dromara.business.domain.BusinessAlert; |
|
|
import org.dromara.business.domain.bo.BusinessAlertBo; |
|
|
import org.dromara.business.domain.bo.BusinessAlertBo; |
|
@ -12,6 +13,7 @@ import org.dromara.business.mapper.BusinessAlertMapper; |
|
|
import org.dromara.business.service.IBusinessAlertService; |
|
|
import org.dromara.business.service.IBusinessAlertService; |
|
|
import org.dromara.business.service.IBusinessAlertStatisticsService; |
|
|
import org.dromara.business.service.IBusinessAlertStatisticsService; |
|
|
import org.dromara.common.core.exception.ServiceException; |
|
|
import org.dromara.common.core.exception.ServiceException; |
|
|
|
|
|
import org.dromara.common.mybatis.enums.DataScopeType; |
|
|
import org.dromara.common.redis.utils.RedisUtils; |
|
|
import org.dromara.common.redis.utils.RedisUtils; |
|
|
import org.dromara.common.satoken.utils.LoginHelper; |
|
|
import org.dromara.common.satoken.utils.LoginHelper; |
|
|
import org.dromara.system.api.RemoteDataScopeService; |
|
|
import org.dromara.system.api.RemoteDataScopeService; |
|
@ -44,6 +46,7 @@ import static org.dromara.common.core.constant.Constants.FLY_COUNT; |
|
|
* |
|
|
* |
|
|
*预警统计Service业务层处理 |
|
|
*预警统计Service业务层处理 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
@Service |
|
|
@Service |
|
|
public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatisticsService { |
|
|
public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatisticsService { |
|
@ -186,57 +189,58 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist |
|
|
//----------------------------------------------获取飞行总架次、总时长----------------------------------------------
|
|
|
//----------------------------------------------获取飞行总架次、总时长----------------------------------------------
|
|
|
//获取飞行总架次、总时长
|
|
|
//获取飞行总架次、总时长
|
|
|
//获取机场信息根据当前登录人
|
|
|
//获取机场信息根据当前登录人
|
|
|
List<String> deviceSnList = ObjectUtil.isNotEmpty(feignDeviceGroup.listDevice(LoginHelper.getUserId()))?feignDeviceGroup.listDevice(LoginHelper.getUserId()):ListUtil.empty(); |
|
|
// List<String> deviceSnList = ObjectUtil.isNotEmpty(feignDeviceGroup.listDevice(LoginHelper.getUserId()))?feignDeviceGroup.listDevice(LoginHelper.getUserId()):ListUtil.empty();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//过滤redis中用户所拥有的设备
|
|
|
//过滤redis中用户所拥有的设备
|
|
|
Map<String, Object> countMap = Optional.ofNullable(RedisUtils.getCacheMap(FLY_COUNT)) |
|
|
// Map<String, Object> countMap = Optional.ofNullable(RedisUtils.getCacheMap(FLY_COUNT))
|
|
|
.map(map -> map.entrySet().stream() |
|
|
// .map(map -> map.entrySet().stream()
|
|
|
.filter(entry -> deviceSnList.contains(entry.getKey())) |
|
|
// .filter(entry -> deviceSnList.contains(entry.getKey()))
|
|
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) |
|
|
// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)))
|
|
|
.orElse(new HashMap<>()); |
|
|
// .orElse(new HashMap<>());
|
|
|
|
|
|
|
|
|
int flyCount; |
|
|
// int flyCount;
|
|
|
|
|
|
//
|
|
|
if (ObjectUtil.isNotEmpty(countMap)){ |
|
|
// if (ObjectUtil.isNotEmpty(countMap)){
|
|
|
flyCount = countMap.values().stream() |
|
|
// flyCount = countMap.values().stream()
|
|
|
.filter(Objects::nonNull) |
|
|
// .filter(Objects::nonNull)
|
|
|
.mapToInt(value -> { |
|
|
// .mapToInt(value -> {
|
|
|
if (value instanceof Number) { |
|
|
// if (value instanceof Number) {
|
|
|
return ((Number) value).intValue(); |
|
|
// return ((Number) value).intValue();
|
|
|
} |
|
|
// }
|
|
|
return 0; |
|
|
// return 0;
|
|
|
}) |
|
|
// })
|
|
|
.sum(); |
|
|
// .sum();
|
|
|
} else { |
|
|
// } else {
|
|
|
flyCount = 0; |
|
|
// flyCount = 0;
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
//过滤redis中用户所拥有的设备
|
|
|
//过滤redis中用户所拥有的设备
|
|
|
Map<String, Object> accTimeMap = Optional.ofNullable(RedisUtils.getCacheMap(FLY_ACC_TIME)) |
|
|
// Map<String, Object> accTimeMap = Optional.ofNullable(RedisUtils.getCacheMap(FLY_ACC_TIME))
|
|
|
.map(map -> map.entrySet().stream() |
|
|
// .map(map -> map.entrySet().stream()
|
|
|
.filter(entry -> deviceSnList.contains(entry.getKey())) |
|
|
// .filter(entry -> deviceSnList.contains(entry.getKey()))
|
|
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) |
|
|
// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)))
|
|
|
.orElse(new HashMap<>()); |
|
|
// .orElse(new HashMap<>());
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
double flyAccTime; |
|
|
// double flyAccTime;
|
|
|
|
|
|
//
|
|
|
if (ObjectUtil.isNotEmpty(accTimeMap)) { |
|
|
// if (ObjectUtil.isNotEmpty(accTimeMap)) {
|
|
|
flyAccTime = accTimeMap.values().stream() |
|
|
// flyAccTime = accTimeMap.values().stream()
|
|
|
.filter(Objects::nonNull) |
|
|
// .filter(Objects::nonNull)
|
|
|
.mapToDouble(value -> { |
|
|
// .mapToDouble(value -> {
|
|
|
if (value instanceof Number) { |
|
|
// if (value instanceof Number) {
|
|
|
return ((Number) value).doubleValue(); |
|
|
// return ((Number) value).doubleValue();
|
|
|
} |
|
|
// }
|
|
|
return 0.0; |
|
|
// return 0.0;
|
|
|
}) |
|
|
// })
|
|
|
.sum(); |
|
|
// .sum();
|
|
|
} else { |
|
|
// } else {
|
|
|
flyAccTime = 0.0; |
|
|
// flyAccTime = 0.0;
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
//----------------------------------------------获取飞行总架次、总时长----------------------------------------------
|
|
|
//----------------------------------------------获取飞行总架次、总时长----------------------------------------------
|
|
|
|
|
|
Map<String, Integer> devices = feignDeviceGroup.getDevices(); |
|
|
|
|
|
|
|
|
Map<String, Object> panel = baseMapper.countPanelAlert(businessAlertBo); |
|
|
Map<String, Object> panel = baseMapper.countPanelAlert(businessAlertBo); |
|
|
|
|
|
|
|
@ -245,8 +249,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist |
|
|
ObjectUtil.isEmpty(panel.get("total"))?0:panel.get("total"), |
|
|
ObjectUtil.isEmpty(panel.get("total"))?0:panel.get("total"), |
|
|
ObjectUtil.isEmpty(panel.get("finishCount"))?0:panel.get("finishCount"), |
|
|
ObjectUtil.isEmpty(panel.get("finishCount"))?0:panel.get("finishCount"), |
|
|
ObjectUtil.isEmpty(panel.get("cancelCount"))?0:panel.get("cancelCount"), |
|
|
ObjectUtil.isEmpty(panel.get("cancelCount"))?0:panel.get("cancelCount"), |
|
|
flyCount, |
|
|
ObjectUtil.isEmpty(devices.get("flyCount"))?0:devices.get("flyCount"), |
|
|
flyAccTime); |
|
|
ObjectUtil.isEmpty(devices.get("flyAccTime"))?0:devices.get("flyAccTime")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -774,20 +778,37 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void createPermissions(BusinessAlertBo businessAlertBo) { |
|
|
private void createPermissions(BusinessAlertBo businessAlertBo) { |
|
|
Long roleId = Optional.ofNullable(LoginHelper.getLoginUser()) |
|
|
try { |
|
|
.map(LoginUser::getRoles) |
|
|
RoleDTO roleDTO = LoginHelper.getLoginUser().getRoles().getFirst(); |
|
|
.filter(roles -> !roles.isEmpty()) |
|
|
|
|
|
.map(List::getFirst) |
|
|
//自定义权限
|
|
|
.map(RoleDTO::getRoleId) |
|
|
if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.CUSTOM.getCode())){ |
|
|
.orElse(null); |
|
|
String roleCustom = remoteDataScopeService.getRoleCustom(roleDTO.getRoleId()); |
|
|
|
|
|
if (roleCustom.equalsIgnoreCase("-1")){ |
|
|
String roleCustom = remoteDataScopeService.getRoleCustom(roleId); |
|
|
businessAlertBo.setDeptIdList(ListUtil.empty()); |
|
|
if (roleCustom.equalsIgnoreCase("-1")){ |
|
|
}else { |
|
|
|
|
|
businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) |
|
|
|
|
|
.map(Long::parseLong) |
|
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.DEPT_AND_CHILD.getCode())) { |
|
|
|
|
|
//部门及其以下
|
|
|
|
|
|
String deptAndChild = remoteDataScopeService.getDeptAndChild(LoginHelper.getDeptId()); |
|
|
|
|
|
if (deptAndChild.equalsIgnoreCase("-1")){ |
|
|
|
|
|
businessAlertBo.setDeptIdList(ListUtil.empty()); |
|
|
|
|
|
}else { |
|
|
|
|
|
businessAlertBo.setDeptIdList(Arrays.stream(deptAndChild.split(",")) |
|
|
|
|
|
.map(Long::parseLong) |
|
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.DEPT.getCode())) { |
|
|
|
|
|
//本部门
|
|
|
|
|
|
businessAlertBo.setDeptIdList(List.of(LoginHelper.getDeptId())); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
businessAlertBo.setDeptIdList(ListUtil.empty()); |
|
|
businessAlertBo.setDeptIdList(ListUtil.empty()); |
|
|
}else { |
|
|
log.error(e.getMessage(),e); |
|
|
businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) |
|
|
|
|
|
.map(Long::parseLong) |
|
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|