<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质保书打印">
	<query id="QcmZbsQueryFrm.getSaleorg" desc="查询对应的销售组织">
		select SALE_ORG from
		SLM_BASE_SALE_AREA_TYP t where t.departid = ?
	</query>
	<query id="QcmZbsQueryFrm.getOrderInfoByBiltNo" desc="通过提单号查询合同信息">
	<![CDATA[ 
SELECT CASE
         WHEN T1.REALINVOICENO IS NOT NULL AND T1.REALINVOICENO1 IS NOT NULL THEN
          T1.REALINVOICENO || '/' || T1.REALINVOICENO1
         WHEN T1.REALINVOICENO IS NULL THEN
          T1.REALINVOICENO1
         WHEN T1.REALINVOICENO1 IS NULL THEN
          T1.REALINVOICENO
       END AS REALINVOICENO,
       T1.BILL_NO,
       T1.BILL_NO_SEQ,
       T1.ZBS_ORDER_NO,
       DECODE(T1.LOCK_BILL_FLAG, '1', '已锁定', '未锁定') LOCK_BILL_FLAG,
       T1.ORDER_NO || '/' || T1.ORDER_SEQ AS ORDER_SEQ_NO,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.DELIVERY_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.LANGUAGE_CODE,
       T1.LANGUAGE_NAME,
       T1.ZBS_TYPE_CODE,
       T1.ZBS_TYPE_DESC,
       T2.PRODUCCODE,
       T2.PRODUCNAME,
       T2.STEELCODE,
       T2.STEELNAME,
       T2.STD_CODE,
       T2.STD_NAME,
       T2.STD_STYLE,
       T2.STD_STYLE_DESC,
       T2.MODEL_CODE,
       T2.MODEL_DESC,
       T2.SPEC_CODE,
       T2.SPEC_NAME,
       T1.DELVRY_ADDR,
       TO_CHAR(T2.LEN_MIN, 'FM9990.00') AS LEN_MIN,
       TO_CHAR(T2.LEN_MAX, 'FM9990.00') AS LEN_MAX,
       T3.DELVRY_QTY,
       T3.ORDER_UNIT,
       T3.WGT_ESTMT,
       (SELECT T5.BASENAME
          FROM COM_BASE_INFO T5
         WHERE T5.BASECODE = T1.PLAN_TRANS_TYPE) AS ACT_TRANS_TYPE,
       T1.RECEIV_NO,
       T1.RECEIV_NM,
       T4.STLMT_UNIT_NO,
       T4.STLMT_UNIT_NM,
       T1.CUSTOMER_NO,
       T1.CUSTOMER_NM,
       NVL(T1.PLAN_WT, 0) AS PLAN_WT,
       NVL(T1.PLAN_NUM, 0) AS PLAN_NUM,
       --T1.ACT_WT,
       (SELECT NVL(SUM(T6.ACT_COUNT), 0)
          FROM YDM_ZC_LOADVEHICLE_MAT T6
         WHERE T6.BILL_NO = T1.BILL_NO
           AND T6.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK) AS ACT_NUM,
       (SELECT NVL(SUM(CASE
                         WHEN NVL(T6.PONDER_GROSS_WT, 0) != 0 THEN
                          T6.PONDER_GROSS_WT
                         WHEN NVL(T6.PONDER_GROSS_WT, 0) = 0 AND T.ORDER_UNIT = '吨' THEN
                          T6.SEND_NUM
                         ELSE
                          T6.ACT_WEIGHT
                       END),
                   0)
          FROM YDM_ZC_LOADVEHICLE_MAT T6, SLM_ORDER_LINE T
         WHERE T6.BILL_NO = T1.BILL_NO
           AND T6.ORD_LN_PK = T.ORD_LN_PK
           AND T6.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK) AS ACT_WT,
       T1.ZBS_FLAG,
       T1.ZBS_NUM,
       TO_CHAR(T1.ZBS_TIME, 'YYYY-MM-DD HH24:MI:SS') ZBS_TIME,
       (SELECT TO_CHAR(MAX(O.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
          FROM YDM_ZC_LOADVEHICLE O
         WHERE O.BILL_NO = T1.BILL_NO
           AND O.VALIDFLAG = '1') OUT_TIME,
       T5.ZBS_NAME,
       T5.ZBS_PATH,
       T2.FINAL_USER_DESC,
       T2.QUALITY_USER_DESC,
       NVL(DECODE(T1.ASK_ITEM_NO,
                  '',
                  (SELECT A.ASK_SUB_ITME_VAL
                     FROM SLM_ORDER_ADD_ASK A
                    WHERE A.ASK_SUB_ITME = '12100704'
                      AND A.ADD_ASK_NO = T2.ADD_ASK_NO),
                  T1.ASK_ITEM_NO),
           '1210070400000001') ASK_SUB_ITME_VAL,
       NVL(t1.METRIC_SYSTEM, '1') METRIC_SYSTEM,
       T1.LICENSE_NO,
       (SELECT MAX(C.PLINE_NAME)
          FROM YDM_ZC_BILL_C C
         WHERE C.BILL_NO = T1.BILL_NO
           AND C.ORDER_NO = T1.ORDER_NO
           AND C.ORDER_SEQ = T1.ORDER_SEQ) PLINE_NAME,
       (SELECT MAX(C.PLINE_CODE)
          FROM YDM_ZC_BILL_C C
         WHERE C.BILL_NO = T1.BILL_NO
           AND C.ORDER_NO = T1.ORDER_NO
           AND C.ORDER_SEQ = T1.ORDER_SEQ) PLINE_CODE,
       (SELECT O.CRAFT_NO
          FROM CRAFT_ORD_DESIGN O
         WHERE O.ORD_LN_PK = T1.ORD_LN_PK
           AND O.VALIDFLAG = '1') CRAFT_NO,
       (SELECT O.CRAFT_PATH
          FROM CRAFT_ORD_DESIGN O
         WHERE O.ORD_LN_PK = T1.ORD_LN_PK
           AND O.VALIDFLAG = '1') CRAFT_PATH,
       T1.CHECK_NO,
       CASE
         WHEN T1.SALE_ORG = '100102' THEN
          T1.BILL_NO || SUBSTR(T1.BILL_NO_SEQ, -3)
         ELSE
          T1.BILL_NO
       END BILL_NO1,T5.CREATE_NAME ZBS_CREATE_NAME,T5.CREATE_TIME ZBS_CREATE_TIME,T5.ZBS_EDITION
  FROM YDM_ZC_BILL_M           T1,
       SLM_ORDER_LINE          T2,
       SLM_ORDER_LINE_DELIVERY T3,
       SLM_ORDER_HEAD          T4,
       (
		SELECT
			BILL_NO,
			ORDER_NO,
			ORD_LN_DLY_PK,
			MAX( ZBS_PATH ) ZBS_PATH,
			MAX( ZBS_NAME ) ZBS_NAME,
			MAX( CREATE_NAME ) CREATE_NAME,
			MAX( CREATE_TIME ) CREATE_TIME,
			MAX( ZBS_EDITION ) ZBS_EDITION,
			ZBS_TYPE_DESC,
			LANGUAGE_NAME
		FROM
			QCM_ZBS_PATH
			where IS_VALID = '1'
		GROUP BY
			BILL_NO,
			ORDER_NO,
			ORD_LN_DLY_PK,
			ZBS_TYPE_DESC,
			LANGUAGE_NAME
		) T5
 WHERE T1.ORD_LN_PK = T2.ORD_LN_PK(+)
   AND T1.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK(+)
   AND T1.ORD_PK = T4.ORD_PK(+)
   	AND T1.BILL_NO = T5.BILL_NO ( + )
	AND T1.ORD_LN_DLY_PK = T5.ORD_LN_DLY_PK ( + )
	AND T1.LANGUAGE_NAME = T5.LANGUAGE_NAME ( + )
	AND T1.ZBS_TYPE_DESC = T5.ZBS_TYPE_DESC ( + )
   AND T1.BILL_NO || SUBSTR(T1.BILL_NO_SEQ, -3) || '&' LIKE
       ('%' || ? || '%')
   AND T1.ORDER_NO || '/' || T1.ORDER_SEQ || '&' LIKE ('%' || ? || '%')
   AND T1.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   AND T1.VALIDFLAG = '1'
   AND T1.RETURN_FLAG = '0'
   --AND (T1.BILL_STATUS >= '4' or
   --    T1.BILL_STATUS < '4' and T1.ISPRECLOS xxE <> '0')
   AND (T1.ZBS_SOURCE = '1' OR T1.PRODUCNAME = '连铸圆坯')
	]]>
	</query>

	<query id="QcmZbsQueryFrm.getJustStoveNoInfoByBiltNo" desc="通过提单号查询炉信息">
	<![CDATA[ 
	SELECT P1.BILL_NO,
       P1.JUDGE_STOVE_NO,
       P1.BATCH_NO,
       P1.GROUP_NO,
       P1.PRODUCCODE,
       P1.PRODUCNAME,
       P1.STD_CODE,
       P1.STD_NAME,
       P1.GRADECODE,
       P1.GRADENAME,
       P1.STEELCODE,
       P1.STEELNAME,
       P1.STD_STYLE,
       P1.STD_STYLE_DESC,
       P1.SPEC_CODE,
       P1.SPEC_NAME,
       P1.MODEL_CODE,
       P1.MODEL_DESC,
       P1.ACT_DIMATER,
       P1.ACT_HEIGHT,
       TO_CHAR(P1.ACT_LEN_MIN,'FM9990.00') AS ACT_LEN_MIN,
        TO_CHAR(P1.ACT_LEN_MAX,'FM9990.00') AS ACT_LEN_MAX,
       P1.ORD_PK,
       P1.ORD_LN_PK,
       P1.ORD_LN_DLY_PK,
       P1.ORDER_UNIT,
       P1.PRT_FLAG,
       NVL(P1.ACT_COUNT,0) AS ACT_COUNT,
        NVL(P1.ACT_WEIGHT,0) AS ACT_WEIGHT,
        NVL(P1.ACT_COUNT_LOAD,0) AS ACT_COUNT_LOAD,
        NVL(P1.ACT_WEIGHT_LOAD,0) AS ACT_WEIGHT_LOAD,
        NVL(P1.ACT_TALL_COUNT,0) AS ACT_TALL_COUNT,
        NVL(P1.ACT_TALL_WT,0) AS ACT_TALL_WT,
        NVL(P1.SEND_NUM,0) AS SEND_NUM,
       TO_NUMBER(P1.ACT_WEIGHT_LOADMAT)-TO_NUMBER(P1.ACT_WEIGHT_LOAD) ACT_WEIGHT_POST
  FROM (SELECT T.BILL_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.GROUP_NO,
               T.PRODUCCODE,
               T.PRODUCNAME,
               T.STD_CODE,
               T.STD_NAME,
               T.GRADECODE,
               T.GRADENAME,
               T.STEELCODE,
               T.STEELNAME,
               T.STD_STYLE,
               T.STD_STYLE_DESC,
               T.SPEC_CODE,
               T.SPEC_NAME,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.ACT_DIMATER,
               T.ACT_HEIGHT,
               T.ACT_LEN_MIN,
               T.ACT_LEN_MAX,
               T.ORD_PK,
               T.ORD_LN_PK,
               T.ORD_LN_DLY_PK,
               T2.ORDER_UNIT,
               T.PRT_FLAG,
               SUM(NVL(T.ACT_COUNT,0)) ACT_COUNT,
               SUM(NVL(T.ACT_WEIGHT,0)) ACT_WEIGHT,
               SUM(NVL(T1.ACT_COUNT,0)) ACT_COUNT_LOAD,
               SUM(NVL(T1.SEND_NUM,0)) SEND_NUM,
               SUM(CASE
                     WHEN T.EDIT_FLAG = '1' THEN
                      T.ACT_COUNT
                     ELSE
                      0
                   END) ACT_TALL_COUNT,
                   SUM(CASE
                     WHEN  T.EDIT_FLAG = '1' THEN
                      T.ACT_WEIGHT
                     ELSE
                      0
                   END) ACT_TALL_WT,
               SUM(NVL(CASE
                     WHEN T.PRT_FLAG = '0' THEN
                      T1.ACT_WEIGHT
                     ELSE
                      T1.PONDER_GROSS_WT
                   END,0)) ACT_WEIGHT_LOAD,
               SUM(NVL(T1.ACT_WEIGHT,0)) ACT_WEIGHT_LOADMAT
          FROM YDM_ZC_BILL_C T, YDM_ZC_LOADVEHICLE_MAT T1,SLM_ORDER_LINE_DELIVERY T2
         WHERE T.MAT_NO = T1.MAT_NO(+)
         AND T.BILL_NO=T1.BILL_NO(+)
         AND T.ORD_LN_DLY_PK=T2.ORD_LN_DLY_PK(+)
         AND T.BILL_NO = ?
         GROUP BY T.BILL_NO,
                  T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.GROUP_NO,
                  T.PRODUCCODE,
                  T.PRODUCNAME,
                  T.STD_CODE,
                  T.STD_NAME,
                  T.GRADECODE,
                  T.GRADENAME,
                  T.STEELCODE,
                  T.STEELNAME,
                  T.STD_STYLE,
                  T.STD_STYLE_DESC,
                  T.SPEC_CODE,
                  T.SPEC_NAME,
                  T.MODEL_CODE,
                  T.MODEL_DESC,
                  T.ACT_DIMATER,
                  T.ACT_HEIGHT,
                  T.ACT_LEN_MIN,
                  T.ACT_LEN_MAX,
                  T.ORD_PK,
                  T.ORD_LN_PK,
                  T.ORD_LN_DLY_PK,
                  T.PRT_FLAG,T2.ORDER_UNIT) P1
            ORDER BY P1.JUDGE_STOVE_NO,
       P1.BATCH_NO,
       P1.GROUP_NO
	]]>
	</query>

	<query id="QcmZbsQueryFrm.getJustStoveInfoByBillNo" desc="根据提单号查询炉信息">
	<![CDATA[ 
	SELECT T.BILL_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ORD_LN_PK
  FROM YDM_ZC_BILL_C T
 WHERE T.BILL_NO = ?
   AND T.VALIDFLAG = '1'
   AND T.RETURN_FLAG='0'
 GROUP BY T.BILL_NO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.GROUP_NO,
          T.PRODUCCODE,
          T.PRODUCNAME,
          T.STD_CODE,
          T.STD_NAME,
          T.GRADECODE,
          T.GRADENAME,
          T.STEELCODE,
          T.STEELNAME,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.ACT_DIMATER,
          T.ACT_HEIGHT,
          T.ACT_LEN_MIN,
          T.ACT_LEN_MAX,
          T.ORD_LN_PK
	]]>
	</query>
	<query id="QcmZbsQueryFrm.AddZbsC" desc="新增质保书拆分合同信息">
	<![CDATA[
	INSERT INTO QCM_ZBS_ORDER
  (ZBS_ID, ZBS_SEQ, ORD_LN_PK, ACT_COUNT, ORDER_NO, ORDER_SEQ, ZBS_NAME)
VALUES
  (?, (SELECT NVL(MAX(T.ZBS_SEQ),0)+1 FROM QCM_ZBS_ORDER T WHERE T.ZBS_ID=?), ?, ?, ?, ?, ?)
	]]>
	</query>
	<query id="QcmZbsQueryFrm.getOrderAskSub" desc="查询语言要求">
	<![CDATA[
	SELECT T.ASK_ITEM_NO,T.ASK_ITEM_DESC FROM SLM_BASE_ADD_ASK T WHERE T.ASK_P_ITEM_NO =? AND T.VALIDFLAG='1'
	]]>
	</query>
	<query id="QcmZbsQueryFrm.doQuerLanguage" desc="查询多语言质保书">
	<![CDATA[
	SELECT T.BILL_NO,
       T.LANGUAGE_CODE,
       T.LANGUAGE_NAME,
       T.ZBS_PATH,
       T.ORDER_NO,
       T.ORD_LN_DLY_PK,
       T.ZBS_NAME,
       T.METRIC_SYSTEM,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.ZBS_NUM,
       TO_CHAR(T.ZBS_TIME, 'YYYY-MM-DD HH24:MI:SS') ZBS_TIME,
       T.PRINT_NAME,
       T.ZBS_PATH_JG,
       T.ZBS_NAME_JG,
       T.ZBS_NUM_JG,
       TO_CHAR(T.ZBS_TIME_JG, 'YYYY-MM-DD HH24:MI:SS') ZBS_TIME_JG,
       T.PRINT_NAME_JG,
       T.ZBS_PATH_ZB,
       T.ZBS_NAME_ZB,
       T.ZBS_NUM_ZB,
       TO_CHAR(T.ZBS_TIME_ZB, 'YYYY-MM-DD HH24:MI:SS') ZBS_TIME_ZB,
       T.PRINT_NAME_ZB,
       T.ZBS_TYPE_CODE,
       T.ZBS_TYPE_DESC,
       T.ZBS_EDITION,
       DECODE(T.IS_VALID, '1', '有效', '0', '无效') IS_VALID,
       T.WASTE_NAME,
       TO_CHAR(T.WASTE_TIME, 'YYYY-MM-DD HH24:MI:SS') WASTE_TIME
  FROM QCM_ZBS_PATH T
 WHERE T.BILL_NO = ?
   AND T.ORD_LN_DLY_PK = ?
 ORDER BY T.ZBS_EDITION,T.LANGUAGE_CODE ASC
	]]>
	</query>
	<query id="QcmZbsQueryFrm.doQuerLanguage2" desc="查询多语言质保书">
	<![CDATA[
	SELECT * FROM  (SELECT T.BILL_NO,
       T.LANGUAGE_CODE,
       T.LANGUAGE_NAME,
       T.ZBS_PATH,
       T.ORDER_NO,
       T.ORD_LN_DLY_PK,
       T.ZBS_NAME,
       T.METRIC_SYSTEM,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.ZBS_NUM,
       TO_CHAR(T.ZBS_TIME, 'YYYY-MM-DD HH24:MI:SS') ZBS_TIME,
       T.PRINT_NAME,
       T.ZBS_TYPE_CODE,
       T.ZBS_TYPE_DESC,
       T.ZBS_EDITION,
       DECODE(T.IS_VALID, '1', '有效', '0', '无效',T.IS_VALID) IS_VALID,
       T.WASTE_NAME,
       TO_CHAR(T.WASTE_TIME, 'YYYY-MM-DD HH24:MI:SS') WASTE_TIME
  FROM QCM_ZBS_PATH T
 WHERE T.BILL_NO = ?
   AND T.ORD_LN_DLY_PK = ?
   AND T.IS_VALID = ?
 ORDER BY T.ZBS_EDITION DESC)
 WHERE  ZBS_EDITION =
 (SELECT MAX(ZBS_EDITION)
          FROM QCM_ZBS_PATH
         WHERE BILL_NO =  ?
           AND ORD_LN_DLY_PK = ?
           AND IS_VALID =  ?)
	]]>
	</query>

	<query id="QcmZbsQueryFrm.doQuerLanguage3" desc="查询多语言质保书">
		<![CDATA[
	SELECT
		T.BILL_NO,
		MAX( T.LANGUAGE_CODE ) LANGUAGE_CODE,
		T.LANGUAGE_NAME,
		MAX( T.ZBS_PATH ) ZBS_PATH,
		T.ORDER_NO,
		T.ORD_LN_DLY_PK,
		MAX( T.ZBS_NAME ) ZBS_NAME,
		T.METRIC_SYSTEM,
		MAX( T.CREATE_NAME ) CREATE_NAME,
		MAX( TO_CHAR( T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS' ) ) CREATE_TIME,
		MAX( T.ZBS_NUM ) ZBS_NUM,
		MAX( TO_CHAR( T.ZBS_TIME, 'YYYY-MM-DD HH24:MI:SS' ) ) ZBS_TIME,
		MAX( T.PRINT_NAME ) PRINT_NAME,
		MAX( T.ZBS_PATH_JG ) ZBS_PATH_JG,
		MAX( T.ZBS_NAME_JG ) ZBS_NAME_JG,
		MAX( T.ZBS_NUM_JG ) ZBS_NUM_JG,
		MAX( TO_CHAR( T.ZBS_TIME_JG, 'YYYY-MM-DD HH24:MI:SS' ) ) ZBS_TIME_JG,
		MAX( T.PRINT_NAME_JG ) PRINT_NAME_JG,
		MAX( T.ZBS_PATH_ZB ) ZBS_PATH_ZB,
		MAX( T.ZBS_NAME_ZB ) ZBS_NAME_ZB,
		MAX( T.ZBS_NUM_ZB ) ZBS_NUM_ZB,
		MAX( TO_CHAR( T.ZBS_TIME_ZB, 'YYYY-MM-DD HH24:MI:SS' ) ) ZBS_TIME_ZB,
		MAX( T.PRINT_NAME_ZB ) PRINT_NAME_ZB,
		MAX( T.ZBS_TYPE_CODE ) ZBS_TYPE_CODE,
		T.ZBS_TYPE_DESC,
		MAX( T.ZBS_EDITION ) ZBS_EDITION,
		MAX( DECODE( T.IS_VALID, '1', '有效', '0', '无效' ) ) IS_VALID,
		MAX( T.WASTE_NAME ) WASTE_NAME,
		MAX( TO_CHAR( T.WASTE_TIME, 'YYYY-MM-DD HH24:MI:SS' ) ) WASTE_TIME
	FROM
		QCM_ZBS_PATH T
	WHERE
		T.BILL_NO = ?
		AND T.ORD_LN_DLY_PK = ?
		AND T.IS_VALID = '1'
	GROUP BY
		T.BILL_NO,
		T.ORDER_NO,
		T.ORD_LN_DLY_PK,
		t.ZBS_TYPE_DESC,
		t.LANGUAGE_NAME,
		T.METRIC_SYSTEM
	]]>
	</query>

	<query id="QcmZbsQueryFrm.AddZbsLang" desc="新增质保书">
	<![CDATA[
	INSERT INTO QCM_ZBS_PATH
  (BILL_NO, LANGUAGE_CODE, LANGUAGE_NAME, ZBS_PATH, ORDER_NO, ORD_LN_DLY_PK, ZBS_NAME, METRIC_SYSTEM, CREATE_NAME, CREATE_TIME)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE)
	]]>
	</query>
	<query id="QcmZbsQueryFrm.AddZbsLangNEW" desc="新增质保书">
	<![CDATA[
	INSERT INTO QCM_ZBS_PATH
  (BILL_NO, LANGUAGE_CODE, LANGUAGE_NAME, ZBS_PATH, ORDER_NO, ORD_LN_DLY_PK, ZBS_NAME, METRIC_SYSTEM, CREATE_NAME, CREATE_TIME,ZBS_TYPE_CODE,ZBS_TYPE_DESC,ZBS_EDITION)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE,?,?,?)
	]]>
	</query>
	<query id="QcmZbsQueryFrm.AddZbsLangJG" desc="新增接箍质保书">
	<![CDATA[
	INSERT INTO QCM_ZBS_PATH
  (BILL_NO, LANGUAGE_CODE, LANGUAGE_NAME, ZBS_PATH_JG, ORDER_NO, ORD_LN_DLY_PK, ZBS_NAME_JG, METRIC_SYSTEM, CREATE_NAME, CREATE_TIME)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE)
	]]>
	</query>
	<query id="QcmZbsQueryFrm.AddZbsLangZB" desc="新增招标质保书">
	<![CDATA[
	INSERT INTO QCM_ZBS_PATH
  (BILL_NO, LANGUAGE_CODE, LANGUAGE_NAME, ZBS_PATH_ZB, ORDER_NO, ORD_LN_DLY_PK, ZBS_NAME_ZB, METRIC_SYSTEM, CREATE_NAME, CREATE_TIME)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE)
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.UpdateZbsLang" desc="修改质保书">
	<![CDATA[
	UPDATE QCM_ZBS_PATH T
   SET T.ZBS_PATH = ?, T.ZBS_NAME = ?
 WHERE T.BILL_NO = ?
   AND T.LANGUAGE_CODE = ?
   AND T.ORD_LN_DLY_PK = ?
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.UpdateZbsLangJG" desc="修改接箍质保书">
	<![CDATA[
	UPDATE QCM_ZBS_PATH T
   SET T.ZBS_PATH_JG = ?, T.ZBS_NAME_JG = ?
 WHERE T.BILL_NO = ?
   AND T.LANGUAGE_CODE = ?
   AND T.ORD_LN_DLY_PK = ?
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.UpdateZbsLangZB" desc="修改招标质保书">
	<![CDATA[
	UPDATE QCM_ZBS_PATH T
   SET T.ZBS_PATH_ZB = ?, T.ZBS_NAME_ZB = ?
 WHERE T.BILL_NO = ?
   AND T.LANGUAGE_CODE = ?
   AND T.ORD_LN_DLY_PK = ?
	]]>
	</query>
	<query id="QcmZbsQueryFrm.doQuerLanguage1" desc="查询多语言质保书">
	<![CDATA[
	SELECT ZBS_NAME 质保书,
       LANGUAGE_NAME 语言,
       DECODE(METRIC_SYSTEM, '0', '英制PSI', '2', '英制KSI', '1', '公制') 公英制方式,
       ZBS_PATH 质保书路径
  FROM QCM_ZBS_PATH
 WHERE BILL_NO = ?
   AND ORD_LN_DLY_PK = ?
   AND IS_VALID = '1'
   AND ZBS_TYPE_CODE IN ('410801','410806')
 ORDER BY LANGUAGE_CODE ASC
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.QueryCoupling" desc="查询接箍情况">
	<![CDATA[
	select t.* from MCH_TWISTINGLY_RESULT_D t WHERE T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ?
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.QueryCouplingByBillNo" desc="查询接箍情况">
	<![CDATA[
	select t.*
  from MCH_TWISTINGLY_RESULT_D t
 WHERE T.JUDGE_STOVE_NO || T.BATCH_NO IN
       (SELECT DISTINCT C.JUDGE_STOVE_NO || C.BATCH_NO
          FROM YDM_ZC_BILL_C C
         WHERE C.BILL_NO = ?)
 ORDER BY T.COUPLING_STOVE_NO, T.LOT_NO
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.getBaseInfo" desc="查询基础数据">
	<![CDATA[
	SELECT T.*
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   --AND T.MEMO = DECODE((SELECT MAX(T1.SUPPLY_UNIT)
                         --FROM YDM_ZC_BILL_M T1
                        --WHERE T1.BILL_NO = ?),
                       --'120501',
                      --'天管',
                      --'120504','天淮')
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.getZbsEdition" desc="质保书版本">
	<![CDATA[
	SELECT TO_CHAR(COUNT(*) + 1, 'FM000') zbsEdition
  FROM QCM_ZBS_PATH
 WHERE BILL_NO = ?
   AND ORD_LN_DLY_PK = ?
	]]>
	</query>
	
	<query id="QcmZbsQueryFrm.getOrderCE" desc="查询合同是否有打印CE标识">
	<![CDATA[
	SELECT COUNT(1) ACOUNT
  FROM SLM_ORDER_LINE B, CRAFT_ORD_DESIGN C, CRAFT_ORD_DESIGN_ADD_ASK D
 WHERE C.ORD_LN_PK = B.ORD_LN_PK
   AND C.DESGIN_KEY = D.DESGIN_KEY
   AND C.VALIDFLAG = '1'
   AND B.ORD_LN_PK = ?
   AND D.ASK_SUB_ITME_VAL_DESC LIKE '%CE标识%'
	]]>
	</query>
	<query id="QcmZbsQueryFrm.getOrderEAC" desc="查询合同是否有打印EAC标识">
	<![CDATA[
	SELECT COUNT(1) ACOUNT
  FROM SLM_ORDER_LINE B, CRAFT_ORD_DESIGN C, CRAFT_ORD_DESIGN_ADD_ASK D
 WHERE C.ORD_LN_PK = B.ORD_LN_PK
   AND C.DESGIN_KEY = D.DESGIN_KEY
   AND C.VALIDFLAG = '1'
   AND B.ORD_LN_PK = ?
   AND D.ASK_SUB_ITME_VAL_DESC LIKE '%EAC标识%'
	]]>
	</query>
	
	<query id = "QcmZbsQueryFrm.getZbsPath" desc = "规划院质保书查询路径">
	<![CDATA[
	SELECT 
           BILL_NO, LANGUAGE_CODE, LANGUAGE_NAME, ZBS_PATH, ORDER_NO, ORD_LN_DLY_PK, 
           ZBS_NAME, METRIC_SYSTEM, CREATE_NAME, CREATE_TIME, ZBS_NUM, ZBS_TIME, PRINT_NAME, 
           ZBS_PATH_JG, ZBS_NAME_JG, ZBS_NUM_JG, ZBS_TIME_JG, PRINT_NAME_JG, ZBS_PATH_ZB, ZBS_NAME_ZB, ZBS_NUM_ZB, 
           ZBS_TIME_ZB, PRINT_NAME_ZB, ZBS_TYPE_CODE, ZBS_TYPE_DESC, ZBS_EDITION, IS_VALID, WASTE_NAME, WASTE_TIME,IS_UPLOAD
             FROM QCM_ZBS_PATH T
            WHERE T.BILL_NO = ?
              AND T.ORD_LN_DLY_PK = ?
              AND T.ZBS_EDITION = ?
              AND T.IS_VALID = ?
	]]>
	</query>
	
	<query id = "QcmZbsQueryFrm.getZbsBase" desc = "规划院质保书查询">
	<![CDATA[
	  SELECT t1.ZBS_ID,
       t1.CUSTM_ORDER_NO,
       t1.STEELNAME,
       t1.STD_NAME,
       t1.STOVE_NO,
       t1.CUSTOMER_NM,
       t1.CUSTOMER_NO,
       t1.RECEIV_NM,
       t1.RECEIV_NO,
       t1.LOT_NO,
       y.ponder_no,
       y.act_dimater,
       y.act_height,
       y.act_len
  from QCM_ZBS_INFO T1
  LEFT JOIN (SELECT Y.ZBS_ID, y.judge_stove_no, y.batch_no,y.lot_no,m.ponder_no,
                   	sum(y.act_dimater)act_dimater,
                    sum(y.act_height)act_height,
                    sum(y.act_len*1000) act_len
               FROM YDM_ZC_BILL_C Y left join ydm_zc_loadvehicle_mat m on 
                y.bill_no = m.bill_no
                and 
                y.ord_ln_dly_pk = m.ord_ln_dly_pk
              WHERE Y.Bill_No = ?
              and y.ord_ln_dly_pk = ?
              GROUP BY Y.ZBS_ID, y.judge_stove_no, y.batch_no,y.lot_no,m.ponder_no
             HAVING sum(Y.ACT_COUNT) > 0
             ) Y
    ON T1.JUDGE_STOVE_NO = Y.JUDGE_STOVE_NO
   AND T1.BATCH_NO = Y.BATCH_NO
  LEFT JOIN QCM_ZBS_INFO_DJ Y3
    ON Y3.ZBS_ID = Y.ZBS_ID
  LEFT JOIN QCM_ZBS_INFO_JG Y4
    ON Y4.ZBS_ID = Y.ZBS_ID
 WHERE ((T1.ZBS_ID = Y3.DJ_ZBS_ID) OR (T1.ZBS_ID = Y4.JG_ZBS_ID) OR
       T1.ZBS_ID = Y.ZBS_ID)
 ORDER BY T1.JUDGE_STOVE_NO
	]]>
	</query>
	
</queryMap>