<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="COM_BASE_INFO">
    <query id="ComBaseInfoDAL.Query" desc="查询">
        <![CDATA[
 SELECT T.BASECODE,
        T.BASENAME,
        T.SORTCODE,
        T.ISVISIBLE,
        T.MNEMONIC_CODE,
        T.SEQ,
        T.FLAG,
        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,
        DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
        T.MEMO,
        T.COEFFICIENT
   FROM COM_BASE_INFO T
  WHERE T.SORTCODE = '#SORTCODE#'
    AND T.BASENAME LIKE '%#BASENAME#%'
    AND T.VALIDFLAG IN ('1', '#VALIDFLAG#')
        ]]>
    </query>
    <query id="ComBaseInfoDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.BASECODE,
       T.BASENAME,
       T.SORTCODE,
       T.ISVISIBLE,
       T.MNEMONIC_CODE,
       T.SEQ,
       T.FLAG,
       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.VALIDFLAG,
       T.MEMO,
       T.COEFFICIENT
 FROM COM_BASE_INFO T
 WHERE
       T.BASECODE = '#BASECODE#'
        ]]>
    </query>
    <query id="ComBaseInfoDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO COM_BASE_INFO(
        BASECODE,
        BASENAME,
        SORTCODE,
        MNEMONIC_CODE,
        SEQ,
        FLAG,
        CREATE_NAME,
        CREATE_TIME,
        MEMO)
 VALUES( 
        '#BASECODE#',
        '#BASENAME#',
        '#SORTCODE#',
        '#MNEMONIC_CODE#',
        (SELECT NVL(MAX(SEQ), 0) + 1 FROM COM_BASE_INFO),
        '0',
        '#CREATE_NAME#',
        SYSDATE,
        '#MEMO#')
        ]]>
    </query>
    <query id="ComBaseInfoDAL.Update" desc="修改">
        <![CDATA[
 UPDATE COM_BASE_INFO T
   SET 
        T.BASECODE = '#BASECODE#',
        T.BASENAME = '#BASENAME#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.MEMO = '#MEMO#'
 WHERE
       T.BASECODE = '#BASECODE#'
        ]]>
    </query>
    <query id="ComBaseInfoDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT '#SORTCODE#' || LPAD(NVL(MAX(SUBSTR(BASECODE, 5, 2)), 0) + 1, 2, '0') MAX_VALUE
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = '#SORTCODE#'
        ]]>
    </query>
    <query id="ComBaseInfoDAL.Delete" desc="作废">
        <![CDATA[
UPDATE COM_BASE_INFO T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.BASECODE = '#BASECODE#'
        ]]>
    </query>
    <query id="ComBaseInfoDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE COM_BASE_INFO T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.BASECODE = '#BASECODE#'
        ]]>
    </query>
    <query id="ComBaseInfoDAL.QueryBaseNameCnt" desc="查询基础数据是否存在">
        <![CDATA[
SELECT COUNT(1) CNT
    FROM COM_BASE_INFO T
   WHERE T.SORTCODE = '#SORTCODE#'
     AND T.BASENAME = '#BASENAME#'
     AND T.BASECODE <> '#BASECODE#'
        ]]>
    </query>
</queryMap>