|
@@ -4,6 +4,7 @@ import cn.com.ctop.job.bytedance.data.entity.BytedanceErrorLog;
|
|
|
import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
|
|
import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.mapper.DianZhongMapper;
|
|
import cn.com.ctop.job.bytedance.data.mapper.DianZhongMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IDianZhongService;
|
|
import cn.com.ctop.job.bytedance.data.service.IDianZhongService;
|
|
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.DateUtils;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
|
|
import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
import cn.hutool.crypto.SecureUtil;
|
|
@@ -12,6 +13,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class DianZhongServiceImpl implements IDianZhongService {
|
|
public class DianZhongServiceImpl implements IDianZhongService {
|
|
@@ -21,8 +24,12 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DianZhongMapper dianZhongMapper;
|
|
private DianZhongMapper dianZhongMapper;
|
|
|
|
|
|
|
|
|
|
+ public List<JSONObject> getDZRetry(){
|
|
|
|
|
+ return dianZhongMapper.getDZRetry();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void getDownloadUrl(String dataType, String clientId, String token,
|
|
public void getDownloadUrl(String dataType, String clientId, String token,
|
|
|
- String statDay, String startTime, String endTime) {
|
|
|
|
|
|
|
+ String startTime, String endTime, Long errId, boolean isLog) {
|
|
|
long l = System.currentTimeMillis();
|
|
long l = System.currentTimeMillis();
|
|
|
JSONObject param = new JSONObject()
|
|
JSONObject param = new JSONObject()
|
|
|
.fluentPut("clientId", clientId)
|
|
.fluentPut("clientId", clientId)
|
|
@@ -30,43 +37,53 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
.fluentPut("edate", String.valueOf(DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss").getTime() / 1000))
|
|
.fluentPut("edate", String.valueOf(DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss").getTime() / 1000))
|
|
|
.fluentPut("timestamp", l)
|
|
.fluentPut("timestamp", l)
|
|
|
.fluentPut("signKey", getSignKey(clientId, token, l));
|
|
.fluentPut("signKey", getSignKey(clientId, token, l));
|
|
|
|
|
+ if ("user".equals(dataType)) {
|
|
|
|
|
+ param.put("queryField", "loginTime");
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
String url = "https://routine.wqxsw.com/flames/channel/query/" + dataType;
|
|
String url = "https://routine.wqxsw.com/flames/channel/query/" + dataType;
|
|
|
String response = HttpUtils.httpPostRequest(url, param, null);
|
|
String response = HttpUtils.httpPostRequest(url, param, null);
|
|
|
JSONObject responseJson = JSONObject.parseObject(response);
|
|
JSONObject responseJson = JSONObject.parseObject(response);
|
|
|
- System.out.println(response);
|
|
|
|
|
if ("0".equals(responseJson.getString("retCode"))) {
|
|
if ("0".equals(responseJson.getString("retCode"))) {
|
|
|
String taskId = responseJson.getString("data");
|
|
String taskId = responseJson.getString("data");
|
|
|
JSONObject jsonObject = new JSONObject()
|
|
JSONObject jsonObject = new JSONObject()
|
|
|
- .fluentPut("stat_date", statDay.replace("-", ""))
|
|
|
|
|
|
|
+ .fluentPut("stat_date", DateUtils.transformFormat(endTime,"yyyy-MM-dd HH:mm:ss","yyyyMMdd"))
|
|
|
.fluentPut("task_id", taskId)
|
|
.fluentPut("task_id", taskId)
|
|
|
.fluentPut("type", dataType)
|
|
.fluentPut("type", dataType)
|
|
|
.fluentPut("client_id", clientId);
|
|
.fluentPut("client_id", clientId);
|
|
|
dianZhongMapper.insertDownloadTask(jsonObject);
|
|
dianZhongMapper.insertDownloadTask(jsonObject);
|
|
|
log.info("获取点众数据下载地址成功 {} {} {}~{} ", dataType, clientId, startTime, endTime);
|
|
log.info("获取点众数据下载地址成功 {} {} {}~{} ", dataType, clientId, startTime, endTime);
|
|
|
|
|
+
|
|
|
|
|
+ if (errId != null) {
|
|
|
|
|
+ promoterReportMapper.deleteInfoByErrorId(errId);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
log.error("获取点众数据下载地址错误 {} {} {}~{} msg:{}", dataType, clientId, startTime, endTime, responseJson.getString("retMsg"));
|
|
log.error("获取点众数据下载地址错误 {} {} {}~{} msg:{}", dataType, clientId, startTime, endTime, responseJson.getString("retMsg"));
|
|
|
|
|
+ if (isLog) {
|
|
|
|
|
+ promoterReportMapper.replaceErrorInfo(
|
|
|
|
|
+ BytedanceErrorLog.builder()
|
|
|
|
|
+ .msg(responseJson.getString("retMsg"))
|
|
|
|
|
+ .advertiserId(Long.valueOf(clientId))
|
|
|
|
|
+ .dataDimension("dianzhong_url")
|
|
|
|
|
+ .dataType(dataType)
|
|
|
|
|
+ .startDate(startTime)
|
|
|
|
|
+ .endDate(endTime)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("获取点众数据下载地址错误 {} {} {}~{} ", dataType, clientId, startTime, endTime, e);
|
|
|
|
|
+ if (isLog) {
|
|
|
promoterReportMapper.replaceErrorInfo(
|
|
promoterReportMapper.replaceErrorInfo(
|
|
|
BytedanceErrorLog.builder()
|
|
BytedanceErrorLog.builder()
|
|
|
- .msg(responseJson.getString("retMsg"))
|
|
|
|
|
|
|
+ .msg(e.getMessage())
|
|
|
.advertiserId(Long.valueOf(clientId))
|
|
.advertiserId(Long.valueOf(clientId))
|
|
|
- .dataDimension("dianzhong")
|
|
|
|
|
|
|
+ .dataDimension("dianzhong_url")
|
|
|
.dataType(dataType)
|
|
.dataType(dataType)
|
|
|
.startDate(startTime)
|
|
.startDate(startTime)
|
|
|
.endDate(endTime)
|
|
.endDate(endTime)
|
|
|
.build());
|
|
.build());
|
|
|
}
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("获取点众数据下载地址错误 {} {} {}~{} ", dataType, clientId, startTime, endTime, e);
|
|
|
|
|
- promoterReportMapper.replaceErrorInfo(
|
|
|
|
|
- BytedanceErrorLog.builder()
|
|
|
|
|
- .msg(e.getMessage())
|
|
|
|
|
- .advertiserId(Long.valueOf(clientId))
|
|
|
|
|
- .dataDimension("dianzhong")
|
|
|
|
|
- .dataType(dataType)
|
|
|
|
|
- .startDate(startTime)
|
|
|
|
|
- .endDate(endTime)
|
|
|
|
|
- .build());
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|