<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	<query id="CoreChemistryElements.GetMaxCode" desc="获取代码最大值">
		<![CDATA[
			select max(CHEM_CODE) from COM_BASE_CHEM
		]]>
	</query>
	
	<query id="CoreChemistryElements.GetName" desc="判断描述是否存在">
		<![CDATA[
			select CHEM_NAME from COM_BASE_CHEM where CHEM_NAME=?
		]]>
	</query>
	
	<query id="CoreChemistryElements.QUERY" desc="权限功能">
		<![CDATA[
SELECT CHEM_CODE,
       CHEM_NAME,
       CHEM_TYPE,
       DECODE(CHEM_TYPE, 'A', '单一元素', '复合元素') CHEMTYPENAME,
       CHEM_FORMULA,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       VALIDFLAG,
       DECODE(VALIDFLAG, '1', '有效', '无效') VALIDFLAGNAME,
       ROUNDING_DIGITS,
       MEMO,
       CHEM_SEQ
  FROM COM_BASE_CHEM
 WHERE VALIDFLAG IN ('1', ?)
   AND LOWER(CHEM_NAME) || '&' LIKE '%' || LOWER(?) || '%'
 ORDER BY CHEM_CODE
		]]>
	</query>
	<query id="CoreChemistryElements.ADD" desc="新增">
		<![CDATA[
			 INSERT INTO COM_BASE_CHEM
							(CHEM_CODE,
					        CHEM_NAME,
					        CHEM_TYPE,
							CHEM_FORMULA,
					        CREATE_NAME,
					        CREATE_TIME,
					        VALIDFLAG,
					        MEMO,
					        ROUNDING_DIGITS,
					        CHEM_SEQ)
							VALUES(?,?,?,?,
							?,SYSDATE,
							'1',?, ?, ?)
								  
		]]>
	</query>
	<query id="CoreChemistryElements.MODIFY" desc="修改">
		<![CDATA[
			 UPDATE COM_BASE_CHEM set
							CHEM_NAME=?, 
							CHEM_TYPE=?, 
							CHEM_FORMULA=?, 
							UPDATE_NAME=?, 
							UPDATE_TIME=TO_DATE(?, 'yyyy-mm-dd hh24:mi:ss'),
							MEMO=?,
							ROUNDING_DIGITS = ?,
							CHEM_SEQ = ?
							WHERE CHEM_CODE=?
		]]>
	</query>
	<query id="CoreChemistryElements.DELETE" desc="作废">
		<![CDATA[
			 UPDATE COM_BASE_CHEM T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.CHEM_CODE = ?
		]]>
	</query>
	
	<query id="CoreChemistryElements.RESUME" desc="恢复">
		<![CDATA[
			UPDATE COM_BASE_CHEM T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.CHEM_CODE = ?
		]]>
	</query>
	
	<query id="CoreChemistryElements.Gs" desc="判定复合公式">
		<![CDATA[
			 SELECT T.TABLE_NAME, C.COLUMN_NAME
			  FROM USER_TAB_COMMENTS T, USER_COL_COMMENTS C
			 WHERE T.TABLE_NAME = C.TABLE_NAME
			   AND T.TABLE_NAME = 'V_STL_CHEMELEMENT'
		]]>
	</query>
	
	<query id="CoreChemistryElements.isComplex" desc="是否复合公式">
		<![CDATA[
			 SELECT SUM(CNT)
			  FROM (SELECT COUNT(1) CNT
			          FROM USER_TAB_COMMENTS T, USER_COL_COMMENTS C
			         WHERE T.TABLE_NAME = C.TABLE_NAME
			           AND T.TABLE_NAME = 'STL_CHEMELEMENT'
			           AND C.COLUMN_NAME IN (#ELEMENTS#)
			        UNION ALL
			        SELECT COUNT(1) CNT
			          FROM COM_BASE_INFO
			         WHERE SORTCODE = '4073'
			           AND BASENAME IN (#ELEMENTS#))

		]]>
	</query>
	
	<query id="FreeTest.ADD" desc="新增">
		<![CDATA[
			 INSERT INTO COM_BASE_LIMS_FREE_TEST
							(SUPP_NAME,
					        DIMATER,
					        HEIGHT,
							DELVRY_STATE,
					        STD_NAME,
					        GRADE,
					        FINAL_STOVE_NUM,
					        CREATE_NAME,
					        CREATE_TIME,
					        VALID_FLAG,STOVE_NUM)
							VALUES(?,?,?,?,
							?,?,?,?,SYSDATE,
							'1','1')
								  
		]]>
	</query>
	
	<query id="FreeTest.MODIFY" desc="修改">
		<![CDATA[
			 UPDATE COM_BASE_LIMS_FREE_TEST set
							SUPP_NAME=?, 
							DIMATER=?, 
							HEIGHT=?, 
							DELVRY_STATE = ?,
							STD_NAME = ?,
							GRADE = ?,
							FINAL_STOVE_NUM = ?,
							STOVE_NUM = '1',
							UPDATE_NAME=?, 
							UPDATE_TIME=sysdate,
							VALID_FLAG = '1'
							WHERE id=?
		]]>
	</query>
	<query id="FreeTest.QUERY" desc="权限功能">
		<![CDATA[
SELECT id,SUPP_NAME,
       DIMATER,
       HEIGHT,
       DELVRY_STATE,
       STD_NAME,
       GRADE,
       FINAL_STOVE_NUM,
       STOVE_NUM,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       VALID_FLAG,
       DECODE(VALID_FLAG, '1', '有效', '无效') VALIDFLAGNAME
  FROM COM_BASE_LIMS_FREE_TEST
 WHERE LOWER(GRADE) || '&' LIKE '%' || LOWER(?) || '%'
 ORDER BY ID
		]]>
	</query>
	
	<query id="FreeTest.DELETE" desc="作废">
		<![CDATA[
			 UPDATE COM_BASE_LIMS_FREE_TEST T
			   SET T.UPDATE_NAME = ?, T.UPDATE_TIME = SYSDATE, T.VALID_FLAG = '0',STOVE_NUM = '1'
			 WHERE T.ID = ?
		]]>
	</query>
	
	<query id="FreeTest.RESUME" desc="恢复">
		<![CDATA[
			UPDATE COM_BASE_LIMS_FREE_TEST T
               SET T.UPDATE_NAME = '', T.UPDATE_TIME = SYSDATE, T.VALID_FLAG = '1',STOVE_NUM = '1'
             WHERE T.ID = ?
		]]>
	</query>
	
</queryMap>