/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  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.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.util;

import com.hst.framework.util.HstDateUtil;
import com.hst.framework.util.HstReflectUtil;
import com.hst.taxService.domain.wxqyh.zhdjPostDomain.ZhdjPostDataDomain;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
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.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 ZhdjSendMessUtil {
    static Log _logger = LogFactory.getLog(ZhdjSendMessUtil.class);

    public static Map<String, String> doSendMess(String url, String actionName, Object parm) {
        HttpPost httppost = new HttpPost(String.valueOf(url) + actionName);
        String strResult = "";
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HashMap<String, String> res = new HashMap<String, String>();
        try {
            Field[] fields;
            httppost.addHeader("Content-type", "application/x-www-form-urlencoded;charset=gbk");
            ArrayList<BasicNameValuePair> par = new ArrayList<BasicNameValuePair>();
            Class<?> parmClass = parm.getClass();
            Field[] fieldArray = fields = parmClass.getDeclaredFields();
            int n = fields.length;
            int n2 = 0;
            while (n2 < n) {
                Field field = fieldArray[n2];
                par.add(new BasicNameValuePair(field.getName(), (String)HstReflectUtil.getFieldValue(parm, field.getName())));
                ++n2;
            }
            httppost.setEntity((HttpEntity)new UrlEncodedFormEntity(par, "UTF-8"));
            CloseableHttpResponse response = httpClient.execute((HttpUriRequest)httppost);
            if (response.getStatusLine().getStatusCode() == 200) {
                strResult = EntityUtils.toString((HttpEntity)response.getEntity());
                res.put("code", "00");
            } else {
                String err = String.valueOf(response.getStatusLine().getStatusCode());
                res.put("code", "01");
                strResult = String.valueOf(strResult) + "\u8bf7\u6c42\u5931\u8d25\uff0c\u9519\u8bef\u4ee3\u7801\uff1a" + err;
            }
        }
        catch (ClientProtocolException clientProtocolException) {
            res.put("code", "01");
        }
        catch (IOException iOException) {
        }
        catch (NoSuchMethodException e) {
            res.put("code", "01");
            e.printStackTrace();
        }
        catch (IllegalAccessException e) {
            res.put("code", "01");
            e.printStackTrace();
        }
        catch (InvocationTargetException e) {
            res.put("code", "01");
            e.printStackTrace();
        }
        if ((strResult.indexOf("\u6210\u529f") > 0 || strResult.indexOf("SUCESS") > 0) && strResult.indexOf("UUID") > 0) {
            String uuid = strResult.substring(strResult.indexOf("\uff1a") + 1).trim();
            _logger.debug((Object)uuid);
        }
        _logger.debug((Object)("\u8c03\u7528\u63a5\u53e3\uff0cURL=" + url + ",\u8fd4\u56de\u7ed3\u679c" + strResult));
        res.put("mess", strResult);
        return res;
    }

    public static void main(String[] args) throws Exception {
        ZhdjPostDataDomain par = new ZhdjPostDataDomain();
        par.setRisenniCusr("001027015");
        par.setRisenniCusrname("\u76d6\u4f0a\u60f3\u7684");
        par.setRisenniTitle("\u70b9\u70b9\u6ef4\u6ef4");
        par.setRisenniDate(HstDateUtil.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss"));
        par.setRisenniContent("\u5730\u5730\u9053\u9053\u7684");
        par.setUserType("2");
        par.setUuid("3FAF27518276481BA59D084BD6D8AFB5");
        par.setRisenpnCusr("001027015");
        par.setRisenpnCusrname("22");
        par.setRisenpnTitle("\u83dc\u5200\u961f\u7684\u7684");
        par.setRisenpnType("1");
        par.setRisenpnOrgName("");
        par.setRisenpnOrgUuid("");
        par.setRisenpnSendeename("");
        par.setRisenpnSendeeuuid("");
        par.setRisenpnContent("ee\u540a\u9876");
        par.setRisenpnDate("2017-06-22");
        par.setImageName("");
        par.setImagePath("");
        par.setFileName("");
        par.setFilePath("");
        ZhdjSendMessUtil.doSendMess("http://120.26.40.88:8010/public/xy/weixin/", "addPublicnotify.action", par);
    }
}
