Merge branch 'feature_探索'

This commit is contained in:
Weasley J
2023-08-09 17:35:02 +08:00
20 changed files with 499 additions and 55 deletions
@@ -1,5 +1,5 @@
#!/bin/bash
TAG="1.1.0"
TAG="1.1.1"
docker stop chinaport-data-signature && docker rm -f chinaport-data-signature
docker rmi -f weasleyj/chinaport-data-signature:${TAG}-arm64
docker build -t weasleyj/chinaport-data-signature:${TAG}-arm64 . -f ./Dockerfile
@@ -1,5 +1,5 @@
#!/bin/bash
TAG="1.1.0"
TAG="1.1.1"
docker stop chinaport-data-signature && docker rm -f chinaport-data-signature
docker rmi -f weasleyj/chinaport-data-signature:${TAG}
docker build -t weasleyj/chinaport-data-signature:${TAG} . -f ./Dockerfile
+16 -17
View File
@@ -5,13 +5,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cn.alphahub.eport.signature</groupId>
<artifactId>chinaport-data-signature-app</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<name>chinaport-data-signature-app</name>
<url>https://github.com/Weasley-J/chinaport-data-signature.git</url>
@@ -33,8 +33,9 @@
<dtt-utils.version>1.4.1</dtt-utils.version>
<commons-io.version>2.13.0</commons-io.version>
<multiple-email.version>3.0.0</multiple-email.version>
<signature-data-model.version>1.0.6</signature-data-model.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<signature-data-model.version>1.0.7</signature-data-model.version>
<jaxb-api.version>2.4.0-b180830.0359</jaxb-api.version>
<jaxb-runtime.version>2.3.8</jaxb-runtime.version>
<guava.version>32.1.1-jre</guava.version>
<sonar.host.url>http://192.168.31.140:9001</sonar.host.url>
<sonar.login>admin</sonar.login>
@@ -160,18 +161,6 @@
<version>${jna.version}</version>
</dependency>
<!-- jaxb -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@@ -199,6 +188,16 @@
<artifactId>hutool-all</artifactId>
<version>${hutool-all.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@@ -292,7 +291,7 @@
<artifactId>smart-doc-maven-plugin</artifactId>
<configuration>
<configFile>./src/main/resources/smart-doc.json</configFile>
<projectName>中国电子口岸(海口海关)报文加签API文档</projectName>
<projectName>中国电子口岸报文加签API文档</projectName>
<excludes>
<exclude>com.alibaba:fastjson</exclude>
</excludes>
@@ -3,6 +3,7 @@ package cn.alphahub.eport.signature.config;
import cn.alphahub.eport.signature.base.exception.EportWebClientException;
import cn.alphahub.eport.signature.core.web.EportCebMessageHttpClient;
import cn.alphahub.eport.signature.core.web.EportCustoms179HttpClient;
import cn.alphahub.eport.signature.core.web.EportReportResultHttpClient;
import cn.alphahub.eport.signature.core.web.WebfluxDemoHttpClient;
import cn.alphahub.eport.signature.support.OriginalPropertyNamingStrategy;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -84,6 +85,21 @@ public class WebClientConfiguration {
return httpServiceProxyFactory.createClient(EportCustoms179HttpClient.class);
}
/**
* @return A proxy bean of EportReportResultHttpClient
*/
@Bean
public EportReportResultHttpClient eportReportResultHttpClient() {
WebClient webClient = WebClient.builder()
.filter(logRequest())
.filter(logResponse())
.defaultStatusHandler(HttpStatusCode::isError, resp -> Mono.just(new EportWebClientException("Web Client 调用发生异常!")))
.baseUrl("http://" + new String(Base64.decodeBase64("MzYuMTAxLjIwOC4yMzA=")) + ":8090")
.build();
HttpServiceProxyFactory httpServiceProxyFactory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build();
return httpServiceProxyFactory.createClient(EportReportResultHttpClient.class);
}
/**
* @return A proxy bean of WebfluxDemoHttpClient
*/
@@ -0,0 +1,79 @@
package cn.alphahub.eport.signature.controller.rpc;
import cn.alphahub.eport.signature.base.domain.Result;
import cn.alphahub.eport.signature.config.ChinaEportProperties;
import cn.alphahub.eport.signature.core.web.EportReportResultHttpClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* 查询申报回执结果
*
* @author weasley
* @version 1.1.0
* @apiNote 目前仅实现:CEB311Message、CEB621Message 申报结果查询
*/
@Slf4j
@RestController
@RequestMapping("/rpc/eport/report/result")
public class EportReportResultController {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
@Autowired
private ChinaEportProperties chinaEportProperties;
@Autowired
private EportReportResultHttpClient eportReportResultHttpClient;
/**
* 查询311进口单申报结果
*
* @param qryId 查询时间,日期时间格式:yyyyMMddHHmmss
* @response {
* "message": "操作成功",
* "success": true,
* "timestamp": "2023-08-09 15:18:25",
* "code": 200,
* "data": "[{org_id=1, instm=1691397836000, re_order_guid=NWIVQA-WEASLEY-20230807164347-GCVZ4S, returnstatus=2, ebpcode=46016602EV, returntime2=20230807164356, ebccode=46016602EV, trans_dxpid=DXPENT0000530815, returninfo=新增申报成功[NWIVQA-WEASLEY-20230807164347-GCVZ4S], returntime=1691397830000, orderno=JO_D8079556739228400022}]"
* }
* @apiNote 查询此时间点之后的数据,必须在当前时间点之前,默认查询当前时间前15秒的申报数据,当前时间:20230806144417,则 qryId=20230806144401,不传的情况适用于刚刚申报成功查询回执结果,海关的处理时间间隔约为15秒
* @since 1.1.1
*/
@GetMapping("/ceb312msg")
public Result<String> getCeb312msgResult(@RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime qryId) {
qryId = ObjectUtils.defaultIfNull(qryId, LocalDateTime.now().plusSeconds(15));
log.info("开始查询311申报回执结果 {}", FORMATTER.format(qryId));
String ceb312msgResult = eportReportResultHttpClient.getCeb312msgResult(chinaEportProperties.getDxpId(), FORMATTER.format(qryId));
return Result.ok(ceb312msgResult);
}
/**
* 查询621进口单申报结果
*
* @param qryId 查询时间,日期时间格式:yyyyMMddHHmmss
* @response {
* "message": "操作成功",
* "success": true,
* "timestamp": "2023-08-09 15:26:53",
* "code": 200,
* "data": "[{org_id=1, instm=1691397837000, agentcode=46016602EV, re_elist_guid_cus=9422f96b-ccbc-4a69-a899-6d9dd583d501, returnstatus=2, ebpcode=46016602EV, preno=B20230807570793612, returntime2=20230807164357, ebccode=46016602EV, createtime=20230807164351, trans_dxpid=DXPENT0000530815, returninfo=清单新增申报成功[3CQHDG-WEASLEY-20230807164348-7KYRQN][电商企业编码:46016602EV订单编号:JO_D8079556739228400022], returntime=1691397830000, re_elist_guid=3CQHDG-WEASLEY-20230807164348-7KYRQN, customscode=6409}, {org_id=1, instm=1691397847000, agentcode=46016602EV, re_elist_guid_cus=9422f96b-ccbc-4a69-a899-6d9dd583d501, returnstatus=120, ebpcode=46016602EV, preno=B20230807570793612, returntime2=20230807164407, ebccode=46016602EV, createtime=20230807164355, trans_dxpid=DXPENT0000530815, returninfo=[Code:1800;Desc:逻辑校验通过], returntime=1691397831000, re_elist_guid=4e7a2dab-064b-410b-9ce6-e322c590ae3d, customscode=6409, invtno=64092023I000722460}, {org_id=1, instm=1691397847000, agentcode=46016602EV, re_elist_guid_cus=9422f96b-ccbc-4a69-a899-6d9dd583d501, returnstatus=800, ebpcode=46016602EV, preno=B20230807570793612, returntime2=20230807164407, ebccode=46016602EV, createtime=20230807164355, trans_dxpid=DXPENT0000530815, returninfo=[Code:2600;Desc:放行], returntime=1691397832000, re_elist_guid=4e7a2dab-064b-410b-9ce6-e322c590ae3d, customscode=6409, invtno=64092023I000722460}]"
* }
* @apiNote 查询此时间点之后的数据,必须在当前时间点之前,默认查询当前时间前15秒的申报数据,当前时间:20230806144417,则 qryId=20230806144401,不传的情况适用于刚刚申报成功查询回执结果,海关的处理时间间隔约为15秒
* @since 1.1.1
*/
@GetMapping("/ceb622msg")
public Result<String> getCe622msgResult(@RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime qryId) {
qryId = ObjectUtils.defaultIfNull(qryId, LocalDateTime.now().plusSeconds(15));
log.info("开始查询621进口单申报回执结果 {}", FORMATTER.format(qryId));
String ceb622msgResult = eportReportResultHttpClient.getCe622msgResult(chinaEportProperties.getDxpId(), FORMATTER.format(qryId));
return Result.ok(ceb622msgResult);
}
}
@@ -22,7 +22,7 @@ import java.util.Map;
* 电子口岸报文推送
*
* @author weasley
* @version 1.0.0
* @version 1.1.0
*/
@Slf4j
@RestController
@@ -38,9 +38,10 @@ public class EportUploadController {
* @param request CEBMessage报文
* @return 结果,OK 表示已推送
* @apiNote <ul>
* <b>支持JSON报文和XML报文</b>
* 支持JSON报文和XML报文
* <li>JSON报文: 无需组装XML结构报文</li>
* <li>XML报文: 需组装XML结构的报文</li>
* (已实现的CEBMessage报文: 311/621)
* </ul>
*/
@PostMapping("/CEBMessage")
@@ -24,7 +24,7 @@ import java.util.Set;
import static org.springframework.http.HttpStatus.NOT_FOUND;
/**
* 电子口岸报文加签测试
* 电子口岸报文加签测试
*
* @author lwj
* @version 1.1.0
@@ -0,0 +1,56 @@
package cn.alphahub.eport.signature.core.web;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;
/**
* 查询CEB Message申报回执Http客户端
*
* @author weasley
* @version 1.0.0
*/
@HttpExchange
public interface EportReportResultHttpClient {
/**
* 查询 311 申报回执
* <p>
* 返回示例:
* <pre>
* [
* {
* org_id=1,
* instm=1644919105000,
* re_order_guid=CEB311_HNZB_FXJK_20220215175237_0013,
* returnstatus=2,
* ebpcode=46121601BC,
* returntime2=20220215175825,
* ebccode=46121601BC,
* trans_dxpid=DXPENT0000458763,
* returninfo=新增申报成功
* [
* CEB311_HNZB_FXJK_20220215175237_0014
* ],
* returntime=1644919100000,
* orderno=20220215148803180891992064
* }
* ]
* </pre>
*
* @param dxpid 向中国电子口岸数据中心申请数据交换平台的用户编号
* @param qryid 查询时间,日期时间格式:yyyyMMddHHmmss
* @apiNote 查询此时间点之后的数据,必须在当前时间点之前
*/
@GetExchange(value = "/ceb312msg")
String getCeb312msgResult(@RequestParam String dxpid, @RequestParam String qryid);
/**
* 查询 621 申报回执
*
* @param dxpid 向中国电子口岸数据中心申请数据交换平台的用户编号
* @param qryid 查询时间,日期时间格式:yyyyMMddHHmmss
* @apiNote 查询此时间点之后的数据,必须在当前时间点之前
*/
@GetExchange(value = "/ceb622msg")
String getCe622msgResult(@RequestParam String dxpid, @RequestParam String qryid);
}
@@ -15,6 +15,8 @@ logging:
jdbc.sqltiming: debug
com.alibaba.cloud.nacos.client: error
com.alibaba.nacos: error
org.springframework.web.reactive.function.client.ExchangeFunctions: trace
reactor.netty.http.client.HttpClient: DEBUG
spring:
jackson:
@@ -40,6 +42,9 @@ spring:
enable: true
debug: false #是否开始debug模式,终端会打印日志
mvc:
log-request-details: on
#中国电子口岸u-key的配置参数
eport:
signature:
@@ -55,7 +60,7 @@ eport:
auth:
enable: off
token: DefaultAuthToken
# 报文传输企业元数据配置(数据上报)
# 报文传输企业元数据配置(数据上报)
report:
# CEBMessage XML加签配置
ceb-message:
@@ -15,6 +15,9 @@ logging:
jdbc.sqltiming: debug
com.alibaba.cloud.nacos.client: error
com.alibaba.nacos: error
org.springframework.web.reactive.function.client.ExchangeFunctions: trace
reactor.netty.http.client.HttpClient: DEBUG
file:
path: ./logs/
name: ${logging.file.path}/${spring.application.name}.log
@@ -49,6 +52,9 @@ spring:
enable: true
debug: false #是否开始debug模式,终端会打印日志
mvc:
log-request-details: on
#中国电子口岸u-key的配置参数
eport:
signature:
@@ -64,7 +70,7 @@ eport:
auth:
enable: true
token: DefaultAuthToken
# 报文传输企业元数据配置(数据上报)
# 报文传输企业元数据配置(数据上报)
report:
# CEBMessage XML加签配置
ceb-message:
@@ -15,6 +15,9 @@ logging:
jdbc.sqltiming: debug
com.alibaba.cloud.nacos.client: error
com.alibaba.nacos: error
org.springframework.web.reactive.function.client.ExchangeFunctions: trace
reactor.netty.http.client.HttpClient: DEBUG
file:
path: ./logs/
name: ${logging.file.path}/${spring.application.name}.log
@@ -49,6 +52,9 @@ spring:
enable: true
debug: false #是否开始debug模式,终端会打印日志
mvc:
log-request-details: on
#中国电子口岸u-key的配置参数
eport:
signature:
@@ -64,7 +70,7 @@ eport:
auth:
enable: on
token: DefaultAuthToken
# 报文传输企业元数据配置(数据上报)
# 报文传输企业元数据配置(数据上报)
report:
# CEBMessage XML加签配置
ceb-message:
@@ -8,7 +8,7 @@
"packageFilters": "cn.alphahub.*.controller.*.*Controller",
"md5EncryptedHtmlName": false,
"style": "xt256",
"projectName": "中国电子口岸(海口海关)加签后端接口文档",
"projectName": "中国电子口岸报文加签推送后端API文档",
"skipTransientField": true,
"sortByTitle": false,
"showAuthor": true,
@@ -56,6 +56,13 @@
"status": "编辑",
"author": "Weasley J",
"remarks": "补充API文档"
},
{
"version": "1.1.1",
"revisionTime": "2023-08-09 15:48",
"status": "更新",
"author": "Weasley J",
"remarks": "增加查询申报回执结果"
}
]
}
File diff suppressed because one or more lines are too long
@@ -8,8 +8,8 @@ api.push({
api[0].list.push({
alias: 'EportTestController',
order: '1',
link: '电子口岸报文加签测试',
desc: '电子口岸报文加签测试',
link: '电子口岸报文加签测试',
desc: '电子口岸报文加签测试',
list: []
})
api[0].list[0].list.push({
@@ -31,13 +31,32 @@ api[0].list[0].list.push({
desc: '执行脚本命令',
});
api[0].list.push({
alias: 'UkeyHealthController',
alias: 'EportReportResultController',
order: '2',
link: '查询申报回执结果',
desc: '查询申报回执结果',
list: []
})
api[0].list[1].list.push({
order: '1',
deprecated: 'false',
url: 'http://localhost:8080/rpc/eport/report/result/ceb312msg',
desc: '查询311进口单申报结果',
});
api[0].list[1].list.push({
order: '2',
deprecated: 'false',
url: 'http://localhost:8080/rpc/eport/report/result/ceb622msg',
desc: '查询621进口单申报结果',
});
api[0].list.push({
alias: 'UkeyHealthController',
order: '3',
link: 'ukey健康状态恢复',
desc: 'Ukey健康状态恢复',
list: []
})
api[0].list[1].list.push({
api[0].list[2].list.push({
order: '1',
deprecated: 'false',
url: 'http://localhost:8080/rpc/eport/ukey/health/endpoint/{command}',
@@ -45,18 +64,18 @@ api[0].list[1].list.push({
});
api[0].list.push({
alias: 'EportUploadController',
order: '3',
order: '4',
link: '电子口岸报文推送',
desc: '电子口岸报文推送',
list: []
})
api[0].list[2].list.push({
api[0].list[3].list.push({
order: '1',
deprecated: 'false',
url: 'http://localhost:8080/rpc/eport/upload/CEBMessage',
desc: '推送CEBMessage报文',
});
api[0].list[2].list.push({
api[0].list[3].list.push({
order: '2',
deprecated: 'false',
url: 'http://localhost:8080/rpc/eport/upload/179/data',
@@ -64,12 +83,12 @@ api[0].list[2].list.push({
});
api[0].list.push({
alias: 'EportCertController',
order: '4',
order: '5',
link: '电子口岸x509证书',
desc: '电子口岸X509证书',
list: []
})
api[0].list[3].list.push({
api[0].list[4].list.push({
order: '1',
deprecated: 'false',
url: 'http://localhost:8080/rpc/eport/cert/download',
@@ -77,12 +96,12 @@ api[0].list[3].list.push({
});
api[0].list.push({
alias: 'EportSignController',
order: '5',
order: '6',
link: '电子口岸报文加签',
desc: '电子口岸报文加签',
list: []
})
api[0].list[4].list.push({
api[0].list[5].list.push({
order: '1',
deprecated: 'false',
url: 'http://localhost:8080/rpc/eport/signature',
@@ -0,0 +1,99 @@
package cn.alphahub.eport.signature.core.web;
import cn.alphahub.eport.signature.core.SignHandler;
import cn.alphahub.eport.signature.entity.SignRequest;
import cn.alphahub.eport.signature.entity.SignResult;
import cn.alphahub.eport.signature.entity.UkeyRequest;
import cn.hutool.json.JSONUtil;
import io.github.weasleyj.china.eport.sign.model.customs179.Customs179Request;
import io.github.weasleyj.china.eport.sign.util.GUIDUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.LinkedHashMap;
import java.util.Map;
import static cn.alphahub.dtt.plus.util.JacksonUtil.toJson;
import static cn.alphahub.eport.signature.core.CertificateHandler.SING_DATA_METHOD;
@Slf4j
@SpringBootTest
class EportCustoms179HttpClientTest {
@Autowired
SignHandler signHandler;
@Autowired
EportCustoms179HttpClient eportCustoms179HttpClient;
@Test
void report179Data() {
String json = """
{
"sessionID": "fe2374-8fnejf97-32839218",
"payExchangeInfoHead": {
"guid": "fe2374-8fnejf97-32839218",
"initalRequest": "<xml><appid>wxa3412c979c7c6fb7</appid><mch_id>1537923071</mch_id><nonce_str>20220214148382001542606848</nonce_str><sign>38198AD6D22E59B3CCC683D67D8BB402</sign><sign_type>MD5</sign_type><body>测试订单编号411312450000027161</body><attach><![CDATA[16dbeaa5-92d8-47f5-a0a8-813a4d45a5f9]]></attach><out_trade_no>20220214148382001542606848</out_trade_no><total_fee>1</total_fee><spbill_create_ip>10.0.12.208</spbill_create_ip><notify_url>https://boss-dev.fengyouhui.net/be/api/mall-payment-c/api/public/gateway/payment/notice/wx/pay/20220214148382001542606848</notify_url><trade_type>MWEB</trade_type><openid></openid></xml>",
"initalResponse": "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg><result_code><![CDATA[SUCCESS]]></result_code><mch_id><![CDATA[1537923071]]></mch_id><appid><![CDATA[wxa3412c979c7c6fb7]]></appid><nonce_str><![CDATA[6SgxJ98xsr1nUnRG]]></nonce_str><sign><![CDATA[EB632B9C9F8BCB8027ACE9195878EE4F]]></sign><prepay_id><![CDATA[wx14105706563206ab24a00689936c800000]]></prepay_id><trade_type><![CDATA[MWEB]]></trade_type><mweb_url><![CDATA[https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx14105706563206ab24a00689936c800000&package=2518465012]]></mweb_url></xml>",
"ebpCode": "请替换",
"payCode": "1537923071",
"payTransactionId": "20220214148382001542606848",
"totalAmount": 0.01,
"currency": "502",
"verDept": "3",
"payType": "1",
"tradingTime": "20220214105714",
"note": "备注"
},
"payExchangeInfoLists": [
{
"orderNo": "202009231454218421271832",
"goodsInfo": [
{
"gname": "济州花梨精华面膜",
"itemLink": "http://m.yunjiweidian.com/yunjibuyer/static/vue-buyer/idc/index.html#/detail?itemId=999761&shopId=453"
}
],
"recpAccount": "请替换",
"recpCode": "请替换",
"recpName": "请替换"
}
],
"serviceTime": "1533282603450"
}
""";
Customs179Request customs179Request = JSONUtil.toBean(json, Customs179Request.class);
String guid = GUIDUtil.getGuid();
customs179Request.setSessionID(guid);
customs179Request.setServiceTime(String.valueOf(System.currentTimeMillis()));
customs179Request.getPayExchangeInfoHead().setGuid(guid);
// 加签
String dataInfo179 = "\"sessionID\":\"" + customs179Request.getSessionID() + "\"||" +
"\"payExchangeInfoHead\":\"" + toJson(customs179Request.getPayExchangeInfoHead()) + "\"||" +
"\"payExchangeInfoLists\":\"" + toJson(customs179Request.getPayExchangeInfoLists()) + "\"||" +
"\"serviceTime\":" + "\"" + customs179Request.getServiceTime() + "\"";
UkeyRequest ukeyRequest = new UkeyRequest(SING_DATA_METHOD, new LinkedHashMap<>() {{
put("inData", dataInfo179);
put("passwd", "88888888");
}});
String signParams = toJson(ukeyRequest);
SignRequest request = new SignRequest(dataInfo179);
SignResult result = signHandler.sign(request, signParams);
customs179Request.setCertNo(result.getCertNo());
customs179Request.setSignValue(result.getSignatureValue());
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("payExInfoStr", toJson(customs179Request));
log.info("begin reportrequest data is {}", toJson(paramMap));
eportCustoms179HttpClient.report179Data(paramMap).subscribe(capture179DataResponse -> {
Assertions.assertNotNull(capture179DataResponse, "海关 179 数据返回不为空");
System.out.println(JSONUtil.toJsonPrettyStr(capture179DataResponse));
});
}
}
@@ -0,0 +1,35 @@
package cn.alphahub.eport.signature.core.web;
import cn.alphahub.eport.signature.config.ChinaEportProperties;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.time.format.DateTimeFormatter;
@Slf4j
@SpringBootTest
class EportReportResultHttpClientTest {
@Autowired
ChinaEportProperties chinaEportProperties;
@Autowired
EportReportResultHttpClient eportReportResultHttpClient;
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
@Test
@DisplayName("查询 311 申报回执")
void getCeb312msg() {
String result = eportReportResultHttpClient.getCeb312msgResult(chinaEportProperties.getDxpId(), "20230806121200");
log.info("311回执结果:{}", result);
}
@Test
@DisplayName("查询 621 申报回执")
void getCe622msg() {
String result = eportReportResultHttpClient.getCe622msgResult(chinaEportProperties.getDxpId(), "20230806121200");
log.info("621回执结果:{}", result);
}
}
@@ -11,6 +11,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import io.github.weasleyj.china.eport.sign.model.cebmessage.export.CEB303Message;
import io.github.weasleyj.china.eport.sign.util.JAXBUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@@ -27,6 +28,7 @@ import java.util.HashMap;
class Upload303XmlTests {
@Test
@DisplayName("303进口单加签测试")
void sign() {
final String data = """
<?xml version="1.0" encoding="utf-8" standalone="no"?>
+4 -3
View File
@@ -5,7 +5,7 @@
<groupId>io.github.weasley-j</groupId>
<artifactId>chinaport-data-signature-data-model</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<name>chinaport-data-signature-data-model</name>
<packaging>jar</packaging>
<url>https://github.com/Weasley-J/chinaport-data-signature/tree/main/chinaport-data-signature-data-model</url>
@@ -38,7 +38,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<lombok.version>1.18.28</lombok.version>
<slf4j-api.version>2.0.7</slf4j-api.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<jaxb-api.version>2.4.0-b180830.0359</jaxb-api.version>
<jaxb-runtime.version>2.3.8</jaxb-runtime.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<nexus-staging.version>1.6.13</nexus-staging.version>
<maven-javadoc.version>3.4.0</maven-javadoc.version>
@@ -64,7 +65,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-api.version}</version>
<version>${jaxb-runtime.version}</version>
</dependency>
</dependencies>
+1 -1
View File
@@ -5,7 +5,7 @@
<groupId>cn.gov.chinaport</groupId>
<artifactId>chinaport-data-signature</artifactId>
<version>1.1.0</version>
<version>1.0.0</version>
<name>chinaport-data-signature</name>
<packaging>pom</packaging>
<url>https://github.com/Weasley-J/chinaport-data-signature.git</url>
+109 -8
View File
@@ -1,14 +1,15 @@
# 中国电子口岸(海口海关)报文加签API文档
# 中国电子口岸报文加签API文档
| Version | Update Time | Status | Author | Description |
|---------|-------------|--------|--------|-------------|
|1.0.0|2022-02-16 10:30|创建|Weasley J|创建API文档|
|1.0.9|2023-06-11 15:36|编辑|Weasley J|更新API文档|
|1.1.0|2023-07-15 15:36|编辑|Weasley J|补充API文档|
|1.1.1|2023-08-09 15:48|更新|Weasley J|增加查询申报回执结果|
## 电子口岸报文加签测试
## 电子口岸报文加签测试
### 海关总署XML数据加签
**URL:** http://localhost:8080/rpc/eport/test/cebmessage/signature
@@ -52,15 +53,15 @@ curl -X GET -H 'x-auth-token-eport-sign:DefaultAuthToken' -i http://localhost:80
{
"message": "操作成功",
"success": true,
"timestamp": "2023-07-30 19:39:34",
"timestamp": "2023-07-31 17:42:58",
"code": 200,
"data": {
"success": true,
"certNo": "03000000000cde6f",
"x509Certificate": "MIIEoDCCBESgAwIBAgIIAwAAAAAM3m8wDAYIKoEcz1UBg3UFADCBmDELMAkGA1UEBhMCQ04xDzANBgNVBAgMBuWMl+S6rDEPMA0GA1UEBwwG5YyX5LqsMRswGQYDVQQKDBLkuK3lm73nlLXlrZDlj6PlsrgxGzAZBgNVBAsMEuivgeS5pueuoeeQhuS4reW/gzEtMCsGA1UEAwwk5Lit5Zu955S15a2Q5Lia5Yqh6K+B5Lmm566h55CG5Lit5b+DMB4XDTIzMDMyOTAwMDAwMFoXDTMzMDMyOTAwMDAwMFowVjELMAkGA1UEBhMCQ04xMzAxBgNVBAsMKua1t+WNl+ecgeiNo+iqiei/m+WHuuWPo+i0uOaYk+aciemZkOWFrOWPuDESMBAGA1UEAwwJ5p2o5aaC6YeRMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE0vOQmplAr9igPZrA8F1msqnFd0U++6G6NhG5rNuIUWft0BwQn7eSJkt5/fvSSoe7pUg2/awHUWPnzkeeQc7oVqOCArUwggKxMBEGCWCGSAGG+EIBAQQEAwIFoDAOBgNVHQ8BAf8EBAMCBsAwCQYDVR0TBAIwADApBgNVHSUEIjAgBggrBgEFBQcDAgYIKwYBBQUHAwQGCisGAQQBgjcUAgIwHwYDVR0jBBgwFoAURCQxt0wEvoAVXmuo4N1bjKXTh0UwHQYDVR0OBBYEFAytGob5L0WqhOCZ5l6Lf2jUdNrAMGgGA1UdIARhMF8wXQYEVR0gADBVMFMGCCsGAQUFBwIBFkdodHRwczovL3d3dy5jaGluYXBvcnQuZ292LmNuL3RjbXNmaWxlL3UvY21zL3d3dy8yMDIyMDQvMTIxMzI5NDh4dDZwLnBkZjB/BgNVHR8EeDB2MHSgcqBwhm5sZGFwOi8vbGRhcC5jaGluYXBvcnQuZ292LmNuOjM4OS9jbj1jcmwwMzAwMDAsb3U9Y3JsMDAsb3U9Y3JsLGM9Y24/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdD9iYXNlP2NuPWNybDAzMDAwMDA+BggrBgEFBQcBAQQyMDAwLgYIKwYBBQUHMAGGImh0dHA6Ly9vY3NwLmNoaW5hcG9ydC5nb3YuY246ODgwMC8wOgYKKwYBBAGpQ2QFAQQsDCrmtbfljZfnnIHojaPoqonov5vlh7rlj6PotLjmmJPmnInpmZDlhazlj7gwEgYKKwYBBAGpQ2QFAwQEDAIwMTAiBgorBgEEAalDZAUIBBQMEjUxMjMyNDE5NjQxMDE3Mjk3WDAgBgorBgEEAalDZAUJBBIMEDAzLUpKMEc5MDAyMjA3NTIwGQYKKwYBBAGpQ2QFCwQLDAlNQTVUTkZHWTkwEgYKKwYBBAGpQ2QFDAQEDAIwMDASBgorBgEEAalDZAIBBAQMAjEyMBIGCisGAQQBqUNkAgQEBAwCMTQwDAYIKoEcz1UBg3UFAANIADBFAiBM4OVAc8aaCZU4XFfcVMkC7bWIIenRnPLxrnwVeYO3CQIhANQ767YIurkJCoLtwyqQPbUZe/+3BjGZcIWqB1mAl9T+",
"digestValue": "EW5//PlrSsuQ8pw+hRRtSsSDaN4=",
"signatureValue": "JnCJZxlCX1/fp0vtdrIePjmYZXoyiqTc2kdtYIhI7iT77knJACq5nSMZ0Q+6H3coHJIxA92niYOyBOZqPUfiwA==",
"signatureNode": "<ds:SignedInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\n <ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>\n <ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sm2-sm3\"/>\n <ds:Reference URI=\"\">\n <ds:Transforms>\n <ds:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/>\n </ds:Transforms>\n <ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\n <ds:DigestValue>EW5//PlrSsuQ8pw+hRRtSsSDaN4=</ds:DigestValue>\n </ds:Reference>\n</ds:SignedInfo>"
"digestValue": "/uy5whbEnIhnrSkF7hSAJNm8ISI=",
"signatureValue": "lziAtii3Ibn4UaHMAZ5MI90PLlQvn8Qm7m06gjRM/TcCI5pCtCbBGsZ+UoMmjbSjk4KP90wugL5DV5PXKVwYlA==",
"signatureNode": "<ds:SignedInfo xmlns:ceb=\"http://www.chinaport.gov.cn/ceb\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sm2-sm3\"></ds:SignatureMethod><ds:Reference URI=\"\"><ds:Transforms><ds:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></ds:DigestMethod><ds:DigestValue>/uy5whbEnIhnrSkF7hSAJNm8ISI=</ds:DigestValue></ds:Reference></ds:SignedInfo>"
}
}
```
@@ -152,6 +153,105 @@ curl -X GET -H 'x-auth-token-eport-sign:DefaultAuthToken' -i http://localhost:80
Return void.
```
## 查询申报回执结果
### 查询311进口单申报结果
**URL:** http://localhost:8080/rpc/eport/report/result/ceb312msg
**Type:** GET
**Author:** weasley
**Content-Type:** application/x-www-form-urlencoded;charset=UTF-8
**Description:** 查询此时间点之后的数据,必须在当前时间点之前,默认查询当前时间前15秒的申报数据,当前时间:20230806144417,则 qryId=20230806144401,不传的情况适用于刚刚申报成功查询回执结果,海关的处理时间间隔约为15秒
**Request-headers:**
| Header | Type | Required | Description | Since |
|--------|------|----------|-------------|-------|
|x-auth-token-eport-sign|string|true|客户端加签时携带的请求头,token值必须和配置文件里面配置鉴权token相等|v1.1.0|
**Query-parameters:**
| Parameter | Type | Required | Description | Since |
|-----------|------|----------|-------------|-------|
|qryId|string|false|查询时间,日期时间格式:yyyyMMddHHmmss|-|
**Request-example:**
```
curl -X GET -H 'x-auth-token-eport-sign:DefaultAuthToken' -i http://localhost:8080/rpc/eport/report/result/ceb312msg?qryId=yyyy-MM-dd HH:mm:ss
```
**Response-fields:**
| Field | Type | Description | Since |
|-------|------|-------------|-------|
|message|string|返回消息|-|
|success|boolean|是否成功|-|
|timestamp|string|响应时间戳|-|
|code|int32|状态码|-|
|data|string|响应数据|-|
**Response-example:**
```
{
"message": "操作成功",
"success": true,
"timestamp": "2023-08-09 15:18:25",
"code": 200,
"data": "[{org_id=1, instm=1691397836000, re_order_guid=NWIVQA-WEASLEY-20230807164347-GCVZ4S, returnstatus=2, ebpcode=46016602EV, returntime2=20230807164356, ebccode=46016602EV, trans_dxpid=DXPENT0000530815, returninfo=新增申报成功[NWIVQA-WEASLEY-20230807164347-GCVZ4S], returntime=1691397830000, orderno=JO_D8079556739228400022}]"
}
```
### 查询621进口单申报结果
**URL:** http://localhost:8080/rpc/eport/report/result/ceb622msg
**Type:** GET
**Author:** weasley
**Content-Type:** application/x-www-form-urlencoded;charset=UTF-8
**Description:** 查询此时间点之后的数据,必须在当前时间点之前,默认查询当前时间前15秒的申报数据,当前时间:20230806144417,则 qryId=20230806144401,不传的情况适用于刚刚申报成功查询回执结果,海关的处理时间间隔约为15秒
**Request-headers:**
| Header | Type | Required | Description | Since |
|--------|------|----------|-------------|-------|
|x-auth-token-eport-sign|string|true|客户端加签时携带的请求头,token值必须和配置文件里面配置鉴权token相等|v1.1.0|
**Query-parameters:**
| Parameter | Type | Required | Description | Since |
|-----------|------|----------|-------------|-------|
|qryId|string|false|查询时间,日期时间格式:yyyyMMddHHmmss|-|
**Request-example:**
```
curl -X GET -H 'x-auth-token-eport-sign:DefaultAuthToken' -i http://localhost:8080/rpc/eport/report/result/ceb622msg?qryId=yyyy-MM-dd HH:mm:ss
```
**Response-fields:**
| Field | Type | Description | Since |
|-------|------|-------------|-------|
|message|string|返回消息|-|
|success|boolean|是否成功|-|
|timestamp|string|响应时间戳|-|
|code|int32|状态码|-|
|data|string|响应数据|-|
**Response-example:**
```
{
"message": "操作成功",
"success": true,
"timestamp": "2023-08-09 15:26:53",
"code": 200,
"data": "[{org_id=1, instm=1691397837000, agentcode=46016602EV, re_elist_guid_cus=9422f96b-ccbc-4a69-a899-6d9dd583d501, returnstatus=2, ebpcode=46016602EV, preno=B20230807570793612, returntime2=20230807164357, ebccode=46016602EV, createtime=20230807164351, trans_dxpid=DXPENT0000530815, returninfo=清单新增申报成功[3CQHDG-WEASLEY-20230807164348-7KYRQN][电商企业编码:46016602EV订单编号:JO_D8079556739228400022], returntime=1691397830000, re_elist_guid=3CQHDG-WEASLEY-20230807164348-7KYRQN, customscode=6409}, {org_id=1, instm=1691397847000, agentcode=46016602EV, re_elist_guid_cus=9422f96b-ccbc-4a69-a899-6d9dd583d501, returnstatus=120, ebpcode=46016602EV, preno=B20230807570793612, returntime2=20230807164407, ebccode=46016602EV, createtime=20230807164355, trans_dxpid=DXPENT0000530815, returninfo=[Code:1800;Desc:逻辑校验通过], returntime=1691397831000, re_elist_guid=4e7a2dab-064b-410b-9ce6-e322c590ae3d, customscode=6409, invtno=64092023I000722460}, {org_id=1, instm=1691397847000, agentcode=46016602EV, re_elist_guid_cus=9422f96b-ccbc-4a69-a899-6d9dd583d501, returnstatus=800, ebpcode=46016602EV, preno=B20230807570793612, returntime2=20230807164407, ebccode=46016602EV, createtime=20230807164355, trans_dxpid=DXPENT0000530815, returninfo=[Code:2600;Desc:放行], returntime=1691397832000, re_elist_guid=4e7a2dab-064b-410b-9ce6-e322c590ae3d, customscode=6409, invtno=64092023I000722460}]"
}
```
## Ukey健康状态恢复
### ukey健康指令
**URL:** http://localhost:8080/rpc/eport/ukey/health/endpoint/{command}
@@ -222,9 +322,10 @@ curl -X POST -H 'x-auth-token-eport-sign:DefaultAuthToken' -i http://localhost:8
**Content-Type:** application/json
**Description:** <ul>
<b>支持JSON报文和XML报文</b>
支持JSON报文和XML报文
<li>JSON报文: 无需组装XML结构报文</li>
<li>XML报文: 需组装XML结构的报文</li>
(已实现的CEBMessage报文: 311/621)
</ul>
**Request-headers:**
@@ -238,7 +339,7 @@ curl -X POST -H 'x-auth-token-eport-sign:DefaultAuthToken' -i http://localhost:8
| Parameter | Type | Required | Description | Since |
|-----------|------|----------|-------------|-------|
|messageType|enum|true|消息类型<br/>[Enum values:<br/>CEB311Message("CEB311Message")<br/>CEB621Message("CEB621Message")<br/>CEB303Message("CEB303Message")<br/>]|-|
|messageType|enum|true|消息类型<br/>[Enum values:<br/>CEB311Message("CEB311Message", IMPORT_MESSAGE)<br/>CEB312Message("CEB312Message", IMPORT_MESSAGE)<br/>CEB411Message("CEB411Message", IMPORT_MESSAGE)<br/>CEB412Message("CEB412Message", IMPORT_MESSAGE)<br/>CEB511Message("CEB511Message", IMPORT_MESSAGE)<br/>CEB512Message("CEB512Message", IMPORT_MESSAGE)<br/>CEB513Message("CEB513Message", IMPORT_MESSAGE)<br/>CEB514Message("CEB514Message", IMPORT_MESSAGE)<br/>CEB621Message("CEB621Message", IMPORT_MESSAGE)<br/>CEB622Message("CEB622Message", IMPORT_MESSAGE)<br/>CEB623Message("CEB623Message", IMPORT_MESSAGE)<br/>CEB624Message("CEB624Message", IMPORT_MESSAGE)<br/>CEB625Message("CEB625Message", IMPORT_MESSAGE)<br/>CEB626Message("CEB626Message", IMPORT_MESSAGE)<br/>CEB711Message("CEB711Message", IMPORT_MESSAGE)<br/>CEB712Message("CEB712Message", IMPORT_MESSAGE)<br/>CEB213Message("CEB213Message", EXPORT_MESSAGE)<br/>CEB214Message("CEB214Message", EXPORT_MESSAGE)<br/>CEB215Message("CEB215Message", EXPORT_MESSAGE)<br/>CEB216Message("CEB216Message", EXPORT_MESSAGE)<br/>CEB303Message("CEB303Message", EXPORT_MESSAGE)<br/>CEB304Message("CEB304Message", EXPORT_MESSAGE)<br/>CEB403Message("CEB403Message", EXPORT_MESSAGE)<br/>CEB404Message("CEB404Message", EXPORT_MESSAGE)<br/>CEB505Message("CEB505Message", EXPORT_MESSAGE)<br/>CEB506Message("CEB506Message", EXPORT_MESSAGE)<br/>CEB507Message("CEB507Message", EXPORT_MESSAGE)<br/>CEB508Message("CEB508Message", EXPORT_MESSAGE)<br/>CEB509Message("CEB509Message", EXPORT_MESSAGE)<br/>CEB510Message("CEB510Message", EXPORT_MESSAGE)<br/>CEB603Message("CEB603Message", EXPORT_MESSAGE)<br/>CEB604Message("CEB604Message", EXPORT_MESSAGE)<br/>CEB605Message("CEB605Message", EXPORT_MESSAGE)<br/>CEB606Message("CEB606Message", EXPORT_MESSAGE)<br/>CEB607Message("CEB607Message", EXPORT_MESSAGE)<br/>CEB608Message("CEB608Message", EXPORT_MESSAGE)<br/>CEB701Message("CEB701Message", EXPORT_MESSAGE)<br/>CEB702Message("CEB702Message", EXPORT_MESSAGE)<br/>CEB792Message("CEB792Message", EXPORT_MESSAGE)<br/>]|-|
|dataType|enum|true|报文的数据类型<br/>[Enum values:<br/>JSON()<br/>XML()<br/>]|-|
|cebMessage|object|true|进口单、出口单的底层数据模型<br/><ul><br/>以CEB311Message数据类型为例<br/><li><br/><p>JSON示例</p><br/><pre><code><br/>{"order":{"orderHead":{"guid":"AFNC7T-WEASLEY-20230713095517-N04JEE","appType":"1","appTime":"20230704181028","appStatus":"2","orderType":"I","orderNo":"T_C5051511332138160010","ebpCode":"4601630004","ebpName":"海南省荣誉进出口贸易有限公司","ebcCode":"4601630004","ebcName":"海南省荣誉进出口贸易有限公司","goodsValue":"0.01","freight":"0","discount":"0","taxTotal":"0","acturalPaid":"0.01","currency":"142","buyerRegNo":"4","buyerName":"袁晓雨","buyerTelephone":"13701727375","buyerIdType":"1","buyerIdNumber":"130435200009241538","consignee":"袁晓雨","consigneeTelephone":"13701727375","consigneeAddress":"北京北京市东城区","note":"test"},"orderList":[{"gnum":1,"itemNo":"1","itemName":"LANNA兰纳","gmodel":"10片/包","itemDescribe":"","barCode":"1","unit":"011","qty":"1","price":"1","totalPrice":"1","currency":"142","country":"136","note":"test"}]},"guid":"AFNC7T-WEASLEY-20230713095517-N04JEE","version":"1.0","baseTransfer":{"copCode":"4601630004","copName":"海南省荣誉进出口贸易有限公司","dxpMode":"DXP","dxpId":"DXPENT0000530815","note":"test"}}<br/></code></pre><br/></li><br/><li><br/><p>XML示例: 不带ds:Signature节点的CEBXxxMessage.xml原文;<a href='http://tool.qdhuaxun.cn/ceb/CEB311Message.xml'>待加签xml报文样例</a></p><br/></li><br/></ul>|-|