forked from I3-YF/i3plus-mes-yfai
maximo仪表主数据和设备主数据 webService服务 地址:http://localhost:8300/i3plus/mes-service?wsdl localhost替换为部署环境的ip
parent
94b3bd2199
commit
46684e8ee8
@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache ImppLicense, Version 2.0 (the
|
||||||
|
* "ImppLicense"); you may not use this file except in compliance
|
||||||
|
* with the ImppLicense. You may obtain a copy of the ImppLicense at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the ImppLicense is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the ImppLicense for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the ImppLicense.
|
||||||
|
*/
|
||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.config;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.interceptor.CxfInInterceptor;
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.webservice.WebServiceServer;
|
||||||
|
import org.apache.cxf.Bus;
|
||||||
|
import org.apache.cxf.jaxws.EndpointImpl;
|
||||||
|
import org.apache.cxf.phase.Phase;
|
||||||
|
import org.apache.cxf.transport.servlet.CXFServlet;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.xml.ws.Endpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : WebService Server 服务配置
|
||||||
|
* WSDL URL: /block/softswitch/server/web-service?wsdl
|
||||||
|
* @Reference :
|
||||||
|
* @Author : wei.peng
|
||||||
|
* @CreateDate : 2019/9/10 下午3:13
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
public class WebServiceConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Bus bus;
|
||||||
|
|
||||||
|
@Bean("cxfServletRegistration")
|
||||||
|
public ServletRegistrationBean dispatcherServlet() {
|
||||||
|
return new ServletRegistrationBean(new CXFServlet(), "/i3plus/*");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Endpoint endpoint() {
|
||||||
|
EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServer());
|
||||||
|
endpoint.publish("/mes-service");
|
||||||
|
endpoint.getInInterceptors().add(new CxfInInterceptor(Phase.RECEIVE));
|
||||||
|
return endpoint;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.interceptor;
|
||||||
|
|
||||||
|
import org.apache.cxf.binding.soap.SoapMessage;
|
||||||
|
import org.apache.cxf.helpers.IOUtils;
|
||||||
|
import org.apache.cxf.interceptor.Fault;
|
||||||
|
import org.apache.cxf.io.CachedOutputStream;
|
||||||
|
import org.apache.cxf.phase.AbstractPhaseInterceptor;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : Castle
|
||||||
|
* @CreateDate : 2024/6/12 16:20
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public class CxfInInterceptor extends AbstractPhaseInterceptor<SoapMessage> {
|
||||||
|
|
||||||
|
public CxfInInterceptor(String phase) {
|
||||||
|
super(phase);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(SoapMessage message) throws Fault {
|
||||||
|
// 获取消息内容
|
||||||
|
InputStream is = message.getContent(InputStream.class);
|
||||||
|
try {
|
||||||
|
if (is != null) {
|
||||||
|
CachedOutputStream bos = new CachedOutputStream();
|
||||||
|
IOUtils.copy(is, bos);
|
||||||
|
String startXmlMessage = new String(bos.getBytes(), UTF_8);
|
||||||
|
String afterMessage = "";
|
||||||
|
if (startXmlMessage.contains("SyncMaximoEquip")) {
|
||||||
|
afterMessage = startXmlMessage.replaceAll("ws:", "").replaceAll("tem:info", "ws:assetInfo");
|
||||||
|
} else if (startXmlMessage.contains("SyncMaximoInstrumen")) {
|
||||||
|
afterMessage = startXmlMessage.replaceAll("ws:", "").replaceAll("tem:info", "ws:meterInfo");
|
||||||
|
}
|
||||||
|
// 重新设置输入流,因为它已经被读取
|
||||||
|
message.setContent(InputStream.class, new ByteArrayInputStream(afterMessage.getBytes()));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : Castle
|
||||||
|
* @CreateDate : 2024/6/12 14:04
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class AssetInfo {
|
||||||
|
private String ASSETNUM;
|
||||||
|
private String DESCRIPTION;
|
||||||
|
private String FAILURECODE;
|
||||||
|
private String LOCATION;
|
||||||
|
private String LOCDESC;
|
||||||
|
private String SITEID;
|
||||||
|
private String STATUS;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : Castle
|
||||||
|
* @CreateDate : 2024/6/12 15:03
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class MeterInfo {
|
||||||
|
private String ASSETNUM;
|
||||||
|
|
||||||
|
private String BASEMEASUREUNITID;
|
||||||
|
|
||||||
|
private String METERNAME;
|
||||||
|
|
||||||
|
private String SITEID;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.webservice;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.model.AssetInfo;
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.model.MeterInfo;
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.MaximoServiceImpl;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.model.MaximoParamModel;
|
||||||
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.jws.WebMethod;
|
||||||
|
import javax.jws.WebParam;
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@WebService(targetNamespace = "http://tempuri.org/")
|
||||||
|
public class WebServiceServer {
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(WebServiceServer.class);
|
||||||
|
|
||||||
|
@WebMethod(action = "SyncMaximoEquip", operationName = "SyncMaximoEquip")
|
||||||
|
public Map syncEquip(@WebParam(name = "assetInfo", targetNamespace = "http://schemas.datacontract.org/2004/07/WS.MAXIMO.DataInBound") AssetInfo assetInfo) {
|
||||||
|
LOGGER.info("SyncMaximoEquip主数据:{}", assetInfo);
|
||||||
|
MaximoParamModel maximoParamModel = new MaximoParamModel();
|
||||||
|
maximoParamModel.setAssetNum(assetInfo.getASSETNUM());
|
||||||
|
maximoParamModel.setStatus(assetInfo.getSTATUS());
|
||||||
|
maximoParamModel.setSiteId(assetInfo.getSITEID());
|
||||||
|
maximoParamModel.setFailureCode(assetInfo.getFAILURECODE());
|
||||||
|
maximoParamModel.setDescription(assetInfo.getDESCRIPTION());
|
||||||
|
MaximoServiceImpl bean = (MaximoServiceImpl)SpringContextsUtil.getBean("maximoServiceImpl");
|
||||||
|
return bean.doAssetMainData(maximoParamModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WebMethod(action = "SyncMaximoInstrument", operationName = "SyncMaximoInstrument")
|
||||||
|
public Map syncInstrument(@WebParam(name = "meterInfo", targetNamespace = "http://schemas.datacontract.org/2004/07/WS.MAXIMO.DataInBound") MeterInfo meterInfo) {
|
||||||
|
LOGGER.info("syncInstrument主数据:{}", meterInfo);
|
||||||
|
MaximoParamModel maximoParamModel = new MaximoParamModel();
|
||||||
|
maximoParamModel.setAssetNum(meterInfo.getASSETNUM());
|
||||||
|
maximoParamModel.setBaseMeasureUnitId(meterInfo.getBASEMEASUREUNITID());
|
||||||
|
maximoParamModel.setMeterName(meterInfo.getMETERNAME());
|
||||||
|
MaximoServiceImpl bean = (MaximoServiceImpl)SpringContextsUtil.getBean("maximoServiceImpl");
|
||||||
|
return bean.doAssetMainData(maximoParamModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue