From a567f7782085506d63cd252d9f41a4061b657105 Mon Sep 17 00:00:00 2001 From: Hjj <126586545@qq.com> Date: Tue, 1 Jul 2025 00:17:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Follow/AllCollegesFollowCharts.php | 149 ----------------- .../Examples/Follow/AllEnrollCollege.php | 143 ----------------- .../Examples/Follow/AllEnrollSpeciality.php | 144 ----------------- .../Examples/Follow/AllNewFollowCollege.php | 150 ------------------ .../Follow/AllNewFollowSpeciality.php | 133 ---------------- .../Metrics/Examples/Follow/Allspeciality.php | 99 ------------ 6 files changed, 818 deletions(-) delete mode 100644 app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php delete mode 100644 app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php delete mode 100644 app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php delete mode 100644 app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php delete mode 100644 app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php delete mode 100644 app/Admin/Metrics/Examples/Follow/Allspeciality.php diff --git a/app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php b/app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php deleted file mode 100644 index e34c049..0000000 --- a/app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php +++ /dev/null @@ -1,149 +0,0 @@ -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 = <<{ - newStr += `
-
- -
-
- \${item.name}: \${item.data[dataPointIndex]} -
-
` - }) - - return ` -
-
\${w.config.labels[dataPointIndex]}
-
-
- -
-
- \${w.config.series[0].name}: \${w.config.series[0].data[dataPointIndex]} -
-
- \${newStr} -
- `; -} -JS; - - $this->option('tooltip.custom', JavaScript::make($tooltipCustomFunction)); - } -} diff --git a/app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php b/app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php deleted file mode 100644 index 1d1246a..0000000 --- a/app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php +++ /dev/null @@ -1,143 +0,0 @@ -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( - << -
-
- - 总人数 -
-
- {$finished} -
-
- -
-
- - 男生 -
-
- {$pending} -
-
- -
-
- - 女生 -
-
- {$rejected} -
-
- -HTML - ); - } -} - diff --git a/app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php b/app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php deleted file mode 100644 index 292af53..0000000 --- a/app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php +++ /dev/null @@ -1,144 +0,0 @@ -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( - << -
-
- - 总人数 -
-
- {$finished} -
-
- -
-
- - 男生 -
-
- {$pending} -
-
- -
-
- - 女生 -
-
- {$rejected} -
-
- -HTML - ); - } -} - diff --git a/app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php b/app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php deleted file mode 100644 index 385cae5..0000000 --- a/app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php +++ /dev/null @@ -1,150 +0,0 @@ -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( - << -
-
- - 总人数 -
-
- {$finished} -
-
- -
-
- - 男生 -
-
- {$pending} -
-
- -
-
- - 女生 -
-
- {$rejected} -
-
- -HTML - ); - } -} diff --git a/app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php b/app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php deleted file mode 100644 index 263375f..0000000 --- a/app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php +++ /dev/null @@ -1,133 +0,0 @@ -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( - << -
-
- - 总人数 -
-
- {$finished} -
-
- -
-
- - 男生 -
-
- {$pending} -
-
- -
-
- - 女生 -
-
- {$rejected} -
-
- -HTML - ); - } -} diff --git a/app/Admin/Metrics/Examples/Follow/Allspeciality.php b/app/Admin/Metrics/Examples/Follow/Allspeciality.php deleted file mode 100644 index 60ab02c..0000000 --- a/app/Admin/Metrics/Examples/Follow/Allspeciality.php +++ /dev/null @@ -1,99 +0,0 @@ -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( - << -
-
- - 全部 -
-
- {$finished} -
-
- -
-
- - 男生 -
-
- {$pending} -
-
- -
-
- - 女生 -
-
- {$rejected} -
-
- -HTML - ); - } -}