source;
private int base;
private int rate;
diff --git a/src/main/java/me/ehlxr/sftp/SFTPUtil.java b/src/main/java/me/ehlxr/sftp/SFTPUtil.java
index 1b19fe7..3402cd4 100644
--- a/src/main/java/me/ehlxr/sftp/SFTPUtil.java
+++ b/src/main/java/me/ehlxr/sftp/SFTPUtil.java
@@ -1,176 +1,167 @@
package me.ehlxr.sftp;
+import com.jcraft.jsch.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import java.util.Vector;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelSftp;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.SftpException;
-
/**
* SFTP工具类
- *
- * @author ehlxr
*
+ * @author ehlxr
*/
public class SFTPUtil {
- private static Log log = LogFactory.getLog(SFTPUtil.class);
- private static String ip;
- private static String user;
- private static String psw;
- private static int port;
+ private static final Log log = LogFactory.getLog(SFTPUtil.class);
+ private static String ip;
+ private static String user;
+ private static String psw;
+ private static int port;
- private static Session session = null;
- private static Channel channel = null;
+ private static Session session = null;
+ private static Channel channel = null;
- static {
- try {
- InputStream propFile = SFTPUtil.class.getResourceAsStream("sftp.properties");
- if (propFile != null) {
- Properties p = new Properties();
- p.load(propFile);
- ip = p.getProperty("sftp.ip");
- user = p.getProperty("sftp.user");
- psw = p.getProperty("sftp.psw");
- String portStr = p.getProperty("sftp.port");
- port = (portStr != null ? Integer.parseInt(portStr) : -1);
- propFile.close();
- propFile = null;
- }
- } catch (Exception e) {
- log.error("读取sftp配置文件失败:" + e.getMessage());
- e.printStackTrace();
- }
- }
+ static {
+ try {
+ InputStream propFile = SFTPUtil.class.getResourceAsStream("sftp.properties");
+ if (propFile != null) {
+ Properties p = new Properties();
+ p.load(propFile);
+ ip = p.getProperty("sftp.ip");
+ user = p.getProperty("sftp.user");
+ psw = p.getProperty("sftp.psw");
+ String portStr = p.getProperty("sftp.port");
+ port = (portStr != null ? Integer.parseInt(portStr) : -1);
+ propFile.close();
+ propFile = null;
+ }
+ } catch (Exception e) {
+ log.error("读取sftp配置文件失败:" + e.getMessage());
+ e.printStackTrace();
+ }
+ }
- private static ChannelSftp getSFTP() throws Exception {
- log.info("正在连接服务器[" + ip + "].....");
- ChannelSftp sftp = null;
- JSch jsch = new JSch();
- if (port <= 0) {
- // 连接服务器,采用默认端口
- session = jsch.getSession(user, ip);
- } else {
- // 采用指定的端口连接服务器
- session = jsch.getSession(user, ip, port);
- }
+ private static ChannelSftp getSFTP() throws Exception {
+ log.info("正在连接服务器[" + ip + "].....");
+ ChannelSftp sftp = null;
+ JSch jsch = new JSch();
+ if (port <= 0) {
+ // 连接服务器,采用默认端口
+ session = jsch.getSession(user, ip);
+ } else {
+ // 采用指定的端口连接服务器
+ session = jsch.getSession(user, ip, port);
+ }
- // 如果服务器连接不上,则抛出异常
- if (session == null) {
- log.error("连接服务器[" + ip + "]失败.....");
- throw new Exception("session is null");
- }
+ // 如果服务器连接不上,则抛出异常
+ if (session == null) {
+ log.error("连接服务器[" + ip + "]失败.....");
+ throw new Exception("session is null");
+ }
- // 设置登陆主机的密码
- session.setPassword(psw);// 设置密码
- // 设置第一次登陆的时候提示,可选值:(ask | yes | no)
- session.setConfig("StrictHostKeyChecking", "no");
- // 设置登陆超时时间
- session.connect(30000);
+ // 设置登陆主机的密码
+ session.setPassword(psw);// 设置密码
+ // 设置第一次登陆的时候提示,可选值:(ask | yes | no)
+ session.setConfig("StrictHostKeyChecking", "no");
+ // 设置登陆超时时间
+ session.connect(30000);
- try {
- // 创建sftp通信通道
- channel = (Channel) session.openChannel("sftp");
- channel.connect(1000);
- sftp = (ChannelSftp) channel;
- log.info("连接服务器[" + ip + "]成功.....");
- } catch (Exception e) {
- log.error("服务器[" + ip + "]创建sftp通信通道失败:" + e.getMessage());
- e.printStackTrace();
- closeSFTP();
- }
- return sftp;
- }
+ try {
+ // 创建sftp通信通道
+ channel = session.openChannel("sftp");
+ channel.connect(1000);
+ sftp = (ChannelSftp) channel;
+ log.info("连接服务器[" + ip + "]成功.....");
+ } catch (Exception e) {
+ log.error("服务器[" + ip + "]创建sftp通信通道失败:" + e.getMessage());
+ e.printStackTrace();
+ closeSFTP();
+ }
+ return sftp;
+ }
- private static void closeSFTP() {
- if (session != null && session.isConnected()) {
- session.disconnect();
- }
- if (channel != null && channel.isConnected()) {
- channel.disconnect();
- }
- }
+ private static void closeSFTP() {
+ if (session != null && session.isConnected()) {
+ session.disconnect();
+ }
+ if (channel != null && channel.isConnected()) {
+ channel.disconnect();
+ }
+ }
- /**
- * SFTP上传文件
- *
- * @param desPath
- * ftp服务器目录
- * @param desFileName
- * 上传后的文件名
- * @param resFile
- * 要上传的文件
- * @throws Exception
- */
- public static void putFile(String desPath, String desFileName, File resFile) {
- try {
- ChannelSftp sftp = getSFTP();
- mkdirs(sftp, desPath);
+ /**
+ * SFTP上传文件
+ *
+ * @param desPath ftp服务器目录
+ * @param desFileName 上传后的文件名
+ * @param resFile 要上传的文件
+ * @throws Exception
+ */
+ public static void putFile(String desPath, String desFileName, File resFile) {
+ try {
+ ChannelSftp sftp = getSFTP();
+ mkdirs(sftp, desPath);
- // 进入服务器指定的文件夹
- sftp.cd(desPath);
+ // 进入服务器指定的文件夹
+ sftp.cd(desPath);
- sftp.put(resFile.getAbsolutePath(), desFileName, ChannelSftp.OVERWRITE);
- log.info("文件[" + desPath + desFileName + "]上传完成...");
- closeSFTP();
- } catch (Exception e) {
- log.error("文件[" + desPath + desFileName + "]上传失败:" + e.getMessage());
- e.printStackTrace();
- closeSFTP();
- }
- }
+ sftp.put(resFile.getAbsolutePath(), desFileName, ChannelSftp.OVERWRITE);
+ log.info("文件[" + desPath + desFileName + "]上传完成...");
+ closeSFTP();
+ } catch (Exception e) {
+ log.error("文件[" + desPath + desFileName + "]上传失败:" + e.getMessage());
+ e.printStackTrace();
+ closeSFTP();
+ }
+ }
- public static void main(String[] args) {
- try {
- SFTPUtil.putFile("/upload/222/1111", "212321.txt", new File("D:/1.txt"));
+ public static void main(String[] args) {
+ try {
+ SFTPUtil.putFile("/upload/222/1111", "212321.txt", new File("D:/1.txt"));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- /**
- * 在远程服务器创建多级目录
- *
- * @param sftp
- * @param desPath
- * @throws Exception
- */
- private static void mkdirs(ChannelSftp sftp, String desPath) throws Exception {
- String[] paths = desPath.split("/");
- String path = "";
- for (int i = 0; i < paths.length; i++) {
- path += paths[i] + "/";
- if (!isExistDir(sftp, path)) {
- sftp.mkdir(path);
- }
- }
- }
+ /**
+ * 在远程服务器创建多级目录
+ *
+ * @param sftp
+ * @param desPath
+ * @throws Exception
+ */
+ private static void mkdirs(ChannelSftp sftp, String desPath) throws Exception {
+ String[] paths = desPath.split("/");
+ String path = "";
+ for (int i = 0; i < paths.length; i++) {
+ path += paths[i] + "/";
+ if (!isExistDir(sftp, path)) {
+ sftp.mkdir(path);
+ }
+ }
+ }
- /**
- * 判断远程目录是否存在
- *
- * @param sftp
- * @param desPath
- * @return
- */
- private static boolean isExistDir(ChannelSftp sftp, String desPath) {
- boolean isExist = false;
- try {
- Vector> content = sftp.ls(desPath);
- if (content != null) {
- isExist = true;
- }
- } catch (SftpException e) {
- isExist = false;
- }
- return isExist;
- }
+ /**
+ * 判断远程目录是否存在
+ *
+ * @param sftp
+ * @param desPath
+ * @return
+ */
+ private static boolean isExistDir(ChannelSftp sftp, String desPath) {
+ boolean isExist = false;
+ try {
+ Vector> content = sftp.ls(desPath);
+ if (content != null) {
+ isExist = true;
+ }
+ } catch (SftpException e) {
+ isExist = false;
+ }
+ return isExist;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/ehlxr/sort/InsertSort.java b/src/main/java/me/ehlxr/sort/InsertSort.java
index bdaf209..79a5798 100644
--- a/src/main/java/me/ehlxr/sort/InsertSort.java
+++ b/src/main/java/me/ehlxr/sort/InsertSort.java
@@ -4,7 +4,7 @@ import java.util.Arrays;
/**
* 插入排序
- *
+ *
* 基本思想是:
* 将数组中的所有元素依次跟前面已经排好的元素相比较,如果选择的元素比已排序的元素小,
* 则交换,直到全部元素都比较过为止。
diff --git a/src/main/java/me/ehlxr/test/DirList.java b/src/main/java/me/ehlxr/test/DirList.java
index efcb110..2dbd4cd 100644
--- a/src/main/java/me/ehlxr/test/DirList.java
+++ b/src/main/java/me/ehlxr/test/DirList.java
@@ -4,28 +4,29 @@ import java.io.File;
import java.io.FilenameFilter;
public class DirList {
- public static void main(String[] args) {
- File path = new File("D://");
- String arg = "dsp_impclk_15";
- String[] list;
- if (arg.length() == 0)
- list = path.list();
- else
- list = path.list(new DirFilter(arg));
- for (int i = 0; i < list.length; ++i) {
- System.out.println(list[i]);
- }
- }
+ public static void main(String[] args) {
+ File path = new File("D://");
+ String arg = "dsp_impclk_15";
+ String[] list;
+ if (arg.length() == 0)
+ list = path.list();
+ else
+ list = path.list(new DirFilter(arg));
+ for (int i = 0; i < list.length; ++i) {
+ System.out.println(list[i]);
+ }
+ }
}
class DirFilter implements FilenameFilter {
- String afn;
- DirFilter(String afn) {
- this.afn = afn;
- }
+ String afn;
- public boolean accept(File dir, String name) {
- String f = new File(name).getName();
- return f.indexOf(afn) != -1;
- }
+ DirFilter(String afn) {
+ this.afn = afn;
+ }
+
+ public boolean accept(File dir, String name) {
+ String f = new File(name).getName();
+ return f.indexOf(afn) != -1;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/ehlxr/test/ExecBaics50Log.java b/src/main/java/me/ehlxr/test/ExecBaics50Log.java
index d4b58e4..669369d 100644
--- a/src/main/java/me/ehlxr/test/ExecBaics50Log.java
+++ b/src/main/java/me/ehlxr/test/ExecBaics50Log.java
@@ -2,60 +2,58 @@ package me.ehlxr.test;
import java.io.BufferedReader;
import java.io.FileReader;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Date;
import java.util.TimeZone;
public class ExecBaics50Log {
- public static void main(String[] args) throws Exception {
- StringBuffer sb = new StringBuffer("");
+ public static void main(String[] args) throws Exception {
+ StringBuffer sb = new StringBuffer();
- FileReader reader = new FileReader("C:\\Users\\ehlxr\\Desktop\\minisite\\20160606\\3\\2016-06-06(3、4、5).txt");
- BufferedReader br = new BufferedReader(reader);
- String str = null;
- while ((str = br.readLine()) != null) {
- String[] split = str.split(",");
- String ssString = "";
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ FileReader reader = new FileReader("C:\\Users\\ehlxr\\Desktop\\minisite\\20160606\\3\\2016-06-06(3、4、5).txt");
+ BufferedReader br = new BufferedReader(reader);
+ String str = null;
+ while ((str = br.readLine()) != null) {
+ String[] split = str.split(",");
+ String ssString = "";
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- for (String s : split) {
+ for (String s : split) {
- String substring = s.substring(s.indexOf("=") + 1);
- if (substring.contains("CST")) {
- substring = formatDate(substring);
-
-
- ssString += "'" + substring + "'";
- }else{
-
- ssString += "'" + substring + "',";
- }
- }
+ String substring = s.substring(s.indexOf("=") + 1);
+ if (substring.contains("CST")) {
+ substring = formatDate(substring);
- System.out.println(
- "insert into user_info (`u_name`, `u_gender`, `u_tel`, `u_province`, `u_city`, `u_dealername`,`u_dealercode`, `u_scheduledtime`, `addtime`) VALUES("
- + ssString + ");");
- }
- br.close();
- reader.close();
-
- }
-
- private static String formatDate(String date) throws Exception{
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat sdf1 = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", java.util.Locale.ENGLISH);
- TimeZone tz = TimeZone.getTimeZone("CST");
- sdf1.setTimeZone(tz);
- sdf.setTimeZone(tz);
-
- Calendar c = Calendar.getInstance();
- c.setTime(sdf1.parse(date));
-
- c.set(Calendar.HOUR, c.get(Calendar.HOUR) - 1);
- return sdf.format(c.getTime());
- }
+ ssString += "'" + substring + "'";
+ } else {
+
+ ssString += "'" + substring + "',";
+ }
+ }
+
+ System.out.println(
+ "insert into user_info (`u_name`, `u_gender`, `u_tel`, `u_province`, `u_city`, `u_dealername`,`u_dealercode`, `u_scheduledtime`, `addtime`) VALUES("
+ + ssString + ");");
+ }
+
+ br.close();
+ reader.close();
+
+ }
+
+ private static String formatDate(String date) throws Exception {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ SimpleDateFormat sdf1 = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", java.util.Locale.ENGLISH);
+ TimeZone tz = TimeZone.getTimeZone("CST");
+ sdf1.setTimeZone(tz);
+ sdf.setTimeZone(tz);
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(sdf1.parse(date));
+
+ c.set(Calendar.HOUR, c.get(Calendar.HOUR) - 1);
+ return sdf.format(c.getTime());
+ }
}
diff --git a/src/main/java/me/ehlxr/test/IChargeCounter.java b/src/main/java/me/ehlxr/test/IChargeCounter.java
index b7a7446..b78aa6a 100644
--- a/src/main/java/me/ehlxr/test/IChargeCounter.java
+++ b/src/main/java/me/ehlxr/test/IChargeCounter.java
@@ -3,21 +3,21 @@ package me.ehlxr.test;
import java.math.BigDecimal;
public interface IChargeCounter {
- /**
- * 按点击计费
- *
- * @param campaignid
- * @param groupid
- * @param cost
- */
- public void chargeForThisResult(String campaignid, String groupid, BigDecimal cost);
+ /**
+ * 按点击计费
+ *
+ * @param campaignid
+ * @param groupid
+ * @param cost
+ */
+ void chargeForThisResult(String campaignid, String groupid, BigDecimal cost);
- /**
- * 投放次数控制
- *
- * @param groupid
- * @param count
- * @param type
- */
- public void counterControlForThisSumResult(String groupid, int count, String type);
+ /**
+ * 投放次数控制
+ *
+ * @param groupid
+ * @param count
+ * @param type
+ */
+ void counterControlForThisSumResult(String groupid, int count, String type);
}
\ No newline at end of file
diff --git a/src/main/java/me/ehlxr/test/Main.java b/src/main/java/me/ehlxr/test/Main.java
index 617f072..ec74445 100644
--- a/src/main/java/me/ehlxr/test/Main.java
+++ b/src/main/java/me/ehlxr/test/Main.java
@@ -7,7 +7,7 @@ import me.ehlxr.redis.JedisUtil;
*/
public class Main {
public static void main(String[] args) {
- JedisUtil.set("test_20160614","20160614");
+ JedisUtil.set("test_20160614", "20160614");
System.out.println(JedisUtil.getStr("test_20160614"));
}
}
diff --git a/src/main/java/me/ehlxr/test/Test.java b/src/main/java/me/ehlxr/test/Test.java
index 88f61a6..eb19c02 100644
--- a/src/main/java/me/ehlxr/test/Test.java
+++ b/src/main/java/me/ehlxr/test/Test.java
@@ -6,8 +6,8 @@ package me.ehlxr.test;
public class Test {
public static void main(String[] args) {
String s0 = "kvill";
- String s1 = new String("kvill");
- String s2 = new String("kvill");
+ String s1 = "kvill";
+ String s2 = "kvill";
System.out.println(s0 == s1);
System.out.println("**********");
s1.intern();
diff --git a/src/main/java/me/ehlxr/test/TestAudiQ2.java b/src/main/java/me/ehlxr/test/TestAudiQ2.java
index f61ea44..914589a 100644
--- a/src/main/java/me/ehlxr/test/TestAudiQ2.java
+++ b/src/main/java/me/ehlxr/test/TestAudiQ2.java
@@ -3,9 +3,9 @@ package me.ehlxr.test;
import me.ehlxr.utils.HttpClientUtil;
public class TestAudiQ2 {
- public static String URL = "http://127.0.0.1:8080/Audi2016Q2Wap/getUserInfo";
+ public static String URL = "http://127.0.0.1:8080/Audi2016Q2Wap/getUserInfo";
- public static void main(String[] args) throws Exception {
- System.out.println(HttpClientUtil.sendPostJSONData(URL, ""));
- }
+ public static void main(String[] args) throws Exception {
+ System.out.println(HttpClientUtil.sendPostJSONData(URL, ""));
+ }
}
diff --git a/src/main/java/me/ehlxr/test/TestCode.java b/src/main/java/me/ehlxr/test/TestCode.java
index 25ae469..708f549 100644
--- a/src/main/java/me/ehlxr/test/TestCode.java
+++ b/src/main/java/me/ehlxr/test/TestCode.java
@@ -2,11 +2,7 @@ package me.ehlxr.test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TimeZone;
+import java.util.*;
public class TestCode {
@@ -28,14 +24,14 @@ public class TestCode {
// Map resultMap = new HashMap();
// System.out.println((String)resultMap.get("dd"));
-// try {
-// String str = null;
-// str.equals("");
-// } catch (Exception e) {
-// System.out.println(e.getMessage());
-// e.printStackTrace();
-// }
-// System.out.println("fffff");
+ // try {
+ // String str = null;
+ // str.equals("");
+ // } catch (Exception e) {
+ // System.out.println(e.getMessage());
+ // e.printStackTrace();
+ // }
+ // System.out.println("fffff");
// String[] s = {"111","eee"};
// System.out.println(Arrays.toString(s));
@@ -114,217 +110,217 @@ public class TestCode {
// System.out.println(jj.optString("pring"));
-// // 根据网卡取本机配置的IP
-// InetAddress inet = null;
-// try {
-// inet = InetAddress.getLocalHost();
-// } catch (UnknownHostException e) {
-// e.printStackTrace();
-// }
-// String ipAddress = inet.getHostAddress();
-//
-// System.out.println(ipAddress);
+ // // 根据网卡取本机配置的IP
+ // InetAddress inet = null;
+ // try {
+ // inet = InetAddress.getLocalHost();
+ // } catch (UnknownHostException e) {
+ // e.printStackTrace();
+ // }
+ // String ipAddress = inet.getHostAddress();
+ //
+ // System.out.println(ipAddress);
-// TestCode test = new TestCode();
-// System.out.println(test.dd("ddd"));
+ // TestCode test = new TestCode();
+ // System.out.println(test.dd("ddd"));
-// Package pkg = Package.getPackage("osc.git.eh3.test");
-// Annotation[] annotations = pkg.getAnnotations();
-// for (Annotation annotation : annotations) {
-// System.out.println(annotation);
-// }
+ // Package pkg = Package.getPackage("osc.git.eh3.test");
+ // Annotation[] annotations = pkg.getAnnotations();
+ // for (Annotation annotation : annotations) {
+ // System.out.println(annotation);
+ // }
-// String[] arrs = new String[]{"111","111","2222"};
-// for (String string : Array2Set(arrs)) {
-//
-// System.out.println(string);
-// }
+ // String[] arrs = new String[]{"111","111","2222"};
+ // for (String string : Array2Set(arrs)) {
+ //
+ // System.out.println(string);
+ // }
-// Class> clazz = StatisByHourModel.class;
-// Method[] methods = clazz.getMethods();
-// for (Method method : methods) {
-// System.out.println(method.getName());
-// }
-// Object dd = new Date();
-//
-// System.out.println(dd instanceof Date);
-//
-// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-// System.out.println(sdf.format(dd));
+ // Class> clazz = StatisByHourModel.class;
+ // Method[] methods = clazz.getMethods();
+ // for (Method method : methods) {
+ // System.out.println(method.getName());
+ // }
+ // Object dd = new Date();
+ //
+ // System.out.println(dd instanceof Date);
+ //
+ // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ // System.out.println(sdf.format(dd));
-// JSONObject groupAdxs = JSONObject.fromObject("{\"4ebdb328-5d4b-42e6-80c3-a6aaaecdcea1\":[\"1e03319c-425d-4a17-a6bf-eeec2f48db29\",\"1fed4171-9925-4834-aa7b-9b4d3a58841b\",\"ce579246-e707-4cb9-b982-88cad7944b92\"],\"9262cbe8-a9dc-4f4e-888b-cf3ffe65defd\":\"ce579246-e707-4cb9-b982-88cad7944b92\"}");
-// Set keySet = groupAdxs.keySet();
-// for (Object object : keySet) {
-// System.out.println(groupAdxs.get(object).getClass().isArray());
-// }
+ // JSONObject groupAdxs = JSONObject.fromObject("{\"4ebdb328-5d4b-42e6-80c3-a6aaaecdcea1\":[\"1e03319c-425d-4a17-a6bf-eeec2f48db29\",\"1fed4171-9925-4834-aa7b-9b4d3a58841b\",\"ce579246-e707-4cb9-b982-88cad7944b92\"],\"9262cbe8-a9dc-4f4e-888b-cf3ffe65defd\":\"ce579246-e707-4cb9-b982-88cad7944b92\"}");
+ // Set keySet = groupAdxs.keySet();
+ // for (Object object : keySet) {
+ // System.out.println(groupAdxs.get(object).getClass().isArray());
+ // }
-// System.out.println(UUID.randomUUID().toString());
+ // System.out.println(UUID.randomUUID().toString());
-// System.out.println(new Integer(0x11));
-// System.out.println(Integer.toBinaryString(30000));
-// System.out.println(Integer.valueOf("11", 16));
-// System.out.println(Integer.valueOf("11", 2));
+ // System.out.println(new Integer(0x11));
+ // System.out.println(Integer.toBinaryString(30000));
+ // System.out.println(Integer.valueOf("11", 16));
+ // System.out.println(Integer.valueOf("11", 2));
-// System.out.println(AESTool.encrypt("ehlxr"));
-// System.out.println(AESTool.decrypt(AESEncrypter.encrypt("ehlxr")));
+ // System.out.println(AESTool.encrypt("ehlxr"));
+ // System.out.println(AESTool.decrypt(AESEncrypter.encrypt("ehlxr")));
-// System.out.println(AESTool.encrypt("liixangrong","adjdjfjfjfjdkdkd"));
-// System.out.println(AESTool.decrypt("bfb0c038342ffead45511879853279bf","adjdjfjfjfjdkdkd"));
-// System.out.println(Base64.encodeToString(AESTool.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202").getBytes(), false));
+ // System.out.println(AESTool.encrypt("liixangrong","adjdjfjfjfjdkdkd"));
+ // System.out.println(AESTool.decrypt("bfb0c038342ffead45511879853279bf","adjdjfjfjfjdkdkd"));
+ // System.out.println(Base64.encodeToString(AESTool.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202").getBytes(), false));
-// byte[] bytes = "ehlxr".getBytes();
-// for (int i = 0; i < bytes.length; i++) {
-// System.out.println(bytes[i]);
-// }
+ // byte[] bytes = "ehlxr".getBytes();
+ // for (int i = 0; i < bytes.length; i++) {
+ // System.out.println(bytes[i]);
+ // }
-// System.out.println(Base64.encodeToString("ehlxr".getBytes(), false));
+ // System.out.println(Base64.encodeToString("ehlxr".getBytes(), false));
-// double lon1 = 109.0145193759;
-// double lat1 = 34.236080797698;
-// System.out.println(GeoHash.encode(lat1, lon1));
-// System.out.println(GeoHash.decode("wmtdgn5esrb1")[0]+" "+GeoHash.decode("wmtdgn5esrb1")[1]);
+ // double lon1 = 109.0145193759;
+ // double lat1 = 34.236080797698;
+ // System.out.println(GeoHash.encode(lat1, lon1));
+ // System.out.println(GeoHash.decode("wmtdgn5esrb1")[0]+" "+GeoHash.decode("wmtdgn5esrb1")[1]);
-// String url = "http://api.map.baidu.com/place/v2/search?query=银行&location=39.915,116.404&radius=2000&output=json&ak=LCG4dyrXyadeD8hFhi8SGCv6";
-// System.out.println(HttpClientUtil.sendGet(url));
+ // String url = "http://api.map.baidu.com/place/v2/search?query=银行&location=39.915,116.404&radius=2000&output=json&ak=LCG4dyrXyadeD8hFhi8SGCv6";
+ // System.out.println(HttpClientUtil.sendGet(url));
-// JSONArray array = new JSONArray();
-// array.add("1");
-// array.add("2");
-// array.add("3");
-// array.add("4");
-// array.add("5");
-// List list = JSONArray.toList(array, new String(), new JsonConfig());
-// System.out.println(list);
+ // JSONArray array = new JSONArray();
+ // array.add("1");
+ // array.add("2");
+ // array.add("3");
+ // array.add("4");
+ // array.add("5");
+ // List list = JSONArray.toList(array, new String(), new JsonConfig());
+ // System.out.println(list);
-// System.out.println(System.nanoTime());
-// System.out.println(System.nanoTime());
+ // System.out.println(System.nanoTime());
+ // System.out.println(System.nanoTime());
-// Map postParam = new HashMap();
-// postParam.put("groupid", "100003");
-// postParam.put("count", "1");
-// postParam.put("type", "m");
-// for(int i=0;i<5;i++){
-// try {
-// HttpClientUtil.sendPostParam("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", postParam);
-//// HttpClientUtil.sendPost("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", "groupid=100003&count=1&type=m");
-// break;
-// } catch (Exception e) {
-// System.out.println(e.getMessage());
-// try {
-// Thread.sleep(1000);
-// } catch (InterruptedException e1) {
-// e1.printStackTrace();
-// }
-// }
-// }
+ // Map postParam = new HashMap();
+ // postParam.put("groupid", "100003");
+ // postParam.put("count", "1");
+ // postParam.put("type", "m");
+ // for(int i=0;i<5;i++){
+ // try {
+ // HttpClientUtil.sendPostParam("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", postParam);
+ //// HttpClientUtil.sendPost("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", "groupid=100003&count=1&type=m");
+ // break;
+ // } catch (Exception e) {
+ // System.out.println(e.getMessage());
+ // try {
+ // Thread.sleep(1000);
+ // } catch (InterruptedException e1) {
+ // e1.printStackTrace();
+ // }
+ // }
+ // }
-// String str = "0,";
-// System.out.println(str.split(",").length);
+ // String str = "0,";
+ // System.out.println(str.split(",").length);
-// System.out.println(JedisUtil.getStr("0000"));
-// Map result = new HashMap();
-// System.out.println(result.get("jj"));
-// double budgets = 10000;
-// System.out.println((budgets/100));
+ // System.out.println(JedisUtil.getStr("0000"));
+ // Map result = new HashMap();
+ // System.out.println(result.get("jj"));
+ // double budgets = 10000;
+ // System.out.println((budgets/100));
-// String str = null;
-// BigDecimal budget = new BigDecimal(str);
-// budget = budget.subtract(new BigDecimal(10));
-// if (budget.compareTo(new BigDecimal(0)) <= 0) {
-// System.out.println("1");
-// } else {
-// System.out.println("2");
-// }
-// System.out.println(budget.doubleValue());
+ // String str = null;
+ // BigDecimal budget = new BigDecimal(str);
+ // budget = budget.subtract(new BigDecimal(10));
+ // if (budget.compareTo(new BigDecimal(0)) <= 0) {
+ // System.out.println("1");
+ // } else {
+ // System.out.println("2");
+ // }
+ // System.out.println(budget.doubleValue());
-// String REG_FLOAT = "^[1-9]\\d*.?\\d+$"; // 浮点正数
-// System.out.println(Pattern.compile(REG_FLOAT).matcher("1.21").matches());
+ // String REG_FLOAT = "^[1-9]\\d*.?\\d+$"; // 浮点正数
+ // System.out.println(Pattern.compile(REG_FLOAT).matcher("1.21").matches());
-// String str ="浮点数sss";
-// String s1 = new String(str.getBytes("utf-8"),"gbk");
-// System.out.println(s1);
-// System.out.println(new String(s1.getBytes("gbk")));
-// System.out.println();
-////
-// String s2 = URLEncoder.encode(str, "utf-8");
-// System.out.println(s2);
-// System.out.println(URLDecoder.decode(s2,"utf-8"));
+ // String str ="浮点数sss";
+ // String s1 = new String(str.getBytes("utf-8"),"gbk");
+ // System.out.println(s1);
+ // System.out.println(new String(s1.getBytes("gbk")));
+ // System.out.println();
+ ////
+ // String s2 = URLEncoder.encode(str, "utf-8");
+ // System.out.println(s2);
+ // System.out.println(URLDecoder.decode(s2,"utf-8"));
//System.out.println(new String(Hex.decodeHex("E8AFB7E6B182E5A4B1E8B4A5EFBC8CE8AFB7E7A88DE5908EE9878DE8AF95".toCharArray()), "utf-8"));
-// Object object = null;
-// JSONObject creativeGroupObj = JSONObject.fromObject(object);
-// System.out.println(creativeGroupObj.isEmpty());
-//
-// System.out.println(UUID.randomUUID().toString());
+ // Object object = null;
+ // JSONObject creativeGroupObj = JSONObject.fromObject(object);
+ // System.out.println(creativeGroupObj.isEmpty());
+ //
+ // System.out.println(UUID.randomUUID().toString());
-// JSONArray putTime = JSONArray.fromObject("[{\"monday\":[\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"tuesday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"wednesday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"thursday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"friday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"saturday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"sunday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]}]");
-// JSONArray periods = new JSONArray();
-// for (Object object : putTime) {
-// JSONObject putTimeObj = JSONObject.fromObject(object);
-// if (!putTimeObj.isEmpty()) {
-// Set keySet = putTimeObj.keySet();
-// JSONObject period = new JSONObject();
-// for (String key : keySet) {
-// JSONArray value = putTimeObj.optJSONArray(key);
-// int start = -1,end = -1;
-// StringBuffer sb = new StringBuffer();
-// for (int i = 0; i < value.size(); i++) {
-// Object object2 = value.get(i);
-// // 第一次出现 1
-// if (object2.equals("1") && start==-1) {
-// start=i;
-// end = 0;
-// }
-// // 出现1后的第一次出现0结束
-// if (object2.equals("0") && start>-1) {
-// end=i-1;
-// sb.append(start+"-"+end+",");
-// start = -1;end = -1;
-// }
-// }
-// period.put("week", key);
-// period.put("ranges",sb.toString().substring(0, (sb.length()-1)));
-// }
-// periods.add(period);
-// }
-// }
-// System.out.println(periods.toString());
+ // JSONArray putTime = JSONArray.fromObject("[{\"monday\":[\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"tuesday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"wednesday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"thursday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"friday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"saturday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]},{\"sunday\":[\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]}]");
+ // JSONArray periods = new JSONArray();
+ // for (Object object : putTime) {
+ // JSONObject putTimeObj = JSONObject.fromObject(object);
+ // if (!putTimeObj.isEmpty()) {
+ // Set keySet = putTimeObj.keySet();
+ // JSONObject period = new JSONObject();
+ // for (String key : keySet) {
+ // JSONArray value = putTimeObj.optJSONArray(key);
+ // int start = -1,end = -1;
+ // StringBuffer sb = new StringBuffer();
+ // for (int i = 0; i < value.size(); i++) {
+ // Object object2 = value.get(i);
+ // // 第一次出现 1
+ // if (object2.equals("1") && start==-1) {
+ // start=i;
+ // end = 0;
+ // }
+ // // 出现1后的第一次出现0结束
+ // if (object2.equals("0") && start>-1) {
+ // end=i-1;
+ // sb.append(start+"-"+end+",");
+ // start = -1;end = -1;
+ // }
+ // }
+ // period.put("week", key);
+ // period.put("ranges",sb.toString().substring(0, (sb.length()-1)));
+ // }
+ // periods.add(period);
+ // }
+ // }
+ // System.out.println(periods.toString());
-// JSONObject period = new JSONObject();
-// period.put("test", 100.32);
-// System.out.println(period.optString("test"));
+ // JSONObject period = new JSONObject();
+ // period.put("test", 100.32);
+ // System.out.println(period.optString("test"));
-// BigDecimal clicks = new BigDecimal(100.23);
-// System.out.println(clicks.intValue());
+ // BigDecimal clicks = new BigDecimal(100.23);
+ // System.out.println(clicks.intValue());
-// System.out.println(Long.parseLong("8000.01"));
+ // System.out.println(Long.parseLong("8000.01"));
-// JSONObject jsonParam = new JSONObject();
-// JSONArray jsonArray = new JSONArray();
-// jsonArray.add("000000");
-// jsonParam.put("app", jsonArray);
-// System.out.println(jsonParam);
+ // JSONObject jsonParam = new JSONObject();
+ // JSONArray jsonArray = new JSONArray();
+ // jsonArray.add("000000");
+ // jsonParam.put("app", jsonArray);
+ // System.out.println(jsonParam);
-// String head = "00,";
-// head = head.substring(0, head.lastIndexOf(","));
-// System.out.println(head);
-//
-// String ip = "127, 0, 0,1";
-// // String [] s = ip.split(".");
-// String[] s = ip.split("\\,");
-// for (String string : s) {
-// System.out.println(string);
-// }
-//
-// Object str = null;
-//// String dd = (String)str;
-// String dd = String.valueOf(str);
-// System.out.println(String.valueOf(str) == String.valueOf("null"));
+ // String head = "00,";
+ // head = head.substring(0, head.lastIndexOf(","));
+ // System.out.println(head);
+ //
+ // String ip = "127, 0, 0,1";
+ // // String [] s = ip.split(".");
+ // String[] s = ip.split("\\,");
+ // for (String string : s) {
+ // System.out.println(string);
+ // }
+ //
+ // Object str = null;
+ //// String dd = (String)str;
+ // String dd = String.valueOf(str);
+ // System.out.println(String.valueOf(str) == String.valueOf("null"));
//String sr = "2016-05-25 00:39:33,285 zanadu INFO \"39.159.247.16\" \"Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H321 Safari/600.1.4\" \"http://site.pxene.com/Audi2016Q2Wap/?bid=7ef9ab83e32c4f9c80312b92fba261b1&mapid=0055cb29-dee1-4e77-81bb-0991d2d644c8\" \"load success:Audi load success:bid=7ef9ab83e32c4f9c80312b92fba261b1&mapid=0055cb29-dee1-4e77-81bb-0991d2d644c8\"";
@@ -385,9 +381,9 @@ public class TestCode {
Long n = 19000000L;
- if ((n >= min && n <= mx)||(n >= min && n <= mx)){
+ if ((n >= min && n <= mx) || (n >= min && n <= mx)) {
System.out.println("ture");
- }else {
+ } else {
System.out.println("false");
}
diff --git a/src/main/java/me/ehlxr/test/TestCounter.java b/src/main/java/me/ehlxr/test/TestCounter.java
index 983e9ec..9c716eb 100644
--- a/src/main/java/me/ehlxr/test/TestCounter.java
+++ b/src/main/java/me/ehlxr/test/TestCounter.java
@@ -1,11 +1,11 @@
package me.ehlxr.test;
public class TestCounter {
- public static void main(String[] args) throws Exception {
-
- for (int i = 0; i < 8000; i++) {
- new Thread(new TestThread()).start();
-// Thread.sleep(5);
- }
- }
+ public static void main(String[] args) throws Exception {
+
+ for (int i = 0; i < 8000; i++) {
+ new Thread(new TestThread()).start();
+ // Thread.sleep(5);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/ehlxr/test/TestDecodeHex.java b/src/main/java/me/ehlxr/test/TestDecodeHex.java
index f01c100..a744f06 100644
--- a/src/main/java/me/ehlxr/test/TestDecodeHex.java
+++ b/src/main/java/me/ehlxr/test/TestDecodeHex.java
@@ -2,6 +2,8 @@ package me.ehlxr.test;
import org.apache.commons.codec.binary.Hex;
+import java.nio.charset.StandardCharsets;
+
/**
* Created by ehlxr on 2016/9/12.
*/
@@ -9,7 +11,7 @@ public class TestDecodeHex {
// 十六进制转字符串
public static void main(String[] args) throws Exception {
String data = "E88194E7B3BBE4BABAE6B7BBE58AA0E5A4B1E8B4A5";
- System.out.println(new String(Hex.decodeHex(data.toCharArray()), "utf-8"));
+ System.out.println(new String(Hex.decodeHex(data.toCharArray()), StandardCharsets.UTF_8));
System.out.println(Hex.encodeHexString("测试粗我".getBytes()));
diff --git a/src/main/java/me/ehlxr/test/TestFile.java b/src/main/java/me/ehlxr/test/TestFile.java
index faa8da4..657e110 100644
--- a/src/main/java/me/ehlxr/test/TestFile.java
+++ b/src/main/java/me/ehlxr/test/TestFile.java
@@ -6,32 +6,32 @@ import java.io.FileReader;
import java.io.IOException;
public class TestFile {
- public static void main(String[] args) {
- File file = new File("C:\\Users\\ehlxr\\Desktop\\20160628\\161845");
- BufferedReader reader = null;
- try {
+ public static void main(String[] args) {
+ File file = new File("C:\\Users\\ehlxr\\Desktop\\20160628\\161845");
+ BufferedReader reader = null;
+ try {
- reader = new BufferedReader(new FileReader(file));
- String tempString = null;
- while ((tempString = reader.readLine()) != null) {
- String[] tempArr = tempString.split("\\|");
- long time = Long.parseLong(tempArr[0]);
- long rang = 1467100800000L;
- if (time < rang) {
- System.out.println(tempString);
- }
- }
- reader.close();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e1) {
- }
- }
- }
+ reader = new BufferedReader(new FileReader(file));
+ String tempString = null;
+ while ((tempString = reader.readLine()) != null) {
+ String[] tempArr = tempString.split("\\|");
+ long time = Long.parseLong(tempArr[0]);
+ long rang = 1467100800000L;
+ if (time < rang) {
+ System.out.println(tempString);
+ }
+ }
+ reader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e1) {
+ }
+ }
+ }
- }
+ }
}
diff --git a/src/main/java/me/ehlxr/test/TestGeoHash.java b/src/main/java/me/ehlxr/test/TestGeoHash.java
index a6a89fb..ce58f64 100644
--- a/src/main/java/me/ehlxr/test/TestGeoHash.java
+++ b/src/main/java/me/ehlxr/test/TestGeoHash.java
@@ -3,34 +3,34 @@ package me.ehlxr.test;
import me.ehlxr.utils.GeoHash;
public class TestGeoHash {
-
- public static void main(String[] args) {
-// double lon1 = 109.014520;
-// double lat1 = 34.236080;
-//
-// double lon2 = 108.9644583556;
-// double lat2 = 34.286439088548;
-// double dist;
-// String geocode;
-//
-// dist = CommonUtils.getDistance(lon1, lat1, lon2, lat2);
-// System.out.println("两点相距:" + dist + " 米");
-//
-// geocode = GeoHash.encode(lat1, lon1);
-// System.out.println("当前位置编码:" + geocode);
-//
-// geocode = GeoHash.encode(lat2, lon2);
-// System.out.println("远方位置编码:" + geocode);
-//
-// System.out.println(GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[0]+" "+GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[1]);
-
- double lon1 = 112.014520;
- double lat1 = 69.236080;
- System.out.println(GeoHash.encode(lat1, lon1));
-
- double lat = 34.236088;
- double lon = 109.01455;
- System.out.println(GeoHash.encode(lat, lon));
- }
+
+ public static void main(String[] args) {
+ // double lon1 = 109.014520;
+ // double lat1 = 34.236080;
+ //
+ // double lon2 = 108.9644583556;
+ // double lat2 = 34.286439088548;
+ // double dist;
+ // String geocode;
+ //
+ // dist = CommonUtils.getDistance(lon1, lat1, lon2, lat2);
+ // System.out.println("两点相距:" + dist + " 米");
+ //
+ // geocode = GeoHash.encode(lat1, lon1);
+ // System.out.println("当前位置编码:" + geocode);
+ //
+ // geocode = GeoHash.encode(lat2, lon2);
+ // System.out.println("远方位置编码:" + geocode);
+ //
+ // System.out.println(GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[0]+" "+GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[1]);
+
+ double lon1 = 112.014520;
+ double lat1 = 69.236080;
+ System.out.println(GeoHash.encode(lat1, lon1));
+
+ double lat = 34.236088;
+ double lon = 109.01455;
+ System.out.println(GeoHash.encode(lat, lon));
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/ehlxr/test/TestJdbc.java b/src/main/java/me/ehlxr/test/TestJdbc.java
index d64ecc1..f0e2893 100644
--- a/src/main/java/me/ehlxr/test/TestJdbc.java
+++ b/src/main/java/me/ehlxr/test/TestJdbc.java
@@ -1,92 +1,83 @@
package me.ehlxr.test;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
import me.ehlxr.redis.JedisUtil;
import net.sf.json.JSONObject;
+import java.sql.*;
+import java.util.Date;
+import java.util.*;
+
public class TestJdbc {
- private static Connection getConn() {
- String driver = "com.mysql.jdbc.Driver";
- String url = "jdbc:mysql://192.168.3.11:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
- String username = "root";
- String password = "pxene";
- Connection conn = null;
- try {
- Class.forName(driver); // classLoader,加载对应驱动
- conn = (Connection) DriverManager.getConnection(url, username, password);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return conn;
- }
+ private static Connection getConn() {
+ String driver = "com.mysql.jdbc.Driver";
+ String url = "jdbc:mysql://192.168.3.11:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
+ String username = "root";
+ String password = "pxene";
+ Connection conn = null;
+ try {
+ Class.forName(driver); // classLoader,加载对应驱动
+ conn = DriverManager.getConnection(url, username, password);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return conn;
+ }
- private static Integer getAll() {
- Connection conn = getConn();
- String sql = "SELECT v.* FROM dsp_v_app_motionclick_day_count v WHERE v.time BETWEEN 1433088000000 AND 1453046400000 ";
- // String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
- // = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
- PreparedStatement pstmt;
- try {
- pstmt = (PreparedStatement) conn.prepareStatement(sql);
- ResultSet rs = pstmt.executeQuery();
- ResultSetMetaData metaData = rs.getMetaData();
- while (rs.next()) {
- JSONObject jsonObject = new JSONObject();
- String time = "";
- String mapid = "";
- String appid = "";
- String adxtype = "";
- for (int i = 1; i <= metaData.getColumnCount(); i++) {
- String columnName = metaData.getColumnName(i);
- if ("time".equals(columnName)) {
- time = rs.getString(i);
- }
- if ("mapid".equals(columnName)) {
- mapid = rs.getString(i);
- }
- if ("appid".equals(columnName)) {
- appid = rs.getString(i);
- }
- if ("adxtype".equals(columnName)) {
- adxtype = rs.getString(i);
- }
+ private static Integer getAll() {
+ Connection conn = getConn();
+ String sql = "SELECT v.* FROM dsp_v_app_motionclick_day_count v WHERE v.time BETWEEN 1433088000000 AND 1453046400000 ";
+ // String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
+ // = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
+ PreparedStatement pstmt;
+ try {
+ pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+ ResultSetMetaData metaData = rs.getMetaData();
+ while (rs.next()) {
+ JSONObject jsonObject = new JSONObject();
+ String time = "";
+ String mapid = "";
+ String appid = "";
+ String adxtype = "";
+ for (int i = 1; i <= metaData.getColumnCount(); i++) {
+ String columnName = metaData.getColumnName(i);
+ if ("time".equals(columnName)) {
+ time = rs.getString(i);
+ }
+ if ("mapid".equals(columnName)) {
+ mapid = rs.getString(i);
+ }
+ if ("appid".equals(columnName)) {
+ appid = rs.getString(i);
+ }
+ if ("adxtype".equals(columnName)) {
+ adxtype = rs.getString(i);
+ }
- jsonObject.put(columnName, rs.getString(i));
- }
- Map map = new HashMap<>();
- map.put(time + "_" + appid + "_" + adxtype, jsonObject.toString());
- JedisUtil.hset("HistoryAPPData_" + mapid, map);
+ jsonObject.put(columnName, rs.getString(i));
+ }
+ Map map = new HashMap<>();
+ map.put(time + "_" + appid + "_" + adxtype, jsonObject.toString());
+ JedisUtil.hset("HistoryAPPData_" + mapid, map);
- // JedisUtil.lpush("HistoryAPPData_"+mapid+"_"+time,
- // jsonObject.toString());
- System.out.println("HistoryAPPData_" + mapid);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return null;
- }
+ // JedisUtil.lpush("HistoryAPPData_"+mapid+"_"+time,
+ // jsonObject.toString());
+ System.out.println("HistoryAPPData_" + mapid);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
- public static void main(String[] args) {
-
- insertData();
-
- // getAll();
-// JedisUtil.deleteByPattern("HistoryAPPData_*");
+ public static void main(String[] args) {
+
+ insertData();
+
+ // getAll();
+ // JedisUtil.deleteByPattern("HistoryAPPData_*");
/*
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start = new Date();
@@ -110,44 +101,44 @@ public class TestJdbc {
System.out.println(sdf.format(start));
System.out.println(sdf.format(end));
*/
- }
+ }
- private static List getMapid() {
- List mapids = new ArrayList();
- Connection conn = getConn();
- String sql = "SELECT t2.id AS mapid FROM dsp_t_ad_group_creative t2 LEFT JOIN dsp_t_ad_group t3 ON t2.groupid = t3.id LEFT JOIN dsp_t_campaign t4 ON t3.campaignid = t4.id LEFT JOIN dsp_t_advertiser_account t5 ON t4.accountid = t5.id LEFT JOIN dsp_t_advertiser t6 ON t5.advertiserid = t6.id WHERE ( t4.accountid IN ( SELECT id FROM dsp_t_advertiser_account t6 WHERE t6.advertiserid IN ( SELECT id FROM dsp_t_advertiser t7 WHERE t7.parentid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' ) ) OR t4.accountid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' )";
- // String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
- // = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
- PreparedStatement pstmt;
- try {
- pstmt = (PreparedStatement) conn.prepareStatement(sql);
- ResultSet rs = pstmt.executeQuery();
- ResultSetMetaData metaData = rs.getMetaData();
- while (rs.next()) {
- for (int i = 1; i <= metaData.getColumnCount(); i++) {
- mapids.add(rs.getString(i));
- }
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return mapids;
- }
+ private static List getMapid() {
+ List mapids = new ArrayList();
+ Connection conn = getConn();
+ String sql = "SELECT t2.id AS mapid FROM dsp_t_ad_group_creative t2 LEFT JOIN dsp_t_ad_group t3 ON t2.groupid = t3.id LEFT JOIN dsp_t_campaign t4 ON t3.campaignid = t4.id LEFT JOIN dsp_t_advertiser_account t5 ON t4.accountid = t5.id LEFT JOIN dsp_t_advertiser t6 ON t5.advertiserid = t6.id WHERE ( t4.accountid IN ( SELECT id FROM dsp_t_advertiser_account t6 WHERE t6.advertiserid IN ( SELECT id FROM dsp_t_advertiser t7 WHERE t7.parentid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' ) ) OR t4.accountid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' )";
+ // String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
+ // = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
+ PreparedStatement pstmt;
+ try {
+ pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+ ResultSetMetaData metaData = rs.getMetaData();
+ while (rs.next()) {
+ for (int i = 1; i <= metaData.getColumnCount(); i++) {
+ mapids.add(rs.getString(i));
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return mapids;
+ }
- private static void insertData(){
- Connection conn = getConn();
- System.out.println(new Date());
- for (int i = 0; i > -1; i++) {
- String cid = UUID.randomUUID().toString();
- String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '"+cid+"', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
- PreparedStatement pstmt;
- try {
- pstmt = (PreparedStatement) conn.prepareStatement(sql);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- System.out.println(new Date());
- }
+ private static void insertData() {
+ Connection conn = getConn();
+ System.out.println(new Date());
+ for (int i = 0; i > -1; i++) {
+ String cid = UUID.randomUUID().toString();
+ String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
+ PreparedStatement pstmt;
+ try {
+ pstmt = conn.prepareStatement(sql);
+ pstmt.executeUpdate();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.println(new Date());
+ }
}
diff --git a/src/main/java/me/ehlxr/test/TestJdbc143.java b/src/main/java/me/ehlxr/test/TestJdbc143.java
index fd809b4..c0058ad 100644
--- a/src/main/java/me/ehlxr/test/TestJdbc143.java
+++ b/src/main/java/me/ehlxr/test/TestJdbc143.java
@@ -5,66 +5,65 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Date;
-import java.util.UUID;
public class TestJdbc143 {
- private static Connection getConn() {
- String driver = "com.mysql.jdbc.Driver";
- String url = "jdbc:mysql://111.235.158.31:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
- String username = "root";
- String password = "pxene";
- Connection conn = null;
- try {
- Class.forName(driver); // classLoader,加载对应驱动
- conn = (Connection) DriverManager.getConnection(url, username, password);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return conn;
- }
+ private static Connection getConn() {
+ String driver = "com.mysql.jdbc.Driver";
+ String url = "jdbc:mysql://111.235.158.31:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
+ String username = "root";
+ String password = "pxene";
+ Connection conn = null;
+ try {
+ Class.forName(driver); // classLoader,加载对应驱动
+ conn = DriverManager.getConnection(url, username, password);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return conn;
+ }
- public static void main(String[] args) {
- insertData();
-// updateData();
- }
+ public static void main(String[] args) {
+ insertData();
+ // updateData();
+ }
- private static void insertData(){
- Connection conn = getConn();
- System.out.println(new Date());
- for (int i = 0; i < 1; i++) {
-// String cid = UUID.randomUUID().toString();
- String cid = "0123456789";
- String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '"+cid+"', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
- PreparedStatement pstmt;
- try {
- pstmt = (PreparedStatement) conn.prepareStatement(sql);
- pstmt.executeUpdate();
-
- if(i%200 == 0){
- Thread.sleep(200);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- System.out.println(new Date());
- }
-
- private static void updateData(){
- Connection conn = getConn();
- System.out.println(new Date());
- for (int i = 0; i < 800; i++) {
- String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='"+i+"' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
- PreparedStatement pstmt;
- try {
- pstmt = (PreparedStatement) conn.prepareStatement(sql);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- System.out.println(new Date());
- }
+ private static void insertData() {
+ Connection conn = getConn();
+ System.out.println(new Date());
+ for (int i = 0; i < 1; i++) {
+ // String cid = UUID.randomUUID().toString();
+ String cid = "0123456789";
+ String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
+ PreparedStatement pstmt;
+ try {
+ pstmt = conn.prepareStatement(sql);
+ pstmt.executeUpdate();
+
+ if (i % 200 == 0) {
+ Thread.sleep(200);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.println(new Date());
+ }
+
+ private static void updateData() {
+ Connection conn = getConn();
+ System.out.println(new Date());
+ for (int i = 0; i < 800; i++) {
+ String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
+ PreparedStatement pstmt;
+ try {
+ pstmt = conn.prepareStatement(sql);
+ pstmt.executeUpdate();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.println(new Date());
+ }
}
diff --git a/src/main/java/me/ehlxr/test/TestJdbc26.java b/src/main/java/me/ehlxr/test/TestJdbc26.java
index ca867f0..70cbeb4 100644
--- a/src/main/java/me/ehlxr/test/TestJdbc26.java
+++ b/src/main/java/me/ehlxr/test/TestJdbc26.java
@@ -8,61 +8,61 @@ import java.util.Date;
import java.util.UUID;
public class TestJdbc26 {
- private static Connection getConn() {
- String driver = "com.mysql.jdbc.Driver";
- String url = "jdbc:mysql://111.235.158.26:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
- String username = "root";
- String password = "pxene";
- Connection conn = null;
- try {
- Class.forName(driver); // classLoader,加载对应驱动
- conn = (Connection) DriverManager.getConnection(url, username, password);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return conn;
- }
+ private static Connection getConn() {
+ String driver = "com.mysql.jdbc.Driver";
+ String url = "jdbc:mysql://111.235.158.26:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
+ String username = "root";
+ String password = "pxene";
+ Connection conn = null;
+ try {
+ Class.forName(driver); // classLoader,加载对应驱动
+ conn = DriverManager.getConnection(url, username, password);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return conn;
+ }
- public static void main(String[] args) {
- insertData();
-// updateData();
- }
+ public static void main(String[] args) {
+ insertData();
+ // updateData();
+ }
- private static void insertData(){
- Connection conn = getConn();
- System.out.println(new Date());
- for (int i = 0; i > -1; i++) {
- String cid = UUID.randomUUID().toString();
- String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '"+cid+"', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
- PreparedStatement pstmt;
- try {
- pstmt = (PreparedStatement) conn.prepareStatement(sql);
- pstmt.executeUpdate();
- if(i%200 == 0){
- Thread.sleep(200);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- System.out.println(new Date());
- }
-
- private static void updateData(){
- Connection conn = getConn();
- System.out.println(new Date());
- for (int i = 0; i < 800; i++) {
- String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='"+i+"' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
- PreparedStatement pstmt;
- try {
- pstmt = (PreparedStatement) conn.prepareStatement(sql);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- System.out.println(new Date());
- }
+ private static void insertData() {
+ Connection conn = getConn();
+ System.out.println(new Date());
+ for (int i = 0; i > -1; i++) {
+ String cid = UUID.randomUUID().toString();
+ String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
+ PreparedStatement pstmt;
+ try {
+ pstmt = conn.prepareStatement(sql);
+ pstmt.executeUpdate();
+ if (i % 200 == 0) {
+ Thread.sleep(200);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.println(new Date());
+ }
+
+ private static void updateData() {
+ Connection conn = getConn();
+ System.out.println(new Date());
+ for (int i = 0; i < 800; i++) {
+ String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
+ PreparedStatement pstmt;
+ try {
+ pstmt = conn.prepareStatement(sql);
+ pstmt.executeUpdate();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.println(new Date());
+ }
}
diff --git a/src/main/java/me/ehlxr/test/TestReadFile.java b/src/main/java/me/ehlxr/test/TestReadFile.java
index c7d7d77..606336a 100644
--- a/src/main/java/me/ehlxr/test/TestReadFile.java
+++ b/src/main/java/me/ehlxr/test/TestReadFile.java
@@ -11,94 +11,92 @@ import java.util.Map;
public class TestReadFile {
- public static void readFile() {
- File file = new File("C:/Users/ehlxr/Desktop/IPB.txt");
- BufferedReader reader = null;
- Map resultMap = null;
- List startList = null;
- List endList = null;
- try {
- resultMap = new HashMap();
- startList = new ArrayList();
- endList = new ArrayList();
+ public static void readFile() {
+ File file = new File("C:/Users/ehlxr/Desktop/IPB.txt");
+ BufferedReader reader = null;
+ Map resultMap = null;
+ List startList = null;
+ List endList = null;
+ try {
+ resultMap = new HashMap();
+ startList = new ArrayList();
+ endList = new ArrayList();
- reader = new BufferedReader(new FileReader(file));
- String tempString = null;
- while ((tempString = reader.readLine()) != null) {
- String[] tempArr = tempString.split(" ");
+ reader = new BufferedReader(new FileReader(file));
+ String tempString = null;
+ while ((tempString = reader.readLine()) != null) {
+ String[] tempArr = tempString.split(" ");
- resultMap.put(tempArr[0], tempArr);
- startList.add(Long.parseLong(tempArr[0]));
- endList.add(Long.parseLong(tempArr[1]));
- }
- reader.close();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e1) {
- }
- }
- }
-
- long des = 17301504l;
- long key = binarySearch(startList.toArray(new Long[startList.size()]), des);
- String[] tempArr = (String[]) resultMap.get(key);
- for (int i = 0; i < tempArr.length; i++) {
- System.out.println(tempArr[i]);
- }
- }
+ resultMap.put(tempArr[0], tempArr);
+ startList.add(Long.parseLong(tempArr[0]));
+ endList.add(Long.parseLong(tempArr[1]));
+ }
+ reader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e1) {
+ }
+ }
+ }
- public static void readFile1() {
- File file = new File("C:\\Users\\ehlxr\\Desktop\\白名单\\IMEI\\000000_0");
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(file));
- String tempString = null;
- while ((tempString = reader.readLine()) != null) {
- System.out.println(tempString);
- }
- reader.close();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException ignored) {
- }
- }
- }
- }
+ long des = 17301504l;
+ long key = binarySearch(startList.toArray(new Long[startList.size()]), des);
+ String[] tempArr = (String[]) resultMap.get(key);
+ for (int i = 0; i < tempArr.length; i++) {
+ System.out.println(tempArr[i]);
+ }
+ }
- public static void main(String[] args) {
- readFile1();
- }
+ public static void readFile1() {
+ File file = new File("C:\\Users\\ehlxr\\Desktop\\白名单\\IMEI\\000000_0");
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(file));
+ String tempString = null;
+ while ((tempString = reader.readLine()) != null) {
+ System.out.println(tempString);
+ }
+ reader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ }
- /**
- * * 二分查找算法 * *
- *
- * @param srcArray
- * 有序数组 *
- * @param des
- * 查找元素 *
- * @return des的数组下标,没找到返回-1
- */
- public static long binarySearch(Long[] srcArray, long des) {
- int low = 0;
- int high = srcArray.length - 1;
- while (low <= high) {
- int middle = (low + high) / 2;
- if (des == srcArray[middle]) {
- return middle;
- } else if (des < srcArray[middle]) {
- high = middle - 1;
- } else {
- low = middle + 1;
- }
- }
- return -1;
- }
+ public static void main(String[] args) {
+ readFile1();
+ }
+
+ /**
+ * * 二分查找算法 * *
+ *
+ * @param srcArray 有序数组 *
+ * @param des 查找元素 *
+ * @return des的数组下标,没找到返回-1
+ */
+ public static long binarySearch(Long[] srcArray, long des) {
+ int low = 0;
+ int high = srcArray.length - 1;
+ while (low <= high) {
+ int middle = (low + high) / 2;
+ if (des == srcArray[middle]) {
+ return middle;
+ } else if (des < srcArray[middle]) {
+ high = middle - 1;
+ } else {
+ low = middle + 1;
+ }
+ }
+ return -1;
+ }
}
diff --git a/src/main/java/me/ehlxr/test/TestSyncLogData.java b/src/main/java/me/ehlxr/test/TestSyncLogData.java
index 1ff43d4..1dc6445 100644
--- a/src/main/java/me/ehlxr/test/TestSyncLogData.java
+++ b/src/main/java/me/ehlxr/test/TestSyncLogData.java
@@ -1,214 +1,213 @@
package me.ehlxr.test;
+import com.caucho.hessian.client.HessianProxyFactory;
+import me.ehlxr.readlogs.IReadLogs;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.caucho.hessian.client.HessianProxyFactory;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-import me.ehlxr.readlogs.IReadLogs;
-
public class TestSyncLogData {
- public static void main(String[] args) throws Exception {
- List mapids = new ArrayList();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
- SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd_HH");
+ public static void main(String[] args) throws Exception {
+ List mapids = new ArrayList();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd_HH");
- // 测试数据
- mapids.add("ad2176a7-74f2-4eab-965f-04c509653a93");
- mapids.add("63cae342-3288-4591-8097-53a9ac8bbe48");
- mapids.add("b38749f5-d5f9-441f-89de-a97c9b35adb0");
- mapids.add("3bc9a763-b5ad-4ade-a46c-12ce6f7a9479");
- mapids.add("cf384c11-0b25-4462-80ae-8a7eaedbf765");
- mapids.add("e9d823fe-379a-4d86-b9cd-93bb21c085a3");
- mapids.add("fa3c7262-4538-4192-bbca-ac1114f690c1");
- mapids.add("441af98d-917a-423a-ad3d-6faa8609e722");
- mapids.add("60112069-7c05-4135-8430-836ed61576e8");
- mapids.add("62367312-d881-426d-81b4-fe635d1db989");
- mapids.add("c41c1d40-1f71-44d2-88ab-478a584cd030");
- mapids.add("5f9735cf-6036-4902-9cff-5c7a40c76f24");
+ // 测试数据
+ mapids.add("ad2176a7-74f2-4eab-965f-04c509653a93");
+ mapids.add("63cae342-3288-4591-8097-53a9ac8bbe48");
+ mapids.add("b38749f5-d5f9-441f-89de-a97c9b35adb0");
+ mapids.add("3bc9a763-b5ad-4ade-a46c-12ce6f7a9479");
+ mapids.add("cf384c11-0b25-4462-80ae-8a7eaedbf765");
+ mapids.add("e9d823fe-379a-4d86-b9cd-93bb21c085a3");
+ mapids.add("fa3c7262-4538-4192-bbca-ac1114f690c1");
+ mapids.add("441af98d-917a-423a-ad3d-6faa8609e722");
+ mapids.add("60112069-7c05-4135-8430-836ed61576e8");
+ mapids.add("62367312-d881-426d-81b4-fe635d1db989");
+ mapids.add("c41c1d40-1f71-44d2-88ab-478a584cd030");
+ mapids.add("5f9735cf-6036-4902-9cff-5c7a40c76f24");
- Map adxs = new HashMap<>();
- adxs.put("15", 1.0000);
- adxs.put("14", 1.0000);
- adxs.put("2", 1.0000);
- adxs.put("8", 1.0000);
- adxs.put("11", 1.0000);
- adxs.put("1122331", 1.0000);
- adxs.put("1", 1.0000);
- adxs.put("4", 1.0000);
- adxs.put("9", 1.0000);
- adxs.put("13", 1.0000);
- adxs.put("10", 1.0000);
- adxs.put("5", 1.0000);
- adxs.put("7", 1.0000);
- adxs.put("112233", 1.0000);
- adxs.put("3", 0.1569);
+ Map adxs = new HashMap<>();
+ adxs.put("15", 1.0000);
+ adxs.put("14", 1.0000);
+ adxs.put("2", 1.0000);
+ adxs.put("8", 1.0000);
+ adxs.put("11", 1.0000);
+ adxs.put("1122331", 1.0000);
+ adxs.put("1", 1.0000);
+ adxs.put("4", 1.0000);
+ adxs.put("9", 1.0000);
+ adxs.put("13", 1.0000);
+ adxs.put("10", 1.0000);
+ adxs.put("5", 1.0000);
+ adxs.put("7", 1.0000);
+ adxs.put("112233", 1.0000);
+ adxs.put("3", 0.1569);
- HessianProxyFactory factory = new HessianProxyFactory();
- IReadLogs readLogs = (IReadLogs) factory.create(IReadLogs.class, "http://localhost:8080/sync-logs/remote/readlogs");
- String results = readLogs.readFile(sdf.parse("2016-02-24 09"), sdf.parse("2016-02-24 10"), mapids,
- "6692a223-2ae1-439a-93f4-09fb36e718ef",adxs);
- System.out.println(results);
- JSONArray dataArr = new JSONArray();
- dataArr = JSONArray.fromObject(results);
- // List dataList = (List)
- // JSONArray.toCollection(dataArr, StatisByHourModel.class);
+ HessianProxyFactory factory = new HessianProxyFactory();
+ IReadLogs readLogs = (IReadLogs) factory.create(IReadLogs.class, "http://localhost:8080/sync-logs/remote/readlogs");
+ String results = readLogs.readFile(sdf.parse("2016-02-24 09"), sdf.parse("2016-02-24 10"), mapids,
+ "6692a223-2ae1-439a-93f4-09fb36e718ef", adxs);
+ System.out.println(results);
+ JSONArray dataArr = new JSONArray();
+ dataArr = JSONArray.fromObject(results);
+ // List dataList = (List)
+ // JSONArray.toCollection(dataArr, StatisByHourModel.class);
- // List