| | |
| | | package com.jttech.pfcs.services.impl; |
| | | |
| | | import com.jttech.pfcs.services.ITradeService; |
| | | import com.jttech.pfcs.services.wsdl.ESBServerPortType; |
| | | import com.jttech.pfcs.services.wsdl.S080030795; |
| | | import com.jttech.pfcs.vo.req.ReqEPCSnglTranType; |
| | | import com.jttech.pfcs.vo.req.ReqTranQryType; |
| | | import com.jttech.pfcs.vo.resp.RspEPCSnglTranType; |
| | | import com.jttech.pfcs.vo.resp.RspTranQryType; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.jttech.pfcs.services.ITradeService; |
| | | import com.jttech.pfcs.util.OkHttpUtil; |
| | | |
| | | import okhttp3.*; |
| | | |
| | | /** |
| | | * @author wanghc |
| | |
| | | * @date 2023-03-07 |
| | | */ |
| | | @Service |
| | | public class TradeServiceImpl implements ITradeService, InitializingBean { |
| | | public class TradeServiceImpl implements ITradeService { |
| | | |
| | | private Logger mLogger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | private ESBServerPortType mESBServerPortType; |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | | mESBServerPortType = new S080030795().getESBServerSoapEndpoint(); |
| | | } |
| | | |
| | | /** |
| | | * 单笔交易 |
| | | * excute |
| | | * |
| | | * @param reqVo |
| | | * @param content |
| | | * @return |
| | | */ |
| | | @Override |
| | | public RspEPCSnglTranType epcSnglTran(ReqEPCSnglTranType reqVo) { |
| | | mLogger.info("TradeServiceImpl.epcSnglTran req={}", reqVo); |
| | | RspEPCSnglTranType result = mESBServerPortType.epcSnglTran(reqVo); |
| | | mLogger.info("TradeServiceImpl.epcSnglTran resp={}", result); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 交易查询 |
| | | * |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @Override |
| | | public RspTranQryType tranQry(ReqTranQryType req) { |
| | | mLogger.info("TradeServiceImpl.tranQry req={}", req); |
| | | RspTranQryType result = mESBServerPortType.tranQry(req); |
| | | mLogger.info("TradeServiceImpl.tranQry resp={}", result); |
| | | public String excute(String url, String content) { |
| | | mLogger.info("TradeServiceImpl.excute req={}", content); |
| | | String result = ""; |
| | | try { |
| | | OkHttpClient.Builder builder = new OkHttpClient.Builder() |
| | | .sslSocketFactory(OkHttpUtil.getIgnoreInitedSslContext().getSocketFactory(), OkHttpUtil.IGNORE_SSL_TRUST_MANAGER_X509) |
| | | .hostnameVerifier(OkHttpUtil.getIgnoreSslHostnameVerifier()); |
| | | RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), content); |
| | | Request request = new Request.Builder().url(url).post(requestBody).build(); |
| | | Response response = builder.build().newCall(request).execute(); |
| | | result = response.body().string(); |
| | | } catch (Exception e) { |
| | | mLogger.error("TradeServiceImpl.excute error={}", e); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | mLogger.info("TradeServiceImpl.excute resp={}", result); |
| | | return result; |
| | | } |
| | | } |