跳转到内容
返回官网

电子面单云打印

云打印面单接口

提供给用户自主打单的服务,传入模板,面单号,以及附言等内容,蜂巢打印好的电子面单(PDF文件)会直接推送(WebSocket)给蜂巢开发者 。 如何处理推送结果见文档

一、请求参数

POST https://kf.fw199.com/gateway/sfexpress/waybill/cloudprint

参数名类型说明示例
appidString合作伙伴AppIduwkahf@jfs92
timestampString当前时间戳
request_dataStringjson格式的业务参数见下表1.1
custom_dataString蜂巢开发自定义传入的数据,蜂巢将面单打印完成后,将原样返回此字段的值。
signString接口签名如何计算生成见示例代码

一(一)、参数request_data 的说明

#属性名字段含义必选类型说明
1templateCode模板编码String模板编码
2documents业务数据array字段定义参考 1.3 模板固定字段
3version版本号String版本号,传固定值:1.0
4fileType生成面单文件格式Stringpdf格式

一(二)、参数templateCode模板编码说明

#模板编码模板说明样例
1fm_150_standard_ZLXXKWh丰密二联面单100mm*150mm查看
2fm_180_standard_ZLXXKWh丰密二联面单100mm*180mm查看
3fm_210_standard_ZLXXKWh丰密三联面单100mm*210mm查看
4fm_76130_standard_ZLXXKWh丰密二联面单76mm*130mm查看
5fm_150_international_ZLXXKWh丰密二联国际面单100mm*150mm查看
6fm_210_international_ZLXXKWh丰密三联国际面单100mm*210mm查看

一(三)、参数documents模板固定字段

固定字段名类型必 传描述值说明
masterWaybillNoString主运单号
branchWaybillNoString子运单号单票运单时不填
backWaybillNoString签回单号打印签回单时,masterWayBillNo和branchWaybillNo为空
seqString该运单号打印时对应的顺序号,母运单序号=1,子运单号时递增该值单票运单时不填,当打印子母单时必填
sumString子母件运单总数单票运单时不填,当打印子母单时必填
isPrintLogoString如热敏贴纸上已印刷LOGO及服务电话则不需打印。如未印刷则需打印。 true:热敏纸上无印刷需要打印不需要打印则不填
remarkString自定义区域备注

二、请求示例代码

Java

/**
* 云打印面单打印
* @throws Exception
*/
@Test
public void cloudPrintWayBill() throws Exception {
String result ="";
// 单个订单时的示例
String jsonData = "{\"templateCode\": \"fm_76130_standard_ZLXXKWh\", \"version\":\"1.0\",\"fileType\":\"pdf\",\"documents\": [{\"masterWaybillNo\": \"SF1303262056675\" , \"isPrintLogo\":true,\"remark\":\"下午3点后再送1\"}]}";
// 子母件时示例
// String jsonData = "{" +
// " \"templateCode\": \"fm_76130_standard_ZLXXKWh\"," +
// " \"version\": \"1.0\"," +
// " \"fileType\": \"pdf\"," +
// " \"documents\": [{" +
// " \"masterWaybillNo\": \"SF7444432055982\"," +
// " \"seq\": \"1\"," +
// " \"sum\": \"2\"" +
// " }, {" +
// " \"masterWaybillNo\": \"SF7444432055982\"," +
// " \"branchWaybillNo\": \"SF7444510471516\"," +
// " \"seq\": \"2\"," +
// " \"sum\": \"2\"" +
// " } ]" +
// "}";
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost( Config.SFExpressCloudPrintWayBillUrl );
//业务参数
Map<String, String> data = new HashMap<String, String>();
data.put("appid", Config.AppId);
data.put("custom_data", "112233ks");// 自定义数据,推送时会原样返回
data.put("request_data", jsonData);
Long timestamp = System.currentTimeMillis() / 1000;
data.put("timestamp", timestamp.toString());
// 参数签名
data.put("sign", Utils.Sign(data,Config.AppSecret));
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
for (Map.Entry<String, String> entry : data.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
//发起POST请求
try {
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
HttpResponse httpResponse = httpclient.execute(httpPost);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
result = EntityUtils.toString(httpResponse.getEntity());
} else {
result = ("doPost Error Response: " + httpResponse.getStatusLine().toString());
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(result);
}

三、成功时返回结果

{
"code": 0,
"message": "ok",
"data": {
"apiErrorMsg": "",
"apiResponseID": "00017A8974A5113FD3B0FFA235CC5A3F",
"apiResultCode": "A1000",
"apiResultData": "{\"requestId\":\"5jE0kkXBcWHWpmVtnypf\",\"success\":true}"
},
"trace_id": "Eftq41kKxoBRRRwIG51Z"
}

说明: code为0表示成功,非0为失败,message会包含失败原因。

四、失败时返回结果

{
"apiErrorMsg": "auth_error:partnerID:test010d_is_not_exist",
"apiResponseID": "00016ABEC9ECCB3FE1C04106BA87EF3F",
"apiResultCode": "A1011",
"apiResultData": "{***}"
}