|
|
|
|
@ -237,22 +237,23 @@ class OtherController extends CommonController
|
|
|
|
|
$course_type_id = request('course_type_id');
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
|
$query->whereIn('course_type_id1', $course_type_id);
|
|
|
|
|
$query->whereIn('course_type_id', $course_type_id);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$list['course_total'] = (clone $calendar)->count();
|
|
|
|
|
// 开课天数
|
|
|
|
|
$list['course_day_total'] = (clone $calendar)->where('is_count_days', 1)->sum('days');
|
|
|
|
|
|
|
|
|
|
$course_ids = $courses->pluck('id');
|
|
|
|
|
|
|
|
|
|
// 上市公司数(所有上市公司)
|
|
|
|
|
$list['company_market_total'] = Company::companyMarket($start_date, $end_date);
|
|
|
|
|
$list['company_market_total'] = CourseSign::shangshi($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 跟班学员数(在指定时间范围内报名的学员中,from为'跟班学员'的数量)
|
|
|
|
|
$course_ids = $courses->pluck('id');
|
|
|
|
|
$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);
|
|
|
|
|
$list['company_market_year_total'] = CourseSign::companyMarketYear($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 入学后上市公司数量(在指定时间范围内报名的学员所在公司中,在入学后上市的公司数量)
|
|
|
|
|
$list['company_market_after_enrollment_total'] = CourseSign::companyMarketAfterEnrollment($start_date, $end_date, $course_ids);
|
|
|
|
|
@ -260,6 +261,9 @@ class OtherController extends CommonController
|
|
|
|
|
// 入学后被投企业数量(在指定时间范围内报名的学员所在公司中,在入学后被投的公司数量)
|
|
|
|
|
$list['company_invested_after_enrollment_total'] = CourseSign::companyInvestedAfterEnrollment($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 今年被投企业数
|
|
|
|
|
$list['company_invested_year_total'] = CourseSign::companyInvestedYear($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 元和员工参与人数
|
|
|
|
|
$list['company_join_total'] = CourseSign::companyJoin($start_date, $end_date, $course_ids);
|
|
|
|
|
// 全市干部参与企业
|
|
|
|
|
@ -304,30 +308,30 @@ class OtherController extends CommonController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 附加历史课程数据
|
|
|
|
|
$historyCourses = HistoryCourse::whereHas('calendar', function ($query) {
|
|
|
|
|
$query->where('is_count_people', 1);
|
|
|
|
|
})->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(function ($query) {
|
|
|
|
|
$course_type_id = request('course_type_id', '');
|
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
$query->whereIn('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,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
// $historyCourses = HistoryCourse::whereHas('calendar', function ($query) {
|
|
|
|
|
// $query->where('is_count_people', 1);
|
|
|
|
|
// })->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(function ($query) {
|
|
|
|
|
// $course_type_id = request('course_type_id');
|
|
|
|
|
// if ($course_type_id) {
|
|
|
|
|
// $course_type_id = explode(',', $course_type_id);
|
|
|
|
|
// $query->whereIn('type', $course_type_id);
|
|
|
|
|
// }
|
|
|
|
|
// })->get();
|
|
|
|
|
// foreach ($historyCourses as $historyCourse) {
|
|
|
|
|
// $courseTypesSum[] = [
|
|
|
|
|
// 'course_type' => $historyCourse->typeDetail->name,
|
|
|
|
|
// // 培养人数
|
|
|
|
|
// 'course_type_signs_pass' => $historyCourses->where('type', $historyCourse->type)->sum('course_type_signs_pass'),
|
|
|
|
|
// // 去重培养人数
|
|
|
|
|
// 'course_type_signs_pass_unique' => $historyCourses->where('type', $historyCourse->type)->sum('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);
|
|
|
|
|
@ -564,10 +568,17 @@ class OtherController extends CommonController
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'company_market_total':
|
|
|
|
|
// 上市公司明细 - 所有上市公司
|
|
|
|
|
$companies = Company::companyMarket($start_date, $end_date, true);
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
// 上市公司明细 - 所有上市公司,关联学员、课程信息
|
|
|
|
|
// 数据结构:主表是公司,子数据是学员信息
|
|
|
|
|
// 导出时:公司信息只在第一行显示,后续行公司信息为空
|
|
|
|
|
$companiesData = CourseSign::shangshi($start_date, $end_date, $course_ids->toArray(), true);
|
|
|
|
|
|
|
|
|
|
foreach ($companiesData as $item) {
|
|
|
|
|
$company = $item['company'];
|
|
|
|
|
$users = $item['users'] ?? [];
|
|
|
|
|
|
|
|
|
|
// 公司基本信息(只在第一行使用)
|
|
|
|
|
$companyInfo = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
@ -575,7 +586,60 @@ class OtherController extends CommonController
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'company_city' => $company->company_city ?? '',
|
|
|
|
|
'company_area' => $company->company_area ?? '',
|
|
|
|
|
'company_tag' => $company->company_tag ?? '',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (empty($users)) {
|
|
|
|
|
// 如果没有学员报名记录,仍然导出公司基本信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => '',
|
|
|
|
|
'course_name' => '',
|
|
|
|
|
'course_type' => '',
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// 每个学员一行,多个课程合并显示
|
|
|
|
|
$isFirstRow = true;
|
|
|
|
|
foreach ($users as $userInfo) {
|
|
|
|
|
$courses = $userInfo['courses'] ?? [];
|
|
|
|
|
|
|
|
|
|
// 合并同一学员的多个课程:格式为"课程体系-课程名称,课程体系-课程名称"
|
|
|
|
|
$courseList = [];
|
|
|
|
|
foreach ($courses as $courseInfo) {
|
|
|
|
|
$courseType = $courseInfo['course_type'] ?? '';
|
|
|
|
|
$courseName = $courseInfo['course_name'] ?? '';
|
|
|
|
|
if ($courseType && $courseName) {
|
|
|
|
|
$courseList[] = $courseType . '-' . $courseName;
|
|
|
|
|
} elseif ($courseName) {
|
|
|
|
|
$courseList[] = $courseName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$courseDisplay = implode("\r\n", $courseList);
|
|
|
|
|
|
|
|
|
|
if ($isFirstRow) {
|
|
|
|
|
// 第一行:显示公司信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => $userInfo['user_name'] ?? '',
|
|
|
|
|
'course_name' => $courseDisplay,
|
|
|
|
|
'course_type' => '', // 课程类型已合并到课程名称中
|
|
|
|
|
]);
|
|
|
|
|
$isFirstRow = false;
|
|
|
|
|
} else {
|
|
|
|
|
// 后续行:公司信息为空
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => '',
|
|
|
|
|
'company_legal_representative' => '',
|
|
|
|
|
'company_date' => '',
|
|
|
|
|
'stock_date' => '',
|
|
|
|
|
'company_address' => '',
|
|
|
|
|
'company_city' => '',
|
|
|
|
|
'company_area' => '',
|
|
|
|
|
'company_tag' => '',
|
|
|
|
|
'user_name' => $userInfo['user_name'] ?? '',
|
|
|
|
|
'course_name' => $courseDisplay,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
@ -583,8 +647,11 @@ class OtherController extends CommonController
|
|
|
|
|
'company_date' => '成立时间',
|
|
|
|
|
'stock_date' => '上市日期',
|
|
|
|
|
'company_address' => '地址',
|
|
|
|
|
'company_city' => '营业范围',
|
|
|
|
|
'company_area' => '联系电话',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'company_tag' => '企业资质',
|
|
|
|
|
'user_name' => '学员姓名',
|
|
|
|
|
'course_name' => '课程信息',
|
|
|
|
|
];
|
|
|
|
|
$filename = '上市公司明细';
|
|
|
|
|
break;
|
|
|
|
|
@ -614,10 +681,17 @@ class OtherController extends CommonController
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'company_market_year_total':
|
|
|
|
|
// 今年上市公司明细 - 使用模型方法
|
|
|
|
|
$companies = Company::companyMarketYear($start_date, $end_date, $course_ids, true);
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
// 今年上市公司明细 - 所有今年上市公司,关联学员、课程信息
|
|
|
|
|
// 数据结构:主表是公司,子数据是学员信息
|
|
|
|
|
// 导出时:公司信息只在第一行显示,后续行公司信息为空
|
|
|
|
|
$companiesData = CourseSign::companyMarketYear($start_date, $end_date, $course_ids->toArray(), true);
|
|
|
|
|
|
|
|
|
|
foreach ($companiesData as $item) {
|
|
|
|
|
$company = $item['company'];
|
|
|
|
|
$users = $item['users'] ?? [];
|
|
|
|
|
|
|
|
|
|
// 公司基本信息(只在第一行使用)
|
|
|
|
|
$companyInfo = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
@ -625,7 +699,60 @@ class OtherController extends CommonController
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'company_city' => $company->company_city ?? '',
|
|
|
|
|
'company_area' => $company->company_area ?? '',
|
|
|
|
|
'company_tag' => $company->company_tag ?? '',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (empty($users)) {
|
|
|
|
|
// 如果没有学员报名记录,仍然导出公司基本信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => '',
|
|
|
|
|
'course_name' => '',
|
|
|
|
|
'course_type' => '',
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// 每个学员一行,多个课程合并显示
|
|
|
|
|
$isFirstRow = true;
|
|
|
|
|
foreach ($users as $userInfo) {
|
|
|
|
|
$courses = $userInfo['courses'] ?? [];
|
|
|
|
|
|
|
|
|
|
// 合并同一学员的多个课程:格式为"课程体系-课程名称,课程体系-课程名称"
|
|
|
|
|
$courseList = [];
|
|
|
|
|
foreach ($courses as $courseInfo) {
|
|
|
|
|
$courseType = $courseInfo['course_type'] ?? '';
|
|
|
|
|
$courseName = $courseInfo['course_name'] ?? '';
|
|
|
|
|
if ($courseType && $courseName) {
|
|
|
|
|
$courseList[] = $courseType . '-' . $courseName;
|
|
|
|
|
} elseif ($courseName) {
|
|
|
|
|
$courseList[] = $courseName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$courseDisplay = implode("\r\n", $courseList);
|
|
|
|
|
|
|
|
|
|
if ($isFirstRow) {
|
|
|
|
|
// 第一行:显示公司信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => $userInfo['user_name'] ?? '',
|
|
|
|
|
'course_name' => $courseDisplay,
|
|
|
|
|
'course_type' => '', // 课程类型已合并到课程名称中
|
|
|
|
|
]);
|
|
|
|
|
$isFirstRow = false;
|
|
|
|
|
} else {
|
|
|
|
|
// 后续行:公司信息为空
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => '',
|
|
|
|
|
'company_legal_representative' => '',
|
|
|
|
|
'company_date' => '',
|
|
|
|
|
'stock_date' => '',
|
|
|
|
|
'company_address' => '',
|
|
|
|
|
'company_city' => '',
|
|
|
|
|
'company_area' => '',
|
|
|
|
|
'company_tag' => '',
|
|
|
|
|
'user_name' => $userInfo['user_name'] ?? '',
|
|
|
|
|
'course_name' => $courseDisplay,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
@ -633,8 +760,11 @@ class OtherController extends CommonController
|
|
|
|
|
'company_date' => '成立时间',
|
|
|
|
|
'stock_date' => '上市日期',
|
|
|
|
|
'company_address' => '地址',
|
|
|
|
|
'company_city' => '营业范围',
|
|
|
|
|
'company_area' => '联系电话',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'company_tag' => '企业资质',
|
|
|
|
|
'user_name' => '学员姓名',
|
|
|
|
|
'course_name' => '课程信息',
|
|
|
|
|
];
|
|
|
|
|
$filename = '今年上市公司明细';
|
|
|
|
|
break;
|
|
|
|
|
@ -781,7 +911,7 @@ class OtherController extends CommonController
|
|
|
|
|
$data[] = [
|
|
|
|
|
'user_name' => $user->name ?? '',
|
|
|
|
|
'mobile' => $user->mobile ?? '',
|
|
|
|
|
'company_name' => $user->company->company_name ?? '',
|
|
|
|
|
'company_name' => $user->company->company_name ?? $user->company_name,
|
|
|
|
|
'company_position' => $user->company_position ?? '',
|
|
|
|
|
'company_city' => $user->company->company_city ?? '',
|
|
|
|
|
'company_area' => $user->company->company_area ?? '',
|
|
|
|
|
|