|  | @@ -1,6 +1,8 @@
 | 
	
		
			
				|  |  | -package com.iamberry.rst.utils;
 | 
	
		
			
				|  |  | +package com.iamberry.rst.core.tools;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.iamberry.wechat.tools.HttpClient431Util;
 | 
	
		
			
				|  |  | +import com.iamberry.wechat.tools.NameUtils;
 | 
	
		
			
				|  |  |  import net.sf.json.JSONArray;
 | 
	
		
			
				|  |  |  import net.sf.json.JSONObject;
 | 
	
		
			
				|  |  |  import org.jsoup.Jsoup;
 | 
	
	
		
			
				|  | @@ -9,13 +11,13 @@ import org.jsoup.nodes.Element;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +import org.apache.commons.codec.binary.Base64;
 | 
	
		
			
				|  |  |  import java.io.*;
 | 
	
		
			
				|  |  | -import java.net.MalformedURLException;
 | 
	
		
			
				|  |  | -import java.net.URL;
 | 
	
		
			
				|  |  | -import java.net.URLConnection;
 | 
	
		
			
				|  |  | -import java.util.HashMap;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | +import java.net.*;
 | 
	
		
			
				|  |  | +import java.security.MessageDigest;
 | 
	
		
			
				|  |  | +import java.text.ParseException;
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Created by Administrator on 2017/8/15.
 | 
	
	
		
			
				|  | @@ -29,22 +31,13 @@ public class KuaiDi100 {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private static String key = "29833628d495d7a5";//授权密匙key    百度的
 | 
	
		
			
				|  |  |    /*private static String key = "06d6c2ea1bdb4ee9";//授权密匙key  自己的*/
 | 
	
		
			
				|  |  | -                    /*<option value="sto">申通快递</option>
 | 
	
		
			
				|  |  | -					<option value="yto">圆通快递</option>
 | 
	
		
			
				|  |  | -					<option value="sf">顺丰快递</option>
 | 
	
		
			
				|  |  | -					<option value="ems">邮政EMS</option>
 | 
	
		
			
				|  |  | -					<option value="zto">中通快递</option>
 | 
	
		
			
				|  |  | -					<option value="zjs">宅急送</option>
 | 
	
		
			
				|  |  | -					<option value="yunda">韵达快递</option>
 | 
	
		
			
				|  |  | -					<option value="cces">cces快递</option>
 | 
	
		
			
				|  |  | -					<option value="pick">上门提货</option>
 | 
	
		
			
				|  |  | -					<option value="htky">汇通快递</option>
 | 
	
		
			
				|  |  | -					<option value="ttkdex">天天快递</option>
 | 
	
		
			
				|  |  | -					<option value="stars">星晨急便</option>
 | 
	
		
			
				|  |  | -					<option value="jd">京东快递</option>
 | 
	
		
			
				|  |  | -					<option value="01">其他</option>
 | 
	
		
			
				|  |  | -					<option value="02">上门送货</option>*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    //快递鸟 电商ID
 | 
	
		
			
				|  |  | +    private static final String EBusinessID="1343593";
 | 
	
		
			
				|  |  | +    //电商加密私钥,快递鸟提供
 | 
	
		
			
				|  |  | +    private static final String AppKey="3597c368-9dc0-40b5-9cf2-86d9cb90e38a";
 | 
	
		
			
				|  |  | +    // 正式环境地址:
 | 
	
		
			
				|  |  | +    private static final String ReqURL= "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
 | 
	
		
			
				|  |  |    public String logisticsConversions(String code){
 | 
	
		
			
				|  |  |        if(code == null || code.equals("")){
 | 
	
		
			
				|  |  |            return null;
 | 
	
	
		
			
				|  | @@ -140,10 +133,7 @@ public class KuaiDi100 {
 | 
	
		
			
				|  |  |       *	邮政国际包裹	youzhengguoji
 | 
	
		
			
				|  |  |       *	EMS国际快递	emsguoji
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public static void main(String[] agrs){
 | 
	
		
			
				|  |  | -        KuaiDi100 kuaidi = new KuaiDi100();
 | 
	
		
			
				|  |  | -        System.out.println(kuaidi.selectCourierCompany2("yuantong","yt9053971537384"));
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询快递信息
 | 
	
		
			
				|  |  |       * @param com 快递公司代码
 | 
	
	
		
			
				|  | @@ -452,24 +442,92 @@ public class KuaiDi100 {
 | 
	
		
			
				|  |  |      public JSONObject selectCourierCompany2(String code,String num) {
 | 
	
		
			
				|  |  |          num = num.toLowerCase();
 | 
	
		
			
				|  |  |          JSONObject json = null;
 | 
	
		
			
				|  |  | -        try {
 | 
	
		
			
				|  |  | -            Map<String, String> params = new HashMap<String, String>();
 | 
	
		
			
				|  |  | -            String cookie = "BAIDUID=E157C876272626E1F7F498C10A6A3F00:FG=1";
 | 
	
		
			
				|  |  | -            String url = "https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=cb&appid=4001&nu="+num+"&com="+code;
 | 
	
		
			
				|  |  | -            // 发送请求
 | 
	
		
			
				|  |  | -            String html = HttpClient431Util.doGet2(params, url,cookie);
 | 
	
		
			
				|  |  | -            String content = html.substring(7, html.length());
 | 
	
		
			
				|  |  | -            content = content.substring(0, content.length()-1);
 | 
	
		
			
				|  |  | -            json = JSONObject.fromObject(content);
 | 
	
		
			
				|  |  | -            /*String s = json.getString("status");*/
 | 
	
		
			
				|  |  | -        } catch (Exception e) {
 | 
	
		
			
				|  |  | -            e.printStackTrace();
 | 
	
		
			
				|  |  | -            LOGGER.info("=========快递单号:"+code+";处理报错");
 | 
	
		
			
				|  |  | +        if(code.toLowerCase().equals("sf") || code.toLowerCase().equals("shunfeng")){
 | 
	
		
			
				|  |  | +            KuaiDi100 kuaidi = new KuaiDi100();
 | 
	
		
			
				|  |  | +            String result = null;
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                result = kuaidi.selectCourierSF("SF", num);
 | 
	
		
			
				|  |  | +                if(result != null){
 | 
	
		
			
				|  |  | +                    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  | +                    JSONObject jn = JSONObject.fromObject(result);
 | 
	
		
			
				|  |  | +                    String state = jn.getString("State");
 | 
	
		
			
				|  |  | +                    JSONArray context = jn.getJSONArray("Traces");
 | 
	
		
			
				|  |  | +                    Map<String,Object> msg = new HashMap<>();
 | 
	
		
			
				|  |  | +                    Map<String,Map<String,Object>> data = new HashMap<>();
 | 
	
		
			
				|  |  | +                    Map<String,Object> info = new HashMap<>();
 | 
	
		
			
				|  |  | +                    List<HashMap> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +                    for(int i=context.size()-1;i > 0;i--){
 | 
	
		
			
				|  |  | +                        JSONObject job = context.getJSONObject(i);
 | 
	
		
			
				|  |  | +                        HashMap<String,String> map = new HashMap<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        map.put("time",String.valueOf((sf.parse(job.getString("AcceptTime")).getTime()) /1000));
 | 
	
		
			
				|  |  | +                        map.put("desc",job.getString("AcceptStation"));
 | 
	
		
			
				|  |  | +                        list.add(map);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    info.put("state",state);
 | 
	
		
			
				|  |  | +                    info.put("context",JSONArray.fromObject(list));
 | 
	
		
			
				|  |  | +                    data.put("info",info);
 | 
	
		
			
				|  |  | +                    msg.put("status","0");
 | 
	
		
			
				|  |  | +                    msg.put("data",JSONObject.fromObject(data));
 | 
	
		
			
				|  |  | +                    json = JSONObject.fromObject(msg);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                Map<String, String> params = new HashMap<String, String>();
 | 
	
		
			
				|  |  | +                String cookie = "BAIDUID=E157C876272626E1F7F498C10A6A3F00:FG=1";
 | 
	
		
			
				|  |  | +                String url = "https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=cb&appid=4001&nu="+num+"&com="+code;
 | 
	
		
			
				|  |  | +                // 发送请求
 | 
	
		
			
				|  |  | +                String html = HttpClient431Util.doGet2(params, url,cookie);
 | 
	
		
			
				|  |  | +                String content = html.substring(7, html.length());
 | 
	
		
			
				|  |  | +                content = content.substring(0, content.length()-1);
 | 
	
		
			
				|  |  | +                json = JSONObject.fromObject(content);
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +                LOGGER.info("=========快递单号:"+code+";处理报错");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          return json;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     * 百度快递查询签收时间
 | 
	
		
			
				|  |  | +     * 根据物流单号查询快递信息 state 0在途,1揽收,2疑难,3签收,4退签,5派件,6退回
 | 
	
		
			
				|  |  | +     * @param code
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public Date selectCourierSignTime(String code, String num){
 | 
	
		
			
				|  |  | +        JSONObject json = null;
 | 
	
		
			
				|  |  | +        for(int i = 0; i < 3; i++){
 | 
	
		
			
				|  |  | +            json = selectCourierCompany2(code,num);
 | 
	
		
			
				|  |  | +            if(json.getString("status").equals("0")){
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +            if(json.getString("status").equals("0")){
 | 
	
		
			
				|  |  | +                SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  | +                JSONObject data = JSONObject.fromObject(json.getString("data"));
 | 
	
		
			
				|  |  | +                JSONObject info = JSONObject.fromObject(data.getString("info"));
 | 
	
		
			
				|  |  | +                JSONArray context = info.getJSONArray("context");
 | 
	
		
			
				|  |  | +                String state = info.getString("state");
 | 
	
		
			
				|  |  | +                Date time = null;
 | 
	
		
			
				|  |  | +                if(state.equals("3")){
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        time = sf.parse(sf.format(new Date(Long.parseLong(JSONObject.fromObject(context.get(0)).getString("time")) * 1000)));
 | 
	
		
			
				|  |  | +                    } catch (ParseException e) {
 | 
	
		
			
				|  |  | +                        e.printStackTrace();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                return time;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        return null;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 写入文件
 | 
	
		
			
				|  |  |       * @param path
 | 
	
		
			
				|  |  |       * @param s
 | 
	
	
		
			
				|  | @@ -495,5 +553,185 @@ public class KuaiDi100 {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * MD5加密
 | 
	
		
			
				|  |  | +     * @param str 内容
 | 
	
		
			
				|  |  | +     * @param charset 编码方式
 | 
	
		
			
				|  |  | +     * @throws Exception
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @SuppressWarnings("unused")
 | 
	
		
			
				|  |  | +    private static String MD5(String str, String charset) throws Exception {
 | 
	
		
			
				|  |  | +        MessageDigest md = MessageDigest.getInstance("MD5");
 | 
	
		
			
				|  |  | +        md.update(str.getBytes(charset));
 | 
	
		
			
				|  |  | +        byte[] result = md.digest();
 | 
	
		
			
				|  |  | +        StringBuilder sb = new StringBuilder(32);
 | 
	
		
			
				|  |  | +        for (byte aResult : result) {
 | 
	
		
			
				|  |  | +            int val = aResult & 0xff;
 | 
	
		
			
				|  |  | +            if (val <= 0xf) {
 | 
	
		
			
				|  |  | +                sb.append("0");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            sb.append(Integer.toHexString(val));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return sb.toString().toLowerCase();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * base64编码
 | 
	
		
			
				|  |  | +     * @param str 内容
 | 
	
		
			
				|  |  | +     * @param charset 编码方式
 | 
	
		
			
				|  |  | +     * @throws UnsupportedEncodingException
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private static String base64(String str, String charset) throws UnsupportedEncodingException {
 | 
	
		
			
				|  |  | +        return Base64.encodeBase64String(str.getBytes(charset));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @SuppressWarnings("unused")
 | 
	
		
			
				|  |  | +    private static String urlEncoder(String str, String charset) throws UnsupportedEncodingException{
 | 
	
		
			
				|  |  | +        return URLEncoder.encode(str, charset);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 电商Sign签名生成
 | 
	
		
			
				|  |  | +     * @param content 内容
 | 
	
		
			
				|  |  | +     * @param keyValue Appkey
 | 
	
		
			
				|  |  | +     * @param charset 编码方式
 | 
	
		
			
				|  |  | +     * @throws UnsupportedEncodingException ,Exception
 | 
	
		
			
				|  |  | +     * @return DataSign签名
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    /*@SuppressWarnings("unused")*/
 | 
	
		
			
				|  |  | +    private static String encrypt (String content, String keyValue, String charset) throws UnsupportedEncodingException, Exception {
 | 
	
		
			
				|  |  | +        if (keyValue != null)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            return base64(MD5(content + keyValue, charset), charset);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return base64(MD5(content, charset), charset);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * (快递鸟dema)向指定 URL 发送POST方法的请求
 | 
	
		
			
				|  |  | +     * @param url 发送请求的 URL
 | 
	
		
			
				|  |  | +     * @param params 请求的参数集合
 | 
	
		
			
				|  |  | +     * @return 远程资源的响应结果
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private String sendPost(String url, Map<String, String> params) {
 | 
	
		
			
				|  |  | +        OutputStreamWriter out = null;
 | 
	
		
			
				|  |  | +        BufferedReader in = null;
 | 
	
		
			
				|  |  | +        StringBuilder result = new StringBuilder();
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            URL realUrl = new URL(url);
 | 
	
		
			
				|  |  | +            HttpURLConnection conn =(HttpURLConnection) realUrl.openConnection();
 | 
	
		
			
				|  |  | +            // 发送POST请求必须设置如下两行
 | 
	
		
			
				|  |  | +            conn.setDoOutput(true);
 | 
	
		
			
				|  |  | +            conn.setDoInput(true);
 | 
	
		
			
				|  |  | +            // POST方法
 | 
	
		
			
				|  |  | +            conn.setRequestMethod("POST");
 | 
	
		
			
				|  |  | +            // 设置通用的请求属性
 | 
	
		
			
				|  |  | +            conn.setRequestProperty("accept", "*/*");
 | 
	
		
			
				|  |  | +            conn.setRequestProperty("connection", "Keep-Alive");
 | 
	
		
			
				|  |  | +            conn.setRequestProperty("user-agent",
 | 
	
		
			
				|  |  | +                    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
 | 
	
		
			
				|  |  | +            conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
 | 
	
		
			
				|  |  | +            conn.connect();
 | 
	
		
			
				|  |  | +            // 获取URLConnection对象对应的输出流
 | 
	
		
			
				|  |  | +            out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
 | 
	
		
			
				|  |  | +            // 发送请求参数
 | 
	
		
			
				|  |  | +            if (params != null) {
 | 
	
		
			
				|  |  | +                StringBuilder param = new StringBuilder();
 | 
	
		
			
				|  |  | +                for (Map.Entry<String, String> entry : params.entrySet()) {
 | 
	
		
			
				|  |  | +                    if(param.length()>0){
 | 
	
		
			
				|  |  | +                        param.append("&");
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    param.append(entry.getKey());
 | 
	
		
			
				|  |  | +                    param.append("=");
 | 
	
		
			
				|  |  | +                    param.append(entry.getValue());
 | 
	
		
			
				|  |  | +                    //System.out.println(entry.getKey()+":"+entry.getValue());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                //System.out.println("param:"+param.toString());
 | 
	
		
			
				|  |  | +                out.write(param.toString());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            // flush输出流的缓冲
 | 
	
		
			
				|  |  | +            out.flush();
 | 
	
		
			
				|  |  | +            // 定义BufferedReader输入流来读取URL的响应
 | 
	
		
			
				|  |  | +            in = new BufferedReader(
 | 
	
		
			
				|  |  | +                    new InputStreamReader(conn.getInputStream(), "UTF-8"));
 | 
	
		
			
				|  |  | +            String line;
 | 
	
		
			
				|  |  | +            while ((line = in.readLine()) != null) {
 | 
	
		
			
				|  |  | +                result.append(line);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //使用finally块来关闭输出流、输入流
 | 
	
		
			
				|  |  | +        finally{
 | 
	
		
			
				|  |  | +            try{
 | 
	
		
			
				|  |  | +                if(out!=null){
 | 
	
		
			
				|  |  | +                    out.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(in!=null){
 | 
	
		
			
				|  |  | +                    in.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            catch(IOException ex){
 | 
	
		
			
				|  |  | +                ex.printStackTrace();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return result.toString();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 快递鸟查询顺风物流信息
 | 
	
		
			
				|  |  | +     * 根据物流单号查询快递信息
 | 
	
		
			
				|  |  | +     * @param
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public String selectCourierSF(String expCode, String expNo) throws Exception{
 | 
	
		
			
				|  |  | +        String requestData= "{'OrderCode':'','ShipperCode':'" + expCode + "','LogisticCode':'" + expNo + "'}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map<String, String> params = new HashMap<String, String>();
 | 
	
		
			
				|  |  | +        params.put("RequestData", urlEncoder(requestData, "UTF-8"));
 | 
	
		
			
				|  |  | +        params.put("EBusinessID", EBusinessID);
 | 
	
		
			
				|  |  | +        params.put("RequestType", "1002");
 | 
	
		
			
				|  |  | +        String dataSign=encrypt(requestData, AppKey, "UTF-8");
 | 
	
		
			
				|  |  | +        params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
 | 
	
		
			
				|  |  | +        params.put("DataType", "2");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String result=HttpClient431Util.doPost(params,ReqURL);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //根据公司业务处理返回的信息......
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public static void main(String[] agrs){
 | 
	
		
			
				|  |  | +        KuaiDi100 kuaidi = new KuaiDi100();
 | 
	
		
			
				|  |  | +        /*System.out.println(kuaidi.selectCourierCompany2("yuantong","yt9053971537384"));*/
 | 
	
		
			
				|  |  | +        /*System.out.println(kuaidi.selectCourierSignTime("yuantong","yt9053971537384"));*/
 | 
	
		
			
				|  |  | +        /*System.out.println(kuaidi.selectCourierSF("106494280800","SF","291003792023"));*/
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            String result = kuaidi.selectCourierSF("SF", "288904538945");
 | 
	
		
			
				|  |  | +            System.out.print(result);
 | 
	
		
			
				|  |  | +            if(result != null){
 | 
	
		
			
				|  |  | +                JSONObject jn = JSONObject.fromObject(result);
 | 
	
		
			
				|  |  | +                String state = jn.getString("State");
 | 
	
		
			
				|  |  | +                JSONArray context = jn.getJSONArray("Traces");
 | 
	
		
			
				|  |  | +                Map<String,String> msg = new HashMap<>();
 | 
	
		
			
				|  |  | +                Map<String,Map<String,String>> data = new HashMap<>();
 | 
	
		
			
				|  |  | +                Map<String,String> info = new HashMap<>();
 | 
	
		
			
				|  |  | +                List<HashMap> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +                for(int i=context.size()-1;i > 0;i--){
 | 
	
		
			
				|  |  | +                    JSONObject job = context.getJSONObject(i);
 | 
	
		
			
				|  |  | +                    HashMap<String,String> map = new HashMap<>();
 | 
	
		
			
				|  |  | +                    map.put("time",job.getString("AcceptTime"));
 | 
	
		
			
				|  |  | +                    map.put("desc",job.getString("AcceptStation"));
 | 
	
		
			
				|  |  | +                    list.add(map);
 | 
	
		
			
				|  |  | +                    System.out.println(JSON.toJSONString(list)) ;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                info.put("state",state);
 | 
	
		
			
				|  |  | +                info.put("context",JSON.toJSONString(list));
 | 
	
		
			
				|  |  | +                data.put("info",info);
 | 
	
		
			
				|  |  | +                msg.put("status","0");
 | 
	
		
			
				|  |  | +                msg.put("data",JSON.toJSONString(data));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |