Optimized code
This commit is contained in:
@@ -20,7 +20,6 @@ public class PrintMatrixClockWisely {
|
|||||||
* 当前矩阵,最后 1 行 坐标 (start,columns-1-start+1) => (start,endX-1)
|
* 当前矩阵,最后 1 行 坐标 (start,columns-1-start+1) => (start,endX-1)
|
||||||
* 当前矩阵,第 1 行 坐标 (start+1,columns-1+1) => (start+1,endY-1)
|
* 当前矩阵,第 1 行 坐标 (start+1,columns-1+1) => (start+1,endY-1)
|
||||||
*
|
*
|
||||||
* @author WangSai
|
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|||||||
2
src/main/java/me/ehlxr/cache/Cache.java
vendored
2
src/main/java/me/ehlxr/cache/Cache.java
vendored
@@ -17,8 +17,6 @@ package me.ehlxr.cache;
|
|||||||
* Company:
|
* Company:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Deepblue 2008-11-11
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
*/
|
||||||
public class Cache {
|
public class Cache {
|
||||||
private String key;// 缓存ID
|
private String key;// 缓存ID
|
||||||
|
|||||||
24
src/main/java/me/ehlxr/cache/CacheManager.java
vendored
24
src/main/java/me/ehlxr/cache/CacheManager.java
vendored
@@ -1,6 +1,8 @@
|
|||||||
package me.ehlxr.cache;
|
package me.ehlxr.cache;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,11 +23,9 @@ import java.util.Map.Entry;
|
|||||||
* Company:
|
* Company:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Deepblue 2008-11-11
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
*/
|
||||||
public class CacheManager {
|
public class CacheManager {
|
||||||
private static HashMap<String, Object> cacheMap = new HashMap<String, Object>();
|
private static final HashMap<String, Object> cacheMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
// 单实例构造方法
|
// 单实例构造方法
|
||||||
private CacheManager() {
|
private CacheManager() {
|
||||||
@@ -55,7 +55,7 @@ public class CacheManager {
|
|||||||
try {
|
try {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
key = (String) entry.getKey();
|
key = entry.getKey();
|
||||||
if (key.startsWith(type)) { // 如果匹配则删除掉
|
if (key.startsWith(type)) { // 如果匹配则删除掉
|
||||||
arr.add(key);
|
arr.add(key);
|
||||||
}
|
}
|
||||||
@@ -118,11 +118,9 @@ public class CacheManager {
|
|||||||
}
|
}
|
||||||
long nowDt = System.currentTimeMillis(); // 系统当前的毫秒数
|
long nowDt = System.currentTimeMillis(); // 系统当前的毫秒数
|
||||||
long cacheDt = cache.getTimeOut(); // 缓存内的过期毫秒数
|
long cacheDt = cache.getTimeOut(); // 缓存内的过期毫秒数
|
||||||
if (cacheDt <= 0 || cacheDt > nowDt) { // 过期时间小于等于零时,或者过期时间大于当前时间时,则为FALSE
|
// 过期时间小于等于零时,或者过期时间大于当前时间时,则为FALSE
|
||||||
return false;
|
// 大于过期时间 即过期
|
||||||
} else { // 大于过期时间 即过期
|
return cacheDt > 0 && cacheDt <= nowDt;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取缓存中的大小
|
// 获取缓存中的大小
|
||||||
@@ -138,7 +136,7 @@ public class CacheManager {
|
|||||||
try {
|
try {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
key = (String) entry.getKey();
|
key = entry.getKey();
|
||||||
if (key.indexOf(type) != -1) { // 如果匹配则删除掉
|
if (key.indexOf(type) != -1) { // 如果匹配则删除掉
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
@@ -157,7 +155,7 @@ public class CacheManager {
|
|||||||
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
a.add((String) entry.getKey());
|
a.add(entry.getKey());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
@@ -172,7 +170,7 @@ public class CacheManager {
|
|||||||
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
key = (String) entry.getKey();
|
key = entry.getKey();
|
||||||
if (key.indexOf(type) != -1) {
|
if (key.indexOf(type) != -1) {
|
||||||
a.add(key);
|
a.add(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,11 @@
|
|||||||
package me.ehlxr.pack;
|
package me.ehlxr.pack;
|
||||||
|
|
||||||
import java.awt.Component;
|
import javax.swing.*;
|
||||||
import java.awt.Point;
|
import java.awt.*;
|
||||||
import java.awt.Rectangle;
|
import java.io.*;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
|
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
private static int sumError = 0;
|
private static int sumError = 0;
|
||||||
private static int sumExistError = 0;
|
private static int sumExistError = 0;
|
||||||
@@ -29,7 +15,7 @@ public class FileUtil {
|
|||||||
|
|
||||||
private static String getDate(Date date) {
|
private static String getDate(Date date) {
|
||||||
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
return sd.format(date).toString();
|
return sd.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedReader getBufferedReader(String path) throws FileNotFoundException {
|
private static BufferedReader getBufferedReader(String path) throws FileNotFoundException {
|
||||||
|
|||||||
@@ -1,35 +1,28 @@
|
|||||||
package me.ehlxr.pack;
|
package me.ehlxr.pack;
|
||||||
|
|
||||||
import java.awt.Color;
|
import javax.swing.*;
|
||||||
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
import javax.swing.filechooser.FileSystemView;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.JTextPane;
|
|
||||||
import javax.swing.filechooser.FileFilter;
|
|
||||||
import javax.swing.filechooser.FileSystemView;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class PackView extends JFrame {
|
public class PackView extends JFrame {
|
||||||
private JButton jb = new JButton();
|
private final JButton jb = new JButton();
|
||||||
private JButton jb1 = new JButton();
|
private final JButton jb1 = new JButton();
|
||||||
private JButton jb2 = new JButton();
|
private final JButton jb2 = new JButton();
|
||||||
private String inputPath = "D:\\wins-dsp";
|
private final JLabel jl0 = new JLabel();
|
||||||
private String outputPath = "C:\\Users\\ehlxr\\Desktop";
|
private final JButton cancel = new JButton("退出");
|
||||||
private JLabel jl0 = new JLabel();
|
private final JTextPane jText1 = new JTextPane();
|
||||||
private JButton cancel = new JButton("退出");
|
private final JTextPane jText2 = new JTextPane();
|
||||||
private JTextPane jText1 = new JTextPane();
|
|
||||||
private JTextPane jText2 = new JTextPane();
|
|
||||||
public JTextArea jArea = new JTextArea();
|
public JTextArea jArea = new JTextArea();
|
||||||
public JScrollPane p = new JScrollPane(this.jArea);
|
public JScrollPane p = new JScrollPane(this.jArea);
|
||||||
|
private String inputPath = "D:\\wins-dsp";
|
||||||
|
private String outputPath = "C:\\Users\\ehlxr\\Desktop";
|
||||||
|
|
||||||
private PackView() {
|
private PackView() {
|
||||||
setTitle("打包工具(By:Henry)");
|
setTitle("打包工具(By:Henry)");
|
||||||
@@ -149,6 +142,10 @@ public class PackView extends JFrame {
|
|||||||
setDefaultCloseOperation(3);
|
setDefaultCloseOperation(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new PackView();
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> chooseFile(int chooseMode) {
|
private List<String> chooseFile(int chooseMode) {
|
||||||
try {
|
try {
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
@@ -162,10 +159,7 @@ public class PackView extends JFrame {
|
|||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((f.getName().endsWith(".TXT")) || (f.getName().endsWith(".txt"))) {
|
return (f.getName().endsWith(".TXT")) || (f.getName().endsWith(".txt"));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
@@ -188,7 +182,7 @@ public class PackView extends JFrame {
|
|||||||
if (returnVal == 0) {
|
if (returnVal == 0) {
|
||||||
fileName = fileChooser.getSelectedFiles();
|
fileName = fileChooser.getSelectedFiles();
|
||||||
} else {
|
} else {
|
||||||
fileName = (File[]) null;
|
fileName = null;
|
||||||
}
|
}
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
System.out.println("打包文件路径列表:");
|
System.out.println("打包文件路径列表:");
|
||||||
@@ -255,7 +249,7 @@ public class PackView extends JFrame {
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < fileName.size(); i++) {
|
for (int i = 0; i < fileName.size(); i++) {
|
||||||
try {
|
try {
|
||||||
flag = FileUtil.becomePackage((String) fileName.get(i), this.inputPath, this.outputPath, this);
|
flag = FileUtil.becomePackage(fileName.get(i), this.inputPath, this.outputPath, this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -263,8 +257,4 @@ public class PackView extends JFrame {
|
|||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new PackView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
* @since 2019-07-19.
|
* @since 2019-07-19.
|
||||||
*/
|
*/
|
||||||
public class RateBarrier {
|
public class RateBarrier {
|
||||||
private AtomicInteger op = new AtomicInteger(0);
|
private final AtomicInteger op = new AtomicInteger(0);
|
||||||
private List<Integer> source;
|
private List<Integer> source;
|
||||||
private int base;
|
private int base;
|
||||||
private int rate;
|
private int rate;
|
||||||
|
|||||||
@@ -1,27 +1,21 @@
|
|||||||
package me.ehlxr.sftp;
|
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.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
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工具类
|
* SFTP工具类
|
||||||
*
|
*
|
||||||
* @author ehlxr
|
* @author ehlxr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SFTPUtil {
|
public class SFTPUtil {
|
||||||
private static Log log = LogFactory.getLog(SFTPUtil.class);
|
private static final Log log = LogFactory.getLog(SFTPUtil.class);
|
||||||
private static String ip;
|
private static String ip;
|
||||||
private static String user;
|
private static String user;
|
||||||
private static String psw;
|
private static String psw;
|
||||||
@@ -77,7 +71,7 @@ public class SFTPUtil {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 创建sftp通信通道
|
// 创建sftp通信通道
|
||||||
channel = (Channel) session.openChannel("sftp");
|
channel = session.openChannel("sftp");
|
||||||
channel.connect(1000);
|
channel.connect(1000);
|
||||||
sftp = (ChannelSftp) channel;
|
sftp = (ChannelSftp) channel;
|
||||||
log.info("连接服务器[" + ip + "]成功.....");
|
log.info("连接服务器[" + ip + "]成功.....");
|
||||||
@@ -101,12 +95,9 @@ public class SFTPUtil {
|
|||||||
/**
|
/**
|
||||||
* SFTP上传文件
|
* SFTP上传文件
|
||||||
*
|
*
|
||||||
* @param desPath
|
* @param desPath ftp服务器目录
|
||||||
* ftp服务器目录
|
* @param desFileName 上传后的文件名
|
||||||
* @param desFileName
|
* @param resFile 要上传的文件
|
||||||
* 上传后的文件名
|
|
||||||
* @param resFile
|
|
||||||
* 要上传的文件
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void putFile(String desPath, String desFileName, File resFile) {
|
public static void putFile(String desPath, String desFileName, File resFile) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入排序
|
* 插入排序
|
||||||
*
|
* <p>
|
||||||
* 基本思想是:
|
* 基本思想是:
|
||||||
* 将数组中的所有元素依次跟前面已经排好的元素相比较,如果选择的元素比已排序的元素小,
|
* 将数组中的所有元素依次跟前面已经排好的元素相比较,如果选择的元素比已排序的元素小,
|
||||||
* 则交换,直到全部元素都比较过为止。
|
* 则交换,直到全部元素都比较过为止。
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class DirList {
|
|||||||
|
|
||||||
class DirFilter implements FilenameFilter {
|
class DirFilter implements FilenameFilter {
|
||||||
String afn;
|
String afn;
|
||||||
|
|
||||||
DirFilter(String afn) {
|
DirFilter(String afn) {
|
||||||
this.afn = afn;
|
this.afn = afn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package me.ehlxr.test;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class ExecBaics50Log {
|
public class ExecBaics50Log {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
StringBuffer sb = new StringBuffer("");
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
FileReader reader = new FileReader("C:\\Users\\ehlxr\\Desktop\\minisite\\20160606\\3\\2016-06-06(3、4、5).txt");
|
FileReader reader = new FileReader("C:\\Users\\ehlxr\\Desktop\\minisite\\20160606\\3\\2016-06-06(3、4、5).txt");
|
||||||
BufferedReader br = new BufferedReader(reader);
|
BufferedReader br = new BufferedReader(reader);
|
||||||
@@ -29,7 +27,7 @@ public class ExecBaics50Log {
|
|||||||
|
|
||||||
|
|
||||||
ssString += "'" + substring + "'";
|
ssString += "'" + substring + "'";
|
||||||
}else{
|
} else {
|
||||||
|
|
||||||
ssString += "'" + substring + "',";
|
ssString += "'" + substring + "',";
|
||||||
}
|
}
|
||||||
@@ -45,7 +43,7 @@ public class ExecBaics50Log {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatDate(String date) throws Exception{
|
private static String formatDate(String date) throws Exception {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
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);
|
SimpleDateFormat sdf1 = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", java.util.Locale.ENGLISH);
|
||||||
TimeZone tz = TimeZone.getTimeZone("CST");
|
TimeZone tz = TimeZone.getTimeZone("CST");
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public interface IChargeCounter {
|
|||||||
* @param groupid
|
* @param groupid
|
||||||
* @param cost
|
* @param cost
|
||||||
*/
|
*/
|
||||||
public void chargeForThisResult(String campaignid, String groupid, BigDecimal cost);
|
void chargeForThisResult(String campaignid, String groupid, BigDecimal cost);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 投放次数控制
|
* 投放次数控制
|
||||||
@@ -19,5 +19,5 @@ public interface IChargeCounter {
|
|||||||
* @param count
|
* @param count
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public void counterControlForThisSumResult(String groupid, int count, String type);
|
void counterControlForThisSumResult(String groupid, int count, String type);
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import me.ehlxr.redis.JedisUtil;
|
|||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
JedisUtil.set("test_20160614","20160614");
|
JedisUtil.set("test_20160614", "20160614");
|
||||||
System.out.println(JedisUtil.getStr("test_20160614"));
|
System.out.println(JedisUtil.getStr("test_20160614"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ package me.ehlxr.test;
|
|||||||
public class Test {
|
public class Test {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String s0 = "kvill";
|
String s0 = "kvill";
|
||||||
String s1 = new String("kvill");
|
String s1 = "kvill";
|
||||||
String s2 = new String("kvill");
|
String s2 = "kvill";
|
||||||
System.out.println(s0 == s1);
|
System.out.println(s0 == s1);
|
||||||
System.out.println("**********");
|
System.out.println("**********");
|
||||||
s1.intern();
|
s1.intern();
|
||||||
|
|||||||
@@ -2,11 +2,7 @@ package me.ehlxr.test;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class TestCode {
|
public class TestCode {
|
||||||
|
|
||||||
@@ -28,14 +24,14 @@ public class TestCode {
|
|||||||
// Map<String, Object> resultMap = new HashMap<String, Object>();
|
// Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
// System.out.println((String)resultMap.get("dd"));
|
// System.out.println((String)resultMap.get("dd"));
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
// String str = null;
|
// String str = null;
|
||||||
// str.equals("");
|
// str.equals("");
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// System.out.println(e.getMessage());
|
// System.out.println(e.getMessage());
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
// System.out.println("fffff");
|
// System.out.println("fffff");
|
||||||
|
|
||||||
// String[] s = {"111","eee"};
|
// String[] s = {"111","eee"};
|
||||||
// System.out.println(Arrays.toString(s));
|
// System.out.println(Arrays.toString(s));
|
||||||
@@ -114,217 +110,217 @@ public class TestCode {
|
|||||||
// System.out.println(jj.optString("pring"));
|
// System.out.println(jj.optString("pring"));
|
||||||
|
|
||||||
|
|
||||||
// // 根据网卡取本机配置的IP
|
// // 根据网卡取本机配置的IP
|
||||||
// InetAddress inet = null;
|
// InetAddress inet = null;
|
||||||
// try {
|
// try {
|
||||||
// inet = InetAddress.getLocalHost();
|
// inet = InetAddress.getLocalHost();
|
||||||
// } catch (UnknownHostException e) {
|
// } catch (UnknownHostException e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
// String ipAddress = inet.getHostAddress();
|
// String ipAddress = inet.getHostAddress();
|
||||||
//
|
//
|
||||||
// System.out.println(ipAddress);
|
// System.out.println(ipAddress);
|
||||||
|
|
||||||
|
|
||||||
// TestCode test = new TestCode();
|
// TestCode test = new TestCode();
|
||||||
// System.out.println(test.dd("ddd"));
|
// System.out.println(test.dd("ddd"));
|
||||||
|
|
||||||
|
|
||||||
// Package pkg = Package.getPackage("osc.git.eh3.test");
|
// Package pkg = Package.getPackage("osc.git.eh3.test");
|
||||||
// Annotation[] annotations = pkg.getAnnotations();
|
// Annotation[] annotations = pkg.getAnnotations();
|
||||||
// for (Annotation annotation : annotations) {
|
// for (Annotation annotation : annotations) {
|
||||||
// System.out.println(annotation);
|
// System.out.println(annotation);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// String[] arrs = new String[]{"111","111","2222"};
|
// String[] arrs = new String[]{"111","111","2222"};
|
||||||
// for (String string : Array2Set(arrs)) {
|
// for (String string : Array2Set(arrs)) {
|
||||||
//
|
//
|
||||||
// System.out.println(string);
|
// System.out.println(string);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Class<?> clazz = StatisByHourModel.class;
|
// Class<?> clazz = StatisByHourModel.class;
|
||||||
// Method[] methods = clazz.getMethods();
|
// Method[] methods = clazz.getMethods();
|
||||||
// for (Method method : methods) {
|
// for (Method method : methods) {
|
||||||
// System.out.println(method.getName());
|
// System.out.println(method.getName());
|
||||||
// }
|
// }
|
||||||
// Object dd = new Date();
|
// Object dd = new Date();
|
||||||
//
|
//
|
||||||
// System.out.println(dd instanceof Date);
|
// System.out.println(dd instanceof Date);
|
||||||
//
|
//
|
||||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
// System.out.println(sdf.format(dd));
|
// 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\"}");
|
// 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<String> keySet = groupAdxs.keySet();
|
// Set<String> keySet = groupAdxs.keySet();
|
||||||
// for (Object object : keySet) {
|
// for (Object object : keySet) {
|
||||||
// System.out.println(groupAdxs.get(object).getClass().isArray());
|
// 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(new Integer(0x11));
|
||||||
// System.out.println(Integer.toBinaryString(30000));
|
// System.out.println(Integer.toBinaryString(30000));
|
||||||
// System.out.println(Integer.valueOf("11", 16));
|
// System.out.println(Integer.valueOf("11", 16));
|
||||||
// System.out.println(Integer.valueOf("11", 2));
|
// System.out.println(Integer.valueOf("11", 2));
|
||||||
|
|
||||||
|
|
||||||
// System.out.println(AESTool.encrypt("ehlxr"));
|
// System.out.println(AESTool.encrypt("ehlxr"));
|
||||||
// System.out.println(AESTool.decrypt(AESEncrypter.encrypt("ehlxr")));
|
// System.out.println(AESTool.decrypt(AESEncrypter.encrypt("ehlxr")));
|
||||||
|
|
||||||
// System.out.println(AESTool.encrypt("liixangrong","adjdjfjfjfjdkdkd"));
|
// System.out.println(AESTool.encrypt("liixangrong","adjdjfjfjfjdkdkd"));
|
||||||
// System.out.println(AESTool.decrypt("bfb0c038342ffead45511879853279bf","adjdjfjfjfjdkdkd"));
|
// System.out.println(AESTool.decrypt("bfb0c038342ffead45511879853279bf","adjdjfjfjfjdkdkd"));
|
||||||
// System.out.println(Base64.encodeToString(AESTool.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202").getBytes(), false));
|
// System.out.println(Base64.encodeToString(AESTool.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202").getBytes(), false));
|
||||||
|
|
||||||
// byte[] bytes = "ehlxr".getBytes();
|
// byte[] bytes = "ehlxr".getBytes();
|
||||||
// for (int i = 0; i < bytes.length; i++) {
|
// for (int i = 0; i < bytes.length; i++) {
|
||||||
// System.out.println(bytes[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 lon1 = 109.0145193759;
|
||||||
// double lat1 = 34.236080797698;
|
// double lat1 = 34.236080797698;
|
||||||
// System.out.println(GeoHash.encode(lat1, lon1));
|
// System.out.println(GeoHash.encode(lat1, lon1));
|
||||||
// System.out.println(GeoHash.decode("wmtdgn5esrb1")[0]+" "+GeoHash.decode("wmtdgn5esrb1")[1]);
|
// 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";
|
// 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));
|
// System.out.println(HttpClientUtil.sendGet(url));
|
||||||
|
|
||||||
// JSONArray array = new JSONArray();
|
// JSONArray array = new JSONArray();
|
||||||
// array.add("1");
|
// array.add("1");
|
||||||
// array.add("2");
|
// array.add("2");
|
||||||
// array.add("3");
|
// array.add("3");
|
||||||
// array.add("4");
|
// array.add("4");
|
||||||
// array.add("5");
|
// array.add("5");
|
||||||
// List<String> list = JSONArray.toList(array, new String(), new JsonConfig());
|
// List<String> list = JSONArray.toList(array, new String(), new JsonConfig());
|
||||||
// System.out.println(list);
|
// 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<String, String> postParam = new HashMap<String, String>();
|
// Map<String, String> postParam = new HashMap<String, String>();
|
||||||
// postParam.put("groupid", "100003");
|
// postParam.put("groupid", "100003");
|
||||||
// postParam.put("count", "1");
|
// postParam.put("count", "1");
|
||||||
// postParam.put("type", "m");
|
// postParam.put("type", "m");
|
||||||
// for(int i=0;i<5;i++){
|
// for(int i=0;i<5;i++){
|
||||||
// try {
|
// try {
|
||||||
// HttpClientUtil.sendPostParam("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", postParam);
|
// 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");
|
//// HttpClientUtil.sendPost("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", "groupid=100003&count=1&type=m");
|
||||||
// break;
|
// break;
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// System.out.println(e.getMessage());
|
// System.out.println(e.getMessage());
|
||||||
// try {
|
// try {
|
||||||
// Thread.sleep(1000);
|
// Thread.sleep(1000);
|
||||||
// } catch (InterruptedException e1) {
|
// } catch (InterruptedException e1) {
|
||||||
// e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// String str = "0,";
|
// String str = "0,";
|
||||||
// System.out.println(str.split(",").length);
|
// System.out.println(str.split(",").length);
|
||||||
|
|
||||||
// System.out.println(JedisUtil.getStr("0000"));
|
// System.out.println(JedisUtil.getStr("0000"));
|
||||||
// Map<String,Integer> result = new HashMap<String, Integer>();
|
// Map<String,Integer> result = new HashMap<String, Integer>();
|
||||||
// System.out.println(result.get("jj"));
|
// System.out.println(result.get("jj"));
|
||||||
// double budgets = 10000;
|
// double budgets = 10000;
|
||||||
// System.out.println((budgets/100));
|
// System.out.println((budgets/100));
|
||||||
|
|
||||||
// String str = null;
|
// String str = null;
|
||||||
// BigDecimal budget = new BigDecimal(str);
|
// BigDecimal budget = new BigDecimal(str);
|
||||||
// budget = budget.subtract(new BigDecimal(10));
|
// budget = budget.subtract(new BigDecimal(10));
|
||||||
// if (budget.compareTo(new BigDecimal(0)) <= 0) {
|
// if (budget.compareTo(new BigDecimal(0)) <= 0) {
|
||||||
// System.out.println("1");
|
// System.out.println("1");
|
||||||
// } else {
|
// } else {
|
||||||
// System.out.println("2");
|
// System.out.println("2");
|
||||||
// }
|
// }
|
||||||
// System.out.println(budget.doubleValue());
|
// System.out.println(budget.doubleValue());
|
||||||
|
|
||||||
// String REG_FLOAT = "^[1-9]\\d*.?\\d+$"; // 浮点正数
|
// String REG_FLOAT = "^[1-9]\\d*.?\\d+$"; // 浮点正数
|
||||||
// System.out.println(Pattern.compile(REG_FLOAT).matcher("1.21").matches());
|
// System.out.println(Pattern.compile(REG_FLOAT).matcher("1.21").matches());
|
||||||
|
|
||||||
// String str ="浮点数sss";
|
// String str ="浮点数sss";
|
||||||
// String s1 = new String(str.getBytes("utf-8"),"gbk");
|
// String s1 = new String(str.getBytes("utf-8"),"gbk");
|
||||||
// System.out.println(s1);
|
// System.out.println(s1);
|
||||||
// System.out.println(new String(s1.getBytes("gbk")));
|
// System.out.println(new String(s1.getBytes("gbk")));
|
||||||
// System.out.println();
|
// System.out.println();
|
||||||
////
|
////
|
||||||
// String s2 = URLEncoder.encode(str, "utf-8");
|
// String s2 = URLEncoder.encode(str, "utf-8");
|
||||||
// System.out.println(s2);
|
// System.out.println(s2);
|
||||||
// System.out.println(URLDecoder.decode(s2,"utf-8"));
|
// System.out.println(URLDecoder.decode(s2,"utf-8"));
|
||||||
|
|
||||||
//System.out.println(new String(Hex.decodeHex("E8AFB7E6B182E5A4B1E8B4A5EFBC8CE8AFB7E7A88DE5908EE9878DE8AF95".toCharArray()), "utf-8"));
|
//System.out.println(new String(Hex.decodeHex("E8AFB7E6B182E5A4B1E8B4A5EFBC8CE8AFB7E7A88DE5908EE9878DE8AF95".toCharArray()), "utf-8"));
|
||||||
// Object object = null;
|
// Object object = null;
|
||||||
// JSONObject creativeGroupObj = JSONObject.fromObject(object);
|
// JSONObject creativeGroupObj = JSONObject.fromObject(object);
|
||||||
// System.out.println(creativeGroupObj.isEmpty());
|
// System.out.println(creativeGroupObj.isEmpty());
|
||||||
//
|
//
|
||||||
// System.out.println(UUID.randomUUID().toString());
|
// 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 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();
|
// JSONArray periods = new JSONArray();
|
||||||
// for (Object object : putTime) {
|
// for (Object object : putTime) {
|
||||||
// JSONObject putTimeObj = JSONObject.fromObject(object);
|
// JSONObject putTimeObj = JSONObject.fromObject(object);
|
||||||
// if (!putTimeObj.isEmpty()) {
|
// if (!putTimeObj.isEmpty()) {
|
||||||
// Set<String> keySet = putTimeObj.keySet();
|
// Set<String> keySet = putTimeObj.keySet();
|
||||||
// JSONObject period = new JSONObject();
|
// JSONObject period = new JSONObject();
|
||||||
// for (String key : keySet) {
|
// for (String key : keySet) {
|
||||||
// JSONArray value = putTimeObj.optJSONArray(key);
|
// JSONArray value = putTimeObj.optJSONArray(key);
|
||||||
// int start = -1,end = -1;
|
// int start = -1,end = -1;
|
||||||
// StringBuffer sb = new StringBuffer();
|
// StringBuffer sb = new StringBuffer();
|
||||||
// for (int i = 0; i < value.size(); i++) {
|
// for (int i = 0; i < value.size(); i++) {
|
||||||
// Object object2 = value.get(i);
|
// Object object2 = value.get(i);
|
||||||
// // 第一次出现 1
|
// // 第一次出现 1
|
||||||
// if (object2.equals("1") && start==-1) {
|
// if (object2.equals("1") && start==-1) {
|
||||||
// start=i;
|
// start=i;
|
||||||
// end = 0;
|
// end = 0;
|
||||||
// }
|
// }
|
||||||
// // 出现1后的第一次出现0结束
|
// // 出现1后的第一次出现0结束
|
||||||
// if (object2.equals("0") && start>-1) {
|
// if (object2.equals("0") && start>-1) {
|
||||||
// end=i-1;
|
// end=i-1;
|
||||||
// sb.append(start+"-"+end+",");
|
// sb.append(start+"-"+end+",");
|
||||||
// start = -1;end = -1;
|
// start = -1;end = -1;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// period.put("week", key);
|
// period.put("week", key);
|
||||||
// period.put("ranges",sb.toString().substring(0, (sb.length()-1)));
|
// period.put("ranges",sb.toString().substring(0, (sb.length()-1)));
|
||||||
// }
|
// }
|
||||||
// periods.add(period);
|
// periods.add(period);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// System.out.println(periods.toString());
|
// System.out.println(periods.toString());
|
||||||
|
|
||||||
// JSONObject period = new JSONObject();
|
// JSONObject period = new JSONObject();
|
||||||
// period.put("test", 100.32);
|
// period.put("test", 100.32);
|
||||||
// System.out.println(period.optString("test"));
|
// System.out.println(period.optString("test"));
|
||||||
|
|
||||||
// BigDecimal clicks = new BigDecimal(100.23);
|
// BigDecimal clicks = new BigDecimal(100.23);
|
||||||
// System.out.println(clicks.intValue());
|
// System.out.println(clicks.intValue());
|
||||||
|
|
||||||
// System.out.println(Long.parseLong("8000.01"));
|
// System.out.println(Long.parseLong("8000.01"));
|
||||||
|
|
||||||
// JSONObject jsonParam = new JSONObject();
|
// JSONObject jsonParam = new JSONObject();
|
||||||
// JSONArray jsonArray = new JSONArray();
|
// JSONArray jsonArray = new JSONArray();
|
||||||
// jsonArray.add("000000");
|
// jsonArray.add("000000");
|
||||||
// jsonParam.put("app", jsonArray);
|
// jsonParam.put("app", jsonArray);
|
||||||
// System.out.println(jsonParam);
|
// System.out.println(jsonParam);
|
||||||
|
|
||||||
|
|
||||||
// String head = "00,";
|
// String head = "00,";
|
||||||
// head = head.substring(0, head.lastIndexOf(","));
|
// head = head.substring(0, head.lastIndexOf(","));
|
||||||
// System.out.println(head);
|
// System.out.println(head);
|
||||||
//
|
//
|
||||||
// String ip = "127, 0, 0,1";
|
// String ip = "127, 0, 0,1";
|
||||||
// // String [] s = ip.split(".");
|
// // String [] s = ip.split(".");
|
||||||
// String[] s = ip.split("\\,");
|
// String[] s = ip.split("\\,");
|
||||||
// for (String string : s) {
|
// for (String string : s) {
|
||||||
// System.out.println(string);
|
// System.out.println(string);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Object str = null;
|
// Object str = null;
|
||||||
//// String dd = (String)str;
|
//// String dd = (String)str;
|
||||||
// String dd = String.valueOf(str);
|
// String dd = String.valueOf(str);
|
||||||
// System.out.println(String.valueOf(str) == String.valueOf("null"));
|
// 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\"";
|
//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;
|
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");
|
System.out.println("ture");
|
||||||
}else {
|
} else {
|
||||||
System.out.println("false");
|
System.out.println("false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ public class TestCounter {
|
|||||||
|
|
||||||
for (int i = 0; i < 8000; i++) {
|
for (int i = 0; i < 8000; i++) {
|
||||||
new Thread(new TestThread()).start();
|
new Thread(new TestThread()).start();
|
||||||
// Thread.sleep(5);
|
// Thread.sleep(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@ package me.ehlxr.test;
|
|||||||
|
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ehlxr on 2016/9/12.
|
* Created by ehlxr on 2016/9/12.
|
||||||
*/
|
*/
|
||||||
@@ -9,7 +11,7 @@ public class TestDecodeHex {
|
|||||||
// 十六进制转字符串
|
// 十六进制转字符串
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
String data = "E88194E7B3BBE4BABAE6B7BBE58AA0E5A4B1E8B4A5";
|
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()));
|
System.out.println(Hex.encodeHexString("测试粗我".getBytes()));
|
||||||
|
|
||||||
|
|||||||
@@ -6,24 +6,24 @@ public class TestGeoHash {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// double lon1 = 109.014520;
|
// double lon1 = 109.014520;
|
||||||
// double lat1 = 34.236080;
|
// double lat1 = 34.236080;
|
||||||
//
|
//
|
||||||
// double lon2 = 108.9644583556;
|
// double lon2 = 108.9644583556;
|
||||||
// double lat2 = 34.286439088548;
|
// double lat2 = 34.286439088548;
|
||||||
// double dist;
|
// double dist;
|
||||||
// String geocode;
|
// String geocode;
|
||||||
//
|
//
|
||||||
// dist = CommonUtils.getDistance(lon1, lat1, lon2, lat2);
|
// dist = CommonUtils.getDistance(lon1, lat1, lon2, lat2);
|
||||||
// System.out.println("两点相距:" + dist + " 米");
|
// System.out.println("两点相距:" + dist + " 米");
|
||||||
//
|
//
|
||||||
// geocode = GeoHash.encode(lat1, lon1);
|
// geocode = GeoHash.encode(lat1, lon1);
|
||||||
// System.out.println("当前位置编码:" + geocode);
|
// System.out.println("当前位置编码:" + geocode);
|
||||||
//
|
//
|
||||||
// geocode = GeoHash.encode(lat2, lon2);
|
// geocode = GeoHash.encode(lat2, lon2);
|
||||||
// System.out.println("远方位置编码:" + geocode);
|
// System.out.println("远方位置编码:" + geocode);
|
||||||
//
|
//
|
||||||
// System.out.println(GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[0]+" "+GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[1]);
|
// System.out.println(GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[0]+" "+GeoHash.decode("wqjdb8mzw7vspswfydscen0002")[1]);
|
||||||
|
|
||||||
double lon1 = 112.014520;
|
double lon1 = 112.014520;
|
||||||
double lat1 = 69.236080;
|
double lat1 = 69.236080;
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
package me.ehlxr.test;
|
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 me.ehlxr.redis.JedisUtil;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class TestJdbc {
|
public class TestJdbc {
|
||||||
private static Connection getConn() {
|
private static Connection getConn() {
|
||||||
String driver = "com.mysql.jdbc.Driver";
|
String driver = "com.mysql.jdbc.Driver";
|
||||||
@@ -25,7 +16,7 @@ public class TestJdbc {
|
|||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
Class.forName(driver); // classLoader,加载对应驱动
|
Class.forName(driver); // classLoader,加载对应驱动
|
||||||
conn = (Connection) DriverManager.getConnection(url, username, password);
|
conn = DriverManager.getConnection(url, username, password);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -41,7 +32,7 @@ public class TestJdbc {
|
|||||||
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
ResultSetMetaData metaData = rs.getMetaData();
|
ResultSetMetaData metaData = rs.getMetaData();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -86,7 +77,7 @@ public class TestJdbc {
|
|||||||
insertData();
|
insertData();
|
||||||
|
|
||||||
// getAll();
|
// getAll();
|
||||||
// JedisUtil.deleteByPattern("HistoryAPPData_*");
|
// JedisUtil.deleteByPattern("HistoryAPPData_*");
|
||||||
/*
|
/*
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
Date start = new Date();
|
Date start = new Date();
|
||||||
@@ -120,7 +111,7 @@ public class TestJdbc {
|
|||||||
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
ResultSetMetaData metaData = rs.getMetaData();
|
ResultSetMetaData metaData = rs.getMetaData();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -134,15 +125,15 @@ public class TestJdbc {
|
|||||||
return mapids;
|
return mapids;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void insertData(){
|
private static void insertData() {
|
||||||
Connection conn = getConn();
|
Connection conn = getConn();
|
||||||
System.out.println(new Date());
|
System.out.println(new Date());
|
||||||
for (int i = 0; i > -1; i++) {
|
for (int i = 0; i > -1; i++) {
|
||||||
String cid = UUID.randomUUID().toString();
|
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');";
|
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;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class TestJdbc143 {
|
public class TestJdbc143 {
|
||||||
private static Connection getConn() {
|
private static Connection getConn() {
|
||||||
@@ -16,7 +15,7 @@ public class TestJdbc143 {
|
|||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
Class.forName(driver); // classLoader,加载对应驱动
|
Class.forName(driver); // classLoader,加载对应驱动
|
||||||
conn = (Connection) DriverManager.getConnection(url, username, password);
|
conn = DriverManager.getConnection(url, username, password);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -27,22 +26,22 @@ public class TestJdbc143 {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
insertData();
|
insertData();
|
||||||
// updateData();
|
// updateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void insertData(){
|
private static void insertData() {
|
||||||
Connection conn = getConn();
|
Connection conn = getConn();
|
||||||
System.out.println(new Date());
|
System.out.println(new Date());
|
||||||
for (int i = 0; i < 1; i++) {
|
for (int i = 0; i < 1; i++) {
|
||||||
// String cid = UUID.randomUUID().toString();
|
// String cid = UUID.randomUUID().toString();
|
||||||
String cid = "0123456789";
|
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');";
|
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;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
|
|
||||||
if(i%200 == 0){
|
if (i % 200 == 0) {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -52,14 +51,14 @@ public class TestJdbc143 {
|
|||||||
System.out.println(new Date());
|
System.out.println(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateData(){
|
private static void updateData() {
|
||||||
Connection conn = getConn();
|
Connection conn = getConn();
|
||||||
System.out.println(new Date());
|
System.out.println(new Date());
|
||||||
for (int i = 0; i < 800; i++) {
|
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'";
|
String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class TestJdbc26 {
|
|||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
Class.forName(driver); // classLoader,加载对应驱动
|
Class.forName(driver); // classLoader,加载对应驱动
|
||||||
conn = (Connection) DriverManager.getConnection(url, username, password);
|
conn = DriverManager.getConnection(url, username, password);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -27,20 +27,20 @@ public class TestJdbc26 {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
insertData();
|
insertData();
|
||||||
// updateData();
|
// updateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void insertData(){
|
private static void insertData() {
|
||||||
Connection conn = getConn();
|
Connection conn = getConn();
|
||||||
System.out.println(new Date());
|
System.out.println(new Date());
|
||||||
for (int i = 0; i > -1; i++) {
|
for (int i = 0; i > -1; i++) {
|
||||||
String cid = UUID.randomUUID().toString();
|
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');";
|
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;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
if(i%200 == 0){
|
if (i % 200 == 0) {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -50,14 +50,14 @@ public class TestJdbc26 {
|
|||||||
System.out.println(new Date());
|
System.out.println(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateData(){
|
private static void updateData() {
|
||||||
Connection conn = getConn();
|
Connection conn = getConn();
|
||||||
System.out.println(new Date());
|
System.out.println(new Date());
|
||||||
for (int i = 0; i < 800; i++) {
|
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'";
|
String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -80,10 +80,8 @@ public class TestReadFile {
|
|||||||
/**
|
/**
|
||||||
* * 二分查找算法 * *
|
* * 二分查找算法 * *
|
||||||
*
|
*
|
||||||
* @param srcArray
|
* @param srcArray 有序数组 *
|
||||||
* 有序数组 *
|
* @param des 查找元素 *
|
||||||
* @param des
|
|
||||||
* 查找元素 *
|
|
||||||
* @return des的数组下标,没找到返回-1
|
* @return des的数组下标,没找到返回-1
|
||||||
*/
|
*/
|
||||||
public static long binarySearch(Long[] srcArray, long des) {
|
public static long binarySearch(Long[] srcArray, long des) {
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package me.ehlxr.test;
|
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.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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 class TestSyncLogData {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
@@ -53,7 +52,7 @@ public class TestSyncLogData {
|
|||||||
HessianProxyFactory factory = new HessianProxyFactory();
|
HessianProxyFactory factory = new HessianProxyFactory();
|
||||||
IReadLogs readLogs = (IReadLogs) factory.create(IReadLogs.class, "http://localhost:8080/sync-logs/remote/readlogs");
|
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,
|
String results = readLogs.readFile(sdf.parse("2016-02-24 09"), sdf.parse("2016-02-24 10"), mapids,
|
||||||
"6692a223-2ae1-439a-93f4-09fb36e718ef",adxs);
|
"6692a223-2ae1-439a-93f4-09fb36e718ef", adxs);
|
||||||
System.out.println(results);
|
System.out.println(results);
|
||||||
JSONArray dataArr = new JSONArray();
|
JSONArray dataArr = new JSONArray();
|
||||||
dataArr = JSONArray.fromObject(results);
|
dataArr = JSONArray.fromObject(results);
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
package me.ehlxr.test;
|
package me.ehlxr.test;
|
||||||
|
|
||||||
|
import me.ehlxr.utils.HttpClientUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.ehlxr.utils.HttpClientUtil;
|
|
||||||
|
|
||||||
public class TestThread implements Runnable {
|
public class TestThread implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// HessianProxyFactory factory = new HessianProxyFactory();
|
// HessianProxyFactory factory = new HessianProxyFactory();
|
||||||
// IChargeCounter readLogs;
|
// IChargeCounter readLogs;
|
||||||
// for(int i=0;i<5;i++){
|
// for(int i=0;i<5;i++){
|
||||||
// try {
|
// try {
|
||||||
// readLogs = (IChargeCounter) factory.create(IChargeCounter.class, "http://localhost:8080/dsp-counter/remote/chargeCounter");
|
// readLogs = (IChargeCounter) factory.create(IChargeCounter.class, "http://localhost:8080/dsp-counter/remote/chargeCounter");
|
||||||
// readLogs.counterControlForThisSumResult("100003", 1, "m");
|
// readLogs.counterControlForThisSumResult("100003", 1, "m");
|
||||||
// //System.out.println(JedisUtil.getStr("dsp_counter_100003"));
|
// //System.out.println(JedisUtil.getStr("dsp_counter_100003"));
|
||||||
// break;
|
// break;
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// try {
|
// try {
|
||||||
// Thread.sleep(1000);
|
// Thread.sleep(1000);
|
||||||
// } catch (InterruptedException e1) {
|
// } catch (InterruptedException e1) {
|
||||||
// e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> postParam = new HashMap<String, String>();
|
Map<String, String> postParam = new HashMap<String, String>();
|
||||||
postParam.put("groupid", "100003");
|
postParam.put("groupid", "100003");
|
||||||
postParam.put("count", "1");
|
postParam.put("count", "1");
|
||||||
postParam.put("type", "m");
|
postParam.put("type", "m");
|
||||||
for(int i=0;i<5;i++){
|
for (int i = 0; i < 5; i++) {
|
||||||
try {
|
try {
|
||||||
HttpClientUtil.sendPostParam("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", postParam);
|
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");
|
// HttpClientUtil.sendPost("http://192.168.1.135:8080/dsp-counter/remote/chargeCounter/counterControlForThisSumResult", "groupid=100003&count=1&type=m");
|
||||||
break;
|
break;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
package me.ehlxr.test;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.zip.CRC32;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IntelliJ IDEA 14.0.1 注册机
|
|
||||||
*
|
|
||||||
* @author ehlxr
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class keygen {
|
|
||||||
/**
|
|
||||||
* @param s
|
|
||||||
* @param i
|
|
||||||
* @param bytes
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static short getCRC(String s, int i, byte bytes[]) {
|
|
||||||
CRC32 crc32 = new CRC32();
|
|
||||||
if (s != null) {
|
|
||||||
for (int j = 0; j < s.length(); j++) {
|
|
||||||
char c = s.charAt(j);
|
|
||||||
crc32.update(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
crc32.update(i);
|
|
||||||
crc32.update(i >> 8);
|
|
||||||
crc32.update(i >> 16);
|
|
||||||
crc32.update(i >> 24);
|
|
||||||
for (int k = 0; k < bytes.length - 2; k++) {
|
|
||||||
byte byte0 = bytes[k];
|
|
||||||
crc32.update(byte0);
|
|
||||||
}
|
|
||||||
return (short) (int) crc32.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param biginteger
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public static String encodeGroups(BigInteger biginteger) {
|
|
||||||
BigInteger beginner1 = BigInteger.valueOf(0x39aa400L);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0; biginteger.compareTo(BigInteger.ZERO) != 0; i++) {
|
|
||||||
int j = biginteger.mod(beginner1).intValue();
|
|
||||||
String s1 = encodeGroup(j);
|
|
||||||
if (i > 0) {
|
|
||||||
sb.append("-");
|
|
||||||
}
|
|
||||||
sb.append(s1);
|
|
||||||
biginteger = biginteger.divide(beginner1);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String encodeGroup(int i) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int j = 0; j < 5; j++) {
|
|
||||||
int k = i % 36;
|
|
||||||
char c;
|
|
||||||
if (k < 10) {
|
|
||||||
c = (char) (48 + k);
|
|
||||||
} else {
|
|
||||||
c = (char) ((65 + k) - 10);
|
|
||||||
}
|
|
||||||
sb.append(c);
|
|
||||||
i /= 36;
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* @param days
|
|
||||||
* @param id
|
|
||||||
* @param prtype
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String MakeKey(String name, int days, int id) {
|
|
||||||
id %= 100000;
|
|
||||||
byte bkey[] = new byte[12];
|
|
||||||
bkey[0] = (byte) 1; // Product type: IntelliJ IDEA is 1
|
|
||||||
bkey[1] = 14; // version
|
|
||||||
Date d = new Date();
|
|
||||||
long ld = (d.getTime() >> 16);
|
|
||||||
bkey[2] = (byte) (ld & 255);
|
|
||||||
bkey[3] = (byte) ((ld >> 8) & 255);
|
|
||||||
bkey[4] = (byte) ((ld >> 16) & 255);
|
|
||||||
bkey[5] = (byte) ((ld >> 24) & 255);
|
|
||||||
days &= 0xffff;
|
|
||||||
bkey[6] = (byte) (days & 255);
|
|
||||||
bkey[7] = (byte) ((days >> 8) & 255);
|
|
||||||
bkey[8] = 105;
|
|
||||||
bkey[9] = -59;
|
|
||||||
bkey[10] = 0;
|
|
||||||
bkey[11] = 0;
|
|
||||||
int w = getCRC(name, id % 100000, bkey);
|
|
||||||
bkey[10] = (byte) (w & 255);
|
|
||||||
bkey[11] = (byte) ((w >> 8) & 255);
|
|
||||||
BigInteger pow = new BigInteger("89126272330128007543578052027888001981", 10);
|
|
||||||
BigInteger mod = new BigInteger("86f71688cdd2612ca117d1f54bdae029", 16);
|
|
||||||
BigInteger k0 = new BigInteger(bkey);
|
|
||||||
BigInteger k1 = k0.modPow(pow, mod);
|
|
||||||
String s0 = Integer.toString(id);
|
|
||||||
String sz = "0";
|
|
||||||
while (s0.length() != 5) {
|
|
||||||
s0 = sz.concat(s0);
|
|
||||||
}
|
|
||||||
s0 = s0.concat("-");
|
|
||||||
String s1 = encodeGroups(k1);
|
|
||||||
s0 = s0.concat(s1);
|
|
||||||
return s0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Random r = new Random();
|
|
||||||
String userid = "elvin";
|
|
||||||
System.out.println(userid+":"+MakeKey(userid, 0, r.nextInt(100000)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,20 +9,16 @@ import org.bouncycastle.crypto.params.ParametersWithIV;
|
|||||||
import org.bouncycastle.util.encoders.Hex;
|
import org.bouncycastle.util.encoders.Hex;
|
||||||
/**
|
/**
|
||||||
* AES encryption and decryption tool.
|
* AES encryption and decryption tool.
|
||||||
*
|
|
||||||
* @author ben
|
|
||||||
* @creation 2014年3月20日
|
|
||||||
*/
|
*/
|
||||||
public class AESTool {
|
public class AESTool {
|
||||||
private static byte[] initVector = { 0x32, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31,
|
private static final byte[] initVector = {0x32, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31,
|
||||||
0x38, 0x27, 0x36, 0x35, 0x33, 0x23, 0x32, 0x31 };
|
0x38, 0x27, 0x36, 0x35, 0x33, 0x23, 0x32, 0x31};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt the content with a given key using aes algorithm.
|
* Encrypt the content with a given key using aes algorithm.
|
||||||
*
|
*
|
||||||
* @param content
|
* @param content
|
||||||
* @param key
|
* @param key must contain exactly 32 characters
|
||||||
* must contain exactly 32 characters
|
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ import java.util.Arrays;
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @version 2.2
|
|
||||||
* @author Mikael Grev Date: 2004-aug-02 Time: 11:31:11
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Base64 {
|
public class Base64 {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package me.ehlxr.utils;
|
package me.ehlxr.utils;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ehlxr on 2017/3/15.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ehlxr on 2017/3/15.
|
||||||
|
*/
|
||||||
public class MyUrlDemo {
|
public class MyUrlDemo {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
###author liuling
|
|
||||||
###token生成和校验相关配置
|
###token生成和校验相关配置
|
||||||
[tokenVersion<1>]
|
[tokenVersion<1>]=
|
||||||
###生成token时的密钥
|
###生成token时的密钥
|
||||||
create_token_key=QJ=*S:y^s0$!@#&*()%xZ~&U8($*_+r?
|
create_token_key=QJ=*S:y^s0$!@#&*()%xZ~&U8($*_+r?
|
||||||
###自校验时的密钥
|
###自校验时的密钥
|
||||||
check_token_key=QJs#!@%er!#E#$%^%@@!@=**I()^%?
|
check_token_key=QJs#!@%er!#E#$%^%@@!@=**I()^%?
|
||||||
###取MD5加密后的哪几位做为自校验位,共计4字节,32位。最大数字不能超过16
|
###取MD5加密后的哪几位做为自校验位,共计4字节,32位。最大数字不能超过16
|
||||||
check=1,4,6,7
|
check=1,4,6,7
|
||||||
|
[tokenVersion<2>]=
|
||||||
|
|
||||||
[tokenVersion<2>]
|
|
||||||
###生成token时的密钥
|
###生成token时的密钥
|
||||||
create_token_key=D#$%^@W#Rj8)@9o%&rgyYL_+!Ldcr5td
|
create_token_key=D#$%^@W#Rj8)@9o%&rgyYL_+!Ldcr5td
|
||||||
###自校验时的密钥
|
###自校验时的密钥
|
||||||
|
|||||||
Reference in New Issue
Block a user