Browse Source

批量2.0 增加通配符配置项,可选关联封面数

yumeng 4 years ago
parent
commit
8b3d14b31a

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java

@@ -217,6 +217,7 @@ public class KuaiShouGroupTemplate {
     private Integer createType;
     private String photoIds;
     private String schemaUri;
+    private Integer imageCount;
 
     /**
      * 创建时间

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTemplateMapper.java

@@ -18,7 +18,7 @@ public interface KuaiShouGroupTemplateMapper extends BaseMapper<KuaiShouGroupTem
 
     JSONObject getMd5ByPhotoId(@Param("photoId") String photoId);
 
-    List<JSONObject> getImageListByMd5(@Param("md5") String md5);
+    List<JSONObject> getImageListByMd5(@Param("md5") String md5,@Param("imageCount") Integer imageCount);
 
     Integer getApiCreateCount(@Param("accountId") Long accountId, @Param("date") String date);
 

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml

@@ -18,7 +18,7 @@
       url as 'url'
       from ctop_material_cut_frame
       where video_signature = #{md5}
-       ORDER BY RAND() LIMIT 6
+      ORDER BY RAND() LIMIT #{imageCount}
     </select>
     <select id="getImageJsonByMd5" resultType="com.alibaba.fastjson.JSONObject">
       select

+ 21 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java

@@ -7,11 +7,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTemplateMapper;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+import cn.com.ctop.kuaishou.modules.batch.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -123,7 +119,11 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         String description = requestJson.getString("description");
         Long site_id = requestJson.getLong("siteId");
         String schema_uri = requestJson.getString("schemaUri");
-
+        Integer startNumber = 0;
+        if (unitName.contains("{{序号}}")) {
+            startNumber = requestJson.getInteger("startNumber");
+        }
+        Integer imageCount = requestJson.getInteger("imageCount");
 
         List<KuaiShouGroupTemplate> templates = new ArrayList<>();
         for (int i = 0; i < createCount; i++) {
@@ -140,11 +140,22 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                 }
                 template.setPhotoIds(photoIds.toJSONString());
             }
-            String name = unitName + "_" + i;
+            String name = "";
+            if (!unitName.contains("{{序号}}")) {
+                name = unitName + "_" + i;
+            } else {
+                if (i == 0) {
+                    name = unitName.replace("{{序号}}", String.valueOf(startNumber));
+                } else {
+                    name = unitName.replace("{{序号}}", String.valueOf(startNumber + i));
+                }
+            }
+
+            template.setUnitName(name);
             template.setAccountId(accountId);
             template.setUserId(userId);
             template.setCampaignId(campaignId);
-            template.setUnitName(name);
+
             if (!Check.isNull(template_id)) {
                 template.setTemplateId(template_id);
             }
@@ -238,6 +249,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
             if (!Check.isNull(site_id)) {
                 template.setSiteId(site_id);
             }
+            template.setImageCount(imageCount);
             template.setTaskStatus(0);
             template.setCreativeReviewDetail("创意待创建");
             template.setCreativeStatus(0);
@@ -609,7 +621,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
             }
             Integer materialType = videoMd5Json.getInteger("materialType");
             String videoMd5 = videoMd5Json.getString("md5");
-            List<JSONObject> imageList = groupTemplateMapper.getImageListByMd5(videoMd5);
+            List<JSONObject> imageList = groupTemplateMapper.getImageListByMd5(videoMd5, template.getImageCount());
             if (Check.isNull(imageList)) {
                 JSONObject json = new JSONObject();
                 json.put("creative_name", template.getCreativeName());