|
@@ -1,30 +1,222 @@
|
|
|
package org.jeecg;
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.mapper.MailLogMapper;
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.CorpWexinUtils;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouUnitLevelOperationRecordMapper;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Scanner;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
|
|
public class SampleTest {
|
|
|
- @Resource
|
|
|
- CorpWexinUtils corpWexinUtils;
|
|
|
- @Resource
|
|
|
- MailLogMapper mailLogMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IKuaishouAudienceReportDailyGenderService audienceReportDailyGenderService;
|
|
|
@Test
|
|
|
- public void weixin(){
|
|
|
- JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("26bbe90edc5b475ca41ec3f76aa65067");
|
|
|
- StringBuilder text = new StringBuilder();
|
|
|
- text.append("您有一条销售政策需要审核,该客户为:");
|
|
|
- text.append("测试");
|
|
|
- text.append(",请及时登录助手平台-销售政策页面进行审核,谢谢!");
|
|
|
- corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
|
|
|
+ public void IKuaishouAudienceReportDailyGenderServiceTest(){
|
|
|
+ audienceReportDailyGenderService.mergeAudienceReportDailyDate("2021-07-20");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+// @Resource
|
|
|
+// CorpWexinUtils corpWexinUtils;
|
|
|
+// @Resource
|
|
|
+// MailLogMapper mailLogMapper;
|
|
|
+// @Test
|
|
|
+// public void weixin(){
|
|
|
+// JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("26bbe90edc5b475ca41ec3f76aa65067");
|
|
|
+// StringBuilder text = new StringBuilder();
|
|
|
+// text.append("您有一条销售政策需要审核,该客户为:");
|
|
|
+// text.append("测试");
|
|
|
+// text.append(",请及时登录助手平台-销售政策页面进行审核,谢谢!");
|
|
|
+// corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
|
|
|
+// @Resource
|
|
|
+// AiKuaishouUnitLevelOperationRecordMapper kuaishouUnitLevelOperationRecordMapper;
|
|
|
+// @Test
|
|
|
+// public void getAudienceReport() throws InterruptedException {
|
|
|
+// int page = 1;
|
|
|
+// int pageSize = 2000;
|
|
|
+// Date beginDate = DateUtils.parseDate("2021-05-01", "yyyy-MM-dd");
|
|
|
+// Date endDate = DateUtils.parseDate("2021-06-01", "yyyy-MM-dd");
|
|
|
+//
|
|
|
+// while (beginDate.before(endDate)){
|
|
|
+// Date mulDate = beginDate;
|
|
|
+// List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountId(mulDate, DateUtils.addDay(mulDate,1));
|
|
|
+// countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
|
|
|
+// planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
|
|
|
+// try{
|
|
|
+// CtopOauthToken token = tokenService.getTokenByAccountId(planIdAndUnitId.getAccountId());
|
|
|
+// if(!Check.isNull(token)){
|
|
|
+// Date startDate = mulDate;
|
|
|
+// Date enDate = DateUtils.addDay(startDate, 30);
|
|
|
+// // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
|
|
|
+// while (startDate.before(enDate)){
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate,"yyyy-MM-dd"), "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
|
|
|
+// System.out.println("获取完毕 -> unit:" + planIdAndUnitId.getUnitId() +",日期:" + DateUtils.formatDate(startDate,"yyyy-MM-dd"));
|
|
|
+// startDate = DateUtils.addDay(startDate, 1);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else {
|
|
|
+// System.out.println("token异常 -》 accountId:"+planIdAndUnitId.getAccountId());
|
|
|
+// }
|
|
|
+// }catch (Exception e){
|
|
|
+// }finally {
|
|
|
+// countDownLatch.countDown();
|
|
|
+// }
|
|
|
+// }));
|
|
|
+// beginDate = DateUtils.addDay(beginDate, 1);
|
|
|
+// countDownLatch.await();
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("走完了~");
|
|
|
+//
|
|
|
+// }
|
|
|
+// @Autowired
|
|
|
+// cn.com.ctop.kuaishou.modules.report.service.IKuaishouPullTaskInfoService kuaishouPullTaskInfoService;
|
|
|
+// /**
|
|
|
+// * 发布任务到表里,大家消耗任务。 458 淘特项目所有账户从6月1日开始到现在所有的最新的数据
|
|
|
+// */
|
|
|
+// @Test
|
|
|
+// public void initKusishouTaskInfo() {
|
|
|
+// Date beginDate = DateUtils.parseDate("2021-06-01", "yyyy-MM-dd");
|
|
|
+// Date endDate = DateUtils.parseDate("2021-08-04", "yyyy-MM-dd");
|
|
|
+// while (beginDate.before(endDate)) {
|
|
|
+// Date mulDate = beginDate;
|
|
|
+// List<KuaishouPullTaskInfo> result = new ArrayList<>();
|
|
|
+// List<Long> accountIds = kuaishouUnitLevelOperationRecordMapper.selectAllAccountIds(mulDate, DateUtils.addDay(mulDate, 1));
|
|
|
+// accountIds.forEach(accountId -> {
|
|
|
+// KuaishouPullTaskInfo taskInfo = new KuaishouPullTaskInfo();
|
|
|
+// taskInfo.setAccountId(accountId);
|
|
|
+// taskInfo.setTargetDate(DateUtils.formatDate(mulDate,"yyyy-MM-dd"));
|
|
|
+// result.add(taskInfo);
|
|
|
+// });
|
|
|
+// kuaishouPullTaskInfoService.saveBatch(result);
|
|
|
+// beginDate = DateUtils.addDay(beginDate, 1);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+// public void getAudienceReport() throws InterruptedException{
|
|
|
+// int page = 1;
|
|
|
+// int pageSize = 2000;
|
|
|
+//
|
|
|
+// System.out.println("");
|
|
|
+// System.out.println("");
|
|
|
+// System.out.println("");
|
|
|
+// System.out.println("");
|
|
|
+// System.out.println("拉取人群报表数据服务已开始执行!");
|
|
|
+// Scanner scan = new Scanner(System.in);
|
|
|
+// System.out.println("请输入要运行几个任务:");
|
|
|
+// int num = scan.nextInt();
|
|
|
+// System.out.println("即将执行"+num+"个任务,执行完毕会自动退出此程序。");
|
|
|
+// System.out.println("");
|
|
|
+// System.out.println("");
|
|
|
+// System.out.println("");
|
|
|
+// System.out.println("");
|
|
|
+// List<KuaishouPullTaskInfo> taskInfos = kuaishouPullTaskInfoMapper.getTaskInfos(num);
|
|
|
+// System.exit(0);
|
|
|
+// if(!Check.isNull(taskInfos)){
|
|
|
+// taskInfos.forEach(taskInfo -> taskInfo.setStatus(1));
|
|
|
+// kuaishouPullTaskInfoService.updateBatchById(taskInfos);
|
|
|
+//
|
|
|
+// for (KuaishouPullTaskInfo taskInfo : taskInfos) {
|
|
|
+// Date mulDate = DateUtils.parseDate(taskInfo.getTargetDate(), "yyyy-MM-dd");
|
|
|
+// List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountIdAndDate(taskInfo.getAccountId(), mulDate, DateUtils.addDay(mulDate, 1));
|
|
|
+// countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
|
|
|
+// planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
|
|
|
+// try {
|
|
|
+// CtopOauthToken token = tokenService.getTokenByAccountId(planIdAndUnitId.getAccountId());
|
|
|
+// if (!Check.isNull(token)) {
|
|
|
+// Date startDate = mulDate;
|
|
|
+// Date enDate = DateUtils.addDay(startDate, 30);
|
|
|
+// // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
|
|
|
+// while (startDate.before(enDate)) {
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "province", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "city", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "gender", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "clientId", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "businessInterestTags", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
|
|
|
+// System.out.println("获取完毕 -> unit:" + planIdAndUnitId.getUnitId() + ",日期:" + DateUtils.formatDate(startDate, "yyyy-MM-dd"));
|
|
|
+// startDate = DateUtils.addDay(startDate, 1);
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// System.out.println("token异常 -》 accountId:" + planIdAndUnitId.getAccountId());
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// } finally {
|
|
|
+// countDownLatch.countDown();
|
|
|
+// }
|
|
|
+// }));
|
|
|
+// countDownLatch.await();
|
|
|
+// }
|
|
|
+// System.out.println("11111111111111111111111111111111111111111111111111111111");
|
|
|
+// System.out.println("11111111111111111111111111执行完毕111111111111111111111111");
|
|
|
+// System.out.println("11111111111111111111111111111111111111111111111111111111");
|
|
|
+// System.exit(0);
|
|
|
+// }else{
|
|
|
+// List<KuaishouPullTaskLog> taskLogs = kuaishouPullTaskLogMapper.getTaskInfos(num * 1000);
|
|
|
+// if(Check.isNull(taskLogs)){
|
|
|
+// System.out.println("所有的表里的任务走完啦,请联系发布任务!!!");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// taskLogs.forEach(taskLog -> taskLog.setStatus(1));
|
|
|
+// kuaishouPullTaskLogService.updateBatchById(taskLogs);
|
|
|
+//
|
|
|
+// countDownLatch = new CountDownLatch(taskLogs.size());
|
|
|
+// taskLogs.forEach(taskLog -> executorService.submit(() -> {
|
|
|
+// try {
|
|
|
+// CtopOauthToken token = tokenService.getTokenByAccountId(taskLog.getAccountId());
|
|
|
+// if (!Check.isNull(token)) {
|
|
|
+// Date startDate = DateUtils.parseDate(taskLog.getTargetDate(),"yyyy-MM-dd");
|
|
|
+// // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "province", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "city", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "gender", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "clientId", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "ageSegment", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
|
|
|
+// kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "businessInterestTags", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
|
|
|
+// System.out.println("获取完毕 -> unit:" + taskLog.getUnitId() + ",日期:" + taskLog.getTargetDate());
|
|
|
+// } else {
|
|
|
+// System.out.println("token异常 -》 accountId:" + taskLog.getAccountId());
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// } finally {
|
|
|
+// countDownLatch.countDown();
|
|
|
+// }
|
|
|
+// }));
|
|
|
+// countDownLatch.await();
|
|
|
+//
|
|
|
+// System.out.println("11111111111111111111111111111111111111111111111111111111");
|
|
|
+// System.out.println("11111111111111111111111111执行完毕111111111111111111111111");
|
|
|
+// System.out.println("11111111111111111111111111111111111111111111111111111111");
|
|
|
+// System.exit(0);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
}
|