<?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="cokr.xit.fims.cmmn.dao.OutsourcingStngMapper">

<select id="selectArtclStngList" parameterType="cokr.xit.fims.cmmn.OutsourcingStngQuery" resultType="dataobject">
/* 외주파일 항목 설정 조회(outsourcingStngMapper.selectArtclStngList) */
SELECT OUTSOURCING_FORM_ID
     , SGG_CD
     , TASK_SE_CD
     , SNDNG_SE_CD
     , ARTCL_NM
     , ARTCL_SZ
     , ARTCL_ORDR
     , PADDING_DIRECTION
     , FORMATTING
  FROM TB_OUTSOURCING_FORM_STNG
 WHERE USE_YN = 'Y'
   AND SGG_CD = #{sggCd}
   AND TASK_SE_CD = #{taskSeCd}
   AND SNDNG_SE_CD = #{sndngSeCd}
 ORDER BY ARTCL_ORDR
</select>

<insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.OutsourcingArtclStng">
/* 외주요청파일서식 설정 등록(outsourcingStngMapper.insertArtclStng) */
<selectKey resultType="string" keyProperty="outsourcingFormId" keyColumn="NEW_ID" order="BEFORE">
	<include refid="numbering.key">
		<property name="TABLE_NAME" value="TB_OUTSOURCING_FORM_STNG" />
		<property name="TABLE_KEY" value="OUTSOURCING_FORM_ID" />
		<property name="pad" value="10" />
	</include>
</selectKey>
INSERT
  INTO TB_OUTSOURCING_FORM_STNG (
       OUTSOURCING_FORM_ID
     , SGG_CD
     , TASK_SE_CD
     , SNDNG_SE_CD
     , ARTCL_ORDR
     , ARTCL_NM
     , ARTCL_SZ
     , PADDING_DIRECTION
     , FORMATTING
     , USE_YN
     , REG_DT
     , RGTR
  ) VALUES (
       #{outsourcingFormId}
     , #{sggCd}
     , #{taskSeCd}
     , #{sndngSeCd}
     , #{artclOrdr}
     , #{artclNm}
     , #{artclSz}
     , #{paddingDirection}
     , #{formatting}
     , 'Y'
     , <include refid="utility.now" />
     , #{createdBy}
  )
</insert>

<update id="updateArtclStng" parameterType="cokr.xit.fims.cmmn.OutsourcingArtclStng">
/* 외주요청파일서식 설정 수정(outsourcingStngMapper.updateArtclStng) */
UPDATE TB_OUTSOURCING_FORM_STNG
   SET ARTCL_ORDR        = #{artclOrdr}
     , ARTCL_NM          = #{artclNm}
     , ARTCL_SZ          = #{artclSz}
     , PADDING_DIRECTION = #{paddingDirection}
     , FORMATTING        = #{formatting} 
     , MDFCN_DT        = <include refid="utility.now" />
     , MDFR            = #{modifiedBy}
 WHERE OUTSOURCING_FORM_ID = #{outsourcingFormId}
   AND USE_YN = 'Y'
</update>

<update id="deleteArtclStng" parameterType="cokr.xit.fims.cmmn.OutsourcingForm">
/* 외주요청파일서식 설정 삭제(outsourcingStngMapper.deleteArtclStng) */
UPDATE TB_OUTSOURCING_FORM_STNG
   SET USE_YN   = 'N'
     , MDFCN_DT = <include refid="utility.now" />
     , MDFR     = #{modifiedBy}
 WHERE SGG_CD      = #{sggCd}
   AND TASK_SE_CD  = #{taskSeCd}
   AND SNDNG_SE_CD = #{sndngSeCd}
   AND USE_YN = 'Y'
<if test='outsourcingFormIDs != null'>
   AND OUTSOURCING_FORM_ID NOT IN (<foreach collection="outsourcingFormIDs" item="OUTSOURCING_FORM_ID" separator=",">#{OUTSOURCING_FORM_ID}</foreach>)
</if>
</update>

</mapper>