DESKTOP-9JTA2JJ\HP 5 éve
szülő
commit
2821edbe8e

+ 29 - 23
api/application/controllers/Map.php

@@ -316,56 +316,61 @@ class Map extends Base_Controller{
 		$count = $this->input->post('count',true);
 
 		$projectid = $this->input->post('project_id',true);
+		if (empty($projectid)) exit(json_result('0007',$this->response['0007']));
 
 		// 需要查询的字段
-		$fields = "L.id as id,
-				   L.number as number,
-				   L.status,
-				   L.lighteness as light,
-				   L.longitude as longitude,
-				   L.latitude as latitude,
-				   L.isfaulted,
-				   N.status as netStatus";
+		$fields = "id as id,
+				   number as number,
+				   status,
+				   lighteness as light,
+				   longitude as longitude,
+				   latitude as latitude,
+				   isfaulted,
+				   netstatus as netStatus";
 
 		// 筛选条件
 		$filter = array();
-
+		$filter['projectid'] = $projectid;
 		if (!empty($keyword)) {
-			$filter['keyword'] = $keyword;
+			$filter['number|address'] = $keyword;
 		}
 		if (!empty($section)) {
 			$filter['section'] = $section;
 		}
 		$page = empty($page) ? 1 : $page;
 		$count = empty($count) ? 16 : $count;
-		$filter['page'] = $page;
-		$filter['count'] = $count;
+		$limit = $count;
+		$offset = ($page - 1) * $count;
+		// $filter['page'] = $page;
+		// $filter['count'] = $count;
 		switch ($type) {
 			case '1':   // 开灯
-				$filter['L.status'] = 1;
-				$filter['N.status'] = 1;
+				$filter['status'] = 1;
+				$filter['netstatus'] = 1;
 				break;  
 			case '2':   // 关灯
-				$filter['L.status'] = 0;
-				$filter['N.status'] = 1;
+				$filter['status'] = 0;
+				$filter['netstatus'] = 1;
 				break;  
 			case '3':	// 故障
 				// $filter['AI.status'] = 0;
-				$filter['L.isfaulted'] = 1;
+				$filter['isfaulted'] = 1;
 				break;
 			case '4':	// 离线
 				// $filter['AI.status !='] = 0;
-				$filter['N.status'] = 0;
+				$filter['netstatus'] = 0;
 				break;
 			// case '5':	// 监控
 			// 	$filter['monitor'] = 1;
 			// 	break;
 			default:break;
 		}
-		$data = $this->Lamp_model->get_list_by_role($role,0,$projectid,$userid,$fields,$filter);
-		unset($filter['page']);
-		unset($filter['count']);
-		$total = $this->Lamp_model->get_list_by_role($role,0,$projectid,$userid,'L.id',$filter,1);
+		// $data = $this->Lamp_model->get_list_by_role($role,0,$projectid,$userid,$fields,$filter);
+		$data = $this->Lamp_model->get_list($filter,$fields,$limit, $offset, 'number ASC,id DESC', NUll);
+		// unset($filter['page']);
+		// unset($filter['count']);
+		// $total = $this->Lamp_model->get_list_by_role($role,0,$projectid,$userid,'L.id',$filter,1);
+		$total = $this->Lamp_model->get_count($filter);
 		$temp = array();
 		foreach ($data as $v) {
 			if (!empty($type) && $type != 3 && isset($v['lampstatus']) && $v['lampstatus'] == 0) {
@@ -661,10 +666,11 @@ class Map extends Base_Controller{
         // $companyid = $this->get_user_info('companyid');
         $role = $this->get_user_info('role');
         $project_id = intval($this->input->post('project_id', true));
+        if (empty($project_id)) exit(json_result('0007',$this->response['0007']));
 
         $arr = $this->Lamp_model->getTotalLampInfo($role, 0, $project_id, $userid,1);
         if (!empty($arr['num'])) {
-            $online_arr = $this->Lamp_model->getOnlineCount($role, 0, $project_id, $userid, 1);
+            $online_arr = $this->Lamp_model->get_count(['projectid'=>$project_id,'netStatus'=>1]);
             $lighting_arr = $this->Lamp_model->getCountByFilter($role, 0, $project_id, $userid, array('L.status'=>1));
             $failure = $this->Lamp_model->get_fault_count(array('L.projectid'=>$project_id,'L.isfaulted'=>1), $role, 0, $userid);
 

+ 0 - 1
api/application/controllers/Project.php

@@ -711,7 +711,6 @@ class Project extends Base_Controller {
             $sendData = '000101A501';;
             $sendData .= bitSubStr(base_convert(intval($data['patrolinterval']/5), 10, 16));
             lampMqttCmd('/WE/WriteIn/'.$res['address'],'/WE/WriteOut/'.$res['address'],pack('H*', $sendData),0);
-            continue;
         }
         if (isset($res['protocoltype']) && $res['protocoltype'] != 0) {
             $cmd = '{"cmd_type":"set_patrol_cmd","cmd_id":'.$id.',"broadcast":0}';

+ 1 - 1
websocket/idcolWss.php

@@ -40,7 +40,7 @@ $ws_worker->onConnect = function($connection)
 	// 标记连接的客户端
     // $key=uniqid();
     $key = $connection->id;
-    $data = array('status'=>'0000','msg'=>'操作成功','data'=>['clientid'=>$key,'status'=>1]);
+    $data = array('code'=>'0000','msg'=>'操作成功','data'=>['clientid'=>$key,'status'=>1]);
     $connection->send(json_encode($data));
     // $clientArr[$key] = $connection;
 };