Browse Source

整理代码+添加动态词包信息接口数据获取

syh 5 years ago
parent
commit
04fead660c
15 changed files with 636 additions and 334 deletions
  1. 2 1
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/ResultMapUtils.java
  2. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java
  4. 269 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceInterestCategoryController.java
  5. 73 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/BytedanceInterestCategory.java
  6. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/BytedanceInterestCategoryMapper.java
  7. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/BytedanceInterestCategoryMapper.xml
  8. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IByteDanceAdvertiserDataService.java
  9. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBytedanceInterestCategoryService.java
  10. 146 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  11. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ByteDanceCreativeServiceImpl.java
  12. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BytedanceAdvertisePlanTemplateServiceImpl.java
  13. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BytedanceInterestCategoryServiceImpl.java
  14. 17 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/FileInfoServiceImpl.java
  15. 40 326
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

+ 2 - 1
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/ResultMapUtils.java

@@ -1,5 +1,7 @@
 package org.jeecg.common.util;
 package org.jeecg.common.util;
 
 
+import com.alibaba.fastjson.JSONObject;
+
 import java.util.Map;
 import java.util.Map;
 
 
 public class ResultMapUtils {
 public class ResultMapUtils {
@@ -12,5 +14,4 @@ public class ResultMapUtils {
         map.put(MAP_MESSAGE, StatusCode.getDesc(statusCode));
         map.put(MAP_MESSAGE, StatusCode.getDesc(statusCode));
         map.put(MAP_SUCCESS, StatusCode.getFlag(statusCode));
         map.put(MAP_SUCCESS, StatusCode.getFlag(statusCode));
     }
     }
-
 }
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -71,6 +71,8 @@ public class ShiroConfig {
         //pdf预览
         //pdf预览
         filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");
         filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");
 		filterChainDefinitionMap.put("/ctop/bytedanceAreaInfo/**", "anon");
 		filterChainDefinitionMap.put("/ctop/bytedanceAreaInfo/**", "anon");
+		filterChainDefinitionMap.put("/ctop/bytedanceInterestCategory/**", "anon");
+		filterChainDefinitionMap.put("/template/creative/words/get", "anon");
 
 
         //pdf预览需要文件
         //pdf预览需要文件
         filterChainDefinitionMap.put("/generic/**", "anon");
         filterChainDefinitionMap.put("/generic/**", "anon");

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java

@@ -8,6 +8,7 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ctop.entity.ByteDanceCustomAudience;
 import org.jeecg.modules.ctop.entity.ByteDanceCustomAudience;
+import org.jeecg.modules.ctop.entity.ByteDanceUserOrientationTemplate;
 import org.jeecg.modules.ctop.service.IByteDanceAdvertiserDataService;
 import org.jeecg.modules.ctop.service.IByteDanceAdvertiserDataService;
 import org.jeecg.modules.ctop.service.IByteDanceCustomAudienceService;
 import org.jeecg.modules.ctop.service.IByteDanceCustomAudienceService;
 import org.jeecg.modules.ctop.service.IFileInfoService;
 import org.jeecg.modules.ctop.service.IFileInfoService;
@@ -67,6 +68,18 @@ public class ByteDanceAdvertiserPostController {
     }
     }
 
 
     /**
     /**
+     * 3:修改广告计划信息
+     *
+     * @param accountId 本平台广告主id
+     */
+    @RequestMapping("/advertiser/ad/update")
+    public Map<String, Object> advertiserAdUpdate(String accountId, Long adId, String optStatus) {
+        ByteDanceUserOrientationTemplate template = new ByteDanceUserOrientationTemplate();
+        return advertiserDataService.advertiserAdUpdate(accountId, adId, template);
+    }
+
+
+    /**
      * 4:修改广告计划信息状态
      * 4:修改广告计划信息状态
      * @param accountId 本平台广告主id
      * @param accountId 本平台广告主id
      */
      */

+ 269 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceInterestCategoryController.java

@@ -0,0 +1,269 @@
+package org.jeecg.modules.ctop.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 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 org.jeecg.modules.ctop.entity.BytedanceInterestCategory;
+import org.jeecg.modules.ctop.service.IBytedanceInterestCategoryService;
+
+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
+ * @version V1.0
+ * @date 2019-09-18
+ */
+@Slf4j
+@Api(tags = "兴趣分类信息")
+@RestController
+@RequestMapping("/ctop/bytedanceInterestCategory")
+public class BytedanceInterestCategoryController {
+    @Autowired
+    private IBytedanceInterestCategoryService bytedanceInterestCategoryService;
+
+    @GetMapping(value = "/listbycode")
+    public Result<IPage<BytedanceInterestCategory>> queryPageListByCode(@RequestParam(name = "parentCode", defaultValue = "0") String code,
+                                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                        HttpServletRequest req) {
+        Result<IPage<BytedanceInterestCategory>> result = new Result<>();
+        BytedanceInterestCategory category = new BytedanceInterestCategory();
+        QueryWrapper<BytedanceInterestCategory> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
+        queryWrapper.eq("parent_code", code);
+        Page<BytedanceInterestCategory> page = new Page<>(pageNo, pageSize);
+        IPage<BytedanceInterestCategory> pageList = bytedanceInterestCategoryService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 分页列表查询
+     *
+     * @param bytedanceInterestCategory
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-分页列表查询")
+    @ApiOperation(value = "兴趣分类信息-分页列表查询", notes = "兴趣分类信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<BytedanceInterestCategory>> queryPageList(BytedanceInterestCategory bytedanceInterestCategory,
+                                                                  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                  HttpServletRequest req) {
+        Result<IPage<BytedanceInterestCategory>> result = new Result<IPage<BytedanceInterestCategory>>();
+        QueryWrapper<BytedanceInterestCategory> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceInterestCategory, req.getParameterMap());
+        Page<BytedanceInterestCategory> page = new Page<BytedanceInterestCategory>(pageNo, pageSize);
+        IPage<BytedanceInterestCategory> pageList = bytedanceInterestCategoryService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param bytedanceInterestCategory
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-添加")
+    @ApiOperation(value = "兴趣分类信息-添加", notes = "兴趣分类信息-添加")
+    @PostMapping(value = "/add")
+    public Result<BytedanceInterestCategory> add(@RequestBody BytedanceInterestCategory bytedanceInterestCategory) {
+        Result<BytedanceInterestCategory> result = new Result<BytedanceInterestCategory>();
+        try {
+            bytedanceInterestCategoryService.save(bytedanceInterestCategory);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param bytedanceInterestCategory
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-编辑")
+    @ApiOperation(value = "兴趣分类信息-编辑", notes = "兴趣分类信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<BytedanceInterestCategory> edit(@RequestBody BytedanceInterestCategory bytedanceInterestCategory) {
+        Result<BytedanceInterestCategory> result = new Result<BytedanceInterestCategory>();
+        BytedanceInterestCategory bytedanceInterestCategoryEntity = bytedanceInterestCategoryService.getById(bytedanceInterestCategory.getId());
+        if (bytedanceInterestCategoryEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = bytedanceInterestCategoryService.updateById(bytedanceInterestCategory);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        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 {
+            bytedanceInterestCategoryService.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<BytedanceInterestCategory> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<BytedanceInterestCategory> result = new Result<BytedanceInterestCategory>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.bytedanceInterestCategoryService.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<BytedanceInterestCategory> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<BytedanceInterestCategory> result = new Result<BytedanceInterestCategory>();
+        BytedanceInterestCategory bytedanceInterestCategory = bytedanceInterestCategoryService.getById(id);
+        if (bytedanceInterestCategory == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(bytedanceInterestCategory);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<BytedanceInterestCategory> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                BytedanceInterestCategory bytedanceInterestCategory = JSON.parseObject(deString, BytedanceInterestCategory.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(bytedanceInterestCategory, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<BytedanceInterestCategory> pageList = bytedanceInterestCategoryService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "兴趣分类信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, BytedanceInterestCategory.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<BytedanceInterestCategory> listBytedanceInterestCategorys = ExcelImportUtil.importExcel(file.getInputStream(), BytedanceInterestCategory.class, params);
+                bytedanceInterestCategoryService.saveBatch(listBytedanceInterestCategorys);
+                return Result.ok("文件导入成功!数据行数:" + listBytedanceInterestCategorys.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("文件导入失败!");
+    }
+
+}

+ 73 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/BytedanceInterestCategory.java

@@ -0,0 +1,73 @@
+package org.jeecg.modules.ctop.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
+ * @version V1.0
+ * @date 2019-09-18
+ */
+@Data
+@TableName("ctop_bytedance_interest_category")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_bytedance_interest_category对象", description = "兴趣分类信息")
+public class BytedanceInterestCategory {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 名称
+     */
+    @Excel(name = "名称", width = 15)
+    @ApiModelProperty(value = "名称")
+    private String name;
+    /**
+     * code
+     */
+    @Excel(name = "code", width = 15)
+    @ApiModelProperty(value = "code")
+    private String code;
+    /**
+     * parentCode
+     */
+    @Excel(name = "parentCode", width = 15)
+    @ApiModelProperty(value = "parentCode")
+    private String parentCode;
+    /**
+     * level
+     */
+    @Excel(name = "level", width = 15)
+    @ApiModelProperty(value = "level")
+    private Integer level;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

+ 18 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/BytedanceInterestCategoryMapper.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.ctop.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.ctop.entity.BytedanceInterestCategory;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 兴趣分类信息
+ *
+ * @author: jeecg-boot
+ * @date: 2019-09-18
+ * @cersion: V1.0
+ */
+public interface BytedanceInterestCategoryMapper extends BaseMapper<BytedanceInterestCategory> {
+
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/BytedanceInterestCategoryMapper.xml

@@ -0,0 +1,5 @@
+<?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="org.jeecg.modules.ctop.mapper.BytedanceInterestCategoryMapper">
+
+</mapper>

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IByteDanceAdvertiserDataService.java

@@ -1,5 +1,8 @@
 package org.jeecg.modules.ctop.service;
 package org.jeecg.modules.ctop.service;
 
 
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.modules.ctop.entity.ByteDanceUserOrientationTemplate;
+
 import java.util.Map;
 import java.util.Map;
 
 
 public interface IByteDanceAdvertiserDataService {
 public interface IByteDanceAdvertiserDataService {
@@ -28,4 +31,8 @@ public interface IByteDanceAdvertiserDataService {
     Map<String, Object> advertiserCreativeUpdateStatus(String accountId, String ids, String optStatus);
     Map<String, Object> advertiserCreativeUpdateStatus(String accountId, String ids, String optStatus);
 
 
     Map<String, Object> advertiserCustomAudienceSelect(String accountId);
     Map<String, Object> advertiserCustomAudienceSelect(String accountId);
+
+    Map<String, Object> advertiserAdUpdate(String accountId, Long adId, ByteDanceUserOrientationTemplate template);
+
+    JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template);
 }
 }

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBytedanceInterestCategoryService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.service;
+
+import org.jeecg.modules.ctop.entity.BytedanceInterestCategory;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 兴趣分类信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-09-18
+ */
+public interface IBytedanceInterestCategoryService extends IService<BytedanceInterestCategory> {
+
+}

+ 146 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -4,14 +4,26 @@ import cn.com.ctop.common.utils.HttpUtils;
 import cn.com.ctop.common.utils.PropertiesUtils;
 import cn.com.ctop.common.utils.PropertiesUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.jeecg.modules.ctop.entity.*;
 import org.jeecg.modules.ctop.entity.*;
 import org.jeecg.modules.ctop.mapper.*;
 import org.jeecg.modules.ctop.mapper.*;
 import org.jeecg.modules.ctop.service.IByteDanceAdvertiserDataService;
 import org.jeecg.modules.ctop.service.IByteDanceAdvertiserDataService;
 import org.jeecg.modules.ctop.service.ICtopOauthTokenService;
 import org.jeecg.modules.ctop.service.ICtopOauthTokenService;
+import org.jeecgframework.poi.excel.annotation.Excel;
 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.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
@@ -596,19 +608,147 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             resultMap.put("code", -1);
             resultMap.put("code", -1);
             return resultMap;
             return resultMap;
         }
         }
-        for (int i = 0; i < data.size(); i++) {
-            JSONObject dataObject = data.getJSONObject(i);
-            ByteDanceCustomAudience audience = new ByteDanceCustomAudience(token, dataObject);
-            audienceMapper.deleteById(audience.getId());
-            audienceMapper.insert(audience);
-        }
+//        for (int i = 0; i < data.size(); i++) {
+//            JSONObject dataObject = data.getJSONObject(i);
+//            ByteDanceCustomAudience audience = new ByteDanceCustomAudience(token, dataObject);
+//            audienceMapper.deleteById(audience.getId());
+//            audienceMapper.insert(audience);
+//        }
 
 
         resultMap.put("success", true);
         resultMap.put("success", true);
         resultMap.put("message", "人群包信息获取成功");
         resultMap.put("message", "人群包信息获取成功");
+        resultMap.put("data", data);
         resultMap.put("code", 0);
         resultMap.put("code", 0);
         return resultMap;
         return resultMap;
     }
     }
 
 
+    @Override
+    public Map<String, Object> advertiserAdUpdate(String accountId, Long adId, ByteDanceUserOrientationTemplate template) {
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+        return null;
+    }
+
+    public JSONObject updateAd(CtopOauthToken token, Long adId, ByteDanceUserOrientationTemplate template) {
+
+        // 请求地址
+        String url = "https://ad.toutiao.com/open_api/2/ad/update/";
+        // 请求参数
+        JSONObject data = new JSONObject();
+        data.put("advertiser_id", token.getAccountId());
+        data.put("ad_id", adId);
+        data = setUserOrentationData(data, template);
+        return HttpUtils.bytedancePostRequest(token.getAccessToken(), url, data);
+    }
+
+    @Override
+    public JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template) {
+        if (null != template.getGender() && !"".equals(template.getGender().trim())) {
+            data.put("gender", template.getGender());
+        }
+        if (null != template.getAge() && !"".equals(template.getAge().trim())) {
+            JSONArray ageArray = JSONArray.parseArray(template.getAge());
+            data.put("age", ageArray);
+        }
+        if (null != template.getAndroidOsv() && !"".equals(template.getAndroidOsv().trim())) {
+            data.put("android_osv", template.getAndroidOsv());
+        }
+        if (null != template.getIosOsv() && !"".equals(template.getIosOsv().trim())) {
+            data.put("ios_osv", template.getIosOsv());
+        }
+        if (null != template.getCarrier() && !"".equals(template.getCarrier().trim())) {
+            JSONArray carrierArray = JSONArray.parseArray(template.getCarrier());
+            data.put("carrier", carrierArray);
+        }
+        if (null != template.getAc() && !"".equals(template.getAc().trim())) {
+            JSONArray acArray = JSONArray.parseArray(template.getAc());
+            data.put("ac", acArray);
+        }
+        if (null != template.getDeviceBrand() && !"".equals(template.getDeviceBrand().trim())) {
+            JSONArray deviceBrandArray = JSONArray.parseArray(template.getDeviceBrand());
+            data.put("device_brand", deviceBrandArray);
+        }
+        if (null != template.getArticleCategory() && !"".equals(template.getArticleCategory().trim())) {
+            JSONArray articleCategoryArray = JSONArray.parseArray(template.getArticleCategory());
+            data.put("article_category", articleCategoryArray);
+        }
+        if (null != template.getActivateType() && !"".equals(template.getActivateType().trim())) {
+            JSONArray activateTypeArray = JSONArray.parseArray(template.getActivateType());
+            data.put("activate_type", activateTypeArray);
+        }
+        if (null != template.getPlatform() && !"".equals(template.getPlatform().trim())) {
+            JSONArray platformArray = JSONArray.parseArray(template.getPlatform());
+            data.put("platform", platformArray);
+        }
+        if (null != template.getCity() && !"".equals(template.getCity().trim())) {
+            JSONArray cityArray = JSONArray.parseArray(template.getCity());
+            data.put("city", cityArray);
+        }
+        if (null != template.getBusinessIds() && !"".equals(template.getBusinessIds().trim())) {
+            JSONArray bussinessIdArray = JSONArray.parseArray(template.getBusinessIds());
+            data.put("business_ids", bussinessIdArray);
+        }
+        if (null != template.getDistrict() && !"".equals(template.getDistrict().trim())) {
+            data.put("district", template.getDistrict());
+        }
+        if (null != template.getLocationType() && !"".equals(template.getLocationType().trim())) {
+            data.put("location_type", template.getLocationType());
+        }
+        if (null != template.getAdTag() && !"".equals(template.getAdTag().trim())) {
+            JSONArray adTagArray = JSONArray.parseArray(template.getAdTag());
+            data.put("ad_tag", adTagArray);
+        }
+        if (null != template.getInterestTags() && !"".equals(template.getInterestTags().trim())) {
+            JSONArray interestTagArray = JSONArray.parseArray(template.getInterestTags());
+            data.put("interest_tags", interestTagArray);
+        }
+        if (null != template.getAppBehaviorTarget() && !"".equals(template.getAppBehaviorTarget().trim())) {
+            data.put("app_behavior_target", template.getAppBehaviorTarget());
+        }
+        if (null != template.getAppCategory() && !"".equals(template.getAppCategory().trim())) {
+            JSONArray appCategoryArray = JSONArray.parseArray(template.getAppCategory());
+            data.put("app_category", appCategoryArray);
+        }
+        if (null != template.getAppIds() && !"".equals(template.getAppIds().trim())) {
+            JSONArray appIdsArray = JSONArray.parseArray(template.getAppIds());
+            data.put("app_ids", appIdsArray);
+        }
+        if (null != template.getProductPlatformId() && !"".equals(template.getProductPlatformId().trim())) {
+            data.put("product_platform_id", template.getProductPlatformId());
+        }
+        if (null != template.getExternalUrlParams() && !"".equals(template.getExternalUrlParams().trim())) {
+            data.put("external_url_params", template.getExternalUrlParams());
+        }
+        if (null != template.getOpenUrlParams() && !"".equals(template.getOpenUrlParams().trim())) {
+            data.put("open_url_params", template.getOpenUrlParams());
+        }
+        if (null != template.getDpaLocalAudience() && !"".equals(template.getDpaLocalAudience().trim())) {
+            data.put("dpa_local_audience", Long.parseLong(template.getDpaLocalAudience()));
+        }
+        if (null != template.getExcludeCustomActions() && !"".equals(template.getExcludeCustomActions().trim())) {
+            JSONArray excludeCustomActionsArray = JSONArray.parseArray(template.getExcludeCustomActions());
+            data.put("exclude_custom_actions", excludeCustomActionsArray);
+        }
+        if (null != template.getIncludeCustomActions() && !"".equals(template.getIncludeCustomActions().trim())) {
+            JSONArray includeCustomActionsArray = JSONArray.parseArray(template.getIncludeCustomActions());
+            data.put("include_custom_actions", includeCustomActionsArray);
+        }
+        if (null != template.getSuperiorPopularityType() && !"".equals(template.getSuperiorPopularityType().trim())) {
+            data.put("superior_popularity_type", template.getSuperiorPopularityType());
+        }
+        if (null != template.getFlowPackage() && !"".equals(template.getFlowPackage().trim())) {
+            JSONArray flowPackageArray = JSONArray.parseArray(template.getFlowPackage());
+            data.put("flow_package", flowPackageArray);
+        }
+        if (null != template.getExcludeFlowPackage() && !"".equals(template.getExcludeFlowPackage().trim())) {
+            JSONArray excludeFlowPackageArray = JSONArray.parseArray(template.getExcludeFlowPackage());
+            data.put("exclude_flow_package", excludeFlowPackageArray);
+        }
+        return data;
+    }
+
+
+
+
     private void getAdvertiserCreativeByPageNumber(String accountId, Integer pageNumber, String ids) {
     private void getAdvertiserCreativeByPageNumber(String accountId, Integer pageNumber, String ids) {
         CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
         CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
         //2: 根据token以及用户id获取用户信息数据
         //2: 根据token以及用户id获取用户信息数据

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ByteDanceCreativeServiceImpl.java

@@ -87,6 +87,8 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         Long deliverytargetId = template.getLong("deliverytargetId");
         Long deliverytargetId = template.getLong("deliverytargetId");
         Long convertId = template.getLong("convertId");
         Long convertId = template.getLong("convertId");
         Integer iteratorNum = template.getInteger("iteratorNum");
         Integer iteratorNum = template.getInteger("iteratorNum");
+        //获取所有创意信息
+        JSONArray allCreatives = template.getJSONArray("creatives");
 
 
         JSONArray groupImageArray = null;
         JSONArray groupImageArray = null;
         JSONArray horizonImageArray = null;
         JSONArray horizonImageArray = null;

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BytedanceAdvertisePlanTemplateServiceImpl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.service.impl;
 package org.jeecg.modules.ctop.service.impl;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.common.util.ResultMapUtils;
 import org.jeecg.common.util.ResultMapUtils;
@@ -7,6 +8,7 @@ import org.jeecg.common.util.StatusCode;
 import org.jeecg.modules.ctop.entity.*;
 import org.jeecg.modules.ctop.entity.*;
 import org.jeecg.modules.ctop.mapper.*;
 import org.jeecg.modules.ctop.mapper.*;
 import org.jeecg.modules.ctop.service.IByteDanceAdvertisePlanService;
 import org.jeecg.modules.ctop.service.IByteDanceAdvertisePlanService;
+import org.jeecg.modules.ctop.service.IByteDanceAdvertiserDataService;
 import org.jeecg.modules.ctop.service.IBytedanceAdvertisePlanTemplateService;
 import org.jeecg.modules.ctop.service.IBytedanceAdvertisePlanTemplateService;
 import org.jeecg.modules.ctop.service.ICtopOauthTokenService;
 import org.jeecg.modules.ctop.service.ICtopOauthTokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,6 +42,8 @@ public class BytedanceAdvertisePlanTemplateServiceImpl extends ServiceImpl<Byted
     private BytedanceAdvertisePlanTemplateMapper templateMapper;
     private BytedanceAdvertisePlanTemplateMapper templateMapper;
     @Autowired
     @Autowired
     private ICtopOauthTokenService tokenService;
     private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
 
 
     @Override
     @Override
     public Map<String, Object> insertTemplate(BytedanceAdvertisePlanTemplate template, String accountId) {
     public Map<String, Object> insertTemplate(BytedanceAdvertisePlanTemplate template, String accountId) {
@@ -70,6 +74,9 @@ public class BytedanceAdvertisePlanTemplateServiceImpl extends ServiceImpl<Byted
         ByteDanceUserOrientationTemplate userOrientationTemplate = userOrientationTemplateMapper.selectById(userorentationId);
         ByteDanceUserOrientationTemplate userOrientationTemplate = userOrientationTemplateMapper.selectById(userorentationId);
         ByteDanceCampaign campaign = campaignMapper.selectById(campaignId);
         ByteDanceCampaign campaign = campaignMapper.selectById(campaignId);
         JSONObject data = new JSONObject();
         JSONObject data = new JSONObject();
+        if (null != userOrientationTemplate) {
+            data = advertiserDataService.setUserOrentationData(data, userOrientationTemplate);
+        }
         //广告组id
         //广告组id
         data.put("campaign_id", campaignId);
         data.put("campaign_id", campaignId);
         //投放范围
         //投放范围

+ 20 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BytedanceInterestCategoryServiceImpl.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import org.jeecg.modules.ctop.entity.BytedanceInterestCategory;
+import org.jeecg.modules.ctop.mapper.BytedanceInterestCategoryMapper;
+import org.jeecg.modules.ctop.service.IBytedanceInterestCategoryService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 兴趣分类信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-09-18
+ */
+@Service
+public class BytedanceInterestCategoryServiceImpl extends ServiceImpl<BytedanceInterestCategoryMapper, BytedanceInterestCategory> implements IBytedanceInterestCategoryService {
+
+}

+ 17 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/FileInfoServiceImpl.java

@@ -239,7 +239,23 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         // 请求参数
         // 请求参数
         Map<String, Object> data = new HashMap();
         Map<String, Object> data = new HashMap();
         data.put("advertiser_id", advertiserId);
         data.put("advertiser_id", advertiserId);
-        return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, data);
+        JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, data);
+        JSONArray creativeWords = resultObject.getJSONObject("data").getJSONArray("creative_word");
+        resultObject.remove("data");
+        JSONArray array = new JSONArray();
+        if (null != creativeWords && creativeWords.size() > 0) {
+            creativeWords.forEach(word -> {
+                JSONObject getWord = (JSONObject) word;
+                getWord.remove("user_rate");
+                getWord.remove("content_type");
+                getWord.remove("default_word");
+                getWord.remove("words");
+                getWord.remove("max_word_len");
+                array.add(getWord);
+            });
+        }
+        resultObject.put("creative_word", array);
+        return resultObject;
     }
     }
 
 
     public JSONObject searchIndustry(CtopOauthToken token, Integer level) {
     public JSONObject searchIndustry(CtopOauthToken token, Integer level) {

+ 40 - 326
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,24 +1,17 @@
 package org.jeecg;
 package org.jeecg;
 
 
 import cn.com.ctop.common.utils.OSSUtils;
 import cn.com.ctop.common.utils.OSSUtils;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
-import org.apache.poi.hssf.usermodel.HSSFDataFormat;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.xssf.usermodel.XSSFCell;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.shiro.crypto.hash.Hash;
 import org.jeecg.common.util.ResultMapUtils;
 import org.jeecg.common.util.ResultMapUtils;
 import org.jeecg.common.util.StatusCode;
 import org.jeecg.common.util.StatusCode;
 import org.jeecg.common.util.jsonschema.JsonschemaUtil;
 import org.jeecg.common.util.jsonschema.JsonschemaUtil;
 import org.jeecg.modules.ctop.entity.BytedanceAreaInfo;
 import org.jeecg.modules.ctop.entity.BytedanceAreaInfo;
+import org.jeecg.modules.ctop.entity.BytedanceInterestCategory;
 import org.jeecg.modules.ctop.mapper.BytedanceAreaInfoMapper;
 import org.jeecg.modules.ctop.mapper.BytedanceAreaInfoMapper;
-import org.jeecg.modules.ctop.mapper.PlatformCampaignStatisticInfoMapper;
+import org.jeecg.modules.ctop.mapper.BytedanceInterestCategoryMapper;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.jeecg.modules.ctop.service.IReportService;
 import org.jeecg.modules.ctop.service.IReportService;
-import org.jeecg.modules.ctop.vo.StatisticCampaignVo;
 import org.jeecg.modules.demo.mock.MockController;
 import org.jeecg.modules.demo.mock.MockController;
 import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
 import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
 import org.jeecg.modules.demo.test.service.IJeecgDemoService;
 import org.jeecg.modules.demo.test.service.IJeecgDemoService;
@@ -30,10 +23,9 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.context.junit4.SpringRunner;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
-import java.io.*;
+import java.io.File;
 import java.util.Date;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 @RunWith(SpringRunner.class)
 @RunWith(SpringRunner.class)
@@ -77,58 +69,6 @@ public class SampleTest {
         Map<String, Object> map = createInternalService.checkAccountPassword("dcd_ad@bytedance.com", "typdDCD@2018");
         Map<String, Object> map = createInternalService.checkAccountPassword("dcd_ad@bytedance.com", "typdDCD@2018");
         System.out.println(map.toString());
         System.out.println(map.toString());
     }
     }
-    @Test
-    public void getExcelData() throws Exception {
-        String statisticDate = "2019-08-23";
-        Long accountId = 4L;
-        Long secondId = 1L;
-        List<StatisticCampaignVo> statisticCampaign4Vos = statisticInfoMapper.getVoByParams(accountId);
-        List<StatisticCampaignVo> statisticCampaign1Vos = statisticInfoMapper.getVoByParams(secondId);
-
-        File f = new File("D:\\upload\\excel\\template.xlsx");
-        InputStream inputStream = new FileInputStream(f);
-        XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
-//        //获取第一个sheet
-        XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
-        CellStyle numbericCellStyle = xssfWorkbook.createCellStyle();
-        numbericCellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));
-        int index;
-        for (index = 1; index < statisticCampaign4Vos.size() + 1; index++) {
-            StatisticCampaignVo vo = statisticCampaign4Vos.get(index - 1);
-            System.out.println(vo.toString());
-            String content = vo.getContent();
-            String[] contents = content.split("-");
-            Row row = xssfSheet.getRow(index);
-            setExcelRow(numbericCellStyle, vo, contents, row, "single");
-        }
-        Row totalRow = xssfSheet.getRow(index);
-        StatisticCampaignVo total = statisticInfoMapper.getTotalStatisticVoByparams(accountId);
-        if (null != total) {
-            setExcelRow(numbericCellStyle, total, new String[]{}, totalRow, "total4");
-        }
-        index++;
-        for (int j = 0; j < statisticCampaign1Vos.size(); j++) {
-            index++;
-            StatisticCampaignVo vo = statisticCampaign1Vos.get(j);
-            System.out.println(vo.toString());
-            String content = vo.getContent();
-            String[] contents = content.split("-");
-            Row row = xssfSheet.getRow(index);
-            setExcelRow(numbericCellStyle, vo, contents, row, "single");
-        }
-        index++;
-        Row totalRow1 = xssfSheet.getRow(index);
-        StatisticCampaignVo total1 = statisticInfoMapper.getTotalStatisticVoByparams(secondId);
-        if (null != total1) {
-            setExcelRow(numbericCellStyle, total1, new String[]{}, totalRow1, "total1");
-        }
-
-        FileOutputStream fileOutputStream = new FileOutputStream("D:\\upload\\excel\\get.xlsx");
-        xssfWorkbook.write(fileOutputStream);
-        fileOutputStream.close();
-
-
-    }
 
 
     @Test
     @Test
     public void testFileType() {
     public void testFileType() {
@@ -136,272 +76,11 @@ public class SampleTest {
         System.out.println(file);
         System.out.println(file);
     }
     }
 
 
-    private void setExcelRow(CellStyle numbericCellStyle, StatisticCampaignVo vo, String[] contents, Row row, String type) {
-        for (int j = 0; j < 38; j++) {
-            Cell cell = row.createCell(j);
-            if (j == 0) {
-                //日期
-                if (null != type && type.equals("single")) {
-                    cell.setCellValue(vo.getStatisticDate());
-                } else if (null != type && type.equals("total1")) {
-                    cell.setCellValue("户一总计");
-                } else {
-                    cell.setCellValue("户四总计");
-                }
-            } else if (j == 1) {
-                //代理
-                cell.setCellValue(vo.getProxy());
-            } else if (j == 2) {
-                //投放系统
-                if (null != contents && contents.length > 3) {
-                    cell.setCellValue(contents[2]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 3) {
-                //渠道号
-                if (null != contents && contents.length > 2) {
-                    cell.setCellValue(contents[1]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 4) {
-                //content
-                if (null != contents && contents.length > 0) {
-                    cell.setCellValue(contents[0]);
-                } else {
-                    cell.setCellValue("");
-                }
-//                cell.setCellValue(vo.getContent());
-            } else if (j == 5) {
-                if (null != contents && contents.length > 5) {
-                    cell.setCellValue(contents[4]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 6) {
-                //出价方式
-                if (null != contents && contents.length > 6) {
-                    cell.setCellValue(contents[5]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 7) {
-                //定向条件
-                if (null != contents && contents.length > 4) {
-                    cell.setCellValue(contents[3]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 8) {
-                //定向条件
-                if (null != contents && contents.length > 7) {
-                    cell.setCellValue(contents[6]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 9) {
-                //花费
-                if (null != vo.getCost() && !"".equals(vo.getCost())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCost()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 10) {
-                //封面曝光数
-                if (null != vo.getCoverViews() && !"".equals(vo.getCoverViews())) {
-                    cell.setCellValue(Integer.parseInt(vo.getCoverViews()));
-                }
-            } else if (j == 11) {
-                //封面点击数
-                if (null != vo.getCoverClick() && !"".equals(vo.getCoverClick())) {
-                    cell.setCellValue(Integer.parseInt(vo.getCoverClick()));
-                }
-            } else if (j == 12) {
-                //素材曝光数
-                if (null != vo.getMaterialViews() && !"".equals(vo.getMaterialViews())) {
-                    cell.setCellValue(Integer.parseInt(vo.getMaterialViews()));
-                }
-            } else if (j == 13) {
-                //行为数
-                if (null != vo.getActions() && !"".equals(vo.getActions())) {
-                    cell.setCellValue(Integer.parseInt(vo.getActions()));
-                }
-            } else if (j == 14) {
-                //点击率
-                if (null != vo.getClickRate() && !"".equals(vo.getClickRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getClickRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 15) {
-                //行为点击率
-                if (null != vo.getActionClickRate() && !"".equals(vo.getActionClickRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getActionClickRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 16) {
-                //ACTR*BCTR
-                if (null != vo.getAbctr() && !"".equals(vo.getAbctr())) {
-                    cell.setCellValue(Float.parseFloat(vo.getAbctr()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 17) {
-                //点击成本
-                if (null != vo.getClickPrice() && !"".equals(vo.getClickPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getClickPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 18) {
-                //行为成本
-                if (null != vo.getActionPrice() && !"".equals(vo.getActionPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getActionPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 19) {
-                //注册用户
-                if (null != vo.getRegistUserNum() && !"".equals(vo.getRegistUserNum())) {
-                    cell.setCellValue(Integer.parseInt(vo.getRegistUserNum()));
-                }
-            } else if (j == 20) {
-                //完件用户
-                if (null != vo.getComplateUserNum() && !"".equals(vo.getComplateUserNum())) {
-                    cell.setCellValue(Integer.parseInt(vo.getComplateUserNum()));
-                }
-            } else if (j == 21) {
-                //授信用户
-                if (null != vo.getCreditUserNum() && !"".equals(vo.getCreditUserNum())) {
-                    cell.setCellValue(Integer.parseInt(vo.getCreditUserNum()));
-                }
-            } else if (j == 22) {
-                //当日注册且完件数
-                if (null != vo.getRegistCompleteNum() && !"".equals(vo.getRegistCompleteNum())) {
-                    cell.setCellValue(Integer.parseInt(vo.getRegistCompleteNum()));
-                }
-            } else if (j == 23) {
-                //当日注册且授信数
-                if (null != vo.getRegistCreditNum() && !"".equals(vo.getRegistCreditNum())) {
-                    cell.setCellValue(Integer.parseInt(vo.getRegistCreditNum()));
-                }
-            } else if (j == 25) {
-                //注册成本
-                if (null != vo.getRegistPrice() && !"".equals(vo.getRegistPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 26) {
-                //完件成本
-                if (null != vo.getCompletePrice() && !"".equals(vo.getCompletePrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCompletePrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 27) {
-                //授信成本
-                if (null != vo.getCreditPrice() && !"".equals(vo.getCreditPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 28) {
-                //当日注册且完件成本
-                if (null != vo.getRegistCompletePrice() && !"".equals(vo.getRegistCompletePrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCompletePrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 29) {
-                //当日注册且授信成本
-                if (null != vo.getRegistCreditPrice() && !"".equals(vo.getRegistCreditPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCreditPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 30) {
-                //点击注册率
-                if (null != vo.getClickRegistRate() && !"".equals(vo.getClickRegistRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getClickRegistRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 31) {
-                //行为注册率
-                if (null != vo.getActionRegistRate() && !"".equals(vo.getActionRegistRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getActionRegistRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 32) {
-                //完件率
-                if (null != vo.getCompleteRate() && !"".equals(vo.getCompleteRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCompleteRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 33) {
-                //授信率
-                if (null != vo.getCreditRate() && !"".equals(vo.getCreditRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 34) {
-                //当日完件率
-                if (null != vo.getRegistCompleteRate() && !"".equals(vo.getRegistCompleteRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCompleteRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 35) {
-                //当日授信率
-                if (null != vo.getRegistCreditRate() && !"".equals(vo.getRegistCreditRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCreditRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 36) {
-                //当日完件/完件
-                if (null != vo.getCompleteRateDay() && !"".equals(vo.getCompleteRateDay())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCompleteRateDay()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 37) {
-                //当日授信/授信
-                if (null != vo.getCreditRateDay() && !"".equals(vo.getCreditRateDay())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditRateDay()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 38) {
-                //当日授信/注册
-                if (null != vo.getCreditRegistRateDay() && !"".equals(vo.getCreditRegistRateDay())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditRegistRateDay()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            }
-        }
-    }
-
-    @Test
-    public void toPlateform() throws IOException {
-        File f = new File("D:\\upload\\excel\\template.xlsx");
-        InputStream inputStream = new FileInputStream(f);
-        XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
-//        //获取第一个sheet
-        XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
-        for (int i = 1; i < 6; i++) {
-            System.out.println("i:" + i);
-            Row row = xssfSheet.getRow(i);
-            for (int j = 1; j < 4; j++) {
-                Cell cell = row.createCell(j);
-                if (j == 3) {
-                    cell.setCellType(XSSFCell.CELL_TYPE_FORMULA);
-                    cell.setCellFormula("B2*C2");
-                } else {
-                    cell.setCellValue(i);
-                }
-            }
-        }
-        FileOutputStream fileOutputStream = new FileOutputStream("D:\\upload\\excel\\get.xlsx");
-        xssfWorkbook.write(fileOutputStream);
-        fileOutputStream.close();
-    }
-
     @Test
     @Test
     public void testFileUpload() {
     public void testFileUpload() {
         OSSUtils.uploadObject2Oss(new File("D:\\upload\\excel\\template.xlsx"));
         OSSUtils.uploadObject2Oss(new File("D:\\upload\\excel\\template.xlsx"));
     }
     }
 
 
-    @Autowired
-    private PlatformCampaignStatisticInfoMapper statisticInfoMapper;
-
     @Test
     @Test
     public void testNg() {
     public void testNg() {
         JSONObject json = new JSONObject();
         JSONObject json = new JSONObject();
@@ -411,8 +90,44 @@ public class SampleTest {
 
 
     @Autowired
     @Autowired
     private BytedanceAreaInfoMapper areaInfoMapper;
     private BytedanceAreaInfoMapper areaInfoMapper;
+    @Autowired
+    private BytedanceInterestCategoryMapper interestCategoryMapper;
 
 
     @Test
     @Test
+    public void setCategoryData() {
+        String path = "D:\\工作文件\\头条批量\\data_20190222\\ad_tag.json";
+        String jsonString = JsonschemaUtil.readJsonFile(path);
+        JSONObject data = JSONObject.parseObject(jsonString);
+        JSONArray tagArray = data.getJSONArray("adtags");
+        tagArray.forEach(tag -> {
+            JSONObject getTag = (JSONObject) tag;
+            String pcode = getTag.getString("value");
+            String plabel = getTag.getString("label");
+            BytedanceInterestCategory category = new BytedanceInterestCategory();
+            category.setCode(pcode);
+            category.setName(plabel);
+            category.setParentCode("0");
+            category.setLevel(1);
+            category.setCreateTime(new Date());
+            category.setUpdateTime(new Date());
+            interestCategoryMapper.insert(category);
+            JSONArray children = getTag.getJSONArray("subTags");
+            children.forEach(child -> {
+                JSONObject getchild = (JSONObject) child;
+                String code = getchild.getString("value");
+                String label = getchild.getString("label");
+                BytedanceInterestCategory childCategory = new BytedanceInterestCategory();
+                childCategory.setCode(code);
+                childCategory.setName(label);
+                childCategory.setParentCode(pcode);
+                childCategory.setLevel(2);
+                childCategory.setCreateTime(new Date());
+                childCategory.setUpdateTime(new Date());
+                interestCategoryMapper.insert(childCategory);
+            });
+        });
+    }
+    @Test
     public void setJSONFile() {
     public void setJSONFile() {
         String path = "C:\\Users\\宋英豪\\Downloads\\data_20190222\\city.json";
         String path = "C:\\Users\\宋英豪\\Downloads\\data_20190222\\city.json";
         String jsonString = JsonschemaUtil.readJsonFile(path);
         String jsonString = JsonschemaUtil.readJsonFile(path);
@@ -442,7 +157,6 @@ public class SampleTest {
             areaInfo.setCreateTime(new Date());
             areaInfo.setCreateTime(new Date());
             areaInfo.setUpdateTime(new Date());
             areaInfo.setUpdateTime(new Date());
             areaInfoMapper.insert(areaInfo);
             areaInfoMapper.insert(areaInfo);
-
         });
         });
     }
     }
 }
 }