<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="成品成分允许标准表查询">
	<query id="CoreProductCHEMBIAS.QUERY_P" desc="主表查询">
		<![CDATA[
SELECT CIC,
       STD_CODE,
       STD_NAME,
       ASSORTMENT_CODE,
       ASSORTMENT_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', '有效', '0', '无效') VALIDFLAG
  FROM COM_MSC_STD_CHEM_BIAS
 WHERE VALIDFLAG IN ('1', ?)
   AND LOWER(STD_NAME) LIKE '%' || LOWER(?) || '%'
 ORDER BY CIC ASC
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.QUERY_C" desc="从表查询">
		<![CDATA[
	    SELECT CIC,
       INDEX_SEQ,
       CHEM_CODE,
       CHEM_NAME,
       DECODE(WHOLE_BACKLOG, 'A', '单一元素', 'B', '复合元素') WHOLE_BACKLOG,
       CHEM_FORMULA,
       MIN_SIGN,
       MIN_VAL,
       MAX_SIGN,
       MAX_VAL,
       --STD_MIN_SIGN,
       STD_MIN_VAL,
       --STD_MAX_SIGN,
       STD_MAX_VAL,
       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', '有效', '0', '无效') VALIDFLAG
  FROM COM_MSC_STD_CHEM_BIAS_C B
 WHERE VALIDFLAG IN ('1', ?)
   AND EXISTS
 (SELECT 1
          FROM COM_MSC_STD_CHEM_BIAS A
         WHERE A.CIC = B.CIC
           AND A.VALIDFLAG IN ('1', ?)
           AND LOWER(STD_NAME) LIKE '%' || LOWER(?) || '%')	   
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.MaxCIC" desc="最大CIC">
		<![CDATA[
		 SELECT CIC
            FROM COM_MSC_STD_CHEM_BIAS
           WHERE CIC = (SELECT MAX(CIC) CIC FROM COM_MSC_STD_CHEM_BIAS)
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.MaxIndex" desc="最大序号">
		<![CDATA[
	   SELECT INDEX_SEQ
       FROM COM_MSC_STD_CHEM_BIAS_C
       WHERE INDEX_SEQ = (SELECT MAX(INDEX_SEQ) INDEX_SEQ
       FROM COM_MSC_STD_CHEM_BIAS_C   WHERE CIC = ?)
			 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.ADD_P" desc="主表新增">
		<![CDATA[
	 INSERT INTO COM_MSC_STD_CHEM_BIAS
     (CIC,
      STD_CODE,
      STD_NAME,
      ASSORTMENT_CODE,
      ASSORTMENT_NAME,
      CREATE_NAME,
      CREATE_TIME
      )
      VALUES  (?,?,?,?,?,?,SYSDATE)
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.ADD_C" desc="从表新增">
		<![CDATA[
	  INSERT INTO COM_MSC_STD_CHEM_BIAS_C
     (CIC,
      INDEX_SEQ,
      CHEM_CODE,
      CHEM_NAME,
      WHOLE_BACKLOG,
      CHEM_FORMULA,
      MIN_SIGN,
      MIN_VAL,
      MAX_SIGN,
      MAX_VAL,
      --STD_MIN_SIGN,
      STD_MIN_VAL,
     -- STD_MAX_SIGN,
      STD_MAX_VAL,
      CREATE_NAME,
      CREATE_TIME)
      VALUES (?,?,?,?,?,?,?,?,?,?,
              ?,?,?,SYSDATE )
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.Update_P" desc="主表修改">
		<![CDATA[
      UPDATE COM_MSC_STD_CHEM_BIAS
         SET CIC         = ?,
         STD_CODE        = ?,
         STD_NAME        = ?,
         ASSORTMENT_CODE = ?,
         ASSORTMENT_NAME = ?,
         UPDATE_NAME     = ?,
         UPDATE_TIME     = SYSDATE
         WHERE CIC = ?  AND VALIDFLAG='1'
  
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.Update_C" desc="从表修改">
		<![CDATA[
	    UPDATE COM_MSC_STD_CHEM_BIAS_C
        SET CIC       = ?,
        INDEX_SEQ     = ?,
        CHEM_CODE     = ?,
        CHEM_NAME     = ?,
        WHOLE_BACKLOG = ?,
        CHEM_FORMULA  = ?,
        MIN_SIGN      = ?,
        MIN_VAL       = ?,
        MAX_SIGN      = ?,
        MAX_VAL       = ?,
        --STD_MIN_SIGN  = ?,
        STD_MIN_VAL   = ?,
        --STD_MAX_SIGN  = ?,
        STD_MAX_VAL   = ?,
        UPDATE_NAME   = ?,
        UPDATE_TIME   = SYSDATE
        WHERE CIC     = ?  AND INDEX_SEQ = ? AND VALIDFLAG='1'
 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.DELETE_P" desc="主表作废">
		<![CDATA[
         UPDATE COM_MSC_STD_CHEM_BIAS
         SET  
         DELETE_NAME     = ?,
         DELETE_TIME     = SYSDATE ,
         VALIDFLAG       = '0'
         WHERE CIC = ? AND VALIDFLAG='1'
 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.DELETE_C1" desc="从表批量作废">
		<![CDATA[
	    UPDATE COM_MSC_STD_CHEM_BIAS_C
        SET  
        DELETE_NAME   = ?,
        DELETE_TIME   = SYSDATE,
        VALIDFLAG     = '0'
        WHERE CIC =? AND VALIDFLAG='1'
 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.DELETE_C" desc="从表作废">
		<![CDATA[
	    UPDATE COM_MSC_STD_CHEM_BIAS_C
        SET  
        DELETE_NAME   = ?,
        DELETE_TIME   = SYSDATE,
        VALIDFLAG     = '0'
        WHERE CIC =?  AND INDEX_SEQ = ? AND VALIDFLAG='1'
 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.RESUME_P" desc="主表恢复">
		<![CDATA[
		 UPDATE COM_MSC_STD_CHEM_BIAS
         SET  
         DELETE_NAME     = '',
         DELETE_TIME     = '' ,
         VALIDFLAG       = '1'
         WHERE CIC = ? AND VALIDFLAG='0'
 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.RESUME_C" desc="从表恢复">
		<![CDATA[
		UPDATE COM_MSC_STD_CHEM_BIAS_C
        SET  
        DELETE_NAME   = '',
        DELETE_TIME   = '',
        VALIDFLAG     = '1'
        WHERE CIC =?  AND INDEX_SEQ = ? AND VALIDFLAG='0'
 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.getSteel" desc="从表恢复">
		<![CDATA[
	   SELECT 'TRUE' CHK, T.STEELCODE, T.STEELNAME
       FROM COM_MSC_STD_CHEM_STEEL T
       WHERE T.VALIDFLAG = '1'
       AND T.CIC = ?
       UNION
       SELECT 'FALSE' CHK, T2.STEELCODE, T2.STEELNAME
       FROM COM_BASE_STEEL T2
       WHERE T2.VALIDFLAG = '1'
       AND T2.STEELCODE NOT IN (SELECT STEELCODE
                                FROM COM_MSC_STD_CHEM_STEEL T
                               WHERE T.VALIDFLAG = '1'
                                 AND T.CIC = ?)
        ORDER BY STEELNAME
	 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.Delete_Steel" desc="从表恢复">
		<![CDATA[
		DELETE  FROM  COM_MSC_STD_CHEM_STEEL 
		WHERE CIC = ?
 
		]]>
	</query>

	<query id="CoreProductCHEMBIAS.Insert_Steel" desc="从表恢复">
		<![CDATA[
		 INSERT INTO COM_MSC_STD_CHEM_STEEL
         (CIC, STEELCODE, STEELNAME, CREATE_NAME, CREATE_TIME)
         VALUES
         (?, ?, ?, ?, SYSDATE)
		 
		]]>
	</query>

</queryMap>