|  | @@ -159,8 +159,6 @@
 | 
	
		
			
				|  |  |          <result column="class_date_" property="classDate"/>
 | 
	
		
			
				|  |  |          <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 | 
	
		
			
				|  |  |          <result column="name_" property="name"/>
 | 
	
		
			
				|  |  | -        <result column="sign_in_time_" property="signInTime"/>
 | 
	
		
			
				|  |  | -        <result column="sign_out_time_" property="signOutTime"/>
 | 
	
		
			
				|  |  |          <result column="sign_in_status_" property="signInStatus"/>
 | 
	
		
			
				|  |  |          <result column="sign_out_status_" property="signOutStatus"/>
 | 
	
		
			
				|  |  |          <result column="remark_" property="remark"/>
 | 
	
	
		
			
				|  | @@ -168,6 +166,23 @@
 | 
	
		
			
				|  |  |          <result column="end_class_time_" property="endClassTime"/>
 | 
	
		
			
				|  |  |      </resultMap>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    <resultMap id="TeacherAttendancesDto" type="com.ym.mec.biz.dal.dto.TeacherAttendancesDto">
 | 
	
		
			
				|  |  | +        <result column="class_date_" property="classDate"/>
 | 
	
		
			
				|  |  | +        <result column="start_class_time_" property="startClassTime"/>
 | 
	
		
			
				|  |  | +        <result column="end_class_time_" property="endClassTime"/>
 | 
	
		
			
				|  |  | +        <result column="course_schedule_type_" property="courseScheduleType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 | 
	
		
			
				|  |  | +        <result column="course_schedule_status_" property="courseScheduleStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 | 
	
		
			
				|  |  | +        <result column="course_schedule_name_" property="courseScheduleName"/>
 | 
	
		
			
				|  |  | +        <result column="teacher_name_" property="teacherName"/>
 | 
	
		
			
				|  |  | +        <result column="teacher_id_" property="teacherId"/>
 | 
	
		
			
				|  |  | +        <result column="sign_in_status_" property="signInStatus"/>
 | 
	
		
			
				|  |  | +        <result column="sign_out_status_" property="signOutStatus"/>
 | 
	
		
			
				|  |  | +        <result column="sign_in_time_" property="signInTime"/>
 | 
	
		
			
				|  |  | +        <result column="sign_out_time_" property="signOutTime"/>
 | 
	
		
			
				|  |  | +        <result column="remark_" property="remark"/>
 | 
	
		
			
				|  |  | +        <result column="course_schedule_id_" property="courseScheduleId"/>
 | 
	
		
			
				|  |  | +    </resultMap>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      <sql id="queryCondition">
 | 
	
		
			
				|  |  |          <where>
 | 
	
		
			
				|  |  |              (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
 | 
	
	
		
			
				|  | @@ -200,10 +215,42 @@
 | 
	
		
			
				|  |  |              </if>
 | 
	
		
			
				|  |  |          </where>
 | 
	
		
			
				|  |  |      </sql>
 | 
	
		
			
				|  |  | +    <sql id="queryTeacherAttendancesCondition">
 | 
	
		
			
				|  |  | +        <where>
 | 
	
		
			
				|  |  | +            (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL) AND cs.actual_teacher_id_ = ta.teacher_id_
 | 
	
		
			
				|  |  | +            <if test="search != null and search != ''">
 | 
	
		
			
				|  |  | +                AND (su.id_ = #{search} OR su.real_name_ LIKE CONCAT('%',#{search},'%') OR cs.id_ = #{search} OR cs.name_ LIKE CONCAT('%',#{search},'%'))
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="courseStartDate != null">
 | 
	
		
			
				|  |  | +                AND cs.class_date_ >= #{courseStartDate}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="courseEndDate != null">
 | 
	
		
			
				|  |  | +                AND cs.class_date_ <= #{courseEndDate}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="signInStatus != null and signInStatus != '' and signInStatus != 3">
 | 
	
		
			
				|  |  | +                AND ta.sign_in_status_ = #{signInStatus}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="signOutStatus != null and signOutStatus != '' and signOutStatus != 3">
 | 
	
		
			
				|  |  | +                AND ta.sign_out_status_ = #{signOutStatus}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="signOutStatus != null and signOutStatus != '' and signOutStatus == 3">
 | 
	
		
			
				|  |  | +                AND ta.sign_out_status_ IS NULL
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="signInStatus != null and signInStatus != '' and signInStatus == 3">
 | 
	
		
			
				|  |  | +                AND ta.sign_in_status_ IS NULL
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="courseScheduleType != null">
 | 
	
		
			
				|  |  | +                AND cs.type_ = #{courseScheduleType}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="organId != null and organId != ''">
 | 
	
		
			
				|  |  | +                AND FIND_IN_SET(t.organ_id_,#{organId})
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +        </where>
 | 
	
		
			
				|  |  | +    </sql>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="getTeacherPersonalAttendances" parameterType="map" resultMap="teacherPersonalAttendance">
 | 
	
		
			
				|  |  |          SELECT
 | 
	
		
			
				|  |  | -            cs.class_date_,cs.start_class_time_,cs.name_,cs.type_,ta.sign_in_time_,ta.sign_out_time_,
 | 
	
		
			
				|  |  | +            cs.class_date_,cs.start_class_time_,cs.name_,cs.type_,
 | 
	
		
			
				|  |  |              IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
 | 
	
		
			
				|  |  |              IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_,
 | 
	
		
			
				|  |  |              ta.remark_,cs.id_,cs.end_class_time_
 | 
	
	
		
			
				|  | @@ -215,12 +262,37 @@
 | 
	
		
			
				|  |  |          <include refid="global.limit"/>
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    <select id="queryTeacherAttendances" parameterType="map" resultMap="TeacherAttendancesDto">
 | 
	
		
			
				|  |  | +        SELECT su.real_name_ teacher_name_,su.id_ teacher_id_,ta.course_schedule_id_,cs.name_ course_schedule_name_,
 | 
	
		
			
				|  |  | +        cs.status_ course_schedule_status_,
 | 
	
		
			
				|  |  | +        cs.class_date_,cs.start_class_time_,cs.end_class_time_,cs.type_ course_schedule_type_,
 | 
	
		
			
				|  |  | +        IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
 | 
	
		
			
				|  |  | +        IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_,
 | 
	
		
			
				|  |  | +        ta.sign_in_time_,ta.sign_out_time_,ta.remark_
 | 
	
		
			
				|  |  | +        FROM course_schedule cs
 | 
	
		
			
				|  |  | +        LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
 | 
	
		
			
				|  |  | +        LEFT JOIN teacher t ON t.id_ = ta.teacher_id_
 | 
	
		
			
				|  |  | +        LEFT JOIN sys_user su ON su.id_ = t.id_
 | 
	
		
			
				|  |  | +        <include refid="queryTeacherAttendancesCondition"/>
 | 
	
		
			
				|  |  | +        ORDER BY cs.class_date_ ASC,cs.start_class_time_ ASC
 | 
	
		
			
				|  |  | +        <include refid="global.limit"/>
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      <select id="getTeacherPersonalAttendancesCount" resultType="int">
 | 
	
		
			
				|  |  |          SELECT count(cs.id_) FROM course_schedule cs LEFT JOIN teacher_attendance ta
 | 
	
		
			
				|  |  |          ON ta.course_schedule_id_=cs.id_
 | 
	
		
			
				|  |  |          <include refid="queryCondition"/>
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    <select id="countTeacherAttendances" resultType="int">
 | 
	
		
			
				|  |  | +        SELECT COUNT(DISTINCT cs.id_)
 | 
	
		
			
				|  |  | +        FROM course_schedule cs
 | 
	
		
			
				|  |  | +        LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
 | 
	
		
			
				|  |  | +        LEFT JOIN teacher t ON t.id_ = ta.teacher_id_
 | 
	
		
			
				|  |  | +        LEFT JOIN sys_user su ON su.id_ = t.id_
 | 
	
		
			
				|  |  | +        <include refid="queryTeacherAttendancesCondition"/>
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      <select id="countClassTime" resultType="java.lang.Integer">
 | 
	
		
			
				|  |  |          SELECT COUNT(*) FROM teacher_attendance WHERE class_group_id_=#{classGroupId} FOR UPDATE
 | 
	
		
			
				|  |  |      </select>
 |