<?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="com.style24.scm.biz.dao.TssCommonDao">

	<!-- 엑셀조회를 위한 SEARCH 테이블 삭제  -->
	<delete id="deleteExceluploadSearCh" parameterType="SearchData">
		/* TssCommon.deleteExceluploadSearCh */
		DELETE 
		FROM   TB_SEARCH_DATA
		WHERE  REG_NO = #{regNo}
	</delete>

	<!-- 엑셀조회를 위한 SEARCH 테이블  생성 -->
	<insert id="createExceluploadSearch" parameterType="SearchData">
		/* TssCommon.createExceluploadSearch */
		INSERT INTO TB_SEARCH_DATA (
		        REG_NO
		      , SEARCH_CD
		      , DISP_ORD
		 )
		 SELECT #{regNo}
		      , #{searchCd}
		      , (SELECT COUNT(*) + 100
		         FROM   TB_SEARCH_DATA
		         WHERE  REG_NO = #{regNo})
		 FROM   DUAL
		 WHERE  (SELECT COUNT(*) FROM TB_SEARCH_DATA WHERE SEARCH_CD = #{searchCd} AND REG_NO = #{regNo}) = 0
	</insert>
	
	<!-- 엑셀조회를 위한 SEARCH 테이블  생성 - dummy 컬럼 포함 -->
	<insert id="createExceluploadSearchByAll" parameterType="SearchData">
		/* TssCommon.createExceluploadSearchByAll */
		INSERT INTO TB_SEARCH_DATA (
		        REG_NO
		      , SEARCH_CD
		      , DISP_ORD
		      , DUMMY1
		      , DUMMY2
		      , DUMMY3
		 )
		 SELECT #{regNo}
		      , #{searchCd}
		      , (SELECT COUNT(*) + 100
		         FROM   TB_SEARCH_DATA
		         WHERE  REG_NO = #{regNo})
		      , #{dummy1}
		      , #{dummy2}
		      , #{dummy3}
		 FROM   DUAL
		 WHERE  (SELECT COUNT(*) FROM TB_SEARCH_DATA
		         WHERE SEARCH_CD = #{searchCd}
		         AND DUMMY1 = #{dummy1}
		         AND DUMMY2 = #{dummy2}
		         AND DUMMY3 = #{dummy3}
		         AND REG_NO = #{regNo}) = 0
	</insert>
	
	<!-- 샘플파일 시스템파일명 조회 -->
	<select id="getSampleFileSystemFilename" parameterType="String" resultType="String">
		/* TssCommon.getSampleFileSystemFilename */
		SELECT SYS_FILE_NM
		FROM   TB_SAMPLE_FILE
		WHERE  SAMPLE_FILE_ID = #{sampleFileId}
	</select>
	
	<!-- WMS 연동 여부 -->
	<select id="getWmsSyncYn" resultType="String">
		/* TsaSystem.getWmsSyncYn */
		SELECT UPPER(IFNULL(USE_YN,'N')) AS WMS_SYNC_YN
		FROM TB_COMMON_CODE
		WHERE CD_GB = 'G077'
		AND CD = 'WMSSYNCYN'
	</select>
	
</mapper>