1.新能源专项分析代码优化

2.迁移相关代码算法
This commit is contained in:
wr
2025-04-03 16:02:45 +08:00
parent 47a4f73518
commit 25ad24deb9
22 changed files with 248 additions and 1409 deletions

View File

@@ -1,34 +0,0 @@
package com.njcn.prepare.harmonic.api.event;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
import com.njcn.prepare.harmonic.api.event.fallback.RActivePowerRangeFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.pojo.param.RActivePowerRangeParam;
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 有功功率趋势Feign客户端
* @author guofeihu
* @date 2024-08-22
*/
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/rActivePowerRange",//对应controller请求类
fallbackFactory = RActivePowerRangeFeignClientFallbackFactory.class//服务降级处理类
)
public interface RActivePowerRangeFeignClient {
@PostMapping("/record")
HttpResult<List<PowerStatisticsTargetVO>> record(@RequestBody(required = false) RActivePowerRangeParam rActivePowerRangeParam);
@GetMapping("/getDataByLineId")
HttpResult<RActivePowerRangePO> getDataByLineId(@RequestParam("lineId") String lineId,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime);
}

View File

@@ -1,34 +0,0 @@
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 com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
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;
import java.util.List;
/**
* 高低电压穿越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();
@PostMapping("/getDataByEventIds")
HttpResult<SpThroughVO> getDataByEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
@PostMapping("/formatEventIds")
HttpResult<List<String>> formatEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
}

View File

@@ -1,48 +0,0 @@
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.harmonic.pojo.vo.PowerStatisticsTargetVO;
import com.njcn.prepare.harmonic.api.event.RActivePowerRangeFeignClient;
import com.njcn.prepare.harmonic.pojo.param.RActivePowerRangeParam;
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 有功功率趋势熔断降级
* @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<List<PowerStatisticsTargetVO>> record(RActivePowerRangeParam rActivePowerRangeParam) {
log.error("{}异常,降级处理,异常为:{}", "有功功率趋势记录:", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<RActivePowerRangePO> getDataByLineId(String lineId,String startTime,String endTime) {
log.error("{}异常,降级处理,异常为:{}", "根据监测点ID获取有功功率趋势信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,53 +0,0 @@
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.pojo.param.SpThroughParam;
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 高低电压穿越熔断降级
* @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);
}
@Override
public HttpResult<SpThroughVO> getDataByEventIds(SpThroughParam spThroughParam) {
log.error("{}异常,降级处理,异常为:{}", "根据事件ID集合及能源站类型获取高低电压穿越次数:", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> formatEventIds(SpThroughParam spThroughParam) {
log.error("{}异常,降级处理,异常为:{}", "根据原有的事件集合进行过滤:", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,189 +0,0 @@
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;
/**
* 0%~10%区间是否越限
*/
private Integer isOrNot0 = 0;
/**
* 10%~20%区间时间Json
*/
private String minsTime1;
/**
* 10%~20%区间个数
*/
private Integer minsNum1 = 0;;
/**
* 10%~20%区间是否越限
*/
private Integer isOrNot1 = 0;
/**
* 20%~30%区间时间Json
*/
private String minsTime2;
/**
* 20%~30%区间个数
*/
private Integer minsNum2 = 0;;
/**
* 20%~30%区间是否越限
*/
private Integer isOrNot2 = 0;
/**
* 30%~40%区间时间Json
*/
private String minsTime3;
/**
* 30%~40%区间个数
*/
private Integer minsNum3 = 0;;
/**
* 30%~40%区间是否越限
*/
private Integer isOrNot3 = 0;
/**
* 40%~50%区间时间Json
*/
private String minsTime4;
/**
* 40%~50%区间个数
*/
private Integer minsNum4 = 0;;
/**
* 40%~50%区间是否越限
*/
private Integer isOrNot4 = 0;
/**
* 50%~60%区间时间Json
*/
private String minsTime5;
/**
* 50%~60%区间个数
*/
private Integer minsNum5 = 0;;
/**
* 50%~60%区间是否越限
*/
private Integer isOrNot5 = 0;
/**
* 60%~70%区间时间Json
*/
private String minsTime6;
/**
* 60%~70%区间个数
*/
private Integer minsNum6 = 0;;
/**
* 60%~70%区间是否越限
*/
private Integer isOrNot6 = 0;
/**
* 70%~80%区间时间Json
*/
private String minsTime7;
/**
* 70%~80%区间个数
*/
private Integer minsNum7 = 0;;
/**
* 70%~80%区间是否越限
*/
private Integer isOrNot7 = 0;
/**
* 80%~90%区间时间Json
*/
private String minsTime8;
/**
* 80%~90%区间个数
*/
private Integer minsNum8 = 0;;
/**
* 80%~90%区间是否越限
*/
private Integer isOrNot8 = 0;
/**
* 90%~100%区间时间Json
*/
private String minsTime9;
/**
* 90%~100%区间个数
*/
private Integer minsNum9 = 0;;
/**
* 90%~100%区间是否越限
*/
private Integer isOrNot9 = 0;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -1,54 +0,0 @@
package com.njcn.prepare.harmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 高低电压穿越 实体类
* @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;
/**
* 创建时间(自定义)
*/
private LocalDateTime createTime;
}

View File

@@ -1,19 +0,0 @@
package com.njcn.prepare.harmonic.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author guofeihu
* @since 2024-08-14
*/
@Data
public class SpThroughVO {
@ApiModelProperty("低压次数")
private String lowPressure;
@ApiModelProperty("高压次数")
private String highPressure;
}