|
|
|
@ -3,26 +3,23 @@ package com.yuyou.openapi.openapi.task;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.codec.Base64;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.yuyou.openapi.openapi.api.enums.LuoShiAppIDEnum;
|
|
|
|
|
import com.yuyou.openapi.openapi.common.enums.IntentionEnum;
|
|
|
|
|
import com.yuyou.openapi.openapi.common.enums.SourceEnum;
|
|
|
|
|
import com.yuyou.openapi.openapi.consts.SmsConstant;
|
|
|
|
|
import com.yuyou.openapi.openapi.consts.SpecialCityConst;
|
|
|
|
|
import com.yuyou.openapi.openapi.dao.PhonesRepository;
|
|
|
|
|
import com.yuyou.openapi.openapi.model.dto.*;
|
|
|
|
|
import com.yuyou.openapi.openapi.model.pojo.BlackJsonContent;
|
|
|
|
|
import com.yuyou.openapi.openapi.model.pojo.QiZhuangDTO;
|
|
|
|
|
import com.yuyou.openapi.openapi.model.pojo.token.QiZhuangTokenResponse;
|
|
|
|
|
import com.yuyou.openapi.openapi.model.pojo.token.TuBoShuTokenResponse;
|
|
|
|
|
import com.yuyou.openapi.openapi.model.vo.ABClientXMJMessageVO;
|
|
|
|
|
import com.yuyou.openapi.openapi.model.vo.data.DetailInfo;
|
|
|
|
|
import com.yuyou.openapi.openapi.service.ABMessageService;
|
|
|
|
@ -263,10 +260,10 @@ public class ABDownTask {
|
|
|
|
|
@Async(value = "abTaskExecutor")
|
|
|
|
|
public void doRunTaskTuboShu(List<ABMessageDTO> messageDTOList){
|
|
|
|
|
Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
log.info("====== [ task start running, task name is {} ] ======", "ABDownTask");
|
|
|
|
|
log.info("====== [ task start running, task name is {} ] ======", "doRunTaskTuboShu");
|
|
|
|
|
runTaskTuboShu(messageDTOList);
|
|
|
|
|
Long endMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
log.info("====== [ task start end, task name is {},cost milliSecond is {} ] ======", "ABDownTask", (endMilliSecond-satrtMilliSecond));
|
|
|
|
|
log.info("====== [ task start end, task name is {},cost milliSecond is {} ] ======", "doRunTaskTuboShu", (endMilliSecond-satrtMilliSecond));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 执行土拨鼠任务
|
|
|
|
@ -275,36 +272,49 @@ public class ABDownTask {
|
|
|
|
|
*/
|
|
|
|
|
private boolean runTaskTuboShu(List<ABMessageDTO> messageDTOList){
|
|
|
|
|
|
|
|
|
|
Map<String, Object> formMap = new HashMap<>();
|
|
|
|
|
Map<String, Object> formMapT = new HashMap<>();
|
|
|
|
|
formMap.put("password", passWord);
|
|
|
|
|
formMap.put("coopname", coopname);
|
|
|
|
|
|
|
|
|
|
int countToken = 0;
|
|
|
|
|
String tokenT = "";
|
|
|
|
|
//获取token
|
|
|
|
|
while (countToken < 3) {
|
|
|
|
|
// 调用HTTP请求发送数据
|
|
|
|
|
String result = sendPostReqTuBoShu(formMap, tuBoShuTokenUrl);
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(result);
|
|
|
|
|
tokenT = jsonObject.get("msg").toString();
|
|
|
|
|
if ("0".equals(jsonObject.getString("status"))) {
|
|
|
|
|
log.info("========== [ABDownTask|runTaskTuboShu request success, response is {} ] ==========", jsonObject.toJSONString());
|
|
|
|
|
tokenT = jsonObject.get("msg").toString();
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
TuBoShuTokenResponse tuBoShuTokenResponse = abScheduleTask.getTuBoShuTokenResponse();
|
|
|
|
|
// 检查如果第一次不存在就手动调用一次
|
|
|
|
|
if (null == tuBoShuTokenResponse){
|
|
|
|
|
abScheduleTask.executeGetTokenTuboshu();
|
|
|
|
|
tuBoShuTokenResponse = abScheduleTask.getTuBoShuTokenResponse();
|
|
|
|
|
}
|
|
|
|
|
if (tuBoShuTokenResponse != null){
|
|
|
|
|
if ("0".equals(tuBoShuTokenResponse.getStatus())) {
|
|
|
|
|
log.info("========== [ABDownTask|runTaskTuboShu request success, response is {} ] ==========", tuBoShuTokenResponse.toString());
|
|
|
|
|
tokenT = tuBoShuTokenResponse.getToken();
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
countToken++;
|
|
|
|
|
try {
|
|
|
|
|
// 重新发送前休眠3秒
|
|
|
|
|
Thread.sleep(3_0000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("ABDownTask|runTaskTuboShu sleep ERROR. message is {} , {}", e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
log.error("========== [ABDownTask|runTaskTuboShu request fail, response is {} ] ==========", tuBoShuTokenResponse.toString());
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
countToken++;
|
|
|
|
|
try {
|
|
|
|
|
// 重新发送前休眠3秒
|
|
|
|
|
Thread.sleep(3_0000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("ABDownTask|runTaskTuboShu sleep ERROR. message is", e.getMessage(), e);
|
|
|
|
|
log.error("ABDownTask|runTaskTuboShu sleep ERROR. message is {} , {}", e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
log.error("========== [SaveToFileTask|batchSendToEncrypt request fail, response is {} ] ==========", jsonObject.toJSONString());
|
|
|
|
|
log.error("========== [ABDownTask|runTaskTuboShu request fail, response is {} ] ==========", tuBoShuTokenResponse.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (countToken >= 3 || "".equals(tokenT)) {
|
|
|
|
|
log.error("========== [ABDownTask|runTaskTuboShu update send status fail, url is {} ] ==========");
|
|
|
|
|
log.error("========== [ABDownTask|runTaskTuboShu update send status fail, url is {} ] ==========", tuBoShuTokenUrl);
|
|
|
|
|
return Boolean.FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -314,8 +324,8 @@ public class ABDownTask {
|
|
|
|
|
list -> {
|
|
|
|
|
|
|
|
|
|
// 匹配城市
|
|
|
|
|
if (list.getMobile().length() == 11) {
|
|
|
|
|
String substring = StringUtils.substring(list.getMobile(), 0, list.getMobile().length() - 4);
|
|
|
|
|
if (Base64.decodeStr(list.getMobile()).length() == 11) {
|
|
|
|
|
String substring = StringUtils.substring(Base64.decodeStr(list.getMobile()), 0, Base64.decodeStr(list.getMobile()).length() - 4);
|
|
|
|
|
String matchCity = phonesRepository.findByNumber(substring);
|
|
|
|
|
if (StringUtils.isNotBlank(matchCity)) {
|
|
|
|
|
formMapT.put("city", matchCity.trim());
|
|
|
|
@ -332,7 +342,9 @@ public class ABDownTask {
|
|
|
|
|
formMapT.put("chcode", chcode);
|
|
|
|
|
formMapT.put("channel", channelT);
|
|
|
|
|
formMapT.put("real_order", Integer.parseInt(realOrder));
|
|
|
|
|
formMapT.put("coop_orderid", coopOrderid);
|
|
|
|
|
formMapT.put("coop_orderid", ""+list.getRecId()+(int)(Math.random()*90000+1000));
|
|
|
|
|
log.info("========== [ABDownTask|runTaskTuboShu request content is {} ] ==========", formMapT.toString());
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
while (count < 3) {
|
|
|
|
|
// 调用HTTP请求发送数据
|
|
|
|
@ -347,13 +359,13 @@ public class ABDownTask {
|
|
|
|
|
// 重新发送前休眠3秒
|
|
|
|
|
Thread.sleep(3_0000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("ABDownTask|runTaskTuboShu sleep ERROR. message is", e.getMessage(), e);
|
|
|
|
|
log.error("ABDownTask|runTaskTuboShu sleep ERROR. message is {} , {}", e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
log.error("========== [ABDownTask|runTaskTuboShu request fail, response is {} ] ==========", jsonObject.toJSONString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (count >= 3) {
|
|
|
|
|
log.error("========== [ABDownTask|runTaskTuboShu update send status fail, url is {} ] ==========");
|
|
|
|
|
log.error("========== [ABDownTask|runTaskTuboShu update send status fail, url is {} ] ==========", tuBoShuUrl);
|
|
|
|
|
}else {
|
|
|
|
|
abMessageService.updateSendStatus(Long.valueOf(list.getRecId()), Boolean.TRUE);
|
|
|
|
|
}
|
|
|
|
|