1;拉取订单url移动到线程池外部
This commit is contained in:
parent
736992d086
commit
5116c42be4
|
@ -98,7 +98,7 @@ public class MeituanController {
|
|||
// String ck = "WEBDFPID=1720313779673YKASQECfd79fef3d01d5e9aadc18ccd4d0c95072894-1720313779673-1720313779673YKASQECfd79fef3d01d5e9aadc18ccd4d0c95072894; _lxsdk_cuid=1908ab11622c8-05c631efe52fbf-26031d51-1fa400-1908ab11623c8; _lxsdk=1908ab11622c8-05c631efe52fbf-26031d51-1fa400-1908ab11623c8; device_uuid=!add95b49-6d31-414c-b096-458e40b710e0; uuid_update=true; shopCategory=food; JSESSIONID=166osatxa3vej17siwfi3kfzso; logan_session_token=y5xcyzjk6epwp80j79nx; acctId=160394866; token=0vqM7ZAhWG5gEXioWJq2CpJTDb5vmeQ64StlZHudt6Pk*; wmPoiId=18277065; isOfflineSelfOpen=0; city_id=440100; isChain=0; ignore_set_router_proxy=false; region_id=1000440100; region_version=1687236854; set_info=%7B%22ignoreSetRouterProxy%22%3Afalse%2C%22region_id%22%3A%221000440100%22%2C%22region_version%22%3A1687236854%2C%22wmPoiId%22%3A18277065%7D; bsid=LA-NjGQthUuIAYmATre3dMUaeO3fwl-hrGQwBLxOUSxeJmBKyXpk1tC7WdiUH4UoqHDtHHYPiymWJM5KJ80Vag; city_location_id=440100; location_id=440103; wpush_server_url=wss%3A%2F%2Fwpush.meituan.com; has_not_waimai_poi=0; _lxsdk_s=1908ab11624-5f4-1f2-8a6%7C%7C5";
|
||||
// String d = "2024-07-07";
|
||||
// String poiId = "18277065";
|
||||
iMeituanService.orderInfo(wmPoiId, date, cookie);
|
||||
iMeituanService.orderInfo(wmPoiId, date, cookie,"");
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ public class ProxyProperties {
|
|||
String code = jsonObject.getString(("code"));
|
||||
if ("0".equals(code)) {
|
||||
int count = jsonObject.getJSONObject("data").getInteger(proxy);
|
||||
if (count > 400) {
|
||||
if (count > 30) {
|
||||
System.out.println("剩余:"+count);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public interface IMeituanService {
|
|||
* @param cookie
|
||||
* @return
|
||||
*/
|
||||
void orderInfo(String wmPoiId, String date, String cookie);
|
||||
void orderInfo(String wmPoiId, String date, String cookie,String url);
|
||||
|
||||
/**
|
||||
* 获取号码
|
||||
|
|
|
@ -34,14 +34,14 @@ public class AsyncTaskImpl {
|
|||
|
||||
@Async("asyncServiceExecutor")
|
||||
public void executeAsync(List<BusStoreInfo> busStoreInfoList,
|
||||
BusStoreInfoMapper studentService,
|
||||
String url,
|
||||
CountDownLatch countDownLatch) {
|
||||
try{
|
||||
log.info("=============start executeAsync=============");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
//异步线程要做的事情
|
||||
for (BusStoreInfo store : busStoreInfoList) {
|
||||
iMeituanService.orderInfo(store.getStoreCode(),now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),store.getStoreCookie());
|
||||
iMeituanService.orderInfo(store.getStoreCode(),now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),store.getStoreCookie(),url);
|
||||
}
|
||||
log.error("==================end executeAsync===============");
|
||||
}finally {
|
||||
|
|
|
@ -134,7 +134,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
storeInfo.setGrantStatus("1");//授权登录状态
|
||||
storeInfo.setReturnVisitStatus("2");// 营销状态
|
||||
storeInfo.setSelfDeliveryStatus("1");// 1 正常, 2 自配送, 3 删除
|
||||
storeInfo.setMarketingChannels("AI");// 默认渠道 sysDictDataMapper.selectDictLabel("bus_default_script","default_script")
|
||||
storeInfo.setMarketingChannels(sysDictDataMapper.selectDictLabel("bus_default_channel","default_channel"));
|
||||
busStoreInfoService.insertBusStoreInfo(storeInfo);
|
||||
BusStoreDayInfo busStoreDayInfo = new BusStoreDayInfo();
|
||||
busStoreDayInfo.setStoreId(storeInfo.getId());
|
||||
|
@ -295,12 +295,13 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
public String orderInfoList() {
|
||||
BusStoreInfo busStoreInfo = new BusStoreInfo();
|
||||
busStoreInfo.setReturnVisitStatus("1");
|
||||
String getUrl = proxyProperties.gettpsUrl();
|
||||
List<BusStoreInfo> busStoreInfoList = busStoreInfoMapper.selectBusStoreInfoList(busStoreInfo);
|
||||
long startTime = System.currentTimeMillis(); // 开始时间
|
||||
List<List<BusStoreInfo>> list1= SplitListUtils.pagingList(busStoreInfoList,20); //拆分集合
|
||||
CountDownLatch countDownLatch = new CountDownLatch(list1.size());
|
||||
for (List<BusStoreInfo> list2 : list1) {
|
||||
asyncTask.executeAsync(list2,busStoreInfoMapper,countDownLatch);
|
||||
asyncTask.executeAsync(list2,getUrl,countDownLatch);
|
||||
}
|
||||
try {
|
||||
countDownLatch.await(); //保证之前的所有的线程都执行完成,才会走下面的;
|
||||
|
@ -389,10 +390,10 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void orderInfo(String wmPoiId, String date, String cookie) {
|
||||
public void orderInfo(String wmPoiId, String date, String cookie,String getUrl) {
|
||||
try {
|
||||
int pageNum = 1;
|
||||
String getUrl = proxyProperties.gettpsUrl();
|
||||
// String getUrl = proxyProperties.gettpsUrl();
|
||||
BusStoreInfo storeInfo = new BusStoreInfo();
|
||||
storeInfo.setStoreCode(wmPoiId);
|
||||
BusStoreInfo storeInfo1 = busStoreInfoMapper.selectBusStoreInfoList(storeInfo).get(0);
|
||||
|
@ -585,7 +586,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
jsonObject = JSONObject.parseObject(resp);
|
||||
code = jsonObject.getString(("code"));
|
||||
} catch (Exception e) {
|
||||
log.error("==============="+orderInfo.getOrderNo()+"私密代理订单解析号码出错:"+e.getMessage()+"==========转换隧道代理");
|
||||
log.error("==============="+orderInfo.getOrderNo()+"承接-隧道代理订单解析号码出错:"+e.getMessage()+"==========转换隧道代理");
|
||||
client = proxyHttpClient();
|
||||
try {
|
||||
HttpResponse response = client.execute(httpPost);
|
||||
|
@ -594,16 +595,26 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
jsonObject = JSONObject.parseObject(resp);
|
||||
code = jsonObject.getString(("code"));
|
||||
}catch (Exception e1) {
|
||||
log.error("==============="+orderInfo.getOrderNo()+"隧道代理订单解析号码出错:" + e1.getMessage() + "===========转换本地");
|
||||
client = localHttpClient();
|
||||
log.error("==============="+orderInfo.getOrderNo()+"隧道代理订单解析号码出错:" + e1.getMessage() + "===========转换私密代理");
|
||||
client = proxyHttpClient2(proxyProperties.getUrl());
|
||||
try {
|
||||
HttpResponse response = client.execute(httpPost);
|
||||
HttpEntity responseEntity = response.getEntity();
|
||||
String resp = EntityUtils.toString(responseEntity);
|
||||
jsonObject = JSONObject.parseObject(resp);
|
||||
code = jsonObject.getString(("code"));
|
||||
} catch (Exception e2) {
|
||||
log.error("==============="+orderInfo.getOrderNo()+"本地订单解析号码出错:================" + e2.getMessage());
|
||||
}catch (Exception e2){
|
||||
log.error("==============="+orderInfo.getOrderNo()+"私密代理订单解析号码出错:" + e2.getMessage() + "===========转换本地代理");
|
||||
client = localHttpClient();
|
||||
try {
|
||||
HttpResponse response = client.execute(httpPost);
|
||||
HttpEntity responseEntity = response.getEntity();
|
||||
String resp = EntityUtils.toString(responseEntity);
|
||||
jsonObject = JSONObject.parseObject(resp);
|
||||
code = jsonObject.getString(("code"));
|
||||
} catch (Exception e3) {
|
||||
log.error("==============="+orderInfo.getOrderNo()+"本地订单解析号码出错:================" + e3.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1123,4 +1134,22 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
return httpClient;
|
||||
}
|
||||
|
||||
private CloseableHttpClient proxyHttpClient2(String ipPort) {
|
||||
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
|
||||
String proxyHost = ipPort.split(":")[0];
|
||||
int proxyPort = Integer.valueOf(ipPort.split(":")[1]);
|
||||
String username = proxyProperties.getAccountSM();
|
||||
String password = proxyProperties.getPwdSM();
|
||||
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
|
||||
CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
||||
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort),
|
||||
new UsernamePasswordCredentials(username, password));
|
||||
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
|
||||
CloseableHttpClient httpClient = HttpClients
|
||||
.custom()
|
||||
.setDefaultRequestConfig(config)
|
||||
.setDefaultCredentialsProvider(credsProvider)
|
||||
.build();
|
||||
return httpClient;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue