Эх сурвалжийг харах

ice104 module-增加
1:服务端未启动,保持一直重连
2:连接过冲中,中断,保持一直重连
3:优化单例工厂,确保每次线程启动的是同一个连接线路。否则多个线程开启的是多个连接线路,无法监控

hfxc226 2 жил өмнө
parent
commit
646907d228

+ 44 - 46
platform-dao/src/main/resources/mapper/remote/RemoteDegreeLogMapper.xml

@@ -2,97 +2,95 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.platform.dao.mapper.remote.RemoteDegreeLogMapper">
     <sql id="Base_Column_List">
-        degree
-        -log.id,
-                                     degree-log.sb_id,
-                                     degree-log.sb_name,
-                                     degree-log.position_num,
-                                     degree-log.type,
-                                     degree-log.description,
-                                     degree-log.result,
-                                     degree-log.ratio,
-                                     degree-log.unit,
-                                     degree-log.remark,
-                                     degree-log.created_user_id,
-                                     degree-log.update_user_id,
-                                     degree-log.created_time,
-                                     degree-log.update_time
+        degree_log.id,
+                                     degree_log.sb_id,
+                                     degree_log.sb_name,
+                                     degree_log.position_num,
+                                     degree_log.type,
+                                     degree_log.description,
+                                     degree_log.result,
+                                     degree_log.ratio,
+                                     degree_log.unit,
+                                     degree_log.remark,
+                                     degree_log.created_user_id,
+                                     degree_log.update_user_id,
+                                     degree_log.created_time,
+                                     degree_log.update_time
     </sql>
     <sql id="Ref_Column_List">
-        degree
-        -log.sb_id,
-                                     degree-log.sb_name,
-                                     degree-log.position_num,
-                                     degree-log.type,
-                                     degree-log.description,
-                                     degree-log.result,
-                                     degree-log.ratio,
-                                     degree-log.unit,
-                                     degree-log.remark,
+        degree_log.sb_id,
+                                     degree_log.sb_name,
+                                     degree_log.position_num,
+                                     degree_log.type,
+                                     degree_log.description,
+                                     degree_log.result,
+                                     degree_log.ratio,
+                                     degree_log.unit,
+                                     degree_log.remark,
     </sql>
     <sql id="List_Condition">
         <if test="id != null and id != ''">
-            and degree-log.id = #{id}
+            and degree_log.id = #{id}
         </if>
         <if test="sbId != null and sbId != ''">
-            and degree-log.sb_id = #{sbId}
+            and degree_log.sb_id = #{sbId}
         </if>
         <if test="sbName != null and sbName != ''">
-            and degree-log.sb_name = #{sbName}
+            and degree_log.sb_name = #{sbName}
         </if>
         <if test="positionNum != null">
-            and degree-log.position_num = #{positionNum}
+            and degree_log.position_num = #{positionNum}
         </if>
         <if test="type != null">
-            and degree-log.type = #{type}
+            and degree_log.type = #{type}
         </if>
         <if test="description != null and description != ''">
-            and degree-log.description = #{description}
+            and degree_log.description = #{description}
         </if>
         <if test="result != null and result != ''">
-            and degree-log.result = #{result}
+            and degree_log.result = #{result}
         </if>
         <if test="ratio != null">
-            and degree-log.ratio = #{ratio}
+            and degree_log.ratio = #{ratio}
         </if>
         <if test="unit != null and unit != ''">
-            and degree-log.unit = #{unit}
+            and degree_log.unit = #{unit}
         </if>
         <if test="remark != null and remark != ''">
-            and degree-log.remark = #{remark}
+            and degree_log.remark = #{remark}
         </if>
         <if test="createdUserId != null and createdUserId != ''">
-            and degree-log.created_user_id = #{createdUserId}
+            and degree_log.created_user_id = #{createdUserId}
         </if>
         <if test="updateUserId != null and updateUserId != ''">
-            and degree-log.update_user_id = #{updateUserId}
+            and degree_log.update_user_id = #{updateUserId}
         </if>
         <if test="createdTimeStart != null">
-            and degree-log.created_time <![CDATA[>=]]>; #{createdTimeStart}
+            and degree_log.created_time <![CDATA[>=]]>; #{createdTimeStart}
         </if>
         <if test="createdTimeEnd != null">
-            and degree-log.created_time <![CDATA[<=]]> #{createdTimeEnd}
+            and degree_log.created_time <![CDATA[<=]]> #{createdTimeEnd}
         </if>
         <if test="createdTime != null">
-            and degree-log.created_time = #{createdTime}
+            and degree_log.created_time = #{createdTime}
         </if>
         <if test="updateTimeStart != null">
-            and degree-log.update_time <![CDATA[>=]]>; #{updateTimeStart}
+            and degree_log.update_time <![CDATA[>=]]>; #{updateTimeStart}
         </if>
         <if test="updateTimeEnd != null">
-            and degree-log.update_time <![CDATA[<=]]> #{updateTimeEnd}
+            and degree_log.update_time <![CDATA[<=]]> #{updateTimeEnd}
         </if>
         <if test="updateTime != null">
-            and degree-log.update_time = #{updateTime}
+            and degree_log.update_time = #{updateTime}
         </if>
         <if test="keyword != null and keyword != ''">
-            and degree-log.id like concat(concat('%',#{keyword}),'%')
+            and degree_log.id like concat(concat('%',#{keyword}),'%')
         </if>
     </sql>
     <select id="selectList" parameterType="com.platform.dao.dto.remote.RemoteDegreeLogDTO"
             resultType="com.platform.dao.vo.query.remote.RemoteDegreeLogVO">
-        select degree-log.*
-        from t_remote_degree_log as degree-log
+        select degree_log.*
+        from t_remote_degree_log as degree_log
         <where>
             <include refid="List_Condition"/>
         </where>

+ 28 - 0
platform-iec/src/main/java/com/ydl/iec/iec104/server/master/ConnectionListener.java

@@ -0,0 +1,28 @@
+package com.ydl.iec.iec104.server.master;
+
+import com.ydl.iec.iec104.server.Iec104MasterFactory;
+import com.ydl.iec.util.Iec104Util;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.EventLoop;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+public class ConnectionListener implements ChannelFutureListener {
+
+    @Override
+    public void operationComplete(ChannelFuture channelFuture) {
+        if (!channelFuture.isSuccess()) {
+            log.error("服务端链接不上,开始重连操作...");
+            final EventLoop loop = channelFuture.channel().eventLoop();
+            loop.schedule(() -> {
+                log.error("服务端链接不上,开始重连操作...");
+                Iec104MasterFactory.createTcpClientMaster(Iec104Util.host, Iec104Util.port).run();
+            }, 5, TimeUnit.SECONDS);
+        } else {
+            log.info("服务端链接成功...");
+        }
+    }
+}