cmci-pfcs-gateway/pom.xml
@@ -45,15 +45,9 @@ <version>2.0.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>3.3.1</version> </dependency> <dependency> <groupId>com.alibaba</groupId> cmci-pfcs-gateway/src/main/docker/Dockerfile
@@ -1,4 +1,5 @@ FROM java:8 #FROM java:8 太大了660多M 用下面这个120多M FROM openjdk:8-jdk-alpine MAINTAINER whc WORKDIR /home cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/controller/BillController.java
New file @@ -0,0 +1,41 @@ package com.jttech.pfcs.controller; import com.jttech.pfcs.services.IBillService; import com.jttech.pfcs.vo.req.bill.BillApiReqVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.jttech.pfcs.services.IPublicService; import com.jttech.pfcs.vo.ResponseVo; /** * 账单 * @author wanghc * @version 1.0.0 * @date 2023-03-07 */ @RestController @RequestMapping("/bill") public class BillController { private Logger mLogger = LoggerFactory.getLogger(getClass()); @Autowired private IBillService mBillService; @RequestMapping(value = "/postData", method = RequestMethod.POST) public ResponseVo post(@RequestBody BillApiReqVo reqVo) { final long beginTime = System.currentTimeMillis(); ResponseVo result = new ResponseVo(); try { return mBillService.post(reqVo); } finally { final long endTime = System.currentTimeMillis(); mLogger.info("Execute heart the result is {} time spent is {} ", result, (endTime - beginTime)); } } } cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/controller/TradeController.java
@@ -2,8 +2,8 @@ import com.jttech.pfcs.services.ITradeService; import com.jttech.pfcs.vo.ResponseVo; import com.jttech.pfcs.vo.req.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.ReqTranQryType; import com.jttech.pfcs.vo.req.trade.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.trade.ReqTranQryType; import com.jttech.pfcs.vo.resp.RspEPCSnglTranType; import com.jttech.pfcs.vo.resp.RspTranQryType; import org.slf4j.Logger; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/IBillService.java
New file @@ -0,0 +1,19 @@ package com.jttech.pfcs.services; import com.jttech.pfcs.vo.ResponseVo; import com.jttech.pfcs.vo.req.bill.BillApiReqVo; /** * @author wanghc * @version 1.0.0 * @date 2023-03-08 */ public interface IBillService { /** * post请求 * @param reqVo * @return */ ResponseVo post(BillApiReqVo reqVo); } cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/ITradeService.java
@@ -1,7 +1,7 @@ package com.jttech.pfcs.services; import com.jttech.pfcs.vo.req.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.ReqTranQryType; import com.jttech.pfcs.vo.req.trade.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.trade.ReqTranQryType; import com.jttech.pfcs.vo.resp.RspEPCSnglTranType; import com.jttech.pfcs.vo.resp.RspTranQryType; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/impl/BillServiceImpl.java
New file @@ -0,0 +1,65 @@ package com.jttech.pfcs.services.impl; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import com.alibaba.fastjson.JSONObject; import com.jttech.pfcs.services.IBillService; import com.jttech.pfcs.vo.ResponseVo; import com.jttech.pfcs.vo.req.bill.BillApiReqVo; import com.jttech.pfcs.vo.req.bill.BillApiRespVo; import okhttp3.*; /** * 账单服务 * @author wanghc * @version 1.0.0 * @date 2023-03-08 */ @Service public class BillServiceImpl implements IBillService { private Logger mLogger = LoggerFactory.getLogger(getClass()); private static final String contentType = "application/json;charset=utf-8"; /** * 请求编码格式 */ private static final String charset = "UTF-8"; private static final OkHttpClient client = new OkHttpClient.Builder() .connectionPool(new ConnectionPool(500, 5, TimeUnit.MINUTES)).connectTimeout(10000, TimeUnit.MILLISECONDS) .readTimeout(60000, TimeUnit.MILLISECONDS).build(); /** * post请求 * * @param reqVo * @return */ @Override public ResponseVo post(BillApiReqVo reqVo) { try { mLogger.info("BillServiceImpl.post reqvo={}", reqVo); Request request = new Request.Builder().url(reqVo.getUrl()) .post(RequestBody.create(MediaType.parse(contentType), JSONObject.toJSONString(reqVo))) .addHeader("Content-Type", contentType) .build(); Response resp = client.newCall(request).execute(); String body = new String(resp.body().bytes(), charset); mLogger.info("BillServiceImpl.post resp={}", body); return new ResponseVo(JSONObject.parseObject(body, BillApiRespVo.class)); } catch (Exception e) { mLogger.error("BillServiceImpl.post error={}", e); String errMsg = e.getMessage() == null ? "接口调用异常" : e.getMessage(); errMsg = errMsg.substring(0, Math.min(20, errMsg.length())); return ResponseVo.fail(-999, errMsg); } } } cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/impl/TradeServiceImpl.java
@@ -3,8 +3,8 @@ 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.req.trade.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.trade.ReqTranQryType; import com.jttech.pfcs.vo.resp.RspEPCSnglTranType; import com.jttech.pfcs.vo.resp.RspTranQryType; import org.slf4j.Logger; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/wsdl/ESBServerPortType.java
@@ -1,10 +1,10 @@ package com.jttech.pfcs.services.wsdl; import com.jttech.pfcs.util.ObjectFactory; import com.jttech.pfcs.vo.req.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.ReqPymtTrnRsltQryType; import com.jttech.pfcs.vo.req.ReqTranQryType; import com.jttech.pfcs.vo.req.ReqWHPymtTrnRsltQryType; import com.jttech.pfcs.vo.req.trade.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.trade.ReqPymtTrnRsltQryType; import com.jttech.pfcs.vo.req.trade.ReqTranQryType; import com.jttech.pfcs.vo.req.trade.ReqWHPymtTrnRsltQryType; import com.jttech.pfcs.vo.resp.RspEPCSnglTranType; import com.jttech.pfcs.vo.resp.RspPymtTrnRsltQryType; import com.jttech.pfcs.vo.resp.RspTranQryType; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/util/ObjectFactory.java
@@ -8,7 +8,7 @@ import com.jttech.pfcs.metadata.ReqHeaderType; import com.jttech.pfcs.metadata.RspHeaderType; import com.jttech.pfcs.vo.req.*; import com.jttech.pfcs.vo.req.trade.*; import com.jttech.pfcs.vo.resp.*; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/bill/BillApiReqVo.java
New file @@ -0,0 +1,134 @@ package com.jttech.pfcs.vo.req.bill; import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonIgnore; import java.io.Serializable; /** * 账单接口请求内容 * * @author wanghc * @version 1.0.0 * @date 2023-03-08 */ public class BillApiReqVo implements Serializable { private static final long serialVersionUID = 4116116617465409781L; @JSONField(name = "req_client_Id") private String reqClientId; @JSONField(name = "req_secret") private String reqSecret; @JSONField(name = "req_no") private String reqNo; @JSONField(name = "req_dateTime") private String reqDateTime; @JSONField(name = "req_body") private String reqBody; @JSONField(name = "req_sign") private String reqSign; /** * 请求地址 * 这个参数不需要给浦发 */ @JSONField(serialize = false) private String url; public String getReqClientId() { return reqClientId; } public void setReqClientId(String pReqClientId) { reqClientId = pReqClientId; } public String getReqSecret() { return reqSecret; } public void setReqSecret(String pReqSecret) { reqSecret = pReqSecret; } public String getReqNo() { return reqNo; } public void setReqNo(String pReqNo) { reqNo = pReqNo; } public String getReqDateTime() { return reqDateTime; } public void setReqDateTime(String pReqDateTime) { reqDateTime = pReqDateTime; } public String getReqBody() { return reqBody; } public void setReqBody(String pReqBody) { reqBody = pReqBody; } public String getReqSign() { return reqSign; } public void setReqSign(String pReqSign) { reqSign = pReqSign; } public String getUrl() { return url; } public void setUrl(String pUrl) { url = pUrl; } @Override public String toString() { return "BillApiReqVo{" + "reqClientId='" + reqClientId + '\'' + ", reqSecret='" + reqSecret + '\'' + ", reqNo='" + reqNo + '\'' + ", reqDateTime='" + reqDateTime + '\'' + ", reqBody='" + reqBody + '\'' + ", reqSign='" + reqSign + '\'' + ", url='" + url + '\'' + '}'; } } cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/bill/BillApiRespVo.java
New file @@ -0,0 +1,150 @@ package com.jttech.pfcs.vo.req.bill; import com.alibaba.fastjson.annotation.JSONField; import java.io.Serializable; /** * 账单接口请求返回内容 * * @author wanghc * @version 1.0.0 * @date 2023-03-08 */ public class BillApiRespVo implements Serializable { private static final long serialVersionUID = 5932333919303557958L; /** * 用户ID,银行给用户分配 */ @JSONField(name = "rep_client_Id") private String repClientId; /** * 唯一流水 请求流水 */ @JSONField(name = "rep_no") private String repNo; /** * yyyy-MM-dd HH:mm:ss 响应时间 */ @JSONField(name = "rep_dateTime") private String repDateTime; /** * 签名内容 */ @JSONField(name = "rep_sign") private String repSign; /** * 加密报文体 */ @JSONField(name = "rep_body") private String repBody; /** * 返回状态码“0000”-成功 “0001”-失败 */ @JSONField(name = "rep_Code") private String repCode; /** * 返回信息 */ @JSONField(name = "rep_Msg") private String repMsg; public String getRepClientId() { return repClientId; } public void setRepClientId(String pRepClientId) { repClientId = pRepClientId; } public String getRepNo() { return repNo; } public void setRepNo(String pRepNo) { repNo = pRepNo; } public String getRepDateTime() { return repDateTime; } public void setRepDateTime(String pRepDateTime) { repDateTime = pRepDateTime; } public String getRepSign() { return repSign; } public void setRepSign(String pRepSign) { repSign = pRepSign; } public String getRepBody() { return repBody; } public void setRepBody(String pRepBody) { repBody = pRepBody; } public String getRepCode() { return repCode; } public void setRepCode(String pRepCode) { repCode = pRepCode; } public String getRepMsg() { return repMsg; } public void setRepMsg(String pRepMsg) { repMsg = pRepMsg; } @Override public String toString() { return "BillApiRespVo{" + "repClientId='" + repClientId + '\'' + ", repNo='" + repNo + '\'' + ", repDateTime='" + repDateTime + '\'' + ", repSign='" + repSign + '\'' + ", repBody='" + repBody + '\'' + ", repCode='" + repCode + '\'' + ", repMsg='" + repMsg + '\'' + '}'; } } cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/trade/ReqEPCSnglTranType.java
File was renamed from cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/ReqEPCSnglTranType.java @@ -1,5 +1,5 @@ package com.jttech.pfcs.vo.req; package com.jttech.pfcs.vo.req.trade; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/trade/ReqPymtTrnRsltQryType.java
File was renamed from cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/ReqPymtTrnRsltQryType.java @@ -1,5 +1,5 @@ package com.jttech.pfcs.vo.req; package com.jttech.pfcs.vo.req.trade; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/trade/ReqSvcHeaderType.java
File was renamed from cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/ReqSvcHeaderType.java @@ -1,5 +1,5 @@ package com.jttech.pfcs.vo.req; package com.jttech.pfcs.vo.req.trade; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/trade/ReqTranQryType.java
File was renamed from cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/ReqTranQryType.java @@ -1,5 +1,5 @@ package com.jttech.pfcs.vo.req; package com.jttech.pfcs.vo.req.trade; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/trade/ReqWHPymtTrnRsltQryType.java
File was renamed from cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/vo/req/ReqWHPymtTrnRsltQryType.java @@ -1,5 +1,5 @@ package com.jttech.pfcs.vo.req; package com.jttech.pfcs.vo.req.trade; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; cmci-pfcs-gateway/src/main/resources/application.properties
@@ -1,4 +1,8 @@ spring.application.name=@pom.artifactId@ server.port=8400 server.servlet.context-path=/pf-api logging.config=classpath:logback.xml logging.config=classpath:logback.xml #### pf ¹ÒÏúÕËapi ############ pf.bill.trade.flow.qry.url=http://www.baidu.com pf.bill.file.notice.url=http://www.baidu.com cmci-pfcs-gateway/src/test/java/com/jttech/pfcs/services/WsdlTest.java
@@ -2,9 +2,9 @@ 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.ReqSvcHeaderType; import com.jttech.pfcs.vo.req.ReqTranQryType; import com.jttech.pfcs.vo.req.trade.ReqEPCSnglTranType; import com.jttech.pfcs.vo.req.trade.ReqSvcHeaderType; import com.jttech.pfcs.vo.req.trade.ReqTranQryType; import com.jttech.pfcs.vo.resp.RspEPCSnglTranType; import com.jttech.pfcs.vo.resp.RspTranQryType;