yifengyide/application/api/controller/backend/ScoringrecordDate.php

71 lines
1.8 KiB
PHP
Raw Normal View History

<?php
namespace app\api\controller\backend;
use app\common\controller\Api;
use app\api\model\Admin as AdminModel;
use think\Db;
/**
* 数据统计控制器
*/
class ScoringrecordDate extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
2025-04-03 15:50:14 +08:00
public function _initialize()
{
parent::_initialize();
$id = $this->request->header('Token');
if(!$id){
return $this->error('缺少参数');
}
$user = Db::name('user')->where('token', $id)->find();
if(!$user){
return $this->error('用户不存在','',99998);
}
}
/**
* Undocumented function
*月度自评平均分
* @return void
*/
public function monthlySelfScore(){
// 获取当前年月
$currentMonth = date('n'); // 月份1到12
$currentYear = date('Y');
// 查询每个科室的月度自评平均分
$scores = Db::name('scoringrecord')
->field('group_id, AVG(self_score) as average_self_score')
->where('scoring_period', '3')
->group('group_id')
->select();
// $this->success('月度科室评平均分成功',$scores);
// 输出结果
foreach ($scores as $score) {
$groupId = $score['group_id'];
$averageScore = $score['average_self_score'];
// 获取科室名称
$groupName = Db::table('lr_user_group')
->where('id', $groupId)
->value('name');
// echo "科室: " . $groupName . " - 月度自评平均分: " . $averageScore . "\n";
}
$this->success('月度科室评平均分成功',$scores);
}
/**
* Undocumented function
*月度科室评平均分
* @return void
*/
public function monthlyDepartmentScore(){
}
}