alarmRecordsModel = $alarmRecordsModel; } /** * 获取告警通知列表 * */ public function list(Request $request) : \think\Response { $condition = $request->param(); if(!$condition['params']['query']['msgType'] || $condition['params']['query']['msgType'] == 'alarm'){ $list = $this->alarmRecordsModel->dataRange() // ->field('id,state as title,department_name as content,created_at as createTime') ->field('id,state,alarm_reason,has_read,depart_id,device_type,asset_no,start_time,updated_at') ->where(['deleted_at'=>0,'has_read'=>0])->order('id', 'desc')->paginate($condition['params']['pageSize']) ->each(function($item, $key){ $item['title'] = '告警'.(new SysDictData())->getValueByCode('AlarmState',$item['state']); $department_name = Db::table('departments')->where('id',$item['depart_id'])->value('department_name'); $device_type = (new SysDictData())->getValueByCode('DeviceType',$item['device_type']); $alarm_reason = (new SysDictData())->getValueByCode('AlarmReason',$item['alarm_reason']); $item['content'] = $department_name."单位的".$item['asset_no'].'('.$device_type.')'.'发生了'.$alarm_reason; $item['hasRead'] = $item['has_read']; $item['start_time'] = strtotime($item['start_time']); $item['current_time'] = time(); return $item; }); return CatchResponse::paginate($list); }else{ return CatchResponse::success(); } } }