|
@@ -51,102 +51,103 @@ while (1) {
|
|
|
$beginTime = time();
|
|
|
$beginDate = date('H:i',$beginTime);
|
|
|
|
|
|
- if (date('H:00',time() + 6*3600) == '09:00') {
|
|
|
- $db = new Db($config);
|
|
|
- $lampList = $db->query('select W.id,W.batstatus,W.panelstatus,W.lampstatus,W.tempstatus,W.onlinestatus,L.projectid,P.projectname,L.number,L.address,L.section,L.lighteness,L.lampvoltage,L.lampcurrent,L.lamppower,L.netstatus,L.softwareVersion,L.iccid,L.updatetime from warning_info_log W left join lampinfo L on W.lampid = L.id left join project P on L.projectid = P.id where W.is_send = 0 and L.id is not null and P.id is not null and W.status = 0');
|
|
|
- $temp_send = [];
|
|
|
- if (!empty($lampList)) {
|
|
|
+ if (1) {
|
|
|
+ // $db = new Db($config);
|
|
|
+ // $lampList = $db->query('select W.id,W.batstatus,W.panelstatus,W.lampstatus,W.tempstatus,W.onlinestatus,L.projectid,P.projectname,L.number,L.address,L.section,L.lighteness,L.lampvoltage,L.lampcurrent,L.lamppower,L.netstatus,L.softwareVersion,L.iccid,L.updatetime from warning_info_log W left join lampinfo L on W.lampid = L.id left join project P on L.projectid = P.id where W.is_send = 0 and L.id is not null and P.id is not null and W.status = 0');
|
|
|
+ // $temp_send = [];
|
|
|
+ // if (!empty($lampList)) {
|
|
|
|
|
|
- foreach ($lampList as $key => $value) {
|
|
|
- $userList = $db->query('select email,id from alarm_send_user_info where is_send = 1 and FIND_IN_SET('.$value['projectid'].',project)');
|
|
|
+ // foreach ($lampList as $key => $value) {
|
|
|
+ // $userList = $db->query('select email,id from alarm_send_user_info where is_send = 1 and FIND_IN_SET('.$value['projectid'].',project)');
|
|
|
|
|
|
- // $msg = "The device located in project:{$value['hotelName']}->number:{$value['buildName']} appears <span style='color:red;'>{$value['stralarmtype']}</span>, please confirm as soon as possible. If repaired, please ignore it! Thank you for your cooperation! [login www.iotena-web.com to see details]";
|
|
|
- $alarmArr = array();
|
|
|
- if (!empty($value['batstatus']) && isset($batstatusArr[$value['batstatus']])) $alarmArr[] = $batstatusArr[$value['batstatus']];
|
|
|
- if (!empty($value['panelstatus']) && isset($panelstatusArr[$value['panelstatus']])) $alarmArr[] = $panelstatusArr[$value['panelstatus']];
|
|
|
- if (!empty($value['lampstatus']) && isset($lampstatusArr[$value['lampstatus']])) $alarmArr[] = $lampstatusArr[$value['lampstatus']];
|
|
|
- if (!empty($value['tempstatus']) && isset($tempstatusArr[$value['tempstatus']])) $alarmArr[] = $tempstatusArr[$value['tempstatus']];
|
|
|
- if (!empty($value['onlinestatus']) && isset($onlinestatusArr[$value['onlinestatus']])) $alarmArr[] = $onlinestatusArr[$value['onlinestatus']];
|
|
|
- if (!empty($alarmArr)) {
|
|
|
- $stralarmtype = implode(',',$alarmArr);
|
|
|
- $msg = '';
|
|
|
- $msg .= '<table border="1" cellpadding="2" cellspacing="0">';
|
|
|
- $msg .= '<tr>';
|
|
|
- $msg .= '<td>Project name</td>';
|
|
|
- $msg .= '<td>'.$value['projectname'].'</td>';
|
|
|
- $msg .= '<td>Lamp number</td>';
|
|
|
- $msg .= '<td>'.$value['number'].'</td>';
|
|
|
- $msg .= '<td>Wireless module address</td>';
|
|
|
- $msg .= '<td>'.$value['address'].'</td>';
|
|
|
- $msg .= '<td>Road</td>';
|
|
|
- $msg .= '<td>'.$value['section'].'</td>';
|
|
|
- $msg .= '</tr>';
|
|
|
+ // // $msg = "The device located in project:{$value['hotelName']}->number:{$value['buildName']} appears <span style='color:red;'>{$value['stralarmtype']}</span>, please confirm as soon as possible. If repaired, please ignore it! Thank you for your cooperation! [login www.iotena-web.com to see details]";
|
|
|
+ // $alarmArr = array();
|
|
|
+ // if (!empty($value['batstatus']) && isset($batstatusArr[$value['batstatus']])) $alarmArr[] = $batstatusArr[$value['batstatus']];
|
|
|
+ // if (!empty($value['panelstatus']) && isset($panelstatusArr[$value['panelstatus']])) $alarmArr[] = $panelstatusArr[$value['panelstatus']];
|
|
|
+ // if (!empty($value['lampstatus']) && isset($lampstatusArr[$value['lampstatus']])) $alarmArr[] = $lampstatusArr[$value['lampstatus']];
|
|
|
+ // if (!empty($value['tempstatus']) && isset($tempstatusArr[$value['tempstatus']])) $alarmArr[] = $tempstatusArr[$value['tempstatus']];
|
|
|
+ // if (!empty($value['onlinestatus']) && isset($onlinestatusArr[$value['onlinestatus']])) $alarmArr[] = $onlinestatusArr[$value['onlinestatus']];
|
|
|
+ // if (!empty($alarmArr)) {
|
|
|
+ // $stralarmtype = implode(',',$alarmArr);
|
|
|
+ // $msg = '';
|
|
|
+ // $msg .= '<table border="1" cellpadding="2" cellspacing="0">';
|
|
|
+ // $msg .= '<tr>';
|
|
|
+ // $msg .= '<td>Project name</td>';
|
|
|
+ // $msg .= '<td>'.$value['projectname'].'</td>';
|
|
|
+ // $msg .= '<td>Lamp number</td>';
|
|
|
+ // $msg .= '<td>'.$value['number'].'</td>';
|
|
|
+ // $msg .= '<td>Wireless module address</td>';
|
|
|
+ // $msg .= '<td>'.$value['address'].'</td>';
|
|
|
+ // $msg .= '<td>Road</td>';
|
|
|
+ // $msg .= '<td>'.$value['section'].'</td>';
|
|
|
+ // $msg .= '</tr>';
|
|
|
|
|
|
- $msg .= '<tr>';
|
|
|
- $msg .= '<td>Brightness</td>';
|
|
|
- $msg .= '<td>'.$value['lighteness'].'%</td>';
|
|
|
- $msg .= '<td>Lamp voltage</td>';
|
|
|
- $msg .= '<td>'.$value['lampvoltage'].'V</td>';
|
|
|
- $msg .= '<td>Lamp current</td>';
|
|
|
- $msg .= '<td>'.$value['lampcurrent'].'A</td>';
|
|
|
- $msg .= '<td>Lamp power</td>';
|
|
|
- $msg .= '<td>'.$value['lamppower'].'W</td>';
|
|
|
- $msg .= '</tr>';
|
|
|
+ // $msg .= '<tr>';
|
|
|
+ // $msg .= '<td>Brightness</td>';
|
|
|
+ // $msg .= '<td>'.$value['lighteness'].'%</td>';
|
|
|
+ // $msg .= '<td>Lamp voltage</td>';
|
|
|
+ // $msg .= '<td>'.$value['lampvoltage'].'V</td>';
|
|
|
+ // $msg .= '<td>Lamp current</td>';
|
|
|
+ // $msg .= '<td>'.$value['lampcurrent'].'A</td>';
|
|
|
+ // $msg .= '<td>Lamp power</td>';
|
|
|
+ // $msg .= '<td>'.$value['lamppower'].'W</td>';
|
|
|
+ // $msg .= '</tr>';
|
|
|
|
|
|
- $netstatus = $value['netstatus'] == 0 ? 'Not online' : 'Online';
|
|
|
- $updatetime = empty($value['updatetime']) ? date('Y-m-d H:i:s',time() - 4*3600) : date('Y-m-d H:i:s',strtotime($value['updatetime']) - 2*3600);
|
|
|
- $msg .= '<tr>';
|
|
|
- $msg .= '<td>Network status</td>';
|
|
|
- $msg .= '<td>'.$netstatus.'</td>';
|
|
|
- $msg .= '<td>Version information</td>';
|
|
|
- $msg .= '<td>'.$value['softwareVersion'].'</td>';
|
|
|
- $msg .= '<td>ICCID</td>';
|
|
|
- $msg .= '<td>'.$value['iccid'].'</td>';
|
|
|
- $msg .= '<td>Update time</td>';
|
|
|
- $msg .= '<td>'.$updatetime.'</td>';
|
|
|
- $msg .= '</tr>';
|
|
|
+ // $netstatus = $value['netstatus'] == 0 ? 'Not online' : 'Online';
|
|
|
+ // $updatetime = empty($value['updatetime']) ? date('Y-m-d H:i:s',time() - 4*3600) : date('Y-m-d H:i:s',strtotime($value['updatetime']) - 2*3600);
|
|
|
+ // $msg .= '<tr>';
|
|
|
+ // $msg .= '<td>Network status</td>';
|
|
|
+ // $msg .= '<td>'.$netstatus.'</td>';
|
|
|
+ // $msg .= '<td>Version information</td>';
|
|
|
+ // $msg .= '<td>'.$value['softwareVersion'].'</td>';
|
|
|
+ // $msg .= '<td>ICCID</td>';
|
|
|
+ // $msg .= '<td>'.$value['iccid'].'</td>';
|
|
|
+ // $msg .= '<td>Update time</td>';
|
|
|
+ // $msg .= '<td>'.$updatetime.'</td>';
|
|
|
+ // $msg .= '</tr>';
|
|
|
|
|
|
- $msg .= '</table>';
|
|
|
- $msg .= "The device located in project:{$value['projectname']}->number:{$value['number']} appears <span style='color:red;'>{$stralarmtype}</span>, please confirm as soon as possible. If repaired, please ignore it! Thank you for your cooperation!";
|
|
|
- foreach ($userList as $user) {
|
|
|
- if (!empty($user['email'])) {
|
|
|
- if (!empty($value['onlinestatus'])) {
|
|
|
- if ($value['netstatus'] == 0) {
|
|
|
- if (isset($temp_send[$user['id']])) {
|
|
|
- $temp_send[$user['id']]['msg'] .= $msg;
|
|
|
- }else{
|
|
|
- $user['msg'] = $msg;
|
|
|
- $temp_send[$user['id']] = $user;
|
|
|
- }
|
|
|
- // send_email($user['email'],$msg,'Alarm info');
|
|
|
- }
|
|
|
- }else{
|
|
|
- if (isset($temp_send[$user['id']])) {
|
|
|
- $temp_send[$user['id']]['msg'] .= $msg;
|
|
|
- }else{
|
|
|
- $user['msg'] = $msg;
|
|
|
- $temp_send[$user['id']] = $user;
|
|
|
- }
|
|
|
- // send_email($user['email'],$msg,'Alarm info');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // $msg .= '</table>';
|
|
|
+ // $msg .= "The device located in project:{$value['projectname']}->number:{$value['number']} appears <span style='color:red;'>{$stralarmtype}</span>, please confirm as soon as possible. If repaired, please ignore it! Thank you for your cooperation!";
|
|
|
+ // foreach ($userList as $user) {
|
|
|
+ // if (!empty($user['email'])) {
|
|
|
+ // if (!empty($value['onlinestatus'])) {
|
|
|
+ // if ($value['netstatus'] == 0) {
|
|
|
+ // if (isset($temp_send[$user['id']])) {
|
|
|
+ // $temp_send[$user['id']]['msg'] .= $msg;
|
|
|
+ // }else{
|
|
|
+ // $user['msg'] = $msg;
|
|
|
+ // $temp_send[$user['id']] = $user;
|
|
|
+ // }
|
|
|
+ // // send_email($user['email'],$msg,'Alarm info');
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // if (isset($temp_send[$user['id']])) {
|
|
|
+ // $temp_send[$user['id']]['msg'] .= $msg;
|
|
|
+ // }else{
|
|
|
+ // $user['msg'] = $msg;
|
|
|
+ // $temp_send[$user['id']] = $user;
|
|
|
+ // }
|
|
|
+ // // send_email($user['email'],$msg,'Alarm info');
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- $db->table('warning_info_log')->where('id='.$value['id'])->update(['is_send'=>1]);
|
|
|
- }
|
|
|
- }
|
|
|
+ // $db->table('warning_info_log')->where('id='.$value['id'])->update(['is_send'=>1]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
$file = fopen('./alarm_info.txt', 'w+');
|
|
|
-
|
|
|
- if (!empty($temp_send)) {
|
|
|
- foreach ($temp_send as $key => $value) {
|
|
|
- fwrite($file, $value['msg'].'----'.date('Y-m-d H:i:s',time()).'
|
|
|
+ fwrite($file, $value['msg'].'----'.date('Y-m-d H:i:s',time()).'
|
|
|
');
|
|
|
- fwrite($file, $value['email'].'----'.date('Y-m-d H:i:s',time()).'
|
|
|
-');
|
|
|
- send_email($value['email'],$value['msg'],'Alarm info');
|
|
|
- }
|
|
|
- }
|
|
|
+// if (!empty($temp_send)) {
|
|
|
+// foreach ($temp_send as $key => $value) {
|
|
|
+// fwrite($file, $value['msg'].'----'.date('Y-m-d H:i:s',time()).'
|
|
|
+// ');
|
|
|
+// fwrite($file, $value['email'].'----'.date('Y-m-d H:i:s',time()).'
|
|
|
+// ');
|
|
|
+// send_email($value['email'],$value['msg'],'Alarm info');
|
|
|
+// }
|
|
|
+// }
|
|
|
fclose($file);
|
|
|
$db->close();
|
|
|
}
|