zbj//1.计算pt值和ct值

This commit is contained in:
zhangbaojian
2023-07-04 11:24:51 +08:00
parent 90b3570f49
commit 709109ca23
4 changed files with 120 additions and 1 deletions

View File

@@ -0,0 +1,58 @@
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.RStatEventFeignClient;
import com.njcn.prepare.harmonic.api.line.RStatSubstationFeignClient;
import com.njcn.prepare.harmonic.pojo.param.OrgParam;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* pqs
* 变电站指标统计
* @author zbj
* @date 2023/07/04
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class RStatSubstationJob {
private final RStatSubstationFeignClient rStatSubstationFeignClient;
@XxlJob("rStartSubstationDHandler")
public void rStartSubstationDHandler(){
OrgParam orgParam = new OrgParam();
orgParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
orgParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
rStatSubstationFeignClient.rStartSubstationHandler(orgParam);
}
@XxlJob("rStartSubstationMHandler")
public void rStartSubstationMHandler(){
OrgParam orgParam = new OrgParam();
orgParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
orgParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
rStatSubstationFeignClient.rStartSubstationHandler(orgParam);
}
@XxlJob("rStartSubstationQHandler")
public void rStartSubstationQHandler(){
OrgParam orgParam = new OrgParam();
orgParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_QUARTER));
orgParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_QUARTER));
rStatSubstationFeignClient.rStartSubstationHandler(orgParam);
}
@XxlJob("rStartSubstationYHandler")
public void rStartSubstationYHandler(){
OrgParam orgParam = new OrgParam();
orgParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_YEAR));
orgParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_YEAR));
rStatSubstationFeignClient.rStartSubstationHandler(orgParam);
}
}

View File

@@ -0,0 +1,21 @@
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.RStatEventFeignClientFallbackFactory;
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 = "/rStartSubstation",//对应controller请求类
fallbackFactory = RStatEventFeignClientFallbackFactory.class//服务降级处理类
)
public interface RStatSubstationFeignClient {
@PostMapping("/rStartSubstationHandler")
HttpResult<Boolean> rStartSubstationHandler(@RequestBody OrgParam orgParam);
}

View File

@@ -31,7 +31,7 @@ public class RStatEventOrgFeignClientFallbackFactory implements FallbackFactory<
@Override
public HttpResult<Boolean> rStartEventOrgHandler(OrgParam orgParam) {
log.error("{}异常,降级处理,异常为:{}", "暂态指标统计: ", throwable.toString());
log.error("{}异常,降级处理,异常为:{}", "单位暂态指标统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -0,0 +1,40 @@
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.RStatEventFeignClient;
import com.njcn.prepare.harmonic.api.line.RStatSubstationFeignClient;
import com.njcn.prepare.harmonic.pojo.param.OrgParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author zbj
*/
@Slf4j
@Component
public class RStatSubstationFeignClientFallbackFactory implements FallbackFactory<RStatSubstationFeignClient> {
@Override
public RStatSubstationFeignClient 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 RStatSubstationFeignClient() {
@Override
public HttpResult<Boolean> rStartSubstationHandler(OrgParam orgParam) {
log.error("{}异常,降级处理,异常为:{}", "变电站指标统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}