<iftest="instrumentTypeId != null">#{instrumentTypeId},(select instrument_type_name from school_instrument_classify where id = #{instrumentTypeId}),</if>
<iftest="instrumentTypeId != null">instrument_type_id = #{instrumentTypeId},instrument_type_name = (select instrument_type_name from school_instrument_classify where id = #{instrumentTypeId}),</if>
ep.id as id, ep.grade_id as gradeId, ep.grade as grade, ep.school_year as schoolYear, ep.semester as semester, ep.experiment_name as experimentName, ep.sub as sub,
COUNT(epc.id) as totalClass,
(SELECT COUNT(tla.id) FROM school_teacher_lab_apply tla WHERE tla.del_flag = '0' AND tla.state = '1' AND tla.lab_class_year_id in (SELECT id FROM school_lab_class_year lcy WHERE lcy.del_flag = '0' AND lcy.experiment_plan_id = ep.id)) as completeClass
FROM
school_experiment_plan ep
LEFT JOIN school_experiment_plan_class epc ON ep.id = epc.experiment_plan_id AND epc.del_flag = '0'
WHERE
ep.del_flag = '0'
<iftest="sub != null and sub != ''"> and ep.sub = #{sub}</if>
<iftest="gradeId != null "> and ep.grade_id = #{gradeId}</if>
<iftest="grade != null and grade != ''"> and ep.grade like concat('%', #{grade}, '%')</if>
<iftest="experimentName != null and experimentName != ''"> and ep.experiment_name like concat('%', #{experimentName}, '%')</if>
<iftest="schoolYear != null and schoolYear != ''"> and ep.school_year = #{schoolYear}</if>
<iftest="semester != null and semester != ''"> and ep.semester = #{semester}</if>
( SELECT COUNT( CASE WHEN state = 1 THEN state END ) FROM school_teacher_lab_apply WHERE del_flag = '0' AND class_id = epc.class_id and grade_id = ep.grade_id ) as ywcsys
FROM
school_experiment_plan ep
LEFT JOIN school_experiment_plan_class epc ON ep.id = epc.experiment_plan_id
LEFT JOIN school_class c ON epc.class_id = c.id
WHERE
ep.del_flag = '0' and epc.del_flag = '0'
<iftest="semester != null and semester != ''">and ep.semester = #{semester}</if>
<iftest="schoolYear != null and schoolYear != ''">and ep.school_year = #{schoolYear}</if>
<iftest="statu != null and statu != ''"> and statu = #{statu}</if>
<iftest="startTime != null and endTime != null and startTime != '' and endTime != ''">and DATE_FORMAT(appointment_time,'%Y-%m-%d') between #{startTime} and #{endTime}</if>