0){ $ids = Db::name('group_device') ->where('org_id',$orgId) ->where('group_id',$groupId) ->column('device_id'); if(empty($ids)){ $map[] = ['id', '=', -1]; }else{ $map[] = ['id', 'in', $ids]; } } if($userId!=1){ $ids = Db::name('temperature_auth') ->where('user_id',$userId) ->where('org_id',$orgId) ->column('temperature_id'); if(!empty($ids)){ $map[] = ['id', 'in',$ids]; }else{ $map[] = ['id', '=',-1]; } } $lists = Db::name('temperature_device') ->where($map)->page($page, $size) ->select(); foreach ($lists as $k => &$v) { $v['tj'] = ''; $v['abnormal_name'] = $this->abnormal[$v['abnormal']]; $gd = Db::name('group_device') ->where('device_id',$v['id']) ->column('group_id'); if(empty($gd)){ $t = ''; }else{ $x = Db::name('group') ->where('id','in',$gd) ->column('title'); $t = implode(',',$x); $v['dev_name'] = $v['dev_name'].'('.$t.')'; } } return $lists?$lists:[]; } public function getGroup($orgId,$userId,$page,$size){ $map[] = ['org_id', '=', $orgId]; $map[] = ['del', '=', 0]; if ($userId!=1){ $ids = Db::name('temperature_auth') ->where('user_id',$userId) ->where('org_id',$orgId) ->column('temperature_id'); if(!empty($ids)){ $map[] = ['id', 'in',$ids]; }else{ $map[] = ['id', '=',-1]; } } $lists = Db::name('temperature_device') ->where($map) ->column('id'); if(empty($lists)){ return[]; }else{ $groupId = Db::name('group_device') ->where('org_id',$orgId) ->where('device_id','in',$lists) ->column('group_id'); if(empty($groupId)) return []; $iid = array_unique($groupId); $gList = Db::name('group') ->where('id','in',$iid) ->field('id,title') ->page($page, $size) ->select(); return $gList; } } public function getAllList($orgId){ $map[] = ['org_id', '=', $orgId]; $map[] = ['del', '=', 0]; $ids = Db::name('group_device') ->where('org_id',$orgId) ->where('group_id','>',0) ->column('device_id'); if(!empty($ids)){ $map[] = ['id', 'not in', $ids]; } $lists = Db::name('temperature_device') ->field('id,dev_name as title') ->where($map) ->select(); return $lists?$lists:[]; } public function getIdSList($orgId,$id){ $map[] = ['org_id', '=', $orgId]; $map[] = ['del', '=', 0]; $ids = Db::name('group_device') ->where('org_id',$orgId) ->where('group_id','=',$id) ->column('device_id'); if(!empty($ids)){ $map[] = ['id', 'in', $ids]; } $lists = Db::name('temperature_device') ->field('id,dev_name as title') ->where($map) ->select(); $lists = $lists?$lists:[]; $ids1 = Db::name('group_device') ->where('org_id',$orgId) ->where('group_id','>',0) ->column('device_id'); $map1[] = ['org_id', '=', $orgId]; $map1[] = ['del', '=', 0]; if(!empty($ids1)){ $map1[] = ['id', 'not in', $ids1]; } $lists1 = Db::name('temperature_device') ->field('id,dev_name as title') ->where($map1) ->select(); $lists1 = $lists1?$lists1:[]; $lists = array_merge($lists,$lists1); return $lists; } public function updates(){ $data = request()->post(); $data['org_id'] = cur_org_id(); $data['snaddr'] = trim($data['snaddr']); return $this->updateInfo($data,'TemperatureDevice',''); } }