1.部分算法调度任务添加

2.算法调整
This commit is contained in:
2023-07-26 15:29:26 +08:00
parent c14db734fe
commit f4b5786236
23 changed files with 857 additions and 68 deletions

View File

@@ -0,0 +1,24 @@
package com.njcn.prepare.harmonic.api.newalgorithm;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.RMpEventDetailFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import io.swagger.annotations.ApiOperation;
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;
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/rmpeventdetail",//对应controller请求类
fallbackFactory = RMpEventDetailFeignClientFallbackFactory.class//服务降级处理类
)
public interface RMpEventDetailFeignClient {
@PostMapping("/eventdetailHandler")
@ApiOperation("监测点暂态指标处理")
HttpResult<String> eventdetailHandler(@RequestBody @Validated LineParam lineParam);
}

View File

@@ -0,0 +1,23 @@
package com.njcn.prepare.harmonic.api.newalgorithm;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.RMpMonitorEvaluateFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
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;
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/rmpmonitorevaluate",//对应controller请求类
fallbackFactory = RMpMonitorEvaluateFeignClientFallbackFactory.class//服务降级处理类
)
public interface RMpMonitorEvaluateFeignClient {
@ApiOperation("监测点评价_日统计(MySQL库)")
@PostMapping("handlerMonitorEvaluate")
HttpResult<Boolean> handlerMonitorEvaluate(@RequestBody LineParam jobParam );
}

View File

@@ -0,0 +1,24 @@
package com.njcn.prepare.harmonic.api.newalgorithm;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.ROperatingMonitorFeignClientFallbackFactory;
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;
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/roperatingmonitor",//对应controller请求类
fallbackFactory = ROperatingMonitorFeignClientFallbackFactory.class//服务降级处理类
)
public interface ROperatingMonitorFeignClient {
@PostMapping("handlerMonitorOperatingD")
HttpResult<Boolean> handlerMonitorOperatingD(@RequestBody LineParam jobParam );
@PostMapping("handlerMonitorOperatingM")
HttpResult<Boolean> handlerMonitorOperatingM(@RequestBody LineParam jobParam );
}

View File

@@ -0,0 +1,23 @@
package com.njcn.prepare.harmonic.api.newalgorithm;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.RStatAbnormalFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
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;
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/rmstatabnormal",//对应controller请求类
fallbackFactory = RStatAbnormalFeignClientFallbackFactory.class//服务降级处理类
)
public interface RStatAbnormalFeignClient {
@ApiOperation("监测点异常_日统计(MySQL库)")
@PostMapping("handlerMonitorAbnormal")
HttpResult<Boolean> handlerMonitorAbnormal(@RequestBody LineParam jobParam );
}

View File

@@ -0,0 +1,21 @@
package com.njcn.prepare.harmonic.api.newalgorithm;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.RStatHarmonicFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.pojo.param.OrgParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/rstatharmonic",//对应controller请求类
fallbackFactory = RStatHarmonicFeignClientFallbackFactory.class//服务降级处理类
)
public interface RStatHarmonicFeignClient {
@PostMapping("/Handler")
HttpResult<String> handler(@RequestBody OrgParam orgParam);
}

View File

@@ -0,0 +1,33 @@
package com.njcn.prepare.harmonic.api.newalgorithm.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.biz.utils.DeviceEnumUtil;
import com.njcn.prepare.harmonic.api.newalgorithm.RMpEventDetailFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RMpEventDetailFeignClientFallbackFactory implements FallbackFactory<RMpEventDetailFeignClient> {
@Override
public RMpEventDetailFeignClient 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 RMpEventDetailFeignClient() {
@Override
public HttpResult<String> eventdetailHandler(LineParam lineParam) {
log.error("{}异常,降级处理,异常为:{}", "监测点暂态指标处理: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,33 @@
package com.njcn.prepare.harmonic.api.newalgorithm.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.biz.utils.DeviceEnumUtil;
import com.njcn.prepare.harmonic.api.newalgorithm.RMpMonitorEvaluateFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RMpMonitorEvaluateFeignClientFallbackFactory implements FallbackFactory<RMpMonitorEvaluateFeignClient> {
@Override
public RMpMonitorEvaluateFeignClient 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 RMpMonitorEvaluateFeignClient() {
@Override
public HttpResult<Boolean> handlerMonitorEvaluate(LineParam jobParam) {
log.error("{}异常,降级处理,异常为:{}", "监测点评价_日统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,38 @@
package com.njcn.prepare.harmonic.api.newalgorithm.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.biz.utils.DeviceEnumUtil;
import com.njcn.prepare.harmonic.api.newalgorithm.ROperatingMonitorFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class ROperatingMonitorFeignClientFallbackFactory implements FallbackFactory<ROperatingMonitorFeignClient> {
@Override
public ROperatingMonitorFeignClient 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 ROperatingMonitorFeignClient() {
@Override
public HttpResult<Boolean> handlerMonitorOperatingD(LineParam jobParam) {
log.error("{}异常,降级处理,异常为:{}", "监测点数据质量_日统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> handlerMonitorOperatingM(LineParam jobParam) {
log.error("{}异常,降级处理,异常为:{}", "监测点数据质量_月统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,33 @@
package com.njcn.prepare.harmonic.api.newalgorithm.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.biz.utils.DeviceEnumUtil;
import com.njcn.prepare.harmonic.api.newalgorithm.RStatAbnormalFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RStatAbnormalFeignClientFallbackFactory implements FallbackFactory<RStatAbnormalFeignClient> {
@Override
public RStatAbnormalFeignClient 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 RStatAbnormalFeignClient() {
@Override
public HttpResult<Boolean> handlerMonitorAbnormal(LineParam jobParam) {
log.error("{}异常,降级处理,异常为:{}", "监测点异常_日统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,33 @@
package com.njcn.prepare.harmonic.api.newalgorithm.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.biz.utils.DeviceEnumUtil;
import com.njcn.prepare.harmonic.api.newalgorithm.RStatHarmonicFeignClient;
import com.njcn.prepare.harmonic.pojo.param.OrgParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RStatHarmonicFeignClientFallbackFactory implements FallbackFactory<RStatHarmonicFeignClient> {
@Override
public RStatHarmonicFeignClient 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 RStatHarmonicFeignClient() {
@Override
public HttpResult<String> handler(OrgParam orgParam) {
log.error("{}异常,降级处理,异常为:{}", "单位监测点稳态指标统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -87,26 +87,20 @@
<select id="getAvgDayData" resultType="com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO">
select
Y.lineId,
avg(Y.vUnbalance) vUnbalance,
avg(Y.vHarmonic) vHarmonic,
avg(Y.vlDev) vlDev,
avg(Y.freqDev) freqDev,
avg(Y.plt) plt,
avg(Y.sagTimes) sagTimes,
avg(Y.interruptTimes) interruptTimes
from
t0.lineId,
coalesce(t0.vUnbalance, 0) vUnbalance,
coalesce(t0.v, 0) vHarmonic,
coalesce(t1.vlDev, 0) vlDev,
coalesce(t1.freqDev, 0) freqDev,
coalesce(t2.plt, 0) plt,
coalesce(t3.sagTimes, 0) sagTimes,
coalesce(t3.interruptTimes, 0) interruptTimes
from
(
select
A.time,
A.lineId,
coalesce(A.vUnbalance, 0) vUnbalance,
coalesce(A.v, 0) vHarmonic,
coalesce(B.vlDev, 0) vlDev,
coalesce(B.freqDev, 0) freqDev,
coalesce(C.plt, 0) plt,
coalesce(D.sagTimes, 0) sagTimes,
coalesce(D.interruptTimes, 0) interruptTimes
avg(A.vUnbalance) vUnbalance,
avg(A.v) v
from
(
select
@@ -115,27 +109,50 @@
max(v_unbalance) vUnbalance,
max(greatest(v_thd, v_1, v_2, v_3, v_4, v_5, v_6, v_7, v_8, v_9, v_10, v_11, v_12, v_13, v_14, v_15, v_16, v_17, v_18, v_19, v_20, v_21, v_22, v_23, v_24, v_25, v_26, v_27, v_28, v_29, v_30, v_31, v_32, v_33, v_34, v_35, v_36, v_37, v_38, v_39, v_40, v_41, v_42, v_43, v_44, v_45, v_46, v_47, v_48, v_49, v_50)) v
from
r_stat_data_v_d t0
r_stat_data_v_d
where
`time` between #{startTime} and #{endTime} and value_type = 'CP95'
group by `time`,line_id
) A
left join
(
`time` between #{startTime} and #{endTime}
and value_type = 'CP95'
group by
`time`,
line_id
) A
group by
A.lineId
) t0
left join
(
select
B.lineId,
avg(B.vlDev) vlDev,
avg(B.freqDev) freqDev
from
(
select
`time`,
line_id lineId,
max(abs(vl_dev)) vlDev,
max(abs(freq_dev)) freqDev
from
r_stat_data_v_d t0
r_stat_data_v_d
where
`time` between #{startTime} and #{endTime} and value_type = 'MAX'
group by `time`,line_id
) B
on A.lineId = B.lineId
left join
(
`time` between #{startTime} and #{endTime}
and value_type = 'MAX'
group by
`time`,
line_id
) B
group by
B.lineId
) t1
on t0.lineId = t1.lineId
left join
(
select
C.lineId,
avg(C.plt) plt
from
(
select
`time` ,
line_id lineId,
@@ -143,33 +160,38 @@
from
r_stat_data_plt_d
where
`time` between #{startTime} and #{endTime} and value_type = 'MAX'
group by `time`,line_id
) C
on A.lineId = C.lineId
left join
(
select
measurement_point_id lineId,
data_date dataDate,
sag_times sagTimes,
interrupt_times interruptTimes
from
r_mp_event_detail_d
where
data_date between #{startTime} and #{endTime}
) D
on A.lineId = D.lineId
<where>
<if test="list != null and list.size() > 0">
A.lineId in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
) Y
group by Y.lineId
`time` between #{startTime} and #{endTime}
and value_type = 'MAX'
group by
`time`,
line_id
) C
group by
C.lineId
) t2
on t0.lineId = t2.lineId
left join
(
select
measurement_point_id lineId,
avg(sag_times) sagTimes,
avg(interrupt_times) interruptTimes
from
r_mp_event_detail_d
where
data_date between #{startTime} and #{endTime}
group by
measurement_point_id
) t3
on t0.lineId = t3.lineId
<where>
<if test="list != null and list.size() > 0">
A.lineId in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="getTargetWarnD" resultType="com.njcn.prepare.harmonic.pojo.dto.RMpTargetWarnDDTO">

View File

@@ -382,7 +382,207 @@
or t0.inuharm_16_overtime>0
) then 1
else 0
end isInuharm
end isInuharm,
case
when t0.uharm_2_overtime>0 then 1
else 0
end +
case
when t0.uharm_3_overtime>0 then 1
else 0
end +
case
when t0.uharm_4_overtime>0 then 1
else 0
end +
case
when t0.uharm_5_overtime>0 then 1
else 0
end +
case
when t0.uharm_6_overtime>0 then 1
else 0
end +
case
when t0.uharm_7_overtime>0 then 1
else 0
end +
case
when t0.uharm_8_overtime>0 then 1
else 0
end +
case
when t0.uharm_9_overtime>0 then 1
else 0
end +
case
when t0.uharm_10_overtime>0 then 1
else 0
end +
case
when t0.uharm_11_overtime>0 then 1
else 0
end +
case
when t0.uharm_12_overtime>0 then 1
else 0
end +
case
when t0.uharm_13_overtime>0 then 1
else 0
end +
case
when t0.uharm_14_overtime>0 then 1
else 0
end +
case
when t0.uharm_15_overtime>0 then 1
else 0
end +
case
when t0.uharm_16_overtime>0 then 1
else 0
end +
case
when t0.uharm_17_overtime>0 then 1
else 0
end +
case
when t0.uharm_18_overtime>0 then 1
else 0
end +
case
when t0.uharm_19_overtime>0 then 1
else 0
end +
case
when t0.uharm_20_overtime>0 then 1
else 0
end +
case
when t0.uharm_21_overtime>0 then 1
else 0
end +
case
when t0.uharm_22_overtime>0 then 1
else 0
end +
case
when t0.uharm_23_overtime>0 then 1
else 0
end +
case
when t0.uharm_24_overtime>0 then 1
else 0
end +
case
when t0.uharm_25_overtime>0 then 1
else 0
end vTimes,
case
when t0.iharm_2_overtime>0 then 1
else 0
end +
case
when t0.iharm_3_overtime>0 then 1
else 0
end +
case
when t0.iharm_4_overtime>0 then 1
else 0
end +
case
when t0.iharm_5_overtime>0 then 1
else 0
end +
case
when t0.iharm_6_overtime>0 then 1
else 0
end +
case
when t0.iharm_7_overtime>0 then 1
else 0
end +
case
when t0.iharm_8_overtime>0 then 1
else 0
end +
case
when t0.iharm_9_overtime>0 then 1
else 0
end +
case
when t0.iharm_10_overtime>0 then 1
else 0
end +
case
when t0.iharm_11_overtime>0 then 1
else 0
end +
case
when t0.iharm_12_overtime>0 then 1
else 0
end +
case
when t0.iharm_13_overtime>0 then 1
else 0
end +
case
when t0.iharm_14_overtime>0 then 1
else 0
end +
case
when t0.iharm_15_overtime>0 then 1
else 0
end +
case
when t0.iharm_16_overtime>0 then 1
else 0
end +
case
when t0.iharm_17_overtime>0 then 1
else 0
end +
case
when t0.iharm_18_overtime>0 then 1
else 0
end +
case
when t0.iharm_19_overtime>0 then 1
else 0
end +
case
when t0.iharm_20_overtime>0 then 1
else 0
end +
case
when t0.iharm_21_overtime>0 then 1
else 0
end +
case
when t0.iharm_22_overtime>0 then 1
else 0
end +
case
when t0.iharm_23_overtime>0 then 1
else 0
end +
case
when t0.iharm_24_overtime>0 then 1
else 0
end +
case
when t0.iharm_25_overtime>0 then 1
else 0
end iTimes,
case
when t0.ubalance_overtime>0 then 1
else 0
end unbalanceTimes,
case
when t0.i_neg_overtime>0 then 1
else 0
end iNegTimes
from
r_stat_limit_rate_d t0
left join

View File

@@ -126,7 +126,71 @@
case
when t0.inuharm_16_overtime>0 then 1
else 0
end isInuharm16
end isInuharm16,
case
when t0.inuharm_1_overtime>0 then 1
else 0
end +
case
when t0.inuharm_2_overtime>0 then 1
else 0
end +
case
when t0.inuharm_3_overtime>0 then 1
else 0
end +
case
when t0.inuharm_4_overtime>0 then 1
else 0
end +
case
when t0.inuharm_5_overtime>0 then 1
else 0
end +
case
when t0.inuharm_6_overtime>0 then 1
else 0
end +
case
when t0.inuharm_7_overtime>0 then 1
else 0
end +
case
when t0.inuharm_8_overtime>0 then 1
else 0
end +
case
when t0.inuharm_9_overtime>0 then 1
else 0
end +
case
when t0.inuharm_10_overtime>0 then 1
else 0
end +
case
when t0.inuharm_11_overtime>0 then 1
else 0
end +
case
when t0.inuharm_12_overtime>0 then 1
else 0
end +
case
when t0.inuharm_13_overtime>0 then 1
else 0
end +
case
when t0.inuharm_14_overtime>0 then 1
else 0
end +
case
when t0.inuharm_15_overtime>0 then 1
else 0
end +
case
when t0.inuharm_16_overtime>0 then 1
else 0
end inuharmTimes
from
r_stat_limit_rate_d t0
where

View File

@@ -36,6 +36,8 @@ public class RMpPartHarmonicDetailDServiceImpl extends MppServiceImpl<RMpPartHar
log.info(LocalDateTime.now()+"===>监测点稳态指标超标明细日表1开始执行");
List<RMpPartHarmonicDetailD> result = new ArrayList<>();
if (Objects.equals(lineParam.getType(),5)){
System.out.println(lineParam.getDataDate());
System.out.println(lineParam.getLineIds());
result = getData(lineParam.getDataDate(),lineParam.getLineIds());
} else if (Objects.equals(lineParam.getType(),3)){
int year = Integer.parseInt(lineParam.getDataDate().split("-")[0]);