마이바티스 채번 처리 SQL 추가

main
이범준 6 months ago
parent 47b9957ed6
commit 61d383af4c

@ -20,13 +20,17 @@ SELECT FOUND_ROWS() TOT_CNT</select>
<sql id="orderBy"><if test="fetchSize == null or fetchSize &lt; 1"><include refid="utility.sortBy" /></if></sql> <sql id="orderBy"><if test="fetchSize == null or fetchSize &lt; 1"><include refid="utility.sortBy" /></if></sql>
<sql id="now"><if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_TIMESTAMP, '%Y%m%d%H%i%s')</if> <sql id="now">
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISS')</if></sql> <if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_TIMESTAMP, '%Y%m%d%H%i%s')</if>
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISS')</if>
</sql>
<sql id="selectNow">SELECT<include refid="utility.now" />NOW FROM DUAL</sql> <sql id="selectNow">SELECT<include refid="utility.now" />NOW FROM DUAL</sql>
<sql id="today"><if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_DATE, '%Y%m%d')</if> <sql id="today">
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_DATE, 'YYYYMMDD')</if></sql> <if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_DATE, '%Y%m%d')</if>
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_DATE, 'YYYYMMDD')</if>
</sql>
<sql id="selectToday">SELECT<include refid="utility.today" />TODAY FROM DUAL</sql> <sql id="selectToday">SELECT<include refid="utility.today" />TODAY FROM DUAL</sql>
@ -34,4 +38,9 @@ SELECT FOUND_ROWS() TOT_CNT</select>
<sql id="selectThisDay">SELECT<include refid="utility.thisDay" />THIS_DAY FROM DUAL</sql> <sql id="selectThisDay">SELECT<include refid="utility.thisDay" />THIS_DAY FROM DUAL</sql>
<sql id="currentYear">
<if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_DATE, '%Y')</if>
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_DATE, 'YYYY')</if>
</sql>
</mapper> </mapper>

@ -18,10 +18,11 @@ SELECT EXTR_BSC_ID
<insert id="insertBscStng" parameterType="cokr.xit.fims.cmmn.ExtrForm"> <insert id="insertBscStng" parameterType="cokr.xit.fims.cmmn.ExtrForm">
/* PDF 자료 추출 템플릿 문구 설정 등록(extrStngMapper.insertBscStng) */ /* PDF 자료 추출 템플릿 문구 설정 등록(extrStngMapper.insertBscStng) */
<selectKey resultType="string" keyProperty="extrBscId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="extrBscId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(EXTR_BSC_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_EXTR_BSC_STNG" />
AS NEW_ID <property name="TABLE_KEY" value="EXTR_BSC_ID" />
FROM TB_EXTR_BSC_STNG <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_EXTR_BSC_STNG ( INTO TB_EXTR_BSC_STNG (
@ -69,10 +70,11 @@ SELECT EXTR_FORM_ID
<insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.ExtrArtclStng"> <insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.ExtrArtclStng">
/* 추출 설정 등록(extrStngMapper.insertArtclStng) */ /* 추출 설정 등록(extrStngMapper.insertArtclStng) */
<selectKey resultType="string" keyProperty="extrFormId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="extrFormId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(EXTR_FORM_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_EXTR_FORM_STNG" />
AS NEW_ID <property name="TABLE_KEY" value="EXTR_FORM_ID" />
FROM TB_EXTR_FORM_STNG <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_EXTR_FORM_STNG ( INTO TB_EXTR_FORM_STNG (

@ -5,11 +5,11 @@
<insert id="insertElectronicNoticeSndngMaster" parameterType="map"> <insert id="insertElectronicNoticeSndngMaster" parameterType="map">
/* 전자고지 발송 마스터 정보 등록(linkMapper.insertElectronicNoticeSndngMaster) */ /* 전자고지 발송 마스터 정보 등록(linkMapper.insertElectronicNoticeSndngMaster) */
<selectKey resultType="string" keyProperty="unitySndngMastrId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="unitySndngMastrId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.keyByYear">
CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), LPAD(CAST(IFNULL(MAX(SUBSTRING(UNITY_SNDNG_MASTR_ID,5)) + 1, 1) AS INT), 16, '0')) <property name="TABLE_NAME" value="TB_CNTC_SNDNG_MASTR" />
AS NEW_ID <property name="TABLE_KEY" value="UNITY_SNDNG_MASTR_ID" />
FROM TB_CNTC_SNDNG_MASTR <property name="pad" value="20" />
WHERE UNITY_SNDNG_MASTR_ID LIKE CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), '%') </include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_CNTC_SNDNG_MASTR ( INTO TB_CNTC_SNDNG_MASTR (
@ -50,11 +50,11 @@ INSERT
<insert id="insertElectronicNoticeSndngDetail" parameterType="map"> <insert id="insertElectronicNoticeSndngDetail" parameterType="map">
/* 전자고지 발송 디테일 정보 등록(linkMapper.insertElectronicNoticeSndngDetail) */ /* 전자고지 발송 디테일 정보 등록(linkMapper.insertElectronicNoticeSndngDetail) */
<selectKey resultType="string" keyProperty="unitySndngDetailId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="unitySndngDetailId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.keyByYear">
CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), LPAD(CAST(IFNULL(MAX(SUBSTRING(UNITY_SNDNG_DETAIL_ID,5)) + 1, 1) AS INT), 16, '0')) <property name="TABLE_NAME" value="TB_CNTC_SNDNG_DETAIL" />
AS NEW_ID <property name="TABLE_KEY" value="UNITY_SNDNG_DETAIL_ID" />
FROM TB_CNTC_SNDNG_DETAIL <property name="pad" value="20" />
WHERE UNITY_SNDNG_DETAIL_ID LIKE CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), '%') </include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_CNTC_SNDNG_DETAIL ( INTO TB_CNTC_SNDNG_DETAIL (

@ -24,10 +24,11 @@ SELECT OTPT_BSC_ID
<insert id="insertBscStng" parameterType="cokr.xit.fims.cmmn.OtptForm"> <insert id="insertBscStng" parameterType="cokr.xit.fims.cmmn.OtptForm">
/* 출력 기본 설정 등록(otptStngMapper.insertBscStng) */ /* 출력 기본 설정 등록(otptStngMapper.insertBscStng) */
<selectKey resultType="string" keyProperty="otptBscId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="otptBscId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(OTPT_BSC_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_OTPT_BSC_STNG" />
AS NEW_ID <property name="TABLE_KEY" value="OTPT_BSC_ID" />
FROM TB_OTPT_BSC_STNG <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_OTPT_BSC_STNG ( INTO TB_OTPT_BSC_STNG (
@ -109,10 +110,11 @@ SELECT OTPT_FORM_ID
<insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.OtptArtclStng"> <insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.OtptArtclStng">
/* 출력 설정 등록(otptStngMapper.insertArtclStng) */ /* 출력 설정 등록(otptStngMapper.insertArtclStng) */
<selectKey resultType="string" keyProperty="otptFormId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="otptFormId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(OTPT_FORM_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_OTPT_FORM_STNG" />
AS NEW_ID <property name="TABLE_KEY" value="OTPT_FORM_ID" />
FROM TB_OTPT_FORM_STNG <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_OTPT_FORM_STNG ( INTO TB_OTPT_FORM_STNG (

@ -24,10 +24,11 @@ SELECT OUTSOURCING_FORM_ID
<insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.OutsourcingArtclStng"> <insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.OutsourcingArtclStng">
/* 외주요청파일서식 설정 등록(outsourcingStngMapper.insertArtclStng) */ /* 외주요청파일서식 설정 등록(outsourcingStngMapper.insertArtclStng) */
<selectKey resultType="string" keyProperty="outsourcingFormId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="outsourcingFormId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(OUTSOURCING_FORM_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_OUTSOURCING_FORM_STNG" />
AS NEW_ID <property name="TABLE_KEY" value="OUTSOURCING_FORM_ID" />
FROM TB_OUTSOURCING_FORM_STNG <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_OUTSOURCING_FORM_STNG ( INTO TB_OUTSOURCING_FORM_STNG (

@ -88,10 +88,11 @@ UPDATE TB_DEPT
<insert id="insertDefaultTask" parameterType="map"> <insert id="insertDefaultTask" parameterType="map">
/* 사용자 기본 업무 등록 (stngMapper.insertDefaultTask) */ /* 사용자 기본 업무 등록 (stngMapper.insertDefaultTask) */
<selectKey resultType="string" keyProperty="taskMtchgId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="taskMtchgId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(TASK_MTCHG_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_TASK_MTCHG" />
AS NEW_ID <property name="TABLE_KEY" value="TASK_MTCHG_ID" />
FROM TB_TASK_MTCHG <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_TASK_MTCHG ( INTO TB_TASK_MTCHG (

@ -5,11 +5,11 @@
<insert id="insertCrdn" parameterType="cokr.xit.fims.crdn.Crdn"> <insert id="insertCrdn" parameterType="cokr.xit.fims.crdn.Crdn">
/* 단속 대장 등록(crdnInstMapper.insertCrdn) */ /* 단속 대장 등록(crdnInstMapper.insertCrdn) */
<selectKey resultType="string" keyProperty="crdnId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="crdnId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.keyByYear">
CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), LPAD(CAST(IFNULL(MAX(SUBSTRING(CRDN_ID,5)) + 1, 1) AS INT), 16, '0')) <property name="TABLE_NAME" value="TB_CRDN" />
AS NEW_ID <property name="TABLE_KEY" value="CRDN_ID" />
FROM TB_CRDN <property name="pad" value="20" />
WHERE CRDN_ID LIKE CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), '%') </include>
</selectKey> </selectKey>
INSERT INTO TB_CRDN ( INSERT INTO TB_CRDN (
CRDN_ID <!-- 단속 ID --> CRDN_ID <!-- 단속 ID -->

@ -111,10 +111,11 @@ SELECT A.FILE_LAYOUT_ID
<insert id="insertCrdnFileLayout" parameterType="map"> <insert id="insertCrdnFileLayout" parameterType="map">
/* 연계파일 레이아웃 등록(crdnStngMapper.insertCrdnFileLayout) */ /* 연계파일 레이아웃 등록(crdnStngMapper.insertCrdnFileLayout) */
<selectKey resultType="string" keyProperty="layoutDescriptor.fileLayoutId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="layoutDescriptor.fileLayoutId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(FILE_LAYOUT_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_CRDN_FILE_LAYOUT" />
AS NEW_ID <property name="TABLE_KEY" value="FILE_LAYOUT_ID" />
FROM TB_CRDN_FILE_LAYOUT <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_CRDN_FILE_LAYOUT ( INTO TB_CRDN_FILE_LAYOUT (

@ -52,10 +52,11 @@ UPDATE TB_TEAM
<insert id="insertTeamInfo" parameterType="cokr.xit.fims.crdn.Team"> <insert id="insertTeamInfo" parameterType="cokr.xit.fims.crdn.Team">
/* 단속팀 정보 등록(crdnTeamMapper.insertTeamInfo) */ /* 단속팀 정보 등록(crdnTeamMapper.insertTeamInfo) */
<selectKey resultType="string" keyProperty="teamId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="teamId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(TEAM_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_TEAM" />
AS NEW_ID <property name="TABLE_KEY" value="TEAM_ID" />
FROM TB_TEAM <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_TEAM ( INTO TB_TEAM (

@ -53,10 +53,11 @@ SELECT A.EXMPTN_VHCL_ID
<insert id="insertExemptionVehicleInfo" parameterType="cokr.xit.fims.crdn.ExmptnVhcl"> <insert id="insertExemptionVehicleInfo" parameterType="cokr.xit.fims.crdn.ExmptnVhcl">
/* 면제차량 정보 등록(exmptnVhclMapper.insertExemptionVehicleInfo) */ /* 면제차량 정보 등록(exmptnVhclMapper.insertExemptionVehicleInfo) */
<selectKey resultType="string" keyProperty="exmptnVhclId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="exmptnVhclId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(EXMPTN_VHCL_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_EXMPTN_VHCL" />
AS NEW_ID <property name="TABLE_KEY" value="EXMPTN_VHCL_ID" />
FROM TB_EXMPTN_VHCL <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INTO TB_EXMPTN_VHCL ( INSERT INTO TB_EXMPTN_VHCL (
EXMPTN_VHCL_ID <!-- 면제 차량 ID --> EXMPTN_VHCL_ID <!-- 면제 차량 ID -->

@ -160,10 +160,11 @@ UPDATE TB_CVLCPT_BSC_WORDS
<insert id="insertAnswerBodyWordsInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt"> <insert id="insertAnswerBodyWordsInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt">
/* 본문 문구 설정 등록(answerWordsMapper.insertAnswerBodyWordsInfo) */ /* 본문 문구 설정 등록(answerWordsMapper.insertAnswerBodyWordsInfo) */
<selectKey resultType="string" keyProperty="ansWordsId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="ansWordsId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(ANS_WORDS_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_CVLCPT_ANS_WORDS" />
AS NEW_ID <property name="TABLE_KEY" value="ANS_WORDS_ID" />
FROM TB_CVLCPT_ANS_WORDS <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_CVLCPT_ANS_WORDS( INTO TB_CVLCPT_ANS_WORDS(

@ -649,11 +649,11 @@ SELECT CC.CVLCPT_LINK_ID /* 민원 연계 ID */
<insert id="insertCrdnFromSelect" parameterType="map"> <insert id="insertCrdnFromSelect" parameterType="map">
/* 단속정보 복사(crdnCvlcptMapper.insertCrdnFromSelect) */ /* 단속정보 복사(crdnCvlcptMapper.insertCrdnFromSelect) */
<selectKey resultType="string" keyProperty="newCrdnId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="newCrdnId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.keyByYear">
CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), LPAD(CAST(IFNULL(MAX(SUBSTRING(CRDN_ID,5)) + 1, 1) AS INT), 16, '0')) <property name="TABLE_NAME" value="TB_CRDN" />
AS NEW_ID <property name="TABLE_KEY" value="CRDN_ID" />
FROM TB_CRDN <property name="pad" value="20" />
WHERE CRDN_ID LIKE CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), '%') </include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_CRDN ( INTO TB_CRDN (

@ -31,11 +31,11 @@ SELECT SA.INDIV_ID <!-- 개별 ID -->
<insert id="insertDmndDataInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt"> <insert id="insertDmndDataInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt">
<selectKey resultType="string" keyProperty="indivId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="indivId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.keyByYear">
CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), LPAD(CAST(IFNULL(MAX(SUBSTRING(INDIV_ID, 5)) + 1, 1) AS INT), 26, '0')) <property name="TABLE_NAME" value="TB_SA_CVLCPT_INDIV_DMND" />
AS NEW_ID <property name="TABLE_KEY" value="INDIV_ID" />
FROM TB_SA_CVLCPT_INDIV_DMND <property name="pad" value="30" />
WHERE INDIV_ID LIKE CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), '%') </include>
</selectKey> </selectKey>
/* 새올요청자료 등록(saCvlcptIndviDmndMapper.insertDmndDataInfo) */ /* 새올요청자료 등록(saCvlcptIndviDmndMapper.insertDmndDataInfo) */
INSERT INSERT

@ -25,10 +25,11 @@ SELECT A.CODE AS LEVY_EXCL_RSN_CD
<insert id="insertWarningWordsInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt"> <insert id="insertWarningWordsInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt">
/* 계도문 문구 설정 등록(warningWordsMapper.insertWarningWordsInfo) */ /* 계도문 문구 설정 등록(warningWordsMapper.insertWarningWordsInfo) */
<selectKey resultType="string" keyProperty="ansWordsId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="ansWordsId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(ANS_WORDS_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_CVLCPT_ANS_WORDS" />
AS NEW_ID <property name="TABLE_KEY" value="ANS_WORDS_ID" />
FROM TB_CVLCPT_ANS_WORDS <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_CVLCPT_ANS_WORDS( INTO TB_CVLCPT_ANS_WORDS(

@ -67,10 +67,11 @@ WHERE A.DEL_YN = 'N'
<insert id="insertNtc" parameterType="map"> <insert id="insertNtc" parameterType="map">
/* 공지사항 등록(ntcMapper.insertNtc) */ /* 공지사항 등록(ntcMapper.insertNtc) */
<selectKey resultType="string" keyProperty="ntc.ntcId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="ntc.ntcId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(NTC_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_NOTICE" />
AS NEW_ID <property name="TABLE_KEY" value="NTC_ID" />
FROM TB_NOTICE <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_NOTICE ( INTO TB_NOTICE (

@ -58,10 +58,11 @@ WHERE DEL_YN = 'N'
<insert id="insertSchdl" parameterType="map"> <insert id="insertSchdl" parameterType="map">
/* 일정관리 등록(schdlMapper.insertSchdl) */ /* 일정관리 등록(schdlMapper.insertSchdl) */
<selectKey resultType="string" keyProperty="schdl.schdlId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="schdl.schdlId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(SCHDL_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_SCHDL" />
AS NEW_ID <property name="TABLE_KEY" value="SCHDL_ID" />
FROM TB_SCHDL <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_SCHDL ( INTO TB_SCHDL (

@ -102,10 +102,11 @@
<insert id="insertVltn" parameterType="map"> <insert id="insertVltn" parameterType="map">
/* 위반 정보 등록(vltnMapper.insertVltn) */ /* 위반 정보 등록(vltnMapper.insertVltn) */
<selectKey resultType="string" keyProperty="vltnId" keyColumn="NEW_ID" order="BEFORE"> <selectKey resultType="string" keyProperty="vltnId" keyColumn="NEW_ID" order="BEFORE">
SELECT <include refid="numbering.key">
LPAD(CAST(IFNULL(MAX(VLTN_ID) + 1, 1) AS INT), 10, '0') <property name="TABLE_NAME" value="TB_VLTN" />
AS NEW_ID <property name="TABLE_KEY" value="VLTN_ID" />
FROM TB_VLTN <property name="pad" value="10" />
</include>
</selectKey> </selectKey>
INSERT INSERT
INTO TB_VLTN ( INTO TB_VLTN (

@ -0,0 +1,33 @@
<?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="numbering">
<sql id="key">
SELECT
LPAD(CAST(IFNULL(MAX(${TABLE_KEY}) + 1, 1) AS INT), ${pad}, '0')
AS NEW_ID
FROM ${TABLE_NAME}
</sql>
<sql id="keyByYear">
SELECT
CONCAT(
<include refid="utility.currentYear" />
, LPAD(CAST(IFNULL(MAX(SUBSTRING(${TABLE_KEY}, 4+1)) + 1, 1) AS INT), ${pad}-4, '0')
) AS NEW_ID
FROM ${TABLE_NAME}
WHERE ${TABLE_KEY} LIKE CONCAT(<include refid="utility.currentYear" />, '%')
</sql>
<sql id="keyBySggAndYear">
SELECT
CONCAT(
#{sggCd}
, <include refid="utility.currentYear" />
, LPAD(CAST(IFNULL(MAX(SUBSTRING(${TABLE_KEY}, 9+1)) + 1, 1) AS INT), ${pad}-9, '0')
) AS NEW_ID
FROM ${TABLE_NAME}
WHERE ${TABLE_KEY} LIKE CONCAT(#{sggCd}, <include refid="utility.currentYear" />, '%')
</sql>
</mapper>
Loading…
Cancel
Save