代码调整
This commit is contained in:
@@ -0,0 +1,71 @@
|
|||||||
|
package com.njcn.executor.handler;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||||
|
import com.njcn.executor.utils.CommonExecutorUtils;
|
||||||
|
import com.njcn.prepare.harmonic.api.line.HarmOverLimitFeignClient;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/5/10 14:29
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class HarmOverLimitJob {
|
||||||
|
|
||||||
|
private final HarmOverLimitFeignClient harmOverLimitFeignClient;
|
||||||
|
|
||||||
|
@XxlJob("harmonicDetailDay1Job")
|
||||||
|
public void harmonicDetailDay1Job(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
harmOverLimitFeignClient.harmonicDetailDay1(lineParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XxlJob("harmonicDetailDay2Job")
|
||||||
|
public void harmonicDetailDay2Job(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
harmOverLimitFeignClient.harmonicDetailDay2(lineParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XxlJob("harmonicDetailMonth1Job")
|
||||||
|
public void harmonicDetailMonth1Job(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
harmOverLimitFeignClient.harmonicDetailMonth1(lineParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XxlJob("harmonicDetailMonth2Job")
|
||||||
|
public void harmonicDetailMonth2Job(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
harmOverLimitFeignClient.harmonicDetailMonth2(lineParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XxlJob("harmonicThdDayJob")
|
||||||
|
public void harmonicThdDayJob(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
harmOverLimitFeignClient.harmonicThdDay(lineParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.njcn.executor.handler;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||||
|
import com.njcn.executor.utils.CommonExecutorUtils;
|
||||||
|
import com.njcn.prepare.harmonic.api.line.TargetWarnFeignClient;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/5/10 14:29
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class TargetWarnJob {
|
||||||
|
|
||||||
|
private final TargetWarnFeignClient targetWarnFeignClient;
|
||||||
|
|
||||||
|
@XxlJob("targetDiffJob")
|
||||||
|
public void targetDiffJob(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
targetWarnFeignClient.targetDiff(lineParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XxlJob("alarmDayJob")
|
||||||
|
public void alarmDayJob(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
targetWarnFeignClient.alarmDay(lineParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XxlJob("alarmMonthJob")
|
||||||
|
public void alarmMonthJob(){
|
||||||
|
LineParam lineParam = new LineParam();
|
||||||
|
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
|
||||||
|
lineParam.setDataSource(2);
|
||||||
|
targetWarnFeignClient.alarmMonth(lineParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.njcn.prepare.harmonic.api.line;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
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.api.line.fallback.HarmOverLimitFeignClientFallbackFactory;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
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 = "/harmonicOverLimit",//对应controller请求类
|
||||||
|
fallbackFactory = HarmOverLimitFeignClientFallbackFactory.class//服务降级处理类
|
||||||
|
)
|
||||||
|
public interface HarmOverLimitFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/harmonicDetailDay1")
|
||||||
|
HttpResult<Boolean> harmonicDetailDay1(@RequestBody LineParam lineParam);
|
||||||
|
|
||||||
|
@PostMapping("/harmonicDetailDay2")
|
||||||
|
HttpResult<Boolean> harmonicDetailDay2(@RequestBody LineParam lineParam);
|
||||||
|
|
||||||
|
@PostMapping("/harmonicDetailMonth1")
|
||||||
|
HttpResult<Boolean> harmonicDetailMonth1(@RequestBody @Validated LineParam lineParam);
|
||||||
|
|
||||||
|
@PostMapping("/harmonicDetailMonth2")
|
||||||
|
HttpResult<Boolean> harmonicDetailMonth2(@RequestBody @Validated LineParam lineParam);
|
||||||
|
|
||||||
|
@PostMapping("/harmonicThdDay")
|
||||||
|
HttpResult<Boolean> harmonicThdDay(@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.TargetWarnFeignClientFallbackFactory;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@FeignClient(
|
||||||
|
value = ServerInfo.PREPARE_BOOT,//对应模块名
|
||||||
|
path = "/alarmDetail",//对应controller请求类
|
||||||
|
fallbackFactory = TargetWarnFeignClientFallbackFactory.class//服务降级处理类
|
||||||
|
)
|
||||||
|
public interface TargetWarnFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/targetDiff")
|
||||||
|
HttpResult<Boolean> targetDiff(@RequestBody @Validated LineParam lineParam);
|
||||||
|
|
||||||
|
@PostMapping("/alarmDay")
|
||||||
|
HttpResult<Boolean> alarmDay(@RequestBody @Validated LineParam lineParam);
|
||||||
|
|
||||||
|
@PostMapping("/alarmMonth")
|
||||||
|
HttpResult<Boolean> alarmMonth(@RequestBody @Validated LineParam lineParam);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
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.biz.utils.DeviceEnumUtil;
|
||||||
|
import com.njcn.prepare.harmonic.api.line.HarmOverLimitFeignClient;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuyang
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class HarmOverLimitFeignClientFallbackFactory implements FallbackFactory<HarmOverLimitFeignClient> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HarmOverLimitFeignClient 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 HarmOverLimitFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> harmonicDetailDay1(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点稳态指标超标明细日表1: ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> harmonicDetailDay2(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点稳态指标超标明细日表2: ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> harmonicDetailMonth1(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点稳态指标超标明细月表1: ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> harmonicDetailMonth2(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点稳态指标超标明细月表1: ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> harmonicThdDay(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "谐波畸变率日表: ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
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.biz.utils.DeviceEnumUtil;
|
||||||
|
import com.njcn.prepare.harmonic.api.line.HarmOverLimitFeignClient;
|
||||||
|
import com.njcn.prepare.harmonic.api.line.TargetWarnFeignClient;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuyang
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class TargetWarnFeignClientFallbackFactory implements FallbackFactory<TargetWarnFeignClient> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TargetWarnFeignClient 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 TargetWarnFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> targetDiff(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点稳态指标差值日统计: ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> alarmDay(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点指标告警日统计(新): ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> alarmMonth(LineParam lineParam) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点指标告警月统计(新): ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.area.IRMpMonitorAlarmCountMService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.area.RMpTargetWarnDService;
|
||||||
import com.njcn.prepare.harmonic.service.mysql.line.AlarmDetailService;
|
import com.njcn.prepare.harmonic.service.mysql.line.AlarmDetailService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -35,6 +37,10 @@ public class AlarmDetailController extends BaseController {
|
|||||||
|
|
||||||
private final AlarmDetailService alarmDetailService;
|
private final AlarmDetailService alarmDetailService;
|
||||||
|
|
||||||
|
private final RMpTargetWarnDService rMpTargetWarnDService;
|
||||||
|
|
||||||
|
private final IRMpMonitorAlarmCountMService rMpMonitorAlarmCountMService;
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||||
@PostMapping("/alarmDetailAlarm")
|
@PostMapping("/alarmDetailAlarm")
|
||||||
@ApiOperation("监测点指标告警日统计")
|
@ApiOperation("监测点指标告警日统计")
|
||||||
@@ -61,4 +67,24 @@ public class AlarmDetailController extends BaseController {
|
|||||||
alarmDetailService.targetDiff(lineParam);
|
alarmDetailService.targetDiff(lineParam);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||||
|
@PostMapping("/alarmDay")
|
||||||
|
@ApiOperation("监测点指标告警日统计(新)")
|
||||||
|
@ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
|
||||||
|
public HttpResult<Boolean> alarmDay(@RequestBody @Validated LineParam lineParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("alarmDay");
|
||||||
|
rMpTargetWarnDService.alarmDay(lineParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||||
|
@PostMapping("/alarmMonth")
|
||||||
|
@ApiOperation("监测点指标告警月统计(新)")
|
||||||
|
@ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
|
||||||
|
public HttpResult<Boolean> alarmMonth(@RequestBody @Validated LineParam lineParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("alarmMonth");
|
||||||
|
rMpMonitorAlarmCountMService.alarmMonth(lineParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package com.njcn.prepare.harmonic.controller.line;
|
|
||||||
|
|
||||||
|
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
|
||||||
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.mysql.area.IRMpMonitorAlarmCountMService;
|
|
||||||
import com.njcn.prepare.harmonic.service.mysql.area.RMpTargetWarnDService;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @since 2023-05-08
|
|
||||||
*/
|
|
||||||
@Validated
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/alarmDetailData")
|
|
||||||
@Api(tags = "监测点指标告警明细")
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class RMpTargetWarnController extends BaseController {
|
|
||||||
|
|
||||||
private final RMpTargetWarnDService rMpTargetWarnDService;
|
|
||||||
|
|
||||||
private final IRMpMonitorAlarmCountMService rMpMonitorAlarmCountMService;
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
|
||||||
@PostMapping("/alarmDay")
|
|
||||||
@ApiOperation("监测点指标告警日统计(新)")
|
|
||||||
@ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
|
|
||||||
public HttpResult<Boolean> alarmDay(@RequestBody @Validated LineParam lineParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("alarmDay");
|
|
||||||
rMpTargetWarnDService.alarmDay(lineParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
|
||||||
@PostMapping("/alarmMonth")
|
|
||||||
@ApiOperation("监测点指标告警月统计(新)")
|
|
||||||
@ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
|
|
||||||
public HttpResult<Boolean> alarmMonth(@RequestBody @Validated LineParam lineParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("alarmMonth");
|
|
||||||
rMpMonitorAlarmCountMService.alarmMonth(lineParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -20,6 +20,6 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface RMpTargetWarnDMapper extends MppBaseMapper<RMpTargetWarnDPO> {
|
public interface RMpTargetWarnDMapper extends MppBaseMapper<RMpTargetWarnDPO> {
|
||||||
|
|
||||||
List<RMpMonitorAlarmCountMDTO> getDate(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
List<RMpMonitorAlarmCountMDTO> getDate(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("list") List<String> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,14 @@
|
|||||||
r_mp_target_warn_d
|
r_mp_target_warn_d
|
||||||
where
|
where
|
||||||
data_date between #{startTime} and #{endTime}
|
data_date between #{startTime} and #{endTime}
|
||||||
|
<where>
|
||||||
|
<if test="list != null and list.size() > 0">
|
||||||
|
and measurement_point_id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
group by measurement_point_id
|
group by measurement_point_id
|
||||||
order by harmonicTypeGradeTotal desc,eventTypeGradeTotal desc
|
order by harmonicTypeGradeTotal desc,eventTypeGradeTotal desc
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ public interface RStatDataVDMapper extends MppBaseMapper<RStatDataVDPO> {
|
|||||||
* @param time 时间
|
* @param time 时间
|
||||||
* @return 集合
|
* @return 集合
|
||||||
*/
|
*/
|
||||||
List<RMpTargetDiffDPO> getDayData(@Param("time") String time);
|
List<RMpTargetDiffDPO> getDayData(@Param("time") String time, @Param("list") List<String> list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取本年的所有(监测点日报表)稳态指标最大值(有的取最大值,有的取95概率大值)求一个平均值
|
* 获取本年的所有(监测点日报表)稳态指标最大值(有的取最大值,有的取95概率大值)求一个平均值
|
||||||
*/
|
*/
|
||||||
List<AlarmDetailDayDTO> getAvgDayData(@Param("startTime") String time, @Param("endTime") String endTime);
|
List<AlarmDetailDayDTO> getAvgDayData(@Param("startTime") String time, @Param("endTime") String endTime, @Param("list") List<String> list);
|
||||||
|
|
||||||
List<RMpTargetWarnDDTO> getTargetWarnD(@Param("time") String time);
|
List<RMpTargetWarnDDTO> getTargetWarnD(@Param("time") String time, @Param("list") List<String> list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,14 @@
|
|||||||
data_date = #{time}
|
data_date = #{time}
|
||||||
) D
|
) D
|
||||||
on A.lineId = D.lineId
|
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>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getAvgDayData" resultType="com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO">
|
<select id="getAvgDayData" resultType="com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO">
|
||||||
@@ -152,6 +160,14 @@
|
|||||||
data_date between #{startTime} and #{endTime}
|
data_date between #{startTime} and #{endTime}
|
||||||
) D
|
) D
|
||||||
on A.lineId = D.lineId
|
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
|
) Y
|
||||||
group by Y.lineId
|
group by Y.lineId
|
||||||
</select>
|
</select>
|
||||||
@@ -269,6 +285,14 @@
|
|||||||
data_date = #{time}
|
data_date = #{time}
|
||||||
) G
|
) G
|
||||||
on A.lineId = G.lineId
|
on A.lineId = G.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>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -13,6 +13,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface AlarmMapper extends MppBaseMapper<RMpTargetDiffDPO> {
|
public interface AlarmMapper extends MppBaseMapper<RMpTargetDiffDPO> {
|
||||||
|
|
||||||
List<AlarmDetailDayDTO> getAvgDiffData(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
List<AlarmDetailDayDTO> getAvgDiffData(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("list") List<String> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,12 @@
|
|||||||
from
|
from
|
||||||
r_mp_target_diff_d
|
r_mp_target_diff_d
|
||||||
where `time` between #{startTime} and #{endTime}
|
where `time` between #{startTime} and #{endTime}
|
||||||
|
<if test="list != null and list.size() > 0">
|
||||||
|
and line_id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
group by line_id
|
group by line_id
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class RMpTargetWarnDServiceImpl extends MppServiceImpl<RMpTargetWarnDMapp
|
|||||||
List<String> dayList = PublicUtil.getDayByMonth(year,month);
|
List<String> dayList = PublicUtil.getDayByMonth(year,month);
|
||||||
for (String item : dayList) {
|
for (String item : dayList) {
|
||||||
log.info(item+"-->开始执行");
|
log.info(item+"-->开始执行");
|
||||||
List<RMpTargetWarnDPO> day = getData(item);
|
List<RMpTargetWarnDPO> day = getData(item,lineParam.getLineIds());
|
||||||
if (!CollectionUtils.isEmpty(day)){
|
if (!CollectionUtils.isEmpty(day)){
|
||||||
list.addAll(day);
|
list.addAll(day);
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public class RMpTargetWarnDServiceImpl extends MppServiceImpl<RMpTargetWarnDMapp
|
|||||||
}
|
}
|
||||||
//日处理
|
//日处理
|
||||||
else {
|
else {
|
||||||
list = getData(lineParam.getDataDate());
|
list = getData(lineParam.getDataDate(),lineParam.getLineIds());
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(list)){
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
this.saveOrUpdateBatchByMultiId(list,50);
|
this.saveOrUpdateBatchByMultiId(list,50);
|
||||||
@@ -103,24 +103,24 @@ public class RMpTargetWarnDServiceImpl extends MppServiceImpl<RMpTargetWarnDMapp
|
|||||||
int month = Integer.parseInt(lineParam.getDataDate().split("-")[1]);
|
int month = Integer.parseInt(lineParam.getDataDate().split("-")[1]);
|
||||||
String startTime = PublicUtil.getFisrtDayOfMonth(year,month);
|
String startTime = PublicUtil.getFisrtDayOfMonth(year,month);
|
||||||
String endTime = PublicUtil.getLastDayOfMonth(year,month);
|
String endTime = PublicUtil.getLastDayOfMonth(year,month);
|
||||||
return this.baseMapper.getDate(startTime,endTime);
|
return this.baseMapper.getDate(startTime,endTime,lineParam.getLineIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RMpTargetWarnDPO> getData(String time){
|
public List<RMpTargetWarnDPO> getData(String time, List<String> list){
|
||||||
List<RMpTargetWarnDPO> result = new ArrayList<>();
|
List<RMpTargetWarnDPO> result = new ArrayList<>();
|
||||||
List<AlarmDetailDayDTO> rlList = new ArrayList<>(),uclList = new ArrayList<>();
|
List<AlarmDetailDayDTO> rlList = new ArrayList<>(),uclList = new ArrayList<>();
|
||||||
//基础数据
|
//基础数据
|
||||||
String yesterday = PublicUtil.getYesterday(time);
|
String yesterday = PublicUtil.getYesterday(time);
|
||||||
List<RMpTargetWarnDDTO> todayList = rStatDataVDMapper.getTargetWarnD(time + " 00:00:00");
|
List<RMpTargetWarnDDTO> todayList = rStatDataVDMapper.getTargetWarnD(time + " 00:00:00",list);
|
||||||
List<RMpTargetWarnDDTO> yesterdayList = rStatDataVDMapper.getTargetWarnD(yesterday + " 00:00:00");
|
List<RMpTargetWarnDDTO> yesterdayList = rStatDataVDMapper.getTargetWarnD(yesterday + " 00:00:00",list);
|
||||||
List<RMpTargetWarnDDTO> theDayBeforeYesterday = rStatDataVDMapper.getTargetWarnD(PublicUtil.getYesterday(yesterday) + " 00:00:00");
|
List<RMpTargetWarnDDTO> theDayBeforeYesterday = rStatDataVDMapper.getTargetWarnD(PublicUtil.getYesterday(yesterday) + " 00:00:00",list);
|
||||||
List<RMpTargetWarnDDTO> threeDaysAgo = rStatDataVDMapper.getTargetWarnD(PublicUtil.getYesterday(PublicUtil.getYesterday(yesterday)) + " 00:00:00");
|
List<RMpTargetWarnDDTO> threeDaysAgo = rStatDataVDMapper.getTargetWarnD(PublicUtil.getYesterday(PublicUtil.getYesterday(yesterday)) + " 00:00:00",list);
|
||||||
if (!CollectionUtils.isEmpty(todayList)){
|
if (!CollectionUtils.isEmpty(todayList)){
|
||||||
Map<String,List<RMpTargetWarnDDTO>> map2 = new HashMap<>(),map3 = new HashMap<>(),map4 = new HashMap<>();
|
Map<String,List<RMpTargetWarnDDTO>> map2 = new HashMap<>(),map3 = new HashMap<>(),map4 = new HashMap<>();
|
||||||
//本年的rm值
|
//本年的rm值
|
||||||
List<AlarmDetailDayDTO> rmList = alarmDetailService.getAvgDiffData(time);
|
List<AlarmDetailDayDTO> rmList = alarmDetailService.getAvgDiffData(time,list);
|
||||||
//本年的CL值
|
//本年的CL值
|
||||||
List<AlarmDetailDayDTO> clList = rStatDataVDMapper.getAvgDayData(PublicUtil.getLastYearDay(time),time);
|
List<AlarmDetailDayDTO> clList = rStatDataVDMapper.getAvgDayData(PublicUtil.getLastYearDay(time),time,list);
|
||||||
//本年的RL值
|
//本年的RL值
|
||||||
if (!CollectionUtils.isEmpty(rmList)){
|
if (!CollectionUtils.isEmpty(rmList)){
|
||||||
rlList = rmList.stream().map(item->{
|
rlList = rmList.stream().map(item->{
|
||||||
|
|||||||
@@ -128,30 +128,30 @@ public class AlarmDetailServiceImpl extends MppServiceImpl<AlarmMapper, RMpTarge
|
|||||||
log.info(item+"-->开始执行");
|
log.info(item+"-->开始执行");
|
||||||
startTime = item + " 00:00:00";
|
startTime = item + " 00:00:00";
|
||||||
endTime = PublicUtil.getYesterday(item) + " 00:00:00";
|
endTime = PublicUtil.getYesterday(item) + " 00:00:00";
|
||||||
diffData(startTime,endTime);
|
diffData(startTime,endTime,lineParam.getLineIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//日处理
|
//日处理
|
||||||
else {
|
else {
|
||||||
startTime = lineParam.getDataDate() + " 00:00:00";
|
startTime = lineParam.getDataDate() + " 00:00:00";
|
||||||
endTime = PublicUtil.getYesterday(lineParam.getDataDate()) + " 00:00:00";
|
endTime = PublicUtil.getYesterday(lineParam.getDataDate()) + " 00:00:00";
|
||||||
diffData(startTime,endTime);
|
diffData(startTime,endTime,lineParam.getLineIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AlarmDetailDayDTO> getAvgDiffData(String time) {
|
public List<AlarmDetailDayDTO> getAvgDiffData(String time,List<String> list) {
|
||||||
String endTime = PublicUtil.getLastYearDay(time);
|
String endTime = PublicUtil.getLastYearDay(time);
|
||||||
//计算本年的rm值
|
//计算本年的rm值
|
||||||
return this.baseMapper.getAvgDiffData(endTime,time);
|
return this.baseMapper.getAvgDiffData(endTime,time,list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成指标差值日统计
|
* 生成指标差值日统计
|
||||||
*/
|
*/
|
||||||
public void diffData(String startTime, String endTime) {
|
public void diffData(String startTime, String endTime, List<String> list) {
|
||||||
List<RMpTargetDiffDPO> localData = rStatDataVDMapper.getDayData(startTime);
|
List<RMpTargetDiffDPO> localData = rStatDataVDMapper.getDayData(startTime,list);
|
||||||
List<RMpTargetDiffDPO> yesterdayData = rStatDataVDMapper.getDayData(endTime);
|
List<RMpTargetDiffDPO> yesterdayData = rStatDataVDMapper.getDayData(endTime,list);
|
||||||
if (!CollectionUtils.isEmpty(localData) && !CollectionUtils.isEmpty(yesterdayData)){
|
if (!CollectionUtils.isEmpty(localData) && !CollectionUtils.isEmpty(yesterdayData)){
|
||||||
//取两个集合的交集,做算法处理取绝对值
|
//取两个集合的交集,做算法处理取绝对值
|
||||||
List<RMpTargetDiffDPO> intersectionList = localData.stream().map(map->yesterdayData.stream().filter(m->Objects.equals(m.getLineId(),map.getLineId())).findFirst().map(m->{
|
List<RMpTargetDiffDPO> intersectionList = localData.stream().map(map->yesterdayData.stream().filter(m->Objects.equals(m.getLineId(),map.getLineId())).findFirst().map(m->{
|
||||||
|
|||||||
@@ -24,5 +24,5 @@ public interface AlarmDetailService {
|
|||||||
|
|
||||||
void targetDiff(LineParam lineParam);
|
void targetDiff(LineParam lineParam);
|
||||||
|
|
||||||
List<AlarmDetailDayDTO> getAvgDiffData(String time);
|
List<AlarmDetailDayDTO> getAvgDiffData(String time,List<String> list);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user