This commit is contained in:
Lx 2025-07-08 10:41:00 +08:00
parent 26fbc39043
commit 0062df3660
7 changed files with 177 additions and 8 deletions

View File

@ -18,6 +18,7 @@ public class BusinessRecordVO extends TenantBaseDO {
private String channel;
private String courseId;
private String courseName;
private String courseType;
private String coachUserName;
private BigDecimal reserveMoney;
private BigDecimal restMoney;
@ -30,5 +31,6 @@ public class BusinessRecordVO extends TenantBaseDO {
private BigDecimal subsidy;
private String scheme;
private String ifEnd;
private String image;
}

View File

@ -2,12 +2,14 @@ package cn.iocoder.yudao.module.jx.domain;
import cn.iocoder.yudao.annotation.Excel;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.train.entity.Train;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 车辆信息对象 drive_school_car
@ -118,4 +120,36 @@ public class DriveSchoolCar extends TenantBaseDO
/** 车龄 */
@TableField(exist = false)
private Long carOld;
private String userNum;
/**
* 训练开始时间
*/
private Date earliestStartTime;
/**
* 训练结束时间
*/
private Date latestEndTime;
/**
* 累计训练时间
*/
private String totalTrainTime;
/**
* 科目二训练时间
*/
private String subject2TrainTime;
/**
* 科目三训练时间
*/
private String subject3TrainTime;
/**
* 学员姓名及科目
*/
private List<Train> studentList;
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.jx.mapper;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolCar;
import cn.iocoder.yudao.module.train.entity.Train;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -54,7 +55,15 @@ public interface DriveSchoolCarMapper extends BaseMapper<DriveSchoolCar>
* @param endTime 截止时间
* @return java.util.List<cn.iocoder.yudao.module.base.vo.DriveSchoolCar>
**/
IPage<DriveSchoolCar> selectTrainCar(@Param("coachId")Long coachId, @Param("startTime") String startTime,
IPage<DriveSchoolCar> selectTrainCar(@Param("coachId")Long coachId, @Param("subject") Integer subject, @Param("startTime") String startTime,
@Param("endTime")String endTime,@Param("searchValue")String searchValue,
@Param("courseType")String courseType, Page<DriveSchoolCar> page);
List<Train> selectTrainStudentList(@Param("coachId")Long coachId, @Param("subject") Integer subject, @Param("startTime") String startTime,
@Param("endTime")String endTime, @Param("searchValue")String searchValue,
@Param("courseType")String courseType);
String selectTrainStudent(@Param("coachId")Long coachId, @Param("subject") Integer subject, @Param("startTime") String startTime,
@Param("endTime")String endTime,@Param("searchValue")String searchValue,
@Param("courseType")String courseType);
}

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
import cn.iocoder.yudao.module.course.service.ProcessService;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolCar;
import cn.iocoder.yudao.module.jx.mapper.DriveSchoolCarMapper;
import cn.iocoder.yudao.module.train.entity.Train;
import cn.iocoder.yudao.module.train.service.TrainService;
import cn.iocoder.yudao.module.train.vo.TrainVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -22,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 练车记录")
@ -129,7 +132,52 @@ public class TrainController {
}else{
//训练车辆
Page<DriveSchoolCar> page = new Page<>(pageNo,pageSize);
return success(carMapper.selectTrainCar(coachId,startTimeStr,endTimeStr,searchValue,courseType,page));
IPage<DriveSchoolCar> driveSchoolCarIPage = carMapper.selectTrainCar(coachId, subject, startTimeStr, endTimeStr, searchValue, courseType, page);
for (DriveSchoolCar record : driveSchoolCarIPage.getRecords()) {
List<Train> trainList = carMapper.selectTrainStudentList(Long.parseLong(record.getUserId()), subject, startTimeStr, endTimeStr, searchValue, courseType);
record.setStudentList(trainList);
}
return success(driveSchoolCarIPage);
}
}
}
@GetMapping("/indexGetTrainStudentNum")
@Operation(summary = "首页数据统计查询接口")
public CommonResult<?> indexGetTrainStudentNum(@RequestParam(value = "type") String type,
@RequestParam(value = "timeType") String timeType,
@RequestParam(value = "coachId",required = false) Long coachId,
@RequestParam(value = "sourceCoachId",required = false) Long sourceCoachId,
@RequestParam(value = "searchValue",required = false) String searchValue,
@RequestParam(value = "courseType",required = false) String courseType,
@RequestParam(value = "subject",required = false) Integer subject,
@RequestParam(value = "sort",required = false) String sort,
@RequestParam(value = "startTime",required = false) String startTime,
@RequestParam(value = "endTime",required = false) String endTime,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
//默认查全部数据
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(carMapper.selectTrainStudent(coachId,subject, startTimeStr,endTimeStr,searchValue,courseType));
}
}

View File

@ -130,7 +130,7 @@ public class AppTrainController {
}else{
//训练车辆
Page<DriveSchoolCar> page = new Page<>(pageNo,pageSize);
return success(carMapper.selectTrainCar(coachId,startTimeStr,endTimeStr,searchValue,courseType,page));
return success(carMapper.selectTrainCar(coachId,subject,startTimeStr,endTimeStr,searchValue,courseType,page));
}
}
}
}

View File

@ -147,7 +147,8 @@
dsco.create_time,
dsco.sign_time,
dsco.course_id,
dsco.scheme_id AS scheme
dsco.scheme_id AS scheme,
dsco.course_type
from drive_school_course_order dsco
LEFT JOIN drive_school_student dss ON dss.user_id = dsco.user_id AND dss.deleted = 0
LEFT JOIN drive_school_coach dsc ON dss.source_user_id = dsc.user_id AND dsc.deleted = 0
@ -172,6 +173,9 @@
<if test="entity.paymentStatus != null and entity.paymentStatus != ''">
AND dsco.payment_status = #{entity.paymentStatus}
</if>
<if test="entity.courseType != null and entity.courseType != ''">
AND dsco.course_type = #{entity.courseType}
</if>
<if test="entity.startTimeStr != null and entity.startTimeStr != ''">
AND dsco.create_time &gt;= #{entity.startTimeStr}
</if>
@ -217,7 +221,8 @@
dsco.is_sign,
dsc.name AS businessName,
dsc.phone AS businessPhone,
dsco.create_time
dsco.create_time,
dsc.image
from drive_school_student dss
LEFT JOIN drive_school_course_order dsco ON dss.user_id = dsco.user_id
<if test="entity.startTimeStr != null and entity.startTimeStr != ''">

View File

@ -102,7 +102,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectTrainCar" resultType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCar">
SELECT
dscc.*
dscc.*,
COUNT(DISTINCT dst.user_id) AS userNum,
MIN(dst.start_time) AS earliestStartTime,
MAX(dst.end_time) AS latestEndTime,
SUM(dst.train_time) AS totalTrainTime,
SUM(CASE WHEN dst.subject = 2 THEN dst.train_time ELSE 0 END) AS subject2TrainTime,
SUM(CASE WHEN dst.subject = 3 THEN dst.train_time ELSE 0 END) AS subject3TrainTime
FROM
drive_school_train dst
LEFT JOIN drive_school_coach dsc ON dst.coach_id = dsc.user_id AND dst.deleted = 0
@ -125,9 +131,74 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endTime!=null and endTime!=''">
AND dst.create_time &lt;= #{endTime}
</if>
<if test="subject!=null and subject!=''">
AND dst.subject = #{subject}
</if>
GROUP BY
dscc.id
</select>
<select id="selectTrainStudentList" resultType="cn.iocoder.yudao.module.train.entity.Train">
SELECT
dst.*
FROM
drive_school_train dst
LEFT JOIN drive_school_coach dsc ON dst.coach_id = dsc.user_id AND dst.deleted = 0
LEFT JOIN drive_school_car dscc ON dsc.car_id = dscc.car_no
WHERE
dst.id IS NOT NULL
AND dsc.deleted = 0
<if test="coachId != null and coachId != ''">
AND dst.coach_id = #{coachId}
</if>
<if test="searchValue != null and searchValue != ''">
AND dsc.car_no LIKE CONCAT('%',#{searchValue},'%')
</if>
<if test="courseType != null and courseType != ''">
AND dscc.course_type =#{courseType}
</if>
<if test="startTime!=null and startTime!=''">
AND dst.create_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
AND dst.create_time &lt;= #{endTime}
</if>
<if test="subject!=null and subject!=''">
AND dst.subject = #{subject}
</if>
GROUP BY
dst.user_id
</select>
<select id="selectTrainStudent" resultType="string">
SELECT
COUNT(DISTINCT dst.user_id)
FROM
drive_school_train dst
LEFT JOIN drive_school_coach dsc ON dst.coach_id = dsc.user_id AND dst.deleted = 0
LEFT JOIN drive_school_car dscc ON dsc.car_id = dscc.car_no
WHERE
dst.user_id IS NOT NULL
AND dsc.deleted = 0
<if test="coachId != null and coachId != ''">
AND dst.coach_id = #{coachId}
</if>
<if test="searchValue != null and searchValue != ''">
AND dsc.car_no LIKE CONCAT('%',#{searchValue},'%')
</if>
<if test="courseType != null and courseType != ''">
AND dscc.course_type =#{courseType}
</if>
<if test="startTime!=null and startTime!=''">
AND dst.create_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
AND dst.create_time &lt;= #{endTime}
</if>
<if test="subject!=null and subject!=''">
AND dst.subject = #{subject}
</if>
</select>
</mapper>