Browse Source

1.HDSDK代码优化
2.大屏代码优化

wangxiaofei 1 week ago
parent
commit
6f207cf4d4

+ 10 - 10
taphole-iron/src/main/java/com/sckj/iron/constant/L1TagConstants.java

@@ -5,24 +5,24 @@ package com.sckj.iron.constant;
  */
 public class L1TagConstants {
     //1号出铁状态标记
-    public static final String TAG_TAPHOLE1_STATUS = "AOD25606.PV";
+    public static final String TAG_TAPHOLE1_STATUS = "BF4_1_IRONNOTCH_TAPPING";
     //2号出铁状态标记
-    public static final String TAG_TAPHOLE2_STATUS = "AOD25622.PV";
+    public static final String TAG_TAPHOLE2_STATUS = "BF4_2_IRONNOTCH_TAPPING";
     //3号出铁状态标记
-    public static final String TAG_TAPHOLE3_STATUS = "AOD25706.PV";
+    public static final String TAG_TAPHOLE3_STATUS = "BF4_3_IRONNOTCH_TAPPING";
     //4号出铁状态标记
-    public static final String TAG_TAPHOLE4_STATUS = "AOD25722.PV";
+    public static final String TAG_TAPHOLE4_STATUS = "BF4_4_IRONNOTCH_TAPPING";
     //铁水温度
-    public static final String TAG_IRON_TEMP = "CL510104.CPV";
+    public static final String TAG_IRON_TEMP = "BF4_1_IRONNOTCH_MIR_TEMP";
     //1TH-1号车受铁速度
-    public static final String TAG_CAR11 = "WZ540101.PV";
+    public static final String TAG_CAR11 = "BF4_1_IRONNOTCH_RAILLINE_ACPIRON_SPEED1";
     //1TH-2号车受铁速度
-    public static final String TAG_CAR12 = "WZ540201.PV";
+    public static final String TAG_CAR12 = "BF4_1_IRONNOTCH_RAILLINE_ACPIRON_SPEED2";
     //1TH-1号车总重
-    public static final String TAG_IRON_WEIGHT11 = "WI5401.PV";
+    public static final String TAG_IRON_WEIGHT11 = "BF4_1TH_1_TPC_TWT";
     //1TH-2号车TPC总重
-    public static final String TAG_IRON_WEIGHT12 = "WI5402.PV";
+    public static final String TAG_IRON_WEIGHT12 = "BF4_1TH_2_TPC_TWT";
     //冲渣状态
-    public static final String TAG_FLUSH_STATUS = "AOD25607.PV";
+    public static final String TAG_FLUSH_STATUS = "BF4_1TH_SLAG_TAPPING_SIGNAL";
 
 }

+ 26 - 33
taphole-iron/src/main/java/com/sckj/iron/socketio/DeviceEventListener.java

@@ -1,6 +1,5 @@
 package com.sckj.iron.socketio;
 
-import com.baosight.hdsdk.domain.data.HDRecord;
 import com.corundumstudio.socketio.SocketIOClient;
 import com.corundumstudio.socketio.annotation.OnEvent;
 import com.google.common.eventbus.Subscribe;
@@ -387,12 +386,10 @@ public class DeviceEventListener extends EventListener { //
 
     /***
      * IHD
-     * @param record
+     * @param opcData
      */
     @Subscribe
-    public void onMessageEvent(HDRecord record) {
-        OPCData opcData = OPCData.builder().data(record.getValueStr()).pointName(record.getBelongTagID() + "").serverTime(new Date(record.getSecond() * 1000)).build();
-
+    public void onMessageEvent(OPCData opcData) {
         //异步保存OPC数据
         taskExecutor.submit(() -> {
             opcDataService.save(opcData);
@@ -410,27 +407,27 @@ public class DeviceEventListener extends EventListener { //
     //出铁次数编号
     private String mIronNo;
 
-    /***
-     * L2数据项
-     * @param l2Data
-     */
-    @Subscribe
-    public void onL2DataMessageEvent(L2Data l2Data) {
-        if (ObjectUtils.isNotEmpty(l2Data.getIronNo())) {
-            //只要是新的出铁次数编号,后续都一直用这个编号,直到有新的出铁编号
-            mIronNo = l2Data.getIronNo();
-        }
-
-        taskExecutor.submit(() -> {
-            getIronTimeNo();
-        });
-
-
-        //推送实时数据
-        taskExecutor.submit(() -> {
-            setRealtimeDataAndStatus(null, l2Data);
-        });
-    }
+//    /***
+//     * L2数据项
+//     * @param l2Data
+//     */
+//    @Subscribe
+//    public void onL2DataMessageEvent(L2Data l2Data) {
+//        if (ObjectUtils.isNotEmpty(l2Data.getIronNo())) {
+//            //只要是新的出铁次数编号,后续都一直用这个编号,直到有新的出铁编号
+//            mIronNo = l2Data.getIronNo();
+//        }
+//
+//        taskExecutor.submit(() -> {
+//            getIronTimeNo();
+//        });
+//
+//
+//        //推送实时数据
+//        taskExecutor.submit(() -> {
+//            setRealtimeDataAndStatus(null, l2Data);
+//        });
+//    }
 
     /***
      * 记录出铁日期和次数,并返回给前端
@@ -958,13 +955,14 @@ public class DeviceEventListener extends EventListener { //
                 for (IronStepVO child : stepDTO.getChilds()) {
                     for (IronStepVO childchild : child.getChilds()) {
 
+
                         //plc的point和step的point一致
                         String newPointName = childchild.getPointName();
 
                         if (ObjectUtils.isEmpty(newPointName)) {
                             continue;
                         }
-                        newPointName = CustomUtil.createNewPointName(newPointName, activeProfiles);
+                        newPointName = CustomUtil.createNewPointName(newPointName, activeProfiles,mOPCData.getServerType());
                         if (Objects.equals(newPointName, pointName)) {
                             //3.创建变量上下文,设置变量
                             childchild.setData(data);
@@ -974,7 +972,7 @@ public class DeviceEventListener extends EventListener { //
                     if (ObjectUtils.isEmpty(newPointName)) {
                         continue;
                     }
-                    newPointName = CustomUtil.createNewPointName(newPointName, activeProfiles);
+                    newPointName = CustomUtil.createNewPointName(newPointName, activeProfiles,mOPCData.getServerType());
                     if (Objects.equals(newPointName, pointName)) {
                         child.setData(data);
                     }
@@ -1020,11 +1018,6 @@ public class DeviceEventListener extends EventListener { //
         if (!foundFalsePass && 0 == stepDTO.getPassResult()) {
             foundFalsePass = true;
         }
-//        if(Objects.equals(stepDTO.getIdentifier(),"yc")){
-//            double sfyl = Double.parseDouble(ObjectUtils.defaultIfNull(mContext.lookupVariable("sfyl"), "0").toString());
-//            double ldyl = Double.parseDouble(ObjectUtils.defaultIfNull(mContext.lookupVariable("ldyl"), "0").toString());
-//            stepDTO.setData(sfyl-ldyl);
-//        }
         //父项
         if (foundFalsePass) {
             stepDTO.setPassResult(0);

+ 2 - 3
taphole-opc/src/main/java/com/sckj/opc/controller/THdTagController.java

@@ -199,7 +199,7 @@ public class THdTagController {
     @ResponseBody
     @NotLogin
     @ApiOperation(value = "根据tagName刷新TagId")
-    public AjaxResult refreshTagIds(THdTag hdTag) {
+    public AjaxResult refreshTagIds() {
         try {
             hdService.refreshTagIds();
             return AjaxResult.success();
@@ -220,8 +220,7 @@ public class THdTagController {
     @ApiOperation(value = "根据Tag名称获取普通类型Tag对象")
     public AjaxResult getBasicTagByName(THdTag hdTag) {
         try {
-            hdService.getBasicTagByName(hdTag);
-            return AjaxResult.success();
+            return AjaxResult.success(hdService.getBasicTagByName(hdTag));
         } catch (Exception e) {
             e.printStackTrace();
             return AjaxResult.failed(e.getMessage());

+ 185 - 56
taphole-opc/src/main/java/com/sckj/opc/dataservice/HDServiceImpl.java

@@ -1,7 +1,6 @@
 package com.sckj.opc.dataservice;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baosight.hdsdk.HDConnectionFactory;
 import com.baosight.hdsdk.HDDataProvider;
 import com.baosight.hdsdk.HDServerFactory;
@@ -15,6 +14,7 @@ import com.google.common.eventbus.AsyncEventBus;
 import com.sckj.common.exception.OperateException;
 import com.sckj.common.manager.ScheduledTaskManager;
 import com.sckj.opc.dto.HdTagDTO;
+import com.sckj.opc.entity.OPCData;
 import com.sckj.opc.entity.OPCServer;
 import com.sckj.opc.entity.THdTag;
 import com.sckj.opc.service.OPCDataServiceImpl;
@@ -24,9 +24,12 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -99,16 +102,25 @@ public class HDServiceImpl {
      * 测试连接
      */
     public void testConnection(OPCServer opcServer) throws HDSdkException {
+        if (ObjectUtils.isEmpty(opcServer)
+                || ObjectUtils.isEmpty(opcServer.getIp())
+                || ObjectUtils.isEmpty(opcServer.getPort())
+                || ObjectUtils.isEmpty(opcServer.getUsername())
+                || ObjectUtils.isEmpty(opcServer.getPassword())
+        ) {
+            throw new OperateException(String.format("HDSDK服务器信息:【ip:%s,port:%s,username:%s,password:%s】", opcServer.getIp(), opcServer.getPort(), opcServer.getUsername(), opcServer.getPassword()));
+        }
+        log.info("hdsdk【ip:{},port:{},username:{},password:{}】", opcServer.getIp(), opcServer.getPort(), opcServer.getUsername(), opcServer.getPassword());
         HDDataServer server = HDServerFactory.getHDDataServer(opcServer.getIp(), opcServer.getPort(), "", opcServer.getPort());
         HDDataConnection dataConn = null;
         try {
             dataConn = HDConnectionFactory.getHDDataConnection(server);
             dataConn.loginToServer(opcServer.getUsername(), opcServer.getPassword());
-            System.out.println(dataConn);
+            log.info("hdsdk connection info:{}", dataConn.toString());
         } finally {
             if (dataConn != null) {
-                log.info("ihdk connection close");
                 dataConn.dispose();
+                log.info("hdsdk connection close");
             }
         }
     }
@@ -116,35 +128,69 @@ public class HDServiceImpl {
     /**
      * 获得基础的连接信息
      */
-    public HDDataConnection createConnection(OPCServer opcServer) {
+    private synchronized HDDataConnection createConnection(OPCServer opcServer) {
+        if (ObjectUtils.isEmpty(opcServer)
+                || ObjectUtils.isEmpty(opcServer.getIp())
+                || ObjectUtils.isEmpty(opcServer.getPort())
+                || ObjectUtils.isEmpty(opcServer.getUsername())
+                || ObjectUtils.isEmpty(opcServer.getPassword())
+        ) {
+            throw new OperateException(String.format("HDSDK服务器信息:【ip:%s,port:%s,username:%s,password:%s】", opcServer.getIp(), opcServer.getPort(), opcServer.getUsername(), opcServer.getPassword()));
+        }
         return mOPCDaClientMap.computeIfAbsent(opcServer.getId(), id -> {
+            log.info("hdsdk【ip:{},port:{},username:{},password:{}】", opcServer.getIp(), opcServer.getPort(), opcServer.getUsername(), opcServer.getPassword());
             HDDataServer server = HDServerFactory.getHDDataServer(opcServer.getIp(), opcServer.getPort(), "", opcServer.getPort());
             HDDataConnection dataConn = null;
             try {
+                log.info("hdsdk start connection:{}", LocalDateTime.now());
                 dataConn = HDConnectionFactory.getHDDataConnection(server);
+                log.info("hdsdk init success:{}", LocalDateTime.now());
                 dataConn.loginToServer(opcServer.getUsername(), opcServer.getPassword());
-            } catch (HDSdkException e) {
-                e.printStackTrace();
+                log.info("hdsdk connected success:{}", LocalDateTime.now());
+                return dataConn;
+            } catch (Exception e) {
+//                e.printStackTrace();
+                if (dataConn != null) {
+                    try {
+                        dataConn.dispose();
+                        log.info("ihsdk connection close");
+                    } catch (HDSdkException ex) {
+                        ex.printStackTrace();
+                    }
+                }
+                throw new OperateException("ihdsdk connection failed : " + e.getMessage());
             }
-            return dataConn;
         });
     }
 
 
     private void createSubscription(OPCServer opcServer, THdTag hdTag) {
         if (ObjectUtils.isEmpty(opcServer) || ObjectUtils.isEmpty(hdTag)) {
-            throw new OperateException("未获取到服务器信息或未获取到标记信号");
+            throw new OperateException("未获取到服务器或标记信息");
+        }
+        if (ObjectUtils.isEmpty(hdTag.getTagId()) || ObjectUtils.isEmpty(hdTag.getTagName()) || ObjectUtils.isEmpty(hdTag.getPeriod())) {
+            log.warn("subscription point => tagId:{},tagName{},period{}",hdTag.getTagId(),hdTag.getTagName(),hdTag.getPeriod());
+            throw new OperateException("tagId 、tagName、period不能为空");
         }
         scheduledTaskManager.addTask(hdTag.getTagName(), 0, hdTag.getPeriod(), TimeUnit.SECONDS, () -> {
-            HDDataConnection connection = createConnection(opcServer);
-            HDDataProvider dp = new HDDataProvider(connection);
             try {
-                HDRecord hdRecord = dp.querySnapshotByTagID(hdTag.getTagId());
-                log.info("{}:{}", hdTag.getTagName(), hdRecord.toString());
-                asyncEventBus.post(hdRecord);
-            } catch (HDSdkException e) {
-                e.printStackTrace();
-                log.info("{}订阅异常:{}", hdTag.getTagName(), e.getMessage());
+                final HDDataConnection connection = createConnection(opcServer);
+                HDDataProvider dp = new HDDataProvider(connection);
+                HDRecord record = dp.querySnapshotByTagID(hdTag.getTagId());
+
+                OPCData build = OPCData.builder()
+                        .data(record.getValueStr())
+                        .pointName(hdTag.getTagName())
+                        .belongTagID(record.getBelongTagID())
+                        .sourceTime(new Date(record.getSecond() * 1000))
+                        .serverTime(new Date(record.getSecond() * 1000))
+                        .serverType(opcServer.getType())
+                        .build();
+                asyncEventBus.post(build);
+                log.info("{}({})获取数据成功,数据:{}", hdTag.getTagName(),hdTag.getTagDesc(), record);
+            } catch (Exception e) {
+               // e.printStackTrace();
+                log.info("{}({})获取数据异常:{}", hdTag.getTagName(),hdTag.getTagDesc(), e.getMessage());
             }
         });
     }
@@ -154,17 +200,16 @@ public class HDServiceImpl {
      * @param hdTag
      */
     public void subscribe(THdTag hdTag) {
-        HdTagDTO opcPointDTO = hdTagService.selectInfoWithServer(hdTag);
-        if (ObjectUtils.isEmpty(opcPointDTO)) {
-            throw new OperateException("未查询到该节点数据");
+        HdTagDTO hdTagDTO = hdTagService.selectInfoWithServer(hdTag);
+        if (ObjectUtils.isEmpty(hdTagDTO)) {
+            throw new OperateException(hdTag.getTagName() + "未查询到信息");
         }
-
         QueryWrapper<HdTagDTO> pointQueryWrapper = new QueryWrapper<>();
         pointQueryWrapper.lambda().eq(HdTagDTO::getStatus, "1");
         OPCServer opcServer = new OPCServer();
-        BeanUtils.copyProperties(opcPointDTO, opcServer);
-        opcServer.setId(opcPointDTO.getOpcServerId());
-        createSubscription(opcServer, opcPointDTO);
+        BeanUtils.copyProperties(hdTagDTO, opcServer);
+        opcServer.setId(hdTagDTO.getOpcServerId());
+        createSubscription(opcServer, hdTagDTO);
     }
 
 
@@ -195,7 +240,7 @@ public class HDServiceImpl {
         serverQueryWrapper.lambda().eq(OPCServer::getStatus, "1");
         List<OPCServer> opcServerList = opcServerService.list(serverQueryWrapper);
         if (ObjectUtils.isEmpty(opcServerList)) {
-            throw new OperateException("没有可用的服务器!");
+            throw new OperateException("没有可用的服务器,请确认服务器是否被禁用!");
         }
         for (OPCServer opcServer : opcServerList) {
             QueryWrapper<THdTag> pointQueryWrapper = new QueryWrapper<>();
@@ -204,7 +249,7 @@ public class HDServiceImpl {
             if (ObjectUtils.isNotEmpty(opcPointList)) {
                 log.info("start point list:");
                 for (THdTag opcPoint : opcPointList) {
-                    log.info(opcPoint.getTagName());
+                   // log.info(opcPoint.getTagName());
                     createSubscription(opcServer, opcPoint);
                 }
             }
@@ -217,71 +262,157 @@ public class HDServiceImpl {
      *
      * @param hdTag
      * @throws Exception
+     *
+     *{
+     *   "code": 200,
+     *   "msg": "成功",
+     *   "data": {
+     *     "second": 1748263901,
+     *     "microSecond": 32,
+     *     "quality": 192,
+     *     "dataType": "FLOAT32",
+     *     "valueStr": "0.0",
+     *     "belongTagID": 180772,
+     *     "timeStampStr": "2025-05-26 20:51:41:032"
+     *   }
+     * }
+     *
      */
     public HDRecord readTagValue(THdTag hdTag) throws Exception {
         HdTagDTO opcPointDTO = hdTagService.selectInfoWithServer(hdTag);
         if (ObjectUtils.isEmpty(opcPointDTO)) {
-            return null;
+            throw new OperateException(hdTag.getTagName() + "未查询到信息");
         }
         OPCServer opcServer = new OPCServer();
         BeanUtils.copyProperties(opcPointDTO, opcServer);
         opcServer.setId(opcPointDTO.getOpcServerId());
-        HDDataConnection connection = createConnection(opcServer);
-        HDDataProvider dp = new HDDataProvider(connection);
-        HDRecord hdRecord = dp.querySnapshotByTagID(hdTag.getTagId());
+        HDRecord hdRecord = null;
+        try {
+            HDDataConnection connection = createConnection(opcServer);
+            HDDataProvider dp = new HDDataProvider(connection);
+            hdRecord = dp.querySnapshotByTagID(opcPointDTO.getTagId());
+        } catch (HDSdkException e) {
+            throw new RuntimeException(e);
+        }
         return hdRecord;
     }
 
     /***
      * 根据tagName刷新TagId
      */
+    @Transactional(rollbackFor = {Exception.class})
     public void refreshTagIds() throws HDSdkException {
         QueryWrapper<OPCServer> serverQueryWrapper = new QueryWrapper<>();
         serverQueryWrapper.lambda().eq(OPCServer::getType, "3");
         List<OPCServer> opcServerList = opcServerService.list(serverQueryWrapper);
         if (ObjectUtils.isEmpty(opcServerList)) {
-            throw new OperateException("没有可用的服务器!");
+            throw new OperateException("没有可用的服务器,请确认服务器是否被禁用!");
         }
+        StringBuilder sb  = new StringBuilder("订阅信息:\n");
         for (OPCServer opcServer : opcServerList) {
-            HDDataConnection connection = createConnection(opcServer);
+            HDDataConnection connection = null;
+            try {
+                connection = createConnection(opcServer);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
             if (null == connection) {
                 continue;
             }
-            try {
-                QueryWrapper<THdTag> pointQueryWrapper = new QueryWrapper<>();
-                List<THdTag> opcPointList = hdTagService.list(pointQueryWrapper);
-                if (ObjectUtils.isNotEmpty(opcPointList)) {
-                    for (THdTag opcPoint : opcPointList) {
-                        log.info(opcPoint.getTagName());
+            sb.append("服务器地址:"+opcServer.getIp()+"\n");
+//            try {
+            QueryWrapper<THdTag> pointQueryWrapper = new QueryWrapper<>();
+            pointQueryWrapper.lambda().eq(THdTag::getStatus, "1");
+            List<THdTag> opcPointList = hdTagService.list(pointQueryWrapper);
+            if (ObjectUtils.isNotEmpty(opcPointList)) {
+                for (THdTag opcPoint : opcPointList) {
+//                    log.info(opcPoint.getTagName());
+                    HDBasicTag basicTag = null;
+                    try {
                         HDTagManager tagManager = connection.getTagManager();
-                        HDBasicTag basicTag = tagManager.getBasicTagByName(opcPoint.getTagName());
-                        if (ObjectUtils.isEmpty(basicTag)) {
-                            log.info("{}未查询到数据", opcPoint.getTagName());
-                            continue;
-                        }
-                        UpdateWrapper<THdTag> updateWrapper = new UpdateWrapper<>();
-                        updateWrapper.lambda()
-                                .set(THdTag::getTagId, basicTag.getId())
-                                .set(THdTag::getTagType, basicTag.getTagDataType().name())
-                                .eq(THdTag::getId, opcPoint.getId());
+                        basicTag = tagManager.getBasicTagByName(opcPoint.getTagName());
+                    } catch (HDSdkException e) {
+                        log.error("{},{}", opcPoint.getTagName(), e.getMessage());
                     }
+                    if (ObjectUtils.isEmpty(basicTag)) {
+//                        log.info("{}未查询到信息", opcPoint.getTagName());
+                        sb.append("编号:"+opcPoint.getId()+",tageId:"+basicTag.getId()+",tageName:"+opcPoint.getTagName()+",tageType:"+basicTag.getTagDataType().name()+"\n");
+                        continue;
+                    }
+//                    log.info("{}查询到信息:TagId:{},TagType:{},Id:{}", opcPoint.getTagName(), basicTag.getId(), basicTag.getTagDataType().name(), opcPoint.getId());
+                    THdTag newTHdTag = new THdTag();
+                    newTHdTag.setId(opcPoint.getId());
+                    newTHdTag.setTagId(basicTag.getId());
+                    newTHdTag.setTagType(basicTag.getTagDataType().name());
+                    hdTagService.updateById(newTHdTag);
                 }
-            } catch (HDSdkException e) {
-                throw new RuntimeException(e);
-            } finally {
-                connection.dispose();
             }
+            log.info("刷新信息失败:{}",sb.toString());
+//            } catch (HDSdkException e) {
+//                throw new RuntimeException(e);
+//            }
         }
     }
 
     /***
      * 根据Tag名称获取普通类型Tag对象
+     * {
+     *   "code": 200,
+     *   "msg": "成功",
+     *   "data": {
+     *     "name": "BF4_1_IRONNOTCH_TAPPING",
+     *     "desc": "四高炉1号铁口出铁中",
+     *     "id": 180772,
+     *     "hdServer": {
+     *       "serverIp": "10.3.231.3",
+     *       "serverPort": 5673,
+     *       "serverBakIp": "",
+     *       "serverBakPort": 5673
+     *     },
+     *     "tagDataType": "FLOAT32",
+     *     "tagClass": "BASIC",
+     *     "archiving": true,
+     *     "scan": true,
+     *     "changeDate": 1740730555,
+     *     "changer": "admin",
+     *     "creationDate": 1740730555,
+     *     "creator": "admin",
+     *     "excMaxTime": 300,
+     *     "excDev": 0,
+     *     "compDev": 0,
+     *     "compMaxTime": 0,
+     *     "compType": 0,
+     *     "recAccess": 53,
+     *     "recOperateGroup": "admin",
+     *     "recOwnerGroup": "admin",
+     *     "tagAccess": 53,
+     *     "tagOperateGroup": "admin",
+     *     "tagOwnerGroup": "admin",
+     *     "span": 100,
+     *     "minValue": 0,
+     *     "digitalSet": "DEFAULT",
+     *     "engUnits": "",
+     *     "instrumentPoint": "AOD25606.PV",
+     *     "instrumentPointType": 0,
+     *     "param1": 0,
+     *     "param2": 0,
+     *     "param3": 0,
+     *     "param4": 0,
+     *     "param5": 0,
+     *     "deviceName": "Yokogawa.ExaopcDACS1.1",
+     *     "collectorID": 25,
+     *     "collectorName": "BF4",
+     *     "deviceID": 23,
+     *     "scanGroupID": 253,
+     *     "scanGroupName": "BF4_ZNCT"
+     *   }
+     * }
      */
     public HDBasicTag getBasicTagByName(THdTag hdTag) throws HDSdkException {
         HDBasicTag basicTag = null;
         HdTagDTO opcPointDTO = hdTagService.selectInfoWithServer(hdTag);
         if (ObjectUtils.isEmpty(opcPointDTO)) {
-            return basicTag;
+            throw new OperateException(hdTag.getTagName() + "未查询到信息");
         }
         OPCServer opcServer = new OPCServer();
         BeanUtils.copyProperties(opcPointDTO, opcServer);
@@ -291,10 +422,8 @@ public class HDServiceImpl {
             connection = createConnection(opcServer);
             HDTagManager tm = connection.getTagManager();
             basicTag = tm.getBasicTagByName(opcPointDTO.getTagName());
-        } finally {
-            if (connection != null) {
-                connection.dispose();
-            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
         return basicTag;
     }

+ 1 - 1
taphole-opc/src/main/java/com/sckj/opc/dataservice/OPCDAServiceImpl.java

@@ -96,7 +96,7 @@ public class OPCDAServiceImpl {
                             return null;
                         }
 
-                        newPointName =  CustomUtil.createNewPointName(newPointName,activeProfiles);
+                        newPointName =  CustomUtil.createNewPointName(newPointName,activeProfiles,"1");
 
                         log.info("{} start subscribe", newPointName);
 

+ 7 - 0
taphole-opc/src/main/java/com/sckj/opc/entity/OPCData.java

@@ -1,6 +1,7 @@
 package com.sckj.opc.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -42,4 +43,10 @@ public class OPCData {
     @ApiModelProperty(value = "订阅点名称")
     private String pointName;
 
+    @TableField(exist = false)
+    private Integer belongTagID;
+
+    @TableField(exist = false)
+    private String serverType;
+
 }

+ 1 - 1
taphole-opc/src/main/java/com/sckj/opc/entity/OPCServer.java

@@ -61,7 +61,7 @@ public class OPCServer {
     @ApiModelProperty(value = "备注")
     private String remark;
 
-    @NotNull(message = "type参数缺失")
+    @NotNull(message = "服务器类型")
     private String type;
 
     @ApiModelProperty(value = "创建人")

+ 6 - 4
taphole-opc/src/main/java/com/sckj/opc/utils/CustomUtil.java

@@ -3,10 +3,12 @@ package com.sckj.opc.utils;
 import com.google.common.collect.Sets;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
 
 import java.net.*;
-import java.util.*;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * @author kangaroo hy
@@ -75,8 +77,8 @@ public class CustomUtil {
     }
 
 
-    public static String createNewPointName(String pointName, String activeProfiles) {
-        if ("prod".equals(activeProfiles)) {
+    public static String createNewPointName(String pointName, String activeProfiles,String serverType) {
+        if ("prod".equals(activeProfiles) || "3".equals(serverType)) {
             return pointName;
         }
         if (pointName.contains(".")) {

BIN
taphole-opc/src/main/resources/lib/hd/linux/libLogC.so


BIN
taphole-opc/src/main/resources/lib/hd/linux/libhdDNAPI.so


BIN
taphole-opc/src/main/resources/lib/hd/linux/libhdDataSDK.so


BIN
taphole-opc/src/main/resources/lib/hd/linux/libhdKingAPI.so


BIN
taphole-opc/src/main/resources/lib/hd/linux/libhdNetClient.so


BIN
taphole-opc/src/main/resources/lib/hd/linux/libhdOS.so


BIN
taphole-opc/src/main/resources/lib/hd/linux/libhdProcComm.so


+ 4 - 4
taphole-opc/src/main/resources/mapper/HdTagMapper.xml

@@ -4,8 +4,8 @@
 
 
     <select id="selectInfoWithServer" resultType="com.sckj.opc.dto.HdTagDTO">
-        select a.*,b.ip ip,b.username,b.password,b.port port
-        from t_hd_tag a left join t_opc_server b on a.opc_server_id=b.id
+        select a.*,b.ip ip,b.username username,b.password password,b.port port,b.type type
+        from t_hd_tag a left join t_opc_server b on a.opc_server_id = b.id
         <where>
             <if test="id != null">
                 and a.id = #{id}
@@ -21,9 +21,9 @@
     </select>
 
     <select id="getAvailablePoints" resultType="com.sckj.opc.dto.HdTagDTO">
-        select a.*,b.ip ip,b.username,b.password,b.port port
+        select a.*,b.ip ip,b.username username,b.password password,b.port port,b.type type
         from t_hd_tag a
-          inner join (select * from t_opc_server where status='1') b on a.opc_server_id=b.id
+          inner join (select * from t_opc_server where status='1') b on a.opc_server_id = b.id
         where a.status = '1'
     </select>