代码合并
This commit is contained in:
@@ -1,34 +1,34 @@
|
|||||||
package com.njcn.prepare.harmonic.api.event;
|
//package com.njcn.prepare.harmonic.api.event;
|
||||||
|
//
|
||||||
import com.njcn.common.pojo.constant.ServerInfo;
|
//import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
//import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.prepare.harmonic.api.event.fallback.SpThroughFeignClientFallbackFactory;
|
//import com.njcn.prepare.harmonic.api.event.fallback.SpThroughFeignClientFallbackFactory;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
//import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
|
//import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
//import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.validation.annotation.Validated;
|
//import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
//import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
//import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 高低电压穿越Feign客户端
|
// * 高低电压穿越Feign客户端
|
||||||
* @author guofeihu
|
// * @author guofeihu
|
||||||
* @date 2024-08-22
|
// * @date 2024-08-22
|
||||||
*/
|
// */
|
||||||
@FeignClient(
|
//@FeignClient(
|
||||||
value = ServerInfo.PREPARE_BOOT,//对应模块名
|
// value = ServerInfo.PREPARE_BOOT,//对应模块名
|
||||||
path = "/spThrough",//对应controller请求类
|
// path = "/spThrough",//对应controller请求类
|
||||||
fallbackFactory = SpThroughFeignClientFallbackFactory.class//服务降级处理类
|
// fallbackFactory = SpThroughFeignClientFallbackFactory.class//服务降级处理类
|
||||||
)
|
//)
|
||||||
public interface SpThroughFeignClient {
|
//public interface SpThroughFeignClient {
|
||||||
|
//
|
||||||
@PostMapping("/record")
|
// @PostMapping("/record")
|
||||||
HttpResult<Boolean> record();
|
// HttpResult<Boolean> record();
|
||||||
|
//
|
||||||
@PostMapping("/getDataByEventIds")
|
// @PostMapping("/getDataByEventIds")
|
||||||
HttpResult<SpThroughVO> getDataByEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
|
// HttpResult<SpThroughVO> getDataByEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
|
||||||
|
//
|
||||||
@PostMapping("/formatEventIds")
|
// @PostMapping("/formatEventIds")
|
||||||
HttpResult<List<String>> formatEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
|
// HttpResult<List<String>> formatEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,53 +1,53 @@
|
|||||||
package com.njcn.prepare.harmonic.api.event.fallback;
|
//package com.njcn.prepare.harmonic.api.event.fallback;
|
||||||
|
//
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
//import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
//import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
//import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.prepare.harmonic.api.event.SpThroughFeignClient;
|
//import com.njcn.prepare.harmonic.api.event.SpThroughFeignClient;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
//import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
|
//import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
|
||||||
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
|
//import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
|
||||||
import feign.hystrix.FallbackFactory;
|
//import feign.hystrix.FallbackFactory;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 高低电压穿越熔断降级
|
// * 高低电压穿越熔断降级
|
||||||
* @author guofeihu
|
// * @author guofeihu
|
||||||
* @date 2024-08-22
|
// * @date 2024-08-22
|
||||||
*/
|
// */
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Component
|
//@Component
|
||||||
public class SpThroughFeignClientFallbackFactory implements FallbackFactory<SpThroughFeignClient> {
|
//public class SpThroughFeignClientFallbackFactory implements FallbackFactory<SpThroughFeignClient> {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public SpThroughFeignClient create(Throwable throwable) {
|
// public SpThroughFeignClient create(Throwable throwable) {
|
||||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
// Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
if (throwable.getCause() instanceof BusinessException) {
|
// if (throwable.getCause() instanceof BusinessException) {
|
||||||
BusinessException businessException = (BusinessException)throwable.getCause();
|
// BusinessException businessException = (BusinessException)throwable.getCause();
|
||||||
exceptionEnum = PrepareEnumUtil.getExceptionEnum(businessException.getResult());
|
// exceptionEnum = PrepareEnumUtil.getExceptionEnum(businessException.getResult());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
// Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
return new SpThroughFeignClient() {
|
// return new SpThroughFeignClient() {
|
||||||
@Override
|
// @Override
|
||||||
public HttpResult<Boolean> record() {
|
// public HttpResult<Boolean> record() {
|
||||||
log.error("{}异常,降级处理,异常为:{}", "高低电压穿越记录:", throwable.toString());
|
// log.error("{}异常,降级处理,异常为:{}", "高低电压穿越记录:", throwable.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
// throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public HttpResult<SpThroughVO> getDataByEventIds(SpThroughParam spThroughParam) {
|
// public HttpResult<SpThroughVO> getDataByEventIds(SpThroughParam spThroughParam) {
|
||||||
log.error("{}异常,降级处理,异常为:{}", "根据事件ID集合及能源站类型获取高低电压穿越次数:", throwable.toString());
|
// log.error("{}异常,降级处理,异常为:{}", "根据事件ID集合及能源站类型获取高低电压穿越次数:", throwable.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
// throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public HttpResult<List<String>> formatEventIds(SpThroughParam spThroughParam) {
|
// public HttpResult<List<String>> formatEventIds(SpThroughParam spThroughParam) {
|
||||||
log.error("{}异常,降级处理,异常为:{}", "根据原有的事件集合进行过滤:", throwable.toString());
|
// log.error("{}异常,降级处理,异常为:{}", "根据原有的事件集合进行过滤:", throwable.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
// throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.annotation.OperateInfo;
|
|||||||
import com.njcn.common.pojo.constant.OperateType;
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
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.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
@@ -192,8 +193,11 @@ public class DictTreeController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true),
|
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true),
|
||||||
@ApiImplicitParam(name = "conType", value = "接线方式", required = true)
|
@ApiImplicitParam(name = "conType", value = "接线方式", required = true)
|
||||||
})
|
})
|
||||||
public HttpResult<List<SysDicTreePO>> queryDictType(@RequestParam @Validated String lineId, @RequestParam @Validated Integer conType) {
|
public HttpResult<List<SysDicTreePO>> queryDictType(@RequestParam @Validated String lineId, @RequestParam(required = false) @Validated Integer conType) {
|
||||||
String methodDescribe = getMethodDescribe("queryDictType");
|
String methodDescribe = getMethodDescribe("queryDictType");
|
||||||
|
if (conType == null) {
|
||||||
|
throw new BusinessException("监测点缺失接线方式");
|
||||||
|
}
|
||||||
List<SysDicTreePO> result = sysDicTreePOService.queryDictType(lineId,conType);
|
List<SysDicTreePO> result = sysDicTreePOService.queryDictType(lineId,conType);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.njcn.system.timer.tasks;
|
||||||
|
|
||||||
|
import com.njcn.system.timer.TimerTaskRunner;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高低电压穿越算法执行定时任务
|
||||||
|
* @author guofeihu
|
||||||
|
* @date 2024/8/21
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SpThroughTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
|
// private final SpThroughFeignClient spThroughFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(String date) {
|
||||||
|
// spThroughFeignClient.record();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user