Forráskód Böngészése

Merge remote-tracking branch 'origin/finance' into finance

yangzian 3 éve
szülő
commit
ba7b0a063a
40 módosított fájl, 1081 hozzáadás és 542 törlés
  1. 1 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 9 5
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CreateSheetServiceImpl.java
  3. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java
  4. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java
  5. 7 7
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java
  6. 70 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java
  7. 6 3
      jeecg-boot-finance/src/main/resources/application-dev.yml
  8. 10 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java
  9. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  10. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCampaignLevelOperationRecord.java
  11. 18 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCreativeLevelOperationRecord.java
  12. 32 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouUnitLevelOperationRecord.java
  13. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouUnitLevelOperationRecordMapper.java
  14. 26 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouUnitLevelOperationRecordMapper.xml
  15. 2 16
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  16. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouProjectCreateCreativeServiceImpl.java
  17. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupController.java
  18. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java
  19. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  20. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java
  21. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  22. 6 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  23. 91 28
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/controller/KuaishouChannelController.java
  24. 16 13
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/entity/KuaishouChannel.java
  25. 11 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/entity/KuaishouChannelCreateStrategy.java
  26. 6 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelMapper.java
  27. 70 67
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml
  28. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelRelMapper.xml
  29. 5 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java
  30. 432 349
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java
  31. 21 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/controller/DocumentLibraryController.java
  32. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/DocumentLibraryMapper.java
  33. 11 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/xml/DocumentLibraryMapper.xml
  34. 4 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/DocumentLibraryService.java
  35. 62 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/impl/DocumentLibraryServiceImpl.java
  36. 95 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouAudienceReportDailyController.java
  37. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyService.java
  38. 4 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouReportAccountHourlyServiceImpl.java
  39. 23 11
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  40. 6 1
      jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-dev.yml

+ 1 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -229,6 +229,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/material/bytedance/report/**", "anon");
         filterChainDefinitionMap.put("/cwjsSaleAssistantInfo/**", "anon");
         filterChainDefinitionMap.put("/task/kuaishouHostingTask/**", "anon");
+        filterChainDefinitionMap.put("/audienceReport/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 9 - 5
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CreateSheetServiceImpl.java

@@ -117,6 +117,8 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
         cell.setCellStyle(style);
         sheet.autoSizeColumn(0, true);
         List<SheetBytedanceVo> resultList = new ArrayList<>(accountIdList.size());
+        //获取当前年月的 第一天 和 最后一天
+        Map<String,String> timeMap = SettlementUtil.getFirstAndLastDayOfMonth(uploadYears);
         //查看账户数据
         List<Map<String,Object>> list = reportSettlementMapper.getAccountTransactionDayBytedanceSheet(accountIdList,uploadYears);
         for (Map<String,Object> map : list) {
@@ -130,7 +132,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
             List<String> policyDaysList = new ArrayList<>();
             if (!Check.isNull(map.get("productName"))){
                 //查询 头条利润表  返点类型和比列
-                List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName")+"",null,"1",uploadYears+"-01",uploadYears+"-31");
+                List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName")+"",null,"1",timeMap.get("startTime"),timeMap.get("endTime"));
                 List listPolicyTIme = new ArrayList();
                 for (Map<String, Object> rate : rateMap) {
                     listPolicyTIme.add(rate.get("policyStartDate"));
@@ -187,7 +189,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
 
             //不使用政策 的时间段
             // 获取两个日期之间 所有的 时间 年-月-日
-            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(uploadYears+"-01",uploadYears+"-31");
+            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(timeMap.get("startTime"),timeMap.get("endTime"));
             // 时间差集(所有时间段 - 使用政策的时间段)
             List<String>  reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
             //差集拼接  开始 和 结束时间
@@ -332,7 +334,9 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
 
         List<SheetKuaiShouVo> resultList = new ArrayList<>(accountIdList.size());
         //查询该时段 快手 数据
-        List<Map<String,Object>> accountList = reportSettlementMapper.getProfitKuaiShouAccountCostSheet(accountIdList,uploadYears+"-01",uploadYears+"-31");
+        //获取当前年月的 第一天 和 最后一天
+        Map<String,String> timeMap = SettlementUtil.getFirstAndLastDayOfMonth(uploadYears);
+        List<Map<String,Object>> accountList = reportSettlementMapper.getProfitKuaiShouAccountCostSheet(accountIdList,timeMap.get("startTime"),timeMap.get("endTime"));
         for (Map<String,Object> map : accountList) {
             SheetKuaiShouVo voSource = new SheetKuaiShouVo();
             voSource.setAccountId(map.get("accountId")+"");
@@ -343,7 +347,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
             List<String> policyDaysList = new ArrayList<>();
             if (!Check.isNull(map.get("productName"))) {
                 //查询 快手利润表  返点类型和比列
-                List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName") + "", null,"2", uploadYears+"-01",uploadYears+"-31");
+                List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName") + "", null,"2", timeMap.get("startTime"),timeMap.get("endTime"));
                 List listPolicyTIme = new ArrayList();
                 for (Map<String, Object> rate : rateMap) {
                     listPolicyTIme.add(rate.get("policyStartDate"));
@@ -406,7 +410,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
 
             //不使用政策 的时间段
             // 获取两个日期之间 所有的 时间 年-月-日
-            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(uploadYears+"-01",uploadYears+"-31");
+            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(timeMap.get("startTime"),timeMap.get("endTime"));
             // 时间差集(所有时间段 - 使用政策的时间段)
             List<String> reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
             //差集拼接  开始 和 结束时间

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java

@@ -33,6 +33,7 @@ public class ExportReportController {
     @Autowired
     private ISysUserService userService;
 
+    //结算单-日期修改-master
     @ApiOperation(value = "财务结算-结算单导出-头条", notes = "财务结算-结算单导出-头条")
     @GetMapping(value = "/settlementReportBytedance")
     public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) throws Exception{
@@ -53,7 +54,6 @@ public class ExportReportController {
         if(null == date||date.equals("")){
             paramsVo.setUploadYears(DateUtils.formatDate(new Date(),"yyyy-MM"));
         }
-        log.info("快手结算单----------{}",paramsVo);
         return reportSettlementService.settlementReportKuaiShou(paramsVo,response,user);
     }
 

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java

@@ -47,7 +47,7 @@ public class SettlementFileController {
     public Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo,
                                                                        @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                                        @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
-        //查询用户角色
+        //查询用户角色 -master
         String roleCode = sysRoleService.getRoleCodeByUserId(paramsVo.getCreateUserId());
         List<String> userIds = new ArrayList<>();
         //管理员 || 财务

+ 7 - 7
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -252,8 +252,10 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                         BufferedImage bufferImg = createExcelByTemplate.toBufferedImage(imageTookittitle);
                         ImageIO.write(bufferImg, imagePath.substring(imagePath.lastIndexOf(".") + 1), byteArrayOut);
                         int startIndex = settlementList.size() +6;
+                        int hight = (int)Math.round(bufferImg.getHeight() / 28.35 / (sheet.getDefaultRowHeightInPoints() / 28.35));
+                        int width = (int)Math.round(bufferImg.getWidth() / (96/2.54) / ((sheet.getColumnWidthInPixels(settlementList.size()) / (96 / 2.54))));
                         //anchor主要用于设置图片的属性
-                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+50*j, (short) 25, startIndex+(5*j)+50*(j+1));
+                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+hight*j, (short) width, startIndex+(5*j)+hight*(j+1));
                         //HSSFClientAnchor anchor2 = new HSSFClientAnchor(0, 0, 255, 255, (short) 5, settlementList.size() + 40, (short) 10, 40 * 2);
                         anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
                         //插入图片
@@ -312,11 +314,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         }
         //查询财务模块中已上传的账户
         List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
-        log.info("快手结算单----已上传的账户------{}",settlementAccountList);
-
         //查询已绑定账户
         allocations = userAllocationMapper.getAccountInfoBySalesId(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
-        log.info("快手结算单------已绑定账户----{},{}",allocations.size(),allocations);
         return mergeAccountId(settlementAccountList,allocations,uploadYears);
     }
 
@@ -363,8 +362,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             //查询 需要导出的数据的账户id
             List<String> accountIdList = this.getAccountId(paramsVo,user);
 
-            log.info("最终的账户{}==={}",accountIdList.size(),accountIdList);
-
 
             if (Check.isNull(accountIdList)){
                 return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息");
@@ -496,7 +493,10 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                         ImageIO.write(bufferImg, imagePath.substring(imagePath.lastIndexOf(".") + 1), byteArrayOut);
                         //anchor主要用于设置图片的属性
                         int startIndex = settlementList.size()+7;
-                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+50*j, (short) 25, startIndex+(5*j)+50*(j+1));
+                        int hight = (int)Math.round(bufferImg.getHeight() / 28.35 / (sheet.getDefaultRowHeightInPoints() / 28.35));
+                        int width = (int)Math.round(bufferImg.getWidth() / (96/2.54) / ((sheet.getColumnWidthInPixels(settlementList.size()) / (96 / 2.54))));
+                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+hight*j, (short) width, startIndex+(5*j)+hight*(j+1));
+
                         //HSSFClientAnchor anchor2 = new HSSFClientAnchor(0, 0, 255, 255, (short) 5, settlementList.size() + 40, (short) 10, 40 * 2);
                         anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
                         //插入图片

+ 70 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java

@@ -294,4 +294,74 @@ public class SettlementUtil {
         return dayAfter;
     }
 
+
+    /**
+     * 获取当前日期 年-月 的 第一天和最后一天
+     */
+    public static Map<String,String> getFirstAndLastDayOfMonth(String yearMonth){
+        Map<String,String> map = new HashMap<>();
+        String[] year = yearMonth.split("-");
+        Integer y = Integer.valueOf(year[0]);
+        Integer m = Integer.valueOf(year[1]);
+        String firstDay = getFirstDayOfMonth(y,m);
+        String lastDay = getLastDayOfMonth(y,m);
+        map.put("startTime",firstDay);
+        map.put("endTime",lastDay);
+        return map;
+    }
+
+
+
+
+
+    /**
+     * 获取指定年月的第一天
+     * @param year
+     * @param month
+     * @return
+     */
+    public static String getFirstDayOfMonth(int year, int month) {
+        Calendar cal = Calendar.getInstance();
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置月份
+        cal.set(Calendar.MONTH, month-1);
+        //获取某月最小天数
+        int firstDay = cal.getMinimum(Calendar.DATE);
+        //设置日历中月份的最小天数
+        cal.set(Calendar.DAY_OF_MONTH,firstDay);
+        //格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(cal.getTime());
+    }
+
+
+    /**
+     * 获取指定年月的最后一天
+     * @param year
+     * @param month
+     * @return
+     */
+    public static String getLastDayOfMonth(int year, int month) {
+        Calendar cal = Calendar.getInstance();
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置月份
+        cal.set(Calendar.MONTH, month-1);
+        //获取某月最大天数
+        int lastDay = cal.getActualMaximum(Calendar.DATE);
+        //设置日历中月份的最大天数
+        cal.set(Calendar.DAY_OF_MONTH, lastDay);
+        //格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(cal.getTime());
+    }
+
+
+    public static void main(String[] args) {
+        System.out.println(getFirstAndLastDayOfMonth("2021-02").get("startTime"));;
+        System.out.println(getFirstAndLastDayOfMonth("2021-02").get("endTime"));;
+    }
+
+
 }

+ 6 - 3
jeecg-boot-finance/src/main/resources/application-dev.yml

@@ -106,10 +106,13 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.165.84:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-          username: hcst
-          password: hcst@2020
+#          url: jdbc:mysql://139.186.165.84:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+#          username: hcst
+#          password: hcst@2020
           driver-class-name: com.mysql.jdbc.Driver
+          url: jdbc:mysql://139.186.27.96:3390/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          username: data
+          password: hcst@2021
           # 多数据源配置
           #multi-datasource1:
           #url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai

+ 10 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java

@@ -2,9 +2,11 @@ package cn.com.ctop.common.module.service.impl;
 
 import cn.com.ctop.common.module.entity.BindAccountAuth;
 import cn.com.ctop.common.module.entity.OauthConfig;
+import cn.com.ctop.common.module.entity.OauthDetail;
 import cn.com.ctop.common.module.mapper.BindAccountAuthMapper;
 import cn.com.ctop.common.module.service.IBindAccountAuthService;
 import cn.com.ctop.common.module.service.IOauthConfigService;
+import cn.com.ctop.common.module.service.IOauthDetailService;
 import cn.com.ctop.common.module.utils.BytedanceInterfaceConstant;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
@@ -69,6 +71,8 @@ public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMappe
 
     @Autowired
     private IOauthConfigService oauthConfigService;
+    @Autowired
+    private IOauthDetailService detailService;
 
     @Override
     public String getKuaishouCodeUrl(JSONObject state) throws UnsupportedEncodingException {
@@ -78,10 +82,15 @@ public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMappe
         OauthConfig config = oauthConfigService.getById(id);
         state.put("appId", config.getAppId());
         state.put("callbackUrl", config.getCallbackUrl());
+        OauthDetail detail = new OauthDetail();
+        detail.setDetailText(state.toJSONString());
+        detailService.save(detail);
+
+
         sb.append(PropertiesUtils.getValue("kuaishou_config", "kuaishou_auth_url"))
                 .append(KuaishouInterfaceConstant.AUTH_PATH)
                 .append("?app_id=" + config.getAppId())
-                .append("&state=" + URLEncoder.encode(URLEncoder.encode(URLEncoder.encode(state.toJSONString()))))
+                .append("&state=" + detail.getId())
                 .append("&redirect_uri=" + URLEncoder.encode(config.getRedirectUri(), "UTF-8"));
         if (config.getOauthType() != 1) {
             sb.append("&scope=%5B%22report_service%22%2C%22ad_query%22%2C%22account_service%22%2C%22ad_manage%22%5D");

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -55,6 +55,11 @@ public class KuaishouInterfaceConstant {
      * 创建广告创意
      */
     public static final String AD_CREATIVE_CREATE = "/rest/openapi/v2/creative/create";
+
+    /**
+     * 批量创建&修改创意
+     */
+    public static final String AD_CREATIVE_BATCH_CREATE = "/rest/openapi/v2/creative/batch/update";
     /**
      * 程序化创意 2.0
      */

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCampaignLevelOperationRecord.java

@@ -92,6 +92,21 @@ public class AiKuaishouCampaignLevelOperationRecord {
         this.createTime = new Date();
     }
 
+    public AiKuaishouCampaignLevelOperationRecord(AiKuaishouAccountAutoStrategy strategy, Long campaignId, Integer code, String message,String campaignName,String campaignUuid) {
+        this.accountId = strategy.getAccountId();
+        this.dayBudget = strategy.getCampaignDayBudget().longValue();
+        this.dayBudgetSchedule = strategy.getCampaignDayBudgetSchedule();
+        this.campaignType = strategy.getCampaignType();
+        this.campaignId = campaignId;
+        this.status = code;
+        this.message = message;
+        this.operationType = 1;
+        this.createTime = new Date();
+        this.campaignName = campaignName;
+        this.aiStrategyUuid = campaignUuid;
+        this.createType = 3;
+    }
+
     public AiKuaishouCampaignLevelOperationRecord(KuaishouProjectStrategy strategy, Long campaignId, Integer code, String message) {
         this.accountId = strategy.getAccountId();
         this.dayBudget = strategy.getCampaignDayBudget();

+ 18 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCreativeLevelOperationRecord.java

@@ -1,9 +1,11 @@
 package cn.com.ctop.kuaishou.modules.ai.entity;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
+import org.springframework.beans.BeanUtils;
 
 import java.util.Date;
 
@@ -155,4 +157,20 @@ public class AiKuaishouCreativeLevelOperationRecord {
      * 1:账户自动投放 2:项目自动投放
      */
     private Integer createType;
+
+    public AiKuaishouCreativeLevelOperationRecord() {
+
+    }
+
+    public AiKuaishouCreativeLevelOperationRecord(AiKuaishouAccountAutoStrategy strategy, Integer creativeCode, JSONObject creativeParams, String creativeMessage, Long unitId, String uuid) {
+        BeanUtils.copyProperties(strategy, this);
+        this.status = creativeCode;
+        this.description = creativeParams.getString("description");
+        this.photoId = creativeParams.getString("photo_id");
+        this.message = creativeMessage;
+        this.unitId = unitId;
+        this.aiStrategyUuid = uuid;
+        this.createTime = new Date();
+        this.createType = 3;
+    }
 }

+ 32 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouUnitLevelOperationRecord.java

@@ -1,9 +1,11 @@
 package cn.com.ctop.kuaishou.modules.ai.entity;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
+import org.springframework.beans.BeanUtils;
 
 import java.util.Date;
 
@@ -193,7 +195,7 @@ public class AiKuaishouUnitLevelOperationRecord {
     private Integer gender;
     /**
      * 创建类型
-     * 1:账户自动投放 2:项目自动投放
+     * 1:账户自动投放 2:项目自动投放 3 账户重构
      */
     private Integer createType;
     /**
@@ -313,9 +315,38 @@ public class AiKuaishouUnitLevelOperationRecord {
      */
     private Integer assetMining;
     /**
+     * 本地定向ID
+     */
+    private Long autoTargetId;
+
+    /**
+     * 渠道号Id
+     */
+    private Long channelId;
+
+    /**
      * 深度转化目标出价
      */
     private Integer deepConversionBid;
     private Long targetCombineId;
 
+    public AiKuaishouUnitLevelOperationRecord() {
+
+    }
+
+    public AiKuaishouUnitLevelOperationRecord(AiKuaishouAccountAutoStrategy strategy, JSONObject unitParams, Integer unitCode, String unitMessage, String strategyUuid, Long autoTargetId, Long channelId) {
+        BeanUtils.copyProperties(strategy, this);
+        this.groupName = unitParams.getString("unit_name");
+        this.campaignId = unitParams.getLong("campaign_id");
+        this.cpaBid = unitParams.getInteger("cpa_bid");
+        this.bid = unitParams.getInteger("bid");
+        this.deepConversionBid = unitParams.getInteger("deep_conversion_bid");
+        this.createTime = new Date();
+        this.status = unitCode;
+        this.message = unitMessage;
+        this.aiStrategyUuid = strategyUuid;
+        this.createType = 3;
+        this.channelId = channelId;
+        this.autoTargetId = autoTargetId;
+    }
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouUnitLevelOperationRecordMapper.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.ai.mapper;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
 import java.util.List;
@@ -15,5 +16,5 @@ import java.util.List;
 public interface AiKuaishouUnitLevelOperationRecordMapper extends BaseMapper<AiKuaishouUnitLevelOperationRecord> {
     List<AiKuaishouUnitLevelOperationRecord> selectAllByAccountId(Date startDate, Date endDate);
     List<Long> selectAllAccountIds(Date startDate, Date endDate);
-    List<AiKuaishouUnitLevelOperationRecord> selectAllByAccountIdAndDate(Long accountId, Date startDate, Date endDate);
+    List<AiKuaishouUnitLevelOperationRecord> selectAllByAccountIdAndDate(@Param("accountId") Long accountId, @Param("startDate") Date startDate,@Param("endDate") Date endDate);
 }

+ 26 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouUnitLevelOperationRecordMapper.xml

@@ -1,14 +1,35 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouUnitLevelOperationRecordMapper">
-    <select id="selectAllByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord">
-        select distinct account_id,campaign_id,unit_id from ctop_ai_kuaishou_unit_level_operation_record where unit_id is not null and  create_time &gt;= #{startDate} and create_time &lt;= #{endDate} and account_id in (select account_id from ctop_user_allocation where project_id = 458) group by account_id,campaign_id,unit_id
+    <select id="selectAllByAccountId"
+            resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord">
+        select distinct account_id, campaign_id, unit_id
+        from ctop_ai_kuaishou_unit_level_operation_record
+        where unit_id is not null
+          and create_time &gt;= #{startDate}
+          and create_time &lt;= #{endDate}
+          and account_id in (select account_id from ctop_user_allocation where project_id = 458)
+        group by account_id, campaign_id, unit_id
     </select>
-    <select id="selectAllByAccountIdAndDate" resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord">
-        select distinct account_id,campaign_id,unit_id from ctop_ai_kuaishou_unit_level_operation_record where unit_id is not null and unit_type = 4 and create_time &gt;= #{startDate} and create_time &lt;= #{endDate} and account_id = #{accountId} group by account_id,campaign_id,unit_id
+    <select id="selectAllByAccountIdAndDate"
+            resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord">
+        select distinct account_id, campaign_id, unit_id
+        from ctop_ai_kuaishou_unit_level_operation_record
+        where unit_id is not null
+          and unit_type = 4
+          and create_time &gt;= #{startDate}
+          and create_time &lt;= #{endDate}
+          and account_id = #{accountId}
+        group by unit_id
     </select>
 
     <select id="selectAllAccountIds" resultType="long">
-        select distinct account_id from ctop_ai_kuaishou_unit_level_operation_record where unit_id is not null and  create_time &gt;= #{startDate} and create_time &lt;= #{endDate} and account_id in (select account_id from ctop_user_allocation where project_id = 458) group by account_id
+        select distinct account_id
+        from ctop_ai_kuaishou_unit_level_operation_record
+        where unit_id is not null
+          and create_time &gt;= #{startDate}
+          and create_time &lt;= #{endDate}
+          and account_id in (select account_id from ctop_user_allocation where project_id = 458)
+        group by account_id
     </select>
 </mapper>

+ 2 - 16
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -801,7 +801,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Long unitNum = customUnitCnt * hour / 20;
         log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -834,7 +834,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         log.info("{}当天可创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -1439,20 +1439,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         return Long.valueOf(bidString);
     }
 
-    private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
-        JSONArray result = new JSONArray();
-        if (null == scenceArray || scenceArray.isEmpty()) {
-            return result;
-        }
-        for (int i = 0; i < scenceArray.size(); i++) {
-            Integer senceId = scenceArray.getInteger(i);
-            if (senceId != 5 && senceId != 3) {
-                result.add(senceId);
-            }
-        }
-        return result;
-    }
-
     /**
      * 获取定向包
      *

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouProjectCreateCreativeServiceImpl.java

@@ -145,7 +145,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         int unitNum = customUnitCnt * hour / 20;
         log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         int remindCnt = unitNum - unitCreateCnt;
         int concat = strategy.getSourceMaterial().contains("3") ? 3 : 0;
@@ -185,7 +185,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
             }
             log.info("{}可创建组总数:{}", strategy.getAccountId(), customUnitCnt);
             //查询当前账户创建自定义类型组数量
-            int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
+            int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
             log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
             int remindCnt = customUnitCnt - unitCreateCnt;
             if (remindCnt >= 1) {

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupController.java

@@ -184,7 +184,7 @@ public class KuaiShouGroupController {
     @GetMapping(value = "/queryToDayBuiltCount")
     public Result<Object> queryToDayBuiltCount(Long accountId) {
         try {
-            int count = kuaiShouGroupService.queryToDayBuiltCount(accountId);
+            int count = kuaiShouGroupService.queryToDayBuiltCount(accountId, 4);
             return Result.ok(600 - count);
         } catch (Exception e) {
             e.printStackTrace();

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java

@@ -30,7 +30,7 @@ public interface KuaiShouGroupMapper extends BaseMapper<KuaiShouGroup> {
 
     List<KuaiShouGroup> queryUnitInfoByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
 
-    Integer queryToDayBuiltCount(@Param("accountId") Long accountId, @Param("date") String date);
+    Integer queryToDayBuiltCount(@Param("accountId") Long accountId, @Param("date") String date,@Param("unitType") Integer unitType);
 
     void deleteByAccountId(@Param("accountId") Long accountId);
 

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml

@@ -139,7 +139,8 @@
         SELECT count(1) FROM ctop_kuaishou_group
         WHERE account_id = #{accountId}
           AND create_channel =1
-          AND LOCATE(#{date}, group_create_time)
+          AND group_create_time like concat(#{date},'%')
+          AND unit_type = #{unitType}
     </select>
     <select id="getNewDataByAccountIdAndDate" resultType="java.lang.Integer">
      select

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java

@@ -39,7 +39,7 @@ public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
 
     KuaiShouGroup selectGroupByUnitId(Long accountId, Long unitId);
 
-    Integer queryToDayBuiltCount(Long accountId);
+    Integer queryToDayBuiltCount(Long accountId,Integer unitType);
 
     void deleteByAccountId(Long accountId);
 

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -132,9 +132,9 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     }
 
     @Override
-    public Integer queryToDayBuiltCount(Long accountId) {
+    public Integer queryToDayBuiltCount(Long accountId,Integer unitType) {
         String date = DateUtil.formatDate(new Date());
-        return groupMapper.queryToDayBuiltCount(accountId, date);
+        return groupMapper.queryToDayBuiltCount(accountId, date,unitType);
     }
 
     @Override

+ 6 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -2080,15 +2080,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 if (code == 0) {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
-                        JSONArray add_creative_ids = dataJson.getJSONArray("add_creative_ids");
-                        if (!Check.isNull(add_creative_ids)) {
+                        JSONArray addCreativeIds = dataJson.getJSONArray("add_creative_ids");
+                        if (!Check.isNull(addCreativeIds)) {
                             Thread thread = new Thread() {
                                 @Override
                                 public void run() {
                                     try {
                                         Thread.sleep(100);
-                                        getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
-                                        createLandPageAndUnit(requestJson, add_creative_ids);
+                                        getCreativeByCreativeIds(accessToken, advertiserId, addCreativeIds);
+                                        createLandPageAndUnit(requestJson, addCreativeIds);
                                     } catch (InterruptedException e) {
                                         e.printStackTrace();
                                     }
@@ -2102,7 +2102,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("code", 0);
                         returnMap.put("message", "success");
                         returnMap.put("success", true);
-                        returnMap.put("count", add_creative_ids.size());
+                        returnMap.put("count", addCreativeIds.size());
+                        returnMap.put("ids",addCreativeIds);
                     }
                 } else {
                     if (code == 500000 && count <= 4) {

+ 91 - 28
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/controller/KuaishouChannelController.java

@@ -68,17 +68,17 @@ public class KuaishouChannelController {
      * 查询渠道号管理首页数据
      */
     @GetMapping(value = "/channelManagementHome")
-    public Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId, String userId,
-                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+    public Result<Object> channelManagementHome(KuaishouChannel kuaishouChannel, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
-            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-            if ("admin".equals(roleCode) || "sale".contains(roleCode) || "meidaManager".equals(roleCode)) {
-                userId = null;
+            String roleCode = sysRoleService.getRoleCodeByUserId(kuaishouChannel.getUserId());
+            if (Check.isNull(roleCode)) {
+                return Result.error("缺失 人员信息");
+            }
+            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+                kuaishouChannel.setUserId(null);
             }
-
             PageHelper.startPage(pageNo, pageSize);
-            return kuaishouChannelService.channelManagementHome(productId, projectId, accountId, userId);
+            return kuaishouChannelService.channelManagementHome(kuaishouChannel);
         } catch (Exception e) {
             e.printStackTrace();
             return Result.error("查询渠道号管理首页数据异常");
@@ -92,10 +92,14 @@ public class KuaishouChannelController {
     @GetMapping(value = "/channelNumberDetails")
     public Result<Object> channelNumberDetails(KuaishouChannel kuaishouChannel, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
-            if (Check.isNull(kuaishouChannel.getAccountId()) && Check.isNull(kuaishouChannel.getProjectId())) {
+            if (Check.isNull(kuaishouChannel.getAccountId())) {
                 return Result.error("请选择账户");
             }
             return kuaishouChannelService.channelNumberDetails(kuaishouChannel, pageNo, pageSize);
+
+
+
+
         } catch (Exception e) {
             e.printStackTrace();
             return Result.error("查询渠道号详情异常");
@@ -139,10 +143,10 @@ public class KuaishouChannelController {
 
 
     /**
-     * 修改渠道号
+     * 修改渠道号状态
      */
-    @GetMapping(value = "/updateChannel")
-    public Result<Object> updateChannel(KuaishouChannel channel) {
+    @GetMapping(value = "/updateChannelState")
+    public Result<Object> updateChannelState(KuaishouChannel channel) {
         try {
             if (Check.isNull(channel.getId())) {
                 return Result.error("缺失参数");
@@ -161,6 +165,41 @@ public class KuaishouChannelController {
     }
 
     /**
+     * 修改首页账户渠道号状态
+     */
+    @GetMapping(value = "/updateAccountChannelState")
+    public Result<Object> updateAccountChannelState(KuaishouChannel channel) {
+        try {
+            if (Check.isNull(channel.getAccountId())) {
+                return Result.error("缺失参数");
+            }
+            QueryWrapper<KuaishouChannel> wrapper = new QueryWrapper<>();
+            wrapper.eq("account_id", channel.getAccountId());
+            kuaishouChannelService.update(channel, wrapper);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("修改渠道号异常");
+        }
+        return Result.ok("修改成功");
+    }
+
+    /**
+     * 修改渠道号
+     */
+    @GetMapping(value = "/updateChannels")
+    public Result<Object> updateChannels(KuaishouChannel channel) {
+        try {
+            if (Check.isNull(channel.getAccountId())||Check.isNull(channel.getUserId())) {
+                return Result.error("缺失参数");
+            }
+            return kuaishouChannelService.updateChannels(channel);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("修改渠道号异常");
+        }
+    }
+
+    /**
      * 导出单品模板
      */
     @GetMapping("/exportChannelTemplate")
@@ -172,28 +211,46 @@ public class KuaishouChannelController {
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
-            String[] titles = {"产品(固定项,勿修改)", "项目(固定项,勿修改)", "使用范围(1代表账户,2代表项目)", "账户ID(和项目对应)", "渠道号创建人(固定项,勿修改)", "渠道号(如:数字加字母)", "渠道号名称", "下载链接", "应用包名", "应用名称", "应用标记", "隐私政策链接"
-                    , "第三方点击监测链接", "是否关联单品(0代表不关联,1代表关联)", "关联单品名称", "使用层级(账户:account,计划:plan,组:group)", "是否循环(0代表不循环,1代表循环)", "循环次数", "调起链接(选填)", "第三方actionBar监测链接(选填)"};
+            String[] titles = {
+                    "产品(固定项,勿修改)",
+                    "项目(固定项,勿修改)",
+                    "渠道号创建人(固定项,勿修改)",
+                    "使用范围(1代表账户,2代表项目)",
+                    "账户ID(和项目对应)",
+                    "渠道号(如:数字加字母)",
+                    "渠道号名称",
+                    "下载链接",
+                    "应用包名",
+                    "应用名称",
+                    "应用标记",
+                    "隐私政策链接",
+                    "第三方点击监测链接",
+                    "是否关联单品(0代表不关联,1代表关联)",
+                    "关联单品名称",
+                    "使用层级(账户:account,计划:plan,组:group)",
+                    "是否循环(0代表不循环,1代表循环)",
+                    "调起链接(选填)",
+                    "第三方actionBar监测链接(选填)"
+            };
             List<List<Object>> list = new ArrayList<>();
             List<Object> ids = new ArrayList<>();
             ids.add(productId);//产品
             ids.add(projectId);//项目
+            ids.add(userId);//渠道号创建人
             ids.add(1);//使用范围(1项目,2账户)
             ids.add(23212);//账户ID
-            ids.add(userId);//渠道号创建人
             ids.add("KS_0001");//渠道号(数字加字母)
             ids.add("快手0001");//渠道号名称
             ids.add("http://test.com.cn");//下载链接
             ids.add("com.test.hcst");//应用包名
             ids.add("示例包_HCST");//应用名称
             ids.add("hcst");//应用标记
-            ids.add("http://test.com.cn");//隐私政策链接
-            ids.add("http://test.com.cn");//第三方点击监测链接
+            ids.add("http://test123.com.cn");//隐私政策链接
+            ids.add("http://test123456.com.cn");//第三方点击监测链接
             ids.add(1);//是否关联单品(0否,1是)
             ids.add("剑来");//关联单品名称
             ids.add("account");//使用层级(账户:account,计划:plan,组:group)
             ids.add(1);//是否循环(0否,1是)
-            ids.add(10);//循环次数
             list.add(ids);
             eeu.exportExcelForAttendance(workbook, 0, "Sheet1", titles, list);
             eeu.putResponseHeader(response, "渠道号模板.xlsx");
@@ -241,29 +298,35 @@ public class KuaishouChannelController {
     }
 
     /**
-     * 定制创建渠道号
+     * 通过账户查询渠道号接口
      */
-    @PostMapping(value = "/customizedCreate")
-    public Result<Object> customizedCreate(@RequestBody JSONObject request) {
+    @PostMapping(value = "/queryChannel")
+    public Result<Object> queryChannel(Long accountId, String usageLevel, String appName, String photoName) {
         try {
-            return kuaishouChannelService.customizedCreate(request, 3);
+            if (Check.isNull(accountId) || Check.isNull(usageLevel) || Check.isNull(appName)) {
+                return Result.error("缺失参数");
+            }
+            return kuaishouChannelService.queryChannel(accountId, usageLevel, appName, photoName);
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("定制创建渠道号异常", e);
-            return Result.error("定制创建渠道号失败," + e.getMessage());
+            log.error("通过账户查询渠道号异常", e);
+            return Result.error("通过账户查询渠道号失败," + e.getMessage());
         }
     }
 
     /**
      * 通过账户查询渠道号接口
      */
-    @PostMapping(value = "/queryChannel")
-    public Result<Object> queryChannel(Long accountId, String usageLevel, String appName, String photoName) {
+    @GetMapping(value = "/queryChannelList")
+    public Result<Object> queryChannelList(Long accountId, String appName,
+                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
-            if (Check.isNull(accountId) || Check.isNull(usageLevel) || Check.isNull(appName)) {
+            if (Check.isNull(accountId) || Check.isNull(appName)) {
                 return Result.error("缺失参数");
             }
-            return kuaishouChannelService.queryChannel(accountId, usageLevel, appName, photoName);
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouChannelService.queryChannelList(accountId, appName);
         } catch (Exception e) {
             e.printStackTrace();
             log.error("通过账户查询渠道号异常", e);

+ 16 - 13
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/entity/KuaishouChannel.java

@@ -74,7 +74,12 @@ public class KuaishouChannel {
     private Integer createType;
 
     /**
-     * 状态 0无效,1有效
+     * 渠道号状态 0无效,1有效
+     */
+    private Integer channelState;
+
+    /**
+     * 账户是否使用渠道号 0不用,1使用
      */
     private Integer state;
 
@@ -175,18 +180,6 @@ public class KuaishouChannel {
     @ApiModelProperty(value = "是否循环重复使用 0:否,1:是")
     private Integer isCycle;
     /**
-     * 可循环次数
-     */
-    @Excel(name = "可循环次数", width = 15)
-    @ApiModelProperty(value = "可循环次数")
-    private Integer cycleTimes;
-    /**
-     * 已循环次数
-     */
-    @Excel(name = "已循环次数", width = 15)
-    @ApiModelProperty(value = "已循环次数")
-    private Integer haveCycleTimes;
-    /**
      * createTime
      */
     @ApiModelProperty(value = "createTime")
@@ -202,4 +195,14 @@ public class KuaishouChannel {
 
     @TableField(exist = false)
     private List<KuaishouChannelItems> items;
+
+    @TableField(exist = false)
+    private String authName;
+
+    @TableField(exist = false)
+    private Long campaignId;
+
+    @TableField(exist = false)
+    private Long unitId;
+
 }

+ 11 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/entity/KuaishouChannelCreateStrategy.java

@@ -64,7 +64,7 @@ public class KuaishouChannelCreateStrategy {
     @ApiModelProperty(value = "账户id")
     private Long accountId;
     /**
-     * 创建方式 1-批量,2-excel导入,3-自定义
+     * 创建方式 1-批量,2-excel导入
      */
     @Excel(name = "创建方式 1-批量,2-excel导入,3-自定义", width = 15)
     @ApiModelProperty(value = "创建方式 1-批量,2-excel导入,3-自定义")
@@ -88,6 +88,10 @@ public class KuaishouChannelCreateStrategy {
     @ApiModelProperty(value = "编号长度")
     private Integer numberLength;
     /**
+     * 编号原始值
+     */
+    private String numberValue;
+    /**
      * 编号最小值
      */
     @Excel(name = "编号最小值", width = 15)
@@ -148,12 +152,6 @@ public class KuaishouChannelCreateStrategy {
     @ApiModelProperty(value = "是否循环重复使用 0:否,1:是")
     private Integer isCycle;
     /**
-     * 可循环次数
-     */
-    @Excel(name = "可循环次数", width = 15)
-    @ApiModelProperty(value = "可循环次数")
-    private Integer cycleTimes;
-    /**
      * 应用标记
      */
     @Excel(name = "应用标记", width = 15)
@@ -187,6 +185,7 @@ public class KuaishouChannelCreateStrategy {
     @Excel(name = "图片MD5标识", width = 15)
     @ApiModelProperty(value = "图片MD5标识")
     private String imageToken;
+
     /**
      * createTime
      */
@@ -198,7 +197,6 @@ public class KuaishouChannelCreateStrategy {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
-    @TableField(exist = false)
     private Long appId;
 
     @TableField(exist = false)
@@ -207,4 +205,9 @@ public class KuaishouChannelCreateStrategy {
     @TableField(exist = false)
     private String itemName;
 
+    @TableField(exist = false)
+    private String projectName;
+    @TableField(exist = false)
+    private String ProductName;
+
 }

+ 6 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelMapper.java

@@ -18,7 +18,7 @@ import java.util.List;
  */
 public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
 
-    List<JSONObject> channelManagementHome(@Param("productId") Long productId, @Param("projectId") Long projectId, @Param("accountId") Long accountId, @Param("userId") String userId);
+    List<JSONObject> channelManagementHome(KuaishouChannel kuaishouChannel);
 
     Long channelNumberDetailsTotal(KuaishouChannel kuaishouChannel);
 
@@ -26,7 +26,7 @@ public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
 
     Long channelNumberUsageDetailsListTotal(KuaishouChannel kuaishouChannel);
 
-    List<JSONObject> channelNumberUsageDetailsList(KuaishouChannel kuaishouChannel);
+    List<KuaishouChannel> channelNumberUsageDetailsList(KuaishouChannel kuaishouChannel);
 
     List<JSONObject> channelNumberBindingItemInfo(@Param("request") JSONArray request);
 
@@ -47,4 +47,8 @@ public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
     List<JSONObject> queryItemsListByAccountId(@Param("accountId") Long accountId, @Param("appName") String appName);
 
     KuaishouChannel queryUsedChannel(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId, @Param("level") String level);
+
+    List<JSONObject> queryChannelList(@Param("accountId") Long accountId, @Param("appName") String appName);
+
+    List<KuaishouChannel> queryChannelListByAccount(@Param("accountId") Long accountId);
 }

+ 70 - 67
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml

@@ -3,8 +3,8 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.channel.mapper.KuaishouChannelMapper">
 
     <select id="channelManagementHome" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT * FROM (
         SELECT
+               t1.id,
         IFNULL(t1.product_name, '')as 'productName',
         IFNULL(t1.project_name, '')as 'projectName',
         IFNULL(t1.account_id, '')as 'accountId',
@@ -12,51 +12,31 @@
         IFNULL(t2.realname, '')as 'realname',
         MAX(t1.state_date) as 'stateDate',
         IFNULL(t1.create_type, '') as 'createType',
+        IFNULL(t1.state,0) as 'state',
+        usage_level as 'usageLevel',
+        (select auth_name from ctop_user_allocation where account_id = t1.account_id) as 'authName',
         t1.create_time
         FROM ctop_kuaishou_channel t1
         LEFT JOIN sys_user t2 ON t1.user_id = t2.id
-        where account_id is not null
-        <if test="userId != null">
-            and t1.user_id = #{userId}
-        </if>
-        <if test="projectId != null">
-            and project_id = #{projectId}
-        </if>
-        <if test="productId != null">
-            and product_id = #{productId}
-        </if>
-        <if test="accountId != null">
-            and account_id= #{accountId}
-        </if>
+        <where>
+            <if test="userId != null">
+                and t1.user_id = #{userId}
+            </if>
+            <if test="projectId != null">
+                and project_id = #{projectId}
+            </if>
+            <if test="productId != null">
+                and product_id = #{productId}
+            </if>
+            <if test="accountId != null">
+                and account_id= #{accountId}
+            </if>
+            <if test="state != null">
+                and state= #{state}
+            </if>
+        </where>
         GROUP BY account_id
-        UNION ALL
-        SELECT
-        IFNULL(t1.product_name, '')as 'productName',
-        IFNULL(t1.project_name, '')as 'projectName',
-        IFNULL(t1.account_id, '')as 'accountId',
-        IFNULL(t1.project_id, '')as 'projectId',
-        IFNULL(t2.realname, '')as 'realname',
-        MAX(t1.state_date) as 'stateDate',
-        IFNULL(t1.create_type, '') as 'createType',
-        t1.create_time
-        FROM ctop_kuaishou_channel t1
-        LEFT JOIN sys_user t2 ON t1.user_id = t2.id
-        where account_id is null
-        <if test="userId != null">
-            and t1.user_id = #{userId}
-        </if>
-        <if test="projectId != null">
-            and project_id = #{projectId}
-        </if>
-        <if test="productId != null">
-            and product_id = #{productId}
-        </if>
-        <if test="accountId != null">
-            and account_id= #{accountId}
-        </if>
-        GROUP BY project_id
-        ) t
-        ORDER BY t.create_time DESC
+        ORDER BY create_time DESC
     </select>
 
     <select id="channelNumberDetailsTotal" resultType="java.lang.Long">
@@ -66,12 +46,6 @@
             <if test="accountId != null">
                 AND account_id = #{accountId}
             </if>
-            <if test="projectId != null">
-                AND project_id = #{projectId}
-            </if>
-            <if test="createType != null">
-                AND create_type = #{createType}
-            </if>
             <if test="channelName != null">
                 AND LOCATE(#{channelName},channel_name)
             </if>
@@ -88,12 +62,6 @@
             <if test="accountId != null">
                 AND account_id = #{accountId}
             </if>
-            <if test="projectId != null">
-                AND project_id = #{projectId}
-            </if>
-            <if test="createType != null">
-                AND create_type = #{createType}
-            </if>
             <if test="channelName != null">
                 AND LOCATE(#{channelName},channel_name)
             </if>
@@ -115,22 +83,23 @@
           AND t3.unit_id is not null
     </select>
 
-    <select id="channelNumberUsageDetailsList" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT CASE
-                   t1.usage_range
-                   WHEN 1 THEN
-                       '账户'
-                   WHEN 2 THEN
-                       '项目'
-                   ELSE ''
-                   END AS 'usageRange', IFNULL(t3.channel_code, '') AS 'channelCode', IFNULL(t1.project_name, '') AS 'projectName', IFNULL(t2.auth_name, '') AS 'authName', IFNULL(t3.account_id, '') AS 'accountId', IFNULL(t3.campaign_id, '') AS 'campaignId', IFNULL(t3.unit_id, '') AS 'unitId'
+    <select id="channelNumberUsageDetailsList" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
+        SELECT  t1.usage_level,
+               t3.channel_code,
+               t1.channel_name,
+              t1.project_name,
+              t2.auth_name,
+              t3.account_id,
+              t3.campaign_id,
+              t3.unit_id,
+               t3.create_time
         FROM ctop_kuaishou_channel_rel t3
-                 INNER JOIN ctop_kuaishou_channel t1 ON t1.account_id = t3.account_id
-            AND t1.channel_code = t3.channel_code
-                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_kuaishou_channel t1 ON t1.account_id = t3.account_id AND t1.channel_code = t3.channel_code
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         WHERE t3.account_id = #{accountId}
           AND t3.channel_code = #{channelCode}
           AND t3.unit_id is not null
+          order by t3.create_time
     </select>
 
     <select id="channelNumberBindingItemInfo" resultType="com.alibaba.fastjson.JSONObject">
@@ -223,7 +192,8 @@
         channel_name,
         click_track_url,
         actionbar_click_url,
-        schema_uri
+        schema_uri,
+        have_cycle_times
         FROM `ctop_kuaishou_channel`
         WHERE strategy_id IN
         <foreach collection="strategys" item="item" separator=","
@@ -267,6 +237,39 @@
         GROUP BY tt2.keyword
     </select>
 
+  <select id="queryChannelList" resultType="com.alibaba.fastjson.JSONObject">
+      SELECT
+          t1.id,
+          channel_code,
+          channel_name,
+          t1.url,
+          schema_uri,
+          click_track_url,
+          actionbar_click_url
+      FROM
+          ctop_kuaishou_channel t1
+              LEFT JOIN ctop_kuaishou_channel_app_info t2 ON t1.app_id = t2.app_id
+      WHERE
+          t1.state = 1
+        AND t1.account_id = #{accountId}
+        AND t2.app_name = #{appName}
+        AND usage_times &lt; cycle_times
+      ORDER BY
+      t1.create_time DESC
+  </select>
+
+
+     <select id="queryChannelListByAccount" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
+      SELECT
+          id,
+          channel_code
+      FROM
+          ctop_kuaishou_channel
+      WHERE channel_state = 1
+        AND state = 1
+        AND account_id = #{accountId}
+    </select>
+
 
     <select id="queryUsedChannel" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
         SELECT t2.*

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelRelMapper.xml

@@ -4,7 +4,7 @@
 
     <select id="queryByAccountChannelCode"
             resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelRel">
-        SELECT *
+        SELECT t1.*
         FROM ctop_kuaishou_channel_rel t1
                  LEFT JOIN ctop_kuaishou_channel_app_info t2 ON t1.app_id = t2.app_id
         WHERE t1.account_id =#{accountId}

+ 5 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java

@@ -16,7 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
  */
 public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
-    Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId, String userId);
+    Result<Object> channelManagementHome(KuaishouChannel kuaishouChannel);
 
     Result<Object> channelNumberDetails(KuaishouChannel kuaishouCha, Integer pageNo, Integer pageSizennel);
 
@@ -28,8 +28,6 @@ public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
     Result<Object> systemBatchCreation(JSONObject request);
 
-    Result<Object> customizedCreate(JSONObject request, Integer createType) throws Exception;
-
     Result<Object> queryChannel(Long accountId, String usageLevel, String appName, String photoName) throws Exception;
 
     Result<Object> queryChannelLevel(JSONObject request);
@@ -37,4 +35,8 @@ public interface IKuaishouChannelService extends IService<KuaishouChannel> {
     void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId, Integer state);
 
     KuaishouChannel queryUsedChannel(Long accountId, Long newCampaignId, String level);
+
+    Result<Object> queryChannelList(Long accountId, String appName);
+
+    Result<Object> updateChannels(KuaishouChannel channel);
 }

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 432 - 349
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java


+ 21 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/controller/DocumentLibraryController.java

@@ -1,11 +1,13 @@
 package cn.com.ctop.kuaishou.modules.document.controller;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.document.service.DocumentLibraryService;
 import org.jeecg.common.api.vo.Result;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -96,4 +98,23 @@ public class DocumentLibraryController {
 
     }
 
+
+    /**
+     * Excel导入广告语,回显广告语列表(excel)
+     */
+    @PostMapping(value = "/importAdLanguage")
+    @ResponseBody
+    public Result<Object> importAdLanguage(HttpServletResponse response, @RequestParam("file") MultipartFile file) {
+        response.setHeader("Access-Control-Allow-Origin", "*");
+        try {
+            if (Check.isNull(file)) {
+                return Result.error("执行失败,请上传应用Excel文件");
+            }
+            return documentLibraryService.importAdLanguage(file);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("Excel导入广告语异常," + e.getMessage());
+        }
+    }
+
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/DocumentLibraryMapper.java

@@ -24,4 +24,6 @@ public interface DocumentLibraryMapper {
     List<String> getDataByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
 
     List<Map<String,String>> getDocumentByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
+
+    void insertBatch(@Param("list") List<DocumentLibraryInfo> list);
 }

+ 11 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/xml/DocumentLibraryMapper.xml

@@ -8,6 +8,17 @@
         (#{copyWriterId},#{copyWriter},#{accountId},#{status},#{createTime})
     </insert>
 
+    <insert id="insertBatch" parameterType="cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo">
+        insert into ctop_document_library
+        (copy_writer_id,copy_writer,account_id,status,create_time)
+        values
+        <foreach collection="list" item="video" separator=",">
+            (
+            #{video.copyWriterId},#{video.copyWriter},#{video.accountId},#{video.status},#{video.createTime}
+            )
+        </foreach>
+    </insert>
+
 
     <select id="getDocumentLibraryList" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t.copy_writer_id as 'copyWriterId',t.copy_writer,t.status,COUNT(t1.creative_id) as 'relatedSize',COUNT(if(t2.status= 42 ,TRUE,NULL)) as 'refusedSize'  from

+ 4 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/DocumentLibraryService.java

@@ -25,4 +25,8 @@ public interface DocumentLibraryService {
     Result getRefusedList(String copyWriterId, int pageNumber, int pageSize);
 
     Result getAcoountId(String copyWriterId);
+
+    Result<Object> importAdLanguage(MultipartFile file) throws Exception;
+
+    void insertBatch(String description,Long accountId);
 }

+ 62 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/impl/DocumentLibraryServiceImpl.java

@@ -1,13 +1,21 @@
 package cn.com.ctop.kuaishou.modules.document.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo;
 import cn.com.ctop.kuaishou.modules.document.mapper.DocumentLibraryMapper;
 import cn.com.ctop.kuaishou.modules.document.service.DocumentLibraryService;
 import cn.com.ctop.kuaishou.modules.utils.ExcelUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
@@ -206,4 +214,58 @@ public class DocumentLibraryServiceImpl implements DocumentLibraryService {
         }
         return result;
     }
+
+    @Override
+    public Result<Object> importAdLanguage(MultipartFile file) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        Workbook workbook = null;
+        String fileName = file.getOriginalFilename();
+        String substring = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase();
+        if ("XLS".equals(substring)) {
+            workbook = new HSSFWorkbook(file.getInputStream());
+        } else if ("XLSX".equals(substring)) {
+            workbook = new XSSFWorkbook(file.getInputStream());
+        } else {
+            throw new Exception("文件不是Excel文件");
+        }
+        Sheet sheet = workbook.getSheet("Sheet1");
+        if (Check.isNull(sheet)) {
+            throw new Exception("Sheet标题不是默认的Sheet1");
+        }
+        int rows = sheet.getLastRowNum();// 指的行数,一共有多少行+
+        if (rows == 0) {
+            throw new Exception("请填写数据");
+        }
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        JSONArray array = new JSONArray();
+        for (int i = 1; i <= rows + 1; i++) {
+            Row row = sheet.getRow(i);
+            if (row != null) {
+                String value = eeu.getCellValue(row.getCell(0));
+                if (Check.isNull(value)) {
+                    return Result.error("解析数据失败,文档中项目列缺失数据");
+                }
+                array.add(value);
+            }
+        }
+        return Result.ok(array);
+    }
+
+    @Override
+    public void insertBatch(String description,Long accountId) {
+        JSONArray array = JSONArray.parseArray(description);
+        List<DocumentLibraryInfo> list = new ArrayList<>();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        for (int i = 0; i < array.size(); i++) {
+            DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
+            documentLibraryInfo.setCopyWriter(array.getString(i).trim());
+            documentLibraryInfo.setCopyWriterId(UUID.randomUUID().toString());
+            documentLibraryInfo.setCreateTime(formatter.format(new Date()));
+            documentLibraryInfo.setStatus(0);
+            documentLibraryInfo.setAccountId(accountId.toString());
+            list.add(documentLibraryInfo);
+        }
+
+        documentLibraryMapper.insertBatch(list);
+    }
 }

+ 95 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouAudienceReportDailyController.java

@@ -1,5 +1,10 @@
 package cn.com.ctop.kuaishou.modules.report.controller;
 
+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.AiKuaishouUnitLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouUnitLevelOperationRecordMapper;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAccountService;
@@ -16,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -28,14 +34,20 @@ import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * 人群分析报表
@@ -287,4 +299,87 @@ public class KuaishouAudienceReportDailyController {
         return Result.ok("文件导入失败!");
     }
 
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    static CountDownLatch countDownLatch = null;
+    @Resource
+    AiKuaishouUnitLevelOperationRecordMapper kuaishouUnitLevelOperationRecordMapper;
+
+    @GetMapping(value = "/getAudienceDataNew")
+    public void getAudienceData(@RequestParam(required = false, defaultValue = "2019-01-01") String date) throws Exception {
+        int page = 1;
+        int pageSize = 2000;
+        if (date.equals("2019-01-01")) {
+            date = DateUtils.formatDate(DateUtils.addDay(DateUtils.getNowDate(), -1), "yyyy-MM-dd");
+        }
+        int count = 0;
+        List<CtopOauthToken> tokens = tokenService.getByProjectId(458L);    //淘特项目
+        SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
+        for (CtopOauthToken token : tokens) {
+            Date enDate = DateUtils.addDay(DateUtils.getNowDate(), -1);
+            if (enDate.after(token.getAccessTokenExpiresIn())) {   //过期跳过
+                continue;
+            }
+            Date startDate = DateUtils.addDay(enDate, -30);
+            log.info("accountId=" + token.getAccountId() + "开始:" + DateUtils.getLastDay(date, 30) + "结束:" + DateUtils.getLastDay(date, 1));
+            List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountIdAndDate(token.getAccountId(), startDate, enDate);
+            if (Check.isNull(planIdsAndUnitIds)) {
+                continue;
+            }
+            log.info("账户总数:" + tokens.size() + "当前:" + ++count);
+            countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
+            String finalDate = date;
+            planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
+                try {
+                    // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "province", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "city", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "gender", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "clientId", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "businessInterestTags", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                } catch (Exception e) {
+                } finally {
+                    countDownLatch.countDown();
+                }
+            }));
+            countDownLatch.await();
+        }
+    }
+
+
+    @GetMapping(value = "/getOneAudienceDataNew")
+    public void getOneAudienceDataNew(Long accountId) throws Exception {
+        int page = 1;
+        int pageSize = 2000;
+        int count = 0;
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        Date enDate = DateUtils.addDay(DateUtils.getNowDate(), -1);
+        if (enDate.after(token.getAccessTokenExpiresIn())) {   //过期跳过
+            return;
+        }
+        Date startDate = DateUtils.addDay(enDate, -30);
+        List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountIdAndDate(token.getAccountId(), startDate, enDate);
+        if (Check.isNull(planIdsAndUnitIds)) {
+            return;
+        }
+        countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
+        String finalDate = DateUtils.formatDate(enDate, "yyyy-MM-dd");;
+        planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
+            try {
+                // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
+                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "province", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "city", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "gender", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "clientId", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "businessInterestTags", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+            } catch (Exception e) {
+            } finally {
+                countDownLatch.countDown();
+            }
+        }));
+    }
+
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyService.java

@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @Version: V1.0
  */
 public interface IKuaishouAudienceReportDailyService extends IService<KuaishouAudienceReportDaily> {
-    /**
+    /*
      * 人群分析报表
      *
      * @param

+ 4 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouReportAccountHourlyServiceImpl.java

@@ -470,7 +470,7 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
         List<String> ids = new ArrayList<>();
         List<JSONObject> departIds = new ArrayList<>();
         //管理员和运营总经理 可以查看所有快手的运营信息
-        if ("genera_manager_of_operations".equals(roleCode) || "admin".equals(roleCode)) {
+        if ("genera_manager_of_operations".equals(roleCode) || "admin".equals(roleCode) || "salesSupportManager".equals(roleCode)) {
             JSONObject obj = new JSONObject();
             //快手运营部 峰级部门 ID
             obj.put("id", "024b0dc0840045afb048022a8c61253f");
@@ -498,7 +498,7 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
         String userId = request.getString("userId");
         String startTime = request.getString("startTime");
         String endTime = request.getString("endTime");
-        if (Check.isNull(userId)||Check.isNull(startTime)||Check.isNull(endTime)) {
+        if (Check.isNull(userId) || Check.isNull(startTime) || Check.isNull(endTime)) {
             return Result.error("缺少账户入参");
         }
         String sortCode = request.getString("sortCode");
@@ -541,13 +541,13 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
         int total = 0;
         //单日数据
         if (endTime.equals(startTime)) {
-            if(!today.equals(startTime)){
+            if (!today.equals(startTime)) {
                 request.put("yesterday", startTime);
             }
             total = etlHourlyAccountMapper.operatingStaffDataListTotal(request);
             PageHelper.startPage(pageNo, pageSize, false);
             list = etlHourlyAccountMapper.operatingStaffDataList(request);
-        }else {
+        } else {
             total = etlDailyAccountMapper.operatingStaffDataListTotal(request);
             PageHelper.startPage(pageNo, pageSize, false);
             list = etlDailyAccountMapper.operatingStaffDataList(request);

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

@@ -1,17 +1,11 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.OauthDetail;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
-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.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.common.module.service.*;
+import cn.com.ctop.common.module.utils.*;
 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;
@@ -69,6 +63,8 @@ public class CallbackController {
     private IReportService reportService;
     @Autowired
     private IKuaishouAppPackageService kuaishouAppPackageService;
+    @Autowired
+    private IOauthDetailService detailService;
 
     @GetMapping("/qywexin")
     public void qywexin(HttpServletRequest request,
@@ -120,13 +116,27 @@ public class CallbackController {
      * @param state
      * @return
      */
+
+
     @GetMapping("/kuaishou")
     public String kuaishouCallback(HttpServletRequest request, HttpServletResponse response, @RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
+        Long id = Long.valueOf(state);
         try {
-            JSONObject json = JSONObject.parseObject(state);
-            if (Check.isNull(json)) {
+            //    JSONObject json = JSONObject.parseObject(state);
+
+            OauthDetail byId = detailService.getById(id);
+            if (Check.isNull(byId)) {
                 throw new Exception("回调信息为空");
             }
+            String detailText = byId.getDetailText();
+            if (Check.isNull(detailText)) {
+                throw new Exception("用户授权信息为空");
+            }
+            JSONObject json = JSONObject.parseObject(detailText);
+            if (Check.isNull(json)) {
+                throw new Exception("数据转化异常");
+            }
+
             log.info("快手授权返回信息:{}", json);
             log.info("快手授权返回oauthCode:{}", authCode);
             Integer agentType = json.getInteger("agentType");
@@ -244,11 +254,13 @@ public class CallbackController {
                     };
                     t.start();
                 }
+                detailService.removeById(id);
                 return "授权绑定成功";
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
+        detailService.removeById(id);
         return "授权绑定失败!";
     }
 

+ 6 - 1
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-dev.yml

@@ -116,7 +116,12 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.165.84:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#---------------------线上库
+#          url: jdbc:mysql://139.186.27.96:3390/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=GMT%2B8
+#          username: data
+#          password: hcst@2021
+#---------------------测试库
+          url: jdbc:mysql://139.186.165.84:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true
           username: hcst
           password: hcst@2020
           driver-class-name: com.mysql.jdbc.Driver