<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质保书打印">

	<query id="ZbsInfoInput.getBillInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
		SELECT T1.*,
       T4.ORDER_NO,
       T3.ORDER_SEQ,
       T3.STEELCODE,
       T3.STEELNAME,
       T4.CUSTOMER_NO,
       T4.CUSTOMER_NM,
       T2.RECEIV_NO,
       T2.RECEIV_NM,
       T3.STD_CODE,
       T3.STD_NAME,
       T3.PRODUCCODE,
       T3.PRODUCNAME,
       T3.ORDER_SPEC_CODE,
       T3.ORDER_SPEC_DESC,
       T3.MODEL_CODE,
       T3.MODEL_DESC,
       T3.OUTPUT_STD_NO,
       T3.LEN_NO,
       T3.USE_CODE,
       T3.USE_DESC,
       T4.CUSTM_ORDER_NO,
       T3.SPEC_CODE,
       T3.SPEC_NAME,
       T3.LEN_UNIT,
       T3.LEN_MIN,
       T3.LEN_MAX,
       T3.LEN_DESC
  FROM (SELECT T.JUDGE_STOVE_NO,
  			   T.STOVE_NO,
               T.BATCH_NO,
               T.BILL_NO,
               MAX(T.PLINE_CODE) PLINE_CODE,
               MAX(T.PLINE_NAME) PLINE_NAME,
               SUM(T.ACT_COUNT) ACT_COUNT,
               SUM(T.ACT_WEIGHT) ACT_WEIGHT,
               T.ORD_LN_PK,
               T.ORD_LN_DLY_PK
          FROM YDM_ZC_BILL_C T, YDM_ZC_BILL_M T2
         WHERE T.BILL_NO=T2.BILL_NO
           AND T2.SUPPLY_UNIT='120504'
           AND T.BILL_NO LIKE '%' || ? || '%' 
           AND T.JUDGE_STOVE_NO  LIKE '%' || ? || '%' 
           AND T.CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
           AND T.CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
           AND NOT EXISTS (SELECT 1
                  FROM QCM_ZBS_INFO Q
                 WHERE Q.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND Q.BATCH_NO = T.BATCH_NO)
         GROUP BY T.BILL_NO,
                  T.JUDGE_STOVE_NO,
                  T.STOVE_NO,
                  T.BATCH_NO,
                  T.ORD_LN_PK,
                  T.ORD_LN_DLY_PK) T1,
       SLM_ORDER_LINE_DELIVERY T2,
       SLM_ORDER_LINE T3,
       SLM_ORDER_HEAD T4
	 WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
	   AND T2.ORD_LN_PK = T3.ORD_LN_PK
	   AND T3.ORD_PK = T4.ORD_PK


	]]>
	</query>
	
	<query id="ZbsInfoInput.getPlineInfo" desc="获取最大质保书ID">
		<![CDATA[
		select t.pline_code,t.pline_name from com_base_pline t where t.pline_name like '%天淮%'
		]]>
	</query>

	<query id="ZbsInfoInput.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="ZbsInfoInput.addZbsInfo" desc="">
		<![CDATA[
			INSERT INTO QCM_ZBS_INFO(
				            ZBS_ID,STOVE_NO,JUDGE_STOVE_NO,BATCH_NO,PLINE_CODE,
							CHEM_RESULT,PHY_RESULT,FACE_RESULT,SPEC_RESULT,DETECT_RESULT,
							WATER_RESULT,PROCESS_RESULT,JUDGE_RESULT,CREATE_NAME,CREATE_TIME,
							ACT_COUNT,ACT_WEIGHT,ACT_THEORY_WEIGHT,STEELCODE,GRADECODE,
							STEELNAME,GRADENAME,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,
							USE_CODE,USE_DESC,CUSTM_ORDER_NO,SPEC_CODE,SPEC_NAME,
							LEN_UNIT,LEN_MIN,LEN_MAX,LEN_DESC,LEN_MIN_MAX_UNIT,
							ORD_LN_PK,ORD_LN_DLY_PK,IS_MANUAL,FLAG
							) 
				            VALUES
				            (?,?,?,?,?,
				            ?,?,?,?,?,
				            ?,?,?,?,SYSDATE,
				            ?,?,?,?,?,
				            ?,?,?,?,?,
				            ?,?,?,?,?,
				            ?,?,?,?,?,
				            ?,?,?,?,?,
				            ?,?,?,?,?,
				            ?,?,?,?,?,
				            ?,?,'1','1')
					          
		]]>
	</query>
	
	<query id="ZbsInfoInput.updateBillZbs" desc="获取最大质保书ID">
		<![CDATA[
			DECLARE
			BEGIN
			  UPDATE YDM_ZC_BILL_M T SET T.ZBS_SOURCE='1' WHERE T.BILL_NO=?;
			  UPDATE YDM_ZC_BILL_C T SET T.ZBS_ID=? WHERE T.BILL_NO=?;
			END;
		]]>
	</query>
	
	<query id="ZbsInfoInput.clearBillZbs" desc="获取最大质保书ID">
		<![CDATA[
			  UPDATE YDM_ZC_BILL_C T SET T.ZBS_ID=NULL WHERE T.ZBS_ID=?
		]]>
	</query>
	
	<query id="ZbsInfoInput.getZbsInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			SELECT ACT_COUNT,
	       ACT_THEORY_WEIGHT,
	       ACT_WEIGHT,
	       BATCH_NO,
	       CHEM_RESULT,
	       CREATE_NAME,
	       CREATE_TIME,
	       CUSTM_ORDER_NO,
	       CUSTOMER_NM,
	       CUSTOMER_NO,
	       CUT_NUM,
	       DELIVERY_STATE_CODE,
	       DELIVERY_STATE_NAME,
	       DETECT_RESULT,
	       DETECT_RESULT2,
	       FACE_RESULT,
	       FLAG,
	       GRADECODE,
	       GRADENAME,
	       JUDGE_RESULT,
	       JUDGE_STOVE_NO,
	       LEN_DESC,
	       LEN_MAX,
	       LEN_MIN,
	       LEN_MIN_MAX_UNIT,
	       LEN_NO,
	       LEN_UNIT,
	       LOT_NO,
	       LOT_NO_GROUP,
	       MEMO,
	       MODEL_CODE,
	       MODEL_DESC,
	       ORDER_NO,
	       ORDER_SEQ,
	       ORDER_SPEC_CODE,
	       ORDER_SPEC_DESC,
	       ORD_LN_DLY_PK,
	       ORD_LN_PK,
	       OUTPUT_STD_NO,
	       PHY_RESULT,
	       PLINE_CODE,
	       PROCESS_CODE,
	       PROCESS_DESC,
	       PROCESS_RESULT,
	       PRODUCCODE,
	       PRODUCNAME,
	       RECEIV_NM,
	       RECEIV_NO,
	       SPEC_CODE,
	       SPEC_NAME,
	       SPEC_RESULT,
	       STD_CODE,
	       STD_NAME,
	       STD_STYLE,
	       STD_STYLE_DESC,
	       STEELCODE,
	       STEELNAME,
	       STOVE_NO,
	       USE_CODE,
	       USE_DESC,
	       WATER_RESULT,
	       WO_ID,
	       ZBS_ADD_ASK_DESC,
	       ZBS_ID,
	       ZBS_MEMO,
	       ZBS_MEMO_JG
	  FROM QCM_ZBS_INFO
 		WHERE JUDGE_STOVE_NO LIKE '%' || ? || '%' 
		   AND CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
           AND CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
           AND IS_MANUAL='1'

	]]>
	</query>
	
		<query id="ZbsInfoInput.saveZbsInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			UPDATE QCM_ZBS_INFO T
			SET ACT_COUNT=?,
	       ACT_THEORY_WEIGHT=?,
	       ACT_WEIGHT=?,
	       BATCH_NO=?,
	       CHEM_RESULT=?,
	       CREATE_NAME=?,
	       CREATE_TIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
	       CUSTM_ORDER_NO=?,
	       CUSTOMER_NM=?,
	       CUSTOMER_NO=?,
	       CUT_NUM=?,
	       DELIVERY_STATE_CODE=?,
	       DELIVERY_STATE_NAME=?,
	       DETECT_RESULT=?,
	       DETECT_RESULT2=?,
	       FACE_RESULT=?,
	       FLAG=?,
	       GRADECODE=?,
	       GRADENAME=?,
	       JUDGE_RESULT=?,
	       JUDGE_STOVE_NO=?,
	       LEN_DESC=?,
	       LEN_MAX=?,
	       LEN_MIN=?,
	       LEN_MIN_MAX_UNIT=?,
	       LEN_NO=?,
	       LEN_UNIT=?,
	       LOT_NO=?,
	       LOT_NO_GROUP=?,
	       MEMO=?,
	       MODEL_CODE=?,
	       MODEL_DESC=?,
	       ORDER_NO=?,
	       ORDER_SEQ=?,
	       ORDER_SPEC_CODE=?,
	       ORDER_SPEC_DESC=?,
	       ORD_LN_DLY_PK=?,
	       ORD_LN_PK=?,
	       OUTPUT_STD_NO=?,
	       PHY_RESULT=?,
	       PLINE_CODE=?,
	       PROCESS_CODE=?,
	       PROCESS_DESC=?,
	       PROCESS_RESULT=?,
	       PRODUCCODE=?,
	       PRODUCNAME=?,
	       RECEIV_NM=?,
	       RECEIV_NO=?,
	       SPEC_CODE=?,
	       SPEC_NAME=?,
	       SPEC_RESULT=?,
	       STD_CODE=?,
	       STD_NAME=?,
	       STD_STYLE=?,
	       STD_STYLE_DESC=?,
	       STEELCODE=?,
	       STEELNAME=?,
	       STOVE_NO=?,
	       USE_CODE=?,
	       USE_DESC=?,
	       WATER_RESULT=?,
	       WO_ID=?,
	       ZBS_ADD_ASK_DESC=?,
	       ZBS_MEMO=?,
	       ZBS_MEMO_JG=?
	  WHERE ZBS_ID=?

	]]>
	</query>
	
	<query id="ZbsInfoInput.doDeleteZbsInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			DELETE QCM_ZBS_INFO T
			WHERE T.ZBS_ID=?
	]]>
	</query>
	
		<query id="ZbsInfoInput.DeleteChemInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			DELETE QCM_ZBS_CHEM_RESULT T
			WHERE T.ZBS_ID=?
			AND T.ZBS_SEQ=DECODE(?,NULL,T.ZBS_SEQ,?)
	]]>
	</query>
	
		<query id="ZbsInfoInput.DeletePhyInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			DELETE QCM_ZBS_PHY_RESULT T
			WHERE T.ZBS_ID=?
			AND T.ZBS_SEQ=DECODE(?,NULL,T.ZBS_SEQ,?)
	]]>
	</query>
	
	<query id="ZbsInfoInput.saveChemInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			INSERT INTO QCM_ZBS_CHEM_RESULT(
		        ZBS_ID,
		        ZBS_SEQ,
		        SAMPLE_NO,PROCESS_CODE,CHEM_TYPE,CHEM_NAME,CHEM_VALUE,
		        NK_MIN,NK_MAX,NK_QUALIFIED,JF_MIN,JF_MAX,
		        JF_QUALIFIED,ROUND,SAMPLE_ID,JUDGE_STOVE_NO)
		 VALUES( 
		        ?,(SELECT NVL(MAX(A.ZBS_SEQ), 0) + 1 FROM QCM_ZBS_CHEM_RESULT A WHERE A.ZBS_ID = ?),
		        ?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?)
	]]>
	</query>
	
	<query id="ZbsInfoInput.getChemInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			SELECT CHEM_NAME,
		       CHEM_TYPE,
		       CHEM_VALUE,
		       JF_MAX,
		       JF_MIN,
		       JF_QUALIFIED,
		       JUDGE_STOVE_NO,
		       NK_MAX,
		       NK_MIN,
		       NK_QUALIFIED,
		       PROCESS_CODE,
		       ROUND,
		       SAMPLE_ID,
		       SAMPLE_NO,
		       ZBS_ID,
		       ZBS_SEQ
		       FROM QCM_ZBS_CHEM_RESULT
		       WHERE ZBS_ID=?
	]]>
	</query>
	
		<query id="ZbsInfoInput.getPhyInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			SELECT AUDIT_NAME,
		       AUDIT_TIME,
		       AVERAGE,
		       AVERAGE_VALUE_F,
		       CHECK_NAME,
		       CHECK_TEMP,
		       CHECK_TIME,
		       DEVICE_NAME,
		       DEVICE_NO,
		       FORMUAL_NAME,
		       FORMUAL_NO,
		       HARDNESS_TYPE,
		       ISRCL,
		       IS_DEFECT,
		       IS_GOOD,
		       ITEM_CODE_F,
		       ITEM_CODE_S,
		       ITEM_CODE_W,
		       ITEM_NAME_F,
		       ITEM_NAME_S,
		       ITEM_NAME_W,
		       JF_ADD_CONDITION,
		       JF_ADD_JUDGE_BASIS,
		       JF_ADD_MAX,
		       JF_ADD_MIN,
		       JF_JUDGE_BASIS,
		       JF_MAX,
		       JF_MIN,
		       JF_TOL_QUALIFIED,
		       NK_ADD_CONDITION,
		       NK_ADD_JUDGE_BASIS,
		       NK_ADD_MAX,
		       NK_ADD_MIN,
		       NK_JUDGE_BASIS,
		       NK_MAX,
		       NK_MIN,
		       NK_TOL_QUALIFIED,
		       PHY_CODE,
		       PHY_CODE_DIR,
		       PHY_CODE_MAX,
		       PHY_CODE_MIN,
		       PHY_NAME,
		       PHY_NAME_DIR,
		       PHY_NAME_MAX,
		       PHY_NAME_MIN,
		       PROCESS_CODE,
		       REMARK,
		       SAMPLE_ID,
		       SAMPLE_NO,
		       SAMPLE_SIZE,
		       SAMPLE_STYLE,
		       SIZE_DESC,
		       VALUE1,
		       VALUE10,
		       VALUE11,
		       VALUE12,
		       VALUE13,
		       VALUE14,
		       VALUE15,
		       VALUE2,
		       VALUE3,
		       VALUE4,
		       VALUE5,
		       VALUE6,
		       VALUE7,
		       VALUE8,
		       VALUE9,
		       VALUE_F2,
		       VALUE_F3,
		       VALUE_KSI,
		       VALUE_PSI,
		       ZBS_ID,
		       ZBS_SEQ
		  FROM QCM_ZBS_PHY_RESULT
		       WHERE ZBS_ID=?
	]]>
	</query>
	
		<query id="ZbsInfoInput.savePhyInfo" desc="通过提单号查询合同信息">
	<![CDATA[ 
			INSERT INTO QCM_ZBS_PHY_RESULT(
		       ZBS_ID,ZBS_SEQ,
		       AUDIT_NAME,AUDIT_TIME,AVERAGE,AVERAGE_VALUE_F,CHECK_NAME,
		       CHECK_TEMP,CHECK_TIME,DEVICE_NAME,DEVICE_NO,FORMUAL_NAME,
		       FORMUAL_NO,HARDNESS_TYPE,ISRCL,IS_DEFECT,IS_GOOD,
		       ITEM_CODE_F,ITEM_CODE_S,ITEM_CODE_W,ITEM_NAME_F,ITEM_NAME_S,
		       ITEM_NAME_W,JF_ADD_CONDITION,JF_ADD_JUDGE_BASIS,JF_ADD_MAX,JF_ADD_MIN,
		       JF_JUDGE_BASIS,JF_MAX,JF_MIN,JF_TOL_QUALIFIED,NK_ADD_CONDITION,
		       NK_ADD_JUDGE_BASIS,NK_ADD_MAX,NK_ADD_MIN,NK_JUDGE_BASIS,NK_MAX,
		       NK_MIN,NK_TOL_QUALIFIED,PHY_CODE,PHY_CODE_DIR,PHY_CODE_MAX,
		       PHY_CODE_MIN,PHY_NAME,PHY_NAME_DIR,PHY_NAME_MAX,PHY_NAME_MIN,
		       PROCESS_CODE,REMARK,SAMPLE_ID,SAMPLE_NO,SAMPLE_SIZE,
		       SAMPLE_STYLE,SIZE_DESC,VALUE1,VALUE10,VALUE11,
		       VALUE12,VALUE13,VALUE14,VALUE15,VALUE2,
		       VALUE3,VALUE4,VALUE5,VALUE6,VALUE7,
		       VALUE8,VALUE9,VALUE_F2,VALUE_F3,VALUE_KSI,
		       VALUE_PSI)
		 VALUES( 
		        ?,(SELECT NVL(MAX(A.ZBS_SEQ), 0) + 1 FROM QCM_ZBS_PHY_RESULT A WHERE A.ZBS_ID = ?),
		        ?,SYSDATE,?,?,?,
				?,SYSDATE,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?,?,?,?,?,
				?)
	]]>
	</query>
	
</queryMap>