1.冀北终端在线率代码提交
This commit is contained in:
@@ -27,6 +27,9 @@ public class DevDetail {
|
|||||||
@ApiModelProperty("供电公司")
|
@ApiModelProperty("供电公司")
|
||||||
private String gdName;
|
private String gdName;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属部门")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
@ApiModelProperty("变电站名称")
|
@ApiModelProperty("变电站名称")
|
||||||
private String bdzName;
|
private String bdzName;
|
||||||
|
|
||||||
@@ -37,9 +40,15 @@ public class DevDetail {
|
|||||||
@ApiModelProperty("终端等级")
|
@ApiModelProperty("终端等级")
|
||||||
private String lineGrade;
|
private String lineGrade;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端厂商")
|
||||||
|
private String manufacturer;
|
||||||
|
|
||||||
@ApiModelProperty("通讯状态(0:中断;1:正常)")
|
@ApiModelProperty("通讯状态(0:中断;1:正常)")
|
||||||
private Integer comFlag;
|
private Integer comFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("运行状态(0:运行;1:检修;2:停运;3:调试;4:退运)")
|
||||||
|
private Integer runFlag;
|
||||||
|
|
||||||
@ApiModelProperty("定检时间")
|
@ApiModelProperty("定检时间")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDate nextTimeCheck;
|
private LocalDate nextTimeCheck;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.njcn.device.pq.pojo.vo;
|
package com.njcn.device.pq.pojo.vo;
|
||||||
|
|
||||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.njcn.device.pq.pojo.vo.common;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description
|
||||||
|
* @date 2025/11/26 11:00
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeviceOnlineRate {
|
||||||
|
|
||||||
|
@ApiModelProperty("总终端数量")
|
||||||
|
private Integer totalNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("低于90终端数据")
|
||||||
|
private Integer belowNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("总终端在线率")
|
||||||
|
private String totalOnlineRate;
|
||||||
|
|
||||||
|
@ApiModelProperty("统计信息")
|
||||||
|
List<CitDetail> citDetailList;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class CitDetail {
|
||||||
|
|
||||||
|
@ApiModelProperty("地市")
|
||||||
|
private String citName;
|
||||||
|
|
||||||
|
@ApiModelProperty("总终端数量")
|
||||||
|
private Integer citTotalNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("低于90终端数据")
|
||||||
|
private Integer citBelowNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("总终端在线率")
|
||||||
|
private String citTotalOnlineRate;
|
||||||
|
|
||||||
|
@ApiModelProperty("统计信息")
|
||||||
|
List<?> detailList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
|
||||||
|
@ApiModelProperty("地市")
|
||||||
|
private String cit;
|
||||||
|
|
||||||
|
@ApiModelProperty("供电公司")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@ApiModelProperty("变电站")
|
||||||
|
private String subStation;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端ID")
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端名称")
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端厂家")
|
||||||
|
private String manufacturer;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端IP")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端运行状态")
|
||||||
|
private Integer runFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端运行状态")
|
||||||
|
private Integer comFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("在线率")
|
||||||
|
private String onlineRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.njcn.device.common.mapper.onlinerate;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.device.pq.pojo.param.OnlineRateParam;
|
||||||
|
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
|
||||||
|
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 在线率日表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2023-03-28
|
||||||
|
*/
|
||||||
|
public interface OnLineRateMapper extends BaseMapper<RStatOnlinerateD> {
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 获取设备在线率
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-04-03 10:10
|
||||||
|
* @param param
|
||||||
|
* @return List<OnlineRate>
|
||||||
|
*/
|
||||||
|
List<RStatOnlinerateVO> getOnlineRateByDevIds(@Param("param") OnlineRateParam param);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.device.common.mapper.onlinerate.OnLineRateMapper">
|
||||||
|
<select id="getOnlineRateByDevIds" resultType="com.njcn.device.pq.pojo.vo.RStatOnlinerateVO">
|
||||||
|
select
|
||||||
|
dev_index,
|
||||||
|
sum(online_min) as onlineMin,
|
||||||
|
sum(offline_min) as offlineMin,
|
||||||
|
ROUND( sum(online_min)*1.0/(sum(online_min) + sum(offline_min))*100,2) as onlineRate
|
||||||
|
from r_stat_onlinerate_d
|
||||||
|
<where>
|
||||||
|
<if test="param!=null and param.ids != null and param.ids.size > 0">
|
||||||
|
AND dev_index IN
|
||||||
|
<foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test=" param.startTime != null and param.startTime !=''">
|
||||||
|
AND time_id >= #{param.startTime}
|
||||||
|
</if>
|
||||||
|
<if test="param.endTime != null and param.endTime != ''">
|
||||||
|
AND time_id <= #{param.endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
group by dev_index ;
|
||||||
|
</select>
|
||||||
|
<select id="getTotalOnlineRates" resultType="java.lang.Float">
|
||||||
|
select
|
||||||
|
if( sum( online_min )/( sum( online_min ) + sum( offline_min ))* 100 > 100,
|
||||||
|
100,
|
||||||
|
IFNULL( ROUND( sum( online_min )/( sum( online_min ) + sum( offline_min ))* 100, 2 ), 0 ))
|
||||||
|
as online_rate
|
||||||
|
from r_stat_onlinerate_d
|
||||||
|
<where>
|
||||||
|
<if test="param!=null and param.ids != null and param.ids.size > 0">
|
||||||
|
AND dev_index IN
|
||||||
|
<foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test=" param.startTime != null and param.startTime !=''">
|
||||||
|
AND time_id >= #{param.startTime}
|
||||||
|
</if>
|
||||||
|
<if test="param.endTime != null and param.endTime != ''">
|
||||||
|
AND time_id <= #{param.endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -34,6 +34,7 @@ import com.njcn.system.pojo.enums.StatisticsEnum;
|
|||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.user.api.DeptFeignClient;
|
import com.njcn.user.api.DeptFeignClient;
|
||||||
import com.njcn.user.pojo.dto.DeptDTO;
|
import com.njcn.user.pojo.dto.DeptDTO;
|
||||||
|
import com.njcn.user.pojo.po.Dept;
|
||||||
import com.njcn.web.utils.WebUtil;
|
import com.njcn.web.utils.WebUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -796,12 +797,25 @@ public class GeneralDeviceService {
|
|||||||
List<DictData> gradeType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_GRADE.getCode()).getData();
|
List<DictData> gradeType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_GRADE.getCode()).getData();
|
||||||
Map<String, Integer> gradeMap = gradeType.stream().collect(Collectors.toMap(DictData::getId, DictData::getAlgoDescribe));
|
Map<String, Integer> gradeMap = gradeType.stream().collect(Collectors.toMap(DictData::getId, DictData::getAlgoDescribe));
|
||||||
|
|
||||||
|
List<DictData> manufacturerList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_MANUFACTURER.getCode()).getData();
|
||||||
|
Map<String, String> manufacturerMap = manufacturerList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
|
||||||
|
|
||||||
|
List<Dept> deptList = deptFeignClient.getAllDept().getData();
|
||||||
|
Map<String, String> deptMap = deptList.stream().collect(Collectors.toMap(Dept::getId, Dept::getName));
|
||||||
List<DevDetail> devDetails = deviceMapper.selectDevByIds(devIds);
|
List<DevDetail> devDetails = deviceMapper.selectDevByIds(devIds);
|
||||||
for (DevDetail devDetail : devDetails) {
|
for (DevDetail devDetail : devDetails) {
|
||||||
//终端等级
|
//终端等级
|
||||||
if(gradeMap.containsKey(devDetail.getLineGrade())){
|
if(gradeMap.containsKey(devDetail.getLineGrade())){
|
||||||
devDetail.setLineGrade(String.valueOf(gradeMap.get(devDetail.getLineGrade())));
|
devDetail.setLineGrade(String.valueOf(gradeMap.get(devDetail.getLineGrade())));
|
||||||
}
|
}
|
||||||
|
//部门
|
||||||
|
if(deptMap.containsKey(devDetail.getDeptName())){
|
||||||
|
devDetail.setDeptName(deptMap.get(devDetail.getDeptName()));
|
||||||
|
}
|
||||||
|
//终端厂商
|
||||||
|
if(manufacturerMap.containsKey(devDetail.getManufacturer())){
|
||||||
|
devDetail.setManufacturer(manufacturerMap.get(devDetail.getManufacturer()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return devDetails;
|
return devDetails;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.njcn.device.device.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.device.device.service.OnLineRateService;
|
||||||
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.common.DeviceOnlineRate;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 终端在线率
|
||||||
|
* @Author: wr
|
||||||
|
* @Date: 2025/11/26 10:28
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "终端在线率")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/onLineRate")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class OnLineRateController extends BaseController {
|
||||||
|
|
||||||
|
private final OnLineRateService onLineRateService;
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/deviceOnlineRateInfo")
|
||||||
|
@ApiOperation("终端在线率列表(冀北)")
|
||||||
|
public HttpResult<DeviceOnlineRate> deviceOnlineRateInfo(@RequestBody DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("deviceOnlineRateInfo");
|
||||||
|
DeviceOnlineRate rate = onLineRateService.deviceOnlineRateInfo(deviceInfoParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rate, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -229,6 +229,7 @@
|
|||||||
<select id="selectDevByIds" resultType="com.njcn.device.pq.pojo.vo.DevDetail">
|
<select id="selectDevByIds" resultType="com.njcn.device.pq.pojo.vo.DevDetail">
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
device.id as devIndex,
|
device.id as devIndex,
|
||||||
|
pd.Id as deptName,
|
||||||
gd.NAME as gdName,
|
gd.NAME as gdName,
|
||||||
substation.NAME as bdzName,
|
substation.NAME as bdzName,
|
||||||
device.NAME as devName,
|
device.NAME as devName,
|
||||||
@@ -236,9 +237,12 @@
|
|||||||
deviceDetail.Update_Time AS timeID,
|
deviceDetail.Update_Time AS timeID,
|
||||||
deviceDetail.ip as ip,
|
deviceDetail.ip as ip,
|
||||||
deviceDetail.Com_Flag as comFlag,
|
deviceDetail.Com_Flag as comFlag,
|
||||||
|
deviceDetail.run_Flag as runFlag,
|
||||||
|
deviceDetail.Manufacturer as manufacturer,
|
||||||
deviceDetail.Next_Time_Check as nextTimeCheck
|
deviceDetail.Next_Time_Check as nextTimeCheck
|
||||||
FROM
|
FROM
|
||||||
pq_line line,
|
pq_line line,
|
||||||
|
pq_dept_line pd,
|
||||||
pq_line voltage,
|
pq_line voltage,
|
||||||
pq_line device,
|
pq_line device,
|
||||||
pq_line substation,
|
pq_line substation,
|
||||||
@@ -253,6 +257,7 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
AND line.pid = voltage.id
|
AND line.pid = voltage.id
|
||||||
|
AND line.id = pd.Line_Id
|
||||||
AND voltage.pid = device.id
|
AND voltage.pid = device.id
|
||||||
AND device.pid = substation.id
|
AND device.pid = substation.id
|
||||||
AND substation.pid = gd.id
|
AND substation.pid = gd.id
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.njcn.device.device.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.common.DeviceOnlineRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 终端在线率
|
||||||
|
* @Author: wr
|
||||||
|
* @Date: 2025/11/26 10:27
|
||||||
|
*/
|
||||||
|
public interface OnLineRateService {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端详情列表
|
||||||
|
* @param deviceInfoParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
DeviceOnlineRate deviceOnlineRateInfo(DeviceInfoParam.BusinessParam deviceInfoParam);
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package com.njcn.device.device.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.device.common.service.GeneralDeviceService;
|
||||||
|
import com.njcn.device.device.service.OnLineRateService;
|
||||||
|
import com.njcn.device.common.mapper.onlinerate.OnLineRateMapper;
|
||||||
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||||
|
import com.njcn.device.pq.pojo.param.OnlineRateParam;
|
||||||
|
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
|
||||||
|
import com.njcn.device.pq.pojo.vo.DevDetail;
|
||||||
|
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
|
||||||
|
import com.njcn.device.pq.pojo.vo.common.DeviceOnlineRate;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description
|
||||||
|
* @date 2025/11/26 10:26
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class OnLineRateServiceImpl extends ServiceImpl<OnLineRateMapper, RStatOnlinerateD> implements OnLineRateService {
|
||||||
|
|
||||||
|
private final GeneralDeviceService deviceService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceOnlineRate deviceOnlineRateInfo(DeviceInfoParam.BusinessParam param) {
|
||||||
|
DeviceOnlineRate rate = new DeviceOnlineRate();
|
||||||
|
//获取终端台账类信息
|
||||||
|
List<GeneralDeviceDTO> deviceInfo = deviceService.getDeviceInfo(param, null, Arrays.asList(1));
|
||||||
|
if (CollUtil.isNotEmpty(deviceInfo)) {
|
||||||
|
List<String> deviceIds = deviceInfo.stream()
|
||||||
|
.flatMap(x -> x.getDeviceIndexes().stream()).collect(Collectors.toList())
|
||||||
|
.stream()
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
rate.setTotalNum(deviceIds.size());
|
||||||
|
OnlineRateParam onlineRateParam = new OnlineRateParam();
|
||||||
|
onlineRateParam.setIds(deviceIds);
|
||||||
|
onlineRateParam.setStartTime(param.getSearchBeginTime());
|
||||||
|
onlineRateParam.setEndTime(param.getSearchEndTime());
|
||||||
|
//获取所有终端在线率
|
||||||
|
List<RStatOnlinerateVO> onlineRateByDev = this.baseMapper.getOnlineRateByDevIds(onlineRateParam);
|
||||||
|
|
||||||
|
//获取所有终端信息
|
||||||
|
List<DevDetail> devInfoByIds = deviceService.getDevInfoByIds(deviceIds);
|
||||||
|
rate.setBelowNum(CollUtil.isNotEmpty(onlineRateByDev)?calculateOnLineRate(onlineRateByDev,90):deviceIds.size());
|
||||||
|
rate.setTotalOnlineRate(calculateOnLineRate(onlineRateByDev,deviceIds));
|
||||||
|
List<DeviceOnlineRate.CitDetail> citDetailList=new ArrayList<>();
|
||||||
|
DeviceOnlineRate.CitDetail citDetail;
|
||||||
|
DeviceOnlineRate.Detail detail;
|
||||||
|
for (GeneralDeviceDTO dto : deviceInfo) {
|
||||||
|
//获取部门终端集合
|
||||||
|
List<RStatOnlinerateVO> citDevOnRate = onlineRateByDev.stream().filter(x -> dto.getDeviceIndexes().contains(x.getDevIndex())).collect(Collectors.toList());
|
||||||
|
Map<String, Float> onlineRateByDevMap = citDevOnRate.stream()
|
||||||
|
.collect(Collectors.toMap(RStatOnlinerateVO::getDevIndex, RStatOnlinerateVO::getOnlineRate));
|
||||||
|
citDetail=new DeviceOnlineRate.CitDetail();
|
||||||
|
citDetail.setCitName(dto.getName());
|
||||||
|
citDetail.setCitTotalNum(dto.getDeviceIndexes().size());
|
||||||
|
citDetail.setCitBelowNum(CollUtil.isNotEmpty(citDevOnRate)?calculateOnLineRate(onlineRateByDev,90):dto.getDeviceIndexes().size());
|
||||||
|
citDetail.setCitTotalOnlineRate(calculateOnLineRate(onlineRateByDev,dto.getDeviceIndexes()));
|
||||||
|
List<DeviceOnlineRate.Detail> detailList = new ArrayList<>();
|
||||||
|
List<DevDetail> details = devInfoByIds.stream().filter(x -> dto.getDeviceIndexes().contains(x.getDevIndex())).collect(Collectors.toList());
|
||||||
|
for (DevDetail dev : details) {
|
||||||
|
detail=new DeviceOnlineRate.Detail();
|
||||||
|
detail.setCit(dev.getDeptName());
|
||||||
|
detail.setCompany(dev.getGdName());
|
||||||
|
detail.setSubStation(dev.getBdzName());
|
||||||
|
detail.setDeviceId(dev.getDevIndex());
|
||||||
|
detail.setDeviceName(dev.getDevName());
|
||||||
|
detail.setManufacturer(dev.getManufacturer());
|
||||||
|
detail.setIp(dev.getIp());
|
||||||
|
detail.setRunFlag(dev.getRunFlag());
|
||||||
|
detail.setComFlag(dev.getComFlag());
|
||||||
|
detail.setOnlineRate(onlineRateByDevMap.containsKey(dev.getDevIndex())?onlineRateByDevMap.get(dev.getDevIndex()).toString():"0");
|
||||||
|
detailList.add(detail);
|
||||||
|
}
|
||||||
|
citDetail.setDetailList(detailList);
|
||||||
|
citDetailList.add(citDetail);
|
||||||
|
}
|
||||||
|
rate.setCitDetailList(citDetailList);
|
||||||
|
}
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String calculateOnLineRate(List<RStatOnlinerateVO> onlineRateByDev ,List<String> deviceIds){
|
||||||
|
List<RStatOnlinerateVO> list = onlineRateByDev.stream().filter(x -> deviceIds.contains(x.getDevIndex())).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(list)){
|
||||||
|
BigDecimal onlineMin = BigDecimal.valueOf(list.stream().mapToLong(RStatOnlinerateVO::getOnlineMin).sum());
|
||||||
|
BigDecimal offlineMin =BigDecimal.valueOf( list.stream().mapToLong(RStatOnlinerateVO::getOfflineMin).sum());
|
||||||
|
BigDecimal sumMin= onlineMin.add(offlineMin);
|
||||||
|
return onlineMin.divide(sumMin,2).toString();
|
||||||
|
}
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer calculateOnLineRate(List<RStatOnlinerateVO> onlineRateByDev,Integer limit){
|
||||||
|
return onlineRateByDev.stream().filter(x -> x.getOnlineRate() < limit).collect(Collectors.toList()).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user