|
|
|
|
@@ -12,19 +12,34 @@ import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
|
|
|
|
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
|
|
|
|
|
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
|
|
|
|
|
import com.njcn.device.pq.pojo.vo.DeviceRunEvaluateVO;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.njcn.device.pq.enums.LineBaseEnum;
|
|
|
|
|
import com.njcn.device.pq.enums.PowerFlagEnum;
|
|
|
|
|
import com.njcn.device.pq.enums.RunFlagEnum;
|
|
|
|
|
import com.njcn.device.pq.mapper.LineMapper;
|
|
|
|
|
import com.njcn.device.pq.pojo.dto.MonitorInfoDTO;
|
|
|
|
|
import com.njcn.device.pq.pojo.vo.TerminalEvaluateAreaVO;
|
|
|
|
|
import com.njcn.device.pq.service.DeviceRunEvaluateService;
|
|
|
|
|
import com.njcn.harmonic.api.RStatLimitRateDClient;
|
|
|
|
|
import com.njcn.harmonic.pojo.param.RStatLimitQueryParam;
|
|
|
|
|
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
|
|
|
|
|
import com.njcn.supervision.api.UserLedgerFeignClient;
|
|
|
|
|
import com.njcn.supervision.pojo.param.user.UserReportParam;
|
|
|
|
|
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author wr
|
|
|
|
|
* @description
|
|
|
|
|
@@ -34,24 +49,26 @@ import java.util.stream.Collectors;
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class DeviceRunEvaluateServiceImpl implements DeviceRunEvaluateService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据完整性:50%
|
|
|
|
|
*/
|
|
|
|
|
private static BigDecimal ONINTEGRITY = new BigDecimal(0.5);
|
|
|
|
|
/**
|
|
|
|
|
* 数据合格率:30%
|
|
|
|
|
*/
|
|
|
|
|
private static BigDecimal ONLINERATE = new BigDecimal(0.2);
|
|
|
|
|
/**
|
|
|
|
|
* 终端在线率:20%
|
|
|
|
|
*/
|
|
|
|
|
private static BigDecimal LIMITRATE = new BigDecimal(0.3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final GeneralDeviceService generalDeviceService;
|
|
|
|
|
private final RStatLimitRateDClient rStatLimitRateDClient;
|
|
|
|
|
private final RStatOnlinerateDMapper onLineRateDMapper;
|
|
|
|
|
private final RStatIntegrityDMapper integrityDMapper;
|
|
|
|
|
private final LineMapper lineMapper;
|
|
|
|
|
private final UserLedgerFeignClient userLedgerFeignClient;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据完整性:50%
|
|
|
|
|
*/
|
|
|
|
|
private static final BigDecimal ONINTEGRITY = new BigDecimal("0.5");
|
|
|
|
|
/**
|
|
|
|
|
* 数据合格率:30%
|
|
|
|
|
*/
|
|
|
|
|
private static final BigDecimal ONLINERATE = new BigDecimal("0.2");
|
|
|
|
|
/**
|
|
|
|
|
* 终端在线率:20%
|
|
|
|
|
*/
|
|
|
|
|
private static final BigDecimal LIMITRATE = new BigDecimal("0.3");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<DeviceRunEvaluateVO> getRunEvaluate(DeviceInfoParam.CompareBusinessParam param) {
|
|
|
|
|
@@ -161,4 +178,109 @@ public class DeviceRunEvaluateServiceImpl implements DeviceRunEvaluateService {
|
|
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TerminalEvaluateAreaVO> areaTerminalStatistic(DeviceInfoParam.BusinessParam businessParam) {
|
|
|
|
|
List<TerminalEvaluateAreaVO> result = new ArrayList<>();
|
|
|
|
|
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(businessParam, Stream.of(RunFlagEnum.RUNNING.getStatus()).collect(Collectors.toList()), Stream.of(PowerFlagEnum.REAL_DEVICE.getCode()).collect(Collectors.toList()));
|
|
|
|
|
if (CollectionUtil.isNotEmpty(generalDeviceDTOList)) {
|
|
|
|
|
if (generalDeviceDTOList.size() == 1 && generalDeviceDTOList.get(0).getIndex().equals(businessParam.getDeptIndex())) {
|
|
|
|
|
List<UserLedgerVO> userLedgerVOList = userLedgerFeignClient.selectUserList(new UserReportParam()).getData();
|
|
|
|
|
Map<String, UserLedgerVO> userReportVOMap = userLedgerVOList.stream().collect(Collectors.toMap(UserLedgerVO::getId, Function.identity()));
|
|
|
|
|
//已经最底层,展示电站和用户场站
|
|
|
|
|
List<MonitorInfoDTO> lineDetailList = lineMapper.getLineListByIds(generalDeviceDTOList.get(0).getLineIndexes());
|
|
|
|
|
List<MonitorInfoDTO> detailList = lineDetailList.stream().filter(it -> StrUtil.isNotBlank(it.getObjId())).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(detailList)) {
|
|
|
|
|
List<String> ids = detailList.stream().map(MonitorInfoDTO::getId).distinct().collect(Collectors.toList());
|
|
|
|
|
List<String> devIds = detailList.stream().map(it->it.getPids().split(StrUtil.COMMA)[LineBaseEnum.DEVICE_LEVEL.getCode()]).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<RStatIntegrityD> rStatIntegrityDList = new ArrayList<>();
|
|
|
|
|
List<RStatOnlinerateD> rStatOnlinerateDList = new ArrayList<>();
|
|
|
|
|
List<RStatLimitRateDPO> rStatLimitRateDPOList = new ArrayList<>();
|
|
|
|
|
getData(rStatIntegrityDList,rStatOnlinerateDList,rStatLimitRateDPOList,ids,devIds,businessParam.getSearchBeginTime(),businessParam.getSearchEndTime());
|
|
|
|
|
Map<String, List<MonitorInfoDTO>> map = detailList.stream().collect(Collectors.groupingBy(MonitorInfoDTO::getObjId));
|
|
|
|
|
map.forEach((objId, list) -> {
|
|
|
|
|
UserLedgerVO userLedgerVO = userReportVOMap.get(objId);
|
|
|
|
|
List<String> lineIds = list.stream().map(MonitorInfoDTO::getId).collect(Collectors.toList());
|
|
|
|
|
List<String> devList = list.stream().map(it->it.getPids().split(StrUtil.COMMA)[LineBaseEnum.DEVICE_LEVEL.getCode()]).collect(Collectors.toList());
|
|
|
|
|
List<RStatIntegrityD> temIntegrityList = rStatIntegrityDList.stream().filter(it->lineIds.contains(it.getLineIndex())).collect(Collectors.toList());
|
|
|
|
|
List<RStatLimitRateDPO> temlimitList = rStatLimitRateDPOList.stream().filter(it->lineIds.contains(it.getLineId())).collect(Collectors.toList());
|
|
|
|
|
List<RStatOnlinerateD> onlineList = rStatOnlinerateDList.stream().filter(it->devList.contains(it.getDevIndex())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
result.add(getScoreData(userLedgerVO.getProjectName(),devList,temIntegrityList,onlineList,temlimitList));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
|
|
|
|
List<RStatIntegrityD> rStatIntegrityDList = new ArrayList<>();
|
|
|
|
|
List<RStatOnlinerateD> rStatOnlinerateDList = new ArrayList<>();
|
|
|
|
|
List<RStatLimitRateDPO> rStatLimitRateDPOList = new ArrayList<>();
|
|
|
|
|
getData(rStatIntegrityDList,rStatOnlinerateDList,rStatLimitRateDPOList,generalDeviceDTO.getLineIndexes(),generalDeviceDTO.getDeviceIndexes(),businessParam.getSearchBeginTime(),businessParam.getSearchEndTime());
|
|
|
|
|
result.add(getScoreData(generalDeviceDTO.getName(),generalDeviceDTO.getDeviceIndexes(),rStatIntegrityDList,rStatOnlinerateDList,rStatLimitRateDPOList));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TerminalEvaluateAreaVO getScoreData(String name,List<String> devIds,List<RStatIntegrityD> rStatIntegrityDList,List<RStatOnlinerateD> rStatOnlinerateDList,List<RStatLimitRateDPO> rStatLimitRateDPOList) {
|
|
|
|
|
double integrityRate = 0;
|
|
|
|
|
double onlineRate = 0;
|
|
|
|
|
double qualifiedRate = 0;
|
|
|
|
|
TerminalEvaluateAreaVO terminalEvaluateAreaVO = new TerminalEvaluateAreaVO();
|
|
|
|
|
terminalEvaluateAreaVO.setName(name);
|
|
|
|
|
terminalEvaluateAreaVO.setCount(devIds.size());
|
|
|
|
|
if (CollectionUtil.isNotEmpty(rStatIntegrityDList)) {
|
|
|
|
|
integrityRate = rStatIntegrityDList.stream().mapToDouble(it -> (double) it.getRealTime() / it.getDueTime()).average().orElse(0);
|
|
|
|
|
terminalEvaluateAreaVO.setIntegrity(NumberUtil.round(integrityRate*100,2).doubleValue());
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(rStatOnlinerateDList)) {
|
|
|
|
|
onlineRate = rStatOnlinerateDList.stream().mapToDouble(it -> (double) it.getOnlineRate() / it.getOnlineRate() + it.getOfflineMin()).average().orElse(0);
|
|
|
|
|
terminalEvaluateAreaVO.setOnline(NumberUtil.round(onlineRate*100,2).doubleValue());
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(rStatLimitRateDPOList)) {
|
|
|
|
|
qualifiedRate = rStatLimitRateDPOList.stream().mapToDouble(it -> {
|
|
|
|
|
if (it.getAllTime() == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
int limit = it.getUharm2Overtime() + it.getUharm3Overtime() + it.getUharm4Overtime() + it.getUharm5Overtime() + it.getUharm6Overtime() +
|
|
|
|
|
it.getUharm7Overtime() + it.getUharm8Overtime() + it.getUharm9Overtime() + it.getUharm10Overtime() + it.getUharm11Overtime() +
|
|
|
|
|
it.getUharm12Overtime() + it.getUharm13Overtime() + it.getUharm14Overtime() + it.getUharm15Overtime() + it.getUharm16Overtime() +
|
|
|
|
|
it.getUharm17Overtime() + it.getUharm18Overtime() + it.getUharm19Overtime() + it.getUharm20Overtime() + it.getUharm21Overtime() +
|
|
|
|
|
it.getUharm22Overtime() + it.getUharm23Overtime() + it.getUharm24Overtime() + it.getUharm25Overtime() + it.getUaberranceOvertime();
|
|
|
|
|
return 1 - ((double) (limit) / it.getAllTime() * 25);
|
|
|
|
|
}
|
|
|
|
|
}).average().orElse(0);
|
|
|
|
|
terminalEvaluateAreaVO.setQualified(NumberUtil.round(qualifiedRate*100,2).doubleValue());
|
|
|
|
|
double pingFen = integrityRate * 0.5 + onlineRate * 0.2 + qualifiedRate * 0.3;
|
|
|
|
|
terminalEvaluateAreaVO.setScore(BigDecimal.valueOf(pingFen*100).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
}
|
|
|
|
|
return terminalEvaluateAreaVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getData(List<RStatIntegrityD> rStatIntegrityDList,List<RStatOnlinerateD> rStatOnlinerateDList,List<RStatLimitRateDPO> rStatLimitRateDPOList,List<String> lineIds,List<String> devIds,String startTime,String endTime){
|
|
|
|
|
if(CollUtil.isNotEmpty(lineIds)){
|
|
|
|
|
rStatIntegrityDList.addAll(integrityDMapper.selectList(new QueryWrapper<RStatIntegrityD>()
|
|
|
|
|
.select("sum(real_time) as realTime,sum(due_time) as dueTime,line_index as lineIndex")
|
|
|
|
|
.in(CollUtil.isNotEmpty(lineIds), "line_index", lineIds)
|
|
|
|
|
.between("time_id",startTime,endTime)
|
|
|
|
|
.groupBy("line_index")));
|
|
|
|
|
RStatLimitQueryParam rStatLimitQueryParam = new RStatLimitQueryParam();
|
|
|
|
|
rStatLimitQueryParam.setIds(lineIds);
|
|
|
|
|
rStatLimitQueryParam.setDate(startTime);
|
|
|
|
|
rStatLimitQueryParam.setEndDate(endTime);
|
|
|
|
|
rStatLimitRateDPOList.addAll(rStatLimitRateDClient.monitorIdsGetLimitInfo(rStatLimitQueryParam).getData());
|
|
|
|
|
}
|
|
|
|
|
if(CollectionUtil.isNotEmpty(devIds)) {
|
|
|
|
|
rStatOnlinerateDList.addAll(onLineRateDMapper.selectList(new QueryWrapper<RStatOnlinerateD>()
|
|
|
|
|
.select("sum(online_min) as onlineMin,sum(offline_min) as offlineMin,dev_index as devIndex")
|
|
|
|
|
.in(CollUtil.isNotEmpty(devIds), "dev_index", devIds)
|
|
|
|
|
.between("time_id",startTime,endTime)
|
|
|
|
|
.groupBy("dev_index")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|