<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="下线库钢管入库管理">
	<query id="FrmPipeMagement.queryMatMent" desc="查询材料信息">
	<![CDATA[
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PLINE_CODE,
       --(SELECT T3.BASENAME
          --FROM COM_BASE_INFO T3
         --WHERE T3.BASECODE = T1.PRODUCT_FLAG)
          T1.PRODUCT_FLAG,
       --(SELECT T3.BASENAME
         -- FROM COM_BASE_INFO T3
        -- WHERE T3.BASECODE = T1.MAT_STATUS)
        T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T2.LOCATION_NO,
       (SELECT T5.LOCATION_NAME FROM YDM_BS_LOCATION T5 WHERE T5.LOCATION_NO = T2.LOCATION_NO)LOCATION_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.PIPMEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS LKACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.STD_NAME AS JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG,
       T1.ZBS_FLAG,
       T1.FIX_NUM,
       T1.SUPPLY_UNIT_CODE,
       T1.SUPPLY_UNIT
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 WHERE T1.MAT_NO = T2.MAT_NO
 AND T1.INSTOCK_DOC IS NULL
	]]>
	</query>
	<query id = "FrmPipeMagement.doQueryProduct" desc = "查询成品信息(按支)">
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.LOT_NO,
       T1.STOVE_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG,
       T1.MAT_NO,
       T1.MEASURING_SEQ,
       T1.ACT_LEN,
       T1.ACT_COUNT,
       T1.ACT_WEIGHT,
       T1.ZBS_FLAG,
       T1.PRO_NO，
        T1.PRO_ORDER_NO,
        T1.FIX_NUM
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 WHERE T1.MAT_NO = T2.MAT_NO
 AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 AND T1.BATCH_NO = '#BATCH_NO#'
 AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
 AND NVL(T1.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
 AND NVL(T1.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
 AND T1.BELONG_CODE = '#BELONG_CODE#'
 AND T1.MAT_STATUS = '#MAT_STATUS#'
 AND NVL(T1.FIX_NUM,'0') = NVL('#FIX_NUM#','0')
        AND NVL(T1.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
        AND NVL(T2.STORAGE_NO,'/') = NVL('#STORAGE_NO#','/')
        AND NVL(T2.LOCATION_NO,'/') = NVL('#LOCATION_NO#','/')
 AND T1.PRODUCT_FLAG = '801402'
 AND T1.LOCK_FLAG = '0'
 AND T1.MNG_LOCK_FLAG = '0'
 ORDER BY T1.MAT_NO ASC
	</query>
	<query id = "FrmPipeMagement.doQueryGoods" desc = "查询成品信息(按支)">
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.LOT_NO,
       T1.STOVE_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG,
       T1.MAT_NO,
       T1.MEASURING_SEQ,
       T1.ACT_LEN,
       T1.ACT_COUNT,
       T1.ACT_WEIGHT,
       T1.ZBS_FLAG,
       T1.PRO_NO,
        T1.FIX_NUM
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 WHERE T1.MAT_NO = T2.MAT_NO
 AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 AND T1.BATCH_NO = '#BATCH_NO#'
 AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
 AND NVL(T1.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
 AND NVL(T1.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
 AND T1.BELONG_CODE = '#BELONG_CODE#'
 AND NVL(T1.FIX_NUM,'0') = NVL('#FIX_NUM#','0'）
        AND NVL(T1.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
        AND NVL(T2.STORAGE_NO,'/') = NVL('#STORAGE_NO#','/')
        AND NVL(T2.LOCATION_NO,'/') = NVL('#LOCATION_NO#','/')
 AND T1.PRODUCT_FLAG = '801403'
 AND T1.MAT_STATUS = '80150301'
 AND T1.LOCK_FLAG = '0'
 AND T1.MNG_LOCK_FLAG = '0'
 ORDER BY T1.MAT_NO ASC
	</query>
<query id = "FrmPipeMagement.queryMatMentS" desc = "查询商品物料信息">
<![CDATA[
	
  SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T2.LOCATION_NO,
        (SELECT T5.LOCATION_NAME
          FROM YDM_BS_LOCATION T5
         WHERE T5.LOCATION_NO = T2.LOCATION_NO) LOCATION_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.PIPMEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS TDACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG,
       T1.PRO_NO,
       DECODE(T1.LOCK_LIKU,'0','审核通过','1','未审核')LOCK_LIKU,
       T1.IN_MOLD,
       T1.FIX_NUM,
       MAX(T1.SUPPLY_UNIT_CODE)SUPPLY_UNIT_CODE,
       MAX(T1.SUPPLY_UNIT)SUPPLY_UNIT
  FROM MAT_ZC_M T1,YDM_ZC_BUTTRESS T2,slm_order_head T5
 WHERE T1.Mat_No=T2.Mat_No
   and T1.Ord_Pk = T5.Ord_Pk(+)
   and T1.PRODUCT_FLAG = '801403'
   AND T1.MAT_STATUS = '80150301'
  
	]]>
</query>

	<query id="FrmPipeMagement.queryHistoryMatMent" desc="查询历史材料信息">
	<![CDATA[
	   SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.EVENT_ID,
       T1.EVENT_DESC,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MAX(T1.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.CREATE_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.FINISHPRO_MOLD,
       T1.IN_MOLD
  FROM MAT_ZC_TRACK T1
 WHERE T1.ORDER_NO || '&' LIKE '%' || ? || '%'
   AND T1.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
   AND T1.PRODUCT_FLAG || '&' LIKE '%' || ? || '%'
   AND T1.MAT_STATUS || '&' LIKE '%' || ? || '%'
   AND T1.BELONG_CODE || '&' LIKE '%' || ? || '%'
   AND T1.SPEC_NAME || '&' LIKE '%' || ? || '%'
        

	]]>
	</query>
<query id="FrmPipeMagement.queryHistoryMomner" desc="查询脱单历史材料信息">
	<![CDATA[
	   SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.EVENT_ID,
       T1.EVENT_DESC,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MAX(T1.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.CREATE_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.IN_MOLD,
       T1.FINISHPRO_MOLD
  FROM MAT_ZC_TRACK T1
 WHERE T1.ORDER_NO || '&' LIKE '%' || ? || '%'
   AND T1.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
   AND T1.PRODUCT_FLAG || '&' LIKE '%' || ? || '%'
   AND T1.MAT_STATUS || '&' LIKE '%' || ? || '%'
   AND T1.BELONG_CODE || '&' LIKE '%' || ? || '%'
   AND T1.SPEC_NAME || '&' LIKE '%' || ? || '%'
   AND T1.FILL_QUANTITY_FLAG = '0'
   AND T1.EVENT_ID = '900101'
	]]>
	</query>
	<query id = "insertOrderSeqNo.insertOrderSeqDivleyNo" desc = "新增交货行">
	DECLARE
  V_TIME          SLM_ORDER_LINE_DELIVERY.CREATE_TIME%TYPE := SYSDATE;
  V_DELIVERY_NO   SLM_ORDER_LINE_DELIVERY.DELIVERY_NO%TYPE := NULL;
  V_ORD_LN_DLY_PK SLM_ORDER_LINE_DELIVERY.ORD_LN_DLY_PK%TYPE := NULL;
BEGIN
  SELECT LPAD(MAX(T.DELIVERY_NO)+1,3,'0')
    INTO V_DELIVERY_NO
    FROM SLM_ORDER_LINE_DELIVERY T
   WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?;
  FOR MYROW IN (SELECT T.*
                  FROM SLM_ORDER_LINE_DELIVERY T
                 WHERE T.ORD_PK = ?
                   AND T.ORD_LN_PK = ?
                   AND T.ORD_LN_DLY_PK = ?) LOOP
                   V_ORD_LN_DLY_PK := MYROW.ORD_LN_PK|| LPAD(V_DELIVERY_NO, 3, '0');
    INSERT INTO SLM_ORDER_LINE_DELIVERY
      (EXTRA_FLAG,
       IS_ADD,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       DELVRY_BDATE,
       DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       TRANSIT_TYP,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       BE_DELIVERY_STATUS,
       BE_OBJ_STS_OP,
       DELIVERY_STATUS,
       OBJ_STS_OP,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ISLOCK,
       PICKUP_FLAG)
    VALUES
      (MYROW.EXTRA_FLAG,
       '2',
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       V_ORD_LN_DLY_PK,
       V_DELIVERY_NO,
       MYROW.DELVRY_BDATE,
       MYROW.DELVRY_EDATE,
       ?,
       MYROW.ORDER_UNIT,
       ?,
       MYROW.ENSU_TOTL_LEN,
       MYROW.RECEIV_NO,
       MYROW.RECEIV_NM,
       MYROW.DELVRY_ADDR,
       MYROW.AGENCY_FL,
       MYROW.RECEIV_ADDR,
       MYROW.TRANSIT_TYP,
       MYROW.TRANSIT_PLAN,
       MYROW.TRANSIT_MNY,
       MYROW.BE_DELIVERY_STATUS,
       '脱单补量',
       MYROW.DELIVERY_STATUS,
       '脱单补量',
       '1',
       ?,
       V_TIME,
       '',
       '',
       '',
       '',
       '0',
       MYROW.PICKUP_FLAG);
  END LOOP;
END;
	</query>
	<query id = "insertOrderSeqNo.updateFlag" desc = "修改补量标志">
	UPDATE MAT_ZC_TRACK T
   SET T.FILL_QUANTITY_FLAG = '1'
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
	</query>
	<query id = "insertOrderSeqNo.selectMatZcTrackO" desc = "查询脱单记录是否已补量">
	SELECT T.FILL_QUANTITY_FLAG
  FROM MAT_ZC_TRACK T
 WHERE T.ORD_PK = ?
   AND T.ORD_LN_PK = ?
   AND T.ORD_LN_DLY_PK = ?

	</query>
	<query id="FrmPipeMagement.queryMaterialSTyle" desc="查询材料类别信息">
	<![CDATA[
            SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = '8014'
   AND T.VALIDFLAG = '1'
 ORDER BY T.BASECODE  
	]]>
	</query>

	<query id="FrmPipeMagement.queryMaterialStatus" desc="查询材料状态信息">
	<![CDATA[
	 SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = '801502'
    OR T.SORTCODE = '801503'
   AND T.VALIDFLAG = '1'
 ORDER BY T.BASECODE    
	]]>
	</query>

<query id="FrmPipeMagement.queryMaterialStatusflag" desc="查询材料状态信息">
	<![CDATA[
	 SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE || '&' LIKE '%' || ? || '%'
   AND T.VALIDFLAG = '1'
 ORDER BY T.BASECODE    
	]]>
	</query>

	<query id="FrmPipeMagement.getDelivyInfo" desc="查询交货行信息">
	<![CDATA[
	 SELECT T1.ORDER_NO,
       T2.ORDER_SEQ,
       T3.DELIVERY_NO,
       T1.ORD_PK,
       T1.ORDER_TYP,
       T1.ORDER_TYP_DESC,
       T2.ORD_LN_PK,
       T3.ORD_LN_DLY_PK,
       (SELECT T6.BASENAME
          FROM COM_BASE_INFO T6
         WHERE T6.BASECODE = T3.DELIVERY_STATUS) DELIVERY_STATUS,
       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,
        DECODE(T2.DELVRY_RANGE_TPE,
              '%',
              '-' || T2.DELVRY_RANGE_MIN || '%' || ',+' ||
              T2.DELVRY_RANGE_MAX || '%',
              '(' || T2.DELVRY_RANGE_MIN || ',' || T2.DELVRY_RANGE_MAX || ')') DELVRY_RANGE_TPE,       
       T2.DELVRY_RANGE_MIN,
       T2.DELVRY_RANGE_MAX,
       T3.DELVRY_QTY,
       T3.ORDER_UNIT,
       T3.WGT_ESTMT,
       TO_CHAR(T3.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T4.PAYDOWNWEIGHT,
       T4.PAYDOWN_NUM,
       T4.PLANWEIGHT,
       T4.ORDERNUM AS PLAN_NUM,
       T2.LEN_MIN,
       T2.LEN_MAX,
       (SELECT PRIORITY_MEMO FROM PLN_SALEORD_PROC WHERE ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK AND ROWNUM = 1) PRIORITY_MEMO,
       (SELECT SUM(T5.ACT_COUNT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900101') MONOMER_BRANCH,
       (SELECT SUM(T5.ACT_WEIGHT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900101') MONOMER_TON,
       (SELECT SUM(T5.ACT_COUNT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID in ('900102','900103')) LIKU_BRANCH,
       (SELECT SUM(T5.ACT_WEIGHT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID in ('900102','900103')) LIKU_TON,
           T8.SEND_COUNT,
           T8.SEND_WEIGHT
  FROM SLM_ORDER_HEAD          T1,
       SLM_ORDER_LINE          T2,
       SLM_ORDER_LINE_DELIVERY T3,
       PLN_SALEORD           T4,
       (SELECT NVL(SUM(T7.ACT_COUNT), 0) SEND_COUNT,NVL(SUM(CASE
                        WHEN T7.PONDER_NO IS NULL THEN
                          NVL(T7.ACT_WEIGHT, 0)
                         ELSE
                         NVL(T7.PONDER_GROSS_WT, 0)
                      END),
                  0)SEND_WEIGHT,
                  T7.ORD_LN_DLY_PK
                 FROM YDM_ZC_OUTLIST T7 WHERE T7.OUTSTOCK_TYPE_CODE = '800805' GROUP BY T7.ORD_PK,T7.ORD_LN_PK,T7.ORD_LN_DLY_PK)T8
 WHERE T3.ORD_PK = T1.ORD_PK
   AND T3.ORD_LN_PK = T2.ORD_LN_PK
   AND T3.ORD_LN_DLY_PK = T4.ORD_LN_DLY_PK(+)
   AND T3.ORD_LN_DLY_PK = T8.ORD_LN_DLY_PK(+)
   AND T1.ORDER_NO || '&' LIKE '%' || ? || '%'
   AND T2.PRODUCCODE || '&' LIKE '%' || ? || '%'
   AND T2.STEELCODE || '&' LIKE '%' || ? || '%'
   AND T2.STD_CODE || '&' LIKE '%' || ? || '%'
   AND T2.STD_STYLE || '&' LIKE '%' || ? || '%'
   AND T2.MODEL_CODE || '&' LIKE '%' || ? || '%'
   AND T2.SPEC_CODE || '&' LIKE '%' || ? || '%'
   AND T1.VALIDFLAG = '1'
   AND T2.VALIDFLAG = '1'
   AND T3.VALIDFLAG = '1'
   AND T1.ORDER_TYP NOT IN('120103','120104')
	]]>
	</query>

	<query id="FrmPipeMagement.getMageStatusByMononer" desc="查询物料信息状态">
	<![CDATA[
     SELECT T1.MAT_NO,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.LOT_NO,
       T1.STOVE_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.MAT_SQE_NO,
       T1.SAMPLE_FLAG,
       T1.CUTTING_FLAG,
       T1.ORIGIN_MAT_NO,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.INPUT_MATERIAL_NAME,
       T1.INPUT_MATERIAL_NO,
       T1.INPUT_ORIGIN_CODE,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.GRADECODE,
       T1.GRADENAME,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_NO1,
       T1.PRO_ORDER_ID,
       T1.PRO_ORDER_ID1,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.CRAF_NO,
       T1.PROCESS_CDOE,
       T1.PROCESS_DESC,
       T1.NEXT_PROCESS_CDOE,
       T1.NEXT_PROCESS_DESC,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.MAT_ORIGIN_CODE,
       T1.MAT_ORIGIN_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       T1.LEN_MIN,
       T1.LEN_MAX,
       T1.TARG_DIMATER,
       T1.TARG_HEIGHT,
       T1.TARG_LEN_MIN,
       T1.TARG_LEN_MAX,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.ACT_COUNT,
       T1.ACT_WEIGHT,
       T1.ACT_THEORY_WEIGHT,
       T1.MEASURE_FLAG,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.PACK_FLAG,
       T1.PACK_TYPE_CODE,
       T1.PACK_TYPE_NAME,
       T1.PACK_NO,
       T1.PACK_TIME,
       T1.PACK_MAT_WT,
       T1.MAT_GROSS_WT,
       T1.MAT_GOWHERE_CODE,
       T1.MAT_GOWHERE_NAME,
       T1.COOL_HOT_FLAG,
       T1.MAT_RETURN_FLAG,
       T1.HEAT_TREAT_NO,
       T1.POST_FLAG,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_RSN_CODE,
       T1.MNG_LOCK_TIME,
       T1.MNG_LOCK_MAKER,
       T1.MNG_LOCK_REMARK,
       T1.LOCK_RSN_CODE,
       T1.LOCK_TIME,
       T1.LOCK_MAKER,
       T1.LOCK_REMARK,
       T1.UNLOCK_TIME,
       T1.UNLOCK_MAKER,
       T1.UNLOCK_REMARK,
       T1.OLD_ORDER_NO,
       T1.OLD_ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO,
       T1.OLD_MATERIAL_NO,
       T1.OLD_MATERIAL_NAME,
       T1.REMAIN_RSN_CODE,
       T1.REMAIN_JUGDE_TIME,
       T1.REMAIN_JUGDE_MAKER,
       T1.REMAIN_JUGDE_CODE,
       T1.REMAIN_REMARK,
       T1.JUGDE_APPLY_FLAG,
       T1.JUGDE_APPLY_CODE,
       T1.JUGDE_APPLY_TIME,
       T1.JUGDE_SCAN_TIME,
       T1.FACE_RESULT_CODE,
       T1.FACE_RESULT_TIME,
       T1.FACE_MAKER,
       T1.SPEC_RESULT_CODE,
       T1.SPEC_RESULT_TIME,
       T1.SPEC_MAKER,
       T1.CHEM_RESULT_CODE,
       T1.CHEM_RESULT_TIME,
       T1.CHEM_MAKER,
       T1.PHY_RESULT_CODE,
       T1.PHY_RESULT_TIME,
       T1.PHY_MAKER,
       T1.DETECT_REPORT_NO,
       T1.DETECT_RESULT_CODE,
       T1.WPRESSURE_REPORT_NO,
       T1.WPRESSURE_RESULT_CODE,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       T1.JUDGE_RESULT_TIME,
       T1.JUDGE_MAKER,
       T1.BUG_NO,
       T1.BUG_DEAL,
       T1.REPAIR_FLAG,
       T1.REPAIR_REMARK,
       T1.SAMPLING_FLAG,
       T1.SAMPLING_TYPE,
       T1.SAMPLING_NO,
       T1.CHECKOUT_NO,
       T1.CHEM_STCHECK_NO,
       T1.CHEM_PROCHECK_NO,
       T1.SH_CHECK_NO,
       T1.COME_PROC_FLAG,
       T1.CONFM_FLAG,
       T1.INSTOCK_FLAG,
       T1.INSTOCK_TIME,
       T1.OUTSTOCK_TIME,
       T1.PRO_BC,
       T1. PRO_BZ,
       T1.RPO_TIME,
       T1.BAR_CODE,
       T1.BEGINNING_FLAG,
       T1.MEMO,
       T1.CREATE_NAME,
       T1.CREATE_TIME,
       T1.UPDATE_NAME,
       T1.UPDATE_TIME,
       T1.REQ_BL_ID,
       T1.IF_BATCHED_JG,
       T1.COUPCUT_BATCH_ID,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.OLD_ORD_PK,
       T1.OLD_ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK from  
(SELECT T1.MAT_NO,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.LOT_NO,
       T1.STOVE_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.MAT_SQE_NO,
       T1.SAMPLE_FLAG,
       T1.CUTTING_FLAG,
       T1.ORIGIN_MAT_NO,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.INPUT_MATERIAL_NAME,
       T1.INPUT_MATERIAL_NO,
       T1.INPUT_ORIGIN_CODE,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.GRADECODE,
       T1.GRADENAME,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_NO1,
       T1.PRO_ORDER_ID,
       T1.PRO_ORDER_ID1,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.CRAF_NO,
       T1.PROCESS_CDOE,
       T1.PROCESS_DESC,
       T1.NEXT_PROCESS_CDOE,
       T1.NEXT_PROCESS_DESC,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.MAT_ORIGIN_CODE,
       T1.MAT_ORIGIN_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       T1.LEN_MIN,
       T1.LEN_MAX,
       T1.TARG_DIMATER,
       T1.TARG_HEIGHT,
       T1.TARG_LEN_MIN,
       T1.TARG_LEN_MAX,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.ACT_COUNT,
       T1.ACT_WEIGHT,
       T1.ACT_THEORY_WEIGHT,
       T1.MEASURE_FLAG,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.PACK_FLAG,
       T1.PACK_TYPE_CODE,
       T1.PACK_TYPE_NAME,
       T1.PACK_NO,
       T1.PACK_TIME,
       T1.PACK_MAT_WT,
       T1.MAT_GROSS_WT,
       T1.MAT_GOWHERE_CODE,
       T1.MAT_GOWHERE_NAME,
       T1.COOL_HOT_FLAG,
       T1.MAT_RETURN_FLAG,
       T1.HEAT_TREAT_NO,
       T1.POST_FLAG,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_RSN_CODE,
       T1.MNG_LOCK_TIME,
       T1.MNG_LOCK_MAKER,
       T1.MNG_LOCK_REMARK,
       T1.LOCK_RSN_CODE,
       T1.LOCK_TIME,
       T1.LOCK_MAKER,
       T1.LOCK_REMARK,
       T1.UNLOCK_TIME,
       T1.UNLOCK_MAKER,
       T1.UNLOCK_REMARK,
       T1.OLD_ORDER_NO,
       T1.OLD_ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO,
       T1.OLD_MATERIAL_NO,
       T1.OLD_MATERIAL_NAME,
       T1.REMAIN_RSN_CODE,
       T1.REMAIN_JUGDE_TIME,
       T1.REMAIN_JUGDE_MAKER,
       T1.REMAIN_JUGDE_CODE,
       T1.REMAIN_REMARK,
       T1.JUGDE_APPLY_FLAG,
       T1.JUGDE_APPLY_CODE,
       T1.JUGDE_APPLY_TIME,
       T1.JUGDE_SCAN_TIME,
       T1.FACE_RESULT_CODE,
       T1.FACE_RESULT_TIME,
       T1.FACE_MAKER,
       T1.SPEC_RESULT_CODE,
       T1.SPEC_RESULT_TIME,
       T1.SPEC_MAKER,
       T1.CHEM_RESULT_CODE,
       T1.CHEM_RESULT_TIME,
       T1.CHEM_MAKER,
       T1.PHY_RESULT_CODE,
       T1.PHY_RESULT_TIME,
       T1.PHY_MAKER,
       T1.DETECT_REPORT_NO,
       T1.DETECT_RESULT_CODE,
       T1.WPRESSURE_REPORT_NO,
       T1.WPRESSURE_RESULT_CODE,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       T1.JUDGE_RESULT_TIME,
       T1.JUDGE_MAKER,
       T1.BUG_NO,
       T1.BUG_DEAL,
       T1.REPAIR_FLAG,
       T1.REPAIR_REMARK,
       T1.SAMPLING_FLAG,
       T1.SAMPLING_TYPE,
       T1.SAMPLING_NO,
       T1.CHECKOUT_NO,
       T1.CHEM_STCHECK_NO,
       T1.CHEM_PROCHECK_NO,
       T1.SH_CHECK_NO,
       T1.COME_PROC_FLAG,
       T1.CONFM_FLAG,
       T1.INSTOCK_FLAG,
       T1.INSTOCK_TIME,
       T1.OUTSTOCK_TIME,
       T1.PRO_BC,
       T1. PRO_BZ,
       T1.RPO_TIME,
       T1.BAR_CODE,
       T1.BEGINNING_FLAG,
       T1.MEMO,
       T1.CREATE_NAME,
       T1.CREATE_TIME,
       T1.UPDATE_NAME,
       T1.UPDATE_TIME,
       T1.REQ_BL_ID,
       T1.IF_BATCHED_JG,
       T1.COUPCUT_BATCH_ID,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.OLD_ORD_PK,
       T1.OLD_ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 WHERE T1.MAT_NO = T2.MAT_NO
   AND T1.BELONG_CODE = '#BELONG_CODE#'
   AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T1.BATCH_NO = '#BATCH_NO#'
   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND NVL(T1.SPEC_CODE,'/') = NVL('#SPEC_CODE#','/')
   --AND T1.ACT_DIMATER = '#ACT_DIMATER#'
   --AND T1.ACT_HEIGHT = '#ACT_HEIGHT#'
   --AND T1.ACT_LEN_MIN = '#ACT_LEN_MIN#'
   --AND T1.ACT_LEN_MAX = '#ACT_LEN_MAX#'
   AND T1.PRODUCCODE = '#PRODUCCODE#'
   AND T1.STEELCODE = '#STEELCODE#'
   --AND NVL(T1.STD_CODE,'/') = NVL('#STD_CODE#','/')
   AND T1.ORDER_NO = '#ORDER_NO#'
   AND T1.ORDER_SEQ = '#ORDER_SEQ#'
   AND nvl(T1.ORDER_SEQ_NO,'/') = nvl('#ORDER_SEQ_NO#','/')
   AND T1.ORD_PK = '#ORD_PK#'
   AND T1.ORD_LN_PK = '#ORD_LN_PK#'
   AND nvl(T1.ORD_LN_DLY_PK,'/') = nvl('#ORD_LN_DLY_PK#','/')
   AND NVL(T2.STORAGE_NO,'/') = NVL('#STORAGE_NO#','/')
   AND NVL(T2.LOCATION_NO,'/') = NVL('#LOCATION_NO#','/')
   AND T1.MODEL_CODE='#MODEL_CODE#'
   AND NVL(T1.STD_STYLE,'/')=NVL('#STD_STYLE#','/')
   AND NVL(T1.MEMO,'/')=NVL('#MEMO#','/')
   AND NVL(T1.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
   AND T1.INSTOCK_DOC IS NULL
   AND NVL(T1.FIX_NUM,'0') = NVL('#FIX_NUM#','0')
   AND NVL(T1.JUDGE_RESULT_CODE,'/')=NVL('#JUDGE_RESULT_CODE#','/') order by T1.MAT_NO desc)T1 where rownum<?
	]]>
	</query>

	<query id="FrmPipeMagement.updateMaterialStatus" desc="修改材料状态信息">
	<![CDATA[
	 UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '',
       T1.ORDER_SEQ         = '',
       T1.ORDER_SEQ_NO      = '',
       T1.PRODUCT_FLAG      = '801402',
       T1.MAT_STATUS        = '80150204',
       T1.ORD_PK            = '',
       T1.ORD_LN_PK         = '',
       T1.ORD_LN_DLY_PK     = '',
       T1.OLD_ORDER_NO      = T1.ORDER_NO,
       T1.OLD_ORDER_SEQ     = T1.ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO  = T1.ORDER_SEQ_NO,
       T1.OLD_ORD_PK        = T1.ORD_PK,
       T1.OLD_ORD_LN_PK     = T1.ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK,
       T1.OLD_MATERIAL_NO   = T1.MATERIAL_NO,
       T1.OLD_MATERIAL_NAME = T1.MATERIAL_NAME
 WHERE T1.BELONG_CODE = '#BELONG_CODE#'
   AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T1.BATCH_NO = '#BATCH_NO#'
   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND T1.SPEC_CODE = '#SPEC_CODE#'
   AND T1.ACT_DIMATER = '#ACT_DIMATER#'
   AND T1.ACT_HEIGHT = '#ACT_HEIGHT#'
   AND T1.ACT_LEN_MIN = '#ACT_LEN_MIN#'
   AND T1.ACT_LEN_MAX = '#ACT_LEN_MAX#'
   AND T1.PRODUCCODE = '#PRODUCCODE#'
   AND T1.STEELCODE = '#STEELCODE#'
   
   AND T1.ORDER_NO = '#ORDER_NO#'
   AND T1.ORDER_SEQ = '#ORDER_SEQ#'
   AND nvl(T1.ORDER_SEQ_NO,'/') = nvl('#ORDER_SEQ_NO#','/')
   AND T1.ORD_PK = '#ORD_PK#'
   AND T1.ORD_LN_PK = '#ORD_LN_PK#'
   AND nvl(T1.ORD_LN_DLY_PK,'/') = nvl('#ORD_LN_DLY_PK#','/')
   AND T1.MODEL_CODE='#MODEL_CODE#'
   AND NVL(T1.STD_STYLE,'/')='#STD_STYLE#'
   AND NVL(T1.MEMO,'/')=NVL('#MEMO#','/')
   AND NVL(T1.JUDGE_RESULT_CODE,'/')=NVL('#JUDGE_RESULT_CODE#','/')
   --AND T1.MAT_NO IN (SELECT DISTINCT (T1.MAT_NO)
                      -- FROM YDM_ZC_BUTTRESS T2
                      --WHERE T2.STORAGE_NO = '#STORAGE_NO#'
                      AND T1.MAT_NO = '#MAT_NO#'   
	]]>
	</query>

	<query id="FrmPipeMagement.addMatZcTrack" desc="增加钢管物料跟踪履历表">
	<![CDATA[
     INSERT INTO MAT_ZC_TRACK(
        RESUME_SEQ,
        EVENT_ID,
        EVENT_DESC,
        FORM_NAME,
        CALL_FUNC_CODING,
        KEYVALUE_1,
        KEYVALUE_1_DESC,
        KEYVALUE_2,
        KEYVALUE_2_DESC2,
        KEYVALUE_3,
        KEYVALUE_3_DESC3,
        KEYVALUE_4,
        KEYVALUE_4_DESC4,
        KEYVALUE_5,
        KEYVALUE_5_DESC5,
        KEYVALUE_6,
        KEYVALUE_6_DESC6,
        KEYVALUE_7,
        KEYVALUE_7_DESC7,
        MAT_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        PRO_ORDER_NO,
        PRO_ORDER_ID,
        PRO_ORDER_NO1,
        PRO_ORDER_ID1,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        OLD_ORD_PK,
        OLD_ORD_LN_PK,
        OLD_ORD_LN_DLY_PK,
        OLD_ORDER_NO,
        OLD_ORDER_SEQ,
        OLD_ORDER_SEQ_NO,
        BELONG_CODE,
        BELONG_NAME,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        PRO_NO,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT)
 VALUES( 
        '#RESUME_SEQ#',
        '#EVENT_ID#',
        '#EVENT_DESC#',
        '#FORM_NAME#',
        '#CALL_FUNC_CODING#',
        '#KEYVALUE1#',
        '#KEYVALUE1_DESC#',
        '#KEYVALUE2#',
        '#KEYVALUE2_DESC2#',
        '#KEYVALUE3#',
        '#KEYVALUE3_DESC3#',
        '#KEYVALUE4#',
        '#KEYVALUE4_DESC4#',
        '#KEYVALUE5#',
        '#KEYVALUE5_DESC5#',
        '#KEYVALUE6#',
        '#KEYVALUE6_DESC6#',
        '#KEYVALUE7#',
        '#KEYVALUE7_DESC7#',
        '#MAT_NO#',
        '#PRODUCT_FLAG#',
        '#MAT_STATUS#',
        '#LOT_NO#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#BATCH_GROUD_NO#',
        '#MATERIAL_NO#',
        '#MATERIAL_NAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#ACT_LEN#',
        '#ACT_LEN_MIN#',
        '#ACT_LEN_MAX#',
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        '#ACT_THEORY_WEIGHT#',
        '#PRO_ORDER_NO#',
        '#PRO_ORDER_ID#',
        '#PRO_ORDER_NO1#',
        '#PRO_ORDER_ID1#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORD_LN_DLY_PK#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#ORDER_SEQ_NO#',
        '#OLD_ORD_PK#',
        '#OLD_ORD_LN_PK#',
        '#OLD_ORD_LN_DLY_PK#',
        '#OLD_ORDER_NO#',
        '#OLD_ORDER_SEQ#',
        '#OLD_ORDER_SEQ_NO#',
        '#BELONG_CODE#',
        '#BELONG_NAME#',
        '#MEMO#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        #PRO_NO#,
        '#SUPPLY_UNIT_CODE#',
        '#SUPPLY_UNIT#')
	]]>
	</query>


	<query id="FrmPipeMagement.Liku" desc="利库修改材料状态信息">
	<![CDATA[
	  UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '#ORDER_NO#',
       T1.ORDER_SEQ         = '#ORDER_SEQ#',
       T1.ORDER_SEQ_NO      = '#ORDER_SEQ_NO#',
       T1.PRODUCT_FLAG      = '801403',
       T1.MAT_STATUS        = '80150301',
       T1.ORD_PK            = '#ORD_PK#',
       T1.ORD_LN_PK         = '#ORD_LN_PK#',
       T1.ORD_LN_DLY_PK     = '#ORD_LN_DLY_PK#',
       T1.BELONG_CODE       = '#NEWBELONG_CODE#',
       T1.BELONG_NAME       = '#NEWBELONG_NAME#',
       T1.STD_CODE          = '#STD_CODE#',
       T1.STD_NAME          = '#STD_NAME#',
       T1.PRO_NO            = ?,
       T1.LOCK_LIKU         = ?,
       T1.LOCK_FLAG         = ?,
       T1.LOCK_ID           = ?
 WHERE 
    T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T1.BATCH_NO = '#BATCH_NO#'
   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   --AND (T1.MAT_NO IN (SELECT DISTINCT (T1.MAT_NO)
    --                   FROM YDM_ZC_BUTTRESS T2
    --                  WHERE T2.STORAGE_NO = '#STORAGE_NO#'
    --                  AND T2.LOCATION_NO = '#LOCATION_NO#')
     --                 AND T1.MAT_NO=?)
   and T1.MAT_NO=?
    --#conditions#   
	]]>
	</query>
	<query id = "FrmPipeMagement.LikuSeq" desc = "按支利库">
	UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '#ORDER_NO#',
       T1.ORDER_SEQ         = '#ORDER_SEQ#',
       T1.ORDER_SEQ_NO      = '#ORDER_SEQ_NO#',
       T1.PRODUCT_FLAG      = '801403',
       T1.MAT_STATUS        = '80150301',
       T1.ORD_PK            = '#ORD_PK#',
       T1.ORD_LN_PK         = '#ORD_LN_PK#',
       T1.ORD_LN_DLY_PK     = '#ORD_LN_DLY_PK#',
       T1.BELONG_CODE       = '#BELONG_CODE#',
       T1.BELONG_NAME       = '#BELONG_NAME#',
       T1.STD_CODE          = '#STD_CODE#',
       T1.STD_NAME          = '#STD_NAME#',
       T1.PRO_NO            = '#PRO_NO#',
       T1.LOCK_LIKU         = '#LOCK_LIKU#',
       T1.LOCK_FLAG         = '#LOCK_FLAG#',
       T1.LOCK_ID           = '#LOCK_ID#'
 WHERE 
    T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T1.BATCH_NO = '#BATCH_NO#'
   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND T1.MAT_NO IN (SELECT DISTINCT (T1.MAT_NO)
                       FROM YDM_ZC_BUTTRESS T2
                      WHERE T2.STORAGE_NO = '#STORAGE_NO#')
                      AND T1.MAT_NO='#MAT_NO#'
	</query>
<!-- 
T1.PRODUCCODE        = '#PRODUCCODE#' , 
       T1.PRODUCNAME        = '#PRODUCNAME#' , 
       T1.STEELCODE        = '#STEELCODE#' , 
       T1.STEELNAME        = '#STEELNAME#' , 
       T1.SPEC_CODE        = '#SPEC_CODE#' , 
       T1.SPEC_NAME        = '#SPEC_NAME#' , 
       T1.MODEL_CODE        = '#MODEL_CODE#' , 
       T1.MODEL_DESC        = '#MODEL_DESC#' , 
       T1.STD_CODE        = '#STD_CODE#' , 
       T1.STD_NAME        = '#STD_NAME#' , 
       T1.STD_STYLE        = '#STD_STYLE#' , 
       T1.STD_STYLE_DESC        = '#STD_STYLE_DESC#',
       T1.ACT_LEN_MIN      ='#ACT_LEN_MIN#',
       T1.ACT_LEN_MAX      ='#ACT_LEN_MAX#'
 -->

	<query id="FrmPipeMagement.queryMaterialStatus_1" desc="查询材料状态信息">
	<![CDATA[
	 SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = '801502'
    OR (T.SORTCODE = '801503' AND T.BASECODE != '80150303')
   AND T.VALIDFLAG = '1'
   ORDER BY T.BASECODE      
	]]>
	</query>

	<query id="FrmPipeMagement.getDelivyInfoByKey" desc="通过交货主键查询交货行信息">
	<![CDATA[
	 SELECT
	    T1.SUPPLY_UNIT,
	    T1.ORDER_NO,
       T2.ORDER_SEQ,
       T3.DELIVERY_NO,
       T1.ORD_PK,
       T1.ORDER_TYP,
       T2.ORD_LN_PK,
       T3.ORD_LN_DLY_PK,
       T3.DELIVERY_STATUS,
       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,
        DECODE(T2.DELVRY_RANGE_TPE,
              '%',
              '-' || T2.DELVRY_RANGE_MIN || '%' || ',+' ||
              T2.DELVRY_RANGE_MAX || '%',
              '(' || T2.DELVRY_RANGE_MIN || ',' || T2.DELVRY_RANGE_MAX || ')') DELVRY_RANGE_TPE,       
       T2.DELVRY_RANGE_MIN,
       T2.DELVRY_RANGE_MAX,
       T2.LEN_MIN,
       T2.LEN_MAX,
       T3.DELVRY_QTY,
       T3.ORDER_UNIT,
       T3.WGT_ESTMT,
       TO_CHAR(T3.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T4.PAYDOWNWEIGHT,
       T4.PAYDOWN_NUM,
       T4.PLANWEIGHT,
       T4.ORDERNUM,
       (SELECT SUM(T5.ACT_COUNT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900101') MONOMER_BRANCH,
       (SELECT SUM(T5.ACT_WEIGHT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900101') MONOMER_TON,
       (SELECT SUM(T5.ACT_COUNT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900102') LIKU_BRANCH,
       (SELECT SUM(T5.ACT_WEIGHT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900102') LIKU_TON,
           T1.SALE_ORG,
           T1.SALE_ORG_DESC
  FROM SLM_ORDER_HEAD          T1,
       SLM_ORDER_LINE          T2,
       SLM_ORDER_LINE_DELIVERY T3,
       PLN_SALEORD           T4
 WHERE T3.ORD_PK = T1.ORD_PK
   AND T3.ORD_LN_PK = T2.ORD_LN_PK
   AND T3.ORD_LN_DLY_PK = T4.ORD_LN_DLY_PK(+)
   --AND T1.ORDER_TYP NOT IN ('120102','120103','120104')
   --AND T1.ORDER_TYP NOT IN ('120103','120104')
   AND T3.Ord_Ln_Dly_Pk=?
   ORDER BY T1.ORDER_NO,T2.ORDER_SEQ,T3.DELIVERY_NO  
  
	]]>
	</query>

	<query id="FrmPipeMagement.getMageStatusByLiku" desc="利库查询物料信息状态">
	<![CDATA[
      
SELECT 
T1.MAT_NO,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.LOT_NO,
       T1.STOVE_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.MAT_SQE_NO,
       T1.SAMPLE_FLAG,
       T1.CUTTING_FLAG,
       T1.ORIGIN_MAT_NO,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.INPUT_MATERIAL_NAME,
       T1.INPUT_MATERIAL_NO,
       T1.INPUT_ORIGIN_CODE,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.GRADECODE,
       T1.GRADENAME,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_NO1,
       T1.PRO_ORDER_ID,
       T1.PRO_ORDER_ID1,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.CRAF_NO,
       T1.PROCESS_CDOE,
       T1.PROCESS_DESC,
       T1.NEXT_PROCESS_CDOE,
       T1.NEXT_PROCESS_DESC,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.MAT_ORIGIN_CODE,
       T1.MAT_ORIGIN_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       T1.LEN_MIN,
       T1.LEN_MAX,
       T1.TARG_DIMATER,
       T1.TARG_HEIGHT,
       T1.TARG_LEN_MIN,
       T1.TARG_LEN_MAX,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.ACT_COUNT,
       T1.ACT_WEIGHT,
       T1.ACT_THEORY_WEIGHT,
       T1.MEASURE_FLAG,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.PACK_FLAG,
       T1.PACK_TYPE_CODE,
       T1.PACK_TYPE_NAME,
       T1.PACK_NO,
       T1.PACK_TIME,
       T1.PACK_MAT_WT,
       T1.MAT_GROSS_WT,
       T1.MAT_GOWHERE_CODE,
       T1.MAT_GOWHERE_NAME,
       T1.COOL_HOT_FLAG,
       T1.MAT_RETURN_FLAG,
       T1.HEAT_TREAT_NO,
       T1.POST_FLAG,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_RSN_CODE,
       T1.MNG_LOCK_TIME,
       T1.MNG_LOCK_MAKER,
       T1.MNG_LOCK_REMARK,
       T1.LOCK_RSN_CODE,
       T1.LOCK_TIME,
       T1.LOCK_MAKER,
       T1.LOCK_REMARK,
       T1.UNLOCK_TIME,
       T1.UNLOCK_MAKER,
       T1.UNLOCK_REMARK,
       T1.OLD_ORDER_NO,
       T1.OLD_ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO,
       T1.OLD_MATERIAL_NO,
       T1.OLD_MATERIAL_NAME,
       T1.REMAIN_RSN_CODE,
       T1.REMAIN_JUGDE_TIME,
       T1.REMAIN_JUGDE_MAKER,
       T1.REMAIN_JUGDE_CODE,
       T1.REMAIN_REMARK,
       T1.JUGDE_APPLY_FLAG,
       T1.JUGDE_APPLY_CODE,
       T1.JUGDE_APPLY_TIME,
       T1.JUGDE_SCAN_TIME,
       T1.FACE_RESULT_CODE,
       T1.FACE_RESULT_TIME,
       T1.FACE_MAKER,
       T1.SPEC_RESULT_CODE,
       T1.SPEC_RESULT_TIME,
       T1.SPEC_MAKER,
       T1.CHEM_RESULT_CODE,
       T1.CHEM_RESULT_TIME,
       T1.CHEM_MAKER,
       T1.PHY_RESULT_CODE,
       T1.PHY_RESULT_TIME,
       T1.PHY_MAKER,
       T1.DETECT_REPORT_NO,
       T1.DETECT_RESULT_CODE,
       T1.WPRESSURE_REPORT_NO,
       T1.WPRESSURE_RESULT_CODE,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       T1.JUDGE_RESULT_TIME,
       T1.JUDGE_MAKER,
       T1.BUG_NO,
       T1.BUG_DEAL,
       T1.REPAIR_FLAG,
       T1.REPAIR_REMARK,
       T1.SAMPLING_FLAG,
       T1.SAMPLING_TYPE,
       T1.SAMPLING_NO,
       T1.CHECKOUT_NO,
       T1.CHEM_STCHECK_NO,
       T1.CHEM_PROCHECK_NO,
       T1.SH_CHECK_NO,
       T1.COME_PROC_FLAG,
       T1.CONFM_FLAG,
       T1.INSTOCK_FLAG,
       T1.INSTOCK_TIME,
       T1.OUTSTOCK_TIME,
       T1.PRO_BC,
       T1. PRO_BZ,
       T1.RPO_TIME,
       T1.BAR_CODE,
       T1.BEGINNING_FLAG,
       T1.MEMO,
       T1.CREATE_NAME,
       T1.CREATE_TIME,
       T1.UPDATE_NAME,
       T1.UPDATE_TIME,
       T1.REQ_BL_ID,
       T1.IF_BATCHED_JG,
       T1.COUPCUT_BATCH_ID,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.OLD_ORD_PK,
       T1.OLD_ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK,
       T1.ZBS_FLAG
        from 
(SELECT T1.MAT_NO,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.LOT_NO,
       T1.STOVE_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.MAT_SQE_NO,
       T1.SAMPLE_FLAG,
       T1.CUTTING_FLAG,
       T1.ORIGIN_MAT_NO,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.INPUT_MATERIAL_NAME,
       T1.INPUT_MATERIAL_NO,
       T1.INPUT_ORIGIN_CODE,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.GRADECODE,
       T1.GRADENAME,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_NO1,
       T1.PRO_ORDER_ID,
       T1.PRO_ORDER_ID1,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.CRAF_NO,
       T1.PROCESS_CDOE,
       T1.PROCESS_DESC,
       T1.NEXT_PROCESS_CDOE,
       T1.NEXT_PROCESS_DESC,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.MAT_ORIGIN_CODE,
       T1.MAT_ORIGIN_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       T1.LEN_MIN,
       T1.LEN_MAX,
       T1.TARG_DIMATER,
       T1.TARG_HEIGHT,
       T1.TARG_LEN_MIN,
       T1.TARG_LEN_MAX,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.ACT_COUNT,
       T1.ACT_WEIGHT,
       T1.ACT_THEORY_WEIGHT,
       T1.MEASURE_FLAG,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.PACK_FLAG,
       T1.PACK_TYPE_CODE,
       T1.PACK_TYPE_NAME,
       T1.PACK_NO,
       T1.PACK_TIME,
       T1.PACK_MAT_WT,
       T1.MAT_GROSS_WT,
       T1.MAT_GOWHERE_CODE,
       T1.MAT_GOWHERE_NAME,
       T1.COOL_HOT_FLAG,
       T1.MAT_RETURN_FLAG,
       T1.HEAT_TREAT_NO,
       T1.POST_FLAG,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_RSN_CODE,
       T1.MNG_LOCK_TIME,
       T1.MNG_LOCK_MAKER,
       T1.MNG_LOCK_REMARK,
       T1.LOCK_RSN_CODE,
       T1.LOCK_TIME,
       T1.LOCK_MAKER,
       T1.LOCK_REMARK,
       T1.UNLOCK_TIME,
       T1.UNLOCK_MAKER,
       T1.UNLOCK_REMARK,
       T1.OLD_ORDER_NO,
       T1.OLD_ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO,
       T1.OLD_MATERIAL_NO,
       T1.OLD_MATERIAL_NAME,
       T1.REMAIN_RSN_CODE,
       T1.REMAIN_JUGDE_TIME,
       T1.REMAIN_JUGDE_MAKER,
       T1.REMAIN_JUGDE_CODE,
       T1.REMAIN_REMARK,
       T1.JUGDE_APPLY_FLAG,
       T1.JUGDE_APPLY_CODE,
       T1.JUGDE_APPLY_TIME,
       T1.JUGDE_SCAN_TIME,
       T1.FACE_RESULT_CODE,
       T1.FACE_RESULT_TIME,
       T1.FACE_MAKER,
       T1.SPEC_RESULT_CODE,
       T1.SPEC_RESULT_TIME,
       T1.SPEC_MAKER,
       T1.CHEM_RESULT_CODE,
       T1.CHEM_RESULT_TIME,
       T1.CHEM_MAKER,
       T1.PHY_RESULT_CODE,
       T1.PHY_RESULT_TIME,
       T1.PHY_MAKER,
       T1.DETECT_REPORT_NO,
       T1.DETECT_RESULT_CODE,
       T1.WPRESSURE_REPORT_NO,
       T1.WPRESSURE_RESULT_CODE,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       T1.JUDGE_RESULT_TIME,
       T1.JUDGE_MAKER,
       T1.BUG_NO,
       T1.BUG_DEAL,
       T1.REPAIR_FLAG,
       T1.REPAIR_REMARK,
       T1.SAMPLING_FLAG,
       T1.SAMPLING_TYPE,
       T1.SAMPLING_NO,
       T1.CHECKOUT_NO,
       T1.CHEM_STCHECK_NO,
       T1.CHEM_PROCHECK_NO,
       T1.SH_CHECK_NO,
       T1.COME_PROC_FLAG,
       T1.CONFM_FLAG,
       T1.INSTOCK_FLAG,
       T1.INSTOCK_TIME,
       T1.OUTSTOCK_TIME,
       T1.PRO_BC,
       T1. PRO_BZ,
       T1.RPO_TIME,
       T1.BAR_CODE,
       T1.BEGINNING_FLAG,
       T1.MEMO,
       T1.CREATE_NAME,
       T1.CREATE_TIME,
       T1.UPDATE_NAME,
       T1.UPDATE_TIME,
       T1.REQ_BL_ID,
       T1.IF_BATCHED_JG,
       T1.COUPCUT_BATCH_ID,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.OLD_ORD_PK,
       T1.OLD_ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK,
       T1.ZBS_FLAG
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 WHERE T1.MAT_NO = T2.MAT_NO
   #conditions#
   AND T1.BELONG_CODE = '#BELONG_CODE#'
   AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T1.BATCH_NO = '#BATCH_NO#'
   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND NVL(T1.SPEC_CODE,'/') = NVL('#SPEC_CODE#','/')
   AND NVL(T1.ACT_DIMATER,'0') = NVL('#ACT_DIMATER#','0')
   AND NVL(T1.ACT_HEIGHT,'0') = NVL('#ACT_HEIGHT#','0')
   AND NVL(T1.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
   AND NVL(T1.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
   AND NVL(T1.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
   AND NVL(T1.STEELCODE,'/') = NVL('#STEELCODE#','/')
   AND NVL(T1.STD_CODE,'/') = NVL('#STD_CODE#','/')
   AND NVL(T2.STORAGE_NO,'/') = NVL('#STORAGE_NO#','/')
   AND DECODE('#LOCATION_NO#','','/',T2.LOCATION_NO) = DECODE('#LOCATION_NO#','','/','#LOCATION_NO#')
   AND NVL(T1.MODEL_CODE,'/')=NVL('#MODEL_CODE#','/')
   AND NVL(T1.STD_STYLE,'/')=NVL('#STD_STYLE#','/')
   AND NVL(T1.MEMO,'/')=NVL('#MEMO#','/')
   AND DECODE('#PIPMEMO#','','/',T1.PIPMEMO) = DECODE('#PIPMEMO#','','/','#PIPMEMO#')
   AND NVL(T1.JUDGE_RESULT_CODE,'/')=NVL('#JUDGE_RESULT_CODE#','/')
   AND NVL(T1.PRO_ORDER_NO,'/') = NVL('#PRO_ORDER_NO#','/')
   AND T1.product_flag = ?
   AND T1.MAT_STATUS = ?
   AND T1.MAT_STATUS <>'80150201'
   AND T1.INSTOCK_DOC IS NULL
   AND T1.ORD_LN_PK IS NULL order by T1.MAT_NO desc) T1 where rownum <  ?
	]]>
	</query>
<query id = "FrmPipeMagement.getCount" desc = "查询利库封锁状态">
<![CDATA[
SELECT count(1)ACOUNT
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 WHERE T1.MAT_NO = T2.MAT_NO
   AND T1.BELONG_CODE = '#BELONG_CODE#'
   AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T1.BATCH_NO = '#BATCH_NO#'
   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND NVL(T1.SPEC_CODE,'/') = NVL('#SPEC_CODE#','/')
   AND nvl(T1.ACT_DIMATER,'0') = nvl('#ACT_DIMATER#','0')
   AND nvl(T1.ACT_HEIGHT,'0') = nvl('#ACT_HEIGHT#','0')
   AND NVL(T1.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
   AND NVL(T1.STEELCODE,'/') = NVL('#STEELCODE#','/')
   AND NVL(T1.STD_CODE,'/') = NVL('#STD_CODE#','/')
   AND NVL(T1.STD_NAME,'/') = NVL('#STD_NAME#','/')
   AND NVL(T2.STORAGE_NO,'/') = NVL('#STORAGE_NO#','/')
   AND DECODE('#LOCATION_NO#','','/',T2.LOCATION_NO) = DECODE('#LOCATION_NO#','','/','#LOCATION_NO#')
   AND NVL(T1.MODEL_CODE,'/')=NVL('#MODEL_CODE#','/')
   AND NVL(T1.STD_STYLE,'/')=NVL('#STD_STYLE#','/')
   AND NVL(T1.MEMO,'/')=NVL('#MEMO#','/')
   AND DECODE('#PIPMEMO#','','/',T1.PIPMEMO) = DECODE('#PIPMEMO#','','/','#PIPMEMO#')
   AND NVL(T1.JUDGE_RESULT_CODE,'/')=NVL('#JUDGE_RESULT_CODE#','/')
   AND T1.LOCK_FLAG = '#LOCK_FLAG#'
   AND T1.MNG_LOCK_FLAG = '#MNG_LOCK_FLAG#'
   AND T1.PRODUCT_FLAG = '#PRODUCT_FLAG#'
   AND T1.MAT_STATUS = '#MAT_STATUS#'
   AND NVL(T1.FIX_NUM,'0') = NVL('#FIX_NUM#','0')
   AND NVL(T1.PRO_ORDER_NO,'/') = NVL('#PRO_ORDER_NO#','/')
   AND T1.ORD_LN_PK IS NULL order by T1.MAT_NO desc
]]>
</query>
	<query id="FrmPipeMagement.queryWeightByLiku" desc="查询交货行已经利库的重量">
	<![CDATA[
	  SELECT SUM(T1.ACT_WEIGHT) ACT_WEIGHT FROM   MAT_ZC_M T1 WHERE T1.ORD_LN_DLY_PK=?
	]]>
	</query>

	<query id="FrmPipeMagement.checkOrdNoHead" desc="脱单的数据权限">
	<![CDATA[
	  SELECT COUNT(1) COUNT
  FROM SLM_ORDER_HEAD T
 WHERE T.ORD_PK = ?
   AND T.VALIDFLAG = '1'
	]]>
	</query>
	<query id = "FrmPipeMagement.UpdateProcessMonomer" desc = "脱单写进程表">
	<![CDATA[
	UPDATE PROCESS_ORDER_M T
   SET T.ELIM_NUM = to_number(nvl(T.ELIM_NUM,0)) + to_number('#ELIM_NUM#'),
       T.ELIM_WGT = to_number(nvl(T.ELIM_WGT,0)) + to_number('#ELIM_WGT#'),
       T.ELIM_LEN = to_number(nvl(T.ELIM_LEN,0)) + to_number('#ELIM_LEN#')
   WHERE ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
 ]]>
	</query>
	<query id = "FrmPipeMagement.UpdateProcessLiKu" desc = "利库写进程表">
	<![CDATA[
	DECLARE
BEGIN
	UPDATE PROCESS_ORDER_M T
   SET T.CHARGE_NUM = to_number(nvl(T.CHARGE_NUM,0)) + to_number(?),
       T.CHARGE_WGT = to_number(nvl(T.CHARGE_WGT,0)) + to_number(?),
       T.CHARGE_LEN = to_number(nvl(T.CHARGE_LEN,0)) + to_number(?)
   WHERE ORD_LN_DLY_PK = ?;
   UPDATE SLM_ORDER_LINE_DELIVERY T SET T.LK_ID = T.LK_ID ||'&'||? WHERE T.ORD_LN_DLY_PK = ?;
   END;
   ]]>
	</query>
	<query id = "cancelMonomer.deleteMatTrack" desc = "删除物料跟踪履历表">
	DELETE FROM MAT_ZC_TRACK T WHERE T.MAT_NO = ?
	</query>
	<query id = "cancelMonomer.updateMat" desc = "修改物料表状态(撤销脱单)">
	<![CDATA[
	 UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = T1.OLD_ORDER_NO,
       T1.ORDER_SEQ         = T1.OLD_ORDER_SEQ,
       T1.ORDER_SEQ_NO      = T1.OLD_ORDER_SEQ_NO,
       T1.PRODUCT_FLAG      = '801403',
       T1.MAT_STATUS        = '80150301',
       T1.ORD_PK            = T1.OLD_ORD_PK,
       T1.ORD_LN_PK         = T1.OLD_ORD_LN_PK,
       T1.ORD_LN_DLY_PK     = T1.OLD_ORD_LN_DLY_PK,
       T1.OLD_ORDER_NO      = '',
       T1.OLD_ORDER_SEQ     = '',
       T1.OLD_ORDER_SEQ_NO  = '',
       T1.OLD_ORD_PK        = '',
       T1.OLD_ORD_LN_PK     = '',
       T1.OLD_ORD_LN_DLY_PK = '',
       T1.MATERIAL_NO       = T1.OLD_MATERIAL_NO,
       T1.MATERIAL_NAME     = T1.OLD_MATERIAL_NAME,
       T1.OLD_MATERIAL_NO   = '',
       T1.OLD_MATERIAL_NAME = ''
 WHERE T1.MAT_NO = ?    
	]]>
	</query>
	<query id = "cancelMonomer.updateProcess" desc = "修改进程表">
	<![CDATA[
	UPDATE PROCESS_ORDER_M T
   SET T.ELIM_NUM = to_number(nvl(T.ELIM_NUM,0)) - to_number(?),
       T.ELIM_WGT = to_number(nvl(T.ELIM_WGT,0)) - to_number(?),
       T.ELIM_LEN = to_number(nvl(T.ELIM_LEN,0)) - to_number(?)
   WHERE ORD_LN_DLY_PK = ?
   ]]>
	</query>
	<query id = "CorePipeInTemp.queryMatTrackCount" desc = "获取履历表中重量支数长度">
	   SELECT SUM(T.ACT_COUNT) ACT_COUNT,
          SUM(T.ACT_WEIGHT) ACT_WEIGHT,
          SUM(T.ACT_LEN) ACT_LEN
     FROM MAT_ZC_TRACK T
    WHERE T.ORD_LN_DLY_PK = ?
	</query>
	<query id = "CorePipeInTemp.selectTrack" desc = "查询履历表">
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.EVENT_ID,
       T1.EVENT_DESC,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.CREATE_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.Mat_No
       FROM MAT_ZC_TRACK T1 where NVL(T1.ORD_LN_DLY_PK,'/') = NVL(?,'/')
       AND T1.ORD_LN_PK = ? AND T1.ORD_PK = ?
       AND T1.JUDGE_STOVE_NO = ? AND T1.BATCH_NO = ? AND T1.Batch_Groud_No = ?
       AND T1.EVENT_ID = '900101'
	</query>
	<query id="CorePipeInTemp.getMatStatus" desc = "查询脱单后物料状态是否被改变">
	<![CDATA[
	SELECT COUNT(1) ACOUNT
  FROM MAT_ZC_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND T.MAT_STATUS not in ('80150204','80150205','80150202','80150203')
   ]]>
	</query>
	<query id = "FrmPipeMagement.getOrderLineLock" desc = "查询合同行状态是否锁定">
	<![CDATA[
	   SELECT T.ISLOCK FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK =?
	   ]]>
	</query>
	<query id = "CorePipeInTemp.selectStaus" desc = "获取该材料号状态">
	SELECT T.PRODUCT_FLAG
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
   AND T.MAT_NO = ?
	</query>
	<query id = "FrmPipeMagement.selectMatZc" desc = "查询支数是否满足脱单">
	SELECT SUM(T.ACT_COUNT)ACOUNT
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND NVL(T.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
   AND NVL(T.STEELCODE,'/') = NVL('#STEELCODE#','/')
   AND NVL(T.SPEC_CODE,'/') = NVL('#SPEC_CODE#','/')
   AND NVL(T.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
   AND NVL(T.STD_STYLE,'/') = NVL('#STD_STYLE#','/')
   AND NVL(T.ACT_LEN_MIN,'/') = NVL('#ACT_LEN_MIN#','/')
   AND NVL(T.ACT_LEN_MAX,'/') = NVL('#ACT_LEN_MAX#','/')
   AND T.MAT_STATUS = '#MAT_STATUS#'
   AND NVL(S.STORAGE_NO,'/') = NVL('#STORAGE_NO#','/')
   AND NVL(S.LOCATION_NO,'/') = NVL('#LOCATION_NO#','/')
   AND T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND NVL(T.ORD_LN_DLY_PK,'/') = NVL('#ORD_LN_DLY_PK#','/')
   AND NVL(T.PRO_NO,'/') = NVL('#PRO_NO#','/')
   AND NVL(T.IN_MOLD,'/')= NVL('#IN_MOLD#','/')
   AND NVL(T.JUDGE_STD_NAME,'/') = NVL('#JUDGE_STD_NAME#','/')
   AND NVL(T.STD_NAME,'/') = NVL('#STD_NAME#','/')
   AND NVL(T.MEMO,'/') = NVL('#MEMO#','/')
        AND NVL(T.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
        AND T.BELONG_CODE = '#BELONG_CODE#'
        AND NVL(T.FIX_NUM,'0') = NVL('#FIX_NUM#','0')
	</query>
	<query id = "FrmPipeMagement.monomer" desc = "执行脱单操作">
	<![CDATA[
	DECLARE
  V_RESUME_SEQ MAT_ZC_TRACK.RESUME_SEQ%TYPE := NULL; --履历单号
  V_ELIM_NUM PROCESS_ORDER_M.ELIM_NUM%TYPE :=NULL;
  V_ELIM_WGT PROCESS_ORDER_M.ELIM_WGT%TYPE := NULL;
  V_ELIM_LEN PROCESS_ORDER_M.ELIM_LEN%TYPE := NULL;
  V_OCOUNT   NUMBER := 1;
  V_TIME     MAT_ZC_TRACK.CREATE_TIME%TYPE := SYSDATE;
BEGIN
  --生成履历序号
  SELECT 
         LPAD(NVL(MAX(SUBSTR(T.RESUME_SEQ, 15)), 0) + 1, 10, 0) RESUME_SEQ
    INTO V_OCOUNT
    FROM MAT_ZC_TRACK T
   WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') =
         TO_CHAR(SYSDATE, 'YYYY-MM-DD');
   SELECT SUM(T.ACT_COUNT),SUM(T.ACT_WEIGHT),SUM(T.ACT_LEN)
    INTO V_ELIM_NUM,V_ELIM_WGT,V_ELIM_LEN
                  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
                 WHERE T.MAT_NO = S.MAT_NO
                   AND T.JUDGE_STOVE_NO = ?
                   AND T.BATCH_NO = ?
                   AND T.BATCH_GROUD_NO = ?
                   AND NVL(T.PRODUCCODE,'/') = NVL(?,'/')
                   AND NVL(T.STEELCODE,'/') = NVL(?,'/')
                   AND NVL(T.SPEC_CODE,'/') = NVL(?,'/')
                   AND NVL(T.MODEL_CODE,'/') = NVL(?,'/')
                   AND NVL(T.STD_STYLE,'/') = NVL(?,'/')
                   AND T.MAT_STATUS = ?
                   AND NVL(S.STORAGE_NO,'/') = NVL(?,'/')
                   AND T.ORD_PK = ?
                   AND T.ORD_LN_PK = ?
                   AND NVL(T.ORD_LN_DLY_PK,'/') = NVL(?,'/')
                   AND NVL(T.PRO_NO,'/') = NVL(?,'/')
                   AND NVL(T.IN_MOLD,'/')= NVL(?,'/')
                   AND NVL(T.ACT_LEN_MIN,'/')=NVL(?,'/')
                   AND NVL(T.ACT_LEN_MAX,'/')=NVL(?,'/')
                   AND NVL(T.PIPMEMO,'/') = NVL(?,'/')
                   AND NVL(S.LOCATION_NO,'/') = NVL(?,'/')
                   AND ROWNUM < ?;
  FOR MYROW IN (SELECT T.*,
                       S.STORAGE_NO
                  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
                 WHERE T.MAT_NO = S.MAT_NO
                   AND T.JUDGE_STOVE_NO = ?
                   AND T.BATCH_NO = ?
                   AND T.BATCH_GROUD_NO = ?
                   AND NVL(T.PRODUCCODE,'/') = NVL(?,'/')
                   AND NVL(T.STEELCODE,'/') = NVL(?,'/')
                   AND NVL(T.SPEC_CODE,'/') = NVL(?,'/')
                   AND NVL(T.MODEL_CODE,'/') = NVL(?,'/')
                   AND NVL(T.STD_STYLE,'/') = NVL(?,'/')
                   AND T.MAT_STATUS = ?
                   AND NVL(S.STORAGE_NO,'/') = NVL(?,'/')
                   AND T.ORD_PK = ?
                   AND T.ORD_LN_PK = ?
                   AND NVL(T.ORD_LN_DLY_PK,'/') = NVL(?,'/')
                   AND NVL(T.PRO_NO,'/') = NVL(?,'/')
                   AND NVL(T.IN_MOLD,'/')= NVL(?,'/')
                   AND NVL(T.ACT_LEN_MIN,'/')=NVL(?,'/')
                   AND NVL(T.ACT_LEN_MAX,'/')=NVL(?,'/')
                   AND NVL(T.FIX_NUM,'0') = NVL(?,'0')
                   AND NVL(T.PIPMEMO,'/') = NVL(?,'/')
                   AND NVL(S.LOCATION_NO,'/') = NVL(?,'/')
                   AND ROWNUM < ?
                   ORDER BY T.MAT_NO DESC) LOOP
    V_RESUME_SEQ := TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') || LPAD(V_OCOUNT, 10, 0);
    INSERT INTO MAT_ZC_TRACK(
        RESUME_SEQ,
        EVENT_ID,
        EVENT_DESC,
        FORM_NAME,
        CALL_FUNC_CODING,
        KEYVALUE_1,
        KEYVALUE_1_DESC,
        KEYVALUE_2,
        KEYVALUE_2_DESC2,
        KEYVALUE_3,
        KEYVALUE_3_DESC3,
        KEYVALUE_4,
        KEYVALUE_4_DESC4,
        KEYVALUE_5,
        KEYVALUE_5_DESC5,
        KEYVALUE_6,
        KEYVALUE_6_DESC6,
        KEYVALUE_7,
        KEYVALUE_7_DESC7,
        MAT_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        PRO_ORDER_NO,
        PRO_ORDER_ID,
        PRO_ORDER_NO1,
        PRO_ORDER_ID1,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        OLD_ORD_PK,
        OLD_ORD_LN_PK,
        OLD_ORD_LN_DLY_PK,
        OLD_ORDER_NO,
        OLD_ORDER_SEQ,
        OLD_ORDER_SEQ_NO,
        BELONG_CODE,
        BELONG_NAME,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        FINISHPRO_MOLD,
        IN_MOLD,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT)
 VALUES( 
        V_RESUME_SEQ,
        '900101',
        '脱单',
        'com.steering.pss.ydm.pipemanage.FrmPipeMagement',
        'monomer',
        'ArrayList<MatZcMEntity> paramList',
        '物料主表关键字(group)实体类集合',
        'String monomerExplain',
        '脱单说明',
        'String isRolling',
        '是否补轧',
        'String userName',
        '操作人',
        'String deptId',
        '操作人部门ID',
        '',
        '',
        '',
        '',
         MYROW.MAT_NO,
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        MYROW.LOT_NO,
        MYROW.STOVE_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        MYROW.ACT_THEORY_WEIGHT,
        MYROW.PRO_ORDER_NO,
        MYROW.PRO_ORDER_ID,
        MYROW.PRO_ORDER_NO1,
        MYROW.PRO_ORDER_ID1,
        MYROW.ORD_PK,
        MYROW.ORD_LN_PK,
        MYROW.ORD_LN_DLY_PK,
        MYROW.ORDER_NO,
        MYROW.ORDER_SEQ,
        MYROW.ORDER_SEQ_NO,
        MYROW.OLD_ORD_PK,
        MYROW.OLD_ORD_LN_PK,
        MYROW.OLD_ORD_LN_DLY_PK,
        MYROW.OLD_ORDER_NO,
        MYROW.OLD_ORDER_SEQ,
        MYROW.OLD_ORDER_SEQ_NO,
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        ?,
        ?,
        V_TIME,
        ?,
        MYROW.IN_MOLD,
        MYROW.SUPPLY_UNIT_CODE,
        MYROW.SUPPLY_UNIT);
        UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '',
       T1.ORDER_SEQ         = '',
       T1.ORDER_SEQ_NO      = '',
       T1.PRODUCT_FLAG      = '801402',
       T1.MAT_STATUS        = '80150204',
       T1.ORD_PK            = '',
       T1.ORD_LN_PK         = '',
       T1.ORD_LN_DLY_PK     = '',
       T1.OLD_ORDER_NO      = T1.ORDER_NO,
       T1.OLD_ORDER_SEQ     = T1.ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO  = T1.ORDER_SEQ_NO,
       T1.OLD_ORD_PK        = T1.ORD_PK,
       T1.OLD_ORD_LN_PK     = T1.ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK,
       T1.OLD_MATERIAL_NO   = T1.MATERIAL_NO,
       T1.OLD_MATERIAL_NAME = T1.MATERIAL_NAME,
       T1.LOCK_LIKU         = '0',
       T1.LOCK_FLAG         = '0',
       T1.FINISHPRO_MOLD    = ?
 WHERE T1.MAT_NO = MYROW.MAT_NO;
    V_OCOUNT := V_OCOUNT + 1;
  END LOOP;
  UPDATE PROCESS_ORDER_M T
   SET T.ELIM_NUM = TO_NUMBER(NVL(T.ELIM_NUM,0)) + TO_NUMBER(V_ELIM_NUM),
       T.ELIM_WGT = TO_NUMBER(NVL(T.ELIM_WGT,0)) + TO_NUMBER(V_ELIM_WGT),
       T.ELIM_LEN = TO_NUMBER(NVL(T.ELIM_LEN,0)) + TO_NUMBER(V_ELIM_LEN)
   WHERE ORD_LN_DLY_PK = ?;
END;
	]]>
	</query>
	<query id = "seqMoner.UpdateProcess" desc = "脱单写进程表">
	UPDATE PROCESS_ORDER_M T
   SET T.ELIM_NUM = TO_NUMBER(NVL(T.ELIM_NUM,0)) + TO_NUMBER(?),
       T.ELIM_WGT = TO_NUMBER(NVL(T.ELIM_WGT,0)) + TO_NUMBER(?),
       T.ELIM_LEN = TO_NUMBER(NVL(T.ELIM_LEN,0)) + TO_NUMBER(?)
   WHERE ORD_LN_DLY_PK = ?
	</query>
	<query id = "seqMoner.insertMatZcTarck" desc = "插入脱单履历表">
	<![CDATA[
	DECLARE
  V_RESUME_SEQ MAT_ZC_TRACK.RESUME_SEQ%TYPE := NULL; --履历单号
  V_ELIM_NUM PROCESS_ORDER_M.ELIM_NUM%TYPE :=NULL;
  V_ELIM_WGT PROCESS_ORDER_M.ELIM_WGT%TYPE := NULL;
  V_ELIM_LEN PROCESS_ORDER_M.ELIM_LEN%TYPE := NULL;
  V_OCOUNT   NUMBER := 1;
  V_TIME     MAT_ZC_TRACK.CREATE_TIME%TYPE := SYSDATE;
BEGIN
  --生成履历序号
  SELECT 
         LPAD(NVL(MAX(SUBSTR(T.RESUME_SEQ, 15)), 0) + 1, 10, 0) RESUME_SEQ
    INTO V_OCOUNT
    FROM MAT_ZC_TRACK T
   WHERE T.RESUME_SEQ LIKE TO_CHAR(SYSDATE, 'YYYYMMDD')||'________________';
  FOR MYROW IN (SELECT T.*,
                       S.STORAGE_NO
                  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
                 WHERE T.MAT_NO = S.MAT_NO
                   AND T.MAT_NO = '#MAT_NO#') LOOP
    V_RESUME_SEQ := TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') || LPAD(V_OCOUNT, 10, 0);
    INSERT INTO MAT_ZC_TRACK(
        RESUME_SEQ,
        EVENT_ID,
        EVENT_DESC,
        FORM_NAME,
        CALL_FUNC_CODING,
        KEYVALUE_1,
        KEYVALUE_1_DESC,
        KEYVALUE_2,
        KEYVALUE_2_DESC2,
        KEYVALUE_3,
        KEYVALUE_3_DESC3,
        KEYVALUE_4,
        KEYVALUE_4_DESC4,
        KEYVALUE_5,
        KEYVALUE_5_DESC5,
        KEYVALUE_6,
        KEYVALUE_6_DESC6,
        KEYVALUE_7,
        KEYVALUE_7_DESC7,
        MAT_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        PRO_ORDER_NO,
        PRO_ORDER_ID,
        PRO_ORDER_NO1,
        PRO_ORDER_ID1,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        OLD_ORD_PK,
        OLD_ORD_LN_PK,
        OLD_ORD_LN_DLY_PK,
        OLD_ORDER_NO,
        OLD_ORDER_SEQ,
        OLD_ORDER_SEQ_NO,
        BELONG_CODE,
        BELONG_NAME,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        FINISHPRO_MOLD,
        IN_MOLD,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT)
 VALUES( 
        V_RESUME_SEQ,
        '900101',
        '脱单',
        'com.steering.pss.ydm.pipemanage.FrmPipeMagement',
        'monomer',
        'ArrayList<MatZcMEntity> paramList',
        '物料主表关键字(group)实体类集合',
        'String monomerExplain',
        '脱单说明',
        'String isRolling',
        '是否补轧',
        'String userName',
        '操作人',
        'String deptId',
        '操作人部门ID',
        '',
        '',
        '',
        '',
         MYROW.MAT_NO,
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        MYROW.LOT_NO,
        MYROW.STOVE_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        MYROW.ACT_THEORY_WEIGHT,
        MYROW.PRO_ORDER_NO,
        MYROW.PRO_ORDER_ID,
        MYROW.PRO_ORDER_NO1,
        MYROW.PRO_ORDER_ID1,
        MYROW.ORD_PK,
        MYROW.ORD_LN_PK,
        MYROW.ORD_LN_DLY_PK,
        MYROW.ORDER_NO,
        MYROW.ORDER_SEQ,
        MYROW.ORDER_SEQ_NO,
        MYROW.OLD_ORD_PK,
        MYROW.OLD_ORD_LN_PK,
        MYROW.OLD_ORD_LN_DLY_PK,
        MYROW.OLD_ORDER_NO,
        MYROW.OLD_ORDER_SEQ,
        MYROW.OLD_ORDER_SEQ_NO,
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        '#MEMO#',
        '#CREATE_NAME#',
        V_TIME,
        '#FINISHPRO_MOLD#',
        MYROW.IN_MOLD,
        MYROW.SUPPLY_UNIT_CODE,
        MYROW.SUPPLY_UNIT);
        UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '',
       T1.ORDER_SEQ         = '',
       T1.ORDER_SEQ_NO      = '',
       T1.PRODUCT_FLAG      = '801402',
       T1.MAT_STATUS        = '80150204',
       T1.ORD_PK            = '',
       T1.ORD_LN_PK         = '',
       T1.ORD_LN_DLY_PK     = '',
       T1.OLD_ORDER_NO      = T1.ORDER_NO,
       T1.OLD_ORDER_SEQ     = T1.ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO  = T1.ORDER_SEQ_NO,
       T1.OLD_ORD_PK        = T1.ORD_PK,
       T1.OLD_ORD_LN_PK     = T1.ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK,
       T1.OLD_MATERIAL_NO   = T1.MATERIAL_NO,
       T1.OLD_MATERIAL_NAME = T1.MATERIAL_NAME,
       T1.LOCK_LIKU         = '0',
       T1.FINISHPRO_MOLD    = '#FINISHPRO_MOLD#'
 WHERE T1.MAT_NO = MYROW.MAT_NO;
    V_OCOUNT := V_OCOUNT + 1;
  END LOOP;
END;
]]>
	</query>
	<query id = "seqMoner.UpdateMatZcSeq" desc = "修改材料状态">
	UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '',
       T1.ORDER_SEQ         = '',
       T1.ORDER_SEQ_NO      = '',
       T1.PRODUCT_FLAG      = '801402',
       T1.MAT_STATUS        = '80150204',
       T1.ORD_PK            = '',
       T1.ORD_LN_PK         = '',
       T1.ORD_LN_DLY_PK     = '',
       T1.OLD_ORDER_NO      = T1.ORDER_NO,
       T1.OLD_ORDER_SEQ     = T1.ORDER_SEQ,
       T1.OLD_ORDER_SEQ_NO  = T1.ORDER_SEQ_NO,
       T1.OLD_ORD_PK        = T1.ORD_PK,
       T1.OLD_ORD_LN_PK     = T1.ORD_LN_PK,
       T1.OLD_ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK,
       T1.OLD_MATERIAL_NO   = T1.MATERIAL_NO,
       T1.OLD_MATERIAL_NAME = T1.MATERIAL_NAME,
       T1.LOCK_LIKU         = '0',
       T1.FINISHPRO_MOLD    = '#FINISHPRO_MOLD#'
 WHERE T1.MAT_NO = '#MAT_NO#'
	</query>

    <query id="FrmPipeMagement.queryMatInfo" desc="查询材料信息">
        <![CDATA[
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       --(SELECT T3.BASENAME
        --  FROM COM_BASE_INFO T3
       --  WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       --(SELECT T3.BASENAME
       --   FROM COM_BASE_INFO T3
       --  WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,

       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       t1.PIPMEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS LKACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG,T2.LOCATION_NO
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
  WHERE T1.MAT_NO = T2.MAT_NO
   AND  T1.PRODUCT_FLAG = '801402'
   AND  T1.MAT_STATUS IN ('80150202','80150203','80150204','80150205')
   AND  T1.PRODUCCODE = ?
   AND  T1.STEELCODE = ?
   AND  T1.SPEC_CODE = ?
   AND  T1.MODEL_CODE = ?
   AND  DECODE(T1.STD_NAME, NULL, '1', T1.STD_NAME) =  DECODE(?, NULL, '1', ?)
	]]>
    </query>

    <query id="FrmPipeMagement.queryMatInfo120504" desc="查询材料信息">
        <![CDATA[
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       --(SELECT T3.BASENAME
        --  FROM COM_BASE_INFO T3
       --  WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       --(SELECT T3.BASENAME
       --   FROM COM_BASE_INFO T3
       --  WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,

       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS LKACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG,T2.LOCATION_NO
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
  WHERE T1.MAT_NO = T2.MAT_NO
   AND  T1.PRODUCT_FLAG = '801402'
   AND  T1.MAT_STATUS IN ('80150202','80150203','80150204','80150205')
   AND  T1.PRODUCCODE = ?
   AND  T1.STEELCODE = ?
   AND  T1.SPEC_CODE = ?
   AND  T1.MODEL_CODE = ?
    AND  DECODE(T1.STD_STYLE_DESC, NULL, '1', T1.STD_STYLE_DESC) =  DECODE(?, NULL, '1', ?)
	]]>
    </query>

	<query id="FrmPipeMagement.queryMatInfo1" desc="查询材料信息">
	<![CDATA[
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       --(SELECT T3.BASENAME
        --  FROM COM_BASE_INFO T3
       --  WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       --(SELECT T3.BASENAME
       --   FROM COM_BASE_INFO T3
       --  WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,
       
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS LKACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG,T2.LOCATION_NO
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
  WHERE T1.MAT_NO = T2.MAT_NO
   AND  T1.PRODUCT_FLAG = '801402'
   AND  T1.MAT_STATUS IN ('80150202','80150203','80150204','80150205')
   AND  T1.STEELCODE = ?
   AND  T1.SPEC_CODE = ?
	]]>
	</query>
	
	<query id="FrmPipeMagement.getDelivyInfoByOrdLnDlyPk" desc="查询交货行信息">
	<![CDATA[
	
	 SELECT T1.ORDER_NO,
       T2.ORDER_SEQ,
       T3.DELIVERY_NO,
       T1.ORD_PK,
       T2.ORD_LN_PK,
       T3.ORD_LN_DLY_PK,
       (SELECT T6.BASENAME
          FROM COM_BASE_INFO T6
         WHERE T6.BASECODE = T3.DELIVERY_STATUS) DELIVERY_STATUS,
       T2.PRODUCCODE,
       T2.PRODUCNAME,
       T2.STEELCODE,
       T2.STEELNAME,
       T2.STD_CODE ,
      (T2.STD_NAME  ||','||  T2.USE_DESC) STD_NAME,
       T2.STD_STYLE,
       T2.STD_STYLE_DESC,
       T2.MODEL_CODE,
       T2.MODEL_DESC,
       T2.SPEC_CODE,
       T2.SPEC_NAME,
        DECODE(T2.DELVRY_RANGE_TPE,
              '%',
              '-' || T2.DELVRY_RANGE_MIN || '%' || ',+' ||
              T2.DELVRY_RANGE_MAX || '%',
              '(' || T2.DELVRY_RANGE_MIN || ',' || T2.DELVRY_RANGE_MAX || ')') DELVRY_RANGE_TPE,       
       T2.DELVRY_RANGE_MIN,
       T2.DELVRY_RANGE_MAX,
       T3.DELVRY_QTY,
       T3.ORDER_UNIT,
       T3.WGT_ESTMT,
       TO_CHAR(T3.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T4.PAYDOWNWEIGHT,
       T4.PAYDOWN_NUM,
       T4.PLANWEIGHT,
       T4.ORDERNUM,
       T2.LEN_MIN,
       T2.LEN_MAX,
       (SELECT SUM(T5.ACT_COUNT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900101') MONOMER_BRANCH,
       (SELECT SUM(T5.ACT_WEIGHT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID = '900101') MONOMER_TON,
       (SELECT SUM(T5.ACT_COUNT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID in ('900102','900103')) LIKU_BRANCH,
       (SELECT SUM(T5.ACT_WEIGHT)
          FROM MAT_ZC_TRACK T5
         WHERE T5.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
           AND T5.EVENT_ID in ('900102','900103')) LIKU_TON,
           T8.SEND_COUNT,
           T8.SEND_WEIGHT
  FROM SLM_ORDER_HEAD          T1,
       SLM_ORDER_LINE          T2,
       SLM_ORDER_LINE_DELIVERY T3,
       PLN_SALEORD           T4,
       (SELECT NVL(SUM(T7.ACT_COUNT), 0) SEND_COUNT,NVL(SUM(CASE
                         WHEN T7.PONDER_NO IS NULL THEN
                          NVL(T7.ACT_WEIGHT, 0)
                         ELSE
                          NVL(T7.PONDER_GROSS_WT, 0)
                       END),
                   0)SEND_WEIGHT,
                   T7.ORD_LN_DLY_PK
                   FROM YDM_ZC_OUTLIST T7 WHERE T7.OUTSTOCK_TYPE_CODE = '800805' 
                   GROUP BY T7.ORD_PK,T7.ORD_LN_PK,T7.ORD_LN_DLY_PK)T8
 WHERE T3.ORD_PK = T1.ORD_PK
   AND T3.ORD_LN_PK = T2.ORD_LN_PK
   AND T3.ORD_LN_DLY_PK = T4.ORD_LN_DLY_PK(+)
   AND T3.ORD_LN_DLY_PK = T8.ORD_LN_DLY_PK(+)
   AND T3.ORD_LN_DLY_PK  = ?
   AND T1.VALIDFLAG = '1'
   AND T2.VALIDFLAG = '1'
   AND T3.VALIDFLAG = '1'
   AND T1.ORDER_TYP NOT IN('120103','120104')
   
	]]>
	</query>
	<query id = "FrmPipeMagement.doQueryMaxProNo" desc = "生成利库脱单操作单号">
	SELECT ? || ? || TO_CHAR(SYSDATE,'YYMMDD') ||
         LPAD(SUBSTR(NVL(MAX(T.PRO_NO), '00000'), -5, 5) + 1, 5, '0') AS PRO_NO
    FROM MAT_ZC_TRACK T  WHERE T.PRO_NO LIKE ? || ? || TO_CHAR(SYSDATE,'YYMMDD')||'_____'
	</query>
	<query id = "FrmPipeMagement.updateDiveNo" desc = "写脱单操作编号">
	<![CDATA[
	UPDATE SLM_ORDER_LINE_DELIVERY T SET T.TD_ID = T.TD_ID ||'&'||? WHERE T.ORD_LN_DLY_PK = ?
	]]>
	</query>
	<query id = "seqMoner.UpdateOrdPk" desc = "写脱单操作编号">
	<![CDATA[
	UPDATE SLM_ORDER_LINE_DELIVERY T SET T.TD_ID = T.TD_ID ||'&'||'#PRO_NO#' WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
	]]>
	</query>
	<query id = "FrmPipeMagement.doCheckMat" desc = "审核通过">
	UPDATE MAT_ZC_M T SET T.LOCK_LIKU = '0' WHERE T.PRO_NO = ?
	</query>
    <query id = "FrmPipeMagement.doCheckMat1" desc = "审核通过">
        UPDATE MAT_ZC_M T
        SET T.LOCK_LIKU = '0',
            (ACT_LEN_MIN, ACT_LEN_MAX ) = (SELECT
            LEN_MIN,
            LEN_MAX
            FROM
            SLM_ORDER_LINE
            WHERE
            ORD_LN_PK =  t.ORD_LN_PK
            AND VALIDFLAG = '1')
        WHERE T.PRO_NO = ?
    </query>
	<query id = "FrmPipeMagement.doNoCheckMat" desc = "审核不通过">
	UPDATE MAT_ZC_M T SET T.LOCK_LIKU = '0' WHERE T.PRO_NO = ?
	</query>
	
	<query id = "FrmPipeMagement.queryMatMentSByOrdLnDlyPk" desc = "查询商品物料信息">
<![CDATA[
	
  SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS TDACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.PRO_NO,
       DECODE(T1.LOCK_LIKU,'0','审核通过','1','未审核')LOCK_LIKU,
       T1.FIX_NUM,T2.LOCATION_NO,T1.IN_MOLD,T1.PIPMEMO,max(t1.FINISHPRO_MOLD) FINISHPRO_MOLD
  FROM MAT_ZC_M T1,YDM_ZC_BUTTRESS T2,slm_order_head T5
 WHERE T1.Mat_No=T2.Mat_No
   and T1.Ord_Pk = T5.Ord_Pk(+)
   and T1.PRODUCT_FLAG = '801403'
   and T1.ORD_LN_DLY_PK = ?
  
	]]>
</query>
<query id = "FrmPipeMagement.getOrderLineCraft" desc = "查询工艺文件状态">
SELECT COUNT(1)ACOUNT FROM CRAFT_ORD_DESIGN T WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1'
</query>
<query id = "FrmPipeMagement.selectProcessCode" desc = "查询工序代码">
SELECT T.PROCESS_CODE FROM COM_BASE_PLINE T WHERE T.PLINE_CODE = '#PLINE_CODE#'
</query>
<query id = "FrmPipeMagement.getJudgeId" desc = "生成利库单号">
SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(T.JUDGE_ID, 9)), 0) + 1, 5, 0) JUDGE_ID
    FROM QCM_LK_JUDGE_CHANGE T
   WHERE T.JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '_____'
</query>
<query id = "FrmPipeMagement.insertQcmLk" desc = "插入利库记录表">
 INSERT INTO QCM_LK_JUDGE_CHANGE(
        JUDGE_ID,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        ACT_COUNT,
        ACT_WEIGHT,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_STYLE,
        STD_STYLE_DESC,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        PLINE_CODE,
        PLINE_NAME,
        LOT_NO,
        STOVE_NO,
        CREATE_NAME,
        CREATE_TIME,
        IS_VD,
        PRO_ORDER_NO,
        MANAGE_NO,
        MANAGE_MENT,
        STD_CODE,
        STD_NAME,
        GRADECODE,
        GRADENAME,
        JUDGE_STD_NAME,
        CRAFT_NO,
        CRAFT_SEQ,
        CRAFT_PATH,
        OLD_CIC,
    SUPPLY_UNIT_CODE,
    SUPPLY_UNIT)
 VALUES( 
        '#JUDGE_ID#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#BATCH_GROUD_NO#',
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        '#MATERIAL_NO#',
        '#MATERIAL_NAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#ACT_DIMATER#',
        '#ACT_HEIGHT#',
        '#ACT_LEN#',
        '#ACT_LEN_MIN#',
        '#ACT_LEN_MAX#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#ORDER_SEQ_NO#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORD_LN_DLY_PK#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#LOT_NO#',
        '#STOVE_NO#',
        '#CREATE_NAME#',
        SYSDATE,
        '#IS_VD#',
        '#PRO_ORDER_NO#',
        '#MANAGE_NO#',
        '#MANAGE_MENT#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#JUDGE_STD_NAME#',
        '#CRAFT_NO#',
        '#CRAFT_SEQ#',
        '#CRAFT_PATH#',
        '#OLD_CIC#',
    '#SUPPLY_UNIT_CODE#',
    '#SUPPLY_UNIT#')
</query>
<query id = "FrmPipeMagement.selectMatZcLiku" desc = "查询物料信息">
<![CDATA[
SELECT T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       MAX(T.MATERIAL_NO) MATERIAL_NO,
       MAX(T.MATERIAL_NAME) MATERIAL_NAME,
       MAX(T.PRODUCCODE) PRODUCCODE,
       MAX(T.PRODUCNAME) PRODUCNAME,
       MAX(T.STEELCODE) STEELCODE,
       MAX(T.STEELNAME) STEELNAME,
       MAX(T.GRADECODE) GRADECODE,
       MAX(T.GRADENAME) GRADENAME,
       MAX(T.SPEC_CODE) SPEC_CODE,
       MAX(T.SPEC_NAME) SPEC_NAME,
       MAX(T.MODEL_CODE) MODEL_CODE,
       MAX(T.MODEL_DESC) MODEL_DESC,
       MAX(T.STD_CODE) STD_CODE,
       MAX(T.STD_NAME) STD_NAME,
       MAX(T.STD_STYLE) STD_STYLE,
       MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
       T.PRO_ORDER_NO,
       MAX(T.PLINE_CODE) PLINE_CODE,
       MAX(T.PLINE_NAME) PLINE_NAME,
       MAX(T.ACT_DIMATER) ACT_DIMATER,
       MAX(T.ACT_HEIGHT) ACT_HEIGHT,
       SUM(T.ACT_LEN) ACT_LEN,
       MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
       MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       MAX(T.BELONG_CODE) BELONG_CODE,
       MAX(T.BELONG_NAME) BELONG_NAME,
       T.JUDGE_STD_NAME
  FROM (SELECT *
          FROM (SELECT T1.*
                  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
                 WHERE T1.MAT_NO = T2.MAT_NO
                   AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T1.BATCH_NO = '#BATCH_NO#'
                   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                   AND T1.BELONG_CODE = '#BELONG_CODE#'
                   AND T1.ORD_PK = '#ORD_PK#'
                   AND T1.ORD_LN_PK = '#ORD_LN_PK#'
                   AND T1.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
                   AND T1.LOCK_ID = '#LOCK_ID#'
                 ORDER BY T1.MAT_NO DESC)
         WHERE ROWNUM <= #ACT_COUNT#) T
 GROUP BY T.LOT_NO,
          T.STOVE_NO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PRO_ORDER_NO,
          T.JUDGE_STD_NAME
]]>
</query>
<query id = "FrmPipeMagement.selectMatZcLiku1" desc = "查询利库库存信息">
SELECT T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       MAX(T.MATERIAL_NO) MATERIAL_NO,
       MAX(T.MATERIAL_NAME) MATERIAL_NAME,
       MAX(T.PRODUCCODE) PRODUCCODE,
       MAX(T.PRODUCNAME) PRODUCNAME,
       MAX(T.STEELCODE) STEELCODE,
       MAX(T.STEELNAME) STEELNAME,
       MAX(T.GRADECODE) GRADECODE,
       MAX(T.GRADENAME) GRADENAME,
       MAX(T.SPEC_CODE) SPEC_CODE,
       MAX(T.SPEC_NAME) SPEC_NAME,
       MAX(T.MODEL_CODE) MODEL_CODE,
       MAX(T.MODEL_DESC) MODEL_DESC,
       MAX(T.STD_CODE) STD_CODE,
       MAX(T.STD_NAME) STD_NAME,
       MAX(T.STD_STYLE) STD_STYLE,
       MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
       T.PRO_ORDER_NO,
       MAX(T.PLINE_CODE) PLINE_CODE,
       MAX(T.PLINE_NAME) PLINE_NAME,
       MAX(T.ACT_DIMATER) ACT_DIMATER,
       MAX(T.ACT_HEIGHT) ACT_HEIGHT,
       SUM(T.ACT_LEN) ACT_LEN,
       MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
       MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       MAX(T.BELONG_CODE) BELONG_CODE,
       MAX(T.BELONG_NAME) BELONG_NAME,
       MAX(T.JUDGE_STD_NAME)JUDGE_STD_NAME
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS T2
 WHERE T.MAT_NO = T2.MAT_NO
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND T.BELONG_CODE = '#NEWBELONG_CODE#'
   AND T.LOCK_ID = '#LOCK_ID#'
   AND T.LOCK_FLAG = '2'
 GROUP BY T.LOT_NO,
          T.STOVE_NO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PRO_ORDER_NO
</query>
<query id = "FrmPipeMagement.selectStoveVd" desc = "查询是否经过VD">
SELECT COUNT(1) ACOUNT FROM STL_VDS_OPTINFO T WHERE T.STOVE_NO = '#STOVE_NO#'
</query>
<query id = "FrmPipeMagement.selectManageN" desc = "查询工艺科室">
SELECT T5.UNIT_CODE_PROCESS,T5.UNIT_DESC_PROCESS,T3.CRAFT_NO,T3.CRAFT_SEQ,T3.CRAFT_PATH
       FROM CRAFT_ORD_DESIGN T3, CRAFT_ORD_DESIGN_MSC T4, COM_MSC T5
      WHERE T3.ORD_LN_PK = T4.ORD_LN_PK
        AND T3.VALIDFLAG = '1'
        AND T4.DESGIN_KEY = T3.DESGIN_KEY
        AND T5.MSC = T4.MSC
        AND T3.ORD_LN_PK = '#ORD_LN_PK#'
</query>
<query id = "FrmPipeMagement.selectManageNByNew" desc = "查询工艺科室(新流程)">
SELECT '002023005003' UNIT_CODE_PROCESS,'工艺科' UNIT_DESC_PROCESS,T3.CRAFT_NO,T3.CRAFT_SEQ,T3.CRAFT_PATH
       FROM CRAFT_ORD_DESIGN T3, CRAFT_ORD_DESIGN_MSC T4
      WHERE T3.ORD_LN_PK = T4.ORD_LN_PK
        AND T3.VALIDFLAG = '1'
        AND T4.DESGIN_KEY = T3.DESGIN_KEY
        AND T3.ORD_LN_PK = '#ORD_LN_PK#'
</query>
<query id = "FrmPipeMagement.selectMatZcProOrderNo" desc = "查询生产合同号">
SELECT T.PRO_ORDER_NO
  FROM MAT_ZC_M T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND T.BELONG_CODE = '#BELONG_CODE#'
   AND ROWNUM = 1
</query>
<query id = "FrmPipeMagement.selectPlnOrd" desc = "查询生产合同制程">
SELECT S1.WHOLE_BACKLOG
  FROM PLN_ORDER_ZG_S S,CRAFT_ORD_DESIGN_MSC_PL S1
 WHERE S.WHOLE_BACKLOG_DESC = S1.WHOLE_BACKLOG_DESC
 AND S.ORDER_NO || '/' || S.ORDER_SEQ = '#ORDER_NO#'
   AND ROWNUM = 1
</query>
<query id = "FrmPipeMagement.selectNewPlnOrd" desc = "查询新合同制程">
SELECT S1.WHOLE_BACKLOG
  FROM PLN_ORDER_ZG_S S,CRAFT_ORD_DESIGN_MSC_PL S1
 WHERE S.WHOLE_BACKLOG_DESC = S1.WHOLE_BACKLOG_DESC
 AND S.ORDER_NO = '#ORDER_NO#'
   AND S.ORDER_SEQ = '#ORDER_SEQ#'
   AND S.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND ROWNUM = 1
</query>
<query id = "FrmPipeMagement.selectMatNoStaus" desc = "查询材料状态">
SELECT T.* FROM MAT_ZC_M T WHERE T.MAT_NO = ?
</query>
<query id = "FrmPipeMagement.selectOldCic" desc = "查询原CIC">
SELECT T.CIC
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.TARGET = 'A'
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP = '0'
   AND ROWNUM = 1
</query>
    <query id = "FrmPipeMagement.insertInListOut" desc = "转移所属权">
        DECLARE
        V_INSTOCK_SEQ  YDM_ZC_INLIST.INSTOCK_SQE%TYPE := NULL;
        V_INCOUNT      NUMBER := 1;
        V_OUTSTOCK_SQE YDM_ZC_OUTLIST.OUTSTOCK_SQE%TYPE := NULL;
        V_OUTCOUNT     NUMBER := 1;
        BEGIN

        FOR MYROW IN (SELECT T.*,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        S.STORAGE_ATTR,
        S.STORAGE_ATTR_NAME,
        S.STORAGE_TYPE_NO,
        S.STORAGE_TYPE_NAME
        FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.MAT_NO = '#MAT_NO#'
        AND T.BELONG_CODE IN ('100101', '100103', '100102','100105')
        ) LOOP
        V_INSTOCK_SEQ  := '#INSTOCK_DOC#' || LPAD(V_INCOUNT, 4, 0);
        V_OUTSTOCK_SQE := '#OUTSTOCK_DOC#' || LPAD(V_OUTCOUNT, 4, 0);
        INSERT INTO YDM_ZC_INLIST
        (INSTOCK_SQE,
        INSTOCK_DOC,
        INSTOCK_TYPE_CODE,
        INSTOCK_TYPE_NAME,
        MAT_NO,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        PRODUCCODE,
        PRODUCNAME,
        STD_CODE,
        STD_NAME,
        STEELCODE,
        STEELNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        BELONG_CODE,
        BELONG_NAME,
        STORAGE_NO,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        PRODUCT_FLAG,
        MAT_STATUS,
        INSTOCK_TIME,
        ACT_LEN,
        JUDGE_STD_NAME,
        PLINE_CODE,
        PLINE_NAME,
        GRADECODE,
        GRADENAME,
        BAL_YEAR_MONTH,
        IN_TIME_F,
        PIPMEMO,
        MAT_ORIGIN_CODE,
        MAT_ORIGIN_NAME,
        SOURE_CODE,
        SOURE_NAME,
        MATERIAL_NO,
        MATERIAL_NAME,
        IN_MOLD,
        PACK_NO,
        PRO_ORDER_NO)
        VALUES
        ('#INSTOCK_SQE#',
        '#INSTOCK_DOC#',
        '800712',
        '转所属权入库',
        MYROW.MAT_NO,
        MYROW.LOT_NO,
        MYROW.STOVE_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.ACT_DIMATER,
        MYROW.ACT_HEIGHT,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        '#NEWBELONG_CODE#',
        '#NEWBELONG_NAME#',
        MYROW.STORAGE_NO,
        MYROW.MEMO,
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        MYROW.ACT_LEN,
        MYROW.JUDGE_STD_NAME,
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        MYROW.GRADECODE,
        MYROW.GRADENAME,
        '#BAL_YEAR_MONTH#',
        MYROW.INSTOCK_TIME,
        MYROW.PIPMEMO,
        '801302',
        '产线',
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.IN_MOLD,
        MYROW.PACK_NO,
        MYROW.PRO_ORDER_NO);
        INSERT INTO YDM_ZC_INLIST_XS
        (INSTOCK_SQE,
        INSTOCK_DOC,
        INSTOCK_TYPE_CODE,
        INSTOCK_TYPE_NAME,
        MAT_NO,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        PRODUCCODE,
        PRODUCNAME,
        STD_CODE,
        STD_NAME,
        STEELCODE,
        STEELNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        BELONG_CODE,
        BELONG_NAME,
        STORAGE_NO,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        PRODUCT_FLAG,
        MAT_STATUS,
        INSTOCK_TIME,
        ACT_LEN,
        JUDGE_STD_NAME,
        PLINE_CODE,
        PLINE_NAME,
        GRADECODE,
        GRADENAME,
        BAL_YEAR_MONTH,
        IN_TIME_F,
        PIPMEMO,
        MAT_ORIGIN_CODE,
        MAT_ORIGIN_NAME,
        SOURE_CODE,
        SOURE_NAME,
        MATERIAL_NO,
        MATERIAL_NAME,
        IN_MOLD,
        PACK_NO,
        PRO_ORDER_NO)
        VALUES
        ('#INSTOCK_SQE#',
        '#INSTOCK_DOC#',
        '800712',
        '转所属权入库',
        MYROW.MAT_NO,
        MYROW.LOT_NO,
        MYROW.STOVE_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.ACT_DIMATER,
        MYROW.ACT_HEIGHT,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        '#NEWBELONG_CODE#',
        '#NEWBELONG_NAME#',
        MYROW.STORAGE_NO,
        MYROW.MEMO,
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        MYROW.ACT_LEN,
        MYROW.JUDGE_STD_NAME,
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        MYROW.GRADECODE,
        MYROW.GRADENAME,
        '#BAL_YEAR_MONTH#',
        MYROW.INSTOCK_TIME,
        MYROW.PIPMEMO,
        '801302',
        '产线',
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.IN_MOLD,
        MYROW.PACK_NO,
        MYROW.PRO_ORDER_NO);
        INSERT INTO YDM_ZC_OUTLIST
        (OUTSTOCK_SQE,
        OUTSTOCK_DOC,
        OUTSTOCK_TYPE_CODE,
        OUTSTOCK_TYPE_NAME,
        MAT_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STD_CODE,
        STD_NAME,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        PRO_ORDER_NO,
        PLINE_CODE,
        PLINE_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        BELONG_CODE,
        BELONG_NAME,
        STORAGE_NO,
        LOCATION_NO,
        STORAGE_ATTR,
        STORAGE_ATTR_NAME,
        STORAGE_TYPE_NO,
        STORAGE_TYPE_NAME,
        OUTSTOCK_TIME,
        CREATE_NAME,
        CREATE_TIME,
        PRODUCT_FLAG,
        MAT_STATUS,
        JUDGE_STD_NAME,
        JUDGE_STD_CODE,
        BAL_YEAR_MONTH,
        FINISHPRO_MOLD,
        IN_MOLD)
        VALUES
        ('#OUTSTOCK_SQE#',
        '#OUTSTOCK_DOC#',
        '800812',
        '转所属权出库',
        MYROW.MAT_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.GRADECODE,
        MYROW.GRADENAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.PRO_ORDER_NO,
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        MYROW.ACT_DIMATER,
        MYROW.HEIGHT,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        MYROW.ACT_THEORY_WEIGHT,
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        MYROW.STORAGE_NO,
        MYROW.LOCATION_NO,
        MYROW.STORAGE_ATTR,
        MYROW.STORAGE_ATTR_NAME,
        MYROW.STORAGE_TYPE_NO,
        MYROW.STORAGE_TYPE_NAME,
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        MYROW.JUDGE_STD_NAME,
        MYROW.JUDGE_STD_CODE,
        '#BAL_YEAR_MONTH#',
        MYROW.FINISHPRO_MOLD,
        MYROW.IN_MOLD);
        INSERT INTO YDM_ZC_OUTLIST_XS
        (OUTSTOCK_SQE,
        OUTSTOCK_DOC,
        OUTSTOCK_TYPE_CODE,
        OUTSTOCK_TYPE_NAME,
        MAT_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STD_CODE,
        STD_NAME,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        PRO_ORDER_NO,
        PLINE_CODE,
        PLINE_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        BELONG_CODE,
        BELONG_NAME,
        STORAGE_NO,
        LOCATION_NO,
        STORAGE_ATTR,
        STORAGE_ATTR_NAME,
        STORAGE_TYPE_NO,
        STORAGE_TYPE_NAME,
        OUTSTOCK_TIME,
        CREATE_NAME,
        CREATE_TIME,
        PRODUCT_FLAG,
        MAT_STATUS,
        JUDGE_STD_NAME,
        JUDGE_STD_CODE,
        BAL_YEAR_MONTH,
        FINISHPRO_MOLD,
        IN_MOLD)
        VALUES
        ('#OUTSTOCK_SQE#',
        '#OUTSTOCK_DOC#',
        '800812',
        '转所属权出库',
        MYROW.MAT_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.GRADECODE,
        MYROW.GRADENAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.PRO_ORDER_NO,
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        MYROW.ACT_DIMATER,
        MYROW.HEIGHT,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        MYROW.ACT_THEORY_WEIGHT,
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        MYROW.STORAGE_NO,
        MYROW.LOCATION_NO,
        MYROW.STORAGE_ATTR,
        MYROW.STORAGE_ATTR_NAME,
        MYROW.STORAGE_TYPE_NO,
        MYROW.STORAGE_TYPE_NAME,
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        MYROW.JUDGE_STD_NAME,
        MYROW.JUDGE_STD_CODE,
        '#BAL_YEAR_MONTH#',
        MYROW.FINISHPRO_MOLD,
        MYROW.IN_MOLD);
        END LOOP;
        END;
    </query>


    <query id="FrmPipeMagement.queryMatTH" desc="查询天淮成品材料信息">
        <![CDATA[
            SELECT
               T1.MAT_NO,
               T1.BELONG_CODE,
               T1.BELONG_NAME,
               T1.JUDGE_STOVE_NO,
               T1.BATCH_NO,
               T1.BATCH_GROUD_NO,
               T1.PLINE_CODE,
               T1.PRODUCT_FLAG,
               T1.MAT_STATUS,
               T1.SPEC_CODE,
               T1.SPEC_NAME,
               T1.ACT_DIMATER,
               T1.ACT_HEIGHT,
               T1.ACT_LEN_MIN,
               T1.ACT_LEN_MAX,
               T1.PRODUCCODE,
               T1.PRODUCNAME,
               T1.MATERIAL_NO,
               T1.MATERIAL_NAME,
               T1.STEELCODE,
               T1.STEELNAME,
               T1.STD_CODE,
               T1.STD_NAME,
               T1.ORDER_NO,
               T1.ORDER_SEQ,
               T1.ORDER_SEQ_NO,
               T1.ORD_PK,
               T1.ORD_LN_PK,
               T1.ORD_LN_DLY_PK,
               T1.PRO_ORDER_NO,
               T1.PRO_ORDER_ID,
               TO_CHAR(T1.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
               (SELECT T4.STORAGE_NAME
                  FROM YDM_BS_STORAGE T4
                 WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
               T2.STORAGE_NO,
               T2.LOCATION_NO,
               (SELECT T5.LOCATION_NAME FROM YDM_BS_LOCATION T5 WHERE T5.LOCATION_NO = T2.LOCATION_NO)LOCATION_NAME,
               T1.MODEL_CODE,
               T1.MODEL_DESC,
               T1.STD_STYLE,
               T1.STD_STYLE_DESC,
               T1.MEMO,
               T1.PIPMEMO,
               T1.JUDGE_RESULT_CODE,
               T1.JUDGE_RESULT,
               NVL(T1.ACT_LEN, 0) AS ACT_LEN,
               NVL(T1.ACT_COUNT, 0) AS ACT_COUNT,
               NVL(T1.ACT_COUNT,0) AS LKACT_COUNT,
               NVL(T1.ACT_WEIGHT, 0) AS ACT_WEIGHT,
               NVL(T1.ACT_THEORY_WEIGHT, 0) AS ACT_THEORY_WEIGHT,
               T1.STD_NAME AS JUDGE_STD_NAME,
               T1.LOCK_FLAG,
               T1.MNG_LOCK_FLAG,
               T1.ZBS_FLAG,
               T1.FIX_NUM,
               T1.SUPPLY_UNIT_CODE,
               T1.SUPPLY_UNIT,
               T1.LOCK_ID
          FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
         WHERE T1.MAT_NO = T2.MAT_NO
         AND T1.INSTOCK_DOC IS NULL
         AND T1.ORDER_NO LIKE 'TH%'
	]]>
    </query>

    <query id="FrmPipeMagement.queryMatTHLog" desc="查询天淮成品材料信息">
        <![CDATA[
             SELECT
                   T.ID,
                   T.OLD_ORDER_NO,
                   T.OLD_ORDER_SEQ,
                   T.OLD_DELIVERY_NO,
                   T.NEW_ORDER_NO,
                   T.NEW_ORDER_SEQ,
                   T.NEW_DELIVERY_NO,
                   T.MAT_NO,
                   T.JUDGE_STOVE_NO,
                   T.BATCH_NO,
                   T.BATCH_GROUD_NO,
                   T.CREATE_NAME,
                   TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME
             FROM MAT_TH_CHANG_LOG T
             WHERE
            1=1
	]]>
    </query>

    <query id="FrmPipeMagement.changeMatTH" desc="修改天淮成品材料合同信息">
        <![CDATA[
            DECLARE
              V_INSTOCK_SEQ  YDM_ZC_INLIST.INSTOCK_SQE%TYPE := NULL;
              V_INCOUNT      NUMBER := 1;
              V_OUTSTOCK_SQE YDM_ZC_OUTLIST.OUTSTOCK_SQE%TYPE := NULL;
              V_OUTCOUNT     NUMBER := 1;
            BEGIN
              SELECT NVL(MAX(SUBSTR(T.INSTOCK_SQE, LENGTH(T.INSTOCK_SQE) - 4)), 0) + 1
                INTO V_INCOUNT
                FROM YDM_ZC_INLIST T
               WHERE T.INSTOCK_DOC = '#INSTOCK_DOC#';

              SELECT NVL(MAX(SUBSTR(T.OUTSTOCK_SQE, LENGTH(T.OUTSTOCK_SQE) - 4)), 0) + 1
                INTO V_OUTCOUNT
                FROM YDM_ZC_OUTLIST T
               WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
              FOR MYROW IN (SELECT T.*,
                                           S.STORAGE_NO,
                                           S.LOCATION_NO,
                                           S.LARY_NO,
                                           S.LOC_NO,
                                           S.STORAGE_ATTR,
                                           S.STORAGE_ATTR_NAME,
                                           S.STORAGE_TYPE_NO,
                                           S.STORAGE_TYPE_NAME
                                      FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
                                     WHERE T.MAT_NO = S.MAT_NO
                                        and T.ORDER_NO = ?
                                        AND T.ORDER_SEQ = ?
                                        AND T.ORDER_SEQ_NO = ?
                                        AND T.MAT_NO = ?
                                     ORDER BY T.MAT_NO ASC
                             ) LOOP
                V_INSTOCK_SEQ  := '#INSTOCK_DOC#' || LPAD(V_INCOUNT, 4, 0);
                V_OUTSTOCK_SQE := '#OUTSTOCK_DOC#' || LPAD(V_OUTCOUNT, 4, 0);
                UPDATE MAT_ZC_M T1
                   SET T1.ORDER_NO          = '#ORDER_NO#',
                       T1.ORDER_SEQ         = '#ORDER_SEQ#',
                       T1.ORDER_SEQ_NO      = '#ORDER_SEQ_NO#',
                       T1.ORD_PK            = '#ORD_PK#',
                       T1.ORD_LN_PK         = '#ORD_LN_PK#',
                       T1.ORD_LN_DLY_PK     = '#ORD_LN_DLY_PK#',
                       T1.BELONG_CODE       = '#BELONG_CODE#',
                       T1.BELONG_NAME       = '#BELONG_NAME#'
                 WHERE
                    T1.ORDER_NO = MYROW.ORDER_NO
                    AND T1.ORDER_SEQ = MYROW.ORDER_SEQ
                    AND T1.ORDER_SEQ_NO = MYROW.ORDER_SEQ_NO
                    AND T1.MAT_NO = MYROW.MAT_NO;
                    
                    UPDATE MAT_ZC_M_XS T1
                   SET T1.ORDER_NO          = '#ORDER_NO#',
                       T1.ORDER_SEQ         = '#ORDER_SEQ#',
                       T1.ORDER_SEQ_NO      = '#ORDER_SEQ_NO#',
                       T1.ORD_PK            = '#ORD_PK#',
                       T1.ORD_LN_PK         = '#ORD_LN_PK#',
                       T1.ORD_LN_DLY_PK     = '#ORD_LN_DLY_PK#',
                       T1.BELONG_CODE       = '#BELONG_CODE#',
                       T1.BELONG_NAME       = '#BELONG_NAME#'
                 WHERE
                    T1.ORDER_NO = MYROW.ORDER_NO
                    AND T1.ORDER_SEQ = MYROW.ORDER_SEQ
                    AND T1.ORDER_SEQ_NO = MYROW.ORDER_SEQ_NO
                    AND T1.MAT_NO = MYROW.MAT_NO;
                    
                INSERT INTO YDM_ZC_INLIST
                  (INSTOCK_SQE,
                   INSTOCK_DOC,
                   INSTOCK_TYPE_CODE,
                   INSTOCK_TYPE_NAME,
                   MAT_NO,
                   LOT_NO,
                   STOVE_NO,
                   JUDGE_STOVE_NO,
                   BATCH_NO,
                   BATCH_GROUD_NO,
                   PRODUCCODE,
                   PRODUCNAME,
                   STD_CODE,
                   STD_NAME,
                   STEELCODE,
                   STEELNAME,
                   STD_STYLE,
                   STD_STYLE_DESC,
                   SPEC_CODE,
                   SPEC_NAME,
                   MODEL_CODE,
                   MODEL_DESC,
                   ACT_DIMATER,
                   ACT_HEIGHT,
                   ACT_LEN_MIN,
                   ACT_LEN_MAX,
                   ACT_COUNT,
                   ACT_WEIGHT,
                   BELONG_CODE,
                   BELONG_NAME,
                   STORAGE_NO,
                   MEMO,
                   CREATE_NAME,
                   CREATE_TIME,
                   PRODUCT_FLAG,
                   MAT_STATUS,
                   INSTOCK_TIME,
                   ACT_LEN,
                   JUDGE_STD_NAME,
                   PLINE_CODE,
                   PLINE_NAME,
                   GRADECODE,
                   GRADENAME,
                   BAL_YEAR_MONTH,
                   IN_TIME_F,
                   PIPMEMO,
                   MAT_ORIGIN_CODE,
                   MAT_ORIGIN_NAME,
                   SOURE_CODE,
                   SOURE_NAME,
                   MATERIAL_NO,
                   MATERIAL_NAME,
                   IN_MOLD,
                   PACK_NO,
                   PRO_ORDER_NO,
                   SUPPLY_UNIT_CODE,
                   SUPPLY_UNIT,
                   IS_DEALER,
                   PROCESS_CDOE,
                   PROCESS_DESC)
                VALUES
                  (V_INSTOCK_SEQ,
                   '#INSTOCK_DOC#',
                   '800712',
                   '转所属权入库',
                   MYROW.MAT_NO,
                   MYROW.LOT_NO,
                   MYROW.STOVE_NO,
                   MYROW.JUDGE_STOVE_NO,
                   MYROW.BATCH_NO,
                   MYROW.BATCH_GROUD_NO,
                   MYROW.PRODUCCODE,
                   MYROW.PRODUCNAME,
                   MYROW.STD_CODE,
                   MYROW.STD_NAME,
                   MYROW.STEELCODE,
                   MYROW.STEELNAME,
                   MYROW.STD_STYLE,
                   MYROW.STD_STYLE_DESC,
                   MYROW.SPEC_CODE,
                   MYROW.SPEC_NAME,
                   MYROW.MODEL_CODE,
                   MYROW.MODEL_DESC,
                   MYROW.ACT_DIMATER,
                   MYROW.ACT_HEIGHT,
                   MYROW.ACT_LEN_MIN,
                   MYROW.ACT_LEN_MAX,
                   MYROW.ACT_COUNT,
                   MYROW.ACT_WEIGHT,
                   '#BELONG_CODE#',
                   '#BELONG_NAME#',
                   MYROW.STORAGE_NO,
                   MYROW.MEMO,
                   '#CREATE_NAME#',
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   MYROW.PRODUCT_FLAG,
                   MYROW.MAT_STATUS,
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   MYROW.ACT_LEN,
                   MYROW.JUDGE_STD_NAME,
                   MYROW.PLINE_CODE,
                   MYROW.PLINE_NAME,
                   MYROW.GRADECODE,
                   MYROW.GRADENAME,
                   '#BAL_YEAR_MONTH#',
                   MYROW.INSTOCK_TIME,
                   MYROW.PIPMEMO,
                   '801302',
                   '产线',
                   MYROW.BELONG_CODE,
                   MYROW.BELONG_NAME,
                   MYROW.MATERIAL_NO,
                   MYROW.MATERIAL_NAME,
                   MYROW.IN_MOLD,
                   MYROW.PACK_NO,
                   MYROW.PRO_ORDER_NO,
                   MYROW.SUPPLY_UNIT_CODE,
                   MYROW.SUPPLY_UNIT,
                   MYROW.IS_DEALER,
                   MYROW.PROCESS_CDOE,
                   MYROW.PROCESS_DESC);
                   
                   INSERT INTO YDM_ZC_INLIST_XS
                  (INSTOCK_SQE,
                   INSTOCK_DOC,
                   INSTOCK_TYPE_CODE,
                   INSTOCK_TYPE_NAME,
                   MAT_NO,
                   LOT_NO,
                   STOVE_NO,
                   JUDGE_STOVE_NO,
                   BATCH_NO,
                   BATCH_GROUD_NO,
                   PRODUCCODE,
                   PRODUCNAME,
                   STD_CODE,
                   STD_NAME,
                   STEELCODE,
                   STEELNAME,
                   STD_STYLE,
                   STD_STYLE_DESC,
                   SPEC_CODE,
                   SPEC_NAME,
                   MODEL_CODE,
                   MODEL_DESC,
                   ACT_DIMATER,
                   ACT_HEIGHT,
                   ACT_LEN_MIN,
                   ACT_LEN_MAX,
                   ACT_COUNT,
                   ACT_WEIGHT,
                   BELONG_CODE,
                   BELONG_NAME,
                   STORAGE_NO,
                   MEMO,
                   CREATE_NAME,
                   CREATE_TIME,
                   PRODUCT_FLAG,
                   MAT_STATUS,
                   INSTOCK_TIME,
                   ACT_LEN,
                   JUDGE_STD_NAME,
                   PLINE_CODE,
                   PLINE_NAME,
                   GRADECODE,
                   GRADENAME,
                   BAL_YEAR_MONTH,
                   IN_TIME_F,
                   PIPMEMO,
                   MAT_ORIGIN_CODE,
                   MAT_ORIGIN_NAME,
                   SOURE_CODE,
                   SOURE_NAME,
                   MATERIAL_NO,
                   MATERIAL_NAME,
                   IN_MOLD,
                   PACK_NO,
                   PRO_ORDER_NO,
                   SUPPLY_UNIT_CODE,
                   SUPPLY_UNIT,
                   IS_DEALER,
                   PROCESS_CDOE,
                   PROCESS_DESC)
                VALUES
                  (V_INSTOCK_SEQ,
                   '#INSTOCK_DOC#',
                   '800712',
                   '转所属权入库',
                   MYROW.MAT_NO,
                   MYROW.LOT_NO,
                   MYROW.STOVE_NO,
                   MYROW.JUDGE_STOVE_NO,
                   MYROW.BATCH_NO,
                   MYROW.BATCH_GROUD_NO,
                   MYROW.PRODUCCODE,
                   MYROW.PRODUCNAME,
                   MYROW.STD_CODE,
                   MYROW.STD_NAME,
                   MYROW.STEELCODE,
                   MYROW.STEELNAME,
                   MYROW.STD_STYLE,
                   MYROW.STD_STYLE_DESC,
                   MYROW.SPEC_CODE,
                   MYROW.SPEC_NAME,
                   MYROW.MODEL_CODE,
                   MYROW.MODEL_DESC,
                   MYROW.ACT_DIMATER,
                   MYROW.ACT_HEIGHT,
                   MYROW.ACT_LEN_MIN,
                   MYROW.ACT_LEN_MAX,
                   MYROW.ACT_COUNT,
                   MYROW.ACT_WEIGHT,
                   '#BELONG_CODE#',
                   '#BELONG_NAME#',
                   MYROW.STORAGE_NO,
                   MYROW.MEMO,
                   '#CREATE_NAME#',
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   MYROW.PRODUCT_FLAG,
                   MYROW.MAT_STATUS,
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   MYROW.ACT_LEN,
                   MYROW.JUDGE_STD_NAME,
                   MYROW.PLINE_CODE,
                   MYROW.PLINE_NAME,
                   MYROW.GRADECODE,
                   MYROW.GRADENAME,
                   '#BAL_YEAR_MONTH#',
                   MYROW.INSTOCK_TIME,
                   MYROW.PIPMEMO,
                   '801302',
                   '产线',
                   MYROW.BELONG_CODE,
                   MYROW.BELONG_NAME,
                   MYROW.MATERIAL_NO,
                   MYROW.MATERIAL_NAME,
                   MYROW.IN_MOLD,
                   MYROW.PACK_NO,
                   MYROW.PRO_ORDER_NO,
                   MYROW.SUPPLY_UNIT_CODE,
                   MYROW.SUPPLY_UNIT,
                   MYROW.IS_DEALER,
                   MYROW.PROCESS_CDOE,
                   MYROW.PROCESS_DESC);
                   
                INSERT INTO YDM_ZC_OUTLIST
                  (OUTSTOCK_SQE,
                   OUTSTOCK_DOC,
                   OUTSTOCK_TYPE_CODE,
                   OUTSTOCK_TYPE_NAME,
                   MAT_NO,
                   JUDGE_STOVE_NO,
                   BATCH_NO,
                   BATCH_GROUD_NO,
                   MATERIAL_NO,
                   MATERIAL_NAME,
                   PRODUCCODE,
                   PRODUCNAME,
                   STD_CODE,
                   STD_NAME,
                   GRADECODE,
                   GRADENAME,
                   STEELCODE,
                   STEELNAME,
                   STD_STYLE,
                   STD_STYLE_DESC,
                   SPEC_CODE,
                   SPEC_NAME,
                   MODEL_CODE,
                   MODEL_DESC,
                   PRO_ORDER_NO,
                   PLINE_CODE,
                   PLINE_NAME,
                   ACT_DIMATER,
                   ACT_HEIGHT,
                   ACT_LEN,
                   ACT_LEN_MIN,
                   ACT_LEN_MAX,
                   ACT_COUNT,
                   ACT_WEIGHT,
                   ACT_THEORY_WEIGHT,
                   BELONG_CODE,
                   BELONG_NAME,
                   STORAGE_NO,
                   LOCATION_NO,
                   STORAGE_ATTR,
                   STORAGE_ATTR_NAME,
                   STORAGE_TYPE_NO,
                   STORAGE_TYPE_NAME,
                   OUTSTOCK_TIME,
                   CREATE_NAME,
                   CREATE_TIME,
                   PRODUCT_FLAG,
                   MAT_STATUS,
                   JUDGE_STD_NAME,
                   JUDGE_STD_CODE,
                   BAL_YEAR_MONTH,
                   FINISHPRO_MOLD,
                   IN_MOLD,
                   SUPPLY_UNIT_CODE,
                   SUPPLY_UNIT,
                   IS_DEALER,
                   PROCESS_CDOE,
                   PROCESS_DESC)
                VALUES
                  (V_OUTSTOCK_SQE,
                   '#OUTSTOCK_DOC#',
                   '800812',
                   '转所属权出库',
                   MYROW.MAT_NO,
                   MYROW.JUDGE_STOVE_NO,
                   MYROW.BATCH_NO,
                   MYROW.BATCH_GROUD_NO,
                   MYROW.MATERIAL_NO,
                   MYROW.MATERIAL_NAME,
                   MYROW.PRODUCCODE,
                   MYROW.PRODUCNAME,
                   MYROW.STD_CODE,
                   MYROW.STD_NAME,
                   MYROW.GRADECODE,
                   MYROW.GRADENAME,
                   MYROW.STEELCODE,
                   MYROW.STEELNAME,
                   MYROW.STD_STYLE,
                   MYROW.STD_STYLE_DESC,
                   MYROW.SPEC_CODE,
                   MYROW.SPEC_NAME,
                   MYROW.MODEL_CODE,
                   MYROW.MODEL_DESC,
                   MYROW.PRO_ORDER_NO,
                   MYROW.PLINE_CODE,
                   MYROW.PLINE_NAME,
                   MYROW.ACT_DIMATER,
                   MYROW.HEIGHT,
                   MYROW.ACT_LEN,
                   MYROW.ACT_LEN_MIN,
                   MYROW.ACT_LEN_MAX,
                   MYROW.ACT_COUNT,
                   MYROW.ACT_WEIGHT,
                   MYROW.ACT_THEORY_WEIGHT,
                   MYROW.BELONG_CODE,
                   MYROW.BELONG_NAME,
                   MYROW.STORAGE_NO,
                   MYROW.LOCATION_NO,
                   MYROW.STORAGE_ATTR,
                   MYROW.STORAGE_ATTR_NAME,
                   MYROW.STORAGE_TYPE_NO,
                   MYROW.STORAGE_TYPE_NAME,
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   '#CREATE_NAME#',
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   MYROW.PRODUCT_FLAG,
                   MYROW.MAT_STATUS,
                   MYROW.JUDGE_STD_NAME,
                   MYROW.JUDGE_STD_CODE,
                   '#BAL_YEAR_MONTH#',
                   MYROW.FINISHPRO_MOLD,
                   MYROW.IN_MOLD,
                   MYROW.SUPPLY_UNIT_CODE,
                   MYROW.SUPPLY_UNIT,
                   MYROW.IS_DEALER,
                   MYROW.PROCESS_CDOE,
                   MYROW.PROCESS_DESC);
                   
                   INSERT INTO YDM_ZC_OUTLIST_XS
                  (OUTSTOCK_SQE,
                   OUTSTOCK_DOC,
                   OUTSTOCK_TYPE_CODE,
                   OUTSTOCK_TYPE_NAME,
                   MAT_NO,
                   JUDGE_STOVE_NO,
                   BATCH_NO,
                   BATCH_GROUD_NO,
                   MATERIAL_NO,
                   MATERIAL_NAME,
                   PRODUCCODE,
                   PRODUCNAME,
                   STD_CODE,
                   STD_NAME,
                   GRADECODE,
                   GRADENAME,
                   STEELCODE,
                   STEELNAME,
                   STD_STYLE,
                   STD_STYLE_DESC,
                   SPEC_CODE,
                   SPEC_NAME,
                   MODEL_CODE,
                   MODEL_DESC,
                   PRO_ORDER_NO,
                   PLINE_CODE,
                   PLINE_NAME,
                   ACT_DIMATER,
                   ACT_HEIGHT,
                   ACT_LEN,
                   ACT_LEN_MIN,
                   ACT_LEN_MAX,
                   ACT_COUNT,
                   ACT_WEIGHT,
                   ACT_THEORY_WEIGHT,
                   BELONG_CODE,
                   BELONG_NAME,
                   STORAGE_NO,
                   LOCATION_NO,
                   STORAGE_ATTR,
                   STORAGE_ATTR_NAME,
                   STORAGE_TYPE_NO,
                   STORAGE_TYPE_NAME,
                   OUTSTOCK_TIME,
                   CREATE_NAME,
                   CREATE_TIME,
                   PRODUCT_FLAG,
                   MAT_STATUS,
                   JUDGE_STD_NAME,
                   JUDGE_STD_CODE,
                   BAL_YEAR_MONTH,
                   FINISHPRO_MOLD,
                   IN_MOLD,
                   SUPPLY_UNIT_CODE,
                   SUPPLY_UNIT,
                   IS_DEALER,
                   PROCESS_CDOE,
                   PROCESS_DESC)
                VALUES
                  (V_OUTSTOCK_SQE,
                   '#OUTSTOCK_DOC#',
                   '800812',
                   '转所属权出库',
                   MYROW.MAT_NO,
                   MYROW.JUDGE_STOVE_NO,
                   MYROW.BATCH_NO,
                   MYROW.BATCH_GROUD_NO,
                   MYROW.MATERIAL_NO,
                   MYROW.MATERIAL_NAME,
                   MYROW.PRODUCCODE,
                   MYROW.PRODUCNAME,
                   MYROW.STD_CODE,
                   MYROW.STD_NAME,
                   MYROW.GRADECODE,
                   MYROW.GRADENAME,
                   MYROW.STEELCODE,
                   MYROW.STEELNAME,
                   MYROW.STD_STYLE,
                   MYROW.STD_STYLE_DESC,
                   MYROW.SPEC_CODE,
                   MYROW.SPEC_NAME,
                   MYROW.MODEL_CODE,
                   MYROW.MODEL_DESC,
                   MYROW.PRO_ORDER_NO,
                   MYROW.PLINE_CODE,
                   MYROW.PLINE_NAME,
                   MYROW.ACT_DIMATER,
                   MYROW.HEIGHT,
                   MYROW.ACT_LEN,
                   MYROW.ACT_LEN_MIN,
                   MYROW.ACT_LEN_MAX,
                   MYROW.ACT_COUNT,
                   MYROW.ACT_WEIGHT,
                   MYROW.ACT_THEORY_WEIGHT,
                   MYROW.BELONG_CODE,
                   MYROW.BELONG_NAME,
                   MYROW.STORAGE_NO,
                   MYROW.LOCATION_NO,
                   MYROW.STORAGE_ATTR,
                   MYROW.STORAGE_ATTR_NAME,
                   MYROW.STORAGE_TYPE_NO,
                   MYROW.STORAGE_TYPE_NAME,
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   '#CREATE_NAME#',
                   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
                   MYROW.PRODUCT_FLAG,
                   MYROW.MAT_STATUS,
                   MYROW.JUDGE_STD_NAME,
                   MYROW.JUDGE_STD_CODE,
                   '#BAL_YEAR_MONTH#',
                   MYROW.FINISHPRO_MOLD,
                   MYROW.IN_MOLD,
                   MYROW.SUPPLY_UNIT_CODE,
                   MYROW.SUPPLY_UNIT,
                   MYROW.IS_DEALER,
                   MYROW.PROCESS_CDOE,
                   MYROW.PROCESS_DESC);
                   
                V_INCOUNT  := V_INCOUNT + 1;
                V_OUTCOUNT := V_OUTCOUNT + 1;
              END LOOP;
            END;
        ]]>
    </query>

    <query id="FrmPipeMagement.changeMatThLog" desc="修改天淮成品材料合同信息">
        <![CDATA[
             INSERT INTO MAT_TH_CHANG_LOG(
                    OLD_ORDER_NO,
                    OLD_ORDER_SEQ,
                    OLD_DELIVERY_NO,
                    NEW_ORDER_NO,
                    NEW_ORDER_SEQ,
                    NEW_DELIVERY_NO,
                    MAT_NO,
                    JUDGE_STOVE_NO,
                    BATCH_NO,
                    BATCH_GROUD_NO,
                    CREATE_NAME,
                    CREATE_TIME)
             VALUES(
                    '#OLD_ORDER_NO#',
                    '#OLD_ORDER_SEQ#',
                    '#OLD_DELIVERY_NO#',
                    '#NEW_ORDER_NO#',
                    '#NEW_ORDER_SEQ#',
                    '#NEW_DELIVERY_NO#',
                    '#MAT_NO#',
                    '#JUDGE_STOVE_NO#',
                    '#BATCH_NO#',
                    '#BATCH_GROUD_NO#',
                    '#CREATE_NAME#',
                    SYSDATE)
        ]]>
    </query>
</queryMap>