465d5c4666546e7e54f0e3c34c7bcce5830aaa6a..69fbaaa1a5fd16b05953e750ea7fcc3e18e3a27c
2023-10-18 yantian yue
OPCUA更新
69fbaa 对比 | 目录
2023-10-18 yantian yue
OPCUA更新
f4a343 对比 | 目录
已修改5个文件
55 ■■■■ 文件已修改
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/cert/MethodName.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/client/ClientHandler.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/controller/OpcuaConfController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/mapper/OpcuaConfMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/service/impl/OpcuaConfServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/cert/MethodName.java
@@ -5,12 +5,12 @@
@Slf4j
public class MethodName {
    public void a(String name){
        log.info("str={}", name);
        log.info("str={},响应方法:{}", name,"A");
    }
    public void b(String name,String value){
        log.info("item={}, value={},{}", name, value,"BBBBBB");
    public void b(String name){
        log.info("str={},响应方法:{}", name,"B");
    }
    public void c(String name,String value){
        log.info("item={}, value={},{}", name, value,"CCCCCC");
        }
    public void c(String name){
        log.info("str={},响应方法:{}", name,"C");
    }
}
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/client/ClientHandler.java
@@ -1,8 +1,19 @@
package cn.stylefeng.guns.opcua.client;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.opcua.controller.OpcuaConfController;
import cn.stylefeng.guns.opcua.entity.OpcuaConf;
import cn.stylefeng.guns.opcua.mapper.OpcuaConfMapper;
import cn.stylefeng.guns.opcua.model.params.OpcuaConfParam;
import cn.stylefeng.guns.opcua.model.result.OpcuaConfResult;
import cn.stylefeng.guns.opcua.service.OpcuaConfService;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.ImmutableList;
import cn.stylefeng.guns.opcua.entity.NodeEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
import org.eclipse.milo.opcua.sdk.client.api.nodes.VariableNode;
import org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscription;
@@ -42,6 +53,10 @@
    @Autowired
    private ClientRunner clientRunner;
    @Autowired
    private OpcuaConfController opcuaConfController;
    /**
     * 
@@ -147,21 +162,23 @@
     */
    public void handle(NodeId id, Variant value){
        String className = "cn.stylefeng.guns.opcua.cert.MethodName";
        String methodName = "a";
        long startTime = System.currentTimeMillis();
        OpcuaConfParam opcuaConfParam=new OpcuaConfParam();
        opcuaConfParam.setNode(id.getIdentifier().toString());
        List<OpcuaConfResult> a=opcuaConfController.mylist(opcuaConfParam);
        String str1 = id.getIdentifier().toString()+":"+value.getValue().toString();
        try {
            Class<?> clazz = Class.forName(className);
            Method method = clazz.getMethod(methodName, String.class);
            Class<?> clazz = Class.forName(a.get(0).getRModule());
            Method method = clazz.getMethod(a.get(0).getRFunction(), String.class);
            method.invoke(clazz.newInstance(), str1);
        } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException |
                 InvocationTargetException e) {
            e.printStackTrace();
        }
        //if(id.getIdentifier().toString().equals("my.device.x1")){
        //    log.info("item={}, value={},{}", id.getIdentifier().toString(), value,"返回一个SN号");
        //}
        log.info("代码执行时间:" + (System.currentTimeMillis() - startTime) + "毫秒");
    }
    /**
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/controller/OpcuaConfController.java
@@ -3,6 +3,7 @@
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.opcua.entity.OpcuaConf;
import cn.stylefeng.guns.opcua.model.params.OpcuaConfParam;
import cn.stylefeng.guns.opcua.model.result.OpcuaConfResult;
import cn.stylefeng.guns.opcua.service.OpcuaConfService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
@@ -12,6 +13,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
@@ -131,6 +133,12 @@
    public LayuiPageInfo list(OpcuaConfParam opcuaConfParam) {
        return this.opcuaConfService.findPageBySpec(opcuaConfParam);
    }
    @ResponseBody
    @RequestMapping("/mylist")
    @DataSource(name = "self")
    public List<OpcuaConfResult> mylist(OpcuaConfParam opcuaConfParam) {
        return this.opcuaConfService.findListBySpec(opcuaConfParam);
    }
}
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/mapper/OpcuaConfMapper.java
@@ -3,6 +3,7 @@
import cn.stylefeng.guns.opcua.entity.OpcuaConf;
import cn.stylefeng.guns.opcua.model.params.OpcuaConfParam;
import cn.stylefeng.guns.opcua.model.result.OpcuaConfResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
guns-vip-main/src/main/java/cn/stylefeng/guns/opcua/service/impl/OpcuaConfServiceImpl.java
@@ -53,7 +53,8 @@
    @Override
    public List<OpcuaConfResult> findListBySpec(OpcuaConfParam param){
        return null;
        return this.baseMapper.customList(param);
    }
    @Override