|
|
@@ -43,61 +43,65 @@ public class GetPolyvAnalysisBigData extends BaseClass implements Runnable {
|
|
|
String[] channelids = dbConnect.runSqlQuery("select channelid from tlive where DATEADD(Day,1, lastlivedate)>=convert(varchar(10),getDate(),120) ").toArray("channelid");
|
|
|
Polyv polyv = new Polyv();
|
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
|
- JSONArray dataArray = polyv.getChannelSummary(channelids, getDate_Str());
|
|
|
- if (dataArray == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- for (Object o : dataArray) {
|
|
|
- JSONObject contentsObject = (JSONObject) o;
|
|
|
- String userId = contentsObject.getString("userId");
|
|
|
- String channelId = contentsObject.getString("channelId");
|
|
|
- String name = contentsObject.getString("name");
|
|
|
- int pcPlayDuration = contentsObject.getInteger("pcPlayDuration");
|
|
|
- long pcFlowSize = contentsObject.getLong("pcFlowSize");
|
|
|
- int pcVideoView = contentsObject.getInteger("pcVideoView");
|
|
|
- int pcUniqueViewer = contentsObject.getInteger("pcUniqueViewer");
|
|
|
- int mobilePlayDuration = contentsObject.getInteger("mobilePlayDuration");
|
|
|
- long mobileFlowSize = contentsObject.getLong("mobileFlowSize");
|
|
|
- int mobileVideoView = contentsObject.getInteger("mobileVideoView");
|
|
|
- int mobileUniqueViewer = contentsObject.getInteger("mobileUniqueViewer");
|
|
|
- int livePcPlayDuration = contentsObject.getInteger("livePcPlayDuration");
|
|
|
- int playbackPcPlayDuration = contentsObject.getInteger("playbackPcPlayDuration");
|
|
|
- int liveMobilePlayDuration = contentsObject.getInteger("liveMobilePlayDuration");
|
|
|
- int playbackMobilePlayDuration = contentsObject.getInteger("playbackMobilePlayDuration");
|
|
|
- int unknownPcPlayDuration = contentsObject.getInteger("unknownPcPlayDuration");
|
|
|
- int unknownMobilePlayDuration = contentsObject.getInteger("unknownMobilePlayDuration");
|
|
|
- String creatorName = contentsObject.getString("creatorName");//
|
|
|
+ String[] dates = new String[]{getDate_Str(-1), getDate_Str()};
|
|
|
+ for (String date : dates) {
|
|
|
+ JSONArray dataArray = polyv.getChannelSummary(channelids, date);
|
|
|
+ if (dataArray == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (Object o : dataArray) {
|
|
|
+ JSONObject contentsObject = (JSONObject) o;
|
|
|
+ String userId = contentsObject.getString("userId");
|
|
|
+ String channelId = contentsObject.getString("channelId");
|
|
|
+ String name = contentsObject.getString("name");
|
|
|
+ int pcPlayDuration = contentsObject.getInteger("pcPlayDuration");
|
|
|
+ long pcFlowSize = contentsObject.getLong("pcFlowSize");
|
|
|
+ int pcVideoView = contentsObject.getInteger("pcVideoView");
|
|
|
+ int pcUniqueViewer = contentsObject.getInteger("pcUniqueViewer");
|
|
|
+ int mobilePlayDuration = contentsObject.getInteger("mobilePlayDuration");
|
|
|
+ long mobileFlowSize = contentsObject.getLong("mobileFlowSize");
|
|
|
+ int mobileVideoView = contentsObject.getInteger("mobileVideoView");
|
|
|
+ int mobileUniqueViewer = contentsObject.getInteger("mobileUniqueViewer");
|
|
|
+ int livePcPlayDuration = contentsObject.getInteger("livePcPlayDuration");
|
|
|
+ int playbackPcPlayDuration = contentsObject.getInteger("playbackPcPlayDuration");
|
|
|
+ int liveMobilePlayDuration = contentsObject.getInteger("liveMobilePlayDuration");
|
|
|
+ int playbackMobilePlayDuration = contentsObject.getInteger("playbackMobilePlayDuration");
|
|
|
+ int unknownPcPlayDuration = contentsObject.getInteger("unknownPcPlayDuration");
|
|
|
+ int unknownMobilePlayDuration = contentsObject.getInteger("unknownMobilePlayDuration");
|
|
|
+ String creatorName = contentsObject.getString("creatorName");//
|
|
|
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "频道直播概览统计数据插入");
|
|
|
- sqlFactory.addParameter("date", getDate_Str());
|
|
|
- sqlFactory.addParameter("userid", userId);
|
|
|
- sqlFactory.addParameter("channelid", channelId);
|
|
|
- sqlFactory.addParameter("name", name);
|
|
|
- sqlFactory.addParameter("pcplayduration", pcPlayDuration);
|
|
|
- sqlFactory.addParameter("pcflowsize", pcFlowSize);
|
|
|
- sqlFactory.addParameter("pcvideoview", pcVideoView);
|
|
|
- sqlFactory.addParameter("pcuniqueviewer", pcUniqueViewer);
|
|
|
- sqlFactory.addParameter("mobileplayduration", mobilePlayDuration);
|
|
|
- sqlFactory.addParameter("mobileflowsize", mobileFlowSize);
|
|
|
- sqlFactory.addParameter("mobilevideoview", mobileVideoView);
|
|
|
- sqlFactory.addParameter("mobileuniqueviewer", mobileUniqueViewer);
|
|
|
- sqlFactory.addParameter("livepcplayduration", livePcPlayDuration);
|
|
|
- sqlFactory.addParameter("playbackpcplayduration", playbackPcPlayDuration);
|
|
|
- sqlFactory.addParameter("livemobileplayduration", liveMobilePlayDuration);
|
|
|
- sqlFactory.addParameter("playbackmobileplayduratio", playbackMobilePlayDuration);
|
|
|
- sqlFactory.addParameter("unknownpcplayduration", unknownPcPlayDuration);
|
|
|
- sqlFactory.addParameter("unknownmobileplayduration", unknownMobilePlayDuration);
|
|
|
- sqlFactory.addParameter("creatorname", creatorName);
|
|
|
- sqllist.add(sqlFactory.getSQL());
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "频道直播概览统计数据插入");
|
|
|
+ sqlFactory.addParameter("date", date);
|
|
|
+ sqlFactory.addParameter("userid", userId);
|
|
|
+ sqlFactory.addParameter("channelid", channelId);
|
|
|
+ sqlFactory.addParameter("name", name);
|
|
|
+ sqlFactory.addParameter("pcplayduration", pcPlayDuration);
|
|
|
+ sqlFactory.addParameter("pcflowsize", pcFlowSize);
|
|
|
+ sqlFactory.addParameter("pcvideoview", pcVideoView);
|
|
|
+ sqlFactory.addParameter("pcuniqueviewer", pcUniqueViewer);
|
|
|
+ sqlFactory.addParameter("mobileplayduration", mobilePlayDuration);
|
|
|
+ sqlFactory.addParameter("mobileflowsize", mobileFlowSize);
|
|
|
+ sqlFactory.addParameter("mobilevideoview", mobileVideoView);
|
|
|
+ sqlFactory.addParameter("mobileuniqueviewer", mobileUniqueViewer);
|
|
|
+ sqlFactory.addParameter("livepcplayduration", livePcPlayDuration);
|
|
|
+ sqlFactory.addParameter("playbackpcplayduration", playbackPcPlayDuration);
|
|
|
+ sqlFactory.addParameter("livemobileplayduration", liveMobilePlayDuration);
|
|
|
+ sqlFactory.addParameter("playbackmobileplayduratio", playbackMobilePlayDuration);
|
|
|
+ sqlFactory.addParameter("unknownpcplayduration", unknownPcPlayDuration);
|
|
|
+ sqlFactory.addParameter("unknownmobileplayduration", unknownMobilePlayDuration);
|
|
|
+ sqlFactory.addParameter("creatorname", creatorName);
|
|
|
+ sqllist.add(sqlFactory.getSQL());
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
}
|
|
|
- dbConnect.runSqlUpdate(sqllist);
|
|
|
}
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
GetPolyvAnalysisBigData getPolyvAnalysisBigData = new GetPolyvAnalysisBigData();
|
|
|
Polyv polyv = new Polyv();
|
|
|
- JSONObject object = polyv.getPageViewlog("2771246", getPolyvAnalysisBigData.getDate_Str(), "200", "1");
|
|
|
+ //JSONObject object = polyv.getPageViewlog("2771246", getPolyvAnalysisBigData.getDate_Str(), "200", "1");
|
|
|
+ JSONArray object = polyv.getChannelSummary(new String[]{"2771246"}, "");
|
|
|
System.err.println(object);
|
|
|
}
|
|
|
|
|
|
@@ -108,80 +112,83 @@ public class GetPolyvAnalysisBigData extends BaseClass implements Runnable {
|
|
|
DBConnect dbConnect = new DBConnect();
|
|
|
String[] channelids = dbConnect.runSqlQuery("select channelid from tlive where DATEADD(Day,1, lastlivedate)>=convert(varchar(10),getDate(),120)").toArray("channelid");
|
|
|
Polyv polyv = new Polyv();
|
|
|
- for (String channelid : channelids) {
|
|
|
- ArrayList<String> sqllist = new ArrayList<>();
|
|
|
- boolean islastpage = false;
|
|
|
- int pageNumber = 1;
|
|
|
- do {
|
|
|
- JSONObject object = polyv.getPageViewlog(channelid, getDate_Str(), "200", String.valueOf(pageNumber++));
|
|
|
- if (object == null) {
|
|
|
- break;
|
|
|
- }
|
|
|
- islastpage = object.getBoolean("lastPage");
|
|
|
- JSONArray contentsarray = object.getJSONArray("contents");
|
|
|
- if(contentsarray.isEmpty()){
|
|
|
- break;
|
|
|
- }
|
|
|
- for (Object o : contentsarray) {
|
|
|
- JSONObject contentsObject = (JSONObject) o;
|
|
|
- String playId = contentsObject.getString("playId");
|
|
|
- String userId = contentsObject.getString("userId");
|
|
|
- String channelId = contentsObject.getString("channelId");
|
|
|
- int playDuration = contentsObject.getInteger("playDuration");
|
|
|
- int stayDuration = contentsObject.getInteger("stayDuration");
|
|
|
- long flowSize = contentsObject.getLong("flowSize");
|
|
|
- String sessionId = contentsObject.getString("sessionId");
|
|
|
- String param1 = contentsObject.getString("param1");
|
|
|
- String param2 = contentsObject.getString("param2");
|
|
|
- String param3 = contentsObject.getString("param3");
|
|
|
- String param4 = contentsObject.getString("param4");
|
|
|
- String param5 = contentsObject.getString("param5");
|
|
|
- String ipAddress = contentsObject.getString("ipAddress");
|
|
|
- String country = contentsObject.getString("country");
|
|
|
- String province = contentsObject.getString("province");
|
|
|
- String city = contentsObject.getString("city");
|
|
|
- String isp = contentsObject.getString("isp");
|
|
|
- String referer = contentsObject.getString("referer");
|
|
|
- String userAgent = contentsObject.getString("userAgent");
|
|
|
- String operatingSystem = contentsObject.getString("operatingSystem");
|
|
|
- String browser = contentsObject.getString("browser");
|
|
|
- String isMobile = contentsObject.getString("isMobile");
|
|
|
- String currentDay = contentsObject.getString("currentDay");
|
|
|
- long createdTime = contentsObject.getLong("createdTime");
|
|
|
- long lastModified = contentsObject.getLong("lastModified");
|
|
|
- int ptype = contentsObject.getInteger("ptype");
|
|
|
+ String[] dates = new String[]{getDate_Str(-1), getDate_Str()};
|
|
|
+ for (String date : dates) {
|
|
|
+ for (String channelid : channelids) {
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+ boolean islastpage = false;
|
|
|
+ int pageNumber = 1;
|
|
|
+ do {
|
|
|
+ JSONObject object = polyv.getPageViewlog(channelid, date, "200", String.valueOf(pageNumber++));
|
|
|
+ if (object == null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ islastpage = object.getBoolean("lastPage");
|
|
|
+ JSONArray contentsarray = object.getJSONArray("contents");
|
|
|
+ if (contentsarray.isEmpty()) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (Object o : contentsarray) {
|
|
|
+ JSONObject contentsObject = (JSONObject) o;
|
|
|
+ String playId = contentsObject.getString("playId");
|
|
|
+ String userId = contentsObject.getString("userId");
|
|
|
+ String channelId = contentsObject.getString("channelId");
|
|
|
+ int playDuration = contentsObject.getInteger("playDuration");
|
|
|
+ int stayDuration = contentsObject.getInteger("stayDuration");
|
|
|
+ long flowSize = contentsObject.getLong("flowSize");
|
|
|
+ String sessionId = contentsObject.getString("sessionId");
|
|
|
+ String param1 = contentsObject.getString("param1");
|
|
|
+ String param2 = contentsObject.getString("param2");
|
|
|
+ String param3 = contentsObject.getString("param3");
|
|
|
+ String param4 = contentsObject.getString("param4");
|
|
|
+ String param5 = contentsObject.getString("param5");
|
|
|
+ String ipAddress = contentsObject.getString("ipAddress");
|
|
|
+ String country = contentsObject.getString("country");
|
|
|
+ String province = contentsObject.getString("province");
|
|
|
+ String city = contentsObject.getString("city");
|
|
|
+ String isp = contentsObject.getString("isp");
|
|
|
+ String referer = contentsObject.getString("referer");
|
|
|
+ String userAgent = contentsObject.getString("userAgent");
|
|
|
+ String operatingSystem = contentsObject.getString("operatingSystem");
|
|
|
+ String browser = contentsObject.getString("browser");
|
|
|
+ String isMobile = contentsObject.getString("isMobile");
|
|
|
+ String currentDay = contentsObject.getString("currentDay");
|
|
|
+ long createdTime = contentsObject.getLong("createdTime");
|
|
|
+ long lastModified = contentsObject.getLong("lastModified");
|
|
|
+ int ptype = contentsObject.getInteger("ptype");
|
|
|
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "频道直播观看详情数据插入");
|
|
|
- sqlFactory.addParameter("ptype", ptype);
|
|
|
- sqlFactory.addParameter("playid", playId);
|
|
|
- sqlFactory.addParameter("userid", userId);
|
|
|
- sqlFactory.addParameter("channelid", channelId);
|
|
|
- sqlFactory.addParameter("playduration", playDuration);
|
|
|
- sqlFactory.addParameter("stayduration", stayDuration);
|
|
|
- sqlFactory.addParameter("flowsize", flowSize);
|
|
|
- sqlFactory.addParameter("sessionid", sessionId);
|
|
|
- sqlFactory.addParameter("param1", param1);
|
|
|
- sqlFactory.addParameter("param2", param2);
|
|
|
- sqlFactory.addParameter("param3", param3);
|
|
|
- sqlFactory.addParameter("param4", param4);
|
|
|
- sqlFactory.addParameter("param5", param5);
|
|
|
- sqlFactory.addParameter("ipaddress", ipAddress);
|
|
|
- sqlFactory.addParameter("country", country);
|
|
|
- sqlFactory.addParameter("province", province);
|
|
|
- sqlFactory.addParameter("city", city);
|
|
|
- sqlFactory.addParameter("isp", isp);
|
|
|
- sqlFactory.addParameter("referer", referer);
|
|
|
- sqlFactory.addParameter("useragent", userAgent);
|
|
|
- sqlFactory.addParameter("operatingsystem", operatingSystem);
|
|
|
- sqlFactory.addParameter("browser", browser);
|
|
|
- sqlFactory.addParameter("ismobile", isMobile);
|
|
|
- sqlFactory.addParameter("currentday", currentDay);
|
|
|
- sqlFactory.addParameter("createdtime", createdTime);
|
|
|
- sqlFactory.addParameter("lastmodified", lastModified);
|
|
|
- sqllist.add(sqlFactory.getSQL());
|
|
|
- }
|
|
|
- } while (!islastpage);
|
|
|
- dbConnect.runSqlUpdate(sqllist);
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "频道直播观看详情数据插入");
|
|
|
+ sqlFactory.addParameter("ptype", ptype);
|
|
|
+ sqlFactory.addParameter("playid", playId);
|
|
|
+ sqlFactory.addParameter("userid", userId);
|
|
|
+ sqlFactory.addParameter("channelid", channelId);
|
|
|
+ sqlFactory.addParameter("playduration", playDuration);
|
|
|
+ sqlFactory.addParameter("stayduration", stayDuration);
|
|
|
+ sqlFactory.addParameter("flowsize", flowSize);
|
|
|
+ sqlFactory.addParameter("sessionid", sessionId);
|
|
|
+ sqlFactory.addParameter("param1", param1);
|
|
|
+ sqlFactory.addParameter("param2", param2);
|
|
|
+ sqlFactory.addParameter("param3", param3);
|
|
|
+ sqlFactory.addParameter("param4", param4);
|
|
|
+ sqlFactory.addParameter("param5", param5);
|
|
|
+ sqlFactory.addParameter("ipaddress", ipAddress);
|
|
|
+ sqlFactory.addParameter("country", country);
|
|
|
+ sqlFactory.addParameter("province", province);
|
|
|
+ sqlFactory.addParameter("city", city);
|
|
|
+ sqlFactory.addParameter("isp", isp);
|
|
|
+ sqlFactory.addParameter("referer", referer);
|
|
|
+ sqlFactory.addParameter("useragent", userAgent);
|
|
|
+ sqlFactory.addParameter("operatingsystem", operatingSystem);
|
|
|
+ sqlFactory.addParameter("browser", browser);
|
|
|
+ sqlFactory.addParameter("ismobile", isMobile);
|
|
|
+ sqlFactory.addParameter("currentday", currentDay);
|
|
|
+ sqlFactory.addParameter("createdtime", createdTime);
|
|
|
+ sqlFactory.addParameter("lastmodified", lastModified);
|
|
|
+ sqllist.add(sqlFactory.getSQL());
|
|
|
+ }
|
|
|
+ } while (!islastpage);
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -210,7 +217,7 @@ public class GetPolyvAnalysisBigData extends BaseClass implements Runnable {
|
|
|
break;
|
|
|
}
|
|
|
JSONArray contentsarray = object.getJSONArray("contents");
|
|
|
- if(contentsarray.isEmpty()){
|
|
|
+ if (contentsarray.isEmpty()) {
|
|
|
break;
|
|
|
}
|
|
|
islastpage = contentsarray.size() == 0;
|