yifengyide/application/api/controller/backend/ScoringrecordDate.php
2025-04-03 15:50:14 +08:00

71 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 = ['*'];
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(){
}
}