59 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			59 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?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 = ['*'];
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 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(){
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |