Browse Source

修改表数据来源

xueyiming 1 month ago
parent
commit
335a81373d

+ 42 - 40
api-module/src/main/java/com/tzld/piaoquan/api/job/ContentPlatformDatastatJob.java

@@ -152,8 +152,8 @@ public class ContentPlatformDatastatJob {
         }
         Long now = System.currentTimeMillis();
         // 公众号自动回复数据统计
-        String sql = String.format("SELECT company_shortname, 首层访问人数, dt " +
-                "FROM loghubods.loghubods.gzh_autoreply_behavior_uv_total_agent WHERE dt=%s;", dt);
+        String sql = String.format("SELECT channel_shortname, first_uv, dt " +
+                "FROM loghubods.out_channel_mid_first_total WHERE tag = '投放渠道内去重' and type = '公众号即时回复' and dt=%s;", dt);
         List<Record> dataList = OdpsUtil.getOdpsData(sql);
         // 所有公众号
         List<ContentPlatformAccount> accountList = getAllAccount();
@@ -334,8 +334,8 @@ public class ContentPlatformDatastatJob {
         }
         Long now = System.currentTimeMillis();
         // 公众号自动回复数据统计
-        String sql = String.format("SELECT channel, 首层访问人数, dt " +
-                "FROM loghubods.loghubods.fwhhzdyy_data_per_channel WHERE dt=%s;", dt);
+        String sql = String.format("SELECT channel_shortname, first_uv, dt " +
+                "FROM loghubods.out_channel_mid_first_total WHERE tag = '投放渠道内去重' and type = '服务号代运营' and dt=%s;", dt);
         List<Record> dataList = OdpsUtil.getOdpsData(sql);
         // 所有公众号
         List<ContentPlatformAccount> accountList = getAllAccount();
@@ -555,48 +555,22 @@ public class ContentPlatformDatastatJob {
         }
         dataStatMapperExt.deleteQwDatastatTotal(dt);
         Map<String, ContentPlatformQwDataStatTotal> saveMap = new HashMap<>();
-        String outSql = String.format("SELECT * FROM loghubods.qw_out_touliu_behavior_total WHERE dt=%s;", dt);
+        String outSql = String.format("SELECT channel_shortname, first_uv, dt " +
+                "FROM loghubods.out_channel_mid_first_total WHERE tag = '投放渠道内去重' and type = '企微外部' and dt=%s;", dt);
+//        String outSql = String.format("SELECT * FROM loghubods.qw_out_touliu_behavior_total WHERE dt=%s;", dt);
         List<Record> outDataList = OdpsUtil.getOdpsData(outSql);
         Long now = System.currentTimeMillis();
         if (CollectionUtils.isNotEmpty(outDataList)) {
             for (Record record : outDataList) {
-                String type = (String) record.get(1);
-                if (!"社群".equals(type) && !"自动回复".equals(type)) {
-                    continue;
-                }
-                String channel = (String) record.get(33);
-                int firstLevelCount = Integer.parseInt((String) record.get(6));
-                if (firstLevelCount == 0) {
-                    continue;
-                }
-                ContentPlatformQwDataStatTotal item = saveMap.getOrDefault(channel, new ContentPlatformQwDataStatTotal());
-                item.setDateStr(dt);
-                item.setChannel(channel);
-                if (item.getFirstLevelCount() == null) {
-                    item.setFirstLevelCount(0);
-                }
-                item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
-                item.setCreateTimestamp(now);
-                saveMap.put(channel, item);
-            }
-        }
-        String out2Sql = String.format("SELECT * FROM loghubods.qw_out2_touliu_behavior_total WHERE dt=%s;", dt);
-        List<Record> out2DataList = OdpsUtil.getOdpsData(out2Sql);
-        if (CollectionUtils.isNotEmpty(out2DataList)) {
-            List<String> out2Channels = new ArrayList<>();
-            for (Record record : out2DataList) {
-                String type = (String) record.get(1);
-                if (!"社群".equals(type) && !"自动回复".equals(type)) {
-                    continue;
-                }
-                String channel = (String) record.get(33);
-                int firstLevelCount = Integer.parseInt((String) record.get(6));
+//                String type = (String) record.get(1);
+//                if (!"社群".equals(type) && !"自动回复".equals(type)) {
+//                    continue;
+//                }
+                String channel = (String) record.get(0);
+                int firstLevelCount = Integer.parseInt((String) record.get(1));
                 if (firstLevelCount == 0) {
                     continue;
                 }
-                if (saveMap.containsKey(channel) && !out2Channels.contains(channel)) {
-                    saveMap.remove(channel);
-                }
                 ContentPlatformQwDataStatTotal item = saveMap.getOrDefault(channel, new ContentPlatformQwDataStatTotal());
                 item.setDateStr(dt);
                 item.setChannel(channel);
@@ -605,10 +579,38 @@ public class ContentPlatformDatastatJob {
                 }
                 item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
                 item.setCreateTimestamp(now);
-                out2Channels.add(channel);
                 saveMap.put(channel, item);
             }
         }
+//        String out2Sql = String.format("SELECT * FROM loghubods.qw_out2_touliu_behavior_total WHERE dt=%s;", dt);
+//        List<Record> out2DataList = OdpsUtil.getOdpsData(out2Sql);
+//        if (CollectionUtils.isNotEmpty(out2DataList)) {
+//            List<String> out2Channels = new ArrayList<>();
+//            for (Record record : out2DataList) {
+//                String type = (String) record.get(1);
+//                if (!"社群".equals(type) && !"自动回复".equals(type)) {
+//                    continue;
+//                }
+//                String channel = (String) record.get(33);
+//                int firstLevelCount = Integer.parseInt((String) record.get(6));
+//                if (firstLevelCount == 0) {
+//                    continue;
+//                }
+//                if (saveMap.containsKey(channel) && !out2Channels.contains(channel)) {
+//                    saveMap.remove(channel);
+//                }
+//                ContentPlatformQwDataStatTotal item = saveMap.getOrDefault(channel, new ContentPlatformQwDataStatTotal());
+//                item.setDateStr(dt);
+//                item.setChannel(channel);
+//                if (item.getFirstLevelCount() == null) {
+//                    item.setFirstLevelCount(0);
+//                }
+//                item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
+//                item.setCreateTimestamp(now);
+//                out2Channels.add(channel);
+//                saveMap.put(channel, item);
+//            }
+//        }
         List<ContentPlatformQwDataStatTotal> saveList = new ArrayList<>(saveMap.values());
         if (CollectionUtils.isNotEmpty(saveList)) {
             List<String> channels = saveList.stream().map(ContentPlatformQwDataStatTotal::getChannel).distinct().collect(Collectors.toList());