浏览代码

no message

wzh 5 年之前
父节点
当前提交
ad7aa2d0fc

+ 3 - 1
api/application/config/config.php

@@ -581,4 +581,6 @@ $config['RedioPassword'] = 'djx123';
 $config['batstatus'] = array('1'=>'Overdischarge','2'=>'Over Charge','3'=>'High temperature','4'=>'Battery overtemperature');
 $config['panelstatus'] = array('1'=>'Less than the optiocally controlled voltage','2'=>'greate than the optiocally controlled voltage','3'=>'greater than the battery voltage');
 $config['lampstatus'] = array('1'=>'open circuit','2'=>'short circuit','3'=>'overload','4'=>'Lamp overtemperature');
-$config['tempstatus'] = array('1'=>'Charge high temperature','2'=>'Charge over temperature','3'=>'Discharge high temperature','4'=>'Discharge over temperature');
+$config['tempstatus'] = array('1'=>'Charge high temperature','2'=>'Charge over temperature','3'=>'Discharge high temperature','4'=>'Discharge over temperature');
+$config['onlinestatus'] = array('1'=>'Offline failure');
+

+ 7 - 4
api/application/controllers/Alarm.php

@@ -73,10 +73,12 @@ class Alarm extends Base_Controller {
 				$t_1 = 'batstatus';
 			}elseif ($t_ty == 2) {
 				$t_1 = 'panelstatus';
-			}elseif ($t_ty == 2) {
+			}elseif ($t_ty == 3) {
 				$t_1 = 'lampstatus';
-			}else {
+			}elseif ($t_ty == 4) {
 				$t_1 = 'tempstatus';
+			}else {
+				$t_1 = 'onlinestatus';
 			}
 
 			$where[] = 'AI.'.$t_1.' = '.$t_ty2;
@@ -98,7 +100,7 @@ class Alarm extends Base_Controller {
 				$join[] = ['table'=>'global_location as G','cond'=>'G.id = P.cityid','type'=>'inner'];
 				$where[] = '(AI.batstatus != 0 OR AI.panelstatus != 0 OR AI.lampstatus != 0 OR AI.tempstatus != 0)';
 				$where = implode(' AND ', $where);
-				$alarm = $this->Alarm_model->get_list_by_join($where, 'AI.batstatus,AI.panelstatus,AI.lampstatus,AI.tempstatus,AI.status,AI.updatetime,G.timezone,L.number,P.projectname as project,AI.id',$limit, $offset, $join, 'AI.updatetime DESC,id DESC', NUll, 'AI');
+				$alarm = $this->Alarm_model->get_list_by_join($where, 'AI.batstatus,AI.panelstatus,AI.lampstatus,AI.tempstatus,AI.status,AI.onlinestatus,AI.updatetime,G.timezone,L.number,P.projectname as project,AI.id',$limit, $offset, $join, 'AI.updatetime DESC,id DESC', NUll, 'AI');
 				$total = $this->Alarm_model->get_list_by_multi_join($where, 'count(*) as total',null, null, $join, null, NUll, 'AI',true);
 				$total = $total['total'];
 				// $alarm = $this->Alarm_model->getList($filter, $role, $user_id, $page, $count,1);
@@ -110,7 +112,7 @@ class Alarm extends Base_Controller {
 				$join[] = ['table'=>'global_location as G','cond'=>'G.id = P.cityid','type'=>'inner'];
 				$where[] = '(AI.batstatus != 0 OR AI.panelstatus != 0 OR AI.lampstatus != 0 OR AI.tempstatus != 0)';
 				$where = implode(' AND ', $where);
-				$alarm = $this->Alarm_model->get_list_by_join($where, 'AI.batstatus,AI.panelstatus,AI.lampstatus,AI.tempstatus,AI.status,AI.updatetime,G.timezone,L.number,P.projectname as project,AI.id',$limit, $offset, $join, 'AI.updatetime DESC,id DESC', NUll, 'AI');
+				$alarm = $this->Alarm_model->get_list_by_join($where, 'AI.batstatus,AI.panelstatus,AI.lampstatus,AI.tempstatus,AI.status,AI.onlinestatus,AI.updatetime,G.timezone,L.number,P.projectname as project,AI.id',$limit, $offset, $join, 'AI.updatetime DESC,id DESC', NUll, 'AI');
 				$total = $this->Alarm_model->get_list_by_multi_join($where, 'count(*) as total',null, null, $join, null, NUll, 'AI',true);
 				$total = $total['total'];
 			}
@@ -130,6 +132,7 @@ class Alarm extends Base_Controller {
 		        if (isset($panelstatus[$value['panelstatus']])) $temp2[] = $panelstatus[$value['panelstatus']];
 		        if (isset($lampstatus[$value['lampstatus']])) $temp2[] = $lampstatus[$value['lampstatus']];
 		        if (isset($tempstatus[$value['tempstatus']])) $temp2[] = $tempstatus[$value['tempstatus']];
+		        if (isset($onlinestatus[$value['onlinestatus']])) $temp2[] = $onlinestatus[$value['onlinestatus']];
 		        $value['stralarmtype'] = implode(',', $temp2);
 		        $value['updatetime'] = set_timezone($value['updatetime'],$value['timezone']);
 			}

+ 4 - 0
api/application/controllers/Home.php

@@ -782,6 +782,7 @@ class Home extends Base_Controller {
         $panelstatus = $this->config->item('panelstatus');
         $lampstatus = $this->config->item('lampstatus');
         $tempstatus = $this->config->item('tempstatus');
+        $onlinestatus = $this->config->item('onlinestatus');
         $list = array();
         foreach ($batstatus as $key => $value) {
             $list[] = ['name'=>$value,'value'=>'1'.$key];
@@ -796,6 +797,9 @@ class Home extends Base_Controller {
         foreach ($tempstatus as $key => $value) {
             $list[] = ['name'=>$value,'value'=>'4'.$key];
         }
+        foreach ($onlinestatus as $key => $value) {
+            $list[] = ['name'=>$value,'value'=>'5'.$key];
+        }
         if ($this->os == 2) {
             exit(json_result('0000',$this->response['0000'],['list'=>$list]));
         }else{

+ 3 - 1
sendCmd/idcol_alarm_info_send.php

@@ -48,11 +48,12 @@ $batstatusArr = array('1'=>'Overdischarge','2'=>'Over Charge','3'=>'High tempera
 $panelstatusArr = array('1'=>'Less than the optiocally controlled voltage','2'=>'greate than the optiocally controlled voltage','3'=>'greater than the battery voltage');
 $lampstatusArr = array('1'=>'open circuit','2'=>'short circuit','3'=>'overload','4'=>'Lamp overtemperature');
 $tempstatusArr = array('1'=>'Charge high temperature','2'=>'Charge over temperature','3'=>'Discharge high temperature','4'=>'Discharge over temperature');
+$onlinestatusArr = array('1'=>'Offline failure');
 
 while (1) {
 	$db = new Db($config);
 
-	$lampList = $db->query('select W.id,W.batstatus,W.panelstatus,W.lampstatus,W.tempstatus,L.projectid,P.projectname,L.number 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');
+	$lampList = $db->query('select W.id,W.batstatus,W.panelstatus,W.lampstatus,W.tempstatus,W.onlinestatus,L.projectid,P.projectname,L.number 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');
 	foreach ($lampList as $key => $value) {
 		$userList = $db->query('select email from alarm_send_user_info where is_send = 1 and FIND_IN_SET('.$value['projectid'].',project)');
 
@@ -62,6 +63,7 @@ while (1) {
 		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 = "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!";

+ 14 - 18
sendCmd/idcol_online_alarm.php

@@ -11,22 +11,6 @@ $config = [
 	'dbname' => 'idcol',
 ];
 
-function send_cmd($cmd,$type = 0, $timeout = 30, $ms_timeout = 200) {
-	$ip = '123.57.20.89';
-    $port = '6800';
-	$client = @stream_socket_client("tcp://{$ip}:{$port}", $errno, $errstr, 30);
-	if ($client) {
-		fwrite($client, $cmd);
-		stream_set_timeout($client, $timeout, $ms_timeout);
-		$result = fread($client, 8196);
-		fclose($client);
-		return $result;
-	} else {
-        sleep(1);
-        send_cmd($cmd,$type, $timeout, $ms_timeout);
-	}
-}
-
 $begin = date('H:i',time());
 while (1) {
 	
@@ -35,9 +19,21 @@ while (1) {
 	// 生成离线故障
 	$sql = 'SELECT L.id FROM lampinfo as L left join warning_info_log AS WI on WI.lampid = L.id and WI.onlinestatus = 1 and WI.status = 0 where L.netstatus = 0 and WI.id is null';
 	$list = $db->query($sql);
-	var_dump($list);die;
+	// var_dump($list);die;
 	foreach ($list as $value) {
-		
+		$alarm_info = array();
+		$alarm_info['lampid'] = $value['id'];
+		$alarm_info['onlinestatus'] = 1;
+		$alarm_info['updatetime'] = date('Y-m-d H:i:s',time()-8*3600);
+
+		$db->table('warning_info_log')->insert($alarm_info);
+	}
+
+	// 离线故障解除
+	$sql = 'SELECT WI.id FROM warning_info_log as WI left join lampinfo AS L on WI.lampid = L.id where L.netstatus = 1 and WI.onlinestatus = 1 and WI.status != 1 and L.id is not null';
+	$list = $db->query($sql);
+	foreach ($list as $key => $value) {
+		$db->table('warning_info_log')->where('id='.$value['id'])->update(['status'=>1]);
 	}
 	$db->close();
 	$end = date('H:i',time());