This commit is contained in:
Vinjor 2025-02-20 09:31:00 +08:00
commit 89a6bcd013
6 changed files with 147 additions and 13 deletions

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.base.controller.admin;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolStudentService;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
@ -8,12 +9,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 驾校学员")
@ -48,11 +52,12 @@ public class DlDriveSchoolStudentController {
/**
* 获取学员详细信息
* @author PQZ
* @date 9:58 2025/2/10
*
* @param id 学员id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO>
**/
* @author PQZ
* @date 9:58 2025/2/10
**/
@GetMapping("/get")
@Operation(summary = "获得驾校学员")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@ -81,29 +86,70 @@ public class DlDriveSchoolStudentController {
/**
* 获取可以考试的学员列表
*
* @param courseId 课程ID
* @param subject 科目
* @return List<DlDriveSchoolStudent>
* @author vinjor-M
* @date 23:16 2025/1/20
* @param courseId 课程ID
* @param subject 科目
* @return List<DlDriveSchoolStudent>
**/
@GetMapping("/getCanExamStudentList")
@Operation(summary = "获取可以考试的学员列表")
public CommonResult<?> getCanExamStudentList(String courseId,Integer subject,String userName) {
return success(schoolStudentService.getCanExamStudentList(courseId, subject,userName));
public CommonResult<?> getCanExamStudentList(String courseId, Integer subject, String userName) {
return success(schoolStudentService.getCanExamStudentList(courseId, subject, userName));
}
/**
* 教练查自己所有学生列表
* 教练查自己所有学生列表
*
* @author vinjor-M
* @date 17:20 2025/2/12
**/
**/
@GetMapping("/myStudentCoachPage")
@Operation(summary = "教练查自己所有学生列表")
public CommonResult<IPage<?>> myStudentCoachPage(@Valid DlDriveSchoolStudentVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<DlDriveSchoolStudentVO> page = new Page<>(pageNo, pageSize);
return success(schoolStudentService.queryCoachListPage(pageReqVO, page));
}
/**
* @param type 时间查询类型01驾校统招02教练自招03自来客户
* @param timeType 时间查询类型all-全部|day-当日|month-当月|more-自定义
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.util.List < ?>>
* @author PQZ
* @date 16:30 2025/2/19
**/
@GetMapping("/indexStuentList")
@Operation(summary = "首页数据统计查询接口")
public CommonResult<List<?>> indexGetTrainList(@RequestParam(value = "type") String type,
@RequestParam(value = "timeType") String timeType,
@RequestParam(value = "coachId", required = false) Long coachId,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime) {
//默认查全部数据
String startTimeStr = "";
String endTimeStr = "";
if("more".equals(timeType)){
if(StringUtils.isNotEmpty(startTime)){
startTimeStr = startTime+" 00:00:01";
}
if(StringUtils.isNotEmpty(endTime)) {
endTimeStr = endTime + " 23:59:59";
}
}else if("month".equals(timeType)){
//当月
startTimeStr = DateUtil.format(DateUtil.beginOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 00:00:01";
endTimeStr = DateUtil.format(DateUtil.endOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 23:59:59";
}else if("day".equals(timeType)){
//当天
startTimeStr = DateUtil.formatDate(DateUtil.date())+" 00:00:01";
endTimeStr = DateUtil.formatDate(DateUtil.date())+" 23:59:59";
}
return success(schoolStudentService.indexGetTrainList(type,coachId,startTimeStr,endTimeStr));
}
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.base.mapper;
import cn.iocoder.yudao.module.base.entity.DlDriveSchoolStudent;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStaffVO;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
import cn.iocoder.yudao.module.base.vo.StudentCountVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -87,5 +88,14 @@ public interface DlDriveSchoolStudentMapper extends BaseMapper<DlDriveSchoolStud
**/
IPage<DlDriveSchoolStudentVO> selectTrainStudent(@Param("coachId")Long coachId, @Param("startTime") String startTime, @Param("endTime")String endTime,@Param("searchValue")String searchValue, Page<DlDriveSchoolStudent> page);
/**
* @param type 时间查询类型01驾校统招02教练自招03自来客户
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
* @return java.util.List<cn.iocoder.yudao.module.base.vo.StudentCountVO>
* @author PQZ
* @date 17:08 2025/2/19
**/
List<StudentCountVO> indexGetTrainList(@Param("type")String type, @Param("coachId")Long coachId, @Param("startTime")String startTime, @Param("endTime")String endTime);
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.base.service;
import cn.iocoder.yudao.module.base.entity.DlDriveSchoolStudent;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStaffVO;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
import cn.iocoder.yudao.module.base.vo.StudentCountVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
@ -110,4 +111,16 @@ public interface DlDriveSchoolStudentService extends IService<DlDriveSchoolStude
* @date 10:41 2025/1/18
**/
IPage<DlDriveSchoolStudentVO> queryCoachListPage(DlDriveSchoolStudentVO pageReqVO, Page<DlDriveSchoolStudentVO> page);
/**
*
* @author PQZ
* @date 17:08 2025/2/19
* @param type 时间查询类型01驾校统招02教练自招03自来客户
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
* @return java.util.List<cn.iocoder.yudao.module.base.vo.StudentCountVO>
**/
List<StudentCountVO> indexGetTrainList(String type, Long coachId, String startTime, String endTime);
}

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.base.mapper.DlDriveSchoolStudentMapper;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolStudentService;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStaffVO;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
import cn.iocoder.yudao.module.base.vo.StudentCountVO;
import cn.iocoder.yudao.module.course.service.ProcessService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -159,5 +160,19 @@ public class DlDriveSchoolStudentServiceImpl extends ServiceImpl<DlDriveSchoolSt
return pageResult;
}
/**
* @param type 时间查询类型01驾校统招02教练自招03自来客户
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
* @return java.util.List<cn.iocoder.yudao.module.base.vo.StudentCountVO>
* @author PQZ
* @date 17:08 2025/2/19
**/
@Override
public List<StudentCountVO> indexGetTrainList(String type, Long coachId, String startTime, String endTime) {
return dlDriveSchoolStudentMapper.indexGetTrainList(type,coachId,startTime,endTime);
}
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.base.vo;
import lombok.Data;
@Data
public class StudentCountVO {
/**教练头像*/
private String image;
/**姓名*/
private String coachName;
/**车牌号*/
private String carId;
/**C1人数*/
private Integer c1Num;
/**C2人数*/
private Integer c2Num;
/**总人数*/
private Integer totalNum;
}

View File

@ -147,4 +147,35 @@
GROUP BY
dss.id
</select>
<select id="indexGetTrainList" resultType="cn.iocoder.yudao.module.base.vo.StudentCountVO">
SELECT
c.image AS image,
c.NAME AS coachName,
c.car_id AS carId,
COUNT(DISTINCT s.user_id) AS totalNum,
COUNT(DISTINCT CASE WHEN o.course_type = 'C1' THEN o.user_id END) AS c1Num,
COUNT(DISTINCT CASE WHEN o.course_type = 'C2' THEN o.user_id END) AS c2Num
FROM
drive_school_coach c
LEFT JOIN drive_school_student s ON c.id = s.source_user_id
<if test="type != null and type != ''">
AND s.source = #{type}
</if>
LEFT JOIN drive_school_course_order o ON s.user_id = o.user_id AND o.payment_status > 1
<if test="startTime != null and startTime != ''">
AND o.create_time &gt;= #{starTime}
</if>
<if test="endTime != null and endTime != ''">
AND o.create_time &lt;= #{endTime}
</if>
WHERE
c.deleted = 0
<if test="coachId != null and coachId != ''">
AND c.user_id = #{coachId}
</if>
GROUP BY
c.image, c.NAME, c.car_id
ORDER BY
totalNum ASC;
</select>
</mapper>