| | |
| | | //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(); |
| | | } |
| | | } |