1.终端运行评价
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.device.pq.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description
|
||||||
|
* @date 2025/5/8 14:11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceRunEvaluateVO {
|
||||||
|
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("评价")
|
||||||
|
private BigDecimal evaluate;
|
||||||
|
|
||||||
|
@ApiModelProperty("完整率")
|
||||||
|
private BigDecimal integrityRate;
|
||||||
|
|
||||||
|
@ApiModelProperty("在线率")
|
||||||
|
private BigDecimal onLineRate;
|
||||||
|
|
||||||
|
@ApiModelProperty("合格率")
|
||||||
|
private BigDecimal passRate;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,12 +1,26 @@
|
|||||||
package com.njcn.device.pq.controller;
|
package com.njcn.device.pq.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.pq.pojo.param.DeviceInfoParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.DeviceRunEvaluateVO;
|
||||||
import com.njcn.device.pq.service.DeviceRunEvaluateService;
|
import com.njcn.device.pq.service.DeviceRunEvaluateService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 终端运行评价
|
* @author 终端运行评价
|
||||||
* @description
|
* @description
|
||||||
@@ -17,8 +31,18 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/deviceRunEvaluate")
|
@RequestMapping("/deviceRunEvaluate")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DeviceRunEvaluateController {
|
public class DeviceRunEvaluateController extends BaseController {
|
||||||
|
|
||||||
private final DeviceRunEvaluateService deviceRunEvaluateService;
|
private final DeviceRunEvaluateService deviceRunEvaluateService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@PostMapping("/getRunEvaluate")
|
||||||
|
@ApiOperation("终端运行评价")
|
||||||
|
public HttpResult<List<DeviceRunEvaluateVO>> getRunEvaluate(@RequestBody @Validated DeviceInfoParam.CompareBusinessParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("getRunEvaluate");
|
||||||
|
List<DeviceRunEvaluateVO> runEvaluate = deviceRunEvaluateService.getRunEvaluate(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, runEvaluate, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
package com.njcn.device.pq.service;
|
package com.njcn.device.pq.service;
|
||||||
|
|
||||||
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.DeviceRunEvaluateVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wr
|
* @author wr
|
||||||
* @description
|
* @description
|
||||||
* @date 2025/5/8 13:45
|
* @date 2025/5/8 13:45
|
||||||
*/
|
*/
|
||||||
public interface DeviceRunEvaluateService {
|
public interface DeviceRunEvaluateService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端运行评价
|
||||||
|
* @param deviceInfoParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DeviceRunEvaluateVO> getRunEvaluate(DeviceInfoParam.CompareBusinessParam deviceInfoParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,31 @@
|
|||||||
package com.njcn.device.pq.service.impl;
|
package com.njcn.device.pq.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.njcn.device.pq.mapper.RStatIntegrityDMapper;
|
||||||
|
import com.njcn.device.pq.mapper.RStatOnlinerateDMapper;
|
||||||
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
|
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 com.njcn.device.pq.service.DeviceRunEvaluateService;
|
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 lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wr
|
* @author wr
|
||||||
* @description
|
* @description
|
||||||
@@ -13,6 +35,122 @@ import org.springframework.stereotype.Service;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DeviceRunEvaluateServiceImpl implements DeviceRunEvaluateService {
|
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;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceRunEvaluateVO> getRunEvaluate(DeviceInfoParam.CompareBusinessParam param) {
|
||||||
|
List<DeviceRunEvaluateVO> info = new ArrayList<>();
|
||||||
|
List<GeneralDeviceDTO> deptDeviceInfos = generalDeviceService.getDeviceInfo(param, Arrays.asList(0), Arrays.asList(1));
|
||||||
|
//监测点id集合
|
||||||
|
List<String> lineIds = deptDeviceInfos.stream().flatMap(x -> x.getLineIndexes().stream()).distinct().collect(Collectors.toList());
|
||||||
|
//终端id集合
|
||||||
|
List<String> devIds = deptDeviceInfos.stream().flatMap(x -> x.getDeviceIndexes().stream()).distinct().collect(Collectors.toList());
|
||||||
|
List<RStatLimitRateDPO> limitRateList = new ArrayList<>();
|
||||||
|
List<RStatOnlinerateD> onlineRateList = new ArrayList<>();
|
||||||
|
List<RStatIntegrityD> onIntegrityList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(lineIds)) {
|
||||||
|
RStatLimitQueryParam limitQueryParam = new RStatLimitQueryParam();
|
||||||
|
limitQueryParam.setIds(lineIds);
|
||||||
|
limitQueryParam.setDate(param.getSearchBeginTime());
|
||||||
|
limitQueryParam.setEndDate(param.getSearchEndTime());
|
||||||
|
limitRateList.addAll(rStatLimitRateDClient.monitorIdsGetLimitInfo(limitQueryParam).getData());
|
||||||
|
|
||||||
|
//监测点完整性
|
||||||
|
onIntegrityList.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)
|
||||||
|
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), "time_id", DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())))
|
||||||
|
.le(StrUtil.isNotBlank(param.getSearchEndTime()), "time_id", DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
|
||||||
|
.groupBy("line_index")));
|
||||||
|
//终端在线率
|
||||||
|
onlineRateList.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)
|
||||||
|
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), "time_id", DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())))
|
||||||
|
.le(StrUtil.isNotBlank(param.getSearchEndTime()), "time_id", DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
|
||||||
|
.groupBy("dev_index")));
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceRunEvaluateVO evaluateVO;
|
||||||
|
for (GeneralDeviceDTO deptDeviceInfo : deptDeviceInfos) {
|
||||||
|
evaluateVO = new DeviceRunEvaluateVO();
|
||||||
|
evaluateVO.setName(deptDeviceInfo.getName());
|
||||||
|
|
||||||
|
//监测完整率
|
||||||
|
List<RStatIntegrityD> integrityDS = onIntegrityList.stream().filter(x -> deptDeviceInfo.getLineIndexes().contains(x.getLineIndex())).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(integrityDS)) {
|
||||||
|
double realTime = integrityDS.stream().mapToDouble(RStatIntegrityD::getRealTime).sum();
|
||||||
|
double dueTime = integrityDS.stream().mapToDouble(RStatIntegrityD::getDueTime).sum();
|
||||||
|
evaluateVO.setIntegrityRate(NumberUtil.round(realTime * 100 / dueTime, 2));
|
||||||
|
}
|
||||||
|
//终端在线率
|
||||||
|
List<RStatOnlinerateD> onlineRateDS = onlineRateList.stream().filter(x -> deptDeviceInfo.getDeviceIndexes().contains(x.getDevIndex())).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(onlineRateDS)) {
|
||||||
|
double onlineTime = onlineRateDS.stream().mapToDouble(RStatOnlinerateD::getOnlineMin).sum();
|
||||||
|
double offlineTime = onlineRateDS.stream().mapToDouble(RStatOnlinerateD::getOfflineMin).sum();
|
||||||
|
evaluateVO.setOnLineRate(NumberUtil.round(onlineTime * 100.0 / (onlineTime + offlineTime), 2));
|
||||||
|
}
|
||||||
|
//终端在线率
|
||||||
|
List<RStatLimitRateDPO> limitRateDPOS = limitRateList.stream().filter(x -> deptDeviceInfo.getLineIndexes().contains(x.getLineId())).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(limitRateDPOS)) {
|
||||||
|
double overTime = limitRateDPOS.stream().mapToDouble(x -> (x.getUaberranceOvertime() +
|
||||||
|
x.getUharm2Overtime() +
|
||||||
|
x.getUharm3Overtime() +
|
||||||
|
x.getUharm4Overtime() +
|
||||||
|
x.getUharm5Overtime() +
|
||||||
|
x.getUharm6Overtime() +
|
||||||
|
x.getUharm7Overtime() +
|
||||||
|
x.getUharm8Overtime() +
|
||||||
|
x.getUharm9Overtime() +
|
||||||
|
x.getUharm10Overtime() +
|
||||||
|
x.getUharm11Overtime() +
|
||||||
|
x.getUharm12Overtime() +
|
||||||
|
x.getUharm13Overtime() +
|
||||||
|
x.getUharm14Overtime() +
|
||||||
|
x.getUharm15Overtime() +
|
||||||
|
x.getUharm16Overtime() +
|
||||||
|
x.getUharm17Overtime() +
|
||||||
|
x.getUharm18Overtime() +
|
||||||
|
x.getUharm19Overtime() +
|
||||||
|
x.getUharm20Overtime() +
|
||||||
|
x.getUharm21Overtime() +
|
||||||
|
x.getUharm22Overtime() +
|
||||||
|
x.getUharm23Overtime() +
|
||||||
|
x.getUharm24Overtime() +
|
||||||
|
x.getUharm25Overtime())).sum();
|
||||||
|
double allTime = limitRateDPOS.stream().mapToDouble(x -> x.getAllTime() * 25.0).sum();
|
||||||
|
if (ObjUtil.equals(allTime, 0)) {
|
||||||
|
evaluateVO.setPassRate(new BigDecimal(0));
|
||||||
|
} else {
|
||||||
|
evaluateVO.setPassRate(NumberUtil.round(overTime * 100.0 / allTime, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
evaluateVO.setEvaluate(
|
||||||
|
ONINTEGRITY.multiply(evaluateVO.getIntegrityRate())
|
||||||
|
.add(ONLINERATE.multiply(evaluateVO.getOnLineRate())
|
||||||
|
.add(LIMITRATE.multiply(evaluateVO.getPassRate())))
|
||||||
|
);
|
||||||
|
info.add(evaluateVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user