<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="WebAttendance">
	
	<select id="selectListAttendanceDate" parameterType="hashmap" resultType="hashmap">
		WITH RECURSIVE T_TEMP_DATES AS (
    SELECT DATE(CONCAT(#{attendanceSearchDate}, '-01')) AS RESULT_DATE
            UNION ALL
            SELECT DATE_ADD(RESULT_DATE, INTERVAL 1 DAY)
            FROM T_TEMP_DATES
            WHERE RESULT_DATE &lt; LAST_DAY(CONCAT(#{attendanceSearchDate}, '-01'))
                                         )
                                         SELECT
                                         RESULT_DATE AS "resultDate",
                                         MONTH(RESULT_DATE) AS "month",
                                         DAY(RESULT_DATE) AS "day",
                                         CASE DAYOFWEEK(RESULT_DATE)
                                             WHEN 1 THEN '일'
                                             WHEN 2 THEN '월'
                                             WHEN 3 THEN '화'
                                             WHEN 4 THEN '수'
                                             WHEN 5 THEN '목'
                                             WHEN 6 THEN '금'
                                             WHEN 7 THEN '토'
                                             END AS "dayOfWeek"
                                         FROM T_TEMP_DATES
                                         ORDER BY RESULT_DATE

	</select>
	
	<select id="selectListAttendanceMember" parameterType="hashmap" resultType="hashmap">
		SELECT MA.MU_MEMBER_ID                                   AS "muMemberId"
			  ,MA.NAME                                           AS "memberName"
			  ,MA.LOGIN_ID                                       AS "loginId"
			  ,MA.MU_GROUP_ID                                    AS "muGroupId"
			  ,IFNULL((SELECT MG.GROUP_NAME
						 FROM MU_GROUP AS MG
						WHERE MG.USE_YN      = 'Y'
			 			  AND MG.MU_GROUP_ID = MA.MU_GROUP_ID
			 			LIMIT 0, 1
			   ),'')                                             AS "groupName"
			  ,MA.MU_DUTY_ID                                     AS "muDutyId"
			  ,IFNULL((SELECT MD.DUTY_NAME
						 FROM MU_DUTY AS MD
						WHERE MD.USE_YN      = 'Y'
			 			  AND MD.MU_DUTY_ID = MA.MU_DUTY_ID
			 			LIMIT 0, 1
			   ),'')                                             AS "dutyName"
		      ,MA.MEMBER_CODE                                    AS "memberCode"
		  FROM (
				SELECT DISTINCT MM.MU_MEMBER_ID
					  ,MM.NAME
					  ,MM.LOGIN_ID
					  ,MM.MU_GROUP_ID
					  ,MM.MU_DUTY_ID
					  ,MM.MEMBER_CODE
				  FROM MU_MEMBER AS MM
			 LEFT JOIN MU_ATTENDANCE MA
				    ON MM.MU_MEMBER_ID = MA.MU_MEMBER_ID
				   AND MM.USE_YN  = 'Y'
				   AND MA.USE_YN  = 'Y'
				   AND MA.STATUS != 'D'
				   AND ((DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{attendanceSearchStartDate} AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')    >= #{attendanceSearchStartDate})
				    OR (DATE_FORMAT(MA.START_DATE,'%Y-%m-%d')  &lt;= #{attendanceSearchEndDate}   AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')    >= #{attendanceSearchEndDate})
				    OR (DATE_FORMAT(MA.START_DATE,'%Y-%m-%d')      > #{attendanceSearchStartDate} AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')  &lt; #{attendanceSearchEndDate}))
			     WHERE MM.USE_YN = 'Y'
				   AND MM.STATUS = 'Y'
		  ) AS MA
		 WHERE 1 = 1
		   <if test="attendanceSearchGroupId != null and attendanceSearchGroupId != ''">
		   AND MA.MU_GROUP_ID  = #{attendanceSearchGroupId}
		   </if>
		   <if test="attendanceSearchKeywordParam != null and attendanceSearchKeywordParam != ''">
		   AND (MA.NAME LIKE CONCAT('%',TRIM(#{attendanceSearchKeywordParam}),'%'))
		   </if>
	  ORDER BY MA.MEMBER_CODE ASC
	</select>
	
	<select id="selectListAttendance" parameterType="hashmap" resultType="hashmap">
		SELECT MAX(MU_ATTENDANCE_ID)                                                         AS "muAttendanceId"
			  ,MA.MU_MEMBER_ID                                                               AS "muMemberId"
			  ,'A'                                                                           AS "attendanceType"
			  ,#{searchDate}                                                                 AS "searchDate"
			  ,IFNULL(MAX(START_TIME),'-')                                                   AS "startTime"
			  ,MAX(MU_ATTENDANCE_ID2)                                                        AS "muAttendanceId2"
			  ,IFNULL(MAX(END_TIME),'-')                                                     AS "endTime"
			  ,IFNULL(DATE_FORMAT(TIMEDIFF(MAX(END_TIME), MAX(START_TIME)), '%H시간%i분'),'-') AS "totalWorkHour"
			  ,''                                                                            AS "muVacationId"
			  ,''                                                                            AS "vacationName"
		 FROM (
					<!-- 출근 -->
					SELECT MA.MU_ATTENDANCE_ID                          AS MU_ATTENDANCE_ID
						  ,MA.MU_MEMBER_ID                              AS MU_MEMBER_ID
						  ,DATE_FORMAT(MA.ATTENDANCE_TIME, '%H:%i')     AS START_TIME
						  ,''                                           AS MU_ATTENDANCE_ID2 
						  ,NULL                                         AS END_TIME 
					  FROM MU_ATTENDANCE AS MA
					 WHERE MA.USE_YN                                 = 'Y'
					   AND MA.STATUS                                != 'D'
					   AND MA.ATTENDANCE_TYPE                        = 'A'
					   AND MA.MU_MEMBER_ID                           = #{muMemberId}
					   AND DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{searchDate}
					   AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')      >= #{searchDate}
					 UNION
					<!-- 퇴근 -->
					SELECT ''                                           AS MU_ATTENDANCE_ID
						  ,MA.MU_MEMBER_ID                              AS MU_MEMBER_ID
						  ,NULL                                         AS START_TIME
						  ,MA.MU_ATTENDANCE_ID                          AS MU_ATTENDANCE_ID2
						  ,DATE_FORMAT(MA.ATTENDANCE_TIME, '%H:%i')     AS END_TIME
					  FROM MU_ATTENDANCE AS MA
					 WHERE MA.USE_YN                                 = 'Y'
					   AND MA.STATUS                                != 'D'
					   AND MA.ATTENDANCE_TYPE                        = 'B'
					   AND MA.MU_MEMBER_ID                           = #{muMemberId}
					   AND DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{searchDate}
					   AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')      >= #{searchDate}
			   ) AS MA
	  GROUP BY MU_MEMBER_ID
		 UNION
		<!-- 휴무 -->
		SELECT MA.MU_ATTENDANCE_ID                                      AS "muAttendanceId"
			  ,MA.MU_MEMBER_ID                                          AS "muMemberId"
			  ,MA.ATTENDANCE_TYPE                                       AS "attendanceType"
			  ,#{searchDate}                                            AS "searchDate"
			  ,''                                                       AS "startTime"
			  ,''                                                       AS "muAttendanceId2"
			  ,''                                                       AS "endTime"
			  ,''                                                       AS "totalWorkHour"
			  ,''                                                       AS "muVacationId"
			  ,''                                                       AS "vacationName"
		  FROM MU_ATTENDANCE AS MA
		 WHERE MA.USE_YN                                 = 'Y'
		   AND MA.STATUS                                != 'D'
		   AND MA.ATTENDANCE_TYPE                        = 'C'
		   AND MA.MU_MEMBER_ID                           = #{muMemberId}
		   AND DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{searchDate}
		   AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')      >= #{searchDate}
		 UNION
		<!-- 연차/반차 -->
		SELECT MA.MU_ATTENDANCE_ID                                      AS "muAttendanceId"
			  ,MA.MU_MEMBER_ID                                          AS "muMemberId"
			  ,MA.ATTENDANCE_TYPE                                       AS "attendanceType"
			  ,#{searchDate}                                            AS "searchDate"
			  ,DATE_FORMAT(MA.START_TIME, '%H:%i')                      AS "startTime"
			  ,''                                                       AS "muAttendanceId2"
			  ,DATE_FORMAT(MA.END_TIME, '%H:%i')                        AS "endTime"
			  ,''                                                       AS "totalWorkHour"
			  ,MA.MU_VACATION_ID                                        AS "muVacationId"
			  ,IFNULL((SELECT MV.VACATION_NAME
						 FROM MU_VACATION AS MV
						WHERE MV.USE_YN      = 'Y'
			 			  AND MV.MU_VACATION_ID = MA.MU_VACATION_ID
			 			LIMIT 0, 1
			   ),'')                                                    AS "vacationName"
		  FROM MU_ATTENDANCE AS MA
		 WHERE MA.USE_YN                                 = 'Y'
		   AND MA.STATUS                                != 'D'
		   AND MA.ATTENDANCE_TYPE                       IN ('D', 'E')
		   AND MA.MU_MEMBER_ID                           = #{muMemberId}
		   AND DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{searchDate}
		   AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')      >= #{searchDate}
	</select>

	<select id="selectAttendance" parameterType="hashmap" resultType="hashmap">
		SELECT MA.MU_ATTENDANCE_ID                                AS "muAttendanceId"
			  ,MA.MU_MEMBER_ID                                    AS "muMemberId"
			  ,IFNULL((SELECT MM.NAME
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.MU_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                              AS "memberName"
			  ,IFNULL((SELECT MM.LOGIN_ID
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.MU_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                              AS "loginId"
			  ,MA.MU_GROUP_ID                                     AS "muGroupId"
			  ,IFNULL((SELECT MG.GROUP_NAME
						 FROM MU_GROUP AS MG
						WHERE MG.USE_YN      = 'Y'
			 			  AND MG.MU_GROUP_ID = MA.MU_GROUP_ID
			 			LIMIT 0, 1
			   ),'')                                              AS "groupName"
			  ,MA.MU_DUTY_ID                                      AS "muDutyId"
			  ,IFNULL((SELECT MD.DUTY_NAME
						 FROM MU_DUTY AS MD
						WHERE MD.USE_YN      = 'Y'
			 			  AND MD.MU_DUTY_ID = MA.MU_DUTY_ID
			 			LIMIT 0, 1
			   ),'')                                              AS "dutyName"
			  ,DATE_FORMAT(MA.START_DATE, '%Y-%m-%d')             AS "startDate"
			  ,DATE_FORMAT(MA.END_DATE, '%Y-%m-%d')               AS "endDate"
			  ,ABS(DATEDIFF(MA.START_DATE, MA.END_DATE))+1        AS "days"
			  ,MA.STATUS                                          AS "status"
			  ,CASE MA.STATUS
					WHEN 'C' THEN '등록'
					WHEN 'U' THEN '등록(수정)'
					WHEN 'D' THEN '취소'
					ELSE ''
			   END                                                AS "statusKorName"
			  ,IFNULL(MA.ETC, '')                                 AS "etc"
			  ,IFNULL(MA.CANCEL_ETC, '')                          AS "cancelEtc"
			  ,DATE_FORMAT(MA.CANCEL_DATE, '%Y-%m-%d, %H:%i')     AS "cancelDate"
			  ,DATE_FORMAT(MA.WRITE_DATE, '%Y-%m-%d')             AS "writeDate"
			  ,DATE_FORMAT(MA.WRITE_TIME, '%H:%i')                AS "writeTime"
			  ,MA.WRITE_MEMBER_ID                                 AS "writeMemberId"
			  ,IFNULL((SELECT MM.NAME
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.WRITE_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                              AS "writeMemberName"
			  ,MA.CANCEL_MEMBER_ID                                 AS "cancelMemberId"
			  ,IFNULL((SELECT MM.NAME
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.CANCEL_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                              AS "cancelMemberName"
		  FROM MU_ATTENDANCE AS MA
		 WHERE MA.USE_YN            = 'Y'
		   AND MA.ATTENDANCE_TYPE   = 'C'
		   AND MA.MU_ATTENDANCE_ID  = #{muAttendanceId}
		 LIMIT 0, 1
	</select>
	
	<select id="selectAttendanceDate" parameterType="hashmap" resultType="hashmap">
		SELECT COUNT(*)        AS "totalCount"
		  FROM MU_ATTENDANCE AS MA
		 WHERE MA.USE_YN            = 'Y'
		   AND MA.STATUS               != 'D'
			<choose>
				<when test="attendanceType eq 'C'.toString()">
					AND MA.ATTENDANCE_TYPE  = 'E'
				</when>
				<when test="attendanceType eq 'E'.toString()">
					AND MA.ATTENDANCE_TYPE  != 'B'
					AND MA.ATTENDANCE_TYPE  != 'A'
				</when>
				<otherwise>
					AND MA.ATTENDANCE_TYPE  != 'E'
				</otherwise>
			</choose>
		   <if test="attendanceType eq 'A'.toString()">
		   AND MA.ATTENDANCE_TYPE  != 'B'
		   </if>
		   <if test="attendanceType eq 'B'.toString()">
		   AND MA.ATTENDANCE_TYPE  != 'A'
		   </if>
		   <if test="muAttendanceId != null and muAttendanceId != ''">
		   AND MU_ATTENDANCE_ID    != #{muAttendanceId}
		   </if>
		   AND MA.MU_MEMBER_ID      = #{muMemberId}
		   AND ((DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{startDate} AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d') &gt;= #{startDate})
			OR (DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{endDate} AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d') &gt;= #{endDate})
			OR (DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &gt; #{startDate} AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d') &lt; #{endDate}))
	</select>
	
	<select id="selectAttendanceCommute" parameterType="hashmap" resultType="hashmap">
		SELECT MA.MU_MEMBER_ID                                          AS "muMemberId"
			  ,IFNULL((SELECT MM.NAME
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.MU_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                                    AS "memberName"
			  ,IFNULL((SELECT MM.LOGIN_ID
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.MU_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                                    AS "loginId"
			  ,MAX(MU_ATTENDANCE_ID)                                    AS "muAttendanceId"
			  ,MAX(START_TIME)                                          AS "startTime"
			  ,MAX(ETC)                                                 AS "etc"
			  ,MAX(MU_ATTENDANCE_ID2)                                   AS "muAttendanceId2"
			  ,MAX(END_TIME)                                            AS "endTime"
			  ,MAX(ETC2)                                                AS "etc2"
		 FROM (
					SELECT MA.MU_MEMBER_ID                              AS MU_MEMBER_ID
						  ,MA.MU_ATTENDANCE_ID                          AS MU_ATTENDANCE_ID
						  ,DATE_FORMAT(MA.ATTENDANCE_TIME, '%H:%i')     AS START_TIME
						  ,MA.ETC                                       AS ETC
						  ,''                                           AS MU_ATTENDANCE_ID2 
						  ,NULL                                         AS END_TIME 
						  ,''                                           AS ETC2
					  FROM MU_ATTENDANCE AS MA
					 WHERE MA.USE_YN                = 'Y'
					   AND MA.STATUS               != 'D'
					   AND MA.ATTENDANCE_TYPE       = 'A'
					   AND MA.MU_ATTENDANCE_ID      = #{muAttendanceId}
					 UNION
					SELECT MA.MU_MEMBER_ID                              AS MU_MEMBER_ID
						  ,''                                           AS MU_ATTENDANCE_ID
						  ,NULL                                         AS START_TIME
						  ,''                                           AS ETC
						  ,MA.MU_ATTENDANCE_ID                          AS MU_ATTENDANCE_ID2
						  ,DATE_FORMAT(MA.ATTENDANCE_TIME, '%H:%i')     AS END_TIME
						  ,MA.ETC                                       AS ETC2
					  FROM MU_ATTENDANCE AS MA
					 WHERE MA.USE_YN                = 'Y'
					   AND MA.STATUS               != 'D'
					   AND MA.ATTENDANCE_TYPE       = 'B'
					   AND MA.MU_ATTENDANCE_ID      = #{muAttendanceId2}
			   ) AS MA
	  GROUP BY MU_MEMBER_ID
	</select>
	
	
	<select id="selectAttendanceVacation" parameterType="hashmap" resultType="hashmap">
		SELECT MU_ATTENDANCE_ID                                         AS "muAttendanceId"
			  ,MU_MEMBER_ID                                             AS "muMemberId"
			  ,IFNULL((SELECT MM.NAME
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.MU_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                                    AS "memberName"
			  ,IFNULL((SELECT MM.LOGIN_ID
						 FROM MU_MEMBER AS MM
						WHERE MM.USE_YN       = 'Y'
						  AND MM.MU_MEMBER_ID = MA.MU_MEMBER_ID
						LIMIT 0, 1
			   ),'')                                                    AS "loginId"
			  ,ATTENDANCE_TYPE                                          AS "attendanceType"
			  ,MU_VACATION_ID                                           AS "muVacationId"
			  ,MU_VACATION_MANAGEMENT_ID                                AS "muVacationManagementId"
			  ,DATE_FORMAT(START_DATE,'%Y-%m-%d')                       AS "startDate"
			  ,DATE_FORMAT(END_DATE,'%Y-%m-%d')                         AS "endDate"
			  ,STATUS													AS "status"
			  ,CASE
				   WHEN MA.ATTENDANCE_TYPE = 'E' THEN 0.5
				   ELSE ABS(DATEDIFF(START_DATE,END_DATE)) + 1
				END 													AS "days"
			  ,DATE_FORMAT(ATTENDANCE_TIME, '%H:%i')                    AS "attendanceTime"
			  ,DATE_FORMAT(START_TIME, '%H:%i')                         AS "startTime"
			  ,DATE_FORMAT(END_TIME, '%H:%i')                           AS "endTime"
			  ,ETC                                                      AS "etc"
			  ,CANCEL_ETC												AS "cancelEtc"
		  FROM MU_ATTENDANCE AS MA
		 WHERE MA.USE_YN                = 'Y'
		   AND MA.ATTENDANCE_TYPE       IN ('D', 'E')
		   AND MA.MU_ATTENDANCE_ID      = #{muAttendanceId}
	</select>
	
	<select id="selectListTodayAttendance" parameterType="hashmap" resultType="hashmap">
		SELECT MU_GROUP_ID                                  AS "muGroupId"
			  ,GROUP_NAME                                   AS "groupName"
			  ,MEMBER_NAME                                  AS "memberName"
		  FROM (
					SELECT MA.MU_GROUP_ID
						  ,IFNULL((SELECT MG.GROUP_NAME
									 FROM MU_GROUP AS MG
									WHERE MG.MU_GROUP_ID = MA.MU_GROUP_ID
									LIMIT 0, 1
						   ),'')                                        AS GROUP_NAME
						  ,GROUP_CONCAT(DISTINCT MM.NAME)               AS MEMBER_NAME
					  FROM MU_ATTENDANCE AS MA
				INNER JOIN MU_MEMBER AS MM
						ON MM.MU_MEMBER_ID = MA.MU_MEMBER_ID 
					   AND MA.USE_YN               = 'Y'
					   AND MM.USE_YN               = 'Y'
					   AND MA.STATUS              != 'D'
					   AND MA.ATTENDANCE_TYPE NOT IN ('C', 'D')
					   AND DATE_FORMAT(MA.START_DATE,'%Y-%m-%d') &lt;= #{searchDate}
					   AND DATE_FORMAT(MA.END_DATE,'%Y-%m-%d')      >= #{searchDate}
				  GROUP BY MA.MU_GROUP_ID
			   ) AS MA
		 WHERE 1=1
	  ORDER BY GROUP_NAME ASC
	</select>

	<insert id="insertAttendance" parameterType="hashmap">
		<selectKey resultType="string" keyProperty="id" order="BEFORE">
			SELECT CONCAT(#{muAttendanceId},LPAD((SELECT NEXTVAL(MU_ATTENDANCE_SEQ)), 11, 0))
		</selectKey>
		INSERT INTO MU_ATTENDANCE(
					 MU_ATTENDANCE_ID
					,MU_MEMBER_ID
					,MU_GROUP_ID
					,MU_DUTY_ID
					,MU_VACATION_ID
					,MU_VACATION_MANAGEMENT_ID
					,ATTENDANCE_TYPE
					,START_DATE
					,END_DATE
				 <if test="attendanceTime != null and attendanceTime != ''">
					,ATTENDANCE_TIME
				 </if>
				 <if test="startTime != null and startTime != ''">
					,START_TIME
				 </if>
				 <if test="endTime != null and endTime != ''">
					,END_TIME
				 </if>
					,ETC
					,STATUS
					,WRITE_MEMBER_ID
					,WRITE_DATE
					,WRITE_TIME
					,CUD_FLAG
					,USE_YN
					,REG_ID
					,REG_DATE
					,MOD_ID
					,MOD_DATE
					,T_ID
					,T_DATE
		)VALUES(
					 #{id}
					,#{muMemberId}
					,#{muGroupId}
					,#{muDutyId}
					,#{muVacationId, jdbcType=VARCHAR}
					,#{muVacationManagementId, jdbcType=VARCHAR}
					,#{attendanceType}
					,#{startDate}
					,#{endDate}
				 <if test="attendanceTime != null and attendanceTime != ''">
					,#{attendanceTime}
				 </if>
				 <if test="startTime != null and startTime != ''">
					,#{startTime}
				 </if>
				 <if test="endTime != null and endTime != ''">
					,#{endTime}
				 </if>
					,#{etc, jdbcType=VARCHAR}
					,'C'
					,#{regId}
					,CURDATE()
					,CURTIME()
					,'C'
					,'Y'
					,#{regId}
					,NOW()
					,#{modId}
					,NOW()
					,#{tId}
					,#{tDate}
		)
	</insert>
	
	<update id="updateAttendanceCommute" parameterType="hashmap">
		UPDATE MU_ATTENDANCE
		   SET MOD_ID                  = #{modId}
			  ,MOD_DATE                = NOW()
			  ,CUD_FLAG                = 'U'
			  ,STATUS                  = 'U'
			  ,ATTENDANCE_TIME         = #{attendanceTime}
			  ,ETC                     = #{etc, jdbcType=VARCHAR}
		 WHERE USE_YN            = 'Y'
		   AND MU_ATTENDANCE_ID  = #{muAttendanceId}
	</update>
	
	<update id="updateAttendanceVacation" parameterType="hashmap">
		UPDATE MU_ATTENDANCE
		   SET MOD_ID                      = #{modId}
			  ,MOD_DATE                    = NOW()
			  ,CUD_FLAG                    = 'U'
			  ,STATUS                      = 'U'
			  ,ATTENDANCE_TYPE             = #{attendanceType}
			  ,MU_VACATION_ID              = #{muVacationId}
			  ,MU_VACATION_MANAGEMENT_ID   = #{muVacationManagementId}
			  ,START_DATE                  = #{startDate}
			  ,END_DATE                    = #{endDate}
		   <if test="startTime != null and startTime != ''">
			  ,START_TIME                  = #{startTime}
		   </if>
		   <if test="endTime != null and endTime != ''">
			  ,END_TIME                    = #{endTime}
		   </if>
			  ,ETC                         = #{etc, jdbcType=VARCHAR}
		 WHERE USE_YN            = 'Y'
		   AND MU_ATTENDANCE_ID  = #{muAttendanceId}
	</update>
	
	<update id="updateAttendanceCancel" parameterType="hashmap">
		UPDATE MU_ATTENDANCE
		   SET MOD_ID                  = #{modId}
			  ,MOD_DATE                = NOW()
			  ,CUD_FLAG                = 'U'
			  ,STATUS                  = 'D'
			  ,CANCEL_MEMBER_ID        = #{modId}
			  ,CANCEL_DATE             = NOW()
			  ,CANCEL_ETC              = #{cancelEtc}
		 WHERE USE_YN            = 'Y'
		   AND MU_ATTENDANCE_ID  = #{muAttendanceId}
	</update>
	
	<update id="updateAttendanceCancelEtc" parameterType="hashmap">
		UPDATE MU_ATTENDANCE
		   SET MOD_ID        = #{modId}
			  ,MOD_DATE      = NOW()
			  ,CUD_FLAG      = 'U'
			  ,CANCEL_ETC    = #{cancelEtc}
		 WHERE USE_YN            = 'Y'
		   AND MU_ATTENDANCE_ID  = #{muAttendanceId}
	</update>
	
	<update id="deleteAttendance" parameterType="hashmap">
		UPDATE MU_ATTENDANCE
		   SET MOD_ID        = #{modId}
			  ,MOD_DATE	     = NOW()
			  ,CUD_FLAG      = 'D'
			  ,USE_YN        = 'N'
		 WHERE USE_YN            = 'Y'
		   AND MU_ATTENDANCE_ID  = #{muAttendanceId}
	</update>
</mapper>