master #1
@ -301,4 +301,58 @@ 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('审核操作失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,47 +174,81 @@ 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('月份参数格式错误');
|
||||
}
|
||||
if ($page < 1 || $limit < 1) {
|
||||
$this->error('分页参数错误');
|
||||
}
|
||||
|
||||
// 计算月末日期
|
||||
$firstDay = $searchMonth . '-01';
|
||||
$lastDay = date('Y-m-d', strtotime("last day of $searchMonth"));
|
||||
// 计算时间范围
|
||||
$firstDay = $searchMonth . '-01 00:00:00';
|
||||
$lastDay = date('Y-m-d 23:59:59', strtotime("last day of $searchMonth"));
|
||||
|
||||
$result = Db::name('user')
|
||||
// 获取用户总数(用于分页)
|
||||
$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(){
|
||||
// 接收参数
|
||||
$userId = $this->request->param('user_id', 0, 'intval');
|
||||
|
132
application/api/controller/backend/Evaluationlevel.php
Normal file
132
application/api/controller/backend/Evaluationlevel.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\backend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\common\library\Ems;
|
||||
use app\common\library\Sms;
|
||||
use fast\Random;
|
||||
use think\Config;
|
||||
use think\Validate;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 考评级别
|
||||
*/
|
||||
class Evaluationlevel extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function geEvaluationlevelData()
|
||||
{
|
||||
$group_id = $this->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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
274
application/api/controller/backend/ExcelController.php
Normal file
274
application/api/controller/backend/ExcelController.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
namespace app\api\controller\backend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class ExcelController extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
|
||||
|
||||
public function dailyexport()
|
||||
{
|
||||
$ids = $this->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;
|
||||
}
|
||||
|
||||
}
|
79
application/api/controller/backend/Mail.php
Normal file
79
application/api/controller/backend/Mail.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\backend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 站内信控制器
|
||||
*/
|
||||
class Mail extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
*/
|
||||
public function getMailData()
|
||||
{
|
||||
// 从数据库中获取所有数据
|
||||
$page = $this->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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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('数据插入失败');
|
||||
|
124
application/api/controller/backend/PartyStyle.php
Normal file
124
application/api/controller/backend/PartyStyle.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\backend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\api\model\Admin as AdminModel;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 党风教育控制器
|
||||
*/
|
||||
class PartyStyle extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
*/
|
||||
public function getPartyStylData()
|
||||
{
|
||||
$page = $this->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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
527
application/api/controller/backend/Pdf.php
Normal file
527
application/api/controller/backend/Pdf.php
Normal file
@ -0,0 +1,527 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\backend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use Exception;
|
||||
use think\Session;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf as PdfWriter;
|
||||
use app\common\model\Member;
|
||||
use think\Db;
|
||||
|
||||
class Pdf extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
public function exportPdf()
|
||||
{
|
||||
$id = $this->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 = '
|
||||
<style>
|
||||
table tr{
|
||||
line-height:30px;
|
||||
}
|
||||
table td{
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<div style="text-align: center; font-size: 36px; font-weight: bold; width: 80%; margin: 50px auto; padding-bottom: 10px;">
|
||||
投诉建议回访表
|
||||
</div>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="0">
|
||||
<tr >
|
||||
<td>姓名</td>
|
||||
<td colspan="5">'.$user['user_name'].'</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>科室</td>
|
||||
<td colspan="5">'.$user['group_name'].'</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>投诉时间</td>
|
||||
<td colspan="5">'.$user['createtime'].'</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>处理状态</td>
|
||||
<td colspan="5">'.$acceptance_status.'</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>处理内容</td>
|
||||
<td colspan="5">'.$user['acceptance_content'].'</td>
|
||||
|
||||
</tr>
|
||||
<tr >
|
||||
<td>受理时间</td>
|
||||
<td colspan="5">'.$user['acceptance_time'].'</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>投诉内容</td>
|
||||
<td colspan="5">'.$user['politics_content'].'</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><p> </p><p> </p>本人签字</td>
|
||||
<td colspan="5">
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<span style="width:200px;"> 本人签字: </span>
|
||||
<span style="width:100px;"> 年 </span>
|
||||
<span style="width:100px;"> 月 </span>
|
||||
<span style="width:100px;"> 日 </span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr >
|
||||
<td><p> </p>本人所在单位回访意见</td>
|
||||
<td colspan="5">
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<span style="width:200px;"> 盖章: </span>
|
||||
<span style="width:100px;"> 年 </span>
|
||||
<span style="width:100px;"> 月 </span>
|
||||
<span style="width:100px;"> 日 </span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>';
|
||||
|
||||
//设置正文字体,大小 (stsongstdlight,网上说这个字体支持的文字更全,支持中文不乱码)
|
||||
$pdf->SetFont($FontStyle, '', 14);
|
||||
//创建页面,渲染PDF
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAlpha(0.2); //设置你需要的透明度
|
||||
$img_file = $_SERVER["DOCUMENT_ROOT"] .'water.png';
|
||||
$pdf->Image($img_file, 10, 0, 0, 0, '', '', '', true, 300, '', false, false);
|
||||
$pdf->SetAlpha(1);//恢复原始透明度
|
||||
$pdf->writeHTML($table_info_three, true, false, false, false, '');
|
||||
|
||||
|
||||
$pdf->LastPage();
|
||||
//文件保存
|
||||
$saveName = date('Y-m-d').'.pdf';
|
||||
$savePath = $saveName;
|
||||
|
||||
//PDF输出模式 I:在浏览器中打开,D:下载,F:在服务器生成pdf ,S:只返回pdf的字符串
|
||||
$pdf->Output($savePath,'D');
|
||||
if(!file_exists($savePath)){
|
||||
$pdf->Output($savePath,'D');
|
||||
};
|
||||
return json(['status'=>'11','msg'=>'生成成功']);
|
||||
}
|
||||
|
||||
|
||||
public function personalProfile()
|
||||
{
|
||||
$user_id = $this->request->get('id',261);
|
||||
$time = $this->request->get('time',date('Y'));
|
||||
$evaluation_schedule_id = $this->request->post('evaluation_schedule_id');
|
||||
$scoringrecord_status = $this->request->post('scoringrecord_status');
|
||||
$where = [];
|
||||
if($user_id){
|
||||
$where['a.id'] = $user_id;
|
||||
}
|
||||
$user = Db::name('user')
|
||||
->field('a.*,p.name as group_name')
|
||||
->alias('a')
|
||||
->join('user_group p','a.group_id = p.id','LEFT')
|
||||
->where($where)
|
||||
->find();
|
||||
|
||||
// return $this->success('查询成功', $result);
|
||||
// foreach ($result as $key => $value) {
|
||||
// $group_name = Db::name('user_group')->where('id', $value['group_id'])->value('name');
|
||||
$user_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('self_score');
|
||||
$department_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('department_score');
|
||||
$hospital_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('hospital_score');
|
||||
$party_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('party_branch_score');
|
||||
$overall_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('overall_party_score');
|
||||
//获取改年总加分的分值
|
||||
$zongjiafenfenzhi = Db::name('addition_and_subtraction_records')->where('user_id',$user_id)->where('YEAR(createtime)', $time)->where('status',2)->where('assessment_type',1)->sum('score_value');
|
||||
//获取改年总减分的分值
|
||||
$zongjianfenfenzhi = Db::name('addition_and_subtraction_records')->where('user_id', $user_id)->where('YEAR(createtime)', $time)->where('status',2)->where('assessment_type',2)->sum('score_value');
|
||||
$time= $time;
|
||||
$zongjiafen = 0;
|
||||
$scoringrecord_status = '1';
|
||||
$total_score = 0;
|
||||
|
||||
if($user_scoringrecord == 0){
|
||||
$scoringrecord_status = '2';
|
||||
}
|
||||
if($department_score_scoringrecord != 0){
|
||||
$scoringrecord_status = '3';
|
||||
}
|
||||
// if($result[$key]['party_score_scoringrecord'] != 0){
|
||||
// $result[$key]['scoringrecord_status'] = '5';
|
||||
// }
|
||||
// if($result[$key]['overall_score_scoringrecord'] != 0){
|
||||
// $result[$key]['scoringrecord_status'] = '6';
|
||||
// }
|
||||
if($hospital_score_scoringrecord != 0){
|
||||
$scoringrecord_status = '4';
|
||||
$total_score = $user_scoringrecord * 0.4 + $department_score_scoringrecord * 0.6 + $party_score_scoringrecord * 0.4 + $zongjiafenfenzhi - $zongjianfenfenzhi;
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
// return $this->success('查询成功', $result);
|
||||
|
||||
// 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);
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAlpha(0.2); //设置你需要的透明度
|
||||
|
||||
$pdf->SetAlpha(1);//恢复原始透明度
|
||||
$pdf->SetFont($FontStyle, '', 16);
|
||||
$pdf->Ln(33);
|
||||
$html_one = '<h1 style="text-align:center;line-height:50%;">信阳市传染病医院医德医风考评档案</h1>';
|
||||
$pdf->writeHTML($html_one, true, false, true, false, '');
|
||||
|
||||
$pdf->Ln(40);
|
||||
$pdf->SetLeftMargin(40);
|
||||
$pdf->Line(78, 107, 155, 107, $style=array());
|
||||
$pdf->Line(78, 115, 155, 115, $style=array());
|
||||
$pdf->Line(78, 123, 155, 123, $style=array());
|
||||
$html_two = '
|
||||
<dl style="letter-spacing:2px;font-size:14px;">
|
||||
<dd><p style="line-height:80%;">姓<span> </span>名:<span> </span>'.$user['nickname'].'</p></dd>
|
||||
<dd><p style="line-height:80%;">科<span> </span>室:<span> </span>'.$user['group_name'].'</p></dd>
|
||||
<dd><p style="line-height:80%;">填表日期:<span> </span>'.date('Y年m月d日',time()).'</p></dd>
|
||||
</dl>';
|
||||
$pdf->writeHTML($html_two, true, false, true, false, '');
|
||||
|
||||
$pdf->SetLeftMargin(55);
|
||||
$pdf->SetRightMargin(53);
|
||||
|
||||
$pdf->SetLeftMargin(55);
|
||||
$pdf->SetRightMargin(53);
|
||||
$pdf->Ln(60);
|
||||
$html_three = '
|
||||
<p style="text-align:center;line-height:40%;">信阳市第五人民医院</p>
|
||||
<p style="text-align:center;line-height:40%;">二○二五年制</p>';
|
||||
$pdf->writeHTML($html_three, true, false, true, false, '');
|
||||
|
||||
$pdf->SetLeftMargin(10);
|
||||
$table_info_three = '
|
||||
<style>
|
||||
table tr{
|
||||
line-height:40px;
|
||||
}
|
||||
table td{
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
</style>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="0">
|
||||
<tr >
|
||||
<td>姓名</td>
|
||||
<td colspan="2" >'.$user['nickname'].'</td>
|
||||
<td>科室</td>
|
||||
<td colspan="2">'.$user['group_name'].'</td>
|
||||
<td>政治面貌</td>
|
||||
<td colspan="3">'.$user['nickname'].'</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>岗位</td>
|
||||
<td colspan="2" >'.$user['position'].'</td>
|
||||
<td>职称</td>
|
||||
<td colspan="2">'.$user['administrative_position'].'</td>
|
||||
<td>出生日期</td>
|
||||
<td colspan="3">'.$user['birthday'].'</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>自我评价小结</td>
|
||||
<td colspan="9">
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>自我评价</td>
|
||||
<td colspan="9">
|
||||
等级:> 优秀□ 良好□ 一般□ 较差□
|
||||
<p>
|
||||
<span style="width:200px;"> 个人签名: </span>
|
||||
<span style="width:100px;"> 年 </span>
|
||||
<span style="width:100px;"> 月 </span>
|
||||
<span style="width:100px;"> 日 </span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>科室评价意见</td>
|
||||
<td colspan="9">
|
||||
等级:> 优秀□ 良好□ 一般□ 较差□
|
||||
<p>
|
||||
<span style="width:150px;"> 科室评价负责人签字: </span>
|
||||
<span style="width:100px;"> 年 </span>
|
||||
<span style="width:100px;"> 月 </span>
|
||||
<span style="width:100px;"> 日 </span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>单位意见评价</td>
|
||||
<td colspan="9">
|
||||
等级:> 优秀□ 良好□ 一般□ 较差□
|
||||
<p>
|
||||
<span style="width:200px;"> (盖章): </span>
|
||||
<span style="width:100px;"> 年 </span>
|
||||
<span style="width:100px;"> 月 </span>
|
||||
<span style="width:100px;"> 日 </span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
//设置正文字体,大小 (stsongstdlight,网上说这个字体支持的文字更全,支持中文不乱码)
|
||||
$pdf->SetFont($FontStyle, '', 14);
|
||||
//创建页面,渲染PDF
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAlpha(0.2); //设置你需要的透明度
|
||||
$img_file = $_SERVER["DOCUMENT_ROOT"] .'water.png';
|
||||
|
||||
$pdf->Image($img_file, 10, 0, 0, 0, '', '', '', true, 300, '', false, false);
|
||||
$pdf->SetLeftMargin(10);
|
||||
$pdf->SetRightMargin(10);
|
||||
|
||||
$pdf->SetLeftMargin(10);
|
||||
$pdf->SetRightMargin(10);
|
||||
$pdf->SetAlpha(1);//恢复原始透明度
|
||||
$pdf->SetMargins(0, 10, 10, true);
|
||||
$pdf->writeHTML($table_info_three, true, false, false, false, '');
|
||||
|
||||
|
||||
|
||||
|
||||
$table_info_one = '
|
||||
<style>
|
||||
table tr{line-height:40px;}
|
||||
table td{
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
table tr{line-height:30px;}
|
||||
table td{
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<h1 style="text-align:center;line-height:50%;">信阳市传染病医院医德医风考评档案</h1>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="0">
|
||||
|
||||
<tr >
|
||||
<td colspan="7">考评内容</td>
|
||||
<td>分值</td>
|
||||
<td>得分</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="5" ><p> </p>一、爱岗敬业奉献,恪守职业道德(15分)</td>
|
||||
<td colspan="6">1.服务热情周到,态度和蔼可亲, 着装整洁,举止端庄,语言文明规范,无“生、冷、硬、顶、推、拖”现象。</td>
|
||||
<td style="vertical-align: middle;">3分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">2.加强政治理论和职业道德学习,刻苦钻研与业务工作相关的新知识、新技术,提高专业技术能力和水平,提升医疗服务质量。</td>
|
||||
<td>3分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">3.树立救死扶伤、以病人为中心、全心全意为人民服务的宗旨意识和服务意识,大力弘扬新时代卫生职业精神,热爱本职工作;责任意识强,有效防范杜绝医疗差错、医疗事故的发生。</td>
|
||||
<td>3分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">4.平等对待患者,做到一视同仁,不歧视患者。维护患者合法权益,尊重患者知情权、选择权和隐私权,为患者保守医疗秘密。</td>
|
||||
<td>3分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">5.依法依规开展临床药物、医疗器械及临床医疗技术试验,应用新技术和有创诊疗活动中,遵守医学伦理道德,尊重患者的知情同意权。</td>
|
||||
<td>3分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td rowspan="9"><p> </p><p> </p>二、严格遵守“九项”准则,切实规范诊疗行为(75分)</td>
|
||||
<td colspan="6">1.合法按劳取酬,不接受商业提成。依法依规按劳取酬。严禁利用执业之便开单提成;严禁以商业目的进行统方;除就诊医院所在医联体的其他医疗机构,和被纳入医保“双通道”管理的定点零售药店外,严禁安排患者到其他指定地点购买医药耗材等产品;严禁向患者推销商品或服务并从中谋取私利;严禁接受互联网企业与开处方配药有关的费用。</td>
|
||||
<td>10分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">2.严守诚信原则,不参与欺诈骗保。依法依规合理使用医疗保障基金,遵守医保协议管理,向医保患者告知提供的医药服务是否在医保规定的支付范围内。严禁诱导、协助他人冒名或者虚假就医、购药、提供虚假证明材料、串通他人虚开费用单据等手段骗取、套取医疗保障基金。</td>
|
||||
<td>10分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">3.依据规范行医,不实施过度诊疗。严格执行各项规章制度,在诊疗活动中应当向患者说明病情、医疗措施。严禁以单纯增加医疗机构收入或谋取私利为目的过度治疗和过度检查,给患者增加不必要的风险和费用负担。</td>
|
||||
<td>8分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">4.遵守工作规程,不违规接受捐赠。依法依规接受捐赠。严禁以个人名义,或者假借单位名义接受利益相关者的捐赠资助,并据此区别对待患者。</td>
|
||||
<td>7分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">5.恪守保密准则,不泄露患者隐私。确保患者院内信息安全。严禁违规收集、使用、加工、传输、透露、买卖患者在医疗机构内所提供的个人资料、产生的医疗信息。</td>
|
||||
<td>5分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">6.服从诊疗需要,不牟利转介患者。客观公正合理地根据患者需要提供医学信息、运用医疗资源。除因需要在医联体内正常转诊外,严禁以谋取个人利益为目的,经由网上或线下途径介绍、引导患者到指定医疗机构就诊。</td>
|
||||
<td>10分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">7.维护诊疗秩序,不破坏就医公平。坚持平等原则,共建公平就医环境。严禁利用号源、床源、紧缺药品耗材等医疗资源或者检查、手术等诊疗安排收受好处、损公肥私。</td>
|
||||
<td>5分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">8.共建和谐关系,不收受患方“红包”。恪守医德、严格自律。严禁索取或者收受患者及其亲友的礼品、礼金、消费卡和有价证券、股权、其他金融产品等财物;严禁参加其安排、组织或者支付费用的宴请或者旅游、健身、娱乐等活动安排。</td>
|
||||
<td>10分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">9.恪守交往底线,不收受企业回扣。遵纪守法、廉洁从业。严禁接受药品、医疗设备、医疗器械、医用卫生材料等医疗产品生产、经营企业或者经销人员以任何名义、形式给予的回扣;严禁参加其安排、组织或者支付费用的宴请或者旅游、健身、娱乐等活动安排。</td>
|
||||
<td>10分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td rowspan="2">三、服从指挥调配,团结协作共事(10分)</td>
|
||||
<td colspan="6">1.服从指挥、调配,积极参加上级安排的指令性医疗任务和社会公益性的疫情防控、义诊、对口帮扶和突发公共卫生事件等医疗活动。</td>
|
||||
<td>5分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">2.正确处理同行、同事间的关系,互相尊重,互相配合,取长补短,共同进步。</td>
|
||||
<td>5分</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td colspan="1">总分</td>
|
||||
<td colspan="7"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<p></p>
|
||||
<h1 style="text-align:center;line-height:50%;">说明:优秀90-100分,良好76-89分,一般60-75分,较差﹤60分。</h1>
|
||||
';
|
||||
|
||||
|
||||
//设置正文字体,大小 (stsongstdlight,网上说这个字体支持的文字更全,支持中文不乱码)
|
||||
$pdf->SetFont($FontStyle, '', 10);
|
||||
//创建页面,渲染PDF
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAlpha(0.2); //设置你需要的透明度
|
||||
$img_file = $_SERVER["DOCUMENT_ROOT"] .'water.png';
|
||||
|
||||
$pdf->Image($img_file, 10, 0, 0, 0, '', '', '', true, 300, '', false, false);
|
||||
|
||||
$pdf->SetAlpha(1);//恢复原始透明度
|
||||
|
||||
$pdf->writeHTML($table_info_one, true, false, true, true, '');
|
||||
|
||||
$pdf->LastPage();
|
||||
//文件保存
|
||||
$saveName = date('Y-m-d').'.pdf';
|
||||
$savePath = $saveName;
|
||||
|
||||
//PDF输出模式 I:在浏览器中打开,D:下载,F:在服务器生成pdf ,S:只返回pdf的字符串
|
||||
$pdf->Output($savePath,'D');
|
||||
if(!file_exists($savePath)){
|
||||
$pdf->Output($savePath,'D');
|
||||
};
|
||||
return json(['status'=>'11','msg'=>'生成成功']);
|
||||
}
|
||||
}
|
@ -93,7 +93,9 @@ class Politics extends Api
|
||||
if ($result === false) {
|
||||
return $this->error('编辑失败');
|
||||
}
|
||||
$user = Db::name('politics')->where('id', $id)->find();
|
||||
|
||||
Mail::createMail($user['user_id'],'您的投诉建议已受理,请查看');
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
}
|
||||
|
@ -255,6 +255,11 @@ class Quarter 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('数据插入失败');
|
||||
@ -748,6 +753,16 @@ class Quarter extends Api
|
||||
// 对比并输出结果
|
||||
$result = [];
|
||||
foreach ($periods as $period) {
|
||||
if (!isset($scoringQuarters[$period])) {
|
||||
$scoringQuarters[$period] = [
|
||||
'plus_score' => 0,
|
||||
'minus_score' => 0,
|
||||
'self_score' => 0,
|
||||
'department_score' => 0,
|
||||
'hospital_score' => 0,
|
||||
'createtime' => null,
|
||||
];
|
||||
}
|
||||
list($year, $quarter) = explode('-', $period);
|
||||
$quarterStartMonth = ($quarter - 1) * 3 + 1;
|
||||
$quarterEndMonth = $quarter * 3;
|
||||
@ -786,11 +801,11 @@ class Quarter extends Api
|
||||
'quarter' => $period,
|
||||
'user' => $user['nickname'],
|
||||
'currentQuarter' => $currentPeriod,
|
||||
'plus_score' => $scoringQuarters[$period]['plus_score'] ?? '',
|
||||
'minus_score' => $scoringQuarters[$period]['minus_score'] ?? '',
|
||||
'self_score' => $scoringQuarters[$period]['self_score'] ?? '',
|
||||
'department_score' => $scoringQuarters[$period]['department_score'] ?? '',
|
||||
'hospital_score' => $scoringQuarters[$period]['hospital_score'] ?? '',
|
||||
'plus_score' => $scoringQuarters[$period]['plus_score'] ?? 0,
|
||||
'minus_score' => $scoringQuarters[$period]['minus_score'] ?? 0,
|
||||
'self_score' => $scoringQuarters[$period]['self_score'] ?? 0,
|
||||
'department_score' => $scoringQuarters[$period]['department_score'] ?? 0,
|
||||
'hospital_score' => $scoringQuarters[$period]['hospital_score'] ?? 0,
|
||||
'if' => isset($scoringQuarters[$period]) ? 2 : 1,
|
||||
'if_period' => $if_period,
|
||||
'scoringrecord_status' => $scoringrecord_status ?? 2,
|
||||
|
473
application/api/controller/backend/Questionnaire.php
Normal file
473
application/api/controller/backend/Questionnaire.php
Normal file
@ -0,0 +1,473 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\backend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\common\library\Ems;
|
||||
use app\common\library\Sms;
|
||||
use fast\Random;
|
||||
use think\Config;
|
||||
use think\Validate;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
use fast\Tree;
|
||||
/**
|
||||
* 调查问卷接口
|
||||
*/
|
||||
class Questionnaire extends Api
|
||||
{
|
||||
//如果$noNeedLogin为空表示所有接口都需要登录才能请求
|
||||
//如果$noNeedRight为空表示所有接口都需要验证权限才能请求
|
||||
//如果接口已经设置无需登录,那也就无需鉴权了
|
||||
//
|
||||
// 无需登录的接口,*表示全部
|
||||
protected $noNeedLogin = ['*','searchById', 'search'];
|
||||
// 无需鉴权的接口,*表示全部
|
||||
protected $noNeedRight = ['test2'];
|
||||
|
||||
protected $dataLimit = 'personal';
|
||||
|
||||
/**
|
||||
*
|
||||
* 问卷列表
|
||||
*
|
||||
*/
|
||||
public function questionnaireIndex(){
|
||||
$title = input('questionnaire');
|
||||
$page = input("page",1);
|
||||
$size = input("size",10);
|
||||
$Token = $this->request->header('Token');
|
||||
if(!$Token){
|
||||
return $this->error('缺少参数');
|
||||
}
|
||||
$user_id = Db::name('user')->where('token', $Token)->value('id');
|
||||
if(!$user_id){
|
||||
return $this->error('该用户不存在');
|
||||
}
|
||||
|
||||
$where = [];
|
||||
if($title){
|
||||
$where['title'] = ['like',"%$title%"];
|
||||
}
|
||||
$data = Db::name('questionnaire')
|
||||
->where($where)
|
||||
->order('releasetime desc')
|
||||
->page($page,$size)
|
||||
->select();
|
||||
foreach ($data as $key => $val){
|
||||
$res = Db::name('questionnaire_log')
|
||||
->where('questionnaire_id', $val['id'])
|
||||
->where('user_id', $user_id)
|
||||
->select();
|
||||
$data[$key]['type'] = '未填写';
|
||||
if($res){
|
||||
$data[$key]['type'] = '已填写';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$count = Db::name('questionnaire')
|
||||
->where($where)
|
||||
->count();
|
||||
$data = [
|
||||
'count' => $count,
|
||||
'data' => $data
|
||||
];
|
||||
$this->success('返回成功',$data);
|
||||
}
|
||||
|
||||
//单挑查询
|
||||
public function questionnairefind()
|
||||
{
|
||||
$questionnaireId = input('id');
|
||||
|
||||
// 1. 查询问卷所有题目(带权重排序)
|
||||
$topics = Db::name('questionnaire_topic')
|
||||
->where('questionnaire_id', $questionnaireId)
|
||||
->order('id desc') // 注意:原代码中的"wight"应为"weight"的拼写错误
|
||||
->select();
|
||||
|
||||
// 2. 预处理题目数据:解码选项
|
||||
$processedTopics = [];
|
||||
foreach ($topics as $topic) {
|
||||
$topic['option'] = json_decode($topic['option'], true);
|
||||
$processedTopics[$topic['id']] = $topic; // 使用ID作为键方便后续匹配
|
||||
}
|
||||
|
||||
// 3. 查询该问卷所有题目的答题记录
|
||||
$topicIds = array_keys($processedTopics);
|
||||
$answerLogs = Db::name('questionnaire_log')
|
||||
->where('topic_id', 'in', $topicIds)
|
||||
->select();
|
||||
|
||||
// 4. 合并答题记录到题目数据
|
||||
foreach ($answerLogs as $log) {
|
||||
$topicId = $log['topic_id'];
|
||||
if (isset($processedTopics[$topicId])) {
|
||||
// 添加 type 标识和答案数据
|
||||
// $processedTopics[$topicId]['type'] = 1;
|
||||
$processedTopics[$topicId]['topic'] = $log['option'];
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 转换为数组(保持顺序)
|
||||
$result = array_values($processedTopics);
|
||||
|
||||
$this->success('查询成功', $result);
|
||||
}
|
||||
|
||||
//问卷统计查询
|
||||
public function questionnaireStatistics(){
|
||||
$id = input('id');
|
||||
// 题目
|
||||
$topic = Db::name('questionnaire_topic')
|
||||
->where('activity_id', $id)
|
||||
->select();
|
||||
|
||||
$jianda = Db::name('questionnaire_topic')
|
||||
->where('questionnaire_id', $id)
|
||||
->order('wight desc')
|
||||
->select();
|
||||
foreach($jianda as $key => $val){
|
||||
$jianda[$key]['option'] = json_decode($val['option'], true);
|
||||
}
|
||||
$jianda_log = Db::name('questionnaire_topic')
|
||||
->where('questionnaire_id', $id)
|
||||
->column('id');
|
||||
$topic_id = implode(',',$jianda_log);
|
||||
$jiandaer = Db::name('questionnaire_log')
|
||||
->where('topic_id','in' ,$topic_id)
|
||||
->select();
|
||||
foreach($jianda as $topic_key => $topic_val){
|
||||
$log_jianda = [];
|
||||
foreach($jiandaer as $log_key => $log_val){
|
||||
|
||||
if($topic_val['id'] == $log_val['topic_id']){
|
||||
array_push($log_jianda, $log_val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$jianda[$topic_key]['list'] = $log_jianda;
|
||||
$jianda[$topic_key]['quantity'] = count($jianda[$topic_key]['list']);
|
||||
}
|
||||
// 遍历 $jianda 数组
|
||||
foreach ($jianda as &$val) { // 使用引用 & 来直接修改原数组
|
||||
// 遍历 'option' 数组
|
||||
foreach ($val['option'] as &$option) { // 使用引用 & 来直接修改原数组
|
||||
// 初始化 'num' 为 0(以防 'list' 中没有任何匹配的项)
|
||||
$option['num'] = 0;
|
||||
|
||||
// 遍历 'list' 数组
|
||||
foreach ($val['list'] as $b) {
|
||||
// 检查 'list' 中的 'option' 是否包含当前 'option' 的 'name'
|
||||
if (strpos($b['option'], $option['name']) !== false) {
|
||||
// 如果找到匹配项,增加 'num' 并退出循环(因为不需要继续检查)
|
||||
$option['num']++;
|
||||
// break; // 退出当前 'list' 的循环
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 取消对 $val 的引用,避免后续潜在问题
|
||||
unset($val);
|
||||
}
|
||||
$this->success('返回成功',$jianda);
|
||||
|
||||
}
|
||||
|
||||
public function questionnaireAdd(){
|
||||
$data = input();
|
||||
$data['createtime'] = time();
|
||||
$adddata = Db::name('questionnaire')->strict(false)->insert($data);
|
||||
if ($adddata) {
|
||||
$this->success('已添加');
|
||||
} else {
|
||||
$this->error('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function questionnaireEdit(){
|
||||
$data = input();
|
||||
$id = $data['id'];
|
||||
// $this->success('已更新',$data);
|
||||
|
||||
$update = Db::name('questionnaire')->where('id', $id)->strict(false)->update($data);
|
||||
if ($update) {
|
||||
$this->success('已更新');
|
||||
} else {
|
||||
$this->error('更新失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function questionnaireDel(){
|
||||
$data = input();
|
||||
$id = $data['id'];
|
||||
$delete = Db::name('questionnaire')->where('id', $id)->delete();
|
||||
if ($delete) {
|
||||
$this->success('已删除');
|
||||
} else {
|
||||
$this->error('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function topicIndex(){
|
||||
$data = input();
|
||||
$id = $data['id'];
|
||||
$topic = Db::name('questionnaire_topic')->where('questionnaire_id',$id)->select();
|
||||
if ($topic) {
|
||||
$this->success('查询成功',$topic);
|
||||
} else {
|
||||
$this->success('查询成功',[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function topicAdd(){
|
||||
$data = $_POST['topic'];
|
||||
$activity_id = $this->request->post('questionnaire_id');
|
||||
|
||||
if (!$activity_id) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
|
||||
// 解析 JSON 并校验
|
||||
$array = json_decode($data, true);
|
||||
if ($array === null) {
|
||||
$error = json_last_error_msg();
|
||||
$this->error("JSON 解析失败: " . $error);
|
||||
}
|
||||
|
||||
// 遍历处理数据
|
||||
foreach ($array as $key => $val) {
|
||||
$array[$key]['questionnaire_id'] = $activity_id;
|
||||
$array[$key]['createtime'] = date('Y-m-d H:i:s');
|
||||
$array[$key]['option'] = json_encode($val['option'], JSON_UNESCAPED_UNICODE); // 避免中文转义
|
||||
}
|
||||
|
||||
// 插入数据库
|
||||
$adddata = Db::name('questionnaire_topic')->strict(false)->insertAll($array);
|
||||
|
||||
if ($adddata) {
|
||||
$this->success('已添加');
|
||||
} else {
|
||||
$this->error('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function topicEdit(){
|
||||
$data = $_POST['topic'];
|
||||
$array = json_decode($data, true);
|
||||
// $this->success('已更新', $array);
|
||||
$id = $array['id'];
|
||||
$array['option'] = json_encode( $array['option'],true);
|
||||
$update = Db::name('questionnaire_topic')->where('id', $id)->strict(false)->update($array);
|
||||
|
||||
if ($update) {
|
||||
$this->success('已更新');
|
||||
} else {
|
||||
$this->error('内容未更新');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function topicDel(){
|
||||
$id = $this->request->post('id');
|
||||
if(!$id){
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
|
||||
$delete = Db::name('questionnaire_topic')->where('id', $id)->delete();
|
||||
if ($delete) {
|
||||
$this->success('已删除');
|
||||
} else {
|
||||
$this->error('删除失败');
|
||||
}
|
||||
}
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// 移动端
|
||||
public function appIndex(){
|
||||
$title = input('questionnaire');
|
||||
$page = input("page",1);
|
||||
$size = input("size",10);
|
||||
$where = [];
|
||||
if($title){
|
||||
$where['title'] = ['like',"%$title%"];
|
||||
}
|
||||
|
||||
$data = Db::name('questionnaire')
|
||||
->where($where)
|
||||
->order('releasetime desc')
|
||||
->page($page,$size)
|
||||
->select();
|
||||
$one = [];
|
||||
$two = [];
|
||||
$there = [];
|
||||
foreach($data as $key => $val){
|
||||
if(strtotime($val['releasetime']) < time() && strtotime($val['endtime']) > time()){
|
||||
$id = $val['id'];
|
||||
$val['log'] = Db::name('questionnaire_log')
|
||||
->where('questionnaire_id', $id)
|
||||
->group('member_id')
|
||||
->count();
|
||||
array_push($two,$val);
|
||||
}
|
||||
|
||||
}
|
||||
$this->success('返回成功',$two);
|
||||
}
|
||||
|
||||
//单挑查询
|
||||
public function appFind(){
|
||||
$id = input('id');
|
||||
|
||||
$data = Db::name('questionnaire')
|
||||
->where('id', $id)
|
||||
->order('releasetime desc')
|
||||
->select();
|
||||
// 题目
|
||||
$topic = Db::name('questionnaire_topic')
|
||||
->where('questionnaire_id', $id)
|
||||
->select();
|
||||
|
||||
$jianda = Db::name('questionnaire_topic')
|
||||
->where('questionnaire_id', $id)
|
||||
->where('type',1)
|
||||
->select();
|
||||
|
||||
$jianda_log = Db::name('questionnaire_topic')
|
||||
// ->field('id')
|
||||
->where('questionnaire_id', $id)
|
||||
->where('type',1)
|
||||
->column('id');
|
||||
$topic_id = implode(',',$jianda_log);
|
||||
$jiandaer = Db::name('questionnaire_log')
|
||||
// ->field('id')
|
||||
->where('topic_id','in' ,$topic_id)
|
||||
->select();
|
||||
|
||||
// var_dump($jiandaer);die();
|
||||
|
||||
|
||||
if($jianda_log){
|
||||
foreach($jianda as $topic_key => $topic_val){
|
||||
|
||||
$log_jianda = [];
|
||||
|
||||
foreach($jiandaer as $log_key => $log_val){
|
||||
|
||||
if($topic_val['id'] == $log_val['topic_id']){
|
||||
array_push($log_jianda, $log_val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$jianda[$topic_key]['list'] = $log_jianda;
|
||||
}
|
||||
}else{
|
||||
$jianda_log = [];
|
||||
}
|
||||
|
||||
foreach($topic as $key => $val){
|
||||
|
||||
$topic[$key]['count'] = Db::name('questionnaire_topic')
|
||||
->where('questionnaire_id', $id)
|
||||
->count();
|
||||
|
||||
$option = json_decode($val['option'],true);
|
||||
|
||||
$b = [];
|
||||
$c = [];
|
||||
foreach($option as $k => $v){
|
||||
|
||||
$a = Db::name('questionnaire_log')
|
||||
->where('topic_id', $val['id'])
|
||||
->where('option','like',"%$k%")
|
||||
->count();
|
||||
|
||||
$b = [
|
||||
'name' => $v['name'],
|
||||
'xvanxiang' => $k,
|
||||
'mun' => $a
|
||||
];
|
||||
array_push($c,$b);
|
||||
|
||||
}
|
||||
|
||||
$topic[$key]['canyurenshu'] = $c;
|
||||
if($val['type'] == 1){
|
||||
unset($topic[$key]);
|
||||
}
|
||||
|
||||
}
|
||||
$topic = array_values($topic);
|
||||
$info = [
|
||||
'data' => $data,
|
||||
'topic' =>$topic,
|
||||
'jianda'=>$jianda
|
||||
];
|
||||
$this->success('返回成功',$info);
|
||||
}
|
||||
|
||||
public function appAdd(){
|
||||
$option = $_POST['option'];
|
||||
$Token = $this->request->header('Token');
|
||||
if(!$Token){
|
||||
return $this->error('缺少参数');
|
||||
}
|
||||
$user_id = Db::name('user')->where('token', $Token)->value('id');
|
||||
if(!$user_id){
|
||||
return $this->error('该用户不存在');
|
||||
}
|
||||
$member_id = $user_id;
|
||||
$option = json_decode($option, true);
|
||||
|
||||
foreach($option as $key => $val){
|
||||
$option[$key]['user_id'] = $user_id;
|
||||
$option[$key]['createtime'] = date('Y-m-d H:i:s');
|
||||
$where = [];
|
||||
if($member_id){
|
||||
$where['user_id'] = $member_id;
|
||||
}
|
||||
if($val['questionnaire_id']){
|
||||
$where['questionnaire_id'] = $val['questionnaire_id'];
|
||||
}
|
||||
|
||||
$if = Db::name('questionnaire_log')
|
||||
->where($where)
|
||||
->find();
|
||||
if($if){
|
||||
$this->success('问卷只能填写一次哦');
|
||||
}
|
||||
}
|
||||
// $this->success('提交成功',$option);
|
||||
// $data = json_decode($option,true);
|
||||
$adddata = Db::name('questionnaire_log')
|
||||
->strict(false)
|
||||
->insertAll($option);
|
||||
|
||||
$this->success('提交成功',$adddata);
|
||||
}
|
||||
|
||||
public function appFindLog(){
|
||||
|
||||
$member_id = input('member_id');
|
||||
$questionnaire_id = input('questionnaire_id');
|
||||
$where = [];
|
||||
if($member_id){
|
||||
$where['member_id'] = $member_id;
|
||||
}
|
||||
if($questionnaire_id){
|
||||
$where['questionnaire_id'] = $questionnaire_id;
|
||||
}
|
||||
$if = Db::name('questionnaire_log')
|
||||
->where($where)
|
||||
->select();
|
||||
if($if){
|
||||
$this->success('返回成功',$if);
|
||||
}
|
||||
$this->error('未查询到');
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@ class RejectRedEnvelopes extends Api
|
||||
$status= $this->request->post('status');
|
||||
$time= $this->request->post('fsdate');
|
||||
$user_id= $this->request->post('user_id');
|
||||
// var_dump($group);die();
|
||||
$where = [];
|
||||
//判断该用户有没有权限审核
|
||||
if($this->level == 2){
|
||||
@ -57,6 +58,7 @@ class RejectRedEnvelopes extends Api
|
||||
if ($time) {
|
||||
$where['a.fsdate'] = $time;
|
||||
}
|
||||
// return $this->success('查询成功1',$where);
|
||||
}
|
||||
if($this->level == 1){
|
||||
$where['a.group_id'] = $this->group_id;
|
||||
@ -69,7 +71,7 @@ class RejectRedEnvelopes extends Api
|
||||
if ($user_id) {
|
||||
$where['a.user_id'] = $user_id;
|
||||
}
|
||||
|
||||
// return $this->success('查询成功2',$where);
|
||||
}
|
||||
if($this->auth_id == 1 && $group){
|
||||
$where['a.group_id'] = $group;
|
||||
@ -83,6 +85,7 @@ class RejectRedEnvelopes extends Api
|
||||
if ($user_id) {
|
||||
$where['a.user_id'] = $user_id;
|
||||
}
|
||||
// return $this->success('查询成功3',$where);
|
||||
}
|
||||
// 获取指定科室及其子科室的ID
|
||||
$groupIds = $this->getGroupAndSubGroupIds($group);
|
||||
@ -90,6 +93,7 @@ class RejectRedEnvelopes extends Api
|
||||
if (!empty($groupIds)) {
|
||||
$where['a.group_id'] = ['in', $groupIds];
|
||||
}
|
||||
// return $this->success('查询成功',$where);
|
||||
$date = Db::name('reject_red_envelopes')
|
||||
->field('a.*,u.nickname,g.name as group_name,w.nickname as zm_nickname')
|
||||
->alias('a')
|
||||
@ -159,26 +163,53 @@ class RejectRedEnvelopes extends Api
|
||||
/**
|
||||
* 审核
|
||||
*/
|
||||
public function examine(){
|
||||
public function examine()
|
||||
{
|
||||
// 1. 参数接收与基础验证
|
||||
$id = $this->request->post('id');
|
||||
$status = $this->request->post('status');
|
||||
$reason = $this->request->post('reason', ''); // 设置默认值避免未定义警告
|
||||
|
||||
// 2. 权限验证(前置检查)
|
||||
if ($this->level == 2) {
|
||||
return $this->error('您没有权限');
|
||||
return $this->error('您没有审核权限');
|
||||
}
|
||||
if(!$id || !$status){
|
||||
return $this->error('缺少参数');
|
||||
|
||||
// 3. 参数有效性验证
|
||||
if (empty($id) || !is_numeric($id)) {
|
||||
return $this->error('缺少有效的红包记录ID');
|
||||
}
|
||||
$where = [
|
||||
'id' => $id,
|
||||
];
|
||||
$update = [
|
||||
|
||||
if (!in_array($status, [1, 2, 3])) { // 假设状态值只能是1/2/3
|
||||
return $this->error('无效的审核状态值');
|
||||
}
|
||||
|
||||
// 4. 构建更新数据
|
||||
$updateData = [
|
||||
'status' => $status,
|
||||
// 'audit_time' => date('Y-m-d H:i:s') // 添加审核时间记录
|
||||
];
|
||||
$res = Db::name('reject_red_envelopes')->where($where)->update($update);
|
||||
if($res){
|
||||
return $this->success('审核成功');
|
||||
|
||||
// 5. 状态为驳回时的特殊处理
|
||||
if ($status == 3) {
|
||||
if (empty(trim($reason))) {
|
||||
return $this->error('驳回时必须填写原因');
|
||||
}
|
||||
return $this->error('审核失败');
|
||||
$updateData['reason'] = htmlspecialchars($reason); // 防止XSS攻击
|
||||
}
|
||||
|
||||
|
||||
$where = ['id' => $id];
|
||||
$result = Db::name('reject_red_envelopes')
|
||||
->where($where)
|
||||
->update($updateData);
|
||||
|
||||
if($result){
|
||||
$this->success('审核成功');
|
||||
|
||||
}
|
||||
return $this->error('操作失败,请重试');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
104
application/api/controller/backend/Solicitopinions.php
Normal file
104
application/api/controller/backend/Solicitopinions.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\backend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\api\model\Admin as AdminModel;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 征求意见
|
||||
*/
|
||||
class Solicitopinions extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
// // 参数验证
|
||||
$validate = $this->validate($param, [
|
||||
|
||||
'page' => 'number',
|
||||
'size' => 'number',
|
||||
]);
|
||||
|
||||
if (true !== $validate) {
|
||||
return $this->error($validate);
|
||||
}
|
||||
$where = [];
|
||||
if(!empty($param['group_id'])){
|
||||
$where['a.group_id'] = $param['group_id'];
|
||||
}
|
||||
$query = Db::name('solicit_opinions')
|
||||
->field('a.*,p.name as group_name')
|
||||
->alias('a')
|
||||
// ->join('user w','a.user_id = w.id','LEFT')
|
||||
->join('user_group p','a.group_id = p.id','LEFT')
|
||||
->where($where)
|
||||
// ->where('a.deletetime', 'null')
|
||||
->order('a.id', 'asc');
|
||||
|
||||
// 分页查询
|
||||
$list = $query->paginate([
|
||||
'page' => $param['page'] ?? 1,
|
||||
'list_rows' => $param['size'] ?? 10,
|
||||
]);
|
||||
|
||||
// 处理返回数据
|
||||
$data = [
|
||||
'total' => $list->total(),
|
||||
'list' => $list->items(),
|
||||
];
|
||||
|
||||
return $this->success('查询成功', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function h5add()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$user_id = $this->request->param('user_id', 0);
|
||||
|
||||
$param['politics_type'] = 1;
|
||||
if($user_id != 0){
|
||||
$param['politics_type'] = 2;
|
||||
$user = Db::name('user')
|
||||
->where('id', $user_id)
|
||||
->find();
|
||||
$param['nickname'] = $user['nickname'];
|
||||
$param['phone'] = $user['mobile'];
|
||||
}
|
||||
$param['createtime'] = date('Y-m-d H:i:s');
|
||||
$param['weigh'] = 100;
|
||||
// 参数验证
|
||||
$validate = $this->validate($param, [
|
||||
'group_id' => 'require|number',
|
||||
// 'nickname' => 'require',
|
||||
'phone' => 'require|number',
|
||||
'content' => 'require',
|
||||
]);
|
||||
|
||||
if (true !== $validate) {
|
||||
return $this->error($validate);
|
||||
}
|
||||
// 更新数据
|
||||
$result = Db::name('solicit_opinions')->strict(false)->insert($param);
|
||||
|
||||
if ($result === false) {
|
||||
return $this->error('添加失败');
|
||||
}
|
||||
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
}
|
@ -18,6 +18,17 @@ class User extends Api
|
||||
protected $noNeedLogin = ['*'];
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
public function getEvaluation()
|
||||
{
|
||||
$id = $this->request->header('Token');
|
||||
if(!$id){
|
||||
return $this->error('缺少参数');
|
||||
}
|
||||
$group_id = Db::name('user')->where('token', $id)->find();
|
||||
if(!$group_id){
|
||||
return $this->error('未查询到该用户科室');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 用户列表
|
||||
*/
|
||||
@ -165,16 +176,29 @@ class User extends Api
|
||||
if (!$id) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$ret = Db::name('user')->where('id',$id)->find();
|
||||
$ret = Db::name('user')
|
||||
->field('a.*, u.name as gorup_name, d.name as party_name')
|
||||
->alias('a')
|
||||
->join('user_group u','a.group_id = u.id','LEFT')
|
||||
->join('party_group d','a.party_id = d.id','LEFT')
|
||||
->where('a.id',$id)
|
||||
->find();
|
||||
$startDate = $time . '-01-01';
|
||||
$endDate = $time . '-12-31';
|
||||
|
||||
$date = Db::name('addition_and_subtraction_records')
|
||||
->field('a.*,p.project_name,p.scoring_criteria')
|
||||
->alias('a')
|
||||
->join('plus_minus_scoring p','a.assessment_project = p.id','LEFT')
|
||||
->where('user_id', $id)
|
||||
->where('YEAR(createtime)', $time)
|
||||
->where('status',2)
|
||||
->where('a.user_id', $id)
|
||||
->where('a.status', 2)
|
||||
->whereBetween('a.createtime', [$startDate, $endDate]) // 使用日期范围
|
||||
->order('a.id', 'desc')
|
||||
->select();
|
||||
|
||||
if(!$date){
|
||||
$date = [];
|
||||
}
|
||||
$array = [
|
||||
'user' => $ret,
|
||||
'date' => $date,
|
||||
@ -186,4 +210,27 @@ class User extends Api
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 单个用户查询
|
||||
*/
|
||||
public function getH5UserFind()
|
||||
{
|
||||
$id = $this->request->post('user_id');
|
||||
if (!$id) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$ret = Db::name('user')
|
||||
->field('a.nickname,a.mobile,a.position,a.certificate_code,a.license_code,a.license_image,p.name as user_group_name')
|
||||
->alias('a')
|
||||
->join('user_group p','a.group_id = p.id','LEFT')
|
||||
->where('a.id',$id)
|
||||
->find();
|
||||
if ($ret) {
|
||||
$this->success(__('Logged in successful'), $ret);
|
||||
} else {
|
||||
$this->error($this->auth->getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
@ -165,6 +190,7 @@ class Year extends Api
|
||||
'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
|
||||
// ]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user