riskAllotModel = new RiskAllot(); $this->PatrolProblemModel = new PatrolProblem(); $this->Patroltasks = new Patroltasks(); } #代办数量 public function getTaskNumber() { $param = request()->get(); $data['patrol'] = 0;#巡查 $data['allot'] = 0;#分配 $data['abarbeitung'] = 0;#整改 $data['check'] = 0;#验收 $data['score'] = 0;#得分 #巡查------------------------------------------ $adminId = \Tinywan\Jwt\JwtToken::getCurrentId(); $data['patrol'] = $this->Patroltasks ->where([['report_user_id', '=', $adminId]]) ->distinct() // 去重 ->count(); #分配------------------------------------------ $data['allot'] = $this->PatrolProblemModel ->where( [ ['distribution_person_id', '=', $adminId], ['find_problem_org_id', '=', $param['org_id']], ['the_problem_is_distribution', '=', 1] ] ) ->count(); #整改------------------------------------------ $data['abarbeitung'] = $this->PatrolProblemModel ->where([ ['deal_problem_person_id', '=', $adminId],#处理人 ['the_problem_is_deal', '=', 1],#未处理 ['the_problem_is_distribution', '=', 2]#问题是否被处理 ]) ->count(); #验收------------------------------------------ $data['check'] = $this->PatrolProblemModel ->where([ ['find_problem_org_id', '=', $param['org_id']], ['the_problem_is_deal', '<>', 1], ['the_problem_is_comment', '=', 1], ['find_problem_person_id', '=', $adminId] ]) ->count(); #得分------------------------------------------ $data['score'] = $this->PatrolProblemModel ->where([ ['find_problem_org_id', '=', $param['org_id']], ['the_problem_is_deal', '<>', 1], ['the_problem_is_comment', '=', 2], ]) ->count(); return sparkSuccess(dataReturn(0, '查询成功', $data)); } #我的分配任务 项目部 public function index() { $param = request()->get(); $limit = $param['limit'] ?? 10; $where = []; $where[] = ['find_problem_org_id', '=', $param['org_id']]; #还需要添加该项目部指定的任务分配负责人 # $adminId = \Tinywan\Jwt\JwtToken::getCurrentId(); $where[] = ['distribution_person_id', '=', $adminId]; #筛选是否已分配 $where[] = ['the_problem_is_distribution', '=', 1]; // dump($where); $list = $this->PatrolProblemModel ->getPaginateList($where, ['*'], ['id' => 'asc'], [], $limit); return sparkSuccess(dataReturn(0, 'success', $list)); } #我的任务 public function myProblem() { try { $param = request()->get(); $limit = $param['limit'] ?? 10; checkEmpty($param, ['userId' => '查询用户id']); $where = []; $where[] = ['deal_problem_person_id', '=', $param['userId']];#处理人 $where[] = ['the_problem_is_deal', '=', 1];#未处理 #问题是否被分配 $where[] = ['the_problem_is_distribution', '=', 2]; // if (isset($param['is_distribution']) && !empty($param['is_distribution'])) { // $where[] = ['the_problem_is_distribution', '=', $param['is_distribution']]; // } $list = $this->PatrolProblemModel ->getPaginateList($where, ['*'], ['id' => 'asc'], [], $limit); return sparkSuccess(dataReturn(0, 'success', $list)); } catch (\Exception $e) { return sparkSuccess(dataReturn(-1, $e->getMessage())); } } #获取项目部所有角色 public function getOrgAllUser() { $param = request()->get(); $limit = $param['limit'] ?? 10; $where = []; $where[] = ['find_problem_org_id', '=', $param['org_id']]; if (isset($param['is_distribution']) && !empty($param['is_distribution'])) { $where[] = ['the_problem_is_distribution', '=', $param['is_distribution']]; } // dump($where); $list = $this->PatrolProblemModel ->getPaginateList($where, ['*'], ['id' => 'asc'], [], $limit); return sparkSuccess(dataReturn(0, 'success', $list)); } #获取所以有人员 public function getAllUser() { $param = request()->get(); $limit = $param['limit']; $where = []; if (isset($param['nickname']) && !empty($param['nickname'])) { $where[] = ['nickname', 'like', '%' . $param['nickname'] . '%']; } if (isset($param['name']) && !empty($param['name'])) { $where[] = ['name', 'like', '%' . $param['name'] . '%']; } if (isset($param['org_id']) && !empty($param['org_id'])) { $where[] = ['admin_org_user_role.org_id', '=', $param['org_id']]; } $adminUserModel = new AdminUser(); $list = $adminUserModel ->select( 'admin_user.avatar', 'admin_user.nickname', 'admin_user.name', 'admin_user.mobile', 'admin_user.role_id', 'admin_user.id' ) ->join('admin_org_user_role', 'admin_user.id', '=', 'admin_org_user_role.user_id') ->where($where) ->orderBy('admin_user.id', 'asc') ->paginate($limit)->toArray(); foreach ($list['data'] as $key => $item) { if ($item['role_id'] == 0) { $list['data'][$key]['role_name'] = '超级管理员'; } } return sparkSuccess(dataReturn(0, 'success', $list)); } #设置处理人 public function setDistributionProblemPerson() { try { $param = request()->get(); checkEmpty($param, [ "id" => "用户id", 'name' => '用户姓名', 'tid' => '任务id' ]); $data = [ 'the_problem_is_distribution' => 2,#已分配 'deal_problem_person_id' => $param['id'],# 分配到处理人id 'deal_problem_person_name' => $param['name'],# 分配到处理人姓名 'distribution_problem_time' => now(),# 分配时间 ]; $this->PatrolProblemModel->updateById($data, $param['tid']); return sparkSuccess(dataReturn(0, 'success')); } catch (\Exception $e) { return sparkSuccess(dataReturn(-1, $e->getMessage())); } } #设置问题不需要处理 public function setProblemDeal() { try { $param = request()->get(); checkEmpty($param, [ 'tid' => '任务id' ]); $data = [ 'the_problem_is_distribution' => 2,#已分配 'the_problem_is_deal' => 3,# 3=>不需要处理 ]; $this->PatrolProblemModel->updateById($data, $param['tid']); return sparkSuccess(dataReturn(0, '设置成功!')); } catch (\Exception $e) { return sparkSuccess(dataReturn(1, $e->getMessage())); } } #整改问题 public function dealProblem() { try { $param = request()->post(); checkEmpty($param, [ 'tid' => '任务id', 'deal_problem_video' => '视频地址', 'deal_problem_description' => '问题描述' ]); dump($param['deal_problem_video']); $data = [ 'the_problem_is_deal' => 2, 'deal_problem_video' => json_encode($param['deal_problem_video']),# 'deal_problem_description' => $param['deal_problem_description'],# 'deal_problem_time' => date('Y-m-d H:i:s'),# ]; $this->PatrolProblemModel->updateById($data, $param['tid']); return sparkSuccess(dataReturn(0, '提交成功!')); } catch (\Exception $e) { return sparkSuccess(dataReturn(1, $e->getMessage())); } } #我的评价问题 public function myCommentProblem() { try { $param = request()->get(); checkEmpty($param, [ 'userId' => '用户id', 'the_problem_is_comment' => '是否评价' ]); $limit = $param['limit'] ?? 10; #发现问题的人 $where[] = ['find_problem_org_id', '=', $param['org_id']];//项目部 $where[] = ['the_problem_is_deal', '<>', 1];#已处理 $where[] = ['the_problem_is_comment', '=', $param['the_problem_is_comment']]; if ($param['the_problem_is_comment'] == 1) { #0是验收----有人员限制 ; 1 是得分 $where[] = ['find_problem_person_id', '=', $param['userId']]; } #是否已解决 if (isset($param['comment_problem_is_solve']) && !empty($param['comment_problem_is_solve'])) { $where[] = ['comment_problem_is_solve', '=', $param['comment_problem_is_solve']]; } $list = $this->PatrolProblemModel ->getPaginateList($where, ['*'], ['id' => 'desc'], [], $limit); return sparkSuccess(dataReturn(0, 'success', $list)); } catch (\Exception $e) { return sparkSuccess(dataReturn(-1, $e->getMessage())); } } #评价问题 public function setMyCommentProblem() { try { $param = request()->post(); checkEmpty($param, [ 'tid' => '任务id', 'comment_problem_is_solve' => '是否合格', 'comment_problem_score' => '评分', 'userId' => '用户id', 'name' => '用户姓名' ]); $data = [ 'the_problem_is_comment' => 2, 'comment_problem_is_solve' => $param['comment_problem_is_solve'],# 'comment_problem_score' => $param['comment_problem_score'],# 'comment_problem_person_id' => date('Y-m-d H:i:s'),# 'comment_problem_person_name' => $param['name'], 'comment_problem_time' => date('Y-m-d H:i:s'), 'update_time' => date('Y-m-d H:i:s'), ]; $this->PatrolProblemModel->updateById($data, $param['tid']); return sparkSuccess(dataReturn(0, '提交成功!')); } catch (\Exception $e) { return sparkSuccess(dataReturn(-1, $e->getMessage())); } } }