|  | @@ -3,6 +3,7 @@
 | 
												
													
														
															|  |   */
 |  |   */
 | 
												
													
														
															|  |  package com.jeeplus.modules.workclientinfo.service;
 |  |  package com.jeeplus.modules.workclientinfo.service;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +import com.alibaba.fastjson.JSONObject;
 | 
												
													
														
															|  |  import com.google.common.base.Strings;
 |  |  import com.google.common.base.Strings;
 | 
												
													
														
															|  |  import com.jeeplus.common.config.Global;
 |  |  import com.jeeplus.common.config.Global;
 | 
												
													
														
															|  |  import com.jeeplus.common.oss.OSSClientUtil;
 |  |  import com.jeeplus.common.oss.OSSClientUtil;
 | 
												
											
												
													
														
															|  | @@ -30,13 +31,17 @@ import org.springframework.transaction.annotation.Transactional;
 | 
												
													
														
															|  |  import org.springframework.web.multipart.MultipartFile;
 |  |  import org.springframework.web.multipart.MultipartFile;
 | 
												
													
														
															|  |  import org.springframework.web.multipart.commons.CommonsMultipartFile;
 |  |  import org.springframework.web.multipart.commons.CommonsMultipartFile;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +import javax.net.ssl.HostnameVerifier;
 | 
												
													
														
															|  | 
 |  | +import javax.net.ssl.HttpsURLConnection;
 | 
												
													
														
															|  | 
 |  | +import javax.net.ssl.SSLSession;
 | 
												
													
														
															|  |  import javax.servlet.http.HttpServletRequest;
 |  |  import javax.servlet.http.HttpServletRequest;
 | 
												
													
														
															|  | -import java.io.File;
 |  | 
 | 
												
													
														
															|  | -import java.io.FileInputStream;
 |  | 
 | 
												
													
														
															|  | -import java.io.IOException;
 |  | 
 | 
												
													
														
															|  | -import java.io.InputStream;
 |  | 
 | 
												
													
														
															|  | 
 |  | +import java.io.*;
 | 
												
													
														
															|  | 
 |  | +import java.net.HttpURLConnection;
 | 
												
													
														
															|  | 
 |  | +import java.net.URL;
 | 
												
													
														
															|  | 
 |  | +import java.net.URLEncoder;
 | 
												
													
														
															|  |  import java.util.ArrayList;
 |  |  import java.util.ArrayList;
 | 
												
													
														
															|  |  import java.util.List;
 |  |  import java.util.List;
 | 
												
													
														
															|  | 
 |  | +import java.util.Map;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |  /**
 |  |  /**
 | 
												
													
														
															|  |   * 客户管理Service
 |  |   * 客户管理Service
 | 
												
											
												
													
														
															|  | @@ -60,8 +65,13 @@ public class WorkClientInfoService extends CrudService<WorkClientInfoDao, WorkCl
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |      @Autowired
 |  |      @Autowired
 | 
												
													
														
															|  |      private AreaDao areaDao;
 |  |      private AreaDao areaDao;
 | 
												
													
														
															|  | -	
 |  | 
 | 
												
													
														
															|  | -	public WorkClientInfo get(String id) {
 |  | 
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    private static final String DEF_CHATSET = "UTF-8";
 | 
												
													
														
															|  | 
 |  | +    private static final int DEF_CONN_TIMEOUT = 30000;
 | 
												
													
														
															|  | 
 |  | +    private static final int DEF_READ_TIMEOUT = 30000;
 | 
												
													
														
															|  | 
 |  | +    private static String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    public WorkClientInfo get(String id) {
 | 
												
													
														
															|  |  	    if(StringUtils.isBlank(id)){
 |  |  	    if(StringUtils.isBlank(id)){
 | 
												
													
														
															|  |  	        return new WorkClientInfo();
 |  |  	        return new WorkClientInfo();
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
											
												
													
														
															|  | @@ -555,4 +565,164 @@ public class WorkClientInfoService extends CrudService<WorkClientInfoDao, WorkCl
 | 
												
													
														
															|  |          page.setList(workClientBankDao.findList(workClientBank));
 |  |          page.setList(workClientBankDao.findList(workClientBank));
 | 
												
													
														
															|  |          return page;
 |  |          return page;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    //企业开票税号查询
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    private static final HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() {
 | 
												
													
														
															|  | 
 |  | +        public boolean verify(String hostname, SSLSession session) {
 | 
												
													
														
															|  | 
 |  | +            return true;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +    };
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     *
 | 
												
													
														
															|  | 
 |  | +     * @param strUrl 请求地址
 | 
												
													
														
															|  | 
 |  | +     * @param params 请求参数
 | 
												
													
														
															|  | 
 |  | +     * @param method 请求方法
 | 
												
													
														
															|  | 
 |  | +     * @return  网络请求字符串
 | 
												
													
														
															|  | 
 |  | +     * @throws Exception
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    public static String net(String strUrl, Map<String,Object> params, Map<String,Object> headerParams, String method, String paramFormat) throws Exception {
 | 
												
													
														
															|  | 
 |  | +        HttpURLConnection conn = null;
 | 
												
													
														
															|  | 
 |  | +        BufferedReader reader = null;
 | 
												
													
														
															|  | 
 |  | +        String rs = null;
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            String contentType = null;
 | 
												
													
														
															|  | 
 |  | +            if(headerParams.containsKey("Content-Type"))
 | 
												
													
														
															|  | 
 |  | +                contentType = headerParams.get("Content-Type").toString();
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +            StringBuffer sb = new StringBuffer();
 | 
												
													
														
															|  | 
 |  | +            if(method==null || method.equals("GET")){
 | 
												
													
														
															|  | 
 |  | +				strUrl = strUrl+"?"+urlencode(params);
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +            trustAllHttpsCertificates();
 | 
												
													
														
															|  | 
 |  | +            HttpsURLConnection.setDefaultHostnameVerifier(DO_NOT_VERIFY);
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +            URL url = new URL(strUrl);
 | 
												
													
														
															|  | 
 |  | +            conn = (HttpURLConnection) url.openConnection();
 | 
												
													
														
															|  | 
 |  | +            if(method==null || method.equals("GET")){
 | 
												
													
														
															|  | 
 |  | +                conn.setRequestMethod("GET");
 | 
												
													
														
															|  | 
 |  | +            }else{
 | 
												
													
														
															|  | 
 |  | +                conn.setRequestMethod("POST");
 | 
												
													
														
															|  | 
 |  | +                conn.setDoOutput(true);
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            conn.setRequestProperty("User-agent", userAgent);
 | 
												
													
														
															|  | 
 |  | +            for (String i : headerParams.keySet()) {
 | 
												
													
														
															|  | 
 |  | +                conn.setRequestProperty(i, headerParams.get(i).toString());
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            if("form".equals(paramFormat) && !"application/x-www-form-urlencoded".equals(contentType) && !"application/xml".equals(contentType)) {
 | 
												
													
														
															|  | 
 |  | +                conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            conn.setUseCaches(false);
 | 
												
													
														
															|  | 
 |  | +            conn.setConnectTimeout(DEF_CONN_TIMEOUT);
 | 
												
													
														
															|  | 
 |  | +            conn.setReadTimeout(DEF_READ_TIMEOUT);
 | 
												
													
														
															|  | 
 |  | +            conn.setInstanceFollowRedirects(false);
 | 
												
													
														
															|  | 
 |  | +            conn.connect();
 | 
												
													
														
															|  | 
 |  | +            if (params!= null && method.equals("POST")) {
 | 
												
													
														
															|  | 
 |  | +                try {
 | 
												
													
														
															|  | 
 |  | +                    OutputStream out = conn.getOutputStream();
 | 
												
													
														
															|  | 
 |  | +                    if("form".equals(paramFormat)) {
 | 
												
													
														
															|  | 
 |  | +                        if("application/x-www-form-urlencoded".equals(contentType))
 | 
												
													
														
															|  | 
 |  | +                            out.write(urlencode(params).getBytes("utf-8"));
 | 
												
													
														
															|  | 
 |  | +                        else if("application/xml".equals(contentType))
 | 
												
													
														
															|  | 
 |  | +                            out.write(xmlencode(params).getBytes("utf-8"));
 | 
												
													
														
															|  | 
 |  | +                        else
 | 
												
													
														
															|  | 
 |  | +                            out.write(jsonencode(params).getBytes("utf-8"));
 | 
												
													
														
															|  | 
 |  | +                    } else
 | 
												
													
														
															|  | 
 |  | +                        out.write(params.toString().getBytes("utf-8"));
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +                } catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | +                    e.printStackTrace();
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            InputStream is = conn.getInputStream();
 | 
												
													
														
															|  | 
 |  | +            reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET));
 | 
												
													
														
															|  | 
 |  | +            String strRead = null;
 | 
												
													
														
															|  | 
 |  | +            while ((strRead = reader.readLine()) != null) {
 | 
												
													
														
															|  | 
 |  | +                sb.append(strRead);
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            rs = sb.toString();
 | 
												
													
														
															|  | 
 |  | +        } catch (IOException e) {
 | 
												
													
														
															|  | 
 |  | +            e.printStackTrace();
 | 
												
													
														
															|  | 
 |  | +        } finally {
 | 
												
													
														
															|  | 
 |  | +            if (reader != null) {
 | 
												
													
														
															|  | 
 |  | +                reader.close();
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            if (conn != null) {
 | 
												
													
														
															|  | 
 |  | +                conn.disconnect();
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return rs;
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    //将map型转为请求参数型
 | 
												
													
														
															|  | 
 |  | +    public static String urlencode(Map<String,Object>data) {
 | 
												
													
														
															|  | 
 |  | +        StringBuilder sb = new StringBuilder();
 | 
												
													
														
															|  | 
 |  | +        for (Map.Entry i : data.entrySet()) {
 | 
												
													
														
															|  | 
 |  | +            try {
 | 
												
													
														
															|  | 
 |  | +                if(("").equals(i.getKey())) {
 | 
												
													
														
															|  | 
 |  | +                    sb.append(URLEncoder.encode(i.getValue()+"","UTF-8"));
 | 
												
													
														
															|  | 
 |  | +                } else {
 | 
												
													
														
															|  | 
 |  | +                    sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&");
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +            } catch (UnsupportedEncodingException e) {
 | 
												
													
														
															|  | 
 |  | +                e.printStackTrace();
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return sb.toString();
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    //将map型转为请求参数型
 | 
												
													
														
															|  | 
 |  | +    public static String jsonencode(Map<String,Object>data) {
 | 
												
													
														
															|  | 
 |  | +        JSONObject jparam = new JSONObject();
 | 
												
													
														
															|  | 
 |  | +        for (Map.Entry i : data.entrySet())
 | 
												
													
														
															|  | 
 |  | +            jparam.put((String) i.getKey(), i.getValue());
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        return jparam.toString();
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    //将map型转为请求参数型
 | 
												
													
														
															|  | 
 |  | +    public static String xmlencode(Map<String,Object>data) {
 | 
												
													
														
															|  | 
 |  | +        StringBuffer xmlData = new StringBuffer();
 | 
												
													
														
															|  | 
 |  | +        xmlData.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
 | 
												
													
														
															|  | 
 |  | +        for (Map.Entry i : data.entrySet())
 | 
												
													
														
															|  | 
 |  | +            xmlData.append("<" + i.getKey() + ">" + i.getValue() + "</" + i.getKey() + ">");
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        return xmlData.toString();
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
 | 
												
													
														
															|  | 
 |  | +        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
 | 
												
													
														
															|  | 
 |  | +            return null;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
 | 
												
													
														
															|  | 
 |  | +            return true;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
 | 
												
													
														
															|  | 
 |  | +            return true;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
 | 
												
													
														
															|  | 
 |  | +                throws java.security.cert.CertificateException {
 | 
												
													
														
															|  | 
 |  | +            return;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
 | 
												
													
														
															|  | 
 |  | +                throws java.security.cert.CertificateException {
 | 
												
													
														
															|  | 
 |  | +            return;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    private static void trustAllHttpsCertificates() throws Exception {
 | 
												
													
														
															|  | 
 |  | +        javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
 | 
												
													
														
															|  | 
 |  | +        javax.net.ssl.TrustManager tm = new miTM();
 | 
												
													
														
															|  | 
 |  | +        trustAllCerts[0] = tm;
 | 
												
													
														
															|  | 
 |  | +        javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
 | 
												
													
														
															|  | 
 |  | +        sc.init(null, trustAllCerts, null);
 | 
												
													
														
															|  | 
 |  | +        javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |  }
 |  |  }
 |