wangyunpeng před 1 týdnem
rodič
revize
74b203c73e

+ 19 - 7
api-module/src/main/java/com/tzld/piaoquan/api/job/contentplatform/ContentPlatformDatastatJob.java

@@ -80,12 +80,15 @@ public class ContentPlatformDatastatJob {
                         "and first_level.dt = fission.dt and first_level.type = fission.type and first_level.tag = fission.tag " +
                         "WHERE first_level.dt = %s and first_level.type = '公众号即时回复' and first_level.tag = '分投放渠道客户分账号去重';", dt);
         List<Record> dataList = OdpsUtil.getOdpsData(sql);
+        List<ContentPlatformAccount> accountList = getAllAccount();
+        Map<String, ContentPlatformAccount> accountMap = accountList.stream()
+                .collect(Collectors.toMap(ContentPlatformAccount::getChannel, account -> account));
         // 所有公众号
-        List<ContentPlatformGzhAccount> accountList = getAllGzhAccount();
-        Map<String, ContentPlatformGzhAccount> accountMap = accountList.stream()
-                .collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, account -> account));
-        List<String> ghIds = accountList.stream().map(ContentPlatformGzhAccount::getGhId).collect(Collectors.toList());
-        List<String> accountExternalIds = accountList.stream().map(ContentPlatformGzhAccount::getExternalId)
+        List<ContentPlatformGzhAccount> gzhAccountList = getAllGzhAccount();
+        Map<Long, Map<String, ContentPlatformGzhAccount>> gzhAccountMap = gzhAccountList.stream()
+                .collect(Collectors.groupingBy(ContentPlatformGzhAccount::getCreateAccountId,
+                        Collectors.toMap(ContentPlatformGzhAccount::getGhId, account -> account)));
+        List<String> accountExternalIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getExternalId)
                 .collect(Collectors.toList());
         String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
         List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
@@ -110,10 +113,19 @@ public class ContentPlatformDatastatJob {
                     sumScore = fissionRate.add(new BigDecimal(fissionArpu));
                     continue;
                 }
-                if (!ghIds.contains(ghId)) {
+                ContentPlatformAccount account = accountMap.get(channel);
+                if (Objects.isNull(account)) {
+                    continue;
+                }
+                Map<String, ContentPlatformGzhAccount> gzhAccounts = gzhAccountMap.get(account.getId());
+                if (Objects.isNull(gzhAccounts)) {
+                    continue;
+                }
+
+                ContentPlatformGzhAccount gzhAccount = gzhAccounts.get(ghId);
+                if (Objects.isNull(gzhAccount)) {
                     continue;
                 }
-                ContentPlatformGzhAccount gzhAccount = accountMap.get(ghId);
                 ContentPlatformGzhDataStat item = new ContentPlatformGzhDataStat();
                 item.setDateStr(dt);
                 item.setAccountId(gzhAccount.getId());