|
|
@ -3,6 +3,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.equiplog;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IWriteOPCEquipmentService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IWriteOPCEquipmentService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.datatable.DataColumnCollection;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.datatable.DataColumnCollection;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.XML;
|
|
|
|
import cn.hutool.json.XML;
|
|
|
@ -16,6 +17,10 @@ import org.springframework.http.*;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@ -54,6 +59,58 @@ public class WriteOPCEquipmentServiceImpl implements IWriteOPCEquipmentService {
|
|
|
|
throw new ImppBusiException(String.format("Error Code %s", response.getStatusCode().toString()));
|
|
|
|
throw new ImppBusiException(String.format("Error Code %s", response.getStatusCode().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String writeVariableHttp(String equipmentId,String channel,String clientHandle,String v, String wsUrl)throws Exception{
|
|
|
|
|
|
|
|
//服务的地址 http://172.28.16.50:8111
|
|
|
|
|
|
|
|
wsUrl="http://172.28.16.50:8111";
|
|
|
|
|
|
|
|
URL url = new URL(wsUrl);
|
|
|
|
|
|
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn.setDoInput(true);
|
|
|
|
|
|
|
|
conn.setDoOutput(true);
|
|
|
|
|
|
|
|
conn.setRequestMethod("POST");
|
|
|
|
|
|
|
|
conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//请求体---使用soapui获取
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
sb.append("<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tem=\"http://tempuri.org/\">");
|
|
|
|
|
|
|
|
sb.append("<soap:Header>");
|
|
|
|
|
|
|
|
sb.append("<a:To s:mustUnderstand=\"1\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">http://172.28.16.50:8111/WriteOPCEquipmentService</a:To>\n");
|
|
|
|
|
|
|
|
sb.append("</soap:Header>");
|
|
|
|
|
|
|
|
sb.append("<soap:Body>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("<tem:WriteVariable>");
|
|
|
|
|
|
|
|
sb.append("<tem:equipmentId>"+equipmentId+"</tem:equipmentId>");
|
|
|
|
|
|
|
|
sb.append("<tem:channel>"+channel+"</tem:channel>");
|
|
|
|
|
|
|
|
sb.append("<tem:clientHandle>"+clientHandle+ "</tem:clientHandle>");
|
|
|
|
|
|
|
|
sb.append("<tem:v>"+v+"</tem:v>");
|
|
|
|
|
|
|
|
sb.append("</tem:WriteVariable>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("</soap:Body>");
|
|
|
|
|
|
|
|
sb.append("</soap:Envelope>");
|
|
|
|
|
|
|
|
String soap = sb.toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn.connect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutputStream os = conn.getOutputStream();
|
|
|
|
|
|
|
|
os.write(soap.getBytes("UTF-8"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputStream is = conn.getInputStream();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] b = new byte[1024];
|
|
|
|
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
String s = "";
|
|
|
|
|
|
|
|
while ((len = is.read(b)) != -1) {
|
|
|
|
|
|
|
|
String ss = new String(b, 0, len, "UTF-8");
|
|
|
|
|
|
|
|
s += ss;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is.close();
|
|
|
|
|
|
|
|
os.close();
|
|
|
|
|
|
|
|
conn.disconnect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
private String convertListToXml(DataColumnCollection newTable, List<Map<String, Object>> listData, String rootNodeName, String nodeName,
|
|
|
|
private String convertListToXml(DataColumnCollection newTable, List<Map<String, Object>> listData, String rootNodeName, String nodeName,
|
|
|
|
String rootClassName, String nodeClassName) {
|
|
|
|
String rootClassName, String nodeClassName) {
|
|
|
|
if (listData == null || listData.size() == 0) {
|
|
|
|
if (listData == null || listData.size() == 0) {
|
|
|
|