tags/yfai-mes-ext-v1.0
gsz 11 months ago
commit 14ae5dcdf4

@ -19,11 +19,10 @@
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 cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.webservice.WebServiceServerIns;
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;
@ -54,8 +53,14 @@ public class WebServiceConfig {
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServer());
endpoint.publish("/mes-service");
endpoint.getInInterceptors().add(new CxfInInterceptor(Phase.RECEIVE));
endpoint.publish("/mes-service-equip");
return endpoint;
}
@Bean
public Endpoint endpointIns() {
EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServerIns());
endpoint.publish("/mes-service-instrument");
return endpoint;
}
}

@ -1,51 +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);
}
}
}
//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);
// }
// }
//
//}

@ -12,10 +12,11 @@ import lombok.Data;
@Data
public class AssetInfo {
private String ASSETNUM;
private String DESCRIPTION;
private String cur30;
private String description;
private String FAILURECODE;
private String LOCATION;
private String LOCDESC;
private String SITEID;
private String STATUS;
private String location;
private String locdesc;
private String siteid;
private String status;
}

@ -21,7 +21,7 @@ import java.util.List;
**/
@Service
@Slf4j
public class MesMoveRuleImpl extends BaseMesService<MesMoveRule> implements IMesMoveRuleService {
public class MesMoveRuleServiceImpl extends BaseMesService<MesMoveRule> implements IMesMoveRuleService {
@Override
protected void setPackQueryBean(MesMoveRule bean, DdlPackBean packBean) {

@ -18,7 +18,7 @@ import org.springframework.stereotype.Service;
**/
@Service
@Slf4j
public class MesPrinterConfigureImpl extends BaseMesService<MesPrinterConfigure> implements IMesPrinterConfigureService {
public class MesPrinterConfigureServiceImpl extends BaseMesService<MesPrinterConfigure> implements IMesPrinterConfigureService {
@Override
protected void setPackQueryBean(MesPrinterConfigure bean, DdlPackBean packBean) {

@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
* @Modify:
**/
@Service
public class MesProductOffLineImpl extends BaseMesService<MesProductOffLine> implements IMesProductOffLineService {
public class MesProductOffLineServiceImpl extends BaseMesService<MesProductOffLine> implements IMesProductOffLineService {
}

@ -18,32 +18,21 @@ import javax.jws.WebService;
import java.util.Map;
@Component
@WebService(targetNamespace = "http://tempuri.org/")
@WebService(targetNamespace = "http://yfaiesb/services/ServiceSyncMaximoEquip")
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) {
public Map syncEquip(@WebParam(name = "info") AssetInfo assetInfo) {
LOGGER.info("SyncMaximoEquip主数据:{}", assetInfo);
MaximoParamModel maximoParamModel = new MaximoParamModel();
maximoParamModel.setAssetNum(assetInfo.getASSETNUM());
maximoParamModel.setStatus(assetInfo.getSTATUS());
maximoParamModel.setSiteId(assetInfo.getSITEID());
maximoParamModel.setStatus(assetInfo.getStatus());
maximoParamModel.setSiteId(assetInfo.getSiteid());
maximoParamModel.setFailureCode(assetInfo.getFAILURECODE());
maximoParamModel.setDescription(assetInfo.getDESCRIPTION());
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);
}
}

@ -0,0 +1,30 @@
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.webservice;
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 javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import java.util.Map;
@WebService(targetNamespace = "http://yfaiesb/services/ServiceSyncMaximoInstrument")
public class WebServiceServerIns {
public static final Logger LOGGER = LoggerFactory.getLogger(WebServiceServerIns.class);
@WebMethod(action = "SyncMaximoInstrument", operationName = "SyncMaximoInstrument")
public Map syncInstrument(@WebParam(name = "info") 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…
Cancel
Save