<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质保书主表">
	<query id="JdgQcmZbsInfo.getMaxZbsId" desc="获取最大质保书ID">
		<![CDATA[
SELECT NVL(MAX(T.ZBS_ID), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 ZBS_ID
  FROM QCM_ZBS_INFO T
 WHERE T.ZBS_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
		]]>
	</query>

	<query id="JdgQcmZbsInfo.GetMaxPk0" desc="获取最大主键(刷新尾号是0)">
		<![CDATA[
SELECT  NVL(SUBSTR(MAX(T.ZBS_ID), 1, 13), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 || '0' ZBS_ID
  FROM QCM_ZBS_INFO T
 WHERE T.ZBS_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
        ]]>
	</query>

	<query id="JdgQcmZbsInfo.GetMaxPk1" desc="获取最大主键（判定尾号是1）">
		<![CDATA[
SELECT  NVL(SUBSTR(MAX(T.ZBS_ID), 1, 13), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 || '1' ZBS_ID
  FROM QCM_ZBS_INFO T
 WHERE T.ZBS_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
        ]]>
	</query>
	
	<query id="JdgQcmZbsInfo.getByBatchNoOrdLnDlyPk" desc="通过炉批、交货行获取">
		<![CDATA[
SELECT T.* FROM QCM_ZBS_INFO T WHERE T.JUDGE_STOVE_NO = {0} AND T.BATCH_NO = {1}
AND T.ORD_LN_DLY_PK = {2} AND ({3} IS NULL OR T.WO_ID = {3})
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.getBlByBatchNo" desc="通过炉批获取">
		<![CDATA[
SELECT T.* FROM QCM_ZBS_INFO T WHERE T.JUDGE_STOVE_NO = {0} AND T.BATCH_NO = {1} AND T.ORD_LN_DLY_PK LIKE 'ZZB%'
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.updateCount" desc="更新">
		<![CDATA[
UPDATE QCM_ZBS_INFO T
   SET T.ACT_COUNT         = '#ACT_COUNT#',
       T.ACT_WEIGHT        = '#ACT_WEIGHT#',
       T.ACT_THEORY_WEIGHT = '#ACT_THEORY_WEIGHT#'
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.insert" desc="新增">
		<![CDATA[
 INSERT INTO QCM_ZBS_INFO(
        ZBS_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        PLINE_CODE,
        PROCESS_CODE,
        PROCESS_DESC,
        CHEM_RESULT,
        PHY_RESULT,
        FACE_RESULT,
        SPEC_RESULT,
        DETECT_RESULT,
        DETECT_RESULT2,
        WATER_RESULT,
        PROCESS_RESULT,
        JUDGE_RESULT,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        DELIVERY_STATE_CODE,
        DELIVERY_STATE_NAME,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        STEELCODE,
        GRADECODE,
        STEELNAME,
        GRADENAME,
        CUT_NUM,
        LOT_NO,
        LOT_NO_GROUP,
        CUSTOMER_NO,
        CUSTOMER_NM,
        RECEIV_NO,
        RECEIV_NM,
        ORDER_NO,
        ORDER_SEQ,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        PRODUCCODE,
        PRODUCNAME,
        ORDER_SPEC_CODE,
        ORDER_SPEC_DESC,
        MODEL_CODE,
        MODEL_DESC,
        OUTPUT_STD_NO,
        LEN_NO,
        LEN_DESC,
        USE_CODE,
        USE_DESC,
        CUSTM_ORDER_NO,
        ZBS_ADD_ASK_DESC,
        FLAG,
        ORD_LN_DLY_PK,
        ORD_LN_PK,
        SPEC_CODE,
        SPEC_NAME,
        LEN_UNIT,
        LEN_MIN,
        LEN_MAX,
        LEN_MIN_MAX_UNIT,
        WO_ID,
        SUPP_CODE)
 VALUES( 
        '#ZBS_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#PLINE_CODE#',
        '#PROCESS_CODE#',
        '#PROCESS_DESC#',
        '#CHEM_RESULT#',
        '#PHY_RESULT#',
        '#FACE_RESULT#',
        '#SPEC_RESULT#',
        '#DETECT_RESULT#',
        '#DETECT_RESULT2#',
        '#WATER_RESULT#',
        '#PROCESS_RESULT#',
        '#JUDGE_RESULT#',
        '#MEMO#',
        '#CREATE_NAME#',
        SYSDATE,
        '#DELIVERY_STATE_CODE#',
        '#DELIVERY_STATE_NAME#',
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        '#ACT_THEORY_WEIGHT#',
        '#STEELCODE#',
        '#GRADECODE#',
        '#STEELNAME#',
        '#GRADENAME#',
        '#CUT_NUM#',
        '#LOT_NO#',
        '#LOT_NO_GROUP#',
         '#CUSTOMER_NO#',
        '#CUSTOMER_NM#',
        '#RECEIV_NO#',
        '#RECEIV_NM#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#ORDER_SPEC_CODE#',
        '#ORDER_SPEC_DESC#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#OUTPUT_STD_NO#',
        '#LEN_NO#',
        '#LEN_DESC#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#CUSTM_ORDER_NO#',
        '#ZBS_ADD_ASK_DESC#',
        '1',
        '#ORD_LN_DLY_PK#',
        '#ORD_LN_PK#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#LEN_UNIT#',
        '#LEN_MIN#',
        '#LEN_MAX#',
        '#LEN_MIN_MAX_UNIT#',
        '#WO_ID#',
        '#SUPP_CODE#')
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.delete" desc="删除">
		<![CDATA[
DELETE FROM QCM_ZBS_INFO T WHERE T.ZBS_ID = {0}
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.update" desc="修改">
		<![CDATA[
 UPDATE QCM_ZBS_INFO T
   SET 
        T.STOVE_NO = '#STOVE_NO#',
        T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        T.BATCH_NO = '#BATCH_NO#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PROCESS_CODE = '#PROCESS_CODE#',
        T.PROCESS_DESC = '#PROCESS_DESC#',
        T.CHEM_RESULT = '#CHEM_RESULT#',
        T.PHY_RESULT = '#PHY_RESULT#',
        T.FACE_RESULT = '#FACE_RESULT#',
        T.SPEC_RESULT = '#SPEC_RESULT#',
        T.DETECT_RESULT = '#DETECT_RESULT#',
        T.DETECT_RESULT2 = '#DETECT_RESULT2#',
        T.WATER_RESULT = '#WATER_RESULT#',
        T.PROCESS_RESULT = '#PROCESS_RESULT#',
        T.JUDGE_RESULT = '#JUDGE_RESULT#',
        T.MEMO = '#MEMO#',
        T.CREATE_NAME = '#CREATE_NAME#',
        T.CREATE_TIME = SYSDATE,
        T.DELIVERY_STATE_CODE = '#DELIVERY_STATE_CODE#',
        T.DELIVERY_STATE_NAME = '#DELIVERY_STATE_NAME#',
        T.ACT_COUNT = '#ACT_COUNT#',
        T.ACT_WEIGHT = '#ACT_WEIGHT#',
        T.ACT_THEORY_WEIGHT = '#ACT_THEORY_WEIGHT#',
        T.STEELCODE = '#STEELCODE#',
        T.GRADECODE = '#GRADECODE#',
        T.STEELNAME = '#STEELNAME#',
        T.GRADENAME = '#GRADENAME#',
        T.CUT_NUM = '#CUT_NUM#',
        T.LOT_NO = '#LOT_NO#',
        T.LOT_NO_GROUP = '#LOT_NO_GROUP#',
        T.CUSTOMER_NO = '#CUSTOMER_NO#',
        T.CUSTOMER_NM = '#CUSTOMER_NM#',
        T.RECEIV_NO = '#RECEIV_NO#',
        T.RECEIV_NM = '#RECEIV_NM#',
        T.ORDER_NO = '#ORDER_NO#',
        T.ORDER_SEQ = '#ORDER_SEQ#',
        T.STD_CODE = '#STD_CODE#',
        T.STD_NAME = '#STD_NAME#',
        T.STD_STYLE = '#STD_STYLE#',
        T.STD_STYLE_DESC = '#STD_STYLE_DESC#',
        T.PRODUCCODE = '#PRODUCCODE#',
        T.PRODUCNAME = '#PRODUCNAME#',
        T.ORDER_SPEC_CODE = '#ORDER_SPEC_CODE#',
        T.ORDER_SPEC_DESC = '#ORDER_SPEC_DESC#',
        T.MODEL_CODE = '#MODEL_CODE#',
        T.MODEL_DESC = '#MODEL_DESC#',
        T.OUTPUT_STD_NO = '#OUTPUT_STD_NO#',
        T.LEN_NO = '#LEN_NO#',
        T.LEN_DESC = '#LEN_DESC#',
        T.USE_CODE = '#USE_CODE#',
        T.USE_DESC = '#USE_DESC#',
        T.CUSTM_ORDER_NO = '#CUSTM_ORDER_NO#',
        T.ZBS_ADD_ASK_DESC = '#ZBS_ADD_ASK_DESC#',
        T.FLAG = '#FLAG#',
        T.LEN_MIN_MAX_UNIT = '#LEN_MIN_MAX_UNIT#'
 WHERE T.ZBS_ID = '#ZBS_ID#'
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.update2" desc="修改">
		<![CDATA[
 UPDATE QCM_ZBS_INFO T
   SET T.MEMO                = '#MEMO#',
       T.DELIVERY_STATE_CODE = '#DELIVERY_STATE_CODE#',
       T.DELIVERY_STATE_NAME = '#DELIVERY_STATE_NAME#',
       T.STEELCODE           = '#STEELCODE#',
       T.GRADECODE           = '#GRADECODE#',
       T.STEELNAME           = '#STEELNAME#',
       T.GRADENAME           = '#GRADENAME#',
       T.CUT_NUM             = '#CUT_NUM#',
       T.LOT_NO              = '#LOT_NO#',
       T.LOT_NO_GROUP        = '#LOT_NO_GROUP#',
       T.CUSTOMER_NO         = '#CUSTOMER_NO#',
       T.CUSTOMER_NM         = '#CUSTOMER_NM#',
       T.RECEIV_NO           = '#RECEIV_NO#',
       T.RECEIV_NM           = '#RECEIV_NM#',
       T.ORDER_NO            = '#ORDER_NO#',
       T.ORDER_SEQ           = '#ORDER_SEQ#',
       T.STD_CODE            = '#STD_CODE#',
       T.STD_NAME            = '#STD_NAME#',
       T.STD_STYLE           = '#STD_STYLE#',
       T.STD_STYLE_DESC      = '#STD_STYLE_DESC#',
       T.PRODUCCODE          = '#PRODUCCODE#',
       T.PRODUCNAME          = '#PRODUCNAME#',
       T.ORDER_SPEC_CODE     = '#ORDER_SPEC_CODE#',
       T.ORDER_SPEC_DESC     = '#ORDER_SPEC_DESC#',
       T.MODEL_CODE          = '#MODEL_CODE#',
       T.MODEL_DESC          = '#MODEL_DESC#',
       T.OUTPUT_STD_NO       = '#OUTPUT_STD_NO#',
       T.LEN_NO              = '#LEN_NO#',
       T.LEN_DESC            = '#LEN_DESC#',
       T.USE_CODE            = '#USE_CODE#',
       T.USE_DESC            = '#USE_DESC#',
       T.CUSTM_ORDER_NO      = '#CUSTM_ORDER_NO#',
       T.ZBS_ADD_ASK_DESC    = '#ZBS_ADD_ASK_DESC#',
       T.FLAG                = '#FLAG#',
       T.LEN_MIN_MAX_UNIT    = '#LEN_MIN_MAX_UNIT#'
 WHERE T.ZBS_ID = '#ZBS_ID#'
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.zbsInfoCtrlQuery" desc="删除">
		<![CDATA[
SELECT T.ZBS_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PLINE_CODE,
       A.PLINE_NAME,
       T.PROCESS_CODE,
       T.PROCESS_DESC,
       T.MEMO,
       T.CREATE_NAME,
       T.CREATE_TIME,
       T.DELIVERY_STATE_CODE,
       T.DELIVERY_STATE_NAME,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.STEELCODE,
       T.GRADECODE,
       T.STEELNAME,
       T.GRADENAME,
       T.CUT_NUM,
       T.LOT_NO,
       T.LOT_NO_GROUP,
       T.CUSTOMER_NO,
       T.CUSTOMER_NM,
       T.RECEIV_NO,
       T.RECEIV_NM,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.ORDER_SPEC_CODE,
       T.ORDER_SPEC_DESC,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.OUTPUT_STD_NO,
       T.LEN_NO,
       T.LEN_DESC,
       T.USE_CODE,
       T.USE_DESC,
       T.CUSTM_ORDER_NO,
       T.ZBS_ADD_ASK_DESC,
       'False' CHK,
       (SELECT TO_CHAR(MIN(B.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS')
          FROM QCM_ZC_JUDGE B
         WHERE B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND B.BATCH_NO = T.BATCH_NO
           AND B.PROCESS_CDOE = T.PROCESS_CODE
           AND B.VALIDFLAG = '1') JUDGE_TIME,
       T.LEN_MIN_MAX_UNIT
  FROM QCM_ZBS_INFO T
  LEFT JOIN COM_BASE_PLINE A
    ON A.PLINE_CODE = T.PLINE_CODE
 WHERE ({0} IS NULL OR T.JUDGE_STOVE_NO = {0})
   AND ({1} IS NULL OR T.LOT_NO = {1})
   AND EXISTS
 (SELECT 1
          FROM QCM_ZC_JUDGE B
         WHERE B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND B.BATCH_NO = T.BATCH_NO
           AND B.PROCESS_CDOE = T.PROCESS_CODE
           AND B.VALIDFLAG = '1'
           AND ({2} IS NULL OR
               B.CREATE_TIME >= TO_DATE({2}, 'YYYY-MM-DD HH24:MI:SS'))
           AND ({2} IS NULL OR
               B.CREATE_TIME <= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS')))
   AND ({4} IS NULL OR T.ORDER_NO LIKE '%' || {4} || '%')
   AND ({5} IS NULL OR T.ORDER_SEQ = {5})
   ORDER BY T.LOT_NO, T.JUDGE_STOVE_NO, T.BATCH_NO
		]]>
	</query>
	
	<query id="JdgQcmZbsInfo.temp" desc="">
		<![CDATA[
  SELECT C.*, A.ZBS_ID FROM QCM_ZBS_INFO A,
    QCM_ZG_JUGDE_APPLY C
    WHERE C.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
    AND C.BATCH_NO = A.BATCH_NO
    AND C.PROCESS_CODE = A.PROCESS_CODE
    AND C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
		]]>
	</query>


	<query id="JdgQcmZbsInfo.getxh" desc="">
		<![CDATA[
SELECT a.* FROM QCM_ZBS_INFO A, SLM_ORDER_HEAD C, SLM_ORDER_LINE D
WHERE NOT EXISTS(SELECT 1 FROM QCM_ZBS_CHEM_RESULT B
WHERE B.ZBS_ID = A.ZBS_ID)
AND D.ORD_LN_PK = A.ORD_LN_PK
AND D.ORD_PK = C.ORD_PK
AND C.ORDER_TYP_desc = '现货合同'
ORDER BY A.CREATE_TIME DESC
		]]>
	</query>
	
		<query id="JdgQcmZbsInfo.getLgSupp" desc="">
		<![CDATA[
	select DISTINCT T5.SUPP_CODE
	  from QCM_GP_JUDGE_APPLY T1, YDM_GP_INLIST T2, BUY_GP_ORDER T3,COM_BASE_SUPP T5
	 WHERE T1.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
	   AND T2.ORD_PK = T3.ORD_NO_PK
	   AND T3.SUPP_CODE=T5.SUPP_SHORT_NAME
	   AND T1.JUDGE_STOVE_NO = {0}
	  UNION ALL
	  SELECT DISTINCT T5.SUPP_CODE
	  from QCM_GP_JUDGE_APPLY T1, YDM_GP_INLIST T2, BUY_GP_ORDER T3,QCM_GP_JUDGE_CHANGE T4,COM_BASE_SUPP T5
	 WHERE T1.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
	   AND T2.ORD_PK = T3.ORD_NO_PK
	   AND T1.JUDGE_STOVE_NO=T4.JUDGE_STOVE_NO
	   AND T3.SUPP_CODE=T5.SUPP_SHORT_NAME
	   AND T4.JUDGE_STOVE_NO_GP = {0}
		]]>
	</query>
</queryMap>