Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangbaojian
2023-06-08 10:11:47 +08:00
26 changed files with 802 additions and 120 deletions

View File

@@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
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;
@@ -113,4 +114,12 @@ public interface GeneralDeviceInfoClient {
*/
@PostMapping("/getOnlineRateByDevIds")
HttpResult<List<RStatOnlinerateVO>> getOnlineRateByDevIds(@RequestBody OnlineRateParam param);
/**
*
* @author cdf
* @date 2023/6/7
*/
@PostMapping("/deptGetRunLine")
HttpResult<List<String>> deptGetRunLine(@RequestParam("deptId")String deptId);
}

View File

@@ -0,0 +1,34 @@
package com.njcn.device.pq.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.fallback.DeviceTreeClientFallbackFactory;
import com.njcn.device.pq.api.fallback.LineIntegrityClientFallbackFactory;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import com.njcn.device.pq.pojo.vo.AlarmStrategyVO;
import org.springframework.cloud.openfeign.FeignClient;
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;
/**
* 监测点数据完整性
* @author cdf
* @date 2023/6/7
*/
@FeignClient(value = ServerInfo.DEVICE,
path = "/LineIntegrityData",
fallbackFactory = LineIntegrityClientFallbackFactory.class,
contextId = "LineIntegrityData")
public interface LineIntegrityClient {
/**
*
* @author cdf
* @date 2023/6/7
*/
@PostMapping("/getIntegrityByLineIds")
HttpResult<List<RStatIntegrityD>> getIntegrityByLineIds(@RequestBody List<String> lineIds, @RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime);
}

View File

@@ -0,0 +1,32 @@
package com.njcn.device.pq.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.pq.api.fallback.LineIntegrityClientFallbackFactory;
import com.njcn.device.pq.api.fallback.OverLimitFallbackFactory;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* 监测点数据完整性
* @author cdf
* @date 2023/6/7
*/
@FeignClient(value = ServerInfo.DEVICE,
path = "/overLimit",
fallbackFactory = OverLimitFallbackFactory.class,contextId = "overLimit")
public interface OverLimitClient {
/**
*
* @author cdf
* @date 2023/6/7
*/
@PostMapping("/getOverLimitByLineIds")
HttpResult<List<Overlimit>> getOverLimitByLineIds(@RequestBody List<String> lineIds);
}

View File

@@ -86,6 +86,12 @@ public class GeneralDeviceInfoClientFallbackFactory implements FallbackFactory<G
log.error("{}异常,降级处理,异常为:{}", "获取终端在线率(谐波专用)", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> deptGetRunLine(String deptId) {
log.error("{}异常,降级处理,异常为:{}", "获取单位投运监测点", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};

View File

@@ -0,0 +1,45 @@
package com.njcn.device.pq.api.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.device.pq.api.AlarmClient;
import com.njcn.device.pq.api.LineIntegrityClient;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import com.njcn.device.pq.pojo.vo.AlarmStrategyVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 告警管理熔断降级
* @author yzh
* @date 2022/9/19
*/
@Slf4j
@Component
public class LineIntegrityClientFallbackFactory implements FallbackFactory<LineIntegrityClient> {
@Override
public LineIntegrityClient 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 LineIntegrityClient() {
@Override
public HttpResult<List<RStatIntegrityD>> getIntegrityByLineIds(List<String> lineIds,String startTime,String endTime) {
log.error("{}异常,降级处理,异常为:{}", "获取监测点数据完整性", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,44 @@
package com.njcn.device.pq.api.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.pojo.po.Overlimit;
import com.njcn.device.biz.utils.DeviceEnumUtil;
import com.njcn.device.pq.api.LineIntegrityClient;
import com.njcn.device.pq.api.OverLimitClient;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 告警管理熔断降级
* @author yzh
* @date 2022/9/19
*/
@Slf4j
@Component
public class OverLimitFallbackFactory implements FallbackFactory<OverLimitClient> {
@Override
public OverLimitClient 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 OverLimitClient() {
@Override
public HttpResult<List<Overlimit>> getOverLimitByLineIds(List<String> lineIds) {
log.error("{}异常,降级处理,异常为:{}", "监测点限值", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -9,6 +9,7 @@ import java.time.LocalDateTime;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Transient;
/**
* <p>
@@ -34,5 +35,8 @@ public class RStatIntegrityD {
private Integer realTime;
@Transient
private Float integrityData;
}