Forráskód Böngészése

增加代理商报表

xuzuoyun 5 éve
szülő
commit
d34703a0d8

+ 1 - 1
jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties

@@ -1,7 +1,7 @@
 #mysql 
 diver_name=com.mysql.jdbc.Driver
 url=jdbc:mysql://39.106.184.70:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
-username=hcst
+username=root
 password=hcst2019
 database_name=jeecg-boot
 #oracle

+ 33 - 2
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils2.java

@@ -30,8 +30,7 @@ import org.apache.http.util.EntityUtils;
 import org.eclipse.jetty.util.UrlEncoded;
 
 import javax.net.ssl.SSLContext;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
+import java.io.*;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
@@ -106,6 +105,38 @@ public class HttpUtils2 {
         return strReturn;
     }
 
+    public static void getFile(String url,Map<String,String> headerMap,String filePath){
+        HttpClient httpClient = createSSLClientDefault();
+        HttpResponse response = null;
+        HttpGet httpGet = new HttpGet(url);
+        String result = null;
+        try {
+            httpGet.setHeader("User-Agent", USER_AGENT);
+            response = httpClient.execute(httpGet);
+            HttpEntity entity = response.getEntity();
+            InputStream in = entity.getContent();
+            File file = new File(filePath);
+            try {
+                FileOutputStream fout = new FileOutputStream(file);
+                int l = -1;
+                byte[] tmp = new byte[1024];
+                while ((l = in.read(tmp)) != -1) {
+                    fout.write(tmp, 0, l);
+                }
+                fout.flush();
+                fout.close();
+            } catch (Exception e){
+                e.printStackTrace();
+            }
+            finally{
+                // 关闭低层流。
+                in.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
     public static String httpPostRequest(String url, Map<String, Object> param, Map<String, String> headers) {
         HttpClient httpClient = createSSLClientDefault();
         String strReturn = "";

+ 2 - 2
module-common/src/main/java/cn/com/ctop/common/module/utils/MpsUtils.java

@@ -202,8 +202,8 @@ public class MpsUtils {
         JSONObject output = new JSONObject();
         output.put("OutputObject", outputOssObject);
         JSONObject video = new JSONObject();
-        video.put("Width", "1280");
-        video.put("Height", "720");
+        video.put("Width", "720");
+        video.put("Height", "1280");
         output.put("Video", video.toJSONString());
         output.put("MergeList", mergeList.toJSONString());
         // Outputs

+ 223 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouReportDailyAgentController.java

@@ -0,0 +1,223 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 代理商报表
+ * @author jeecg-boot
+ * @date   2019-12-13
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="代理商报表")
+@RestController
+@RequestMapping("/report/kuaishouReportDailyAgent")
+public class KuaishouReportDailyAgentController {
+    @Autowired
+    private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
+
+    /**
+     * 分页列表查询
+     * @param kuaishouReportDailyAgent
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "代理商报表-分页列表查询")
+    @ApiOperation(value="代理商报表-分页列表查询", notes="代理商报表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouReportDailyAgent>> queryPageList(KuaishouReportDailyAgent kuaishouReportDailyAgent,
+                                                                 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+                                                                 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+                                                                 HttpServletRequest req) {
+        Result<IPage<KuaishouReportDailyAgent>> result = new Result<IPage<KuaishouReportDailyAgent>>();
+        QueryWrapper<KuaishouReportDailyAgent> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouReportDailyAgent, req.getParameterMap());
+        Page<KuaishouReportDailyAgent> page = new Page<KuaishouReportDailyAgent>(pageNo, pageSize);
+        IPage<KuaishouReportDailyAgent> pageList = kuaishouReportDailyAgentService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     *   添加
+     * @param kuaishouReportDailyAgent
+     * @return
+     */
+    @AutoLog(value = "代理商报表-添加")
+    @ApiOperation(value="代理商报表-添加", notes="代理商报表-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouReportDailyAgent> add(@RequestBody KuaishouReportDailyAgent kuaishouReportDailyAgent) {
+        Result<KuaishouReportDailyAgent> result = new Result<KuaishouReportDailyAgent>();
+        try {
+            kuaishouReportDailyAgentService.save(kuaishouReportDailyAgent);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(),e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+
+    /**
+     *   通过id删除
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "代理商报表-通过id删除")
+    @ApiOperation(value="代理商报表-通过id删除", notes="代理商报表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+        try {
+            kuaishouReportDailyAgentService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败",e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     *  批量删除
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "代理商报表-批量删除")
+    @ApiOperation(value="代理商报表-批量删除", notes="代理商报表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouReportDailyAgent> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+        Result<KuaishouReportDailyAgent> result = new Result<KuaishouReportDailyAgent>();
+        if(ids==null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        }else {
+            this.kuaishouReportDailyAgentService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "代理商报表-通过id查询")
+    @ApiOperation(value="代理商报表-通过id查询", notes="代理商报表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouReportDailyAgent> queryById(@RequestParam(name="id",required=true) String id) {
+        Result<KuaishouReportDailyAgent> result = new Result<KuaishouReportDailyAgent>();
+        KuaishouReportDailyAgent kuaishouReportDailyAgent = kuaishouReportDailyAgentService.getById(id);
+        if(kuaishouReportDailyAgent==null) {
+            result.error500("未找到对应实体");
+        }else {
+            result.setResult(kuaishouReportDailyAgent);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouReportDailyAgent> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouReportDailyAgent kuaishouReportDailyAgent = JSON.parseObject(deString, KuaishouReportDailyAgent.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouReportDailyAgent, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouReportDailyAgent> pageList = kuaishouReportDailyAgentService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "代理商报表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouReportDailyAgent.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("代理商报表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouReportDailyAgent> listKuaishouReportDailyAgents = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouReportDailyAgent.class, params);
+                kuaishouReportDailyAgentService.saveBatch(listKuaishouReportDailyAgents);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouReportDailyAgents.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(),e);
+                return Result.error("文件导入失败:"+e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 117 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgent.java

@@ -0,0 +1,117 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 代理商报表
+ * @author jeecg-boot
+ * @date   2019-12-13
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_report_daily_agent")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_report_daily_agent对象", description="代理商报表")
+public class KuaishouReportDailyAgent {
+
+	/**日期*/
+	@Excel(name = "日期", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern="yyyy-MM-dd")
+	@ApiModelProperty(value = "日期")
+	private java.util.Date date;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+	@ApiModelProperty(value = "账户ID")
+	private java.lang.Integer accountId;
+	/**快手ID*/
+	@Excel(name = "快手ID", width = 15)
+	@ApiModelProperty(value = "快手ID")
+	private java.lang.Integer kid;
+	/**广告主名称*/
+	@Excel(name = "广告主名称", width = 15)
+	@ApiModelProperty(value = "广告主名称")
+	private java.lang.String advertiserName;
+	/**广告主创建时间*/
+	@Excel(name = "广告主创建时间", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern="yyyy-MM-dd")
+	@ApiModelProperty(value = "广告主创建时间")
+	private java.util.Date advertiserCreateTime;
+	/**有消费计划数*/
+	@Excel(name = "有消费计划数", width = 15)
+	@ApiModelProperty(value = "有消费计划数")
+	private java.lang.Integer costCampaignCount;
+	/**总余额*/
+	@Excel(name = "总余额", width = 15)
+	@ApiModelProperty(value = "总余额")
+	private java.math.BigDecimal balance;
+	/**总消耗*/
+	@Excel(name = "总消耗", width = 15)
+	@ApiModelProperty(value = "总消耗")
+	private java.math.BigDecimal cost;
+	/**现金消耗*/
+	@Excel(name = "现金消耗", width = 15)
+	@ApiModelProperty(value = "现金消耗")
+	private java.math.BigDecimal xianjinCost;
+	/**后返消耗*/
+	@Excel(name = "后返消耗", width = 15)
+	@ApiModelProperty(value = "后返消耗")
+	private java.math.BigDecimal fandianCost;
+	/**框返消耗*/
+	@Excel(name = "框返消耗", width = 15)
+	@ApiModelProperty(value = "框返消耗")
+	private java.math.BigDecimal kuangfanCost;
+	/**激励账户消耗*/
+	@Excel(name = "激励账户消耗", width = 15)
+	@ApiModelProperty(value = "激励账户消耗")
+	private java.math.BigDecimal jiliCost;
+	/**信用账户消耗*/
+	@Excel(name = "信用账户消耗", width = 15)
+	@ApiModelProperty(value = "信用账户消耗")
+	private java.math.BigDecimal xinyongCost;
+	/**封面曝光数*/
+	@Excel(name = "封面曝光数", width = 15)
+	@ApiModelProperty(value = "封面曝光数")
+	private java.lang.Integer fengmianShowCount;
+	/**封面点击数*/
+	@Excel(name = "封面点击数", width = 15)
+	@ApiModelProperty(value = "封面点击数")
+	private java.lang.Integer fengmianClickCount;
+	/**素材曝光数*/
+	@Excel(name = "素材曝光数", width = 15)
+	@ApiModelProperty(value = "素材曝光数")
+	private java.lang.Integer sucaiShowCount;
+	/**行为数*/
+	@Excel(name = "行为数", width = 15)
+	@ApiModelProperty(value = "行为数")
+	private java.lang.Integer convertCount;
+	/**封面点击率*/
+	@Excel(name = "封面点击率", width = 15)
+	@ApiModelProperty(value = "封面点击率")
+	private java.math.BigDecimal fengmianClickRate;
+	/**转化点击率*/
+	@Excel(name = "转化点击率", width = 15)
+	@ApiModelProperty(value = "转化点击率")
+	private java.math.BigDecimal convertClickRate;
+	/**创建时间*/
+	@ApiModelProperty(value = "创建时间")
+	private java.util.Date createTime;
+	/**修改时间*/
+	@ApiModelProperty(value = "修改时间")
+	private java.util.Date updateTime;
+}

+ 155 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/job/KuaishouReportAgentJob.java

@@ -0,0 +1,155 @@
+package cn.com.ctop.kuaishou.modules.report.job;
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.client.CookieStore;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.cookie.BasicClientCookie;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Cookie;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class KuaishouReportAgentJob implements Job {
+    @Value("${jeecg.path.chrome-driver}")
+    private String chromeDriver;
+    @Autowired
+    private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
+    public static void main(String[] args){
+
+    }
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        System.getProperties().setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
+        String url = "https://agent.e.kuaishou.com";
+        ChromeOptions chromeOptions = new ChromeOptions();
+        chromeOptions.addArguments("--headless");
+        chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-gpu");
+//        chromeOptions.addArguments("--no-sandbox");
+        chromeOptions.addArguments("--window-size=1920,1080");
+        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
+        chromeOptions.setAcceptInsecureCerts(true);
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
+        try {
+            Thread.sleep(3000L);
+            HttpUtils2.cookieStore = new BasicCookieStore();
+            webDriver.manage().deleteAllCookies();
+            //获取登录页面
+            webDriver.get(url);
+            Thread.sleep(3000L);
+            WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
+            accountElement.sendKeys("17718376864");
+            Thread.sleep(3000L);
+            WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
+            passwordElement.sendKeys("hcstbaoliang567");
+            WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
+            Thread.sleep(3000L);
+            //点击登录
+            loginElement.click();
+            Thread.sleep(3000L);
+            Map<String,String> headerMap = new HashMap<String,String>();
+            headerMap.put("Accept","application/json");
+            headerMap.put("Accept-Encoding","gzip, deflate, br");
+            headerMap.put("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
+            headerMap.put("Connection","keep-alive");
+            headerMap.put("Host","agent.e.kuaishou.com");
+            headerMap.put("Referer","https://agent.e.kuaishou.com/");
+            headerMap.put("Content-Type","application/json;charset=utf-8");
+            headerMap.put("User-Agent",HttpUtils2.USER_AGENT);
+//            headerMap.put("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
+//            headerMap.put("Accept-Encoding","gzip, deflate, br");
+//            headerMap.put("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
+//            headerMap.put("Connection","keep-alive");
+//            headerMap.put("Host","agent.e.kuaishou.com");
+//            headerMap.put("Referer","https://agent.e.kuaishou.com/");
+//            headerMap.put("Upgrade-Insecure-Requests","1");
+            Set<Cookie> cookies = webDriver.manage().getCookies();
+            Iterator iterator = cookies.iterator();
+            CookieStore cookieStore = new BasicCookieStore();
+            while (iterator.hasNext()) {
+                String cookieStr = iterator.next().toString();
+                String[] cookieArray = cookieStr.split(";");
+                Map<String, String> cookieMap = new HashMap<String, String>();
+                for (String cookie : cookieArray) {
+                    String[] kv = cookie.split("=");
+                    if (kv.length > 1) {
+                        cookieMap.put(kv[0].trim(), kv[1].trim());
+                    }
+                }
+                BasicClientCookie clientCookie = new BasicClientCookie(cookieArray[0].split("=")[0],
+                        cookieArray[0].split("=")[1]);
+                clientCookie.setDomain("agent.e.kuaishou.com");
+                clientCookie.setPath(cookieMap.get("path"));
+                HttpUtils2.cookieStore.addCookie(clientCookie);
+            }
+            String listUrl = "https://agent.e.kuaishou.com/rest/dsp/agent/account/data/list";
+            String postData = "{\"agentId\":403756224,\"date\":\"2019-12-13\",\"sortKey\":\"totalCharge\",\"isAscending\":false,\"pageInfo\":{\"totalCount\":1616,\"currentPage\":1,\"pageSize\":999999}}";
+            String result = HttpUtils2.httpPostRequestTest(listUrl,postData,headerMap);
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode resultNode = mapper.readTree(result);
+            Integer code = resultNode.get("result").intValue();
+            if(code == 1){
+                Iterator<JsonNode> iterator1 = resultNode.get("data").elements();
+                int i = 0;
+                List<KuaishouReportDailyAgent> reportList = new ArrayList<>();
+                while (iterator1.hasNext()){
+                    JsonNode dataNode = iterator1.next();
+                    if(i == 0){
+
+                    }else {
+                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+                        KuaishouReportDailyAgent kuaishouReportDailyAgent = new KuaishouReportDailyAgent();
+                        kuaishouReportDailyAgent.setAccountId(dataNode.get("accountId").asInt());
+                        kuaishouReportDailyAgent.setAdvertiserCreateTime(sdf.parse(dataNode.get("createTime").asText()));
+                        kuaishouReportDailyAgent.setAdvertiserName(dataNode.get("accountName").asText());
+                        kuaishouReportDailyAgent.setBalance(dataNode.get("totalBalanceDouble").decimalValue());
+                        kuaishouReportDailyAgent.setConvertClickRate(dataNode.get("actionbarClickRatio").decimalValue());
+                        kuaishouReportDailyAgent.setConvertCount(dataNode.get("actionbarClick").asInt());
+                        kuaishouReportDailyAgent.setCost(dataNode.get("totalChargedInYuan").decimalValue());
+                        kuaishouReportDailyAgent.setCostCampaignCount(dataNode.get("chargedCampaignCount").asInt());
+                        kuaishouReportDailyAgent.setDate(sdf.parse(dataNode.get("dateTime").asText()));
+                        kuaishouReportDailyAgent.setFengmianClickCount(dataNode.get("adPhotoClick").asInt());
+                        kuaishouReportDailyAgent.setFengmianClickRate(dataNode.get("clickRatio").decimalValue());
+                        kuaishouReportDailyAgent.setFengmianShowCount(dataNode.get("impression").asInt());
+                        kuaishouReportDailyAgent.setFandianCost(dataNode.get("rebateRealChargedInYuan").decimalValue());
+                        kuaishouReportDailyAgent.setJiliCost(dataNode.get("directRebateRealChargedInYuan").decimalValue());
+                        kuaishouReportDailyAgent.setKid(dataNode.get("userId").asInt());
+                        kuaishouReportDailyAgent.setKuangfanCost(dataNode.get("contractRebateRealChargedInYuan").decimalValue());
+                        kuaishouReportDailyAgent.setSucaiShowCount(dataNode.get("click").asInt());
+                        kuaishouReportDailyAgent.setXianjinCost(dataNode.get("realChargedInYuan").decimalValue());
+                        kuaishouReportDailyAgent.setXinyongCost(dataNode.get("creditRealChargedInYuan").decimalValue());
+                        reportList.add(kuaishouReportDailyAgent);
+                    }
+                    i++;
+                }
+                if(reportList != null && reportList.size() > 0){
+                    kuaishouReportDailyAgentService.replaceBatch(reportList);
+                }
+            }
+            System.out.println(result);
+//            String downloadUrl = "https://agent.e.kuaishou.com/rest/dsp/agent/account/data/download?agentId=403756224&startDate=2019-11-12&endDate=2019-12-12";
+//            HttpUtils2.httpGet(downloadUrl,new HashMap<>(),headerMap);
+//            String filePath = "D:/csv/"+ UUID.randomUUID()+".csv";
+//            HttpUtils2.getFile(downloadUrl,headerMap,filePath);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            webDriver.manage().deleteAllCookies();
+            webDriver.close();
+        }
+    }
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 代理商日报
+ * @author: jeecg-boot
+ * @date:   2019-12-13
+ * @cersion: V1.0
+ */
+public interface KuaishouReportDailyAgentMapper extends BaseMapper<KuaishouReportDailyAgent> {
+    public void replaceBatch(List<KuaishouReportDailyAgent> list);
+}

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

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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.KuaishouReportDailyAgentMapper">
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_report_daily_agent(
+        `date`,
+        `account_id`,
+        `kid`,
+        `advertiser_name`,
+        `advertiser_create_time`,
+        `cost_campaign_count`,
+        `balance`,
+        `cost`,
+        `xianjin_cost`,
+        `fandian_cost`,
+        `kuangfan_cost`,
+        `jili_cost`,
+        `xinyong_cost`,
+        `fengmian_show_count`,
+        `fengmian_click_count`,
+        `sucai_show_count`,
+        `convert_count`,
+        `fengmian_click_rate`,
+        `convert_lick_rate`
+        )
+        values
+        <foreach collection="list" item="agent" separator=",">
+            (#{agent.date},
+            #{agent.accountId},
+            #{agent.kid},
+            #{agent.advertiserName},
+            #{agent.advertiserCreateTime},
+            #{agent.costCampaignCount},
+            #{agent.balance},
+            #{agent.cost},
+            #{agent.xianjinCost},
+            #{agent.fandianCost},
+            #{agent.kuangfanCost},
+            #{agent.jiliCost},
+            #{agent.xinyongCost},
+            #{agent.fengmianShowCount},
+            #{agent.fengmianClickCount},
+            #{agent.sucaiShowCount},
+            #{agent.convertCount},
+            #{agent.fengmianClickRate},
+            #{agent.convertClickRate})
+        </foreach>
+    </insert>
+</mapper>

+ 16 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAgentService.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 代理商日报
+ * @author jeecg-boot
+ * @date   2019-12-13
+ * @version V1.0
+ */
+public interface IKuaishouReportDailyAgentService extends IService<KuaishouReportDailyAgent> {
+    public void replaceBatch(List<KuaishouReportDailyAgent> list);
+}

+ 27 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java

@@ -0,0 +1,27 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAgentMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.util.List;
+
+/**
+ * 代理商日报
+ * @author jeecg-boot
+ * @date   2019-12-13
+ * @version V1.0
+ */
+@Service
+public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouReportDailyAgentMapper, KuaishouReportDailyAgent> implements IKuaishouReportDailyAgentService {
+    @Autowired
+    private KuaishouReportDailyAgentMapper kuaishouReportDailyAgentMapper;
+    @Override
+    public void replaceBatch(List<KuaishouReportDailyAgent> list) {
+        kuaishouReportDailyAgentMapper.replaceBatch(list);
+    }
+}