Pārlūkot izejas kodu

Merge branch 'V2.0.1' into test

zhaoxian 3 gadi atpakaļ
vecāks
revīzija
0ca277108f
16 mainītis faili ar 723 papildinājumiem un 257 dzēšanām
  1. 60 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoDoController.java
  2. 5 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java
  3. 13 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java
  4. 8 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoVideo.java
  5. 6 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoVideoMapper.java
  6. 33 16
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml
  7. 7 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoDoService.java
  8. 538 188
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java
  9. 10 12
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoVideoServiceImpl.java
  10. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java
  11. 27 19
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  12. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java
  13. 0 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java
  14. 6 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCampaignServiceImpl.java
  15. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelCreateStrategyMapper.xml
  16. 3 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml

+ 60 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoDoController.java

@@ -28,7 +28,65 @@ public class AiKuaishouAccountAutoDoController {
     static ExecutorService programService = Executors.newFixedThreadPool(8);
 
     /**
-     * 创建自定义广告创意
+     * 创建自定义上新广告创意 、频率 20分钟/次
+     */
+    @GetMapping(value = "/createCustomUpNewCreative")
+    public JSONObject createCustomUpNewCreative(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("主键id不能为空");
+            }
+            AiKuaishouAccountAutoStrategy strategy = strategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Boolean unitOverrun = autoDoService.getUnitOverrun(strategy.getAccountId());
+            if (unitOverrun) {
+                log.error("****** 广告组创建超限,accountId:{}", strategy.getAccountId());
+                throw new Exception("今日广告组创建已超限");
+            }
+            customService.submit(() -> autoDoService.createCustomUpNewCreative(strategy));
+            returnJson.put("code", 0);
+            returnJson.put("message", "异步创建中");
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 每日补充创建创意 、频率 每天22点05分钟执行1次
+     */
+    @GetMapping(value = "/supplementTodayCreatives")
+    public JSONObject supplementTodayCreatives(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("主键id不能为空");
+            }
+            AiKuaishouAccountAutoStrategy strategy = strategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Boolean unitOverrun = autoDoService.getUnitOverrun(strategy.getAccountId());
+            if (unitOverrun) {
+                log.error("****** 广告组创建超限,accountId:{}", strategy.getAccountId());
+                throw new Exception("今日广告组创建已超限");
+            }
+            customService.submit(() -> autoDoService.supplementTodayCreatives(strategy));
+            returnJson.put("code", 0);
+            returnJson.put("message", "异步创建中");
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 创建自定义非上新广告创意 、频率 60分钟/次
      */
     @GetMapping(value = "/createCustomCreative")
     public JSONObject createCustomCreative(String id) {
@@ -58,7 +116,7 @@ public class AiKuaishouAccountAutoDoController {
     }
 
     /**
-     * 创建程序化广告创意
+     * 创建程序化广告创意 频率 60分钟/次
      */
     @GetMapping(value = "/createProgramCreative")
     public JSONObject createProgramCreative(String id) {

+ 5 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java

@@ -116,6 +116,9 @@ public class AiKuaishouAccountAutoStrategyController {
                 if (null != allocation) {
                     record.setAuthName(allocation.getAuthName());
                 }
+                //TODO
+                record.setCustomCreatedUnitCnt(0);
+                record.setProgramCreatedUnitCnt(0);
             });
         }
         pageInfo.setList(list);
@@ -205,7 +208,7 @@ public class AiKuaishouAccountAutoStrategyController {
      * @return
      */
     @ApiOperation(value = "自动投放重构-账户策略表-编辑", notes = "自动投放重构-账户策略表-编辑")
-    @PutMapping(value = "/edit")
+    @PostMapping(value = "/edit")
     public Result<AiKuaishouAccountAutoStrategy> edit(@RequestBody AiKuaishouAccountAutoStrategy aiKuaishouAccountAutoStrategy) {
         Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
         AiKuaishouAccountAutoStrategy aiKuaishouAccountAutoStrategyEntity = aiKuaishouAccountAutoStrategyService.getById(aiKuaishouAccountAutoStrategy.getId());
@@ -213,7 +216,7 @@ public class AiKuaishouAccountAutoStrategyController {
             result.error500("未找到对应实体");
         } else {
             Integer singleAppId = aiKuaishouAccountAutoStrategy.getSingleAppid();
-            if (aiKuaishouAccountAutoStrategy.getCampaignType() == 2 || aiKuaishouAccountAutoStrategy.getCampaignType() == 7) {
+            if (aiKuaishouAccountAutoStrategyEntity.getCampaignType() == 2 || aiKuaishouAccountAutoStrategyEntity.getCampaignType() == 7) {
                 if (null != singleAppId && singleAppId == 1) {
                     Long appId = Long.valueOf(JSONArray.parseArray(aiKuaishouAccountAutoStrategy.getAppIdArray()).getString(0));
                     aiKuaishouAccountAutoStrategy.setAppId(appId);

+ 13 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java

@@ -335,10 +335,10 @@ public class AiKuaishouAccountAutoStrategy {
     @ApiModelProperty(value = "创意标签")
     private String creativeTag;
     /**
-     * 物料关联的封面个数
+     * 自定义创意数量
      */
-    @Excel(name = "物料关联的封面个数", width = 15)
-    @ApiModelProperty(value = "物料关联的封面个数")
+    @Excel(name = "自定义创意数量", width = 15)
+    @ApiModelProperty(value = "自定义创意数量")
     private Integer imageCnt;
     /**
      * 程序化创意2.0-是否开启智能抽帧
@@ -491,4 +491,14 @@ public class AiKuaishouAccountAutoStrategy {
 
     @TableField(exist = false)
     private String authName;
+
+    @TableField(exist = false)
+    private int customCreatedUnitCnt;
+
+    @TableField(exist = false)
+    private int programCreatedUnitCnt;
+
+    //待建广告组数
+    @TableField(exist = false)
+    private int toBeBuiltCnt;
 }

+ 8 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoVideo.java

@@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.google.common.base.Objects;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -24,6 +25,7 @@ import java.util.Date;
  * @date 2021-10-20
  */
 @Data
+@AllArgsConstructor
 @TableName("ctop_ai_kuaishou_account_auto_video")
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
@@ -75,8 +77,8 @@ public class AiKuaishouAccountAutoVideo {
     /**
      * 使用时间
      */
-    @Excel(name = "使用时间", width = 15)
-    @ApiModelProperty(value = "使用时间")
+    @Excel(name = "素材创建时间", width = 15)
+    @ApiModelProperty(value = "素材创建时间")
     private String statDate;
     /**
      * MD5值
@@ -123,6 +125,10 @@ public class AiKuaishouAccountAutoVideo {
     @TableField(exist = false)
     private Long campaignId;
 
+    public AiKuaishouAccountAutoVideo() {
+
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o) {

+ 6 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoVideoMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.ai.mapper;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -19,15 +20,17 @@ public interface AiKuaishouAccountAutoVideoMapper extends BaseMapper<AiKuaishouA
 
     List<AiKuaishouAccountAutoVideo> getUpNewVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate, @Param("createType") String createType);
 
-    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("createType") String createType);
+    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("createType") String createType, @Param("statDate") String statDate);
 
-    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt);
+    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate);
 
-    List<AiKuaishouAccountAutoVideo> getZeroVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt);
+    List<AiKuaishouAccountAutoVideo> getZeroVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt, @Param("statDate") String date);
 
     Integer getAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType);
 
     void addAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType, @Param("usageTimes") Integer usageTimes, @Param("date") String date);
 
     void updateAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType, @Param("usageTimes") Integer usageTimes, @Param("date") String date);
+
+    List<String> selectBatchByPhotoIds(@Param("details") JSONArray details, @Param("statDate") String statDate, @Param("accountId") Long accountId);
 }

+ 33 - 16
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml

@@ -5,25 +5,27 @@
     <insert id="insertBatch">
         replace into ctop_ai_kuaishou_account_auto_video(
         account_id,
+        custom_status,
+        program_status,
         photo_id,
-        status,
+        photo_name,
         material_type,
-        stat_date,
         channel_type,
-        signature,
-        photo_name
+        stat_date,
+        signature
         )
         values
         <foreach collection="videoGetList" item="video" separator=",">
             (
             #{video.accountId},
+            #{video.customStatus},
+            #{video.programStatus},
             #{video.photoId},
-            #{video.status},
-            #{video.materialType},
-            #{video.statDate},
+            #{video.photoName},
+           #{video.materialType},
             #{video.channelType},
-            #{video.signature},
-            #{video.photoName}
+            #{video.statDate},
+            #{video.signature}
             )
         </foreach>
     </insert>
@@ -32,10 +34,10 @@
     <select id="getUpNewVideos" resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo">
         SELECT * FROM ctop_ai_kuaishou_account_auto_video
         WHERE account_id = #{accountId}
-        <if test="createType ==custom">
+        <if test="createType == 'custom' ">
             AND custom_status = 1
         </if>
-        <if test="createType ==program">
+        <if test="createType == 'program'">
             AND program_status = 1
         </if>
         <if test="channelType!=null">
@@ -76,7 +78,7 @@
         channel_type,
         material_type
         from ctop_material_top_cost
-        where t1.account_id = #{accountId}
+        where account_id = #{accountId}
         and md5 not in
         (
         SELECT signature FROM ctop_ai_kuaishou_account_auto_video_used
@@ -96,7 +98,7 @@
             and material_name like concat(#{keyword},'%')
         </if>
         group by signature
-        ORDER BY t2.7day_cost DESC
+        ORDER BY 7day_cost DESC
         LIMIT #{videoCnt}
     </select>
 
@@ -108,8 +110,8 @@
         material_name as 'photoName',
         channel_type,
         material_type
-        from ctop_material_top_cost
-        where t1.account_id = #{accountId}
+        from ctop_history_material_catch
+        where account_id = #{accountId}
         and md5 not in
         (
         SELECT signature FROM ctop_ai_kuaishou_account_auto_video_used
@@ -127,7 +129,7 @@
             and material_name like concat(#{keyword},'%')
         </if>
         group by signature
-        ORDER BY t2.sum_cost DESC
+        ORDER BY sum_cost DESC
         LIMIT #{videoCnt}
     </select>
 
@@ -172,4 +174,19 @@
           AND video_type = #{videoType}
           AND create_type = #{createType}
     </update>
+
+    <select id="selectBatchByPhotoIds" resultType="java.lang.String">
+        SELECT photo_id
+        FROM ctop_ai_kuaishou_account_auto_video
+        WHERE account_id = #{accountId}
+          AND stat_date = #{statDate}
+        <if test="details!=null">
+            AND photo_id in
+            <foreach item="item" collection="details"
+                     open="(" separator="," close=")">
+                #{item.photo_id}
+            </foreach>
+          </if>
+    </select>
+
 </mapper>

+ 7 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoDoService.java

@@ -2,11 +2,12 @@ package cn.com.ctop.kuaishou.modules.ai.service;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoStrategy;
 
-import java.text.ParseException;
-
 public interface IAiKuaishouAccountAutoDoService {
 
-    //创建自定义广告创意
+    //创建自定义上新广告创意
+    void createCustomUpNewCreative(AiKuaishouAccountAutoStrategy strategy);
+
+    //创建自定义非上新广告创意
     void createCustomCreative(AiKuaishouAccountAutoStrategy strategy);
 
     //创建程序化广告创意
@@ -15,4 +16,7 @@ public interface IAiKuaishouAccountAutoDoService {
     // 组创建是否超限
     Boolean getUnitOverrun(Long accountId);
 
+    //每日补齐创建
+    void supplementTodayCreatives(AiKuaishouAccountAutoStrategy strategy);
+
 }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 538 - 188
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java


+ 10 - 12
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoVideoServiceImpl.java

@@ -49,17 +49,17 @@ public class AiKuaishouAccountAutoVideoServiceImpl extends ServiceImpl<AiKuaisho
 
     @Override
     public List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType) {
-        return autoVideoMapper.getHistoryTopVideos(accountId, channelType, keyword, videoCnt, createType);
+        return autoVideoMapper.getHistoryTopVideos(accountId, channelType, keyword, videoCnt, createType, statDate);
     }
 
     @Override
     public List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate) {
-        return autoVideoMapper.getZeroVideoByParams(accountId, channelType, keyword, videoCnt);
+        return autoVideoMapper.getZeroVideoByParams(accountId, channelType, keyword, videoCnt, statDate);
     }
 
     @Override
     public List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate) {
-        return autoVideoMapper.getHistoryCatchVideos(accountId, channelType, keyword, videoCnt);
+        return autoVideoMapper.getHistoryCatchVideos(accountId, channelType, keyword, videoCnt, statDate);
     }
 
 
@@ -94,8 +94,8 @@ public class AiKuaishouAccountAutoVideoServiceImpl extends ServiceImpl<AiKuaisho
             param.put("advertiser_id", token.getAccountId());
             param.put("page_size", pageSize);
             param.put("page", page);
-            param.put("start_date", date);
-            param.put("end_date", date);
+//            param.put("start_date", date);
+//            param.put("end_date", date);
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (Check.isNull(resultJson)) {
@@ -118,25 +118,23 @@ public class AiKuaishouAccountAutoVideoServiceImpl extends ServiceImpl<AiKuaisho
             }
 
             List<AiKuaishouAccountAutoVideo> videoGetList = new ArrayList<>();
+
+            Long accountId = token.getAccountId();
+            List<String> photoIds = autoVideoMapper.selectBatchByPhotoIds(details, date, accountId);
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detailJson = details.getJSONObject(i);
                 if (Check.isNull(detailJson)) {
                     continue;
                 }
                 String photoId = detailJson.getString("photo_id");
-                Long accountId = token.getAccountId();
-                QueryWrapper<AiKuaishouAccountAutoVideo> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("photo_id", photoId);
-                queryWrapper.eq("account_id", accountId).last("limit 1");
-                AiKuaishouAccountAutoVideo one = this.getOne(queryWrapper);
-                if (!Check.isNull(one)) {
+                if (!Check.isNull(photoIds) && photoIds.contains(photoId)) {
                     continue;
                 }
                 AiKuaishouAccountAutoVideo videoGet = new AiKuaishouAccountAutoVideo();
                 videoGet.setAccountId(accountId);
                 videoGet.setPhotoId(photoId);
                 videoGet.setPhotoName(detailJson.getString("photo_name"));
-                videoGet.setStatDate(date);
+                videoGet.setStatDate(DateUtils.formatDate(detailJson.getDate("create_time"), DateUtils.WEB_FORMAT));
                 String signature = detailJson.getString("signature");
                 videoGet.setSignature(signature);
                 Integer source = detailJson.getInteger("source");

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -25,4 +26,6 @@ public interface KuaiShouCampaignMapper extends BaseMapper<KuaiShouCampaign> {
     Long getCampaignIdByAccountAndName(@Param("accountId") Long accountId, @Param("name") String replaceString);
 
     Long getCampaignIdByAccountAndNameAndDate(@Param("accountId") Long accountId, @Param("name") String replaceString, @Param("nowDate") String nowDate);
+
+    List<JSONObject> getCampaignIdsByParameters(@Param("accountId") Long accountId, @Param("typeName") String typeName, @Param("nowDate") String nowDate);
 }

+ 27 - 19
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml

@@ -36,38 +36,46 @@
 
     <select id="queryIdsByPutStatus" resultType="java.lang.Long">
         SELECT campaign_id
-        FROM
-        ctop_kuaishou_campaign
+        FROM ctop_kuaishou_campaign
         WHERE account_id = #{accountId}
-        AND put_status = #{putStatus}
+          AND put_status = #{putStatus}
     </select>
     <select id="queryCampaignIdByAccountId" resultType="java.lang.Long">
         SELECT campaign_id
-        FROM
-        ctop_kuaishou_campaign
+        FROM ctop_kuaishou_campaign
         WHERE account_id = #{accountId}
     </select>
     <select id="getNewDataByAccountIdAndDate" resultType="java.lang.Integer">
-     select
-     count(1)
-     from ctop_kuaishou_campaign
-     where account_id = #{accountId}
-     and DATE_FORMAT(put_create_time,'%Y-%m-%d') = #{statDate}
+        select count(1)
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and DATE_FORMAT(put_create_time, '%Y-%m-%d') = #{statDate}
     </select>
     <select id="getCampaignIdByAccountAndName" resultType="java.lang.Long">
-        select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
-        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
-        order by put_create_time DESC
-        limit 1
+        select campaign_id
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and campaign_name like CONCAT('%', CONCAT(#{name}, '%'))
+        order by put_create_time DESC limit 1
 
 
     </select>
     <select id="getCampaignIdByAccountAndNameAndDate" resultType="java.lang.Long">
-          select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
-        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
-        and put_create_time &gt;= #{nowDate}
-        order by put_create_time DESC
-        limit 1
+        select campaign_id
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and campaign_name like CONCAT('%', CONCAT(#{name}, '%'))
+          and put_create_time &gt;= #{nowDate}
+        order by put_create_time DESC limit 1
 
     </select>
+
+    <select id="getCampaignIdsByParameters" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT campaign_id as 'campaignId',
+               (SELECT COUNT(1) FROM ctop_kuaishou_group WHERE campaign_id = t.campaign_id) AS 'count'
+        FROM ctop_kuaishou_campaign t
+        WHERE account_id = #{accountId}
+          AND campaign_name LIKE CONCAT('%', CONCAT(#{typeName}, '%'))
+          AND put_create_time &gt;= #{nowDate}
+    </select>
 </mapper>

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -27,4 +28,6 @@ public interface IKuaiShouCampaignService extends IService<KuaiShouCampaign> {
     Long getCampaignIdByAccountAndName(Long accountId, String replaceString);
 
     Long getCampaignIdByAccountAndNameAndDate(Long accountId, String replaceString, String nowDate);
+
+    List<JSONObject> getCampaignIdsByParameters(Long accountId, String typeName, String nowDate);
 }

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

@@ -500,9 +500,7 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         };
                         thread2.start();
                     }
-
                 } else {
-
                     if (code == 500000 && count <= 4) {
                         adUnitCreate(requestJson, count + 1);
                     }

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

@@ -5,6 +5,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -91,4 +92,9 @@ public class KuaiShouCampaignServiceImpl extends ServiceImpl<KuaiShouCampaignMap
         return campaignMapper.getCampaignIdByAccountAndNameAndDate(accountId, replaceString, nowDate);
     }
 
+    @Override
+    public List<JSONObject> getCampaignIdsByParameters(Long accountId, String typeName, String nowDate) {
+        return campaignMapper.getCampaignIdsByParameters(accountId, typeName, nowDate);
+    }
+
 }

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

@@ -3,7 +3,7 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.channel.mapper.KuaishouChannelCreateStrategyMapper">
 
     <select id="queryAllIdByAccountId" resultType="java.lang.Long">
-        SELECT *
+        SELECT id
         FROM (SELECT id
               FROM ctop_kuaishou_channel_create_strategy
               WHERE account_id = #{accountId}

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

@@ -198,7 +198,7 @@
         WHERE t1.strategy_id IN
         <foreach collection="strategys" item="item" separator=","
                  open="(" close=")">
-            #{item.id}
+            #{item}
         </foreach>
             AND t1.state = 1
             AND t1.channel_state = 1
@@ -206,21 +206,20 @@
             AND is_cycle = 1
           </if>
             AND app_id in (
-                SELECT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}
+                SELECT DISTINCT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}  and app_id is not null
             )
             AND t1.usage_times = #{usageTimes}
             and t1.usage_level = #{usageLevel}
             ORDER BY t1.create_time,t1.channel_number
     </select>
 
-
     <select id="queryUsedLevel" resultType="java.lang.Integer">
         SELECT usage_times
         FROM `ctop_kuaishou_channel`
         where strategy_id in
         <foreach collection="strategys" item="item" separator=","
                  open="(" close=")">
-            #{item.id}
+            #{item}
         </foreach>
         AND state = 1
         group by usage_times