<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	<query id="CoreStandard1.QUERY" desc="标准基础查询">
		<![CDATA[
			SELECT  
					STD_CODE,
				    STD_NAME,
				    STD_NAME AS STD_NAME_OLD,
				    DECODE(STDSTYLE,'G','订货标准','K','Alpha','N','内控','X','协议标准','S','试验标准','P','成分偏差标准') STDSTYLE,
					STD_NOTE,
					STD_STYLE,
					STD_STYLE_NAME,
					STD_VERSION,
					DEPARTMENT_CODE,
					DEPARTMENT_DESC,
					UNIT_CODE,
					UNIT_DESC,
					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,
					DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAG,
					MEMO
				FROM COM_BASE_STD
				   WHERE VALIDFLAG in ('1' , ?) 
				   AND lower(STD_NAME)||'&' LIKE '%' || lower(?) || '%'
				   ORDER BY STD_CODE
		]]>
	</query>	
	
	<query id="CoreStandard1.QUERYALPHA" desc="标准基础查询">
		<![CDATA[
			SELECT  
					ALPHA_CODE AS STD_CODE,
				    (SELECT STD_NAME FROM COM_BASE_STD C WHERE C.STD_CODE=T.STD_CODE) STD_NAME,
				    'Alpha' STDSTYLE,
					STD_NOTE,
					STD_STYLE,
					STD_STYLE_NAME,
					STD_VERSION,
					DEPARTMENT_CODE,
					DEPARTMENT_DESC,
					UNIT_CODE,
					UNIT_DESC,
					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,
					DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAG,
					MEMO
				FROM COM_BASE_STD_ALPHA T
				   WHERE VALIDFLAG in ('1' ,?) 
				   AND lower(ALPHA_NAME)||'&' LIKE '%' || lower(?) || '%'
				   ORDER BY ALPHA_CODE
		]]>
	</query>	
	
	<query id="CoreStandard1.ADD" desc="标准基础增加">
		<![CDATA[
			INSERT INTO COM_BASE_STD
  (STD_CODE,
   STD_NAME,
   STDSTYLE,
   STD_NOTE,
   STD_STYLE,
   STD_STYLE_NAME,
   STD_VERSION,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   UNIT_CODE,
   UNIT_DESC,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, DEFAULT, ?)
		]]>
	</query>
	
	<query id="CoreStandard1.UPDATE" desc="标准基础修改">
		<![CDATA[
			UPDATE COM_BASE_STD
   SET STD_CODE        = ?,
       STD_NAME        = ?,
       STDSTYLE        = ?,
       STD_NOTE        = ?,
       STD_STYLE       = ?,
       STD_STYLE_NAME  = ?,
       STD_VERSION     = ?,
       DEPARTMENT_CODE = ?,
       DEPARTMENT_DESC = ?,
       UNIT_CODE       = ?,
       UNIT_DESC       = ?,
       UPDATE_NAME     = ?,
       MEMO            = ?
 WHERE STD_CODE = ?
			
		]]>
	</query>
	
	<query id="CoreStandard1.DELETE" desc="标准基础作废">
		<![CDATA[
			UPDATE COM_BASE_STD
   SET DELETE_NAME = ?, DELETE_TIME = SYSDATE, VALIDFLAG = '0'
 WHERE STD_CODE = ?
		]]>
	</query>
	
	<query id="CoreStandard1.RESUME" desc="标准基础恢复">
		<![CDATA[
			UPDATE COM_BASE_STD
   SET DELETE_NAME = ?, DELETE_TIME = NULL, VALIDFLAG = '1'
 WHERE STD_CODE = ?
		]]>
	</query>
	
	
	<query id="CoreStandard1.GetStdStyle" desc="获取标准类别描述">
		<![CDATA[
			SELECT T.Std_Style, T.STD_STYLE_DESC FROM COM_BASE_STD_STYLE T WHERE T.VALIDFLAG = '1'
			ORDER BY T.STD_STYLE_DESC ASC
		]]>
	</query>
	
	<query id="CoreStandard1.BANDSTDXH" desc="绑定标准协会代码">
		<![CDATA[
			select BASECODE,BASENAME from COM_BASE_INFO where SORTCODE=4001 AND VALIDFLAG = '1'
			ORDER BY BASENAME ASC
		]]>
	</query>
	
	<query id="CoreStandard1.GETCUST" desc="绑定选择客户">
		<![CDATA[
			SELECT CUSTOMER_NO,CUSTOMER_NM FROM SLM_BASE_CUSTOMER ORDER BY CUSTOMER_NO
		]]>
	</query>
	
	<query id="CoreStandard1.COMPSC" desc="产品规范查询">
		<![CDATA[
			SELECT PSC,
                   P.PSC_DESC,
                   P.PRODUCCODE,
                   P.PRODUCNAME,
                   P.STD_CODE,
                   P.STD_NAME,
                   P.STEELCODE,
                   P.STEELNAME,
                   P.STD_STYLE,
                   P.STD_STYLE_DESC,
                   DECODE(P.NEW_PROC_CODE, '1', 'TRUE', 'FALSE') NEW_PROC_CODE,
                   P.NEW_PROC_DESC,
                   P.DEPARTMENT_CODE,
                   P.DEPARTMENT_DESC,
                   P.UNIT_CODE,
                   DECODE(P.AUTOJUDGE, '1', 'TRUE', 'FALSE') AUTOJUDGE,
                   P.UNIT_DESC,
                   P.CREATE_NAME,
                   TO_CHAR(P.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
                   P.UPDATE_NAME,
                   TO_CHAR(P.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
                   P.DELETE_NAME,
                   TO_CHAR(P.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
                   DECODE(P.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
                   P.MEMO,
                   R.PRODUC_DESC
              FROM COM_PSC P
         LEFT JOIN COM_BASE_PRODUCT R
                ON p.produccode = R.PRODUCCODE
             WHERE P.STD_NAME=?
          ORDER BY PSC
		]]>
	</query>
	
	<query id="CoreStandard1.ADD1" desc="产品规范 增加">
		<![CDATA[
			INSERT INTO COM_PSC
  (PSC,
   PSC_DESC,
   PRODUCCODE,
   PRODUCNAME,
   STD_CODE,
   STD_NAME,
   STEELCODE,
   STEELNAME,
   STD_STYLE,
   STD_STYLE_DESC,
   NEW_PROC_CODE,
   NEW_PROC_DESC,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   UNIT_CODE,
   AUTOJUDGE,
   UNIT_DESC,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO)
VALUES
  ((SELECT 'PSC' || LPAD(TO_CHAR(TO_NUMBER(SUBSTR(NVL(MAX(PSC), 'PSC0000000'), 4, 7)) + 1),7,'0') AS PSC FROM COM_PSC),
  ?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,DEFAULT,?)
		]]>
	</query>
	
	<query id="CoreStandard1.UPDATE1" desc="产品规范修改">
		<![CDATA[
			UPDATE COM_PSC
   SET
       PSC_DESC        = ?,
       PRODUCCODE      = ?,
       PRODUCNAME      = ?,
       STD_CODE        = ?,
       STD_NAME        = ?,
       STEELCODE       = ?,
       STEELNAME       = ?,
       STD_STYLE       = ?,
       STD_STYLE_DESC  = ?,
       NEW_PROC_CODE   = ?,
       NEW_PROC_DESC   = ?,
       DEPARTMENT_CODE = ?,
       DEPARTMENT_DESC = ?,
       UNIT_CODE       = ?,
       AUTOJUDGE       = ?,
       UNIT_DESC       = ?,
       UPDATE_NAME     = ?,
       UPDATE_TIME     = SYSDATE,
       MEMO            = ?
 WHERE PSC = ?
		]]>
	</query>
	
	
	<query id="CoreStandard1.COMSTDRCUST" desc="客户标准与最终用户对应表">
		<![CDATA[
		SELECT STD_CODE,
       STD_NAME,
       CUST_CODE,
       CUST_NAME,
       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,
       DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAG,
       MEMO,
       CUST_CODE AS OLD_CUST_CODE
       FROM COM_BASE_STD_R_CUST WHERE STD_NAME = ?
		]]>
	</query>
	
	<query id="CoreStandard1.GETPRODUCT" desc="获取品名描述">
		<![CDATA[
			SELECT T.PRODUCNAME, T.PRODUCCODE,T.PRODUC_DESC FROM COM_BASE_PRODUCT T WHERE T.VALIDFLAG = '1'
			ORDER BY T.PRODUCCODE ASC
		]]>
	</query>
	
	<query id="CoreStandard1.GETSTEEL" desc="获取钢级（牌号）描述">
		<![CDATA[
			SELECT T.STEELCODE, T.STEELNAME FROM COM_BASE_STEEL T WHERE T.VALIDFLAG = '1'
			ORDER BY T.STEELNAME ASC
		]]>
	</query>
	
	<query id="CoreStandard1.MAXSTDCODE" desc="最大标准代码">
		<![CDATA[
			SELECT STD_CODE
              FROM COM_BASE_STD
             WHERE STD_CODE = (SELECT MAX(T.STD_CODE) STD_CODE FROM COM_BASE_STD T)
		]]>
	</query>
	
	

	<query id="CoreStandard1.ADD2" desc="客户增加">
		<![CDATA[
			INSERT INTO COM_BASE_STD_R_CUST
  (STD_CODE,
   STD_NAME,
   CUST_CODE,
   CUST_NAME,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO)
VALUES(?,?,?, ?,?,SYSDATE,DEFAULT,?)
		]]>
	</query>
	
	<query id="CoreStandard1.UPDATE2" desc="客户修改">
		<![CDATA[
			UPDATE COM_BASE_STD_R_CUST
   SET STD_CODE    = ?,
       STD_NAME    = ?,
       CUST_CODE   = ?,
       CUST_NAME   = ?,
       UPDATE_NAME = ?,
       UPDATE_TIME = SYSDATE,
       MEMO        = ?
 WHERE STD_CODE = ?
   AND CUST_CODE = ?
		]]>
	</query>
	
	
	
	<query id="CoreStandard1.DELETE1" desc="产品规范作废">
		<![CDATA[
			UPDATE COM_PSC
   SET DELETE_NAME = ?, DELETE_TIME = SYSDATE, VALIDFLAG = '0'
 WHERE PSC = ?
		]]>
	</query>
	
	<query id="CoreStandard1.RESUME1" desc="产品规范恢复">
		<![CDATA[
			UPDATE COM_PSC
   SET DELETE_NAME = ?, DELETE_TIME = NULL, VALIDFLAG = '1'
 WHERE PSC = ?			
		]]>
	</query>
	
	<query id="CoreStandard1.DELETE2" desc="最终客户作废">
		<![CDATA[
			UPDATE COM_BASE_STD_R_CUST
   SET DELETE_NAME = ?, DELETE_TIME = SYSDATE, VALIDFLAG = '0'
 WHERE STD_CODE = ?
   AND CUST_CODE = ?
		]]>
	</query>
	
	<query id="CoreStandard1.RESUME2" desc="最终客户恢复">
		<![CDATA[
			UPDATE COM_BASE_STD_R_CUST
   SET DELETE_NAME = ?, DELETE_TIME = NULL, VALIDFLAG = '1'
 WHERE STD_CODE = ?
   AND CUST_CODE = ?
		]]>
	</query>
	
	<query id="CoreStandard1.CHECKSTDNAME" desc="标准名称">
		<![CDATA[
SELECT STD_NAME
  FROM COM_BASE_STD T
 WHERE STD_NAME = '#STD_NAME#'
   AND T.STDSTYLE = '#STDSTYLE#'
		]]>
	</query>
	
	<query id="CoreStandard1.CHECKSTDNAME1" desc="标准名称">
		<![CDATA[
SELECT STD_NAME
  FROM (SELECT STD_NAME, STDSTYLE FROM COM_BASE_STD WHERE STD_CODE != '#STD_CODE#')
 WHERE STD_NAME = '#STD_NAME#'
   AND STDSTYLE = '#STDSTYLE#'
		]]>
	</query>
	
	<query id="CoreStandard1.CHECKPSC" desc="产品规范描述">
		<![CDATA[
		SELECT C.PSC_DESC FROM COM_PSC C WHERE C.PSC_DESC = ? 
		]]>
	</query>
	
	<query id="CoreStandard1.CHECKPSC1" desc="产品规范描述">
		<![CDATA[
		SELECT PSC_DESC
  FROM (SELECT PSC_DESC FROM COM_PSC WHERE PSC != ?)
 WHERE PSC_DESC = ?
		]]>
	</query>
	
	<query id="CoreStandard1.CHECKCUST" desc="最终客户描述">
		<![CDATA[
		SELECT  CUST_NAME FROM COM_BASE_STD_R_CUST WHERE CUST_CODE = ? AND STD_CODE=?
		]]>
	</query>
	
	<query id="CoreStandard1.CHECKCUST1" desc="最终客户描述">
		<![CDATA[
		SELECT CuST_NAME FROM COM_BASE_STD_R_CUST WHERE STD_CODE = ?  AND CUST_CODE= ? 
		]]>
	</query>
</queryMap>