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

@ -19,11 +19,10 @@
package cn.estsh.i3plus.ext.mes.apiservice.config; 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.WebServiceServer;
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.webservice.WebServiceServerIns;
import org.apache.cxf.Bus; import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.transport.servlet.CXFServlet; import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
@ -54,8 +53,14 @@ public class WebServiceConfig {
@Bean @Bean
public Endpoint endpoint() { public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServer()); EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServer());
endpoint.publish("/mes-service"); endpoint.publish("/mes-service-equip");
endpoint.getInInterceptors().add(new CxfInInterceptor(Phase.RECEIVE)); return endpoint;
}
@Bean
public Endpoint endpointIns() {
EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServerIns());
endpoint.publish("/mes-service-instrument");
return endpoint; return endpoint;
} }
} }

@ -1,51 +1,51 @@
package cn.estsh.i3plus.ext.mes.apiservice.interceptor; //package cn.estsh.i3plus.ext.mes.apiservice.interceptor;
//
import org.apache.cxf.binding.soap.SoapMessage; //import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.helpers.IOUtils; //import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.interceptor.Fault; //import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.io.CachedOutputStream; //import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.phase.AbstractPhaseInterceptor; //import org.apache.cxf.phase.AbstractPhaseInterceptor;
//
import java.io.ByteArrayInputStream; //import java.io.ByteArrayInputStream;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
//
import static java.nio.charset.StandardCharsets.UTF_8; //import static java.nio.charset.StandardCharsets.UTF_8;
//
/** ///**
* @Description : // * @Description :
* @Reference : // * @Reference :
* @Author : Castle // * @Author : Castle
* @CreateDate : 2024/6/12 16:20 // * @CreateDate : 2024/6/12 16:20
* @Modify: // * @Modify:
**/ // **/
public class CxfInInterceptor extends AbstractPhaseInterceptor<SoapMessage> { //public class CxfInInterceptor extends AbstractPhaseInterceptor<SoapMessage> {
//
public CxfInInterceptor(String phase) { // public CxfInInterceptor(String phase) {
super(phase); // super(phase);
} // }
//
@Override // @Override
public void handleMessage(SoapMessage message) throws Fault { // public void handleMessage(SoapMessage message) throws Fault {
// 获取消息内容 // // 获取消息内容
InputStream is = message.getContent(InputStream.class); // InputStream is = message.getContent(InputStream.class);
try { // try {
if (is != null) { // if (is != null) {
CachedOutputStream bos = new CachedOutputStream(); // CachedOutputStream bos = new CachedOutputStream();
IOUtils.copy(is, bos); // IOUtils.copy(is, bos);
String startXmlMessage = new String(bos.getBytes(), UTF_8); // String startXmlMessage = new String(bos.getBytes(), UTF_8);
String afterMessage = ""; // String afterMessage = "";
if (startXmlMessage.contains("SyncMaximoEquip")) { // if (startXmlMessage.contains("SyncMaximoEquip")) {
afterMessage = startXmlMessage.replaceAll("ws:", "").replaceAll("tem:info", "ws:assetInfo"); // afterMessage = startXmlMessage.replaceAll("ws:", "").replaceAll("tem:info", "ws:assetInfo");
} else if (startXmlMessage.contains("SyncMaximoInstrumen")) { // } else if (startXmlMessage.contains("SyncMaximoInstrumen")) {
afterMessage = startXmlMessage.replaceAll("ws:", "").replaceAll("tem:info", "ws:meterInfo"); // afterMessage = startXmlMessage.replaceAll("ws:", "").replaceAll("tem:info", "ws:meterInfo");
} // }
// 重新设置输入流,因为它已经被读取 // // 重新设置输入流,因为它已经被读取
message.setContent(InputStream.class, new ByteArrayInputStream(afterMessage.getBytes())); // message.setContent(InputStream.class, new ByteArrayInputStream(afterMessage.getBytes()));
} // }
} catch (IOException e) { // } catch (IOException e) {
throw new RuntimeException(e); // throw new RuntimeException(e);
} // }
} // }
//
} //}

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

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

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

@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
* @Modify: * @Modify:
**/ **/
@Service @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; import java.util.Map;
@Component @Component
@WebService(targetNamespace = "http://tempuri.org/") @WebService(targetNamespace = "http://yfaiesb/services/ServiceSyncMaximoEquip")
public class WebServiceServer { public class WebServiceServer {
public static final Logger LOGGER = LoggerFactory.getLogger(WebServiceServer.class); public static final Logger LOGGER = LoggerFactory.getLogger(WebServiceServer.class);
@WebMethod(action = "SyncMaximoEquip", operationName = "SyncMaximoEquip") @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); LOGGER.info("SyncMaximoEquip主数据:{}", assetInfo);
MaximoParamModel maximoParamModel = new MaximoParamModel(); MaximoParamModel maximoParamModel = new MaximoParamModel();
maximoParamModel.setAssetNum(assetInfo.getASSETNUM()); maximoParamModel.setAssetNum(assetInfo.getASSETNUM());
maximoParamModel.setStatus(assetInfo.getSTATUS()); maximoParamModel.setStatus(assetInfo.getStatus());
maximoParamModel.setSiteId(assetInfo.getSITEID()); maximoParamModel.setSiteId(assetInfo.getSiteid());
maximoParamModel.setFailureCode(assetInfo.getFAILURECODE()); maximoParamModel.setFailureCode(assetInfo.getFAILURECODE());
maximoParamModel.setDescription(assetInfo.getDESCRIPTION()); maximoParamModel.setDescription(assetInfo.getDescription());
MaximoServiceImpl bean = (MaximoServiceImpl)SpringContextsUtil.getBean("maximoServiceImpl"); MaximoServiceImpl bean = (MaximoServiceImpl)SpringContextsUtil.getBean("maximoServiceImpl");
return bean.doAssetMainData(maximoParamModel); 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