Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

songyh 3 lat temu
rodzic
commit
05bdba682d

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -98,7 +98,7 @@
      <if test="uploadYears !=null and uploadYears != ''">
      <if test="uploadYears !=null and uploadYears != ''">
         AND DATE_FORMAT( date_time, '%Y-%m' ) =  #{uploadYears}
         AND DATE_FORMAT( date_time, '%Y-%m' ) =  #{uploadYears}
     </if>
     </if>
-    <if test="accountIds !=null and accountIds != ''">
+    <if test='accountIds != null and accountIds.size() > 0'>
         AND account_id in
         AND account_id in
         <foreach collection="accountIds" item="item" separator=","
         <foreach collection="accountIds" item="item" separator=","
                  open="(" close=")">
                  open="(" close=")">

+ 3 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -51,7 +51,7 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
 
     List<UserAllocation> getAccountListByUserIdAndProductId(@Param("userId") String userId, @Param("projectId") Long projectId, @Param("productId") Long productId);
     List<UserAllocation> getAccountListByUserIdAndProductId(@Param("userId") String userId, @Param("projectId") Long projectId, @Param("productId") Long productId);
 
 
-    List<JSONObject> getUserIdListByProductId(@Param("productId") Long productId);
+    List<JSONObject> getUserIdListByProductId(@Param("productId") Long productId, @Param("userId") String userId);
 
 
     List<JSONObject> getByAccountIds(@Param("accountIds") JSONArray accountIds);
     List<JSONObject> getByAccountIds(@Param("accountIds") JSONArray accountIds);
 
 
@@ -59,7 +59,7 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
 
     List<JSONObject> selectAccountsByKuaishouUserId(@Param("userId") Long userId);
     List<JSONObject> selectAccountsByKuaishouUserId(@Param("userId") Long userId);
 
 
-    int updateProjectStrategyStatus(@Param("accountId") Long accountId,@Param("projectStrategy") Integer projectStrategy);
+    int updateProjectStrategyStatus(@Param("accountId") Long accountId, @Param("projectStrategy") Integer projectStrategy);
 
 
     List<Long> queryAutomaticAccounts(@Param("projectId") Long projectId);
     List<Long> queryAutomaticAccounts(@Param("projectId") Long projectId);
 
 
@@ -73,5 +73,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<JSONObject> getAccountListByProjectListV2(@Param("list") List list);
     List<JSONObject> getAccountListByProjectListV2(@Param("list") List list);
 
 
     List<JSONObject> getAccountListByProjectAndUserId(@Param("projectId") Long projectId, @Param("userId") String userId);
     List<JSONObject> getAccountListByProjectAndUserId(@Param("projectId") Long projectId, @Param("userId") String userId);
+
     List<Long> getAccountListByProjectId(@Param("projectId") Long projectId);
     List<Long> getAccountListByProjectId(@Param("projectId") Long projectId);
 }
 }

+ 46 - 13
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -85,18 +85,47 @@
     GROUP BY t1.user_id;
     GROUP BY t1.user_id;
     </select>
     </select>
     <select id="getUserIdListByProductId" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getUserIdListByProductId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.user_id as 'userId',
-               t1.account_id as 'accountId',
-               t1.user_name  as 'userName'
-        from  ctop_kuaishou_advertiser_base_info t1  LEFT JOIN
-              ctop_user_allocation  t2
-              ON t1.account_id = t2.account_id
-                                                     left join
-              ctop_project t3
-                on t2.project_id=t3.id
-        WHERE t3.product_id = #{productId}
-          AND t2.account_status = 0
-        GROUP BY t1.user_id;
+       SELECT
+	*
+FROM
+	(
+		SELECT
+			t4.user_id AS 'userId',
+			t3.account_id AS 'accountId',
+			t3.auth_name AS 'userName',
+			t1.project_name AS 'projectName'
+		FROM
+			ctop_project t1
+		INNER JOIN (
+			SELECT
+				project_id
+			FROM
+				ctop_project_member
+			WHERE
+				project_id IN (
+					SELECT
+						id
+					FROM
+						ctop_project
+					WHERE
+						product_id = #{productId}
+					AND media_id IN (2, 4)
+				)
+        <if test="userId != null and userId != ''">
+            AND user_id = #{userId}
+        </if>
+		) t2 ON t1.id = t2.project_id
+		LEFT JOIN ctop_user_allocation t3 ON t1.id = t3.project_id
+		LEFT JOIN ctop_kuaishou_advertiser_base_info t4 ON t3.account_id = t4.account_id
+		WHERE
+			t1.product_id = #{productId}
+		AND t3.account_status = 0
+		GROUP BY
+			t4.user_id
+	) t
+ORDER BY
+	t.projectName,
+	t.userId
     </select>
     </select>
 
 
     <select id="getValidProjectIds" resultType="java.lang.Long">
     <select id="getValidProjectIds" resultType="java.lang.Long">
@@ -308,7 +337,11 @@
             id = #{id}
             id = #{id}
     </update>
     </update>
 
 
-
+    <select id="getAccountListByProjectId" resultType="java.lang.Long">
+        select account_id from ctop_user_allocation
+        WHERE account_status = 0
+          AND project_id = #{projectId}
+    </select>
 
 
 
 
 </mapper>
 </mapper>

+ 4 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -4,7 +4,6 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.apache.ibatis.annotations.Param;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 
 
 import java.util.List;
 import java.util.List;
@@ -46,11 +45,11 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
 
     List<Long> getAccountsByDeleteComment();
     List<Long> getAccountsByDeleteComment();
 
 
-    List<UserAllocation> getAccountListByUserIdAndProductId(String userId,Long projectId,Long productId);
+    List<UserAllocation> getAccountListByUserIdAndProductId(String userId, Long projectId, Long productId);
 
 
     Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
     Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
 
 
-    List<JSONObject> getUserIdListByProductId(Long productId);
+    List<JSONObject> getUserIdListByProductId(Long productId, String userId);
 
 
     /**
     /**
      * 获取有效的项目ID集合
      * 获取有效的项目ID集合
@@ -65,6 +64,7 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     List<Long> getKuaiShouUserIdListByProjectId(Long projectId);
     List<Long> getKuaiShouUserIdListByProjectId(Long projectId);
 
 
     List<JSONObject> selectAccountsByKuaishouUserId(Long userId);
     List<JSONObject> selectAccountsByKuaishouUserId(Long userId);
+
     boolean updateProjectStrategyStatus(Long accountId, Integer projectStrategy);
     boolean updateProjectStrategyStatus(Long accountId, Integer projectStrategy);
 
 
     List<Long> queryAutomaticAccounts(Long projectId);
     List<Long> queryAutomaticAccounts(Long projectId);
@@ -74,5 +74,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     Map<Long, List<JSONObject>> getAccountListByProjectListV2(List<JSONObject> projectList);
     Map<Long, List<JSONObject>> getAccountListByProjectListV2(List<JSONObject> projectList);
 
 
     List<JSONObject> getAccountListByProjectAndUserId(Long projectId, String userId);
     List<JSONObject> getAccountListByProjectAndUserId(Long projectId, String userId);
+
     List<Long> getAccountListByProjectId(Long projectId);
     List<Long> getAccountListByProjectId(Long projectId);
 }
 }

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -223,8 +223,8 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
     }
 
 
     @Override
     @Override
-    public List<JSONObject> getUserIdListByProductId(Long productId) {
-        return userAllocationMapper.getUserIdListByProductId(productId);
+    public List<JSONObject> getUserIdListByProductId(Long productId,String userId) {
+        return userAllocationMapper.getUserIdListByProductId(productId,userId);
     }
     }
 
 
     @Override
     @Override

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

@@ -8,35 +8,14 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCampaignLevelOperationRecord;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCreativeLevelOperationRecord;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
+import cn.com.ctop.kuaishou.modules.ai.entity.*;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreativeLevelOperationRecordService;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouUnitLevelOperationRecordService;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
-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.IKuaiShouUpdateService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelService;
 import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelService;
@@ -54,14 +33,7 @@ import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.UUID;
+import java.util.*;
 
 
 @Slf4j
 @Slf4j
 @Service
 @Service
@@ -302,12 +274,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     appName = appInfo.getAppName();
                     appName = appInfo.getAppName();
                 }
                 }
             }
             }
+            KuaishouChannel channel = null;
+            KuaishouChannel usedchannel = null;
+            Long newCampaignId = null;
             //渠道号应用层级,account-账户,plan-计划,group-组
             //渠道号应用层级,account-账户,plan-计划,group-组
             String level = strategy.getUsageLevel();
             String level = strategy.getUsageLevel();
             Integer useChannel = strategy.getUseChannel();//0不使用,1使用
             Integer useChannel = strategy.getUseChannel();//0不使用,1使用
-            KuaishouChannel channel = null;
-            if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
-                try {
+            try {
+                if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
                     Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
                     Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
                     Integer code = result.getCode();
                     Integer code = result.getCode();
                     if (code == 200) {
                     if (code == 200) {
@@ -322,113 +296,123 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         log.error("通过账户(" + accountId + ")未获取到渠道号!!!");
                         log.error("通过账户(" + accountId + ")未获取到渠道号!!!");
                         return videoCnt;
                         return videoCnt;
                     }
                     }
-                } catch (Exception e) {
-                    e.printStackTrace();
                 }
                 }
-            }
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
-            if (null == newCampaignId) {
-                return videoCnt;
-            }
-            KuaishouChannel usedchannel = null;
-            if (useChannel == 1) {
-                strategy.setMaterialKeyword(null);
-                if (!"group".equals(level)) {
-                    usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
-                    if (Check.isNull(usedchannel)) {
-                        if ("account".equals(level)) {
-                            usedchannel = channel;
-                        } else {
-                            return videoCnt;
-                        }
+                newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
+                if (null == newCampaignId) {
+                    if (!Check.isNull(channel)) {
+                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
                     }
                     }
-                    List<KuaishouChannelItems> items = usedchannel.getItems();
-                    if (!Check.isNull(items) && !items.isEmpty()) {
-                        strategy.setMaterialKeyword(items.get(0).getKeyword());
+                    return videoCnt;
+                }
+                if (useChannel == 1) {
+                    strategy.setMaterialKeyword(null);
+                    if (!"group".equals(level)) {
+                        usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
+                        if (Check.isNull(usedchannel)) {
+                            if ("account".equals(level)) {
+                                usedchannel = channel;
+                            } else {
+                                if (!Check.isNull(channel)) {
+                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
+                                }
+                                return videoCnt;
+                            }
+                        }
+                        List<KuaishouChannelItems> items = usedchannel.getItems();
+                        if (!Check.isNull(items) && !items.isEmpty()) {
+                            strategy.setMaterialKeyword(items.get(0).getKeyword());
+                        }
                     }
                     }
                 }
                 }
-            }
-            List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
-            if (null == newVideos || newVideos.isEmpty()) {
-                log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
-                return videoCnt;
-            }
-            //3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
-            for (KuaiShouVideoGet videoItem : newVideos) {
-                Boolean unitOverrun = getUnitOverrun(accountId);
-                if (unitOverrun) {
-                    log.error("组创建超限,accountId:{}", accountId);
-                    return 0L;
+                List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
+                if (null == newVideos || newVideos.isEmpty()) {
+                    log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
+                    return videoCnt;
                 }
                 }
+                //3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
+                for (KuaiShouVideoGet videoItem : newVideos) {
+                    Boolean unitOverrun = getUnitOverrun(accountId);
+                    if (unitOverrun) {
+                        log.error("组创建超限,accountId:{}", accountId);
+                        return 0L;
+                    }
 
 
-                KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
-                if (null != overrunInfo) {
-                    return 0L;
-                }
-                // 每个组,搭配5个创意
-                List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
-                if ((null == cutFrameList || cutFrameList.isEmpty())) {
-                    log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
-                    continue;
-                }
-                //获取组级渠道号
-                if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
-                    try {
-                        Result<Object> result = channelService.queryChannel(accountId, level, appName, videoItem.getPhotoName());
-                        Integer code = result.getCode();
-                        if (code == 200) {
-                            usedchannel = (KuaishouChannel) result.getResult();
-                            if (Check.isNull(usedchannel)) {
-                                log.info("(组级)账户:{}素材名称({}),{}",accountId,videoItem.getPhotoName(), result.getMessage());
-                                continue;
+                    KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
+                    if (null != overrunInfo) {
+                        return 0L;
+                    }
+                    // 每个组,搭配5个创意
+                    List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                    if ((null == cutFrameList || cutFrameList.isEmpty())) {
+                        log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
+                        continue;
+                    }
+                    //获取组级渠道号
+                    if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
+                        try {
+                            Result<Object> result = channelService.queryChannel(accountId, level, appName, videoItem.getPhotoName());
+                            Integer code = result.getCode();
+                            if (code == 200) {
+                                usedchannel = (KuaishouChannel) result.getResult();
+                                if (Check.isNull(usedchannel)) {
+                                    log.info("(组级)账户:{}素材名称({}),{}", accountId, videoItem.getPhotoName(), result.getMessage());
+                                    continue;
+                                } else {
+                                    log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
+                                }
                             } else {
                             } else {
-                                log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
+                                log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!", accountId, videoItem.getPhotoName());
+                                continue;
                             }
                             }
-                        } else {
-                            log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!",accountId,videoItem.getPhotoName());
-                            continue;
+                        } catch (Exception e) {
+                            e.printStackTrace();
                         }
                         }
-                    } catch (Exception e) {
-                        e.printStackTrace();
                     }
                     }
-                }
-                String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, usedchannel);
-                JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
-                log.info("创建广告组入参:{}", unitParams);
-                Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
-                Integer unitCode = (Integer) unitCreateResult.get("code");
-                String unitMessage = (String) unitCreateResult.get("message");
-                AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
-                BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
-                unitLevelOperationRecord.setGroupName(unitName);
-                unitLevelOperationRecord.setCampaignId(newCampaignId);
-                unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
-                unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
-                unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
-                unitLevelOperationRecord.setCreateTime(new Date());
-                unitLevelOperationRecord.setStatus(unitCode);
-                unitLevelOperationRecord.setMessage(unitMessage);
-                unitLevelOperationRecord.setCampaignId(newCampaignId);
-                unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
-                if (unitCode != 0) {
-                    log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                    String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, usedchannel);
+                    JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
+                    log.info("创建广告组入参:{}", unitParams);
+                    Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
+                    Integer unitCode = (Integer) unitCreateResult.get("code");
+                    String unitMessage = (String) unitCreateResult.get("message");
+                    AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
+                    BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                    unitLevelOperationRecord.setGroupName(unitName);
+                    unitLevelOperationRecord.setCampaignId(newCampaignId);
+                    unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                    unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
+                    unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
+                    unitLevelOperationRecord.setCreateTime(new Date());
+                    unitLevelOperationRecord.setStatus(unitCode);
+                    unitLevelOperationRecord.setMessage(unitMessage);
+                    unitLevelOperationRecord.setCampaignId(newCampaignId);
+                    unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
+                    if (unitCode != 0) {
+                        log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                        unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                        if (!Check.isNull(usedchannel)) {
+                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
+                        }
+                        continue;
+                    }
+                    Long unitId = (Long) unitCreateResult.get("unitId");
+                    unitLevelOperationRecord.setUnitId(unitId);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                    videoCnt--;
                     if (!Check.isNull(usedchannel)) {
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
                     }
                     }
-                    continue;
+                    JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
+                    createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
+                    if (videoCnt <= 0) {
+                        return 0L;
+                    }
+
                 }
                 }
-                Long unitId = (Long) unitCreateResult.get("unitId");
-                unitLevelOperationRecord.setUnitId(unitId);
-                unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                videoCnt--;
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("创建自定义广告组异常", e);
                 if (!Check.isNull(usedchannel)) {
                 if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
-                }
-                JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
-                createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
-                if (videoCnt <= 0) {
-                    return 0L;
+                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
                 }
                 }
             }
             }
         }
         }
@@ -662,8 +646,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             String level = strategy.getUsageLevel();
             String level = strategy.getUsageLevel();
             Integer useChannel = strategy.getUseChannel();//0不使用,1使用
             Integer useChannel = strategy.getUseChannel();//0不使用,1使用
             KuaishouChannel channel = null;
             KuaishouChannel channel = null;
-            if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
-                try {
+            KuaishouChannel usedchannel = null;
+            Long newCampaignId = null;
+            try {
+                if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
                     Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
                     Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
                     Integer code = result.getCode();
                     Integer code = result.getCode();
                     if (code == 200) {
                     if (code == 200) {
@@ -678,114 +664,123 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         log.error("通过账户(" + accountId + ")未获取到渠道号!!!");
                         log.error("通过账户(" + accountId + ")未获取到渠道号!!!");
                         return;
                         return;
                     }
                     }
-                } catch (Exception e) {
-                    e.printStackTrace();
                 }
                 }
-            }
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
-            if (null == newCampaignId) {
-                return;
-            }
-            KuaishouChannel usedchannel = null;
-            if (useChannel == 1) {
-                strategy.setMaterialKeyword(null);
-                if (!"group".equals(level)) {
-                    usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
-                    if (Check.isNull(usedchannel)) {
-                        if ("account".equals(level)) {
-                            usedchannel = channel;
-                        } else {
-                            return;
-                        }
+                newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
+                if (null == newCampaignId) {
+                    if (!Check.isNull(channel)) {
+                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
                     }
                     }
-                    List<KuaishouChannelItems> items = usedchannel.getItems();
-                    if (!Check.isNull(items) && !items.isEmpty()) {
-                        strategy.setMaterialKeyword(items.get(0).getKeyword());
+                    return;
+                }
+                if (useChannel == 1) {
+                    strategy.setMaterialKeyword(null);
+                    if (!"group".equals(level)) {
+                        usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
+                        if (Check.isNull(usedchannel)) {
+                            if ("account".equals(level)) {
+                                usedchannel = channel;
+                            } else {
+                                if (!Check.isNull(channel)) {
+                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
+                                }
+                                return;
+                            }
+                        }
+                        List<KuaishouChannelItems> items = usedchannel.getItems();
+                        if (!Check.isNull(items) && !items.isEmpty()) {
+                            strategy.setMaterialKeyword(items.get(0).getKeyword());
+                        }
                     }
                     }
                 }
                 }
-            }
-            List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
-            if (null == allVideos) {
-                return;
-            }
-            //创意
-            List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
-            for (int j = 1; j < splitVideos.size() + 1; j++) {
-                Boolean unitOverrun = getUnitOverrun(accountId);
-                if (unitOverrun) {
-                    log.error("组创建超限,accountId:{}", accountId);
+                List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
+                if (null == allVideos) {
                     return;
                     return;
                 }
                 }
-
-                Object redisObj = redisUtil.get(key);
-                if (!Check.isNull(redisObj)) {
-                    Integer value = (Integer) redisObj;
-                    if (value == 1) {
-                        log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
+                //创意
+                List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
+                for (int j = 1; j < splitVideos.size() + 1; j++) {
+                    Boolean unitOverrun = getUnitOverrun(accountId);
+                    if (unitOverrun) {
+                        log.error("组创建超限,accountId:{}", accountId);
                         return;
                         return;
                     }
                     }
-                }
-                //获取组级渠道号
-                if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
-                    try {
-                        KuaiShouVideoGet videoGet = splitVideos.get(1).get(0);
-                        if (Check.isNull(videoGet)) {
+
+                    Object redisObj = redisUtil.get(key);
+                    if (!Check.isNull(redisObj)) {
+                        Integer value = (Integer) redisObj;
+                        if (value == 1) {
+                            log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
                             return;
                             return;
                         }
                         }
-                        Result<Object> result = channelService.queryChannel(accountId, level, appName, videoGet.getPhotoName());
-                        Integer code = result.getCode();
-                        if (code == 200) {
-                            usedchannel = (KuaishouChannel) result.getResult();
-                            if (Check.isNull(usedchannel)) {
-                                log.info("(组级)账户:{}素材名称({}),{}",accountId,videoGet.getPhotoName(), result.getMessage());
-                                continue;
+                    }
+                    //获取组级渠道号
+                    if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
+                        try {
+                            KuaiShouVideoGet videoGet = splitVideos.get(1).get(0);
+                            if (Check.isNull(videoGet)) {
+                                return;
+                            }
+                            Result<Object> result = channelService.queryChannel(accountId, level, appName, videoGet.getPhotoName());
+                            Integer code = result.getCode();
+                            if (code == 200) {
+                                usedchannel = (KuaishouChannel) result.getResult();
+                                if (Check.isNull(usedchannel)) {
+                                    log.info("(组级)账户:{}素材名称({}),{}", accountId, videoGet.getPhotoName(), result.getMessage());
+                                    continue;
+                                } else {
+                                    log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
+                                }
                             } else {
                             } else {
-                                log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
+                                log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!", accountId, videoGet.getPhotoName());
+                                continue;
                             }
                             }
-                        } else {
-                            log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!",accountId,videoGet.getPhotoName());
-                            continue;
+                        } catch (Exception e) {
+                            e.printStackTrace();
                         }
                         }
-                    } catch (Exception e) {
-                        e.printStackTrace();
                     }
                     }
-                }
 
 
-                //创建组
-                String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, usedchannel);
-                JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
-                log.info("创建广告组入参:{}", unitParams);
-                Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
-                Integer unitCode = (Integer) unitCreateResult.get("code");
-                String unitMessage = (String) unitCreateResult.get("message");
-                AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
-                BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
-                unitLevelOperationRecord.setGroupName(unitName);
-                unitLevelOperationRecord.setCampaignId(newCampaignId);
-                unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
-                unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
-                unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
-                unitLevelOperationRecord.setCreateTime(new Date());
-                unitLevelOperationRecord.setStatus(unitCode);
-                unitLevelOperationRecord.setMessage(unitMessage);
-                unitLevelOperationRecord.setCampaignId(newCampaignId);
-                unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
-                if (unitCode != 0) {
-                    log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                    //创建组
+                    String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, usedchannel);
+                    JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
+                    log.info("创建广告组入参:{}", unitParams);
+                    Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
+                    Integer unitCode = (Integer) unitCreateResult.get("code");
+                    String unitMessage = (String) unitCreateResult.get("message");
+                    AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
+                    BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                    unitLevelOperationRecord.setGroupName(unitName);
+                    unitLevelOperationRecord.setCampaignId(newCampaignId);
+                    unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                    unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
+                    unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
+                    unitLevelOperationRecord.setCreateTime(new Date());
+                    unitLevelOperationRecord.setStatus(unitCode);
+                    unitLevelOperationRecord.setMessage(unitMessage);
+                    unitLevelOperationRecord.setCampaignId(newCampaignId);
+                    unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
+                    if (unitCode != 0) {
+                        log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                        unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                        if (!Check.isNull(usedchannel)) {
+                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
+                        }
+                        continue;
+                    }
+                    Long unitId = (Long) unitCreateResult.get("unitId");
+                    unitLevelOperationRecord.setUnitId(unitId);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     if (!Check.isNull(usedchannel)) {
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
                     }
                     }
-                    return;
+                    JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
+                    createProgramCreative(token, creativeParams, strategy);
                 }
                 }
-                Long unitId = (Long) unitCreateResult.get("unitId");
-                unitLevelOperationRecord.setUnitId(unitId);
-                unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                if (!Check.isNull(channel)) {
-                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("创建程序化广告组异常", e);
+                if (!Check.isNull(usedchannel)) {
+                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
                 }
                 }
-                JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
-                createProgramCreative(token, creativeParams, strategy);
             }
             }
         }
         }
 
 
@@ -1058,14 +1053,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         }
         String appVersion = null;
         String appVersion = null;
         if (Check.isNull(strategy.getMaterialKeyword())) {
         if (Check.isNull(strategy.getMaterialKeyword())) {
-            if (!Check.isNull(appInfo.getAppVersion())) {
-                String[] split = appInfo.getAppVersion().split("-");
-                if (split.length > 1) {
-                    appVersion = split[1];
-                } else {
-                    return null;
+            if (!Check.isNull(appInfo)) {
+                if (!Check.isNull(appInfo.getAppVersion())) {
+                    String[] split = appInfo.getAppVersion().split("-");
+                    if (split.length > 1) {
+                        appVersion = split[1];
+                    } else {
+                        return null;
+                    }
                 }
                 }
             }
             }
+
         } else { //  tt语音 特殊素材查询
         } else { //  tt语音 特殊素材查询
             appVersion = strategy.getMaterialKeyword();
             appVersion = strategy.getMaterialKeyword();
         }
         }

+ 5 - 15
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelItemsServiceImpl.java

@@ -3,7 +3,6 @@ package cn.com.ctop.kuaishou.modules.channel.service.impl;
 import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItemsRel;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItemsRel;
 import cn.com.ctop.kuaishou.modules.channel.mapper.KuaishouChannelItemsMapper;
 import cn.com.ctop.kuaishou.modules.channel.mapper.KuaishouChannelItemsMapper;
@@ -14,10 +13,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -26,16 +22,11 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.common.util.MD5Util;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -108,15 +99,14 @@ public class KuaishouChannelItemsServiceImpl extends ServiceImpl<KuaishouChannel
                 continue;
                 continue;
             }
             }
             QueryWrapper<KuaishouChannelItemsRel> queryWrapper = new QueryWrapper<>();
             QueryWrapper<KuaishouChannelItemsRel> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("channel_id", object.getLong("channelId"));
-            queryWrapper.eq("item_id", object.getLong("id")).last("limit 1");
+            queryWrapper.eq("channel_id", object.getLong("channelId")).last("limit 1");
             KuaishouChannelItemsRel one = channelItemsRelService.getOne(queryWrapper);
             KuaishouChannelItemsRel one = channelItemsRelService.getOne(queryWrapper);
             if (Check.isNull(one)) {
             if (Check.isNull(one)) {
-                KuaishouChannelItemsRel rel = new KuaishouChannelItemsRel();
-                rel.setItemId(object.getLong("id"));
-                rel.setChannelId(object.getLong("channelId"));
-                channelItemsRelService.save(rel);
+                one = new KuaishouChannelItemsRel();
             }
             }
+            one.setItemId(object.getLong("id"));
+            one.setChannelId(object.getLong("channelId"));
+            channelItemsRelService.saveOrUpdate(one);
         }
         }
         return Result.ok("绑定成功");
         return Result.ok("绑定成功");
     }
     }

+ 94 - 73
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

@@ -54,12 +54,10 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 
 /**
 /**
  * 渠道号信息表
  * 渠道号信息表
@@ -123,8 +121,6 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     private static final String NUMBER_STR = "{{编号}}";
     private static final String NUMBER_STR = "{{编号}}";
     private static final String CHANNEL = "_channel_FLAG";
     private static final String CHANNEL = "_channel_FLAG";
 
 
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
-
 
 
     @Override
     @Override
     public Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId, String userId) {
     public Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId, String userId) {
@@ -329,41 +325,47 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                     }
                     }
                 } else {
                 } else {
                     /**-----------------项目维度:使用层级是计划、组-----------------*/
                     /**-----------------项目维度:使用层级是计划、组-----------------*/
-                    accountList.forEach(accountId -> executorService.submit(() -> {
-                        //获取token
-                        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-                        //获取应用图片token
-                        JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
-                        if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
-                            log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
-                        }
-                        //使用范围是账户时,查询旧app来做匹配
-                        kuaishouInterfaceService.getAppList(accountId, token.getAccessToken());
-                        List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
-                        strategy.setImageToken(tokenJson.getString("imageToken"));
-                        strategy.setAccountId(accountId);
-                        if (url.contains(CHANNEL_STR)) {
-                            for (int i = numberMin; i <= numberMax; i++) {
-                                try {
-                                    KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
-                                    createApp(replaceData, token, oldAppList);
-                                    createChannel(replaceData, i, 1);
-                                } catch (Exception e) {
-                                    e.printStackTrace();
+                    Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            for (Long accountId : accountList) {
+                                //获取token
+                                CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+                                //获取应用图片token
+                                JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
+                                if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
+                                    log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
                                 }
                                 }
-                            }
-                        } else {
-                            try {
-                                createApp(strategy, token, oldAppList);
-                                for (int i = numberMin; i <= numberMax; i++) {
-                                    KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
-                                    createChannel(replaceData, i, 1);
+                                //使用范围是账户时,查询旧app来做匹配
+                                kuaishouInterfaceService.getAppList(accountId, token.getAccessToken());
+                                List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
+                                strategy.setImageToken(tokenJson.getString("imageToken"));
+                                strategy.setAccountId(accountId);
+                                if (url.contains(CHANNEL_STR)) {
+                                    for (int i = numberMin; i <= numberMax; i++) {
+                                        try {
+                                            KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
+                                            createApp(replaceData, token, oldAppList);
+                                            createChannel(replaceData, i, 1);
+                                        } catch (Exception e) {
+                                            e.printStackTrace();
+                                        }
+                                    }
+                                } else {
+                                    try {
+                                        createApp(strategy, token, oldAppList);
+                                        for (int i = numberMin; i <= numberMax; i++) {
+                                            KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
+                                            createChannel(replaceData, i, 1);
+                                        }
+                                    } catch (Exception e) {
+                                        e.printStackTrace();
+                                    }
                                 }
                                 }
-                            } catch (Exception e) {
-                                e.printStackTrace();
                             }
                             }
                         }
                         }
-                    }));
+                    };
+                    thread.start();
                 }
                 }
             } else {
             } else {
                 /**==========================范围是 账户==========================*/
                 /**==========================范围是 账户==========================*/
@@ -379,25 +381,38 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                 List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(token.getAccountId());
                 List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(token.getAccountId());
                 strategy.setImageToken(tokenJson.getString("imageToken"));
                 strategy.setImageToken(tokenJson.getString("imageToken"));
                 if (url.contains(CHANNEL_STR)) {
                 if (url.contains(CHANNEL_STR)) {
-                    ilist.forEach(i -> executorService.submit(() -> {
-                        try {
-                            KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
-                            createApp(replaceData, token, oldAppList);
-                            createChannel(replaceData, i, 1);
-                        } catch (Exception e) {
-                            e.printStackTrace();
+                    Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            try {
+                                for (int i = numberMin; i <= numberMax; i++) {
+                                    KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
+                                    createApp(replaceData, token, oldAppList);
+                                    createChannel(replaceData, i, 1);
+                                }
+
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
                         }
                         }
-                    }));
+                    };
+                    thread.start();
                 } else {
                 } else {
                     createApp(strategy, token, oldAppList);
                     createApp(strategy, token, oldAppList);
-                    ilist.forEach(i -> executorService.submit(() -> {
-                        try {
-                            KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
-                            createChannel(replaceData, i, 1);
-                        } catch (Exception e) {
-                            e.printStackTrace();
+                    Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            try {
+                                for (int i = numberMin; i <= numberMax; i++) {
+                                    KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
+                                    createChannel(replaceData, i, 1);
+                                }
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
                         }
                         }
-                    }));
+                    };
+                    thread.start();
                 }
                 }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
@@ -913,26 +928,32 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                         }
                         }
                     } else {
                     } else {
                         /**-----------------项目维度:使用层级是计划、组-----------------*/
                         /**-----------------项目维度:使用层级是计划、组-----------------*/
-                        accountList.forEach(accountId -> executorService.submit(() -> {
-                            //获取token
-                            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-                            //获取应用图片token
-                            JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
-                            if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
-                                log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
-                            }
-                            //使用范围是账户时,查询旧app来做匹配
-                            kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
-                            List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
-                            strategy.setImageToken(tokenJson.getString("imageToken"));
-                            strategy.setAccountId(accountId);
-                            try {
-                                createApp(strategy, token, oldAppList);
-                                createChannel(strategy, 0, 1);
-                            } catch (Exception e) {
-                                e.printStackTrace();
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                for (Long accountId : accountList) {
+                                    //获取token
+                                    CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+                                    //获取应用图片token
+                                    JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
+                                    if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
+                                        log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
+                                    }
+                                    //使用范围是账户时,查询旧app来做匹配
+                                    kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
+                                    List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
+                                    strategy.setImageToken(tokenJson.getString("imageToken"));
+                                    strategy.setAccountId(accountId);
+                                    try {
+                                        createApp(strategy, token, oldAppList);
+                                        createChannel(strategy, 0, 1);
+                                    } catch (Exception e) {
+                                        e.printStackTrace();
+                                    }
+                                }
                             }
                             }
-                        }));
+                        };
+                        thread.start();
                     }
                     }
                 } else {
                 } else {
                     /**==========================范围是 账户==========================*/
                     /**==========================范围是 账户==========================*/
@@ -1035,8 +1056,9 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             queryWrapper.eq("channel_code", channelCode).last("limit 1");
             queryWrapper.eq("channel_code", channelCode).last("limit 1");
             KuaishouChannel one = this.getOne(queryWrapper);
             KuaishouChannel one = this.getOne(queryWrapper);
             if (!Check.isNull(one)) {
             if (!Check.isNull(one)) {
+                one.setUpdateTime(new Date());
+                one.setChannelLock(1);
                 if (0 == state) {
                 if (0 == state) {
-                    one.setChannelLock(1);
                     this.saveOrUpdate(one);
                     this.saveOrUpdate(one);
                 } else {
                 } else {
                     QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
                     QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
@@ -1049,16 +1071,15 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                         }
                         }
                         rel.setCampaignId(planId);
                         rel.setCampaignId(planId);
                         rel.setUnitId(groupId);
                         rel.setUnitId(groupId);
+                        rel.setUpdateTime(new Date());
                         channelRelService.save(rel);
                         channelRelService.save(rel);
                         if ("plan".equals(level)) {
                         if ("plan".equals(level)) {
                             Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
                             Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
                             one.setUsageTimes(usageTimes);
                             one.setUsageTimes(usageTimes);
-                            one.setChannelLock(1);
                             this.saveOrUpdate(one);
                             this.saveOrUpdate(one);
                         } else if ("group".equals(level)) {
                         } else if ("group".equals(level)) {
                             Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
                             Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
                             one.setUsageTimes(usageTimes);
                             one.setUsageTimes(usageTimes);
-                            one.setChannelLock(1);
                             this.saveOrUpdate(one);
                             this.saveOrUpdate(one);
                         }
                         }
                     }
                     }

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

@@ -1,7 +1,5 @@
 package org.jeecg.modules.ctop.controller;
 package org.jeecg.modules.ctop.controller;
 
 
-import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
-import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.Project;
@@ -13,7 +11,6 @@ import cn.com.ctop.common.module.service.ISysRoleExtService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.common.module.utils.StringUtils;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAdvertiserBaseInfoService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
@@ -98,13 +95,17 @@ public class UserAllocationController {
 
 
 
 
     @GetMapping(value = "/getUserIdListByProductId")
     @GetMapping(value = "/getUserIdListByProductId")
-    public Result<List<JSONObject>> getUserIdListByProductId(Long productId) {
+    public Result<List<JSONObject>> getUserIdListByProductId(Long productId, String userId) {
         Result<List<JSONObject>> result = new Result<>();
         Result<List<JSONObject>> result = new Result<>();
         try {
         try {
             if (Check.isNull(productId)) {
             if (Check.isNull(productId)) {
                 throw new Exception("请选择产品id");
                 throw new Exception("请选择产品id");
             }
             }
-            List<JSONObject> userIdList = userAllocationService.getUserIdListByProductId(productId);
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (roleCode.equals("admin")) {
+                userId = null;
+            }
+            List<JSONObject> userIdList = userAllocationService.getUserIdListByProductId(productId, userId);
             result.setSuccess(true);
             result.setSuccess(true);
             result.setResult(userIdList);
             result.setResult(userIdList);
         } catch (Exception e) {
         } catch (Exception e) {