Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

syh vor 4 Jahren
Ursprung
Commit
ecdf03a092
26 geänderte Dateien mit 1728 neuen und 86 gelöschten Zeilen
  1. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 7 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  3. 7 5
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  4. 20 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysUserDepart.java
  5. 7 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml
  6. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java
  7. 77 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java
  8. 403 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouCrowdPackController.java
  9. 134 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouCrowdPack.java
  10. 41 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouCrowdPackMapper.java
  11. 344 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouCrowdPackMapper.xml
  12. 31 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouCrowdPackService.java
  13. 277 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouCrowdPackServiceImpl.java
  14. 7 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouAccountBudgetService.java
  15. 5 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  16. 9 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouPopulationService.java
  17. 30 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouAccountBudgetServiceImpl.java
  18. 52 29
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouPopulationServiceImpl.java
  19. 11 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsVideoReportCtrl.java
  20. 176 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouDimensionReportController.java
  21. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  22. 28 22
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KsVideoReportMapper.xml
  23. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  24. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouDimensionReportService.java
  25. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouDimensionReportServiceImpl.java
  26. 5 2
      module-kuaishou/src/main/resources/json_template/kuaishou_video_report_filed_dict.json

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

@@ -102,6 +102,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/kuaishouChannelRegInfo/*", "anon");
         filterChainDefinitionMap.put("/ctop/byteDance/homePage/report/*", "anon");
         filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
+        filterChainDefinitionMap.put("/dimension/report/*", "anon");
 
         filterChainDefinitionMap.put("/v1/**", "anon");
 
@@ -196,6 +197,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/kuaishou/videoReport/*", "anon");
         filterChainDefinitionMap.put("/ai/create/*", "anon");
         //filterChainDefinitionMap.put("/overView/*", "anon");
+        filterChainDefinitionMap.put("/kuaishouCrowdPack/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 7 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -352,6 +352,7 @@ public class SysUserController {
     public Result<SysUser> edit(@RequestBody JSONObject jsonObject) {
         Result<SysUser> result = new Result<SysUser>();
         try {
+            //根据id查询用户信息
             SysUser sysUser = sysUserService.getById(jsonObject.getString("id"));
             sysBaseAPI.addLog("编辑用户,id: " + jsonObject.getString("id"), CommonConstant.LOG_TYPE_2, 2);
             if (sysUser == null) {
@@ -360,18 +361,19 @@ public class SysUserController {
                 SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
                 user.setLeaderName(user.getLeaderName().trim());
                 user.setUpdateTime(new Date());
+                user.setLeaderName(user.getLeaderName().trim());
                 //String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt());
                 user.setPassword(sysUser.getPassword());
-                String roles = jsonObject.getString("selectedroles");
-                String departs = jsonObject.getString("selecteddeparts");
+                String roles = jsonObject.getString("selectedroles");//用户角色
+                String departs = jsonObject.getString("selecteddeparts");//用户部门
                 if (!Check.isNull(departs)) {
                     SysDepart depart = departService.getById(departs);
                     if (!Check.isNull(depart)) {
                         user.setOrgCode(depart.getOrgCode());
                     }
                 }
-                sysUserService.editUserWithRole(user, roles);
-                sysUserService.editUserWithDepart(user, departs);
+                sysUserService.editUserWithRole(user, roles);//修改角色
+                sysUserService.editUserWithDepart(user, departs);//修改部门
                 sysUserService.updateNullPhoneEmail();
 
                 userCompanyService.addOrUpdateUserWithCompany(user);
@@ -385,7 +387,7 @@ public class SysUserController {
                                 memberQueryWrapper.eq("user_id", user.getId());
                                 ProjectMember updateMember = new ProjectMember();
                                 updateMember.setRoleCode(sysRole.getRoleCode());
-                                memberService.update(updateMember, memberQueryWrapper);
+                                memberService.update(updateMember, memberQueryWrapper);//更新项目人员角色信息
                             }
                         }
                     };

+ 7 - 5
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -402,13 +402,13 @@ public class SampleTest {
         //汇创 人员
 //        wechatUserInfoService.getUserList();
 //        //考勤记录
-//        wechatCheckinDataService.getCheckinData("2020-11-01 00:00:00", "2020-12-01 23:59:59");
+//        wechatCheckinDataService.getCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
         //异常记录
-//        wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "0");
+        wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "0");
         //优容
-        wechatUserInfoService.getYRUserList();
-        wechatCheckinDataService.getYRCheckinData("2020-11-01 00:00:00", "2020-11-30 23:59:59");
-        wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "1");
+//        wechatUserInfoService.getYRUserList();
+//        wechatCheckinDataService.getYRCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
+        wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "1");
     }
 
     @Autowired
@@ -556,4 +556,6 @@ public class SampleTest {
         etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate());
     }
 
+
+
 }

+ 20 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/SysUserDepart.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.Date;
 
 @Data
 @TableName("sys_user_depart")
@@ -19,6 +20,25 @@ public class SysUserDepart implements Serializable {
 	private String userId;
 	/**部门id*/
 	private String depId;
+
+	/**
+	 * 创建时间
+	 */
+	private Date createTime;
+	/**
+	 * 创建人id
+	 */
+	private String createUserId;
+
+
+	public SysUserDepart(String id, String userId, String depId, Date createTime, String createUserId) {
+		this.id = id;
+		this.userId = userId;
+		this.depId = depId;
+		this.createTime = createTime;
+		this.createUserId = createUserId;
+	}
+
 	public SysUserDepart(String id, String userId, String depId) {
 		super();
 		this.id = id;

+ 7 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml

@@ -276,8 +276,10 @@ SELECT
             role.role_code = 'designTeamLeader'
     </select>
 
+    <!-- 查询用户列表-->
     <select id="queryPageList" resultType="cn.com.ctop.common.module.entity.SysUser">
-        SELECT t1.*,t3.depart_name ,role.role_name
+        SELECT t4.* from (
+        SELECT t1.*,t3.depart_name ,role.role_name,t2.create_time AS updTime
         FROM sys_user t1
         LEFT JOIN sys_user_depart t2 ON t1.id = t2.user_id
         LEFT JOIN sys_depart t3 ON t2.dep_id = t3.id
@@ -311,6 +313,10 @@ SELECT
         <if test="sex != null and sex != ''">
             AND t1.sex =#{sex}
         </if>
+        ORDER BY updTime DESC
+        limit 99999
+        ) t4
+        GROUP BY t4.id
     </select>
     <select id="getUserMapByMap" resultType="com.alibaba.fastjson.JSONObject">
         select id,realname from sys_user

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java

@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CacheConstant;
 import org.jeecg.common.constant.CommonConstant;
@@ -372,9 +373,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     public void addUserWithDepart(SysUser user, String selectedParts) {
 //		this.save(user);  //保存角色的时候已经添加过一次了
         if (oConvertUtils.isNotEmpty(selectedParts)) {
+            LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             String[] arr = selectedParts.split(",");
             for (String deaprtId : arr) {
                 SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId);
+                userDeaprt.setCreateUserId(loginUser.getId());
+                userDeaprt.setCreateTime(new Date());//添加创建时间 和 创建人id
                 sysUserDepartMapper.insert(userDeaprt);
             }
         }
@@ -406,11 +410,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 }
             }
         }
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //先删后加
         sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
         if (oConvertUtils.isNotEmpty(departs)) {
             for (String departId : arr) {
                 SysUserDepart userDepart = new SysUserDepart(user.getId(), departId);
+                userDepart.setCreateUserId(loginUser.getId());
+                userDepart.setCreateTime(new Date());
                 sysUserDepartMapper.insert(userDepart);
             }
         }

+ 77 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java

@@ -0,0 +1,77 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+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.kuaishou.modules.ai.entity.KuaishouCrowdPack;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class CrowdListQueryJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private KuaishouCrowdPackMapper crowdPackMapper;
+    @Autowired
+    private IKuaishouPopulationService iKuaishouPopulationService;
+    @Autowired
+    private IKuaishouCrowdPackService crowdPackService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+    @XxlJob("crowdListQueryJob")
+    public void execute() {
+        List<Integer> list = new ArrayList<>();
+        for (int i = 0; i <= 7; i++) {
+            if (i != 2) {
+                list.add(i);
+            }
+        }
+        list.forEach(status -> executorService.submit(() -> {
+            List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
+            for (KuaishouCrowdPack crowdPack : crowdList) {
+                CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
+                JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), status);
+                if (jsonObject.getInteger("code") == 0) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        JSONArray details = data.getJSONArray("details");
+                        if (details.size() > 0) {
+                            for (int j = 0; j < details.size(); j++) {
+                                JSONObject obj = details.getJSONObject(j);
+                                if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
+                                    KuaishouCrowdPack oldPack = crowdPackMapper.queryByAccountId(null, obj.getLong("orientation_id"));
+                                    KuaishouCrowdPack crowdPackEntity = JSONObject.toJavaObject(obj, KuaishouCrowdPack.class);
+                                    if (!Check.isNull(oldPack)) {
+                                        crowdPackEntity.setStatDate(oldPack.getStatDate());
+                                        crowdPackEntity.setUrl(oldPack.getUrl());
+                                        crowdPackEntity.setSignature(oldPack.getSignature());
+                                        crowdPackEntity.setMessage("PUSH OK");
+                                        crowdPackEntity.setDataStatus(1);
+                                    }
+                                    crowdPackService.save(crowdPackEntity);
+                                } else {
+                                    crowdPackMapper.update(obj);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }));
+        XxlJobHelper.log("快手人群报表更新成功");
+    }
+}

+ 403 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouCrowdPackController.java

@@ -0,0 +1,403 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
+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.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.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+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-03-26
+ */
+@Slf4j
+@Api(tags = "人群报表")
+@RestController
+@RequestMapping("/kuaishouCrowdPack")
+public class KuaishouCrowdPackController {
+    @Autowired
+    private IKuaishouCrowdPackService kuaishouCrowdPackService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouCrowdPack
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "人群报表-分页列表查询")
+    @ApiOperation(value = "人群报表-分页列表查询", notes = "人群报表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouCrowdPack>> list(KuaishouCrowdPack kuaishouCrowdPack,
+                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                 HttpServletRequest req) {
+        Result<IPage<KuaishouCrowdPack>> result = new Result<>();
+        QueryWrapper<KuaishouCrowdPack> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCrowdPack, req.getParameterMap());
+        Page<KuaishouCrowdPack> page = new Page<KuaishouCrowdPack>(pageNo, pageSize);
+        IPage<KuaishouCrowdPack> pageList = kuaishouCrowdPackService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 人群包列表
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/queryPageList")
+    public Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack,
+                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouCrowdPackService.queryPageList(kuaishouCrowdPack, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 相关账户查询
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/queryRel")
+    public Result<Object> queryRel(String type, String signature,
+                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(type) || Check.isNull(signature)) {
+                return Result.error("缺失参数");
+            }
+            return kuaishouCrowdPackService.queryRel(type, signature, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询原因
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/queryFailReason")
+    public Result<Object> queryFailReason(String signature,
+                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouCrowdPackService.queryFailReason(signature, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 上传前的人群包校验
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/checkCrowdPackage")
+    public Result<Object> checkCrowdPackage(String signature) {
+        try {
+            return kuaishouCrowdPackService.checkCrowdPackage(signature);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 上传人群包
+     *
+     * @param kuaishouCrowdPack
+     * @return
+     */
+
+    @PostMapping(value = "/uploadCrowdPack")
+    public Result<Object> uploadCrowdPack(@RequestBody JSONObject request) {
+        Integer type = request.getInteger("type");
+        String orientationName = request.getString("orientationName");
+        Long accountId = request.getLong("accountId");
+        String url = request.getString("url");
+        try {
+            if (Check.isNull(type) || Check.isNull(orientationName) || Check.isNull(url) || Check.isNull(accountId)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouCrowdPackService.uploadCrowdPack(type, orientationName, accountId, url);
+        } catch (Exception e) {
+            log.error("上传异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("上传失败");
+    }
+
+    /**
+     * 账户推送
+     *
+     * @param kuaishouCrowdPack
+     * @return
+     */
+    @AutoLog(value = "账户推送")
+    @ApiOperation(value = "账户推送", notes = "账户推送")
+    @PostMapping(value = "/accountPush")
+    public Result<Object> accountPush(@RequestBody JSONObject request) {
+        try {
+            JSONArray accountIds = request.getJSONArray("accountIds");
+            String signature = request.getString("signature");
+            if (Check.isNull(accountIds) || Check.isNull(signature)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouCrowdPackService.accountPush(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @RequestMapping(value = "/crowdListQuery")
+    public Result<Object> crowdListQuery() {
+        try {
+            kuaishouCrowdPackService.crowdListQuery();
+            return Result.ok("success");
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouCrowdPack
+     * @return
+     */
+    @AutoLog(value = "人群报表-添加")
+    @ApiOperation(value = "人群报表-添加", notes = "人群报表-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouCrowdPack> add(@RequestBody KuaishouCrowdPack kuaishouCrowdPack) {
+        Result<KuaishouCrowdPack> result = new Result<>();
+        try {
+            kuaishouCrowdPackService.save(kuaishouCrowdPack);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouCrowdPack
+     * @return
+     */
+    @AutoLog(value = "人群报表-编辑")
+    @ApiOperation(value = "人群报表-编辑", notes = "人群报表-编辑")
+    @PostMapping(value = "/edit")
+    public Result<KuaishouCrowdPack> edit(@RequestBody KuaishouCrowdPack kuaishouCrowdPack) {
+        Result<KuaishouCrowdPack> result = new Result<KuaishouCrowdPack>();
+        KuaishouCrowdPack kuaishouCrowdPackEntity = kuaishouCrowdPackService.getById(kuaishouCrowdPack.getId());
+        if (kuaishouCrowdPackEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouCrowdPackService.updateById(kuaishouCrowdPack);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "人群报表-通过id删除")
+    @ApiOperation(value = "人群报表-通过id删除", notes = "人群报表-通过id删除")
+    @GetMapping(value = "/delete")
+    public Result<Object> delete(KuaishouCrowdPack kuaishouCrowdPack) {
+        KuaishouCrowdPack kuaishouCrowdPackEntity = kuaishouCrowdPackService.getById(kuaishouCrowdPack.getId());
+        if (kuaishouCrowdPackEntity == null) {
+            return Result.error("未找到对应实体");
+        } else {
+            kuaishouCrowdPackEntity.setDataStatus(0);
+            return kuaishouCrowdPackService.updateDataStatus(kuaishouCrowdPackEntity);
+        }
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "人群报表-批量删除")
+    @ApiOperation(value = "人群报表-批量删除", notes = "人群报表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouCrowdPack> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouCrowdPack> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouCrowdPackService.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<KuaishouCrowdPack> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouCrowdPack> result = new Result<>();
+        KuaishouCrowdPack kuaishouCrowdPack = kuaishouCrowdPackService.getById(id);
+        if (kuaishouCrowdPack == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouCrowdPack);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouCrowdPack> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouCrowdPack kuaishouCrowdPack = JSON.parseObject(deString, KuaishouCrowdPack.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCrowdPack, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouCrowdPack> pageList = kuaishouCrowdPackService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "人群报表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouCrowdPack.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<KuaishouCrowdPack> listKuaishouCrowdPacks = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouCrowdPack.class, params);
+                kuaishouCrowdPackService.saveBatch(listKuaishouCrowdPacks);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouCrowdPacks.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("文件导入失败!");
+    }
+
+}

+ 134 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouCrowdPack.java

@@ -0,0 +1,134 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+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;
+
+/**
+ * 人群报表
+ * package
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-03-26
+ */
+@Data
+@TableName("ctop_kuaishou_crowd_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_crowd_package对象", description = "人群报表")
+public class KuaishouCrowdPack {
+
+    /**
+     * 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 statDate;
+    /**
+     * 人群包ID
+     */
+    @Excel(name = "人群包ID", width = 15)
+    @ApiModelProperty(value = "人群包ID")
+    private Long orientationId;
+    /**
+     * 人群包名称
+     */
+    @Excel(name = "人群包名称", width = 15)
+    @ApiModelProperty(value = "人群包名称")
+    private String orientationName;
+    /**
+     * 链接
+     */
+    private String url;
+    /**
+     * 数据状态'0 删除,1 有效'
+     */
+    private Integer dataStatus;
+    /**
+     * 执行结果反馈
+     */
+    private String message;
+    /**
+     * MD5
+     */
+    private String signature;
+    /**
+     * 人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...
+     */
+    @Excel(name = "人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...", width = 15)
+    @ApiModelProperty(value = "人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...")
+    private String populationType;
+    /**
+     * 匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5
+     */
+    @Excel(name = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5", width = 15)
+    @ApiModelProperty(value = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5")
+    private Integer type;
+    /**
+     * 状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效
+     */
+    @Excel(name = "状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效", width = 15)
+    @ApiModelProperty(value = "状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效")
+    private Integer status;
+    /**
+     * 覆盖人群
+     */
+    @Excel(name = "覆盖人群", width = 15)
+    @ApiModelProperty(value = "覆盖人群")
+    private Long coverNum;
+    /**
+     * 上传数量
+     */
+    @Excel(name = "上传数量", width = 15)
+    @ApiModelProperty(value = "上传数量")
+    private Long recordSize;
+    /**
+     * 匹配数量
+     */
+    @Excel(name = "匹配数量", width = 15)
+    @ApiModelProperty(value = "匹配数量")
+    private Long matchSize;
+    /**
+     * 创建时间
+     */
+    @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;
+
+    @TableField(exist = false)
+    private String accountName;
+}

+ 41 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouCrowdPackMapper.java

@@ -0,0 +1,41 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 人群报表
+ *
+ * @author: jeecg-boot
+ * @date: 2021-03-26
+ * @cersion: V1.0
+ */
+public interface KuaishouCrowdPackMapper extends BaseMapper<KuaishouCrowdPack> {
+
+    Long getTotal(@Param(value = "status") Integer status, @Param(value = "accountId") Long accountId, @Param(value = "orientationName") String orientationName);
+
+    List<JSONObject> queryPageList(@Param(value = "status") Integer status, @Param(value = "accountId") Long accountId, @Param(value = "orientationName") String orientationName);
+
+    List<KuaishouCrowdPack> queryListByStatus();
+
+    List<JSONObject> queryFailReason(@Param(value = "signature") String signature);
+
+    List<JSONObject> queryRelAccounts(@Param(value = "signature") String signature);
+
+    List<JSONObject> queryRelProject(@Param(value = "signature") String signature);
+
+    void replaceBatch(@Param(value = "list") List<KuaishouCrowdPack> list);
+
+    Integer queryProjectCount(@Param(value = "signature") String signature);
+
+    KuaishouCrowdPack queryByAccountId(@Param(value = "accountId") Long accountId, @Param(value = "orientationId") Long orientationId);
+
+    Integer queryAccountCount(@Param(value = "signature") String signature);
+
+    void update(JSONObject obj);
+}

+ 344 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouCrowdPackMapper.xml

@@ -0,0 +1,344 @@
+<?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.ai.mapper.KuaishouCrowdPackMapper">
+
+    <select id="getTotal" resultType="java.lang.Long">
+        SELECT  IFNULL(COUNT(1),0) FROM(
+        SELECT 1
+        FROM ctop_kuaishou_crowd_package t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE t1.`status` is not null
+        AND t1.`status`!=2
+        and t1.data_status = 1
+        AND t1.signature is not null
+        <if test="orientationName !=null">
+            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
+        </if>
+        <if test="accountId !=null">
+            AND t2.account_id = #{accountId}
+        </if>
+        <if test="status !=null">
+            AND t1.`status` =#{status}
+        </if>
+        GROUP BY t1.signature
+        ) t
+    </select>
+
+    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.id,
+        t1.account_id as 'accountId',
+        t2.auth_name as 'accountName',
+        IFNULL(stat_date,'') as 'statDate',
+        IFNULL(t1.orientation_id,'') as 'orientationId',
+        IFNULL(orientation_name,'') as 'orientationName',
+        IFNULL(url,'') as 'url',
+        IFNULL(population_type,'') as 'populationType',
+        IFNULL(t1.type,'') as 'type',
+        CASE t1.type
+        WHEN 1 THEN 'IMEI'
+        WHEN 2 THEN 'IDFA'
+        WHEN 3 THEN 'IMEI_MD5'
+        WHEN 4 THEN 'IDFA_MD5'
+        WHEN 5 THEN '手机号-MD5'
+        WHEN 7 THEN 'OAID'
+        WHEN 8 THEN 'OAID_MD5'
+        ELSE ''
+        END as 'typeStr',
+        <if test="status ==null">
+            t4.statusStr,
+            t4.`status`,
+        </if>
+        <if test="status !=null">
+            t1.`status`,
+            CASE t1.`status`
+            WHEN 0 THEN '计算中'
+            WHEN 1 THEN '已生效'
+            WHEN 3 THEN '推送中'
+            WHEN 4 THEN '已推送'
+            WHEN 5 THEN '计算失败'
+            WHEN 6 THEN '推送失败'
+            WHEN 7 THEN '已失效'
+            ELSE ''
+            END as 'statusStr',
+        </if>
+        IFNULL(t1.signature,'') as 'signature',
+        IFNULL(cover_num,0) as 'coverNum'
+        FROM ctop_kuaishou_crowd_package t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN (
+        SELECT t.signature ,COUNT(1) as 'num' FROM (SELECT DISTINCT signature, t2.project_id FROM
+        ctop_kuaishou_crowd_package t1
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where orientation_id is not null
+        GROUP BY project_id) t
+        ) t3 ON t1.signature = t3.signature
+        left join
+        (
+        SELECT signature,
+        CASE maxlevel
+        WHEN 66 THEN '计算中'
+        WHEN 77 THEN '已生效'
+        WHEN 88 THEN '推送中'
+        WHEN 99 THEN '已推送'
+        WHEN 33 THEN '计算失败'
+        WHEN 44 THEN '推送失败'
+        WHEN 55 THEN '已失效'
+        ELSE ''
+        END as 'statusStr',
+        CASE maxlevel
+        WHEN 66 THEN 0
+        WHEN 77 THEN 1
+        WHEN 88 THEN 3
+        WHEN 99 THEN 4
+        WHEN 33 THEN 5
+        WHEN 44 THEN 6
+        WHEN 55 THEN 7
+        ELSE -1
+        END as 'status'
+        FROM (
+        SELECT signature,max(level) as 'maxlevel' FROM (
+        SELECT signature,
+        CASE t1.`status`
+        WHEN 0 THEN 66
+        WHEN 1 THEN 77
+        WHEN 3 THEN 88
+        WHEN 4 THEN 99
+        WHEN 5 THEN 33
+        WHEN 6 THEN 44
+        WHEN 7 THEN 55
+        ELSE ''
+        END as 'level'
+        FROM ctop_kuaishou_crowd_package t1
+        where signature IN(
+        SELECT signature
+        FROM ctop_kuaishou_crowd_package t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE t1.`status` is not null
+        AND t1.`status`!=2
+        and t1.data_status = 1
+        AND t1.signature is not null
+        <if test="orientationName !=null">
+            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
+        </if>
+        <if test="accountId !=null">
+            AND t2.account_id =#{accountId}
+        </if>
+        GROUP BY t1.signature
+        )
+        GROUP BY t1.signature,`status`
+        )t1
+        GROUP BY signature
+        ) t2
+        ) t4 ON t1.signature = t4.signature
+        WHERE t1.`status` is not null
+        AND t1.`status`!=2
+        and t1.data_status = 1
+        AND t1.signature is not null
+        <if test="orientationName !=null">
+            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
+        </if>
+        <if test="accountId !=null">
+            AND t2.account_id =#{accountId}
+        </if>
+        <if test="status !=null">
+            AND t1.`status` =#{status}
+        </if>
+        GROUP BY t1.signature
+        order by t1.update_time desc
+    </select>
+
+    <select id="queryListByStatus" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
+        SELECT account_id
+        FROM ctop_kuaishou_crowd_package
+        WHERE `status` !=2
+        GROUP BY account_id
+    </select>
+
+    <select id="queryFailReason" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DISTINCT IFNULL(t3.project_name, null) as 'projectName', IFNULL(t2.auth_name, null)as 'accountName', IFNULL(t1.message, null) as 'message'
+        FROM ctop_kuaishou_crowd_package t1
+                 INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                 INNER JOIN ctop_project t3 ON t2.project_id = t3.id
+        WHERE t1.signature = #{signature}
+          AND t1.data_status = 0
+    </select>
+
+    <select id="queryRelAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT IFNULL(t1.project_name, '') AS 'projectName' ,
+               IFNULL(t1.auth_name, '') AS 'accountName',
+               t2.count,
+               t1.`status`,
+               CASE t1.`status`
+                   WHEN 0 THEN '计算中'
+                   WHEN 1 THEN '已生效'
+                   WHEN 2 THEN '已删除'
+                   WHEN 3 THEN '推送中'
+                   WHEN 4 THEN '已推送'
+                   WHEN 5 THEN '计算失败'
+                   WHEN 6 THEN '推送失败'
+                   WHEN 7 THEN '已失效'
+                   ELSE ''
+                   END as 'statusStr'
+        FROM (
+                 SELECT t2.auth_name, t2.account_id, t3.project_name, t1.status
+                 FROM ctop_kuaishou_crowd_package t1
+                          INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                          INNER JOIN ctop_project t3 ON t3.id = t2.project_id
+                 where signature = #{signature}
+                   and data_status = 1
+                   AND `status` !=2
+                 GROUP BY t1.account_id
+             ) t1
+                 LEFT JOIN(
+            SELECT t.account_id, COUNT(1) as 'count'
+            FROM (
+                     SELECT t1.account_id, signature
+                     FROM ctop_kuaishou_crowd_package t1
+                              INNER JOIN (
+                         SELECT t1.account_id
+                         FROM ctop_kuaishou_crowd_package t1
+                                  INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                         where signature = #{signature}
+                           and data_status = 1
+                           AND `status` !=2
+                         GROUP BY account_id
+                     ) t2 ON t1.account_id = t2.account_id
+                     where signature is not NULL
+                       AND data_status = 1
+                       AND `status` != 2
+                     GROUP BY signature, t1.account_id
+                 ) t
+            GROUP BY t.account_id
+        ) t2 ON t1.account_id = t2.account_id
+    </select>
+
+    <select id="queryRelProject" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT IFNULL(CONCAT(tt3.project_name, '(', tt.project_id, ')'), '') as 'projectName' ,
+               tt.accountCount,
+               tt2.count
+        FROM (
+                 SELECT t.project_id, COUNT(1) as  'accountCount'
+                 FROM (
+                          SELECT t1.project_id, t1.account_id
+                          FROM ctop_user_allocation t1
+                                   INNER JOIN(
+                              SELECT t1.account_id
+                              FROM ctop_kuaishou_crowd_package t1
+                                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                              where signature = #{signature}
+                                AND data_status = 1
+                                AND `status` !=2
+                              GROUP BY t1.account_id
+                          ) t2 ON t2.account_id = t1.account_id
+                      ) t
+                 GROUP BY t.project_id
+             ) tt
+                 LEFT JOIN
+             (
+                 SELECT t.project_id, t.account_id, COUNT(1) as 'count'
+                 FROM (
+                          SELECT t3.project_id, t1.account_id, signature
+                          FROM ctop_kuaishou_crowd_package t1
+                                   INNER JOIN (
+                              SELECT t1.account_id
+                              FROM ctop_kuaishou_crowd_package t1
+                                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                              where signature = #{signature}
+                                AND data_status = 1
+                                AND `status` !=2
+                              GROUP BY t1.account_id
+                          ) t2 ON t1.account_id = t2.account_id
+                                   INNER JOIN ctop_user_allocation t3 ON t3.account_id = t2.account_id
+                          where signature is not NULL
+                            AND data_status = 1
+                            AND `status` != 2
+                          GROUP BY signature, t1.account_id, t3.project_id
+                      ) t
+                 GROUP BY t.account_id, t.project_id
+             ) tt2 ON tt2.project_id = tt.project_id
+                 LEFT JOIN ctop_project tt3 ON tt2.project_id = tt3.id
+        GROUP BY tt.project_id
+    </select>
+
+    <select id="queryProjectCount" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(1),0)
+        FROM (SELECT t2.project_id
+              FROM ctop_kuaishou_crowd_package t1
+                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+              where orientation_id is not null
+                AND signature = #{signature}
+                AND data_status = 1
+                AND `status` !=2
+              GROUP BY project_id) t
+    </select>
+    <select id="queryAccountCount" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(1),0)
+        FROM (
+                 SELECT account_id
+                 FROM ctop_kuaishou_crowd_package
+                 WHERE signature = #{signature}
+                   AND `status` !=2
+                 AND data_status = 1
+                 GROUP BY account_id) t
+    </select>
+
+    <select id="queryByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
+        SELECT *
+        FROM ctop_kuaishou_crowd_package
+        where data_status = 1
+        AND `status` !=2
+        <if test="accountId!=null">
+            AND account_id = #{accountId}
+        </if>
+        <if test="orientationId!=null">
+            AND orientation_id = #{orientationId}
+        </if>
+        limit 1
+    </select>
+
+    <update id="update">
+        update ctop_kuaishou_crowd_package
+        set status = #{status}
+        where account_id = #{account_id}
+        and orientation_id = #{orientation_id}
+    </update>
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_crowd_package(
+        account_id,
+        stat_date,
+        orientation_id,
+        orientation_name,
+        url,
+        population_type,
+        data_status,
+        type,
+        status,
+        signature,
+        cover_num,
+        record_size,
+        match_size,
+        message
+        )
+        values
+        <foreach collection="list" item="li" separator=",">
+            (
+            #{li.accountId},
+            #{li.statDate},
+            #{li.orientationId},
+            #{li.orientationName},
+            #{li.url},
+            #{li.populationType},
+            #{li.dataStatus},
+            #{li.type},
+            #{li.status},
+            #{li.signature},
+            #{li.coverNum},
+            #{li.recordSize},
+            #{li.matchSize},
+            #{li.message}
+            )
+        </foreach>
+    </insert>
+
+</mapper>

+ 31 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouCrowdPackService.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群报表
+ * @Author: jeecg-boot
+ * @Date: 2021-03-26
+ * @Version: V1.0
+ */
+public interface IKuaishouCrowdPackService extends IService<KuaishouCrowdPack> {
+
+    Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack, Integer pageNo, Integer pageSize);
+
+    Result<Object> uploadCrowdPack(Integer type, String orientationName, Long accountId, String url);
+
+    Result<Object> accountPush(JSONObject request);
+
+    void crowdListQuery();
+
+    Result<Object> queryRel(String type, String signature, Integer pageNo, Integer pageSize);
+
+    Result<Object> queryFailReason(String signature, Integer pageNo, Integer pageSize);
+
+    Result<Object> updateDataStatus(KuaishouCrowdPack kuaishouCrowdPack);
+
+    Result<Object> checkCrowdPackage(String signature);
+}

+ 277 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouCrowdPackServiceImpl.java

@@ -0,0 +1,277 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.LoadFileUtil;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * 人群报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-03-26
+ */
+@Slf4j
+@Service
+public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackMapper, KuaishouCrowdPack> implements IKuaishouCrowdPackService {
+
+    @Autowired
+    private KuaishouCrowdPackMapper crowdPackMapper;
+
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    @Autowired
+    private IKuaishouPopulationService iKuaishouPopulationService;
+
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Autowired
+    UserAllocationMapper userAllocationMapper;
+
+    @Value("${zip.local.download-path}")
+    private String downloadPath;
+
+
+    @Override
+    public Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack, Integer pageNo, Integer pageSize) {
+        Long total = crowdPackMapper.getTotal(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationName());
+        PageHelper.startPage(pageNo, pageSize, false);
+        List<JSONObject> list = crowdPackMapper.queryPageList(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationName());
+        for (JSONObject object : list) {
+            int count = crowdPackMapper.queryProjectCount(object.getString("signature"));
+            object.put("projectCount", count);
+            int accountCount = crowdPackMapper.queryAccountCount(object.getString("signature"));
+            object.put("accountCount", accountCount);
+        }
+        PageInfo pageInfo = new PageInfo(list);
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> uploadCrowdPack(Integer type, String orientationName, Long accountId, String url) {
+        StringBuffer path = new StringBuffer();
+        path.append(downloadPath).append(DateUtils.getNowDate(DateUtils.WEB_FORMAT)).append("/").append(UUID.randomUUID().toString()).append("/");
+        if (!url.contains("http")) {
+            url = "https:".concat(url);
+        }
+        String newFileUrl = LoadFileUtil.downLoadFromUrl(url, path.toString());
+        if (Check.isNull(newFileUrl)) {
+            return Result.error("文件下载失败,路径:" + url);
+        }
+        String md5 = null;
+        try {
+            md5 = LoadFileUtil.getMD5(newFileUrl);
+        } catch (IOException e) {
+            log.error("获取MD5签名失败", e);
+        }
+        QueryWrapper<KuaishouCrowdPack> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("signature", md5);
+        queryWrapper.eq("data_status", 1);
+        queryWrapper.last("limit 1");
+        KuaishouCrowdPack one = crowdPackMapper.selectOne(queryWrapper);
+        if (!Check.isNull(one)) {
+            return Result.error("本账户已上传过该人群包,人群包名为:" + one.getOrientationName());
+        }
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        JSONObject jsonObject = iKuaishouPopulationService.updatePopulation(token, type, orientationName, newFileUrl);
+        LoadFileUtil.delFile(newFileUrl);
+        if (!Check.isNull(jsonObject)) {
+            if (jsonObject.getInteger("code") == 0) {
+                KuaishouCrowdPack crowdPack = JSONObject.toJavaObject(jsonObject.getJSONObject("data"), KuaishouCrowdPack.class);
+                crowdPack.setSignature(md5);
+                crowdPack.setUrl(url);
+                crowdPack.setMessage(jsonObject.getString("message"));
+                crowdPack.setStatDate(DateUtils.formatDate(new Date()));
+                crowdPack.setDataStatus(1);
+                this.save(crowdPack);
+            } else {
+                KuaishouCrowdPack crowdPack = new KuaishouCrowdPack();
+                crowdPack.setAccountId(accountId);
+                crowdPack.setOrientationName(orientationName);
+                crowdPack.setSignature(md5);
+                crowdPack.setUrl(url);
+                crowdPack.setMessage(jsonObject.getString("message"));
+                crowdPack.setStatDate(DateUtils.formatDate(new Date()));
+                crowdPack.setDataStatus(0);
+                this.save(crowdPack);
+                return Result.error(jsonObject.getString("message"));
+            }
+        }
+        return Result.ok("success");
+    }
+
+    @Override
+    public Result<Object> accountPush(JSONObject request) {
+        JSONArray accountIds = request.getJSONArray("accountIds");
+        String signature = request.getString("signature");
+        Long accountId = request.getLong("accountId");
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        QueryWrapper<KuaishouCrowdPack> wrapper = new QueryWrapper<>();
+        wrapper.eq("account_id", accountId);
+        wrapper.eq("signature", signature);
+        wrapper.eq("status", 4);
+        wrapper.last("limit 1");
+        KuaishouCrowdPack kuaishouCrowdPack = crowdPackMapper.selectOne(wrapper);
+        if (Check.isNull(kuaishouCrowdPack)) {
+            return Result.error("该账户下没有可推送人群包");
+        }
+        JSONObject jsonObject = iKuaishouPopulationService.pushAccountsPopulation(token, kuaishouCrowdPack.getOrientationId(), accountIds);
+        if (jsonObject.getInteger("code") == 0) {
+            List<KuaishouCrowdPack> list = new ArrayList<>();
+            JSONObject data = jsonObject.getJSONObject("data");
+            if (!Check.isNull(data)) {
+                JSONArray success = data.getJSONArray("success");
+                for (Object account : success) {
+                    kuaishouCrowdPack.setAccountId(Long.valueOf(String.valueOf(account)));
+                    kuaishouCrowdPack.setMessage("PUSH OK");
+                    kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
+                    list.add(kuaishouCrowdPack);
+                }
+                JSONArray fail = data.getJSONArray("fail");
+                for (Object account : fail) {
+                    Long aaccount = Long.valueOf(String.valueOf(account));
+                    KuaishouCrowdPack crowdPack = crowdPackMapper.queryByAccountId(aaccount, kuaishouCrowdPack.getOrientationId());
+                    if (Check.isNull(crowdPack)) {
+                        kuaishouCrowdPack.setDataStatus(0);
+                        kuaishouCrowdPack.setAccountId(aaccount);
+                        kuaishouCrowdPack.setMessage("推送失败");
+                        kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
+                        kuaishouCrowdPack.setStatus(null);
+                        kuaishouCrowdPack.setType(null);
+                        kuaishouCrowdPack.setCoverNum(null);
+                        kuaishouCrowdPack.setRecordSize(null);
+                        kuaishouCrowdPack.setMatchSize(null);
+                        list.add(kuaishouCrowdPack);
+                    }
+                }
+                if (list.size() > 0) {
+                    crowdPackMapper.replaceBatch(list);
+                }
+            }
+        } else {
+            return Result.error(jsonObject.getString("message"));
+        }
+        return Result.ok("success");
+    }
+
+    @Override
+    public void crowdListQuery() {
+        List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
+        for (int i = 0; i <= 7; i++) {
+            if (i != 2) {
+                for (KuaishouCrowdPack crowdPack : crowdList) {
+                    CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
+                    JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), i);
+                    if (jsonObject.getInteger("code") == 0) {
+                        JSONObject data = jsonObject.getJSONObject("data");
+                        if (!Check.isNull(data)) {
+                            JSONArray details = data.getJSONArray("details");
+                            if (details.size() > 0) {
+                                for (int j = 0; j < details.size(); j++) {
+                                    JSONObject obj = details.getJSONObject(j);
+                                    if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
+                                        KuaishouCrowdPack oldPack = crowdPackMapper.queryByAccountId(null, obj.getLong("orientation_id"));
+                                        KuaishouCrowdPack crowdPackEntity = JSONObject.toJavaObject(obj, KuaishouCrowdPack.class);
+                                        if (!Check.isNull(oldPack)) {
+                                            crowdPackEntity.setStatDate(oldPack.getStatDate());
+                                            crowdPackEntity.setUrl(oldPack.getUrl());
+                                            crowdPackEntity.setSignature(oldPack.getSignature());
+                                        }
+                                        crowdPackEntity.setMessage("PUSH OK");
+                                        crowdPackEntity.setDataStatus(1);
+                                        this.save(crowdPackEntity);
+                                    } else {
+                                        crowdPackMapper.update(obj);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public Result<Object> queryRel(String type, String signature, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = null;
+        if ("1".equals(type)) {
+            list = crowdPackMapper.queryRelProject(signature);
+        } else {
+            list = crowdPackMapper.queryRelAccounts(signature);
+        }
+        PageInfo pageInfo = new PageInfo(list);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> queryFailReason(String signature, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = crowdPackMapper.queryFailReason(signature);
+        PageInfo pageInfo = new PageInfo(list);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> updateDataStatus(KuaishouCrowdPack kuaishouCrowdPack) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(kuaishouCrowdPack.getAccountId());
+        JSONObject object = iKuaishouPopulationService.deletePopulation(kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationId(), token.getAccessToken());
+        if (!Check.isNull(object)) {
+            if (object.getInteger("code") == 0) {
+                if (this.removeById(kuaishouCrowdPack.getId())) {
+                    return Result.ok("删除成功");
+                }
+            }
+            return Result.error("删除失败,".concat(object.getString("message")));
+        }
+        return Result.error("删除失败");
+    }
+
+    @Override
+    public Result<Object> checkCrowdPackage(String signature) {
+        QueryWrapper<KuaishouCrowdPack> wrapper = new QueryWrapper<>();
+        wrapper.eq("signature", signature);
+        wrapper.eq("data_status", 1);
+        wrapper.last("limit 1");
+        KuaishouCrowdPack kuaishouCrowdPack = crowdPackMapper.selectOne(wrapper);
+        Result result = new Result();
+        if (Check.isNull(kuaishouCrowdPack)) {
+            return Result.ok("success");
+        }
+        result.setSuccess(true);
+        result.setCode(201);
+        result.setMessage("后台保存过该人群包,名称为:" + kuaishouCrowdPack.getOrientationName());
+        result.setResult(kuaishouCrowdPack);
+        return result;
+    }
+}

+ 7 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouAccountBudgetService.java

@@ -1,13 +1,16 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouAccountBudget;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**
  * 账户日预算
+ *
  * @author jeecg-boot
- * @date   2020-04-26
  * @version V1.0
+ * @date 2020-04-26
  */
 public interface IKuaishouAccountBudgetService extends IService<KuaishouAccountBudget> {
 
@@ -18,6 +21,8 @@ public interface IKuaishouAccountBudgetService extends IService<KuaishouAccountB
      * @param advertiserId
      * @param accessToken
      */
-    void getAccountBudget(Long advertiserId, String accessToken);
+    JSONObject getAccountBudget(CtopOauthToken oauthToken);
+
+    void insertAccountBudget(Long advertiserId, String accessToken);
 
 }

+ 5 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -5,7 +5,11 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.entity.*;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 

+ 9 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouPopulationService.java

@@ -1,8 +1,11 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.util.List;
@@ -24,7 +27,7 @@ public interface IKuaishouPopulationService extends IService<KuaishouPopulation>
      * @param accountId    广告主ID
      * @return
      */
-    boolean deletePopulation(Long accountId, String populationId, String accessToken);
+    JSONObject deletePopulation(Long accountId, Long populationId, String accessToken);
 
     /**
      * 获取人群包接口
@@ -33,11 +36,11 @@ public interface IKuaishouPopulationService extends IService<KuaishouPopulation>
      * @param populationName 人群包名称
      * @param type           1:IMEI 2:IDFA 3:IMEI_MD5 4:IDFA_MD5 5:手机号-MD5 7:OAID
      * @param accountId      广告主ID
-     * @param file           请求的页码
+     * @param filePath       文件路径
      * @param accessToken    token
      * @return
      */
-    JSONObject updatePopulation(Long accountId, int type, String populationName, File file, String accessToken);
+    JSONObject updatePopulation(CtopOauthToken token,int type, String populationName,  String filePath);
 
     /**
      * 推送人群包接口(单日最多可调用50次推送接口)
@@ -59,7 +62,7 @@ public interface IKuaishouPopulationService extends IService<KuaishouPopulation>
      * @param ids          要推送的账户ids
      * @return
      */
-    boolean pushAccountsPopulation(Long accountId, String populationId, Long[] ids, String accessToken);
+    JSONObject pushAccountsPopulation(CtopOauthToken token, Long orientationId, JSONArray accountIds);
 
     /**
      * 游戏精选标签人群包
@@ -70,6 +73,7 @@ public interface IKuaishouPopulationService extends IService<KuaishouPopulation>
      */
     JSONObject selectGameTags(String accessToken);
 
+    JSONObject getPopulationList(Long accountId, String accessToken,Integer status);
     /**
      * 游戏精选标签人群包
      * 游戏精选标签创建
@@ -91,7 +95,7 @@ public interface IKuaishouPopulationService extends IService<KuaishouPopulation>
      * @param file           请求的文件,最大支持500MB
      * @return
      */
-    JSONObject updatePopulation(Long accountId, Integer type, Long populationId, Integer populationType, File file, String accessToken);
+    JSONObject updatePopulations(Long accountId, Integer type, Long populationId, Integer populationType, File file, String accessToken);
 
     /**
      * 获取人群预估数量

+ 30 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouAccountBudgetServiceImpl.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
@@ -10,21 +11,21 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouAccountBudgetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouAccountBudgetService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
 /**
  * 账户日预算
+ *
  * @author jeecg-boot
- * @date   2020-04-26
  * @version V1.0
+ * @date 2020-04-26
  */
 @Slf4j
 @Service
@@ -37,12 +38,13 @@ public class KuaishouAccountBudgetServiceImpl extends ServiceImpl<KuaishouAccoun
 
     /**
      * 获取账户日预算结果
+     *
      * @param advertiserId
      * @param accessToken
      * @return
      */
     @Override
-    public void getAccountBudget(Long advertiserId, String accessToken) {
+    public void insertAccountBudget(Long advertiserId, String accessToken) {
         try {
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_BUDGET;
             Map<String, String> headers = new HashMap<>();
@@ -82,4 +84,28 @@ public class KuaishouAccountBudgetServiceImpl extends ServiceImpl<KuaishouAccoun
         }
 
     }
+
+    @Override
+    public JSONObject getAccountBudget(CtopOauthToken oauthToken) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_BUDGET;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", oauthToken.getAccessToken());
+        headers.put("Content-Type", "application/json");
+        JSONObject json = new JSONObject();
+        json.put("advertiser_id", oauthToken.getAccountId());
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject dataJson = resultJson.getJSONObject("data");
+                if (!Check.isNull(dataJson)) {
+                    return dataJson;
+                }
+            } else {
+                log.error("获取账户日预算失败,返回信息:{}", resultJson);
+            }
+        }
+        return null;
+    }
 }

+ 52 - 29
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouPopulationServiceImpl.java

@@ -1,12 +1,15 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouPopulationMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
@@ -33,6 +36,30 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
     private KuaishouPopulationMapper populationMapper;
     private String urlPath = PropertiesUtils.getConfig("kuaishou_api_url");
 
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+
+    @Override
+    public JSONObject getPopulationList(Long accountId, String accessToken, Integer status) {
+        log.info("获取人群包列表,accountId:{}", accountId);
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.POPULATION_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", "application/json");
+        JSONObject requestJson = new JSONObject();
+        requestJson.put("advertiser_id", accountId);
+        requestJson.put("status", status);
+        requestJson.put("page", 1);
+        requestJson.put("page_size", 500);
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            return resultJson;
+        }
+        return null;
+    }
+
     /**
      * 获取人群包接口
      *
@@ -43,7 +70,7 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
      * @return
      */
     @Override
-    public boolean deletePopulation(Long accountId, String populationId, String accessToken) {
+    public JSONObject deletePopulation(Long accountId, Long populationId, String accessToken) {
         log.info("删除人群包,accountId:{}", accountId);
         String url = urlPath + KuaishouInterfaceConstant.POPULATION_DELETE;
         Map<String, String> headers = new HashMap<>();
@@ -55,10 +82,9 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
         String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         if (!Check.isNull(resultJson)) {
-            Integer code = resultJson.getInteger("code");
-            return code == 0;
+            return resultJson;
         }
-        return false;
+        return null;
     }
 
 
@@ -74,23 +100,21 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
      * @return
      */
     @Override
-    public JSONObject updatePopulation(Long accountId, int type, String populationName, File file, String accessToken) {
-        log.info("上传人群包,accountId:{}", accountId);
+    public JSONObject updatePopulation(CtopOauthToken token, int type, String populationName, String filePath) {
         String url = urlPath + KuaishouInterfaceConstant.POPULATION_UPLOAD;
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Access-Token", accessToken);
-        headers.put("Content-Type", "application/json");
+        Map<String, String> headerMap = new HashMap<>();
+        headerMap.put("Access-Token", token.getAccessToken());
+        headerMap.put("Content-Type", "multipart/form-data");
         JSONObject requestJson = new JSONObject();
-        requestJson.put("advertiser_id", accountId);
-        requestJson.put("type", type);
-        requestJson.put("orientation_name", populationName);
-        requestJson.put("file", file);
-        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) {
-                return resultJson.getJSONObject("data");
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("advertiser_id", token.getAccountId());
+        paramMap.put("type", type);
+        paramMap.put("orientation_name", populationName);
+        String result = kuaishouInterfaceService.exceptInfoForRestTemplate(url, paramMap, headerMap, filePath);
+        if (!Check.isNull(result)) {
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                return resultJson;
             }
         }
         return null;
@@ -134,23 +158,22 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
      * @return
      */
     @Override
-    public boolean pushAccountsPopulation(Long accountId, String populationId, Long[] ids, String accessToken) {
-        log.info("推送人群包,accountId:{}", accountId);
+    public JSONObject pushAccountsPopulation(CtopOauthToken token, Long orientationId, JSONArray accountIds) {
+        log.info("推送人群包,accountId:{}", token.getAccountId());
         String url = urlPath + KuaishouInterfaceConstant.POPULATION_PUSH_ACCOUNTS;
         Map<String, String> headers = new HashMap<>();
-        headers.put("Access-Token", accessToken);
+        headers.put("Access-Token", token.getAccessToken());
         headers.put("Content-Type", "application/json");
         JSONObject requestJson = new JSONObject();
-        requestJson.put("advertiser_id", accountId);
-        requestJson.put("orientation_id", populationId);
-        requestJson.put("dest_account_ids", ids);
+        requestJson.put("advertiser_id", token.getAccountId());
+        requestJson.put("orientation_id", orientationId);
+        requestJson.put("dest_account_ids", accountIds);
         String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         if (!Check.isNull(resultJson)) {
-            Integer code = resultJson.getInteger("code");
-            return code == 0;
+            return resultJson;
         }
-        return false;
+        return null;
     }
 
     /**
@@ -232,7 +255,7 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
      * @return
      */
     @Override
-    public JSONObject updatePopulation(Long accountId, Integer type, Long populationId, Integer populationType, File file, String accessToken) {
+    public JSONObject updatePopulations(Long accountId, Integer type, Long populationId, Integer populationType, File file, String accessToken) {
         String url = urlPath + KuaishouInterfaceConstant.POPULATION_UPDATE;
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", accessToken);

+ 11 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsVideoReportCtrl.java

@@ -108,6 +108,9 @@ public class KsVideoReportCtrl {
             if (!Check.isNull(requestBody.getString("order"))) {
                 requestMap.put("order", requestBody.getString("order"));
             }
+            if (!Check.isNull(requestBody.getInteger("channelType"))) {
+                requestMap.put("channelType", requestBody.getInteger("channelType"));
+            }
             PageInfo<JSONObject> listData = ksVideoReportService.getKuaiShouVideoPageReportByMap(requestMap, pageSize, pageNo);
             if (Check.isNull(listData)) {
                 throw new Exception("暂无素材相关信息,请检查账户");
@@ -241,17 +244,13 @@ public class KsVideoReportCtrl {
                         HttpServletRequest request,
                         HttpServletResponse response) {
         Result<PageInfo<JSONObject>> result = new Result<>();
-    try {
+        try {
 
 
             if (Check.isNull(requestBody)) {
                 throw new Exception("入参不能为空");
             }
             JSONArray columns = requestBody.getJSONArray("columns");
-            if (Check.isNull(columns)) {
-                throw new Exception("请传入表头");
-            }
-
             String startDate = requestBody.getString("startDate");
             if (Check.isNull(startDate)) {
                 throw new Exception("请输入查询开始时间");
@@ -290,6 +289,9 @@ public class KsVideoReportCtrl {
             if (!Check.isNull(requestBody.getString("order"))) {
                 requestMap.put("order", requestBody.getString("order"));
             }
+            if (!Check.isNull(requestBody.getInteger("channelType"))) {
+                requestMap.put("channelType", requestBody.getInteger("channelType"));
+            }
 
             JSONArray columns2 = new JSONArray();
             columns2.add(0, "materialName");
@@ -301,8 +303,10 @@ public class KsVideoReportCtrl {
             columns2.add(6, "plan");
             columns2.add(7, "shot");
             columns2.add(8, "createTime");
-            for (int i = 0; i < columns.size(); i++) {
-                columns2.add(columns2.size(), columns.getString(i));
+            if (!Check.isNull(columns)) {
+                for (int i = 0; i < columns.size(); i++) {
+                    columns2.add(columns2.size(), columns.getString(i));
+                }
             }
             columns2.add(columns2.size(), "url");
             List<String> titles = getfileIds(AccountReportConstants.kuaishouVideoReportDict, columns2);
@@ -321,7 +325,6 @@ public class KsVideoReportCtrl {
                 }
                 excelList.add(temp);
             }
-
             try {
                 String[] strings = titles.toArray(new String[]{});
                 OutputStream os = response.getOutputStream();
@@ -335,8 +338,6 @@ public class KsVideoReportCtrl {
             } catch (IOException e) {
                 log.error(e.getMessage());
             }
-
-
             result.setSuccess(true);
 
         } catch (Exception e) {

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

@@ -0,0 +1,176 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouDimensionReportService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.AccountReportConstants;
+import org.jeecg.common.util.JsonResourceUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Api(tags = "快手-多维度数据报表")
+@RestController
+@RequestMapping("/dimension/report")
+public class KuaishouDimensionReportController {
+    @Autowired
+    private IKuaishouDimensionReportService dimensionReportService;
+
+
+    /**
+     * 获取分版位数据
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/getPositionData")
+    public Result<List<JSONObject>> getPositionData(@RequestBody JSONObject requestJson) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(accountIds)) {
+                throw new Exception("请输入需要账户id");
+            }
+            String startDate = requestJson.getString("startDate");
+            if (Check.isNull(startDate)) {
+                throw new Exception("请输入开始时间");
+            }
+            String endDate = requestJson.getString("endDate");
+            if (Check.isNull(endDate)) {
+                throw new Exception("请输入结束时间");
+            }
+            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapKs);
+            if (Check.isNull(filedAll)) {
+                throw new Exception("查询配置为空");
+            }
+            List<JSONObject> positionList = dimensionReportService.getPositionData(accountIds, startDate, endDate, filedAll);
+            result.setResult(positionList);
+            result.setSuccess(true);
+            result.setMessage("success");
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+
+    /**
+     * 分版位数据导出
+     *
+     * @param requestJson
+     * @param request
+     * @param response
+     */
+    @PostMapping("/positionDataImportExcel")
+    public void positionDataImportExcel(@RequestBody JSONObject requestJson,
+                                        HttpServletRequest request,
+                                        HttpServletResponse response) {
+        Result<PageInfo<JSONObject>> result = new Result<>();
+        try {
+
+            JSONArray columns = requestJson.getJSONArray("columns");
+            if (Check.isNull(columns)) {
+                throw new Exception("请传入表头");
+            }
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(accountIds)) {
+                throw new Exception("请输入需要账户id");
+            }
+            String startDate = requestJson.getString("startDate");
+            if (Check.isNull(startDate)) {
+                throw new Exception("请输入开始时间");
+            }
+            String endDate = requestJson.getString("endDate");
+            if (Check.isNull(endDate)) {
+                throw new Exception("请输入结束时间");
+            }
+            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapKs);
+            if (Check.isNull(filedAll)) {
+                throw new Exception("查询配置为空");
+            }
+            JSONArray columns2 = new JSONArray();
+            columns2.add(0, "adScene");
+
+            for (int i = 0; i < columns.size(); i++) {
+                columns2.add(columns2.size(), columns.getString(i));
+            }
+            List<String> titles = getfileIds(AccountReportConstants.kuaishouVideoReportDict, columns2);
+            List<JSONObject> positionList = dimensionReportService.getPositionData(accountIds, startDate, endDate, filedAll);
+            if (Check.isNull(positionList)) {
+                throw new Exception("暂无投放场景相关信息,请检查账户");
+            }
+            List<List<Object>> excelList = new ArrayList<>();
+            for (int i = 0; i < positionList.size(); i++) {
+                List<Object> temp = new ArrayList<>();
+                JSONObject jsonObject = positionList.get(i);
+                for (int j = 0; j < columns2.size(); j++) {
+                    String key = columns2.getString(j);
+                    String value = jsonObject.getString(key);
+                    temp.add(value);
+                }
+                excelList.add(temp);
+            }
+            try {
+                String[] strings = titles.toArray(new String[]{});
+                OutputStream os = response.getOutputStream();
+                ExportExcelUtils eeu = new ExportExcelUtils();
+                XSSFWorkbook workbook = new XSSFWorkbook();
+                eeu.exportExcel(workbook, 0, "投放场景", strings, excelList);
+                HttpUtils.setResponseHeader(response, "快手投放场景报表.xlsx");
+                workbook.write(os);
+                os.flush();
+                os.close();
+            } catch (IOException e) {
+                log.error(e.getMessage());
+            }
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage(), e);
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+
+    }
+
+
+    private List<String> getfileIds(Map<String, Map<String, Object>> kuaishouVideoReportMap, JSONArray columns) {
+        List<String> titles = new ArrayList<>();
+        for (int i = 0; i < columns.size(); i++) {
+            String string = columns.getString(i);
+            Map<String, Object> stringObjectMap = kuaishouVideoReportMap.get(string);
+            if (Check.isNull(stringObjectMap)) {
+                titles.add("-");
+                continue;
+            }
+            Object comment = stringObjectMap.get("comment");
+            titles.add(String.valueOf(comment));
+
+        }
+        return titles;
+    }
+
+
+}

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.common.module.vo.KuaishouReportAccountDailyDTOEntity;
 import cn.com.ctop.kuaishou.modules.report.entity.*;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -54,4 +55,6 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
     List<EtlKuaishouReportAccountHourly> queryEveryDayDataForAccount();
 
     BigDecimal getSumChargeByAccountIdAndStatDate(@Param("accountId") Long accountId, @Param("statDate") String statDate);
+
+    List<JSONObject> getPositionData(@Param("accountIds") JSONArray accountIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("filedAll") String filedAll);
 }

+ 28 - 22
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KsVideoReportMapper.xml

@@ -5,15 +5,15 @@
     <select id="getKuaiShouVideoReportByMap" resultType="com.alibaba.fastjson.JSONObject" parameterType="map">
         SELECT
         t1.*,
-        t2.clip_name as clip,
-        t2.plan_name as plan,
-        t2.shot_name as shot,
-        t2.design_team_leader_name as designLeader,
-        t2.video_name as materialName,
-        t2.cover_url as coverUrl,
-        t2.url as url ,
-        t2.channel_name AS channel,
-        t2.state_date as createTime
+        IFNULL(t2.clip_name,'-') as clip,
+        IFNULL(t2.plan_name,'-') as plan,
+        IFNULL(t2.shot_name,'-') as shot,
+        IFNULL(t2.design_team_leader_name,'-') as designLeader,
+        IFNULL(t2.video_name,'-') as materialName,
+        IFNULL(t2.cover_url,'-') as coverUrl,
+        IFNULL(t2.url,'-') as url ,
+        IFNULL(t2.channel_name,'-') AS channel,
+        IFNULL(t2.state_date,'-') as createTime
         FROM
         (select ${filed}
         from ctop_etl_kuaishou_account_material_report_daily t1
@@ -40,6 +40,9 @@
         <if test="leaderId !=null and leaderId != ''">
             AND t2.design_team_leader_id = #{leaderId}
         </if>
+        <if test="channelType != null">
+            AND t2.channel_type = #{channelType}
+        </if>
         <if test="clipId !=null and clipId != ''">
             AND t2.clip_id = #{clipId}
         </if>
@@ -83,6 +86,9 @@
         <if test="leaderId !=null and leaderId != ''">
             AND t2.design_team_leader_id = #{leaderId}
         </if>
+        <if test="channelType != null">
+            AND t2.channel_type = #{channelType}
+        </if>
         <if test="clipId !=null and clipId != ''">
             AND t2.clip_id = #{clipId}
         </if>
@@ -176,22 +182,22 @@
     </select>
 
     <select id="getDesignList" resultType="com.alibaba.fastjson.JSONObject">
-    SELECT
-	t1.user_id AS 'userId',
+        SELECT t1.user_id AS 'userId',
 	LEFT (t1.company_name, 2) AS 'companyName',
 	t3.role_name AS 'ruleName',
 	t1.user_name AS 'userName'
-    FROM
-	user_company t1
-    LEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id
-    LEFT JOIN sys_role t3 ON t2.role_id = t3.id
-    WHERE
-	t3.role_code IN (
-		'plan',
-		'shot',
-		'clip',
-		'designTeamLeader'
-	)
+        FROM
+            user_company t1
+            LEFT JOIN sys_user_role t2
+        ON t1.user_id = t2.user_id
+            LEFT JOIN sys_role t3 ON t2.role_id = t3.id
+        WHERE
+            t3.role_code IN (
+            'plan'
+            , 'shot'
+            , 'clip'
+            , 'designTeamLeader'
+            )
     </select>
 
 

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

@@ -1513,5 +1513,19 @@
         where account_id = #{accountId}
           and stat_date = #{statDate}
     </select>
+    <select id="getPositionData" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.ad_scene as 'adScene',
+        ${filedAll}
+        FROM ctop_kuaishou_report_daily_account_ad_scene t1
+        WHERE t1.stat_date &lt;= #{endDate}
+        AND t1.stat_date &gt;= #{startDate}
+        AND t1.account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by t1.ad_scene
+    </select>
 
 </mapper>

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

@@ -0,0 +1,10 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
+public interface IKuaishouDimensionReportService {
+    List<JSONObject> getPositionData(JSONArray accountIds, String startDate, String endDate, String filedAll);
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouDimensionReportService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class KuaishouDimensionReportServiceImpl implements IKuaishouDimensionReportService {
+    @Autowired
+    private KuaishouReportDailyAccountMapper dailyAccountMapper;
+
+    @Override
+    public List<JSONObject> getPositionData(JSONArray accountIds, String startDate, String endDate, String filedAll) {
+        return dailyAccountMapper.getPositionData(accountIds, startDate, endDate, filedAll);
+    }
+}

+ 5 - 2
module-kuaishou/src/main/resources/json_template/kuaishou_video_report_filed_dict.json

@@ -3,7 +3,7 @@
     "comment": "剪辑"
   },
   "channel": {
-    "comment": "来源"
+    "comment": "渠道"
   },
   "plan": {
     "comment": "编导"
@@ -18,7 +18,7 @@
     "comment": "素材名称"
   },
   "createTime": {
-    "comment": "上线时间"
+    "comment": "创建时间"
   },
   "coverUrl": {
     "comment": "封面链接"
@@ -184,5 +184,8 @@
   },
   "play3sRate": {
     "comment": "3s播放率"
+  },
+  "adScene": {
+    "comment": "投放场景"
   }
 }