Signed-off-by: lixiangrong <lixiangrong@pxene.com>

This commit is contained in:
lixiangrong 2016-04-08 13:37:28 +08:00
parent 1a97f310b4
commit 398853c3a2
8 changed files with 324 additions and 165 deletions

10
pom.xml
View File

@ -149,6 +149,16 @@
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.6</version>
</dependency>
</dependencies>
<build>
<finalName>useful-code</finalName>

View File

@ -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=

View File

@ -1,131 +1,153 @@
package osc.git.eh3.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.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import osc.git.eh3.redis.JedisUtil;
public class TestJdbc {
private static Connection getConn() {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.3.166:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
String username = "root";
String password = "pxene";
Connection conn = null;
try {
Class.forName(driver); // classLoader,加载对应驱动
conn = (Connection) DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
private static Integer getAll() {
Connection conn = getConn();
String sql = "SELECT v.* FROM dsp_v_app_motionclick_day_count v WHERE v.time BETWEEN 1433088000000 AND 1453046400000 ";
// String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
PreparedStatement pstmt;
try {
pstmt = (PreparedStatement) conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
while (rs.next()) {
JSONObject jsonObject = new JSONObject();
String time = "";
String mapid = "";
String appid = "";
String adxtype = "";
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String columnName = metaData.getColumnName(i);
if ("time".equals(columnName)) {
time = rs.getString(i);
}
if ("mapid".equals(columnName)) {
mapid = rs.getString(i);
}
if ("appid".equals(columnName)) {
appid = rs.getString(i);
}
if ("adxtype".equals(columnName)) {
adxtype = rs.getString(i);
}
jsonObject.put(columnName, rs.getString(i));
}
Map<String, String> map = new HashMap<>();
map.put(time + "_" + appid + "_" + adxtype, jsonObject.toString());
JedisUtil.hset("HistoryAPPData_" + mapid, map);
// JedisUtil.lpush("HistoryAPPData_"+mapid+"_"+time,
// jsonObject.toString());
System.out.println("HistoryAPPData_" + mapid);
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
// getAll();
JedisUtil.deleteByPattern("HistoryAPPData_*");
/*
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start = new Date();
List<String> mapids = getMapid();
// String[] keys = JedisUtil.getKeys("HistoryAPPData_*");
List<String> alldata = new ArrayList<String>();
for (String mapid : mapids) {
String key = "HistoryAPPData_" + mapid;
String[] hkeys = JedisUtil.hkeys(key);
// for (String hkey : hkeys) {
// System.out.println(JedisUtil.hget(key, hkey));
// }
if(hkeys.length>0){
List<String> hmget = JedisUtil.hmget(key, hkeys);
alldata.addAll(hmget);
}
}
System.out.println(alldata.size());
Date end = new Date();
System.out.println(sdf.format(start));
System.out.println(sdf.format(end));
*/
}
private static List<String> getMapid() {
List<String> mapids = new ArrayList<String>();
Connection conn = getConn();
String sql = "SELECT t2.id AS mapid FROM dsp_t_ad_group_creative t2 LEFT JOIN dsp_t_ad_group t3 ON t2.groupid = t3.id LEFT JOIN dsp_t_campaign t4 ON t3.campaignid = t4.id LEFT JOIN dsp_t_advertiser_account t5 ON t4.accountid = t5.id LEFT JOIN dsp_t_advertiser t6 ON t5.advertiserid = t6.id WHERE ( t4.accountid IN ( SELECT id FROM dsp_t_advertiser_account t6 WHERE t6.advertiserid IN ( SELECT id FROM dsp_t_advertiser t7 WHERE t7.parentid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' ) ) OR t4.accountid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' )";
// String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
PreparedStatement pstmt;
try {
pstmt = (PreparedStatement) conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
while (rs.next()) {
for (int i = 1; i <= metaData.getColumnCount(); i++) {
mapids.add(rs.getString(i));
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return mapids;
}
}
package osc.git.eh3.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 net.sf.json.JSONObject;
import osc.git.eh3.redis.JedisUtil;
public class TestJdbc {
private static Connection getConn() {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.3.11:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
String username = "root";
String password = "pxene";
Connection conn = null;
try {
Class.forName(driver); // classLoader,加载对应驱动
conn = (Connection) DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
private static Integer getAll() {
Connection conn = getConn();
String sql = "SELECT v.* FROM dsp_v_app_motionclick_day_count v WHERE v.time BETWEEN 1433088000000 AND 1453046400000 ";
// String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
PreparedStatement pstmt;
try {
pstmt = (PreparedStatement) conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
while (rs.next()) {
JSONObject jsonObject = new JSONObject();
String time = "";
String mapid = "";
String appid = "";
String adxtype = "";
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String columnName = metaData.getColumnName(i);
if ("time".equals(columnName)) {
time = rs.getString(i);
}
if ("mapid".equals(columnName)) {
mapid = rs.getString(i);
}
if ("appid".equals(columnName)) {
appid = rs.getString(i);
}
if ("adxtype".equals(columnName)) {
adxtype = rs.getString(i);
}
jsonObject.put(columnName, rs.getString(i));
}
Map<String, String> map = new HashMap<>();
map.put(time + "_" + appid + "_" + adxtype, jsonObject.toString());
JedisUtil.hset("HistoryAPPData_" + mapid, map);
// JedisUtil.lpush("HistoryAPPData_"+mapid+"_"+time,
// jsonObject.toString());
System.out.println("HistoryAPPData_" + mapid);
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
insertData();
// getAll();
// JedisUtil.deleteByPattern("HistoryAPPData_*");
/*
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start = new Date();
List<String> mapids = getMapid();
// String[] keys = JedisUtil.getKeys("HistoryAPPData_*");
List<String> alldata = new ArrayList<String>();
for (String mapid : mapids) {
String key = "HistoryAPPData_" + mapid;
String[] hkeys = JedisUtil.hkeys(key);
// for (String hkey : hkeys) {
// System.out.println(JedisUtil.hget(key, hkey));
// }
if(hkeys.length>0){
List<String> hmget = JedisUtil.hmget(key, hkeys);
alldata.addAll(hmget);
}
}
System.out.println(alldata.size());
Date end = new Date();
System.out.println(sdf.format(start));
System.out.println(sdf.format(end));
*/
}
private static List<String> getMapid() {
List<String> mapids = new ArrayList<String>();
Connection conn = getConn();
String sql = "SELECT t2.id AS mapid FROM dsp_t_ad_group_creative t2 LEFT JOIN dsp_t_ad_group t3 ON t2.groupid = t3.id LEFT JOIN dsp_t_campaign t4 ON t3.campaignid = t4.id LEFT JOIN dsp_t_advertiser_account t5 ON t4.accountid = t5.id LEFT JOIN dsp_t_advertiser t6 ON t5.advertiserid = t6.id WHERE ( t4.accountid IN ( SELECT id FROM dsp_t_advertiser_account t6 WHERE t6.advertiserid IN ( SELECT id FROM dsp_t_advertiser t7 WHERE t7.parentid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' ) ) OR t4.accountid = 'dfecbd8a-2d7e-4941-bd89-e39c576c5ee5' )";
// String sql = "SELECT * FROM dsp_t_ad_group_adx_creative WHERE groupid
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
PreparedStatement pstmt;
try {
pstmt = (PreparedStatement) conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
while (rs.next()) {
for (int i = 1; i <= metaData.getColumnCount(); i++) {
mapids.add(rs.getString(i));
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return mapids;
}
private static void insertData(){
Connection conn = getConn();
System.out.println(new Date());
for (int i = 0; i > -1; i++) {
String cid = UUID.randomUUID().toString();
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '"+cid+"', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
PreparedStatement pstmt;
try {
pstmt = (PreparedStatement) conn.prepareStatement(sql);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
System.out.println(new Date());
}
}

View File

@ -0,0 +1,57 @@
package osc.git.eh3.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 net.sf.json.JSONObject;
import osc.git.eh3.redis.JedisUtil;
public class TestJdbc2 {
private static Connection getConn() {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.3.11:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000";
String username = "root";
String password = "pxene";
Connection conn = null;
try {
Class.forName(driver); // classLoader,加载对应驱动
conn = (Connection) DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
public static void main(String[] args) {
insertData();
}
private static void insertData(){
Connection conn = getConn();
System.out.println(new Date());
for (int i = 0; i > -1; i++) {
String cid = UUID.randomUUID().toString();
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '"+cid+"', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
PreparedStatement pstmt;
try {
pstmt = (PreparedStatement) conn.prepareStatement(sql);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
System.out.println(new Date());
}
}

View File

@ -0,0 +1,57 @@
package osc.git.eh3.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 net.sf.json.JSONObject;
import osc.git.eh3.redis.JedisUtil;
public class TestJdbc3 {
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 username = "root";
String password = "pxene";
Connection conn = null;
try {
Class.forName(driver); // classLoader,加载对应驱动
conn = (Connection) DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
public static void main(String[] args) {
insertData();
}
private static void insertData(){
Connection conn = getConn();
System.out.println(new Date());
for (int i = 0; i > -1; i++) {
String cid = UUID.randomUUID().toString();
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '"+cid+"', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
PreparedStatement pstmt;
try {
pstmt = (PreparedStatement) conn.prepareStatement(sql);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
System.out.println(new Date());
}
}

View File

@ -9,7 +9,7 @@ public class TestRedisData {
public static void main(String[] args) throws IOException {
showSom("fa5f9738-6055-4881-b1be-32f8111a18d1");
showSom("27ef277d-25e7-4347-b07f-9668a8a802cd");
}
public static void showSom(String groupid){

View File

@ -0,0 +1,14 @@
package osc.git.eh3.test;
import com.dxpmedia.hdtsspapitest.CreativeService;
import com.dxpmedia.hdtsspapitest.CreativeServiceSoap;
public class TestWS {
public static void main(String[] args) {
CreativeService service = new CreativeService();
CreativeServiceSoap serviceSoap = service.getCreativeServiceSoap();
String result = serviceSoap.creativeSubmit("0", "1",2);
System.out.println(result);
}
}

View File

@ -1,32 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry location="C:\Users\lixiangrong\.m2\repository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar"/>
<context id="MySQL" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.166/wins-dsp-new" userId="root" password="pxene">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<javaModelGenerator targetPackage="com.pxene.dsp.archer.model" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.pxene.dsp.archer.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.pxene.dsp.archer.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="dsp_t_coordinate" domainObjectName="CoordinateModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>
<table tableName="dsp_t_group_coordinate" domainObjectName="GroupCoordinateModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>
</context>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry location="C:\Users\lixiangrong\.m2\repository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar"/>
<context id="MySQL" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.166/wins-dsp-new" userId="root" password="pxene">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<javaModelGenerator targetPackage="com.pxene.dsp.archer.model" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.pxene.dsp.archer.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.pxene.dsp.archer.dao" targetProject="src/main/java">
<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>
</context>
</generatorConfiguration>