Change-Id: I98d4f79a83a5fa612b3edd777f64d38d3e910ba8
This commit is contained in:
parent
b1c4e54d93
commit
5794fa2aef
17
pom.xml
17
pom.xml
@ -21,6 +21,11 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>1.46</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@ -175,12 +180,12 @@
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.38</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.38</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
<!-- 指定JDK编译版本 -->
|
||||
|
202
src/main/java/osc/git/eh3/pack/FileUtil.java
Normal file
202
src/main/java/osc/git/eh3/pack/FileUtil.java
Normal file
@ -0,0 +1,202 @@
|
||||
package osc.git.eh3.pack;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
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.util.Date;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class FileUtil {
|
||||
private static int sumError = 0;
|
||||
private static int sumExistError = 0;
|
||||
private static int sumNotFoundError = 0;
|
||||
private static int sumSuccess = 0;
|
||||
private static int sumNum = 1;
|
||||
|
||||
private static String getDate(Date date) {
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sd.format(date).toString();
|
||||
}
|
||||
|
||||
private static BufferedReader getBufferedReader(String path) throws FileNotFoundException {
|
||||
return new BufferedReader(new InputStreamReader(new FileInputStream(path)));
|
||||
}
|
||||
|
||||
public static void setInfo(String info, JFrame root) {
|
||||
sumError += 1;
|
||||
info.equals("");
|
||||
|
||||
Component[] components = root.getRootPane().getContentPane().getComponents();
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (components[i].getClass().toString().equals("class javax.swing.JScrollPane")) {
|
||||
JTextArea textarea = (JTextArea) ((JScrollPane) components[i]).getViewport().getView();
|
||||
if (info.equals("")) {
|
||||
sumError = 0;
|
||||
sumExistError = 0;
|
||||
sumNotFoundError = 0;
|
||||
sumSuccess = 0;
|
||||
sumNum = 1;
|
||||
textarea.setText("");
|
||||
} else if ((textarea.getText().equals("")) || (textarea.getText() == null)) {
|
||||
textarea.setText(sumNum + ". " + info);
|
||||
} else {
|
||||
textarea.setText(textarea.getText() + "\n" + sumNum + ". " + info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean copy(String from, String dirPath, JFrame root) {
|
||||
boolean isCommon = true;
|
||||
File fromFile = new File(from);
|
||||
if (!fromFile.exists()) {
|
||||
sumExistError += 1;
|
||||
setInfo(from + "-------未找到!", root);
|
||||
|
||||
System.out.println(from + "---------------未找到!");
|
||||
return false;
|
||||
}
|
||||
makeDirs(dirPath);
|
||||
try {
|
||||
File toFile = new File(dirPath + File.separatorChar + fromFile.getName());
|
||||
if (toFile.exists()) {
|
||||
sumNotFoundError += 1;
|
||||
int k = checkFileVersion(fromFile, toFile);
|
||||
if (k == -1) {
|
||||
setInfo(fromFile.getAbsolutePath() + "--输出失败(已存在!)", root);
|
||||
System.out.println(
|
||||
"文件版本在目标版本之前,处理为不覆盖!若要处理请人工处理!\n原文件:" + fromFile.getAbsolutePath() + "\n目标文件:" + toFile.getAbsolutePath());
|
||||
JOptionPane jp = new JOptionPane();
|
||||
jp.setBounds(new Rectangle(new Point(400, 400)));
|
||||
|
||||
int isYes = JOptionPane.showConfirmDialog(root, "发现相同的文件,文件版本在目标版本之前!是否要进行覆盖?\n当前文件:" +
|
||||
|
||||
fromFile.getAbsolutePath() + ",修改日期:" + getDate(new Date(fromFile.lastModified())) + "\n目标文件:"
|
||||
+ toFile.getAbsolutePath() + ",修改日期:" + getDate(new Date(toFile.lastModified())));
|
||||
if (isYes == 0) {
|
||||
isCommon = false;
|
||||
System.out.println("您选择了是!");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (k == 0) {
|
||||
setInfo(fromFile.getAbsolutePath() + "--输出失败(已存在)", root);
|
||||
System.out
|
||||
.println("相同文件重复,处理为不覆盖!若要处理请人工处理!\n原文件:" + fromFile.getAbsolutePath() + "\n目标文件:" + toFile.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
if (k == 1) {
|
||||
isCommon = false;
|
||||
}
|
||||
} else if (!toFile.exists()) {
|
||||
toFile.createNewFile();
|
||||
isCommon = false;
|
||||
}
|
||||
if (!isCommon) {
|
||||
InputStream is = new FileInputStream(fromFile);
|
||||
OutputStream out = new FileOutputStream(toFile);
|
||||
byte[] b = new byte[1024];
|
||||
int len = -1;
|
||||
while ((len = is.read(b)) != -1) {
|
||||
out.write(b, 0, len);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
is.close();
|
||||
toFile.setLastModified(fromFile.lastModified());
|
||||
sumSuccess += 1;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Copy Error!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void makeDirs(String path) {
|
||||
File f = new File(path);
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
private static int checkFileVersion(File file1, File file2) {
|
||||
long file1LastTime = file1.lastModified();
|
||||
long file2LastTime = file2.lastModified();
|
||||
if (file1LastTime > file2LastTime) {
|
||||
return 1;
|
||||
}
|
||||
if (file1LastTime < file2LastTime) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean becomePackage(String fileList, String cutStr, String dir, JFrame root) throws Exception {
|
||||
dir = dir + "\\";
|
||||
|
||||
String filePath = null;
|
||||
String addStr = null;
|
||||
String fromFile = null;
|
||||
String toFile = null;
|
||||
boolean flag = false;
|
||||
try {
|
||||
BufferedReader br = getBufferedReader(fileList);
|
||||
addStr = br.readLine();
|
||||
addStr = addStr.trim();
|
||||
setInfo("", root);
|
||||
while ((filePath = br.readLine()) != null) {
|
||||
sumNum += 1;
|
||||
if (!"".equals(filePath.trim())) {
|
||||
filePath = filePath.replaceAll("/", "\\\\");
|
||||
|
||||
System.out.println(filePath.replaceAll("\\\\", "/"));
|
||||
if (filePath.startsWith(cutStr)) {
|
||||
fromFile = filePath.trim();
|
||||
toFile = dir + addStr + File.separatorChar + getCenter(cutStr, fromFile);
|
||||
flag = copy(fromFile, toFile, root);
|
||||
} else {
|
||||
fromFile = cutStr + File.separatorChar + filePath.trim();
|
||||
toFile = dir + addStr + File.separatorChar + filePath.substring(0, filePath.trim().lastIndexOf("\\"));
|
||||
|
||||
flag = copy(fromFile, toFile, root);
|
||||
}
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
setInfo("----成功:" + sumSuccess + "\n" + "----失败:" + sumError + "\n" + "--------未找到:" + sumNotFoundError + "\n" + "--------已存在:"
|
||||
+ sumExistError, root);
|
||||
return flag;
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("列表文件没有找到!");
|
||||
throw new Exception("列表文件没有找到!");
|
||||
} catch (IOException e) {
|
||||
System.out.println("列表文件读取出错!");
|
||||
throw new Exception("列表文件读取出错!");
|
||||
}
|
||||
}
|
||||
|
||||
private static String getCenter(String flag, String message) {
|
||||
int k1 = message.trim().indexOf(flag);
|
||||
int k2 = message.trim().lastIndexOf("\\");
|
||||
if ((k1 != -1) && (k2 != -1)) {
|
||||
return message.substring(flag.length() + 1, k2 + 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
270
src/main/java/osc/git/eh3/pack/PackView.java
Normal file
270
src/main/java/osc/git/eh3/pack/PackView.java
Normal file
@ -0,0 +1,270 @@
|
||||
package osc.git.eh3.pack;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
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")
|
||||
public class PackView extends JFrame {
|
||||
private JButton jb = new JButton();
|
||||
private JButton jb1 = new JButton();
|
||||
private JButton jb2 = new JButton();
|
||||
private String inputPath = "D:\\wins-dsp";
|
||||
private String outputPath = "D:";
|
||||
private JLabel jl0 = new JLabel();
|
||||
private JButton cancel = new JButton("退出");
|
||||
private JTextPane jText1 = new JTextPane();
|
||||
private JTextPane jText2 = new JTextPane();
|
||||
public JTextArea jArea = new JTextArea();
|
||||
public JScrollPane p = new JScrollPane(this.jArea);
|
||||
|
||||
private PackView() {
|
||||
setTitle("打包工具(By:Henry)");
|
||||
setBounds(400, 400, 500, 300);
|
||||
setLayout(null);
|
||||
setResizable(false);
|
||||
this.jb.setText("打包清单");
|
||||
this.jb1.setText("打包根目录");
|
||||
this.jb2.setText("输出目录");
|
||||
|
||||
this.jText1.setText(this.inputPath);
|
||||
this.jText2.setText(this.outputPath);
|
||||
|
||||
this.jb.addMouseListener(new MouseListener() {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (PackView.this.packs()) {
|
||||
PackView.this.jl0.setText("成功打包!");
|
||||
PackView.this.jb.setText("...继续");
|
||||
} else {
|
||||
PackView.this.jl0.setText("打包失败!");
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
this.jb1.addMouseListener(new MouseListener() {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
PackView.this.choosePath(1);
|
||||
PackView.this.jText1.setText(PackView.this.inputPath);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
this.jb2.addMouseListener(new MouseListener() {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
PackView.this.choosePath(2);
|
||||
PackView.this.jText2.setText(PackView.this.outputPath);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
this.cancel.addMouseListener(new MouseListener() {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
PackView.this.close();
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
this.jb1.setBounds(10, 5, 100, 30);
|
||||
this.jText1.setBounds(120, 5, 250, 30);
|
||||
|
||||
this.jb2.setBounds(10, 40, 100, 30);
|
||||
this.jText2.setBounds(120, 40, 250, 30);
|
||||
|
||||
this.jb.setBounds(10, 100, 100, 30);
|
||||
this.cancel.setBounds(120, 100, 100, 30);
|
||||
this.jl0.setBounds(230, 100, 100, 30);
|
||||
this.jArea.setLineWrap(true);
|
||||
this.jArea.setForeground(Color.red);
|
||||
this.jArea.setEditable(false);
|
||||
|
||||
this.p.setBounds(10, 130, 480, 130);
|
||||
|
||||
this.p.setVerticalScrollBarPolicy(22);
|
||||
this.p.setHorizontalScrollBarPolicy(32);
|
||||
|
||||
add(this.jb1);
|
||||
add(this.jText1);
|
||||
add(this.jb2);
|
||||
add(this.jText2);
|
||||
add(this.jb);
|
||||
add(this.cancel);
|
||||
add(this.jl0);
|
||||
|
||||
add(this.p);
|
||||
setVisible(true);
|
||||
setDefaultCloseOperation(3);
|
||||
}
|
||||
|
||||
private List<String> chooseFile(int chooseMode) {
|
||||
try {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
fileChooser.setMultiSelectionEnabled(true);
|
||||
fileChooser.setDialogTitle("文件打包");
|
||||
fileChooser.setDragEnabled(true);
|
||||
fileChooser.setAutoscrolls(true);
|
||||
|
||||
fileChooser.setFileFilter(new FileFilter() {
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
if ((f.getName().endsWith(".TXT")) || (f.getName().endsWith(".txt"))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return ".txt";
|
||||
}
|
||||
});
|
||||
fileChooser.setCurrentDirectory(FileSystemView.getFileSystemView().getHomeDirectory());
|
||||
|
||||
fileChooser.setOpaque(true);
|
||||
fileChooser.setDoubleBuffered(true);
|
||||
int returnVal = -1;
|
||||
switch (chooseMode) {
|
||||
case 1:
|
||||
returnVal = fileChooser.showOpenDialog(this);
|
||||
break;
|
||||
case 2:
|
||||
returnVal = fileChooser.showSaveDialog(this);
|
||||
}
|
||||
File[] fileName;
|
||||
if (returnVal == 0) {
|
||||
fileName = fileChooser.getSelectedFiles();
|
||||
} else {
|
||||
fileName = (File[]) null;
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
System.out.println("打包文件路径列表:");
|
||||
String filePath = null;
|
||||
for (int i = 0; i < fileName.length; i++) {
|
||||
filePath = fileName[i].getAbsolutePath();
|
||||
if (filePath.toUpperCase().endsWith("TXT")) {
|
||||
list.add(filePath);
|
||||
System.out.println("序号 " + i + " " + filePath);
|
||||
} else {
|
||||
System.out.println("序号 " + i + " " + filePath + " >>该文件不能作为打包文件! ");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean choosePath(int id) {
|
||||
try {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
fileChooser.setMultiSelectionEnabled(true);
|
||||
switch (id) {
|
||||
case 1:
|
||||
fileChooser.setDialogTitle("打包文件根目录");
|
||||
fileChooser.setCurrentDirectory(new File(this.inputPath));
|
||||
break;
|
||||
case 2:
|
||||
fileChooser.setDialogTitle("输出文件目录");
|
||||
fileChooser.setCurrentDirectory(new File(this.outputPath));
|
||||
}
|
||||
fileChooser.setDragEnabled(true);
|
||||
fileChooser.setAutoscrolls(true);
|
||||
fileChooser.setAcceptAllFileFilterUsed(true);
|
||||
fileChooser.setOpaque(true);
|
||||
fileChooser.setDoubleBuffered(true);
|
||||
fileChooser.setFileSelectionMode(1);
|
||||
|
||||
fileChooser.showOpenDialog(this);
|
||||
switch (id) {
|
||||
case 1:
|
||||
this.inputPath = fileChooser.getSelectedFile().toString();
|
||||
break;
|
||||
case 2:
|
||||
this.outputPath = fileChooser.getSelectedFile().toString();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void close() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
private boolean packs() {
|
||||
boolean flag = true;
|
||||
List<String> fileName = chooseFile(1);
|
||||
if ((fileName == null) || (fileName.size() <= 0)) {
|
||||
System.out.println("打包原始文件没有找到");
|
||||
flag = false;
|
||||
} else {
|
||||
for (int i = 0; i < fileName.size(); i++) {
|
||||
try {
|
||||
flag = FileUtil.becomePackage((String) fileName.get(i), this.inputPath, this.outputPath, this);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new PackView();
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ redis.pool.maxIdle=200
|
||||
redis.pool.maxWait=1000
|
||||
redis.pool.testOnBorrow=true
|
||||
redis.pool.testOnReturn=true
|
||||
#redis.ip=192.168.3.166
|
||||
redis.ip=111.235.158.31
|
||||
redis.ip=192.168.3.166
|
||||
#redis.ip=111.235.158.31
|
||||
redis.port=7379
|
||||
redis.password=
|
@ -0,0 +1,77 @@
|
||||
package osc.git.eh3.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import osc.git.eh3.redis.JedisUtil;
|
||||
|
||||
public class OperateKPIBudgetRedisData {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
showSom("022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
// delete("c46b8885-4c1d-48f9-befb-3ba3a0f33d4a");
|
||||
}
|
||||
|
||||
public static void showSom(String groupid){
|
||||
String[] keys = JedisUtil.getKeys("dsp_budget_*_"+groupid);
|
||||
BigDecimal totals = new BigDecimal(0);
|
||||
for (String key : keys) {
|
||||
System.out.println(key+"-----------:"+JedisUtil.getStr(key));
|
||||
totals = totals.add(new BigDecimal(JedisUtil.getStr(key)));
|
||||
}
|
||||
System.out.println("budget_balance_"+groupid+"----------:"+JedisUtil.getStr("budget_balance_"+groupid));
|
||||
totals = totals.add(new BigDecimal(JedisUtil.getStr("budget_balance_"+groupid)));
|
||||
System.out.println("-------------------------------------------------------------:"+totals.toPlainString());
|
||||
System.out.println();
|
||||
|
||||
totals = new BigDecimal(0);
|
||||
keys = JedisUtil.getKeys("dsp_counter_*_"+groupid);
|
||||
for (String key : keys) {
|
||||
System.out.println(key+"-----------:"+JedisUtil.getStr(key));
|
||||
String[] split = JedisUtil.getStr(key).split(",");
|
||||
if(split.length>1){
|
||||
totals = totals.add(new BigDecimal(split[1]));
|
||||
}else{
|
||||
totals = totals.add(new BigDecimal(split[0]));
|
||||
}
|
||||
}
|
||||
System.out.println("counter_balance_"+groupid+"---------:"+JedisUtil.getStr("counter_balance_"+groupid));
|
||||
String[] split = JedisUtil.getStr("counter_balance_"+groupid).split(",");
|
||||
if(split.length>1){
|
||||
totals = totals.add(new BigDecimal(split[1]));
|
||||
}else{
|
||||
totals = totals.add(new BigDecimal(split[0]));
|
||||
}
|
||||
System.out.println("-------------------------------------------------------------:"+totals.toPlainString());
|
||||
}
|
||||
|
||||
|
||||
public static void delete(String groupid){
|
||||
|
||||
|
||||
String[] keys ={"d012aa41-35b8-4ef9-a3ee-9bc918d0da82",
|
||||
"f26701ea-3bfc-4b4f-ae88-f39bff59c77c",
|
||||
"a4e14ee1-1ae3-4e04-8850-c1345c5af200",
|
||||
"d3ca7a1a-7a8d-4e43-be28-46f450a84d99",
|
||||
"f9fdd963-558c-4d5a-b18f-c7d8386fac2d",
|
||||
"a4dbe6b6-bd69-4bab-aa84-d5459860ad7b",
|
||||
"6d3508d8-c978-4446-ba4c-895196af5021",
|
||||
"033d5820-2ca8-4304-87ab-aaad6a0d0652",
|
||||
"b4572eae-3f4f-46e2-95be-78ec3cb47b75",
|
||||
"8c6f32fc-450d-4912-a7e3-7bbc7e4341a9",
|
||||
"7275405b-b12d-4f8b-95a4-7274cbf3f942",
|
||||
"6f1d947b-bc03-4560-b3ff-1200725f352c",
|
||||
"52a9558d-bada-4e2b-8e71-d83ee40e804f",
|
||||
"92b8bd98-6698-48b7-b402-5ccf49e9c674",
|
||||
"b605daa7-6a85-40dc-8c5e-d9022e8fc3d2",
|
||||
"853aad03-a2f5-4665-aaac-26aadd42be84",
|
||||
"5f3668bf-ebb9-4db7-ac29-62216fd86f2d"};
|
||||
|
||||
for (String key : keys) {
|
||||
JedisUtil.delete("dsp_mapid_"+key);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -8,6 +8,9 @@ import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import osc.git.eh3.utils.AESTool;
|
||||
import osc.git.eh3.utils.Base64;
|
||||
|
||||
public class TestCode {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@ -169,12 +172,12 @@ public class TestCode {
|
||||
// System.out.println(Integer.valueOf("11", 2));
|
||||
|
||||
|
||||
// System.out.println(AESEncrypter.encrypt("lixiangrong"));
|
||||
// System.out.println(AESEncrypter.decrypt(AESEncrypter.encrypt("lixiangrong")));
|
||||
// System.out.println(AESTool.encrypt("lixiangrong"));
|
||||
// System.out.println(AESTool.decrypt(AESEncrypter.encrypt("lixiangrong")));
|
||||
|
||||
// System.out.println(AESEncrypter.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202"));
|
||||
// System.out.println(AESEncrypter.decrypt(AESEncrypter.encrypt("lixiangrong","0"),"0"));
|
||||
// System.out.println(Base64.encodeToString(AESEncrypter.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 = "lixiangrong".getBytes();
|
||||
// for (int i = 0; i < bytes.length; i++) {
|
||||
@ -232,15 +235,15 @@ public class TestCode {
|
||||
// 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());
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
||||
public class TestJdbc143 {
|
||||
private static Connection getConn() {
|
||||
String driver = "com.mysql.jdbc.Driver";
|
||||
String url = "jdbc:mysql://115.182.33.143:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
|
||||
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;
|
||||
@ -33,8 +33,9 @@ public class TestJdbc143 {
|
||||
private static void insertData(){
|
||||
Connection conn = getConn();
|
||||
System.out.println(new Date());
|
||||
for (int i = 0; i > -1; i++) {
|
||||
String cid = UUID.randomUUID().toString();
|
||||
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 {
|
||||
|
@ -1,32 +0,0 @@
|
||||
package osc.git.eh3.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import osc.git.eh3.redis.JedisUtil;
|
||||
|
||||
public class TestRedisData {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
showSom("b8093670-ceb0-4c1d-9413-8bb23a1217f2");
|
||||
}
|
||||
|
||||
public static void showSom(String groupid){
|
||||
String[] keys = JedisUtil.getKeys("dsp_budget_*_"+groupid);
|
||||
BigDecimal totals = new BigDecimal(0);
|
||||
for (String key : keys) {
|
||||
System.out.println(key+"-----------:"+JedisUtil.getStr(key));
|
||||
totals = totals.add(new BigDecimal(JedisUtil.getStr(key)));
|
||||
}
|
||||
System.out.println("budget_balance_"+groupid+"-----------:"+JedisUtil.getStr("budget_balance_"+groupid));
|
||||
totals = totals.add(new BigDecimal(JedisUtil.getStr("budget_balance_"+groupid)));
|
||||
System.out.println(totals.toPlainString());
|
||||
|
||||
keys = JedisUtil.getKeys("dsp_counter_*_"+groupid);
|
||||
for (String key : keys) {
|
||||
System.out.println(key+"-----------:"+JedisUtil.getStr(key));
|
||||
}
|
||||
System.out.println("counter_balance_"+groupid+"-----------:"+JedisUtil.getStr("counter_balance_"+groupid));
|
||||
}
|
||||
}
|
127
src/main/java/osc/git/eh3/test/keygen.java
Normal file
127
src/main/java/osc/git/eh3/test/keygen.java
Normal file
@ -0,0 +1,127 @@
|
||||
package osc.git.eh3.test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
/**
|
||||
* IntelliJ IDEA 14.0.1 注册机
|
||||
*
|
||||
* @author lixiangrong
|
||||
*
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
}
|
146
src/main/java/osc/git/eh3/testopen/SignatureUtil.java
Normal file
146
src/main/java/osc/git/eh3/testopen/SignatureUtil.java
Normal file
@ -0,0 +1,146 @@
|
||||
package osc.git.eh3.testopen;
|
||||
|
||||
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* 签名工具类
|
||||
*
|
||||
*/
|
||||
public class SignatureUtil {
|
||||
|
||||
|
||||
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
private static String encryptionAlgorithm = "SHA-1";
|
||||
|
||||
public static String bytesToHexString(byte[] bytes) {
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
for (int j = 0; j < bytes.length; j++) {
|
||||
int v = bytes[j] & 0xFF;
|
||||
hexChars[j * 2] = hexArray[v >>> 4];
|
||||
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
||||
}
|
||||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static byte[] hexStringToBytes(String s) {
|
||||
int len = s.length();
|
||||
byte[] data = new byte[len / 2];
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用指定算法生成消息摘要,默认是md5
|
||||
*
|
||||
* @param strSrc
|
||||
* , a string will be encrypted; <br/>
|
||||
* @param encName
|
||||
* , the algorithm name will be used, dafault to "MD5"; <br/>
|
||||
* @return
|
||||
*/
|
||||
public static String digest(String strSrc, String encName) {
|
||||
MessageDigest md = null;
|
||||
String strDes = null;
|
||||
byte[] bt = strSrc.getBytes();
|
||||
try {
|
||||
if (encName == null || encName.equals("")) {
|
||||
encName = "MD5";
|
||||
}
|
||||
md = MessageDigest.getInstance(encName);
|
||||
md.update(bt);
|
||||
strDes = bytesToHexString(md.digest()); // to HexString
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return null;
|
||||
}
|
||||
return strDes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据appid、token、lol以及时间戳来生成签名
|
||||
*
|
||||
* @param appid
|
||||
* @param token
|
||||
* @param lol
|
||||
* @param millis
|
||||
* @return
|
||||
*/
|
||||
public static String generateSignature(String appid, String token, String lol, long millis) {
|
||||
String timestamp = String.valueOf(millis);
|
||||
String signature = null;
|
||||
if (StringUtils.isNotBlank(token) && StringUtils.isNotBlank(timestamp) && StringUtils.isNotBlank(appid)) {
|
||||
List<String> srcList = new ArrayList<String>();
|
||||
srcList.add(timestamp);
|
||||
srcList.add(appid);
|
||||
srcList.add(token);
|
||||
srcList.add(lol);
|
||||
// 按照字典序逆序拼接参数
|
||||
Collections.sort(srcList);
|
||||
Collections.reverse(srcList);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
sb.append(srcList.get(i));
|
||||
}
|
||||
signature = digest(sb.toString(), encryptionAlgorithm);
|
||||
srcList.clear();
|
||||
srcList = null;
|
||||
}
|
||||
return signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证签名: <br/>
|
||||
* 1.根据appid获取该渠道的token;<br/>
|
||||
* 2.根据appid、token、lol以及时间戳计算一次签名;<br/>
|
||||
* 3.比较传过来的签名以及计算出的签名是否一致;
|
||||
*
|
||||
* @param signature
|
||||
* @param appid
|
||||
* @param lol
|
||||
* @param millis
|
||||
* @return
|
||||
*/
|
||||
public static boolean isValid(String signature, String appid,String token, String lol, long millis) {
|
||||
String calculatedSignature = generateSignature(appid, token, lol, millis);
|
||||
if (StringUtils.equals(calculatedSignature, signature)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String xmlString = "<root><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name><name>test</name></root>";
|
||||
System.out.println(xmlString.getBytes().length);
|
||||
|
||||
//消息
|
||||
String digest = SignatureUtil.digest(xmlString, "MD5");
|
||||
System.out.println("----" + digest);
|
||||
System.out.println(digest.getBytes().length);
|
||||
|
||||
|
||||
String appid = "canairport001";
|
||||
String token = "111ddff";
|
||||
long millis = System.currentTimeMillis();
|
||||
|
||||
//生成签名
|
||||
String signature = SignatureUtil.generateSignature(appid, token, digest, millis);
|
||||
|
||||
System.out.println(signature);
|
||||
|
||||
//验证签名
|
||||
boolean isValid = SignatureUtil.isValid(signature, appid,token, digest, millis);
|
||||
System.out.println(isValid);
|
||||
}
|
||||
}
|
232
src/main/java/osc/git/eh3/testopen/TestOpenPuton.java
Normal file
232
src/main/java/osc/git/eh3/testopen/TestOpenPuton.java
Normal file
@ -0,0 +1,232 @@
|
||||
package osc.git.eh3.testopen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import osc.git.eh3.utils.AESTool;
|
||||
import osc.git.eh3.utils.Base64;
|
||||
import osc.git.eh3.utils.HttpClientUtil;
|
||||
|
||||
public class TestOpenPuton {
|
||||
public static String URL = "http://127.0.0.1:3/dsp-open/opendsp.do";
|
||||
private static String key = "adjdjfjfjfjdkdkd";//
|
||||
private static String appid = "t123456";// 用户
|
||||
private static String token = "cst123456";// 令牌
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
String sendPostParam = HttpClientUtil.sendPostParam(URL, getPostParam("getKpiByCampaignIds"));// 获得数据并且发送请求
|
||||
String data = getData(sendPostParam);
|
||||
System.out.println(JSONObject.fromObject(data));
|
||||
}
|
||||
|
||||
// 解密
|
||||
public static String getData(String encryptString) throws Exception {
|
||||
byte[] decode = Base64.decode(encryptString.getBytes());
|
||||
String aString = new String(decode, "utf-8");
|
||||
String decrypt = AESTool.decrypt(aString, key);
|
||||
return decrypt;
|
||||
}
|
||||
|
||||
public static Map<String, String> getPostParam(String content) throws Exception {
|
||||
Map<String, String> postParam = new HashMap<String, String>();
|
||||
content = getContent(content);
|
||||
|
||||
// 业务数据
|
||||
long millis = System.currentTimeMillis();// 时间戳j
|
||||
content = AESTool.encrypt(content, key);// 使用aes加密
|
||||
String lol = SignatureUtil.digest(content, "MD5");// 摘要
|
||||
String signature = SignatureUtil.generateSignature(appid, token, lol, millis);// 签名
|
||||
|
||||
// 准备提交数据
|
||||
postParam.put("appid", appid);
|
||||
postParam.put("content", content);
|
||||
postParam.put("lol", lol);
|
||||
postParam.put("signature", signature);
|
||||
postParam.put("millis", millis + "");
|
||||
|
||||
return postParam;
|
||||
}
|
||||
|
||||
// 在这里写请求数据
|
||||
public static String getContent(String contentName) {
|
||||
JSONObject content = new JSONObject();
|
||||
JSONObject param = new JSONObject();
|
||||
content.put("servicename", "putonServiceCall");
|
||||
|
||||
switch (contentName) {
|
||||
case "putOnByCreative":
|
||||
param.put("campaignid", "26861f62-5cd7-4073-9186-676f8f5d7b24");
|
||||
param.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
param.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
|
||||
|
||||
JSONArray mapIds = new JSONArray();
|
||||
mapIds.add("28f13909-dbbe-42e4-b9fd-edd97a31d6ce");
|
||||
mapIds.add("8b7b1b4a-eb3a-4be0-809b-b497c58a14f6");
|
||||
mapIds.add("b7f39e0c-3025-4fa3-8e83-ef1f492fe358");
|
||||
param.put("mapids", mapIds);
|
||||
|
||||
content.put("funcname", "putOnByCreative");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "pauseByCreative":
|
||||
param.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
param.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
|
||||
|
||||
mapIds = new JSONArray();
|
||||
mapIds.add("28f13909-dbbe-42e4-b9fd-edd97a31d6ce");
|
||||
mapIds.add("8b7b1b4a-eb3a-4be0-809b-b497c58a14f6");
|
||||
mapIds.add("b7f39e0c-3025-4fa3-8e83-ef1f492fe358");
|
||||
param.put("mapids", mapIds);
|
||||
|
||||
content.put("funcname", "pauseByCreative");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "putOnByAdx":
|
||||
param.put("campaignid", "26861f62-5cd7-4073-9186-676f8f5d7b24");
|
||||
|
||||
JSONArray groupAdxs = new JSONArray();
|
||||
JSONObject groupAdx = new JSONObject();
|
||||
groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
groupAdx.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
|
||||
groupAdxs.add(groupAdx);
|
||||
groupAdx = new JSONObject();
|
||||
groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
groupAdx.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa");
|
||||
groupAdxs.add(groupAdx);
|
||||
groupAdx = new JSONObject();
|
||||
groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
groupAdx.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92");
|
||||
groupAdxs.add(groupAdx);
|
||||
|
||||
param.put("groupadxs", groupAdxs);
|
||||
|
||||
content.put("funcname", "putOnByAdx");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "pauseByAdx":
|
||||
groupAdxs = new JSONArray();
|
||||
groupAdx = new JSONObject();
|
||||
groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
groupAdx.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
|
||||
groupAdxs.add(groupAdx);
|
||||
groupAdx = new JSONObject();
|
||||
groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
groupAdx.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa");
|
||||
groupAdxs.add(groupAdx);
|
||||
groupAdx = new JSONObject();
|
||||
groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
groupAdx.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92");
|
||||
groupAdxs.add(groupAdx);
|
||||
|
||||
param.put("groupadxs", groupAdxs);
|
||||
|
||||
content.put("funcname", "pauseByAdx");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "putOnByGroup":
|
||||
param.put("campaignid", "26861f62-5cd7-4073-9186-676f8f5d7b24");
|
||||
|
||||
JSONArray groupids = new JSONArray();
|
||||
groupids.add("022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
param.put("groupids", groupids);
|
||||
|
||||
content.put("funcname", "putOnByGroup");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "pauseByGroup":
|
||||
groupids = new JSONArray();
|
||||
groupids.add("022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
param.put("groupids", groupids);
|
||||
|
||||
content.put("funcname", "pauseByGroup");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "putOnByCampaign":
|
||||
JSONArray campaignids = new JSONArray();
|
||||
campaignids.add("26861f62-5cd7-4073-9186-676f8f5d7b24");
|
||||
param.put("campaignids", campaignids);
|
||||
|
||||
content.put("funcname", "putOnByCampaign");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "pauseByCampaign":
|
||||
campaignids = new JSONArray();
|
||||
campaignids.add("26861f62-5cd7-4073-9186-676f8f5d7b24");
|
||||
param.put("campaignids", campaignids);
|
||||
|
||||
content.put("funcname", "pauseByCampaign");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "setAdxProp":
|
||||
JSONArray propdatas = new JSONArray();
|
||||
JSONObject propdata = new JSONObject();
|
||||
JSONObject adxprop = new JSONObject();
|
||||
JSONArray adxprops = new JSONArray();
|
||||
|
||||
adxprop.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
|
||||
adxprop.put("prop", 40);
|
||||
adxprops.add(adxprop);
|
||||
|
||||
adxprop = new JSONObject();
|
||||
adxprop.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa");
|
||||
adxprop.put("prop", 30);
|
||||
adxprops.add(adxprop);
|
||||
|
||||
adxprop = new JSONObject();
|
||||
adxprop.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92");
|
||||
adxprop.put("prop", 30);
|
||||
adxprops.add(adxprop);
|
||||
|
||||
propdata.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
propdata.put("adxprops", adxprops);
|
||||
|
||||
propdatas.add(propdata);
|
||||
|
||||
param.put("propdatas", propdatas);
|
||||
content.put("funcname", "setAdxProp");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "setCreateivePrice":
|
||||
JSONArray createiveprices = new JSONArray();
|
||||
|
||||
JSONObject createiveprice = new JSONObject();
|
||||
createiveprice.put("mapid", "28f13909-dbbe-42e4-b9fd-edd97a31d6ce");
|
||||
createiveprice.put("price", 10);
|
||||
createiveprices.add(createiveprice);
|
||||
|
||||
createiveprice = new JSONObject();
|
||||
createiveprice.put("mapid", "8b7b1b4a-eb3a-4be0-809b-b497c58a14f6");
|
||||
createiveprice.put("price", 6);
|
||||
createiveprices.add(createiveprice);
|
||||
|
||||
createiveprice = new JSONObject();
|
||||
createiveprice.put("mapid", "b7f39e0c-3025-4fa3-8e83-ef1f492fe358");
|
||||
createiveprice.put("price", 8);
|
||||
createiveprices.add(createiveprice);
|
||||
|
||||
param.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
|
||||
param.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
|
||||
param.put("createiveprices", createiveprices);
|
||||
|
||||
content.put("funcname", "setCreateivePrice");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
case "getKpiByCampaignIds":
|
||||
campaignids = new JSONArray();
|
||||
campaignids.add("26861f62-5cd7-4073-9186-676f8f5d7b24");
|
||||
|
||||
param.put("campaignids", campaignids);
|
||||
|
||||
content.put("funcname", "getKpiByCampaignIds");
|
||||
content.put("methodparam", param);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
System.out.println(content.toString());
|
||||
return content.toString();
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
package osc.git.eh3.utils;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
|
||||
public class AESEncrypter {
|
||||
|
||||
private static byte[] iv = new byte[] { 21, 22, 50, 44, -16, 124, -40, -114, -11, -40, 37, 23, -33, 23, -33, 75 };
|
||||
private static String defalut_key = "defalut_keydefalut_key";
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*
|
||||
* @param content
|
||||
* 要加密的内容
|
||||
* @return 加密后的32位字符串
|
||||
*/
|
||||
public static String encrypt(String content) {
|
||||
return encrypt(content, defalut_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param content
|
||||
* AES密文
|
||||
* @return 解密后的内容
|
||||
*/
|
||||
public static String decrypt(String content) {
|
||||
return decrypt(content, defalut_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*
|
||||
* @param content
|
||||
* 要加密的内容
|
||||
* @param key
|
||||
* 秘钥
|
||||
* @return 加密后的32位字符串
|
||||
*/
|
||||
public static String encrypt(String content, String key) {
|
||||
String str = "";
|
||||
try {
|
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
||||
kgen.init(128, new SecureRandom(key.getBytes()));
|
||||
AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
|
||||
SecretKey skey = kgen.generateKey();
|
||||
Cipher ecipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
ecipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec);
|
||||
str = asHex(ecipher.doFinal(content.getBytes()));
|
||||
} catch (BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param content
|
||||
* AES密文
|
||||
* @param key
|
||||
* 秘钥
|
||||
* @return 解密后的内容
|
||||
*/
|
||||
public static String decrypt(String content, String key) {
|
||||
try {
|
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
||||
kgen.init(128, new SecureRandom(key.getBytes()));
|
||||
AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
|
||||
SecretKey skey = kgen.generateKey();
|
||||
Cipher dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
dcipher.init(Cipher.DECRYPT_MODE, skey, paramSpec);
|
||||
return new String(dcipher.doFinal(asBin(content)));
|
||||
} catch (BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String asHex(byte buf[]) {
|
||||
StringBuffer strbuf = new StringBuffer(buf.length * 2);
|
||||
int i;
|
||||
for (i = 0; i < buf.length; i++) {
|
||||
if (((int) buf[i] & 0xff) < 0x10)
|
||||
strbuf.append("0");
|
||||
strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
|
||||
}
|
||||
return strbuf.toString();
|
||||
}
|
||||
|
||||
private static byte[] asBin(String src) {
|
||||
if (src.length() < 1)
|
||||
return null;
|
||||
byte[] encrypted = new byte[src.length() / 2];
|
||||
for (int i = 0; i < src.length() / 2; i++) {
|
||||
int high = Integer.parseInt(src.substring(i * 2, i * 2 + 1), 16);
|
||||
int low = Integer.parseInt(src.substring(i * 2 + 1, i * 2 + 2), 16);
|
||||
|
||||
encrypted[i] = (byte) (high * 16 + low);
|
||||
}
|
||||
return encrypted;
|
||||
}
|
||||
}
|
150
src/main/java/osc/git/eh3/utils/AESTool.java
Normal file
150
src/main/java/osc/git/eh3/utils/AESTool.java
Normal file
File diff suppressed because one or more lines are too long
@ -42,7 +42,7 @@ import org.apache.http.protocol.HttpContext;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HttpClientUtil {
|
||||
private static Log log = LogFactory.getLog(HttpClientUtil.class);
|
||||
private static final int timeOut = 30000;// timeOut(Millisecond)
|
||||
private static final int timeOut = 300000;// timeOut(Millisecond)
|
||||
private static final int BUFFERSIZE = 2048;
|
||||
|
||||
private static Registry<CookieSpecProvider> getRegistry() {
|
||||
|
@ -24,6 +24,6 @@
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</javaClientGenerator>
|
||||
|
||||
<table tableName="dsp_t_geohash_precision" domainObjectName="GeohashPrecisionModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>
|
||||
<table tableName="dsp_t_statis_by_hour" domainObjectName="StatisByHourModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
Loading…
Reference in New Issue
Block a user