Explorar o código

人群包添加有效账户接口

zhaoxian %!s(int64=4) %!d(string=hai) anos
pai
achega
02653bc891

+ 38 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouPopulationPackageController.java

@@ -172,9 +172,46 @@ public class KuaishouPopulationPackageController {
             log.error("查询异常", e);
         }
         return Result.error("查询失败");
-
+    }
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getAccountByProjectId")
+    public Result<Object> getAccountByProjectId(Long projectId, String id,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.getAccountByProjectId(projectId, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
     }
 
+    @RequestMapping(value = "/crowdListQuery")
+    public Result<Object> crowdListQuery() {
+        try {
+            kuaishouPopulationPackageService.crowdListQuery();
+            return Result.ok("success");
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
     /**
      * 添加
      *

+ 6 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageMapper.java

@@ -20,7 +20,11 @@ public interface KuaishouPopulationPackageMapper extends BaseMapper<KuaishouPopu
 
     List<JSONObject> queryPageList(@Param("projectId") Long projectId, @Param("orientationName") String orientationName);
 
-    Long queryUnitCount(@Param("id")  Long id);
+    Long queryUnitCount(@Param("id") Long id);
 
-    List<JSONObject> getRelatedGroups(@Param("id") Long id,@Param("accountId") Long accountId);
+    List<JSONObject> getRelatedGroups(@Param("id") Long id, @Param("accountId") Long accountId);
+
+    List<Long> queryListByStatus();
+
+    void updateStatus(@Param("accountId") Long accountId, @Param("orientationId") Long orientationId, @Param("status") Integer status);
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageRelMapper.java

@@ -31,4 +31,6 @@ public interface KuaishouPopulationPackageRelMapper extends BaseMapper<KuaishouP
     List<JSONObject> getRelatedAccounts(@Param("id") Long id);
 
     KuaishouPopulationPackageRel queryEntity(@Param("accountId") Long accountId, @Param("id") Long id);
+
+    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId,@Param("id") String id);
 }

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageMapper.xml

@@ -59,6 +59,13 @@
               )
     </select>
 
+    <select id="queryListByStatus" resultType="java.lang.Long">
+        SELECT account_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE data_status =1
+        GROUP BY account_id
+    </select>
+
     <select id="getRelatedGroups" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t2.account_id as 'accountId',
         t2.auth_name as 'authName',
@@ -78,4 +85,11 @@
         order by t1.create_time desc
     </select>
 
+    <update id="updateStatus">
+        update
+            ctop_kuaishou_population_package_rel
+        set status = #{status}
+        where orientation_id = #{orientationId}
+          and account_id = #{accountId}
+    </update>
 </mapper>

+ 20 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageRelMapper.xml

@@ -126,4 +126,24 @@
         </foreach>
     </insert>
 
+    <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.account_id as 'accountId',
+            CONCAT(t1.auth_name,'(',t1.account_id,')') as 'authName',
+            CASE  WHEN
+                          t2.data_status = 0
+                          OR t2.data_status = 1
+                          OR t2.data_status = 3
+                          OR t2.data_status = 4
+                      THEN 1 ELSE 0 END
+            as 'state'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN (
+            SELECT account_id,data_status FROM ctop_kuaishou_population_package_rel
+            WHERE  project_id = #{projectId}
+              AND pop_id = #{id}
+        ) t2 ON t1.account_id = t2.account_id
+        where t1.account_status = 0
+          AND t1.project_id =#{projectId}
+    </select>
 </mapper>

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageService.java

@@ -28,4 +28,8 @@ public interface IKuaishouPopulationPackageService extends IService<KuaishouPopu
     Result<Object> getRelatedAccounts(Long id);
 
     Result<Object> getRelatedGroups(Long id,Long accountId);
+
+    void crowdListQuery();
+
+    Result<Object> getAccountByProjectId(Long projectId, String id);
 }

+ 35 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageServiceImpl.java

@@ -52,6 +52,8 @@ public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPo
     @Autowired
     private IKuaishouPopulationService kuaishouPopulationService;
     @Autowired
+    private IKuaishouPopulationService iKuaishouPopulationService;
+    @Autowired
     private IKuaishouPopulationGroupService populationGroupService;
     @Value("${zip.local.download-path}")
     private String downloadPath;
@@ -272,4 +274,37 @@ public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPo
         return Result.ok(new PageInfo<>(list));
     }
 
+    @Override
+    public void crowdListQuery() {
+        List<Long> accountIds = KuaishouPopulationPackageMapper.queryListByStatus();
+        for (int i = 0; i <= 7; i++) {
+            if (i != 2) {
+                for (Long accountId : accountIds) {
+                    CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+                    if (!Check.isNull(token)) {
+                        JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), i);
+                        if (jsonObject.getInteger("code") == 0) {
+                            JSONObject data = jsonObject.getJSONObject("data");
+                            if (!Check.isNull(data)) {
+                                JSONArray details = data.getJSONArray("details");
+                                if (details.size() > 0) {
+                                    for (int j = 0; j < details.size(); j++) {
+                                        JSONObject obj = details.getJSONObject(j);
+                                        KuaishouPopulationPackageMapper.updateStatus(obj.getLong("account_id"), obj.getLong("orientation_id"),obj.getInteger("status"));
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, String id) {
+        List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
 }

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml

@@ -21,11 +21,11 @@
     </select>
 
     <update id="updateHuanbiByDateAndSignature">
-        update
+       ` update
             ctop_bytedance_video_report_daily
         set huanbi = #{huanbi}
         where stat_datetime = #{date}
-          and signature = #{signature}
+          and signature = #{signature}`
     </update>
 
     <sql id="selectSql">