diff --git a/src/main/java/com/qgs/dc/mq/producer/controller/TestController.java b/src/main/java/com/qgs/dc/mq/producer/controller/TestController.java index 915fdfe..c1ad3e3 100644 --- a/src/main/java/com/qgs/dc/mq/producer/controller/TestController.java +++ b/src/main/java/com/qgs/dc/mq/producer/controller/TestController.java @@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.qgs.dc.common.utils.CommonFunction; +import com.qgs.dc.mq.entity.CallbackMessageEntity; import com.qgs.dc.mq.producer.component.RabbitSender; import com.qgs.dc.mq.entity.MQMessage; import com.qgs.dc.mq.entity.common.Header; import com.qgs.dc.mq.entity.specificBody.QueryEQStatusBody; +import com.qgs.dc.opcua.controller.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import java.io.IOException; @@ -29,6 +33,40 @@ public class TestController { @Autowired RabbitSender rabbitSender; + @PostMapping("/eapRequest") + /** + * desc : 回复EAP的request 的回调接口(向rabbitmq中发送消息(direct模式)) + * MES => DC(数据采集中间件) => MQ => EAP + */ + public R eapRequest(){ + try { + //properties 这里的参数是写在MQ消息 header里面的,如果EAP端 需要某些参数 可以写在这里,eap去取更方便一些 + Map properties = new HashMap<>(); + CallbackMessageEntity callbackMessageEntity = new CallbackMessageEntity(); + properties.put("equipmentName","PID001"); + callbackMessageEntity.setExchangeName("00B_Exchange"); + callbackMessageEntity.setRoutingKey("00B_EAP_Request_Queue_RoutingKey"); + + MQMessage mesResponse = new MQMessage(); + + Header header = new Header("Request","Execute","QUERYEQPStatus","12"); + QueryEQStatusBody queryEQStatusBody = new QueryEQStatusBody(); + queryEQStatusBody.setVidType("u4"); + List vids = new ArrayList<>(); + vids.add("10000"); + vids.add("10001"); + vids.add("10002"); + queryEQStatusBody.setVidList(vids); + mesResponse.setBody(JSONObject.toJSONString(queryEQStatusBody)); + mesResponse.setHeader(header); + callbackMessageEntity.setMqMessage(mesResponse); + properties.put("transitionId", "12312"); + rabbitSender.reply(callbackMessageEntity.getMqMessage(),properties, callbackMessageEntity.getExchangeName(), callbackMessageEntity.getRoutingKey()); + return R.ok("回复成功"); + }catch (Exception e){ + return R.error().put("result",e.getMessage()); + } + } public static void main(String[] args) throws IOException { diff --git a/src/main/java/com/qgs/dc/opcua/controller/OperateController.java b/src/main/java/com/qgs/dc/opcua/controller/OperateController.java index d47278c..72d7ec2 100644 --- a/src/main/java/com/qgs/dc/opcua/controller/OperateController.java +++ b/src/main/java/com/qgs/dc/opcua/controller/OperateController.java @@ -97,7 +97,7 @@ public class OperateController { } } - @GetMapping("/getBrows") + @PostMapping("/getBrows") public R getBrows(@RequestBody BrowsArgEntity browsArgEntity){ NodeIdKey nodeIdKey = uaService.browseA(browsArgEntity.getPlcName(), browsArgEntity.getRootNameSpace(), browsArgEntity.getIdenrifier()); if(nodeIdKey == null){ @@ -138,7 +138,7 @@ public class OperateController { } - @GetMapping("/read") + @PostMapping("/read") //public R read(Integer nameSpace,String identifier,String plcName) { public R read(@RequestBody ReadArgEntity readArgEntity) { try { @@ -393,14 +393,14 @@ public class OperateController { } } - @GetMapping("getUniqueWebSocketId") + @PostMapping("getUniqueWebSocketId") public R getUniqueWebSocketId() throws Exception { String uniqeId = webSocketServer.getUniqeId(); return R.ok().put("result",uniqeId); } - @GetMapping("getConnectedPLC") + @PostMapping("getConnectedPLC") public R getConnectedPLC() { return R.ok().put("result",uaService.getConnectedPLC()); }