CalcGXCSendTime.java
3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
/**
* Created by liuchong on 2017/11/22.
* Copyright(c) 2017 quanmincai Co., Ltd.
* All right reserved.
*/
public class CalcGXCSendTime {
public static String filePath = "/Users/liuchong/Downloads/gxc-send-jc";
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
public static void main(String[] args) throws Exception {
int count500 = 0;
int count1000 = 0;
int count2000 = 0;
int count5000 = 0;
int countAll = 0;
int countError = 0;
int count10000 = 0;
File file = new File(filePath);
File[] files = file.listFiles();
Map<String, Long> timeMap = new HashMap<String, Long>();
System.out.println("需要解析的文件个数是 :" + files.length);
for (File file1 : files) {
BufferedReader fileRead = new BufferedReader(new FileReader(file1));
String info = "";
while ((info = fileRead.readLine()) != null) {
String[] line = info.substring(0, 100).split("\\|");
//System.out.println(line);
String time = line[0];
String id = line[4];
if (info.contains("|ERR|")) {
countAll++;
countError++;
//System.out.println("id" + id + " " + time);
continue;
}
long currentTime = sdf.parse(time).getTime();
if (timeMap.containsKey(id)) {
countAll++;
// 送票时间
long startTime = timeMap.get(id);
long dis = currentTime - startTime;
if (dis <= 500) {
count500++;
}
if (dis <= 1000 && dis > 500) {
count1000++;
}
if (dis <= 5000 && dis > 1000) {
count2000++;
}
if (dis > 5000) {
count5000++;
}
if (dis > 10000) {
count10000++;
System.out.println(id + " " + dis + " " + file1.getName());
}
timeMap.remove(id);
} else {
timeMap.put(id, currentTime);
}
}
}
System.out.println(timeMap.size());
System.out.println("all :" + countAll);
System.out.println("小于500 :" + count500);
System.out.println("500-1000 :" + count1000);
System.out.println("1000-2000:" + count2000);
System.out.println("大于5000 :" + count5000);
System.out.println("大于10000 :" + count10000);
System.out.println("Error :" + countError);
}
}