china-port-dds (中国电子口岸海关总署XML报文&海关179数据加签)
Gitee源码地址:https://gitee.com/wxm-cookies/china-port-dds
Version | Update Time | Status | Author | Description |
---|---|---|---|---|
1.0.0 | 2023-07-14 10:30 | 创建 | Weixm | 创建api文档 |
application.yml配置说明
名称 | 说明 | 默认值 |
---|---|---|
task.cron | 定时器cron | 0/20 * * * * ? |
dds.url | 加签URL[本地加签客户端URL] | http://localhost:8080/rpc/eport/signature |
dds.gain-url | 获取加密数据URL | |
dds.gain-size | 加密数据的获取条数 | 10 |
dds.notify-url | 数据加密好后的回调URL | |
push-179-url | 推单179的URL | https://customs.chinaport.gov.cn/ceb2grab/grab/realTimeDataUpload |
Task说明
china-port-dds定时器轮询 -> 获取商城系统的加签数据 -> 循环需要加签数据 -> chinaport-data-signature加签 -> 签名回调给商城
公共响应(平台加签数据/Task加签回调 都基于以下格式,data为业务响应)
Field | Type | Description |
---|---|---|
code | Integer | 状态码 200-成功 |
data | Object | 数据 |
msg | String | 描述 |
@Data
public class DdsR<T> implements Serializable {
private Integer code;
private T data;
private String msg;
public static <T> DdsR<T> ok(T data){
DdsR<T> r = new DdsR<>();
r.setCode(200);
r.setData(data);
r.setMsg("成功");
return r;
}
public static <T> DdsR<T> error(String msg){
DdsR<T> r = new DdsR<>();
r.setCode(500);
r.setData(null);
r.setMsg(msg);
return r;
}
}
加签数据获取说明(平台准备接口 china-port-dds进行配置调用)
-
URL: application.yml配置中dds.gain-url
-
Type: GET
-
Author: Weixm
-
Description: 获取平台需要加签的数据List
-
Request-fields:
Field Type Description size Integer 加签数据获取条数 application.yml中配置的dds.gain-size -
Response-fields:
Field Type Description id Integer 平台加签数据唯一标记 type String 类型[枚举ChinaPortDdsTypeEnum] reqValue String 加签数据 -
Request-example:
curl -X GET -i http://localhost:11201/order/china/port/dds/get?size=20
-
Response-example:
{ "code":200, "data":[ { "id":5, "type":"179", "reqValue":"加签数据xxxxx" } ], "msg":"成功" }
-
Java-example:
@GetMapping("/get") public DdsR<List<ChinaPortDdsEntity>> get(@RequestParam("size") Integer size){ try { List<ChinaPortDdsEntity> list = this.获取签名的List(size); return DdsR.ok(list); }catch (Exception e){ return DdsR.error("查询失败"); } } @Data public class ChinaPortDdsEntity implements Serializable { /** * ID */ private Integer id; /** * 类型[枚举ChinaPortDdsTypeEnum] */ private String type; /** * 加签请求 */ private String reqValue; }
加签数据回调说明(平台准备接口 china-port-dds进行配置调用)
-
URL: application.yml配置中dds.notify-url
-
Type: Post
-
Author: Weixm
-
Description: 加签数据返回
-
Request-fields:
Field Type Description id Integer 平台加签数据唯一标记 type Integer 类型[枚举ChinaPortDdsTypeEnum] code Integer 状态 200为成功 result JSONObject String -
Request-example:
curl -X POST http://localhost:11201/order/china/port/dds/notify -H "Content-Type: application/json;" -d "{\"msg\":\"成功\",\"code\":200,\"data\":{\"msg\":\"POST请求失败Failed to connect to localhost/0:0:0:0:0:0:0:1:8080\",\"result\":\"POST请求失败Failed to connect to localhost/0:0:0:0:0:0:0:1:8080\",\"code\":500,\"id\":6,\"type\":\"179\"}}"
-
Response-example:
{ "code":200, "data":"成功", "msg":"成功" }
-
Java-example:
@PostMapping("/notify") public DdsR<String> notify(@RequestBody JSONObject param){ JSONObject data = param.getJSONObject("data"); //ID Integer id = data.getInteger("id"); //类型 String type = data.getString("type"); //状态码 if (new Integer("200").equals(data.getInteger("code"))){ //成功处理 this.处理回调成功加签数据(id,type,data); }else { //失败处理 this.处理回调失败加签数据(id,data.getString("result")); } return DdsR.ok("成功"); }
179响应示例
- 成功
{ "msg":"成功", "code":200, "data":{ "result":"上传成功", "code":200, "id":20, "type":"179" } }
- 失败
{ "msg":"成功", "code":200, "data":{ "result":"上传失败,入库失败: 唯一标识sessionID重复", "code":500, "id":20, "type":"179" } }
其他加签响应示例
-
成功
{ "msg":"成功", "code":200, "data":{ "result":{ "success":true, "certNo":"fzex4q", "x509Certificate":"7wj4ki", "digestValue":"rakt0t", "signatureValue":"pbyy9u" }, "code":200, "id":20, "type":"621" } }
-
失败
{ "msg":"成功", "code":200, "data":{ "result":"加签失败", "code":500, "id":20, "type":"621" } }