|
|
|
|
@ -221,8 +221,7 @@ class OtherController extends CommonController
|
|
|
|
|
$end_date = $params['end_date'];
|
|
|
|
|
$course_type_id = $params['course_type_id'];
|
|
|
|
|
$courses = $params['courses'];
|
|
|
|
|
// 被投企业数
|
|
|
|
|
$list['course_signs_invested'] = CourseSign::yhInvested($start_date, $end_date, $courses->pluck('id')->toArray());
|
|
|
|
|
|
|
|
|
|
// 报名人数
|
|
|
|
|
$list['course_signs_total'] = CourseSign::courseSignsTotal($start_date, $end_date, null, $courses->pluck('id'));
|
|
|
|
|
// 审核通过人数
|
|
|
|
|
@ -230,16 +229,33 @@ class OtherController extends CommonController
|
|
|
|
|
// 审核通过人数去重
|
|
|
|
|
$list['course_signs_pass_unique'] = CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $courses->pluck('id'), null);
|
|
|
|
|
// 开课场次
|
|
|
|
|
// 开课场次
|
|
|
|
|
$calendar = Calendar::where(function ($query) use ($start_date, $end_date) {
|
|
|
|
|
$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');
|
|
|
|
|
})->where(function ($query) use ($course_type_id) {
|
|
|
|
|
// 条件1:有 course_id 的数据,通过 course.type 匹配课程体系
|
|
|
|
|
// 条件2:没有 course_id 的数据,直接用 course_type_id 字段匹配
|
|
|
|
|
// 两个条件是或关系
|
|
|
|
|
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
|
$query->whereIn('course_type_id', $course_type_id);
|
|
|
|
|
$course_type_id_array = is_array($course_type_id) ? $course_type_id : explode(',', $course_type_id);
|
|
|
|
|
|
|
|
|
|
// 条件1:有 course_id 时,通过关联的 course.type 匹配
|
|
|
|
|
$query->where(function ($q) use ($course_type_id_array) {
|
|
|
|
|
|
|
|
|
|
$q->whereHas('course', function ($subQ) use ($course_type_id_array) {
|
|
|
|
|
$subQ->whereIn('type', $course_type_id_array);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 条件2:没有 course_id 时,直接用 course_type_id 字段匹配(或关系)
|
|
|
|
|
$query->orWhere(function ($q) use ($course_type_id_array) {
|
|
|
|
|
$q->whereIn('course_type_id', $course_type_id_array);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
|
|
$list['course_total'] = (clone $calendar)->count();
|
|
|
|
|
// 开课天数
|
|
|
|
|
$list['course_day_total'] = (clone $calendar)->where('is_count_days', 1)->sum('days');
|
|
|
|
|
@ -258,9 +274,15 @@ class OtherController extends CommonController
|
|
|
|
|
// 入学后上市公司数量(在指定时间范围内报名的学员所在公司中,在入学后上市的公司数量)
|
|
|
|
|
$list['company_market_after_enrollment_total'] = CourseSign::companyMarketAfterEnrollment($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 累计被投企业数
|
|
|
|
|
$list['course_signs_invested'] = CourseSign::yhInvestedTotal(CourseType::START_DATE, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 入学后被投企业数量(在指定时间范围内报名的学员所在公司中,在入学后被投的公司数量)
|
|
|
|
|
$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);
|
|
|
|
|
// 全市干部参与企业
|
|
|
|
|
@ -290,11 +312,11 @@ class OtherController extends CommonController
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
'course_type' => $courseType->name,
|
|
|
|
|
// 培养人数
|
|
|
|
|
'course_type_signs_pass' => CourseSign::courseSignsTotal($start_date, $end_date, 1, $courses2->pluck('id')),
|
|
|
|
|
'course_type_signs_pass' => CourseSign::courseSignsTotal($start_date, $end_date, 1, $courses2->pluck('id'), false, false),
|
|
|
|
|
// 去重培养人数
|
|
|
|
|
'course_type_signs_pass_unique' => CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $courses2->pluck('id'), null),
|
|
|
|
|
'course_type_signs_pass_unique' => CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $courses2->pluck('id'), false, false),
|
|
|
|
|
'course_name' => $course->name,
|
|
|
|
|
'course_signs_pass' => CourseSign::courseSignsTotal($start_date, $end_date, 1, [$course->id]),
|
|
|
|
|
'course_signs_pass' => CourseSign::courseSignsTotal($start_date, $end_date, 1, [$course->id], false, false),
|
|
|
|
|
// 跟班学员数量
|
|
|
|
|
'genban_total' => CourseSign::genban($start_date, $end_date, [$course->id]),
|
|
|
|
|
// 被投企业数
|
|
|
|
|
@ -305,29 +327,33 @@ 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');
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
|
$query->whereIn('type', $course_type_id);
|
|
|
|
|
$courseTypesHistory = CourseType::where('is_history', 1)->whereIn('id', $course_type_id)->get();
|
|
|
|
|
foreach ($courseTypesHistory as $historyCourse) {
|
|
|
|
|
$courses3 = 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('type', $historyCourse->id)->get();
|
|
|
|
|
foreach ($courses3 as $course) {
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
'course_type' => $historyCourse->name,
|
|
|
|
|
'course_name' => $course->course_name,
|
|
|
|
|
// 培养人数
|
|
|
|
|
'course_type_signs_pass' => $course->course_type_signs_pass,
|
|
|
|
|
// 去重培养人数
|
|
|
|
|
'course_type_signs_pass_unique' => $course->course_type_signs_pass_unique,
|
|
|
|
|
// 课程人数
|
|
|
|
|
'course_signs_pass' => $course->course_signs_pass,
|
|
|
|
|
// 跟班学员数量
|
|
|
|
|
'genban_total' => 0,
|
|
|
|
|
// 被投企业数
|
|
|
|
|
'yh_invested_total' => 0,
|
|
|
|
|
// 元禾同事数
|
|
|
|
|
'company_join_total' => 0,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
})->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,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 区域明细统计
|
|
|
|
|
@ -341,7 +367,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-入学后上市公司明细, company_invested_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="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-入学后上市公司明细, company_invested_after_enrollment_total-入学后被投企业明细, company_invested_year_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,多个英文逗号"),
|
|
|
|
|
@ -374,7 +400,7 @@ class OtherController extends CommonController
|
|
|
|
|
switch ($export_type) {
|
|
|
|
|
case 'course_signs_invested':
|
|
|
|
|
// 被投企业明细 - 使用与coursesHome相同的算法
|
|
|
|
|
$companies = CourseSign::yhInvested($start_date, $end_date, $course_ids, true);
|
|
|
|
|
$companies = CourseSign::yhInvestedTotal($start_date, $end_date, $course_ids, true);
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
@ -830,6 +856,92 @@ class OtherController extends CommonController
|
|
|
|
|
$filename = '入学后被投企业明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'company_invested_year_total':
|
|
|
|
|
// 年份范围内被投企业明细 - 所有年份范围内被投企业,关联学员、课程信息
|
|
|
|
|
// 数据结构:主表是公司,子数据是学员信息
|
|
|
|
|
// 导出时:公司信息只在第一行显示,后续行公司信息为空
|
|
|
|
|
$companiesData = CourseSign::companyInvestedYear($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 ?? '',
|
|
|
|
|
'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' => '',
|
|
|
|
|
'company_address' => '',
|
|
|
|
|
'company_city' => '',
|
|
|
|
|
'company_area' => '',
|
|
|
|
|
'company_tag' => '',
|
|
|
|
|
'user_name' => $userInfo['user_name'] ?? '',
|
|
|
|
|
'course_name' => $courseDisplay,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_legal_representative' => '法人',
|
|
|
|
|
'company_date' => '成立时间',
|
|
|
|
|
'company_address' => '地址',
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
'company_tag' => '企业资质',
|
|
|
|
|
'user_name' => '学员姓名',
|
|
|
|
|
'course_name' => '课程信息',
|
|
|
|
|
];
|
|
|
|
|
$filename = '年份范围内被投企业明细';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'course_total':
|
|
|
|
|
// 开课场次明细 - 与coursesHome算法一致
|
|
|
|
|
$calendars = Calendar::whereBetween('date', [$start_date, $end_date])
|
|
|
|
|
|