From 86f19c30b243337f1400244f3a0426c13e54a475 Mon Sep 17 00:00:00 2001
From: zhuguifei <312353457@qq.com>
Date: 星期三, 27 十一月 2024 13:46:27 +0800
Subject: [PATCH] Merge branch 'herb' of https://gitee.com/baoshwi/herb into herb

---
 jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java |  134 ++++++++++++++++++++++----------------------
 1 files changed, 68 insertions(+), 66 deletions(-)

diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java
index 84e7484..cc083dd 100644
--- a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java
+++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java
@@ -1,66 +1,68 @@
-//package org.jeecg.modules.dry.controller;
-//
-//import com.kangaroohy.milo.model.ReadWriteEntity;
-//import com.kangaroohy.milo.service.MiloService;
-//import io.swagger.annotations.Api;
-//import io.swagger.annotations.ApiOperation;
-//import lombok.extern.slf4j.Slf4j;
-//import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-//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.jeecg.common.api.vo.Result;
-//import org.jeecg.modules.dry.entity.DryOpcDevice;
-//import org.jeecg.modules.dry.service.IDryOpcDeviceService;
-//import org.jeecg.modules.dry.vo.CommandMessageVo;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.web.bind.annotation.PostMapping;
-//import org.springframework.web.bind.annotation.RequestBody;
-//import org.springframework.web.bind.annotation.RequestMapping;
-//import org.springframework.web.bind.annotation.RestController;
-//
-//import java.util.List;
-//import java.util.concurrent.ExecutionException;
-//
-///**
-// * opc鎺у埗鍣紝鐢ㄤ簬鎺у埗鐜板満鎽勫儚澶寸數婧愶紝鐏殑寮�鍏�
-// */
-//
-//@Api(tags="OPC鎺у埗鍣�")
-//@RestController
-//@RequestMapping("/dry/opc")
-//@Slf4j
-//public class OpcController {
-//
-//    @Autowired
-//    private MiloService miloService;
-//
-//    @Autowired
-//    private IDryOpcDeviceService opcDeviceService;
-//
-//
-//    @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�")
-//    @PostMapping("/sendWriteCommand")
-//    public Result<?> sendWriteCommand(@RequestBody CommandMessageVo msgVo) throws Exception {
-//
-//        miloService.writeToOpcUa(ReadWriteEntity.builder()
-//                .identifier(msgVo.getCode())
-//                //Kep涓槸Boolean绫诲瀷
-//                .value(Boolean.valueOf(msgVo.getMsg()))
-//                .build());
-//        return Result.OK();
-//    }
-//
-//    @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�")
-//    @PostMapping("/initDevice")
-//    public Result<?> initDevice() throws Exception {
-//        List<DryOpcDevice> list = opcDeviceService.list();
-//
-//        list.forEach(item -> {
-//
-//        });
-//
-//        return Result.OK();
-//    }
-//}
+package org.jeecg.modules.dry.controller;
+
+import com.kangaroohy.milo.model.ReadWriteEntity;
+import com.kangaroohy.milo.service.MiloService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
+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.jeecg.common.api.vo.Result;
+import org.jeecg.modules.dry.entity.DryOpcDevice;
+import org.jeecg.modules.dry.service.IDryOpcDeviceService;
+import org.jeecg.modules.dry.vo.CommandMessageVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+/**
+ * opc鎺у埗鍣紝鐢ㄤ簬鎺у埗鐜板満鎽勫儚澶寸數婧愶紝鐏殑寮�鍏�
+ */
+
+@Api(tags="OPC鎺у埗鍣�")
+@RestController
+@RequestMapping("/dry/opc")
+@Slf4j
+@ConditionalOnProperty(name = "kangaroohy.milo.enabled", havingValue = "true")
+public class OpcController {
+
+    @Autowired
+    private MiloService miloService;
+
+    @Autowired
+    private IDryOpcDeviceService opcDeviceService;
+
+
+    @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�")
+    @PostMapping("/sendWriteCommand")
+    public Result<?> sendWriteCommand(@RequestBody CommandMessageVo msgVo) throws Exception {
+
+        miloService.writeToOpcUa(ReadWriteEntity.builder()
+                .identifier(msgVo.getCode())
+                //Kep涓槸Boolean绫诲瀷
+                .value(Boolean.valueOf(msgVo.getMsg()))
+                .build());
+        return Result.OK();
+    }
+
+    @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�")
+    @PostMapping("/initDevice")
+    public Result<?> initDevice() throws Exception {
+        List<DryOpcDevice> list = opcDeviceService.list();
+
+        list.forEach(item -> {
+
+        });
+
+        return Result.OK();
+    }
+}

--
Gitblit v1.9.3