|
|
@@ -26,10 +26,14 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
+ private static final ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
+
|
|
|
@Autowired
|
|
|
private ICacheService cacheService;
|
|
|
|
|
|
@@ -129,33 +133,44 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
下载点众IAP数据
|
|
|
*/
|
|
|
public void getUrlData(String statDate) {
|
|
|
- List<JSONObject> tasks = dianZhongMapper.getTaskUrl(statDate.replace("-", ""));
|
|
|
+ List<JSONObject> tasks = dianZhongMapper.getTaskUrl(statDate == null ? null : statDate.replace("-", ""));
|
|
|
if (!Check.isNull(tasks)) {
|
|
|
for (JSONObject task : tasks) {
|
|
|
- String taskId = task.getString("task_id");
|
|
|
- String url = task.getString("url");
|
|
|
- String type = task.getString("type");
|
|
|
- String clientId = task.getString("client_id");
|
|
|
-
|
|
|
- downloadFileRestTemplate.execute(url, org.springframework.http.HttpMethod.GET, null,
|
|
|
- (ResponseExtractor<Void>) response -> {
|
|
|
- try (BufferedReader reader = new BufferedReader(
|
|
|
- new InputStreamReader(response.getBody(), StandardCharsets.UTF_8))) {
|
|
|
- String line;
|
|
|
- while ((line = reader.readLine()) != null) {
|
|
|
- if ("user".equals(type)) {
|
|
|
- getDZUser(line);
|
|
|
- getDZLogin(line);
|
|
|
- getDZActivation(line);
|
|
|
- getDZRegister(line, statDate);
|
|
|
- } else if ("order".equals(type)) {
|
|
|
- getDZOrder(line);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- });
|
|
|
- dianZhongMapper.updateTaskDownloaded(taskId);
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ String taskId = task.getString("task_id");
|
|
|
+ String url = task.getString("url");
|
|
|
+ String type = task.getString("type");
|
|
|
+ String clientId = task.getString("client_id");
|
|
|
+ String dataDate = task.getString("stat_date");
|
|
|
+ try {
|
|
|
+ log.info("开始下载点众数据 taskId:{}, clientId:{}, type:{}", taskId, clientId, type);
|
|
|
+ downloadFileRestTemplate.execute(url, org.springframework.http.HttpMethod.GET, null,
|
|
|
+ (ResponseExtractor<Void>) response -> {
|
|
|
+ try (BufferedReader reader = new BufferedReader(
|
|
|
+ new InputStreamReader(response.getBody(), StandardCharsets.UTF_8))) {
|
|
|
+ String line;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ if ("user".equals(type)) {
|
|
|
+ getDZUser(line);
|
|
|
+ getDZLogin(line);
|
|
|
+ getDZActivation(line);
|
|
|
+ getDZRegister(line, dataDate);
|
|
|
+ } else if ("order".equals(type)) {
|
|
|
+ getDZOrder(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ dianZhongMapper.updateTaskDownloaded(taskId);
|
|
|
+ log.info("下载点众数据成功 taskId:{}, clientId:{}, type:{}", taskId, clientId, type);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("下载点众数据失败 taskId:{}, clientId:{}, type:{}", taskId, clientId, type, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -180,7 +195,7 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
- String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
String fromMedia = jsonObject.getString("from");
|
|
|
userJson.put("app_id", appIdByChannelId);
|
|
|
userJson.put("uid", jsonObject.getString("userId"));
|
|
|
@@ -230,8 +245,8 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
- String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
- String activationDate = DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
+ String activationDate = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd") : null;
|
|
|
Long ctime = jsonObject.getLong("ctime");
|
|
|
String registerTime = DateUtils.formatDate(ctime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
String registerDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
@@ -287,6 +302,9 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
+ if (dyeTime == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
String statDate = DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd");
|
|
|
String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
Long ctime = jsonObject.getLong("ctime");
|
|
|
@@ -346,8 +364,8 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
- String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
- String activationDate = DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
+ String activationDate = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd") : null;
|
|
|
String registerTime = DateUtils.formatDate(ctime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
String registerDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
String fromMedia = jsonObject.getString("from");
|
|
|
@@ -407,8 +425,8 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
- String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
- String activationDate = DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
+ String activationDate = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd") : null;
|
|
|
Long registerT = jsonObject.getLong("registerDate");
|
|
|
String registerTime = DateUtils.formatDate(registerT * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
String registerDate = DateUtils.formatDate(registerT * 1000, "yyyyMMdd");
|