From b37275dba6b782bf3bb3817c4504f6cdef1bef7c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 18 三月 2021 18:38:51 +0800
Subject: [PATCH] APP首页顶部标签兼容

---
 src/test/java/com/hxh/spring/test/LogTest.java |   64 ++++++++++++++++++++++++++++++-
 1 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/src/test/java/com/hxh/spring/test/LogTest.java b/src/test/java/com/hxh/spring/test/LogTest.java
index b6126f8..6a14b9d 100644
--- a/src/test/java/com/hxh/spring/test/LogTest.java
+++ b/src/test/java/com/hxh/spring/test/LogTest.java
@@ -6,7 +6,7 @@
 
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.util.Scanner;
+import java.util.*;
 
 public class LogTest {
 
@@ -16,14 +16,72 @@
     public void testLog() throws FileNotFoundException {
         int count = 0;
         String path = "";
-        Scanner scanner = new Scanner(new FileInputStream("C:\\Users\\Administrator\\Desktop\\鏃ュ織\\甯冧父鎾斁\\video_play.2021-03-05.log"));
+        Scanner scanner = new Scanner(new FileInputStream("C:\\Users\\Administrator\\Desktop\\鏃ュ織\\甯冧父鎾斁\\video_play.2021-03-12.log"));
         while (scanner.hasNextLine()) {
             String text = scanner.nextLine();
-            if (text != null && text.contains("getVideoDetail:")) {
+            if (text != null && text.contains("getUserVideoDetail:")) {
+                String content = text.split("getUserVideoDetail:")[1];
+                content = content.replace("##", "# #");
+                String[] sts = content.split("#");
+                // device,utdId, loginUid, detailSystemId, videoId, resourceId, from
+                resource(sts[4]);
+                video(sts[3]);
+
                 count++;
             }
         }
         scanner.close();
         System.out.println(count);
+        printMap(resourceMap);
+        printMap(videoMap);
     }
+
+    Map<String, Integer> resourceMap = new HashMap<>();
+
+
+    private void resource(String resourceId) {
+        Integer r = resourceMap.get(resourceId);
+        if (r == null) {
+            resourceMap.put(resourceId, 0);
+        }
+        resourceMap.put(resourceId, resourceMap.get(resourceId) + 1);
+    }
+
+    Map<String, Integer> videoMap = new HashMap<>();
+
+    private void video(String videoId) {
+        Integer r = videoMap.get(videoId);
+        if (r == null) {
+            videoMap.put(videoId, 0);
+        }
+        videoMap.put(videoId, videoMap.get(videoId) + 1);
+    }
+
+    private void printMap(Map<String, Integer> map) {
+        //list鎺掑簭
+        TreeMap<Integer, Set<String>> ordersMap = new TreeMap<>(Comparator.reverseOrder());
+        for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) {
+            String key = its.next();
+            Integer value = map.get(key);
+            if (ordersMap.get(value) == null) {
+                ordersMap.put(value, new HashSet<>());
+            }
+            ordersMap.get(value).add(key);
+        }
+
+
+
+
+
+        int p = 0;
+        for (Iterator<Integer> its = ordersMap.keySet().iterator(); its.hasNext(); ) {
+            Integer key = its.next();
+            System.out.println(key + ":" + ordersMap.get(key));
+            p++;
+            if (p > 100) {
+                break;
+            }
+        }
+    }
+
 }

--
Gitblit v1.8.0