From 0c38037ff515a568a005f555436ad74cbaaed2db Mon Sep 17 00:00:00 2001 From: bsw215583320 <baoshiwei121@163.com> Date: 星期二, 05 十一月 2024 08:24:34 +0800 Subject: [PATCH] 合并opc ua部分 --- jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java | 132 ++++++++++++++++++++++---------------------- 1 files changed, 66 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..02852d6 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,66 @@ -//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.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(); + } +} -- Gitblit v1.9.3