Compare commits
5 Commits
ff1351b107
...
62c3c09a6b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62c3c09a6b | ||
|
|
b523a24e5b | ||
|
|
075dfc19d6 | ||
|
|
279c5c7642 | ||
|
|
b0ef851479 |
@@ -55,7 +55,11 @@ public interface Param {
|
||||
//长时间闪变值
|
||||
String pst = "DataFlicker-pst";
|
||||
|
||||
//电压暂降
|
||||
String Voltage_Dip = "r_mp_event_detail-Voltage_Dip";
|
||||
//电压暂升
|
||||
String Voltage_Rise = "r_mp_event_detail-Voltage_Rise";
|
||||
|
||||
String pf = "DataHarmPowerP-pf";
|
||||
|
||||
|
||||
|
||||
@@ -137,6 +137,16 @@ public class PqDataVerifyBak {
|
||||
*/
|
||||
private Integer pst;
|
||||
|
||||
/**
|
||||
* 电压暂降(0:正常 1:异常)
|
||||
*/
|
||||
private Integer dip;
|
||||
|
||||
/**
|
||||
* 电压暂升(0:正常 1:异常)
|
||||
*/
|
||||
private Integer rise;
|
||||
|
||||
/**
|
||||
* 判断所有指标 0:无异常 1:有异常
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,9 @@ public class DevDetail {
|
||||
@ApiModelProperty("供电公司")
|
||||
private String gdName;
|
||||
|
||||
@ApiModelProperty("所属部门")
|
||||
private String deptName;
|
||||
|
||||
@ApiModelProperty("变电站名称")
|
||||
private String bdzName;
|
||||
|
||||
@@ -37,9 +40,15 @@ public class DevDetail {
|
||||
@ApiModelProperty("终端等级")
|
||||
private String lineGrade;
|
||||
|
||||
@ApiModelProperty("终端厂商")
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty("通讯状态(0:中断;1:正常)")
|
||||
private Integer comFlag;
|
||||
|
||||
@ApiModelProperty("运行状态(0:运行;1:检修;2:停运;3:调试;4:退运)")
|
||||
private Integer runFlag;
|
||||
|
||||
@ApiModelProperty("定检时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate nextTimeCheck;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.device.pq.pojo.vo;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import lombok.Data;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,6 +50,8 @@ public class DetailAbnormalVO {
|
||||
private String avg;
|
||||
//CP95
|
||||
private String cp95;
|
||||
//幅值
|
||||
private String featureAmplitude;
|
||||
|
||||
}
|
||||
|
||||
@@ -73,6 +75,7 @@ public class DetailAbnormalVO {
|
||||
//最大
|
||||
private String val;
|
||||
|
||||
|
||||
//限值
|
||||
private float overLimitValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,29 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class JsonBaseVO {
|
||||
|
||||
/**
|
||||
* 超标时间
|
||||
*/
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 异常值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 相别
|
||||
*/
|
||||
private String phasic;
|
||||
|
||||
/**
|
||||
* 数据类型(最大值:max、最小值:min、平均值:avg、95值:cp95)
|
||||
*/
|
||||
private String valueType;
|
||||
|
||||
/**
|
||||
* 限值
|
||||
*/
|
||||
private float overLimitValue;
|
||||
|
||||
}
|
||||
|
||||
@@ -509,6 +509,7 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
|
||||
vo.setVal(valArr[i]);
|
||||
vo.setPhaseType(phasic);
|
||||
vo.setTargetName(StrUtil.isNotBlank(count) ? count + "次" + targetName : targetName);
|
||||
vo.setOverLimitValue(it.getOverLimitValue());
|
||||
result.add(vo);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -244,7 +244,6 @@ public class GridDiagramServiceImpl implements GridDiagramService {
|
||||
public GridDiagramVO getGridDiagramDev(GridDiagramParam param) {
|
||||
//获取电压等级
|
||||
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData();
|
||||
|
||||
List<DictData> v = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.PANORAMIC_VOLTAGE.getCode()).getData();
|
||||
List<String> voltageIds;
|
||||
//获取电压等级550 220 110 35
|
||||
@@ -264,7 +263,6 @@ public class GridDiagramServiceImpl implements GridDiagramService {
|
||||
List<Dept> data = deptFeignClient.getDirectSonSelf(param.getOrgId()).getData();
|
||||
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
||||
deptGetLineParam.setDeptId(param.getOrgId());
|
||||
deptGetLineParam.setLineRunFlag(0);
|
||||
List<DeptGetChildrenMoreDTO> deptGetChildrenMoreDTOS = commTerminalService.deptGetLine(deptGetLineParam);
|
||||
|
||||
|
||||
|
||||
@@ -475,7 +475,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
vo.setTargetKey(targetKey);
|
||||
vo.setPhaseType(phaseKey);
|
||||
|
||||
if ((pqReasonableRangeDto.getInfluxdbTableName() + SEPARATOR + pqReasonableRangeDto.getIndexCode()).equals(targetKey)) {
|
||||
if ((DataCleanEnum.DataI.getCode() + SEPARATOR + DataCleanEnum.RmsI.getCode() ).equals(targetKey)) {
|
||||
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + "*CT1" + unit);
|
||||
} else {
|
||||
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + unit);
|
||||
@@ -493,6 +493,8 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
break;
|
||||
case "CP95":
|
||||
vo.setCp95(ites.getVal());
|
||||
case "Feature_Amplitude":
|
||||
vo.setFeatureAmplitude(ites.getVal());
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -518,7 +520,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
queryWrapper.select("line_id as lineId,sum(freq) as freq,sum(freq_Dev) as freqDev,sum(v_Rms) as vRms,sum(v_Pos) as vPos,sum(v_Neg) as vNeg," +
|
||||
"sum(v_Zero) as vZero,sum(v_Unbalance) as vUnbalance,sum(rms_Lvr) as rmsLvr,sum(vu_Dev) as vuDev,sum(vl_Dev) as vlDev," +
|
||||
"sum(v_Thd) as vThd,sum(v) as v,sum(i_Rms) as iRms,sum(plt) as plt,sum(v_Inharm) as vInharm,sum(v_Harm) as vHarm,sum(pf) as pf," +
|
||||
"sum(v_Phasic) as vPhasic,sum(v1_Phasic) as v1Phasic,sum(fluc) as fluc,sum(pst) as pst,sum(state) as state")
|
||||
"sum(v_Phasic) as vPhasic,sum(v1_Phasic) as v1Phasic,sum(fluc) as fluc,sum(pst) as pst,sum(dip) as dip,sum(rise) as rise,sum(state) as state")
|
||||
.lambda().between(PqDataVerifyBak::getTimeId, DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())), DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())))
|
||||
.in(PqDataVerifyBak::getLineId, monitorIds)
|
||||
.eq(PqDataVerifyBak::getState, 1)
|
||||
@@ -652,6 +654,14 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
ids = dataVerifyList.stream().filter(it -> it.getPf() > 0).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.Voltage_Dip:
|
||||
ids = dataVerifyList.stream().filter(it -> it.getDip() > 0).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.Voltage_Rise:
|
||||
ids = dataVerifyList.stream().filter(it -> it.getRise() > 0).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
default:
|
||||
log.error("未匹配到异常数据指标");
|
||||
break;
|
||||
|
||||
@@ -133,11 +133,6 @@ public class RunManageServiceImpl implements RunManageService {
|
||||
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
|
||||
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
|
||||
deviceInfoParam.setServerName("pqs-common");
|
||||
if(CollUtil.isNotEmpty(runManageParam.getRunFlag())){
|
||||
if(runManageParam.getRunFlag().get(0)==0){
|
||||
deviceInfoParam.setLineRunFlag(0);
|
||||
}
|
||||
}
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
|
||||
if (CollectionUtils.isEmpty(generalDeviceDTOList)) {
|
||||
throw new BusinessException("当前部门没有装置台账");
|
||||
|
||||
@@ -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.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.utils.WebUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -408,7 +409,7 @@ public class GeneralDeviceService {
|
||||
return generalDeviceDTO;
|
||||
}
|
||||
// 提取该部门及其子部门所有监测点id
|
||||
List<String> lineIds = deptLines.stream().map(DeptLine::getLineId).collect(Collectors.toList());
|
||||
List<String> lineIds = deptLines.stream().map(DeptLine::getLineId).distinct().collect(Collectors.toList());
|
||||
// 获取line详细数据 :根据监测点id,获取所有监测点 联查 pq_line、pq_line_detail
|
||||
List<Line> lines = terminalBaseService.getLineByCondition(lineIds, deviceInfoParam);
|
||||
// 返回空数据
|
||||
@@ -417,17 +418,17 @@ public class GeneralDeviceService {
|
||||
}
|
||||
|
||||
//1.筛选出母线id,理论上监测点的pids中第六个id为母线id 联查: pq_line t1 ,pq_voltage t2
|
||||
List<String> voltageIds=lines.stream().map(Line::getPid).collect(Collectors.toList());
|
||||
List<String> voltageIds=lines.stream().map(Line::getPid).distinct().collect(Collectors.toList());
|
||||
//再根据电压等级筛选合法母线信息
|
||||
List<Line> voltages = terminalBaseService.getVoltageByCondition(voltageIds, deviceInfoParam.getScale());
|
||||
|
||||
//2.筛选出终端id,理论上监测点的pids中第五个id为终端id
|
||||
List<String> devIds=voltages.stream().map(Line::getPid).collect(Collectors.toList());
|
||||
List<String> devIds=voltages.stream().map(Line::getPid).distinct().collect(Collectors.toList());
|
||||
// 再根据终端条件筛选合法终端信息 联查:pq_line t1,pq_device t2
|
||||
List<Line> devices = terminalBaseService.getDeviceByCondition(devIds, deviceType, deviceInfoParam.getManufacturer());
|
||||
|
||||
//3.筛选出变电站id,理论上监测点的pids中第四个id为变电站id 联查: pq_line t1 ,pq_substation t2
|
||||
List<String> subIds=devices.stream().map(Line::getPid).collect(Collectors.toList());
|
||||
List<String> subIds=devices.stream().map(Line::getPid).distinct().collect(Collectors.toList());
|
||||
List<Line> sub = terminalBaseService.getSubByCondition(subIds, new ArrayList<>());
|
||||
|
||||
//筛选最终的数据
|
||||
@@ -796,12 +797,25 @@ public class GeneralDeviceService {
|
||||
List<DictData> gradeType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_GRADE.getCode()).getData();
|
||||
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);
|
||||
for (DevDetail devDetail : devDetails) {
|
||||
//终端等级
|
||||
if(gradeMap.containsKey(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;
|
||||
}
|
||||
|
||||
@@ -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 DISTINCT
|
||||
device.id as devIndex,
|
||||
pd.Id as deptName,
|
||||
gd.NAME as gdName,
|
||||
substation.NAME as bdzName,
|
||||
device.NAME as devName,
|
||||
@@ -236,9 +237,12 @@
|
||||
deviceDetail.Update_Time AS timeID,
|
||||
deviceDetail.ip as ip,
|
||||
deviceDetail.Com_Flag as comFlag,
|
||||
deviceDetail.run_Flag as runFlag,
|
||||
deviceDetail.Manufacturer as manufacturer,
|
||||
deviceDetail.Next_Time_Check as nextTimeCheck
|
||||
FROM
|
||||
pq_line line,
|
||||
pq_dept_line pd,
|
||||
pq_line voltage,
|
||||
pq_line device,
|
||||
pq_line substation,
|
||||
@@ -253,6 +257,7 @@
|
||||
</foreach>
|
||||
</if>
|
||||
AND line.pid = voltage.id
|
||||
AND line.id = pd.Line_Id
|
||||
AND voltage.pid = device.id
|
||||
AND device.pid = substation.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