mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
完善
This commit is contained in:
@@ -4,6 +4,8 @@ import feign.Headers;
|
||||
import feign.Param;
|
||||
import feign.RequestLine;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface DustApi {
|
||||
@@ -63,7 +65,26 @@ public interface DustApi {
|
||||
String strtime
|
||||
|
||||
|
||||
) {}
|
||||
) {
|
||||
public boolean notEmpty() {
|
||||
return !ObjectUtils.allNull(pm25
|
||||
,pm10
|
||||
,noise
|
||||
,tem
|
||||
,hum
|
||||
,wp
|
||||
,ws
|
||||
,wd8
|
||||
,wd360
|
||||
,tsp
|
||||
,atm
|
||||
,lux
|
||||
,co
|
||||
,so2
|
||||
,no2
|
||||
,o3);
|
||||
}
|
||||
}
|
||||
|
||||
record GetTokenResponse(String code, String message, GetTokenData data) {}
|
||||
|
||||
|
||||
@@ -327,6 +327,13 @@ public class EmDeviceService extends BaseService<EmDeviceEntity, EmDeviceReposit
|
||||
|
||||
List<EmDeviceDataEntity> collect =
|
||||
data.stream()
|
||||
.peek(x -> {
|
||||
if (!x.notEmpty()){
|
||||
log.error("data is empty {}", x);
|
||||
}
|
||||
|
||||
})
|
||||
.filter(DustApi.DeviceData::notEmpty)
|
||||
.map(
|
||||
x -> {
|
||||
EmDeviceDataEntity emDeviceData =
|
||||
|
||||
@@ -9,6 +9,7 @@ import jakarta.validation.ConstraintViolation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@@ -16,6 +17,8 @@ import org.springframework.web.method.HandlerMethod;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestControllerAdvice
|
||||
@@ -24,6 +27,22 @@ import java.util.stream.Collectors;
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
|
||||
@ExceptionHandler(InvalidDataAccessApiUsageException.class)
|
||||
public R handleException(
|
||||
InvalidDataAccessApiUsageException ex, HttpServletRequest request, HandlerMethod handlerMethod) {
|
||||
logEx(ex, request, handlerMethod);
|
||||
|
||||
Pattern pattern = Pattern.compile("\\[(.+?)\\]");
|
||||
|
||||
Matcher matcher = pattern.matcher(ex.getMessage());
|
||||
|
||||
if (matcher.find()) {
|
||||
return R.fail("fieldNotExist", "字段不存在: " + matcher.group(1));
|
||||
}
|
||||
|
||||
|
||||
return R.fail("sysError", "系统异常: " + ex.getMessage());
|
||||
}
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public R handleException(
|
||||
MethodArgumentNotValidException ex, HttpServletRequest request, HandlerMethod handlerMethod) {
|
||||
|
||||
Reference in New Issue
Block a user