高低电压穿越及有功功率趋势算法

This commit is contained in:
guofeihu
2024-08-22 15:25:44 +08:00
parent f27a107bba
commit 957af09daa
18 changed files with 690 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package com.njcn.prepare.harmonic.api.event;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.event.fallback.RActivePowerRangeFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* 有功功率趋势Feign客户端
* @author guofeihu
* @date 2024-08-22
*/
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/rActivePowerRange",//对应controller请求类
fallbackFactory = RActivePowerRangeFeignClientFallbackFactory.class//服务降级处理类
)
public interface RActivePowerRangeFeignClient {
@PostMapping("/record")
HttpResult<Boolean> record();
}

View File

@@ -0,0 +1,23 @@
package com.njcn.prepare.harmonic.api.event;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.event.fallback.SpThroughFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* 高低电压穿越Feign客户端
* @author guofeihu
* @date 2024-08-22
*/
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/spThrough",//对应controller请求类
fallbackFactory = SpThroughFeignClientFallbackFactory.class//服务降级处理类
)
public interface SpThroughFeignClient {
@PostMapping("/record")
HttpResult<Boolean> record();
}

View File

@@ -0,0 +1,38 @@
package com.njcn.prepare.harmonic.api.event.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.prepare.harmonic.api.event.RActivePowerRangeFeignClient;
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 有功功率趋势熔断降级
* @author guofeihu
* @date 2024-08-22
*/
@Slf4j
@Component
public class RActivePowerRangeFeignClientFallbackFactory implements FallbackFactory<RActivePowerRangeFeignClient> {
@Override
public RActivePowerRangeFeignClient create(Throwable throwable) {
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException)throwable.getCause();
exceptionEnum = PrepareEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new RActivePowerRangeFeignClient() {
@Override
public HttpResult<Boolean> record() {
log.error("{}异常,降级处理,异常为:{}", "有功功率趋势记录: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,38 @@
package com.njcn.prepare.harmonic.api.event.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.prepare.harmonic.api.event.SpThroughFeignClient;
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 高低电压穿越熔断降级
* @author guofeihu
* @date 2024-08-22
*/
@Slf4j
@Component
public class SpThroughFeignClientFallbackFactory implements FallbackFactory<SpThroughFeignClient> {
@Override
public SpThroughFeignClient create(Throwable throwable) {
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException)throwable.getCause();
exceptionEnum = PrepareEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new SpThroughFeignClient() {
@Override
public HttpResult<Boolean> record() {
log.error("{}异常,降级处理,异常为:{}", "高低电压穿越记录: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,189 @@
package com.njcn.prepare.harmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import java.time.LocalDate;
import lombok.Data;
/**
* 有功功率趋势 实体类
* @author guofeihu
* @since 2024-08-20
*/
@Data
@TableName("r_active_power_range")
public class RActivePowerRangePO extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private String id;
/**
* 监测点ID
*/
private String lineId;
/**
* 日期(天)
*/
private LocalDate timeId;
/**
* 0%~10%区间时间Json
*/
private String minsTime0;
/**
* 0%~10%区间个数
*/
private Integer minsNum0;
/**
* 0%~10%区间是否越限
*/
private Integer isOrNot0;
/**
* 10%~20%区间时间Json
*/
private String minsTime1;
/**
* 10%~20%区间个数
*/
private Integer minsNum1;
/**
* 10%~20%区间是否越限
*/
private Integer isOrNot1;
/**
* 20%~30%区间时间Json
*/
private String minsTime2;
/**
* 20%~30%区间个数
*/
private Integer minsNum2;
/**
* 20%~30%区间是否越限
*/
private Integer isOrNot2;
/**
* 30%~40%区间时间Json
*/
private String minsTime3;
/**
* 30%~40%区间个数
*/
private Integer minsNum3;
/**
* 30%~40%区间是否越限
*/
private Integer isOrNot3;
/**
* 40%~50%区间时间Json
*/
private String minsTime4;
/**
* 40%~50%区间个数
*/
private Integer minsNum4;
/**
* 40%~50%区间是否越限
*/
private Integer isOrNot4;
/**
* 50%~60%区间时间Json
*/
private String minsTime5;
/**
* 50%~60%区间个数
*/
private Integer minsNum5;
/**
* 50%~60%区间是否越限
*/
private Integer isOrNot5;
/**
* 60%~70%区间时间Json
*/
private String minsTime6;
/**
* 60%~70%区间个数
*/
private Integer minsNum6;
/**
* 60%~70%区间是否越限
*/
private Integer isOrNot6;
/**
* 70%~80%区间时间Json
*/
private String minsTime7;
/**
* 70%~80%区间个数
*/
private Integer minsNum7;
/**
* 70%~80%区间是否越限
*/
private Integer isOrNot7;
/**
* 80%~90%区间时间Json
*/
private String minsTime8;
/**
* 80%~90%区间个数
*/
private Integer minsNum8;
/**
* 80%~90%区间是否越限
*/
private Integer isOrNot8;
/**
* 90%~100%区间时间Json
*/
private String minsTime9;
/**
* 90%~100%区间个数
*/
private Integer minsNum9;
/**
* 90%~100%区间是否越限
*/
private Integer isOrNot9;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -0,0 +1,48 @@
package com.njcn.prepare.harmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
/**
* 高低电压穿越 实体类
* @author guofeihu
* @since 2024-08-22
*/
@Data
@TableName("sp_through")
public class SpThroughPO extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private String id;
/**
* 暂降事件ID
*/
private String eventId;
/**
* 暂降类型(暂升、暂降)
*/
private String eventType;
/**
* 关联PQS_Dictionary表变电站类型风电场、光伏电站
*/
private String stationType;
/**
* 是否穿越
*/
private Integer isOrNot;
/**
* 状态0-删除 1-正常
*/
private Boolean state;
}