兼容主干代码

This commit is contained in:
xy
2025-08-22 11:19:24 +08:00
parent e2f3ea7764
commit c7b84e0481
7 changed files with 404 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
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

@@ -0,0 +1,34 @@
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

@@ -0,0 +1,48 @@
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

@@ -0,0 +1,53 @@
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

@@ -0,0 +1,27 @@
package com.njcn.prepare.harmonic.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author guofeihu
* @since 2024-08-14
*/
@Data
public class SpThroughParam {
@ApiModelProperty(name = "eventIds",value = "事件ID集合")
private List<String> eventIds;
@ApiModelProperty(name = "lineType",value = "监测点类别(1:风电场、2:光伏电站)")
private String stationType;
public SpThroughParam(List<String> eventIds, String stationType) {
this.eventIds = eventIds;
this.stationType = stationType;
}
public SpThroughParam() {
}
}

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;
/**
* 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

@@ -0,0 +1,19 @@
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;
}