更新
This commit is contained in:
parent
09035cd750
commit
5c20deaae1
@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.qgs.dc.common.utils.CommonFunction;
|
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.producer.component.RabbitSender;
|
||||||
|
|
||||||
import com.qgs.dc.mq.entity.MQMessage;
|
import com.qgs.dc.mq.entity.MQMessage;
|
||||||
import com.qgs.dc.mq.entity.common.Header;
|
import com.qgs.dc.mq.entity.common.Header;
|
||||||
import com.qgs.dc.mq.entity.specificBody.QueryEQStatusBody;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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 org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -29,6 +33,40 @@ public class TestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
RabbitSender rabbitSender;
|
RabbitSender rabbitSender;
|
||||||
|
|
||||||
|
@PostMapping("/eapRequest")
|
||||||
|
/**
|
||||||
|
* desc : 回复EAP的request 的回调接口(向rabbitmq中发送消息(direct模式))
|
||||||
|
* MES => DC(数据采集中间件) => MQ => EAP
|
||||||
|
*/
|
||||||
|
public R eapRequest(){
|
||||||
|
try {
|
||||||
|
//properties 这里的参数是写在MQ消息 header里面的,如果EAP端 需要某些参数 可以写在这里,eap去取更方便一些
|
||||||
|
Map<String,Object> 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<String> 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 {
|
public static void main(String[] args) throws IOException {
|
||||||
|
@ -97,7 +97,7 @@ public class OperateController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getBrows")
|
@PostMapping("/getBrows")
|
||||||
public R getBrows(@RequestBody BrowsArgEntity browsArgEntity){
|
public R getBrows(@RequestBody BrowsArgEntity browsArgEntity){
|
||||||
NodeIdKey nodeIdKey = uaService.browseA(browsArgEntity.getPlcName(), browsArgEntity.getRootNameSpace(), browsArgEntity.getIdenrifier());
|
NodeIdKey nodeIdKey = uaService.browseA(browsArgEntity.getPlcName(), browsArgEntity.getRootNameSpace(), browsArgEntity.getIdenrifier());
|
||||||
if(nodeIdKey == null){
|
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(Integer nameSpace,String identifier,String plcName) {
|
||||||
public R read(@RequestBody ReadArgEntity readArgEntity) {
|
public R read(@RequestBody ReadArgEntity readArgEntity) {
|
||||||
try {
|
try {
|
||||||
@ -393,14 +393,14 @@ public class OperateController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("getUniqueWebSocketId")
|
@PostMapping("getUniqueWebSocketId")
|
||||||
public R getUniqueWebSocketId() throws Exception {
|
public R getUniqueWebSocketId() throws Exception {
|
||||||
String uniqeId = webSocketServer.getUniqeId();
|
String uniqeId = webSocketServer.getUniqeId();
|
||||||
return R.ok().put("result",uniqeId);
|
return R.ok().put("result",uniqeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("getConnectedPLC")
|
@PostMapping("getConnectedPLC")
|
||||||
public R getConnectedPLC() {
|
public R getConnectedPLC() {
|
||||||
return R.ok().put("result",uaService.getConnectedPLC());
|
return R.ok().put("result",uaService.getConnectedPLC());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user