From 418bf4c1e6913dc9f255dfb4daba7962eeabbd3d Mon Sep 17 00:00:00 2001 From: qinzexin <“731344816@qq.com”> Date: Tue, 1 Apr 2025 18:09:26 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(backend):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E5=90=8E=E5=8F=B0=E5=8A=9F=E8=83=BD=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增考评级别相关接口 - 新增站内信相关接口 - 新增党风教育相关接口 - 新增加减分记录导出功能 - 新增月度自评审核通知功能 - 优化月度自评数据插入逻辑 --- .../backend/AdditionAndSubtractionRecords.php | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/application/api/controller/backend/AdditionAndSubtractionRecords.php b/application/api/controller/backend/AdditionAndSubtractionRecords.php index f20658b..ef2d781 100644 --- a/application/api/controller/backend/AdditionAndSubtractionRecords.php +++ b/application/api/controller/backend/AdditionAndSubtractionRecords.php @@ -300,5 +300,59 @@ class AdditionAndSubtractionRecords extends Api } return $this->error('审核失败'); } - + + public function plexamine() + { + // 接收原始参数 + $idsParam = $this->request->post('ids'); + $status = $this->request->post('status'); + + // 权限验证 + $level = Db::name('auth_group') + ->where('id', $this->auth_group) + ->value('level'); + if ($level == 2) { + return $this->error('您没有审核权限'); + } + + // 参数预处理 + $ids = []; + if (!empty($idsParam)) { + // 将字符串转换为数组并过滤无效ID + $ids = array_filter(explode(',', $idsParam), function($id) { + return is_numeric($id) && $id > 0; + }); + } + + // 参数校验 + if (empty($ids) || !$status) { + return $this->error('缺少必要参数或包含无效ID'); + } + + // 构造批量更新条件 + $where = [ + 'id' => ['in', $ids] + ]; + + $update = [ + 'status' => $status, + // 'updatetime' => time() + ]; + + // 执行批量更新 + $affectedRows = Db::name('addition_and_subtraction_records') + ->where($where) + ->update($update); + + // 结果处理 + if ($affectedRows !== false) { + if ($affectedRows > 0) { + return $this->success("成功更新{$affectedRows}条记录"); + } + return $this->error('未找到可更新的记录'); + } + + return $this->error('审核操作失败'); + } + } -- 2.47.2 From 9b599993afa30667d3965a779dad773c30fb0b5a Mon Sep 17 00:00:00 2001 From: qinzexin <“731344816@qq.com”> Date: Tue, 1 Apr 2025 18:11:54 +0800 Subject: [PATCH 2/4] Initial commit --- .../api/controller/backend/Evaluate.php | 86 +++++++++++++------ 1 file changed, 60 insertions(+), 26 deletions(-) diff --git a/application/api/controller/backend/Evaluate.php b/application/api/controller/backend/Evaluate.php index 1b6d916..79af116 100644 --- a/application/api/controller/backend/Evaluate.php +++ b/application/api/controller/backend/Evaluate.php @@ -174,46 +174,80 @@ class Evaluate extends Api $group_id = $this->request->param('group_id', 0, 'intval'); $searchMonth = $this->request->param('month', date('Y-m')); - // 验证月份格式 + // 新增分页参数 + $page = $this->request->param('page', 1, 'intval'); + $limit = $this->request->param('limit', 10, 'intval'); + $offset = ($page - 1) * $limit; + + // 参数验证 + if ($group_id <= 0) { + $this->error('无效的group_id'); + } if (!preg_match('/^\d{4}-\d{2}$/', $searchMonth)) { $this->error('月份参数格式错误'); } - - // 计算月末日期 - $firstDay = $searchMonth . '-01'; - $lastDay = date('Y-m-d', strtotime("last day of $searchMonth")); - - $result = Db::name('user') + if ($page < 1 || $limit < 1) { + $this->error('分页参数错误'); + } + + // 计算时间范围 + $firstDay = $searchMonth . '-01 00:00:00'; + $lastDay = date('Y-m-d 23:59:59', strtotime("last day of $searchMonth")); + + // 获取用户总数(用于分页) + $totalUsers = Db::name('user') ->alias('u') - ->field([ - 'u.id', - 'u.nickname AS username', - 'u.group_id', - 'g.name AS group_name', - 'SUM(CASE WHEN r.assessment_type = 1 THEN r.score_value ELSE 0 END) AS total_addition', - 'SUM(CASE WHEN r.assessment_type = 2 THEN r.score_value ELSE 0 END) AS total_subtraction' - ]) - ->join('addition_and_subtraction_records r', 'u.id = r.user_id') ->join('user_group g', 'u.group_id = g.id') ->where('u.group_id', $group_id) - ->whereTime('r.fsdate', 'between', [$firstDay, $lastDay]) // 修正后的时间查询 - ->group('u.id') + ->count(); + + // 分页查询用户 + $users = Db::name('user') + ->alias('u') + ->field(['u.id', 'u.nickname AS username', 'g.name AS group_name']) + ->join('user_group g', 'u.group_id = g.id') + ->where('u.group_id', $group_id) + ->limit($offset, $limit) ->select(); - + + // 统计分数(使用子查询优化) + $scores = Db::name('addition_and_subtraction_records') + ->field([ + 'user_id', + 'SUM(CASE WHEN assessment_type = 1 THEN score_value ELSE 0 END) AS total_addition', + 'SUM(CASE WHEN assessment_type = 2 THEN score_value ELSE 0 END) AS total_subtraction' + ]) + ->whereTime('fsdate', 'between', [$firstDay, $lastDay]) + ->group('user_id') + ->select(); + // 构建返回数据 $returnData = []; - foreach ($result as $item) { + foreach ($users as $user) { + $scoreArray = array_column($scores, null, 'user_id'); + $total_addition = $scoreArray[$user['id']]['total_addition'] ?? 0; + $total_subtraction = $scoreArray[$user['id']]['total_subtraction'] ?? 0; + $returnData[] = [ - 'username' => $item['username'], - 'group_name' => $item['group_name'], // 需要根据实际科室表字段替换 - 'month' => date('Y-m'), - 'total_addition' => $item['total_addition'], - 'total_subtraction' => $item['total_subtraction'], + 'user_id' => $user['id'], + 'username' => $user['username'], + 'group_name' => $user['group_name'], + 'month' => $searchMonth, + 'total_addition' => floatval($total_addition), + 'total_subtraction' => floatval($total_subtraction) ]; } - + + // 分页信息 + $totalPages = ceil($totalUsers / $limit); + $returnData = [ + 'data' => $returnData, + 'count' => $totalUsers, + ]; + return $this->success('评价成功', $returnData); } + public function groupIndexrecordsList(){ // 接收参数 -- 2.47.2 From be6b1e2e69ebb3fa9150b3f2088c55e13809701d Mon Sep 17 00:00:00 2001 From: qinzexin <“731344816@qq.com”> Date: Tue, 1 Apr 2025 18:18:34 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/backend/Year.php | 225 +++++++++++++++++++- 1 file changed, 221 insertions(+), 4 deletions(-) diff --git a/application/api/controller/backend/Year.php b/application/api/controller/backend/Year.php index 67ee51c..62e0c2f 100644 --- a/application/api/controller/backend/Year.php +++ b/application/api/controller/backend/Year.php @@ -149,6 +149,31 @@ class Year extends Api } $createtime = null; // 无记录时显示0 } + $total_score = 0; + if (($scoringYears[$period]['hospital_score'] ?? 0) > 0) { + + $scoringrecord_status = 4; + // 获取该年总加分和减分的分值 + $zongjiafenfenzhi = Db::name('addition_and_subtraction_records') + ->where('user_id', $id) + ->where('YEAR(createtime)', $period) + ->where('status', 2) + ->where('assessment_type', 1) + ->sum('score_value'); + + $zongjianfenfenzhi = Db::name('addition_and_subtraction_records') + ->where('user_id', $id) + ->where('YEAR(createtime)', $period) + ->where('status', 2) + ->where('assessment_type', 2) + ->sum('score_value'); + + $total_score = $scoringYears[$period]['self_score'] * 0.2 + + $scoringYears[$period]['department_score'] * 0.4 + + $scoringYears[$period]['party_branch_score'] * 0.4 + + $zongjiafenfenzhi + - $zongjianfenfenzhi; + } $result[] = [ 'year' => $period, @@ -158,13 +183,14 @@ class Year extends Api 'minus_score' => $scoringYears[$period]['minus_score'] ?? '', 'self_score' => $scoringYears[$period]['self_score'] ?? '', 'department_score' => $scoringYears[$period]['department_score'] ?? '', - 'party_branch_score' => $scoringYears[$period]['party_branch_score'] ?? '', - 'overall_party_score' => $scoringYears[$period]['overall_party_score'] ?? '', - 'hospital_score' => $scoringYears[$period]['hospital_score'] ?? '', + 'party_branch_score' => $scoringYears[$period]['party_branch_score'] ?? '', + 'overall_party_score' => $scoringYears[$period]['overall_party_score'] ?? '', + 'hospital_score' => $scoringYears[$period]['hospital_score'] ?? '', 'if' => isset($scoringYears[$period]) ? 2 : 1, 'if_period' => $if_period, 'year_range' => "{$period}-01至{$period}-12", 'createtime' => $createtime, + 'total_score' => $total_score, ]; } @@ -261,6 +287,11 @@ class Year extends Api if (!empty($insertData)) { $result = Db::name('scoringrecord')->strict(false)->insertAll($insertData); if ($result) { + $user = Db::name('user')->where('id', $user_id)->find(); + $group_id = $user['group_id']; + $mail_user = Db::name('user')->where('group_id', $group_id)->where('auth_group_id',4)->find(); + $mail_user_id = $mail_user['id']; + Mail::createMail($mail_user_id,'您的科室下有年度自评待审核人员'); return $this->success('数据插入成功', $result); } else { return $this->error('数据插入失败'); @@ -472,19 +503,22 @@ class Year extends Api $evaluation_schedule_id = $this->request->post('evaluation_schedule_id'); $page = $this->request->post('page',1); $size = $this->request->post('size',10); + $scoringrecord_status = $this->request->post('scoringrecord_status'); $where = []; if(!$groupId){ return $this->error('参数错误'); } + if($user_id){ $where['id'] = $user_id; } $where['group_id'] = $groupId; - // return $this->success('查询成功', $where); + $result = Db::name('user') ->where($where) ->page($page,$size) ->select(); + $count = Db::name('user') ->where($where) ->count(); @@ -883,4 +917,187 @@ class Year extends Api $sortedResult = $this->sortByMonthDescending($result); return $this->success('请求成功', $sortedResult); } + + public function data() +{ + $time = $this->request->post('time', date('Y')); + $group_id = $this->request->post('group_id'); + + // 统计总人数(添加时间筛选和分组) + $totalUsers = Db::name('user') + // ->where('year', $time) + ->where('group_id', $group_id) + ->count(); + + // 统计已考评人数(添加时间筛选和分组) + $evaluatedUsers = Db::name('scoringrecord') + // ->where('year', $time) + ->where('group_id', $group_id) + ->field('COUNT(DISTINCT user_id) as total') + ->find()['total']; + + // 构建带筛选条件的复杂SQL + $sql = "SELECT + COUNT(*) AS total, + SUM(CASE WHEN total_score >= 90 THEN 1 ELSE 0 END) AS excellent, + SUM(CASE WHEN total_score >= 60 AND total_score < 90 THEN 1 ELSE 0 END) AS qualified, + SUM(CASE WHEN total_score < 60 THEN 1 ELSE 0 END) AS unqualified + FROM ( + SELECT + u.id, + COALESCE( + (SUM(CASE WHEN sr.type = 1 THEN sr.self_score ELSE 0 END) * 0.2) + + (SUM(CASE WHEN sr.type = 1 THEN sr.department_score ELSE 0 END) * 0.4) + + (SUM(CASE WHEN sr.type = 1 THEN sr.party_branch_score ELSE 0 END) * 0.4) + + SUM(CASE WHEN sr.type = 2 THEN sr.value ELSE 0 END), + 0) AS total_score + FROM lr_user u + LEFT JOIN lr_scoringrecord sr ON u.id = sr.user_id + WHERE sr.term = :time AND sr.group_id = :group_id -- 添加筛选条件 + GROUP BY u.id + ) AS score_table"; + + // 使用参数绑定防止SQL注入 + $result = Db::query($sql, [ + 'time' => $time, + 'group_id' => $group_id + ]); + + // 计算比率(添加空值保护) + $excellentRate = $totalUsers > 0 ? round(($result[0]['excellent'] ?? 0) / $totalUsers * 100, 2) : 0; + $qualifiedRate = $totalUsers > 0 ? round(($result[0]['qualified'] ?? 0) / $totalUsers * 100, 2) : 0; + $unqualifiedRate = $totalUsers > 0 ? round(($result[0]['unqualified'] ?? 0) / $totalUsers * 100, 2) : 0; + + // 返回统计结果 + $res = [ + 'total' => $totalUsers, + 'evaluated' => $evaluatedUsers, + 'unevaluated' => $totalUsers > 0 ? ($totalUsers - $evaluatedUsers) : 0, // 添加保护 + 'excellent' => $result[0]['excellent'] ?? 0, + 'excellent_rate' => $excellentRate . '%', + 'qualified' => $result[0]['qualified'] ?? 0, + 'qualified_rate' => $qualifiedRate . '%', + 'unqualified' => $result[0]['unqualified'] ?? 0, + 'unqualified_rate' => $unqualifiedRate . '%' + ]; + + return $this->success('请求成功', $res); +} + + + + + + + + + + + + + + + + + + + + // $time = $this->request->post('time', date('Y')); + // $evaluation_schedule_id = $this->request->post('evaluation_schedule_id'); + + // // 统计总人数 + // $totalUsers = Db::name('user')->count(); + // return $this->success('统计完成', $totalUsers); + // // 获取所有需要统计的用户列表 + // $users = Db::name('user') + // ->where($where) + // ->field('id,group_id,username') + // ->select(); + + // $statistics = [ + // 'total' => $totalUsers, + // 'evaluated' => 0, + // 'unevaluated' => 0, + // 'excellent' => 0, + // 'good' => 0, + // 'unqualified' => 0, + // 'excellent_rate' => 0, + // 'good_rate' => 0, + // 'unqualified_rate' => 0 + // ]; + + // // 评分统计标准(需要根据实际业务调整阈值) + // $scoreThresholds = [ + // 'excellent' => 90, // 优秀阈值 + // 'good' => 60, // 合格阈值 + // 'unqualified' => 0 // 不合格阈值 + // ]; + + // foreach ($users as &$user) { + // // 获取用户评分记录 + // $scoringRecords = Db::name('scoringrecord') + // ->where('user_id', $user['id']) + // ->where($where) + // ->select(); + + // // 获取用户加减分记录 + // $additionSubtraction = Db::name('addition_and_subtraction_records') + // ->where('user_id', $user['id']) + // ->where('YEAR(createtime)', $time) + // ->where('status', 1) // 假设1为有效状态 + // ->sum('value'); + + // if (empty($scoringRecords)) { + // $statistics['unevaluated']++; + // continue; + // } + + // $statistics['evaluated']++; + + // // 计算总分 + // $totalScore = 0; + // foreach ($scoringRecords as $record) { + // $totalScore += ( + // $record['self_score'] * 0.2 + + // $record['department_score'] * 0.4 + + // $record['party_branch_score'] * 0.4 + // ); + // } + + // // 加上加减分项 + // $totalScore += $additionSubtraction ?: 0; + + // // 统计分类 + // if ($totalScore >= $scoreThresholds['excellent']) { + // $statistics['excellent']++; + // } elseif ($totalScore >= $scoreThresholds['good']) { + // $statistics['good']++; + // } else { + // $statistics['unqualified']++; + // } + // } + + // // 计算比率 + // $totalEvaluated = $statistics['evaluated']; + // if ($totalEvaluated > 0) { + // $statistics['excellent_rate'] = round($statistics['excellent'] / $totalEvaluated * 100, 2); + // $statistics['good_rate'] = round($statistics['good'] / $totalEvaluated * 100, 2); + // $statistics['unqualified_rate'] = round($statistics['unqualified'] / $totalEvaluated * 100, 2); + // } + + // // 补充用户分组信息 + // $groupIds = array_column($users, 'group_id'); + // $groups = Db::name('user_group')->where('id', 'in', $groupIds)->column('id,name', 'id'); + + // foreach ($users as &$user) { + // $user['group_name'] = $groups[$user['group_id']] ?? '未分组'; + // } + + // return $this->success('统计完成', [ + // 'statistics' => $statistics, + // 'users' => $users + // ]); + + + } -- 2.47.2 From 4578d6519c0761b1ab2e0f8202994b477f704e88 Mon Sep 17 00:00:00 2001 From: qinzexin <“731344816@qq.com”> Date: Tue, 1 Apr 2025 18:18:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9C=80=E6=96=B0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/backend/Evaluationlevel.php | 132 +++++ .../controller/backend/ExcelController.php | 274 +++++++++ application/api/controller/backend/Mail.php | 79 +++ .../api/controller/backend/Monthly.php | 6 + .../api/controller/backend/PartyStyle.php | 124 +++++ application/api/controller/backend/Pdf.php | 527 ++++++++++++++++++ .../api/controller/backend/Politics.php | 6 +- .../api/controller/backend/Quarter.php | 25 +- .../api/controller/backend/Questionnaire.php | 473 ++++++++++++++++ .../controller/backend/RejectRedEnvelopes.php | 59 +- .../controller/backend/Solicitopinions.php | 104 ++++ application/api/controller/backend/User.php | 67 ++- 12 files changed, 1845 insertions(+), 31 deletions(-) create mode 100644 application/api/controller/backend/Evaluationlevel.php create mode 100644 application/api/controller/backend/ExcelController.php create mode 100644 application/api/controller/backend/Mail.php create mode 100644 application/api/controller/backend/PartyStyle.php create mode 100644 application/api/controller/backend/Pdf.php create mode 100644 application/api/controller/backend/Questionnaire.php create mode 100644 application/api/controller/backend/Solicitopinions.php diff --git a/application/api/controller/backend/Evaluationlevel.php b/application/api/controller/backend/Evaluationlevel.php new file mode 100644 index 0000000..312d723 --- /dev/null +++ b/application/api/controller/backend/Evaluationlevel.php @@ -0,0 +1,132 @@ +request->post('group_id'); + $page = $this->request->post('page',1); + $size = $this->request->post('size',10); + if(!$group_id){ + $this->error(__('Invalid parameters')); + } + $where = []; + $where['a.group_id'] = $group_id; + // 从数据库中获取所有数据 + $data = Db::name('evaluation_level') + ->field('a.*,p.name as user_group_name') + ->alias('a') + // ->join('party_group w','a.party_id = w.id','LEFT') + ->join('user_group p','a.group_id = p.id','LEFT') + ->where($where) + ->page($page,$size) + ->order('a.id asc') + ->select(); + $count = Db::name('evaluation_level') + ->field('a.*,p.name as user_group_name') + ->alias('a') + // ->join('party_group w','a.party_id = w.id','LEFT') + ->join('user_group p','a.group_id = p.id','LEFT') + ->where($where) + ->order('a.id asc') + ->count(); + $res = [ + 'count' => $count, + 'data' => $data, + ]; + return $this->success('请求成功',$res); + } + /** + * 单个用户查询 + */ + public function getEvaluationlevelFind() + { + $id = $this->request->post('id'); + if (!$id) { + $this->error(__('Invalid parameters')); + } + $ret = Db::name('evaluation_level')->where('id',$id)->find(); + if ($ret) { + $this->success(__('Logged in successful'), $ret); + } else { + $this->error($this->auth->getError()); + } + } + + public function create() + { + $data = $this->request->post(); + // if($data['password']){ + // $data['password'] = md5($data['password']); + // } + // $data['createtime'] = date('Y-m-d H:i:s'); + // $data['updatetime'] = date('Y-m-d H:i:s'); + $result = Db::name('evaluation_level')->strict(false)->insert($data); + if ($result) { + return $this->success('添加成功',$result); + } else { + return $this->error('添加失败',$result); + } + } + + /** + * 更新记录 + * + * @param Request $request + * @param int $id + * @return \think\Response + */ + public function update() + { + $id = $this->request->post('id'); + $data = $this->request->post(); + $result = Db::name('evaluation_level')->where('id', $id)->strict(false)->update($data); + if ($result) { + return $this->success('更新成功',$result); + } else { + return $this->error('更新失败',$result); + } + } + + + /** + * 删除记录 + * + * @param int $id + * @return \think\Response + */ + public function delete() + { + $id = $this->request->post('id'); + if(!$id){ + return $this->error('缺少参数'); + } + $result = Db::name('evaluation_level')->delete($id); + if ($result) { + return $this->success('删除成功',$result); + } else { + return $this->error('删除失败',$result); + } + } + + +} diff --git a/application/api/controller/backend/ExcelController.php b/application/api/controller/backend/ExcelController.php new file mode 100644 index 0000000..67a3b75 --- /dev/null +++ b/application/api/controller/backend/ExcelController.php @@ -0,0 +1,274 @@ +request->get('ids',''); + // $ids = '9,10,12,13,'; + if(empty($ids)) { + return $this->error('缺少用户ID参数'); + } + + // 转换ID格式 + $idArray = explode(',', rtrim($ids, ',')); + $idArray = array_filter($idArray); // 过滤空值 + if(empty($idArray)) { + return $this->error('无效的ID参数'); + } + + + // 构建查询条件 + $where = [ + 'a.id' => ['in', $idArray] + ]; + // $this->success('返回成功', $where); + // 执行查询 + $date = Db::name('addition_and_subtraction_records') + ->alias('a') + ->field('a.*,u.nickname,g.name as group_name,w.nickname as zm_nickname,p.project_name,p.scoring_criteria,z.nickname as tb_nickname,a.fj_url') + ->join('user u','a.user_id = u.id','LEFT') + ->join('user_group g','a.group_id = g.id','LEFT') + ->join('user w','a.zm_user_id = w.id','LEFT') + ->join('user z','a.tb_user_id = z.id','LEFT') + ->join('plus_minus_scoring p','a.assessment_project = p.id','LEFT') + ->where($where) + ->order('a.id', 'desc') + ->select(); + // $this->success('返回成功', $date); + // 创建一个新的 Excel 文件 + + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + + // 设置表头 + $headers = ['姓名', '记录时间', '加减分类型', '记录人', '加减分项目', '内容', '分值', '附件地址']; // 根据你的 member 表字段进行调整 + $columnIndex = 1; // A = 1, B = 2, ... + foreach ($headers as $header) { + $sheet->setCellValueByColumnAndRow($columnIndex, 1, $header); + $columnIndex++; + } + + // 填充数据 + $rowNumber = 2; // 从第二行开始填充数据 + foreach ($date as $member) { + $type = '加分'; + if($member['assessment_type'] == 2){ + $type = '减分'; + } + $columnIndex = 1; + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['nickname']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fsdate']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $type); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['tb_nickname']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['project_name']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['scoring_criteria']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['score_value']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fj_url']); + $rowNumber++; + } + + // 保存到 PHP 输出流 + $writer = new Xlsx($spreadsheet); + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment; filename="' . '加减分数据' . date('YmdHis') . '.xlsx"'); + // header('Content-Disposition: attachment;filename="活动报名列表' . date('YmdHis') . '.xlsx"'); + header('Cache-Control: max-age=0'); + + // 输出到浏览器供用户下载 + $writer->save('php://output'); + + // 清理并退出 + exit; + } + + public function groupIndexrecordsex() + { + $ids = $this->request->param('ids',''); + $searchMonth = $this->request->param('month', date('Y-m')); + + // 转换ID格式 + $idArray = explode(',', rtrim($ids, ',')); + $group_id = array_filter($idArray); // 过滤空值 + if(empty($group_id)) { + return $this->error('无效的ID参数'); + } + // 参数验证 + // if (!$group_id) { + // $this->error('无效的id'); + // } + if (!preg_match('/^\d{4}-\d{2}$/', $searchMonth)) { + $this->error('月份参数格式错误'); + } + + + // 计算时间范围 + $firstDay = $searchMonth . '-01 00:00:00'; + $lastDay = date('Y-m-d 23:59:59', strtotime("last day of $searchMonth")); + + + // 分页查询用户 + $users = Db::name('user') + ->alias('u') + ->field(['u.id', 'u.nickname AS username', 'g.name AS group_name']) + ->join('user_group g', 'u.group_id = g.id') + ->where('u.id','in', $group_id) + ->select(); + + // 统计分数(使用子查询优化) + $scores = Db::name('addition_and_subtraction_records') + ->field([ + 'user_id', + 'SUM(CASE WHEN assessment_type = 1 THEN score_value ELSE 0 END) AS total_addition', + 'SUM(CASE WHEN assessment_type = 2 THEN score_value ELSE 0 END) AS total_subtraction' + ]) + ->whereTime('fsdate', 'between', [$firstDay, $lastDay]) + ->group('user_id') + ->select(); + + // 构建返回数据 + $returnData = []; + foreach ($users as $user) { + $scoreArray = array_column($scores, null, 'user_id'); + $total_addition = $scoreArray[$user['id']]['total_addition'] ?? 0; + $total_subtraction = $scoreArray[$user['id']]['total_subtraction'] ?? 0; + + $returnData[] = [ + 'user_id' => $user['id'], + 'username' => $user['username'], + 'group_name' => $user['group_name'], + 'month' => $searchMonth, + 'total_addition' => floatval($total_addition), + 'total_subtraction' => floatval($total_subtraction) + ]; + } + + + // return $this->success('评价成功', $returnData); + // $this->success('返回成功', $date); + // 创建一个新的 Excel 文件 + + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + + // 设置表头 + $headers = ['姓名', '科室', '月份', '加分值', '扣分值']; // 根据你的 member 表字段进行调整 + $columnIndex = 1; // A = 1, B = 2, ... + foreach ($headers as $header) { + $sheet->setCellValueByColumnAndRow($columnIndex, 1, $header); + $columnIndex++; + } + + // 填充数据 + $rowNumber = 2; // 从第二行开始填充数据 + foreach ($returnData as $member) { + $columnIndex = 1; + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['username']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['group_name']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['month']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['total_addition']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['total_subtraction']); + $rowNumber++; + } + + // 保存到 PHP 输出流 + $writer = new Xlsx($spreadsheet); + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment; filename="' . '年终考评数据' . date('YmdHis') . '.xlsx"'); + // header('Content-Disposition: attachment;filename="活动报名列表' . date('YmdHis') . '.xlsx"'); + header('Cache-Control: max-age=0'); + + // 输出到浏览器供用户下载 + $writer->save('php://output'); + + // 清理并退出 + exit; + } + + public function RejectRedEnvelopesEs() + { + $ids = $this->request->param('ids',''); + + // 转换ID格式 + $idArray = explode(',', rtrim($ids, ',')); + $idArray = array_filter($idArray); // 过滤空值 + if(empty($idArray)) { + return $this->error('无效的ID参数'); + } + $where = [ + 'a.id' => ['in', $idArray] + ]; + $date = Db::name('reject_red_envelopes') + ->field('a.*,u.nickname,g.name as group_name,w.nickname as zm_nickname') + ->alias('a') + ->join('user u','a.user_id = u.id','LEFT') + ->join('user_group g','a.group_id = g.id','LEFT') + ->join('user w','a.zm_user_id = w.id','LEFT') + ->where($where) + ->order('a.id', 'desc') + ->select(); + + // return $this->success('查询成功',$date); + + // return $this->success('评价成功', $returnData); + // $this->success('返回成功', $date); + // 创建一个新的 Excel 文件 + + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + + // 设置表头 + $headers = ['发生时间', '科室', '病区', '当事人姓名', '患者姓名', '人员编号', '退还金额', '退还日期', '退还方式', '备注', '附件地址链接']; // 根据你的 member 表字段进行调整 + $columnIndex = 1; // A = 1, B = 2, ... + foreach ($headers as $header) { + $sheet->setCellValueByColumnAndRow($columnIndex, 1, $header); + $columnIndex++; + } + + // 填充数据 + $rowNumber = 2; // 从第二行开始填充数据 + foreach ($date as $member) { + $fangshi = '现金'; + if($member['refunding_type'] == 2){ + $fangshi = '转账'; + } + $columnIndex = 1; + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fsdate']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['group_name']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['bq_name']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['nickname']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['hz_name']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['code']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['refunding_amount']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['thdate']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $fangshi); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['notes']); + $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fj_url']); + $rowNumber++; + } + + // 保存到 PHP 输出流 + $writer = new Xlsx($spreadsheet); + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment; filename="' . '拒收红包数据' . date('YmdHis') . '.xlsx"'); + // header('Content-Disposition: attachment;filename="活动报名列表' . date('YmdHis') . '.xlsx"'); + header('Cache-Control: max-age=0'); + + // 输出到浏览器供用户下载 + $writer->save('php://output'); + + // 清理并退出 + exit; + } + +} \ No newline at end of file diff --git a/application/api/controller/backend/Mail.php b/application/api/controller/backend/Mail.php new file mode 100644 index 0000000..493fc97 --- /dev/null +++ b/application/api/controller/backend/Mail.php @@ -0,0 +1,79 @@ +request->post('page',1); + $size = $this->request->post('size',10); + $data = Db::name('mail') + ->field('a.*,w.nickname') + ->alias('a') + ->join('user w','a.user_id = w.id','LEFT') + ->page($page,$size) + ->order('a.id asc') + ->select(); + $count = Db::name('mail') + ->field('a.*,w.nickname') + ->alias('a') + ->join('user w','a.user_id = w.id','LEFT') + ->count(); + $res = [ + 'count' => $count, + 'data' => $data, + ]; + return $this->success('请求成功',$res); + } + + /** + *添加数据 + */ + public static function createMail($user_id,$notification_content) + { + $data['createtime'] = date('Y-m-d H:i:s'); + $data['user_id'] = $user_id; + $data['notify_status'] = 1; + $data['notification_content'] = $notification_content; + $result = Db::name('mail')->strict(false)->insert($data); + + } + + /** + *修改 + */ + public function updateMail() + { + $id = $this->request->post('id'); + if (!$id) { + $this->error(__('Invalid parameters')); + } + $data = []; + $data['createtime'] = date('Y-m-d H:i:s'); + $data['notify_status'] = 2; + $result = Db::name('mail')->where('id', $id)->update($data); + if ($result) { + return $this->success('更新成功',$result); + } else { + return $this->error('更新失败',$result); + } + + } + + +} diff --git a/application/api/controller/backend/Monthly.php b/application/api/controller/backend/Monthly.php index aa270e6..f71dcde 100644 --- a/application/api/controller/backend/Monthly.php +++ b/application/api/controller/backend/Monthly.php @@ -5,6 +5,7 @@ namespace app\api\controller\backend; use app\common\controller\Api; use app\api\model\Admin as AdminModel; use think\Db; +use app\api\controller\backend\Mail; /** * 月度控制器 @@ -263,6 +264,11 @@ class Monthly extends Api if (!empty($insertData)) { $result = Db::name('scoringrecord')->strict(false)->insertAll($insertData); if ($result) { + $user = Db::name('user')->where('id', $user_id)->find(); + $group_id = $user['group_id']; + $mail_user = Db::name('user')->where('group_id', $group_id)->where('auth_group_id',4)->find(); + $mail_user_id = $mail_user['id']; + Mail::createMail($mail_user_id,'您的科室下有月度自评待审核人员'); return $this->success('数据插入成功', $result); } else { return $this->error('数据插入失败'); diff --git a/application/api/controller/backend/PartyStyle.php b/application/api/controller/backend/PartyStyle.php new file mode 100644 index 0000000..3d7e807 --- /dev/null +++ b/application/api/controller/backend/PartyStyle.php @@ -0,0 +1,124 @@ +request->post('page',1); + $size = $this->request->post('size',10); + // 从数据库中获取所有数据 + $data = Db::name('party_style')->select(); + $count = Db::name('party_style')->count(); + $res = [ + 'data' => $data, + 'count' => $count + ]; + return $this->success('请求成功',$res); + } + + + + + + /** + *单个科室查询 + */ + public function getPartyStylFind() + { + $id = $this->request->post('id'); + if(!$id){ + return $this->error('缺少参数'); + } + // 从数据库中获取所有数据 + $data = Db::name('party_style')->where('id', $id)->find(); + + return $this->success('请求成功',$data); + } + + + /** + *添加数据 + */ + public function create() + { + $data = $this->request->post(); + $data['createtime'] = date('Y-m-d H:i:s'); + $result = Db::name('party_style')->strict(false)->insert($data); + if ($result) { + return $this->success('添加成功',$result); + } else { + return $this->error('添加失败',$result); + } + } + + /** + * 更新记录 + * + * @param Request $request + * @param int $id + * @return \think\Response + */ + public function update() + { + $id = $this->request->post('id'); + if (!$id) { + return $this->error('参数错误'); + } + + // 获取原始POST数据(包含所有字段) + $data = $_POST; + + // 移除ID字段(避免更新ID) + // unset($data['id']); + // return $this->success('更新成功', $data); + // 关闭字段严格校验 + $result = Db::name('party_style') + ->where('id', $id) + ->strict(false) // 关闭字段白名单校验 + ->update($data); + + if ($result !== false) { + return $this->success('更新成功', $result); + } else { + return $this->error('更新失败'); + } + } + + + /** + * 删除记录 + * + * @param int $id + * @return \think\Response + */ + public function delete() + { + $id = $this->request->post('id'); + if(!$id){ + return $this->error('缺少参数'); + } + $result = Db::name('party_style')->delete($id); + if ($result) { + return $this->success('删除成功',$result); + } else { + return $this->error('删除失败',$result); + } + } + +} diff --git a/application/api/controller/backend/Pdf.php b/application/api/controller/backend/Pdf.php new file mode 100644 index 0000000..197b5bf --- /dev/null +++ b/application/api/controller/backend/Pdf.php @@ -0,0 +1,527 @@ +request->get('id'); + if(!$id){ + return $this->error('缺少参数'); + } + $user = Db::name('politics') + ->field('a.*,p.nickname as user_name,p.gender,u.name as group_name') + ->alias('a') + ->join('user p','a.user_id = p.id','LEFT') + ->join('user_group u','a.group_id = u.id','LEFT') + ->where('a.id', $id) + ->find(); + + // return $this->success('请求成功',$user); + $content = htmlspecialchars_decode($user['politics_content']); + $FontStyle = 'stsongstdlight';//字体 + + + //引入扩展 + vendor('Tcpdf.tcpdf'); + + //初始化tcpdf className = Tcpdf + $pdf = new \Tcpdf('P', 'mm', 'A4', true, 'UTF-8', false); + $pdf->SetFont($FontStyle, '', 12); + + // 是否显示页眉 + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(true); + + //设置文档对齐,间距,字体,图片 + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + + //设置页眉页脚 边距 + $pdf->setHeaderMargin(PDF_MARGIN_HEADER); + $pdf->setFooterMargin(PDF_MARGIN_FOOTER); + + //自动分页 + $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + $pdf->setFontSubsetting(true); + + +$if_organization = $user['open_status'] == 1 ? '匿名' : $user['user_name']; +$gender = $user['gender'] == 1 ? '男' : '女'; +$acceptance_status = $user['acceptance_status'] == 1 ? '待处理' : '已回复'; +// $tuanweifuzerenxinxiPhone = ''; +// if($user_info['tuanweifuzerenxinxi']){ +// $user_info['tuanweifuzerenxinxi'] = json_decode($user_info['tuanweifuzerenxinxi'], true)[0]['name']; +// $tuanweifuzerenxinxiPhone = json_decode($user_info['tuanweifuzerenxinxi'], true)[0]['phone']; +// // } +// return $this->success('请求成功',$user); +// var_dump($user);die(); +$table_info_three = ' + +
姓名 | +'.$user['user_name'].' | +||||
科室 | +'.$user['group_name'].' | +||||
投诉时间 | +'.$user['createtime'].' | +||||
处理状态 | +'.$acceptance_status.' | +||||
处理内容 | +'.$user['acceptance_content'].' | + +||||
受理时间 | +'.$user['acceptance_time'].' | +||||
投诉内容 | +'.$user['politics_content'].' | +||||
本人签字 |
+
+ + + + 本人签字: + 年 + 月 + 日 + |
+ ||||
本人所在单位回访意见 |
+
+ + + + 盖章: + 年 + 月 + 日 + |
+
姓 名: '.$user['nickname'].'
科 室: '.$user['group_name'].'
填表日期: '.date('Y年m月d日',time()).'
信阳市第五人民医院
+二○二五年制
'; + $pdf->writeHTML($html_three, true, false, true, false, ''); + +$pdf->SetLeftMargin(10); +$table_info_three = ' + +姓名 | +'.$user['nickname'].' | +科室 | +'.$user['group_name'].' | +政治面貌 | +'.$user['nickname'].' | +||||
岗位 | +'.$user['position'].' | +职称 | +'.$user['administrative_position'].' | +出生日期 | +'.$user['birthday'].' | +||||
自我评价小结 | +
+ + + |
+||||||||
自我评价 | +
+ 等级:> 优秀□ 良好□ 一般□ 较差□
+ + 个人签名: + 年 + 月 + 日 + + |
+||||||||
科室评价意见 | +
+ 等级:> 优秀□ 良好□ 一般□ 较差□
+ + 科室评价负责人签字: + 年 + 月 + 日 + + |
+||||||||
单位意见评价 | +
+ 等级:> 优秀□ 良好□ 一般□ 较差□
+ + (盖章): + 年 + 月 + 日 + + |
+
考评内容 | +分值 | +得分 | +||||||
一、爱岗敬业奉献,恪守职业道德(15分) |
+ 1.服务热情周到,态度和蔼可亲, 着装整洁,举止端庄,语言文明规范,无“生、冷、硬、顶、推、拖”现象。 | +3分 | ++ | |||||
2.加强政治理论和职业道德学习,刻苦钻研与业务工作相关的新知识、新技术,提高专业技术能力和水平,提升医疗服务质量。 | +3分 | ++ | ||||||
3.树立救死扶伤、以病人为中心、全心全意为人民服务的宗旨意识和服务意识,大力弘扬新时代卫生职业精神,热爱本职工作;责任意识强,有效防范杜绝医疗差错、医疗事故的发生。 | +3分 | ++ | ||||||
4.平等对待患者,做到一视同仁,不歧视患者。维护患者合法权益,尊重患者知情权、选择权和隐私权,为患者保守医疗秘密。 | +3分 | ++ | ||||||
5.依法依规开展临床药物、医疗器械及临床医疗技术试验,应用新技术和有创诊疗活动中,遵守医学伦理道德,尊重患者的知情同意权。 | +3分 | ++ | ||||||
二、严格遵守“九项”准则,切实规范诊疗行为(75分) |
+ 1.合法按劳取酬,不接受商业提成。依法依规按劳取酬。严禁利用执业之便开单提成;严禁以商业目的进行统方;除就诊医院所在医联体的其他医疗机构,和被纳入医保“双通道”管理的定点零售药店外,严禁安排患者到其他指定地点购买医药耗材等产品;严禁向患者推销商品或服务并从中谋取私利;严禁接受互联网企业与开处方配药有关的费用。 | +10分 | ++ | |||||
2.严守诚信原则,不参与欺诈骗保。依法依规合理使用医疗保障基金,遵守医保协议管理,向医保患者告知提供的医药服务是否在医保规定的支付范围内。严禁诱导、协助他人冒名或者虚假就医、购药、提供虚假证明材料、串通他人虚开费用单据等手段骗取、套取医疗保障基金。 | +10分 | ++ | ||||||
3.依据规范行医,不实施过度诊疗。严格执行各项规章制度,在诊疗活动中应当向患者说明病情、医疗措施。严禁以单纯增加医疗机构收入或谋取私利为目的过度治疗和过度检查,给患者增加不必要的风险和费用负担。 | +8分 | ++ | ||||||
4.遵守工作规程,不违规接受捐赠。依法依规接受捐赠。严禁以个人名义,或者假借单位名义接受利益相关者的捐赠资助,并据此区别对待患者。 | +7分 | ++ | ||||||
5.恪守保密准则,不泄露患者隐私。确保患者院内信息安全。严禁违规收集、使用、加工、传输、透露、买卖患者在医疗机构内所提供的个人资料、产生的医疗信息。 | +5分 | ++ | ||||||
6.服从诊疗需要,不牟利转介患者。客观公正合理地根据患者需要提供医学信息、运用医疗资源。除因需要在医联体内正常转诊外,严禁以谋取个人利益为目的,经由网上或线下途径介绍、引导患者到指定医疗机构就诊。 | +10分 | ++ | ||||||
7.维护诊疗秩序,不破坏就医公平。坚持平等原则,共建公平就医环境。严禁利用号源、床源、紧缺药品耗材等医疗资源或者检查、手术等诊疗安排收受好处、损公肥私。 | +5分 | ++ | ||||||
8.共建和谐关系,不收受患方“红包”。恪守医德、严格自律。严禁索取或者收受患者及其亲友的礼品、礼金、消费卡和有价证券、股权、其他金融产品等财物;严禁参加其安排、组织或者支付费用的宴请或者旅游、健身、娱乐等活动安排。 | +10分 | ++ | ||||||
9.恪守交往底线,不收受企业回扣。遵纪守法、廉洁从业。严禁接受药品、医疗设备、医疗器械、医用卫生材料等医疗产品生产、经营企业或者经销人员以任何名义、形式给予的回扣;严禁参加其安排、组织或者支付费用的宴请或者旅游、健身、娱乐等活动安排。 | +10分 | ++ | ||||||
三、服从指挥调配,团结协作共事(10分) | +1.服从指挥、调配,积极参加上级安排的指令性医疗任务和社会公益性的疫情防控、义诊、对口帮扶和突发公共卫生事件等医疗活动。 | +5分 | ++ | |||||
2.正确处理同行、同事间的关系,互相尊重,互相配合,取长补短,共同进步。 | +5分 | ++ | ||||||
总分 | ++ | + |