Explorar o código

头条批量代码逻辑

syh %!s(int64=4) %!d(string=hai) anos
pai
achega
ba3c12bc39
Modificáronse 15 ficheiros con 665 adicións e 28 borrados
  1. 0 5
      jeecg-boot-module-system/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java
  2. 10 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  3. 6 10
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  4. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  5. 1 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  6. 73 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java
  7. 241 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/BytedanceImageInfoController.java
  8. 95 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/BytedanceImageInfo.java
  9. 18 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java
  10. 35 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml
  11. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java
  12. 17 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceImageInfoService.java
  13. 44 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  14. 97 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java
  15. 26 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java

+ 0 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java

@@ -29,19 +29,14 @@ public class MybatisInterceptor implements Interceptor {
 	@Override
 	public Object intercept(Invocation invocation) throws Throwable {
 		MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
-		String sqlId = mappedStatement.getId();
-		log.debug("------sqlId------" + sqlId);
 		SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
 		Object parameter = invocation.getArgs()[1];
-		log.debug("------sqlCommandType------" + sqlCommandType);
-
 		if (parameter == null) {
 			return invocation.proceed();
 		}
 		if (SqlCommandType.INSERT == sqlCommandType) {
 			Field[] fields = oConvertUtils.getAllFields(parameter);
 			for (Field field : fields) {
-				log.debug("------field.name------" + field.getName());
 				try {
 					// 获取登录用户信息
 					LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

+ 10 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -325,7 +325,7 @@ public class ProjectMemberController {
      *
      * @return
      */
-    @GetMapping(value = "/getProjectAccountByUserId")
+    @GetMapping("/getProjectAccountByUserId")
     public Result<List<Map<String, Object>>> getProjectAccountBy() {
         Result<List<Map<String, Object>>> resultBody = new Result<>();
         try {
@@ -346,8 +346,6 @@ public class ProjectMemberController {
      *
      * @return
      */
-    @AutoLog(value = "头条视频报表-参与项目列表")
-    @ApiOperation(value = "头条视频报表-参与项目列表", notes = "头条视频报表-参与项目列表")
     @GetMapping(value = "/getSaleOwnProjects")
     public Result<List<ProjectMember>> getSaleOwnProjects(@RequestParam(required = true ,name = "mediaIds") List<Integer> mediaIds) {
         Result<List<ProjectMember>> result = new Result<>();
@@ -368,12 +366,16 @@ public class ProjectMemberController {
      *
      * @return
      */
-    @AutoLog(value = "头条视频报表-参与项目列表")
-    @ApiOperation(value = "头条视频报表-参与项目列表", notes = "头条视频报表-参与项目列表")
-    @GetMapping(value = "/getOwnProjects")
-    public Result<List<ProjectMember>> getOwnProjects(@RequestParam(required = true ,name = "mediaIds") List<Integer> mediaIds) {
+    @GetMapping("/getOwnProjects")
+    public Result<List<ProjectMember>> getOwnProjects(@RequestBody JSONObject data) {
         Result<List<ProjectMember>> result = new Result<>();
-
+        JSONArray ids = data.getJSONArray("mediaIds");
+        List<Integer> mediaIds = new ArrayList<>();
+        if(null!=ids&&!ids.isEmpty()){
+            for(int i=0;i<ids.size();i++){
+                mediaIds.add(ids.getIntValue(i));
+            }
+        }
         List<ProjectMember> projectMemberList = projectMemberService.getOwnProjects(mediaIds);
         if (projectMemberList == null) {
             result.error500("未找到对应实体");

+ 6 - 10
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -4,8 +4,6 @@ import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
@@ -16,13 +14,10 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
-import cn.com.ctop.toutiao.modules.material.vo.BytedanceCampaignEditVo;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.cp.bean.WxCpMessage;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.entity.KuaishouEffectVideoInfo;
 import org.jeecg.modules.ctop.service.IKuaishouEffectVideoInfoService;
@@ -37,11 +32,6 @@ import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.cp.api.WxCpService;
-import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
-import me.chanjar.weixin.cp.bean.WxCpMessage;
-import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
@@ -193,6 +183,12 @@ public class SampleTest {
         JSONObject jsonObject = HttpUtils.bytedanceGetRequest(access_token, url, new JSONObject());
         System.out.println(jsonObject.toJSONString());
     }
+
+    @Test
+    public void loadImageInfo(){
+        CtopOauthToken token = oauthTokenService.getTokenByAccountId(1649600126891015L);
+        advertiserDataService.getImageByPage(token,null,1);
+    }
 }
 
 

+ 0 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -1148,7 +1148,6 @@ public class BatchController {
         return result;
     }
 
-
     /**
      * 获取素材信息
      *

+ 1 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -865,9 +865,7 @@
         --         (SELECT media_id from ctop_project c where c.id=a.project_id limit 1) as mediaId,
                 responsible_name as responsibleName,
                 design_responsible_name as designResponsibleName
-        from
-
-        left join ctop_project
+        from ctop_project
         where
         id in
             <foreach collection="projectIds" item="item" separator=","

+ 73 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java

@@ -1,16 +1,25 @@
 package cn.com.ctop.toutiao.modules.batch.controller;
 
 import cn.com.ctop.common.module.service.IFileInfoService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.toutiao.modules.batch.service.IBytedanceIndustryInfoService;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
+import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceImageInfoService;
 import com.alibaba.fastjson.JSONObject;
+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.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -28,6 +37,9 @@ public class ByteDanceBatchController {
     private IFileInfoService fileInfoService;
     @Autowired
     private IByteDanceCreativeService creativeService;
+    @Autowired
+    private IByteDanceVideoInfoService videoInfoService;
+
     /**
      * 获取动态词包信息
      *
@@ -48,12 +60,72 @@ public class ByteDanceBatchController {
     public Map<String,Object>getIndustryList(){
         return bytedanceIndustryInfoService.getIndustryList();
     }
-
     @GetMapping("load/industry")
     public Map<String,Object>loadIndustryList(Long accountId,Integer level){
         return bytedanceIndustryInfoService.getBytedanceIndustryList(accountId,level);
     }
 
+    @GetMapping(value = "/getVideoList")
+    public Result<IPage<ByteDanceVideoInfo>> getBytedqanceVideoList(@RequestParam(name = "accountId") Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    @RequestParam(name = "startDate", defaultValue = "") String startDate,
+                                                                    @RequestParam(name = "endDate", defaultValue = "") String endDate) {
+        Result<IPage<ByteDanceVideoInfo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+
+            QueryWrapper<ByteDanceVideoInfo> queryWrapper = new QueryWrapper<>();
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                queryWrapper.between("create_time", startDate+" 00:00:00", endDate+" 23:59:59");
+            }
+            queryWrapper.eq("account_id",accountId);
+            queryWrapper.orderByDesc("material_upload_time");
+            queryWrapper.groupBy("signature");
+            Page<ByteDanceVideoInfo> page = new Page<>(pageNo, pageSize);
+            IPage<ByteDanceVideoInfo> pageList = videoInfoService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+    @Autowired
+    private IBytedanceImageInfoService imageInfoService;
+
+    @GetMapping(value = "/getImageList")
+    public Result<IPage<BytedanceImageInfo>> getBytedqanceVideoList(@RequestParam(name = "accountId")Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    @RequestParam(name = "startDate", defaultValue = "") String startDate,
+                                                                    @RequestParam(name = "endDate", defaultValue = "") String endDate, HttpServletRequest req) {
+        Result<IPage<BytedanceImageInfo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+            QueryWrapper<BytedanceImageInfo> queryWrapper = new QueryWrapper<>();
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                queryWrapper.between("image_create_time", startDate+" 00:00:00", endDate+" 23:59:59");
+            }
+            queryWrapper.eq("account_id",accountId);
+            queryWrapper.orderByDesc("image_create_time");
+            queryWrapper.groupBy("signature");
+            Page<BytedanceImageInfo> page = new Page<>(pageNo, pageSize);
+            IPage<BytedanceImageInfo> pageList = imageInfoService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
     /**
      *  批量创建计划
      * @param byteDanceAdvertisePlan

+ 241 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/BytedanceImageInfoController.java

@@ -0,0 +1,241 @@
+package cn.com.ctop.toutiao.modules.material.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceImageInfoService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+ /**
+ * 头条图片素材
+ * @author jeecg-boot
+ * @date   2020-08-01
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="头条图片素材")
+@RestController
+@RequestMapping("/ctop/bytedanceImageInfo")
+public class BytedanceImageInfoController {
+	@Autowired
+	private IBytedanceImageInfoService bytedanceImageInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param bytedanceImageInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "头条图片素材-分页列表查询")
+	@ApiOperation(value="头条图片素材-分页列表查询", notes="头条图片素材-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceImageInfo>> queryPageList(BytedanceImageInfo bytedanceImageInfo,
+														   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+														   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+														   HttpServletRequest req) {
+		Result<IPage<BytedanceImageInfo>> result = new Result<>();
+		QueryWrapper<BytedanceImageInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceImageInfo, req.getParameterMap());
+		Page<BytedanceImageInfo> page = new Page<BytedanceImageInfo>(pageNo, pageSize);
+		IPage<BytedanceImageInfo> pageList = bytedanceImageInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param bytedanceImageInfo
+	 * @return
+	 */
+	@AutoLog(value = "头条图片素材-添加")
+	@ApiOperation(value="头条图片素材-添加", notes="头条图片素材-添加")
+	@PostMapping(value = "/add")
+	public Result<BytedanceImageInfo> add(@RequestBody BytedanceImageInfo bytedanceImageInfo) {
+		Result<BytedanceImageInfo> result = new Result<>();
+		try {
+			bytedanceImageInfoService.save(bytedanceImageInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param bytedanceImageInfo
+	 * @return
+	 */
+	@AutoLog(value = "头条图片素材-编辑")
+	@ApiOperation(value="头条图片素材-编辑", notes="头条图片素材-编辑")
+	@PutMapping(value = "/edit")
+	public Result<BytedanceImageInfo> edit(@RequestBody BytedanceImageInfo bytedanceImageInfo) {
+		Result<BytedanceImageInfo> result = new Result<BytedanceImageInfo>();
+		BytedanceImageInfo bytedanceImageInfoEntity = bytedanceImageInfoService.getById(bytedanceImageInfo.getId());
+		if(bytedanceImageInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceImageInfoService.updateById(bytedanceImageInfo);
+			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 {
+			bytedanceImageInfoService.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<BytedanceImageInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<BytedanceImageInfo> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.bytedanceImageInfoService.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<BytedanceImageInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceImageInfo> result = new Result<>();
+		BytedanceImageInfo bytedanceImageInfo = bytedanceImageInfoService.getById(id);
+		if(bytedanceImageInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceImageInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<BytedanceImageInfo> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              BytedanceImageInfo bytedanceImageInfo = JSON.parseObject(deString, BytedanceImageInfo.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(bytedanceImageInfo, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<BytedanceImageInfo> pageList = bytedanceImageInfoService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "头条图片素材列表");
+      mv.addObject(NormalExcelConstants.CLASS, BytedanceImageInfo.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<BytedanceImageInfo> listBytedanceImageInfos = ExcelImportUtil.importExcel(file.getInputStream(), BytedanceImageInfo.class, params);
+              bytedanceImageInfoService.saveBatch(listBytedanceImageInfos);
+              return Result.ok("文件导入成功!数据行数:" + listBytedanceImageInfos.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("文件导入失败!");
+  }
+
+}

+ 95 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/BytedanceImageInfo.java

@@ -0,0 +1,95 @@
+package cn.com.ctop.toutiao.modules.material.entity;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 头条图片素材
+ * @author jeecg-boot
+ * @date   2020-08-01
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_image_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_bytedance_image_info对象", description="头条图片素材")
+public class BytedanceImageInfo {
+
+	/**id*/
+	@TableId()
+    @ApiModelProperty(value = "id")
+	private String id;
+	/**头条平台账号id*/
+	private Long accountId;
+	/**advertiserId*/
+	private Long materialId;
+	/**图片大小*/
+	@Excel(name = "图片大小", width = 15)
+    @ApiModelProperty(value = "图片大小")
+	private Long size;
+	/**图片宽度*/
+	@Excel(name = "图片宽度", width = 15)
+    @ApiModelProperty(value = "图片宽度")
+	private Long width;
+	/**图片高度*/
+	@Excel(name = "图片高度", width = 15)
+    @ApiModelProperty(value = "图片高度")
+	private Long height;
+	/**预览地址*/
+	@Excel(name = "预览地址", width = 15)
+    @ApiModelProperty(value = "预览地址")
+	private String url;
+	private String imageUrl;
+	/**图片格式*/
+	@Excel(name = "图片格式", width = 15)
+    @ApiModelProperty(value = "图片格式")
+	private String format;
+	/**图片Md5*/
+	@Excel(name = "图片Md5", width = 15)
+    @ApiModelProperty(value = "图片Md5")
+	private String signature;
+	private String imageCreateTime;
+	private String fileName;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+
+	public BytedanceImageInfo(JSONObject dataObject, CtopOauthToken token) {
+		String id = dataObject.getString("id");
+		if(null!=id&&id.contains("web")){
+			this.imageUrl = "https://sf6-ttcdn-tos.pstatp.com/obj/"+id;
+		}else{
+			this.imageUrl = "https://sf6-ttcdn-tos.pstatp.com/obj/mosaic-legacy/"+id;
+		}
+		this.id = dataObject.getString("id");
+		this.accountId = token.getAccountId();
+		this.materialId = dataObject.getLong("material_id");
+		this.size = dataObject.getLong("size");
+		this.width = dataObject.getLong("width");
+		this.height = dataObject.getLong("height");
+		this.url = dataObject.getString("url");
+		this.format = dataObject.getString("format");
+		this.signature = dataObject.getString("signature");
+		this.imageCreateTime = dataObject.getString("create_time");
+		this.fileName = dataObject.getString("filename");
+		this.createTime = new Date();
+		this.updateTime = new Date();
+	}
+
+	public BytedanceImageInfo() {
+	}
+}

+ 18 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.toutiao.modules.material.mapper;
+
+import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 头条图片素材
+ * @author: jeecg-boot
+ * @date:   2020-08-01
+ * @cersion: V1.0
+ */
+public interface BytedanceImageInfoMapper extends BaseMapper<BytedanceImageInfo> {
+
+    void replaceBatch(@Param(value = "imageInfos")List<BytedanceImageInfo> imageInfos);
+}

+ 35 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml

@@ -0,0 +1,35 @@
+<?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.toutiao.modules.material.mapper.BytedanceImageInfoMapper">
+
+    <insert id="replaceBatch">
+        replace into ctop_bytedance_image_info(
+        id,
+        account_id,
+        material_id,
+        size,
+        width,
+        height,
+        url,
+        format,
+        signature,
+        image_create_time,
+        create_time,
+        update_time,image_url)
+        values
+        <foreach collection="imageInfos" item="imageInfo" separator=",">
+            (#{imageInfo.id},
+            #{imageInfo.accountId},
+            #{imageInfo.materialId},
+            #{imageInfo.size},
+            #{imageInfo.width},
+            #{imageInfo.height},
+            #{imageInfo.url},
+            #{imageInfo.format},
+            #{imageInfo.signature},
+            #{imageInfo.imageCreateTime},
+            #{imageInfo.createTime},
+            #{imageInfo.updateTime},#{imageInfo.imageUrl})
+        </foreach>
+    </insert>
+</mapper>

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java

@@ -33,4 +33,6 @@ public interface IByteDanceAdvertiserDataService {
     Map<String, Object> flowPackageGet(String accountId);
 
     void getMaterialList(CtopOauthToken token);
+
+    void getImageByPage(CtopOauthToken token, String imageIds, int page);
 }

+ 17 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceImageInfoService.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.toutiao.modules.material.service;
+
+import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 头条图片素材
+ * @author jeecg-boot
+ * @date   2020-08-01
+ * @version V1.0
+ */
+public interface IBytedanceImageInfoService extends IService<BytedanceImageInfo> {
+
+    void replaceBatch(List<BytedanceImageInfo> videoInfoList);
+}

+ 44 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -576,6 +576,50 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     @Override
     public void getMaterialList(CtopOauthToken token) {
         getVideoByPage(token, "", 1);
+        getImageByPage(token, "", 1);
+    }
+
+    @Autowired
+    private IBytedanceImageInfoService imageInfoService;
+    @Override
+    public void getImageByPage(CtopOauthToken token, String imageIds, int page) {
+        // 请求地址
+        String url = "https://ad.oceanengine.com/open_api/2/file/image/get/";
+        // 请求参数
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", token.getAccountId());
+        param.put("page", page);
+        param.put("page_size", 100);
+        if (null != imageIds && !"".equals(imageIds.trim())) {
+            String[] getIds = imageIds.split(StringUtils.COMMA);
+            if (getIds.length > 0) {
+                JSONObject filter = new JSONObject();
+                JSONArray idArray = new JSONArray();
+                Collections.addAll(idArray, getIds);
+                filter.put("image_ids", idArray);
+                param.put("filtering", filter);
+            }
+        }
+
+        JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
+        Integer code = resultObject.getInteger("code");
+        if (null == code || !code.equals(0)) {
+            log.error("获取图片素材库接口异常==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
+            return;
+        }
+        JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
+        if (null == data || data.isEmpty()) {
+            log.info("获取图片素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
+            return;
+        }
+        List<BytedanceImageInfo> videoInfoList = new ArrayList<>();
+        for (int i = 0; i < data.size(); i++) {
+            JSONObject dataObject = data.getJSONObject(i);
+            BytedanceImageInfo imageInfo = new BytedanceImageInfo(dataObject, token);
+            videoInfoList.add(imageInfo);
+        }
+        imageInfoService.replaceBatch(videoInfoList);
+        getImageByPage(token, imageIds, page + 1);
     }
 
     private void getVideoByPage(CtopOauthToken token, String videoIds, int page) {

+ 97 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java

@@ -428,6 +428,103 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
 
         if(null!=creativeWay&&creativeWay.trim().equals("proceduralCreativity")){
             //程序化
+            params.put("creative_material_mode","STATIC_ASSEMBLE");
+            JSONArray titleList = data.getJSONArray("titleList");
+            if(null!=titleList&&!titleList.isEmpty()){
+                JSONArray setTitleList = new JSONArray();
+                for (int i=0;i<titleList.size();i++){
+                    JSONObject titleObject = titleList.getJSONObject(i);
+                    JSONArray creativeWordIds = titleObject.getJSONArray("creativeWordIds");
+                    titleObject.remove("creativeWordIds");
+                    if(null!=creativeWordIds&&!creativeWordIds.isEmpty()){
+                        titleObject.put("creative_word_ids",creativeWordIds);
+                    }
+                    setTitleList.add(titleObject);
+                }
+                params.put("title_list",setTitleList);
+            }
+            JSONArray imageList = data.getJSONArray("imageList");
+            if(null!=imageList&&!imageList.isEmpty()){
+                JSONArray setImageList = new JSONArray();
+                for (int i=0;i<imageList.size();i++){
+                    JSONObject imageObject = imageList.getJSONObject(i);
+                    String imageMode = imageObject.getString("imageMode");
+                    JSONArray imageIds = imageObject.getJSONArray("imageIds");
+                    String imageId = imageObject.getString("imageId");
+                    String videoId = imageObject.getString("videoId");
+                    Integer templateId = imageObject.getInteger("templateId");
+                    imageObject.remove("imageMode");
+                    imageObject.remove("imageIds");
+                    imageObject.remove("imageId");
+                    imageObject.remove("videoId");
+                    imageObject.remove("templateId");
+                    imageObject.put("image_mode",imageMode);
+                    if(null!=imageIds&&!imageIds.isEmpty()){
+                        imageObject.put("image_ids",imageIds);
+                    }
+                    if(null!=imageId&&!"".equals(imageId.trim())){
+                        imageObject.put("image_id",imageId);
+                    }
+                    if(null!=videoId&&!"".equals(videoId.trim())){
+                        imageObject.put("video_id",videoId);
+                    }
+                    if(null!=templateId&&templateId!=0){
+                        imageObject.put("template_id",templateId);
+                    }
+
+                    setImageList.add(imageObject);
+                }
+                params.put("image_list",setImageList);
+            }
+        }else{
+            //自定义创意
+            JSONArray creatives = data.getJSONArray("creatives");
+            if(null!=creatives&&!creatives.isEmpty()){
+                JSONArray setCreatives = new JSONArray();
+                for(int i=0;i<creatives.size();i++){
+                    JSONObject creativeObject = creatives.getJSONObject(i);
+                    JSONArray creativeWordIds = creativeObject.getJSONArray("creativeWordIds");
+                    creativeObject.remove("creativeWordIds");
+                    if(null!=creativeWordIds&&!creativeWordIds.isEmpty()){
+                        creativeObject.put("creative_word_ids",creativeWordIds);
+                    }
+                    String imageMode = creativeObject.getString("imageMode");
+                    creativeObject.remove("imageMode");
+                    creativeObject.put("image_mode",imageMode);
+                    JSONArray imageIds = creativeObject.getJSONArray("imageIds");
+                    creativeObject.remove("imageIds");
+                    if(null!=imageIds&&!imageIds.isEmpty()){
+                        creativeObject.put("image_ids",imageIds);
+                    }
+                    String imageId = creativeObject.getString("imageId");
+                    creativeObject.remove("imageId");
+                    if(null!=imageId&&!"".equals(imageId.trim())){
+                        creativeObject.put("image_id",imageId);
+                    }
+                    String videoId = creativeObject.getString("videoId");
+                    creativeObject.remove("videoId");
+                    if(null!=videoId&&!"".equals(videoId.trim())){
+                        creativeObject.put("video_id",videoId);
+                    }
+                    Integer templateId = creativeObject.getInteger("templateId");
+                    creativeObject.remove("templateId");
+                    if(null!=templateId&&templateId!=0){
+                        creativeObject.put("template_id",templateId);
+                    }
+                    JSONArray dpaDictIds = creativeObject.getJSONArray("dpaDictIds");
+                    creativeObject.remove("dpaDictIds");
+                    if(null!=creativeWordIds&&!creativeWordIds.isEmpty()){
+                        creativeObject.put("creative_word_ids",creativeWordIds);
+                    }
+                    Integer derivePosterCid = creativeObject.getInteger("derivePosterCid");
+                    creativeObject.remove("derivePosterCid");
+                    if(null!=derivePosterCid&&derivePosterCid!=0){
+                        creativeObject.put("derive_poster_cid",derivePosterCid);
+                    }
+                    setCreatives.add(creativeObject);
+                }
+                params.put("creatives",setCreatives);
+            }
         }
         return params;
     }

+ 26 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java

@@ -0,0 +1,26 @@
+package cn.com.ctop.toutiao.modules.material.service.impl;
+
+import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
+import cn.com.ctop.toutiao.modules.material.mapper.BytedanceImageInfoMapper;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceImageInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 头条图片素材
+ * @author jeecg-boot
+ * @date   2020-08-01
+ * @version V1.0
+ */
+@Service
+public class BytedanceImageInfoServiceImpl extends ServiceImpl<BytedanceImageInfoMapper, BytedanceImageInfo> implements IBytedanceImageInfoService {
+    @Autowired
+    private BytedanceImageInfoMapper bytedanceImageInfoMapper;
+    @Override
+    public void replaceBatch(List<BytedanceImageInfo> videoInfoList) {
+        bytedanceImageInfoMapper.replaceBatch(videoInfoList);
+    }
+}