谐波模块:部分业务influxdb转mysql

This commit is contained in:
wurui
2023-04-06 14:28:50 +08:00
parent e45a3d6dab
commit a620ef6a77
38 changed files with 1537 additions and 440 deletions

View File

@@ -1,11 +1,18 @@
package com.njcn.device.pq.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.fallback.GeneralDeviceInfoClientFallbackFactory;
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
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.OnlineRate;
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -95,4 +102,11 @@ public interface GeneralDeviceInfoClient {
@PostMapping("/getBaseLineInfo")
HttpResult<List<BaseLineInfo>> getBaseLineInfo(@RequestBody List<String> lineIndex);
/**
* 终端在线率(谐波专用)
* @param param
* @return
*/
@PostMapping("/getOnlineRateByDevIds")
HttpResult<List<RStatOnlinerateVO>> getOnlineRateByDevIds(@RequestBody OnlineRateParam param);
}

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.fallback.LineFeignClientFallbackFactory;
import com.njcn.device.pq.pojo.dto.*;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.pq.pojo.po.Overlimit;
@@ -297,4 +298,10 @@ public interface LineFeignClient {
*/
@PostMapping("/getLineCountBySubstation")
HttpResult<Integer> getLineCountBySubstation(@RequestParam("subIndex") String subIndex);
/**
* 监测点数据完整率(谐波专用)
*/
@PostMapping("/getOnIntegrityByIds")
HttpResult<List<RStatIntegrityVO>> getOnIntegrityByIds(@RequestBody OnlineRateParam param);
}

View File

@@ -7,6 +7,9 @@ import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
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.OnlineRate;
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
import com.njcn.device.pq.utils.DeviceEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
@@ -78,6 +81,12 @@ public class GeneralDeviceInfoClientFallbackFactory implements FallbackFactory<G
log.error("{}异常,降级处理,异常为:{}", "获取监测点及以上层的基础信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<RStatOnlinerateVO>> getOnlineRateByDevIds(OnlineRateParam param) {
log.error("{}异常,降级处理,异常为:{}", "获取终端在线率(谐波专用)", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};

View File

@@ -6,6 +6,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.dto.*;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.pq.pojo.po.Overlimit;
@@ -219,6 +220,13 @@ public class LineFeignClientFallbackFactory implements FallbackFactory<LineFeign
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<RStatIntegrityVO>> getOnIntegrityByIds(OnlineRateParam param) {
log.error("{}异常,降级处理,异常为:{}", "获取监测点数据完整率(谐波专用): ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}

View File

@@ -0,0 +1,28 @@
package com.njcn.device.pq.pojo.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
*
*
* @author wr
* @createTime: 2023-04-03
*/
@Data
@ApiModel
public class OnlineRateParam {
@ApiModelProperty(name = "ids", value = "设备id")
private List<String> ids;
@ApiModelProperty(name = "startTime", value = "开始时间")
private String startTime;
@ApiModelProperty(name = "endTime", value = "结束时间")
private String endTime;
}

View File

@@ -0,0 +1,31 @@
package com.njcn.device.pq.pojo.vo;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Data;
import java.time.LocalDateTime;
/**
* <p>
* 数据完整性日表
* </p>
*
* @author wr
* @since 2023-04-03
*/
@Data
public class RStatIntegrityVO {
private static final long serialVersionUID = 1L;
private LocalDateTime timeId;
private String lineIndex;
private Integer dueTime;
private Integer realTime;
private Double integrityRate;
}

View File

@@ -0,0 +1,27 @@
package com.njcn.device.pq.pojo.vo;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Data;
import java.time.LocalDateTime;
/**
* <功能描述>
*
* @author wr
* @createTime: 2023-04-03
*/
@Data
public class RStatOnlinerateVO {
private static final long serialVersionUID = 1L;
private LocalDateTime timeId;
private String devIndex;
private Integer onlineMin;
private Integer offlineMin;
private Integer onlineRate;
}

View File

@@ -1,6 +1,5 @@
package com.njcn.device.pq.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
@@ -9,18 +8,13 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.device.pq.enums.DeviceResponseEnum;
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
import com.njcn.device.pq.mapper.*;
import com.njcn.device.pq.pojo.dto.*;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.po.Device;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.pq.pojo.po.Overlimit;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.*;
import com.njcn.device.pq.pojo.vo.*;
import com.njcn.device.pq.mapper.DeviceMapper;
import com.njcn.device.pq.mapper.LineDetailMapper;
import com.njcn.device.pq.mapper.LineMapper;
import com.njcn.device.pq.service.LineService;
import com.njcn.device.pq.service.impl.GeneralDeviceService;
import com.njcn.user.api.DeptFeignClient;
@@ -36,8 +30,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author denghuajun
@@ -63,6 +55,7 @@ public class LineController extends BaseController {
private final DeptFeignClient deptFeignClient;
private final RStatIntegrityDMapper integrityDMapper;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLineDetailData")
@@ -419,4 +412,13 @@ public class LineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe);
}
@PostMapping("/getOnIntegrityByIds")
@ApiOperation("监测点数据完整率(谐波专用)")
@ApiImplicitParam(name = "param", value = "参数实体", required = true)
public HttpResult<List<RStatIntegrityVO>> getOnIntegrityByIds(@RequestBody OnlineRateParam param) {
String methodDescribe = getMethodDescribe("getOnlineRateByDevIds");
List<RStatIntegrityVO> onIntegrityByIds = integrityDMapper.getOnIntegrityByIds(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,onIntegrityByIds,methodDescribe);
}
}

View File

@@ -5,8 +5,13 @@ 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.mapper.OnlineRateMapper;
import com.njcn.device.pq.mapper.RStatOnlinerateDMapper;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.param.TerminalOnlineRateDataParam;
import com.njcn.device.pq.pojo.po.OnlineRate;
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
import com.njcn.device.pq.pojo.vo.TerminalOnlineRateDataVO;
import com.njcn.device.pq.service.TerminalOnlineRateDataService;
import com.njcn.web.controller.BaseController;
@@ -37,6 +42,8 @@ public class TerminalOnlineRateDataController extends BaseController {
private final TerminalOnlineRateDataService terminalOnlineRateDataService;
private final RStatOnlinerateDMapper onlineRateMapper;
/**
* 终端在线率列表
*/
@@ -49,4 +56,15 @@ public class TerminalOnlineRateDataController extends BaseController {
List<TerminalOnlineRateDataVO> onlineRateData = terminalOnlineRateDataService.getOnlineRateData(terminalOnlineRateDataParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,onlineRateData,methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getOnlineRateByDevIds")
@ApiOperation("终端在线率(谐波专用)")
@ApiImplicitParam(name = "param", value = "参数实体", required = true)
public HttpResult<List<RStatOnlinerateVO>> getOnlineRateByDevIds(@RequestBody OnlineRateParam param) {
String methodDescribe = getMethodDescribe("getOnlineRateByDevIds");
List<RStatOnlinerateVO> onlineRateByDevIds = onlineRateMapper.getOnlineRateByDevIds(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,onlineRateByDevIds,methodDescribe);
}
}

View File

@@ -2,8 +2,10 @@ package com.njcn.device.pq.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.LineDataIntegrity;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import com.njcn.device.pq.pojo.vo.RStatIntegrityVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -25,4 +27,13 @@ public interface RStatIntegrityDMapper extends BaseMapper<RStatIntegrityD> {
* @date 2023/3/29
*/
List<LineDataIntegrity> getLineIntegrityRate(@Param("lineIds")List<String> lineIds,@Param("startTime")String startTime,@Param("endTime")String endTime);
/***
* 监测点完整性
* @author wr
* @date 2023-04-03 10:10
* @param param
* @return List<OnlineRate>
*/
List<RStatIntegrityVO> getOnIntegrityByIds(@Param("param") OnlineRateParam param);
}

View File

@@ -2,7 +2,13 @@ package com.njcn.device.pq.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.OnlineRate;
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>
@@ -14,4 +20,12 @@ import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
*/
public interface RStatOnlinerateDMapper extends BaseMapper<RStatOnlinerateD> {
/***
* 获取设备在线率
* @author wr
* @date 2023-04-03 10:10
* @param param
* @return List<OnlineRate>
*/
List<RStatOnlinerateVO> getOnlineRateByDevIds(@Param("param") OnlineRateParam param);
}

View File

@@ -1,6 +1,6 @@
<?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.pq.mapper.TerminalOnlineRateDataMapper">
<mapper namespace="com.njcn.device.pq.mapper.RStatIntegrityDMapper">
<select id="getLineIntegrityRate" resultType="LineDataIntegrity">
select line_index lineId,avg(real_time/due_time) integrityData
@@ -12,4 +12,27 @@
and time_id between #{startTime} and #{endTime}
group by line_index
</select>
<select id="getOnIntegrityByIds" resultType="com.njcn.device.pq.pojo.vo.RStatIntegrityVO">
SELECT
line_index AS lineIndex,
sum( real_time )/ sum( due_time )* 100 AS integrityRate
FROM
r_stat_integrity_d
<where>
<if test="param!=null and param.ids != null and param.ids.size > 0">
AND Dev_Id 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 &lt;= #{param.endTime}
</if>
</where>
group by line_index ;
</select>
</mapper>

View File

@@ -0,0 +1,25 @@
<?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.pq.mapper.RStatOnlinerateDMapper">
<select id="getOnlineRateByDevIds" resultType="com.njcn.device.pq.pojo.vo.RStatOnlinerateVO">
select
dev_index,
sum(online_min)/(sum(online_min) + sum(offline_min))*100 as online_rate
from r_stat_onlinerate_d
<where>
<if test="param!=null and param.ids != null and param.ids.size > 0">
AND Dev_Id 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 &lt;= #{param.endTime}
</if>
</where>
group by dev_index ;
</select>
</mapper>

View File

@@ -1,12 +1,18 @@
package com.njcn.device.pq.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.njcn.device.pq.mapper.OnlineRateMapper;
import com.njcn.device.pq.mapper.RStatIntegrityDMapper;
import com.njcn.device.pq.mapper.RStatOnlinerateDMapper;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.param.PulicTimeParam;
import com.njcn.device.pq.pojo.param.PulicTimeStatisParam;
import com.njcn.device.pq.pojo.vo.CommunicateStatisticsVO;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
import com.njcn.device.pq.pojo.vo.DeviceOnlineDataVO;
import com.njcn.device.pq.pojo.po.LineDataIntegrity;
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
import com.njcn.device.pq.pojo.vo.*;
import com.njcn.device.pq.service.CommunicateService;
import com.njcn.device.pq.service.IRStatOnlinerateDService;
import com.njcn.device.pq.service.LineService;
import com.njcn.device.pq.utils.PublicDateUtil;
import com.njcn.influxdb.utils.InfluxDbUtils;
@@ -36,6 +42,9 @@ public class CommunicateServiceImpl implements CommunicateService {
private final InfluxDbUtils influxDbUtils;
private final RStatOnlinerateDMapper onlinerateDMapper;
private final RStatIntegrityDMapper integrityDMapper;
@Override
public CommunicateVO getComFlagInfoData(PulicTimeParam pulicTimeParam) {
//根据监测点id获取终端状态信息
@@ -49,11 +58,11 @@ public class CommunicateServiceImpl implements CommunicateService {
String devId = lineService.getLineIdByDevId(pulicTimeStatisParam.getId());
List<Float> floatList = new ArrayList<>();
List<Float> floats = new ArrayList<>();
floatList.add(getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 0) * 100);
floats.add(getCondition(devId, pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 1) * 100);
floatList.add( getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 0) );
floats.add( getCondition(devId, pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 1) );
if (StringUtils.isNotBlank(pulicTimeStatisParam.getPeriodBeginTime()) && StringUtils.isNotBlank(pulicTimeStatisParam.getPeriodEndTime())) {
floatList.add(getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 0) * 100);
floats.add(getCondition(devId, pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 1) * 100);
floatList.add( getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 0) );
floats.add( getCondition(devId, pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 1) );
}
communicateStatisticsVO.setOnlineRateData(floats);
communicateStatisticsVO.setIntegrityData(floatList);
@@ -83,7 +92,7 @@ public class CommunicateServiceImpl implements CommunicateService {
if (floatList == 0) {
inter.setOnlineRate(3.14159f);
} else {
inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList * 100)));
inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList)));
}
deviceOnlineDataList.add(inter);
}
@@ -122,35 +131,61 @@ public class CommunicateServiceImpl implements CommunicateService {
*/
private Float getCondition(String lineList, String startTime, String endTime, Integer state) {
final Float[] resultList = {0.0f};
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(TIME + " >= '").append(startTime).append(START_TIME).append("' and ").append(TIME).append(" <= '").append(endTime).append(END_TIME).append("' and (");
//sql语句
String sql = "";
if (state == 0) {
stringBuilder.append(LINE_ID + "='").append(lineList).append("')");
sql = "SELECT SUM(" + REAL + ")/SUM(" + DUE + ") AS integrity FROM pqs_integrity WHERE " + stringBuilder.toString() + " group by " + LINE_ID + " tz('Asia/Shanghai')";
} else {
stringBuilder.append(DEV_INDEX + "='").append(lineList).append("')");
sql = "SELECT SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")) AS onlineRate FROM pqs_onlinerate WHERE " + stringBuilder.toString() + " group by " + DEV_INDEX + " tz('Asia/Shanghai')";
}
//结果集
QueryResult result = influxDbUtils.query(sql);
//处理结果集
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
if (!CollectionUtils.isEmpty(list)) {
list.forEach(po -> {
List<List<Object>> valueList = po.getValues();
if (!CollectionUtils.isEmpty(valueList)) {
for (List<Object> value : valueList) {
OnlineRateParam param=new OnlineRateParam();
param.setIds(Arrays.asList(lineList));
param.setStartTime( DateUtil.beginOfDay(DateUtil.parse(startTime)).toString());
param.setEndTime( DateUtil.endOfDay(DateUtil.parse(endTime)).toString());
if(state == 0){
//在线率
List<RStatOnlinerateVO> onlineRateByDevIds = onlinerateDMapper.getOnlineRateByDevIds(param);
if (CollUtil.isNotEmpty(onlineRateByDevIds)) {
onlineRateByDevIds.forEach(po -> {
//数据完整性 保留四位小数
resultList[0] = value.get(1) == null ? null : BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
}
}
resultList[0] = po.getOnlineRate() == null ? null : BigDecimal.valueOf(Float.parseFloat(po.getOnlineRate().toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
});
}
}else{
//数据完整率
List<RStatIntegrityVO> onIntegrityByIds = integrityDMapper.getOnIntegrityByIds(param);
if (CollUtil.isNotEmpty(onIntegrityByIds)) {
onIntegrityByIds.forEach(po -> {
//数据完整性 保留四位小数
resultList[0] = po.getIntegrityRate() == null ? null : BigDecimal.valueOf(Float.parseFloat(po.getIntegrityRate().toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
});
}
}
return resultList[0];
//
// //组装sql语句
// StringBuilder stringBuilder = new StringBuilder();
// stringBuilder.append(TIME + " >= '").append(startTime).append(START_TIME).append("' and ").append(TIME).append(" <= '").append(endTime).append(END_TIME).append("' and (");
// //sql语句
// String sql = "";
// if (state == 0) {
// stringBuilder.append(LINE_ID + "='").append(lineList).append("')");
// sql = "SELECT SUM(" + REAL + ")/SUM(" + DUE + ") AS integrity FROM pqs_integrity WHERE " + stringBuilder.toString() + " group by " + LINE_ID + " tz('Asia/Shanghai')";
// } else {
// stringBuilder.append(DEV_INDEX + "='").append(lineList).append("')");
// sql = "SELECT SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")) AS onlineRate FROM pqs_onlinerate WHERE " + stringBuilder.toString() + " group by " + DEV_INDEX + " tz('Asia/Shanghai')";
// }
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
// if (!CollectionUtils.isEmpty(list)) {
// list.forEach(po -> {
// List<List<Object>> valueList = po.getValues();
// if (!CollectionUtils.isEmpty(valueList)) {
// for (List<Object> value : valueList) {
// //数据完整性 保留四位小数
// resultList[0] = value.get(1) == null ? null : BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
// }
// }
// });
// }
//
// return resultList[0];
}
/**

View File

@@ -62,4 +62,9 @@ public interface Param {
String PHASIC_TYPE = "phasic_type";
String PARENT_ID = "0";
/**
*数据类型(最大值max、最小值min、平均值avg、95值cp95)
*/
String VALUE_TYPEAVG = "AVG";
}

View File

@@ -82,19 +82,19 @@ public class PQSComAssesPO {
private Double vUnbalance5;
//谐波含量等级1
@Column(name = "v_thd1")
private Double vTHD1;
private Double vThd1;
//谐波含量等级2
@Column(name = "v_thd2")
private Double vTHD2;
private Double vThd2;
//谐波含量等级3
@Column(name = "v_thd3")
private Double vTHD3;
private Double vThd3;
//谐波含量等级4
@Column(name = "v_thd4")
private Double vTHD4;
private Double vThd4;
//谐波含量等级5
@Column(name = "v_thd5")
private Double vTHD5;
private Double vThd5;
//电压暂降等级1
@Column(name = "event1")
private Double event1;

View File

@@ -0,0 +1,255 @@
package com.njcn.harmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
*
* </p>
*
* @author wr
* @since 2023-03-31
*/
@Getter
@Setter
@TableName("r_stat_data_v_d")
public class RStatDataVD {
private static final long serialVersionUID = 1L;
/**
* 统计数据时间
*/
private LocalDateTime time;
/**
* 监测点Id
*/
private String lineId;
/**
* 相别,A表示A相B表示B相,C表示C相,T表示总
*/
private String phasicType;
/**
* 数据类型(最大值max、最小值min、平均值avg、95值cp95)
*/
private String valueType;
/**
* 数据质量标志0-表示是正常数据、1-表示是错误数据、2-表示是有事件的数据数据库默认是0污染数据不参与报表统计
*/
private Integer qualityFlag;
/**
* 频率
*/
private BigDecimal freq;
/**
* 频率偏差
*/
private BigDecimal freqDev;
/**
* 相电压有效值
*/
private BigDecimal rms;
private BigDecimal rmsLvr;
/**
* 负序电压
*/
private BigDecimal vNeg;
/**
* 正序电压
*/
private BigDecimal vPos;
/**
* 谐波含量
*/
private BigDecimal vThd;
/**
* 三相电压不平衡度
*/
private BigDecimal vUnbalance;
/**
* 零序电压
*/
private BigDecimal vZero;
/**
* 电压正偏差
*/
private BigDecimal vlDev;
/**
* 电压负偏差
*/
private BigDecimal vuDev;
@TableField(value = "v_1")
private BigDecimal v1;
@TableField(value = "v_2")
private BigDecimal v2;
@TableField(value = "v_3")
private BigDecimal v3;
@TableField(value = "v_4")
private BigDecimal v4;
@TableField(value = "v_5")
private BigDecimal v5;
@TableField(value = "v_6")
private BigDecimal v6;
@TableField(value = "v_7")
private BigDecimal v7;
@TableField(value = "v_8")
private BigDecimal v8;
@TableField(value = "v_9")
private BigDecimal v9;
@TableField(value = "v_10")
private BigDecimal v10;
@TableField(value = "v_11")
private BigDecimal v11;
@TableField(value = "v_12")
private BigDecimal v12;
@TableField(value = "v_13")
private BigDecimal v13;
@TableField(value = "v_14")
private BigDecimal v14;
@TableField(value = "v_15")
private BigDecimal v15;
@TableField(value = "v_16")
private BigDecimal v16;
@TableField(value = "v_17")
private BigDecimal v17;
@TableField(value = "v_18")
private BigDecimal v18;
@TableField(value = "v_19")
private BigDecimal v19;
@TableField(value = "v_20")
private BigDecimal v20;
@TableField(value = "v_21")
private BigDecimal v21;
@TableField(value = "v_22")
private BigDecimal v22;
@TableField(value = "v_23")
private BigDecimal v23;
@TableField(value = "v_24")
private BigDecimal v24;
@TableField(value = "v_25")
private BigDecimal v25;
@TableField(value = "v_26")
private BigDecimal v26;
@TableField(value = "v_27")
private BigDecimal v27;
@TableField(value = "v_28")
private BigDecimal v28;
@TableField(value = "v_29")
private BigDecimal v29;
@TableField(value = "v_30")
private BigDecimal v30;
@TableField(value = "v_31")
private BigDecimal v31;
@TableField(value = "v_32")
private BigDecimal v32;
@TableField(value = "v_33")
private BigDecimal v33;
@TableField(value = "v_34")
private BigDecimal v34;
@TableField(value = "v_35")
private BigDecimal v35;
@TableField(value = "v_36")
private BigDecimal v36;
@TableField(value = "v_37")
private BigDecimal v37;
@TableField(value = "v_38")
private BigDecimal v38;
@TableField(value = "v_39")
private BigDecimal v39;
@TableField(value = "v_40")
private BigDecimal v40;
@TableField(value = "v_41")
private BigDecimal v41;
@TableField(value = "v_42")
private BigDecimal v42;
@TableField(value = "v_43")
private BigDecimal v43;
@TableField(value = "v_44")
private BigDecimal v44;
@TableField(value = "v_45")
private BigDecimal v45;
@TableField(value = "v_46")
private BigDecimal v46;
@TableField(value = "v_47")
private BigDecimal v47;
@TableField(value = "v_48")
private BigDecimal v48;
@TableField(value = "v_49")
private BigDecimal v49;
@TableField(value = "v_50")
private BigDecimal v50;
}

View File

@@ -0,0 +1,34 @@
package com.njcn.harmonic.pojo.vo;
import lombok.Data;
/**
* <功能描述>
*
* @author wr
* @createTime: 2023-04-03
*/
@Data
public class RStatLimitRateDVO {
private static final long serialVersionUID = 1L;
private Integer alltime;
private Integer frequency;
private Integer uBalance;
private Integer iNeg;
private Integer harmElec;
private Integer harmVoltage;
private Integer flicker;
private Integer allFlicker;
private Integer voltageDeviation;
private Integer inUharm;
}

View File

@@ -0,0 +1,30 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.PQSComAssesPO;
import com.njcn.harmonic.pojo.po.day.RStatComassesDPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 电能质量综合评估 Mapper 接口
* </p>
*
* @author wr
* @since 2023-03-31
*/
public interface RStatComassesDMapper extends BaseMapper<RStatComassesDPO> {
/**
* 统计综合评估平均值
* @param lineIndexes
* @param searchBeginTime
* @param searchEndTime
* @return
*/
List<PQSComAssesPO> getAvgCount(@Param("ids") List<String> lineIndexes,
@Param("statTime") String searchBeginTime,
@Param("endTime") String searchEndTime);
}

View File

@@ -0,0 +1,16 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatDataVD;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-03-31
*/
public interface RStatDataVDMapper extends BaseMapper<RStatDataVD> {
}

View File

@@ -0,0 +1,23 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.RStatLimitRateDVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 合格率统计日表(越限次数) Mapper 接口
* </p>
*
* @author wr
* @since 2023-04-03
*/
public interface RStatLimitRateDMapper extends BaseMapper<RStatLimitRateDPO> {
List<RStatLimitRateDVO> getSumPassRate(@Param("ids") List<String> lineIndexes,
@Param("statTime") String searchBeginTime,
@Param("endTime") String searchEndTime);
}

View File

@@ -0,0 +1,57 @@
<?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.harmonic.mapper.RStatComassesDMapper">
<select id="getAvgCount" resultType="com.njcn.harmonic.pojo.po.PQSComAssesPO">
SELECT
line_id,
AVG ( vu_dev1 ) AS vu_dev1,
AVG ( vu_dev2 ) AS vu_dev2,
AVG ( vu_dev3 ) AS vu_dev3,
AVG ( vu_dev4 ) AS vu_dev4,
AVG ( vu_dev5 ) AS vu_dev5,
AVG ( freq_dev1 ) AS freq_dev1,
AVG ( freq_dev2 ) AS freq_dev2,
AVG ( freq_dev3 ) AS freq_dev3,
AVG ( freq_dev4 ) AS freq_dev4,
AVG ( freq_dev5 ) AS freq_dev5,
AVG ( data_plt1 ) AS data_plt1,
AVG ( data_plt2 ) AS data_plt2,
AVG ( data_plt3 ) AS data_plt3,
AVG ( data_plt4 ) AS data_plt4,
AVG ( data_plt5 ) AS data_plt5,
AVG ( v_unbalance1 ) AS v_unbalance1,
AVG ( v_unbalance2 ) AS v_unbalance2,
AVG ( v_unbalance3 ) AS v_unbalance3,
AVG ( v_unbalance4 ) AS v_unbalance4,
AVG ( v_unbalance5 ) AS v_unbalance5,
AVG ( v_thd1 ) AS v_thd1,
AVG ( v_thd2 ) AS v_thd2,
AVG ( v_thd3 ) AS v_thd3,
AVG ( v_thd4 ) AS v_thd4,
AVG ( v_thd5 ) AS v_thd5,
AVG ( event1 ) AS event1,
AVG ( event2 ) AS event2,
AVG ( event3 ) AS event3,
AVG ( event4 ) AS event4,
AVG ( event5 ) AS event5
FROM
r_stat_comasses_d
<where>
<if test=" ids != null and ids.size > 0">
AND line_id IN
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test=" statTime != null and statTime !=''">
AND time_id >= #{statTime}
</if>
<if test="endTime != null and endTime != ''">
AND time_id &lt;= #{endTime}
</if>
</where>
GROUP BY line_id
</select>
</mapper>

View File

@@ -0,0 +1,5 @@
<?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.harmonic.mapper.RStatDataVDMapper">
</mapper>

View File

@@ -0,0 +1,34 @@
<?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.harmonic.mapper.RStatLimitRateDMapper">
<select id="getSumPassRate" resultType="com.njcn.harmonic.pojo.vo.RStatLimitRateDVO">
SELECT
SUM( all_time ) AS alltime,
SUM( freq_dev_overtime ) AS frequency,
SUM( ubalance_overtime ) AS uBalance,
SUM( i_neg_overtime ) AS iNeg,
SUM( iharm_13_overtime ) AS harmElec,
SUM( uharm_4_overtime ) AS harmVoltage,
SUM( flicker_overtime ) AS flicker,
SUM( flicker_all_time ) AS allFlicker,
SUM( voltage_dev_overtime ) AS voltageDeviation,
SUM( inuharm_9_overtime ) AS inUharm
FROM
r_stat_limit_rate_d
<where>
<if test=" ids != null and ids.size > 0">
AND my_index IN
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test=" statTime != null and statTime !=''">
AND time_id >= #{statTime}
</if>
<if test="endTime != null and endTime != ''">
AND time_id &lt;= #{endTime}
</if>
</where>
</select>
</mapper>

View File

@@ -1,6 +1,8 @@
package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.po.day.RStatComassesDPO;
import com.njcn.harmonic.pojo.vo.ComAssessVO;
import java.util.List;
@@ -10,7 +12,7 @@ import java.util.List;
* @author: chenchao
* @date: 2022/04/21 10:21
*/
public interface ComAssessService {
public interface ComAssessService extends IService<RStatComassesDPO> {
/**
* 获取稳态综合评估分值

View File

@@ -0,0 +1,16 @@
package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.po.RStatDataVD;
/**
* <p>
* 服务类
* </p>
*
* @author wr
* @since 2023-03-31
*/
public interface IRStatDataVDService extends IService<RStatDataVD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
/**
* <p>
* 合格率统计日表(越限次数) 服务类
* </p>
*
* @author wr
* @since 2023-04-03
*/
public interface IRStatLimitRateDService extends IService<RStatLimitRateDPO> {
}

View File

@@ -1,8 +1,13 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.njcn.device.pq.pojo.param.PulicTimeStatisParam;
import com.njcn.harmonic.mapper.RStatComassesDMapper;
import com.njcn.harmonic.pojo.po.PQSComAssesPO;
import com.njcn.harmonic.pojo.vo.AssesVO;
import com.njcn.harmonic.service.AssesService;
import com.njcn.harmonic.service.ComAssessService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.web.utils.ComAssesUtil;
@@ -15,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -30,6 +36,7 @@ public class AssesServiceImpl implements AssesService {
private final ComAssesUtil comAssesUtil;
private final RStatComassesDMapper rStatComassesDMapper;
@Override
public AssesVO getQualityAssessData(PulicTimeStatisParam pulicTimeStatisParam) {
AssesVO assesVO = new AssesVO();
@@ -48,54 +55,60 @@ public class AssesServiceImpl implements AssesService {
* 查询监测点的数据完整性
*/
private Float getCondition(String lineList, String startTime, String endTime) {
float synData;
if (!lineList.isEmpty()) {
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
//sql语句
stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList).append("')");
stringBuilder.append(" group by " + InfluxDBPublicParam.LINE_ID).append(" ");
stringBuilder.append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT" +
" MEAN(freq_dev1) AS freq_dev1," +
" MEAN(freq_dev2) AS freq_dev2," +
" MEAN(freq_dev3) AS freq_dev3," +
" MEAN(freq_dev4) AS freq_dev4," +
" MEAN(freq_dev5) AS freq_dev5," +
" MEAN(vu_dev1) AS vu_dev1," +
" MEAN(vu_dev2) AS vu_dev2," +
" MEAN(vu_dev3) AS vu_dev3," +
" MEAN(vu_dev4) AS vu_dev4," +
" MEAN(vu_dev5) AS vu_dev5," +
" MEAN(data_plt1) AS data_plt1," +
" MEAN(data_plt2) AS data_plt2," +
" MEAN(data_plt3) AS data_plt3," +
" MEAN(data_plt4) AS data_plt4," +
" MEAN(data_plt5) AS data_plt5," +
" MEAN(v_unbalance1) AS v_unbalance1," +
" MEAN(v_unbalance2) AS v_unbalance2," +
" MEAN(v_unbalance3) AS v_unbalance3," +
" MEAN(v_unbalance4) AS v_unbalance4," +
" MEAN(v_unbalance5) AS v_unbalance5," +
" MEAN(v_thd1) AS v_thd1," +
" MEAN(v_thd2) AS v_thd2," +
" MEAN(v_thd3) AS v_thd3," +
" MEAN(v_thd4) AS v_thd4," +
" MEAN(v_thd5) AS v_thd5," +
" MEAN(event1) AS event1," +
" MEAN(event2) AS event2," +
" MEAN(event3) AS event3," +
" MEAN(event4) AS event4," +
" MEAN(event5) AS event5" +
" FROM" +
" pqs_comasses" +
" where " + stringBuilder.toString();
//结果集
QueryResult result = influxDbUtils.query(sql);
//处理结果集
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<PqsComasses> communicateList = influxDBResultMapper.toPOJO(result, PqsComasses.class);
// //组装sql语句
// StringBuilder stringBuilder = new StringBuilder();
// stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
// //sql语句
// stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList).append("')");
// stringBuilder.append(" group by " + InfluxDBPublicParam.LINE_ID).append(" ");
// stringBuilder.append(InfluxDBPublicParam.TIME_ZONE);
// String sql = "SELECT" +
// " MEAN(freq_dev1) AS freq_dev1," +
// " MEAN(freq_dev2) AS freq_dev2," +
// " MEAN(freq_dev3) AS freq_dev3," +
// " MEAN(freq_dev4) AS freq_dev4," +
// " MEAN(freq_dev5) AS freq_dev5," +
// " MEAN(vu_dev1) AS vu_dev1," +
// " MEAN(vu_dev2) AS vu_dev2," +
// " MEAN(vu_dev3) AS vu_dev3," +
// " MEAN(vu_dev4) AS vu_dev4," +
// " MEAN(vu_dev5) AS vu_dev5," +
// " MEAN(data_plt1) AS data_plt1," +
// " MEAN(data_plt2) AS data_plt2," +
// " MEAN(data_plt3) AS data_plt3," +
// " MEAN(data_plt4) AS data_plt4," +
// " MEAN(data_plt5) AS data_plt5," +
// " MEAN(v_unbalance1) AS v_unbalance1," +
// " MEAN(v_unbalance2) AS v_unbalance2," +
// " MEAN(v_unbalance3) AS v_unbalance3," +
// " MEAN(v_unbalance4) AS v_unbalance4," +
// " MEAN(v_unbalance5) AS v_unbalance5," +
// " MEAN(v_thd1) AS v_thd1," +
// " MEAN(v_thd2) AS v_thd2," +
// " MEAN(v_thd3) AS v_thd3," +
// " MEAN(v_thd4) AS v_thd4," +
// " MEAN(v_thd5) AS v_thd5," +
// " MEAN(event1) AS event1," +
// " MEAN(event2) AS event2," +
// " MEAN(event3) AS event3," +
// " MEAN(event4) AS event4," +
// " MEAN(event5) AS event5" +
// " FROM" +
// " pqs_comasses" +
// " where " + stringBuilder.toString();
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
// List<PqsComasses> communicateList = influxDBResultMapper.toPOJO(result, PqsComasses.class);
List<PQSComAssesPO> avgCount = rStatComassesDMapper.getAvgCount(Arrays.asList(lineList),
DateUtil.beginOfDay(DateUtil.parse(startTime)).toString(),
DateUtil.beginOfDay(DateUtil.parse(endTime)).toString());
List<PqsComasses> communicateList = BeanUtil.copyToList(avgCount,PqsComasses.class);
if (!CollectionUtils.isEmpty(communicateList)) {
synData = comAssesUtil.getAllComAss(communicateList);
} else {

View File

@@ -1,10 +1,15 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.mapper.RStatComassesDMapper;
import com.njcn.harmonic.pojo.dto.ComAssessDTO;
import com.njcn.harmonic.pojo.po.PQSComAssesPO;
import com.njcn.harmonic.pojo.po.day.RStatComassesDPO;
import com.njcn.harmonic.pojo.vo.ComAssessVO;
import com.njcn.harmonic.service.ComAssessService;
import com.njcn.harmonic.utils.HarmonicComAssesUtil;
@@ -28,7 +33,7 @@ import java.util.stream.Collectors;
*/
@Service
@AllArgsConstructor
public class ComAssessServiceImpl implements ComAssessService {
public class ComAssessServiceImpl extends ServiceImpl<RStatComassesDMapper, RStatComassesDPO> implements ComAssessService {
private final GeneralDeviceInfoClient generalDeviceInfoClient;
@@ -52,14 +57,12 @@ public class ComAssessServiceImpl implements ComAssessService {
comAssessVO.setMonitors(lineIndexes.size());
if (!CollectionUtils.isEmpty(lineIndexes)) {
List<PQSComAssesPO> pqsComAssesPOS = getComAccessData(lineIndexes, comAccessParam.getSearchBeginTime(), comAccessParam.getSearchEndTime());
if (!CollectionUtils.isEmpty(pqsComAssesPOS)) {
setResults(pqsComAssesPOS,comAssessDTOS);
float allComAss = comAssesUtil.getAllComAss(comAssessDTOS);
String lv = getLevel(allComAss);
comAssessVO.setData(allComAss);
comAssessVO.setLevel(lv);
}
}
List<ComAssessVO> children = new ArrayList<>();
List<ComAssessDTO> childrenDTOS = new ArrayList<>();
@@ -77,14 +80,12 @@ public class ComAssessServiceImpl implements ComAssessService {
assessVO.setMonitors(lines.size());
if (!CollectionUtils.isEmpty(lines)) {
List<PQSComAssesPO> pqsComAssesPOS = getComAccessData(lines, comAccessParam.getSearchBeginTime(), comAccessParam.getSearchEndTime());
if (!CollectionUtils.isEmpty(pqsComAssesPOS)) {
setResults(pqsComAssesPOS,childrenDTOS);
float allComAss = comAssesUtil.getAllComAss(childrenDTOS);
String lv = getLevel(allComAss);
assessVO.setData(allComAss);
assessVO.setLevel(lv);
}
}
children.add(assessVO);
comAssessVO.setChildren(children);
}
@@ -139,15 +140,15 @@ public class ComAssessServiceImpl implements ComAssessService {
comAssessDTO.setVUnbalance4(vu4);
float vu5 = new BigDecimal(pqsComAssesPOS.get(i).getVUnbalance5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVUnbalance5(vu5);
float vt1 = new BigDecimal(pqsComAssesPOS.get(i).getVTHD1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
float vt1 = new BigDecimal(pqsComAssesPOS.get(i).getVThd1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD1(vt1);
float vt2 = new BigDecimal(pqsComAssesPOS.get(i).getVTHD2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
float vt2 = new BigDecimal(pqsComAssesPOS.get(i).getVThd2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD2(vt2);
float vt3 = new BigDecimal(pqsComAssesPOS.get(i).getVTHD3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
float vt3 = new BigDecimal(pqsComAssesPOS.get(i).getVThd3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD3(vt3);
float vt4 = new BigDecimal(pqsComAssesPOS.get(i).getVTHD4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
float vt4 = new BigDecimal(pqsComAssesPOS.get(i).getVThd4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD4(vt4);
float vt5 = new BigDecimal(pqsComAssesPOS.get(i).getVTHD5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
float vt5 = new BigDecimal(pqsComAssesPOS.get(i).getVThd5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD5(vt5);
float e1 = new BigDecimal(pqsComAssesPOS.get(i).getEvent1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setEvent1(e1);
@@ -190,27 +191,37 @@ public class ComAssessServiceImpl implements ComAssessService {
* @param searchEndTime
*/
private List<PQSComAssesPO> getComAccessData(List<String> lineIndexes, String searchBeginTime, String searchEndTime) {
//组装sql语句
StringBuilder builder = new StringBuilder();
builder.append("MEAN(vu_dev1)AS vu_dev1, MEAN(vu_dev2)AS vu_dev2, MEAN(vu_dev3)AS vu_dev3, MEAN(vu_dev4)AS vu_dev4, MEAN(vu_dev5)AS vu_dev5, MEAN(freq_dev1)AS freq_dev1, MEAN(freq_dev2)AS freq_dev2, MEAN(freq_dev3)AS freq_dev3, MEAN(freq_dev4)AS freq_dev4, MEAN(freq_dev5)AS freq_dev5, MEAN(data_plt1)AS data_plt1, MEAN(data_plt2)AS data_plt2, MEAN(data_plt3)AS data_plt3, MEAN(data_plt4)AS data_plt4, MEAN(data_plt5)AS data_plt5, MEAN(v_unbalance1)AS v_unbalance1, MEAN(v_unbalance2)AS v_unbalance2, MEAN(v_unbalance3)AS v_unbalance3, MEAN(v_unbalance4)AS v_unbalance4, MEAN(v_unbalance5)AS v_unbalance5, MEAN(v_thd1)AS v_thd1, MEAN(v_thd2)AS v_thd2, MEAN(v_thd3)AS v_thd3, MEAN(v_thd4)AS v_thd4, MEAN(v_thd5)AS v_thd5, MEAN(event1)AS event1, MEAN(event2)AS event2, MEAN(event3)AS event3, MEAN(event4)AS event4, MEAN(event5)AS event5");
StringBuffer string = new StringBuffer();
string.append(InfluxDBPublicParam.TIME + " >= '" + searchBeginTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + searchEndTime + InfluxDBPublicParam.END_TIME + "' and ");
for (int i = 0; i < lineIndexes.size(); i++) {
if (lineIndexes.size() - i != 1) {
string.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
} else {
string.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' group by " + InfluxDBPublicParam.LINE_ID);
List<PQSComAssesPO> avgCount = this.baseMapper.getAvgCount(lineIndexes,
DateUtil.beginOfDay(DateUtil.parse(searchBeginTime)).toString(),
DateUtil.beginOfDay(DateUtil.parse(searchEndTime)).toString());
if(CollUtil.isNotEmpty(avgCount)){
return avgCount;
}
}
//sql语句
String sql = "SELECT "+ builder +" FROM "+InfluxDBPublicParam.PQS_COMASSES+" WHERE " + string + InfluxDBPublicParam.TIME_ZONE;
//结果集
System.out.println("--------------->>>>"+sql);
QueryResult result = influxDbUtils.query(sql);
//结果集映射到对象中
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<PQSComAssesPO> pqsComAssesPOS = resultMapper.toPOJO(result, PQSComAssesPO.class);
return pqsComAssesPOS;
return new ArrayList<>();
// //组装sql语句
// StringBuilder builder = new StringBuilder();
// builder.append("MEAN(vu_dev1)AS vu_dev1, MEAN(vu_dev2)AS vu_dev2, MEAN(vu_dev3)AS vu_dev3, MEAN(vu_dev4)AS vu_dev4, MEAN(vu_dev5)AS vu_dev5, MEAN(freq_dev1)AS freq_dev1, MEAN(freq_dev2)AS freq_dev2, MEAN(freq_dev3)AS freq_dev3, MEAN(freq_dev4)AS freq_dev4, MEAN(freq_dev5)AS freq_dev5, MEAN(data_plt1)AS data_plt1, MEAN(data_plt2)AS data_plt2, MEAN(data_plt3)AS data_plt3, MEAN(data_plt4)AS data_plt4, MEAN(data_plt5)AS data_plt5, MEAN(v_unbalance1)AS v_unbalance1, MEAN(v_unbalance2)AS v_unbalance2, MEAN(v_unbalance3)AS v_unbalance3, MEAN(v_unbalance4)AS v_unbalance4, MEAN(v_unbalance5)AS v_unbalance5, MEAN(v_thd1)AS v_thd1, MEAN(v_thd2)AS v_thd2, MEAN(v_thd3)AS v_thd3, MEAN(v_thd4)AS v_thd4, MEAN(v_thd5)AS v_thd5, MEAN(event1)AS event1, MEAN(event2)AS event2, MEAN(event3)AS event3, MEAN(event4)AS event4, MEAN(event5)AS event5");
// StringBuffer string = new StringBuffer();
// string.append(InfluxDBPublicParam.TIME + " >= '" + searchBeginTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + searchEndTime + InfluxDBPublicParam.END_TIME + "' and ");
// for (int i = 0; i < lineIndexes.size(); i++) {
// if (lineIndexes.size() - i != 1) {
// string.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
// } else {
// string.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' group by " + InfluxDBPublicParam.LINE_ID);
// }
// }
// //sql语句
// String sql = "SELECT "+ builder +" FROM "+InfluxDBPublicParam.PQS_COMASSES+" WHERE " + string + InfluxDBPublicParam.TIME_ZONE;
// //结果集
// System.out.println("--------------->>>>"+sql);
// QueryResult result = influxDbUtils.query(sql);
// //结果集映射到对象中
// InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
// List<PQSComAssesPO> pqsComAssesPOS = resultMapper.toPOJO(result, PQSComAssesPO.class);
// return pqsComAssesPOS;
}

View File

@@ -1,21 +1,23 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.common.config.GeneralInfo;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.enums.LineBaseEnum;
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.vo.RStatIntegrityVO;
import com.njcn.harmonic.mapper.IntegrityMapper;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.vo.IntegrityIconVO;
import com.njcn.harmonic.pojo.vo.IntegrityVO;
import com.njcn.harmonic.service.IntegrityService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.poi.pojo.bo.BaseLineExcelBody;
@@ -25,7 +27,6 @@ import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -56,6 +57,8 @@ public class IntegrityServiceImpl implements IntegrityService {
private final GeneralInfo generalInfo;
private final LineFeignClient lineFeignClient;
@Override
public List<IntegrityVO> getIntegrityData(DeviceInfoParam.BusinessParam integrityParam) {
List<IntegrityVO> result = new ArrayList<>();
@@ -212,7 +215,7 @@ public class IntegrityServiceImpl implements IntegrityService {
log.error("文件路径" + targetDir);
log.error("文件名" + fileName);
File parentDir = new File(targetDir);
if(!parentDir.exists()){
if (!parentDir.exists()) {
parentDir.mkdirs();
}
File excel = new File(targetDir, fileName);
@@ -350,39 +353,58 @@ public class IntegrityServiceImpl implements IntegrityService {
*/
private List<PublicDTO> getCondition(List<String> lineList, String startTime, String endTime) {
List<PublicDTO> integrityList = new ArrayList<>();
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
for (int i = 0; i < lineList.size(); i++) {
if (lineList.size() - i != 1) {
stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList.get(i)).append("' or ");
} else {
stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList.get(i)).append("')");
}
}
//sql语句
String sql = "SELECT SUM(" + InfluxDBPublicParam.REAL + ")/SUM(" + InfluxDBPublicParam.DUE + ")*100 AS integrity FROM "+InfluxDBPublicParam.PQS_INTEGRITY+" WHERE " + stringBuilder + " group by " + InfluxDBPublicParam.LINE_ID + " tz('Asia/Shanghai')";
//结果集
QueryResult result = influxDbUtils.query(sql);
//处理结果集
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
if (!CollectionUtils.isEmpty(list)) {
list.forEach(po -> {
OnlineRateParam param = new OnlineRateParam();
param.setIds(lineList);
param.setStartTime(DateUtil.beginOfDay(DateUtil.parse(startTime)).toString());
param.setEndTime(DateUtil.endOfDay(DateUtil.parse(endTime)).toString());
List<RStatIntegrityVO> data = lineFeignClient.getOnIntegrityByIds(param).getData();
if (!CollectionUtils.isEmpty(data)) {
data.forEach(po -> {
PublicDTO publicDTO = new PublicDTO();
List<List<Object>> valueList = po.getValues();
String index = po.getTags().get(InfluxDBPublicParam.LINE_ID);
if (!CollectionUtils.isEmpty(valueList)) {
for (List<Object> value : valueList) {
//数据完整性 保留四位小数
Double integrity = value.get(1) == null ? 3.14159 : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, RoundingMode.HALF_UP).doubleValue();
publicDTO.setId(index);
Double integrity = po.getIntegrityRate() == null ? 3.14159 : BigDecimal.valueOf(Double.parseDouble(po.getIntegrityRate().toString())).setScale(2, RoundingMode.HALF_UP).doubleValue();
publicDTO.setId(po.getLineIndex());
publicDTO.setData((integrity > 100.00) ? 100.00 : integrity);
}
}
integrityList.add(publicDTO);
});
}
return integrityList;
// //组装sql语句
// StringBuilder stringBuilder = new StringBuilder();
// stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
// for (int i = 0; i < lineList.size(); i++) {
// if (lineList.size() - i != 1) {
// stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList.get(i)).append("' or ");
// } else {
// stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList.get(i)).append("')");
// }
// }
// //sql语句
// String sql = "SELECT SUM(" + InfluxDBPublicParam.REAL + ")/SUM(" + InfluxDBPublicParam.DUE + ")*100 AS integrity FROM "+InfluxDBPublicParam.PQS_INTEGRITY+" WHERE " + stringBuilder + " group by " + InfluxDBPublicParam.LINE_ID + " tz('Asia/Shanghai')";
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
// if (!CollectionUtils.isEmpty(list)) {
// list.forEach(po -> {
// PublicDTO publicDTO = new PublicDTO();
// List<List<Object>> valueList = po.getValues();
// String index = po.getTags().get(InfluxDBPublicParam.LINE_ID);
// if (!CollectionUtils.isEmpty(valueList)) {
// for (List<Object> value : valueList) {
// //数据完整性 保留四位小数
// Double integrity = value.get(1) == null ? 3.14159 : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, RoundingMode.HALF_UP).doubleValue();
// publicDTO.setId(index);
// publicDTO.setData((integrity > 100.00) ? 100.00 : integrity);
// }
// }
// integrityList.add(publicDTO);
// });
// }
// return integrityList;
}
}

View File

@@ -1,10 +1,15 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.common.config.GeneralInfo;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
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.OnlineRate;
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
import com.njcn.harmonic.mapper.OnlineRateDataMapper;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.vo.OnlineRateCensusVO;
@@ -144,39 +149,57 @@ public class OnlineRateDataServiceImpl implements OnlineRateDataService {
*/
private List<PublicDTO> getCondition(List<String> deviceIndexes, String startTime, String endTime) {
List<PublicDTO> publicDTOList = new ArrayList<>();
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(TIME + " >= '").append(startTime).append(START_TIME).append("' and ").append(TIME).append(" <= '").append(endTime).append(END_TIME).append("' and (");
for (int i = 0; i < deviceIndexes.size(); i++) {
if (deviceIndexes.size() - i != 1) {
stringBuilder.append(DEV_INDEX + "='").append(deviceIndexes.get(i)).append("' or ");
} else {
stringBuilder.append(DEV_INDEX + "='").append(deviceIndexes.get(i)).append("')");
}
}
//sql语句
String sql = "SELECT (SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")))*100 AS onlineRate FROM "+PQS_ONLINERATE+" WHERE " + stringBuilder + " group by " + DEV_INDEX +" tz('Asia/Shanghai')";
//结果集
QueryResult result = influxDbUtils.query(sql);
//处理结果集
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
if (!CollectionUtils.isEmpty(list)) {
list.forEach(po -> {
OnlineRateParam param=new OnlineRateParam();
param.setIds(deviceIndexes);
param.setStartTime( DateUtil.beginOfDay(DateUtil.parse(startTime)).toString());
param.setEndTime( DateUtil.endOfDay(DateUtil.parse(endTime)).toString());
List<RStatOnlinerateVO> data = generalDeviceInfoClient.getOnlineRateByDevIds(param).getData();
if (CollUtil.isNotEmpty(data)) {
data.forEach(po -> {
PublicDTO publicDTO = new PublicDTO();
List<List<Object>> valueList = po.getValues();
String index = po.getTags().get(DEV_INDEX);
if (!CollectionUtils.isEmpty(valueList)) {
for (List<Object> value : valueList) {
//终端在线率 保留两位小数
Double onlineRate = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
publicDTO.setId(index);
Double onlineRate = po.getOnlineRate() == null ? null : BigDecimal.valueOf(Double.parseDouble(po.getOnlineRate().toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
publicDTO.setId(po.getDevIndex());
publicDTO.setData(onlineRate);
}
}
publicDTOList.add(publicDTO);
});
}
return publicDTOList;
// //组装sql语句
// StringBuilder stringBuilder = new StringBuilder();
// stringBuilder.append(TIME + " >= '").append(startTime).append(START_TIME).append("' and ").append(TIME).append(" <= '").append(endTime).append(END_TIME).append("' and (");
// for (int i = 0; i < deviceIndexes.size(); i++) {
// if (deviceIndexes.size() - i != 1) {
// stringBuilder.append(DEV_INDEX + "='").append(deviceIndexes.get(i)).append("' or ");
// } else {
// stringBuilder.append(DEV_INDEX + "='").append(deviceIndexes.get(i)).append("')");
// }
// }
// //sql语句
// String sql = "SELECT (SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")))*100 AS onlineRate FROM "+PQS_ONLINERATE+" WHERE " + stringBuilder + " group by " + DEV_INDEX +" tz('Asia/Shanghai')";
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
// if (!CollectionUtils.isEmpty(list)) {
// list.forEach(po -> {
// PublicDTO publicDTO = new PublicDTO();
// List<List<Object>> valueList = po.getValues();
// String index = po.getTags().get(DEV_INDEX);
// if (!CollectionUtils.isEmpty(valueList)) {
// for (List<Object> value : valueList) {
// //终端在线率 保留两位小数
// Double onlineRate = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// publicDTO.setId(index);
// publicDTO.setData(onlineRate);
// }
// }
// publicDTOList.add(publicDTO);
// });
// }
// return publicDTOList;
}

View File

@@ -0,0 +1,20 @@
package com.njcn.harmonic.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.harmonic.mapper.RStatDataVDMapper;
import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.service.IRStatDataVDService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wr
* @since 2023-03-31
*/
@Service
public class RStatDataVDServiceImpl extends ServiceImpl<RStatDataVDMapper, RStatDataVD> implements IRStatDataVDService {
}

View File

@@ -0,0 +1,20 @@
package com.njcn.harmonic.service.impl;
import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.service.IRStatLimitRateDService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 合格率统计日表(越限次数) 服务实现类
* </p>
*
* @author wr
* @since 2023-04-03
*/
@Service
public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMapper, RStatLimitRateDPO> implements IRStatLimitRateDService {
}

View File

@@ -1,6 +1,11 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.device.pq.pojo.param.PulicTimeStatisParam;
import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.pojo.vo.RStatLimitRateDVO;
import com.njcn.harmonic.pojo.vo.SteadyInfoData;
import com.njcn.harmonic.service.SteadyDataService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
@@ -15,6 +20,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -27,6 +33,7 @@ import java.util.List;
public class SteadyDataServiceImpl implements SteadyDataService {
private final InfluxDbUtils influxDbUtils;
private final RStatLimitRateDMapper rateDMapper;
@Override
public SteadyInfoData getSteadyData(PulicTimeStatisParam pulicTimeStatisParam) {
@@ -47,36 +54,11 @@ public class SteadyDataServiceImpl implements SteadyDataService {
SteadyDataVO steadyDataVO = new SteadyDataVO();
SteadyDataVO steadyData = new SteadyDataVO();
if (!lineList.isEmpty() || StringUtils.isNotBlank(lineList)) {
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
//sql语句
stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList).append("') ");
stringBuilder.append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT" +
" SUM( all_time ) AS alltime," +
" SUM( freq_dev_overtime ) AS frequency," +
" SUM( ubalance_overtime ) AS uBalance," +
" SUM( i_neg_overtime ) AS iNeg," +
" SUM( iharm_13_overtime) AS harmElec," +
" SUM( uharm_4_overtime) AS harmVoltage," +
" SUM( flicker_overtime ) AS flicker," +
" SUM( flicker_all_time ) AS allFlicker," +
" SUM( voltage_dev_overtime ) AS voltageDeviation," +
" SUM( inuharm_9_overtime ) AS inUharm" +
" FROM" +
" limit_rate" +
" WHERE" +
" phasic_type = 'T'" +
" AND " + stringBuilder.toString();
//结果集
QueryResult result = influxDbUtils.query(sql);
//处理结果集
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
if (!CollectionUtils.isEmpty(list)) {
List<List<Object>> valueList = list.get(0).getValues();
List<Object> value = valueList.get(0);
if (new Double(String.valueOf(value.get(1))).intValue() == 0 || new Double(String.valueOf(value.get(1))).intValue() < 0) {
List<RStatLimitRateDVO> list = rateDMapper.getSumPassRate(Arrays.asList(lineList),
DateUtil.beginOfDay(DateUtil.parse(startTime)).toString(),
DateUtil.beginOfDay(DateUtil.parse(endTime)).toString());
if (CollUtil.isNotEmpty(list)) {
if (ObjectUtil.isNull(list.get(0))) {
steadyDataVO.setVoltageDeviation(3.14159f);
steadyDataVO.setUBalance(3.14159f);
steadyDataVO.setFlicker(3.14159f);
@@ -96,16 +78,16 @@ public class SteadyDataServiceImpl implements SteadyDataService {
SteadyDataVO steadyDataList = getSteadyAcc(steadyData);
return getSteadyData(steadyDataList);
} else {
steadyDataVO.setAllTime(Float.parseFloat(value.get(1).toString()));
steadyDataVO.setFrequency(Float.parseFloat(value.get(2).toString()));
steadyDataVO.setUBalance(Float.parseFloat(value.get(3).toString()));
steadyDataVO.setINeg(Float.parseFloat(value.get(4).toString()));
steadyDataVO.setHarmElec(Float.parseFloat(value.get(5).toString()));
steadyDataVO.setHarmVoltage(Float.parseFloat(value.get(6).toString()));
steadyDataVO.setFlicker(Float.parseFloat(value.get(7).toString()));
steadyDataVO.setAllFlicker(Float.parseFloat(value.get(8).toString()));
steadyDataVO.setVoltageDeviation(Float.parseFloat(value.get(9).toString()));
steadyDataVO.setInUharm(Float.parseFloat(value.get(10).toString()));
steadyDataVO.setAllTime(Float.parseFloat(list.get(0).getAlltime().toString()));
steadyDataVO.setFrequency(Float.parseFloat(list.get(0).getFrequency().toString()));
steadyDataVO.setUBalance(Float.parseFloat(list.get(0).getUBalance().toString()));
steadyDataVO.setINeg(Float.parseFloat(list.get(0).getINeg().toString()));
steadyDataVO.setHarmElec(Float.parseFloat(list.get(0).getHarmElec().toString()));
steadyDataVO.setHarmVoltage(Float.parseFloat(list.get(0).getHarmVoltage().toString()));
steadyDataVO.setFlicker(Float.parseFloat(list.get(0).getFlicker().toString()));
steadyDataVO.setAllFlicker(Float.parseFloat(list.get(0).getAllFlicker().toString()));
steadyDataVO.setVoltageDeviation(Float.parseFloat(list.get(0).getVoltageDeviation().toString()));
steadyDataVO.setInUharm(Float.parseFloat(list.get(0).getInUharm().toString()));
}
} else {
//有监测点,但是无数据的处理

View File

@@ -1,18 +1,25 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.mapper.SteadyExceedRateMapper;
import com.njcn.harmonic.pojo.dto.SteadyQualifyDTO;
import com.njcn.harmonic.pojo.po.LimitRatePO;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.SteadyExceedRateCensusVO;
import com.njcn.harmonic.pojo.vo.SteadyExceedRateVO;
import com.njcn.harmonic.service.IRStatLimitRateDService;
import com.njcn.harmonic.service.SteadyExceedRateService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
@@ -44,6 +51,8 @@ public class SteadyExceedRateServiceImpl implements SteadyExceedRateService {
private final InfluxDbUtils influxDbUtils;
private final IRStatLimitRateDService rateDService;
@Override
public List<SteadyExceedRateVO> getSteadyExceedRateData(DeviceInfoParam.BusinessParam steadyExceedParam) {
List<SteadyExceedRateVO> steadyExceedRateVOS = new ArrayList<>();
@@ -410,44 +419,136 @@ public class SteadyExceedRateServiceImpl implements SteadyExceedRateService {
* @param endTime
*/
private List<LimitRatePO> getQualifiesRate(List<String> lineIndexes, String startTime, String endTime) {
List<LimitRatePO> limitRatePOS;
List<LimitRatePO> limitRatePOS = new ArrayList<>();
List<RStatLimitRateDPO> limitRates = rateDService.list(new LambdaQueryWrapper<RStatLimitRateDPO>()
.in(RStatLimitRateDPO::getLineId, lineIndexes)
.eq(RStatLimitRateDPO::getPhasicType,InfluxDBPublicParam.PHASIC_TYPET)
.ge(StrUtil.isNotBlank(startTime), RStatLimitRateDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
.le(StrUtil.isNotBlank(endTime), RStatLimitRateDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
);
if(CollUtil.isNotEmpty(limitRates)){
limitRates.forEach(list ->{
LimitRatePO limitRatePO = new LimitRatePO();
limitRatePO.setDayStr(DateUtil.format(list.getTime(),"yyyy-MM-dd"));
limitRatePO.setMouthStr(DateUtil.format(list.getTime(),"yyyy-MM"));
limitRatePO.setTime(list.getTime().toInstant());
limitRatePO.setLineId(list.getLineId());
limitRatePO.setPhasicType(list.getPhasicType());
limitRatePO.setAllTime(list.getAllTime());
limitRatePO.setFlickerAllTime(list.getFlickerAllTime());
limitRatePO.setFlickerOverTime(list.getFlickerOvertime());
limitRatePO.setFreqDevOverTime(list.getFreqDevOvertime());
limitRatePO.setIHarm2OverTime(list.getIharm2Overtime());
limitRatePO.setIHarm3OverTime(list.getIharm3Overtime());
limitRatePO.setIHarm4OverTime(list.getIharm4Overtime());
limitRatePO.setIHarm5OverTime(list.getIharm5Overtime());
limitRatePO.setIHarm6OverTime(list.getIharm6Overtime());
limitRatePO.setIHarm7OverTime(list.getIharm7Overtime());
limitRatePO.setIHarm8OverTime(list.getIharm8Overtime());
limitRatePO.setIHarm9OverTime(list.getIharm9Overtime());
limitRatePO.setIHarm10OverTime(list.getIharm10Overtime());
limitRatePO.setIHarm11OverTime(list.getIharm11Overtime());
limitRatePO.setIHarm12OverTime(list.getIharm12Overtime());
limitRatePO.setIHarm13OverTime(list.getIharm13Overtime());
limitRatePO.setIHarm14OverTime(list.getIharm14Overtime());
limitRatePO.setIHarm15OverTime(list.getIharm15Overtime());
limitRatePO.setIHarm16OverTime(list.getIharm16Overtime());
limitRatePO.setIHarm17OverTime(list.getIharm17Overtime());
limitRatePO.setIHarm18OverTime(list.getIharm18Overtime());
limitRatePO.setIHarm19OverTime(list.getIharm19Overtime());
limitRatePO.setIHarm20OverTime(list.getIharm20Overtime());
limitRatePO.setIHarm21OverTime(list.getIharm21Overtime());
limitRatePO.setIHarm22OverTime(list.getIharm22Overtime());
limitRatePO.setIHarm23OverTime(list.getIharm23Overtime());
limitRatePO.setIHarm24OverTime(list.getIharm24Overtime());
limitRatePO.setIHarm25OverTime(list.getIharm25Overtime());
limitRatePO.setINegOverTime(list.getINegOvertime());
limitRatePO.setInUHARM1OverTime(list.getInuharm1Overtime());
limitRatePO.setInUHARM2OverTime(list.getInuharm2Overtime());
limitRatePO.setInUHARM3OverTime(list.getInuharm3Overtime());
limitRatePO.setInUHARM4OverTime(list.getInuharm4Overtime());
limitRatePO.setInUHARM5OverTime(list.getInuharm5Overtime());
limitRatePO.setInUHARM6OverTime(list.getInuharm6Overtime());
limitRatePO.setInUHARM7OverTime(list.getInuharm7Overtime());
limitRatePO.setInUHARM8OverTime(list.getInuharm8Overtime());
limitRatePO.setInUHARM9OverTime(list.getInuharm9Overtime());
limitRatePO.setInUHARM10OverTime(list.getInuharm10Overtime());
limitRatePO.setInUHARM11OverTime(list.getInuharm11Overtime());
limitRatePO.setInUHARM12OverTime(list.getInuharm12Overtime());
limitRatePO.setInUHARM13OverTime(list.getInuharm13Overtime());
limitRatePO.setInUHARM14OverTime(list.getInuharm14Overtime());
limitRatePO.setInUHARM15OverTime(list.getInuharm15Overtime());
limitRatePO.setInUHARM16OverTime(list.getInuharm16Overtime());
limitRatePO.setUAberranceOverTime(list.getUaberranceOvertime());
limitRatePO.setUBalanceOverTime(list.getUbalanceOvertime());
limitRatePO.setUHarm2OverTime(list.getUharm2Overtime());
limitRatePO.setUHarm3OverTime(list.getUharm3Overtime());
limitRatePO.setUHarm4OverTime(list.getUharm4Overtime());
limitRatePO.setUHarm5OverTime(list.getUharm5Overtime());
limitRatePO.setUHarm6OverTime(list.getUharm6Overtime());
limitRatePO.setUHarm7OverTime(list.getUharm7Overtime());
limitRatePO.setUHarm8OverTime(list.getUharm8Overtime());
limitRatePO.setUHarm9OverTime(list.getUharm9Overtime());
limitRatePO.setUHarm10OverTime(list.getUharm10Overtime());
limitRatePO.setUHarm11OverTime(list.getUharm11Overtime());
limitRatePO.setUHarm12OverTime(list.getUharm12Overtime());
limitRatePO.setUHarm13OverTime(list.getUharm13Overtime());
limitRatePO.setUHarm14OverTime(list.getUharm14Overtime());
limitRatePO.setUHarm15OverTime(list.getUharm15Overtime());
limitRatePO.setUHarm16OverTime(list.getUharm16Overtime());
limitRatePO.setUHarm17OverTime(list.getUharm17Overtime());
limitRatePO.setUHarm18OverTime(list.getUharm18Overtime());
limitRatePO.setUHarm19OverTime(list.getUharm19Overtime());
limitRatePO.setUHarm20OverTime(list.getUharm20Overtime());
limitRatePO.setUHarm21OverTime(list.getUharm21Overtime());
limitRatePO.setUHarm22OverTime(list.getUharm22Overtime());
limitRatePO.setUHarm23OverTime(list.getUharm23Overtime());
limitRatePO.setUHarm24OverTime(list.getUharm24Overtime());
limitRatePO.setUHarm25OverTime(list.getUharm25Overtime());
limitRatePO.setVoltageDevOverTime(list.getVoltageDevOvertime());
limitRatePOS.add(limitRatePO);
});
}
return limitRatePOS;
//组装sql语句
// StringBuilder string = new StringBuilder();
// string.append(Param.QualityFlag + "='1' and (" + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEA + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEB + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEC + "') and "+ Param.VALUETYPE + "='AVG' and ");
StringBuilder timeId = new StringBuilder();
timeId.append(InfluxDBPublicParam.PHASIC_TYPE + "='" + InfluxDBPublicParam.PHASIC_TYPET + "' and " + InfluxDBPublicParam.TIME + " >= '" + startTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + endTime + InfluxDBPublicParam.END_TIME + "' and ");
for (int i = 0; i < lineIndexes.size(); i++) {
if (lineIndexes.size() - i != 1) {
timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
} else {
timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' tz('Asia/Shanghai')");
}
}
//sql语句
String sql = "SELECT * FROM "+ InfluxDBPublicParam.LIMIT_RATE +" WHERE " + timeId;
//结果集
QueryResult result = influxDbUtils.query(sql);
// if (Objects.isNull(result.getResults().get(0).getSeries())) {
// throw new BusinessException(HarmonicResponseEnum.LIMIT_RATE_ERROR);
// }
//结果集映射到对象中
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
limitRatePOS = resultMapper.toPOJO(result, LimitRatePO.class);
//将时间处理为年月日的字符串
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
limitRatePOS.forEach(item->{
Instant instant = item.getTime();
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zoneId);
String dateStr = dateTimeFormatter.format(localDateTime);
String monthStr = monthFormatter.format(localDateTime);
item.setDayStr(dateStr);
item.setMouthStr(monthStr);
});
return limitRatePOS;
// StringBuilder timeId = new StringBuilder();
// timeId.append(InfluxDBPublicParam.PHASIC_TYPE + "='" + InfluxDBPublicParam.PHASIC_TYPET + "' and " + InfluxDBPublicParam.TIME + " >= '" + startTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + endTime + InfluxDBPublicParam.END_TIME + "' and ");
// for (int i = 0; i < lineIndexes.size(); i++) {
// if (lineIndexes.size() - i != 1) {
// timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
// } else {
// timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' tz('Asia/Shanghai')");
// }
// }
// //sql语句
// String sql = "SELECT * FROM "+ InfluxDBPublicParam.LIMIT_RATE +" WHERE " + timeId;
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// // if (Objects.isNull(result.getResults().get(0).getSeries())) {
// // throw new BusinessException(HarmonicResponseEnum.LIMIT_RATE_ERROR);
// // }
// //结果集映射到对象中
// InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
// limitRatePOS = resultMapper.toPOJO(result, LimitRatePO.class);
// //将时间处理为年月日的字符串
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
// limitRatePOS.forEach(item->{
// Instant instant = item.getTime();
// ZoneId zoneId = ZoneId.systemDefault();
// LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zoneId);
// String dateStr = dateTimeFormatter.format(localDateTime);
// String monthStr = monthFormatter.format(localDateTime);
// item.setDayStr(dateStr);
// item.setMouthStr(monthStr);
// });
//
//
// return limitRatePOS;
}
}

View File

@@ -1,7 +1,12 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
@@ -9,8 +14,10 @@ import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.mapper.SteadyQualifyMapper;
import com.njcn.harmonic.pojo.dto.SteadyQualifyDTO;
import com.njcn.harmonic.pojo.po.LimitRate;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.SteadyQualifyCensusVO;
import com.njcn.harmonic.pojo.vo.SteadyQualifyVO;
import com.njcn.harmonic.service.IRStatLimitRateDService;
import com.njcn.harmonic.service.SteadyQualifyService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
@@ -41,6 +48,8 @@ public class SteadyQualifyServiceImpl implements SteadyQualifyService {
private final InfluxDbUtils influxDbUtils;
private final IRStatLimitRateDService rateDService;
@Override
public List<SteadyQualifyVO> getSteadyQualifyData(DeviceInfoParam.BusinessParam steadyParam) {
List<SteadyQualifyVO> steadyQualifyList = new ArrayList<>();
@@ -407,107 +416,195 @@ public class SteadyQualifyServiceImpl implements SteadyQualifyService {
*/
private List<SteadyQualifyDTO> getQualifiesRate(List<String> lineIndexes, String startTime, String endTime) {
List<SteadyQualifyDTO> qualifyDTOList = new ArrayList<>();
//组装sql语句
StringBuilder timeId = new StringBuilder();
timeId.append(InfluxDBPublicParam.TIME + " >= '" + startTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + endTime + InfluxDBPublicParam.END_TIME + "' and ");
for (int i = 0; i < lineIndexes.size(); i++) {
if (lineIndexes.size() - i != 1) {
timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
} else {
timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' tz('Asia/Shanghai')");
}
}
//sql语句
String sql = "SELECT * FROM "+ InfluxDBPublicParam.LIMIT_RATE +" WHERE " + timeId;
//结果集
QueryResult result = influxDbUtils.query(sql);
//结果集映射到对象中
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<LimitRate> limitRates = influxDBResultMapper.toPOJO(result, LimitRate.class);
List<RStatLimitRateDPO> limitRates = rateDService.list(new LambdaQueryWrapper<RStatLimitRateDPO>()
.in(RStatLimitRateDPO::getLineId, lineIndexes)
.ge(StrUtil.isNotBlank(startTime), RStatLimitRateDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
.le(StrUtil.isNotBlank(endTime), RStatLimitRateDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
);
if(CollUtil.isNotEmpty(limitRates)){
limitRates.forEach(list ->{
SteadyQualifyDTO steadyQualifyDTO = new SteadyQualifyDTO();
LocalDateTime localDateTime = LocalDateTime.ofInstant(list.getTime(), ZoneId.systemDefault());
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
steadyQualifyDTO.setTime(dateTimeFormatter.format(localDateTime));
steadyQualifyDTO.setTime(DateUtil.format(list.getTime(),"yyyy-MM-dd HH:mm:ss.SSS"));
steadyQualifyDTO.setMYINDEX(list.getLineId());
steadyQualifyDTO.setPhasic_Type(list.getPhasicType());
steadyQualifyDTO.setAllTime(Double.parseDouble(list.getAllTime().toString()));
steadyQualifyDTO.setFlicker_AllTime(Double.parseDouble(list.getFlickerAllTime().toString()));
steadyQualifyDTO.setFlicker_OverTime(Double.parseDouble(list.getFlickerOverTime().toString()));
steadyQualifyDTO.setFreq_Dev_OverTime(Double.parseDouble(list.getFreqDevOverTime().toString()));
steadyQualifyDTO.setIHarm_2_OverTime(Double.parseDouble(list.getIHarm2OverTime().toString()));
steadyQualifyDTO.setIHarm_3_OverTime(Double.parseDouble(list.getIHarm3OverTime().toString()));
steadyQualifyDTO.setIHarm_4_OverTime(Double.parseDouble(list.getIHarm4OverTime().toString()));
steadyQualifyDTO.setIHarm_5_OverTime(Double.parseDouble(list.getIHarm5OverTime().toString()));
steadyQualifyDTO.setIHarm_6_OverTime(Double.parseDouble(list.getIHarm6OverTime().toString()));
steadyQualifyDTO.setIHarm_7_OverTime(Double.parseDouble(list.getIHarm7OverTime().toString()));
steadyQualifyDTO.setIHarm_8_OverTime(Double.parseDouble(list.getIHarm8OverTime().toString()));
steadyQualifyDTO.setIHarm_9_OverTime(Double.parseDouble(list.getIHarm9OverTime().toString()));
steadyQualifyDTO.setIHarm_10_OverTime(Double.parseDouble(list.getIHarm10OverTime().toString()));
steadyQualifyDTO.setIHarm_11_OverTime(Double.parseDouble(list.getIHarm11OverTime().toString()));
steadyQualifyDTO.setIHarm_12_OverTime(Double.parseDouble(list.getIHarm12OverTime().toString()));
steadyQualifyDTO.setIHarm_13_OverTime(Double.parseDouble(list.getIHarm13OverTime().toString()));
steadyQualifyDTO.setIHarm_14_OverTime(Double.parseDouble(list.getIHarm14OverTime().toString()));
steadyQualifyDTO.setIHarm_15_OverTime(Double.parseDouble(list.getIHarm15OverTime().toString()));
steadyQualifyDTO.setIHarm_16_OverTime(Double.parseDouble(list.getIHarm16OverTime().toString()));
steadyQualifyDTO.setIHarm_17_OverTime(Double.parseDouble(list.getIHarm17OverTime().toString()));
steadyQualifyDTO.setIHarm_18_OverTime(Double.parseDouble(list.getIHarm18OverTime().toString()));
steadyQualifyDTO.setIHarm_19_OverTime(Double.parseDouble(list.getIHarm19OverTime().toString()));
steadyQualifyDTO.setIHarm_20_OverTime(Double.parseDouble(list.getIHarm20OverTime().toString()));
steadyQualifyDTO.setIHarm_21_OverTime(Double.parseDouble(list.getIHarm21OverTime().toString()));
steadyQualifyDTO.setIHarm_22_OverTime(Double.parseDouble(list.getIHarm22OverTime().toString()));
steadyQualifyDTO.setIHarm_23_OverTime(Double.parseDouble(list.getIHarm23OverTime().toString()));
steadyQualifyDTO.setIHarm_24_OverTime(Double.parseDouble(list.getIHarm24OverTime().toString()));
steadyQualifyDTO.setIHarm_25_OverTime(Double.parseDouble(list.getIHarm25OverTime().toString()));
steadyQualifyDTO.setI_Neg_OverTime(Double.parseDouble(list.getINegOverTime().toString()));
steadyQualifyDTO.setInUHARM_1_OverTime(Double.parseDouble(list.getInuHarm1OverTime().toString()));
steadyQualifyDTO.setInUHARM_2_OverTime(Double.parseDouble(list.getInuHarm2OverTime().toString()));
steadyQualifyDTO.setInUHARM_3_OverTime(Double.parseDouble(list.getInuHarm3OverTime().toString()));
steadyQualifyDTO.setInUHARM_4_OverTime(Double.parseDouble(list.getInuHarm4OverTime().toString()));
steadyQualifyDTO.setInUHARM_5_OverTime(Double.parseDouble(list.getInuHarm5OverTime().toString()));
steadyQualifyDTO.setInUHARM_6_OverTime(Double.parseDouble(list.getInuHarm6OverTime().toString()));
steadyQualifyDTO.setInUHARM_7_OverTime(Double.parseDouble(list.getInuHarm7OverTime().toString()));
steadyQualifyDTO.setInUHARM_8_OverTime(Double.parseDouble(list.getInuHarm8OverTime().toString()));
steadyQualifyDTO.setInUHARM_9_OverTime(Double.parseDouble(list.getInuHarm9OverTime().toString()));
steadyQualifyDTO.setInUHARM_10_OverTime(Double.parseDouble(list.getInuHarm10OverTime().toString()));
steadyQualifyDTO.setInUHARM_11_OverTime(Double.parseDouble(list.getInuHarm11OverTime().toString()));
steadyQualifyDTO.setInUHARM_12_OverTime(Double.parseDouble(list.getInuHarm12OverTime().toString()));
steadyQualifyDTO.setInUHARM_13_OverTime(Double.parseDouble(list.getInuHarm13OverTime().toString()));
steadyQualifyDTO.setInUHARM_14_OverTime(Double.parseDouble(list.getInuHarm14OverTime().toString()));
steadyQualifyDTO.setInUHARM_15_OverTime(Double.parseDouble(list.getInuHarm15OverTime().toString()));
steadyQualifyDTO.setInUHARM_16_OverTime(Double.parseDouble(list.getInuHarm16OverTime().toString()));
steadyQualifyDTO.setUAberrance_OverTime(Double.parseDouble(list.getUAberranceOverTime().toString()));
steadyQualifyDTO.setUBalance_OverTime(Double.parseDouble(list.getUBalanceOverTime().toString()));
steadyQualifyDTO.setUHarm_2_OverTime(Double.parseDouble(list.getUHarm2OverTime().toString()));
steadyQualifyDTO.setUHarm_3_OverTime(Double.parseDouble(list.getUHarm3OverTime().toString()));
steadyQualifyDTO.setUHarm_4_OverTime(Double.parseDouble(list.getUHarm4OverTime().toString()));
steadyQualifyDTO.setUHarm_5_OverTime(Double.parseDouble(list.getUHarm5OverTime().toString()));
steadyQualifyDTO.setUHarm_6_OverTime(Double.parseDouble(list.getUHarm6OverTime().toString()));
steadyQualifyDTO.setUHarm_7_OverTime(Double.parseDouble(list.getUHarm7OverTime().toString()));
steadyQualifyDTO.setUHarm_8_OverTime(Double.parseDouble(list.getUHarm8OverTime().toString()));
steadyQualifyDTO.setUHarm_9_OverTime(Double.parseDouble(list.getUHarm9OverTime().toString()));
steadyQualifyDTO.setUHarm_10_OverTime(Double.parseDouble(list.getUHarm10OverTime().toString()));
steadyQualifyDTO.setUHarm_11_OverTime(Double.parseDouble(list.getUHarm11OverTime().toString()));
steadyQualifyDTO.setUHarm_12_OverTime(Double.parseDouble(list.getUHarm12OverTime().toString()));
steadyQualifyDTO.setUHarm_13_OverTime(Double.parseDouble(list.getUHarm13OverTime().toString()));
steadyQualifyDTO.setUHarm_14_OverTime(Double.parseDouble(list.getUHarm14OverTime().toString()));
steadyQualifyDTO.setUHarm_15_OverTime(Double.parseDouble(list.getUHarm15OverTime().toString()));
steadyQualifyDTO.setUHarm_16_OverTime(Double.parseDouble(list.getUHarm16OverTime().toString()));
steadyQualifyDTO.setUHarm_17_OverTime(Double.parseDouble(list.getUHarm17OverTime().toString()));
steadyQualifyDTO.setUHarm_18_OverTime(Double.parseDouble(list.getUHarm18OverTime().toString()));
steadyQualifyDTO.setUHarm_19_OverTime(Double.parseDouble(list.getUHarm19OverTime().toString()));
steadyQualifyDTO.setUHarm_20_OverTime(Double.parseDouble(list.getUHarm20OverTime().toString()));
steadyQualifyDTO.setUHarm_21_OverTime(Double.parseDouble(list.getUHarm21OverTime().toString()));
steadyQualifyDTO.setUHarm_22_OverTime(Double.parseDouble(list.getUHarm22OverTime().toString()));
steadyQualifyDTO.setUHarm_23_OverTime(Double.parseDouble(list.getUHarm23OverTime().toString()));
steadyQualifyDTO.setUHarm_24_OverTime(Double.parseDouble(list.getUHarm24OverTime().toString()));
steadyQualifyDTO.setUHarm_25_OverTime(Double.parseDouble(list.getUHarm25OverTime().toString()));
steadyQualifyDTO.setVoltage_Dev_OverTime(Double.parseDouble(list.getVoltageDevOverTime().toString()));
steadyQualifyDTO.setFlicker_OverTime(Double.parseDouble(list.getFlickerOvertime().toString()));
steadyQualifyDTO.setFreq_Dev_OverTime(Double.parseDouble(list.getFreqDevOvertime().toString()));
steadyQualifyDTO.setIHarm_2_OverTime(Double.parseDouble(list.getIharm2Overtime().toString()));
steadyQualifyDTO.setIHarm_3_OverTime(Double.parseDouble(list.getIharm3Overtime().toString()));
steadyQualifyDTO.setIHarm_4_OverTime(Double.parseDouble(list.getIharm4Overtime().toString()));
steadyQualifyDTO.setIHarm_5_OverTime(Double.parseDouble(list.getIharm5Overtime().toString()));
steadyQualifyDTO.setIHarm_6_OverTime(Double.parseDouble(list.getIharm6Overtime().toString()));
steadyQualifyDTO.setIHarm_7_OverTime(Double.parseDouble(list.getIharm7Overtime().toString()));
steadyQualifyDTO.setIHarm_8_OverTime(Double.parseDouble(list.getIharm8Overtime().toString()));
steadyQualifyDTO.setIHarm_9_OverTime(Double.parseDouble(list.getIharm9Overtime().toString()));
steadyQualifyDTO.setIHarm_10_OverTime(Double.parseDouble(list.getIharm10Overtime().toString()));
steadyQualifyDTO.setIHarm_11_OverTime(Double.parseDouble(list.getIharm11Overtime().toString()));
steadyQualifyDTO.setIHarm_12_OverTime(Double.parseDouble(list.getIharm12Overtime().toString()));
steadyQualifyDTO.setIHarm_13_OverTime(Double.parseDouble(list.getIharm13Overtime().toString()));
steadyQualifyDTO.setIHarm_14_OverTime(Double.parseDouble(list.getIharm14Overtime().toString()));
steadyQualifyDTO.setIHarm_15_OverTime(Double.parseDouble(list.getIharm15Overtime().toString()));
steadyQualifyDTO.setIHarm_16_OverTime(Double.parseDouble(list.getIharm16Overtime().toString()));
steadyQualifyDTO.setIHarm_17_OverTime(Double.parseDouble(list.getIharm17Overtime().toString()));
steadyQualifyDTO.setIHarm_18_OverTime(Double.parseDouble(list.getIharm18Overtime().toString()));
steadyQualifyDTO.setIHarm_19_OverTime(Double.parseDouble(list.getIharm19Overtime().toString()));
steadyQualifyDTO.setIHarm_20_OverTime(Double.parseDouble(list.getIharm20Overtime().toString()));
steadyQualifyDTO.setIHarm_21_OverTime(Double.parseDouble(list.getIharm21Overtime().toString()));
steadyQualifyDTO.setIHarm_22_OverTime(Double.parseDouble(list.getIharm22Overtime().toString()));
steadyQualifyDTO.setIHarm_23_OverTime(Double.parseDouble(list.getIharm23Overtime().toString()));
steadyQualifyDTO.setIHarm_24_OverTime(Double.parseDouble(list.getIharm24Overtime().toString()));
steadyQualifyDTO.setIHarm_25_OverTime(Double.parseDouble(list.getIharm25Overtime().toString()));
steadyQualifyDTO.setI_Neg_OverTime(Double.parseDouble(list.getINegOvertime().toString()));
steadyQualifyDTO.setInUHARM_1_OverTime(Double.parseDouble(list.getInuharm1Overtime().toString()));
steadyQualifyDTO.setInUHARM_2_OverTime(Double.parseDouble(list.getInuharm2Overtime().toString()));
steadyQualifyDTO.setInUHARM_3_OverTime(Double.parseDouble(list.getInuharm3Overtime().toString()));
steadyQualifyDTO.setInUHARM_4_OverTime(Double.parseDouble(list.getInuharm4Overtime().toString()));
steadyQualifyDTO.setInUHARM_5_OverTime(Double.parseDouble(list.getInuharm5Overtime().toString()));
steadyQualifyDTO.setInUHARM_6_OverTime(Double.parseDouble(list.getInuharm6Overtime().toString()));
steadyQualifyDTO.setInUHARM_7_OverTime(Double.parseDouble(list.getInuharm7Overtime().toString()));
steadyQualifyDTO.setInUHARM_8_OverTime(Double.parseDouble(list.getInuharm8Overtime().toString()));
steadyQualifyDTO.setInUHARM_9_OverTime(Double.parseDouble(list.getInuharm9Overtime().toString()));
steadyQualifyDTO.setInUHARM_10_OverTime(Double.parseDouble(list.getInuharm10Overtime().toString()));
steadyQualifyDTO.setInUHARM_11_OverTime(Double.parseDouble(list.getInuharm11Overtime().toString()));
steadyQualifyDTO.setInUHARM_12_OverTime(Double.parseDouble(list.getInuharm12Overtime().toString()));
steadyQualifyDTO.setInUHARM_13_OverTime(Double.parseDouble(list.getInuharm13Overtime().toString()));
steadyQualifyDTO.setInUHARM_14_OverTime(Double.parseDouble(list.getInuharm14Overtime().toString()));
steadyQualifyDTO.setInUHARM_15_OverTime(Double.parseDouble(list.getInuharm15Overtime().toString()));
steadyQualifyDTO.setInUHARM_16_OverTime(Double.parseDouble(list.getInuharm16Overtime().toString()));
steadyQualifyDTO.setUAberrance_OverTime(Double.parseDouble(list.getUaberranceOvertime().toString()));
steadyQualifyDTO.setUBalance_OverTime(Double.parseDouble(list.getUbalanceOvertime().toString()));
steadyQualifyDTO.setUHarm_2_OverTime(Double.parseDouble(list.getUharm2Overtime().toString()));
steadyQualifyDTO.setUHarm_3_OverTime(Double.parseDouble(list.getUharm3Overtime().toString()));
steadyQualifyDTO.setUHarm_4_OverTime(Double.parseDouble(list.getUharm4Overtime().toString()));
steadyQualifyDTO.setUHarm_5_OverTime(Double.parseDouble(list.getUharm5Overtime().toString()));
steadyQualifyDTO.setUHarm_6_OverTime(Double.parseDouble(list.getUharm6Overtime().toString()));
steadyQualifyDTO.setUHarm_7_OverTime(Double.parseDouble(list.getUharm7Overtime().toString()));
steadyQualifyDTO.setUHarm_8_OverTime(Double.parseDouble(list.getUharm8Overtime().toString()));
steadyQualifyDTO.setUHarm_9_OverTime(Double.parseDouble(list.getUharm9Overtime().toString()));
steadyQualifyDTO.setUHarm_10_OverTime(Double.parseDouble(list.getUharm10Overtime().toString()));
steadyQualifyDTO.setUHarm_11_OverTime(Double.parseDouble(list.getUharm11Overtime().toString()));
steadyQualifyDTO.setUHarm_12_OverTime(Double.parseDouble(list.getUharm12Overtime().toString()));
steadyQualifyDTO.setUHarm_13_OverTime(Double.parseDouble(list.getUharm13Overtime().toString()));
steadyQualifyDTO.setUHarm_14_OverTime(Double.parseDouble(list.getUharm14Overtime().toString()));
steadyQualifyDTO.setUHarm_15_OverTime(Double.parseDouble(list.getUharm15Overtime().toString()));
steadyQualifyDTO.setUHarm_16_OverTime(Double.parseDouble(list.getUharm16Overtime().toString()));
steadyQualifyDTO.setUHarm_17_OverTime(Double.parseDouble(list.getUharm17Overtime().toString()));
steadyQualifyDTO.setUHarm_18_OverTime(Double.parseDouble(list.getUharm18Overtime().toString()));
steadyQualifyDTO.setUHarm_19_OverTime(Double.parseDouble(list.getUharm19Overtime().toString()));
steadyQualifyDTO.setUHarm_20_OverTime(Double.parseDouble(list.getUharm20Overtime().toString()));
steadyQualifyDTO.setUHarm_21_OverTime(Double.parseDouble(list.getUharm21Overtime().toString()));
steadyQualifyDTO.setUHarm_22_OverTime(Double.parseDouble(list.getUharm22Overtime().toString()));
steadyQualifyDTO.setUHarm_23_OverTime(Double.parseDouble(list.getUharm23Overtime().toString()));
steadyQualifyDTO.setUHarm_24_OverTime(Double.parseDouble(list.getUharm24Overtime().toString()));
steadyQualifyDTO.setUHarm_25_OverTime(Double.parseDouble(list.getUharm25Overtime().toString()));
steadyQualifyDTO.setVoltage_Dev_OverTime(Double.parseDouble(list.getVoltageDevOvertime().toString()));
qualifyDTOList.add(steadyQualifyDTO);
});
}
return qualifyDTOList;
// //组装sql语句
// StringBuilder timeId = new StringBuilder();
// timeId.append(InfluxDBPublicParam.TIME + " >= '" + startTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + endTime + InfluxDBPublicParam.END_TIME + "' and ");
// for (int i = 0; i < lineIndexes.size(); i++) {
// if (lineIndexes.size() - i != 1) {
// timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
// } else {
// timeId.append(InfluxDBPublicParam.LINE_ID + "='").append(lineIndexes.get(i)).append("' tz('Asia/Shanghai')");
// }
// }
// //sql语句
// String sql = "SELECT * FROM "+ InfluxDBPublicParam.LIMIT_RATE +" WHERE " + timeId;
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //结果集映射到对象中
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
// List<LimitRate> limitRates = influxDBResultMapper.toPOJO(result, LimitRate.class);
// limitRates.forEach(list ->{
// SteadyQualifyDTO steadyQualifyDTO = new SteadyQualifyDTO();
// LocalDateTime localDateTime = LocalDateTime.ofInstant(list.getTime(), ZoneId.systemDefault());
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
// steadyQualifyDTO.setTime(dateTimeFormatter.format(localDateTime));
// steadyQualifyDTO.setMYINDEX(list.getLineId());
// steadyQualifyDTO.setPhasic_Type(list.getPhasicType());
// steadyQualifyDTO.setAllTime(Double.parseDouble(list.getAllTime().toString()));
// steadyQualifyDTO.setFlicker_AllTime(Double.parseDouble(list.getFlickerAllTime().toString()));
// steadyQualifyDTO.setFlicker_OverTime(Double.parseDouble(list.getFlickerOverTime().toString()));
// steadyQualifyDTO.setFreq_Dev_OverTime(Double.parseDouble(list.getFreqDevOverTime().toString()));
// steadyQualifyDTO.setIHarm_2_OverTime(Double.parseDouble(list.getIHarm2OverTime().toString()));
// steadyQualifyDTO.setIHarm_3_OverTime(Double.parseDouble(list.getIHarm3OverTime().toString()));
// steadyQualifyDTO.setIHarm_4_OverTime(Double.parseDouble(list.getIHarm4OverTime().toString()));
// steadyQualifyDTO.setIHarm_5_OverTime(Double.parseDouble(list.getIHarm5OverTime().toString()));
// steadyQualifyDTO.setIHarm_6_OverTime(Double.parseDouble(list.getIHarm6OverTime().toString()));
// steadyQualifyDTO.setIHarm_7_OverTime(Double.parseDouble(list.getIHarm7OverTime().toString()));
// steadyQualifyDTO.setIHarm_8_OverTime(Double.parseDouble(list.getIHarm8OverTime().toString()));
// steadyQualifyDTO.setIHarm_9_OverTime(Double.parseDouble(list.getIHarm9OverTime().toString()));
// steadyQualifyDTO.setIHarm_10_OverTime(Double.parseDouble(list.getIHarm10OverTime().toString()));
// steadyQualifyDTO.setIHarm_11_OverTime(Double.parseDouble(list.getIHarm11OverTime().toString()));
// steadyQualifyDTO.setIHarm_12_OverTime(Double.parseDouble(list.getIHarm12OverTime().toString()));
// steadyQualifyDTO.setIHarm_13_OverTime(Double.parseDouble(list.getIHarm13OverTime().toString()));
// steadyQualifyDTO.setIHarm_14_OverTime(Double.parseDouble(list.getIHarm14OverTime().toString()));
// steadyQualifyDTO.setIHarm_15_OverTime(Double.parseDouble(list.getIHarm15OverTime().toString()));
// steadyQualifyDTO.setIHarm_16_OverTime(Double.parseDouble(list.getIHarm16OverTime().toString()));
// steadyQualifyDTO.setIHarm_17_OverTime(Double.parseDouble(list.getIHarm17OverTime().toString()));
// steadyQualifyDTO.setIHarm_18_OverTime(Double.parseDouble(list.getIHarm18OverTime().toString()));
// steadyQualifyDTO.setIHarm_19_OverTime(Double.parseDouble(list.getIHarm19OverTime().toString()));
// steadyQualifyDTO.setIHarm_20_OverTime(Double.parseDouble(list.getIHarm20OverTime().toString()));
// steadyQualifyDTO.setIHarm_21_OverTime(Double.parseDouble(list.getIHarm21OverTime().toString()));
// steadyQualifyDTO.setIHarm_22_OverTime(Double.parseDouble(list.getIHarm22OverTime().toString()));
// steadyQualifyDTO.setIHarm_23_OverTime(Double.parseDouble(list.getIHarm23OverTime().toString()));
// steadyQualifyDTO.setIHarm_24_OverTime(Double.parseDouble(list.getIHarm24OverTime().toString()));
// steadyQualifyDTO.setIHarm_25_OverTime(Double.parseDouble(list.getIHarm25OverTime().toString()));
// steadyQualifyDTO.setI_Neg_OverTime(Double.parseDouble(list.getINegOverTime().toString()));
// steadyQualifyDTO.setInUHARM_1_OverTime(Double.parseDouble(list.getInuHarm1OverTime().toString()));
// steadyQualifyDTO.setInUHARM_2_OverTime(Double.parseDouble(list.getInuHarm2OverTime().toString()));
// steadyQualifyDTO.setInUHARM_3_OverTime(Double.parseDouble(list.getInuHarm3OverTime().toString()));
// steadyQualifyDTO.setInUHARM_4_OverTime(Double.parseDouble(list.getInuHarm4OverTime().toString()));
// steadyQualifyDTO.setInUHARM_5_OverTime(Double.parseDouble(list.getInuHarm5OverTime().toString()));
// steadyQualifyDTO.setInUHARM_6_OverTime(Double.parseDouble(list.getInuHarm6OverTime().toString()));
// steadyQualifyDTO.setInUHARM_7_OverTime(Double.parseDouble(list.getInuHarm7OverTime().toString()));
// steadyQualifyDTO.setInUHARM_8_OverTime(Double.parseDouble(list.getInuHarm8OverTime().toString()));
// steadyQualifyDTO.setInUHARM_9_OverTime(Double.parseDouble(list.getInuHarm9OverTime().toString()));
// steadyQualifyDTO.setInUHARM_10_OverTime(Double.parseDouble(list.getInuHarm10OverTime().toString()));
// steadyQualifyDTO.setInUHARM_11_OverTime(Double.parseDouble(list.getInuHarm11OverTime().toString()));
// steadyQualifyDTO.setInUHARM_12_OverTime(Double.parseDouble(list.getInuHarm12OverTime().toString()));
// steadyQualifyDTO.setInUHARM_13_OverTime(Double.parseDouble(list.getInuHarm13OverTime().toString()));
// steadyQualifyDTO.setInUHARM_14_OverTime(Double.parseDouble(list.getInuHarm14OverTime().toString()));
// steadyQualifyDTO.setInUHARM_15_OverTime(Double.parseDouble(list.getInuHarm15OverTime().toString()));
// steadyQualifyDTO.setInUHARM_16_OverTime(Double.parseDouble(list.getInuHarm16OverTime().toString()));
// steadyQualifyDTO.setUAberrance_OverTime(Double.parseDouble(list.getUAberranceOverTime().toString()));
// steadyQualifyDTO.setUBalance_OverTime(Double.parseDouble(list.getUBalanceOverTime().toString()));
// steadyQualifyDTO.setUHarm_2_OverTime(Double.parseDouble(list.getUHarm2OverTime().toString()));
// steadyQualifyDTO.setUHarm_3_OverTime(Double.parseDouble(list.getUHarm3OverTime().toString()));
// steadyQualifyDTO.setUHarm_4_OverTime(Double.parseDouble(list.getUHarm4OverTime().toString()));
// steadyQualifyDTO.setUHarm_5_OverTime(Double.parseDouble(list.getUHarm5OverTime().toString()));
// steadyQualifyDTO.setUHarm_6_OverTime(Double.parseDouble(list.getUHarm6OverTime().toString()));
// steadyQualifyDTO.setUHarm_7_OverTime(Double.parseDouble(list.getUHarm7OverTime().toString()));
// steadyQualifyDTO.setUHarm_8_OverTime(Double.parseDouble(list.getUHarm8OverTime().toString()));
// steadyQualifyDTO.setUHarm_9_OverTime(Double.parseDouble(list.getUHarm9OverTime().toString()));
// steadyQualifyDTO.setUHarm_10_OverTime(Double.parseDouble(list.getUHarm10OverTime().toString()));
// steadyQualifyDTO.setUHarm_11_OverTime(Double.parseDouble(list.getUHarm11OverTime().toString()));
// steadyQualifyDTO.setUHarm_12_OverTime(Double.parseDouble(list.getUHarm12OverTime().toString()));
// steadyQualifyDTO.setUHarm_13_OverTime(Double.parseDouble(list.getUHarm13OverTime().toString()));
// steadyQualifyDTO.setUHarm_14_OverTime(Double.parseDouble(list.getUHarm14OverTime().toString()));
// steadyQualifyDTO.setUHarm_15_OverTime(Double.parseDouble(list.getUHarm15OverTime().toString()));
// steadyQualifyDTO.setUHarm_16_OverTime(Double.parseDouble(list.getUHarm16OverTime().toString()));
// steadyQualifyDTO.setUHarm_17_OverTime(Double.parseDouble(list.getUHarm17OverTime().toString()));
// steadyQualifyDTO.setUHarm_18_OverTime(Double.parseDouble(list.getUHarm18OverTime().toString()));
// steadyQualifyDTO.setUHarm_19_OverTime(Double.parseDouble(list.getUHarm19OverTime().toString()));
// steadyQualifyDTO.setUHarm_20_OverTime(Double.parseDouble(list.getUHarm20OverTime().toString()));
// steadyQualifyDTO.setUHarm_21_OverTime(Double.parseDouble(list.getUHarm21OverTime().toString()));
// steadyQualifyDTO.setUHarm_22_OverTime(Double.parseDouble(list.getUHarm22OverTime().toString()));
// steadyQualifyDTO.setUHarm_23_OverTime(Double.parseDouble(list.getUHarm23OverTime().toString()));
// steadyQualifyDTO.setUHarm_24_OverTime(Double.parseDouble(list.getUHarm24OverTime().toString()));
// steadyQualifyDTO.setUHarm_25_OverTime(Double.parseDouble(list.getUHarm25OverTime().toString()));
// steadyQualifyDTO.setVoltage_Dev_OverTime(Double.parseDouble(list.getVoltageDevOverTime().toString()));
// qualifyDTOList.add(steadyQualifyDTO);
// });
//
//
// return qualifyDTOList;
}

View File

@@ -1,5 +1,10 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.dto.SimpleDTO;
@@ -15,9 +20,11 @@ import com.njcn.harmonic.mapper.RMpVThdMapper;
import com.njcn.harmonic.mapper.THDistortionMapper;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.po.RMpVThd;
import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.pojo.vo.RMpVThdVO;
import com.njcn.harmonic.pojo.vo.THDistortionCensusVO;
import com.njcn.harmonic.pojo.vo.THDistortionVO;
import com.njcn.harmonic.service.IRStatDataVDService;
import com.njcn.harmonic.service.THDistortionService;
import com.njcn.influxdb.utils.InfluxDbUtils;
import lombok.AllArgsConstructor;
@@ -49,7 +56,7 @@ public class THDistortionServiceImpl implements THDistortionService {
private final RMpVThdMapper rMpVThdMapper;
private final LineFeignClient lineFeignClient;
private final IRStatDataVDService statDataVDService;
@Override
public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) {
List<THDistortionVO> thDistortionVOS = new ArrayList<>();
@@ -70,11 +77,14 @@ public class THDistortionServiceImpl implements THDistortionService {
//查找畸变率
List<PublicDTO> condition = getCondition(lineIndexes, thDistortionParam.getSearchBeginTime(), thDistortionParam.getSearchEndTime());
if(CollUtil.isNotEmpty(condition)){
thDistortionVO.setDistortion(condition.stream().mapToDouble(PublicDTO::getData).average().orElse(3.14159));
//组装父级数据树
List<THDistortionVO> treeList = getTreeData(lineIndexes, thDistortionParam);
thDistortionVO.setChildren(treeList);
}
}
thDistortionVOS.add(thDistortionVO);
}
@@ -224,42 +234,70 @@ public class THDistortionServiceImpl implements THDistortionService {
*/
private List<PublicDTO> getCondition(List<String> lineIndexes, String startTime, String endTime) {
List<PublicDTO> publicDTOList = new ArrayList<>();
//组装sql语句
StringBuilder string = new StringBuilder();
string.append(Param.QualityFlag + "='1' and (" + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEA + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEB + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEC + "') and "+ Param.VALUETYPE + "='AVG' and ");
StringBuilder timeId = new StringBuilder();
timeId.append(Param.TIME + " >= '" + startTime + Param.START_TIME + "' and " + Param.TIME + " <= '" + endTime + Param.END_TIME + "' and (");
for (int i = 0; i < lineIndexes.size(); i++) {
if (lineIndexes.size() - i != 1) {
timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
} else {
timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("')");
}
}
// String a = "SELECT MEAN(V_THD) AS distortion FROM Data_V WHERE QualityFlag='1' and (phasic_type='A' or phasic_type='B' or phasic_type='C')and value_type='AVG' and time >= '2022-03-20 00:00:00' and time <= '2022-03-21 23:59:59' and (lineid ='1e3b8531483b2a8cbee6747f1f641cf9') group by lineid;";
//sql语句
String sql = "SELECT MEAN(" + Param.V_THD + ")*100 AS distortion FROM Data_V WHERE " + string + timeId + " group by " + Param.LINE_ID;
//结果集
QueryResult result = influxDbUtils.query(sql);
//处理结果集
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
if (!CollectionUtils.isEmpty(list)){
list.forEach(po->{
PublicDTO publicDTO = new PublicDTO();
List<List<Object>> valueList = po.getValues();
String index = po.getTags().get(Param.LINE_ID);
if (!CollectionUtils.isEmpty(valueList)){
for (List<Object> value : valueList) {
//谐波畸变率 保留两位小数
Double distortion = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
publicDTO.setId(index);
publicDTO.setData(distortion);
}
}
List<String> phasicType=new ArrayList<>();
phasicType.add(Param.PHASIC_TYPEA);
phasicType.add(Param.PHASIC_TYPEB);
phasicType.add(Param.PHASIC_TYPEC);
//数据库查询
List<RStatDataVD> info = statDataVDService.list(new LambdaQueryWrapper<RStatDataVD>()
.in(RStatDataVD::getLineId, lineIndexes)
.ge(StrUtil.isNotBlank(startTime), RStatDataVD::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
.le(StrUtil.isNotBlank(endTime), RStatDataVD::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
.eq(RStatDataVD::getQualityFlag, 1)
.in(RStatDataVD::getPhasicType, phasicType)
.eq(RStatDataVD::getValueType, Param.VALUE_TYPEAVG)
);
if (CollUtil.isNotEmpty(info)){
//根据id分组先乘以100.在取平均值,在四舍五入
Map<String, Double> vthdMap = info.stream().filter(x-> x.getVThd()!=null).collect(Collectors.groupingBy(RStatDataVD::getLineId,
Collectors.averagingDouble(x->x.getVThd().multiply(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue())));
PublicDTO publicDTO ;
for (Map.Entry<String, Double> entry : vthdMap.entrySet()) {
publicDTO = new PublicDTO();
publicDTO.setId(entry.getKey());
publicDTO.setData(entry.getValue());
publicDTOList.add(publicDTO);
});
}
}
return publicDTOList;
//组装sql语句
// StringBuilder string = new StringBuilder();
// string.append(Param.QualityFlag + "='1' and (" + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEA + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEB + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEC + "') and "+ Param.VALUETYPE + "='AVG' and ");
// StringBuilder timeId = new StringBuilder();
// timeId.append(Param.TIME + " >= '" + startTime + Param.START_TIME + "' and " + Param.TIME + " <= '" + endTime + Param.END_TIME + "' and (");
// for (int i = 0; i < lineIndexes.size(); i++) {
// if (lineIndexes.size() - i != 1) {
// timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
// } else {
// timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("')");
// }
// }
// // String a = "SELECT MEAN(V_THD) AS distortion FROM Data_V WHERE QualityFlag='1' and (phasic_type='A' or phasic_type='B' or phasic_type='C')and value_type='AVG' and time >= '2022-03-20 00:00:00' and time <= '2022-03-21 23:59:59' and (lineid ='1e3b8531483b2a8cbee6747f1f641cf9') group by lineid;";
// //sql语句
// String sql = "SELECT MEAN(" + Param.V_THD + ")*100 AS distortion FROM Data_V WHERE " + string + timeId + " group by " + Param.LINE_ID;
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
// if (!CollectionUtils.isEmpty(list)){
// list.forEach(po->{
// PublicDTO publicDTO = new PublicDTO();
// List<List<Object>> valueList = po.getValues();
// String index = po.getTags().get(Param.LINE_ID);
// if (!CollectionUtils.isEmpty(valueList)){
// for (List<Object> value : valueList) {
// //谐波畸变率 保留两位小数
// Double distortion = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// publicDTO.setId(index);
// publicDTO.setData(distortion);
// }
// }
// publicDTOList.add(publicDTO);
// });
// }
// return publicDTOList;
}

View File

@@ -1,9 +1,14 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.config.GeneralInfo;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
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.OnlineRate;
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
import com.njcn.harmonic.mapper.TerminalDataMapper;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.vo.TerminalCensusVO;
@@ -207,39 +212,59 @@ public class TerminalServiceImpl implements TerminalService {
*/
private List<PublicDTO> getCondition(List<String> deviceIndexes, String startTime, String endTime) {
List<PublicDTO> publicDTOList = new ArrayList<>();
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
for (int i = 0; i < deviceIndexes.size(); i++) {
if (deviceIndexes.size() - i != 1) {
stringBuilder.append(InfluxDBPublicParam.DEV_INDEX + "='").append(deviceIndexes.get(i)).append("' or ");
} else {
stringBuilder.append(InfluxDBPublicParam.DEV_INDEX + "='").append(deviceIndexes.get(i)).append("')");
}
}
//sql语句
String sql = "SELECT (SUM(" + InfluxDBPublicParam.ONLINE_MIN + ")/(SUM(" + InfluxDBPublicParam.OFFLINE_MIN + ")+SUM(" + InfluxDBPublicParam.ONLINE_MIN + ")))*100 AS onlineRate FROM "+InfluxDBPublicParam.PQS_ONLINERATE+" WHERE " + stringBuilder + " group by " + InfluxDBPublicParam.DEV_INDEX + InfluxDBPublicParam.TIME_ZONE;
//结果集
QueryResult result = influxDbUtils.query(sql);
//处理结果集
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
if (!CollectionUtils.isEmpty(list)) {
list.forEach(po -> {
OnlineRateParam param=new OnlineRateParam();
param.setIds(deviceIndexes);
param.setStartTime( DateUtil.beginOfDay(DateUtil.parse(startTime)).toString());
param.setEndTime( DateUtil.endOfDay(DateUtil.parse(endTime)).toString());
List<RStatOnlinerateVO> data = generalDeviceInfoClient.getOnlineRateByDevIds(param).getData();
if (CollUtil.isNotEmpty(data)) {
data.forEach(po -> {
PublicDTO publicDTO = new PublicDTO();
List<List<Object>> valueList = po.getValues();
String index = po.getTags().get(InfluxDBPublicParam.DEV_INDEX);
if (!CollectionUtils.isEmpty(valueList)) {
for (List<Object> value : valueList) {
//终端在线率 保留两位小数
Double onlineRate = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
publicDTO.setId(index);
Double onlineRate = po.getOnlineRate() == null ? null : BigDecimal.valueOf(Double.parseDouble(po.getOnlineRate().toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
publicDTO.setId(po.getDevIndex());
publicDTO.setData(onlineRate);
}
}
publicDTOList.add(publicDTO);
});
}
return publicDTOList;
// //组装sql语句
// StringBuilder stringBuilder = new StringBuilder();
// stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
// for (int i = 0; i < deviceIndexes.size(); i++) {
// if (deviceIndexes.size() - i != 1) {
// stringBuilder.append(InfluxDBPublicParam.DEV_INDEX + "='").append(deviceIndexes.get(i)).append("' or ");
// } else {
// stringBuilder.append(InfluxDBPublicParam.DEV_INDEX + "='").append(deviceIndexes.get(i)).append("')");
// }
// }
// //sql语句
// String sql = "SELECT (SUM(" + InfluxDBPublicParam.ONLINE_MIN + ")/(SUM(" + InfluxDBPublicParam.OFFLINE_MIN + ")+SUM(" + InfluxDBPublicParam.ONLINE_MIN + ")))*100 AS onlineRate FROM "+InfluxDBPublicParam.PQS_ONLINERATE+" WHERE " + stringBuilder + " group by " + InfluxDBPublicParam.DEV_INDEX + InfluxDBPublicParam.TIME_ZONE;
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
// if (!CollectionUtils.isEmpty(list)) {
// list.forEach(po -> {
// PublicDTO publicDTO = new PublicDTO();
// List<List<Object>> valueList = po.getValues();
// String index = po.getTags().get(InfluxDBPublicParam.DEV_INDEX);
// if (!CollectionUtils.isEmpty(valueList)) {
// for (List<Object> value : valueList) {
// //终端在线率 保留两位小数
// Double onlineRate = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// publicDTO.setId(index);
// publicDTO.setData(onlineRate);
// }
// }
// publicDTOList.add(publicDTO);
// });
// }
// return publicDTOList;
}
/**