You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
3.8 KiB
154 lines
3.8 KiB
<?php |
|
|
|
namespace App\Admin\Metrics\Examples; |
|
use App\Models\AdmissionNewStudents; |
|
use App\Models\CompletedOfflineStep; |
|
use App\Models\Config; |
|
use App\Models\PaymentList; |
|
use App\Models\UsersMember; |
|
use Dcat\Admin\Widgets\Metrics\Card; |
|
use Illuminate\Contracts\Support\Renderable; |
|
use Illuminate\Http\Request; |
|
use Illuminate\Support\Facades\DB; |
|
|
|
/** |
|
* 女生报到率 |
|
*/ |
|
class FemaleRegistering extends Card |
|
{ |
|
/** |
|
* 卡片底部内容. |
|
* |
|
* @var string|Renderable|\Closure |
|
*/ |
|
protected $footer; |
|
|
|
/** |
|
* 初始化卡片. |
|
*/ |
|
protected function init() |
|
{ |
|
parent::init(); |
|
|
|
$this->title('女生报到率'); |
|
|
|
} |
|
|
|
/** |
|
* 处理请求. |
|
* |
|
* @param Request $request |
|
* |
|
* @return void |
|
*/ |
|
public function handle(Request $request) |
|
{ |
|
|
|
$number = 0; |
|
$studentsNum = 0; |
|
|
|
//取出当前年份 |
|
$config = Config::query()->where([ |
|
"unique_identification" => "annual_session" |
|
])->first(); |
|
|
|
|
|
//取出当前年份录入的女学生 |
|
$importStudents = AdmissionNewStudents::query()->where([ |
|
"annual_session" => $config->data, |
|
"status" => AdmissionNewStudents::STATUS_YES, |
|
"is_new_student" => AdmissionNewStudents::IS_NEW_STUDENT_YES, |
|
"sex" => AdmissionNewStudents:: FEMALE, |
|
])->get("idCard")->toArray(); |
|
if(!empty($importStudents)){ |
|
$idcardList = array_column($importStudents, "idCard"); |
|
//根据身份证集取出已注册的用户 |
|
$userList = UsersMember::query()->whereIn("idcard", $idcardList)->where("status", UsersMember::STATUS_YES)->get("unique_number")->toArray(); |
|
if(!empty($userList)){ |
|
$userList = array_column($userList, "unique_number"); |
|
|
|
//当前年份已完成二级学院扫码的学生(实际报道人数) |
|
$allCount = CompletedOfflineStep::query()->where([ |
|
"annual_session" => $config->data, |
|
])->whereIn("unique_number", $userList)->select("unique_number")->distinct()->get()->toArray(); |
|
|
|
$number = count($allCount); |
|
} |
|
$studentsNum = count($importStudents); |
|
} |
|
|
|
if($number == 0 || $studentsNum == 0){ |
|
$this->content("0%"); |
|
}else{ |
|
$this->content((($number / $studentsNum) * 100)."%"); |
|
} |
|
|
|
} |
|
|
|
/** |
|
* @param int $percent |
|
* |
|
* @return $this |
|
*/ |
|
public function up($percent) |
|
{ |
|
return $this->footer( |
|
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 为当前年份已分配床位数" |
|
); |
|
} |
|
|
|
/** |
|
* @param int $percent |
|
* |
|
* @return $this |
|
*/ |
|
public function down($percent) |
|
{ |
|
return $this->footer( |
|
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 为当前年份已分配床位数" |
|
); |
|
} |
|
|
|
/** |
|
* 设置卡片底部内容. |
|
* |
|
* @param string|Renderable|\Closure $footer |
|
* |
|
* @return $this |
|
*/ |
|
public function footer($footer) |
|
{ |
|
$this->footer = $footer; |
|
|
|
return $this; |
|
} |
|
|
|
/** |
|
* 渲染卡片内容. |
|
* |
|
* @return string |
|
*/ |
|
public function renderContent() |
|
{ |
|
$content = parent::renderContent(); |
|
|
|
return <<<HTML |
|
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
|
<h2 class="ml-1 font-lg-1">{$content}</h2> |
|
</div> |
|
<div class="ml-1 mt-1 font-weight-bold text-80"> |
|
{$this->renderFooter()} |
|
</div> |
|
HTML; |
|
} |
|
|
|
/** |
|
* 渲染卡片底部内容. |
|
* |
|
* @return string |
|
*/ |
|
public function renderFooter() |
|
{ |
|
return $this->toString($this->footer); |
|
} |
|
}
|
|
|