代码调整
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.njcn.prepare.harmonic.api.line;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.api.line.fallback.DistortionRateFeignClientFallbackFactory;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 谐波畸变率
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/4 15:58
|
||||
*/
|
||||
@FeignClient(
|
||||
value = ServerInfo.HARMONIC_PREPARE,
|
||||
path = "/distortion",
|
||||
fallbackFactory = DistortionRateFeignClientFallbackFactory.class
|
||||
)
|
||||
public interface DistortionRateFeignClient {
|
||||
|
||||
@PostMapping("/distortionRate")
|
||||
HttpResult<String> distortionRate(@RequestBody @Validated LineParam lineParam);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.prepare.harmonic.api.line;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.api.line.fallback.DistortionRateFeignClientFallbackFactory;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 稳态综合评估
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/7 15:11
|
||||
*/
|
||||
|
||||
@FeignClient(
|
||||
value = ServerInfo.HARMONIC_PREPARE,
|
||||
path = "/general",
|
||||
fallbackFactory = DistortionRateFeignClientFallbackFactory.class
|
||||
)
|
||||
public interface HarmonicGeneralFeignClient {
|
||||
|
||||
@PostMapping("/generalData")
|
||||
HttpResult<String> generalData(@RequestBody @Validated LineParam lineParam);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.prepare.harmonic.api.line;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.api.line.fallback.HarmonicMetricFeignClientFallbackFactory;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/7 15:12
|
||||
*/
|
||||
|
||||
@FeignClient(
|
||||
value = ServerInfo.HARMONIC_PREPARE,
|
||||
path = "/metric",
|
||||
fallbackFactory = HarmonicMetricFeignClientFallbackFactory.class
|
||||
)
|
||||
public interface HarmonicMetricFeignClient {
|
||||
|
||||
@PostMapping("/metricData")
|
||||
HttpResult<String> metricData(@RequestBody @Validated LineParam lineParam);
|
||||
}
|
||||
@@ -3,10 +3,8 @@ package com.njcn.prepare.harmonic.api.line;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.api.line.fallback.NormalFeignClientFallbackFactory;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 自定义报表
|
||||
@@ -14,9 +12,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
* @date 2022/10/20
|
||||
*/
|
||||
@FeignClient(
|
||||
value = ServerInfo.HARMONIC_PREPARE,//对应模块名
|
||||
path = "/normalLimit",//对应controller请求类
|
||||
fallbackFactory = NormalFeignClientFallbackFactory.class//服务降级处理类
|
||||
value = ServerInfo.HARMONIC_PREPARE,
|
||||
path = "/normalLimit",
|
||||
fallbackFactory = NormalFeignClientFallbackFactory.class
|
||||
)
|
||||
public interface NormalLimitFeignClient {
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class CoustomReportFeignClientFallbackFactory implements FallbackFactory<
|
||||
return new CoustmReportFeignClient() {
|
||||
@Override
|
||||
public HttpResult<Boolean> batchReport(@RequestBody LineParam reportParam){
|
||||
log.error("{}异常,降级处理,异常为:{}", "Date数据转Day数据: ", throwable.toString());
|
||||
log.error("{}异常,降级处理,异常为:{}", "生成自定义报表: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.prepare.harmonic.api.line.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.utils.DeviceEnumUtil;
|
||||
import com.njcn.prepare.harmonic.api.line.DistortionRateFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/7 14:37
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DistortionRateFeignClientFallbackFactory implements FallbackFactory<DistortionRateFeignClient> {
|
||||
@Override
|
||||
public DistortionRateFeignClient create(Throwable throwable) {
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException)throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DistortionRateFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> distortionRate(@RequestBody @Validated LineParam lineParam){
|
||||
log.error("{}异常,降级处理,异常为:{}", "谐波畸变率: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.prepare.harmonic.api.line.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.utils.DeviceEnumUtil;
|
||||
import com.njcn.prepare.harmonic.api.line.HarmonicGeneralFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/7 15:17
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HarmonicGeneralFeignClientFallbackFactory implements FallbackFactory<HarmonicGeneralFeignClient> {
|
||||
@Override
|
||||
public HarmonicGeneralFeignClient create(Throwable throwable) {
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException)throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new HarmonicGeneralFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> generalData(@RequestBody @Validated LineParam lineParam){
|
||||
log.error("{}异常,降级处理,异常为:{}", "稳态综合评估: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.prepare.harmonic.api.line.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.utils.DeviceEnumUtil;
|
||||
import com.njcn.prepare.harmonic.api.line.HarmonicMetricFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/7 15:14
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HarmonicMetricFeignClientFallbackFactory implements FallbackFactory<HarmonicMetricFeignClient> {
|
||||
@Override
|
||||
public HarmonicMetricFeignClient create(Throwable throwable) {
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException)throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new HarmonicMetricFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> metricData(@RequestBody @Validated LineParam lineParam){
|
||||
log.error("{}异常,降级处理,异常为:{}", "稳态指标评估: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.prepare.harmonic.controller.line;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.line.DistortionRateService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/4 15:58
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "谐波畸变率")
|
||||
@RestController
|
||||
@RequestMapping("/distortion")
|
||||
@RequiredArgsConstructor
|
||||
public class DistortionRateController extends BaseController {
|
||||
|
||||
private final DistortionRateService distortionRateService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/distortionRate")
|
||||
@ApiOperation("谐波畸变率排名")
|
||||
@ApiImplicitParam(name = "lineParam", value = "参数", required = true)
|
||||
public HttpResult<String> distortionRate(@RequestBody @Validated LineParam lineParam){
|
||||
String methodDescribe = getMethodDescribe("distortionRate");
|
||||
distortionRateService.distortionRate(lineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.prepare.harmonic.controller.line;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.line.HarmonicGeneralService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/3 9:00
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "稳态综合评估")
|
||||
@RestController
|
||||
@RequestMapping("/general")
|
||||
@RequiredArgsConstructor
|
||||
public class HarmonicGeneralController extends BaseController {
|
||||
|
||||
private final HarmonicGeneralService harmonicGeneralService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/generalData")
|
||||
@ApiOperation("稳态综合评估日数据计算")
|
||||
@ApiImplicitParam(name = "lineParam", value = "参数", required = true)
|
||||
public HttpResult<String> generalData(@RequestBody @Validated LineParam lineParam){
|
||||
String methodDescribe = getMethodDescribe("generalData");
|
||||
harmonicGeneralService.generalData(lineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.prepare.harmonic.controller.line;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.line.HarmonicMetricService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/3 8:59
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Api(tags = "稳态指标评估")
|
||||
@RestController
|
||||
@RequestMapping("/metric")
|
||||
@RequiredArgsConstructor
|
||||
public class HarmonicMetricController extends BaseController {
|
||||
|
||||
private final HarmonicMetricService harmonicMetricService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/metricData")
|
||||
@ApiOperation("稳态指标评估日数据计算")
|
||||
@ApiImplicitParam(name = "lineParam", value = "参数", required = true)
|
||||
public HttpResult<String> metricData(@RequestBody @Validated LineParam lineParam){
|
||||
String methodDescribe = getMethodDescribe("metricData");
|
||||
harmonicMetricService.metricData(lineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.njcn.prepare.harmonic.pojo.po.RMpPollutionD;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -16,6 +17,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface RMpPollutionDMapper extends BaseMapper<RMpPollutionD> {
|
||||
|
||||
int insertPollution(@Param("item") RMpPollutionD item);
|
||||
int insertPollution(@Param("item") Map<String, Object> item);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.prepare.harmonic.mapper.line;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.po.RMpVThd;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 谐波畸变率排名 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiaoyao
|
||||
* @since 2022-11-07
|
||||
*/
|
||||
public interface RMpVThdMapper extends BaseMapper<RMpVThd> {
|
||||
|
||||
int insertRate(@Param("item") Map<String, Object> item);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.prepare.harmonic.mapper.line.ExcelRptTempMapper">
|
||||
|
||||
<select id="getActiveTempList" resultType="ExcelRptTemp">
|
||||
<select id="getActiveTempList" resultType="com.njcn.prepare.harmonic.pojo.po.ExcelRptTemp">
|
||||
SELECT
|
||||
DISTINCT t1.*
|
||||
FROM
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
<mapper namespace="com.njcn.prepare.harmonic.mapper.line.RMpPollutionDMapper">
|
||||
|
||||
<insert id="insertPollution">
|
||||
INSERT INTO r_mp_pollution_d ( line_Id, data_date, freq_dev, v_dev, v_unbalance,
|
||||
v_all, plt, i_all, i_neg, v_inharm) VALUES
|
||||
( #{item.lineId}, #{item.dataDate}, #{item.freqDev}, #{item.vDev}, #{item.vUnbalance},
|
||||
#{item.vAll}, #{item.plt}, #{item.iAll}, #{item.iNeg}, #{item.vInharm} )
|
||||
ON DUPLICATE KEY UPDATE freq_dev = #{item.freqDev}, v_dev = #{item.vDev}, v_unbalance = #{item.vUnbalance},
|
||||
v_all = #{item.vAll}, plt = #{item.plt}, i_all = #{item.iAll}, i_neg = #{item.iNeg}, v_inharm = #{item.vInharm}
|
||||
INSERT INTO r_mp_pollution_d ( line_id, data_date, pollution_type, `value`) VALUES
|
||||
( #{item.lineId}, #{item.dataDate}, #{item.pollutionType}, #{item.value} )
|
||||
ON DUPLICATE KEY UPDATE `value` = #{item.value}
|
||||
</insert>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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.prepare.harmonic.mapper.line.RMpVThdMapper">
|
||||
|
||||
<insert id="insertRate">
|
||||
INSERT INTO r_mp_v_thd ( measurement_point_id, data_type, data_date, v_thd) VALUES
|
||||
( #{item.lineId}, #{item.dataType}, #{item.dataDate}, #{item.vThd} )
|
||||
ON DUPLICATE KEY UPDATE v_thd = #{item.vThd}
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -40,4 +40,8 @@ public class DataFlickerPO {
|
||||
|
||||
@Column(name = "pst")
|
||||
private Double pst;
|
||||
|
||||
//自定义字段
|
||||
@Column(name = "count")
|
||||
private Integer count;
|
||||
}
|
||||
|
||||
@@ -32,4 +32,7 @@ public class DataPltPO {
|
||||
@Column(name = "flicker_all_time")
|
||||
private Integer flickerAllTime;
|
||||
|
||||
//自定义字段
|
||||
@Column(name = "mean")
|
||||
private Double mean;
|
||||
}
|
||||
|
||||
@@ -211,4 +211,12 @@ public class DataVPO {
|
||||
//自定义字段-总计算次数
|
||||
@Column(name = "all_time")
|
||||
private Integer allTime;
|
||||
|
||||
//自定义字段
|
||||
@Column(name = "mean")
|
||||
private Double mean;
|
||||
|
||||
//自定义字段
|
||||
@Column(name = "count")
|
||||
private Integer count;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class RMpPollutionD implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
* 单位id
|
||||
*/
|
||||
@TableId(value = "line_id", type = IdType.AUTO)
|
||||
private String lineId;
|
||||
@@ -31,44 +31,14 @@ public class RMpPollutionD implements Serializable {
|
||||
private LocalDateTime dataDate;
|
||||
|
||||
/**
|
||||
* 频率偏差
|
||||
* 污区图统计类型
|
||||
*/
|
||||
private Float freqDev;
|
||||
private String pollutionType;
|
||||
|
||||
/**
|
||||
* 电压偏差
|
||||
* 统计值
|
||||
*/
|
||||
private Float vDev;
|
||||
|
||||
/**
|
||||
* 三相电压不平衡度
|
||||
*/
|
||||
private Float vUnbalance;
|
||||
|
||||
/**
|
||||
* 谐波电压(电压总谐波畸变率、各次谐波电压含有率)
|
||||
*/
|
||||
private Float vAll;
|
||||
|
||||
/**
|
||||
* 长时闪变
|
||||
*/
|
||||
private Float plt;
|
||||
|
||||
/**
|
||||
* 谐波电流
|
||||
*/
|
||||
private Float iAll;
|
||||
|
||||
/**
|
||||
* 负序电流
|
||||
*/
|
||||
private Float iNeg;
|
||||
|
||||
/**
|
||||
* 间谐波电压含有率
|
||||
*/
|
||||
private Float vInharm;
|
||||
private Float value;
|
||||
|
||||
public String getLineId() {
|
||||
return lineId;
|
||||
@@ -84,76 +54,28 @@ public class RMpPollutionD implements Serializable {
|
||||
public void setDataDate(LocalDateTime dataDate) {
|
||||
this.dataDate = dataDate;
|
||||
}
|
||||
public Float getFreqDev() {
|
||||
return freqDev;
|
||||
public String getPollutionType() {
|
||||
return pollutionType;
|
||||
}
|
||||
|
||||
public void setFreqDev(Float freqDev) {
|
||||
this.freqDev = freqDev;
|
||||
public void setPollutionType(String pollutionType) {
|
||||
this.pollutionType = pollutionType;
|
||||
}
|
||||
public Float getvDev() {
|
||||
return vDev;
|
||||
public Float getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setvDev(Float vDev) {
|
||||
this.vDev = vDev;
|
||||
}
|
||||
public Float getvUnbalance() {
|
||||
return vUnbalance;
|
||||
}
|
||||
|
||||
public void setvUnbalance(Float vUnbalance) {
|
||||
this.vUnbalance = vUnbalance;
|
||||
}
|
||||
public Float getvAll() {
|
||||
return vAll;
|
||||
}
|
||||
|
||||
public void setvAll(Float vAll) {
|
||||
this.vAll = vAll;
|
||||
}
|
||||
public Float getPlt() {
|
||||
return plt;
|
||||
}
|
||||
|
||||
public void setPlt(Float plt) {
|
||||
this.plt = plt;
|
||||
}
|
||||
public Float getiAll() {
|
||||
return iAll;
|
||||
}
|
||||
|
||||
public void setiAll(Float iAll) {
|
||||
this.iAll = iAll;
|
||||
}
|
||||
public Float getiNeg() {
|
||||
return iNeg;
|
||||
}
|
||||
|
||||
public void setiNeg(Float iNeg) {
|
||||
this.iNeg = iNeg;
|
||||
}
|
||||
public Float getvInharm() {
|
||||
return vInharm;
|
||||
}
|
||||
|
||||
public void setvInharm(Float vInharm) {
|
||||
this.vInharm = vInharm;
|
||||
public void setValue(Float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RMpPollutionD{" +
|
||||
"lineId=" + lineId +
|
||||
", dataDate=" + dataDate +
|
||||
", freqDev=" + freqDev +
|
||||
", vDev=" + vDev +
|
||||
", vUnbalance=" + vUnbalance +
|
||||
", vAll=" + vAll +
|
||||
", plt=" + plt +
|
||||
", iAll=" + iAll +
|
||||
", iNeg=" + iNeg +
|
||||
", vInharm=" + vInharm +
|
||||
"}";
|
||||
return "RStatPollutionOrgD{" +
|
||||
"lineId=" + lineId +
|
||||
", dataDate=" + dataDate +
|
||||
", pollutionType=" + pollutionType +
|
||||
", value=" + value +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.njcn.prepare.harmonic.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 谐波畸变率排名
|
||||
* </p>
|
||||
*
|
||||
* @author xiaoyao
|
||||
* @since 2022-11-07
|
||||
*/
|
||||
@TableName("r_mp_v_thd")
|
||||
public class RMpVThd implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 监测点ID
|
||||
*/
|
||||
@TableId(value = "measurement_point_id", type = IdType.AUTO)
|
||||
private String measurementPointId;
|
||||
|
||||
/**
|
||||
* 排名类型,字典表(0日,1月,2季,3年)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private LocalDateTime dataDate;
|
||||
|
||||
/**
|
||||
* 谐波畸变率
|
||||
*/
|
||||
private Float vThd;
|
||||
|
||||
public String getMeasurementPointId() {
|
||||
return measurementPointId;
|
||||
}
|
||||
|
||||
public void setMeasurementPointId(String measurementPointId) {
|
||||
this.measurementPointId = measurementPointId;
|
||||
}
|
||||
public String getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(String dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
public LocalDateTime getDataDate() {
|
||||
return dataDate;
|
||||
}
|
||||
|
||||
public void setDataDate(LocalDateTime dataDate) {
|
||||
this.dataDate = dataDate;
|
||||
}
|
||||
public Float getvThd() {
|
||||
return vThd;
|
||||
}
|
||||
|
||||
public void setvThd(Float vThd) {
|
||||
this.vThd = vThd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RMpVThd{" +
|
||||
"measurementPointId=" + measurementPointId +
|
||||
", dataType=" + dataType +
|
||||
", dataDate=" + dataDate +
|
||||
", vThd=" + vThd +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.njcn.prepare.harmonic.service.Impl.line;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.po.Overlimit;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.prepare.harmonic.mapper.line.RMpVThdMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.pojo.po.DataVPO;
|
||||
import com.njcn.prepare.harmonic.service.line.DistortionRateService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/7 9:19
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DistortionRateServiceImpl implements DistortionRateService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final RMpVThdMapper rMpVThdMapper;
|
||||
|
||||
@Override
|
||||
public void distortionRate(LineParam lineParam) {
|
||||
List<String> lineIdOutList;
|
||||
if (CollUtil.isEmpty(lineParam.getLineIds())){
|
||||
List<Overlimit> overLimitList = getAllLineOutData();
|
||||
lineIdOutList = overLimitList.stream().map(Overlimit::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
lineIdOutList = new ArrayList<>(lineParam.getLineIds());
|
||||
}
|
||||
LocalDateTime local = LocalDateTimeUtil.parse(lineParam.getDataDate() + "T00:00:00");
|
||||
for (String lineId : lineIdOutList){
|
||||
List<DataVPO> rateOut = getDistortionRateInfluxDb(lineId,lineParam.getDataDate());
|
||||
if (rateOut.size() > 0){
|
||||
Map<String, Object> inMap = new HashMap<>();
|
||||
inMap.put("lineId",lineId);
|
||||
inMap.put("dataType","0");
|
||||
inMap.put("dataDate",local);
|
||||
inMap.put("vThd",rateOut.get(0).getVThd());
|
||||
rMpVThdMapper.insertRate(inMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<DataVPO> getDistortionRateInfluxDb(String lineId, String date){
|
||||
String processParam = " and line_id = '"+lineId+"' and time >= '"+date+" 00:00:00' and time <= '"+date+" 23:59:59' tz('Asia/Shanghai')";
|
||||
QueryResult result = influxDbUtils.query("SELECT line_id, max(v_thd) as v_thd FROM data_v WHERE phasic_type != 'T' and value_type = 'MAX'"+processParam);
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
return resultMapper.toPOJO(result, DataVPO.class);
|
||||
}
|
||||
|
||||
private List<Overlimit> getAllLineOutData() {
|
||||
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.njcn.prepare.harmonic.service.Impl.line;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.po.Overlimit;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.pojo.po.DataFlickerPO;
|
||||
import com.njcn.prepare.harmonic.pojo.po.DataVPO;
|
||||
import com.njcn.prepare.harmonic.service.line.HarmonicGeneralService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 稳态综合评估
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/3 11:06
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class HarmonicGeneralServiceImpl implements HarmonicGeneralService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
@Override
|
||||
public void generalData(LineParam lineParam) {
|
||||
List<String> lineIdOutList;
|
||||
if (CollUtil.isEmpty(lineParam.getLineIds())){
|
||||
List<Overlimit> overLimitList = getAllLineOutData();
|
||||
lineIdOutList = overLimitList.stream().map(Overlimit::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
lineIdOutList = new ArrayList<>(lineParam.getLineIds());
|
||||
}
|
||||
Date dateOut = DateUtil.parse(lineParam.getDataDate());
|
||||
List<String> records = new ArrayList<>();
|
||||
for (String lineId : lineIdOutList){
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put("line_id",lineId);
|
||||
Map<String, Object> fields = getGeneralData(lineId,lineParam.getDataDate());
|
||||
if (CollUtil.isEmpty(fields)){
|
||||
continue;
|
||||
}
|
||||
Point point = influxDbUtils.pointBuilder("pqs_comasses", dateOut.getTime(), TimeUnit.MILLISECONDS,tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).tag("line_id", lineId).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
}
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(),"", InfluxDB.ConsistencyLevel.ALL, records);
|
||||
}
|
||||
|
||||
private Map<String, Object> getGeneralData(String lineId, String date){
|
||||
InfluxDBResultMapper mapper = new InfluxDBResultMapper();
|
||||
BigDecimal hundred = BigDecimal.valueOf(100);
|
||||
Map<String, Object> outMap = new HashMap<>();
|
||||
String processParam = " and line_id = '"+lineId+"' and time >= '"
|
||||
+date+" 00:00:00' and time <= '"+date+" 23:59:59' group by time(1m) fill(none) tz('Asia/Shanghai')";
|
||||
|
||||
String vuDevSql = "select count(vu_dev) from data_v where phasic_type != 'T' and quality_flag = '0' and value_type = 'AVG' and ";
|
||||
QueryResult vuDevResult1 = influxDbUtils.query(vuDevSql + "vu_dev >=10" + processParam);
|
||||
QueryResult vuDevResult2 = influxDbUtils.query(vuDevSql + "vu_dev <10 and vu_dev >=7" + processParam);
|
||||
QueryResult vuDevResult3 = influxDbUtils.query(vuDevSql + "vu_dev <7 and vu_dev >=4" + processParam);
|
||||
QueryResult vuDevResult4 = influxDbUtils.query(vuDevSql + "vu_dev <4 and vu_dev >=2" + processParam);
|
||||
QueryResult vuDevResult5 = influxDbUtils.query(vuDevSql + "vu_dev <2 and vu_dev >=0" + processParam);
|
||||
BigDecimal vuDev1 = BigDecimal.valueOf(mapper.toPOJO(vuDevResult1, DataVPO.class).size());
|
||||
BigDecimal vuDev2 = BigDecimal.valueOf(mapper.toPOJO(vuDevResult2, DataVPO.class).size());
|
||||
BigDecimal vuDev3 = BigDecimal.valueOf(mapper.toPOJO(vuDevResult3, DataVPO.class).size());
|
||||
BigDecimal vuDev4 = BigDecimal.valueOf(mapper.toPOJO(vuDevResult4, DataVPO.class).size());
|
||||
BigDecimal vuDev5 = BigDecimal.valueOf(mapper.toPOJO(vuDevResult5, DataVPO.class).size());
|
||||
BigDecimal vuDevAll = vuDev1.add(vuDev2).add(vuDev3).add(vuDev4).add(vuDev5);
|
||||
if (vuDevAll.compareTo(BigDecimal.ZERO)!=0){
|
||||
outMap.put("vu_dev1",vuDev1.multiply(hundred).divide(vuDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("vu_dev2",vuDev2.multiply(hundred).divide(vuDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("vu_dev3",vuDev3.multiply(hundred).divide(vuDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("vu_dev4",vuDev4.multiply(hundred).divide(vuDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("vu_dev5",vuDev5.multiply(hundred).divide(vuDevAll,3, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
String freqDevSql = "select count(freq_dev) from data_v where phasic_type != 'T' and quality_flag = '0' and value_type = 'AVG' and ";
|
||||
QueryResult freqDevResult1 = influxDbUtils.query(freqDevSql + "freq_dev >=0.3" + processParam);
|
||||
QueryResult freqDevResult2 = influxDbUtils.query(freqDevSql + "freq_dev <0.3 and freq_dev >=0.2" + processParam);
|
||||
QueryResult freqDevResult3 = influxDbUtils.query(freqDevSql + "freq_dev <0.2 and freq_dev >=0.1" + processParam);
|
||||
QueryResult freqDevResult4 = influxDbUtils.query(freqDevSql + "freq_dev <0.1 and freq_dev >=0.05" + processParam);
|
||||
QueryResult freqDevResult5 = influxDbUtils.query(freqDevSql + "freq_dev <0.05 and freq_dev >=0" + processParam);
|
||||
BigDecimal freqDev1 = BigDecimal.valueOf(mapper.toPOJO(freqDevResult1, DataVPO.class).size());
|
||||
BigDecimal freqDev2 = BigDecimal.valueOf(mapper.toPOJO(freqDevResult2, DataVPO.class).size());
|
||||
BigDecimal freqDev3 = BigDecimal.valueOf(mapper.toPOJO(freqDevResult3, DataVPO.class).size());
|
||||
BigDecimal freqDev4 = BigDecimal.valueOf(mapper.toPOJO(freqDevResult4, DataVPO.class).size());
|
||||
BigDecimal freqDev5 = BigDecimal.valueOf(mapper.toPOJO(freqDevResult5, DataVPO.class).size());
|
||||
BigDecimal freqDevAll = freqDev1.add(freqDev2).add(freqDev3).add(freqDev4).add(freqDev5);
|
||||
if (freqDevAll.compareTo(BigDecimal.ZERO)!=0){
|
||||
outMap.put("freq_dev1",freqDev1.multiply(hundred).divide(freqDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("freq_dev2",freqDev2.multiply(hundred).divide(freqDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("freq_dev3",freqDev3.multiply(hundred).divide(freqDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("freq_dev4",freqDev4.multiply(hundred).divide(freqDevAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("freq_dev5",freqDev5.multiply(hundred).divide(freqDevAll,3, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
String vThdSql = "select count(v_thd) from data_v where phasic_type != 'T' and quality_flag = '0' and value_type = 'CP95' and ";
|
||||
QueryResult vThdResult1 = influxDbUtils.query(vThdSql + "v_thd >=6" + processParam);
|
||||
QueryResult vThdResult2 = influxDbUtils.query(vThdSql + "v_thd <6 and v_thd >=4" + processParam);
|
||||
QueryResult vThdResult3 = influxDbUtils.query(vThdSql + "v_thd <4 and v_thd >=2" + processParam);
|
||||
QueryResult vThdResult4 = influxDbUtils.query(vThdSql + "v_thd <2 and v_thd >=1" + processParam);
|
||||
QueryResult vThdResult5 = influxDbUtils.query(vThdSql + "v_thd <1 and v_thd >=0" + processParam);
|
||||
BigDecimal vThd1 = BigDecimal.valueOf(mapper.toPOJO(vThdResult1, DataVPO.class).size());
|
||||
BigDecimal vThd2 = BigDecimal.valueOf(mapper.toPOJO(vThdResult2, DataVPO.class).size());
|
||||
BigDecimal vThd3 = BigDecimal.valueOf(mapper.toPOJO(vThdResult3, DataVPO.class).size());
|
||||
BigDecimal vThd4 = BigDecimal.valueOf(mapper.toPOJO(vThdResult4, DataVPO.class).size());
|
||||
BigDecimal vThd5 = BigDecimal.valueOf(mapper.toPOJO(vThdResult5, DataVPO.class).size());
|
||||
BigDecimal vThdAll = vThd1.add(vThd2).add(vThd3).add(vThd4).add(vThd5);
|
||||
if (vThdAll.compareTo(BigDecimal.ZERO)!=0){
|
||||
outMap.put("v_thd1",vThd1.multiply(hundred).divide(vThdAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_thd2",vThd2.multiply(hundred).divide(vThdAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_thd3",vThd3.multiply(hundred).divide(vThdAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_thd4",vThd4.multiply(hundred).divide(vThdAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_thd5",vThd5.multiply(hundred).divide(vThdAll,3, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
String vUnbalanceSql="select count(v_unbalance) from data_v where phasic_type != 'T' and quality_flag = '0' and value_type = 'CP95' and ";
|
||||
QueryResult vUnbalanceResult1 = influxDbUtils.query(vUnbalanceSql + "v_unbalance >=4" + processParam);
|
||||
QueryResult vUnbalanceResult2 = influxDbUtils.query(vUnbalanceSql + "v_unbalance <4 and v_unbalance >=2" + processParam);
|
||||
QueryResult vUnbalanceResult3 = influxDbUtils.query(vUnbalanceSql + "v_unbalance <2 and v_unbalance >=1" + processParam);
|
||||
QueryResult vUnbalanceResult4 = influxDbUtils.query(vUnbalanceSql + "v_unbalance <1 and v_unbalance >=0.5" + processParam);
|
||||
QueryResult vUnbalanceResult5 = influxDbUtils.query(vUnbalanceSql + "v_unbalance <0.5 and v_unbalance >=0" + processParam);
|
||||
BigDecimal vUnbalance1 = BigDecimal.valueOf(mapper.toPOJO(vUnbalanceResult1, DataVPO.class).size());
|
||||
BigDecimal vUnbalance2 = BigDecimal.valueOf(mapper.toPOJO(vUnbalanceResult2, DataVPO.class).size());
|
||||
BigDecimal vUnbalance3 = BigDecimal.valueOf(mapper.toPOJO(vUnbalanceResult3, DataVPO.class).size());
|
||||
BigDecimal vUnbalance4 = BigDecimal.valueOf(mapper.toPOJO(vUnbalanceResult4, DataVPO.class).size());
|
||||
BigDecimal vUnbalance5 = BigDecimal.valueOf(mapper.toPOJO(vUnbalanceResult5, DataVPO.class).size());
|
||||
BigDecimal vUnbalanceAll = vUnbalance1.add(vUnbalance2).add(vUnbalance3).add(vUnbalance4).add(vUnbalance5);
|
||||
if (vUnbalanceAll.compareTo(BigDecimal.ZERO)!=0){
|
||||
outMap.put("v_unbalance1",vUnbalance1.multiply(hundred).divide(vUnbalanceAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_unbalance2",vUnbalance2.multiply(hundred).divide(vUnbalanceAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_unbalance3",vUnbalance3.multiply(hundred).divide(vUnbalanceAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_unbalance4",vUnbalance4.multiply(hundred).divide(vUnbalanceAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("v_unbalance5",vUnbalance5.multiply(hundred).divide(vUnbalanceAll,3, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
String pstSql="select count(pst) from data_flicker where phasic_type != 'T' and quality_flag = '0' and ";
|
||||
QueryResult pstResult1 = influxDbUtils.query(pstSql + "pst >=0.8" + processParam);
|
||||
QueryResult pstResult2 = influxDbUtils.query(pstSql + "pst <0.8 and pst >=0.6" + processParam);
|
||||
QueryResult pstResult3 = influxDbUtils.query(pstSql + "pst <0.6 and pst >=0.4" + processParam);
|
||||
QueryResult pstResult4 = influxDbUtils.query(pstSql + "pst <0.4 and pst >=0.2" + processParam);
|
||||
QueryResult pstResult5 = influxDbUtils.query(pstSql + "pst <0.2 and pst >=0" + processParam);
|
||||
BigDecimal pst1 = BigDecimal.valueOf(mapper.toPOJO(pstResult1, DataFlickerPO.class).size());
|
||||
BigDecimal pst2 = BigDecimal.valueOf(mapper.toPOJO(pstResult2, DataFlickerPO.class).size());
|
||||
BigDecimal pst3 = BigDecimal.valueOf(mapper.toPOJO(pstResult3, DataFlickerPO.class).size());
|
||||
BigDecimal pst4 = BigDecimal.valueOf(mapper.toPOJO(pstResult4, DataFlickerPO.class).size());
|
||||
BigDecimal pst5 = BigDecimal.valueOf(mapper.toPOJO(pstResult5, DataFlickerPO.class).size());
|
||||
BigDecimal pstAll = pst1.add(pst2).add(pst3).add(pst4).add(pst5);
|
||||
if (pstAll.compareTo(BigDecimal.ZERO)!=0){
|
||||
outMap.put("data_pst1",pst1.multiply(hundred).divide(pstAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("data_pst2",pst2.multiply(hundred).divide(pstAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("data_pst3",pst3.multiply(hundred).divide(pstAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("data_pst4",pst4.multiply(hundred).divide(pstAll,3, RoundingMode.HALF_UP));
|
||||
outMap.put("data_pst5",pst5.multiply(hundred).divide(pstAll,3, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
if (!CollUtil.isEmpty(outMap)){
|
||||
outMap.put("event1",100.0);
|
||||
outMap.put("event2",0.0);
|
||||
outMap.put("event3",0.0);
|
||||
outMap.put("event4",0.0);
|
||||
outMap.put("event5",0.0);
|
||||
}
|
||||
return outMap;
|
||||
}
|
||||
|
||||
private List<Overlimit> getAllLineOutData() {
|
||||
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.njcn.prepare.harmonic.service.Impl.line;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.po.Overlimit;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.pojo.po.DataPltPO;
|
||||
import com.njcn.prepare.harmonic.pojo.po.DataVPO;
|
||||
import com.njcn.prepare.harmonic.service.line.HarmonicMetricService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 稳态指标评估
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/3 9:08
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class HarmonicMetricServiceImpl implements HarmonicMetricService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
@Override
|
||||
public void metricData(LineParam lineParam) {
|
||||
List<String> lineIdList;
|
||||
if (CollUtil.isEmpty(lineParam.getLineIds())){
|
||||
List<Overlimit> overLimitList = getAllLineData();
|
||||
lineIdList = overLimitList.stream().map(Overlimit::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
lineIdList = new ArrayList<>(lineParam.getLineIds());
|
||||
}
|
||||
Date dateOut = DateUtil.parse(lineParam.getDataDate());
|
||||
List<String> records = new ArrayList<>();
|
||||
for (String lineId : lineIdList){
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put("line_id",lineId);
|
||||
Map<String, Object> fields = getMetricData(lineId,lineParam.getDataDate());
|
||||
Point point = influxDbUtils.pointBuilder("pqs_asses", dateOut.getTime(), TimeUnit.MILLISECONDS,tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).tag("line_id", lineId).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
}
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(),"", InfluxDB.ConsistencyLevel.ALL, records);
|
||||
}
|
||||
|
||||
private Map<String, Object> getMetricData(String lineId,String date){
|
||||
String processParam = " and line_id = '"+lineId+"' and time >= '"+date+" 00:00:00' and time <= '"+date+" 23:59:59' tz('Asia/Shanghai')";
|
||||
QueryResult vuDevResult = influxDbUtils.query("select abs(vu_dev) as vu_dev from data_v where phasic_type != 'T' and value_type = 'AVG'"+processParam);
|
||||
QueryResult vThdResult = influxDbUtils.query("select mean(v_thd) from data_v where phasic_type != 'T' and value_type = 'CP95'"+processParam);
|
||||
QueryResult freqDevResult = influxDbUtils.query("select abs(freq_dev) as freq_dev from data_v where phasic_type = 'T' and value_type = 'AVG'"+processParam);
|
||||
QueryResult vUnResult = influxDbUtils.query("select mean(v_unbalance) from data_v where phasic_type = 'T' and value_type = 'CP95'"+processParam);
|
||||
QueryResult pltResult = influxDbUtils.query("select mean(plt) from data_plt where phasic_type != 'T'"+processParam);
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
List<DataVPO> vuDev = resultMapper.toPOJO(vuDevResult, DataVPO.class);
|
||||
List<DataVPO> vThd = resultMapper.toPOJO(vThdResult, DataVPO.class);
|
||||
List<DataVPO> freqDev = resultMapper.toPOJO(freqDevResult, DataVPO.class);
|
||||
List<DataVPO> vUn = resultMapper.toPOJO(vUnResult, DataVPO.class);
|
||||
List<DataPltPO> plt = resultMapper.toPOJO(pltResult, DataPltPO.class);
|
||||
Map<String, Object> outMap = new HashMap<>();
|
||||
outMap.put("vu_dev",(vuDev.size()>0)?vuDev.stream().collect(Collectors.averagingDouble(DataVPO::getVuDev)):0.0);
|
||||
outMap.put("v_thd_cp95",(vThd.size()>0)?vThd.get(0).getMean():0.0);
|
||||
outMap.put("freq_dev",(freqDev.size()>0)?freqDev.stream().collect(Collectors.averagingDouble(DataVPO::getFreqDev)):0.0);
|
||||
outMap.put("v_unbalance_cp95",(vUn.size()>0)?vUn.get(0).getMean():0.0);
|
||||
outMap.put("data_plt",(plt.size()>0)?plt.get(0).getMean():0.0);
|
||||
return outMap;
|
||||
}
|
||||
|
||||
private List<Overlimit> getAllLineData() {
|
||||
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
|
||||
}
|
||||
}
|
||||
@@ -60,13 +60,13 @@ public class OnlineRateServiceImpl implements OnlineRateService {
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
Date newDate = Date.from(pqsCommunicate.getTime());
|
||||
OnLineRateDTO onLineRate = onLineMinute(newDate,dateOut,pqsCommunicate.getType(),pqsCommunicate.getLineId(),lineParam.getDataDate());
|
||||
tags.put("dev_id",pqsCommunicate.getLineId());
|
||||
OnLineRateDTO onLineRate = onLineMinute(newDate,dateOut,pqsCommunicate.getType(),pqsCommunicate.getDevId(),lineParam.getDataDate());
|
||||
tags.put("dev_id",pqsCommunicate.getDevId());
|
||||
fields.put("online_min",onLineRate.getOnLineMinute());
|
||||
fields.put("offline_min",onLineRate.getOffLineMinute());
|
||||
fields.put("online_rate",onLineRate.getRate());
|
||||
Point point = influxDbUtils.pointBuilder("pqs_onlinerate", dateOut.getTime(), TimeUnit.MILLISECONDS,tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).tag("dev_id", pqsCommunicate.getLineId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).tag("dev_id", pqsCommunicate.getDevId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
@@ -23,9 +24,6 @@ import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -34,7 +32,6 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -82,9 +79,22 @@ public class PollutionServiceImpl implements PollutionService {
|
||||
public void processPollutionData(LineParam lineParam) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
List<PollutionDTO> pollutionList;
|
||||
//Line_id集合不存在以及时间类型为日的情况下执行influxdb计算
|
||||
if (CollUtil.isEmpty(lineParam.getLineIds()) && Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(lineParam.getType())){
|
||||
List<Overlimit> overLimitList = getAllLinesLimitData();
|
||||
LocalDateTime local = LocalDateTimeUtil.now();
|
||||
if (StrUtil.isNotBlank(lineParam.getDataDate())){
|
||||
local = LocalDateTimeUtil.parse(lineParam.getDataDate() + "T00:00:00");
|
||||
}
|
||||
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POLLUTION_STATIS.getCode()).getData();
|
||||
//时间类型为日的情况下执行influxdb计算
|
||||
if (Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(lineParam.getType())){
|
||||
List<Overlimit> overLimitList = new ArrayList<>();
|
||||
if (CollUtil.isEmpty(lineParam.getLineIds())){
|
||||
overLimitList = getAllLinesLimitData();
|
||||
}else {
|
||||
for (String lineId : lineParam.getLineIds()){
|
||||
Overlimit overlimit = lineFeignClient.getOverLimitData(lineId).getData();
|
||||
overLimitList.add(overlimit);
|
||||
}
|
||||
}
|
||||
List<String> lineList = overLimitList.stream().map(Overlimit::getId).collect(Collectors.toList());
|
||||
//指标数据获取
|
||||
List<PublicDTO> harmonicVoltageList = getHarmonicVoltage(overLimitList,lineParam.getDataDate());
|
||||
@@ -93,7 +103,7 @@ public class PollutionServiceImpl implements PollutionService {
|
||||
List<PublicDTO> voltageDeviationList = getVoltageDeviation(overLimitList,lineParam.getDataDate());
|
||||
List<PublicDTO> threePhaseVoltageList = getThreePhaseVoltageUnbalance(overLimitList,lineParam.getDataDate());
|
||||
List<PublicDTO> negativeSequenceList = getNegativeSequenceCurrent(overLimitList,lineParam.getDataDate());
|
||||
List<PublicDTO> interharmonicVoltageList = getInterharmonicVoltage(overLimitList,lineParam.getDataDate());
|
||||
List<PublicDTO> interHarmonicVoltageList = getInterharmonicVoltage(overLimitList,lineParam.getDataDate());
|
||||
List<PublicDTO> voltageFlickerList = getVoltageFlicker(overLimitList,lineParam.getDataDate());
|
||||
LogUtil.njcnDebug(log, "监测点污染指标数据查询耗时:{}", timer.intervalRestart());
|
||||
|
||||
@@ -103,131 +113,77 @@ public class PollutionServiceImpl implements PollutionService {
|
||||
pollutionDTO.setLineId(item);
|
||||
lineIdList.add(pollutionDTO);
|
||||
});
|
||||
pollutionList = processPollutionList(lineIdList,harmonicVoltageList,harmonicCurrentList,frequencyDeviationList,voltageDeviationList,threePhaseVoltageList,negativeSequenceList,interharmonicVoltageList,voltageFlickerList);
|
||||
|
||||
Date dateOut = new Date();
|
||||
//入表harmonic_pollution
|
||||
if (StrUtil.isNotBlank(lineParam.getDataDate())){
|
||||
dateOut = DateUtil.parse(lineParam.getDataDate());
|
||||
}
|
||||
insertPolluction(pollutionList,dateOut.getTime());
|
||||
LogUtil.njcnDebug(log, "监测点污染指标数据harmonic_pollution插入耗时:{}", timer.intervalRestart());
|
||||
}else {
|
||||
//获取harmonic_pollution数据
|
||||
pollutionList = getDataPolluction(lineParam);
|
||||
pollutionList = processPollutionList(lineIdList,harmonicVoltageList,harmonicCurrentList,frequencyDeviationList,voltageDeviationList,threePhaseVoltageList,negativeSequenceList,interHarmonicVoltageList,voltageFlickerList);
|
||||
//原逻辑修改,influxDb不再进行存储日数据,改为Mysql直存
|
||||
/*insertPolluction(pollutionList,dateOut.getTime());*/
|
||||
//MySql入表 r_mp_pollution_d
|
||||
insertPollutionDayMySql(pollutionList, dictData, local);
|
||||
LogUtil.njcnDebug(log, "监测点污染指标数据MySql插入耗时:{}", timer.intervalRestart());
|
||||
}
|
||||
//MySql入表污区图表等
|
||||
LocalDateTime local = LocalDateTimeUtil.now();
|
||||
if (StrUtil.isNotBlank(lineParam.getDataDate())){
|
||||
local = LocalDateTimeUtil.parse(lineParam.getDataDate() + "T00:00:00");
|
||||
}
|
||||
if (Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(lineParam.getType())){
|
||||
//原逻辑修改,influxDb不再进行存储日数据,改为Mysql直存
|
||||
/*if (Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(lineParam.getType())){
|
||||
insertLinePollution(pollutionList,local);
|
||||
}*/
|
||||
Date dateOut = DateUtil.parse(lineParam.getDataDate());
|
||||
LocalDateTime localEnd = LocalDateTimeUtil.now();
|
||||
LambdaQueryWrapper<RMpPollutionD> lambdaQuery = new LambdaQueryWrapper<>();
|
||||
if (Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(lineParam.getType())){
|
||||
localEnd = LocalDateTimeUtil.parse(lineParam.getDataDate() + "T23:59:59");
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH).equals(lineParam.getType())){
|
||||
Date dateOutb = DateUtil.beginOfMonth(dateOut);
|
||||
Date dateOute = DateUtil.endOfMonth(dateOut);
|
||||
local = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOutb) + "T00:00:00");
|
||||
localEnd = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOute) + "T23:59:59");
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_QUARTER).equals(lineParam.getType())){
|
||||
Date dateOutb = DateUtil.beginOfQuarter(dateOut);
|
||||
Date dateOute = DateUtil.endOfQuarter(dateOut);
|
||||
local = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOutb) + "T00:00:00");
|
||||
localEnd = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOute) + "T23:59:59");
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_YEAR).equals(lineParam.getType())){
|
||||
Date dateOutb = DateUtil.beginOfYear(dateOut);
|
||||
Date dateOute = DateUtil.endOfYear(dateOut);
|
||||
local = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOutb) + "T00:00:00");
|
||||
localEnd = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOute) + "T23:59:59");
|
||||
}
|
||||
insertPolluctionMySql(pollutionList, local, lineParam.getType());
|
||||
lambdaQuery.ge(RMpPollutionD::getDataDate, local).le(RMpPollutionD::getDataDate,localEnd);
|
||||
List<RMpPollutionD> pollutionDayList = rMpPollutionDMapper.selectList(lambdaQuery);
|
||||
//MySql入表变电站、单位
|
||||
insertPolluctionMySql(pollutionDayList, dictData, local, lineParam.getType());
|
||||
LogUtil.njcnDebug(log, "监测点污染指标数据完成耗时:{}", timer.intervalRestart());
|
||||
}
|
||||
|
||||
/**
|
||||
* MySql入表
|
||||
*/
|
||||
private void insertPolluctionMySql(List<PollutionDTO> pollutionList, LocalDateTime local, Integer type){
|
||||
private void insertPolluctionMySql(List<RMpPollutionD> pollutionDayList,List<DictData> dictData, LocalDateTime local, Integer type){
|
||||
HttpResult<Map<String, List<String>>> substationOut = lineFeignClient.getLineBySubstationRelation(1);
|
||||
HttpResult<Map<String, List<String>>> unitOut = deptLineFeignClient.getLineByDeptRelation(1);
|
||||
Map<String, List<String>> substationMap = substationOut.getData();
|
||||
Map<String, List<String>> unitMap = unitOut.getData();
|
||||
List<DictData> polluctionList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POLLUTION_STATIS.getCode()).getData();
|
||||
|
||||
insertSubstation(polluctionList,substationMap,pollutionList,local,type);
|
||||
insertUnit(polluctionList,unitMap,pollutionList,local,type);
|
||||
}
|
||||
|
||||
private List<PollutionDTO> getDataPolluction(LineParam lineParam){
|
||||
List<String> lineList;
|
||||
if (CollUtil.isEmpty(lineParam.getLineIds())){
|
||||
List<Overlimit> overLimitList = getAllLinesLimitData();
|
||||
lineList = overLimitList.stream().map(Overlimit::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
lineList = new ArrayList<>(lineParam.getLineIds());
|
||||
}
|
||||
List<PollutionDTO> pollutionDTOList = new ArrayList<>();
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
for (String lineId : lineList){
|
||||
String sql="SELECT * FROM harmonic_pollution where line_id = '" + lineId +"' "+processDate(lineParam.getDataDate(),lineParam.getType());
|
||||
QueryResult dataPolluctionResult = influxDbUtils.query(sql);
|
||||
List<DataPolluctionPO> threePhaseList = resultMapper.toPOJO(dataPolluctionResult, DataPolluctionPO.class);
|
||||
for (DataPolluctionPO dataPolluction : threePhaseList){
|
||||
PollutionDTO pollutionDTO = new PollutionDTO();
|
||||
pollutionDTO.setLineId(dataPolluction.getLineId());
|
||||
pollutionDTO.setFreqDev(dataPolluction.getFreqDev());
|
||||
pollutionDTO.setVDev(dataPolluction.getVDev());
|
||||
pollutionDTO.setVUnbalance(dataPolluction.getVUnbalance());
|
||||
pollutionDTO.setVAll(dataPolluction.getVAll());
|
||||
pollutionDTO.setPlt(dataPolluction.getPlt());
|
||||
pollutionDTO.setIAll(dataPolluction.getIAll());
|
||||
pollutionDTO.setINeg(dataPolluction.getINeg());
|
||||
pollutionDTO.setVInharm(dataPolluction.getVInharm());
|
||||
pollutionDTOList.add(pollutionDTO);
|
||||
}
|
||||
}
|
||||
return pollutionDTOList;
|
||||
insertSubstation(dictData,substationMap,pollutionDayList,local,type);
|
||||
insertUnit(dictData,unitMap,pollutionDayList,local,type);
|
||||
}
|
||||
|
||||
/*MySql入表 r_mp_pollution_d*/
|
||||
private void insertLinePollution(List<PollutionDTO> pollutionList, LocalDateTime local){
|
||||
private void insertPollutionDayMySql(List<PollutionDTO> pollutionList,List<DictData> dictDataList, LocalDateTime local){
|
||||
for (PollutionDTO pollution : pollutionList){
|
||||
RMpPollutionD rMpPollution = new RMpPollutionD();
|
||||
rMpPollution.setLineId(pollution.getLineId());
|
||||
rMpPollution.setFreqDev(pollution.getFreqDev().floatValue());
|
||||
rMpPollution.setvDev(pollution.getVDev().floatValue());
|
||||
rMpPollution.setvUnbalance(pollution.getVUnbalance().floatValue());
|
||||
rMpPollution.setvAll(pollution.getVAll().floatValue());
|
||||
rMpPollution.setPlt(pollution.getPlt().floatValue());
|
||||
rMpPollution.setiAll(pollution.getIAll().floatValue());
|
||||
rMpPollution.setiNeg(pollution.getINeg().floatValue());
|
||||
rMpPollution.setvInharm(pollution.getVInharm().floatValue());
|
||||
rMpPollution.setDataDate(local);
|
||||
rMpPollutionDMapper.insertPollution(rMpPollution);
|
||||
Map<String, Object> inMap = new HashMap<>();
|
||||
inMap.put("lineId",pollution.getLineId());
|
||||
inMap.put("dataDate",local);
|
||||
for (DictData dictData : dictDataList){
|
||||
processDataLineId(dictData, pollution, inMap);
|
||||
rMpPollutionDMapper.insertPollution(inMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*MySql入表 r_stat_pollution_substation*/
|
||||
private void insertSubstation(List<DictData> polluctionList,Map<String, List<String>> substationMap,List<PollutionDTO> pollutionList,LocalDateTime local, Integer type){
|
||||
private void insertSubstation(List<DictData> dictDataList,Map<String, List<String>> substationMap,List<RMpPollutionD> pollutionDayList,LocalDateTime local, Integer type){
|
||||
for (String key : substationMap.keySet()){
|
||||
List<PollutionDTO> processList = new ArrayList<>();
|
||||
List<RMpPollutionD> processList = new ArrayList<>();
|
||||
List<String> substationList = substationMap.get(key);
|
||||
for(String lineid : substationList){
|
||||
for (PollutionDTO pollution : pollutionList){
|
||||
if (lineid.equals(pollution.getLineId())){
|
||||
processList.add(pollution);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> inMap = new HashMap<>();
|
||||
inMap.put("orgId",key);
|
||||
inMap.put("dataDate",local);
|
||||
for (DictData dictData : polluctionList){
|
||||
inMap = processData(dictData,processList,inMap);
|
||||
if (Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(type)){
|
||||
rStatPollutionOrgDMapper.insertPollution(inMap);
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH).equals(type)){
|
||||
rStatPollutionOrgMMapper.insertPollution(inMap);
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_QUARTER).equals(type)){
|
||||
rStatPollutionOrgQMapper.insertPollution(inMap);
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_YEAR).equals(type)){
|
||||
rStatPollutionOrgYMapper.insertPollution(inMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*MySql入表 r_stat_pollution_org*/
|
||||
private void insertUnit(List<DictData> polluctionList,Map<String, List<String>> unitMap,List<PollutionDTO> pollutionList,LocalDateTime local, Integer type){
|
||||
for (String key : unitMap.keySet()){
|
||||
List<PollutionDTO> processList = new ArrayList<>();
|
||||
List<String> unitList = unitMap.get(key);
|
||||
for(String lineid : unitList){
|
||||
for (PollutionDTO pollution : pollutionList){
|
||||
for (RMpPollutionD pollution : pollutionDayList){
|
||||
if (lineid.equals(pollution.getLineId())){
|
||||
processList.add(pollution);
|
||||
}
|
||||
@@ -236,8 +192,11 @@ public class PollutionServiceImpl implements PollutionService {
|
||||
Map<String, Object> inMap = new HashMap<>();
|
||||
inMap.put("substationId",key);
|
||||
inMap.put("dataDate",local);
|
||||
for (DictData dictData : polluctionList){
|
||||
inMap = processData(dictData,processList,inMap);
|
||||
for (DictData dictData : dictDataList){
|
||||
processData(dictData, processList, inMap);
|
||||
if (!inMap.containsKey("pollutionType")){
|
||||
continue;
|
||||
}
|
||||
if (Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(type)){
|
||||
rStatPollutionSubstationDMapper.insertPollution(inMap);
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH).equals(type)){
|
||||
@@ -251,40 +210,85 @@ public class PollutionServiceImpl implements PollutionService {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> processData(DictData dictData,List<PollutionDTO> processList,Map<String, Object> map){
|
||||
/*MySql入表 r_stat_pollution_org*/
|
||||
private void insertUnit(List<DictData> dictDataList,Map<String, List<String>> unitMap,List<RMpPollutionD> pollutionDayList,LocalDateTime local, Integer type){
|
||||
for (String key : unitMap.keySet()){
|
||||
List<RMpPollutionD> processList = new ArrayList<>();
|
||||
List<String> unitList = unitMap.get(key);
|
||||
for(String lineid : unitList){
|
||||
for (RMpPollutionD pollution : pollutionDayList){
|
||||
if (lineid.equals(pollution.getLineId())){
|
||||
processList.add(pollution);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> inMap = new HashMap<>();
|
||||
inMap.put("orgId",key);
|
||||
inMap.put("dataDate",local);
|
||||
for (DictData dictData : dictDataList){
|
||||
processData(dictData, processList, inMap);
|
||||
if (!inMap.containsKey("pollutionType")){
|
||||
continue;
|
||||
}
|
||||
if (Integer.valueOf(BizParamConstant.STAT_BIZ_DAY).equals(type)){
|
||||
rStatPollutionOrgDMapper.insertPollution(inMap);
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH).equals(type)){
|
||||
rStatPollutionOrgMMapper.insertPollution(inMap);
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_QUARTER).equals(type)){
|
||||
rStatPollutionOrgQMapper.insertPollution(inMap);
|
||||
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_YEAR).equals(type)){
|
||||
rStatPollutionOrgYMapper.insertPollution(inMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processDataLineId(DictData dictData, PollutionDTO pollution, Map<String, Object> map){
|
||||
if ("Freq_Dev".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getFreqDev)).get().getFreqDev());
|
||||
map.put("value",pollution.getFreqDev());
|
||||
}
|
||||
if ("V_Dev".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getVDev)).get().getVDev());
|
||||
map.put("value",pollution.getVDev());
|
||||
}
|
||||
if ("V_Unbalance".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getVUnbalance)).get().getVUnbalance());
|
||||
map.put("value",pollution.getVUnbalance());
|
||||
}
|
||||
if ("V_All".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getVAll)).get().getVAll());
|
||||
map.put("value",pollution.getVAll());
|
||||
}
|
||||
if ("Plt".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getPlt)).get().getPlt());
|
||||
map.put("value",pollution.getPlt());
|
||||
}
|
||||
if ("I_All".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getIAll)).get().getIAll());
|
||||
map.put("value",pollution.getIAll());
|
||||
}
|
||||
if ("I_Neg".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getINeg)).get().getINeg());
|
||||
map.put("value",pollution.getINeg());
|
||||
}
|
||||
if ("V_Inharm".equals(dictData.getCode())){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processList.stream().max(Comparator.comparing(PollutionDTO::getVInharm)).get().getVInharm());
|
||||
map.put("value",pollution.getVInharm());
|
||||
}
|
||||
}
|
||||
|
||||
private void processData(DictData dictData, List<RMpPollutionD> processList, Map<String, Object> map){
|
||||
List<RMpPollutionD> processDataList = new ArrayList<>();
|
||||
for (RMpPollutionD rMpPollution : processList){
|
||||
if (dictData.getId().equals(rMpPollution.getPollutionType())){
|
||||
processDataList.add(rMpPollution);
|
||||
}
|
||||
}
|
||||
if (!CollUtil.isEmpty(processDataList)){
|
||||
map.put("pollutionType",dictData.getId());
|
||||
map.put("value",processDataList.stream().max(Comparator.comparing(RMpPollutionD::getValue)).get().getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -623,31 +627,6 @@ public class PollutionServiceImpl implements PollutionService {
|
||||
return process(outMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 监测点污染指标数据入表 harmonic_pollution
|
||||
*/
|
||||
private void insertPolluction(List<PollutionDTO> list, long time){
|
||||
List<String> records = new ArrayList<String>();
|
||||
list.forEach(item->{
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
tags.put("line_id",item.getLineId());
|
||||
fields.put("freq_dev",item.getFreqDev());
|
||||
fields.put("v_dev",item.getVDev());
|
||||
fields.put("v_unbalance",item.getVUnbalance());
|
||||
fields.put("i_neg",item.getINeg());
|
||||
fields.put("v_all",item.getVAll());
|
||||
fields.put("i_all",item.getIAll());
|
||||
fields.put("v_inharm",item.getVInharm());
|
||||
fields.put("plt",item.getPlt());
|
||||
Point point = influxDbUtils.pointBuilder("harmonic_pollution", time, TimeUnit.MILLISECONDS,tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).tag("line_id", item.getLineId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
});
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(),"", InfluxDB.ConsistencyLevel.ALL, records);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数拼装处理
|
||||
*/
|
||||
@@ -742,4 +721,75 @@ public class PollutionServiceImpl implements PollutionService {
|
||||
private List<Overlimit> getAllLinesLimitData() {
|
||||
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
|
||||
}
|
||||
|
||||
/*private List<PollutionDTO> getDataPolluction(LineParam lineParam){
|
||||
List<String> lineList;
|
||||
if (CollUtil.isEmpty(lineParam.getLineIds())){
|
||||
List<Overlimit> overLimitList = getAllLinesLimitData();
|
||||
lineList = overLimitList.stream().map(Overlimit::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
lineList = new ArrayList<>(lineParam.getLineIds());
|
||||
}
|
||||
List<PollutionDTO> pollutionDTOList = new ArrayList<>();
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
for (String lineId : lineList){
|
||||
String sql="SELECT * FROM harmonic_pollution where line_id = '" + lineId +"' "+processDate(lineParam.getDataDate(),lineParam.getType());
|
||||
QueryResult dataPolluctionResult = influxDbUtils.query(sql);
|
||||
List<DataPolluctionPO> threePhaseList = resultMapper.toPOJO(dataPolluctionResult, DataPolluctionPO.class);
|
||||
for (DataPolluctionPO dataPolluction : threePhaseList){
|
||||
PollutionDTO pollutionDTO = new PollutionDTO();
|
||||
pollutionDTO.setLineId(dataPolluction.getLineId());
|
||||
pollutionDTO.setFreqDev(dataPolluction.getFreqDev());
|
||||
pollutionDTO.setVDev(dataPolluction.getVDev());
|
||||
pollutionDTO.setVUnbalance(dataPolluction.getVUnbalance());
|
||||
pollutionDTO.setVAll(dataPolluction.getVAll());
|
||||
pollutionDTO.setPlt(dataPolluction.getPlt());
|
||||
pollutionDTO.setIAll(dataPolluction.getIAll());
|
||||
pollutionDTO.setINeg(dataPolluction.getINeg());
|
||||
pollutionDTO.setVInharm(dataPolluction.getVInharm());
|
||||
pollutionDTOList.add(pollutionDTO);
|
||||
}
|
||||
}
|
||||
return pollutionDTOList;
|
||||
}*/
|
||||
|
||||
/*MySql入表 r_mp_pollution_d*/
|
||||
/*private void insertLinePollution(List<PollutionDTO> pollutionList, LocalDateTime local){
|
||||
for (PollutionDTO pollution : pollutionList){
|
||||
RMpPollutionD rMpPollution = new RMpPollutionD();
|
||||
rMpPollution.setLineId(pollution.getLineId());
|
||||
rMpPollution.setFreqDev(pollution.getFreqDev().floatValue());
|
||||
rMpPollution.setvDev(pollution.getVDev().floatValue());
|
||||
rMpPollution.setvUnbalance(pollution.getVUnbalance().floatValue());
|
||||
rMpPollution.setvAll(pollution.getVAll().floatValue());
|
||||
rMpPollution.setPlt(pollution.getPlt().floatValue());
|
||||
rMpPollution.setiAll(pollution.getIAll().floatValue());
|
||||
rMpPollution.setiNeg(pollution.getINeg().floatValue());
|
||||
rMpPollution.setvInharm(pollution.getVInharm().floatValue());
|
||||
rMpPollution.setDataDate(local);
|
||||
rMpPollutionDMapper.insertPollution(rMpPollution);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*private void insertPolluction(List<PollutionDTO> list, long time){
|
||||
List<String> records = new ArrayList<String>();
|
||||
list.forEach(item->{
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
tags.put("line_id",item.getLineId());
|
||||
fields.put("freq_dev",item.getFreqDev());
|
||||
fields.put("v_dev",item.getVDev());
|
||||
fields.put("v_unbalance",item.getVUnbalance());
|
||||
fields.put("i_neg",item.getINeg());
|
||||
fields.put("v_all",item.getVAll());
|
||||
fields.put("i_all",item.getIAll());
|
||||
fields.put("v_inharm",item.getVInharm());
|
||||
fields.put("plt",item.getPlt());
|
||||
Point point = influxDbUtils.pointBuilder("harmonic_pollution", time, TimeUnit.MILLISECONDS,tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).tag("line_id", item.getLineId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
});
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(),"", InfluxDB.ConsistencyLevel.ALL, records);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
for (List<Object> columnValue : values) {
|
||||
for (int i = 0; i < columnValue.size(); i++) {
|
||||
if (columns.get(i).equals("value")) {
|
||||
data.setValue(columnValue.get(i).toString());
|
||||
data.setValue(String.format("%.3f", columnValue.get(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.prepare.harmonic.service.line;
|
||||
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/7 9:18
|
||||
*/
|
||||
public interface DistortionRateService {
|
||||
|
||||
void distortionRate(LineParam lineParam);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.prepare.harmonic.service.line;
|
||||
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/3 11:02
|
||||
*/
|
||||
public interface HarmonicGeneralService {
|
||||
|
||||
void generalData(LineParam lineParam);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.prepare.harmonic.service.line;
|
||||
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
|
||||
/**
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/3 9:05
|
||||
*/
|
||||
public interface HarmonicMetricService {
|
||||
|
||||
void metricData(LineParam lineParam);
|
||||
}
|
||||
@@ -45,9 +45,9 @@ logging:
|
||||
|
||||
|
||||
##mybatis配置信息
|
||||
#mybatis-plus:
|
||||
# #别名扫描
|
||||
# type-aliases-package: com.njcn.user.pojo
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.prepare.harmonic.pojo
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
Reference in New Issue
Block a user