<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="附加要求">
	<query id="CoreBaseAddAsk.QueryItem" desc="附加要求项目查询">
		<![CDATA[
		SELECT A.ASK_ITEM_NO,
               A.ASK_ITEM_DESC,
               A.STATION_CODE,
               A.STATION_DESC,
               A.PIC,
               A.ASK_P_ITEM_NO,
               TO_CHAR(A.CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
               A.UPDATE_NAME,
               TO_CHAR(A.UPDATE_TIME,'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
               A.DELETE_NAME,
               TO_CHAR(A.DELETE_TIME,'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
               DECODE(A.VALIDFLAG,'1','有效','无效') VALIDFLAG
          FROM SLM_BASE_ADD_ASK A 
         WHERE LENGTH(A.ASK_ITEM_NO)=6 AND VALIDFLAG IN ('1',?)
         ORDER BY A.ASK_ITEM_NO
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.QuerySub" desc="附加要求分项查询">
		<![CDATA[
		SELECT A.ASK_ITEM_NO,
               A.ASK_ITEM_DESC,
               A.STATION_CODE,
               A.STATION_DESC,
               A.PIC,
               A.ASK_P_ITEM_NO,
               TO_CHAR(A.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
               A.UPDATE_NAME,
               TO_CHAR(A.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
               A.DELETE_NAME,
               TO_CHAR(A.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
               DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
               DECODE(A.IS_ADD,'1','True','0','False') IS_ADD,
               DECODE(A.IS_ALLOW_EDIT, '1', 'True', 'False') IS_ALLOW_EDIT
               FROM SLM_BASE_ADD_ASK A
               WHERE LENGTH(A.ASK_ITEM_NO) = 8
           AND EXISTS (SELECT 1
          FROM SLM_BASE_ADD_ASK B
         WHERE B.ASK_ITEM_NO = A.ASK_P_ITEM_NO) AND VALIDFLAG IN ('1',?)
         ORDER BY A.ASK_ITEM_DESC
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.QueryStand" desc="附加要求标准查询">
		<![CDATA[
		SELECT A.ASK_ITEM_NO,
       A.ASK_ITEM_DESC,
       B.ASK_ITEM_DESC AS ASK_ITEM_NOTWO,
       C.ASK_ITEM_DESC AS ASK_ITEM_NOONE,
       A.STATION_CODE,
       A.STATION_DESC,
       A.PIC,
       A.ASK_P_ITEM_NO,
       TO_CHAR(A.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
       DECODE(A.STDFLAG, '1', 'True', 'False') STDFLAG
  FROM SLM_BASE_ADD_ASK A
  join SLM_BASE_ADD_ASK B
    oN A.ASK_P_ITEM_NO = B.ASK_ITEM_NO
  JOIN SLM_BASE_ADD_ASK C ON B.ASK_P_ITEM_NO = C.ASK_ITEM_NO
 WHERE A.ASK_P_ITEM_NO = ?
  ORDER BY A.ASK_ITEM_NO
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.add" desc="附加要求项目新增">
		<![CDATA[
		INSERT INTO SLM_BASE_ADD_ASK
                    (ASK_ITEM_NO,
                    ASK_ITEM_DESC,
                    STATION_CODE,
                    STATION_DESC,
                    PIC,
                    ASK_P_ITEM_NO,
                    VALIDFLAG,
                    CREATE_NAME,
                    CREATE_TIME,
                    UPDATE_NAME,
                    UPDATE_TIME,
                    DELETE_NAME,
                    DELETE_TIME,
                    STDFLAG,
                    IS_ADD,
                    IS_ALLOW_EDIT)
            VALUES
                   (?,
                    ?,
                    ?,
                    ?,
                    ?,
                    ?,
                    DEFAULT,
                    ?,
                    SYSDATE,
                    '',
                    NULL,
                    '',
                    NULL,
                    ?,
                    ?,
                    ?)
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.update" desc="附加要求修改">
		<![CDATA[
		UPDATE SLM_BASE_ADD_ASK
           SET ASK_ITEM_NO   = ?,
               ASK_ITEM_DESC = ?,
               STATION_CODE  = ?,
               STATION_DESC  = ?,
               PIC           = ?,
               ASK_P_ITEM_NO = ?,
               UPDATE_NAME   = ?,
               UPDATE_TIME   = SYSDATE,
               STDFLAG       = ?,
               IS_ADD        = ?,
               IS_ALLOW_EDIT = ?
         WHERE ASK_ITEM_NO = ?
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.getItemMax" desc="附加要求项目查询最大序号">
		<![CDATA[
		SELECT B.ASK_ITEM_NO
          FROM SLM_BASE_ADD_ASK B
         WHERE B.ASK_ITEM_NO = (SELECT MAX(A.ASK_ITEM_NO) ASKITEMNO
                                  FROM SLM_BASE_ADD_ASK A
                                 WHERE length(A.ASK_ITEM_NO) = 6)
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.getSubitemMax" desc="附加要求分项查询最大序号">
		<![CDATA[
		SELECT B.ASK_ITEM_NO
          FROM SLM_BASE_ADD_ASK B
         WHERE B.ASK_ITEM_NO = (SELECT MAX(A.ASK_ITEM_NO) ASKITEMNO
                                  FROM SLM_BASE_ADD_ASK A
                                 WHERE length(A.ASK_ITEM_NO) = 8 and A.ASK_P_ITEM_NO=?)
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.getStandMax" desc="附加要求标准查询最大序号">
		<![CDATA[
		SELECT B.ASK_ITEM_NO
          FROM SLM_BASE_ADD_ASK B
         WHERE B.ASK_ITEM_NO = (SELECT MAX(A.ASK_ITEM_NO) ASKITEMNO
                                  FROM SLM_BASE_ADD_ASK A
                                 WHERE length(A.ASK_ITEM_NO) = 16 and A.ASK_P_ITEM_NO=?)
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.checkAskItem" desc="检验是否重复">
		<![CDATA[
		SELECT 1 FROM SLM_BASE_ADD_ASK A WHERE A.ASK_ITEM_DESC = ?
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.checkAskItemD" desc="检验是否重复">
		<![CDATA[
		SELECT 1 FROM SLM_BASE_ADD_ASK A WHERE A.ASK_ITEM_DESC = ? and A.ASK_ITEM_code=?
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.delete" desc="作废">
		<![CDATA[
		UPDATE SLM_BASE_ADD_ASK
           SET DELETE_NAME = ?, VALIDFLAG = '0'
         WHERE ASK_ITEM_NO = ?
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.resume" desc="恢复">
		<![CDATA[
		UPDATE SLM_BASE_ADD_ASK
           SET DELETE_NAME = ?, VALIDFLAG = '1'
         WHERE ASK_ITEM_NO = ?
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.isLinkStd" desc="恢复">
		<![CDATA[
		 SELECT 1 FROM COM_BASE_ADDITIONAL 
		 WHERE ASK_SUB_ITME=?
			]]>
	</query>
	<query id="CoreBaseAddAsk.isLinkStd1" desc="恢复">
		<![CDATA[
		 SELECT 1 FROM COM_BASE_ADDITIONAL 
		 WHERE ASK_ITME=?
			]]>
	</query>
	<query id="CoreBaseAddAsk.isLinkStd2" desc="恢复">
		<![CDATA[
		 SELECT 1 FROM COM_BASE_ADDITIONAL 
		 WHERE ASK_SUB_ITME_VAL=?
			]]>
	</query>
	
	<query id="CoreBaseAddAsk.getSlmBaseAddaskByPk" desc="通过主键查询附加要求">
		<![CDATA[
SELECT T.* FROM SLM_BASE_ADD_ASK T WHERE T.ASK_ITEM_NO = '#ASK_ITEM_NO#'
			]]>
	</query>

	<query id="CoreBaseAddAsk.deleteData" desc="删除数据">
		<![CDATA[
DELETE FROM SLM_BASE_ADD_ASK T
 WHERE T.ASK_P_ITEM_NO = {0}
   AND T.VALIDFLAG = '0'
			]]>
	</query>
</queryMap>