Переглянути джерело

Merge remote-tracking branch 'origin/master'

songyh 4 роки тому
батько
коміт
270fb05fc9
46 змінених файлів з 538 додано та 219 видалено
  1. 37 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  2. 57 34
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  3. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ReleaseViewRecordController.java
  4. 14 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java
  5. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  6. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  7. 6 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  8. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  9. 19 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/UserCompanyController.java
  10. 1 1
      jeecg-boot-module-system/src/main/resources/application-jiaoyang.yml
  11. 1 1
      jeecg-boot-module-system/src/main/resources/application-preprod.yml
  12. 1 1
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  13. 1 1
      jeecg-boot-module-system/src/main/resources/application-prod2.yml
  14. 2 2
      jeecg-boot-module-system/src/main/resources/application-test.yml
  15. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/Project.java
  16. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java
  17. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java
  18. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/ProjectMapper.java
  19. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserCompanyMapper.java
  20. 16 22
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml
  21. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml
  22. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserCompanyMapper.xml
  23. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java
  24. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IProjectService.java
  25. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserCompanyService.java
  26. 6 3
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  27. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProjectServiceImpl.java
  28. 11 2
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserCompanyServiceImpl.java
  29. 1 1
      module-job-bytedance/src/main/resources/application-dev.yml
  30. 1 1
      module-job-bytedance/src/main/resources/application-jiaoyang.yml
  31. 1 1
      module-job-bytedance/src/main/resources/application-prod.yml
  32. 51 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAutoSynchronousProjectMaterialJob.java
  33. 16 6
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCreateCreativeJob.java
  34. 2 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java
  35. 1 1
      module-job-kuaishou/src/main/resources/application-jiaoyang.yml
  36. 1 1
      module-job-kuaishou/src/main/resources/application-preprod.yml
  37. 1 1
      module-job-kuaishou/src/main/resources/application-prod.yml
  38. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java
  39. 3 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java
  40. 128 51
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  41. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java
  42. 4 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  43. 29 28
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouAccountReportCtrl.java
  44. 2 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouYiCheReportController.java
  45. 49 19
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml
  46. 1 1
      module-kuaishou/src/main/resources/json_template/kuaishou_filed_mapping.json

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

@@ -9,7 +9,12 @@ import cn.com.ctop.common.module.service.IBindAccountAuthService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.ISysDepartService;
 import cn.com.ctop.common.module.service.ISysUserService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.BytedanceInterfaceConstant;
+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.ai.service.IKuaishouAppPackageService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
@@ -36,7 +41,10 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @RestController
@@ -59,6 +67,8 @@ public class CallbackController {
     private IByteDanceAdvertiserDataService advertiserDataService;
     @Autowired
     private IReportService reportService;
+    @Autowired
+    private IKuaishouAppPackageService kuaishouAppPackageService;
 
     @GetMapping("/qywexin")
     public void qywexin(HttpServletRequest request,
@@ -152,6 +162,10 @@ public class CallbackController {
                     BigDecimal warningProportion = json.getBigDecimal("WarningProportion");
                     BigDecimal warningAmount = json.getBigDecimal("WarningAmount");
                     String systemType = json.getString("systemType");
+                    Integer autoDelivery = json.getInteger("autoDelivery");
+                    String materialTypeStr = json.getString("materialType");
+                    //物料类型,0-不同步,1应用包,(2人群包,3定向包)
+                    JSONArray materialTypeArr = json.getJSONArray("materialType");
 
                     CtopOauthToken topOauthToken = new CtopOauthToken();
                     topOauthToken.setId(String.valueOf(accountId));
@@ -197,15 +211,20 @@ public class CallbackController {
                     userAllocation.setWarningAmount(warningAmount);
                     userAllocation.setCreateTime(new Date());
                     userAllocation.setUpdateTime(new Date());
+                    //自动投放,0关闭,1开启
+                    userAllocation.setAutoDelivery(autoDelivery);
+                    userAllocation.setMaterialType(materialTypeStr);
                     allocationMapper.deleteById(userAllocation.getId());
                     Map<String, Object> deleteUserMap = new HashMap<>();
                     deleteUserMap.put("advertiser_id", advertiserId);
                     deleteUserMap.put("account_id", accountId);
                     allocationMapper.deleteByMap(deleteUserMap);
+                    log.info("待创建账户信息:{}", userAllocation.toString());
                     int i = allocationMapper.insert(userAllocation);
                     if (i > 0) {
                         log.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
                     }
+                    Integer materialType = materialTypeArr.getInteger(0);
                     //账号绑定
                     bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, advertiserId);
                     Thread t = new Thread() {
@@ -213,6 +232,9 @@ public class CallbackController {
                         public void run() {
                             try {
                                 kuaishouInterfaceService.loadKuaishouDataSingle(topOauthToken);
+                                if (!Check.isNull(materialType) && materialType != 0) {
+                                    synchronMaterials(materialType, accountId, projectId);
+                                }
                             } catch (ParseException e) {
                                 e.printStackTrace();
                             }
@@ -228,9 +250,19 @@ public class CallbackController {
         return "授权绑定失败!";
     }
 
-
-    public static void main(String[] args) {
-        System.err.println(UUID.randomUUID().toString().replace("-", ""));
+    private void synchronMaterials(Integer materialType, Long accountId, Long projectId) {
+        if (materialType == 1) {
+            JSONArray accountIds = new JSONArray();
+            accountIds.add(accountId);
+            //1 有效项目模板
+            List<Long> ids = kuaishouAppPackageService.queryByAppVersion(projectId, null, 1);
+            log.info("同步账户应用,应用模板={}", ids);
+            if (!Check.isNull(ids)) {
+                for (Long id : ids) {
+                    kuaishouAppPackageService.pushAppPackage(id, accountIds);
+                }
+            }
+        }
     }
 
     @RequestMapping("/bytedance")

+ 57 - 34
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -20,7 +20,6 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
@@ -79,6 +78,9 @@ public class MaterialInfoController {
     @Autowired
     private IProjectService projectService;
     @Autowired
+    private IProjectMemberService projectMemberService;
+
+    @Autowired
     private IByteDanceCreativeWordPackageService byteDanceGeneralCopywriterService;
 
     @GetMapping("/supplierWatermark")
@@ -298,36 +300,57 @@ public class MaterialInfoController {
                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        List<Long> productIds = null;
+        List<Long> projectIds = new ArrayList<>();
         String userId = user.getId();
         String roleCode = roleService.getRoleCodeByUserId(userId);
         if (null == tagCode || "".equals(tagCode.trim())) {
             tagCode = null;
         }
-        if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || roleCode.contains("sale")) {
-            //查询所有
-            if (null != productId && productId != 0) {
-                productIds = new ArrayList<>();
-                productIds.add(productId);
+        //管理员、销售查询所有素材
+        if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || roleCode.contains("sale")) {
+            if (!Check.isNull(projectId)) {
+                projectIds.add(projectId);
+            } else if (!Check.isNull(productId)) {
+                List<Long> projectIdsByProductId = projectService.getProjectIdsByProductId(productId);
+                projectIds.addAll(projectIdsByProductId);
+            }
+            return materialInfoService.getListByParams(tagCode, type, status, materialName, projectIds, code, startDate, endDate, null, clipId, shotId, planId, offlineFlag, pageNo, pageSize);
+            //运营经理、运营、运营助理
+        } else if ("operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode)) {
+            if (!Check.isNull(projectId)) {
+                projectIds.add(projectId);
+            } else if (!Check.isNull(productId)) {
+                List<Long> partakeProjectIds = projectMemberService.getProjectIdsByProductId(productId, userId);
+                List<Long> productProjectIds = projectService.getProjectIdsByProductIdAndNotIn(productId, partakeProjectIds);
+                projectIds.addAll(partakeProjectIds);
+                projectIds.addAll(productProjectIds);
+            } else {
+                List<Long> partakeProjectIds = projectMemberService.getProjectIdsByProductId(null, userId);
+                List<Long> productProjectIds = projectService.getProjectIdsByProductIdAndNotIn(null, partakeProjectIds);
+                projectIds.addAll(partakeProjectIds);
+                projectIds.addAll(productProjectIds);
             }
-            return materialInfoService.getListByParams(tagCode, type, status, productIds, materialName, code, startDate, endDate, null, projectId, clipId, shotId, planId,offlineFlag, pageNo, pageSize);
+            return materialInfoService.getListByParams(tagCode, type, status, materialName, projectIds, code, startDate, endDate, null, clipId, shotId, planId, offlineFlag, pageNo, pageSize);
+
         } else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)) {
             //查询自己所在项目下的数据
-            if (null == productId || productId == 0) {
-                productIds = memberService.selectProductsByUserId(userId);
+            if (!Check.isNull(projectId)) {
+                projectIds.add(projectId);
+            } else if (!Check.isNull(productId)) {
+                projectIds = projectMemberService.getProjectIdsByProductId(productId, userId);
 
             } else {
-                productIds = new ArrayList<>();
-                productIds.add(productId);
+                projectIds = projectMemberService.getProjectIdsByProductId(null, userId);
             }
-            return materialInfoService.getListByParams(tagCode, type, status, productIds, materialName, code, startDate, endDate, null, projectId, clipId, shotId, planId,offlineFlag, pageNo, pageSize);
+            return materialInfoService.getListByParams(tagCode, type, status, materialName, projectIds, code, startDate, endDate, null, clipId, shotId, planId, offlineFlag, pageNo, pageSize);
         } else {
             //查询自己上传的视频
-            if (null != productId && productId != 0) {
-                productIds = new ArrayList<>();
-                productIds.add(productId);
+            if (!Check.isNull(projectId)) {
+                projectIds.add(projectId);
+            } else if (!Check.isNull(productId)) {
+                projectIds = projectMemberService.getProjectIdsByProductId(productId, userId);
             }
-            return materialInfoService.getListByParams(tagCode, type, status, productIds, materialName, code, startDate, endDate, userId, projectId, clipId, shotId, planId,offlineFlag, pageNo, pageSize);
+            return materialInfoService.getListByParams(tagCode, type, status, materialName, projectIds, code, startDate, endDate, userId, clipId, shotId, planId, offlineFlag, pageNo, pageSize);
         }
     }
 
@@ -520,12 +543,12 @@ public class MaterialInfoController {
             if (null != slogans && !slogans.isEmpty()) {
 
 
-                for (int i = 0;i<slogans.size();i++) {
+                for (int i = 0; i < slogans.size(); i++) {
                     JSONObject slogenInfo = slogans.getJSONObject(i);
                     String title = slogenInfo.getString("title");
-                    title = title.trim().replaceAll("[\\{]{2,}","{");
-                    title = title.trim().replaceAll("[\\}]{2,}","}");
-                    slogenInfo.put("title",title);
+                    title = title.trim().replaceAll("[\\{]{2,}", "{");
+                    title = title.trim().replaceAll("[\\}]{2,}", "}");
+                    slogenInfo.put("title", title);
                     String reg = "\\{[\\u4e00-\\u9fa5\\-]{2,6}\\}";
                     Pattern pattern = Pattern.compile(reg);
                     Matcher matcher = pattern.matcher(title);
@@ -534,44 +557,44 @@ public class MaterialInfoController {
                     int len = StringUtils.lengthAsSlogan(title);
                     int left = title.indexOf("{");
                     int right = title.indexOf("}");
-                    if(left >= 0 || right >= 0){
+                    if (left >= 0 || right >= 0) {
                         int times = 0;
                         while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
                             times++;
-                            if(times>=3){
+                            if (times >= 3) {
                                 result.setCode(500);
                                 result.setMessage("动态词包不合法,词包数量超过2个");
-                                return  result;
+                                return result;
                             }
                             String matchStr = matcher.group();//获取当前匹配的值
-                            title = title.replace(matchStr,"");
-                            ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(matchStr.substring(1,matchStr.length()-1));
-                            if(Check.isNull(creativeWordPackage)){
+                            title = title.replace(matchStr, "");
+                            ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(matchStr.substring(1, matchStr.length() - 1));
+                            if (Check.isNull(creativeWordPackage)) {
                                 result.setCode(500);
                                 result.setMessage("动态词包不合法,词包不存在或者含有单独的非词包大括号");
-                                return  result;
+                                return result;
                             }
                             creativeWordIdsArray.add(creativeWordPackage.getCreativeWordId());
                             len = len - (right - left) + creativeWordPackage.getMaxWordLen();
                             left = title.indexOf("{");
                             right = title.indexOf("}");
                         }
-                        if(title.contains("{") || title.contains("}")){
+                        if (title.contains("{") || title.contains("}")) {
                             return result.error500("大括号单独出现或大括号中内容不合法");
                         }
-                        slogenInfo.put("creative_word_ids",creativeWordIdsArray.toJSONString());
+                        slogenInfo.put("creative_word_ids", creativeWordIdsArray.toJSONString());
                     }
                     //校验标题长度,长度小于5和大于30的全部过滤
-                    if(len<5 || len>30){
+                    if (len < 5 || len > 30) {
                         result.setCode(500);
                         result.setMessage("文案长度不合法,小于5或大于30");
-                        return  result;
+                        return result;
                     }
                 }
 
                 LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-                slogenInfoService.deleteAllSlogens(Check.isNull(materialInfo.getProjectId()) ? materialInfoEntity.getProjectId() : materialInfo.getProjectId(),materialInfoEntity.getCode(),user.getId());
-                slogenInfoService.insertSlogans(Check.isNull(materialInfo.getProjectId()) ? materialInfoEntity.getProjectId() : materialInfo.getProjectId() , materialInfoEntity.getCode(), slogans, user.getId());
+                slogenInfoService.deleteAllSlogens(Check.isNull(materialInfo.getProjectId()) ? materialInfoEntity.getProjectId() : materialInfo.getProjectId(), materialInfoEntity.getCode(), user.getId());
+                slogenInfoService.insertSlogans(Check.isNull(materialInfo.getProjectId()) ? materialInfoEntity.getProjectId() : materialInfo.getProjectId(), materialInfoEntity.getCode(), slogans, user.getId());
             }
         }
         boolean ok = materialInfoService.updateById(materialInfo);

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.QueryGenerator;
+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;
@@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 
 /**

+ 14 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java

@@ -22,32 +22,34 @@ public interface ProjectMemberMapper extends BaseMapper<ProjectMember> {
 
     List<Long> selectProductsByUserId(@Param("userId") String userId);
 
-    List<ProjectMember> adminProjects(@Param("mediaIds")List<Integer> mediaIds);
+    List<ProjectMember> adminProjects(@Param("mediaIds") List<Integer> mediaIds);
 
-    List<ProjectMember> designLeaderProjects(@Param("companyId")String companyId ,@Param("mediaIds")List<Integer> mediaIds);
+    List<ProjectMember> designLeaderProjects(@Param("companyId") String companyId, @Param("mediaIds") List<Integer> mediaIds);
 
-    List<ProjectMember> designProjects(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
+    List<ProjectMember> designProjects(@Param("userId") String userId, @Param("mediaIds") List<Integer> mediaIds);
 
-    List<ProjectMember> operationProjects(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
+    List<ProjectMember> operationProjects(@Param("userId") String userId, @Param("mediaIds") List<Integer> mediaIds);
 
-    String getRoleCodeByUserId(@Param("userId")String userId);
+    String getRoleCodeByUserId(@Param("userId") String userId);
 
-    String getCompanyIdByUserId(@Param("userId")String userId);
+    String getCompanyIdByUserId(@Param("userId") String userId);
 
-    List<ProjectMember> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
+    List<ProjectMember> queryProjectMemberByUserId(@Param("userId") String userId, @Param("mediaIds") List<Integer> mediaIds);
 
 
-    List<ProjectMember> getSaleProjects(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
+    List<ProjectMember> getSaleProjects(@Param("userId") String userId, @Param("mediaIds") List<Integer> mediaIds);
 
     List<Long> getProjectByMap(@Param("userId") String userId);
 
-    List<Project> getProjectByUserId(@Param("userId")String userId);
+    List<Project> getProjectByUserId(@Param("userId") String userId);
 
-    List<Long> getProjectByAccountIds(@Param("accountIds")JSONArray accountIds);
+    List<Long> getProjectByAccountIds(@Param("accountIds") JSONArray accountIds);
 
-    List<Long> getProductByAccountIds(@Param("accountIds")JSONArray accountIds);
+    List<Long> getProductByAccountIds(@Param("accountIds") JSONArray accountIds);
 
     List<JSONObject> getProjectByUserIdAndMediaIds(@Param("userId") String userId, @Param("mediaIds") List<Integer> mediaIds);
 
-    List<ProjectMember> getProductIds(@Param("userId") String userId,@Param("mediaList") List<Integer> mediaList,@Param("productId") Long productId);
+    List<ProjectMember> getProductIds(@Param("userId") String userId, @Param("mediaList") List<Integer> mediaList, @Param("productId") Long productId);
+
+    List<Long> getProjectIdsByProductId(@Param("productId") Long productId, @Param("userId") String userId);
 }

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

@@ -262,6 +262,20 @@
         group by t2.id
         order by t2.create_time desc
     </select>
+    <select id="getProjectIdsByProductId" resultType="java.lang.Long">
+        SELECT
+        t1.id
+        FROM
+        ctop_project t1
+        LEFT JOIN ctop_project_member t2 ON t1.id = t2.project_id
+        WHERE
+        t2.user_id = #{userId}
+        <if test="productId != null and productId != ''">
+            AND t1.product_id = #{productId}
+        </if>
+        GROUP BY
+        t1.id
+    </select>
 
 
 </mapper>

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

@@ -50,4 +50,6 @@ public interface IProjectMemberService extends IService<ProjectMember> {
     List<ProjectMember> getMapsByProjectList(List<ProjectMember> projectMembers);
 
     List<ProjectMember> getOwnProducts(List<Integer> mediaList, Long productId);
+
+    List<Long> getProjectIdsByProductId(Long productId, String userId);
 }

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

@@ -439,7 +439,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         }
         //如果以上角色都不是的话直接查询此角色所属项目
         //   projectMemberList = memberMapper.designProjects(userId, mediaList);
-        List<ProjectMember> projectMemberList  = memberMapper.getProductIds(userId, mediaList,productId);
+        List<ProjectMember> projectMemberList = memberMapper.getProductIds(userId, mediaList, productId);
 
 
         if (null == projectMemberList) {
@@ -449,6 +449,11 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         return projectMemberList;
     }
 
+    @Override
+    public List<Long> getProjectIdsByProductId(Long productId, String userId) {
+        return memberMapper.getProjectIdsByProductId(productId, userId);
+    }
+
 }
 
 

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

@@ -238,7 +238,7 @@ public class SysUserController {
             List<SysUserVo> userList;
 
             PageHelper.startPage(pageNo, pageSize);
-            if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
+            if ("1648c7ceb4d449a9a13fbed7a8d9976c".equals(companyId) || "4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
                 userList = sysUserService.getAllUser(userName, null);
             } else {
                 userList = sysUserService.getUserListByCompany(companyId, userName);

+ 19 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/UserCompanyController.java

@@ -23,7 +23,15 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+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;
@@ -121,6 +129,16 @@ public class UserCompanyController {
         return result;
     }
 
+    @GetMapping(value = "/allCompany")
+    public Result<Object> allCompany() {
+        try {
+            return userCompanyService.allCompany();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
     /**
      * 添加
      *

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-jiaoyang.yml

@@ -127,7 +127,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-preprod.yml

@@ -127,7 +127,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -127,7 +127,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-prod2.yml

@@ -119,7 +119,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -118,8 +118,8 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password:
-    port: 6379
+    password: hcst@2020
+    port: 637900
 #mybatis plus 设置
 mybatis-plus:
   mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:cn/com/ctop/**/xml/*Mapper.xml

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/Project.java

@@ -97,6 +97,7 @@ public class Project {
      */
     private BigDecimal maxDeepCpaBid;
     private Integer checkLink;
+    private Integer materialShare;
     /**
      * 创建时间
      */

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java

@@ -138,6 +138,14 @@ public class UserAllocation implements Serializable {
      * 1 禁用
      */
     private Integer deleteComment;
+    /**
+     * 自动投放,0关闭,1开启
+     */
+    private Integer autoDelivery;
+    /**
+     * 物料类型 0-不同步,1应用包,(2人群包,3定向包)
+     */
+    private String materialType;
 
     /**
      * 修改时间

Різницю між файлами не показано, бо вона завелика
+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java


+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/ProjectMapper.java

@@ -29,4 +29,6 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<JSONObject> getListByMap(@Param("ids") Map<Long, Long> projectIdMap);
 
     List<Long> getProjectIdsByProductId(@Param("productId") Long productId);
+
+    List<Long> getProjectIdsByProductIdAndNotIn(@Param("productId") Long productId, @Param("partakeProjectIds") List<Long> partakeProjectIds);
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserCompanyMapper.java

@@ -1,7 +1,11 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.UserCompany;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.List;
 
 /**
  * 用户够公司
@@ -12,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface UserCompanyMapper extends BaseMapper<UserCompany> {
 
+    List<JSONObject> allCompany();
 }

+ 16 - 22
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -95,15 +95,15 @@
         matInfo.offline_flag
         from ctop_material_info matInfo
         left JOIN (
-            SELECT
-                video_code,
-                count(*) AS slogansCount
-            FROM
-                ctop_bytedance_video_slogen_info
-            WHERE
-                status = 1
-            GROUP BY
-                video_code
+        SELECT
+        video_code,
+        count(*) AS slogansCount
+        FROM
+        ctop_bytedance_video_slogen_info
+        WHERE
+        status = 1
+        GROUP BY
+        video_code
         ) t ON matInfo.code = t.video_code
 
         <if test="tagCode!=null">
@@ -125,24 +125,21 @@
         <if test="planId !=null and planId != ''">
             and ascription.plan_id = #{planId}
         </if>
-        <if test="projectId !=null and projectId != ''">
-            and matInfo.project_id = #{projectId}
-        </if>
-        <if test="status!=null">
+        <if test="status != null">
             and matInfo.status = #{status}
         </if>
-        <if test="userId!=null">
+        <if test="userId != null and userId != ''">
             and matInfo.user_id = #{userId}
         </if>
-        <if test="code!=null">
+        <if test="code != null">
             and matInfo.code = #{code}
         </if>
-        <if test="materialName!=null">
+        <if test="materialName != null">
             and matInfo.material_name like concat('%',#{materialName},'%')
         </if>
-        <if test="productIds!=null">
-            and matInfo.product_id in
-            <foreach item="item" index="index" collection="productIds" open="(" separator="," close=")">
+        <if test="projectIds != null and projectIds.size() != 0 ">
+            and matInfo.project_id in
+            <foreach item="item" index="index" collection="projectIds" open="(" separator="," close=")">
                 #{item}
             </foreach>
         </if>
@@ -152,9 +149,6 @@
         <if test="endDate != null and endDate != '' ">
             and matInfo.create_time &lt;= #{endDate}
         </if>
-        <if test="projectId!=null">
-            and matInfo.project_id = #{projectId}
-        </if>
         <if test="offlineFlag!=null">
             and matInfo.offline_flag = #{offlineFlag}
         </if>

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml

@@ -60,5 +60,20 @@
         from ctop_project
         where product_id = #{productId}
     </select>
+    <select id="getProjectIdsByProductIdAndNotIn" resultType="java.lang.Long">
+        select id from ctop_project
+        where 1 = 1
+        <if test="productId != null and productId != ''">
+            and product_id = #{productId}
+        </if>
+        and material_share = 0
+        <if test="partakeProjectIds != null and partakeProjectIds.size() > 0">
+            and id not in
+            <foreach item="item" index="index" collection="partakeProjectIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+
+    </select>
 
 </mapper>

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserCompanyMapper.xml

@@ -2,4 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.UserCompanyMapper">
 
+    <select id="allCompany" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT company_id as 'companyId',
+               company_name as 'companyName'
+        FROM user_company
+        GROUP BY company_id
+    </select>
+
 </mapper>

+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -78,7 +78,8 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
 
     List<MaterialInfo> getListByDate(String startDate, String endDate);
 
-    Map<String, Object> getListByParams(String tagCode, String type, Integer status, List<Long> projectIds, String materialName, String code, String startDate, String endDate, String userId, Long projectId, String clipId, String shotId, String planId, Integer offlineFlag, Integer pageNo, Integer pageSize);
 
     JSONArray getIdListByProject(Long projectId);
+
+    Map<String, Object> getListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, Integer offlineFlag, Integer pageNo, Integer pageSize);
 }

+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IProjectService.java

@@ -25,8 +25,9 @@ public interface IProjectService extends IService<Project> {
 
     List<JSONObject> getProjectListByIds(JSONArray projectIdArray);
 
-
     Map<Long, String> getProjectMap(Map<Long, Long> projectIdMap);
 
     List<Long> getProjectIdsByProductId(Long productId);
+
+    List<Long> getProjectIdsByProductIdAndNotIn(Long productId, List<Long> partakeProjectIds);
 }

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IUserCompanyService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.common.module.service;
 import cn.com.ctop.common.module.entity.SysUser;
 import cn.com.ctop.common.module.entity.UserCompany;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 /**
  * 用户够公司
@@ -18,4 +19,6 @@ public interface IUserCompanyService extends IService<UserCompany> {
     void removeByUserId(String id);
 
     UserCompany getByUserId(String userId);
+
+    Result<Object> allCompany();
 }

+ 6 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -38,6 +38,7 @@ import java.util.concurrent.Executors;
 
 import static cn.com.ctop.common.module.utils.CloudVideoProcessUtil.getTaskDetailResponse;
 import static cn.com.ctop.common.module.utils.CloudVideoProcessUtil.videoWatermarkHandle;
+
 /**
  * 素材信息
  *
@@ -770,8 +771,9 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         return materialInfoMapper.getListByDate(startDate, endDate);
     }
 
+
     @Override
-    public Map<String, Object> getListByParams(String tagCode, String type, Integer status, List<Long> productId, String materialName, String code, String startDate, String endDate, String userId, Long projectId, String clipId, String shotId, String planId,Integer offlineFlag, Integer pageNo, Integer pageSize) {
+    public Map<String, Object> getListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, Integer offlineFlag, Integer pageNo, Integer pageSize) {
         Map<String, Object> result = new HashMap<>();
         PageHelper.startPage(pageNo, pageSize);
 
@@ -788,8 +790,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             endDate = endDate + " 23:59:59";
         }
 
-
-        List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, productId, materialName, code, startDate, endDate, userId, projectId, ascription, clipId, shotId, planId,offlineFlag);
+        List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, materialName, code, startDate, endDate, userId, projectIds, ascription, clipId, shotId, planId, offlineFlag);
         List<MaterialInfo> setList = new ArrayList<>();
         PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
         if (null != dailyList && !dailyList.isEmpty()) {
@@ -862,6 +863,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     public JSONArray getIdListByProject(Long projectId) {
         return materialInfoMapper.getIdListByProject(projectId);
     }
+
+
 }
 
 

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProjectServiceImpl.java

@@ -70,4 +70,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     public List<Long> getProjectIdsByProductId(Long productId) {
         return projectMapper.getProjectIdsByProductId(productId);
     }
+
+    @Override
+    public List<Long> getProjectIdsByProductIdAndNotIn(Long productId, List<Long> partakeProjectIds) {
+        return projectMapper.getProjectIdsByProductIdAndNotIn(productId, partakeProjectIds);
+    }
 }

+ 11 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserCompanyServiceImpl.java

@@ -9,14 +9,17 @@ import cn.com.ctop.common.module.mapper.SysUserDepartMapper;
 import cn.com.ctop.common.module.mapper.UserCompanyMapper;
 import cn.com.ctop.common.module.service.IUserCompanyService;
 import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -96,9 +99,15 @@ public class UserCompanyServiceImpl extends ServiceImpl<UserCompanyMapper, UserC
 
     @Override
     public UserCompany getByUserId(String userId) {
-        QueryWrapper<UserCompany>queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("user_id",userId);
+        QueryWrapper<UserCompany> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("user_id", userId);
         queryWrapper.last("limit 1");
         return null;
     }
+
+    @Override
+    public Result<Object> allCompany() {
+        List<JSONObject> data = userCompanyMapper.allCompany();
+        return Result.ok(data);
+    }
 }

+ 1 - 1
module-job-bytedance/src/main/resources/application-dev.yml

@@ -86,7 +86,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: ''
+    password:
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 1 - 1
module-job-bytedance/src/main/resources/application-jiaoyang.yml

@@ -101,7 +101,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: ''
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 1 - 1
module-job-bytedance/src/main/resources/application-prod.yml

@@ -101,7 +101,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: ''
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 51 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAutoSynchronousProjectMaterialJob.java

@@ -0,0 +1,51 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import com.alibaba.fastjson.JSONArray;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Component
+public class KuaishouAutoSynchronousProjectMaterialJob {
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private IKuaishouAppPackageService kuaishouAppPackageService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+    @XxlJob("autoSynchronousProjectMaterialJob")
+    public void execute() {
+        List<UserAllocation> userAllocations = userAllocationService.listByMediaId("2", 0);
+        userAllocations.forEach(userAllocation -> executorService.submit(() ->
+                synchronMaterials(userAllocation.getMaterialType(), userAllocation.getAccountId(), userAllocation.getProjectId())
+        ));
+        XxlJobHelper.log("快手物料数据同步完成");
+    }
+
+
+    private void synchronMaterials(String materialType, Long accountId, Long projectId) {
+        if (!Check.isNull(materialType) && materialType.contains("1")) {
+            JSONArray accountIds = new JSONArray();
+            accountIds.add(accountId);
+            //1 有效项目模板
+            List<Long> ids = kuaishouAppPackageService.queryByAppVersion(projectId, null, 1);
+            log.info("同步账户应用,应用模板={}", ids);
+            if (!Check.isNull(ids)) {
+                for (Long id : ids) {
+                    kuaishouAppPackageService.pushAppPackage(id, accountIds);
+                }
+            }
+        }
+    }
+}

+ 16 - 6
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCreateCreativeJob.java

@@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @Component
 public class KuaishouCreateCreativeJob {
@@ -20,6 +22,7 @@ public class KuaishouCreateCreativeJob {
     private IKuaiShouGroupTemplateService groupTemplateService;
     @Autowired
     private ICtopOauthTokenService tokenService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
 
     @XxlJob("kuaihouCreateCreative")
     public void execute() {
@@ -27,17 +30,24 @@ public class KuaishouCreateCreativeJob {
         templateQueryWrapper.eq("task_status", 2);
         templateQueryWrapper.eq("creative_status", 0);
         templateQueryWrapper.orderByAsc("create_time");
-        templateQueryWrapper.last("limit 20");
+        templateQueryWrapper.last("limit 200");
         List<KuaiShouGroupTemplate> list = groupTemplateService.list(templateQueryWrapper);
         if (Check.isNull(list)) {
             return;
         }
         for (KuaiShouGroupTemplate template : list) {
-            CtopOauthToken token = tokenService.getTokenByAccountId(template.getAccountId());
-            if (Check.isNull(token)) {
-                continue;
-            }
-            groupTemplateService.createCreative(token.getAccessToken(), template.getUnitId(), template);
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    CtopOauthToken token = tokenService.getTokenByAccountId(template.getAccountId());
+                    if (Check.isNull(token)) {
+                        return;
+                    }
+                    groupTemplateService.createCreative(token.getAccessToken(), template.getUnitId(), template);
+                }
+            });
+
+
         }
     }
 }

+ 2 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java

@@ -42,14 +42,14 @@ public class KuaishouVideoRelateCreativesJob {
     public void execute() throws Exception {
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.isEmpty()) {
-            XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");
+            XxlJobHelper.log("未获取到可用的token");
             XxlJobHelper.handleFail();
             return;
         }
         //查询有效策略的账户ID
         List<Long> accountIds = kuaishouStrategyService.queryActiveAccount();
         if (Check.isNull(accountIds) || accountIds.size() == 0) {
-            XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到有效策略账户信息");
+            XxlJobHelper.log("未获取到有效策略账户信息");
             XxlJobHelper.handleFail();
             return;
         }

+ 1 - 1
module-job-kuaishou/src/main/resources/application-jiaoyang.yml

@@ -102,7 +102,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 1 - 1
module-job-kuaishou/src/main/resources/application-preprod.yml

@@ -102,7 +102,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 1 - 1
module-job-kuaishou/src/main/resources/application-prod.yml

@@ -102,7 +102,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password: hcst@2021..
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java

@@ -99,12 +99,12 @@ public class KuaiShouVideoGetController {
      * @return
      */
     @GetMapping(value = "/labelMaterialList")
-    public Result<Object> labelMaterialList(String realname, String roleCode, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+    public Result<Object> labelMaterialList(String companyId, String realname, String roleCode, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
             if (Check.isNull(startTime) || Check.isNull(endTime)) {
                 return Result.error("请选择查询日期");
             }
-            return kuaiShouReportDailyMaterialService.labelMaterialList(realname, roleCode, startTime, endTime, pageNo, pageSize);
+            return kuaiShouReportDailyMaterialService.labelMaterialList(companyId, realname, roleCode, startTime, endTime, pageNo, pageSize);
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 3 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java

@@ -39,9 +39,9 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
 
     List<JSONObject> getVideoInfoByList(@Param("photoIdList") List<Long> photoIdList);
 
-    Long labelMaterialListTotal(@Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    Long labelMaterialListTotal(@Param("companyId") String companyId, @Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
-    List<JSONObject> labelMaterialList(@Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    List<JSONObject> labelMaterialList(@Param("companyId") String companyId, @Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
-    JSONObject labelMaterialAll(@Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    JSONObject labelMaterialAll(@Param("companyId") String companyId, @Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
 }

+ 128 - 51
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -326,9 +326,9 @@
 
     <select id="getVideoGetByPhotoId" resultType="cn.com.ctop.kuaishou.modules.report.entity.VideoGetvo">
         select signature as 'signature', channel_type as 'channelType'
-        from ctop_kuaishou_video_get
+        from ctop_etl_kuaishou_video_base_info
         where photo_id = #{photoId}
-          and signature is not null limit 1
+         and signature is not null limit 1
     </select>
 
 
@@ -445,15 +445,16 @@
         LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
@@ -461,6 +462,12 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id in(60155,60156)
         GROUP BY t1.user_id
@@ -484,55 +491,69 @@
         t3.realname,
         t3.role_name
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id in(60155,60156)
         GROUP BY t1.user_id
         ) k
         LEFT JOIN
         (
-            SELECT
+        SELECT
         t1.user_id, SUM(t5.charge) 'zhenren_charge'
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
-        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON t1.`code` = t5.signature
         WHERE t2.parent_id = 60155
         GROUP BY t1.user_id
         ) k1 ON k1.user_id =k.user_id
@@ -541,25 +562,32 @@
         SELECT
         t1.user_id,t4.signature
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id = 60155
         GROUP BY t1.user_id,t1.`code`
@@ -571,27 +599,34 @@
         SELECT
         t1.user_id, SUM(t5.charge) 'zhizuo_charge'
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
-        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON t1.`code` = t5.signature
         WHERE t2.parent_id = 60156
         GROUP BY t1.user_id
         )k3 ON k3.user_id =k.user_id
@@ -600,27 +635,34 @@
         SELECT
         t1.user_id,t4.signature
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
-        WHERE  t2.parent_id = 60156
+        WHERE t2.parent_id = 60156
         GROUP BY t1.user_id,t1.`code`
         ) t
         GROUP BY user_id
@@ -651,25 +693,32 @@
         t3.realname,
         t3.role_name
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id in(60155,60156)
         GROUP BY t1.user_id
@@ -679,12 +728,12 @@
         SELECT
         t1.user_id, SUM(t5.charge) 'zhenren_charge'
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN
@@ -692,15 +741,22 @@
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
-        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON t1.`code` = t5.signature
         WHERE t2.parent_id = 60155
         GROUP BY t1.user_id
         )k1 ON k1.user_id =k.user_id
@@ -709,25 +765,32 @@
         SELECT
         t1.user_id,t4.signature
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id = 60155
         GROUP BY t1.user_id,t1.`code`
@@ -739,27 +802,34 @@
         SELECT
         t1.user_id, SUM(t5.charge) 'zhizuo_charge'
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
-        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON t1.`code` = t5.signature
         WHERE t2.parent_id = 60156
         GROUP BY t1.user_id
         )k3 ON k3.user_id =k.user_id
@@ -768,25 +838,32 @@
         SELECT
         t1.user_id,t4.signature
         FROM ctop_material_tag_info t1
-        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
         INNER JOIN
         (
-        SELECT signature  FROM ctop_kuaishou_video_get
-        WHERE  stat_date &gt;=  #{startTime}
-        AND stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        SELECT signature FROM ctop_kuaishou_video_get
+        WHERE stat_date &gt;= #{startTime}
+        AND stat_date &lt;= concat(#{endTime},' 23:59:59')
         GROUP BY signature
         ) t4 ON t4.signature= t1.`code`
         INNER JOIN(
         SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
         LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
         LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        LEFT JOIN user_company tt4 ON tt1.id = tt4.user_id
         WHERE 1=1
+        <if test="companyId!=null">
+            AND tt4.company_id = #{companyId}
+        </if>
         <if test="realname!=null">
             and tt1.realname LIKE CONCAT('%',#{realname},'%')
         </if>
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id = 60156
         GROUP BY t1.user_id,t1.`code`

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

@@ -28,5 +28,5 @@ public interface IKuaiShouReportDailyMaterialService extends IService<KuaiShouRe
 
     List<KuaiShouReportDailyMaterial> getVideoInfoByList(List<KuaiShouReportDailyMaterial> addList, List<Long> photoIdList);
 
-    Result<Object> labelMaterialList(String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize);
+    Result<Object> labelMaterialList(String companyId,String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize);
 }

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

@@ -127,15 +127,15 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
     }
 
     @Override
-    public Result<Object> labelMaterialList(String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize) {
-        Long total = dailyMaterialMapper.labelMaterialListTotal(realname, roleCode, startTime, endTime);
+    public Result<Object> labelMaterialList(String companyId, String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize) {
+        Long total = dailyMaterialMapper.labelMaterialListTotal(companyId, realname, roleCode, startTime, endTime);
         PageHelper.startPage(pageNo, pageSize, false);
-        PageInfo pageInfo = new PageInfo(dailyMaterialMapper.labelMaterialList(realname, roleCode, startTime, endTime));
+        PageInfo pageInfo = new PageInfo(dailyMaterialMapper.labelMaterialList(companyId, realname, roleCode, startTime, endTime));
         pageInfo.setTotal(total);
         JSONObject data = new JSONObject();
         data.put("pageInfo", pageInfo);
         if (total > 0) {
-            data.put("total", dailyMaterialMapper.labelMaterialAll(realname, roleCode, startTime, endTime));
+            data.put("total", dailyMaterialMapper.labelMaterialAll(companyId, realname, roleCode, startTime, endTime));
         }
         return Result.ok(data);
     }

+ 29 - 28
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouAccountReportCtrl.java

@@ -51,7 +51,7 @@ public class KuaiShouAccountReportCtrl {
         String mediaId = requestBody.getString("mediaId");
         BigDecimal discount = requestBody.getBigDecimal("discount");
         JSONArray accounts = requestBody.getJSONArray("accountIds");
-        if(accounts.isEmpty()){
+        if (accounts.isEmpty()) {
             return resultBody;
         }
         String startDate = requestBody.getString("startDate");
@@ -59,8 +59,8 @@ public class KuaiShouAccountReportCtrl {
         try {
             Map<String, Object> sumData = kuaiShouAccountReportService.getSumDataBy(mediaId, discount, accounts, startDate, endDate);
             List<JSONObject> chartData = kuaiShouAccountReportService.getChartDataBy(mediaId, discount, accounts, startDate, endDate);
-            result.put("sumData",sumData);
-            result.put("chartData",chartData);
+            result.put("sumData", sumData);
+            result.put("chartData", chartData);
             resultBody.setResult(result);
             resultBody.setSuccess(true);
         } catch (Exception e) {
@@ -83,16 +83,16 @@ public class KuaiShouAccountReportCtrl {
         String mediaId = requestBody.getString("mediaId");
         BigDecimal discount = requestBody.getBigDecimal("discount");
         JSONArray accounts = requestBody.getJSONArray("accountIds");
-        if(accounts.isEmpty()){
+        if (accounts.isEmpty()) {
             return result;
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        int hour= requestBody.getInteger("hour");
-        String target= requestBody.getString("target");
-        String order= requestBody.getString("order");
+        int hour = requestBody.getInteger("hour");
+        String target = requestBody.getString("target");
+        String order = requestBody.getString("order");
         try {
-            List<JSONObject> listData= kuaiShouAccountReportService.getListDataBy(mediaId,discount,accounts,startDate,endDate,hour,target,order);
+            List<JSONObject> listData = kuaiShouAccountReportService.getListDataBy(mediaId, discount, accounts, startDate, endDate, hour, target, order);
             result.setResult(listData);
             result.setSuccess(true);
         } catch (Exception e) {
@@ -103,45 +103,46 @@ public class KuaiShouAccountReportCtrl {
     }
 
     /**
-     *  导出数据
+     * 导出数据
      */
     @PostMapping("/report/excel")
     public void getExcelReport(@RequestBody JSONObject requestBody,
                                HttpServletRequest request,
                                HttpServletResponse response) {
-        JSONArray columns=requestBody.getJSONArray("columns");
-        if(columns.isEmpty()){
+        JSONArray columns = requestBody.getJSONArray("columns");
+        if (columns.isEmpty()) {
             log.error("请选择需要导出的字段");
         }
-        String filed= JsonResourceUtil.joinFiled(AccountReportConstants.dicMapKs,columns);
-        List<String> titles= new ArrayList<>();
+        log.info("需要导出的字段:{}", columns);
+        String filed = JsonResourceUtil.joinFiled(AccountReportConstants.dicMapKs, columns);
+        List<String> titles = new ArrayList<>();
         titles.add("账户Id");
         titles.add("账户名称");
-        titles.addAll(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs,columns));
+        titles.addAll(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs, columns));
         //此处增加两个元素是为了保证数据有序
-        columns.add(0,"accountId");
-        columns.add(1,"authName");
+        columns.add(0, "accountId");
+        columns.add(1, "authName");
         String mediaId = requestBody.getString("mediaId");
         JSONArray accounts = requestBody.getJSONArray("accountIds");
-        if(accounts.isEmpty()){
+        if (accounts.isEmpty()) {
             return;
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        String target= requestBody.getString("target");
-        String order= requestBody.getString("order");
-        int hour= requestBody.getInteger("hour");
-        List<JSONObject> excelData= kuaiShouAccountReportService.getExcelDataBy(filed,mediaId,accounts,startDate,endDate,hour,target,order);
-        if(excelData.isEmpty()){
+        String target = requestBody.getString("target");
+        String order = requestBody.getString("order");
+        int hour = requestBody.getInteger("hour");
+        List<JSONObject> excelData = kuaiShouAccountReportService.getExcelDataBy(filed, mediaId, accounts, startDate, endDate, hour, target, order);
+        if (excelData.isEmpty()) {
             return;
         }
-        List<List<Object>> excelList= new ArrayList<>();
-        excelData.forEach(data->{
-            List<Object> temp= new ArrayList<>();
-            columns.forEach(k-> temp.add(data.get(k.toString())));
+        List<List<Object>> excelList = new ArrayList<>();
+        excelData.forEach(data -> {
+            List<Object> temp = new ArrayList<>();
+            columns.forEach(k -> temp.add(data.get(k.toString())));
             excelList.add(temp);
         });
-        try{
+        try {
             String[] headers = titles.toArray(new String[titles.size()]);
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
@@ -151,7 +152,7 @@ public class KuaiShouAccountReportCtrl {
             workbook.write(os);
             os.flush();
             os.close();
-        }catch (IOException e){
+        } catch (IOException e) {
             log.error(e.getMessage());
         }
     }

+ 2 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouYiCheReportController.java

@@ -187,9 +187,7 @@ public class KuaiShouYiCheReportController {
             directApplication.add(directApplicationJson.getString("agent"));
             directApplication.add(directApplicationJson.getString("media"));
             directApplication.add(directApplicationJson.getString("systemType"));
-            if (!Check.isNull(directApplicationJson.getString("statDate"))) {
-                directApplication.add(directApplicationJson.getString("statDate").replace("-", "/"));
-            }
+            directApplication.add(directApplicationJson.getString("statDate"));
             directApplication.add(directApplicationJson.getBigDecimal("charge"));
             directApplication.add(directApplicationJson.getBigDecimal("cashCost"));
             directApplication.add(directApplicationJson.getLong("photoShow"));
@@ -222,9 +220,7 @@ public class KuaiShouYiCheReportController {
                 List<Object> channelSubcontracting = new ArrayList();
                 channelSubcontracting.add(channelSubcontractingJson.getString("agent"));
                 channelSubcontracting.add(channelSubcontractingJson.getString("systemType"));
-                if (!Check.isNull(channelSubcontractingJson.getString("statDate"))) {
-                    channelSubcontracting.add(channelSubcontractingJson.getString("statDate").replace("-", "/"));
-                }
+                channelSubcontracting.add(channelSubcontractingJson.getString("statDate"));
                 channelSubcontracting.add(channelSubcontractingJson.getString("campaignName"));
                 channelSubcontracting.add(channelSubcontractingJson.getBigDecimal("charge"));
                 channelSubcontracting.add(channelSubcontractingJson.getBigDecimal("cashCost"));

+ 49 - 19
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml

@@ -15,7 +15,13 @@
 
     <select id="selectReportByMap" parameterType="java.util.Map" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-        t1.system_type systemType,
+        (case when t1.system_type = 'android'
+         then '安卓'
+         when t1.system_type = 'ios'
+         then 'ios'
+         else '-'
+         end
+        ) as systemType,
         t1.auth_name authName,
         ROUND(sum(t2.charge) / #{disCount},3) charge,
         sum(t2.activation) activation,
@@ -64,7 +70,13 @@
 
     <select id="selectSumReportByMap" parameterType="java.util.Map" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-        t1.system_type systemType,
+        (case when t1.system_type = 'android'
+        then '安卓'
+        when t1.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
         #{dateDesc} authName,
         ROUND(sum(t2.charge) / #{disCount},3) charge,
         sum(t2.activation) activation,
@@ -121,19 +133,25 @@
         '未知'
         END
         ) media,
-        t1.system_type systemType,
-        t2.stat_date statDate,
+        (case when t1.system_type = 'android'
+        then '安卓'
+        when t1.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
+        DATE_FORMAT(t2.stat_date,'%Y/%c/%d')  statDate,
         sum(t2.charge) charge,
         ROUND(sum(t2.charge) / #{disCount}, 3) cashCost,
-        sum(t2.photo_show) photoShow,
-        sum(t2.photo_click) photoClick,
+        sum(t2.aclick + t2.photo_show) photoShow,
+        sum(t2.photo_click + t2.bclick) photoClick,
         (
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
         CAST(ROUND(
         (
-        sum(t2.photo_click) / sum(t2.photo_show)
+        sum(t2.photo_click + t2.bclick) / sum(t2.photo_show + t2.aclick)
         ) * 100,
         3
         ) AS CHAR)
@@ -281,19 +299,25 @@
         '未知'
         END
         ) media,
-        t2.system_type systemType,
-        t2.stat_date statDate,
+        (case when t2.system_type = 'android'
+        then '安卓'
+        when t2.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
+        DATE_FORMAT(t2.stat_date,'%Y/%c/%d') statDate,
         sum(t2.charge) charge,
         ROUND(sum(t2.charge) / #{disCount}, 3) cashCost,
-        sum(t2.photo_show) photoShow,
-        sum(t2.photo_click) photoClick,
+        sum(t2.aclick + t2.photo_show) photoShow,
+        sum(t2.photo_click + t2.bclick) photoClick,
         (
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
         CAST( ROUND(
         (
-        sum(t2.photo_click) / sum(t2.photo_show)
+        sum(t2.photo_click + t2.bclick) / sum(t2.photo_show + t2.aclick)
         ) * 100,
         3
         ) AS CHAR)
@@ -446,7 +470,7 @@
         <if test="projectId != null">
             and t.project_id = #{projectId}
         </if>
-        <if test="systemType != null">
+        <if test="statDate != null">
             and t1.stat_date = #{statDate}
         </if>
         ) t2
@@ -471,20 +495,26 @@
         '未知'
         END
         ) media,
-        t2.system_type systemType,
-        t2.stat_date statDate,
+        (case when t2.system_type = 'android'
+        then '安卓'
+        when t2.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
+        DATE_FORMAT(t2.stat_date,'%Y/%c/%d') statDate,
         t2.campaignName campaignName ,
         sum(t2.charge) charge,
         ROUND(sum(t2.charge) / #{disCount}, 3) cashCost,
-        sum(t2.photo_show) photoShow,
-        sum(t2.photo_click) photoClick,
+        sum(t2.aclick + t2.photo_show) photoShow,
+        sum(t2.photo_click + t2.bclick) photoClick,
         (
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
         CAST( ROUND(
         (
-        sum(t2.photo_click) / sum(t2.photo_show)
+        sum(t2.photo_click + t2.bclick) / sum(t2.photo_show + t2.aclick)
         ) * 100,
         3
         ) AS CHAR)
@@ -626,7 +656,7 @@
         <if test="projectId != null">
             and t.project_id = #{projectId}
         </if>
-        <if test="systemType != null">
+        <if test="statDate != null">
             and t1.stat_date = #{statDate}
         </if>
         ) t2

+ 1 - 1
module-kuaishou/src/main/resources/json_template/kuaishou_filed_mapping.json

@@ -192,7 +192,7 @@
     "comment": "按钮点击率"
   },
   "play3sRate": {
-    "filed": "CASE WHEN sum(CEIL(t1.play_3s_ratio * t1.aclick)) / sum(t1.aclick) IS NULL THEN 0 ELSE round(sum(CEIL(t1.play_3s_ratio * t1.aclick)) / sum(t1.aclick)*100,2)end as play3sRate ",
+    "filed": "(CASE WHEN  sum(t1.aclick) != 0 THEN round( sum(t1.play_3s_ratio * t1.aclick) / sum(t1.aclick) * 100,2) ELSE 0 END )AS play3sRate ",
     "comment": "3s播放率"
   },
   "activeRate": {