get(); $limit = $param['limit'] ?? 10; $where = []; if (isset($param['report_user_id']) && !empty($param['report_user_id'])) { $where[] = ['report_user_id', '=', $param['report_user_id']]; } $patrolTask = new BombTask(); $list = $patrolTask ->selectRaw('DATE(report_time) as date') ->where($where) ->orderBy('date', 'desc') ->groupBy('date') ->paginate($limit); // dump($list[0]); // $list[0]['children'] = []; foreach ($list as $key => $value) { // dump($list[$key]['children'], $value['date']); $list[$key]['children'] = $patrolTask ->where($where) ->where('report_time', 'like', '%' . $value['date'] . '%') ->get() ?? []; } return sparkSuccess(dataReturn(0, 'success', $list)); } /** * 根据任务列表id获取巡查目标 */ public function getPatrolTargetByTaskId(Request $request) { $patrolTask = new BombTask(); $tasksList = $patrolTask->value('specific_location'); return $this->success(dataReturn(0, 'success', $tasksList)); } /** 风险管理列表 */ public function list(Request $request) { $where['status'] = 0; $list = (new Management())->where($where)->get(); $list ? $list->toArray() : []; foreach ($list as $key => $item) { $whereao = [['id', '=', $item['unit']]]; $list[$key]['unitname'] = ((new AdminOrg())->findOne($whereao, 'name'))['data']['name']; $list[$key]['statusname'] = $this->getStatus($item['status']); } return sparKSuccess(dataReturn(0, 'success', $list)); } /** 风险管理状态 */ private function getStatus($id) { $arr = ['已开启', '已关闭']; return $arr[$id]; } /** 查询风险管理 */ public function getOne(Request $request) { $getData = $request->all(); $data['row'] = (new Management()) ->with(['ManagementContentState']) ->where(['id' => $getData['id']]) ->first(); // ->getInfoById($getData['id']); // $data['lid_list'] = $this->getlistids($data['row']['lid']); return sparKSuccess(dataReturn(0, 'success', $data)); } /** id集风险标准库 */ public function getlistids($lid) { if (!isset($lid)) return []; $lid = json_decode($lid); $where = []; if (count($lid) > 0) { $where['lid'] = ['id', 'in', $lid]; // $list = (new Library())->where($where)->first(); $list = (new Library())->getAllList($where); foreach ($list as $key => $item) { $list[$key]['levelname'] = $this->getLevel($item['level']); // $list[$key]['projectname'] = $this->getOnename($item['name']); } return $list; } else { return []; } } /** 风险等级 */ private function getLevel($id) { $arr = ['', '重大风险', '较大风险', '一般风险', '较小风险']; return $arr[$id]; } /** 查询工程类型指定值 */ public function getOnename($id) { dump('错误节点getOnename,', $id); $where = [['id', '=', $id]]; $res = (new Engineering())->findOne($where, 'name'); dump($res); return $res['data']['name']; } public function setManagementState() { $param = request()->get(); checkEmpty($param, [ 'risk_id' => '参数', 'content_id' => '参数', 'state' => '参数' ]); (new ManagementContentState) ->updateOrCreate(['risk_id' => $param['risk_id'], 'content_id' => $param['content_id']], ['state' => $param['state']]); return $this->success(dataReturn(0, 'success')); } }