Browse Source

删除没用的数据卡片

master
Hjj 1 day ago
parent
commit
a567f77820
  1. 149
      app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php
  2. 143
      app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php
  3. 144
      app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php
  4. 150
      app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php
  5. 133
      app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php
  6. 99
      app/Admin/Metrics/Examples/Follow/Allspeciality.php

149
app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php

@ -1,149 +0,0 @@ @@ -1,149 +0,0 @@
<?php
namespace App\Admin\Metrics\Examples\Follow;
use App\Models\AdmissionNewStudents;
use App\Models\Config;
use App\Models\SecondaryCollege;
use App\Models\Speciality;
use App\Models\UserFollowStatus;
use App\Models\UsersMember;
use Dcat\Admin\Support\JavaScript;
use Dcat\Admin\Widgets\ApexCharts\Chart;
use Illuminate\Support\Facades\DB;
class AllCollegesFollowCharts extends Chart
{
//各二级学院女生报道率
public function __construct($containerSelector = null, $options = [])
{
parent::__construct($containerSelector, $options);
$this->setUpOptions();
}
//初始化方法,主要是调用$this->options()方法,执行整个option的初始化操作。
protected function setUpOptions()
{
$this->options([
"chart"=>[
"height"=>300, //高度
"type"=>"bar", //chart 类型
],
]);
$followStatus = UserFollowStatus::query()
->addSelect(DB::raw('\'虚拟字段\' as data'))
->addSelect(DB::raw('\'颜色\' as color'))
->select(['id', 'name'])
->get()
->toArray();
$data = [[
"name" => "总人数",
"data" => [],
"tooltip" => [
[
"name" => "男生",
"data" => [],
"color" => ''
],
[
"name" => "女生",
"data" => [],
"color"=>""
]
],
]];
$label = [];
// 执行你的数据查询逻辑
//取出当前年份
$config = Config::query()->where([
"unique_identification" => "annual_session"
])->first();
//二级学院
$list = SecondaryCollege::query()->where([
"status" => SecondaryCollege::STATUS_YES
])->get(["id", "name"])->toArray();
//不为空时
if(!empty($list)){
// 新生数据
$studentsIds = AdmissionNewStudents::query()->where(["is_new_student" => "1"])->pluck('idCard')->toArray();
foreach($list as $key => $item){
$all = UsersMember::query()
->whereIn("idcard", $studentsIds)
->where("enroll_status", 1)
->where(function ($query)use($item) {
$specialityIds = Speciality::query()->where("secondary_college_id", $item['id'])->pluck('id')->toArray();
$query->whereIn('speciality_id', $specialityIds);
})
->select('sex', DB::raw('count(*) as total'))
->groupBy('sex')
->pluck('total', 'sex')
->toArray();
$list[$key]["registering"] = array_sum($all);
$list[$key]["studentsNum"] = $all[1] ?? 0;
$list[$key]["completedOfflineStep"] = $all[2] ?? 0;
}
foreach($list as $item){
array_push($label, $item["name"]);
if(!empty($item["registering"])){
array_push($data[0]["data"], $item["registering"]);
array_push($data[0]['tooltip'][0]['data'], $item["studentsNum"]);
array_push($data[0]['tooltip'][1]['data'], $item["completedOfflineStep"]);
}else{
array_push($data[0]["data"], 0);
array_push($data[0]['tooltip'][0]['data'], 0);
array_push($data[0]['tooltip'][1]['data'], 0);
}
}
}
$this->option("series",$data);
$this->option("labels",$label);
$this->option("yaxis",["max" => 2000]); //Y轴最大值
$tooltipCustomFunction = <<<JS
function({ series, seriesIndex, dataPointIndex, w }) {
let newStr = "";
w.config.series[0].tooltip.forEach(item=>{
newStr += `<div style="display: flex;padding: 0 10px;align-items: center;margin-top: 8px;">
<div style="width:12px;height:12px;border-radius:50%;background-color: \${item.color};margin-right: 10px;">
</div>
<div style="font-size: 12px;">
\${item.name}: \${item.data[dataPointIndex]}
</div>
</div>`
})
return `
<div style=' border: 1px solid #e3e3e3; background: rgba(255, 255, 255, 0.96); border-radius: 5px; box-shadow: 2px 2px 6px -4px #999; font-size: 14px;'>
<div style='padding:6px;background: #ECEFF1;border-bottom: 1px solid #ddd;font-size:12px;'>\${w.config.labels[dataPointIndex]}</div>
<div style="display: flex;padding: 0 10px;align-items: center; margin-top: 8px;">
<div style="width:12px;height:12px;border-radius:50%;background-color: rgb(0, 143, 251);margin-right: 10px;">
</div>
<div style="font-size: 12px;">
\${w.config.series[0].name}: \${w.config.series[0].data[dataPointIndex]}
</div>
</div>
\${newStr}
</div>
`;
}
JS;
$this->option('tooltip.custom', JavaScript::make($tooltipCustomFunction));
}
}

143
app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php

@ -1,143 +0,0 @@ @@ -1,143 +0,0 @@
<?php
namespace App\Admin\Metrics\Examples\Follow;
use App\Models\AdmissionNewStudents;
use App\Models\SecondaryCollege;
use App\Models\Speciality;
use App\Models\UsersMember;
use Dcat\Admin\Widgets\Metrics\Round;
use Illuminate\Support\Facades\DB;
class AllEnrollCollege extends Round
{
// 保存自定义参数
protected $data = [];
// 构造方法参数必须设置默认值
public function __construct(array $data = [])
{
$this->data = $data;
parent::__construct();
}
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$this->title('各院总录取统计');
if (is_string($this->data['secondary_college_id']) && !empty($this->data['secondary_college_id'])) {
$this->subTitle(SecondaryCollege::query()->where('id', $this->data['secondary_college_id'])->value('name'));
} else {
$this->subTitle("当前学院:全校");
}
// 新生数据
$studentsIds = AdmissionNewStudents::query()->where(["is_new_student" => "1"])->pluck('idCard')->toArray();
$all = UsersMember::query()
->whereIn("idcard", $studentsIds)
->where("enroll_status", 1)
->where(function ($query) {
if (is_array($this->data['secondary_college_id'])) {
$ids = $this->data['secondary_college_id'];
} else {
$ids = explode(',', $this->data['secondary_college_id']);
}
$specialityIds = Speciality::query()->whereIn("secondary_college_id", array_filter($ids))->pluck('id')->toArray();
$query->whereIn('speciality_id', $specialityIds);
})
->select('sex', DB::raw('count(*) as total'))
->groupBy('sex')
->pluck('total', 'sex')
->toArray();
// 总人数
$total = array_sum($all);
// 男生
$man = $all[1] ?? 0;
// 女生
$girl = $all[2] ?? 0;
$manPercent = $total != 0 ? number_format(($man / $total) * 100) : 0;
$girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0;
// 卡片内容
$this->withContent($total, $man, $girl)->height('220px');
$this->chartLabels(['男生', '女生']);
// 图表数据
$this->withChart([$manPercent, $girlPercent]);
// 总数
$this->chartTotal('总人数', $total);
}
/**
* 设置图表数据.
*
* @param array $data
*
* @return $this
*/
public function withChart(array $data)
{
return $this->chart([
'series' => $data,
]);
}
/**
* 卡片内容.
*
* @param int $finished
* @param int $pending
* @param int $rejected
*
* @return $this
*/
public function withContent($finished, $pending, $rejected)
{
return $this->content(
<<<HTML
<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
<div class="chart-info d-flex justify-content-between mb-1 mt-2" >
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-primary"></i>
<span class="text-bold-600 ml-50">总人数</span>
</div>
<div class="product-result">
<span>{$finished}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-warning"></i>
<span class="text-bold-600 ml-50">男生</span>
</div>
<div class="product-result">
<span>{$pending}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-danger"></i>
<span class="text-bold-600 ml-50">女生</span>
</div>
<div class="product-result">
<span>{$rejected}</span>
</div>
</div>
</div>
HTML
);
}
}

144
app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php

@ -1,144 +0,0 @@ @@ -1,144 +0,0 @@
<?php
namespace App\Admin\Metrics\Examples\Follow;
use App\Models\AdminFollowShow;
use App\Models\AdmissionNewStudents;
use App\Models\SecondaryCollege;
use App\Models\Speciality;
use App\Models\UsersMember;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Metrics\Round;
use Illuminate\Support\Facades\DB;
class AllEnrollSpeciality extends Round
{
// 保存自定义参数
protected $data = [];
// 构造方法参数必须设置默认值
public function __construct(array $data = [])
{
$this->data = $data;
parent::__construct();
}
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$this->title('各专业录取统计');
if (!empty($this->data['speciality_id'])) {
$specialityInfo = Speciality::query()->where('id', $this->data['speciality_id'])->first(['speciality_name', 'secondary_college_id']);
$name = "";
if ($specialityInfo) {
$name .= $specialityInfo['speciality_name'];
$collegeName = SecondaryCollege::query()->where('id', $specialityInfo['secondary_college_id'])->value('name');
if ($collegeName) {
$name .= "({$collegeName})";
}
}
} else {
$name = "当前专业:无";
}
$this->subTitle($name);
// 新生数据
$studentsIds = AdmissionNewStudents::query()->where(["is_new_student" => "1"])->pluck('idCard')->toArray();
$all = UsersMember::query()
->where(['enroll_status' => '1'])
->whereIn("idcard", $studentsIds)
->where('speciality_id', $this->data['speciality_id'])
->select('sex', DB::raw('count(*) as total'))
->groupBy('sex')
->pluck('total', 'sex')
->toArray();
// 总人数
$total = array_sum($all);
// 男生
$man = $all[1] ?? 0;
// 女生
$girl = $all[2] ?? 0;
$manPercent = $total != 0 ? number_format(($man /$total) * 100) : 0;
$girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0;
// 卡片内容
$this->withContent($total, $man, $girl)->height('220px');
$this->chartLabels(['男生', '女生']);
// 图表数据
$this->withChart([$manPercent, $girlPercent]);
// 总数
$this->chartTotal('总人数', $total);
}
/**
* 设置图表数据.
*
* @param array $data
*
* @return $this
*/
public function withChart(array $data)
{
return $this->chart([
'series' => $data,
]);
}
/**
* 卡片内容.
*
* @param int $finished
* @param int $pending
* @param int $rejected
*
* @return $this
*/
public function withContent($finished, $pending, $rejected)
{
return $this->content(
<<<HTML
<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
<div class="chart-info d-flex justify-content-between mb-1 mt-2" >
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-primary"></i>
<span class="text-bold-600 ml-50">总人数</span>
</div>
<div class="product-result">
<span>{$finished}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-warning"></i>
<span class="text-bold-600 ml-50">男生</span>
</div>
<div class="product-result">
<span>{$pending}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-danger"></i>
<span class="text-bold-600 ml-50">女生</span>
</div>
<div class="product-result">
<span>{$rejected}</span>
</div>
</div>
</div>
HTML
);
}
}

150
app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php

@ -1,150 +0,0 @@ @@ -1,150 +0,0 @@
<?php
namespace App\Admin\Metrics\Examples\Follow;
use App\Models\AdmissionNewStudents;
use App\Models\Speciality;
use App\Models\UserFollowRecord;
use App\Models\UserFollowStatus;
use App\Models\UsersMember;
use Dcat\Admin\Widgets\Metrics\Round;
use Illuminate\Support\Facades\DB;
class AllNewFollowCollege extends Round
{
// 保存自定义参数
protected $data = [];
// 构造方法参数必须设置默认值
public function __construct(array $data = [])
{
$this->data = $data;
parent::__construct();
}
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$this->title('各院最新回访结果');
if (empty($this->data['follow_id'])) {
$this->subTitle('当前回访状态:未联系');
} else {
$this->subTitle('当前回访状态:' . UserFollowStatus::query()->where(['id' => $this->data['follow_id']])->value('name'));
}
$this->chartLabels(['女生', '男生']);
$table1 = UsersMember::query()->getModel()->getTable();
$table2 = UserFollowRecord::query()->getModel()->getTable();
// 新生数据
$studentsIds = AdmissionNewStudents::query()->where(["is_new_student" => "1"])->pluck('idCard')->toArray();
$all = DB::table("{$table1} as aa")
->leftJoin("{$table2} as bb", function ($join) {
$join->on("aa.unique_number", "=", "bb.unique_number")->where(["bb.is_abandon" => "1"]);
})
->whereIn("aa.idcard", $studentsIds)
->where(function ($query) {
if (is_array($this->data['secondary_college_id'])) {
$ids = $this->data['secondary_college_id'];
} else {
$ids = explode(',', $this->data['secondary_college_id']);
}
$specialityIds = Speciality::query()->whereIn("secondary_college_id", array_filter($ids))->pluck('id')->toArray();
$query->whereIn('speciality_id', $specialityIds);
})
->where(function ($query) {
if (empty($this->data['follow_id'])) {
$query->whereNull("bb.id");
} else {
$query->where(["bb.follow_id" => $this->data['follow_id']]);
}
})
->select('aa.sex', DB::raw('count(*) as total'))
->groupBy('aa.sex')
->pluck('total', 'sex')
->toArray();
// 总人数
$total = array_sum($all);
// 男生
$man = $all[1] ?? 0;
// 女生
$girl = $all[2] ?? 0;
$manPercent = $total != 0 ? number_format(($man /$total) * 100) : 0;
$girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0;
// 卡片内容
$this->withContent($total, $man, $girl)->height('220px');
$this->chartLabels(['男生', '女生']);
// 图表数据
$this->withChart([$manPercent, $girlPercent]);
// 总数
$this->chartTotal('总人数', $total);
}
/**
* 设置图表数据.
* @param array $data
* @return $this
*/
public function withChart(array $data)
{
$this->chartColors(['#586cb1', '#dda451', '#ea5455']);
return $this->chart([
'series' => $data,
]);
}
/**
* 卡片内容.
* @param int $finished
* @param int $pending
* @param int $rejected
* @return $this
*/
public function withContent($finished, $pending, $rejected)
{
return $this->content(
<<<HTML
<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
<div class="chart-info d-flex justify-content-between mb-1 mt-2" >
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-primary"></i>
<span class="text-bold-600 ml-50">总人数</span>
</div>
<div class="product-result">
<span>{$finished}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-warning"></i>
<span class="text-bold-600 ml-50">男生</span>
</div>
<div class="product-result">
<span>{$pending}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-danger"></i>
<span class="text-bold-600 ml-50">女生</span>
</div>
<div class="product-result">
<span>{$rejected}</span>
</div>
</div>
</div>
HTML
);
}
}

133
app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php

@ -1,133 +0,0 @@ @@ -1,133 +0,0 @@
<?php
namespace App\Admin\Metrics\Examples\Follow;
use App\Models\AdmissionNewStudents;
use App\Models\Speciality;
use App\Models\UserFollowRecord;
use App\Models\UserFollowStatus;
use App\Models\UsersMember;
use Dcat\Admin\Widgets\Metrics\Round;
use Illuminate\Support\Facades\DB;
class AllNewFollowSpeciality extends Round
{
// 保存自定义参数
protected $data = [];
// 构造方法参数必须设置默认值
public function __construct(array $data = [])
{
$this->data = $data;
parent::__construct();
}
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$this->title('各专业最新回访结果');
if (empty($this->data['follow_id'])) {
$this->subTitle('当前回访状态:未联系');
} else {
$this->subTitle('当前回访状态:' . UserFollowStatus::query()->where(['id' => $this->data['follow_id']])->value('name'));
}
$this->chartLabels(['女生', '男生']);
$table1 = UsersMember::query()->getModel()->getTable();
$table2 = UserFollowRecord::query()->getModel()->getTable();
// 新生数据
$studentsIds = AdmissionNewStudents::query()->where(["is_new_student" => "1"])->pluck('idCard')->toArray();
$all = DB::table("{$table1} as aa")
->leftJoin("{$table2} as bb", function ($join) {
$join->on("aa.unique_number", "=", "bb.unique_number")->where("bb.is_abandon", "=", "1");
})
->whereIn("aa.idcard", $studentsIds)
->where(['bb.follow_id' => $this->data['follow_id']])
->where(['aa.speciality_id' => $this->data['speciality_id']])
->select('sex', DB::raw('count(*) as total'))
->groupBy('sex')
->pluck('total', 'sex')
->toArray();
// 总人数
$total = array_sum($all);
// 男生
$man = $all[1] ?? 0;
// 女生
$girl = $all[2] ?? 0;
$manPercent = $total != 0 ? number_format(($man /$total) * 100) : 0;
$girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0;
// 卡片内容
$this->withContent($total, $man, $girl)->height('220px');
$this->chartLabels(['男生', '女生']);
// 图表数据
$this->withChart([$manPercent, $girlPercent]);
// 总数
$this->chartTotal('总人数', $total);
}
/**
* 设置图表数据.
* @param array $data
* @return $this
*/
public function withChart(array $data)
{
return $this->chart([
'series' => $data,
]);
}
/**
* 卡片内容.
* @param int $finished
* @param int $pending
* @param int $rejected
* @return $this
*/
public function withContent($finished, $pending, $rejected)
{
return $this->content(
<<<HTML
<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
<div class="chart-info d-flex justify-content-between mb-1 mt-2" >
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-primary"></i>
<span class="text-bold-600 ml-50">总人数</span>
</div>
<div class="product-result">
<span>{$finished}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-warning"></i>
<span class="text-bold-600 ml-50">男生</span>
</div>
<div class="product-result">
<span>{$pending}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-danger"></i>
<span class="text-bold-600 ml-50">女生</span>
</div>
<div class="product-result">
<span>{$rejected}</span>
</div>
</div>
</div>
HTML
);
}
}

99
app/Admin/Metrics/Examples/Follow/Allspeciality.php

@ -1,99 +0,0 @@ @@ -1,99 +0,0 @@
<?php
namespace App\Admin\Metrics\Examples\Follow;
use App\Models\SecondaryCollege;
use App\Models\Speciality;
use Dcat\Admin\Widgets\Metrics\Round;
use Illuminate\Http\Request;
class Allspeciality extends Round
{
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$this->title('各专业录取人数');
$this->chartLabels(['男生', '女生']);
// 图表数据
$this->withChart([0, 0]);
// 总数
$this->chartTotal('全部', 0);
// $this->dropdown($data);
}
/**
* 处理请求
* @param Request $request
* @return void
*/
public function handle(Request $request)
{
// 卡片内容
$this->withContent(0, 0, 0);
}
/**
* 设置图表数据.
* @param array $data
* @return $this
*/
public function withChart(array $data): Allspeciality
{
return $this->chart([
'series' => $data,
]);
}
/**
* 卡片内容.
* @param int $finished
* @param int $pending
* @param int $rejected
* @return $this
*/
public function withContent(int $finished, int $pending, int $rejected): Allspeciality
{
return $this->content(
<<<HTML
<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
<div class="chart-info d-flex justify-content-between mb-1 mt-2" >
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-primary"></i>
<span class="text-bold-600 ml-50">全部</span>
</div>
<div class="product-result">
<span>{$finished}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-warning"></i>
<span class="text-bold-600 ml-50">男生</span>
</div>
<div class="product-result">
<span>{$pending}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-danger"></i>
<span class="text-bold-600 ml-50">女生</span>
</div>
<div class="product-result">
<span>{$rejected}</span>
</div>
</div>
</div>
HTML
);
}
}
Loading…
Cancel
Save