123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- include_once dirname(__FILE__) . '/../main.php';
- $params = query_paras();
- //$params = $_POST['date'];
- $date = $params['date']['ts'];
- $uid = $params['date']['uid'];
- $zoneid = $params['date']['zoneid'];
- $tableName = "tab_op_log" . $date;
- $dic = new stdClass();
- if (daoInst()->tableExist($tableName)) {
- $arr = daoInst()->select("*")->from($tableName)
- ->where('cmd')->eq(6903)
- ->andWhere('zoneid')->eq($zoneid)
- ->andWhere('uid')->eq($uid)
- ->fetchAll();
- $lastItem = null;
- $list = array();
- $index = 1;
- $num = 0;
- foreach ($arr as $item) {
- if ($lastItem != null) {
- $list[] = $lastItem;
- if (strtotime($item->ts) - strtotime($lastItem->ts) > 20 * 60) {
- $timeDic = new stdClass();
- $timeDic->startTs = strtotime($list[0]->ts);
- $timeDic->endTs = strtotime($list[count($list) - 1]->ts);
- $timeDic->durationTs = strtotime($list[count($list) - 1]->ts) - strtotime($list[0]->ts);
- $dic->$index = $timeDic;
- $index += 1;
- $list = array();
- }
- }
- $num += 1;
- $lastItem = $item;
- if (count($arr) == $num) {
- $list[] = $item;
- $timeDic = new stdClass();
- $timeDic->startTs = strtotime($list[0]->ts);
- $timeDic->endTs = strtotime($list[count($list) - 1]->ts);
- $timeDic->durationTs = strtotime($list[count($list) - 1]->ts) - strtotime($list[0]->ts);
- $dic->$index = $timeDic;
- break;
- }
- }
- }
- echo Resp::ret($dic);
- //echo json_encode($result);
|