1;日志

This commit is contained in:
wangshuai 2024-08-01 08:39:14 +08:00
parent b1f85cd3ab
commit 8937604ec0
2 changed files with 62 additions and 129 deletions

View File

@ -10,6 +10,7 @@ import com.ruoyi.common.config.BusTencentProperties;
import com.ruoyi.common.utils.HttpClientUtilT; import com.ruoyi.common.utils.HttpClientUtilT;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SysDictDataMapper; import com.ruoyi.system.mapper.SysDictDataMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.MQProducer; import org.apache.rocketmq.client.producer.MQProducer;
@ -35,6 +36,7 @@ import java.util.stream.Collectors;
* @author ruoyi * @author ruoyi
* @date 2024-07-03 * @date 2024-07-03
*/ */
@Slf4j
@Service @Service
public class AiServiceImpl implements IAiService { public class AiServiceImpl implements IAiService {
@Autowired @Autowired
@ -79,11 +81,11 @@ public class AiServiceImpl implements IAiService {
long apiKeyExpire = Long.valueOf(data.getString("api_key_expire")); long apiKeyExpire = Long.valueOf(data.getString("api_key_expire"));
String userSn = data.getString("user_sn"); String userSn = data.getString("user_sn");
String projectSn = data.getString("project_sn"); String projectSn = data.getString("project_sn");
System.out.println("login 返回:===========apikey,userSn,projectSn=============" + apiKey + "," + userSn + "," + projectSn); log.error("login 返回:===========apikey,userSn,projectSn=============" + apiKey + "," + userSn + "," + projectSn);
redisTemplate.opsForValue().set("apiKey", apiKey); redisTemplate.opsForValue().set("apiKey", apiKey);
return apiKey; return apiKey;
} else { } else {
System.out.println("login接口返回错误 " + jsonObject.toString()); log.error("login接口返回错误 " + jsonObject.toString());
} }
return null; return null;
} }
@ -105,7 +107,7 @@ public class AiServiceImpl implements IAiService {
String taskMainId = data1.getString("dial_task_main_id"); String taskMainId = data1.getString("dial_task_main_id");
String taskMainSn = data1.getString("dial_task_main_sn"); String taskMainSn = data1.getString("dial_task_main_sn");
System.out.println("追加任务返回: ============taskMainId,taskMainSn===========" + taskMainId + "," + taskMainSn); log.error("追加任务返回: ============taskMainId,taskMainSn===========" + taskMainId + "," + taskMainSn);
//定时任务15天之前的删除记录 todo //定时任务15天之前的删除记录 todo
// BusFifteenInfo fifteenInfo = new BusFifteenInfo(); // BusFifteenInfo fifteenInfo = new BusFifteenInfo();
@ -114,12 +116,12 @@ public class AiServiceImpl implements IAiService {
// fifteenInfoService.insertBusFifteenInfo(fifteenInfo); // fifteenInfoService.insertBusFifteenInfo(fifteenInfo);
} else if ("20005".equals(jo.getString("code")) || "20006".equals(jo.getString("code"))) { } else if ("20005".equals(jo.getString("code")) || "20006".equals(jo.getString("code"))) {
System.out.println("建立任务接口返回错误: " + jo.toString()); log.error("建立任务接口返回错误: " + jo.toString());
redisTemplate.delete("apiKey"); redisTemplate.delete("apiKey");
sendAiTask(content, busOrderInfo); sendAiTask(content, busOrderInfo);
} else { } else {
// TODO: 2024/7/10 失败原因判断 是否继续循环 // TODO: 2024/7/10 失败原因判断 是否继续循环
System.out.println("建立任务接口返回错误: " + jo.toString()); log.error("建立任务接口返回错误: " + jo.toString());
} }
} }
@ -139,7 +141,7 @@ public class AiServiceImpl implements IAiService {
String apiKey = data.getString("api_key"); String apiKey = data.getString("api_key");
String userSn = data.getString("user_sn"); String userSn = data.getString("user_sn");
String projectSn = data.getString("project_sn"); String projectSn = data.getString("project_sn");
System.out.println("login 返回:===========apikey,userSn,projectSn=============" + apiKey + "," + userSn + "," + projectSn); log.error("login 返回:===========apikey,userSn,projectSn=============" + apiKey + "," + userSn + "," + projectSn);
int pageIndex = 0; int pageIndex = 0;
int pageSize = 200; int pageSize = 200;
@ -177,14 +179,14 @@ public class AiServiceImpl implements IAiService {
aiInfoService.insertBusAiInfo(aiInfo); aiInfoService.insertBusAiInfo(aiInfo);
reduceIntegral(aiInfo); reduceIntegral(aiInfo);
} catch (Exception e) { } catch (Exception e) {
System.out.println(id + "duplicate"); log.error(id + "duplicate");
} }
} }
} else { } else {
System.out.println("crmList返回错误 " + result1); log.error("crmList返回错误 " + result1);
} }
} else { } else {
System.out.println("login返回错误 " + loginResult); log.error("login返回错误 " + loginResult);
} }
} }
@ -213,7 +215,7 @@ public class AiServiceImpl implements IAiService {
addAiTaskTest(apiKey, content, busOrderInfo); addAiTaskTest(apiKey, content, busOrderInfo);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("建立接口返回错误: " + e.getMessage()); log.error("建立接口返回错误: " + e.getMessage());
} }
} }
@ -222,7 +224,7 @@ public class AiServiceImpl implements IAiService {
@Override @Override
public void sendToAi() { public void sendToAi() {
System.out.println("开始==="); log.error("开始===");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
@ -236,7 +238,7 @@ public class AiServiceImpl implements IAiService {
for (BusStoreInfo busStoreInfo : storeInfoList) { for (BusStoreInfo busStoreInfo : storeInfoList) {
try { try {
if ("2".equals(busStoreInfo.getReturnVisitStatus())) { if ("2".equals(busStoreInfo.getReturnVisitStatus())) {
System.out.println("未开启营销的跳出"); log.error("未开启营销的跳出");
continue;// 未开启营销的跳出 continue;// 未开启营销的跳出
} }
// 配置规则 // 配置规则
@ -246,10 +248,10 @@ public class AiServiceImpl implements IAiService {
List<BusOrderInfo> list = new ArrayList<>(); List<BusOrderInfo> list = new ArrayList<>();
if ("1".equals(busStoreInfo.getSelfDeliveryStatus())) { if ("1".equals(busStoreInfo.getSelfDeliveryStatus())) {
System.out.println("自动营销"); log.error("自动营销");
list = orderInfoService.selectBusOrderInfoListToAi(busStoreInfo.getStoreCode(), t1, t2); list = orderInfoService.selectBusOrderInfoListToAi(busStoreInfo.getStoreCode(), t1, t2);
} else if ("2".equals(busStoreInfo.getSelfDeliveryStatus())) { } else if ("2".equals(busStoreInfo.getSelfDeliveryStatus())) {
System.out.println("自配送营销"); log.error("自配送营销");
LocalDateTime tN = now.minusMinutes(busStoreConfigInfo.getSelfDeliveryDuration()); LocalDateTime tN = now.minusMinutes(busStoreConfigInfo.getSelfDeliveryDuration());
String time = tN.format(dateTimeFormatter); String time = tN.format(dateTimeFormatter);
// 自配送前推时间处理 // 自配送前推时间处理
@ -266,7 +268,7 @@ public class AiServiceImpl implements IAiService {
int cha = agentInfo.getAiDurationBalance(); int cha = agentInfo.getAiDurationBalance();
if (cha < list.size()&&(cha - 1)>0) { if (cha < list.size()&&(cha - 1)>0) {
list.subList(0, cha - 1); list.subList(0, cha - 1);
System.out.println("积分不足截取部分订单营销"); log.error("积分不足截取部分订单营销");
agentInfo.setAiRealTimeNum(agentInfo.getAiDurationBalance()); agentInfo.setAiRealTimeNum(agentInfo.getAiDurationBalance());
} else if(cha < 0){ } else if(cha < 0){
continue; continue;
@ -285,7 +287,7 @@ public class AiServiceImpl implements IAiService {
continue; continue;
} }
} }
System.out.println("结束==="); log.error("结束===");
} }
@Override @Override
@ -295,12 +297,12 @@ public class AiServiceImpl implements IAiService {
String phoneNo = busOrderInfo.getPrivcyPhone().split(",")[0];//#分机号# String phoneNo = busOrderInfo.getPrivcyPhone().split(",")[0];//#分机号#
content = content.replaceAll("分机号",busOrderInfo.getPrivcyPhone().split(",")[1]); content = content.replaceAll("分机号",busOrderInfo.getPrivcyPhone().split(",")[1]);
com.alibaba.fastjson.JSONObject jsonObject = busTencentProperties.smsCredential(phoneNo, content); com.alibaba.fastjson.JSONObject jsonObject = busTencentProperties.smsCredential(phoneNo, content);
System.out.println(jsonObject); // log.error(jsonObject.toJSONString());
if("00".equals(jsonObject.getString("status"))){ if("00".equals(jsonObject.getString("status"))){
//定时任务15天之前的删除记录 todo //定时任务15天之前的删除记录 todo
System.out.println("发送成功========"); log.error("发送成功========");
}else{ }else{
System.out.println("发送失败========"); log.error("发送失败========");
} }
} }
@ -312,7 +314,7 @@ public class AiServiceImpl implements IAiService {
// String ss = "{\"taskId\":\"202203170025799000001\",\"message\":\"success\",\"timestamp\":1647481716818,\"status\":\"00\",\"tag\":\"\"}"; // String ss = "{\"taskId\":\"202203170025799000001\",\"message\":\"success\",\"timestamp\":1647481716818,\"status\":\"00\",\"tag\":\"\"}";
// com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSON.parseObject(ss); // com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSON.parseObject(ss);
com.alibaba.fastjson.JSONObject jsonObject = busTencentProperties.smsCredential(phoneNo, content); com.alibaba.fastjson.JSONObject jsonObject = busTencentProperties.smsCredential(phoneNo, content);
System.out.println(jsonObject); // log.error(jsonObject);
if("00".equals(jsonObject.getString("status"))){ if("00".equals(jsonObject.getString("status"))){
//定时任务15天之前的删除记录 todo //定时任务15天之前的删除记录 todo
// BusFifteenInfo fifteenInfo = new BusFifteenInfo(); // BusFifteenInfo fifteenInfo = new BusFifteenInfo();
@ -320,10 +322,9 @@ public class AiServiceImpl implements IAiService {
// fifteenInfo.setLastVisitTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); // fifteenInfo.setLastVisitTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
// fifteenInfoService.insertBusFifteenInfo(fifteenInfo); // fifteenInfoService.insertBusFifteenInfo(fifteenInfo);
} }
System.out.println("建立sendSmsTask成功 "); log.error("建立sendSmsTask成功 ");
} catch (Exception e) { } catch (Exception e) {
System.out.println("建立sendSmsTask错误 " + busOrderInfo.toString()); log.error("建立sendSmsTask错误 " + busOrderInfo.toString(),e.getMessage());
e.printStackTrace();
} }
} }
@ -344,7 +345,7 @@ public class AiServiceImpl implements IAiService {
String taskMainId = data1.getString("dial_task_main_id"); String taskMainId = data1.getString("dial_task_main_id");
String taskMainSn = data1.getString("dial_task_main_sn"); String taskMainSn = data1.getString("dial_task_main_sn");
System.out.println("建立任务返回: ============taskMainId,taskMainSn===========" + taskMainId + "," + taskMainSn); log.error("建立任务返回: ============taskMainId,taskMainSn===========" + taskMainId + "," + taskMainSn);
redisTemplate.opsForValue().set("dialTaskMainSn", taskMainSn); redisTemplate.opsForValue().set("dialTaskMainSn", taskMainSn);
@ -359,7 +360,7 @@ public class AiServiceImpl implements IAiService {
sendAiTask(content, busOrderInfo); sendAiTask(content, busOrderInfo);
} else { } else {
// TODO: 2024/7/10 失败原因判断 是否继续循环 // TODO: 2024/7/10 失败原因判断 是否继续循环
System.out.println("建立任务接口返回错误: " + jo.toString()); log.error("建立任务接口返回错误: " + jo.toString());
} }
} }
@ -379,7 +380,7 @@ public class AiServiceImpl implements IAiService {
try { try {
returnVisitInfo.setFinishTime(format.parse(aiInfo.getDisconnectedAt())); returnVisitInfo.setFinishTime(format.parse(aiInfo.getDisconnectedAt()));
}catch (Exception e){ }catch (Exception e){
System.out.println("DisconnectedAt异常结果"+aiInfo.getEndreason()); log.error("DisconnectedAt异常结果"+aiInfo.getEndreason());
} }
busReturnVisitInfoMapper.updateBusReturnVisitInfo(returnVisitInfo); busReturnVisitInfoMapper.updateBusReturnVisitInfo(returnVisitInfo);
} }

View File

@ -13,6 +13,7 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.SplitListUtils; import com.ruoyi.common.utils.SplitListUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SysDictDataMapper; import com.ruoyi.system.mapper.SysDictDataMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
@ -56,6 +57,7 @@ import java.util.stream.Collectors;
/** /**
* 采集美团数据service * 采集美团数据service
*/ */
@Slf4j
@Service @Service
public class MeituanServiceImpl implements IMeituanService { public class MeituanServiceImpl implements IMeituanService {
@ -224,19 +226,19 @@ public class MeituanServiceImpl implements IMeituanService {
for (BusStoreInfo store : busStoreInfoList) { for (BusStoreInfo store : busStoreInfoList) {
Boolean flag1 = getScoreOne(store); Boolean flag1 = getScoreOne(store);
if (!flag1) { if (!flag1) {
System.out.println("获取评分信息返回错误..."); log.error("获取评分信息返回错误...");
} }
Boolean flag2 = getCommentsOne(store); Boolean flag2 = getCommentsOne(store);
if (!flag2) { if (!flag2) {
System.out.println("获取好评信息返回错误..."); log.error("获取好评信息返回错误...");
} }
Boolean flag3 = yesterdayCountOne(store); Boolean flag3 = yesterdayCountOne(store);
if (!flag3) { if (!flag3) {
System.out.println("获取昨日单量信息返回错误..."); log.error("获取昨日单量信息返回错误...");
} }
Boolean flag4 = updateDayInfo(store); Boolean flag4 = updateDayInfo(store);
if (!flag4) { if (!flag4) {
System.out.println("获取昨日营销信息返回错误..."); log.error("获取昨日营销信息返回错误...");
} }
} }
return "ok"; return "ok";
@ -253,15 +255,15 @@ public class MeituanServiceImpl implements IMeituanService {
BusStoreInfo store = busStoreInfoMapper.selectBusStoreInfoById(id); BusStoreInfo store = busStoreInfoMapper.selectBusStoreInfoById(id);
Boolean flag1 = getScoreOne(store); Boolean flag1 = getScoreOne(store);
if (!flag1) { if (!flag1) {
System.out.println("获取评分信息返回错误..."); log.error("获取评分信息返回错误...");
} }
Boolean flag2 = getCommentsOne(store); Boolean flag2 = getCommentsOne(store);
if (!flag2) { if (!flag2) {
System.out.println("获取好评信息返回错误..."); log.error("获取好评信息返回错误...");
} }
Boolean flag3 = yesterdayCountOne(store); Boolean flag3 = yesterdayCountOne(store);
if (!flag3) { if (!flag3) {
System.out.println("获取昨日统计信息返回错误..."); log.error("获取昨日统计信息返回错误...");
} }
return "ok"; return "ok";
} }
@ -289,17 +291,11 @@ public class MeituanServiceImpl implements IMeituanService {
try { try {
countDownLatch.await(); //保证之前的所有的线程都执行完成才会走下面的 countDownLatch.await(); //保证之前的所有的线程都执行完成才会走下面的
long endTime = System.currentTimeMillis(); //结束时间 long endTime = System.currentTimeMillis(); //结束时间
System.out.println(("一共耗时time: " + (endTime - startTime) / 1000 + " s")); log.error(("一共耗时time: " + (endTime - startTime) / 1000 + " s"));
// 这样就可以在下面拿到所有线程执行完的集合结果 // 这样就可以在下面拿到所有线程执行完的集合结果
} catch (Exception e) { } catch (Exception e) {
System.out.println("阻塞异常:"+e.getMessage()); log.error("阻塞异常:"+e.getMessage());
} }
// for (BusStoreInfo store : busStoreInfoList) {
// R flag = orderInfo(store.getStoreCode(),now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),store.getStoreCookie());
// if (flag.getCode() != 200) {
// System.out.println("获取订单信息返回错误...");
// }
// }
return "ok"; return "ok";
} }
@ -333,7 +329,7 @@ public class MeituanServiceImpl implements IMeituanService {
try { try {
result = EntityUtils.toString(httpClient.execute(request).getEntity()); result = EntityUtils.toString(httpClient.execute(request).getEntity());
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); log.error("昨日订单量异常跳出",e.getMessage());
return false; return false;
} }
if (result != null) { if (result != null) {
@ -343,7 +339,7 @@ public class MeituanServiceImpl implements IMeituanService {
JSONArray array = jsonObject.getJSONArray("data"); JSONArray array = jsonObject.getJSONArray("data");
JSONObject one = array.getJSONObject(3); JSONObject one = array.getJSONObject(3);
String total = one.getString("base"); String total = one.getString("base");
System.out.println(total); log.error("昨日订单量总数",total);
BusStoreInfo store = new BusStoreInfo(); BusStoreInfo store = new BusStoreInfo();
store.setStoreCode(wmPoiId); store.setStoreCode(wmPoiId);
List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(store); List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(store);
@ -367,7 +363,6 @@ public class MeituanServiceImpl implements IMeituanService {
busStoreInfoService.updateBusStoreInfo(storeInfo); busStoreInfoService.updateBusStoreInfo(storeInfo);
} }
} }
// System.out.println(jsonObject);
return true; return true;
} }
@ -384,11 +379,11 @@ public class MeituanServiceImpl implements IMeituanService {
public R orderInfo(String wmPoiId, String date, String cookie) { public R orderInfo(String wmPoiId, String date, String cookie) {
try { try {
LocalDate localDate = LocalDate.parse(date); LocalDate localDate = LocalDate.parse(date);
LocalDate prevDay = localDate.minusDays(1); // LocalDate prevDay = localDate.minusDays(1);
String oldKey = wmPoiId + prevDay.toString(); // String oldKey = wmPoiId + prevDay.toString();
if (redisTemplate.opsForValue().get(oldKey) != null){ // if (redisTemplate.opsForValue().get(oldKey) != null){
redisTemplate.delete(oldKey); // redisTemplate.delete(oldKey);
} // }
int pageNum = 1; int pageNum = 1;
String getUrl = proxyProperties.gettpsUrl(); String getUrl = proxyProperties.gettpsUrl();
@ -480,7 +475,7 @@ public class MeituanServiceImpl implements IMeituanService {
try { try {
orderInfo.setOrderTime(format.parse(orderTimeFmt)); orderInfo.setOrderTime(format.parse(orderTimeFmt));
} catch (ParseException e) { } catch (ParseException e) {
System.out.println(e.getMessage()); log.error("订单时间解析异常不跳出"+e.getMessage());
} }
orderInfo.setIsPhf(businessType); orderInfo.setIsPhf(businessType);
}catch (Exception e){ }catch (Exception e){
@ -508,7 +503,7 @@ public class MeituanServiceImpl implements IMeituanService {
storeInfo1.setGrantStatus("2"); storeInfo1.setGrantStatus("2");
busStoreInfoMapper.updateBusStoreInfo(storeInfo1); busStoreInfoMapper.updateBusStoreInfo(storeInfo1);
System.out.println(jo.getString("msg")); log.error("掉线",jo.getString("msg"));
return R.fail(jo.getString("msg")); return R.fail(jo.getString("msg"));
} }
} }
@ -522,7 +517,7 @@ public class MeituanServiceImpl implements IMeituanService {
} }
return R.fail(jsonObject.getString("msg")); return R.fail(jsonObject.getString("msg"));
}catch (Exception e){ }catch (Exception e){
System.out.println("================拉取订单出错:==============="+e.getMessage()); log.error("================拉取订单出错:==============="+e.getMessage());
// return orderInfo(wmPoiId, date, cookie); // return orderInfo(wmPoiId, date, cookie);
return R.fail("拉取订单出错"); return R.fail("拉取订单出错");
} }
@ -583,7 +578,7 @@ public class MeituanServiceImpl implements IMeituanService {
jsonObject = JSONObject.parseObject(resp); jsonObject = JSONObject.parseObject(resp);
code = jsonObject.getString(("code")); code = jsonObject.getString(("code"));
} catch (Exception e) { } catch (Exception e) {
System.out.println("===============订单解析号码出错:================"+e.getMessage()); log.error("===============订单解析号码出错:================"+e.getMessage());
client = localHttpClient(); client = localHttpClient();
try { try {
@ -593,7 +588,7 @@ public class MeituanServiceImpl implements IMeituanService {
jsonObject = JSONObject.parseObject(resp); jsonObject = JSONObject.parseObject(resp);
code = jsonObject.getString(("code")); code = jsonObject.getString(("code"));
}catch (Exception e1){ }catch (Exception e1){
System.out.println("===============本地订单解析号码出错:================"+e1.getMessage()); log.error("===============本地订单解析号码出错:================"+e1.getMessage());
} }
} }
if ("0".equals(code)) { if ("0".equals(code)) {
@ -608,7 +603,7 @@ public class MeituanServiceImpl implements IMeituanService {
orderInfo.setRecipientPhone(recipientPhone); orderInfo.setRecipientPhone(recipientPhone);
orderInfo.setRecipientBindedPhone(recipientBindedPhone); orderInfo.setRecipientBindedPhone(recipientBindedPhone);
System.out.println("****************订单解析成功:****************"+JSON.toJSONString(orderInfo)); log.error("****************订单解析成功:****************"+JSON.toJSONString(orderInfo));
lsList.add(orderInfo); lsList.add(orderInfo);
@ -624,10 +619,11 @@ public class MeituanServiceImpl implements IMeituanService {
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
lss.add(returnVisitInfo); lss.add(returnVisitInfo);
} }
} }
log.error(ls.get(0).getStoreCode()+"********************************"+lsList.size());
log.error("********************************"+lss.size());
if (lsList.size() > 0) { if (lsList.size() > 0) {
busOrderInfoMapper.batchInsertOrder(lsList); busOrderInfoMapper.batchInsertOrder(lsList);
} }
@ -659,7 +655,7 @@ public class MeituanServiceImpl implements IMeituanService {
try { try {
result = EntityUtils.toString(httpClient.execute(request).getEntity()); result = EntityUtils.toString(httpClient.execute(request).getEntity());
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); log.error("拼好饭订单数拉取失败",e.getMessage());
} }
JSONObject json = JSONObject.parseObject(result); JSONObject json = JSONObject.parseObject(result);
String code = json.getString("code"); String code = json.getString("code");
@ -707,7 +703,7 @@ public class MeituanServiceImpl implements IMeituanService {
resp = EntityUtils.toString(responseEntity); resp = EntityUtils.toString(responseEntity);
jsonObject = JSONObject.parseObject(resp); jsonObject = JSONObject.parseObject(resp);
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); log.error("分页拉取订单",e.getMessage());
// jsonObject.put("code","403"); // jsonObject.put("code","403");
} }
return jsonObject; return jsonObject;
@ -774,7 +770,7 @@ public class MeituanServiceImpl implements IMeituanService {
} }
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); log.error("店铺名拉取失败"+e.getMessage());
} }
return null; return null;
} }
@ -807,7 +803,7 @@ public class MeituanServiceImpl implements IMeituanService {
} }
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); log.error("店铺名2拉取失败"+e.getMessage());
} }
return null; return null;
} }
@ -829,13 +825,7 @@ public class MeituanServiceImpl implements IMeituanService {
httpPost.setHeader("Content-Type", "application/json"); httpPost.setHeader("Content-Type", "application/json");
Map<String, Object> subUrlParams = new LinkedHashMap<>(); Map<String, Object> subUrlParams = new LinkedHashMap<>();
// subUrlParams.put("url", "https://e.waimai.meituan.com/v2/order/history/r/search/ajax?");
// subUrlParams.put("searchItem", orderId);
// subUrlParams.put("region_id", regionId);
// subUrlParams.put("region_version", regionVersion);
// subUrlParams.put("yodaReady", "h5");
// subUrlParams.put("csecplatform", 4);
// subUrlParams.put("csecversion", "2.4.0");
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("url","https://e.waimai.meituan.com/v2/order/history/r/search/ajax?searchItem="+orderId+"&region_id="+regionId+"&region_version="+regionVersion+"&yodaReady=h5&csecplatform=4&csecversion=2.4.0"); jsonObject.put("url","https://e.waimai.meituan.com/v2/order/history/r/search/ajax?searchItem="+orderId+"&region_id="+regionId+"&region_version="+regionVersion+"&yodaReady=h5&csecplatform=4&csecversion=2.4.0");
jsonObject.put("data",""); jsonObject.put("data","");
@ -843,16 +833,7 @@ public class MeituanServiceImpl implements IMeituanService {
jsonObject.put("method","GET"); jsonObject.put("method","GET");
StringEntity entity = new StringEntity(JSONObject.toJSONString(jsonObject), "utf-8"); StringEntity entity = new StringEntity(JSONObject.toJSONString(jsonObject), "utf-8");
// subUrlParams.put("data", "");
// subUrlParams.put("dfpid", dfpid.split("-")[0]);
// subUrlParams.put("method", "post");
//
// String urlParam = "";
// for (Map.Entry<String, Object> stringObjectEntry : subUrlParams.entrySet()) {
// urlParam = urlParam + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue() + "&";
// }
String result = null; String result = null;
// StringEntity params = new StringEntity(urlParam.substring(0, urlParam.length() - 1));
try { try {
httpPost.setEntity(entity); httpPost.setEntity(entity);
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
@ -955,7 +936,7 @@ public class MeituanServiceImpl implements IMeituanService {
try { try {
result = EntityUtils.toString(httpClient.execute(request).getEntity()); result = EntityUtils.toString(httpClient.execute(request).getEntity());
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); log.error("获取评分失败"+e.getMessage());
return false; return false;
} }
if (result != null) { if (result != null) {
@ -1021,13 +1002,13 @@ public class MeituanServiceImpl implements IMeituanService {
CloseableHttpClient httpClient = proxyHttpClient(); CloseableHttpClient httpClient = proxyHttpClient();
result = EntityUtils.toString(httpClient.execute(request).getEntity()); result = EntityUtils.toString(httpClient.execute(request).getEntity());
if (StringUtils.isEmpty(result)) { if (StringUtils.isEmpty(result)) {
System.out.println(result); log.error("获取好评数五星数失败"+result);
return false; return false;
} }
JSONObject jsonObject = JSONObject.parseObject(result); JSONObject jsonObject = JSONObject.parseObject(result);
String code = jsonObject.getString(("code")); String code = jsonObject.getString(("code"));
if ("1001".equals(code)) { if ("1001".equals(code)) {
System.out.println(result); log.error("掉线"+result);
store.setGrantStatus("2"); store.setGrantStatus("2");
busStoreInfoService.updateBusStoreInfo(store); busStoreInfoService.updateBusStoreInfo(store);
return false; return false;
@ -1045,12 +1026,10 @@ public class MeituanServiceImpl implements IMeituanService {
busStoreDayInfo1.setCreateTime(Date.from(LocalDateTime.now().minusDays(1).atZone(ZoneId.systemDefault()).toInstant())); busStoreDayInfo1.setCreateTime(Date.from(LocalDateTime.now().minusDays(1).atZone(ZoneId.systemDefault()).toInstant()));
busStoreDayInfoService.updateBusStoreDayInfo(busStoreDayInfo1); busStoreDayInfoService.updateBusStoreDayInfo(busStoreDayInfo1);
} }
// System.out.println(jsonObject);//落库
return true; return true;
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); log.error("获取好评数五星数失败",e.getMessage());
return false; return false;
// e.printStackTrace();
} }
} }
@ -1086,42 +1065,7 @@ public class MeituanServiceImpl implements IMeituanService {
.setDefaultRequestConfig(config) .setDefaultRequestConfig(config)
.setDefaultCredentialsProvider(credsProvider) .setDefaultCredentialsProvider(credsProvider)
.build(); .build();
// CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(config).build();
return httpClient; return httpClient;
// String ipPort = proxyProperties.getUrl();
// JDK 8u111版本后目标页面为HTTPS协议启用proxy用户密码鉴权
// System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
//
// String ip = ipPort.split(":")[0];
// int port = Integer.valueOf(ipPort.split(":")[1]);
// HttpHost proxy = new HttpHost(ip, port);
// CredentialsProvider credsProvider = new BasicCredentialsProvider();
// credsProvider.setCredentials(new AuthScope(ip, port),
// new UsernamePasswordCredentials(proxyProperties.getAccountSM(), proxyProperties.getPwdSM()));
// RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
// CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).setDefaultRequestConfig(config).build();
// return httpclient;
// try {
// URL url = new URL(pageUrl);
// HttpHost target = new HttpHost(url.getHost(), url.getDefaultPort(), url.getProtocol());
// HttpHost proxy = new HttpHost(proxyIp, proxyPort);
//
// RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
// HttpGet httpget = new HttpGet(url.getPath());
// httpget.setConfig(config);
// httpget.addHeader("Accept-Encoding", "gzip"); // 使用gzip压缩传输数据让访问更快
// httpget.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36");
// CloseableHttpResponse response = httpclient.execute(target, httpget);
// try {
// System.out.println(response.getStatusLine());
// System.out.println(EntityUtils.toString(response.getEntity()));
// } finally {
// response.close();
// }
// } finally {
// httpclient.close();
// }
} }
private CloseableHttpClient proxyHttpClient() { private CloseableHttpClient proxyHttpClient() {
String proxyHost = proxyProperties.getProxyAddr(); String proxyHost = proxyProperties.getProxyAddr();
@ -1145,21 +1089,9 @@ public class MeituanServiceImpl implements IMeituanService {
private CloseableHttpClient localHttpClient() { private CloseableHttpClient localHttpClient() {
// JDK 8u111版本后目标页面为HTTPS协议启用proxy用户密码鉴权 // JDK 8u111版本后目标页面为HTTPS协议启用proxy用户密码鉴权
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", ""); System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
// String proxyHost = proxyProperties.getProxyAddr();
// int proxyPort = proxyProperties.getProxyPort();
// String username = proxyProperties.getAccount();
// String password = proxyProperties.getPwd();
// 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 CloseableHttpClient httpClient = HttpClients
.custom() .custom()
// .setDefaultRequestConfig(config)
// .setDefaultCredentialsProvider(credsProvider)
.build(); .build();
// CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(config).build();
return httpClient; return httpClient;
} }