Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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.PqsTerminalLogsClientFallbackFactory;
|
||||
import com.njcn.device.pq.pojo.po.Node;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2024/8/13 10:14
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE, path = "/node", fallbackFactory = PqsTerminalLogsClientFallbackFactory.class, contextId = "node")
|
||||
public interface NodeClient {
|
||||
|
||||
|
||||
@ApiOperation("获取全部前置机")
|
||||
@GetMapping("/nodeAllList")
|
||||
HttpResult<List<Node>> nodeAllList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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.NodeClient;
|
||||
import com.njcn.device.pq.api.PqsTerminalLogsClient;
|
||||
import com.njcn.device.pq.pojo.po.Node;
|
||||
import com.njcn.device.pq.pojo.po.PqsTerminalLogs;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zbj
|
||||
* @version 1.0.0
|
||||
* @date 2023年04月13日 13:34
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NodeClientFallbackFactory implements FallbackFactory<NodeClient> {
|
||||
@Override
|
||||
public NodeClient 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 NodeClient()
|
||||
{
|
||||
|
||||
@Override
|
||||
public HttpResult<List<Node>> nodeAllList() {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取全部前置机", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -515,7 +515,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
|
||||
//父级完整性匹配
|
||||
if (CollectionUtil.isNotEmpty(data)){
|
||||
BigDecimal reduce = data.stream().map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
double avg = reduce.divide(new BigDecimal(data.size())).doubleValue();
|
||||
double avg = reduce.divide(new BigDecimal(data.size()),6,RoundingMode.HALF_UP).doubleValue();
|
||||
lineAdministrationTree.setIntegrityData(DataStatisticsUtil.dataLimits(avg));
|
||||
} else {
|
||||
lineAdministrationTree.setIntegrityData(3.14159);
|
||||
|
||||
Reference in New Issue
Block a user