<?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="utilMapper">

	<select id="selectSeqKpiMaster"  resultType="string">
		select RIGHT('00000000' +cast(NEXT VALUE FOR SEQ_KPI_MASTER as NVARCHAR),8)
	</select>

	<select id="selectUserDivision"  parameterType="java.util.HashMap" resultType="CamelHashMap">
		SELECT
			SEG_DIVISION,
			DEPARTMENTCODE
		FROM
			DBO.EMBO_EMP_ORGANIZATION AS EEO
		WHERE
			DEPARTMENTCODE = (
			SELECT
				DEPT_CODE
			FROM
				TN_CF_USER A
			WHERE
				A.USER_ID = #{userId})
	</select>

	<select id="selectDivision"  parameterType="java.util.HashMap" resultType="CamelHashMap">
		SELECT
			SEG_DIVISION as name,
			DEPARTMENTCODE as code
		FROM
			DBO.EMBO_EMP_ORGANIZATION
		ORDER BY SEG_DIVISION

	</select>

	<select id="selectGroupMember"  parameterType="java.util.HashMap" resultType="CamelHashMap">
		SELECT B.GROUP_ID,
		       B.USER_ID,
		       D.KNOX_ID,
		       C.GROUP_NAME
		FROM   DBO.EMBO_USER_GROUP       AS B
		       INNER JOIN DBO.EMBO_GROUP AS C ON C.GROUP_ID = B.GROUP_ID
		       INNER JOIN DBO.TN_CF_USER AS D ON D.USER_ID  = B.USER_ID
		WHERE  1=1
			<if test="@com.samsung.SdlComparator@isNotEmpty(userId)">
			AND
				B.GROUP_ID IN
		       ( SELECT GROUP_ID
		       FROM    DBO.EMBO_USER_GROUP AS A
		       WHERE   USER_ID = #{userId}
		       )
		    </if>
		    <if test="@com.samsung.SdlComparator@isNotEmpty(groupId)">
		    AND
				B.GROUP_ID = #{groupId}
		    </if>

	</select>
</mapper>