admin
2025-02-20 f537abe9f3646c739beaf15076246a2f71a347e9
src/test/java/com/hxh/spring/test/LogTest.java
@@ -109,15 +109,22 @@
    @Test
    public void videoPlay() throws Exception {
        Set<String> sets = new HashSet<>();
        Set<String> totalSets = new HashSet<>();
        Gson gson = new Gson();
        Scanner scanner = new Scanner(new FileInputStream("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\play_2021_03_23.log"));
        Scanner scanner = new Scanner(new FileInputStream("D:\\文件传输\\日志\\2021_04_27.log"));
        Map<String, Integer> countMap = new HashMap<>();
        List<String> videoList = new ArrayList<>();
        int ppcount = 0;
        int count = 0;
        while (scanner.hasNextLine()) {
            count++;
            String text = scanner.nextLine();
            UserVideoPlayLogInfo logInfo = gson.fromJson(text, UserVideoPlayLogInfo.class);
            if ("25".equalsIgnoreCase(logInfo.getResourceId()))
            totalSets.add(logInfo.getUtdId());
            if ("25".equalsIgnoreCase(logInfo.getResourceId())) {
                sets.add(logInfo.getUtdId());
                ppcount++;
            }
            if (countMap.get(logInfo.getUtdId()) == null) {
                countMap.put(logInfo.getUtdId(), 0);
            }
@@ -127,12 +134,25 @@
            countMap.put(logInfo.getUtdId(), countMap.get(logInfo.getUtdId()) + 1);
            System.out.println(logInfo);
        }
        System.out.println(sets.size());
        System.out.println("播放UV总数为:" + totalSets.size());
        System.out.println("PPTV UV播放总数为:" + sets.size());
        System.out.println("PPTV UV比例:" + new BigDecimal(sets.size()).divide(new BigDecimal(totalSets.size()), 2, RoundingMode.FLOOR));
        System.out.println("播放总数为:" + count);
        System.out.println("PPTV 播放总数为:" + ppcount);
        System.out.println("PPTV 比例:" + new BigDecimal(ppcount).divide(new BigDecimal(count), 2, RoundingMode.FLOOR));
        scanner.close();
        for (String st : videoList) {
            System.out.println(st);
        }
    }
    @Test
    public void searchKey() {
        Logger logger = LoggerFactory.getLogger("searchKey");
        logger.info("{}");
    }
    private void printAction(String utdId, List<UserActiveLogInfo> infoList) {
@@ -179,7 +199,7 @@
    @Test
    public void userActive() throws Exception {
        Gson gson = new Gson();
        List<String> list = loadLog("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\active_2021_03_23.log");
        List<String> list = loadLog("D:\\文件传输\\日志\\active_2021_04_27.log");
        Map<String, List<UserActiveLogInfo>> map = new HashMap<>();
        for (String st : list) {
            UserActiveLogInfo activeLogInfo = gson.fromJson(st, UserActiveLogInfo.class);
@@ -247,6 +267,7 @@
        System.out.println("搜索之后播放总数:" + searchPlayCount + "比例为:" + getPercent(map.size(), searchPlayCount));
        System.out.println("搜索之后未播放总数:" + searchNoPlay + "比例为:" + getPercent(map.size(), searchNoPlay));
        System.out.println("未搜索也未播放总数:" + noSearchAndPlay + "比例为:" + getPercent(map.size(), noSearchAndPlay));
        System.out.println("搜索满意度:" + getPercent(searchCount, searchPlayCount));
        System.out.println("未能成功进入首页总数:" + noComeInCount + "比例为:" + getPercent(map.size(), noComeInCount));
        System.out.println("进入首页后无动作的总数:" + comeinAndNoAction + "比例为:" + getPercent(map.size(), comeinAndNoAction));
    }