路由器数据统计SQL脚本

时间:2022-09-21 22:13:59
一、路由器部分
//【饼图】统计路由器在线、离线数量
SELECT COUNT(*) AS total,
COUNT(CASE WHEN last_heartbeat_time >= UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL -30 MINUTE)) THEN 1 ELSE NULL END) AS livecount,
COUNT(CASE WHEN last_heartbeat_time < UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL -30 MINUTE)) THEN 1 WHEN last_heartbeat_time IS NULL THEN 1 ELSE NULL END) AS diecount
FROM wifi_routemap 二、Portal Page页面统计部分 //【饼图】访问页面数量,以路由器进行排名
SELECT `ap_mac`, COUNT(`ap_mac`) AS `total`
FROM `wifi_status_page`
GROUP BY `ap_mac`
ORDER BY `total` DESC //【饼图】访问页面数量,以用户进行排名
SELECT `user_mac`, COUNT(`user_mac`) AS `total`
FROM `wifi_status_page`
GROUP BY `user_mac`
ORDER BY `total` DESC //【饼图】访问页面数量,以页面进行排名
SELECT `page_url`, COUNT(`page_url`) AS `total`
FROM `wifi_status_page`
GROUP BY `page_url`
ORDER BY `total` DESC //【饼图】统计访问页面数量,以分辨率进行排名,
// 实际数据为浏览器,而非屏幕的,取消
SELECT CONCAT(`height`, "*", `width`) AS `resolution`, COUNT(CONCAT(`height`, "*", `width`)) AS `total`
FROM `wifi_status_page`
GROUP BY CONCAT(`height`, "*", `width`)
ORDER BY `total` DESC
LIMIT 0 , 30 //【饼图】查询手机操作系统类型(分Android、IOS、WP、BB、Symbian及其他),不包含在下面的,需要用php计算得出并放入other字段
SELECT COUNT(id) AS total,
COUNT(CASE WHEN user_agent LIKE "%android%" THEN 1 ELSE NULL END ) AS Android,
COUNT(CASE WHEN user_agent LIKE "%iphone%" THEN 1 ELSE NULL END ) AS iOS,
COUNT(CASE WHEN user_agent LIKE "%windows phone%" THEN 1 ELSE NULL END ) AS `Windows Phone`,
COUNT(CASE WHEN user_agent LIKE "%blackberry%" THEN 1 ELSE NULL END ) AS BlackBerry,
COUNT(CASE WHEN user_agent LIKE "%symbian%" THEN 1 ELSE NULL END ) AS Symbian
FROM wifi_status_page //【饼图】查询iPhone手机型号,不包含在下面的,需要用php计算得出并放入other字段
SELECT COUNT(CASE WHEN user_agent LIKE "%iphone%" THEN 1 ELSE NULL END) AS total,
COUNT(CASE WHEN user_agent LIKE "%iphone%" AND CONCAT(height,"*",width) = "480*320" THEN 1 ELSE NULL END ) AS `iPhone 3G/3GS`,
COUNT(CASE WHEN user_agent LIKE "%iphone%" AND CONCAT(height,"*",width) = "960*640" THEN 1 ELSE NULL END ) AS `iPhone 4/4S`,
COUNT(CASE WHEN user_agent LIKE "%iphone%" AND CONCAT(height,"*",width) = "1136*640" THEN 1 ELSE NULL END ) AS `iPhone 5/5C/5S`,
COUNT(CASE WHEN user_agent LIKE "%iphone%" AND (CONCAT(height,"*",width) = "1334*750" OR CONCAT(height,"*",width) = "568*320") THEN 1 ELSE NULL END ) AS `iPhone 6/6S`,
COUNT(CASE WHEN user_agent LIKE "%iphone%" AND CONCAT(height,"*",width) = "1920*1080" THEN 1 ELSE NULL END ) AS `iPhone 6/6S Plus`
FROM wifi_status_page //【饼图】查询浏览器类型,不包含在下面的,需要用php计算得出并放入other字段
SELECT COUNT( id ) AS total,
COUNT(CASE WHEN user_agent LIKE "%QQBrowser%" THEN 1 ELSE NULL END ) AS QQBrowser,
COUNT(CASE WHEN user_agent LIKE "%MicroMessenger%" THEN 1 ELSE NULL END ) AS WeChat,
COUNT(CASE WHEN user_agent LIKE "%UCBrowser%" OR user_agent LIKE "%UCWeb%" THEN 1 ELSE NULL END ) AS UC,
COUNT(CASE WHEN user_agent LIKE "%Opera%" THEN 1 ELSE NULL END ) AS Opera,
COUNT(CASE WHEN user_agent LIKE "%Sogou%" THEN 1 ELSE NULL END ) AS Sogou,
COUNT(CASE WHEN user_agent LIKE "%Chrome%" THEN 1 ELSE NULL END ) AS Chrome,
COUNT(CASE WHEN user_agent LIKE "%360SE%" OR user_agent LIKE "%360EE%" THEN 1 ELSE NULL END ) AS `360`,
COUNT(CASE WHEN user_agent LIKE "%Maxthon%" THEN 1 ELSE NULL END ) AS Maxthon,
COUNT(CASE WHEN user_agent LIKE "%IEMobile%" THEN 1 ELSE NULL END ) AS MSIE,
COUNT(CASE WHEN user_agent LIKE "%dolphin%" THEN 1 ELSE NULL END ) AS dolphin,
COUNT(CASE WHEN user_agent LIKE "%Oupeng%" THEN 1 ELSE NULL END ) AS Oupeng,
COUNT(CASE WHEN user_agent LIKE "%LieBao%" AND user_agent not LIKE "%chrome%" THEN 1 ELSE NULL END ) AS LieBao,
COUNT(CASE WHEN user_agent LIKE "%baidu%" AND user_agent not LIKE "%chrome%" THEN 1 ELSE NULL END ) AS Baidu,
COUNT(CASE WHEN user_agent LIKE "%xiaomi%" AND user_agent not LIKE "%chrome%" THEN 1 ELSE NULL END ) AS XiaoMi,
COUNT(CASE WHEN user_agent LIKE "%Firefox%" THEN 1 ELSE NULL END ) AS Firefox
FROM wifi_status_page //【饼图】查询手机厂商,不包含在下面的,需要用php计算得出并放入other字段,
// 厂家数据太乱,ua也不全不完整,不做...........................................
// SELECT COUNT( id ) AS total,
// COUNT(CASE WHEN user_agent LIKE "%iphone%" THEN 1 ELSE NULL END ) AS Apple,
// COUNT(CASE WHEN user_agent LIKE "%Huawei%" THEN 1 ELSE NULL END ) AS Huawei,
// COUNT(CASE WHEN user_agent LIKE "%XiaoMi%" THEN 1 ELSE NULL END ) AS XiaoMi,
// COUNT(CASE WHEN user_agent LIKE "%MeiZu%" THEN 1 ELSE NULL END ) AS MeiZu,
// COUNT(CASE WHEN user_agent LIKE "%Samsung%" THEN 1 ELSE NULL END ) AS Samsung,
// COUNT(CASE WHEN user_agent LIKE "%VIVO%" THEN 1 ELSE NULL END ) AS VIVO,
// COUNT(CASE WHEN user_agent LIKE "%Nokia%" THEN 1 ELSE NULL END ) AS Nokia,
// COUNT(CASE WHEN user_agent LIKE "%nubia%" THEN 1 ELSE NULL END ) AS nubia,
// COUNT(CASE WHEN user_agent LIKE "%lenovo%" THEN 1 ELSE NULL END ) AS lenovo,
// COUNT(CASE WHEN user_agent LIKE "%oppo%" THEN 1 ELSE NULL END ) AS oppo,
// COUNT(CASE WHEN user_agent LIKE "%zte%" THEN 1 ELSE NULL END ) AS zte,
// COUNT(CASE WHEN user_agent LIKE "%qiku%" THEN 1 ELSE NULL END ) AS qiku,
// COUNT(CASE WHEN user_agent LIKE "%smart%" THEN 1 ELSE NULL END ) AS smartisam,
// COUNT(CASE WHEN user_agent LIKE "%coolpad%" THEN 1 ELSE NULL END ) AS coolpad,
// COUNT(CASE WHEN user_agent LIKE "%oneplus%" THEN 1 ELSE NULL END ) AS oneplus,
// COUNT(CASE WHEN user_agent LIKE "%letv%" THEN 1 ELSE NULL END ) AS letv,
// COUNT(CASE WHEN user_agent LIKE "%htc%" THEN 1 ELSE NULL END ) AS htc,
// COUNT(CASE WHEN user_agent LIKE "%tcl%" THEN 1 ELSE NULL END ) AS tcl,
// COUNT(CASE WHEN user_agent LIKE "%microsoft%" THEN 1 ELSE NULL END ) AS microsoft,
// COUNT(CASE WHEN user_agent LIKE "%philips%" THEN 1 ELSE NULL END ) AS philips,
// COUNT(CASE WHEN user_agent LIKE "%motorola%" THEN 1 ELSE NULL END ) AS motorola,
// COUNT(CASE WHEN user_agent LIKE "%haier%" THEN 1 ELSE NULL END ) AS haier,
// COUNT(CASE WHEN user_agent LIKE "%hisense%" THEN 1 ELSE NULL END ) AS hisense,
// COUNT(CASE WHEN user_agent LIKE "%LG%" THEN 1 ELSE NULL END ) AS LG
// FROM wifi_status_page //【曲线图】今天分时统计(需要用php以当前小时为基点,控制首列小时的显示个数,但在曲线图中横坐标要写满24小时,未到的时间点以空白显示)
//当前几点就减到第几条
SELECT td AS showhour, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT DATE_FORMAT(now(),'%H:00') AS td
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -2 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -3 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -4 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -5 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -6 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -7 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -8 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -9 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -10 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -11 HOUR),'%H:00')
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%H:00') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_page
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】昨天24小时分时统计,每小时统计数量,路由器数,手机数,以小时为序,
SELECT td AS showhour, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -1 HOUR),'%Y-%m-%d %H:00') as td
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -2 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -3 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -4 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -5 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -6 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -7 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -8 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -9 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -10 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -11 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -12 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -13 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -14 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -15 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -16 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -17 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -18 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -19 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -20 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -21 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -22 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -23 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -24 HOUR),'%Y-%m-%d %H:00')
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H:00') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_page
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = date_sub(CURDATE(), INTERVAL 1 DAY) AND ap_mac = 'bc14efab747d'
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】最近7天页面访问量,每日统计数量,路由器数,手机数,以日期为序,
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -1 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 DAY)
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_page
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -6 DAY) AND CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】最近30天页面访问量,每日统计数量,路由器数,手机数,以日期为序,
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -1 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -7 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -8 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -9 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -10 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -11 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -12 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -13 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -14 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -15 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -16 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -17 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -18 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -19 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -20 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -21 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -22 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -23 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -24 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -25 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -26 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -27 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -28 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -29 DAY)
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_page
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -29 DAY) AND CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】指定开始结束日期,每日统计数量,路由器数,手机数,以日期为序,
//开始 '2016-01-10' 结束 '2016-01-26'
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT '2016-01-10' AS td
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 1 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 2 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 3 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 4 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 5 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 6 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 7 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 8 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 9 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 10 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 11 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 12 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 13 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 14 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 15 DAY)
UNION all SELECT DATE_ADD('2016-01-10', INTERVAL 16 DAY)
)a LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_page
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN '2016-01-10' AND '2016-01-26'
GROUP BY add_data
)b ON a.td = b.add_data //php实现
$sdate="2016-01-10";
$edate="2016-01-25"; $datetime1 = date_create($sdate);
$datetime2 = date_create($edate);
$leftday = intval(date_diff($datetime1, $datetime2)->format('%a')); $sql="SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac FROM ( ";
$sql.="SELECT '$sdate' as td ";
for($i=1; $i <= $leftday;$i++){
$sql.="UNION all SELECT DATE_ADD('$sdate', INTERVAL $i DAY) ";
}
$sql.=") a LEFT JOIN ( ";
$sql.="SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac FROM wifi_status_page ";
$sql.="WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') between '$sdate' and '$edate' GROUP BY add_data ";
$sql.=") b on a.td=b.add_data"; echo $sql; 三、微信连WiFi统计部分 //【饼图】微信连WiFi数量,以路由器进行排名
SELECT `ap_mac`, COUNT(`ap_mac`) AS `total`
FROM `wifi_status_wechat`
GROUP BY `ap_mac`
ORDER BY `total` DESC //【饼图】微信连WiFi数量,以微信公众账号进行排名,右连接显示公众账号名称
SELECT wifi_wxwifi.wxgzh, COUNT( wifi_wxwifi.wxgzh ) AS total
FROM wifi_status_wechat
LEFT JOIN wifi_wxwifi ON wifi_status_wechat.shopid = wifi_wxwifi.shopId
GROUP BY wxgzh
ORDER BY total DESC //【曲线图】今天分时统计,到当前小时为止, 微信连WiFi量,每日总连接次数,路由器被连数量,公众账号被连数量,连接手机数量,连接OpenID数量
SELECT td AS showhour, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac, COALESCE(totalappid, 0) AS totalappid, COALESCE(totalopenid, 0) AS totalopenid
FROM (
SELECT DATE_FORMAT(now(),'%H:00') AS td
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -2 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -3 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -4 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -5 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -6 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -7 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -8 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -9 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -10 HOUR),'%H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -11 HOUR),'%H:00')
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%H:00') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac, COUNT(DISTINCT appid) AS totalappid, COUNT(DISTINCT openid) AS totalopenid
FROM wifi_status_wechat
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】昨天24小时分时统计, 微信连WiFi量,每日总连接次数,路由器被连数量,公众账号被连数量,连接手机数量,连接OpenID数量
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac, COALESCE(totalappid, 0) AS totalappid, COALESCE(totalopenid, 0) AS totalopenid
FROM (
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -1 HOUR),'%Y-%m-%d %H:00') as td
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -2 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -3 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -4 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -5 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -6 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -7 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -8 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -9 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -10 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -11 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -12 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -13 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -14 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -15 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -16 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -17 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -18 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -19 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -20 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -21 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -22 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -23 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -24 HOUR),'%Y-%m-%d %H:00')
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H:00') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac, COUNT(DISTINCT appid) AS totalappid, COUNT(DISTINCT openid) AS totalopenid
FROM wifi_status_wechat
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】最近7天微信连WiFi量,每日总连接次数,路由器被连数量,公众账号被连数量,连接手机数量,连接OpenID数量
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac, COALESCE(totalappid, 0) AS totalappid, COALESCE(totalopenid, 0) AS totalopenid
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -1 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 DAY)
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac, COUNT(DISTINCT appid) AS totalappid, COUNT(DISTINCT openid) AS totalopenid
FROM wifi_status_wechat
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -6 DAY) AND CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】最近30天微信连WiFi量,每日总连接次数,路由器被连数量,公众账号被连数量,连接手机数量,连接OpenID数量
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac, COALESCE(totalappid, 0) AS totalappid, COALESCE(totalopenid, 0) AS totalopenid
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -1 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -7 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -8 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -9 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -10 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -11 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -12 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -13 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -14 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -15 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -16 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -17 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -18 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -19 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -20 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -21 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -22 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -23 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -24 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -25 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -26 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -27 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -28 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -29 DAY)
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac, COUNT(DISTINCT appid) AS totalappid, COUNT(DISTINCT openid) AS totalopenid
FROM wifi_status_wechat
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -29 DAY) AND CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data 四、视频点播统计
//【饼图】视频点播数量,以路由器进行排名
SELECT `ap_mac`, COUNT(`ap_mac`) AS `total`
FROM `wifi_status_video`
GROUP BY `ap_mac`
ORDER BY `total` DESC //【饼图】视频点播数量,以点播次数进行排名,右连接视频名称
SELECT wifi_videolist.id, wifi_videolist.name, COUNT( wifi_videolist.name ) AS total
FROM wifi_status_video
LEFT JOIN wifi_videolist ON wifi_status_video.videoid = wifi_videolist.id
GROUP BY name
ORDER BY total DESC //【曲线图】最近24小时视频点播量,每日总连接次数,路由器被点数量,手机点播数量 //【曲线图】昨天24小时视频点播量,每日总连接次数,路由器被点数量,手机点播数量
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -1 HOUR),'%Y-%m-%d %H:00') as td
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -2 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -3 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -4 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -5 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -6 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -7 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -8 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -9 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -10 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -11 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -12 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -13 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -14 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -15 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -16 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -17 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -18 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -19 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -20 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -21 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -22 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -23 HOUR),'%Y-%m-%d %H:00')
UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -24 HOUR),'%Y-%m-%d %H:00')
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H:00') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_video
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
GROUP BY add_data
)b ON a.td = b.add_data //【曲线图】最近7天视频点播量,每日总连接次数,路由器被点数量,手机点播数量 //【曲线图】最近30天视频点播量,每日总连接次数,路由器被点数量,手机点播数量
SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -1 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -7 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -8 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -9 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -10 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -11 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -12 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -13 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -14 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -15 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -16 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -17 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -18 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -19 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -20 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -21 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -22 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -23 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -24 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -25 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -26 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -27 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -28 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -29 DAY)
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT(id) AS totalcount, COUNT(DISTINCT ap_mac) AS totalapmac, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_video
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -29 DAY) AND CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data 五、APP统计
//【饼图】APP点播数量,以路由器进行排名
SELECT `ap_mac`, COUNT(`ap_mac`) AS `total`
FROM `wifi_status_app`
GROUP BY `ap_mac`
ORDER BY `total` DESC //【饼图】APP下载数量,以下载次数进行排名,右连接APP名称
SELECT wifi_applist.appId, wifi_applist.appName, COUNT( wifi_applist.appName ) AS total
FROM wifi_status_app
LEFT JOIN wifi_applist ON wifi_status_app.appid = wifi_applist.appId
GROUP BY appName
ORDER BY total DESC //【曲线图】最近N小时APP下载量,每日总连接次数,路由器被点数量,手机下载数量 //【曲线图】昨天24小时APP下载量,每日总连接次数,路由器被点数量,手机点播数量 //【曲线图】最近7天APP下载量,每日总连接次数,路由器被点数量,手机点播数量 //【曲线图】最近30天APP下载量,每日总连接次数,路由器被点数量,手机点播数量 六、探针
//【柱状图】 24小时内 用户MAC 停留小时长度及用户个数,横坐标:小时长度(1-24); 纵坐标:时间长度(1-24)
// step 1
// //【条状图】 所有apmac的人流量排名,
// SELECT `apmac`, SUM(LENGTH(clients) - LENGTH(REPLACE(clients,',',''))) AS totalcount
// FROM `wifi_probe_status`
// GROUP BY `apmac`
// ORDER BY `totalcount` DESC // step 2
// 1). 获取昨天24小时内所有mac列表,再使用php去重
// SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H') add_data , clients
// FROM wifi_probe_status
// WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND `apmac` = 'bc14efab747d'
// ORDER BY add_data // SELECT apmac, GROUP_CONCAT(clients)
// FROM wifi_probe_status
// WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND `apmac` = 'bc14efab747d' // 2). 获取每个mac在昨天内停留的小时长度
// SELECT MAX(FROM_UNIXTIME(add_time, '%H')) AS max, MIN(FROM_UNIXTIME(add_time, '%H')) AS min, (max - min) as interval
// FROM wifi_probe_status
// WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND clients LIKE "%e82aeadc1950%" // 3). 根据所有mac停留时间长度,算出分布图 【曲线图】昨日各小时附近用户总数,指定路由器
SELECT ap_mac as apmac, COUNT(id) AS total,
COUNT(CASE WHEN h00_time <> '' THEN 1 ELSE NULL END) AS `00`,
COUNT(CASE WHEN h01_time <> '' THEN 1 ELSE NULL END) AS `01`,
COUNT(CASE WHEN h02_time <> '' THEN 1 ELSE NULL END) AS `02`,
COUNT(CASE WHEN h03_time <> '' THEN 1 ELSE NULL END) AS `03`,
COUNT(CASE WHEN h04_time <> '' THEN 1 ELSE NULL END) AS `04`,
COUNT(CASE WHEN h05_time <> '' THEN 1 ELSE NULL END) AS `05`,
COUNT(CASE WHEN h06_time <> '' THEN 1 ELSE NULL END) AS `06`,
COUNT(CASE WHEN h07_time <> '' THEN 1 ELSE NULL END) AS `07`,
COUNT(CASE WHEN h08_time <> '' THEN 1 ELSE NULL END) AS `08`,
COUNT(CASE WHEN h09_time <> '' THEN 1 ELSE NULL END) AS `09`,
COUNT(CASE WHEN h10_time <> '' THEN 1 ELSE NULL END) AS `10`,
COUNT(CASE WHEN h11_time <> '' THEN 1 ELSE NULL END) AS `11`,
COUNT(CASE WHEN h12_time <> '' THEN 1 ELSE NULL END) AS `12`,
COUNT(CASE WHEN h13_time <> '' THEN 1 ELSE NULL END) AS `13`,
COUNT(CASE WHEN h14_time <> '' THEN 1 ELSE NULL END) AS `14`,
COUNT(CASE WHEN h15_time <> '' THEN 1 ELSE NULL END) AS `15`,
COUNT(CASE WHEN h16_time <> '' THEN 1 ELSE NULL END) AS `16`,
COUNT(CASE WHEN h17_time <> '' THEN 1 ELSE NULL END) AS `17`,
COUNT(CASE WHEN h18_time <> '' THEN 1 ELSE NULL END) AS `18`,
COUNT(CASE WHEN h19_time <> '' THEN 1 ELSE NULL END) AS `19`,
COUNT(CASE WHEN h20_time <> '' THEN 1 ELSE NULL END) AS `20`,
COUNT(CASE WHEN h21_time <> '' THEN 1 ELSE NULL END) AS `21`,
COUNT(CASE WHEN h22_time <> '' THEN 1 ELSE NULL END) AS `22`,
COUNT(CASE WHEN h23_time <> '' THEN 1 ELSE NULL END) AS `23`
FROM wifi_status_probe
WHERE ap_user_date LIKE "%20160126%" AND `ap_mac` = 'bc14efab747d'
GROUP BY `apmac`
ORDER BY `total` DESC // SELECT td AS showhour, COALESCE(totalcount, 0) AS totalcount, COALESCE(totalapmac, 0) AS totalapmac
// FROM (
// SELECT DATE_FORMAT(now(),'%Y-%m-%d %H:00') AS td
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -2 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -3 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -4 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -5 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -6 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -7 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -8 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -9 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -10 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -11 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -12 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -13 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -14 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -15 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -16 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -17 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -18 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -19 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -20 HOUR),'%Y-%m-%d %H:00')
// ORDER BY td
// )a
// LEFT JOIN (
// SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H:00') add_data, SUM(LENGTH(clients) - LENGTH(REPLACE(clients,',',''))) AS totalcount, COUNT(DISTINCT apmac) AS totalapmac
// FROM wifi_probe_status
// WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = CURDATE()
// GROUP BY add_data
// )b ON a.td = b.add_data //【曲线图】昨天24小时附近用户总数,不同路由器附近数量
// SELECT td AS showdate, COALESCE(totalcount, 0) AS totalcount
// FROM (
// SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -1 HOUR),'%Y-%m-%d %H:00') as td
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -2 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -3 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -4 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -5 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -6 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -7 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -8 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -9 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -10 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -11 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -12 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -13 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -14 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -15 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -16 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -17 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -18 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -19 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -20 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -21 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -22 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -23 HOUR),'%Y-%m-%d %H:00')
// UNION ALL SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -24 HOUR),'%Y-%m-%d %H:00')
// ORDER BY td
// )a
// LEFT JOIN (
// SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H:00') add_data, SUM(LENGTH(clients) - LENGTH(REPLACE(clients,',',''))) AS totalcount
// FROM wifi_probe_status
// WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND `apmac` = 'bc14efab747d'
// GROUP BY add_data
// )b ON a.td = b.add_data 【柱状图】用户访问次数分布图,每个mac的访问次数
SELECT td AS showvisit, COALESCE(totalcount, 0) AS totalcount
FROM (
SELECT 1 AS td
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
UNION ALL SELECT 10
UNION ALL SELECT 11
UNION ALL SELECT 12
UNION ALL SELECT 13
UNION ALL SELECT 14
UNION ALL SELECT 15
UNION ALL SELECT 16
UNION ALL SELECT 17
UNION ALL SELECT 18
UNION ALL SELECT 19
UNION ALL SELECT 20
UNION ALL SELECT 21
UNION ALL SELECT 22
UNION ALL SELECT 23
UNION ALL SELECT 24
ORDER BY td
)a
LEFT JOIN (
SELECT times, COUNT(times) AS totalcount
FROM (
SELECT id, user_mac, ROUND(LENGTH(CONCAT_WS('', h00_time,h01_time,h02_time,h03_time,h04_time,h05_time,h06_time,h07_time,h08_time,h09_time,h10_time,h11_time,h12_time,h13_time,h14_time,h15_time,h16_time,h17_time,h18_time,h19_time,h20_time,h21_time,h22_time,h23_time))/10) as times
FROM wifi_status_probe
WHERE ap_user_date LIKE "%20160128%" AND `ap_mac` = 'bc14efab7486'
ORDER BY times DESC
) b
GROUP BY times
)b ON a.td = b.times 【柱状图】用户访问次数分布图,每个mac的访问次数
SELECT td AS showvisit, COALESCE(totalcount, 0) AS totalcount
FROM (
SELECT 1 AS td
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
UNION ALL SELECT 10
UNION ALL SELECT 11
UNION ALL SELECT 12
UNION ALL SELECT 13
UNION ALL SELECT 14
UNION ALL SELECT 15
UNION ALL SELECT 16
UNION ALL SELECT 17
UNION ALL SELECT 18
UNION ALL SELECT 19
UNION ALL SELECT 20
UNION ALL SELECT 21
UNION ALL SELECT 22
UNION ALL SELECT 23
UNION ALL SELECT 24
ORDER BY td
)a
LEFT JOIN (
SELECT times, COUNT(times) AS totalcount
FROM (
SELECT id, user_mac, ROUND(LENGTH(CONCAT_WS('', h00_time,h01_time,h02_time,h03_time,h04_time,h05_time,h06_time,h07_time,h08_time,h09_time,h10_time,h11_time,h12_time,h13_time,h14_time,h15_time,h16_time,h17_time,h18_time,h19_time,h20_time,h21_time,h22_time,h23_time))/10) AS times
FROM wifi_status_probe
WHERE ap_user_date LIKE "%20160222%" AND `ap_mac` = 'bc14efab7486'
ORDER BY times DESC
) b
GROUP BY times
)b ON a.td = b.times //【曲线图】最近30天指定ap MAC每天的user mac数量分布
SELECT td AS showdate, COALESCE(totalusermac, 0) AS totalusermac
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -1 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -7 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -8 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -9 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -10 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -11 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -12 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -13 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -14 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -15 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -16 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -17 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -18 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -19 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -20 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -21 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -22 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -23 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -24 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -25 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -26 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -27 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -28 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -29 DAY)
ORDER BY td
)a
LEFT JOIN (
SELECT STR_TO_DATE(RIGHT(ap_user_date, 8), '%Y%m%d') add_data, COUNT(DISTINCT user_mac) AS totalusermac
FROM wifi_status_probe
WHERE STR_TO_DATE(RIGHT(ap_user_date, 8), '%Y%m%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -29 DAY) AND CURDATE() AND `ap_mac` = 'bc14efab7486'
GROUP BY add_data
)b ON a.td = b.add_data 【柱状图】指定ap mac时,用户30天内到到访天数分布
SELECT td AS showvisit, COALESCE(totalcount, 0) AS totalcount
FROM (
SELECT 1 AS td
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
UNION ALL SELECT 10
UNION ALL SELECT 11
UNION ALL SELECT 12
UNION ALL SELECT 13
UNION ALL SELECT 14
UNION ALL SELECT 15
UNION ALL SELECT 16
UNION ALL SELECT 17
UNION ALL SELECT 18
UNION ALL SELECT 19
UNION ALL SELECT 20
UNION ALL SELECT 21
UNION ALL SELECT 22
UNION ALL SELECT 23
UNION ALL SELECT 24
UNION ALL SELECT 25
UNION ALL SELECT 26
UNION ALL SELECT 27
UNION ALL SELECT 28
UNION ALL SELECT 29
UNION ALL SELECT 30
ORDER BY td
)a
LEFT JOIN (
SELECT times, COUNT(times) AS totalcount
FROM (
SELECT `user_mac`, count(`user_mac`) as times
FROM wifi_status_probe
WHERE STR_TO_DATE(RIGHT(ap_user_date, 8), '%Y%m%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -29 DAY) AND CURDATE() AND `ap_mac` = 'bc14efab7486'
GROUP BY user_mac
) b
GROUP BY times
)b ON a.td = b.times //15天内所有记录 , 每个user mac的访问次数
SELECT `user_mac`, count(`user_mac`) as times
FROM wifi_status_probe
WHERE STR_TO_DATE(RIGHT(ap_user_date, 8), '%Y%m%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -29 DAY) AND CURDATE() AND `ap_mac` = 'bc14efab7486'
GROUP BY user_mac

路由器数据统计SQL脚本的更多相关文章

  1. 常用的数据统计Sql 总结

    最近刚在搞一个BI的项目,里面需要大量的sql 数据统计相关运用,加深了我又对SQL的理解与使用. 所以,分享几个数据统计时常用的sql 语句总结: 1. 统计各个条件下的数据 select Batc ...

  2. 常用的数据统计Sql 总结(转)

    转:http://www.cnblogs.com/zhangweizhong/p/5577842.html 最近刚在搞一个BI的项目,里面需要大量的sql 数据统计相关运用,加深了我又对SQL的理解与 ...

  3. SQL Server 2008导出数据为SQL脚本的操作步骤

    以前我们要将一个表中的数据导出为脚本,那么只有在网上找一个导出数据的Script,然后运行就可以导出数据脚本了.现在在SQL Server 2008的Management Studio中增加了一个新特 ...

  4. SQL Server里面如何导出包含数据的SQL脚本

    通常情况下,SQL Server里面的生成SQL脚本,只会包含数据库及表的字段结构,而不会包含表的数据,也就是SQL脚本里面只有Create database,Create table 这样的语句,没 ...

  5. 使用Sqlserver 2012 导出表数据为SQL脚本

    目录 前言 具体步骤 前言 很多时候,我们需要把数控库中的表的数据导出成SQL脚本的情形.然后,在别的库执行的情况. 以下,总结使用Sqlserver 2012数据库中表数据导出成SQL脚本的步骤. ...

  6. 读取excel数据生成sql脚本

    package com.interact.util; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.read.b ...

  7. SQLServer2008导出表数据为SQL脚本

    SQLServer2008的导出脚本方法: 数据库名-->右键 任务-->生存脚本 之后弹出SQLServer脚本生成向导 选择数据库 把编写数据可脚本这一项改为true,默认是false ...

  8. MySQL查询本周、上周、本月、上个月份数据的sql脚本

    2018-11-13 查询今天的数据 select * from 表名 where to_days(时间字段名) = to_days(now()); 查询昨天的数据 SELECT * FROM 表名 ...

  9. SQL Server 2005 导出包含&lpar;insert into&rpar;数据的SQL脚本 &lpar;使用存储过程&rpar; 分类: 数据库

    CREATE PROCEDURE dbo.UspOutputData @tablename sysname AS ) ) ) declare @xtype tinyint declare @name ...

随机推荐

  1. 添加AppWidget功能

    要为程序添加AppWidget 1 首先要建立一个继承于AppWidgetProvider的类 MyWidget public class MyWidget extends AppWidgetProv ...

  2. 【管理心得之四十】中文&OpenCurlyDoubleQuote;其他”、英文&OpenCurlyDoubleQuote;other”、日文&OpenCurlyDoubleQuote;その他”&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;&period;

    场景再现====================={某研讨会}本学期为:调查研究.整理总结阶段.本阶段的主要任务是: 一.学习理论,收集.汇编学习资料,提高自己的素质..... 二.通过对部分班级学生 ...

  3. php技术之路

    按照了解的很多PHP/LNMP程序员的发展轨迹,结合个人经验体会,抽象出很多程序员对未来的迷漫,特别对技术学习的盲目和慌乱,简单梳理了这个每个阶段PHP程序员的技术要求,来帮助很多PHP程序做对照设定 ...

  4. SSH无密码登录配置小结

    ssh-keygen -t rsa //-t指定算法 将公钥复制到被管理机器上面 ssh-copy-id -i ~/.ssh/id_rsa.pub 172.29.0.89 ssh-copy-id -i ...

  5. JSP&sol;Servlet 中的汉字编码问题

    JSP/Servlet 中的汉字编码问题 1.问题的起源 每个国家(或区域)都规定了计算机信息交换用的字符编码集,如美国的 ASCII,中国的 GB2312 -80,日本的 JIS 等,作为该国家/区 ...

  6. xcode6 AsynchronousTesting 异步任务测试

    xcode集成了非常方便的测试框架,XCTest 在xcode6之后,提供了 <XCTest/XCTestCase+AsynchronousTesting.h> 利用此我们可以直接在XCT ...

  7. React之key详解

    一个例子 有这样的一个场景如下图所示,有一组动态数量的input,可以增加和删除和重新排序,数组元素生成的组件用index作为key的值,例如下图生成的ui展示: 上面例子中的input组件渲染的代码 ...

  8. EasyUI List&lt&semi;T&gt&semi;转tree数据格式

    using System; using System.Collections; using System.Collections.Generic; using System.Linq; using S ...

  9. 【python练习题】程序8

    #题目:输出 9*9 乘法口诀表. for i in range(1,10): k = '' for j in range(1,i+1): k += '%s * %s = %s '%(i,j,i*j) ...

  10. python成长之路六-函数的初识

    定义函数 我们现学已知的python函数有<内置函数> 而我们现在要学的是<自定义函数> 1,def  定义一个函数 def name(): # 后接函数名 冒号 pass 2 ...