Commit 6aa1f9ab by 刘冲

analysis guoxin ticket send time

1 parent ddb1d981
......@@ -9,7 +9,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
<nexus.url>tss.qmcai.com</nexus.url>
<core.jar.version>1.4.25</core.jar.version>
<core.jar.version>1.5.62-test1</core.jar.version>
</properties>
<repositories>
<repository>
......
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/guoxinsend";
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;
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++;
//System.out.println(id+" "+dis);
}
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("Error :" + countError);
}
}
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by liuchong on 2017/11/22.
* Copyright(c) 2017 quanmincai Co., Ltd.
* All right reserved.
*/
public class TestLength {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String message = "2017-11-18 23:46:37.940";
Date date = sdf.parse(message);
System.out.println(date.getTime());
String message2 = "2017-11-18 23:46:38.021";
Date date2 = sdf.parse(message2);
System.out.println(date2.getTime());
System.out.println(date2.getTime() - date.getTime());
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!