同步锦浪云模块

This commit is contained in:
2025-08-28 16:20:23 +08:00
parent 563588b835
commit 1bc2743dc7
14 changed files with 537 additions and 38 deletions

View File

@ -0,0 +1,23 @@
package org.dromara.synjinlangyun;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
/**
* 同步锦浪云模块
*
* @author ruoyi
*/
@EnableDubbo
@SpringBootApplication
public class RuoYiSynjinlangyunApplication {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(RuoYiSynjinlangyunApplication.class);
application.setApplicationStartup(new BufferingApplicationStartup(2048));
application.run(args);
System.out.println("(♥◠‿◠)ノ゙ 同步锦浪云模块启动成功 ლ(´ڡ`ლ)゙ ");
}
}

View File

@ -0,0 +1,58 @@
package org.dromara.synjinlangyun.client;
import org.dromara.synjinlangyun.listener.J60870ClientListener;
import org.openmuc.j60870.ClientConnectionBuilder;
import org.openmuc.j60870.Connection;
import java.io.IOException;
import java.net.InetAddress;
public class J60870Client implements Runnable {
//监听类
private J60870ClientListener listener;
//连接类
private Connection connection;
//连接参数
private ClientConnectionBuilder clientConnectionBuilder;
public J60870Client() throws IOException{
try {
//获取server对象从站的IP地址对象
InetAddress address = InetAddress.getByName("127.0.0.1");
//创建连接参数对象
clientConnectionBuilder = new ClientConnectionBuilder(address);
//设置socket的连接超时时间
clientConnectionBuilder.setConnectionTimeout(60000);
}catch (Exception e){
e.printStackTrace();
}
}
@Override
public void run() {
try {
//主站与从站连接
connection = clientConnectionBuilder.build();
//配置数据回调类
listener = new J60870ClientListener();
connection.startDataTransfer(listener);
}catch (Exception e){
e.printStackTrace();
}
}
//关闭连接
public void disconnect(){
try {
this.connection.close();
}catch (Exception e){
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,21 @@
package org.dromara.synjinlangyun.listener;
import org.openmuc.j60870.ASdu;
import org.openmuc.j60870.ConnectionEventListener;
import java.io.IOException;
public class J60870ClientListener implements ConnectionEventListener {
//监听从站发来的数据
@Override
public void newASdu(ASdu aSdu) {
System.out.println(aSdu.toString());
}
//监听连接关闭
@Override
public void connectionClosed(IOException e) {
e.printStackTrace();
}
}

View File

@ -0,0 +1,34 @@
# Tomcat
server:
port: 9202
# Spring
spring:
application:
# 应用名称
name: ruoyi-synjinlangyun
profiles:
# 环境配置
active: @profiles.active@
--- # nacos 配置
spring:
cloud:
nacos:
# nacos 服务地址
server-addr: @nacos.server@
username: @nacos.username@
password: @nacos.password@
discovery:
# 注册组
group: @nacos.discovery.group@
namespace: ${spring.profiles.active}
config:
# 配置组
group: @nacos.config.group@
namespace: ${spring.profiles.active}
config:
import:
- optional:nacos:application-common.yml
- optional:nacos:datasource.yml
- optional:nacos:${spring.application.name}.yml

View File

@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
__/ | __/ |
|___/ |___/

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/${project.artifactId}" />
<!-- 日志输出格式 -->
<property name="console.log.pattern"
value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${console.log.pattern}</pattern>
<charset>utf-8</charset>
</encoder>
</appender>
<include resource="logback-common.xml" />
<include resource="logback-logstash.xml" />
<!-- 开启 skywalking 日志收集 -->
<include resource="logback-skylog.xml" />
<!--系统操作日志-->
<root level="info">
<appender-ref ref="console" />
</root>
</configuration>