<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_ZBS_TEMPLATE_HEAD">
    <query id="QcmZbsTemplateHeadDAL.Query" desc="查询">
        <![CDATA[
 SELECT 
       T.TBH,
       T.DESCRIPTION,
       T.SHEET_COUNT,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.XLS
 FROM QCM_ZBS_TEMPLATE_HEAD T
 WHERE
       NVL2('#DESCRIPTION#', T.DESCRIPTION, '1') LIKE NVL2('#DESCRIPTION#', '%#DESCRIPTION#%', '1')
       AND T.VALIDFLAG IN ('1', '#VALIDFLAG#')
        ]]>
    </query>
    <query id="QcmZbsTemplateHeadDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.TBH,
       T.DESCRIPTION,
       T.SHEET_COUNT,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.XLS
 FROM QCM_ZBS_TEMPLATE_HEAD T
 WHERE
       T.TBH = '#TBH#'
        ]]>
    </query>
    <query id="QcmZbsTemplateHeadDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO QCM_ZBS_TEMPLATE_HEAD(
        TBH,
        DESCRIPTION,
        SHEET_COUNT,
        CREATE_NAME,
        CREATE_TIME,
        XLS)
 VALUES( 
        '#TBH#',
        '#DESCRIPTION#',
        '#SHEET_COUNT#',
        '#CREATE_NAME#',
        SYSDATE,
        '#XLS#')
        ]]>
    </query>
    <query id="QcmZbsTemplateHeadDAL.Update" desc="修改">
        <![CDATA[
 UPDATE QCM_ZBS_TEMPLATE_HEAD T
   SET 
        T.DESCRIPTION = '#DESCRIPTION#',
        T.SHEET_COUNT = '#SHEET_COUNT#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE
 WHERE
       T.TBH = '#TBH#'
        ]]>
    </query>
    <query id="QcmZbsTemplateHeadDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT LPAD(NVL(MAX(T.TBH), 0) + 1, 4, '0') MAX_VALUE FROM QCM_ZBS_TEMPLATE_HEAD T
        ]]>
    </query>
    <query id="QcmZbsTemplateHeadDAL.Delete" desc="作废">
        <![CDATA[
UPDATE QCM_ZBS_TEMPLATE_HEAD T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.TBH = '#TBH#'
        ]]>
    </query>
    <query id="QcmZbsTemplateHeadDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE QCM_ZBS_TEMPLATE_HEAD T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.TBH = '#TBH#'
        ]]>
    </query>
    <query id="QcmZbsTemplateHeadDAL.UpdateXls" desc="修改">
        <![CDATA[
 UPDATE QCM_ZBS_TEMPLATE_HEAD T
   SET 
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.XLS = '#XLS#'
 WHERE
       T.TBH = '#TBH#'
        ]]>
    </query>
</queryMap>