This commit is contained in:
Lx 2025-07-24 17:04:20 +08:00
parent 11b35c0d22
commit 4b43a98bef

View File

@ -55,6 +55,61 @@
</select>
<select id="trainClockByCar" resultType="cn.iocoder.yudao.module.train.vo.TrainCarCountVO">
SELECT
dscc.user_name,
dscc.car_id,
dscc.car_no,
COUNT(*) AS totalCount,
SUM(CASE WHEN dscc.subject = 2 THEN 1 ELSE 0 END) AS subject2Count,
SUM(CASE WHEN dscc.subject = 3 THEN 1 ELSE 0 END) AS subject3Count,
SUM(dscc.train_time) AS trainTimeCount,
SUM(IFNULL(dst.student_count, 0)) AS studentCount,
SUM(CASE WHEN dscc.subject = 2 THEN dscc.train_time ELSE 0 END) AS subject2TrainTime,
SUM(CASE WHEN dscc.subject = 3 THEN dscc.train_time ELSE 0 END) AS subject3TrainTime
FROM
drive_school_coach_clock dscc
LEFT JOIN
drive_school_car car ON dscc.car_id = car.id AND car.deleted = 0
LEFT JOIN (
SELECT
coach_clock_id,
COUNT(*) AS student_count
FROM
drive_school_train
WHERE
deleted = 0
AND coach_clock_id IS NOT NULL
GROUP BY
coach_clock_id
) dst ON dst.coach_clock_id = dscc.id
WHERE
dscc.deleted = 0
AND dscc.subject IN (2, 3)
<if test="entity.userId != null">
AND dscc.user_id = #{entity.userId}
</if>
<if test="entity.carNo != null and entity.carNo != '' ">
AND dscc.car_no = #{entity.carNo}
</if>
<if test="entity.subject != null">
AND dscc.subject = #{entity.subject}
</if>
<if test="entity.courseType != null and entity.courseType != '' ">
AND car.course_type = #{entity.courseType}
</if>
<if test="entity.trainDayStartTime != null and entity.trainDayStartTime != '' ">
AND dscc.train_day &gt;= #{entity.trainDayStartTime}
</if>
<if test="entity.trainDayEndTime != null and entity.trainDayEndTime != '' ">
AND dscc.train_day &lt;= #{entity.trainDayEndTime}
</if>
GROUP BY
dscc.car_no, dscc.car_id, dscc.user_name
ORDER BY
totalCount DESC
</select>
<!-- <select id="trainClockByCar" resultType="cn.iocoder.yudao.module.train.vo.TrainCarCountVO">
SELECT
dscc.user_name,
dscc.car_id,
@ -97,7 +152,7 @@
dscc.car_no, dscc.car_id, dscc.user_name
ORDER BY
totalCount DESC
</select>
</select>-->
<select id="selectCoachClockIdsByCarId" resultType="cn.iocoder.yudao.module.train.entity.DriveSchoolCoachClock">
SELECT