diff --git a/maintain/index.php b/maintain/index.php index c5a3434..7aedda6 100644 --- a/maintain/index.php +++ b/maintain/index.php @@ -91,15 +91,6 @@ foreach ($rows as $row) { if (!empty($cmdData['url'])) { - $pos = strpos($cmdData['url'], '?'); - if ($pos !== false) - { - $cmdData['url'] .= '?termId=' . urlencode($row['term_id']); - } - else - { - $cmdData['url'] .= '&termId=' . urlencode($row['term_id']); - } $result['isUpgrade'] = 1; $result['sj'] = 1; $result['url'] = $cmdData['url']; @@ -107,6 +98,22 @@ foreach ($rows as $row) } else { + if ($row['name'] == 'upload-logs') + { + if (!empty($cmdData['url'])) + { + $pos = strpos($cmdData['url'], '?'); + if ($pos !== false) + { + $cmdData['url'] .= '?termId=' . urlencode($row['term_id']); + } + else + { + $cmdData['url'] .= '&termId=' . urlencode($row['term_id']); + } + } + } + $result['cmd'] = $row['name']; if (!empty($row['cmd'])) { diff --git a/maintain/web/api/doAction.php b/maintain/web/api/doAction.php index 078d639..9f4d3ae 100644 --- a/maintain/web/api/doAction.php +++ b/maintain/web/api/doAction.php @@ -7,17 +7,18 @@ $db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'] \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'" ]); + $action = isset($_GET['act']) ? $_GET['act'] : ''; $termId = isset($_GET['termId']) ? intval($_GET['termId']) : 0; $termIdsStr = isset($_GET['termIds']) ? $_GET['termIds'] : ''; -$mntnMode = isset($_GET['mntn']) ? intval($_GET['mntn']) : 0; -$quickHeartbeat = isset($_GET['quickhb']) ? intval($_GET['quickhb']) : 0; if (!$termId && !$termIdsStr) { exit(); } +$result = array('code' => 0, 'data' => array()); + $termIds = array(); if (!empty($termIdsStr)) { @@ -28,127 +29,155 @@ else $termIds[] = $termId; } -$sql = "DELETE FROM mntn_cmds WHERE term_id=:termid AND `name`=:cmdName"; -$stmt1 = $db->prepare($sql); +if ($action == 'mntn') +{ + $mntnMode = isset($_GET['mntn']) ? intval($_GET['mntn']) : 0; + // $quickHeartbeat = isset($_GET['quickhb']) ? intval($_GET['quickhb']) : 0; -$sql = "INSERT INTO mntn_cmds(term_id,`name`,`cmd`,`desc`) VALUES(:termId,:cmdName,:cmd,:cmdDesc)"; -$stmt2 = $db->prepare($sql); + // header("qhb:" . $quickHeartbeat); + header("mntn:" . $mntnMode); -$sql = "UPDATE mntn_status SET `quick_hb`=:qhb,`in_maintain`=:mntn,`mode_time`=CURRENT_TIMESTAMP() WHERE term_id=:termId"; -$stmt3 = $db->prepare($sql); + $sql = "UPDATE mntn_status SET `in_maintain`=:mntn,`mode_time`=CURRENT_TIMESTAMP() WHERE term_id=:termId"; + $stmt3 = $db->prepare($sql); -header("qhb:" . $quickHeartbeat); -header("mntn:" . $mntnMode); + foreach($termIds as $termId) + { + $res = $stmt3->execute(array('termId' => $termId, 'mntn' => $mntnMode)); + if (!$res) + { + print_r($stmt3->errorInfo()); + } -$result = array('code' => 0, 'data' => array()); -foreach($termIds as $termId) + $result['data'][] = $termId; + } +} +else if ($action == 'quickhb') { - $termId = intval($termId); + $quickHeartbeat = isset($_GET['quickhb']) ? intval($_GET['quickhb']) : 0; - $values = array('termId' => $termId, 'cmd' => '', 'cmdDesc' => '', 'cmdName' => ''); + header("qhb:" . $quickHeartbeat); - if ($action == 'reset') - { - $values['cmdName'] = 'yw_cmd_android_reboot'; - } - else if ($action == 'reset-mcu') - { - $values['cmdName'] = 'yw_cmd_mcu_reboot'; - } - else if ($action == 'upload-logs') - { - $values['cmdName'] = 'yw_cmd_upload_i1_zip_log'; - $values['cmd'] = json_encode(array('url' => $_GET['url'])); - } - else if ($action == 'set-cma') - { - $values['cmdName'] = 'i1_cmd_set_i1_server_ip_port'; - $values['cmd'] = json_encode(array('value_str' => $_GET['ip'], 'value_int' => intval($_GET['port']))); - } - else if ($action == 'set-mntn-svr') - { - $values['cmdName'] = 'i1_cmd_set_xy_yw_ip_port'; - $values['cmd'] = json_encode(array('value_str' => $_GET['ip'], 'value_int' => intval($_GET['port']))); - } - else if ($action == 'set-hb') - { - $values['cmdName'] = 'i1_cmd_set_i1_heart_beat_time'; - $values['cmd'] = json_encode(array('value_int' => intval($_GET['hb']))); - } - else if ($action == 'upload-logs') - { - $values['cmdName'] = 'yw_cmd_upload_i1_zip_log'; - $values['cmd'] = json_encode(array('url' => intval($_GET['url']))); - } - else if ($action == 'upgrade') - { - $values['cmdName'] = 'upgrade'; - $md5 = empty($_GET['md5']) ? '' : $_GET['md5']; - $values['cmd'] = json_encode(array('url' => intval($_GET['url']), 'md5' => $md5)); - } - else if ($action == 'start-frpc') - { - $values['cmdName'] = 'yw_cmd_start_frpc'; - // $frpc['cmd_state'] = 1; - $frpc['server_addr'] = empty($_GET['server_addr']) ? '' : $_GET['server_addr']; - $frpc['server_port'] = empty($_GET['server_port']) ? '0' : intval($_GET['server_port']) . ''; - $frpc['frpc_type'] = empty($_GET['frpc_type']) ? '' : $_GET['frpc_type']; - $frpc['type'] = empty($_GET['type']) ? '' : $_GET['type']; - $frpc['local_ip'] = empty($_GET['local_ip']) ? '' : $_GET['local_ip']; - $frpc['local_port'] = empty($_GET['local_port']) ? '0' : intval($_GET['local_port']) . ''; - $frpc['remote_port'] = empty($_GET['remote_port']) ? '0' : intval($_GET['local_port']) . ''; - - $frpc_str = json_encode($frpc); - - $values['cmd'] = json_encode(array('frpc' => $frpc)); - } - else if ($action == 'stop-frpc') - { - $values['cmdName'] = 'yw_cmd_stop_frpc'; - } - else if ($action == 'stop-aging-test') - { - $values['cmdName'] = 'i1_cmd_stop_aging_test'; - } - else - { - // continue; - } + $sql = "UPDATE mntn_status SET `quick_hb`=:qhb,`mode_time`=CURRENT_TIMESTAMP() WHERE term_id=:termId"; + $stmt3 = $db->prepare($sql); - $res = $stmt3->execute(array('termId' => $termId, 'mntn' => $mntnMode, 'qhb' => $quickHeartbeat)); - if (!$res) + foreach($termIds as $termId) { - print_r($stmt3->errorInfo()); + $res = $stmt3->execute(array('termId' => $termId, 'qhb' => $quickHeartbeat)); + if (!$res) + { + print_r($stmt3->errorInfo()); + } + + $result['data'][] = $termId; } +} +else +{ + $sql = "DELETE FROM mntn_cmds WHERE term_id=:termid AND `name`=:cmdName"; + $stmt1 = $db->prepare($sql); - if (!empty($action)) + $sql = "INSERT INTO mntn_cmds(term_id,`name`,`cmd`,`desc`) VALUES(:termId,:cmdName,:cmd,:cmdDesc)"; + $stmt2 = $db->prepare($sql); + + + foreach($termIds as $termId) { - $res = $stmt1->execute(array('termid' => $termId, 'cmdName' => $values['cmdName'])); - if (!$res) + $termId = intval($termId); + + $values = array('termId' => $termId, 'cmd' => '', 'cmdDesc' => '', 'cmdName' => ''); + + if ($action == 'reset') { - // print_r($stmt1->errorInfo()); + $values['cmdName'] = 'yw_cmd_android_reboot'; + } + else if ($action == 'reset-mcu') + { + $values['cmdName'] = 'yw_cmd_mcu_reboot'; + } + else if ($action == 'upload-logs') + { + $values['cmdName'] = 'yw_cmd_upload_i1_zip_log'; + $values['cmd'] = json_encode(array('url' => $_GET['url'])); + } + else if ($action == 'set-cma') + { + $values['cmdName'] = 'i1_cmd_set_i1_server_ip_port'; + $values['cmd'] = json_encode(array('value_str' => $_GET['ip'], 'value_int' => intval($_GET['port']))); + } + else if ($action == 'set-mntn') + { + $values['cmdName'] = 'i1_cmd_set_xy_yw_ip_port'; + $values['cmd'] = json_encode(array('value_str' => $_GET['ip'], 'value_int' => intval($_GET['port']))); + } + else if ($action == 'set-hb') + { + $values['cmdName'] = 'i1_cmd_set_i1_heart_beat_time'; + $values['cmd'] = json_encode(array('value_int' => intval($_GET['hb']))); + } + else if ($action == 'upgrade') + { + $values['cmdName'] = 'upgrade'; + $md5 = empty($_GET['md5']) ? '' : $_GET['md5']; + $values['cmd'] = json_encode(array('url' => $_GET['url'], 'md5' => $md5)); + } + else if ($action == 'start-frpc') + { + $values['cmdName'] = 'yw_cmd_start_frpc'; + // $frpc['cmd_state'] = 1; + $frpc['server_addr'] = empty($_GET['server_addr']) ? '' : $_GET['server_addr']; + $frpc['server_port'] = empty($_GET['server_port']) ? '0' : intval($_GET['server_port']) . ''; + $frpc['frpc_type'] = empty($_GET['frpc_type']) ? '' : $_GET['frpc_type']; + $frpc['type'] = empty($_GET['type']) ? '' : $_GET['type']; + $frpc['local_ip'] = empty($_GET['local_ip']) ? '' : $_GET['local_ip']; + $frpc['local_port'] = empty($_GET['local_port']) ? '0' : intval($_GET['local_port']) . ''; + $frpc['remote_port'] = empty($_GET['remote_port']) ? '0' : intval($_GET['remote_port']) . ''; + + $frpc_str = json_encode($frpc); + + $values['cmd'] = json_encode(array('frpc' => $frpc)); + } + else if ($action == 'stop-frpc') + { + $values['cmdName'] = 'yw_cmd_stop_frpc'; + } + else if ($action == 'stop-aging-test') + { + $values['cmdName'] = 'i1_cmd_stop_aging_test'; + } + else + { + // continue; } - $res = $stmt2->execute($values); - - if (!$res) + if (!empty($action)) { - // print_r($stmt2->errorInfo()); + $res = $stmt1->execute(array('termid' => $termId, 'cmdName' => $values['cmdName'])); + if (!$res) + { + // print_r($stmt1->errorInfo()); + } + + $res = $stmt2->execute($values); + + if (!$res) + { + // print_r($stmt2->errorInfo()); + } } - } - if ($res) - { - $result['data'][] = $termId; + if ($res) + { + $result['data'][] = $termId; + } + + // i1_cmd_set_i1_server_ip_port //参数 value_str:ip value_int:port + // i1_cmd_set_xy_yw_ip_port //参数 value_str:ip value_int:port + // i1_cmd_set_i1_heart_beat_time ////参数 value_int:心跳间隔 + } - - // i1_cmd_set_i1_server_ip_port //参数 value_str:ip value_int:port - // i1_cmd_set_xy_yw_ip_port //参数 value_str:ip value_int:port - // i1_cmd_set_i1_heart_beat_time ////参数 value_int:心跳间隔 +} - -} header ('Content-type: application/json; charset=utf-8'); diff --git a/maintain/web/api/queryTerms.php b/maintain/web/api/queryTerms.php index cc7bde0..fd2fd7f 100644 --- a/maintain/web/api/queryTerms.php +++ b/maintain/web/api/queryTerms.php @@ -27,13 +27,14 @@ if (!empty($_GET['cmdid'])) $values['cmdid'] = '%' . $_GET['cmdid'] . '%'; } +$conditions[] = "t4.`raw_report_time`<>0"; $conditionStr = ''; if (count($conditions) > 0) { $conditionStr = ' WHERE ' . implode($conditions, ' AND '); } -$sql = "SELECT t1.id, t1.cmdid,t1.`display_name`,t1.`protocol`,t2.`name` AS tower_name,t3.`name` AS line_name, t4.last_raw_report AS raw_report,FROM_UNIXTIME(t4.raw_report_time) AS last_heartbeat,t4.in_maintain,t4.quick_hb,t4.mode_time"; +$sql = "SELECT t1.id, t1.cmdid,t1.`display_name`,t1.`protocol`,t2.`name` AS tower_name,t3.`name` AS line_name, t4.last_raw_report AS raw_report,t4.raw_report_time AS last_heartbeat_ts,FROM_UNIXTIME(t4.raw_report_time) AS last_heartbeat,t4.in_maintain,t4.quick_hb,t4.mode_time"; $sql .= " FROM terminals AS t1 JOIN towers AS t2 ON t1.tower_id=t2.id JOIN `lines` AS t3 ON t2.line_id=t3.id"; $sql .= " LEFT JOIN mntn_status AS t4 ON t1.id=t4.term_id " . $conditionStr . " ORDER BY t2.line_id,t2.`order`,t1.cmdid"; $stmt = $db->prepare($sql); diff --git a/maintain/web/index.html b/maintain/web/index.html index 18270fe..54ec9b3 100644 --- a/maintain/web/index.html +++ b/maintain/web/index.html @@ -14,6 +14,12 @@
+ + @@ -53,7 +59,6 @@ - 运维模式 快心跳模式 @@ -141,6 +146,7 @@ | 重启次数 | CMA服务器 | SIM卡 | +出厂Id | 版本 |
---|