mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-11-03 19:52:27 +08:00
feat: 移出register和monitor
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ public interface DeviceClient {
|
||||
/**
|
||||
* 根据 ID 集合查询 Device
|
||||
*
|
||||
* @param deviceIds Device ID Set
|
||||
* @param deviceIds 设备ID Set
|
||||
* @return Map String:Device
|
||||
*/
|
||||
@PostMapping("/ids")
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public interface DriverInfoClient {
|
||||
* 根据 属性ID 和 设备ID 查询 DriverInfo
|
||||
*
|
||||
* @param attributeId Attribute ID
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @return DriverInfo
|
||||
*/
|
||||
@GetMapping("/attribute_id/{attributeId}/device_id/{deviceId}")
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public interface PointInfoClient {
|
||||
* 根据 属性ID、设备ID 和 位号ID 查询 PointInfo
|
||||
*
|
||||
* @param attributeId Attribute ID
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param pointId Point ID
|
||||
* @return PointInfo
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ eureka:
|
||||
spring:
|
||||
datasource:
|
||||
# Customize MySQL configuration
|
||||
url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/dc3?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://${DB_HOST:dc3-mysql}:${DB_PORT:3306}/${DB_NAME:dc3}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
redis:
|
||||
# Customize Redis configuration
|
||||
host: ${REDIS_HOST:dc3-redis}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public interface RepositoryService {
|
||||
/**
|
||||
* 保存 PointValue 集合
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param pointValues PointValue Array
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ public class RepositoryHandleServiceImpl implements RepositoryHandleService {
|
||||
/**
|
||||
* 保存 PointValues 到指定存储服务
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param pointValues PointValue Array
|
||||
* @param repositoryServices RepositoryService Array
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ eureka:
|
||||
spring:
|
||||
datasource:
|
||||
# Customize MySQL configuration
|
||||
url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/dc3?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://${DB_HOST:dc3-mysql}:${DB_PORT:3306}/${DB_NAME:dc3}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
rabbitmq:
|
||||
# Customize Rabbitmq configuration
|
||||
host: ${RABBITMQ_HOST:dc3-rabbitmq}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public interface DeviceService extends Service<Device, DeviceDto> {
|
||||
/**
|
||||
* 根据 设备Id集 查询设备
|
||||
*
|
||||
* @param ids Device ID Set
|
||||
* @param ids 设备ID Set
|
||||
* @return Device Array
|
||||
*/
|
||||
List<Device> selectByIds(Set<String> ids);
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public interface DriverInfoService extends Service<DriverInfo, DriverInfoDto> {
|
||||
* 根据驱动属性配置 ID 和 设备 ID 查询
|
||||
*
|
||||
* @param driverAttributeId Driver Attribute ID
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @return DriverInfo
|
||||
*/
|
||||
DriverInfo selectByAttributeIdAndDeviceId(String driverAttributeId, String deviceId);
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public interface PointInfoService extends Service<PointInfo, PointInfoDto> {
|
||||
* 根据位号配置信息 ID 、 设备 ID 、 位号 ID 查询
|
||||
*
|
||||
* @param pointAttributeId Point Attribute ID
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param pointId Point ID
|
||||
* @return PointInfo
|
||||
*/
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ public interface ProfileBindService extends Service<ProfileBind, ProfileBindDto>
|
||||
/**
|
||||
* 根据 设备ID 和 模版ID 删除关联的模版映射
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param profileId Profile ID
|
||||
* @return 是否删除
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ public interface ProfileBindService extends Service<ProfileBind, ProfileBindDto>
|
||||
/**
|
||||
* 根据 设备ID 和 模版ID 查询关联的模版映射
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param profileId Profile ID
|
||||
* @return ProfileBind
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ public interface ProfileBindService extends Service<ProfileBind, ProfileBindDto>
|
||||
* 根据 模版ID 查询关联的 设备ID 集合
|
||||
*
|
||||
* @param profileId Profile ID
|
||||
* @return Device ID Set
|
||||
* @return 设备ID Set
|
||||
*/
|
||||
Set<String> selectDeviceIdsByProfileId(String profileId);
|
||||
|
||||
|
||||
+2
-2
@@ -150,7 +150,7 @@ public class BatchServiceImpl implements BatchService {
|
||||
/**
|
||||
* Get driver info map
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param driverAttributeMap Driver Attribute Map
|
||||
* @return map(attributeName, attributeInfo ( value, type))
|
||||
*/
|
||||
@@ -232,7 +232,7 @@ public class BatchServiceImpl implements BatchService {
|
||||
/**
|
||||
* Get profile map
|
||||
*
|
||||
* @param deviceIds Device ID Set
|
||||
* @param deviceIds 设备ID Set
|
||||
* @return map(profileId ( pointId, point))
|
||||
*/
|
||||
public Map<String, Map<String, Point>> getProfilePointMap(Set<String> deviceIds) {
|
||||
|
||||
@@ -21,7 +21,7 @@ eureka:
|
||||
spring:
|
||||
datasource:
|
||||
# Customize MySQL configuration
|
||||
url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/dc3?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://${DB_HOST:dc3-mysql}:${DB_PORT:3306}/${DB_NAME:dc3}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
rabbitmq:
|
||||
# Customize Rabbitmq configuration
|
||||
host: ${RABBITMQ_HOST:dc3-rabbitmq}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
FROM registry.cn-beijing.aliyuncs.com/dc3/alpine-java:corretto-11
|
||||
MAINTAINER pnoker <pnokers.icloud.com>
|
||||
|
||||
ENV JAVA_OPS -server \
|
||||
-javaagent:/usr/local/java/lib/aspectjweaver.jar \
|
||||
-Xms512m \
|
||||
-Xmx2048m \
|
||||
-Xss1m \
|
||||
-Djava.security.egd=file:/dev/./urandom \
|
||||
-XX:MaxDirectMemorySize=256m \
|
||||
-XX:+UseCompressedOops \
|
||||
-XX:+UseCompressedClassPointers \
|
||||
-XX:+SegmentedCodeCache \
|
||||
-XX:+PrintCommandLineFlags
|
||||
ENV GC_LOG -verbose:gc \
|
||||
-XX:+UseG1GC \
|
||||
-XX:+ExplicitGCInvokesConcurrent \
|
||||
-Xlog:gc*,safepoint:dc3/logs/center/monitor/gc/dc3-center-monitor-gc.log:time,uptime:filecount=20,filesize=20M
|
||||
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
WORKDIR /dc3-center/dc3-center-monitor
|
||||
|
||||
ADD ./target/dc3-center-monitor.jar ./
|
||||
|
||||
EXPOSE 8200
|
||||
VOLUME /dc3-center/dc3-center-monitor/dc3/logs
|
||||
|
||||
CMD mkdir -p /dc3-center/dc3-center-monitor/dc3/logs/center/monitor/gc \
|
||||
&& java ${JAVA_OPS} -jar dc3-center-monitor.jar
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2016-present Pnoker All Rights Reserved
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-center</artifactId>
|
||||
<version>2022.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dc3-center-monitor</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>IOT DC3 平台 监控服务中心。</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Spring Boot Admin Server -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Dc3 Common Profiles -->
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-common-profiles</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Development environment, customizable configuration
|
||||
eureka:
|
||||
instance:
|
||||
# Custom node registration ip, dedicated to the development environment
|
||||
ip-address: ${SERVICE_HOST}
|
||||
@@ -1,15 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Product environment, customizable configuration
|
||||
@@ -1,15 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Test environment, customizable configuration
|
||||
@@ -1,41 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
server:
|
||||
port: 8200
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @project.artifactId@
|
||||
profiles:
|
||||
active:
|
||||
- server
|
||||
- register
|
||||
- monitor
|
||||
- ${NODE_ENV:dev}
|
||||
boot:
|
||||
admin:
|
||||
context-path: ${MONITOR_CONTEXT_PATH:/}
|
||||
ui:
|
||||
title: DC3 Monitor Center
|
||||
public-url: ${MONITOR_PUBLIC_URL:/}
|
||||
favicon: /monitor/images/icon/favicon.ico
|
||||
favicon-danger: /monitor/images/icon/favicon-danger.ico
|
||||
brand: <img src="/monitor/images/logo/dc3-logo.png"><span>DC3 Monitor Center</span>
|
||||
|
||||
logging:
|
||||
level:
|
||||
io.github.pnoker: DEBUG
|
||||
file:
|
||||
name: dc3/logs/center/monitor/${spring.application.name}.log
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.7 KiB |
@@ -1,44 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
FROM registry.cn-beijing.aliyuncs.com/dc3/alpine-java:corretto-11
|
||||
MAINTAINER pnoker <pnokers.icloud.com>
|
||||
|
||||
ENV JAVA_OPS -server \
|
||||
-javaagent:/usr/local/java/lib/aspectjweaver.jar \
|
||||
-Xms512m \
|
||||
-Xmx2048m \
|
||||
-Xss1m \
|
||||
-Djava.security.egd=file:/dev/./urandom \
|
||||
-XX:MaxDirectMemorySize=256m \
|
||||
-XX:+UseCompressedOops \
|
||||
-XX:+UseCompressedClassPointers \
|
||||
-XX:+SegmentedCodeCache \
|
||||
-XX:+PrintCommandLineFlags
|
||||
ENV GC_LOG -verbose:gc \
|
||||
-XX:+UseG1GC \
|
||||
-XX:+ExplicitGCInvokesConcurrent \
|
||||
-Xlog:gc*:dc3/logs/center/register/gc/dc3-center-register-gc.log:time,uptime:filecount=20,filesize=20M
|
||||
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
WORKDIR /dc3-center/dc3-center-register
|
||||
|
||||
ADD ./target/dc3-center-register.jar ./
|
||||
|
||||
EXPOSE 8100
|
||||
VOLUME /dc3-center/dc3-center-register/dc3/logs
|
||||
|
||||
CMD mkdir -p /dc3-center/dc3-center-register/dc3/logs/center/register/gc \
|
||||
&& java ${JAVA_OPS} ${GC_LOG} -jar dc3-center-register.jar
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2016-present Pnoker All Rights Reserved
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-center</artifactId>
|
||||
<version>2022.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dc3-center-register</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>IOT DC3 平台 服务注册与发现中心。</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Eureka Server-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Security -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security.oauth</groupId>
|
||||
<artifactId>spring-security-oauth2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Dc3 Common Profiles -->
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-common-profiles</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-present Pnoker All Rights Reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.pnoker.center.register.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @author pnoker
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/eureka/css/**").addResourceLocations("classpath:/static/css/");
|
||||
registry.addResourceHandler("/eureka/images/**").addResourceLocations("classpath:/static/images/");
|
||||
}
|
||||
}
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-present Pnoker All Rights Reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.pnoker.center.register.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
/**
|
||||
* 注册中心安全配置
|
||||
*
|
||||
* @author pnoker
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@EnableWebSecurity
|
||||
public class WebSecurityConfig {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.csrf().disable();
|
||||
http.authorizeRequests().antMatchers("/actuator/**").permitAll();
|
||||
http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Development environment, customizable configuration
|
||||
eureka:
|
||||
instance:
|
||||
# Custom node registration ip, dedicated to the development environment
|
||||
ip-address: ${SERVICE_HOST}
|
||||
server:
|
||||
# Turn off the self-protection mechanism
|
||||
enable-self-preservation: false
|
||||
@@ -1,15 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Product environment, customizable configuration
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Test environment, customizable configuration
|
||||
eureka:
|
||||
server:
|
||||
# Turn off the self-protection mechanism
|
||||
enable-self-preservation: false
|
||||
@@ -1,39 +0,0 @@
|
||||
#
|
||||
# Copyright 2016-present Pnoker All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
server:
|
||||
port: ${EUREKA_PORT:8100}
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @project.artifactId@
|
||||
profiles:
|
||||
active:
|
||||
- server
|
||||
- register
|
||||
- monitor
|
||||
- ${NODE_ENV:dev}
|
||||
|
||||
logging:
|
||||
level:
|
||||
io.github.pnoker: DEBUG
|
||||
file:
|
||||
name: dc3/logs/center/register/${spring.application.name}.log
|
||||
|
||||
eureka:
|
||||
dashboard:
|
||||
path: ${EUREKA_DASHBOARD_PATH:/}
|
||||
server:
|
||||
eviction-interval-timer-in-ms: 5000
|
||||
renewal-percent-threshold: 0.9
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,24 +0,0 @@
|
||||
<#import "/spring.ftl" as spring />
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="<@spring.url dashboardPath/>"><span></span></a>
|
||||
<#--<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>-->
|
||||
</div>
|
||||
<#--<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="<@spring.url dashboardPath/>">Home</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<@spring.url dashboardPath/>/lastn">Last 1000 since startup</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>-->
|
||||
</div>
|
||||
</nav>
|
||||
@@ -1,97 +0,0 @@
|
||||
<#import "/spring.ftl" as spring />
|
||||
<!doctype html>
|
||||
<!--[if lt IE 7]>
|
||||
<html class="no-js lt-ie9 lt-ie8 lt-ie7">
|
||||
<![endif]-->
|
||||
<!--[if IE 7]>
|
||||
<html class="no-js lt-ie9 lt-ie8">
|
||||
<![endif]-->
|
||||
<!--[if IE 8]>
|
||||
<html class="no-js lt-ie9">
|
||||
<![endif]-->
|
||||
<!--[if gt IE 8]>
|
||||
<!-->
|
||||
<html class="no-js">
|
||||
<!--<![endif]-->
|
||||
<head>
|
||||
<base href="<@spring.url basePath/>">
|
||||
<title>DC3 Register Center - Last N events</title>
|
||||
<link rel="icon" href="eureka/images/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="eureka/css/wro.css">
|
||||
</head>
|
||||
<body id="three">
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<p>You are using an <strong>outdated</strong> browser. Please upgrade your browser to improve your experience.</p>
|
||||
<![endif]-->
|
||||
|
||||
<#include "header.ftlh">
|
||||
|
||||
<div class="container-fluid xd-container">
|
||||
<#include "navbar.ftlh">
|
||||
|
||||
<div id="xd-jobs" class="tab-pane active col-md-12">
|
||||
<ul class="nav nav-tabs" role="tablist" id="myTab">
|
||||
<li class="active"><a data-toggle="tab" href="#cancelled">Last 1000 cancelled leases</a></li>
|
||||
<li><a data-toggle="tab" href="#registered">Last 1000 newly registered leases</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane" id="cancelled">
|
||||
<table id='lastNCanceled' class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>Lease</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#if lastNCanceled?has_content>
|
||||
<#list lastNCanceled as entry>
|
||||
<tr>
|
||||
<td>${entry.date?datetime}</td>
|
||||
<td>${entry.id}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#else>
|
||||
<tr>
|
||||
<td colspan="2">No results available</td>
|
||||
</tr>
|
||||
</#if>
|
||||
<tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane" id="registered">
|
||||
<table id='lastNRegistered' class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>Lease</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#if lastNRegistered?has_content>
|
||||
<#list lastNRegistered as entry>
|
||||
<tr>
|
||||
<td>${entry.date?datetime}</td>
|
||||
<td>${entry.id}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#else>
|
||||
<tr>
|
||||
<td colspan="2">No results available</td>
|
||||
</tr>
|
||||
</#if>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="eureka/js/wro.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#myTab a:last').tab('show')
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,72 +0,0 @@
|
||||
<h1>System Status</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<table id='instances' class="table table-condensed table-striped table-hover">
|
||||
<#if amazonInfo??>
|
||||
<tr>
|
||||
<td>EUREKA SERVER</td>
|
||||
<td>AMI: ${amiId!}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Zone</td>
|
||||
<td>${availabilityZone!}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>instance-id</td>
|
||||
<td>${instanceId!}</td>
|
||||
</tr>
|
||||
</#if>
|
||||
<tr>
|
||||
<td>Environment</td>
|
||||
<td>${environment!}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Data center</td>
|
||||
<td>${datacenter!}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<table id='instances' class="table table-condensed table-striped table-hover">
|
||||
<tr>
|
||||
<td>Current time</td>
|
||||
<td>${currentTime}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Uptime</td>
|
||||
<td>${upTime}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lease expiration enabled</td>
|
||||
<td>${registry.leaseExpirationEnabled?c}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Renews threshold</td>
|
||||
<td>${registry.numOfRenewsPerMinThreshold}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Renews (last min)</td>
|
||||
<td>${registry.numOfRenewsInLastMin}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<#if isBelowRenewThreshold>
|
||||
<#if !registry.selfPreservationModeEnabled>
|
||||
<h4 id="uptime"><font size="+1" color="red"><b>RENEWALS ARE LESSER THAN THE THRESHOLD. THE SELF PRESERVATION MODE IS TURNED OFF. THIS MAY NOT PROTECT INSTANCE EXPIRY IN
|
||||
CASE OF NETWORK/OTHER PROBLEMS.</b></font></h4>
|
||||
<#else>
|
||||
<h4 id="uptime"><font size="+1" color="red"><b>EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE
|
||||
THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.</b></font></h4>
|
||||
</#if>
|
||||
<#elseif !registry.selfPreservationModeEnabled>
|
||||
<h4 id="uptime"><font size="+1" color="red"><b>THE SELF PRESERVATION MODE IS TURNED OFF. THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF NETWORK/OTHER PROBLEMS.</b></font></h4>
|
||||
</#if>
|
||||
|
||||
<h1>DS Replicas</h1>
|
||||
<ul class="list-group">
|
||||
<#list replicas as replica>
|
||||
<li class="list-group-item"><a href="${replica.value}">${replica.key}</a></li>
|
||||
</#list>
|
||||
</ul>
|
||||
@@ -1,138 +0,0 @@
|
||||
<#import "/spring.ftl" as spring />
|
||||
<!doctype html>
|
||||
<!--[if lt IE 7]>
|
||||
<html class="no-js lt-ie9 lt-ie8 lt-ie7">
|
||||
<![endif]-->
|
||||
<!--[if IE 7]>
|
||||
<html class="no-js lt-ie9 lt-ie8">
|
||||
<![endif]-->
|
||||
<!--[if IE 8]>
|
||||
<html class="no-js lt-ie9">
|
||||
<![endif]-->
|
||||
<!--[if gt IE 8]>
|
||||
<!-->
|
||||
<html class="no-js">
|
||||
<!--<![endif]-->
|
||||
<head>
|
||||
<base href="<@spring.url basePath/>">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>DC3 Register Center</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="icon" href="eureka/images/favicon.ico">
|
||||
<link rel="stylesheet" href="eureka/css/wro.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body id="one">
|
||||
<#include "header.ftlh">
|
||||
<div class="container-fluid xd-container">
|
||||
<#include "navbar.ftlh">
|
||||
<h1>Instances currently registered with DC3 Register Center</h1>
|
||||
<table id='instances' class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Application</th>
|
||||
<th>AMIs</th>
|
||||
<th>Availability Zones</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#if apps?has_content>
|
||||
<#list apps as app>
|
||||
<tr>
|
||||
<td><b>${app.name}</b></td>
|
||||
<td>
|
||||
<#list app.amiCounts as amiCount>
|
||||
<b>${amiCount.key}</b> (${amiCount.value})<#if amiCount_has_next>,</#if>
|
||||
</#list>
|
||||
</td>
|
||||
<td>
|
||||
<#list app.zoneCounts as zoneCount>
|
||||
<b>${zoneCount.key}</b> (${zoneCount.value})<#if zoneCount_has_next>,</#if>
|
||||
</#list>
|
||||
</td>
|
||||
<td>
|
||||
<#list app.instanceInfos as instanceInfo>
|
||||
<#if instanceInfo.isNotUp>
|
||||
<font color=red size=+1><b>
|
||||
</#if>
|
||||
<b>${instanceInfo.status}</b> (${instanceInfo.instances?size}) -
|
||||
<#if instanceInfo.isNotUp>
|
||||
</b></font>
|
||||
</#if>
|
||||
<#list instanceInfo.instances as instance>
|
||||
<#if instance.isHref>
|
||||
<a href="${instance.url}" target="_blank">${instance.id}</a>
|
||||
<#else>
|
||||
${instance.id}
|
||||
</#if><#if instance_has_next>,</#if>
|
||||
</#list>
|
||||
</#list>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#else>
|
||||
<tr>
|
||||
<td colspan="4">No instances available</td>
|
||||
</tr>
|
||||
</#if>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h1>General Info</h1>
|
||||
|
||||
<table id='generalInfo' class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#list statusInfo.generalStats?keys as stat>
|
||||
<tr>
|
||||
<td>${stat}</td>
|
||||
<td>${statusInfo.generalStats[stat]!""}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#list statusInfo.applicationStats?keys as stat>
|
||||
<tr>
|
||||
<td>${stat}</td>
|
||||
<td>${statusInfo.applicationStats[stat]!""}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h1>Instance Info</h1>
|
||||
|
||||
<table id='instanceInfo' class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
<thead>
|
||||
<tbody>
|
||||
<#list instanceInfo?keys as key>
|
||||
<tr>
|
||||
<td>${key}</td>
|
||||
<td>${instanceInfo[key]!""}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript" src="eureka/js/wro.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('table.stripeable tr:odd').addClass('odd');
|
||||
$('table.stripeable tr:even').addClass('even');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+3
-3
@@ -24,12 +24,12 @@
|
||||
<artifactId>dc3-center</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<description>IOT DC3 平台 综合管理中心集合,包含:服务注册与发现中心、服务监控中心、物联数据采集中心、授权与权限管理中心。</description>
|
||||
<description>IOT DC3 平台
|
||||
综合管理中心集合,包含:服务注册与发现中心、服务监控中心、物联数据采集中心、授权与权限管理中心。
|
||||
</description>
|
||||
|
||||
<modules>
|
||||
<module>dc3-center-auth</module>
|
||||
<module>dc3-center-register</module>
|
||||
<module>dc3-center-monitor</module>
|
||||
<module>dc3-center-manager</module>
|
||||
<module>dc3-center-data</module>
|
||||
</modules>
|
||||
|
||||
+6
-12
@@ -12,24 +12,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.pnoker.center.monitor;
|
||||
package io.github.pnoker.common.exception;
|
||||
|
||||
import de.codecentric.boot.admin.server.config.EnableAdminServer;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
|
||||
/**
|
||||
* 服务监控中心
|
||||
* 自定义 连接器 异常
|
||||
*
|
||||
* @author pnoker
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableAdminServer
|
||||
public class MonitorApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MonitorApplication.class, args);
|
||||
public class ConnectorException extends RuntimeException {
|
||||
public ConnectorException(CharSequence template, Object... params) {
|
||||
super(CharSequenceUtil.format(template, params));
|
||||
}
|
||||
|
||||
}
|
||||
+6
-12
@@ -12,24 +12,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.pnoker.center.register;
|
||||
package io.github.pnoker.common.exception;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
|
||||
/**
|
||||
* 服务注册中心
|
||||
* 自定义 读取位号值 异常
|
||||
*
|
||||
* @author pnoker
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableEurekaServer
|
||||
public class RegisterApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RegisterApplication.class, args);
|
||||
public class ReadPointException extends RuntimeException {
|
||||
public ReadPointException(CharSequence template, Object... params) {
|
||||
super(CharSequenceUtil.format(template, params));
|
||||
}
|
||||
|
||||
}
|
||||
+7
-9
@@ -12,20 +12,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.pnoker.center.monitor.config;
|
||||
package io.github.pnoker.common.exception;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
|
||||
/**
|
||||
* 自定义 写入位号值 异常
|
||||
*
|
||||
* @author pnoker
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/monitor/images/**").addResourceLocations("classpath:/static/images/");
|
||||
public class WritePointException extends RuntimeException {
|
||||
public WritePointException(CharSequence template, Object... params) {
|
||||
super(CharSequenceUtil.format(template, params));
|
||||
}
|
||||
}
|
||||
@@ -37,12 +37,6 @@
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Admin -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/dc3?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://${DB_HOST:dc3-mysql}:${DB_PORT:3306}/${DB_NAME:dc3}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: ${MYSQL_USERNAME:root}
|
||||
password: ${MYSQL_PASSWORD:dc3}
|
||||
username: ${DB_USERNAME:root}
|
||||
password: ${DB_PASSWORD:dc3}
|
||||
hikari:
|
||||
pool-name: dc3-hikaricp
|
||||
max-lifetime: 1765000
|
||||
|
||||
@@ -50,12 +50,6 @@
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Admin -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
+8
-9
@@ -25,9 +25,9 @@ import java.util.Map;
|
||||
*
|
||||
* <ol>
|
||||
* <li>{@link DriverCustomService#initial} 初始化操作,需要根据不同的驱动实现该功能</li>
|
||||
* <li>{@link DriverCustomService#schedule} 调度操作,需要根据不同的驱动实现该功能</li>
|
||||
* <li>{@link DriverCustomService#read} 读操作,需要根据不同的驱动实现该功能</li>
|
||||
* <li>{@link DriverCustomService#write} 写操作,需要根据不同的驱动实现该功能</li>
|
||||
* <li>{@link DriverCustomService#schedule} 调度操作,需要根据不同的驱动实现该功能</li>
|
||||
* </ol>
|
||||
*
|
||||
* @author pnoker
|
||||
@@ -39,6 +39,11 @@ public interface DriverCustomService {
|
||||
*/
|
||||
void initial();
|
||||
|
||||
/**
|
||||
* Schedule Operation
|
||||
*/
|
||||
void schedule();
|
||||
|
||||
/**
|
||||
* Read Operation
|
||||
*
|
||||
@@ -47,9 +52,8 @@ public interface DriverCustomService {
|
||||
* @param device Device
|
||||
* @param point Point
|
||||
* @return String Value
|
||||
* @throws Exception Exception
|
||||
*/
|
||||
String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception;
|
||||
String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point);
|
||||
|
||||
/**
|
||||
* Write Operation
|
||||
@@ -59,12 +63,7 @@ public interface DriverCustomService {
|
||||
* @param device Device
|
||||
* @param value Value Attribute Info
|
||||
* @return Boolean 是否写入
|
||||
* @throws Exception Exception
|
||||
*/
|
||||
Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception;
|
||||
Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value);
|
||||
|
||||
/**
|
||||
* Schedule Operation
|
||||
*/
|
||||
void schedule();
|
||||
}
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ public interface DriverMetadataService {
|
||||
/**
|
||||
* 删除 DeviceDriver 中添加驱动配置信息
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param attributeId Attribute ID
|
||||
*/
|
||||
void deleteDriverInfo(String deviceId, String attributeId);
|
||||
@@ -95,7 +95,7 @@ public interface DriverMetadataService {
|
||||
/**
|
||||
* 删除 DeviceDriver 中添加位号配置信息
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param pointId Point ID
|
||||
* @param attributeId Attribute ID
|
||||
*/
|
||||
|
||||
+20
-20
@@ -53,26 +53,6 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
mqttScheduleService.initial();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
// 因为 MQTT 的数据来源是被动接收的,所以无需实现该 Read 方法
|
||||
// 接收数据处理函数在 io.github.pnoker.driver.mqtt.handler.MqttReceiveHandler.handlerValue
|
||||
return "nil";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo values) throws Exception {
|
||||
String commandTopic = attribute(pointInfo, "commandTopic");
|
||||
String value = values.getValue();
|
||||
try {
|
||||
int commandQos = attribute(pointInfo, "commandQos");
|
||||
mqttSendService.sendToMqtt(commandTopic, commandQos, value);
|
||||
} catch (Exception e) {
|
||||
mqttSendService.sendToMqtt(commandTopic, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void schedule() {
|
||||
|
||||
@@ -90,4 +70,24 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
driverContext.getDriverMetadata().getDeviceMap().keySet().forEach(id -> driverService.deviceStatusSender(id, StatusEnum.ONLINE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
// 因为 MQTT 的数据来源是被动接收的,所以无需实现该 Read 方法
|
||||
// 接收数据处理函数在 io.github.pnoker.driver.mqtt.handler.MqttReceiveHandler.handlerValue
|
||||
return "nil";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo values) {
|
||||
String commandTopic = attribute(pointInfo, "commandTopic");
|
||||
String value = values.getValue();
|
||||
try {
|
||||
int commandQos = attribute(pointInfo, "commandQos");
|
||||
mqttSendService.sendToMqtt(commandTopic, commandQos, value);
|
||||
} catch (Exception e) {
|
||||
mqttSendService.sendToMqtt(commandTopic, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-21
@@ -69,27 +69,6 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
// 因为 Listening Virtual 的数据来源是被动接收的,所以无需实现该 Read 方法
|
||||
// 接收数据处理函数在
|
||||
// - io.github.pnoker.driver.service.netty.tcp.NettyTcpServerHandler.channelRead
|
||||
// - io.github.pnoker.driver.service.netty.udp.NettyUdpServerHandler.channelRead0
|
||||
return "nil";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception {
|
||||
String deviceId = device.getId();
|
||||
|
||||
// TODO 获取设备的Channel,并向下发送数据
|
||||
Channel channel = NettyTcpServer.deviceChannelMap.get(deviceId);
|
||||
if (null != channel) {
|
||||
channel.writeAndFlush(DecodeUtil.stringToByte(value.getValue()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void schedule() {
|
||||
|
||||
@@ -107,4 +86,25 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
driverContext.getDriverMetadata().getDeviceMap().keySet().forEach(id -> driverService.deviceStatusSender(id, StatusEnum.ONLINE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
// 因为 Listening Virtual 的数据来源是被动接收的,所以无需实现该 Read 方法
|
||||
// 接收数据处理函数在
|
||||
// - io.github.pnoker.driver.service.netty.tcp.NettyTcpServerHandler.channelRead
|
||||
// - io.github.pnoker.driver.service.netty.udp.NettyUdpServerHandler.channelRead0
|
||||
return "nil";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) {
|
||||
String deviceId = device.getId();
|
||||
|
||||
// TODO 获取设备的Channel,并向下发送数据
|
||||
Channel channel = NettyTcpServer.deviceChannelMap.get(deviceId);
|
||||
if (null != channel) {
|
||||
channel.writeAndFlush(DecodeUtil.stringToByte(value.getValue()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+100
-42
@@ -28,11 +28,15 @@ import com.serotonin.modbus4j.msg.WriteCoilResponse;
|
||||
import io.github.pnoker.common.bean.driver.AttributeInfo;
|
||||
import io.github.pnoker.common.enums.PointValueTypeEnum;
|
||||
import io.github.pnoker.common.enums.StatusEnum;
|
||||
import io.github.pnoker.common.exception.ConnectorException;
|
||||
import io.github.pnoker.common.exception.ReadPointException;
|
||||
import io.github.pnoker.common.exception.WritePointException;
|
||||
import io.github.pnoker.common.model.Device;
|
||||
import io.github.pnoker.common.model.Point;
|
||||
import io.github.pnoker.common.sdk.bean.driver.DriverContext;
|
||||
import io.github.pnoker.common.sdk.service.DriverCustomService;
|
||||
import io.github.pnoker.common.sdk.service.DriverService;
|
||||
import io.github.pnoker.common.sdk.utils.DriverUtil;
|
||||
import io.github.pnoker.common.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -42,7 +46,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static io.github.pnoker.common.sdk.utils.DriverUtil.attribute;
|
||||
import static io.github.pnoker.common.sdk.utils.DriverUtil.value;
|
||||
|
||||
/**
|
||||
* @author pnoker
|
||||
@@ -63,23 +66,15 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
modbusFactory = new ModbusFactory();
|
||||
}
|
||||
|
||||
private Map<String, ModbusMaster> masterMap;
|
||||
private Map<String, ModbusMaster> connectMap;
|
||||
|
||||
@Override
|
||||
public void initial() {
|
||||
masterMap = new ConcurrentHashMap<>(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
ModbusMaster modbusMaster = getMaster(device.getId(), driverInfo);
|
||||
return readValue(modbusMaster, pointInfo, point.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception {
|
||||
ModbusMaster modbusMaster = getMaster(device.getId(), driverInfo);
|
||||
return writeValue(modbusMaster, pointInfo, value.getType(), value.getValue());
|
||||
/*
|
||||
TODO: 仅供参考
|
||||
可自定义实现
|
||||
*/
|
||||
connectMap = new ConcurrentHashMap<>(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,24 +94,41 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
driverContext.getDriverMetadata().getDeviceMap().keySet().forEach(id -> driverService.deviceStatusSender(id, StatusEnum.ONLINE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
ModbusMaster modbusMaster = getConnector(device.getId(), driverInfo);
|
||||
return readValue(modbusMaster, pointInfo, point.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) {
|
||||
ModbusMaster modbusMaster = getConnector(device.getId(), driverInfo);
|
||||
return writeValue(modbusMaster, pointInfo, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Modbus Master
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param driverInfo Driver Info
|
||||
* @param deviceId 设备ID
|
||||
* @param driverInfo 驱动信息
|
||||
* @return ModbusMaster
|
||||
* @throws ModbusInitException ModbusInitException
|
||||
*/
|
||||
public ModbusMaster getMaster(String deviceId, Map<String, AttributeInfo> driverInfo) throws ModbusInitException {
|
||||
log.debug("Modbus Tcp Connection Info {}", JsonUtil.toJsonString(driverInfo));
|
||||
ModbusMaster modbusMaster = masterMap.get(deviceId);
|
||||
private ModbusMaster getConnector(String deviceId, Map<String, AttributeInfo> driverInfo) {
|
||||
log.debug("Modbus Tcp Connection Info: {}", JsonUtil.toJsonString(driverInfo));
|
||||
ModbusMaster modbusMaster = connectMap.get(deviceId);
|
||||
if (null == modbusMaster) {
|
||||
IpParameters params = new IpParameters();
|
||||
params.setHost(attribute(driverInfo, "host"));
|
||||
params.setPort(attribute(driverInfo, "port"));
|
||||
modbusMaster = modbusFactory.createTcpMaster(params, true);
|
||||
modbusMaster.init();
|
||||
masterMap.put(deviceId, modbusMaster);
|
||||
try {
|
||||
modbusMaster.init();
|
||||
connectMap.put(deviceId, modbusMaster);
|
||||
} catch (ModbusInitException e) {
|
||||
connectMap.entrySet().removeIf(next -> next.getKey().equals(deviceId));
|
||||
log.error("Connect modbus master error: {}", e.getMessage(), e);
|
||||
throw new ConnectorException(e.getMessage());
|
||||
}
|
||||
}
|
||||
return modbusMaster;
|
||||
}
|
||||
@@ -128,29 +140,27 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
* @param pointInfo Point Info
|
||||
* @param type Value Type
|
||||
* @return String Value
|
||||
* @throws ModbusTransportException ModbusTransportException
|
||||
* @throws ErrorResponseException ErrorResponseException
|
||||
*/
|
||||
public String readValue(ModbusMaster modbusMaster, Map<String, AttributeInfo> pointInfo, String type) throws ModbusTransportException, ErrorResponseException {
|
||||
private String readValue(ModbusMaster modbusMaster, Map<String, AttributeInfo> pointInfo, String type) {
|
||||
int slaveId = attribute(pointInfo, "slaveId");
|
||||
int functionCode = attribute(pointInfo, "functionCode");
|
||||
int offset = attribute(pointInfo, "offset");
|
||||
switch (functionCode) {
|
||||
case 1:
|
||||
BaseLocator<Boolean> coilLocator = BaseLocator.coilStatus(slaveId, offset);
|
||||
Boolean coilValue = modbusMaster.getValue(coilLocator);
|
||||
Boolean coilValue = getMasterValue(modbusMaster, coilLocator);
|
||||
return String.valueOf(coilValue);
|
||||
case 2:
|
||||
BaseLocator<Boolean> inputLocator = BaseLocator.inputStatus(slaveId, offset);
|
||||
Boolean inputStatusValue = modbusMaster.getValue(inputLocator);
|
||||
Boolean inputStatusValue = getMasterValue(modbusMaster, inputLocator);
|
||||
return String.valueOf(inputStatusValue);
|
||||
case 3:
|
||||
BaseLocator<Number> holdingLocator = BaseLocator.holdingRegister(slaveId, offset, getValueType(type));
|
||||
Number holdingValue = modbusMaster.getValue(holdingLocator);
|
||||
Number holdingValue = getMasterValue(modbusMaster, holdingLocator);
|
||||
return String.valueOf(holdingValue);
|
||||
case 4:
|
||||
BaseLocator<Number> inputRegister = BaseLocator.inputRegister(slaveId, offset, getValueType(type));
|
||||
Number inputRegisterValue = modbusMaster.getValue(inputRegister);
|
||||
Number inputRegisterValue = getMasterValue(modbusMaster, inputRegister);
|
||||
return String.valueOf(inputRegisterValue);
|
||||
default:
|
||||
return "0";
|
||||
@@ -158,29 +168,41 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 写 Value
|
||||
* 获取 ModbusMaster 值
|
||||
*
|
||||
* @param modbusMaster ModbusMaster
|
||||
* @param locator BaseLocator
|
||||
* @param <T> 类型
|
||||
* @return 类型
|
||||
*/
|
||||
private <T> T getMasterValue(ModbusMaster modbusMaster, BaseLocator<T> locator) {
|
||||
try {
|
||||
return modbusMaster.getValue(locator);
|
||||
} catch (ModbusTransportException | ErrorResponseException e) {
|
||||
log.error("Read modbus master value error: {}", e.getMessage(), e);
|
||||
throw new ReadPointException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入 ModbusMaster 值
|
||||
*
|
||||
* @param modbusMaster ModbusMaster
|
||||
* @param pointInfo Point Info
|
||||
* @param type Value Type
|
||||
* @param value String Value
|
||||
* @param value Value
|
||||
* @return Write Result
|
||||
* @throws ModbusTransportException ModbusTransportException
|
||||
* @throws ErrorResponseException ErrorResponseException
|
||||
*/
|
||||
public boolean writeValue(ModbusMaster modbusMaster, Map<String, AttributeInfo> pointInfo, String type, String value) throws ModbusTransportException, ErrorResponseException {
|
||||
private boolean writeValue(ModbusMaster modbusMaster, Map<String, AttributeInfo> pointInfo, AttributeInfo value) {
|
||||
int slaveId = attribute(pointInfo, "slaveId");
|
||||
int functionCode = attribute(pointInfo, "functionCode");
|
||||
int offset = attribute(pointInfo, "offset");
|
||||
switch (functionCode) {
|
||||
case 1:
|
||||
boolean coilValue = value(type, value);
|
||||
WriteCoilRequest coilRequest = new WriteCoilRequest(slaveId, offset, coilValue);
|
||||
WriteCoilResponse coilResponse = (WriteCoilResponse) modbusMaster.send(coilRequest);
|
||||
WriteCoilResponse coilResponse = setMasterValue(modbusMaster, slaveId, offset, value);
|
||||
return !coilResponse.isException();
|
||||
case 3:
|
||||
BaseLocator<Number> locator = BaseLocator.holdingRegister(slaveId, offset, getValueType(type));
|
||||
modbusMaster.setValue(locator, value(type, value));
|
||||
BaseLocator<Number> locator = BaseLocator.holdingRegister(slaveId, offset, getValueType(value.getType()));
|
||||
setMasterValue(modbusMaster, locator, value);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -197,7 +219,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
* @param type Value Type
|
||||
* @return Modbus Data Type
|
||||
*/
|
||||
public int getValueType(String type) {
|
||||
private int getValueType(String type) {
|
||||
PointValueTypeEnum valueType = PointValueTypeEnum.of(type);
|
||||
if (ObjectUtil.isNull(valueType)) {
|
||||
throw new IllegalArgumentException("Unsupported type of " + type);
|
||||
@@ -215,4 +237,40 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入 ModbusMaster 值
|
||||
*
|
||||
* @param modbusMaster ModbusMaster
|
||||
* @param slaveId 从站ID
|
||||
* @param offset 偏移量
|
||||
* @param value 写入值
|
||||
* @return WriteCoilResponse
|
||||
*/
|
||||
private WriteCoilResponse setMasterValue(ModbusMaster modbusMaster, int slaveId, int offset, AttributeInfo value) {
|
||||
try {
|
||||
WriteCoilRequest coilRequest = new WriteCoilRequest(slaveId, offset, DriverUtil.value(value.getType(), value.getValue()));
|
||||
return (WriteCoilResponse) modbusMaster.send(coilRequest);
|
||||
} catch (ModbusTransportException e) {
|
||||
log.error("Write modbus master value error: {}", e.getMessage(), e);
|
||||
throw new WritePointException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入 ModbusMaster 值
|
||||
*
|
||||
* @param modbusMaster ModbusMaster
|
||||
* @param locator BaseLocator
|
||||
* @param value 写入值
|
||||
* @param <T> 类型
|
||||
*/
|
||||
private <T> void setMasterValue(ModbusMaster modbusMaster, BaseLocator<T> locator, AttributeInfo value) {
|
||||
try {
|
||||
modbusMaster.setValue(locator, DriverUtil.value(value.getType(), value.getValue()));
|
||||
} catch (ModbusTransportException | ErrorResponseException e) {
|
||||
log.error("Write modbus master value error: {}", e.getMessage(), e);
|
||||
throw new WritePointException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -54,14 +54,14 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
// 因为 MQTT 的数据来源是被动接收的,所以无需实现该 Read 方法
|
||||
// 接收数据处理函数在 io.github.pnoker.driver.mqtt.handler.MqttReceiveHandler.handlerValue
|
||||
return "nil";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo values) throws Exception {
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo values) {
|
||||
String commandTopic = attribute(pointInfo, "commandTopic");
|
||||
String value = values.getValue();
|
||||
try {
|
||||
|
||||
+91
-57
@@ -18,11 +18,15 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import io.github.pnoker.common.bean.driver.AttributeInfo;
|
||||
import io.github.pnoker.common.enums.PointValueTypeEnum;
|
||||
import io.github.pnoker.common.enums.StatusEnum;
|
||||
import io.github.pnoker.common.exception.ConnectorException;
|
||||
import io.github.pnoker.common.exception.ReadPointException;
|
||||
import io.github.pnoker.common.exception.WritePointException;
|
||||
import io.github.pnoker.common.model.Device;
|
||||
import io.github.pnoker.common.model.Point;
|
||||
import io.github.pnoker.common.sdk.bean.driver.DriverContext;
|
||||
import io.github.pnoker.common.sdk.service.DriverCustomService;
|
||||
import io.github.pnoker.common.sdk.service.DriverService;
|
||||
import io.github.pnoker.common.sdk.utils.DriverUtil;
|
||||
import io.github.pnoker.common.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
@@ -40,7 +44,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static io.github.pnoker.common.sdk.utils.DriverUtil.attribute;
|
||||
import static io.github.pnoker.common.sdk.utils.DriverUtil.value;
|
||||
|
||||
/**
|
||||
* @author pnoker
|
||||
@@ -58,36 +61,15 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
/**
|
||||
* Opc Da Server Map
|
||||
*/
|
||||
private Map<String, Server> serverMap;
|
||||
private Map<String, Server> connectMap;
|
||||
|
||||
@Override
|
||||
public void initial() {
|
||||
serverMap = new ConcurrentHashMap<>(16);
|
||||
}
|
||||
|
||||
@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: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(point));
|
||||
Server server = getServer(device.getId(), driverInfo);
|
||||
try {
|
||||
Item item = getItem(server, pointInfo);
|
||||
return readItem(item);
|
||||
} finally {
|
||||
server.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@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: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(value));
|
||||
Server server = getServer(device.getId(), driverInfo);
|
||||
try {
|
||||
Item item = getItem(server, pointInfo);
|
||||
writeItem(item, value.getType(), value.getValue());
|
||||
return true;
|
||||
} finally {
|
||||
server.dispose();
|
||||
}
|
||||
/*
|
||||
TODO: 仅供参考
|
||||
可自定义实现
|
||||
*/
|
||||
connectMap = new ConcurrentHashMap<>(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,28 +89,44 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
driverContext.getDriverMetadata().getDeviceMap().keySet().forEach(id -> driverService.deviceStatusSender(id, StatusEnum.ONLINE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
Server server = getConnector(device.getId(), driverInfo);
|
||||
return readValue(server, pointInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) {
|
||||
Server server = getConnector(device.getId(), driverInfo);
|
||||
return writeValue(server, pointInfo, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Opc Da Server
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param driverInfo Driver Info
|
||||
* @param deviceId 设备ID
|
||||
* @param driverInfo 驱动信息
|
||||
* @return Server
|
||||
* @throws JIException JIException
|
||||
* @throws UnknownHostException UnknownHostException
|
||||
*/
|
||||
private Server getServer(String deviceId, Map<String, AttributeInfo> driverInfo) throws JIException, UnknownHostException {
|
||||
Server server = serverMap.get(deviceId);
|
||||
private Server getConnector(String deviceId, Map<String, AttributeInfo> driverInfo) {
|
||||
log.debug("Opc Da Server Connection Info {}", JsonUtil.toJsonString(driverInfo));
|
||||
Server server = connectMap.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 {}", JsonUtil.toJsonString(connectionInformation));
|
||||
String host = attribute(driverInfo, "host");
|
||||
String clsId = attribute(driverInfo, "clsId");
|
||||
String user = attribute(driverInfo, "username");
|
||||
String password = attribute(driverInfo, "password");
|
||||
ConnectionInformation connectionInformation = new ConnectionInformation(host, clsId, user, password);
|
||||
server = new Server(connectionInformation, Executors.newSingleThreadScheduledExecutor());
|
||||
try {
|
||||
server.connect();
|
||||
connectMap.put(deviceId, server);
|
||||
} catch (AlreadyConnectedException | UnknownHostException | JIException e) {
|
||||
connectMap.entrySet().removeIf(next -> next.getKey().equals(deviceId));
|
||||
log.error("Connect opc da server error: {}", e.getMessage(), e);
|
||||
throw new ConnectorException(e.getMessage());
|
||||
}
|
||||
}
|
||||
try {
|
||||
server.connect();
|
||||
} catch (AlreadyConnectedException ignored) {
|
||||
// nothing to do
|
||||
}
|
||||
serverMap.put(deviceId, server);
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -155,6 +153,25 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
return group.addItem(attribute(pointInfo, "tag"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 OpcDa 值
|
||||
*
|
||||
* @param server OpcDa Server
|
||||
* @param pointInfo 位号信息
|
||||
* @return Item Value
|
||||
*/
|
||||
private String readValue(Server server, Map<String, AttributeInfo> pointInfo) {
|
||||
try {
|
||||
Item item = getItem(server, pointInfo);
|
||||
return readItem(item);
|
||||
} catch (NotConnectedException | JIException | AddFailedException | DuplicateGroupException |
|
||||
UnknownHostException e) {
|
||||
server.dispose();
|
||||
log.error("Read opc da value error: {}", e.getMessage(), e);
|
||||
throw new ReadPointException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取 Opc Da 位号值
|
||||
*
|
||||
@@ -190,46 +207,63 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入 OpcDa 值
|
||||
*
|
||||
* @param server OpcDa Server
|
||||
* @param pointInfo 位号信息
|
||||
* @param value 写入值
|
||||
* @return 是否写入
|
||||
*/
|
||||
private boolean writeValue(Server server, Map<String, AttributeInfo> pointInfo, AttributeInfo value) {
|
||||
try {
|
||||
Item item = getItem(server, pointInfo);
|
||||
return writeItem(item, value);
|
||||
} catch (NotConnectedException | AddFailedException | DuplicateGroupException | UnknownHostException |
|
||||
JIException e) {
|
||||
server.dispose();
|
||||
log.error("Write opc da value error: {}", e.getMessage(), e);
|
||||
throw new WritePointException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Opc Da Item
|
||||
*
|
||||
* @param item OpcDa Item
|
||||
* @param type Value Type
|
||||
* @param value String Value
|
||||
* @param value 写入值
|
||||
* @throws JIException OpcDa JIException
|
||||
*/
|
||||
private void writeItem(Item item, String type, String value) throws JIException {
|
||||
int writeResult = 0;
|
||||
|
||||
PointValueTypeEnum valueType = PointValueTypeEnum.of(type);
|
||||
private boolean writeItem(Item item, AttributeInfo value) throws JIException {
|
||||
PointValueTypeEnum valueType = PointValueTypeEnum.of(value.getType());
|
||||
if (ObjectUtil.isNull(valueType)) {
|
||||
throw new IllegalArgumentException("Unsupported type of " + type);
|
||||
throw new IllegalArgumentException("Unsupported type of " + value.getType());
|
||||
}
|
||||
|
||||
// TODO 需要为每个驱动定制自己的数据类型列表,而不是公用一个数据列表,这样很不合理
|
||||
int writeResult = 0;
|
||||
switch (valueType) {
|
||||
case SHORT:
|
||||
short shortValue = value(type, value);
|
||||
short shortValue = DriverUtil.value(value.getType(), value.getValue());
|
||||
writeResult = item.write(new JIVariant(shortValue, false));
|
||||
break;
|
||||
case INT:
|
||||
int intValue = value(type, value);
|
||||
int intValue = DriverUtil.value(value.getType(), value.getValue());
|
||||
writeResult = item.write(new JIVariant(intValue, false));
|
||||
break;
|
||||
case LONG:
|
||||
long longValue = value(type, value);
|
||||
long longValue = DriverUtil.value(value.getType(), value.getValue());
|
||||
writeResult = item.write(new JIVariant(longValue, false));
|
||||
break;
|
||||
case FLOAT:
|
||||
float floatValue = value(type, value);
|
||||
float floatValue = DriverUtil.value(value.getType(), value.getValue());
|
||||
writeResult = item.write(new JIVariant(floatValue, false));
|
||||
break;
|
||||
case DOUBLE:
|
||||
double doubleValue = value(type, value);
|
||||
double doubleValue = DriverUtil.value(value.getType(), value.getValue());
|
||||
writeResult = item.write(new JIVariant(doubleValue, false));
|
||||
break;
|
||||
case BOOLEAN:
|
||||
boolean booleanValue = value(type, value);
|
||||
boolean booleanValue = DriverUtil.value(value.getType(), value.getValue());
|
||||
writeResult = item.write(new JIVariant(booleanValue, false));
|
||||
break;
|
||||
case STRING:
|
||||
@@ -238,7 +272,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
log.debug("OpcDa write item result code: {}", writeResult);
|
||||
return writeResult > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+163
-118
@@ -18,27 +18,29 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import io.github.pnoker.common.bean.driver.AttributeInfo;
|
||||
import io.github.pnoker.common.enums.PointValueTypeEnum;
|
||||
import io.github.pnoker.common.enums.StatusEnum;
|
||||
import io.github.pnoker.common.exception.ConnectorException;
|
||||
import io.github.pnoker.common.exception.ReadPointException;
|
||||
import io.github.pnoker.common.exception.WritePointException;
|
||||
import io.github.pnoker.common.model.Device;
|
||||
import io.github.pnoker.common.model.Point;
|
||||
import io.github.pnoker.common.sdk.bean.driver.DriverContext;
|
||||
import io.github.pnoker.common.sdk.service.DriverCustomService;
|
||||
import io.github.pnoker.common.sdk.service.DriverService;
|
||||
import io.github.pnoker.common.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
|
||||
import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider;
|
||||
import org.eclipse.milo.opcua.stack.core.UaException;
|
||||
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
|
||||
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
|
||||
import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode;
|
||||
import org.eclipse.milo.opcua.stack.core.types.builtin.Variant;
|
||||
import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import static io.github.pnoker.common.sdk.utils.DriverUtil.attribute;
|
||||
import static io.github.pnoker.common.sdk.utils.DriverUtil.value;
|
||||
@@ -57,137 +59,180 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
@Resource
|
||||
private DriverService driverService;
|
||||
|
||||
private Map<String, OpcUaClient> clientMap;
|
||||
private Map<String, OpcUaClient> connectMap;
|
||||
|
||||
@Override
|
||||
public void initial() {
|
||||
clientMap = new ConcurrentHashMap<>(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
int namespace = attribute(pointInfo, "namespace");
|
||||
String tag = attribute(pointInfo, "tag");
|
||||
|
||||
NodeId nodeId = new NodeId(namespace, tag);
|
||||
CompletableFuture<String> value = new CompletableFuture<>();
|
||||
OpcUaClient client = getOpcUaClient(device.getId(), driverInfo);
|
||||
|
||||
client.connect().get();
|
||||
client.readValue(0.0, TimestampsToReturn.Both, nodeId).thenAccept(dataValue -> {
|
||||
try {
|
||||
value.complete(dataValue.getValue().getValue().toString());
|
||||
} catch (Exception e) {
|
||||
log.error("accept point(ns={};s={}) value error: {}", namespace, tag, e.getMessage());
|
||||
}
|
||||
});
|
||||
String rawValue = value.get(1, TimeUnit.SECONDS);
|
||||
log.debug("read point(ns={};s={}) value: {}", namespace, tag, rawValue);
|
||||
return rawValue;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception {
|
||||
writeItem(device.getId(), driverInfo, pointInfo, value);
|
||||
return true;
|
||||
/*
|
||||
TODO: 仅供参考
|
||||
可自定义实现
|
||||
*/
|
||||
connectMap = new ConcurrentHashMap<>(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void schedule() {
|
||||
/*
|
||||
TODO:设备状态
|
||||
上传设备状态,可自行灵活拓展,不一定非要在schedule()接口中实现,也可以在read中实现设备状态的设置;
|
||||
你可以通过某种判断机制确定设备的状态,然后通过driverService.deviceEventSender接口将设备状态交给SDK管理。
|
||||
|
||||
设备状态(StatusEnum)如下:
|
||||
ONLINE:在线
|
||||
OFFLINE:离线
|
||||
MAINTAIN:维护
|
||||
FAULT:故障
|
||||
*/
|
||||
driverContext.getDriverMetadata().getDeviceMap().keySet().forEach(id -> driverService.deviceStatusSender(id, StatusEnum.ONLINE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Opc Ua Client
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param driverInfo Driver Info
|
||||
* @return OpcUaClient
|
||||
*/
|
||||
private OpcUaClient getOpcUaClient(String deviceId, Map<String, AttributeInfo> driverInfo) {
|
||||
OpcUaClient opcUaClient = clientMap.get(deviceId);
|
||||
if (null == opcUaClient) {
|
||||
try {
|
||||
opcUaClient = OpcUaClient.create(
|
||||
String.format("opc.tcp://%s:%s%s",
|
||||
attribute(driverInfo, "host"),
|
||||
attribute(driverInfo, "port"),
|
||||
attribute(driverInfo, "path")
|
||||
),
|
||||
endpoints -> endpoints.stream().findFirst(),
|
||||
configBuilder -> configBuilder
|
||||
.setIdentityProvider(new AnonymousProvider())
|
||||
.setRequestTimeout(uint(5000))
|
||||
.build()
|
||||
);
|
||||
clientMap.put(deviceId, opcUaClient);
|
||||
} catch (UaException e) {
|
||||
log.error("get opc ua client error: {}", e.getMessage());
|
||||
clientMap.entrySet().removeIf(next -> next.getKey().equals(deviceId));
|
||||
}
|
||||
}
|
||||
return clientMap.get(deviceId);
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
OpcUaClient client = getConnector(device.getId(), driverInfo);
|
||||
return readValue(client, pointInfo);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) {
|
||||
OpcUaClient client = getConnector(device.getId(), driverInfo);
|
||||
return writeValue(client, pointInfo, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Opc Ua Point Value
|
||||
* 获取 Opc Ua Client
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param driverInfo Driver Info
|
||||
* @param pointInfo Point Info
|
||||
* @param values Value Array
|
||||
* @param deviceId 设备ID
|
||||
* @param driverInfo 驱动信息
|
||||
* @return OpcUaClient
|
||||
*/
|
||||
private void writeItem(String deviceId, Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, AttributeInfo values) {
|
||||
OpcUaClient client;
|
||||
try {
|
||||
int namespace = attribute(pointInfo, "namespace");
|
||||
String tag = attribute(pointInfo, "tag");
|
||||
String type = values.getType();
|
||||
String value = values.getValue();
|
||||
|
||||
PointValueTypeEnum valueType = PointValueTypeEnum.of(type);
|
||||
if (ObjectUtil.isNull(valueType)) {
|
||||
throw new IllegalArgumentException("Unsupported type of " + type);
|
||||
private OpcUaClient getConnector(String deviceId, Map<String, AttributeInfo> driverInfo) {
|
||||
log.debug("Opc Ua Server Connection Info {}", JsonUtil.toJsonString(driverInfo));
|
||||
OpcUaClient opcUaClient = connectMap.get(deviceId);
|
||||
if (null == opcUaClient) {
|
||||
String host = attribute(driverInfo, "host");
|
||||
String port = attribute(driverInfo, "port");
|
||||
String path = attribute(driverInfo, "path");
|
||||
String url = String.format("opc.tcp://%s:%s%s", host, port, path);
|
||||
try {
|
||||
opcUaClient = OpcUaClient.create(url, endpoints -> endpoints.stream().findFirst(), configBuilder -> configBuilder.setIdentityProvider(new AnonymousProvider()).setRequestTimeout(uint(5000)).build());
|
||||
connectMap.put(deviceId, opcUaClient);
|
||||
} catch (UaException e) {
|
||||
connectMap.entrySet().removeIf(next -> next.getKey().equals(deviceId));
|
||||
log.error("Connect opc ua client error: {}", e.getMessage(), e);
|
||||
throw new ConnectorException(e.getMessage());
|
||||
}
|
||||
|
||||
NodeId nodeId = new NodeId(namespace, tag);
|
||||
client = getOpcUaClient(deviceId, driverInfo);
|
||||
client.connect().get();
|
||||
|
||||
switch (valueType) {
|
||||
case INT:
|
||||
int intValue = value(type, value);
|
||||
client.writeValue(nodeId, new DataValue(new Variant(intValue)));
|
||||
break;
|
||||
case LONG:
|
||||
long longValue = value(type, value);
|
||||
client.writeValue(nodeId, new DataValue(new Variant(longValue)));
|
||||
break;
|
||||
case FLOAT:
|
||||
float floatValue = value(type, value);
|
||||
client.writeValue(nodeId, new DataValue(new Variant(floatValue)));
|
||||
break;
|
||||
case DOUBLE:
|
||||
double doubleValue = value(type, value);
|
||||
client.writeValue(nodeId, new DataValue(new Variant(doubleValue)));
|
||||
break;
|
||||
case BOOLEAN:
|
||||
boolean booleanValue = value(type, value);
|
||||
client.writeValue(nodeId, new DataValue(new Variant(booleanValue)));
|
||||
break;
|
||||
case STRING:
|
||||
client.writeValue(nodeId, new DataValue(new Variant(value)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Opc Ua Point Write Error: {}", e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (ExecutionException e) {
|
||||
log.error("Opc Ua Point Write Error: {}", e.getMessage());
|
||||
}
|
||||
return opcUaClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Opc Ua Item
|
||||
*
|
||||
* @param pointInfo 位号信息
|
||||
* @return OpcUa Node
|
||||
*/
|
||||
private NodeId getNode(Map<String, AttributeInfo> pointInfo) {
|
||||
int namespace = attribute(pointInfo, "namespace");
|
||||
String tag = attribute(pointInfo, "tag");
|
||||
return new NodeId(namespace, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 OpcUa 值
|
||||
*
|
||||
* @param client OpcUaClient
|
||||
* @param pointInfo 位号信息
|
||||
* @return Node Value
|
||||
*/
|
||||
private String readValue(OpcUaClient client, Map<String, AttributeInfo> pointInfo) {
|
||||
try {
|
||||
NodeId nodeId = getNode(pointInfo);
|
||||
client.connect().get();
|
||||
CompletableFuture<String> value = new CompletableFuture<>();
|
||||
client.readValue(0.0, TimestampsToReturn.Both, nodeId).thenAccept(dataValue -> value.complete(dataValue.getValue().getValue().toString()));
|
||||
return value.get(1, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Read opc ua value error: {}", e.getMessage(), e);
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ReadPointException(e.getMessage());
|
||||
} catch (ExecutionException | TimeoutException e) {
|
||||
log.error("Read opc ua value error: {}", e.getMessage(), e);
|
||||
throw new ReadPointException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入 OpcUa 值
|
||||
*
|
||||
* @param pointInfo 位号信息
|
||||
* @param value 写入值
|
||||
*/
|
||||
private boolean writeValue(OpcUaClient client, Map<String, AttributeInfo> pointInfo, AttributeInfo value) {
|
||||
try {
|
||||
NodeId nodeId = getNode(pointInfo);
|
||||
|
||||
client.connect().get();
|
||||
return writeNode(client, nodeId, value);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Write opc ua value error: {}", e.getMessage(), e);
|
||||
Thread.currentThread().interrupt();
|
||||
throw new WritePointException(e.getMessage());
|
||||
} catch (ExecutionException e) {
|
||||
log.error("Write opc ua value error: {}", e.getMessage(), e);
|
||||
throw new WritePointException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Opc Ua Node
|
||||
*
|
||||
* @param client OpcUaClient
|
||||
* @param nodeId OpcUa Node
|
||||
* @param value 写入值
|
||||
* @return 是否写入
|
||||
* @throws ExecutionException ExecutionException
|
||||
* @throws InterruptedException InterruptedException
|
||||
*/
|
||||
private boolean writeNode(OpcUaClient client, NodeId nodeId, AttributeInfo value) throws ExecutionException, InterruptedException {
|
||||
PointValueTypeEnum valueType = PointValueTypeEnum.of(value.getType());
|
||||
if (ObjectUtil.isNull(valueType)) {
|
||||
throw new IllegalArgumentException("Unsupported type of " + value.getType());
|
||||
}
|
||||
|
||||
CompletableFuture<StatusCode> status = new CompletableFuture<>();
|
||||
switch (valueType) {
|
||||
case INT:
|
||||
int intValue = value(value.getType(), value.getValue());
|
||||
status = client.writeValue(nodeId, new DataValue(new Variant(intValue)));
|
||||
break;
|
||||
case LONG:
|
||||
long longValue = value(value.getType(), value.getValue());
|
||||
status = client.writeValue(nodeId, new DataValue(new Variant(longValue)));
|
||||
break;
|
||||
case FLOAT:
|
||||
float floatValue = value(value.getType(), value.getValue());
|
||||
status = client.writeValue(nodeId, new DataValue(new Variant(floatValue)));
|
||||
break;
|
||||
case DOUBLE:
|
||||
double doubleValue = value(value.getType(), value.getValue());
|
||||
status = client.writeValue(nodeId, new DataValue(new Variant(doubleValue)));
|
||||
break;
|
||||
case BOOLEAN:
|
||||
boolean booleanValue = value(value.getType(), value.getValue());
|
||||
status = client.writeValue(nodeId, new DataValue(new Variant(booleanValue)));
|
||||
break;
|
||||
case STRING:
|
||||
status = client.writeValue(nodeId, new DataValue(new Variant(value.getValue())));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (null != status && null != status.get()) {
|
||||
return status.get().getValue() > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -73,7 +73,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
log.debug("Plc S7 Read, device: {}, point: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(point));
|
||||
MyS7Connector myS7Connector = getS7Connector(device.getId(), driverInfo);
|
||||
myS7Connector.lock.writeLock().lock();
|
||||
@@ -91,7 +91,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception {
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) {
|
||||
log.debug("Plc S7 Write, device: {}, value: {}", JsonUtil.toJsonString(device), JsonUtil.toJsonString(value));
|
||||
MyS7Connector myS7Connector = getS7Connector(device.getId(), driverInfo);
|
||||
myS7Connector.lock.writeLock().lock();
|
||||
@@ -130,7 +130,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
* 获取 plcs7 serializer
|
||||
* 先从缓存中取,没有就新建
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param deviceId 设备ID
|
||||
* @param driverInfo DeviceInfo Map
|
||||
* @return S7Serializer
|
||||
*/
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) throws Exception {
|
||||
public String read(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, Point point) {
|
||||
if (point.getType().equals("string")) {
|
||||
return RandomUtil.randomString(8);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class DriverCustomServiceImpl implements DriverCustomService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) throws Exception {
|
||||
public Boolean write(Map<String, AttributeInfo> driverInfo, Map<String, AttributeInfo> pointInfo, Device device, AttributeInfo value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -79,10 +79,10 @@ services:
|
||||
image: registry.cn-beijing.aliyuncs.com/dc3/dc3-center-auth:demo
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -109,10 +109,10 @@ services:
|
||||
image: registry.cn-beijing.aliyuncs.com/dc3/dc3-center-manager:demo
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -150,10 +150,10 @@ services:
|
||||
image: registry.cn-beijing.aliyuncs.com/dc3/dc3-center-data:demo
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
|
||||
+12
-12
@@ -100,10 +100,10 @@ services:
|
||||
image: registry.cn-beijing.aliyuncs.com/dc3/dc3-center-auth:demo
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -133,10 +133,10 @@ services:
|
||||
image: registry.cn-beijing.aliyuncs.com/dc3/dc3-center-manager:demo
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -177,10 +177,10 @@ services:
|
||||
image: registry.cn-beijing.aliyuncs.com/dc3/dc3-center-data:demo
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
|
||||
+16
-16
@@ -118,10 +118,10 @@ services:
|
||||
- 8300:8300
|
||||
environment:
|
||||
- NODE_ENV=prod
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -154,10 +154,10 @@ services:
|
||||
- 8400:8400
|
||||
environment:
|
||||
- NODE_ENV=prod
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -201,10 +201,10 @@ services:
|
||||
- 8500:8500
|
||||
environment:
|
||||
- NODE_ENV=prod
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -512,10 +512,10 @@ services:
|
||||
- 8803:8803
|
||||
environment:
|
||||
- NODE_ENV=prod
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
|
||||
+16
-16
@@ -118,10 +118,10 @@ services:
|
||||
- 8300:8300
|
||||
environment:
|
||||
- NODE_ENV=test
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -154,10 +154,10 @@ services:
|
||||
- 8400:8400
|
||||
environment:
|
||||
- NODE_ENV=test
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -201,10 +201,10 @@ services:
|
||||
- 8500:8500
|
||||
environment:
|
||||
- NODE_ENV=test
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -512,10 +512,10 @@ services:
|
||||
- 8803:8803
|
||||
environment:
|
||||
- NODE_ENV=test
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
|
||||
+16
-16
@@ -118,10 +118,10 @@ services:
|
||||
- 8300:8300
|
||||
environment:
|
||||
- NODE_ENV=dev
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -154,10 +154,10 @@ services:
|
||||
- 8400:8400
|
||||
environment:
|
||||
- NODE_ENV=dev
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -201,10 +201,10 @@ services:
|
||||
- 8500:8500
|
||||
environment:
|
||||
- NODE_ENV=dev
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
@@ -512,10 +512,10 @@ services:
|
||||
- 8803:8803
|
||||
environment:
|
||||
- NODE_ENV=dev
|
||||
- MYSQL_HOST=dc3-mysql
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_USERNAME=root
|
||||
- MYSQL_PASSWORD=dc3
|
||||
- DB_HOST=dc3-mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=dc3
|
||||
- REDIS_HOST=dc3-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=dc3
|
||||
|
||||
@@ -16,11 +16,24 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<parent>
|
||||
<artifactId>dc3-parent</artifactId>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<version>2022.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>iot-dc3</artifactId>
|
||||
<version>2022.1.0</version>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<inceptionYear>2016-2022</inceptionYear>
|
||||
<url>https://github.com/pnoker/iot-dc3</url>
|
||||
<description>
|
||||
IOT-DC3 可分布式的物联网(IOT)平台 , 基于开源Spring Cloud框架搭建,实现设备互联、管理、数据采集、代码生成、快速开发和可视化等,
|
||||
兼容多种流行的物联网数据接入协议(Mqtt\Socket\Modbus-Tcp\Rtsp\Rtmp\Siemens PLC
|
||||
S7\OpcUa\OpcDa...),是一整套完整的物联系统解决方案。
|
||||
</description>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>pnoker</id>
|
||||
@@ -33,68 +46,11 @@
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<url>https://github.com/pnoker/iot-dc3</url>
|
||||
<inceptionYear>2016-2022</inceptionYear>
|
||||
<description>
|
||||
IOT-DC3 可分布式的物联网(IOT)平台 , 基于开源Spring Cloud框架搭建,实现设备互联、管理、数据采集、代码生成、快速开发和可视化等,
|
||||
兼容多种流行的物联网数据接入协议(Mqtt\Socket\Modbus-Tcp\Rtsp\Rtmp\Siemens PLC
|
||||
S7\OpcUa\OpcDa...),是一整套完整的物联系统解决方案。
|
||||
</description>
|
||||
|
||||
<modules>
|
||||
<module>dc3-gateway</module>
|
||||
<module>dc3-center</module>
|
||||
<module>dc3-driver</module>
|
||||
<module>dc3-api</module>
|
||||
<module>dc3-common</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<!-- Spring 相关-->
|
||||
<spring-boot.version>2.7.4</spring-boot.version>
|
||||
<spring-cloud.version>2021.0.4</spring-cloud.version>
|
||||
|
||||
<!-- 其他依赖-->
|
||||
<spring-boot-admin.version>2.7.4</spring-boot-admin.version>
|
||||
<spring-oauth2.version>2.5.2.RELEASE</spring-oauth2.version>
|
||||
<spring-data-mongodb.version>3.4.6</spring-data-mongodb.version>
|
||||
<commons-fileupload.version>1.4</commons-fileupload.version>
|
||||
<mybatis.plus.version>3.5.2</mybatis.plus.version>
|
||||
<jackson.version>2.14.1</jackson.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<jna.version>5.12.1</jna.version>
|
||||
<oshi.version>6.3.2</oshi.version>
|
||||
<jaxb.api.version>2.3.1</jaxb.api.version>
|
||||
<jaxb.version>3.0.2</jaxb.version>
|
||||
<activation.version>1.1.1</activation.version>
|
||||
<milo.version>0.6.8</milo.version>
|
||||
<modbus.version>3.1.0</modbus.version>
|
||||
<netty.version>4.1.85.Final</netty.version>
|
||||
<j.interop.version>2.0.4</j.interop.version>
|
||||
<bouncycastle.version>1.46</bouncycastle.version>
|
||||
<paho.mqttv3.version>1.2.5</paho.mqttv3.version>
|
||||
<elasticsearch.version>7.17.7</elasticsearch.version>
|
||||
<jakarta.version>2.1.1</jakarta.version>
|
||||
<guava.version>31.1-jre</guava.version>
|
||||
<hutool.version>5.8.10</hutool.version>
|
||||
|
||||
<!-- Plugin 相关 -->
|
||||
<maven.gpg.plugin>3.0.1</maven.gpg.plugin>
|
||||
<maven.source.plugin>3.2.1</maven.source.plugin>
|
||||
<maven.javadoc.plugin>3.4.1</maven.javadoc.plugin>
|
||||
<maven.compiler.plugin>3.10.1</maven.compiler.plugin>
|
||||
<maven.resource.plugin>3.1.0</maven.resource.plugin>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
@@ -121,477 +77,12 @@
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Spring Configuration-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Spring Cloud 依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Admin -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--Spring Security OAuth2-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security.oauth</groupId>
|
||||
<artifactId>spring-security-oauth2</artifactId>
|
||||
<version>${spring-oauth2.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mybatis Plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis.plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>${mybatis.plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Data MongoDB -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb</artifactId>
|
||||
<version>${spring-data-mongodb.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.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>
|
||||
|
||||
<!--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>
|
||||
|
||||
<!-- Elasticsearch 相关 -->
|
||||
<dependency>
|
||||
<groupId>co.elastic.clients</groupId>
|
||||
<artifactId>elasticsearch-java</artifactId>
|
||||
<version>${elasticsearch.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.json</groupId>
|
||||
<artifactId>jakarta.json-api</artifactId>
|
||||
<version>${jakarta.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mqtt 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>${paho.mqttv3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- File Upload -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons-fileupload.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>
|
||||
|
||||
<!-- Dc3 Api -->
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-api-auth</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-api-manager</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-api-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-api-rtmp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-api-driver</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Dc3 Driver Sdk -->
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-common-sdk</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Dc3 Common -->
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-common-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-common-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.pnoker</groupId>
|
||||
<artifactId>dc3-common-profiles</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>Aliyun Public Repository</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring</id>
|
||||
<name>Aliyun Spring Repository</name>
|
||||
<url>https://maven.aliyun.com/repository/spring</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>public-plugin</id>
|
||||
<name>Aliyun Public Plugin Repository</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
|
||||
<pluginRepository>
|
||||
<id>spring-plugin</id>
|
||||
<name>Aliyun Spring Plugin Repository</name>
|
||||
<url>https://maven.aliyun.com/repository/spring-plugin</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>pnoker</id>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>pnoker</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<finalName>${project.build.finalName}</finalName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 编译插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.compiler.plugin}</version>
|
||||
<configuration>
|
||||
<target>${java.version}</target>
|
||||
<source>${java.version}</source>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- GPG 插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>${maven.gpg.plugin}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<keyname>pnoker</keyname>
|
||||
<passphraseServerId>pnoker</passphraseServerId>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 源码插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${maven.source.plugin}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 文档插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${maven.javadoc.plugin}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 过滤文件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.resource.plugin}</version>
|
||||
<configuration>
|
||||
<nonFilteredFileExtensions>
|
||||
<nonFilteredFileExtension>ico</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>db</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>key</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>crt</nonFilteredFileExtension>
|
||||
</nonFilteredFileExtensions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<modules>
|
||||
<module>dc3-gateway</module>
|
||||
<module>dc3-center</module>
|
||||
<module>dc3-driver</module>
|
||||
<module>dc3-api</module>
|
||||
<module>dc3-common</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user