yumeng 5 years ago
parent
commit
3536edf663

+ 4 - 128
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,8 +1,10 @@
 package org.jeecg;
 
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportTaskService;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
@@ -27,7 +29,8 @@ public class SampleTest {
         try {
 
 
-            reportTaskService.getTaskList();
+          //  reportTaskService.createTask(1022694L,"c2defedd56511f4a768ce8e34e0232ff");
+           reportTaskService.getTaskList();
 
 
 
@@ -95,136 +98,9 @@ public class SampleTest {
         }
     }
 
-    @Autowired
-    private ICtopOauthTokenService tokenService;
 
-    @Test
-    public void testBakToken() {
-        Date getDate = DateUtils.addDay(new Date(), -1);
-        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("project_id", 215);
-        List<UserAllocation> allocations = userAllocationService.list(queryWrapper);
-        if (null != allocations && allocations.size() > 0) {
-            for (UserAllocation allocation : allocations) {
-                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
-                reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-            }
-        }
-        formatZybData(215, getDate);
-    }
 
-    @Autowired
-    private IUserAllocationService userAllocationService;
-
-    private void formatZybData(Integer projectId, Date getDate) {
-        //清洗关于作业帮数据
-        //1:查询作业帮相关的用户数据
-        QueryWrapper<UserAllocation> wrapper = new QueryWrapper<>();
-        wrapper.eq("project_id", projectId);
-        List<UserAllocation> allocations = userAllocationService.list(wrapper);
-        if (null != allocations && allocations.size() > 0) {
-            allocations.forEach(allocation -> {
-                //根据accountId和时间,查询相关的日报表信息
-                QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
-                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                String dateString = dateFormat.format(getDate) + " 00:00:00";
-                queryWrapper.eq("advertiser_id", allocation.getAccountId())
-                        .eq("stat_datetime", dateString)
-                ;
-                List<BytedancePlanDailyReport> bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
-                if (null != bytedancePlanDailyReports && bytedancePlanDailyReports.size() > 0) {
-                    bytedancePlanDailyReports.forEach(report -> {
-                        String adName = report.getAdName();
-                        String[] tags = adName.split("-");
-                        report.setAdsense(tags[1]);
-                        report.setPlanCode(tags[2]);
-                        String materialName = tags[3];
-                        report.setMaterialName(materialName);
-                        if (materialName.contains("其他")) {
-                            report.setMaterialType("其他");
-                        } else if (materialName.contains("图片轮播")) {
-                            report.setMaterialType("图片轮播");
-                        } else if (materialName.contains("大字报")) {
-                            report.setMaterialType("大字报");
-                        } else if (materialName.contains("文字动画")) {
-                            report.setMaterialType("文字动画");
-                        } else if (materialName.contains("采访形式")) {
-                            report.setMaterialType("采访形式");
-                        } else if (materialName.contains("剧情")) {
-                            report.setMaterialType("剧情");
-                        } else if (materialName.contains("口播")) {
-                            report.setMaterialType("口播");
-                        } else {
-                            report.setMaterialType("其他");
-                        }
-                        planDailyReportService.updateById(report);
-                    });
-                }
-            });
-        }
-    }
-
-    @Autowired
-    private IBytedancePlanDailyReportService planDailyReportService;
-    @Autowired
-    private IReportService reportService;
-
-    /**
-     * CSV文件生成方法
-     *
-     * @param head       文件头
-     * @param dataList   数据列表
-     * @param outPutPath 文件输出路径
-     * @param filename   文件名
-     * @return
-     */
-    public static File createCSVFile(String head, List<CtopOauthToken> dataList, String outPutPath, String filename) {
-
-        File csvFile = null;
-        BufferedWriter csvWtriter = null;
-        try {
-            csvFile = new File(outPutPath + File.separator + filename + ".csv");
-            File parent = csvFile.getParentFile();
-            if (parent != null && !parent.exists()) {
-                parent.mkdirs();
-            }
-            csvFile.createNewFile();
 
-            // GB2312使正确读取分隔符","
-            csvWtriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
-                    csvFile), "GB2312"), 1024);
-            // 写入文件头部
-            writeRow(head, csvWtriter);
-
-            // 写入文件内容
-            for (CtopOauthToken row : dataList) {
-                writeRow(row.toString(), csvWtriter);
-            }
-            csvWtriter.flush();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                csvWtriter.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return csvFile;
-    }
-
-    }
-
-    public static byte[] readInputStream(InputStream inputStream) throws IOException {
-        byte[] buffer = new byte[1024];
-        int len = 0;
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        while ((len = inputStream.read(buffer)) != -1) {
-            bos.write(buffer, 0, len);
-        }
-        bos.close();
-        return bos.toByteArray();
-    }
 
 
 }

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportTaskServiceImpl.java

@@ -10,6 +10,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouReportTask;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouReportTaskMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportTaskService;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
 import cn.com.ctop.kuaishou.modules.utils.DownloadUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -48,6 +49,9 @@ public class KuaiShouReportTaskServiceImpl extends ServiceImpl<KuaiShouReportTas
     @Autowired
     private KuaishouReportDailyAccountMapper reportDailyAccountMapper;
 
+    @Autowired
+    private KuaishouReportDailyCampaignMapper reportDailyCampaignMapper;
+
     @Override
     public void createTask(Long accountId, String token) {
         if (Check.isNull(accountId) || Check.isNull(token)) {
@@ -169,6 +173,9 @@ public class KuaiShouReportTaskServiceImpl extends ServiceImpl<KuaiShouReportTas
             if (!Check.isNull(localPath)) {
                 if (task.getViewType() == 1) {
                     reportDailyAccountMapper.loadAccountDailyReport(task.getAccountId(), localPath);
+                }else if(task.getViewType() == 2){
+                    reportDailyCampaignMapper.loadCampaignDailyReport(task.getAccountId(), localPath);
+
                 }
 
             }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyCampaignMapper.java

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 public interface KuaishouReportDailyCampaignMapper extends BaseMapper<KuaishouReportDailyCampaign> {
+    void loadCampaignDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
 }

+ 67 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyCampaignMapper.xml

@@ -2,4 +2,71 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper">
 
+
+    <insert id="loadCampaignDailyReport">
+		LOAD DATA local INFILE  #{localPath}
+		INTO TABLE ctop_kuaishou_report_daily_campaign_new CHARACTER SET utf8
+		FIELDS TERMINATED BY ',' enclosed by '"' LINES TERMINATED BY '\n'
+		IGNORE 1 LINES
+		(campaign_id,
+		campaign_name,
+		status,
+		@ad_scene,
+        charge,
+        photo_show,
+        aclick,
+        bclick,
+        photo_share,
+        photo_comment,
+        photo_like,
+        follow,
+        cancel_follow,
+        report,
+        block,
+        negative,
+        download_started,
+        download_completed,
+        activation,
+        submit,
+        stat_date,
+        @stat_hour,
+        photo_click,
+        photo_click_ratio,
+        action_ratio,
+        impression_1k_cost,
+        photo_click_cost,
+        action_cost,
+        event_pay_first_day,
+        event_pay_purchase_amount_first_day,
+        event_pay_first_day_roi,
+        event_pay,
+        event_pay_purchase_amount,
+        event_pay_roi,
+        event_register,
+        event_register_cost,
+        event_register_ratio,
+        event_jin_jian_app,
+        event_jin_jian_app_cost,
+        event_credit_grant_app,
+        event_credit_grant_app_cost,
+        event_credit_grant_app_ratio,
+        event_order_paid,
+        event_order_paid_purchase_amount,
+        event_order_paid_cost,
+        form_count,
+        form_cost,
+        form_action_ratio,
+        event_jin_jian_landing_page,
+        event_jin_jian_landing_page_cost,
+        event_credit_grant_landing_page,
+        event_credit_grant_landing_page_cost,
+        event_credit_grant_landing_ratio,
+        event_next_day_stay_cost,
+        event_next_day_stay_ratio,
+        event_next_day_stay,
+        play_3s_ratio
+        )
+          set account_id = #{accountId}
+    </insert>
+
 </mapper>