wzh 5 سال پیش
والد
کامیت
ba8c71c3b2
3فایلهای تغییر یافته به همراه29 افزوده شده و 25 حذف شده
  1. 23 24
      api/application/controllers/Alarm.php
  2. 5 0
      api/application/controllers/Company.php
  3. 1 1
      api/application/controllers/Syslog.php

+ 23 - 24
api/application/controllers/Alarm.php

@@ -265,7 +265,7 @@ class Alarm extends Base_Controller {
 	public function patrol_list(){
 		$role = $this->get_user_info('role');
 		$userid = $this->get_user_info('id');
-		$companyid = $this->get_user_info('companyid');
+		$company = $this->get_user_info('company');
 		$projectid = $this->input->post('projectid',true);
 
 		$page = $this->input->post('page',true);
@@ -278,49 +278,56 @@ class Alarm extends Base_Controller {
 		$page = !isset($page) ? 1 : $page;
 		$count = empty($count) ? 20 : $count;
 
+		$limit = $count;
+		$offset = ($page - 1)*$count;
+
 		// 信息字段
 		$field = "L.id,
-				  N.id as networkid,
 				  P.id as projectid,
-				  N.networkname as network_name,
 				  P.projectname as project_name,
 				  L.number,
-				  cmd.patroltype,
-				  cmd.patrolinterval,
-				  cmd.updatetime";
+				  L.patrolinterval";
 
-		$fiter =array();
+		$where =array();
 		$section = $this->input->post('section',true);
+		$projectid = intval($this->input->post('projectid',true));
 		
-		if (!empty($section)) $fiter['section'] = $section;
-		if (!empty($keyword)) $fiter['keyword'] = $keyword;
-		if (isset($status)) $fiter['status'] = $status;
+		if (!empty($section)) $where['L.section'] = $section;
+		if (!empty($projectid)) $where['L.projectid'] = $projectid;
+		if (!empty($keyword)) $where['L.number|'] = $keyword;
+		if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
 		
+		$join = [];
+		$join[] = ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'left'];
 
 		if (empty($download)) {
+			
 			// 获取巡检信息列表
 			if (isset($print) && !empty($print)) {
-				$data = $this->Patrol_model->getList($role,$companyid,$projectid,$userid,$fiter,$field,$page,$count,1);
+				// $data = $this->Patrol_model->getList($role,$companyid,$projectid,$userid,$fiter,$field,$page,$count,1);
+				$data = $this->Lamp_model->get_list_by_join($where, $field,$limit, $offset, $join, 'L.number ASC,L.id DESC', NUll, 'L');
 			}else{
-				$data = $this->Patrol_model->getList($role,$companyid,$projectid,$userid,$fiter,$field,$page,$count);
+				$data = $this->Lamp_model->get_list_by_join($where, $field,$limit, $offset, $join, 'L.number ASC,L.id DESC', NUll, 'L');
 			}
 			
 			// 获取巡检信息总数
-			$total = $this->Patrol_model->getTotal($role,$companyid,$projectid,$userid,$fiter);
+			$total = $this->Lamp_model->get_list_by_multi_join($where, 'count(*) as total', null, null, $join, 'L.number ASC,L.id DESC', NUll, 'L',true);
+			$total = $total['total'];
 
 			json_result('0000',$this->response['0000'],array('patrol_list'=>$data,'total'=>ceil($total/$count)));
 		}else{
 			// 获取巡检信息列表
-			$data = $this->Patrol_model->getList($role,$companyid,$projectid,$userid,$fiter,$field,($page-1)*$count,3000);
+			$data = $this->Lamp_model->get_list_by_join($where, $field,3000, 0, $join, 'L.number ASC,id DESC', NUll, 'L');
+			// $data = $this->Patrol_model->getList($role,$companyid,$projectid,$userid,$fiter,$field,($page-1)*$count,3000);
 
 			$version = $this->session->userdata('version');
 			if (empty($version)) {
 				$title = array(
-					array('编号','项目名称','网络名称','路灯编号','巡检命令','巡检间隔时间(min)','参数设置时间'),
+					array('编号','项目名称','路灯编号','巡检间隔时间(min)'),
 				);
 			}else{
 				$title = array(
-					array('Number','Project name','Network name','Lamp Number','Patrol order','Inspection interval time(min)','Parameter setting time'),
+					array('Number','Project name','Lamp Number','Inspection interval time(min)'),
 				);
 			}
 			
@@ -329,16 +336,8 @@ class Alarm extends Base_Controller {
 			foreach ($data as $k=>$v) {
 				$temp[$k][] = $i;
 				$temp[$k][] = $v['project_name'];
-				$temp[$k][] = $v['network_name'];
 				$temp[$k][] = $v['number'];
-				if (empty($version)) {
-					$temp[$k][] = $v['patroltype'] == 1 ? '开' : '关';
-				}else{
-					$temp[$k][] = $v['patroltype'] == 1 ? 'on' : 'off';
-				}
-				
 				$temp[$k][] = $v['patrolinterval'];
-				$temp[$k][] = $v['updatetime'];
 				$i ++;
 			}
 

+ 5 - 0
api/application/controllers/Company.php

@@ -33,6 +33,8 @@ class Company extends Base_Controller {
 
 	// 添加编辑公司
 	public function save(){
+		$role = $this->get_user_info('role');
+		if ($role != SYSTEM_ADMIN) exit(json_result('0013',$this->response['0013']));
 		$id = intval($this->input->post('id',true));
 
 		$name = $this->input->post('name',true);
@@ -65,6 +67,9 @@ class Company extends Base_Controller {
 
 	// 删除公司
 	public function del(){
+		$role = $this->get_user_info('role');
+		if ($role != SYSTEM_ADMIN) exit(json_result('0013',$this->response['0013']));
+		
 		$id = intval($this->input->post('id',true));
 		if (empty($id)) exit(json_result('0007',$this->response['0007']));
 

+ 1 - 1
api/application/controllers/Syslog.php

@@ -25,7 +25,7 @@ class Syslog extends Base_Controller {
         $download = $this->input->post('download',true);
 
         if ($role == COMPANY_ADMIN) {
-            $filter['companyid'] = $this->get_user_info('companyid');
+            $filter['company'] = $this->get_user_info('company');
         }elseif ($role == COMPANY_CUSTOMER) {
             $filter['userid'] = $this->get_user_info('id');
         }