소스 검색

智能托管批量创建

yumeng 3 년 전
부모
커밋
c557cb2683
13개의 변경된 파일2035개의 추가작업 그리고 12개의 파일을 삭제
  1. 4 12
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 289 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/controller/KuaishouHostingTaskController.java
  3. 242 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/controller/KuaishouHostingTemplateController.java
  4. 374 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTask.java
  5. 365 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTemplate.java
  6. 25 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/KuaishouHostingTaskMapper.java
  7. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/KuaishouHostingTemplateMapper.java
  8. 146 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/xml/KuaishouHostingTaskMapper.xml
  9. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/xml/KuaishouHostingTemplateMapper.xml
  10. 39 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/IKuaishouHostingTaskService.java
  11. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/IKuaishouHostingTemplateService.java
  12. 497 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/impl/KuaishouHostingTaskServiceImpl.java
  13. 19 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/impl/KuaishouHostingTemplateServiceImpl.java

+ 4 - 12
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -1,7 +1,6 @@
 package org.jeecg.config.shiro;
 
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
 import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
 import org.apache.shiro.mgt.DefaultSubjectDAO;
 import org.apache.shiro.mgt.SecurityManager;
@@ -9,29 +8,21 @@ import org.apache.shiro.spring.LifecycleBeanPostProcessor;
 import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
 import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
 import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
-import org.crazycake.shiro.IRedisManager;
 import org.crazycake.shiro.RedisCacheManager;
-import org.crazycake.shiro.RedisClusterManager;
 import org.crazycake.shiro.RedisManager;
-import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.config.shiro.filters.CustomShiroFilterFactoryBean;
 import org.jeecg.config.shiro.filters.JwtFilter;
 import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.DependsOn;
-import org.springframework.core.env.Environment;
-import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
 import org.springframework.util.StringUtils;
-import redis.clients.jedis.HostAndPort;
-import redis.clients.jedis.JedisCluster;
 
-import javax.annotation.Resource;
 import javax.servlet.Filter;
-import java.util.*;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 /**
  * @author: Scott
@@ -236,6 +227,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/rejected/audit/**", "anon");
 
         filterChainDefinitionMap.put("/cwjsSaleAssistantInfo/**", "anon");
+        filterChainDefinitionMap.put("/task/kuaishouHostingTask/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 289 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/controller/KuaishouHostingTaskController.java

@@ -0,0 +1,289 @@
+package cn.com.ctop.kuaishou.modules.hosting.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTask;
+import cn.com.ctop.kuaishou.modules.hosting.service.IKuaishouHostingTaskService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+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 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
+ * @version V1.0
+ * @date 2021-11-09
+ */
+@Slf4j
+@Api(tags = "智能托管-任务详情")
+@RestController
+@RequestMapping("/task/kuaishouHostingTask")
+public class KuaishouHostingTaskController {
+    @Autowired
+    private IKuaishouHostingTaskService kuaishouHostingTaskService;
+
+    @PostMapping(value = "/submitTask")
+    public Result<Object> submitTask(@RequestBody JSONObject requestJson) {
+        Result<Object> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long templateId = requestJson.getLong("templateId");
+            if (Check.isNull(templateId)) {
+                throw new Exception("请传入模板id");
+            }
+            JSONArray videoArray = requestJson.getJSONArray("videoArray");
+            if (Check.isNull(videoArray)) {
+                throw new Exception("请传入需创建的素材");
+            }
+            kuaishouHostingTaskService.submitTask(templateId, videoArray);
+
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500(e.getMessage());
+        }
+        return result;
+    }
+
+
+    @GetMapping(value = "/createHosting")
+    public Result<Object> createHosting(Long id) {
+        Result<Object> result = new Result<>();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("入参不能为空");
+            }
+            kuaishouHostingTaskService.updateStatusById(id, 2, "智能托管计划创建中");
+            kuaishouHostingTaskService.createHosting(id);
+
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouHostingTask
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "智能托管-任务详情-分页列表查询", notes = "智能托管-任务详情-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouHostingTask>> queryPageList(KuaishouHostingTask kuaishouHostingTask,
+                                                            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                            HttpServletRequest req) {
+        Result<IPage<KuaishouHostingTask>> result = new Result<>();
+        QueryWrapper<KuaishouHostingTask> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouHostingTask, req.getParameterMap());
+        Page<KuaishouHostingTask> page = new Page<KuaishouHostingTask>(pageNo, pageSize);
+        IPage<KuaishouHostingTask> pageList = kuaishouHostingTaskService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouHostingTask
+     * @return
+     */
+    @ApiOperation(value = "智能托管-任务详情-添加", notes = "智能托管-任务详情-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouHostingTask> add(@RequestBody KuaishouHostingTask kuaishouHostingTask) {
+        Result<KuaishouHostingTask> result = new Result<>();
+        try {
+            kuaishouHostingTaskService.save(kuaishouHostingTask);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouHostingTask
+     * @return
+     */
+    @ApiOperation(value = "智能托管-任务详情-编辑", notes = "智能托管-任务详情-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouHostingTask> edit(@RequestBody KuaishouHostingTask kuaishouHostingTask) {
+        Result<KuaishouHostingTask> result = new Result<KuaishouHostingTask>();
+        KuaishouHostingTask kuaishouHostingTaskEntity = kuaishouHostingTaskService.getById(kuaishouHostingTask.getId());
+        if (kuaishouHostingTaskEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouHostingTaskService.updateById(kuaishouHostingTask);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "智能托管-任务详情-通过id删除", notes = "智能托管-任务详情-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id") String id) {
+        try {
+            kuaishouHostingTaskService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "智能托管-任务详情-批量删除", notes = "智能托管-任务详情-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouHostingTask> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaishouHostingTask> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouHostingTaskService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "智能托管-任务详情-通过id查询", notes = "智能托管-任务详情-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouHostingTask> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouHostingTask> result = new Result<>();
+        KuaishouHostingTask kuaishouHostingTask = kuaishouHostingTaskService.getById(id);
+        if (kuaishouHostingTask == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouHostingTask);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouHostingTask> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouHostingTask kuaishouHostingTask = JSON.parseObject(deString, KuaishouHostingTask.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouHostingTask, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouHostingTask> pageList = kuaishouHostingTaskService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "智能托管-任务详情列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouHostingTask.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<KuaishouHostingTask> listKuaishouHostingTasks = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouHostingTask.class, params);
+                kuaishouHostingTaskService.saveBatch(listKuaishouHostingTasks);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouHostingTasks.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("文件导入失败!");
+    }
+
+}

+ 242 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/controller/KuaishouHostingTemplateController.java

@@ -0,0 +1,242 @@
+package cn.com.ctop.kuaishou.modules.hosting.controller;
+
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTemplate;
+import cn.com.ctop.kuaishou.modules.hosting.service.IKuaishouHostingTemplateService;
+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
+ * @version V1.0
+ * @date 2021-11-08
+ */
+@Slf4j
+@Api(tags = "智能托管模板")
+@RestController
+@RequestMapping("/hosting/kuaishouHostingTemplate")
+public class KuaishouHostingTemplateController {
+    @Autowired
+    private IKuaishouHostingTemplateService kuaishouHostingTemplateService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouHostingTemplate
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "智能托管模板-分页列表查询", notes = "智能托管模板-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouHostingTemplate>> queryPageList(KuaishouHostingTemplate kuaishouHostingTemplate,
+                                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                HttpServletRequest req) {
+        Result<IPage<KuaishouHostingTemplate>> result = new Result<>();
+        QueryWrapper<KuaishouHostingTemplate> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouHostingTemplate, req.getParameterMap());
+        queryWrapper.orderByDesc("create_time");
+        Page<KuaishouHostingTemplate> page = new Page<KuaishouHostingTemplate>(pageNo, pageSize);
+        IPage<KuaishouHostingTemplate> pageList = kuaishouHostingTemplateService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouHostingTemplate
+     * @return
+     */
+    @ApiOperation(value = "智能托管模板-添加", notes = "智能托管模板-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouHostingTemplate> add(@RequestBody KuaishouHostingTemplate kuaishouHostingTemplate) {
+        Result<KuaishouHostingTemplate> result = new Result<>();
+        try {
+            kuaishouHostingTemplateService.save(kuaishouHostingTemplate);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouHostingTemplate
+     * @return
+     */
+    @ApiOperation(value = "智能托管模板-编辑", notes = "智能托管模板-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouHostingTemplate> edit(@RequestBody KuaishouHostingTemplate kuaishouHostingTemplate) {
+        Result<KuaishouHostingTemplate> result = new Result<KuaishouHostingTemplate>();
+        KuaishouHostingTemplate kuaishouHostingTemplateEntity = kuaishouHostingTemplateService.getById(kuaishouHostingTemplate.getId());
+        if (kuaishouHostingTemplateEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouHostingTemplateService.updateById(kuaishouHostingTemplate);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "智能托管模板-通过id删除", notes = "智能托管模板-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id") String id) {
+        try {
+            kuaishouHostingTemplateService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "智能托管模板-批量删除", notes = "智能托管模板-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouHostingTemplate> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaishouHostingTemplate> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouHostingTemplateService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "智能托管模板-通过id查询", notes = "智能托管模板-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouHostingTemplate> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouHostingTemplate> result = new Result<>();
+        KuaishouHostingTemplate kuaishouHostingTemplate = kuaishouHostingTemplateService.getById(id);
+        if (kuaishouHostingTemplate == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouHostingTemplate);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouHostingTemplate> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouHostingTemplate kuaishouHostingTemplate = JSON.parseObject(deString, KuaishouHostingTemplate.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouHostingTemplate, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouHostingTemplate> pageList = kuaishouHostingTemplateService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "智能托管模板列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouHostingTemplate.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<KuaishouHostingTemplate> listKuaishouHostingTemplates = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouHostingTemplate.class, params);
+                kuaishouHostingTemplateService.saveBatch(listKuaishouHostingTemplates);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouHostingTemplates.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("文件导入失败!");
+    }
+
+}

+ 374 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTask.java

@@ -0,0 +1,374 @@
+package cn.com.ctop.kuaishou.modules.hosting.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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 org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 智能托管-任务详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-11-09
+ */
+@Data
+@TableName("ctop_kuaishou_hosting_task")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_hosting_task对象", description = "智能托管-任务详情")
+public class KuaishouHostingTask {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 模板ID
+     */
+    @Excel(name = "模板ID", width = 15)
+    @ApiModelProperty(value = "模板ID")
+    private Long templateId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 项目名称
+     */
+    @Excel(name = "项目名称", width = 15)
+    @ApiModelProperty(value = "项目名称")
+    private String name;
+    /**
+     * 营销场景
+     */
+    @Excel(name = "营销场景", width = 15)
+    @ApiModelProperty(value = "营销场景")
+    private Integer hostingScene;
+    /**
+     * 计划类型
+     */
+    @Excel(name = "计划类型", width = 15)
+    @ApiModelProperty(value = "计划类型")
+    private Integer campaignType;
+    /**
+     * APP ID
+     */
+    @Excel(name = "APP ID", width = 15)
+    @ApiModelProperty(value = "APP ID")
+    private Long appId;
+    /**
+     * 应用下载地址/落地页地址
+     */
+    @Excel(name = "应用下载地址/落地页地址", width = 15)
+    @ApiModelProperty(value = "应用下载地址/落地页地址")
+    private String webUri;
+    /**
+     * 优先从系统应用商店下载
+     */
+    @Excel(name = "优先从系统应用商店下载", width = 15)
+    @ApiModelProperty(value = "优先从系统应用商店下载")
+    private Integer useAppMarket;
+    /**
+     * 应用商店列表
+     */
+    @Excel(name = "应用商店列表", width = 15)
+    @ApiModelProperty(value = "应用商店列表")
+    private String appStore;
+    /**
+     * 贴纸id集合
+     */
+    @Excel(name = "贴纸id集合", width = 15)
+    @ApiModelProperty(value = "贴纸id集合")
+    private String stickerStyles;
+    /**
+     * 贴纸广告语集合
+     */
+    @Excel(name = "贴纸广告语集合", width = 15)
+    @ApiModelProperty(value = "贴纸广告语集合")
+    private String coverSlogans;
+    /**
+     * 行动号召按钮
+     */
+    @Excel(name = "行动号召按钮", width = 15)
+    @ApiModelProperty(value = "行动号召按钮")
+    private String actionBar;
+    /**
+     * 作品广告语集合
+     */
+    @Excel(name = "作品广告语集合", width = 15)
+    @ApiModelProperty(value = "作品广告语集合")
+    private String captions;
+    /**
+     * 第三方点击检测链接
+     */
+    @Excel(name = "第三方点击检测链接", width = 15)
+    @ApiModelProperty(value = "第三方点击检测链接")
+    private String clickUrl;
+    /**
+     * 第三方actionbar点击检测链接
+     */
+    @Excel(name = "第三方actionbar点击检测链接", width = 15)
+    @ApiModelProperty(value = "第三方actionbar点击检测链接")
+    private String actionbarClickUrl;
+    /**
+     * 自动生成视频 1:true 2:false
+     */
+    @Excel(name = "自动生成视频 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "自动生成视频 1:true 2:false")
+    private Integer autoCreatePhoto;
+
+    @Excel(name = "投放排期", width = 15)
+    @ApiModelProperty(value = "投放排期")
+    private String schedule;
+    /**
+     * 每日预算
+     */
+    @Excel(name = "每日预算", width = 15)
+    @ApiModelProperty(value = "每日预算")
+    private Long dayBudget;
+    /**
+     * 优化目标
+     */
+    @Excel(name = "优化目标", width = 15)
+    @ApiModelProperty(value = "优化目标")
+    private Integer ocpxActionType;
+    /**
+     * 优化目标出价
+     */
+    @Excel(name = "优化目标出价", width = 15)
+    @ApiModelProperty(value = "优化目标出价")
+    private Long cpaBid;
+    /**
+     * 深度优化目标
+     */
+    @Excel(name = "深度优化目标", width = 15)
+    @ApiModelProperty(value = "深度优化目标")
+    private Integer deepConversionType;
+    /**
+     * 深度优化目标出价
+     */
+    @Excel(name = "深度优化目标出价", width = 15)
+    @ApiModelProperty(value = "深度优化目标出价")
+    private Long deepConversionBid;
+    /**
+     * 建站页面id
+     */
+    @Excel(name = "建站页面id", width = 15)
+    @ApiModelProperty(value = "建站页面id")
+    private Long siteId;
+    /**
+     * 抽帧 1:true 2:false
+     */
+    @Excel(name = "抽帧 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "抽帧 1:true 2:false")
+    private Integer smartCover;
+    /**
+     * roi系数
+     */
+    @Excel(name = "roi系数", width = 15)
+    @ApiModelProperty(value = "roi系数")
+    private Double roiRatio;
+    /**
+     * 咨询组件id
+     */
+    @Excel(name = "咨询组件id", width = 15)
+    @ApiModelProperty(value = "咨询组件id")
+    private Long consultId;
+    /**
+     * 课程库id
+     */
+    @Excel(name = "课程库id", width = 15)
+    @ApiModelProperty(value = "课程库id")
+    private Long merchandiseId;
+    /**
+     * 商品类型
+     */
+    @Excel(name = "商品类型", width = 15)
+    @ApiModelProperty(value = "商品类型")
+    private Integer merchandiseType;
+    /**
+     * 素材挖掘 1:true 2:false
+     */
+    @Excel(name = "素材挖掘 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "素材挖掘 1:true 2:false")
+    private Integer assetMining;
+    /**
+     * 小说id
+     */
+    @Excel(name = "小说id", width = 15)
+    @ApiModelProperty(value = "小说id")
+    private Long fictionId;
+    /**
+     * 落地页类型
+     */
+    @Excel(name = "落地页类型", width = 15)
+    @ApiModelProperty(value = "落地页类型")
+    private Integer webUriType;
+    /**
+     * 最小年龄
+     */
+    @Excel(name = "最小年龄", width = 15)
+    @ApiModelProperty(value = "最小年龄")
+    private Integer minAge;
+    /**
+     * 最大年龄
+     */
+    @Excel(name = "最大年龄", width = 15)
+    @ApiModelProperty(value = "最大年龄")
+    private Integer maxAge;
+    /**
+     * 【18:表示18-23岁】【24:表示24-30岁】【31:表示31-40岁】【41:表示41-49岁】【50:表示50-100岁】
+     */
+    @Excel(name = "【18:表示18-23岁】【24:表示24-30岁】【31:表示31-40岁】【41:表示41-49岁】【50:表示50-100岁】", width = 15)
+    @ApiModelProperty(value = "【18:表示18-23岁】【24:表示24-30岁】【31:表示31-40岁】【41:表示41-49岁】【50:表示50-100岁】")
+    private String agesRange;
+    /**
+     * 定向人群id集合
+     */
+    @Excel(name = "定向人群id集合", width = 15)
+    @ApiModelProperty(value = "定向人群id集合")
+    private String population;
+    /**
+     * 排除人群id集合
+     */
+    @Excel(name = "排除人群id集合", width = 15)
+    @ApiModelProperty(value = "排除人群id集合")
+    private String excludePopulation;
+    /**
+     * 付费人群id集合
+     */
+    @Excel(name = "付费人群id集合", width = 15)
+    @ApiModelProperty(value = "付费人群id集合")
+    private String paidAudience;
+    /**
+     * 性别 "F"代表女性 "M"代表男性
+     */
+    @Excel(name = "性别 F代表女性 M代表男性", width = 15)
+    @ApiModelProperty(value = "性别 F代表女性 M代表男性")
+    private String gender;
+    /**
+     * 定向地域
+     */
+    @Excel(name = "定向地域", width = 15)
+    @ApiModelProperty(value = "定向地域")
+    private String regionIds;
+    /**
+     * 定向地域的人群类型
+     */
+    @Excel(name = "定向地域的人群类型", width = 15)
+    @ApiModelProperty(value = "定向地域的人群类型")
+    private String userType;
+    /**
+     * 智能扩量是否开启 1:true 2:false
+     */
+    @Excel(name = "智能扩量是否开启 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "智能扩量是否开启 1:true 2:false")
+    private Integer isOpen;
+    /**
+     * 是否允许打破年龄带限制 1:true 2:false
+     */
+    @Excel(name = "是否允许打破年龄带限制 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "是否允许打破年龄带限制 1:true 2:false")
+    private Integer noAgeBreak;
+    /**
+     * 是否允许打破性别限制 1:true 2:false
+     */
+    @Excel(name = "是否允许打破性别限制 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "是否允许打破性别限制 1:true 2:false")
+    private Integer noGenderBreak;
+    /**
+     * 是否允许打破地域限制 1:true 2:false
+     */
+    @Excel(name = "是否允许打破地域限制 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "是否允许打破地域限制 1:true 2:false")
+    private Integer noAreaBreak;
+    /**
+     * 操作系统 1: Android, 2: iOS, 0:不限
+     */
+    @Excel(name = "操作系统 1: Android, 2: iOS, 0:不限", width = 15)
+    @ApiModelProperty(value = "操作系统 1: Android, 2: iOS, 3:不限")
+    private Integer platformOs;
+    /**
+     * 版本
+     */
+    @Excel(name = "版本", width = 15)
+    @ApiModelProperty(value = "版本")
+    private Integer platformOv;
+    /**
+     * 过滤已转化人群
+     */
+    @Excel(name = "过滤已转化人群", width = 15)
+    @ApiModelProperty(value = "过滤已转化人群")
+    private Integer filterConvertedLevel;
+    /**
+     * 是否开启命名规则 1:truw 2:false
+     */
+    @Excel(name = "是否开启命名规则 1:truw 2:false", width = 15)
+    @ApiModelProperty(value = "是否开启命名规则 1:truw 2:false")
+    private Integer ruleEnable;
+    /**
+     * 计划命名规则
+     */
+    @Excel(name = "计划命名规则", width = 15)
+    @ApiModelProperty(value = "计划命名规则")
+    private String campaignNameRule;
+    /**
+     * 组命名规则
+     */
+    @Excel(name = "组命名规则", width = 15)
+    @ApiModelProperty(value = "组命名规则")
+    private String unitNameRule;
+    /**
+     * 创意命名规则
+     */
+    @Excel(name = "创意命名规则", width = 15)
+    @ApiModelProperty(value = "创意命名规则")
+    private String creativeNameRule;
+    /**
+     * 1:待创建 2:创建中 3:创建成功 4:创建失败
+     */
+    @Excel(name = "1:待创建 2:创建中 3:创建成功 4:创建失败", width = 15)
+    @ApiModelProperty(value = "1:待创建 2:创建中 3:创建成功 4:创建失败")
+    private Integer taskStatus;
+
+
+    private Long projectId;
+    private Long campaignId;
+    private String photoInfos;
+    /**
+     * 备注
+     */
+    @Excel(name = "备注", width = 15)
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 365 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTemplate.java

@@ -0,0 +1,365 @@
+package cn.com.ctop.kuaishou.modules.hosting.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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 org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 智能托管模板
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-11-08
+ */
+@Data
+@TableName("ctop_kuaishou_hosting_template")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_hosting_template对象", description = "智能托管模板")
+public class KuaishouHostingTemplate {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 创建人
+     */
+    @Excel(name = "创建人", width = 15)
+    @ApiModelProperty(value = "创建人")
+    private String userId;
+    /**
+     * 项目名称
+     */
+    @Excel(name = "项目名称", width = 15)
+    @ApiModelProperty(value = "项目名称")
+    private String name;
+    /**
+     * 营销场景
+     */
+    @Excel(name = "营销场景", width = 15)
+    @ApiModelProperty(value = "营销场景")
+    private Integer hostingScene;
+    /**
+     * 计划类型
+     */
+    @Excel(name = "计划类型", width = 15)
+    @ApiModelProperty(value = "计划类型")
+    private Integer campaignType;
+    /**
+     * APP ID
+     */
+    @Excel(name = "APP ID", width = 15)
+    @ApiModelProperty(value = "APP ID")
+    private Long appId;
+    /**
+     * 应用下载地址/落地页地址
+     */
+    @Excel(name = "应用下载地址/落地页地址", width = 15)
+    @ApiModelProperty(value = "应用下载地址/落地页地址")
+    private String webUri;
+    /**
+     * 优先从系统应用商店下载
+     */
+    @Excel(name = "优先从系统应用商店下载", width = 15)
+    @ApiModelProperty(value = "优先从系统应用商店下载")
+    private Integer useAppMarket;
+    /**
+     * 应用商店列表
+     */
+    @Excel(name = "应用商店列表", width = 15)
+    @ApiModelProperty(value = "应用商店列表")
+    private String appStore;
+    /**
+     * 贴纸id集合
+     */
+    @Excel(name = "贴纸id集合", width = 15)
+    @ApiModelProperty(value = "贴纸id集合")
+    private String stickerStyles;
+    /**
+     * 贴纸广告语集合
+     */
+    @Excel(name = "贴纸广告语集合", width = 15)
+    @ApiModelProperty(value = "贴纸广告语集合")
+    private String coverSlogans;
+    /**
+     * 行动号召按钮
+     */
+    @Excel(name = "行动号召按钮", width = 15)
+    @ApiModelProperty(value = "行动号召按钮")
+    private String actionBar;
+    /**
+     * 作品广告语集合
+     */
+    @Excel(name = "作品广告语集合", width = 15)
+    @ApiModelProperty(value = "作品广告语集合")
+    private String captions;
+    /**
+     * 第三方点击检测链接
+     */
+    @Excel(name = "第三方点击检测链接", width = 15)
+    @ApiModelProperty(value = "第三方点击检测链接")
+    private String clickUrl;
+    /**
+     * 第三方actionbar点击检测链接
+     */
+    @Excel(name = "第三方actionbar点击检测链接", width = 15)
+    @ApiModelProperty(value = "第三方actionbar点击检测链接")
+    private String actionbarClickUrl;
+    /**
+     * 自动生成视频 1:true 2:false
+     */
+    @Excel(name = "自动生成视频 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "自动生成视频 1:true 2:false")
+    private Integer autoCreatePhoto;
+    /**
+     * 投放排期
+     */
+    @Excel(name = "投放排期", width = 15)
+    @ApiModelProperty(value = "投放排期")
+    private String schedule;
+    /**
+     * 每日预算
+     */
+    @Excel(name = "每日预算", width = 15)
+    @ApiModelProperty(value = "每日预算")
+    private Long dayBudget;
+    /**
+     * 优化目标
+     */
+    @Excel(name = "优化目标", width = 15)
+    @ApiModelProperty(value = "优化目标")
+    private Integer ocpxActionType;
+    /**
+     * 优化目标出价
+     */
+    @Excel(name = "优化目标出价", width = 15)
+    @ApiModelProperty(value = "优化目标出价")
+    private Long cpaBid;
+    /**
+     * 深度优化目标
+     */
+    @Excel(name = "深度优化目标", width = 15)
+    @ApiModelProperty(value = "深度优化目标")
+    private Integer deepConversionType;
+    /**
+     * 深度优化目标出价
+     */
+    @Excel(name = "深度优化目标出价", width = 15)
+    @ApiModelProperty(value = "深度优化目标出价")
+    private Long deepConversionBid;
+    /**
+     * 建站页面id
+     */
+    @Excel(name = "建站页面id", width = 15)
+    @ApiModelProperty(value = "建站页面id")
+    private Long siteId;
+    /**
+     * 抽帧 1:true 2:false
+     */
+    @Excel(name = "抽帧 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "抽帧 1:true 2:false")
+    private Integer smartCover;
+    /**
+     * roi系数
+     */
+    @Excel(name = "roi系数", width = 15)
+    @ApiModelProperty(value = "roi系数")
+    private Double roiRatio;
+    /**
+     * 咨询组件id
+     */
+    @Excel(name = "咨询组件id", width = 15)
+    @ApiModelProperty(value = "咨询组件id")
+    private Long consultId;
+    /**
+     * 课程库id
+     */
+    @Excel(name = "课程库id", width = 15)
+    @ApiModelProperty(value = "课程库id")
+    private Long merchandiseId;
+    /**
+     * 商品类型
+     */
+    @Excel(name = "商品类型", width = 15)
+    @ApiModelProperty(value = "商品类型")
+    private Integer merchandiseType;
+    /**
+     * 素材挖掘 1:true 2:false
+     */
+    @Excel(name = "素材挖掘 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "素材挖掘 1:true 2:false")
+    private Integer assetMining;
+    /**
+     * 小说id
+     */
+    @Excel(name = "小说id", width = 15)
+    @ApiModelProperty(value = "小说id")
+    private Long fictionId;
+    /**
+     * 落地页类型
+     */
+    @Excel(name = "落地页类型", width = 15)
+    @ApiModelProperty(value = "落地页类型")
+    private Integer webUriType;
+    /**
+     * 最小年龄
+     */
+    @Excel(name = "最小年龄", width = 15)
+    @ApiModelProperty(value = "最小年龄")
+    private Integer minAge;
+    /**
+     * 最大年龄
+     */
+    @Excel(name = "最大年龄", width = 15)
+    @ApiModelProperty(value = "最大年龄")
+    private Integer maxAge;
+    /**
+     * 【18:表示18-23岁】【24:表示24-30岁】【31:表示31-40岁】【41:表示41-49岁】【50:表示50-100岁】
+     */
+    @Excel(name = "【18:表示18-23岁】【24:表示24-30岁】【31:表示31-40岁】【41:表示41-49岁】【50:表示50-100岁】", width = 15)
+    @ApiModelProperty(value = "【18:表示18-23岁】【24:表示24-30岁】【31:表示31-40岁】【41:表示41-49岁】【50:表示50-100岁】")
+    private String agesRange;
+    /**
+     * 定向人群id集合
+     */
+    @Excel(name = "定向人群id集合", width = 15)
+    @ApiModelProperty(value = "定向人群id集合")
+    private String population;
+    /**
+     * 排除人群id集合
+     */
+    @Excel(name = "排除人群id集合", width = 15)
+    @ApiModelProperty(value = "排除人群id集合")
+    private String excludePopulation;
+    /**
+     * 付费人群id集合
+     */
+    @Excel(name = "付费人群id集合", width = 15)
+    @ApiModelProperty(value = "付费人群id集合")
+    private String paidAudience;
+    /**
+     * 性别 "F"代表女性 "M"代表男性
+     */
+    @Excel(name = "性别 F代表女性 M代表男性", width = 15)
+    @ApiModelProperty(value = "性别 F代表女性 M代表男性")
+    private String gender;
+    /**
+     * 定向地域
+     */
+    @Excel(name = "定向地域", width = 15)
+    @ApiModelProperty(value = "定向地域")
+    private String regionIds;
+    /**
+     * 定向地域的人群类型
+     */
+    @Excel(name = "定向地域的人群类型", width = 15)
+    @ApiModelProperty(value = "定向地域的人群类型")
+    private String userType;
+    /**
+     * 智能扩量是否开启 1:true 2:false
+     */
+    @Excel(name = "智能扩量是否开启 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "智能扩量是否开启 1:true 2:false")
+    private Integer isOpen;
+    /**
+     * 是否允许打破年龄带限制 1:true 2:false
+     */
+    @Excel(name = "是否允许打破年龄带限制 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "是否允许打破年龄带限制 1:true 2:false")
+    private Integer noAgeBreak;
+    /**
+     * 是否允许打破性别限制 1:true 2:false
+     */
+    @Excel(name = "是否允许打破性别限制 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "是否允许打破性别限制 1:true 2:false")
+    private Integer noGenderBreak;
+    /**
+     * 是否允许打破地域限制 1:true 2:false
+     */
+    @Excel(name = "是否允许打破地域限制 1:true 2:false", width = 15)
+    @ApiModelProperty(value = "是否允许打破地域限制 1:true 2:false")
+    private Integer noAreaBreak;
+    /**
+     * 操作系统 1: Android, 2: iOS, 0:不限
+     */
+    @Excel(name = "操作系统 1: Android, 2: iOS, 0:不限", width = 15)
+    @ApiModelProperty(value = "操作系统 1: Android, 2: iOS, 0:不限")
+    private Integer platformOs;
+    /**
+     * 版本
+     */
+    @Excel(name = "版本", width = 15)
+    @ApiModelProperty(value = "版本")
+    private Integer platformOv;
+    /**
+     * 过滤已转化人群
+     */
+    @Excel(name = "过滤已转化人群", width = 15)
+    @ApiModelProperty(value = "过滤已转化人群")
+    private Integer filterConvertedLevel;
+    /**
+     * 是否开启命名规则 1:truw 2:false
+     */
+    @Excel(name = "是否开启命名规则 1:truw 2:false", width = 15)
+    @ApiModelProperty(value = "是否开启命名规则 1:truw 2:false")
+    private Integer ruleEnable;
+    /**
+     * 计划命名规则
+     */
+    @Excel(name = "计划命名规则", width = 15)
+    @ApiModelProperty(value = "计划命名规则")
+    private String campaignNameRule;
+    /**
+     * 组命名规则
+     */
+    @Excel(name = "组命名规则", width = 15)
+    @ApiModelProperty(value = "组命名规则")
+    private String unitNameRule;
+    /**
+     * 创意命名规则
+     */
+    @Excel(name = "创意命名规则", width = 15)
+    @ApiModelProperty(value = "创意命名规则")
+    private String creativeNameRule;
+    /**
+     * 每个智能托管匹配视频数量
+     */
+    @Excel(name = "每个智能托管匹配视频数量", width = 15)
+    @ApiModelProperty(value = "每个智能托管匹配视频数量")
+    private Integer videoCount;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 25 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/KuaishouHostingTaskMapper.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.kuaishou.modules.hosting.mapper;
+
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTask;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 智能托管-任务详情
+ *
+ * @author jeecg-boot
+ * 2021-11-09
+ * @version V1.0
+ */
+public interface KuaishouHostingTaskMapper extends BaseMapper<KuaishouHostingTask> {
+
+    void addBatch(@Param("addList") List<KuaishouHostingTask> addList);
+
+    void updateStatusById(@Param("id") Long id, @Param("taskStatus") Integer taskStatus, @Param("remarks") String remarks);
+
+    Integer getMaterialType(@Param("photoId") Long photoId);
+
+    void updateInfoById(@Param("id") Long id, @Param("projectId") Long projectId, @Param("campaignId") Long campaignId, @Param("taskStatus") Integer taskStatus, @Param("remarks") String remarks);
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/KuaishouHostingTemplateMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.hosting.mapper;
+
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTemplate;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 智能托管模板
+ *
+ * @author jeecg-boot
+ * 2021-11-08
+ * @version V1.0
+ */
+public interface KuaishouHostingTemplateMapper extends BaseMapper<KuaishouHostingTemplate> {
+
+}

+ 146 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/xml/KuaishouHostingTaskMapper.xml

@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.hosting.mapper.KuaishouHostingTaskMapper">
+
+    <insert id="addBatch">
+        insert into ctop_kuaishou_hosting_task(
+        template_id,
+        project_id,
+        account_id,
+        `name`,
+        hosting_scene,
+        campaign_type,
+        app_id,
+        web_uri,
+        use_app_market,
+        app_store,
+        sticker_styles,
+        cover_slogans,
+        action_bar,
+        captions,
+        click_url,
+        actionbar_click_url,
+        auto_create_photo,
+        schedule,
+        day_budget,
+        ocpx_action_type,
+        cpa_bid,
+        deep_conversion_type,
+        deep_conversion_bid,
+        site_id,
+        smart_cover,
+        roi_ratio,
+        consult_id,
+        merchandise_id,
+        merchandise_type,
+        asset_mining,
+        fiction_id,
+        web_uri_type,
+        min_age,
+        max_age,
+        ages_range,
+        population,
+        exclude_population,
+        paid_audience,
+        gender,
+        region_ids,
+        user_type,
+        is_open,
+        no_age_break,
+        no_gender_break,
+        no_area_break,
+        platform_os,
+        platform_ov,
+        filter_converted_level,
+        rule_enable,
+        campaign_name_rule,
+        unit_name_rule,
+        creative_name_rule,
+        photo_infos,
+        task_status,
+        remarks
+        )
+        values
+        <foreach collection="addList" item="add" separator=",">
+            (
+            #{add.templateId},
+            #{add.projectId},
+            #{add.accountId},
+            #{add.name},
+            #{add.hostingScene},
+            #{add.campaignType},
+            #{add.appId},
+            #{add.webUri},
+            #{add.useAppMarket},
+            #{add.appStore},
+            #{add.stickerStyles},
+            #{add.coverSlogans},
+            #{add.actionBar},
+            #{add.captions},
+            #{add.clickUrl},
+            #{add.actionbarClickUrl},
+            #{add.autoCreatePhoto},
+            #{add.schedule},
+            #{add.dayBudget},
+            #{add.ocpxActionType},
+            #{add.cpaBid},
+            #{add.deepConversionType},
+            #{add.deepConversionBid},
+            #{add.siteId},
+            #{add.smartCover},
+            #{add.roiRatio},
+            #{add.consultId},
+            #{add.merchandiseId},
+            #{add.merchandiseType},
+            #{add.assetMining},
+            #{add.fictionId},
+            #{add.webUriType},
+            #{add.minAge},
+            #{add.maxAge},
+            #{add.agesRange},
+            #{add.population},
+            #{add.excludePopulation},
+            #{add.paidAudience},
+            #{add.gender},
+            #{add.regionIds},
+            #{add.userType},
+            #{add.isOpen},
+            #{add.noAgeBreak},
+            #{add.noGenderBreak},
+            #{add.noAreaBreak},
+            #{add.platformOs},
+            #{add.platformOv},
+            #{add.filterConvertedLevel},
+            #{add.ruleEnable},
+            #{add.campaignNameRule},
+            #{add.unitNameRule},
+            #{add.creativeNameRule},
+            #{add.photoInfos},
+            #{add.taskStatus},
+            #{add.remarks}
+            )
+        </foreach>
+
+    </insert>
+    <update id="updateStatusById">
+        update ctop_kuaishou_hosting_task
+        set task_status = #{taskStatus},
+        remarks = #{remarks}
+        where id = #{id}
+    </update>
+    <update id="updateInfoById">
+        update ctop_kuaishou_hosting_task
+        set
+        project_id = #{projectId},
+        campaign_id = #{campaignId},
+        task_status = #{taskStatus},
+        remarks = #{remarks}
+        where id = #{id}
+    </update>
+    <select id="getMaterialType" resultType="java.lang.Integer">
+        select  material_type from ctop_kuaishou_video_get
+        where photo_id = #{photoId}
+        limit 1
+
+    </select>
+</mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/xml/KuaishouHostingTemplateMapper.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="cn.com.ctop.kuaishou.modules.hosting.mapper.KuaishouHostingTemplateMapper">
+
+</mapper>

+ 39 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/IKuaishouHostingTaskService.java

@@ -0,0 +1,39 @@
+package cn.com.ctop.kuaishou.modules.hosting.service;
+
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTask;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 智能托管-任务详情
+ *
+ * @author jeecg-boot
+ * 2021-11-09
+ * @version V1.0
+ */
+public interface IKuaishouHostingTaskService extends IService<KuaishouHostingTask> {
+
+    /**
+     * 任务提交
+     *
+     * @param templateId
+     * @param videoArray
+     */
+    void submitTask(Long templateId, JSONArray videoArray) throws Exception;
+
+    /**
+     * 创建智能托管
+     *
+     * @param id
+     */
+    void createHosting(Long id);
+
+    /**
+     * 修改任务状态
+     *
+     * @param id
+     * @param taskStatus
+     * @param remarks
+     */
+    void updateStatusById(Long id, Integer taskStatus, String remarks);
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/IKuaishouHostingTemplateService.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.hosting.service;
+
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTemplate;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 智能托管模板
+ *
+ * @author jeecg-boot
+ * 2021-11-08
+ * @version V1.0
+ */
+public interface IKuaishouHostingTemplateService extends IService<KuaishouHostingTemplate> {
+
+}

+ 497 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/impl/KuaishouHostingTaskServiceImpl.java

@@ -0,0 +1,497 @@
+package cn.com.ctop.kuaishou.modules.hosting.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTask;
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTemplate;
+import cn.com.ctop.kuaishou.modules.hosting.mapper.KuaishouHostingTaskMapper;
+import cn.com.ctop.kuaishou.modules.hosting.service.IKuaishouHostingTaskService;
+import cn.com.ctop.kuaishou.modules.hosting.service.IKuaishouHostingTemplateService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.RedisUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 智能托管-任务详情
+ *
+ * @author jeecg-boot
+ * 2021-11-09
+ * @version V1.0
+ */
+@Slf4j
+@Service
+public class KuaishouHostingTaskServiceImpl extends ServiceImpl<KuaishouHostingTaskMapper, KuaishouHostingTask> implements IKuaishouHostingTaskService {
+    @Autowired
+    private IKuaishouHostingTemplateService hostingTemplateService;
+    @Autowired
+    private RedisUtil redisUtil;
+    private static String hostingKey = "hosting";
+    @Autowired
+    private KuaishouHostingTaskMapper hostingTaskMapper;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    private HashMap<Integer, JSONObject> ageMap = new HashMap<>();
+
+    @Override
+    public void submitTask(Long templateId, JSONArray videoArray) throws Exception {
+        KuaishouHostingTemplate template = hostingTemplateService.getById(templateId);
+        if (Check.isNull(template)) {
+            throw new Exception("未匹配到模板信息");
+        }
+        List<List<Object>> videoList = Lists.partition(videoArray, template.getVideoCount());
+        List<KuaishouHostingTask> addList = new ArrayList<>();
+        for (int i = 0; i < videoList.size(); i++) {
+            List<Object> videoInfo = videoList.get(i);
+            if (Check.isNull(videoInfo)) {
+                continue;
+            }
+            KuaishouHostingTask task = new KuaishouHostingTask();
+            task.setTemplateId(templateId);
+            task.setAccountId(template.getAccountId());
+            task.setTaskStatus(1);
+            task.setRemarks("待创建");
+            task.setPhotoInfos(videoInfo.toString());
+            task.setName(getName(template.getName()));
+            task.setHostingScene(template.getHostingScene());
+            task.setCampaignType(template.getCampaignType());
+            if (!Check.isNull(template.getAppId())) {
+                task.setAppId(template.getAppId());
+            }
+            if (!Check.isNull(template.getWebUri())) {
+                task.setWebUri(template.getWebUri());
+            }
+            task.setUseAppMarket(template.getUseAppMarket());
+            if (!Check.isNull(template.getAppStore())) {
+                task.setAppStore(template.getAppStore());
+            }
+            if (!Check.isNull(template.getStickerStyles())) {
+                task.setStickerStyles(template.getStickerStyles());
+            }
+            if (!Check.isNull(template.getCoverSlogans())) {
+                task.setCoverSlogans(template.getCoverSlogans());
+            }
+            task.setActionBar(template.getActionBar());
+            task.setCaptions(template.getCaptions());
+            task.setClickUrl(template.getClickUrl());
+            task.setActionbarClickUrl(template.getActionbarClickUrl());
+            task.setAutoCreatePhoto(template.getAutoCreatePhoto());
+            task.setSchedule(template.getSchedule());
+            task.setDayBudget(template.getDayBudget());
+            task.setOcpxActionType(template.getOcpxActionType());
+            task.setCpaBid(template.getCpaBid());
+            if (!Check.isNull(template.getDeepConversionType())) {
+                task.setDeepConversionType(template.getDeepConversionType());
+            }
+            if (!Check.isNull(template.getDeepConversionBid())) {
+                task.setDeepConversionBid(template.getDeepConversionBid());
+            }
+            if (!Check.isNull(template.getSiteId())) {
+                task.setSiteId(template.getSiteId());
+            }
+            task.setSmartCover(template.getSmartCover());
+            if (!Check.isNull(template.getRoiRatio())) {
+                task.setRoiRatio(template.getRoiRatio());
+            }
+            if (!Check.isNull(template.getConsultId())) {
+                task.setConsultId(template.getConsultId());
+            }
+            if (!Check.isNull(template.getMerchandiseId())) {
+                task.setMerchandiseId(template.getMerchandiseId());
+            }
+            if (!Check.isNull(template.getMerchandiseType())) {
+                task.setMerchandiseType(template.getMerchandiseType());
+            }
+            task.setAssetMining(template.getAssetMining());
+            task.setFictionId(template.getFictionId());
+            task.setWebUriType(template.getWebUriType());
+            task.setMaxAge(template.getMaxAge());
+            task.setMinAge(template.getMinAge());
+            task.setAgesRange(template.getAgesRange());
+            task.setPopulation(template.getPopulation());
+            task.setExcludePopulation(template.getExcludePopulation());
+            task.setPaidAudience(template.getPaidAudience());
+            task.setGender(template.getGender());
+            task.setRegionIds(template.getRegionIds());
+            task.setUserType(template.getUserType());
+            task.setIsOpen(template.getIsOpen());
+            task.setNoAgeBreak(template.getNoAgeBreak());
+            task.setNoGenderBreak(template.getNoGenderBreak());
+            task.setNoAreaBreak(template.getNoAreaBreak());
+            task.setPlatformOs(template.getPlatformOs());
+            task.setPlatformOv(template.getPlatformOv());
+            task.setFilterConvertedLevel(template.getFilterConvertedLevel());
+            task.setRuleEnable(template.getRuleEnable());
+            task.setCampaignNameRule(getCampaignName(template.getCampaignNameRule()));
+            task.setUnitNameRule(template.getUnitNameRule());
+            task.setCreativeNameRule(template.getCreativeNameRule());
+            addList.add(task);
+        }
+        if (!Check.isNull(addList)) {
+            hostingTaskMapper.addBatch(addList);
+        }
+    }
+
+    @Override
+    public void createHosting(Long id) {
+        try {
+            KuaishouHostingTask task = hostingTaskMapper.selectById(id);
+            if (Check.isNull(task)) {
+                log.error("未获取到智能托管创建详情,id:{}", id);
+                return;
+            }
+            String photoInfos = task.getPhotoInfos();
+            JSONArray photoArray = JSONArray.parseArray(photoInfos);
+            if (Check.isNull(photoArray)) {
+                hostingTaskMapper.updateStatusById(task.getId(), 4, "未获取到视频信息");
+                log.error("未获取到视频信息,id:{}", id);
+                return;
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(task.getAccountId());
+            if (Check.isNull(token)) {
+                hostingTaskMapper.updateStatusById(task.getId(), 4, "未获取到账户授权信息");
+                log.error("智能托管未获取到相关token,accountId:{}", task.getAccountId());
+                return;
+            }
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", task.getAccountId());
+            requestJson.put("name", task.getName());
+            requestJson.put("hosting_scene", task.getHostingScene());
+            requestJson.put("campaign_type", task.getCampaignType());
+            if (!Check.isNull(task.getAppId())) {
+                requestJson.put("app_id", task.getAppId());
+            }
+            if (!Check.isNull(task.getWebUri())) {
+                requestJson.put("web_uri", task.getWebUri());
+            }
+            if (task.getUseAppMarket() == 1) {
+                requestJson.put("use_app_market", true);
+                if (!Check.isNull(task.getAppStore())) {
+                    requestJson.put("app_store", JSONArray.parseArray(task.getAppStore()));
+                }
+            } else {
+                requestJson.put("use_app_market", false);
+            }
+            if (!Check.isNull(task.getStickerStyles())) {
+                requestJson.put("sticker_styles", JSONArray.parseArray(task.getStickerStyles()));
+            }
+            if (!Check.isNull(task.getCoverSlogans())) {
+                requestJson.put("cover_slogans", JSONArray.parseArray(task.getCoverSlogans()));
+            }
+            requestJson.put("action_bar", task.getActionBar());
+            if (!Check.isNull(task.getCaptions())) {
+                requestJson.put("captions", JSONArray.parseArray(task.getCaptions()));
+            }
+            requestJson.put("click_url", task.getClickUrl());
+            if (!Check.isNull(task.getActionbarClickUrl())) {
+                requestJson.put("actionbar_click_url", task.getActionbarClickUrl());
+            }
+            if (task.getAutoCreatePhoto() == 1) {
+                requestJson.put("auto_create_photo", true);
+            } else {
+                requestJson.put("auto_create_photo", false);
+            }
+            Long begin_time = System.currentTimeMillis();
+            requestJson.put("begin_time", begin_time);
+            requestJson.put("end_time", 0);
+            if (!Check.isNull(task.getSchedule())) {
+                requestJson.put("schedule", JSONArray.parseArray(task.getSchedule()));
+            }
+            requestJson.put("day_budget", task.getDayBudget());
+            requestJson.put("ocpx_action_type", task.getOcpxActionType());
+            requestJson.put("cpa_bid", task.getCpaBid());
+            if (!Check.isNull(task.getDeepConversionType())) {
+                requestJson.put("deep_conversion_type", task.getDeepConversionType());
+            }
+            if (!Check.isNull(task.getDeepConversionBid())) {
+                requestJson.put("deep_conversion_bid", task.getDeepConversionBid());
+            }
+            if (!Check.isNull(task.getSiteId())) {
+                requestJson.put("site_id", task.getSiteId());
+            }
+            if (task.getSmartCover() == 1) {
+                requestJson.put("smart_cover", true);
+            } else {
+                requestJson.put("smart_cover", false);
+            }
+            if (!Check.isNull(task.getRoiRatio())) {
+                requestJson.put("roi_ratio", task.getRoiRatio());
+            }
+            if (!Check.isNull(task.getConsultId())) {
+                requestJson.put("consult_id", task.getConsultId());
+            }
+            if (!Check.isNull(task.getMerchandiseId())) {
+                requestJson.put("merchandise_id", task.getMerchandiseId());
+            }
+            if (!Check.isNull(task.getMerchandiseType())) {
+                requestJson.put("merchandise_type", task.getMerchandiseType());
+            }
+            if (task.getAssetMining() == 1) {
+                requestJson.put("asset_mining", true);
+            } else {
+                requestJson.put("asset_mining", false);
+            }
+            if (!Check.isNull(task.getFictionId())) {
+                requestJson.put("fiction_id", task.getFictionId());
+            }
+            if (!Check.isNull(task.getWebUriType())) {
+                requestJson.put("web_uri_type", task.getWebUriType());
+            }
+            /*---------    命名规则  ---------*/
+            JSONObject nameRule = new JSONObject();
+            if (task.getRuleEnable() == 1) {
+                nameRule.put("rule_enable", true);
+                if (!Check.isNull(task.getCampaignNameRule())) {
+                    nameRule.put("campaign_name_rule", task.getCampaignNameRule());
+                }
+                if (!Check.isNull(task.getUnitNameRule())) {
+                    nameRule.put("unit_name_rule", task.getUnitNameRule());
+                }
+                if (!Check.isNull(task.getCreativeNameRule())) {
+                    nameRule.put("creative_name_rule", task.getCreativeNameRule());
+                }
+            } else {
+                nameRule.put("rule_enable", false);
+            }
+            requestJson.put("name_rule", nameRule);
+            /*---------    定向拼接  ---------*/
+            JSONObject adDspTarget = new JSONObject();
+            Integer minAge = task.getMinAge();
+            Integer maxAge = task.getMaxAge();
+            JSONArray ageArray = new JSONArray();
+            if (!Check.isNull(minAge) && !Check.isNull(maxAge)) {
+                JSONObject ageJson = new JSONObject();
+                ageJson.put("min", minAge);
+                ageJson.put("max", maxAge);
+                ageArray.add(ageJson);
+            } else {
+                String agesRange = task.getAgesRange();
+                JSONArray agesRangeArray = JSONArray.parseArray(agesRange);
+                if (!Check.isNull(agesRangeArray)) {
+                    ageArray = getAgeArray(agesRangeArray);
+                }
+            }
+            adDspTarget.put("age", ageArray);
+            if (!Check.isNull(task.getPopulation())) {
+                adDspTarget.put("population", JSONArray.parseArray(task.getPopulation()));
+            }
+            if (!Check.isNull(task.getExcludePopulation())) {
+                adDspTarget.put("exclude_population", JSONArray.parseArray(task.getExcludePopulation()));
+            }
+            if (!Check.isNull(task.getPaidAudience())) {
+                adDspTarget.put("paid_audience", JSONArray.parseArray(task.getPaidAudience()));
+            }
+            String gender = task.getGender();
+            if (!Check.isNull(gender)) {
+                adDspTarget.put("gender", gender);
+            }
+            if (!Check.isNull(task.getRegionIds())) {
+                adDspTarget.put("region_ids", JSONArray.parseArray(task.getRegionIds()));
+                if (!Check.isNull(JSONArray.parseArray(task.getRegionIds()))) {
+                    adDspTarget.put("user_type", task.getUserType());
+                }
+            }
+            if (task.getIsOpen() == 1) {
+                JSONObject intelliExtend = new JSONObject();
+                intelliExtend.put("isOpen", task.getIsOpen());
+                if (task.getNoAgeBreak() == 1) {
+                    intelliExtend.put("noAgeBreak", true);
+                } else {
+                    intelliExtend.put("noAgeBreak", false);
+                }
+                if (task.getNoGenderBreak() == 1) {
+                    intelliExtend.put("noGenderBreak", true);
+                } else {
+                    intelliExtend.put("noGenderBreak", false);
+                }
+                if (task.getNoAreaBreak() == 1) {
+                    intelliExtend.put("noAreaBreak", true);
+                } else {
+                    intelliExtend.put("noAreaBreak", false);
+                }
+                adDspTarget.put("intelli_extend", intelliExtend);
+            }
+            Integer platformOs = task.getPlatformOs();
+            if (platformOs != 3) {
+                String platformStr = null;
+                if (platformOs == 1) {
+                    platformStr = "android";
+                } else if (platformOs == 2) {
+                    platformStr = "ios";
+                }
+                JSONObject platformJson = new JSONObject();
+                JSONObject ovJson = new JSONObject();
+                ovJson.put("min", task.getPlatformOv());
+                platformJson.put(platformStr, ovJson);
+                adDspTarget.put("platform", platformJson);
+            } else {
+                adDspTarget.put("platform", "{}");
+            }
+            adDspTarget.put("filter_converted_level", task.getFilterConvertedLevel());
+            requestJson.put("ad_dsp_target", adDspTarget);
+            /*---------    视频组装  ---------*/
+            JSONArray videoInfo = getPhotoArray(photoArray);
+            requestJson.put("photo_infos", videoInfo);
+            JSONObject hosting = createHosting(task.getAccountId(), token.getAccessToken(), requestJson);
+            if (!Check.isNull(hosting)) {
+                Integer code = hosting.getInteger("code");
+                Long projectId = null;
+                Long campaignId = null;
+                if (code == 0) {
+                    log.info("智能托管创建成功,accountId:{},返回信息:{}", task.getAccountId(), hosting);
+                    JSONObject data = hosting.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        projectId = data.getLong("project_id");
+                        if (!Check.isNull(projectId)) {
+                            campaignId = getProjectDetail(task.getAccountId(), token.getAccessToken(), projectId);
+                        }
+                    }
+                    hostingTaskMapper.updateInfoById(task.getId(), projectId, campaignId, 3, "创建成功");
+                } else {
+                    log.error("智能托管创建失败,accountId:{},入参:{}。返回:{}", task.getAccountId(), requestJson, hosting);
+                    hostingTaskMapper.updateStatusById(task.getId(), 3, hosting.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            hostingTaskMapper.updateStatusById(id, 3, e.getMessage());
+        }
+    }
+
+    @Override
+    public void updateStatusById(Long id, Integer taskStatus, String remarks) {
+        hostingTaskMapper.updateStatusById(id, taskStatus, remarks);
+    }
+
+    private String getName(String name) {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd").replace("-", "");
+        String redisKey = hostingKey + "_" + nowDate;
+        Object o = redisUtil.get(redisKey);
+        Integer count;
+        if (Check.isNull(o)) {
+            count = 0;
+            redisUtil.set(redisKey, 0, 86400L);
+        } else {
+            count = (Integer) o + 1;
+            redisUtil.set(redisKey, count, 86400L);
+        }
+        return name + "_" + nowDate + "_" + count;
+    }
+
+    private String getCampaignName(String name) {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd").replace("-", "");
+        String redisKey = hostingKey + "_" + nowDate;
+        Object o = redisUtil.get(redisKey);
+        Integer count;
+        if (Check.isNull(o)) {
+            count = 0;
+        } else {
+            count = (Integer) o;
+        }
+        return name + "_" + nowDate + "_" + count;
+    }
+
+    private JSONArray getAgeArray(JSONArray ageArray) {
+        JSONArray returnArray = new JSONArray();
+        if (Check.isNullMap(ageMap)) {
+            JSONObject array18 = new JSONObject();
+            array18.put("min", 18);
+            array18.put("max", 23);
+            ageMap.put(18, array18);
+
+            JSONObject array24 = new JSONObject();
+            array24.put("min", 24);
+            array24.put("max", 30);
+            ageMap.put(24, array24);
+
+            JSONObject array31 = new JSONObject();
+            array31.put("min", 31);
+            array31.put("max", 40);
+            ageMap.put(31, array31);
+
+            JSONObject array41 = new JSONObject();
+            array41.put("min", 41);
+            array41.put("max", 49);
+            ageMap.put(41, array41);
+
+            JSONObject array50 = new JSONObject();
+            array50.put("min", 50);
+            array50.put("max", 100);
+            ageMap.put(50, array50);
+        }
+
+        for (int i = 0; i < ageArray.size(); i++) {
+            Integer age = ageArray.getInteger(i);
+            returnArray.add(ageMap.get(age));
+        }
+        return returnArray;
+    }
+
+    private JSONArray getPhotoArray(JSONArray photoArray) {
+        JSONArray videoArray = new JSONArray();
+        for (int i = 0; i < photoArray.size(); i++) {
+            Long photoId = photoArray.getLong(i);
+            if (Check.isNull(photoId)) {
+                continue;
+            }
+          /*  Integer materialType = hostingTaskMapper.getMaterialType(photoId);
+            if (Check.isNull(materialType)) {
+                continue;
+            }*/
+            JSONObject videoJson = new JSONObject();
+            videoJson.put("photo_id", photoId);
+            videoJson.put("photo_orientation", 1);
+            videoArray.add(videoJson);
+        }
+        return videoArray;
+    }
+
+
+    private JSONObject createHosting(Long accountId, String token, JSONObject requestJson) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/gw/dsp/v1/hosting/project/create";
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        return resultJson;
+    }
+
+
+    private Long getProjectDetail(Long accountId, String token, Long projectId) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/gw/dsp/v1/hosting/project/detail";
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        JSONObject requestJson = new JSONObject();
+        requestJson.put("project_id", projectId);
+        requestJson.put("advertiser_id", accountId);
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject data = resultJson.getJSONObject("data");
+                if (!Check.isNull(data)) {
+                    return data.getLong("campaign_id");
+                }
+            } else {
+                log.error("获取智能托管详情数据失败,入参:{},返回信息:{}", requestJson, resultJson);
+                return null;
+            }
+        }
+        return null;
+    }
+}

+ 19 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/impl/KuaishouHostingTemplateServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.hosting.service.impl;
+
+import cn.com.ctop.kuaishou.modules.hosting.entity.KuaishouHostingTemplate;
+import cn.com.ctop.kuaishou.modules.hosting.mapper.KuaishouHostingTemplateMapper;
+import cn.com.ctop.kuaishou.modules.hosting.service.IKuaishouHostingTemplateService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 智能托管模板
+ *
+ * @author jeecg-boot
+ * 2021-11-08
+ * @version V1.0
+ */
+@Service
+public class KuaishouHostingTemplateServiceImpl extends ServiceImpl<KuaishouHostingTemplateMapper, KuaishouHostingTemplate> implements IKuaishouHostingTemplateService {
+
+}