<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	<query id="CoreSpecificationsGrade.QUERY" desc="权限功能">
		<![CDATA[
SELECT 'FALSE' CB,
       GRADECODE,
       GRADENAME,
       GRADENAME GRADENAME_OLD,
       ASSORTMENT_CODE,
       ASSORTMENT_NAME,
       COEFFICIENT,
       DECODE(ALLOW_BUY, '1', 'TRUE', 'FALSE') ALLOW_BUY,
       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,
       MEMO
  FROM COM_BASE_GRADE
 WHERE VALIDFLAG IN ('1', ?)
   AND GRADECODE || '&' LIKE '%' || ? || '%'
   AND DECODE(?, NULL, '1', UPPER(GRADENAME)) LIKE '%' || UPPER(NVL(?, '1')) || '%'
 ORDER BY GRADECODE ASC
		]]>
	</query>
	<query id="CoreSpecificationsGrade.ADD" desc="新增">
		<![CDATA[
INSERT INTO COM_BASE_GRADE
  (GRADECODE,
   GRADENAME,
   ASSORTMENT_CODE,
   ASSORTMENT_NAME,
   COEFFICIENT,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO,
   ALLOW_BUY)
VALUES
  ('#GRADECODE#',
   '#GRADENAME#',
   '#ASSORTMENT_CODE#',
   '#ASSORTMENT_NAME#',
   TO_NUMBER('#COEFFICIENT#'),
   '#CREATE_NAME#',
   SYSDATE,
   '1',
   '#MEMO#',
   '#ALLOW_BUY#')
		]]>
	</query>
	
	<query id="CoreSpecificationsGrade.getMaxGradeCode" desc="获取最大的钢种代码">
		<![CDATA[
SELECT 'GZ' ||
          LPAD(SUBSTR((NVL(MAX(GRADECODE), 'GZ0000')), 3), 4, '0') MAX_VALUE
     FROM COM_BASE_GRADE
		]]>
	</query>
	
	<query id="CoreSpecificationsGrade.UPDATE" desc="修改">
		<![CDATA[
UPDATE COM_BASE_GRADE
   SET GRADENAME       = '#GRADENAME#',
       ASSORTMENT_CODE = '#ASSORTMENT_CODE#',
       ASSORTMENT_NAME = '#ASSORTMENT_NAME#',
       COEFFICIENT     = TO_NUMBER('#COEFFICIENT#'),
       UPDATE_NAME     = '#UPDATE_NAME#',
       UPDATE_TIME     = SYSDATE,
       MEMO            = '#MEMO#',
       ALLOW_BUY       = '#ALLOW_BUY#'
 WHERE GRADECODE = '#GRADECODE#'
		]]>
	</query>
	<query id="CoreSpecificationsGrade.DELETE" desc="作废">
		<![CDATA[
			 UPDATE COM_BASE_GRADE T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.GRADECODE = ?
		]]>
	</query>

	<query id="CoreSpecificationsGrade.RESUME" desc="恢复">
		<![CDATA[
			UPDATE COM_BASE_GRADE T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.GRADECODE = ?
		]]>
	</query>

	<query id="CoreSpecificationsGrade.MAXID" desc="获取最大id">
		<![CDATA[
			SELECT MAX(gradecode) FROM com_base_grade
		]]>
	</query>

	<query id="CoreSpecificationsGrade.isExistGradeName" desc="是否存在钢种名称">
		<![CDATA[
			SELECT COUNT(1) FROM COM_BASE_GRADE T WHERE T.GRADENAME = '#GRADENAME#'
		]]>
	</query>
	
	<query id="CoreSpecificationsGrade.GetComBaseGrade" desc="查询钢种基础数据">
		<![CDATA[
SELECT T.GRADECODE, T.GRADENAME FROM COM_BASE_GRADE T WHERE T.VALIDFLAG = '1'
		]]>
	</query>
</queryMap>