<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="标准向下试验标准">
	<query id="ComBaseStdRTestDAL.Query" desc="查询试验标准">
		<![CDATA[
SELECT
       T.STD_CODE_TEST,
       T.STD_NAME_TEST,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       T.LEVEL_TEST,
       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.PK
  FROM COM_BASE_STD_R_TEST T
 WHERE NVL2('#PHY_NAME_MIN#', T.PHY_NAME_MIN, '1') LIKE
       NVL2('#PHY_NAME_MIN#', '%#PHY_NAME_MIN#%', '1')
   AND T.VALIDFLAG IN ('1', '#VALIDFLAG#')
 ORDER BY T.LEVEL_TEST
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.Insert" desc="新增试验标准">
		<![CDATA[
INSERT INTO COM_BASE_STD_R_TEST
  (PK,
   STD_CODE_TEST,
   STD_NAME_TEST,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   LEVEL_TEST,
   CREATE_NAME,
   CREATE_TIME,
   MEMO)
VALUES
  ((SELECT LPAD(NVL(MAX(PK), 0) + 1, 5, 0) FROM COM_BASE_STD_R_TEST),
   '#STD_CODE_TEST#',
   '#STD_NAME_TEST#',
   '#PHY_CODE_MIN#',
   '#PHY_NAME_MIN#',
   '#LEVEL_TEST#',
   '#CREATE_NAME#',
   SYSDATE,
   '#MEMO#')
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.Update" desc="修改试验标准">
		<![CDATA[
UPDATE COM_BASE_STD_R_TEST T
   SET T.STD_CODE_TEST = '#STD_CODE_TEST#',
       T.STD_NAME_TEST = '#STD_NAME_TEST#',
       T.PHY_CODE_MIN  = '#PHY_CODE_MIN#',
       T.PHY_NAME_MIN  = '#PHY_NAME_MIN#',
       T.LEVEL_TEST    = '#LEVEL_TEST#',
       T.UPDATE_NAME   = '#UPDATE_NAME#',
       T.UPDATE_TIME   = SYSDATE,
       T.MEMO          = '#MEMO#'
 WHERE T.PK = '#PK#'
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.Delete" desc="作废试验标准">
		<![CDATA[
UPDATE COM_BASE_STD_R_TEST T
   SET T.VALIDFLAG   = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
 WHERE T.PK = '#PK#'
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.Resume" desc="恢复试验标准">
		<![CDATA[
UPDATE COM_BASE_STD_R_TEST T
   SET T.VALIDFLAG   = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
 WHERE T.PK = '#PK#'
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.GetMaxPk" desc="获取最大的主键">
		<![CDATA[
SELECT LPAD(NVL(MAX(T.PK), 00000) + 1, 5, '0') MAX_VALUE FROM COM_BASE_STD_R_TEST T
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.GetComBaseStdS" desc="获取试验标准基础数据">
		<![CDATA[
SELECT T.STD_CODE, T.STD_NAME FROM COM_BASE_STD T WHERE T.STDSTYLE = 'S'
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.GetComBasePhyC" desc="获取取样码基础信息">
		<![CDATA[
SELECT T.PHY_CODE, T.PHY_TYPE FROM COM_BASE_PHY_C T WHERE T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="ComBaseStdRTestDAL.GetRepateCnt" desc="获取取样码基础信息">
		<![CDATA[
SELECT COUNT(1) FROM COM_BASE_STD_R_TEST T WHERE 
T.STD_CODE_TEST = '#STD_CODE_TEST#'
AND T.PHY_CODE_MIN = '#PHY_CODE_MIN#'
AND T.PK <> '#PK#'
		]]>
	</query>
</queryMap>