package shkd.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.bes.enterprise.hc.core.http.message.BasicNameValuePair; import com.bes.mq.org.apache.http.HttpEntity; import com.bes.mq.org.apache.http.HttpResponse; import com.bes.mq.org.apache.http.NameValuePair; import com.bes.mq.org.apache.http.client.ClientProtocolException; import com.bes.mq.org.apache.http.client.methods.HttpGet; import com.bes.mq.org.apache.http.client.utils.URLEncodedUtils; import com.bes.mq.org.apache.http.impl.client.DefaultHttpClient; import com.bes.mq.org.apache.http.params.BasicHttpParams; import com.bes.mq.org.apache.http.params.HttpConnectionParams; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.util.HttpClientUtils; import kd.bos.util.StringUtils; import okhttp3.OkHttpClient; import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; 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.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import java.io.*; import java.net.URI; import java.text.SimpleDateFormat; import java.util.*; /** * 天眼查集成工具类 */ public class TycUtils { //天眼查接口正式_token public static final String tyc_Token = "29493db8-db63-4efe-8530-7b87e0b4b87a";//24000元 // public static final String tyc_Token = "6d62098a-b59a-43a0-8dd6-ec24a647efc5";//500次 //天眼查API_企业基本信息(含主要人员)_819 public static final String tyc_Baseinfo = "http://open.api.tianyancha.com/services/open/ic/baseinfoV3/2.0"; //天眼查API_疑似实际控制人_1123 public static final String tyc_ActualControl = "http://open.api.tianyancha.com/services/open/ic/actualControl/3.0"; //天眼查API_实际控制权_747 public static final String tyc_Companyholding = "http://open.api.tianyancha.com/services/v4/open/companyholding"; //天眼查API_总公司_963 public static final String tyc_ParentCompany = "http://open.api.tianyancha.com/services/open/ic/parentCompany/2.0"; //天眼查API_工商信息_1001 public static final String tyc_Ic = "http://open.api.tianyancha.com/services/open/cb/ic/2.0"; //天眼查API_建筑资质-注册人员_1009 public static final String tyc_RegHuman = "http://open.api.tianyancha.com/services/open/bq/regHuman/2.0"; //天眼查API_建筑资质-工程项目_1011 public static final String tyc_Project = "http://open.api.tianyancha.com/services/open/bq/project/2.0"; //天眼查API_失信被执行人(人员)_1076 public static final String tyc_Human_Dishonest = "http://open.api.tianyancha.com/services/v4/open/human/dishonest"; //天眼查API_被执行(人员)_1077 public static final String tyc_ZhiXingInfo = "http://open.api.tianyancha.com/services/v4/open/human/zhixinginfo"; //苍穹系统预置👇 //天眼查API_资质证书_880 public static final String tyc_Certificate = "http://open.api.tianyancha.com/services/open/m/certificate/2.0"; //天眼查API_建筑资质-资质资格_1007 public static final String tyc_Qualification = "http://open.api.tianyancha.com/services/open/bq/qualification/2.0"; //天眼查API_变更记录_822 public static final String tyc_Changeinfo = "http://open.api.tianyancha.com/services/open/ic/changeinfo/2.0"; //天眼查API_经营异常_848 public static final String tyc_Abnormal = "http://open.api.tianyancha.com/services/open/mr/abnormal/2.0"; //天眼查API_企业股东_821 public static final String tyc_Holder = "http://open.api.tianyancha.com/services/open/ic/holder/2.0"; //天眼查API_建筑资质-不良行为_1030 public static final String tyc_BadConduct = "http://open.api.tianyancha.com/services/open/bq/badConduct/2.0"; //天眼查API_企业三要素验证_1074 public static final String tyc_Verify = "http://open.api.tianyancha.com/services/open/ic/verify/2.0"; //天眼查API_行政处罚_1124 public static final String tyc_PunishmentInfo = "http://open.api.tianyancha.com/services/open/mr/punishmentInfo/3.0"; //天眼查API_严重违法_846 public static final String tyc_Illegalinfo = "http://open.api.tianyancha.com/services/open/mr/illegalinfo/2.0"; //天眼查API_法律诉讼_1114 public static final String tyc_LawSuit = "http://open.api.tianyancha.com/services/open/jr/lawSuit/3.0"; //天眼查API_失信人_843 public static final String tyc_Jr_Dishonest = "http://open.api.tianyancha.com/services/open/jr/dishonest/2.0"; private static final Log logger = LogFactory.getLog(TycUtils.class); /** * http get请求 * @param url 接口url * @param token token * @param supname 供应商name * @param apiname 接口name * @return 返回接口数据 */ public static String executeGet(String token,String url,String supname,String apiname) { // 创建 OkHttpClient 对象 OkHttpClient client = new OkHttpClient(); // 创建请求对象,设置请求地址 Request request = new Request.Builder() .url(url) .header("Content-Type", "application/json") .header("Authorization", token) .build(); String resultData = null; try { Response response = client.newCall(request).execute(); resultData = response.body().string(); JSONObject resultData1 = JSONObject.parseObject(resultData); if (null != resultData1) { JSONObject result = (JSONObject)resultData1.get("result"); DobeDWUtils.saveLog(supname, "天眼查",apiname + "\n"+request.toString(), resultData.toString(), null != result,"query_tyc"); } } catch (Exception e) { DobeDWUtils.saveLog(supname, "天眼查",apiname + "\n"+request.toString(), e.getMessage(), false,"query_tyc"); } return resultData; } public static String convertTimestampToDate(long timestamp) { Date date = new Date(timestamp); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); } public static Map getProvinceMap() { // 省份代码 Map map = new HashMap<>(); map.put("gj","国家");map.put("sh", "上海");map.put("bj", "北京");map.put("tj", "天津");map.put("gd", "广东"); map.put("zj", "浙江");map.put("fj", "福建");map.put("han", "海南");map.put("cq", "重庆");map.put("js", "江苏"); map.put("heb", "河北");map.put("sc", "四川");map.put("hen", "河南");map.put("ah", "安徽");map.put("snx", "陕西"); map.put("sd", "山东");map.put("nx", "宁夏");map.put("gz", "贵州");map.put("jx", "江西");map.put("gx", "广西"); map.put("sx", "山西");map.put("xj", "新疆");map.put("hub", "湖北");map.put("ln", "辽宁");map.put("nmg", "内蒙古"); map.put("jl", "吉林");map.put("qh", "青海");map.put("xz", "西藏");map.put("yn", "云南");map.put("gs", "甘肃"); map.put("hlj", "黑龙江");map.put("hun", "湖南");map.put("hk", "香港"); return map; } public static String getProvinceName(String code) { Map map = getProvinceMap(); if (map.containsKey(code)) { return map.get(code); } return null; } }