Change-Id: Ia06c191d9d7c5bcd40a4a9432929b3332dd11003

This commit is contained in:
lixiangrong 2016-04-15 18:43:56 +08:00
parent dc89382c10
commit c4aaf701ec
4 changed files with 55 additions and 12 deletions

View File

@ -23,7 +23,7 @@ public class PackView extends JFrame {
private JButton jb1 = new JButton(); private JButton jb1 = new JButton();
private JButton jb2 = new JButton(); private JButton jb2 = new JButton();
private String inputPath = "D:\\wins-dsp"; private String inputPath = "D:\\wins-dsp";
private String outputPath = "D:"; private String outputPath = "C:\\Users\\lixiangrong\\Desktop";
private JLabel jl0 = new JLabel(); private JLabel jl0 = new JLabel();
private JButton cancel = new JButton("退出"); private JButton cancel = new JButton("退出");
private JTextPane jText1 = new JTextPane(); private JTextPane jText1 = new JTextPane();

View File

@ -7,6 +7,7 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern;
import osc.git.eh3.utils.AESTool; import osc.git.eh3.utils.AESTool;
import osc.git.eh3.utils.Base64; import osc.git.eh3.utils.Base64;
@ -175,8 +176,8 @@ public class TestCode {
// System.out.println(AESTool.encrypt("lixiangrong")); // System.out.println(AESTool.encrypt("lixiangrong"));
// System.out.println(AESTool.decrypt(AESEncrypter.encrypt("lixiangrong"))); // System.out.println(AESTool.decrypt(AESEncrypter.encrypt("lixiangrong")));
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 = "lixiangrong".getBytes(); // byte[] bytes = "lixiangrong".getBytes();
@ -245,6 +246,9 @@ public class TestCode {
// } // }
// System.out.println(budget.doubleValue()); // System.out.println(budget.doubleValue());
String REG_FLOAT = "^[1-9]\\d*.?\\d+$"; // 浮点正数
System.out.println(Pattern.compile(REG_FLOAT).matcher("1.21").matches());
} }
public static Long parseDate(String s) { public static Long parseDate(String s) {

View File

@ -17,12 +17,16 @@ public class TestOpenPuton {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String sendPostParam = HttpClientUtil.sendPostParam(URL, getPostParam("getKpiByCampaignIds"));// 获得数据并且发送请求 // String sendPostParam = HttpClientUtil.sendPostParam(URL, getPostParam("setAdxProp"));// 获得数据并且发送请求
String data = getData(sendPostParam); // String data = getData(sendPostParam);
System.out.println(JSONObject.fromObject(data)); // System.out.println(JSONObject.fromObject(data));
JSONObject json = new JSONObject();
json.put("param", "sdfdfdsfsdf");
HttpClientUtil.sendPostJSONData(URL, json.toString());
} }
// 解密
public static String getData(String encryptString) throws Exception { public static String getData(String encryptString) throws Exception {
byte[] decode = Base64.decode(encryptString.getBytes()); byte[] decode = Base64.decode(encryptString.getBytes());
String aString = new String(decode, "utf-8"); String aString = new String(decode, "utf-8");
@ -167,17 +171,17 @@ public class TestOpenPuton {
JSONArray adxprops = new JSONArray(); JSONArray adxprops = new JSONArray();
adxprop.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b"); adxprop.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
adxprop.put("prop", 40); adxprop.put("prop", 20);
adxprops.add(adxprop); adxprops.add(adxprop);
adxprop = new JSONObject(); adxprop = new JSONObject();
adxprop.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa"); adxprop.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa");
adxprop.put("prop", 30); adxprop.put("prop", 15.5);
adxprops.add(adxprop); adxprops.add(adxprop);
adxprop = new JSONObject(); adxprop = new JSONObject();
adxprop.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92"); adxprop.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92");
adxprop.put("prop", 30); adxprop.put("prop", 26.5);
adxprops.add(adxprop); adxprops.add(adxprop);
propdata.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); propdata.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
@ -223,6 +227,40 @@ public class TestOpenPuton {
content.put("funcname", "getKpiByCampaignIds"); content.put("funcname", "getKpiByCampaignIds");
content.put("methodparam", param); content.put("methodparam", param);
break; break;
case "getKpiByGroupIds":
groupids = new JSONArray();
groupids.add("022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
param.put("groupids", groupids);
content.put("funcname", "getKpiByGroupIds");
content.put("methodparam", param);
break;
case "getKpiByAdxIds":
JSONArray adxids = new JSONArray();
adxids.add("1fed4171-9925-4834-aa7b-9b4d3a58841b");
adxids.add("6246ae47-d24b-4afa-88ba-57417ccab6aa");
adxids.add("ce579246-e707-4cb9-b982-88cad7944b92");
param.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
param.put("adxids", adxids);
content.put("funcname", "getKpiByAdxIds");
content.put("methodparam", param);
break;
case "getKpiByMapIds":
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("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda");
param.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b");
param.put("mapids", mapids);
content.put("funcname", "getKpiByMapIds");
content.put("methodparam", param);
break;
default: default:
break; break;
} }

View File

@ -208,7 +208,7 @@ public class HttpClientUtil {
} }
public static String sendPostJSONData(String url, String json) throws Exception { public static String sendPostJSONData(String url, String json) throws Exception {
log.debug("请求地址:" + url); System.out.println("请求地址:" + url);
String result = null; String result = null;
StringBuffer out = null; StringBuffer out = null;
CloseableHttpClient httpclient = null; CloseableHttpClient httpclient = null;
@ -228,9 +228,10 @@ public class HttpClientUtil {
.build(); .build();
postmethod.setConfig(requestConfig); postmethod.setConfig(requestConfig);
strentity = new StringEntity(URLEncoder.encode(json.toString(), "UTF-8")); strentity = new StringEntity(URLEncoder.encode(json.toString(), "UTF-8"));
postmethod.addHeader("content-type", "application/json"); postmethod.addHeader("Content-Type", "application/json");
postmethod.setEntity(strentity); postmethod.setEntity(strentity);
response = httpclient.execute(postmethod); response = httpclient.execute(postmethod);
System.out.println(response);
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK) { if (statusCode == HttpStatus.SC_OK) {
entity = response.getEntity(); entity = response.getEntity();