syh пре 5 година
родитељ
комит
1f3dcdcc1b
22 измењених фајлова са 714 додато и 3 уклоњено
  1. 5 0
      jeecg-boot-module-system/pom.xml
  2. 3 1
      jeecg-boot-module-system/src/main/java/org/jeecg/JeecgApplication.java
  3. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  4. 5 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/DramaItemInfoController.java
  5. 251 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaishouChannelRegInfoController.java
  6. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/DramaItemInfo.java
  7. 47 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/KuaishouChannelRegInfo.java
  8. 21 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouReportDailyGroupChannelCodeJob.java
  9. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/KuaishouChannelRegInfoMapper.java
  10. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/KuaishouChannelRegInfoMapper.xml
  11. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IDramaItemInfoService.java
  12. 16 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IKuaishouChannelRegInfoService.java
  13. 14 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/DramaItemInfoServiceImpl.java
  14. 40 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaishouChannelRegInfoServiceImpl.java
  15. 71 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/ExcelUtils.java
  16. 58 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/KuaishouChannelRegInfoExcelListener.java
  17. 37 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/SpringUtils.java
  18. 103 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouChannelRegInfoEntity.java
  19. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java
  20. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyGroupMapper.java
  21. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyGroupService.java
  22. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyGroupServiceImpl.java

+ 5 - 0
jeecg-boot-module-system/pom.xml

@@ -157,6 +157,11 @@
         <version>3.17</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>1.1.2-beat1</version>
+        </dependency>
 
         <dependency>
             <groupId>com.bstek.ureport</groupId>

+ 3 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/JeecgApplication.java

@@ -1,13 +1,14 @@
 package org.jeecg;
 
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.excelutil.SpringUtils;
 import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
 import org.springframework.core.env.Environment;
 import org.springframework.web.client.RestTemplate;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -20,6 +21,7 @@ import java.net.UnknownHostException;
 @SpringBootApplication
 @ComponentScan(basePackages = {"cn.com.ctop", "org.jeecg"})
 @Configuration
+@Import(SpringUtils.class)
 public class JeecgApplication {
     public static void main(String[] args) throws UnknownHostException {
         ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);

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

@@ -75,6 +75,9 @@ public class ShiroConfig {
 		filterChainDefinitionMap.put("/template/creative/words/get", "anon");
 		filterChainDefinitionMap.put("/appium/crawler/*", "anon");
 
+        filterChainDefinitionMap.put("/ctop/kuaishouChannelRegInfo/*", "anon");
+
+
 		//优化师相关
 		//filterChainDefinitionMap.put("/ctop/performanceOptimizer/detail", "anon");
 		//filterChainDefinitionMap.put("/ctop/performanceOptimizer/ranking/list", "anon");

+ 5 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/DramaItemInfoController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.Date;
 
 /**
  * 剧本内容信息
@@ -51,7 +52,7 @@ public class DramaItemInfoController {
         Result<IPage<DramaItemInfo>> result = new Result<IPage<DramaItemInfo>>();
         QueryWrapper<DramaItemInfo> queryWrapper = QueryGenerator.initQueryWrapper(dramaItemInfo, req.getParameterMap());
         Page<DramaItemInfo> page = new Page<DramaItemInfo>(pageNo, pageSize);
-        queryWrapper.orderByAsc("rank");
+        queryWrapper.orderByAsc("rank").orderByDesc("update_time");
         IPage<DramaItemInfo> pageList = dramaItemInfoService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
@@ -70,6 +71,8 @@ public class DramaItemInfoController {
     public Result<DramaItemInfo> add(@RequestBody DramaItemInfo dramaItemInfo) {
         Result<DramaItemInfo> result = new Result<>();
         try {
+            int rank = dramaItemInfoService.getMaxRankByDramaId(dramaItemInfo.getDramaId());
+            dramaItemInfo.setRank(rank);
             dramaItemInfoService.save(dramaItemInfo);
             result.success("添加成功!");
         } catch (Exception e) {
@@ -94,6 +97,7 @@ public class DramaItemInfoController {
         if (dramaItemInfoEntity == null) {
             result.error500("未找到对应实体");
         } else {
+            dramaItemInfo.setUpdateTime(new Date());
             boolean ok = dramaItemInfoService.updateById(dramaItemInfo);
             if (ok) {
                 result.success("修改成功!");

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

@@ -0,0 +1,251 @@
+package org.jeecg.modules.ctop.controller;
+
+import com.alibaba.excel.event.AnalysisEventListener;
+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.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ctop.entity.KuaishouChannelRegInfo;
+import org.jeecg.modules.ctop.service.IKuaishouChannelRegInfoService;
+import org.jeecg.modules.excelutil.ExcelUtils;
+import org.jeecg.modules.excelutil.KuaishouChannelRegInfoExcelListener;
+import org.jeecg.modules.excelutil.entity.KuaishouChannelRegInfoEntity;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+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.FileInputStream;
+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 2020-03-26
+ */
+@Slf4j
+@Api(tags = "快手渠道注册信息表")
+@RestController
+@RequestMapping("/ctop/kuaishouChannelRegInfo")
+public class KuaishouChannelRegInfoController {
+    @Autowired
+    private IKuaishouChannelRegInfoService kuaishouChannelRegInfoService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouChannelRegInfo
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手渠道注册信息表-分页列表查询")
+    @ApiOperation(value = "快手渠道注册信息表-分页列表查询", notes = "快手渠道注册信息表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouChannelRegInfo>> queryPageList(KuaishouChannelRegInfo kuaishouChannelRegInfo,
+                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                               HttpServletRequest req) {
+        Result<IPage<KuaishouChannelRegInfo>> result = new Result<IPage<KuaishouChannelRegInfo>>();
+        QueryWrapper<KuaishouChannelRegInfo> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouChannelRegInfo, req.getParameterMap());
+        Page<KuaishouChannelRegInfo> page = new Page<KuaishouChannelRegInfo>(pageNo, pageSize);
+        IPage<KuaishouChannelRegInfo> pageList = kuaishouChannelRegInfoService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouChannelRegInfo
+     * @return
+     */
+    @AutoLog(value = "快手渠道注册信息表-添加")
+    @ApiOperation(value = "快手渠道注册信息表-添加", notes = "快手渠道注册信息表-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouChannelRegInfo> add(@RequestBody KuaishouChannelRegInfo kuaishouChannelRegInfo) {
+        Result<KuaishouChannelRegInfo> result = new Result<KuaishouChannelRegInfo>();
+        try {
+            kuaishouChannelRegInfoService.save(kuaishouChannelRegInfo);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouChannelRegInfo
+     * @return
+     */
+    @AutoLog(value = "快手渠道注册信息表-编辑")
+    @ApiOperation(value = "快手渠道注册信息表-编辑", notes = "快手渠道注册信息表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouChannelRegInfo> edit(@RequestBody KuaishouChannelRegInfo kuaishouChannelRegInfo) {
+        Result<KuaishouChannelRegInfo> result = new Result<KuaishouChannelRegInfo>();
+        KuaishouChannelRegInfo kuaishouChannelRegInfoEntity = kuaishouChannelRegInfoService.getById(kuaishouChannelRegInfo.getId());
+        if (kuaishouChannelRegInfoEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouChannelRegInfoService.updateById(kuaishouChannelRegInfo);
+            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 {
+            kuaishouChannelRegInfoService.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<KuaishouChannelRegInfo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouChannelRegInfo> result = new Result<KuaishouChannelRegInfo>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouChannelRegInfoService.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<KuaishouChannelRegInfo> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouChannelRegInfo> result = new Result<KuaishouChannelRegInfo>();
+        KuaishouChannelRegInfo kuaishouChannelRegInfo = kuaishouChannelRegInfoService.getById(id);
+        if (kuaishouChannelRegInfo == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouChannelRegInfo);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouChannelRegInfo> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouChannelRegInfo kuaishouChannelRegInfo = JSON.parseObject(deString, KuaishouChannelRegInfo.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouChannelRegInfo, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouChannelRegInfo> pageList = kuaishouChannelRegInfoService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手渠道注册信息表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouChannelRegInfo.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) {
+        //1.读Excel
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            FileInputStream fis = null;
+            try {
+                MultipartFile file = entity.getValue();
+                fis = (FileInputStream) file.getInputStream();
+                AnalysisEventListener listener = new KuaishouChannelRegInfoExcelListener();
+                Boolean flag = ExcelUtils.readExcel(fis, KuaishouChannelRegInfoEntity.class, listener);
+                System.out.println("导入是否成功:" + flag);
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (fis != null) {
+                    try {
+                        fis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+        return Result.ok("文件导入成功!");
+    }
+
+}

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

@@ -39,6 +39,7 @@ public class DramaItemInfo {
     @Excel(name = "元素类型1:情节描述 2:对话", width = 15)
     @ApiModelProperty(value = "元素类型1:描述 2:对话")
     private Integer type;
+    private Integer plainSeq;
     /**
      * 剧本id
      */

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

@@ -0,0 +1,47 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.modules.excelutil.entity.KuaishouChannelRegInfoEntity;
+
+import java.util.Date;
+
+/**
+ * 快手渠道注册信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-03-26
+ */
+@TableName("ctop_kuaishou_channel_reg_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@Data
+public class KuaishouChannelRegInfo {
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    private String stateDate;
+    private String channelCode;
+    private Integer regNum;
+    private String perfectDataRate;
+    private String maleRatio;
+    private Date createTime;
+    private Date updateTime;
+
+    public KuaishouChannelRegInfo() {
+    }
+
+    public KuaishouChannelRegInfo(KuaishouChannelRegInfoEntity regInfoEntity) {
+        this.stateDate = regInfoEntity.getStateDate();
+        this.channelCode = regInfoEntity.getChannelCode() + "_" + regInfoEntity.getChildChannelCode();
+        this.regNum = regInfoEntity.getRegNum();
+        this.perfectDataRate = regInfoEntity.getPerfectDataRate();
+        this.maleRatio = regInfoEntity.getMaleRatio();
+        this.createTime = new Date();
+        this.updateTime = new Date();
+    }
+}

+ 21 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouReportDailyGroupChannelCodeJob.java

@@ -0,0 +1,21 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyGroupService;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+
+public class KuaishouReportDailyGroupChannelCodeJob implements Job {
+    @Autowired
+    private IKuaishouReportDailyGroupService groupService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        String date = DateUtils.formatDate(DateUtils.addDay(new Date(), -1));
+        groupService.formatChannelCode(date);
+    }
+}

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.KuaishouChannelRegInfo;
+
+/**
+ * 快手渠道注册信息表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-03-26
+ * @cersion: V1.0
+ */
+public interface KuaishouChannelRegInfoMapper extends BaseMapper<KuaishouChannelRegInfo> {
+
+}

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

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.ctop.mapper.KuaishouChannelRegInfoMapper">
+
+</mapper>

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

@@ -15,4 +15,6 @@ import java.util.List;
 public interface IDramaItemInfoService extends IService<DramaItemInfo> {
 
     List<DramaItemInfo> getByDramaId(Long dramaId);
+
+    int getMaxRankByDramaId(Long dramaId);
 }

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

@@ -0,0 +1,16 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.KuaishouChannelRegInfo;
+import org.jeecg.modules.excelutil.entity.KuaishouChannelRegInfoEntity;
+
+/**
+ * 快手渠道注册信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-03-26
+ */
+public interface IKuaishouChannelRegInfoService extends IService<KuaishouChannelRegInfo> {
+    void saveOrUpdateBychannelCodeAndDate(KuaishouChannelRegInfoEntity regInfo);
+}

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

@@ -29,7 +29,7 @@ public class DramaItemInfoServiceImpl extends ServiceImpl<DramaItemInfoMapper, D
     @Override
     public List<DramaItemInfo> getByDramaId(Long dramaId) {
         QueryWrapper<DramaItemInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("drama_id", dramaId).eq("enabled", 1).orderByAsc("rank");
+        queryWrapper.eq("drama_id", dramaId).eq("enabled", 1).orderByAsc("rank").orderByDesc("update_time");
         List<DramaItemInfo> infos = this.list(queryWrapper);
         List<DramaItemInfo> returnInfos = new ArrayList<>();
         if (null != infos && infos.size() > 0) {
@@ -43,4 +43,17 @@ public class DramaItemInfoServiceImpl extends ServiceImpl<DramaItemInfoMapper, D
         }
         return returnInfos;
     }
+
+    @Override
+    public int getMaxRankByDramaId(Long dramaId) {
+        QueryWrapper<DramaItemInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("drama_id", dramaId);
+        queryWrapper.orderByDesc("rank").last(" limit 1");
+        DramaItemInfo itemInfo = this.getOne(queryWrapper);
+        if (null == itemInfo) {
+            return 1;
+        } else {
+            return itemInfo.getRank() + 1;
+        }
+    }
 }

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

@@ -0,0 +1,40 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.KuaishouChannelRegInfo;
+import org.jeecg.modules.ctop.mapper.KuaishouChannelRegInfoMapper;
+import org.jeecg.modules.ctop.service.IKuaishouChannelRegInfoService;
+import org.jeecg.modules.excelutil.entity.KuaishouChannelRegInfoEntity;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * 快手渠道注册信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-03-26
+ */
+@Service
+public class KuaishouChannelRegInfoServiceImpl extends ServiceImpl<KuaishouChannelRegInfoMapper, KuaishouChannelRegInfo> implements IKuaishouChannelRegInfoService {
+
+    @Override
+    public void saveOrUpdateBychannelCodeAndDate(KuaishouChannelRegInfoEntity regInfo) {
+        QueryWrapper<KuaishouChannelRegInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("state_date", regInfo.getStateDate());
+        queryWrapper.eq("channel_code", regInfo.getChannelCode());
+        KuaishouChannelRegInfo getRegInfo = this.getOne(queryWrapper);
+        if (null == getRegInfo) {
+            getRegInfo = new KuaishouChannelRegInfo(regInfo);
+            this.save(getRegInfo);
+        } else {
+            getRegInfo.setRegNum(regInfo.getRegNum());
+            getRegInfo.setPerfectDataRate(regInfo.getPerfectDataRate());
+            getRegInfo.setMaleRatio(regInfo.getMaleRatio());
+            getRegInfo.setUpdateTime(new Date());
+            this.updateById(getRegInfo);
+        }
+    }
+}

+ 71 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/ExcelUtils.java

@@ -0,0 +1,71 @@
+package org.jeecg.modules.excelutil;
+
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.excel.metadata.BaseRowModel;
+import com.alibaba.excel.metadata.Sheet;
+import com.alibaba.excel.support.ExcelTypeEnum;
+
+import java.io.*;
+import java.util.List;
+
+public class ExcelUtils {
+    /**
+     * @param is    导入文件输入流
+     * @param clazz Excel实体映射类
+     * @return
+     */
+    public static Boolean readExcel(InputStream is, Class clazz, AnalysisEventListener listener) {
+        BufferedInputStream bis = null;
+        try {
+            bis = new BufferedInputStream(is);
+            // 解析每行结果在listener中处理
+            ExcelReader excelReader = EasyExcelFactory.getReader(bis, listener);
+            excelReader.read(new Sheet(1, 1, clazz));
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        } finally {
+            if (bis != null) {
+                try {
+                    bis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * @param os    文件输出流
+     * @param clazz Excel实体映射类
+     * @param data  导出数据
+     * @return
+     */
+    public static Boolean writeExcel(OutputStream os, Class clazz, List<? extends BaseRowModel> data) {
+        BufferedOutputStream bos = null;
+        try {
+            bos = new BufferedOutputStream(os);
+            ExcelWriter writer = new ExcelWriter(bos, ExcelTypeEnum.XLSX);
+            //写第一个sheet, sheet1  数据全是List<String> 无模型映射关系
+            Sheet sheet1 = new Sheet(1, 0, clazz);
+            writer.write(data, sheet1);
+            writer.finish();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return true;
+    }
+}

+ 58 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/KuaishouChannelRegInfoExcelListener.java

@@ -0,0 +1,58 @@
+package org.jeecg.modules.excelutil;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.service.impl.KuaishouChannelRegInfoServiceImpl;
+import org.jeecg.modules.excelutil.entity.KuaishouChannelRegInfoEntity;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class KuaishouChannelRegInfoExcelListener extends AnalysisEventListener {
+    //自定义用于暂时存储data。
+    //可以通过实例获取该值
+    private List<Object> datas = new ArrayList<Object>();
+
+    @Override
+    public void invoke(Object object, AnalysisContext context) {
+        //数据存储到list,供批量处理,或后续自己业务逻辑处理。
+        datas.add(object);
+        //根据自己业务做处理
+        doSomething(object);
+    }
+
+    private void doSomething(Object object) {
+        //入库调用接口
+        KuaishouChannelRegInfoEntity regInfo = (KuaishouChannelRegInfoEntity) object;
+        regInfo.setCreateTime(new Date());
+        regInfo.setUpdateTime(new Date());
+        regInfo.setChannelCode(regInfo.getChannelCode() + "_" + regInfo.getChildChannelCode());
+        String date = regInfo.getStateDate();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
+        try {
+            date = DateUtils.formatDate(dateFormat.parse(date));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        regInfo.setStateDate(date);
+        KuaishouChannelRegInfoServiceImpl regInfoService = SpringUtils.getApplicationContext().getBean(KuaishouChannelRegInfoServiceImpl.class);
+        regInfoService.saveOrUpdateBychannelCodeAndDate(regInfo);
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext context) {
+        // datas.clear();//解析结束销毁不用的资源
+    }
+
+    public List<Object> getDatas() {
+        return datas;
+    }
+
+    public void setDatas(List<Object> datas) {
+        this.datas = datas;
+    }
+}

+ 37 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/SpringUtils.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.excelutil;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class SpringUtils implements ApplicationContextAware {
+    private static ApplicationContext applicationContext = null;
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        if (SpringUtils.applicationContext == null) {
+            SpringUtils.applicationContext = applicationContext;
+        }
+    }
+
+
+    //获取applicationContext
+    public static ApplicationContext getApplicationContext() {
+        return applicationContext;
+    }
+
+    //通过name获取 Bean.
+    public static Object getBean(String name) {
+        return getApplicationContext().getBean(name);
+    }
+
+    //通过class获取Bean.
+    public static <T> T getBean(Class<T> clazz) {
+        return getApplicationContext().getBean(clazz);
+    }
+
+    //通过name,以及Clazz返回指定的Bean
+    public static <T> T getBean(String name, Class<T> clazz) {
+        return getApplicationContext().getBean(name, clazz);
+    }
+}

+ 103 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouChannelRegInfoEntity.java

@@ -0,0 +1,103 @@
+package org.jeecg.modules.excelutil.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+import com.baomidou.mybatisplus.annotation.TableField;
+
+import java.util.Date;
+
+public class KuaishouChannelRegInfoEntity extends BaseRowModel {
+    @ExcelProperty(index = 0, value = "统计日期")
+    private String stateDate;
+    @ExcelProperty(index = 1, value = "渠道号")
+    private String channelCode;
+    @ExcelProperty(index = 2, value = "子渠道")
+    @TableField(exist = false)
+    private String childChannelCode;
+    @ExcelProperty(index = 3, value = "注册数")
+    private Integer regNum;
+    @ExcelProperty(index = 4, value = "完善资料率")
+    private String perfectDataRate;
+    @ExcelProperty(index = 5, value = "男高占比")
+    private String maleRatio;
+    private Date createTime;
+    private Date updateTime;
+
+    public String getStateDate() {
+        return stateDate;
+    }
+
+    public void setStateDate(String stateDate) {
+        this.stateDate = stateDate;
+    }
+
+    public String getChannelCode() {
+        return channelCode;
+    }
+
+    public void setChannelCode(String channelCode) {
+        this.channelCode = channelCode;
+    }
+
+    public String getChildChannelCode() {
+        return childChannelCode;
+    }
+
+    public void setChildChannelCode(String childChannelCode) {
+        this.childChannelCode = childChannelCode;
+    }
+
+    public Integer getRegNum() {
+        return regNum;
+    }
+
+    public void setRegNum(Integer regNum) {
+        this.regNum = regNum;
+    }
+
+    public String getPerfectDataRate() {
+        return perfectDataRate;
+    }
+
+    public void setPerfectDataRate(String perfectDataRate) {
+        this.perfectDataRate = perfectDataRate;
+    }
+
+    public String getMaleRatio() {
+        return maleRatio;
+    }
+
+    public void setMaleRatio(String maleRatio) {
+        this.maleRatio = maleRatio;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        return "KuaishouChannelRegInfo{" +
+                "stateDate='" + stateDate + '\'' +
+                ", channelCode='" + channelCode + '\'' +
+                ", childChannelCode='" + childChannelCode + '\'' +
+                ", regNum=" + regNum +
+                ", perfectDataRate='" + perfectDataRate + '\'' +
+                ", maleRatio='" + maleRatio + '\'' +
+                ", createTime=" + createTime +
+                ", updateTime=" + updateTime +
+                '}';
+    }
+}

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

@@ -127,4 +127,6 @@ public class KuaishouReportDailyGroup implements Serializable {
     private Date createTime;
     @JsonProperty
     private Date updateTime;
+
+    private String channelCode;
 }

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

@@ -3,7 +3,13 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyGroup;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
 
 public interface KuaishouReportDailyGroupMapper extends BaseMapper<KuaishouReportDailyGroup> {
     void loadGroupDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
+
+    @Update("update ctop_kuaishou_report_daily_group " +
+            "set channel_code = substring_index(unit_name, '-', 1) " +
+            "where stat_date =#{date}")
+    void formatChannelCode(@Param("date") String date);
 }

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

@@ -4,4 +4,5 @@ import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyGroup;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 public interface IKuaishouReportDailyGroupService extends IService<KuaishouReportDailyGroup> {
+    void formatChannelCode(String date);
 }

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

@@ -4,8 +4,16 @@ import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyGroup;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyGroupMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyGroupService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
 public class KuaishouReportDailyGroupServiceImpl extends ServiceImpl<KuaishouReportDailyGroupMapper, KuaishouReportDailyGroup> implements IKuaishouReportDailyGroupService {
+    @Autowired
+    private KuaishouReportDailyGroupMapper groupMapper;
+
+    @Override
+    public void formatChannelCode(String date) {
+        groupMapper.formatChannelCode(date);
+    }
 }