mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-11-02 19:21:51 +08:00
feat: 代码优化
This commit is contained in:
+2
-2
@@ -13,11 +13,11 @@
|
||||
|
||||
package com.dc3.center.data.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.center.data.service.DataCustomService;
|
||||
import com.dc3.center.data.service.elastic.PointValueRepository;
|
||||
import com.dc3.common.bean.point.PointValue;
|
||||
import com.dc3.common.bean.point.TsPointValue;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
@@ -111,7 +111,7 @@ public class DataCustomServiceImpl implements DataCustomService {
|
||||
* @param tsPointValues TsPointValue Array
|
||||
*/
|
||||
private void savePointValueToOpenTsdb(List<TsPointValue> tsPointValues) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), JSON.toJSONString(tsPointValues));
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), JsonUtil.toJsonString(tsPointValues));
|
||||
Request request = new Request.Builder()
|
||||
.url(details ? putUrl + "?details" : putUrl)
|
||||
.post(requestBody)
|
||||
|
||||
+2
-6
@@ -14,14 +14,13 @@
|
||||
package com.dc3.center.manager.api;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.api.center.manager.feign.BatchClient;
|
||||
import com.dc3.center.manager.service.BatchService;
|
||||
import com.dc3.common.bean.R;
|
||||
import com.dc3.common.bean.batch.BatchDriver;
|
||||
import com.dc3.common.constant.Common;
|
||||
import com.dc3.common.exception.ServiceException;
|
||||
import com.dc3.common.utils.Dc3Util;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -51,10 +50,7 @@ public class BatchApi implements BatchClient {
|
||||
throw new ServiceException("Import file is empty");
|
||||
}
|
||||
// Convert json file to BatchDriver Array
|
||||
List<BatchDriver> batchDrivers = JSON.parseArray(
|
||||
Dc3Util.inputStreamToString(multipartFile.getInputStream()),
|
||||
BatchDriver.class
|
||||
);
|
||||
List<BatchDriver> batchDrivers = JsonUtil.parseArray(multipartFile.getInputStream(), BatchDriver.class);
|
||||
if (null == batchDrivers) {
|
||||
throw new ServiceException("Import file is blank");
|
||||
}
|
||||
|
||||
@@ -28,14 +28,6 @@
|
||||
|
||||
<description>IOT DC3 平台 公共基础集合。</description>
|
||||
|
||||
<properties>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<jaxb.version>2.3.0</jaxb.version>
|
||||
<activation.version>1.1.1</activation.version>
|
||||
<hutool.version>5.7.20</hutool.version>
|
||||
<fastjson.version>1.2.79</fastjson.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Web -->
|
||||
<dependency>
|
||||
@@ -75,29 +67,24 @@
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jaxb Api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>${jaxb.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>${jaxb.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>${activation.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Slf4j -->
|
||||
@@ -118,18 +105,16 @@
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- FastJson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@
|
||||
|
||||
package com.dc3.common.exception;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.bean.R;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
@@ -80,7 +80,7 @@ public class GlobalExceptionAdvice {
|
||||
log.warn("Method Argument Not Valid Exception Handler: {}({})", error.getField(), error.getDefaultMessage());
|
||||
map.put(error.getField(), error.getDefaultMessage());
|
||||
});
|
||||
return R.fail(JSON.toJSONString(map));
|
||||
return R.fail(JsonUtil.toJsonString(map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
package com.dc3.common.utils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Json 工具类
|
||||
* 基于 Jackson 实现
|
||||
*
|
||||
* @author pnoker
|
||||
*/
|
||||
public final class JsonUtil {
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE)
|
||||
.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, Boolean.FALSE)
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL).build();
|
||||
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象
|
||||
*
|
||||
* @param text Json String
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(String text, Class<T> valueType) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(text, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象
|
||||
*
|
||||
* @param bytes Json Byte Array
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(byte[] bytes, Class<T> valueType) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(bytes, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象
|
||||
*
|
||||
* @param jsonParser Json Parser
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(JsonParser jsonParser, Class<T> valueType) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(jsonParser, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象
|
||||
*
|
||||
* @param dataInput Json DataInput
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(DataInput dataInput, Class<T> valueType) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(dataInput, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象
|
||||
*
|
||||
* @param inputStream Json InputStream
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(InputStream inputStream, Class<T> valueType) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(inputStream, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象
|
||||
*
|
||||
* @param reader Json Reader
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(Reader reader, Class<T> valueType) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(reader, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象
|
||||
*
|
||||
* @param file Json File
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(File file, Class<T> valueType) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(file, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将Json 字符串转化为指定对象,并将指定对象中的泛型转为指定的T类型
|
||||
*
|
||||
* @param text Json String
|
||||
* @param typeReference TypeReference,T 为指定要转化为的数据类型
|
||||
* @return Java 对象
|
||||
*/
|
||||
public static <T> T parseObject(String text, TypeReference<T> typeReference) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(text, typeReference);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象集合
|
||||
*
|
||||
* @param text Json String
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象集合
|
||||
*/
|
||||
public static <T> List<T> parseArray(String text, Class<T> valueType) {
|
||||
try {
|
||||
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, valueType);
|
||||
return OBJECT_MAPPER.readValue(text, javaType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象集合
|
||||
*
|
||||
* @param bytes Json Byte Array
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象集合
|
||||
*/
|
||||
public static <T> List<T> parseArray(byte[] bytes, Class<T> valueType) {
|
||||
try {
|
||||
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, valueType);
|
||||
return OBJECT_MAPPER.readValue(bytes, javaType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象集合
|
||||
*
|
||||
* @param jsonParser Json JsonParser
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象集合
|
||||
*/
|
||||
public static <T> List<T> parseArray(JsonParser jsonParser, Class<T> valueType) {
|
||||
try {
|
||||
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, valueType);
|
||||
return OBJECT_MAPPER.readValue(jsonParser, javaType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象集合
|
||||
*
|
||||
* @param dataInput Json DataInput
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象集合
|
||||
*/
|
||||
public static <T> List<T> parseArray(DataInput dataInput, Class<T> valueType) {
|
||||
try {
|
||||
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, valueType);
|
||||
return OBJECT_MAPPER.readValue(dataInput, javaType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象集合
|
||||
*
|
||||
* @param inputStream Json InputStream
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象集合
|
||||
*/
|
||||
public static <T> List<T> parseArray(InputStream inputStream, Class<T> valueType) {
|
||||
try {
|
||||
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, valueType);
|
||||
return OBJECT_MAPPER.readValue(inputStream, javaType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象集合
|
||||
*
|
||||
* @param reader Json Reader
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象集合
|
||||
*/
|
||||
public static <T> List<T> parseArray(Reader reader, Class<T> valueType) {
|
||||
try {
|
||||
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, valueType);
|
||||
return OBJECT_MAPPER.readValue(reader, javaType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化,将 Json 字符串解析为 Java 对象集合
|
||||
*
|
||||
* @param file Json File
|
||||
* @param valueType Java 对象
|
||||
* @return Java 对象集合
|
||||
*/
|
||||
public static <T> List<T> parseArray(File file, Class<T> valueType) {
|
||||
try {
|
||||
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, valueType);
|
||||
return OBJECT_MAPPER.readValue(file, javaType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列化,将一个 Java 对象或 Java 对象集合转化为 Json 字符串
|
||||
*
|
||||
* @param type Java 对象引用
|
||||
* @return Json 字符串
|
||||
*/
|
||||
public static <T> String toJsonString(T type) {
|
||||
try {
|
||||
return OBJECT_MAPPER.writeValueAsString(type);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列化,将一个 Java 对象转化为 Json 字符串,并定制 Json 展示内容
|
||||
*
|
||||
* @param type Java 对象引用
|
||||
* @param serializationView 定制现实内容的 Java 对象
|
||||
* @return Json 字符串
|
||||
*/
|
||||
public static <T> String toJsonString(T type, Class<?> serializationView) {
|
||||
try {
|
||||
return OBJECT_MAPPER.writerWithView(serializationView).writeValueAsString(type);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 美化序列化,将一个 Java 对象或 Java 对象集合转化为 Json 字符串
|
||||
*
|
||||
* @param type Java 对象引用
|
||||
* @return Json 字符串
|
||||
*/
|
||||
public static <T> String toPrettyJsonString(T type) {
|
||||
try {
|
||||
return OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(type);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 美化序列化,将一个Java 对象转化为 Json 字符串,并定制 Json 展示内容
|
||||
*
|
||||
* @param type Java 对象引用
|
||||
* @param serializationView 定制现实内容的Java 对象
|
||||
* @return Json 字符串
|
||||
*/
|
||||
public static <T> String toPrettyJsonString(T type, Class<?> serializationView) {
|
||||
try {
|
||||
return OBJECT_MAPPER.writerWithView(serializationView).withDefaultPrettyPrinter().writeValueAsString(type);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列化,将一个 Java 对象或 Java 对象集合转化为 Json Byte Array
|
||||
*
|
||||
* @param type Java 对象引用
|
||||
* @return Json 字符串
|
||||
*/
|
||||
public static <T> byte[] toJsonBytes(T type) {
|
||||
try {
|
||||
return OBJECT_MAPPER.writeValueAsString(type).getBytes(StandardCharsets.UTF_8);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个ObjectMapper对象
|
||||
*
|
||||
* @return ObjectMapper
|
||||
*/
|
||||
public static ObjectMapper getObjectMapper() {
|
||||
return OBJECT_MAPPER;
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,12 @@
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Open Feign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Cache -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
gateway:
|
||||
save:
|
||||
opentsdb: true
|
||||
elasticsearch: true
|
||||
|
||||
auth:
|
||||
save:
|
||||
opentsdb: true
|
||||
elasticsearch: true
|
||||
|
||||
manager:
|
||||
save:
|
||||
opentsdb: true
|
||||
elasticsearch: true
|
||||
|
||||
data:
|
||||
save:
|
||||
opentsdb: true
|
||||
elasticsearch: true
|
||||
@@ -1,11 +1,12 @@
|
||||
feign:
|
||||
circuitbreaker:
|
||||
enabled: true
|
||||
httpclient:
|
||||
enabled: false
|
||||
okhttp:
|
||||
ok-http:
|
||||
enabled: true
|
||||
compression:
|
||||
request:
|
||||
enabled: true
|
||||
response:
|
||||
enabled: true
|
||||
use-gzip-decoder: true
|
||||
enabled: true
|
||||
@@ -25,11 +25,6 @@
|
||||
|
||||
<description>IOT DC3 平台 驱动 SDK 。</description>
|
||||
|
||||
<properties>
|
||||
<jna.version>5.10.0</jna.version>
|
||||
<oshi.version>6.1.0</oshi.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Undertow Web 容器 -->
|
||||
@@ -106,17 +101,14 @@
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>${oshi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dc3 Common Profiles -->
|
||||
|
||||
+4
-4
@@ -15,7 +15,7 @@ package com.dc3.common.sdk.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.dc3.common.constant.Common;
|
||||
import com.dc3.common.exception.ServiceException;
|
||||
import com.dc3.common.model.DeviceEvent;
|
||||
@@ -113,7 +113,7 @@ public class DriverServiceImpl implements DriverService {
|
||||
@Override
|
||||
public void driverEventSender(DriverEvent driverEvent) {
|
||||
if (null != driverEvent) {
|
||||
log.debug("Send driver event: {}", JSON.toJSONString(driverEvent));
|
||||
log.debug("Send driver event: {}", JsonUtil.toJsonString(driverEvent));
|
||||
rabbitTemplate.convertAndSend(
|
||||
Common.Rabbit.TOPIC_EXCHANGE_EVENT,
|
||||
Common.Rabbit.ROUTING_DRIVER_EVENT_PREFIX + serviceName,
|
||||
@@ -124,7 +124,7 @@ public class DriverServiceImpl implements DriverService {
|
||||
|
||||
public void deviceEventSender(DeviceEvent deviceEvent) {
|
||||
if (null != deviceEvent) {
|
||||
log.debug("Send device event: {}", JSON.toJSONString(deviceEvent));
|
||||
log.debug("Send device event: {}", JsonUtil.toJsonString(deviceEvent));
|
||||
rabbitTemplate.convertAndSend(
|
||||
Common.Rabbit.TOPIC_EXCHANGE_EVENT,
|
||||
Common.Rabbit.ROUTING_DEVICE_EVENT_PREFIX + serviceName,
|
||||
@@ -143,7 +143,7 @@ public class DriverServiceImpl implements DriverService {
|
||||
|
||||
public void pointValueSender(PointValue pointValue) {
|
||||
if (null != pointValue) {
|
||||
log.debug("Send point value: {}", JSON.toJSONString(pointValue));
|
||||
log.debug("Send point value: {}", JsonUtil.toJsonString(pointValue));
|
||||
rabbitTemplate.convertAndSend(
|
||||
Common.Rabbit.TOPIC_EXCHANGE_VALUE,
|
||||
Common.Rabbit.ROUTING_POINT_VALUE_PREFIX + serviceName,
|
||||
|
||||
+7
-7
@@ -15,7 +15,6 @@ package com.dc3.common.sdk.service.rabbit;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.bean.driver.DriverConfiguration;
|
||||
import com.dc3.common.bean.driver.DriverMetadata;
|
||||
import com.dc3.common.constant.Common;
|
||||
@@ -23,6 +22,7 @@ import com.dc3.common.model.*;
|
||||
import com.dc3.common.sdk.bean.driver.DriverContext;
|
||||
import com.dc3.common.sdk.service.DriverMetadataService;
|
||||
import com.dc3.common.sdk.service.DriverService;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
@@ -104,7 +104,7 @@ public class DriverMetadataReceiver {
|
||||
break;
|
||||
case Common.Driver.Event.DRIVER_METADATA_SYNC_BACK:
|
||||
DriverMetadata driverMetadata = Convert.convert(DriverMetadata.class, driverConfiguration.getContent());
|
||||
log.debug("Initialization driver metadata : {}", JSON.toJSONString(driverMetadata, true));
|
||||
log.debug("Initialization driver metadata : {}", JsonUtil.toPrettyJsonString(driverMetadata));
|
||||
driverContext.setDriverMetadata(driverMetadata);
|
||||
break;
|
||||
default:
|
||||
@@ -120,7 +120,7 @@ public class DriverMetadataReceiver {
|
||||
private void configurationProfile(DriverConfiguration driverConfiguration) {
|
||||
Profile profile = Convert.convert(Profile.class, driverConfiguration.getContent());
|
||||
if (Common.Driver.Profile.ADD.equals(driverConfiguration.getCommand()) || Common.Driver.Profile.UPDATE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Upsert profile \n{}", JSON.toJSONString(profile, true));
|
||||
log.info("Upsert profile \n{}", JsonUtil.toJsonString(profile));
|
||||
driverMetadataService.upsertProfile(profile);
|
||||
} else if (Common.Driver.Profile.DELETE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Delete profile {}", profile.getName());
|
||||
@@ -136,7 +136,7 @@ public class DriverMetadataReceiver {
|
||||
private void configurationDevice(DriverConfiguration driverConfiguration) {
|
||||
Device device = Convert.convert(Device.class, driverConfiguration.getContent());
|
||||
if (Common.Driver.Device.ADD.equals(driverConfiguration.getCommand()) || Common.Driver.Device.UPDATE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Upsert device \n{}", JSON.toJSONString(device, true));
|
||||
log.info("Upsert device \n{}", JsonUtil.toJsonString(device));
|
||||
driverMetadataService.upsertDevice(device);
|
||||
} else if (Common.Driver.Device.DELETE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Delete device {}", device.getName());
|
||||
@@ -152,7 +152,7 @@ public class DriverMetadataReceiver {
|
||||
private void configurationPoint(DriverConfiguration driverConfiguration) {
|
||||
Point point = Convert.convert(Point.class, driverConfiguration.getContent());
|
||||
if (Common.Driver.Point.ADD.equals(driverConfiguration.getCommand()) || Common.Driver.Point.UPDATE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Upsert point \n{}", JSON.toJSONString(point, true));
|
||||
log.info("Upsert point \n{}", JsonUtil.toJsonString(point));
|
||||
driverMetadataService.upsertPoint(point);
|
||||
} else if (Common.Driver.Point.DELETE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Delete point {}", point.getName());
|
||||
@@ -168,7 +168,7 @@ public class DriverMetadataReceiver {
|
||||
private void configurationDriverInfo(DriverConfiguration driverConfiguration) {
|
||||
DriverInfo driverInfo = Convert.convert(DriverInfo.class, driverConfiguration.getContent());
|
||||
if (Common.Driver.DriverInfo.ADD.equals(driverConfiguration.getCommand()) || Common.Driver.DriverInfo.UPDATE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Upsert driver info \n{}", JSON.toJSONString(driverInfo, true));
|
||||
log.info("Upsert driver info \n{}", JsonUtil.toJsonString(driverInfo));
|
||||
driverMetadataService.upsertDriverInfo(driverInfo);
|
||||
} else if (Common.Driver.DriverInfo.DELETE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Delete driver info {}", driverInfo);
|
||||
@@ -184,7 +184,7 @@ public class DriverMetadataReceiver {
|
||||
private void configurationPointInfo(DriverConfiguration driverConfiguration) {
|
||||
PointInfo pointInfo = Convert.convert(PointInfo.class, driverConfiguration.getContent());
|
||||
if (Common.Driver.PointInfo.ADD.equals(driverConfiguration.getCommand()) || Common.Driver.PointInfo.UPDATE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Upsert point info \n{}", JSON.toJSONString(pointInfo, true));
|
||||
log.info("Upsert point info \n{}", JsonUtil.toJsonString(pointInfo));
|
||||
driverMetadataService.upsertPointInfo(pointInfo);
|
||||
} else if (Common.Driver.PointInfo.DELETE.equals(driverConfiguration.getCommand())) {
|
||||
log.info("Delete point info {}", pointInfo);
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
|
||||
<description>IOT DC3 平台 边缘网关 驱动,该驱动是一个网关类型的驱动。</description>
|
||||
|
||||
<properties>
|
||||
<bouncycastle.version>1.46</bouncycastle.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Spring Integration Stream -->
|
||||
@@ -47,7 +43,6 @@
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>${bouncycastle.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.dc3.driver.mqtt.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -32,7 +32,7 @@ public class MqttPayload {
|
||||
|
||||
public MqttPayload(DataType dataType, Object target) {
|
||||
this.dataType = dataType;
|
||||
this.data = JSON.toJSONString(target);
|
||||
this.data = JsonUtil.toJsonString(target);
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@
|
||||
|
||||
package com.dc3.driver.mqtt.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.sdk.bean.mqtt.MessageHeader;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.dc3.driver.mqtt.bean.MqttPayload;
|
||||
import com.dc3.driver.mqtt.service.MqttReceiveService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -40,7 +40,7 @@ public class MqttReceiveHandler {
|
||||
public MessageHandler handlerValue() {
|
||||
return message -> {
|
||||
MessageHeader messageHeader = new MessageHeader(message.getHeaders());
|
||||
MqttPayload payload = JSON.parseObject(message.getPayload().toString(), MqttPayload.class);
|
||||
MqttPayload payload = JsonUtil.parseObject(message.getPayload().toString(), MqttPayload.class);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,17 +25,12 @@
|
||||
|
||||
<description>IOT DC3 平台 ListeningVirtual驱动,监听模式,提供 Tcp 和 Udp 两种模式,仅用于测试用途。</description>
|
||||
|
||||
<properties>
|
||||
<netty.version>4.1.73.Final</netty.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--Netty-->
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -67,10 +67,25 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: ${driver.project}_${driver.tenant}
|
||||
profiles:
|
||||
active:
|
||||
- server
|
||||
- register
|
||||
- monitor
|
||||
- rabbitmq
|
||||
- quartz
|
||||
- ${NODE_ENV:dev}
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
web:
|
||||
resources:
|
||||
add-mappings: false
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.dc3.common.sdk: DEBUG
|
||||
com.dc3: DEBUG
|
||||
com.dc3.common.sdk: DEBUG
|
||||
file:
|
||||
name: dc3/logs/driver/listening-virtual/${spring.application.name}.log
|
||||
@@ -25,17 +25,12 @@
|
||||
|
||||
<description>IOT DC3 平台 Modbus TCP 驱动。</description>
|
||||
|
||||
<properties>
|
||||
<modbus.version>3.0.4</modbus.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Modbus -->
|
||||
<dependency>
|
||||
<groupId>com.infiniteautomation</groupId>
|
||||
<artifactId>modbus4j</artifactId>
|
||||
<version>${modbus.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.dc3.driver.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.dc3.common.bean.driver.AttributeInfo;
|
||||
import com.dc3.common.constant.Common;
|
||||
import com.dc3.common.model.Device;
|
||||
@@ -103,7 +103,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
* @throws ModbusInitException ModbusInitException
|
||||
*/
|
||||
public ModbusMaster getMaster(Long deviceId, Map<String, AttributeInfo> driverInfo) throws ModbusInitException {
|
||||
log.debug("Modbus Tcp Connection Info {}", JSON.toJSONString(driverInfo));
|
||||
log.debug("Modbus Tcp Connection Info {}", JsonUtil.toJsonString(driverInfo));
|
||||
ModbusMaster modbusMaster = masterMap.get(deviceId);
|
||||
if (null == modbusMaster) {
|
||||
IpParameters params = new IpParameters();
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
|
||||
<description>IOT DC3 平台 Mqtt 驱动。</description>
|
||||
|
||||
<properties>
|
||||
<bouncycastle.version>1.46</bouncycastle.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Spring Integration Stream -->
|
||||
@@ -47,7 +43,6 @@
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>${bouncycastle.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.dc3.driver.mqtt.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -32,7 +32,7 @@ public class MqttPayload {
|
||||
|
||||
public MqttPayload(DataType dataType, Object target) {
|
||||
this.dataType = dataType;
|
||||
this.data = JSON.toJSONString(target);
|
||||
this.data = JsonUtil.toJsonString(target);
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.dc3.driver.mqtt.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.dc3.common.sdk.bean.mqtt.MessageHeader;
|
||||
import com.dc3.driver.mqtt.bean.MqttPayload;
|
||||
import com.dc3.driver.mqtt.service.MqttReceiveService;
|
||||
@@ -40,7 +40,7 @@ public class MqttReceiveHandler {
|
||||
public MessageHandler handlerValue() {
|
||||
return message -> {
|
||||
MessageHeader messageHeader = new MessageHeader(message.getHeaders());
|
||||
MqttPayload payload = JSON.parseObject(message.getPayload().toString(), MqttPayload.class);
|
||||
MqttPayload payload = JsonUtil.parseObject(message.getPayload().toString(), MqttPayload.class);
|
||||
|
||||
// 此处用于接收 MQTT 发送过来的数据,订阅的主题为 application.yml 中 mqtt.receive-topics 配置的 Topic 列表
|
||||
// +(加号):可以(只能)匹配一个单词
|
||||
|
||||
@@ -25,16 +25,12 @@
|
||||
|
||||
<description>IOT DC3 平台 Opc Da 驱动。</description>
|
||||
|
||||
<properties>
|
||||
<j.interop.version>2.0.4</j.interop.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Java Interop 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.jinterop</groupId>
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>${j.interop.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.dc3.driver.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.dc3.common.bean.driver.AttributeInfo;
|
||||
import com.dc3.common.constant.Common;
|
||||
import com.dc3.common.model.Device;
|
||||
@@ -62,7 +62,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
log.debug("Opc Da Read, device: {}, point: {}", JSON.toJSONString(device), JSON.toJSONString(point));
|
||||
log.debug("Opc Da Read, device: {}, point: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(point));
|
||||
Server server = getServer(device.getId(), driverInfo);
|
||||
try {
|
||||
Item item = getItem(server, pointInfo);
|
||||
@@ -74,7 +74,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception {
|
||||
log.debug("Opc Da Write, device: {}, value: {}", JSON.toJSONString(device), JSON.toJSONString(value));
|
||||
log.debug("Opc Da Write, device: {}, value: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(value));
|
||||
Server server = getServer(device.getId(), driverInfo);
|
||||
try {
|
||||
Item item = getItem(server, pointInfo);
|
||||
@@ -115,7 +115,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
Server server = serverMap.get(deviceId);
|
||||
if (null == server) {
|
||||
ConnectionInformation connectionInformation = new ConnectionInformation(attribute(driverInfo, "host"), attribute(driverInfo, "clsId"), attribute(driverInfo, "username"), attribute(driverInfo, "password"));
|
||||
log.debug("Opc Da Server Connection Info {}", JSON.toJSONString(connectionInformation));
|
||||
log.debug("Opc Da Server Connection Info {}", JsonUtil.toJsonString(connectionInformation));
|
||||
server = new Server(connectionInformation, Executors.newSingleThreadScheduledExecutor());
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -25,16 +25,12 @@
|
||||
|
||||
<description>IOT DC3 平台 Opc Ua 驱动。</description>
|
||||
|
||||
<properties>
|
||||
<milo.version>0.6.3</milo.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Eclipse Milo SDK Client -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.milo</groupId>
|
||||
<artifactId>sdk-client</artifactId>
|
||||
<version>${milo.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
+5
-5
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.dc3.driver.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.dc3.common.bean.driver.AttributeInfo;
|
||||
import com.dc3.common.constant.Common;
|
||||
import com.dc3.common.exception.ServiceException;
|
||||
@@ -69,7 +69,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
log.debug("Plc S7 Read, device: {}, point: {}", JSON.toJSONString(device), JSON.toJSONString(point));
|
||||
log.debug("Plc S7 Read, device: {}, point: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(point));
|
||||
MyS7Connector myS7Connector = getS7Connector(device.getId(), driverInfo);
|
||||
myS7Connector.lock.writeLock().lock();
|
||||
S7Serializer serializer = S7SerializerFactory.buildSerializer(myS7Connector.getConnector());
|
||||
@@ -87,7 +87,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception {
|
||||
log.debug("Plc S7 Write, device: {}, value: {}", JSON.toJSONString(device), JSON.toJSONString(value));
|
||||
log.debug("Plc S7 Write, device: {}, value: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(value));
|
||||
MyS7Connector myS7Connector = getS7Connector(device.getId(), driverInfo);
|
||||
myS7Connector.lock.writeLock().lock();
|
||||
S7Serializer serializer = S7SerializerFactory.buildSerializer(myS7Connector.getConnector());
|
||||
@@ -134,7 +134,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
if (null == myS7Connector) {
|
||||
myS7Connector = new MyS7Connector();
|
||||
|
||||
log.debug("Plc S7 Connection Info {}", JSON.toJSONString(driverInfo));
|
||||
log.debug("Plc S7 Connection Info {}", JsonUtil.toJsonString(driverInfo));
|
||||
try {
|
||||
S7Connector s7Connector = S7ConnectorFactory.buildTCPConnector()
|
||||
.withHost(attribute(driverInfo, "host"))
|
||||
@@ -157,7 +157,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
* @return Plcs7PointVariable
|
||||
*/
|
||||
private PlcS7PointVariable getPointVariable(Map<String, AttributeInfo> pointInfo, String type) {
|
||||
log.debug("Plc S7 Point Info {}", JSON.toJSONString(pointInfo));
|
||||
log.debug("Plc S7 Point Info {}", JsonUtil.toJsonString(pointInfo));
|
||||
return new PlcS7PointVariable(attribute(pointInfo, "dbNum"), attribute(pointInfo, "byteOffset"), attribute(pointInfo, "bitOffset"), attribute(pointInfo, "blockSize"), type);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -13,7 +13,6 @@
|
||||
|
||||
package com.dc3.gateway.filter.factory;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dc3.api.center.auth.feign.TenantClient;
|
||||
import com.dc3.api.center.auth.feign.TokenClient;
|
||||
import com.dc3.common.bean.Login;
|
||||
@@ -22,6 +21,7 @@ import com.dc3.common.constant.Common;
|
||||
import com.dc3.common.exception.ServiceException;
|
||||
import com.dc3.common.model.Tenant;
|
||||
import com.dc3.common.utils.Dc3Util;
|
||||
import com.dc3.common.utils.JsonUtil;
|
||||
import com.dc3.gateway.utils.GatewayUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
@@ -74,7 +74,7 @@ public class AuthenticGatewayFilterFactory extends AbstractGatewayFilterFactory<
|
||||
|
||||
try {
|
||||
String cookieToken = GatewayUtil.getRequestCookie(request, Common.Service.DC3_AUTH_TOKEN);
|
||||
Login login = JSON.parseObject(Dc3Util.decode(cookieToken), Login.class);
|
||||
Login login = JsonUtil.parseObject(Dc3Util.decode(cookieToken), Login.class);
|
||||
log.debug("Request cookies: {}", login);
|
||||
|
||||
R<Tenant> tenantR = gatewayFilter.tenantClient.selectByName(login.getTenant());
|
||||
@@ -103,7 +103,7 @@ public class AuthenticGatewayFilterFactory extends AbstractGatewayFilterFactory<
|
||||
response.setStatusCode(HttpStatus.FORBIDDEN);
|
||||
log.error(e.getMessage(), e);
|
||||
|
||||
DataBuffer dataBuffer = response.bufferFactory().wrap(JSON.toJSONBytes(R.fail(e.getMessage())));
|
||||
DataBuffer dataBuffer = response.bufferFactory().wrap(JsonUtil.toJsonBytes(R.fail(e.getMessage())));
|
||||
return response.writeWith(Mono.just(dataBuffer));
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,24 @@
|
||||
|
||||
<spring-boot.version>2.6.6</spring-boot.version>
|
||||
<spring-cloud.version>2021.0.1</spring-cloud.version>
|
||||
<spring-boot-admin.version>2.6.3</spring-boot-admin.version>
|
||||
<spring-boot-admin.version>2.6.6</spring-boot-admin.version>
|
||||
<spring-platform.version>Cairo-SR8</spring-platform.version>
|
||||
|
||||
<codecov.version>2.7</codecov.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<jna.version>5.11.0</jna.version>
|
||||
<oshi.version>6.1.6</oshi.version>
|
||||
<jaxb.version>3.0.2</jaxb.version>
|
||||
<milo.version>0.6.5</milo.version>
|
||||
<modbus.version>3.0.4</modbus.version>
|
||||
<guava.version>31.1-jre</guava.version>
|
||||
<hutool.version>5.7.22</hutool.version>
|
||||
<jaxb.api.version>2.3.1</jaxb.api.version>
|
||||
<netty.version>4.1.76.Final</netty.version>
|
||||
<j.interop.version>2.0.4</j.interop.version>
|
||||
<activation.version>1.1.1</activation.version>
|
||||
<bouncycastle.version>1.46</bouncycastle.version>
|
||||
|
||||
<codecov.version>2.7</codecov.version>
|
||||
<findbugs.version>3.0.5</findbugs.version>
|
||||
<maven.jar.plugin>3.2.0</maven.jar.plugin>
|
||||
<mybatis.plus.version>3.5.1</mybatis.plus.version>
|
||||
@@ -74,6 +87,7 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.plugin>3.8.0</maven.compiler.plugin>
|
||||
<maven.resource.plugin>3.1.0</maven.resource.plugin>
|
||||
<maven.source.plugin>3.2.1</maven.source.plugin>
|
||||
<maven.dependency.plugin>3.1.0</maven.dependency.plugin>
|
||||
<spring.boot.maven.plugin>2.2.2.RELEASE</spring.boot.maven.plugin>
|
||||
</properties>
|
||||
@@ -108,13 +122,6 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -166,6 +173,101 @@
|
||||
<version>${mybatis.plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jwt -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Oshi & Jna -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>${oshi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jaxb Api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb.api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>${jaxb.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>${jaxb.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>${activation.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Eclipse Milo SDK Client -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.milo</groupId>
|
||||
<artifactId>sdk-client</artifactId>
|
||||
<version>${milo.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Modbus -->
|
||||
<dependency>
|
||||
<groupId>com.infiniteautomation</groupId>
|
||||
<artifactId>modbus4j</artifactId>
|
||||
<version>${modbus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--Netty-->
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Java Interop 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.jinterop</groupId>
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>${j.interop.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Tls Cert 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>${bouncycastle.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dc3 Api -->
|
||||
<dependency>
|
||||
<groupId>com.dc3</groupId>
|
||||
@@ -316,6 +418,10 @@
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
@@ -338,6 +444,19 @@
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${maven.source.plugin}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
@@ -366,27 +485,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>dockerfile-maven-plugin</artifactId>
|
||||
<version>1.4.13</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<repository>${docker.image.prefix}/pnoker/${project.artifactId}</repository>
|
||||
<tag>${project.version}</tag>
|
||||
<buildArgs>
|
||||
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 过滤文件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
Reference in New Issue
Block a user