|
|
|
@ -1,11 +1,10 @@ |
|
|
|
package com.zdxt.code.service.impl; |
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.*; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URLConnection; |
|
|
|
import java.time.Instant; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.ZoneId; |
|
|
|
@ -422,15 +421,19 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS |
|
|
|
log.info("获取市监地址,地址为空:{}", url); |
|
|
|
return null; |
|
|
|
} |
|
|
|
StringBuffer sb = new StringBuffer(url); |
|
|
|
StringBuffer replace = sb.replace(7, 39, sjView); |
|
|
|
//爬取页面统一信用代码
|
|
|
|
String s = CrawlerUtil.getCreditCode(url); |
|
|
|
if (StringUtils.isNotEmpty(s)) { |
|
|
|
// EnterpriseInformation enterpriseInformation =
|
|
|
|
// enterpriseInformationMapper.selectEnterpriseInformationByNum(s);
|
|
|
|
EnterpriseInformation enterpriseInformation = ssztJbxx110497Service.selectSsztJbxx110497ByCode(s); |
|
|
|
//获取路由中的cid
|
|
|
|
//解析路由获取企业统一信用代码
|
|
|
|
String cid = getUrlParams(url, "cid"); |
|
|
|
if(StringUtils.isNotEmpty(cid)){ |
|
|
|
EnterpriseInformation enterpriseInformation = ssztJbxx110497Service.selectSsztJbxx110497ByCode(cid); |
|
|
|
return enterpriseInformation; |
|
|
|
}else { |
|
|
|
//爬取页面统一信用代码
|
|
|
|
String s = CrawlerUtil.getCreditCode(url); |
|
|
|
if (StringUtils.isNotEmpty(s)) { |
|
|
|
EnterpriseInformation enterpriseInformation = ssztJbxx110497Service.selectSsztJbxx110497ByCode(s); |
|
|
|
return enterpriseInformation; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
@ -518,5 +521,34 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS |
|
|
|
} |
|
|
|
return statisticsIndicatorList; |
|
|
|
} |
|
|
|
|
|
|
|
public String getUrlParams(String urlStr,String paramKey) throws IOException { |
|
|
|
URL url = new URL(urlStr); |
|
|
|
URLConnection connection = url.openConnection(); |
|
|
|
|
|
|
|
// 获取查询字符串,即URL中"?"后面的部分
|
|
|
|
String query = url.getQuery(); |
|
|
|
|
|
|
|
// 将查询字符串拆分为键值对
|
|
|
|
Map<String, String> queryParams = new HashMap<>(); |
|
|
|
if (query != null) { |
|
|
|
String[] pairs = query.split("&"); |
|
|
|
for (String pair : pairs) { |
|
|
|
int idx = pair.indexOf("="); |
|
|
|
String key = pair.substring(0, idx); |
|
|
|
String value = pair.substring(idx + 1); |
|
|
|
queryParams.put(key, value); |
|
|
|
} |
|
|
|
} |
|
|
|
// 输出参数
|
|
|
|
queryParams.forEach((k, v) -> System.out.println(k + " = " + v)); |
|
|
|
return queryParams.get(paramKey); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|