|
|
|
|
@ -15,6 +15,7 @@ use App\Models\CourseSign;
|
|
|
|
|
use App\Models\CourseType;
|
|
|
|
|
use App\Models\CustomFormField;
|
|
|
|
|
use App\Models\Department;
|
|
|
|
|
use App\Models\HistoryCourse;
|
|
|
|
|
use App\Models\ParameterDetail;
|
|
|
|
|
use App\Models\SupplyDemand;
|
|
|
|
|
use App\Models\TimeEvent;
|
|
|
|
|
@ -126,31 +127,19 @@ class OtherController extends CommonController
|
|
|
|
|
// 今年新增校友数
|
|
|
|
|
$list['schoolmate_year'] = User::where('is_schoolmate', 1)->where('created_at', 'like', '%' . date('Y') . '%')->count();
|
|
|
|
|
// 投后企业
|
|
|
|
|
$list['company_invested_total'] = Company::where('is_yh_invested', 1)->count();
|
|
|
|
|
// 元和员工参与
|
|
|
|
|
$list['company_invested_total'] = CourseSign::yhInvested();
|
|
|
|
|
// 元和员工参与企业
|
|
|
|
|
$companyNameKeyword = ['元禾控股', '元禾原点', '元禾厚望', '元禾重元', '元禾璞华', '元禾谷风', '元禾绿柳', '元禾辰坤', '元禾沙湖', '禾裕集团', '苏州科服', '信诚管理咨询', '集成电路公司', '常州团队', '国企元禾'];
|
|
|
|
|
// 获取公司名字包含$companyNameKeyword任意数据的公司,需要模糊匹配
|
|
|
|
|
$list['company_join_total'] = Company::where(function ($query) use ($companyNameKeyword) {
|
|
|
|
|
foreach ($companyNameKeyword as $item) {
|
|
|
|
|
$query->orWhere('company_name', 'like', '%' . $item . '%');
|
|
|
|
|
}
|
|
|
|
|
})->count();
|
|
|
|
|
$list['company_join_total'] = CourseSign::companyJoin();
|
|
|
|
|
// 全市干部参与企业
|
|
|
|
|
$list['company_ganbu_total'] = Company::whereHas('users', function ($query) {
|
|
|
|
|
$query->where('from', '跟班学员');
|
|
|
|
|
})->count();
|
|
|
|
|
$list['company_ganbu_total'] = CourseSign::ganbu();
|
|
|
|
|
// 三个全覆盖
|
|
|
|
|
// 苏州头部企业
|
|
|
|
|
$list['cover_head_total'] = Company::where('company_tag', 'like', '%' . '高新技术企业' . '%')->count();
|
|
|
|
|
$list['cover_head_total'] = CourseSign::toubuqiye();
|
|
|
|
|
// 高层次人才
|
|
|
|
|
// 获取人才培训课程
|
|
|
|
|
$renCaiCourseIds = Course::whereHas('typeDetail', function ($query) {
|
|
|
|
|
$query->where('name', '人才培训');
|
|
|
|
|
})->pluck('id');
|
|
|
|
|
$list['cover_rencai_total'] = CourseSign::whereIn('course_id', $renCaiCourseIds)->where('status', 1)->count();
|
|
|
|
|
$list['cover_rencai_total'] = CourseSign::rencai();
|
|
|
|
|
// 重点上市公司
|
|
|
|
|
$list['cover_stock_total'] = Company::where('company_market', 1)->count();
|
|
|
|
|
$list['cover_stock_total'] = CourseSign::shangshi();
|
|
|
|
|
// 本月课程
|
|
|
|
|
$monthCourses = Calendar::with('course.teacher')->where('type', 1)
|
|
|
|
|
->where('date', 'like', '%' . date('Y-m') . '%')
|
|
|
|
|
@ -185,6 +174,12 @@ class OtherController extends CommonController
|
|
|
|
|
$countryArea = Company::groupBy('company_city')->whereNotNull('company_city')->get(['company_city']);
|
|
|
|
|
$country = [];
|
|
|
|
|
foreach ($countryArea as $item) {
|
|
|
|
|
$total = User::whereHas('company', function ($query) use ($item) {
|
|
|
|
|
$query->where('company_city', $item->company_city);
|
|
|
|
|
})->where('is_schoolmate', 1)->count();
|
|
|
|
|
if (empty($total)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$country[] = [
|
|
|
|
|
'area' => $item->company_city,
|
|
|
|
|
'total' => User::whereHas('company', function ($query) use ($item) {
|
|
|
|
|
@ -245,7 +240,7 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
// 跟班学员数(在指定时间范围内报名的学员中,from为'跟班学员'的数量)
|
|
|
|
|
$course_ids = $courses->pluck('id');
|
|
|
|
|
$list['ganbu_total'] = CourseSign::ganbu($start_date, $end_date, $course_ids);
|
|
|
|
|
$list['ganbu_total'] = CourseSign::genban($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 今年上市公司数量(stock_date在今年)
|
|
|
|
|
$list['company_market_year_total'] = Company::companyMarketYear($start_date, $end_date, $course_ids);
|
|
|
|
|
@ -253,12 +248,24 @@ class OtherController extends CommonController
|
|
|
|
|
// 入学后上市公司数量(在指定时间范围内报名的学员所在公司中,在入学后上市的公司数量)
|
|
|
|
|
$list['company_market_after_enrollment_total'] = CourseSign::companyMarketAfterEnrollment($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 元和员工参与企业
|
|
|
|
|
$list['company_join_total'] = CourseSign::companyJoin($start_date, $end_date, $course_ids);
|
|
|
|
|
// 全市干部参与企业
|
|
|
|
|
$list['company_ganbu_total'] = CourseSign::ganbu($start_date, $end_date, $course_ids);
|
|
|
|
|
// 苏州头部企业
|
|
|
|
|
$list['cover_head_total'] = CourseSign::toubuqiye($start_date, $end_date, $course_ids);
|
|
|
|
|
// 高层次人才
|
|
|
|
|
$list['cover_rencai_total'] = CourseSign::rencai($start_date, $end_date, $course_ids);
|
|
|
|
|
// 重点上市公司
|
|
|
|
|
$list['cover_stock_total'] = CourseSign::shangshi($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 课程分类明细统计
|
|
|
|
|
$courseTypesSum = [];
|
|
|
|
|
$courseTypes = CourseType::whereIn('id', $course_type_id)->get();
|
|
|
|
|
foreach ($courseTypes as $courseType) {
|
|
|
|
|
// 获取课程
|
|
|
|
|
$courses2 = Course::where('type', $courseType->id)->get();
|
|
|
|
|
$courses2 = Course::where('type', $courseType->id)->orderBy('start_date', 'asc')->get();
|
|
|
|
|
foreach ($courses2 as $course) {
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
'course_type' => $courseType->name,
|
|
|
|
|
@ -271,6 +278,24 @@ class OtherController extends CommonController
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 附加历史课程数据
|
|
|
|
|
$historyCourses = HistoryCourse::where(function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
$query->whereBetween('start_time', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_time', [$start_date, $end_date]);
|
|
|
|
|
})->where('type', $course_type_id)->get();
|
|
|
|
|
foreach ($historyCourses as $historyCourse) {
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
'course_type' => $historyCourse->typeDetail->name,
|
|
|
|
|
// 培养人数
|
|
|
|
|
'course_type_signs_pass' => $historyCourse->course_type_signs_pass,
|
|
|
|
|
// 去重培养人数
|
|
|
|
|
'course_type_signs_pass_unique' => $historyCourse->course_type_signs_pass_unique,
|
|
|
|
|
'course_name' => $historyCourse->course_name,
|
|
|
|
|
'course_signs_pass' => $historyCourse->course_signs_pass,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 区域明细统计
|
|
|
|
|
$areas = CourseSign::area($start_date, $end_date, 1, $courses->pluck('id'), true);
|
|
|
|
|
return $this->success(compact('list', 'courseTypesSum', 'areas'));
|
|
|
|
|
@ -282,7 +307,7 @@ class OtherController extends CommonController
|
|
|
|
|
* tags={"其他"},
|
|
|
|
|
* summary="课程统计明细导出",
|
|
|
|
|
* description="导出课程统计数据的明细",
|
|
|
|
|
* @OA\Parameter(name="export_type", in="query", @OA\Schema(type="string"), required=true, description="导出类型:course_signs_invested-被投企业明细, course_signs_total-报名人数明细, course_signs_pass-审核通过人数明细, course_signs_pass_unique-审核通过人数去重明细, courseTypesSum-课程分类明细, areas-区域明细, company_market_total-上市公司明细, ganbu_total-跟班学员明细, company_market_year_total-今年上市公司明细, company_market_after_enrollment_total-入学后上市公司明细, course_total-开课场次明细, course_day_total-开课天数明细"),
|
|
|
|
|
* @OA\Parameter(name="export_type", in="query", @OA\Schema(type="string"), required=true, description="导出类型:course_signs_invested-被投企业明细, course_signs_total-报名人数明细, course_signs_pass-审核通过人数明细, course_signs_pass_unique-审核通过人数去重明细, courseTypesSum-课程分类明细, areas-区域明细, company_market_total-上市公司明细, ganbu_total-跟班学员明细, company_market_year_total-今年上市公司明细, company_market_after_enrollment_total-入学后上市公司明细, course_total-开课场次明细, course_day_total-开课天数明细, company_join_total-元和员工参与企业明细, company_ganbu_total-全市干部参与企业明细, cover_head_total-苏州头部企业明细, cover_rencai_total-高层次人才明细, cover_stock_total-重点上市公司明细"),
|
|
|
|
|
* @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=false, description="开始日期"),
|
|
|
|
|
* @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=false, description="结束日期"),
|
|
|
|
|
* @OA\Parameter(name="course_type_id", in="query", @OA\Schema(type="string"), required=false, description="课程体系id,多个英文逗号"),
|
|
|
|
|
@ -403,7 +428,7 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
case 'course_signs_pass_unique':
|
|
|
|
|
// 审核通过人数去重明细 - 使用courseSignsTotalByUnique方法获取列表
|
|
|
|
|
$users = CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $course_ids, null, true);
|
|
|
|
|
$users = CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $course_ids, true);
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
// 获取该学员报名的课程列表(与coursesHome逻辑保持一致)
|
|
|
|
|
$userCourseSigns = CourseSign::where('user_id', $user->id)
|
|
|
|
|
@ -527,7 +552,7 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
case 'ganbu_total':
|
|
|
|
|
// 跟班学员明细 - 使用模型方法
|
|
|
|
|
$users = CourseSign::ganbu($start_date, $end_date, $course_ids, true);
|
|
|
|
|
$users = CourseSign::genban($start_date, $end_date, $course_ids, true);
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'name' => $user->username ?? '',
|
|
|
|
|
@ -662,6 +687,156 @@ class OtherController extends CommonController
|
|
|
|
|
$filename = '开课天数明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'company_join_total':
|
|
|
|
|
// 元和员工参与企业明细 - 使用模型方法
|
|
|
|
|
$companies = CourseSign::companyJoin($start_date, $end_date, $course_ids, true);
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'company_city' => $company->company_city ?? '',
|
|
|
|
|
'company_area' => $company->company_area ?? '',
|
|
|
|
|
'business_scope' => $company->business_scope ?? '',
|
|
|
|
|
'contact_phone' => $company->contact_phone ?? '',
|
|
|
|
|
'contact_mail' => $company->contact_mail ?? '',
|
|
|
|
|
'company_tag' => $company->company_tag ?? '',
|
|
|
|
|
'credit_code' => ' ' . $company->credit_code ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_legal_representative' => '法人',
|
|
|
|
|
'company_date' => '成立时间',
|
|
|
|
|
'company_address' => '地址',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'business_scope' => '营业范围',
|
|
|
|
|
'contact_phone' => '联系电话',
|
|
|
|
|
'contact_mail' => '联系邮箱',
|
|
|
|
|
'company_tag' => '企业资质',
|
|
|
|
|
'credit_code' => '统一社会信用代码',
|
|
|
|
|
];
|
|
|
|
|
$filename = '元和员工参与企业明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'company_ganbu_total':
|
|
|
|
|
// 全市干部参与企业明细 - 使用模型方法
|
|
|
|
|
$users = CourseSign::ganbu($start_date, $end_date, $course_ids, true);
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'user_name' => $user->name ?? '',
|
|
|
|
|
'mobile' => $user->mobile ?? '',
|
|
|
|
|
'company_name' => $user->company->company_name ?? '',
|
|
|
|
|
'company_area' => $user->company->company_area ?? '',
|
|
|
|
|
'company_city' => $user->company->company_city ?? '',
|
|
|
|
|
'company_position' => $user->company_position ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'user_name' => '学员姓名',
|
|
|
|
|
'mobile' => '手机号',
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_position' => '职位',
|
|
|
|
|
];
|
|
|
|
|
$filename = '全市干部参与企业明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'cover_head_total':
|
|
|
|
|
// 苏州头部企业明细 - 使用模型方法
|
|
|
|
|
$companies = CourseSign::toubuqiye($start_date, $end_date, $course_ids, true);
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'company_city' => $company->company_city ?? '',
|
|
|
|
|
'company_area' => $company->company_area ?? '',
|
|
|
|
|
'company_tag' => $company->company_tag ?? '',
|
|
|
|
|
'business_scope' => $company->business_scope ?? '',
|
|
|
|
|
'contact_phone' => $company->contact_phone ?? '',
|
|
|
|
|
'contact_mail' => $company->contact_mail ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_legal_representative' => '法人',
|
|
|
|
|
'company_date' => '成立时间',
|
|
|
|
|
'company_address' => '地址',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'company_tag' => '企业资质',
|
|
|
|
|
'business_scope' => '营业范围',
|
|
|
|
|
'contact_phone' => '联系电话',
|
|
|
|
|
'contact_mail' => '联系邮箱',
|
|
|
|
|
];
|
|
|
|
|
$filename = '苏州头部企业明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'cover_rencai_total':
|
|
|
|
|
// 高层次人才明细 - 使用模型方法
|
|
|
|
|
$users = CourseSign::rencai($start_date, $end_date, $course_ids, true);
|
|
|
|
|
// 加载关联关系
|
|
|
|
|
$users->load('company');
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'user_name' => $user->name ?? '',
|
|
|
|
|
'mobile' => $user->mobile ?? '',
|
|
|
|
|
'company_name' => $user->company_name ?? '',
|
|
|
|
|
'company_area' => $user->company_area ?? '',
|
|
|
|
|
'company_city' => $user->company->company_city ?? '',
|
|
|
|
|
'company_position' => $user->company_position ?? '',
|
|
|
|
|
'education' => $user->education ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'user_name' => '学员姓名',
|
|
|
|
|
'mobile' => '手机号',
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_position' => '职位',
|
|
|
|
|
'education' => '学历',
|
|
|
|
|
];
|
|
|
|
|
$filename = '高层次人才明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'cover_stock_total':
|
|
|
|
|
// 重点上市公司明细 - 使用模型方法
|
|
|
|
|
$companies = CourseSign::shangshi($start_date, $end_date, $course_ids, true);
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
'stock_date' => $company->stock_date ?? '',
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'company_city' => $company->company_city ?? '',
|
|
|
|
|
'company_area' => $company->company_area ?? '',
|
|
|
|
|
'business_scope' => $company->business_scope ?? '',
|
|
|
|
|
'contact_phone' => $company->contact_phone ?? '',
|
|
|
|
|
'contact_mail' => $company->contact_mail ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_legal_representative' => '法人',
|
|
|
|
|
'company_date' => '成立时间',
|
|
|
|
|
'stock_date' => '上市日期',
|
|
|
|
|
'company_address' => '地址',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'business_scope' => '营业范围',
|
|
|
|
|
'contact_phone' => '联系电话',
|
|
|
|
|
'contact_mail' => '联系邮箱',
|
|
|
|
|
];
|
|
|
|
|
$filename = '重点上市公司明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, '不支持的导出类型']);
|
|
|
|
|
}
|
|
|
|
|
|