Parcourir la source

项目自动化功能,bug修改

zhaoxian il y a 3 ans
Parent
commit
999f8b6747

+ 8 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouProjectStrategyController.java

@@ -13,7 +13,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -147,13 +149,13 @@ public class KuaishouProjectStrategyController {
             }
             boolean ok = kuaishouProjectStrategyService.checkProjectisOpen(projectId);
             if (ok) {
-                return Result.ok((Object)1);
+                return Result.ok((Object) 1);
             }
         } catch (Exception e) {
             log.error("修改异常,", e.getMessage());
             e.printStackTrace();
         }
-        return Result.ok((Object)0);
+        return Result.ok((Object) 0);
     }
 
     /**
@@ -194,6 +196,10 @@ public class KuaishouProjectStrategyController {
         try {
             KuaishouProjectStrategy kuaishouProjectStrategy = JSONObject.parseObject(data.toJSONString(), KuaishouProjectStrategy.class);
             kuaishouProjectStrategy.setStatDate(DateUtils.getNowDate("yyyy-MM-dd"));
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            if (!Check.isNull(user)) {
+                kuaishouProjectStrategy.setUserId(user.getId());
+            }
             kuaishouProjectStrategyService.saveOrUpdate(kuaishouProjectStrategy);
             result.success("操作成功!");
         } catch (Exception e) {

+ 2 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouProjectStrategyMapper.xml

@@ -143,11 +143,10 @@
         </if>
             ) as 'allAccountCount'
         FROM ctop_user_allocation t1
-                 LEFT JOIN ctop_etl_kuaishou_report_account_daily t2 ON t2.account_id = t1.account_id
+                 LEFT JOIN ctop_etl_kuaishou_report_account_daily t2 ON t2.account_id = t1.account_id and t2.stat_date &gt;=#{startTime}
+                 and t2.stat_date &lt;=#{endTime}
                  LEFT JOIN ctop_project t3 ON t1.project_id = t3.id
         where t1.auto_delivery != 3
-          and t2.stat_date &gt;=#{startTime}
-          and t2.stat_date &lt;=#{endTime}
         <if test="projectId != null ">
             and t1.project_id = #{projectId}
         </if>

+ 10 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouProjectCreateCreativeServiceImpl.java

@@ -1210,6 +1210,15 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         return split[i];
     }
 
+    public static String getDescription(String description) {
+        if (Check.isNull(description)) {
+            return null;
+        }
+        JSONArray descArr = JSONArray.parseArray(description);
+        int i = getrandom(0, descArr.size() - 1);
+        return descArr.getString(i);
+    }
+
     private Long getBidByString(String cpaBid) {
         if (Check.isNull(cpaBid)) {
             return null;
@@ -1240,6 +1249,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         if ((null != cutFrameList && !cutFrameList.isEmpty())) {
             for (int i = 0; i < cutFrameList.size(); i++) {
                 creativeParams.put("action_bar_text", getActionBar(strategy.getActionBarText()));
+                creativeParams.put("description", getDescription(strategy.getDescription()));
                 String imageCode = cutFrameList.get(i).getSignature();
                 String imageUrl = cutFrameList.get(i).getUrl();
                 String imageToken = getImageToken(imageUrl, imageCode, token.getAccountId(), token.getAccessToken());
@@ -1272,10 +1282,6 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         creativeParams.put("unit_id", unitId);
         creativeParams.put("photo_id", videoItem.getPhotoId());
         creativeParams.put("creative_material_type", videoItem.getMaterialType());
-        JSONArray descArr = JSONArray.parseArray(strategy.getDescription());
-        int index = new Random().nextInt(descArr.size());
-        String description = descArr.getString(index);
-        creativeParams.put("description", description);
         // 封面广告语标题
         if (!Check.isNull(strategy.getStickerTitle())) {
             creativeParams.put("sticker_title", strategy.getStickerTitle());