/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.google.gson.Gson
 *  org.apache.commons.httpclient.HttpClient
 *  org.apache.commons.httpclient.HttpMethod
 *  org.apache.commons.httpclient.URIException
 *  org.apache.commons.httpclient.methods.GetMethod
 *  org.apache.commons.httpclient.util.URIUtil
 *  org.apache.commons.lang.StringUtils
 *  org.apache.commons.logging.Log
 *  org.apache.commons.logging.LogFactory
 *  org.apache.http.HttpEntity
 *  org.apache.http.client.ClientProtocolException
 *  org.apache.http.client.entity.UrlEncodedFormEntity
 *  org.apache.http.client.methods.CloseableHttpResponse
 *  org.apache.http.client.methods.HttpGet
 *  org.apache.http.client.methods.HttpPost
 *  org.apache.http.client.methods.HttpUriRequest
 *  org.apache.http.impl.client.CloseableHttpClient
 *  org.apache.http.impl.client.HttpClients
 *  org.apache.http.message.BasicNameValuePair
 *  org.apache.http.util.EntityUtils
 */
package com.hst.taxService.service.imp;

import com.google.gson.Gson;
import com.hst.taxService.domain.GzzXxDomain;
import com.hst.taxService.domain.KddcxReqDomain;
import com.hst.taxService.domain.QttyEmscxReqDomain;
import com.hst.taxService.domain.qtty.QttyEmscxBackDomain;
import com.hst.taxService.domain.qtty.QttyEmscxDomain;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class EmsPostTest {
    public static Log _logger = LogFactory.getLog(EmsPostTest.class);

    public static void main(String[] args) {
        String cfr_ignored_0 = "type=ems&postid=9894311643975&id=1&valicode=&temp=" + Math.random();
        ArrayList<KddcxReqDomain> kddList = new ArrayList<KddcxReqDomain>();
        KddcxReqDomain kdd1 = new KddcxReqDomain();
        kdd1.setId("1");
        kdd1.setType("yunda");
        kdd1.setPostid("9894311643975");
        kddList.add(kdd1);
        KddcxReqDomain kdd2 = new KddcxReqDomain();
        kdd2.setId("1");
        kdd2.setType("ems");
        kdd2.setPostid("9894311643975");
        QttyEmscxReqDomain dom = new QttyEmscxReqDomain();
        Gson gson = new Gson();
        System.out.println(gson.toJson(kddList));
        String str = EmsPostTest.doGet("9894311643975");
        System.out.println(str);
        ArrayList<QttyEmscxDomain> list = new ArrayList<QttyEmscxDomain>();
        QttyEmscxDomain a = new QttyEmscxDomain();
        a.setKddbh("1077888453813");
        list.add(a);
        QttyEmscxDomain c = new QttyEmscxDomain();
        c.setKddbh("10778232032111");
        list.add(c);
        dom.setKddList(list);
        EmsPostTest.sendMess(dom);
    }

    public static String doGet(String url, String queryString) {
        String response = null;
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod(url);
        try {
            try {
                if (StringUtils.isNotBlank((String)queryString)) {
                    method.setQueryString(URIUtil.encodeQuery((String)queryString));
                }
                client.executeMethod((HttpMethod)method);
                if (method.getStatusCode() == 200) {
                    response = method.getResponseBodyAsString();
                }
            }
            catch (URIException e) {
                _logger.error((Object)("\u6267\u884cHTTP Get\u8bf7\u6c42\u65f6\uff0c\u7f16\u7801\u67e5\u8be2\u5b57\u7b26\u4e32\u201c" + queryString + "\u201d\u53d1\u751f\u5f02\u5e38\uff01"), (Throwable)e);
                method.releaseConnection();
            }
            catch (IOException e) {
                _logger.error((Object)("\u6267\u884cHTTP Get\u8bf7\u6c42" + url + "\u65f6\uff0c\u53d1\u751f\u5f02\u5e38\uff01"), (Throwable)e);
                method.releaseConnection();
            }
        }
        finally {
            method.releaseConnection();
        }
        return response;
    }

    public static Map<String, String> sendMess(Object domain) {
        HashMap<String, String> sendResMap = new HashMap<String, String>();
        String url = "http://211.156.193.140:8000/cotrackapi/api/track/mail/";
        HttpPost httppost = new HttpPost(url);
        new HttpGet("http://211.156.193.140:8000/cotrackapi/api/track/mail/9894311643975");
        String strResult = "";
        CloseableHttpClient httpClient = HttpClients.createDefault();
        try {
            httppost.addHeader("Content-type", "application/x-www-form-urlencoded;charset=gbk");
            ArrayList<BasicNameValuePair> par = new ArrayList<BasicNameValuePair>();
            Gson gson = new Gson();
            par.add(new BasicNameValuePair("kddList", gson.toJson(domain)));
            httppost.setEntity((HttpEntity)new UrlEncodedFormEntity(par));
            CloseableHttpResponse response = httpClient.execute((HttpUriRequest)httppost);
            if (response.getStatusLine().getStatusCode() == 200) {
                strResult = EntityUtils.toString((HttpEntity)response.getEntity());
                sendResMap.put("code", "00");
                sendResMap.put("mess", strResult);
            } else {
                String err = String.valueOf(response.getStatusLine().getStatusCode());
                strResult = String.valueOf(strResult) + "\u8bf7\u6c42\u5931\u8d25\uff0c\u9519\u8bef\u4ee3\u7801\uff1a" + err;
                sendResMap.put("code", "01");
                sendResMap.put("mess", strResult);
            }
        }
        catch (ClientProtocolException e) {
            sendResMap.put("code", "01");
            sendResMap.put("mess", e.toString());
            _logger.error((Object)e.toString());
        }
        catch (IOException e) {
            sendResMap.put("code", "01");
            sendResMap.put("mess", e.toString());
            _logger.error((Object)e.toString());
        }
        return sendResMap;
    }

    public static String doGet(String kddh) {
        HttpGet httpget = new HttpGet("http://211.156.193.140:8000/cotrackapi/api/track/mail/" + kddh);
        CloseableHttpClient httpClient = HttpClients.createDefault();
        String strResult = "";
        try {
            httpget.addHeader("authenticate", "4ab3d9a87bf179f83f722339f96118ba");
            httpget.addHeader("version", "ems_track_cn_1.0");
            CloseableHttpResponse response = httpClient.execute((HttpUriRequest)httpget);
            if (response.getStatusLine().getStatusCode() == 200) {
                strResult = EntityUtils.toString((HttpEntity)response.getEntity(), (String)"UTF-8");
            }
            return strResult;
        }
        catch (ClientProtocolException e) {
            _logger.error((Object)e.toString());
        }
        catch (IOException e) {
            _logger.error((Object)e.toString());
        }
        return strResult;
    }

    public static QttyEmscxBackDomain sendMess(QttyEmscxReqDomain kddList) {
        String url = "http://192.168.10.249:9999/guoshui1/kddcxAjaxAction!queryKddList.htm";
        HttpPost httppost = new HttpPost(url);
        String strResult = "";
        CloseableHttpClient httpClient = HttpClients.createDefault();
        QttyEmscxBackDomain dom = new QttyEmscxBackDomain();
        Gson gson = new Gson();
        try {
            httppost.addHeader("Content-type", "application/x-www-form-urlencoded;charset=gbk");
            ArrayList<BasicNameValuePair> par = new ArrayList<BasicNameValuePair>();
            par.add(new BasicNameValuePair("kddList", gson.toJson((Object)kddList)));
            httppost.setEntity((HttpEntity)new UrlEncodedFormEntity(par));
            CloseableHttpResponse response = httpClient.execute((HttpUriRequest)httppost);
            if (response.getStatusLine().getStatusCode() != 200) {
                String err = String.valueOf(response.getStatusLine().getStatusCode());
                strResult = String.valueOf(strResult) + "\u8bf7\u6c42\u5931\u8d25\uff0c\u9519\u8bef\u4ee3\u7801\uff1a" + err;
                dom.setBackCode("-1");
                dom.setErrorMess(strResult);
                throw new RuntimeException(strResult);
            }
            strResult = EntityUtils.toString((HttpEntity)response.getEntity());
            HashMap<String, Class<GzzXxDomain>> classMap = new HashMap<String, Class<GzzXxDomain>>();
            classMap.put("data", GzzXxDomain.class);
            dom = (QttyEmscxBackDomain)gson.fromJson(strResult, QttyEmscxBackDomain.class);
        }
        catch (ClientProtocolException e) {
            dom.setBackCode("-1");
            dom.setErrorMess(e.toString());
            _logger.error((Object)e.toString());
        }
        catch (IOException e) {
            dom.setBackCode("-1");
            dom.setErrorMess(e.toString());
            _logger.error((Object)e.toString());
        }
        return dom;
    }
}
