<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "倒运出库管理">
<query id = "FrmFilpOutStorage.doQueryData" desc = "查询库存数据">
 SELECT (SELECT T2.BASENAME FROM COM_BASE_INFO T2 WHERE T2.BASECODE = T.PRODUCT_FLAG)PRODUCT_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
       T.MAT_STATUS AS MAT_STATUS_CODE,
       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,
       MAX(T.PRO_ORDER_NO)PRO_ORDER_NO,
       MAX(T.PROCESS_CDOE)PROCESS_CDOE,
       MAX(T.PROCESS_DESC)PROCESS_DESC,
       T.NEXT_PROCESS_CDOE,
       T.NEXT_PROCESS_DESC,
       T.PLINE_CODE,
       T.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,
       T.BELONG_CODE,
       T.BELONG_NAME,
       --T.MAT_GOWHERE_CODE,
       --T.MAT_GOWHERE_NAME,
       --T.MAT_GOWHERE_NAME AS UPDATE_GO_WHERE_CODE,
       T.JUDGE_RESULT,
       MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
       MAX(T.JUDGE_MAKER)JUDGE_MAKER,
       MAX(T.JUDGE_STD_NAME)JUDGE_STD_NAME,
       T.PIPMEMO,
       DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '废品') QCM_STAUS,
       MAX(T.TARGET)TARGET,
       T.FLAG_STOVE_NO_ZG,
       T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
       (CASE
         WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
          (SELECT T1.ORDER_NO || '/' || T1.ORDER_SEQ
             FROM PLN_ORDER_DBK_S T1
            WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
              AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
         WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
          (SELECT T2.ORDER_NO || '/' || T2.ORDER_SEQ
             FROM PLN_ORDER_RCL_S T2
            WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
              AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
         WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
          (SELECT T3.ORDER_NO || '/' || T3.ORDER_SEQ
             FROM PLN_ORDER_JGX_S T3
            WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
              AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
         ELSE
          NULL
       END) ORDER_NO_NEXT,
       --MAX(T.JUDGE_STD_DES)JUDGE_STD_DES,
       S.STORAGE_NO,
       S.LOCATION_NO,
       (SELECT S2.LOCATION_NAME FROM YDM_BS_LOCATION S2 WHERE S2.LOCATION_NO = S.LOCATION_NO)LOCATION_NAME,
       S.LARY_NO,
       S.LOC_NO,
       T.PRO_PLAN_ID_NEXT,
       T.GX_PLAN_NO_NEXT,
       (SELECT S1.STORAGE_NAME
          FROM YDM_BS_STORAGE S1
         WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
      (CASE
         WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
          (SELECT (SELECT T5.STORAGE_NAME FROM COM_BASE_PLINE T4,YDM_BS_STORAGE T5 WHERE T4.IN_REPOSITORY = T5.STORAGE_NO
          AND T4.PLINE_CODE = T1.PLINE_CODE)
             FROM PLN_ZY_DBK_M T1
            WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
              AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
              AND ROWNUM = 1)
         WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
          (SELECT (SELECT T7.STORAGE_NAME FROM COM_BASE_PLINE T6,YDM_BS_STORAGE T7 WHERE T6.IN_REPOSITORY = T7.STORAGE_NO
          AND T6.PLINE_CODE = T2.PLINE_CODE)
             FROM PLN_ZY_RCL_M T2
            WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
              AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
              AND ROWNUM = 1)
         WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
          (SELECT (SELECT T9.STORAGE_NAME FROM COM_BASE_PLINE T8,YDM_BS_STORAGE T9 WHERE T8.IN_REPOSITORY = T9.STORAGE_NO
          AND T8.PLINE_CODE = T3.PLINE_CODE)
             FROM PLN_ZY_JGX_M T3
            WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
              AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
              AND ROWNUM = 1)
         ELSE
          NULL
       END) DIRECTION,
         '0' BAR_CODE,
         T.SUBCONTRACT_NO,
         T.SUBCONTRACT_NO_SEQ,
         '否' LOCK_BILL_FLAG
  FROM MAT_BC_M T, YDM_BC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
 #INSTOCK_TIME#
 #JUDGE_STOVE_NO#
 #FLAG_STOVE_NO_ZG#
 #STORAGE_NO#
 #QCM_STATUS#
 GROUP BY T.LOT_NO,
          T.STOVE_NO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PLINE_CODE,
          T.PLINE_NAME,

          T.MAT_STATUS,
          T.QCM_STAUS,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.MAT_GOWHERE_CODE,
          T.MAT_GOWHERE_NAME,
          T.PIPMEMO,
          T.FLAG_STOVE_NO_ZG,
          S.STORAGE_NO,
          S.LOCATION_NO,
          S.LARY_NO,
          S.LOC_NO,
          T.PRO_PLAN_ID_NEXT,
          T.GX_PLAN_NO_NEXT,
          T.JUDGE_RESULT,
          T.NEXT_PROCESS_CDOE,
          T.NEXT_PROCESS_DESC,
          T.PRODUCT_FLAG,
          T.SUBCONTRACT_NO,
          T.SUBCONTRACT_NO_SEQ
          UNION ALL
SELECT 
       (SELECT T2.BASENAME FROM COM_BASE_INFO T2 WHERE T2.BASECODE = T.PRODUCT_FLAG)PRODUCT_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
       T.MAT_STATUS AS MAT_STATUS_CODE,
       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,
       MAX(T.ORDER_NO || '/'||T.ORDER_SEQ)PRO_ORDER_NO,
       '' PROCESS_CDOE,
       '' PROCESS_DESC,
       '' NEXT_PROCESS_CDOE,
       '' NEXT_PROCESS_DESC,
       T.PLINE_CODE,
       T.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,
       T.BELONG_CODE,
       T.BELONG_NAME,
       --'' MAT_GOWHERE_CODE,
       --'' MAT_GOWHERE_NAME,
       --'' UPDATE_GO_WHERE_CODE,
       T.JUDGE_RESULT,
       MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
       MAX(T.JUDGE_MAKER)JUDGE_MAKER,
       MAX(T.JUDGE_STD_NAME)JUDGE_STD_NAME,
       T.PIPMEMO,
       '合格' QCM_STAUS,
       '' TARGET,
       T.FLAG_STOVE_NO_ZG,
       T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
       ''ORDER_NO_NEXT,
       --MAX(T.JUDGE_STD_NAME) JUDGE_STD_DES,
       S.STORAGE_NO,
       S.LOCATION_NO,
       (SELECT S2.LOCATION_NAME FROM YDM_BS_LOCATION S2 WHERE S2.LOCATION_NO = S.LOCATION_NO)LOCATION_NAME,
       S.LARY_NO,
       S.LOC_NO,
       '' PRO_PLAN_ID_NEXT,
       '' GX_PLAN_NO_NEXT,
       (SELECT S1.STORAGE_NAME
          FROM YDM_BS_STORAGE S1
         WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
         '' DIRECTION,
         '1' BAR_CODE,
         T.SUBCONTRACT_NO,
         T.SUBCONTRACT_NO_SEQ,
         DECODE(T.LOCK_BILL_FLAG,'0','否','1','是')LOCK_BILL_FLAG
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
 AND T.BELONG_CODE IN('100101','100102','100103')
 #INSTOCK_TIME#
 #JUDGE_STOVE_NO#
 #FLAG_STOVE_NO_ZG#
 #STORAGE_NO#
 #QCM_STATUS1#
 GROUP BY T.LOT_NO,
          T.STOVE_NO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PLINE_CODE,
          T.PLINE_NAME,
          T.MAT_STATUS,
          T.QCM_STAUS,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.PIPMEMO,
          T.FLAG_STOVE_NO_ZG,
          S.STORAGE_NO,
          S.LOCATION_NO,
          S.LARY_NO,
          S.LOC_NO,
          T.JUDGE_RESULT,
          T.PRODUCT_FLAG,
          T.SUBCONTRACT_NO,
          T.SUBCONTRACT_NO_SEQ,
          T.LOCK_BILL_FLAG
</query>
    <query id = "FrmFilpOutStorage.doQueryDataBc" desc = "查询BC库存">
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.PRO_ORDER_NO) PRO_ORDER_NO,
        MAX(T.PROCESS_CDOE) PROCESS_CDOE,
        MAX(T.PROCESS_DESC) PROCESS_DESC,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        T.PIPMEMO,
        T.MEMO1,
        DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '废品') QCM_STAUS,
        MAX(T.TARGET) TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT T1.ORDER_NO || '/' || T1.ORDER_SEQ
        FROM PLN_ORDER_DBK_S T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT T2.ORDER_NO || '/' || T2.ORDER_SEQ
        FROM PLN_ORDER_RCL_S T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT T3.ORDER_NO || '/' || T3.ORDER_SEQ
        FROM PLN_ORDER_JGX_S T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        ELSE
        NULL
        END) ORDER_NO_NEXT,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        
        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT (SELECT T5.STORAGE_NAME
        FROM COM_BASE_PLINE T4, YDM_BS_STORAGE T5
        WHERE T4.IN_REPOSITORY = T5.STORAGE_NO
        AND T4.PLINE_CODE = T1.PLINE_CODE)
        FROM PLN_ZY_DBK_M T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT (SELECT T7.STORAGE_NAME
        FROM COM_BASE_PLINE T6, YDM_BS_STORAGE T7
        WHERE T6.IN_REPOSITORY = T7.STORAGE_NO
        AND T6.PLINE_CODE = T2.PLINE_CODE)
        FROM PLN_ZY_RCL_M T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT (SELECT T9.STORAGE_NAME
        FROM COM_BASE_PLINE T8, YDM_BS_STORAGE T9
        WHERE T8.IN_REPOSITORY = T9.STORAGE_NO
        AND T8.PLINE_CODE = T3.PLINE_CODE)
        FROM PLN_ZY_JGX_M T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        ELSE
        NULL
        END) DIRECTION,
        '0' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        '否' LOCK_BILL_FLAG,
        T.OFFLINE_DOC,
        T.MEMO
        FROM MAT_BC_M T, YDM_BC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.PRODUCT_FLAG = '801401' #INSTOCK_TIME# #JUDGE_STOVE_NO#
        #FLAG_STOVE_NO_ZG# #STORAGE_NO# #QCM_STATUS#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.MAT_GOWHERE_CODE,
        T.MAT_GOWHERE_NAME,
        T.PIPMEMO,
        T.MEMO1,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        T.JUDGE_RESULT,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.OFFLINE_DOC,
        T.MEMO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
        UNION ALL
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.PRO_ORDER_NO) PRO_ORDER_NO,
        MAX(T.PROCESS_CDOE) PROCESS_CDOE,
        MAX(T.PROCESS_DESC) PROCESS_DESC,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        T.PIPMEMO,
        T.MEMO1,
        DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '废品') QCM_STAUS,
        MAX(T.TARGET) TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT T1.ORDER_NO || '/' || T1.ORDER_SEQ
        FROM PLN_ORDER_DBK_S T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT T2.ORDER_NO || '/' || T2.ORDER_SEQ
        FROM PLN_ORDER_RCL_S T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT T3.ORDER_NO || '/' || T3.ORDER_SEQ
        FROM PLN_ORDER_JGX_S T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        ELSE
        NULL
        END) ORDER_NO_NEXT,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT (SELECT T5.STORAGE_NAME
        FROM COM_BASE_PLINE T4, YDM_BS_STORAGE T5
        WHERE T4.IN_REPOSITORY = T5.STORAGE_NO
        AND T4.PLINE_CODE = T1.PLINE_CODE)
        FROM PLN_ZY_DBK_M T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT (SELECT T7.STORAGE_NAME
        FROM COM_BASE_PLINE T6, YDM_BS_STORAGE T7
        WHERE T6.IN_REPOSITORY = T7.STORAGE_NO
        AND T6.PLINE_CODE = T2.PLINE_CODE)
        FROM PLN_ZY_RCL_M T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT (SELECT T9.STORAGE_NAME
        FROM COM_BASE_PLINE T8, YDM_BS_STORAGE T9
        WHERE T8.IN_REPOSITORY = T9.STORAGE_NO
        AND T8.PLINE_CODE = T3.PLINE_CODE)
        FROM PLN_ZY_JGX_M T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        ELSE
        NULL
        END) DIRECTION,
        '0' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        '否' LOCK_BILL_FLAG,
        T.OFFLINE_DOC,
        T.MEMO
        FROM MAT_BC_M T, YDM_BC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.PRODUCT_FLAG = '801402' #INSTOCK_TIME# #JUDGE_STOVE_NO#
        #FLAG_STOVE_NO_ZG# #STORAGE_NO# #QCM_STATUS#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.MAT_GOWHERE_CODE,
        T.MAT_GOWHERE_NAME,
        T.PIPMEMO,
        T.MEMO1,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        T.JUDGE_RESULT,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.OFFLINE_DOC,
        T.MEMO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
    </query>
    <query id = "FrmFilpOutStorage.doQueryDataZc" desc = "查询ZC库存数据">
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.ORDER_NO || '/' || T.ORDER_SEQ) PRO_ORDER_NO,
        '' PROCESS_CDOE,
        '' PROCESS_DESC,
        '' NEXT_PROCESS_CDOE,
        '' NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        T.PIPMEMO,
        T.MEMO1,
        '合格' QCM_STAUS,
        '' TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        '' ORDER_NO_NEXT,
        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        '' PRO_PLAN_ID_NEXT,
        '' GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        '' DIRECTION,
        '1' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        DECODE(T.LOCK_BILL_FLAG, '0', '否', '1', '是') LOCK_BILL_FLAG,
        ''OFFLINE_DOC,
        T.MEMO
        FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.BELONG_CODE IN ('100101', '100102', '100103')
        AND T.PRODUCT_FLAG = '801402' #INSTOCK_TIME# #JUDGE_STOVE_NO#
        #FLAG_STOVE_NO_ZG# #STORAGE_NO# #QCM_STATUS#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.PIPMEMO,
        T.MEMO1,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.JUDGE_RESULT,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.LOCK_BILL_FLAG,
        T.MEMO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
        UNION ALL
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.ORDER_NO || '/' || T.ORDER_SEQ) PRO_ORDER_NO,
        '' PROCESS_CDOE,
        '' PROCESS_DESC,
        '' NEXT_PROCESS_CDOE,
        '' NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        T.PIPMEMO,
        T.MEMO1,
        '合格' QCM_STAUS,
        '' TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        '' ORDER_NO_NEXT,
        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        '' PRO_PLAN_ID_NEXT,
        '' GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        '' DIRECTION,
        '1' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        DECODE(T.LOCK_BILL_FLAG, '0', '否', '1', '是') LOCK_BILL_FLAG,
        ''OFFLINE_DOC,
        T.MEMO
        FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.BELONG_CODE IN ('100101', '100102', '100103')
        AND T.PRODUCT_FLAG = '801403' #INSTOCK_TIME# #JUDGE_STOVE_NO#
        #FLAG_STOVE_NO_ZG# #STORAGE_NO# #QCM_STATUS#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.PIPMEMO,
        T.MEMO1,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.JUDGE_RESULT,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.LOCK_BILL_FLAG,
        T.MEMO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
    </query>
<query id = "FrmFilpOutStorage.doQueryDataMat" desc = "查询材料号">
SELECT (SELECT T2.BASENAME
          FROM COM_BASE_INFO T2
         WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
       T.MAT_STATUS AS MAT_STATUS_CODE,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.JUDGE_RESULT,
       DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '废品') QCM_STAUS,
       T.FLAG_STOVE_NO_ZG,
       S.STORAGE_NO,
       S.LOCATION_NO,
       (SELECT S2.LOCATION_NAME
          FROM YDM_BS_LOCATION S2
         WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
       S.LARY_NO,
       S.LOC_NO,
       (SELECT S1.STORAGE_NAME
          FROM YDM_BS_STORAGE S1
         WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
       '0' BAR_CODE,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       '否' LOCK_BILL_FLAG,
       T.MEASURING_SEQ,
       T.MAT_NO
  FROM MAT_BC_M T, YDM_BC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
 #INSTOCK_TIME#
 #JUDGE_STOVE_NO#
 #FLAG_STOVE_NO_ZG#
 #STORAGE_NO#
 #QCM_STATUS#
UNION ALL
SELECT (SELECT T2.BASENAME
          FROM COM_BASE_INFO T2
         WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
       T.MAT_STATUS AS MAT_STATUS_CODE,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.JUDGE_RESULT,
       '合格' QCM_STAUS,
       T.FLAG_STOVE_NO_ZG,
       S.STORAGE_NO,
       S.LOCATION_NO,
       (SELECT S2.LOCATION_NAME
          FROM YDM_BS_LOCATION S2
         WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
       S.LARY_NO,
       S.LOC_NO,
       (SELECT S1.STORAGE_NAME
          FROM YDM_BS_STORAGE S1
         WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
       '1' BAR_CODE,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       DECODE(T.LOCK_BILL_FLAG, '0', '否', '1', '是') LOCK_BILL_FLAG,
       T.MEASURING_SEQ,
       T.MAT_NO
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
   AND T.BELONG_CODE IN ('100101', '100102', '100103')
#INSTOCK_TIME#
 #JUDGE_STOVE_NO#
 #FLAG_STOVE_NO_ZG#
 #STORAGE_NO#
 #QCM_STATUS1#
</query>
<query id = "FrmFilpOutStorage.doQueryOutList" desc = "查询倒库出库信息">
 SELECT 
       T.OUTSTOCK_DOC,
       MAX(T.OUTSTOCK_TYPE_CODE)OUTSTOCK_TYPE_CODE,
       MAX(T.OUTSTOCK_TYPE_NAME)OUTSTOCK_TYPE_NAME,
       T.VEHICLE_NO,
       --T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       MAX(T.PRODUCCODE)PRODUCCODE,
       MAX(T.PRODUCNAME)PRODUCNAME,
       MAX(T.STD_CODE)STD_CODE,
       MAX(T.STD_NAME)STD_NAME,
       MAX(T.GRADECODE)GRADECODE,
       MAX(T.GRADENAME)GRADENAME,
       MAX(T.STEELCODE)STEELCODE,
       MAX(T.STEELNAME)STEELNAME,
       MAX(T.STD_STYLE)STD_STYLE,
       MAX(T.STD_STYLE_DESC)STD_STYLE_DESC,
       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.PRO_ORDER_NO)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,
       SUM(T.PONDER_GROSS_WT)PONDER_GROSS_WT,
       MAX(T.BELONG_CODE)BELONG_CODE,
       MAX(T.BELONG_NAME)BELONG_NAME,
       MAX(T.STORAGE_NO)STORAGE_NO,
       (SELECT T2.STORAGE_NAME FROM YDM_BS_STORAGE T2 WHERE T2.STORAGE_NO = T.STORAGE_NO)STORAGE_NAME,
       T.TAR_STORAGE_NO,
       (SELECT T1.STORAGE_NAME FROM YDM_BS_STORAGE T1 WHERE T1.STORAGE_NO = T.TAR_STORAGE_NO)TAR_STORAGE_NAME,
       MAX(TO_CHAR(T.OUTSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) OUTSTOCK_TIME,
       MAX(TO_CHAR(T.LEAVE_FACTORY_TIME, 'YYYY-MM-DD HH24:MI:SS')) LEAVE_FACTORY_TIME,
       MAX(T.LEAVE_FACTORY_NAME) LEAVE_FACTORY_NAME,
       MAX(T.CREATE_NAME)CREATE_NAME,
       MAX(T.JUDGE_STD_NAME)JUDGE_STD_NAME,
       DECODE(T.QCM_STAUS,'00','合格','11','待处理','22','判废')QCM_STAUS,
       MAX(DECODE(T.TAR_REC_FLAG,'0','未接收','1','已接收'))TAR_REC_FLAG,
       MAX(T.DRIVER)DRIVER,
       DECODE(T.OUT_TYPE,'0','写卡倒运','1','票据倒运','2','纠错倒运','3','外委倒运','4','装车皮倒运')OUT_TYPE,
       MAX(T.FLAG_STOVE_NO_ZG)FLAG_STOVE_NO_ZG,
       DECODE(T.PRODUCT_FLAG,'801401','在制品','801402','成品','801403','商品')PRODUCT_FLAG,
      MAX((SELECT T1.FINAL_USER_DESC
        FROM PLN_SALEORD T1
        WHERE (T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK OR
        T1.ORD_LN_DLY_PK = SUBSTR(T.ORD_LN_DLY_PK,0,INSTR(T.ORD_LN_DLY_PK,'-')-1)))) FINAL_USER_DESC
 FROM YDM_BC_OUTLIST T
 WHERE T.OUTSTOCK_TYPE_CODE = '800803'
 AND T.VALIDFLAG = '1'
</query>
    <query id = "FrmFilpOutStorage.doQueryTmsDemand" desc = "查询运输需求">
<![CDATA[
SELECT
       T.CAR_WT_VAL,
       T.CURRENT_JOB_NO,
       TO_CHAR(T.TRANSPORT_START_TIME, 'YYYY-MM-DD HH24:MI:SS') TRANSPORT_START_TIME,
       T.COST_COUNT,
       DECODE(T.VALIDFLAG,'00','无效','10','草稿','20','待分派','30','执行中','40','结束','50','关闭')VALIDFLAG,
       T.OUTPUT_QTY_VAL,
       T.DELETE_USERID,
       T.URGENCY_TYPE_CODE,
       T.DEMAND_ORG_DESC,
       T.DIMATER_VAL,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.START_AREA_DESC,
       T.END_AREA_DESC,
       T.UOM_DESC,
       T.MATERIALS_CODE,
       T.ARCHIVE_FLAG,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.STATUS,
       T.DEMAND_VERTICAL_NO,
       T.PRO_ORDER_SQE,
       T.DEMAND_NO,
       T.COST_TYPE_DESC,
       T.REFE_TYPE_NAME,
       T.DEMAND_ORG_CODE,
       T.DEMAND_QTY_VAL,
       T.HEAT_NO,
       T.CREATE_NAME,
       T.GROUP_NO,
       T.CARRIER_NAME,
       T.UOM_CODE,
       T.OUTPUT_WT_VAL,
       T.ACCOUNT_YEAR_MONTH,
       T.END_NODE_CODE,
       T.CARRIER_CODE,
       T.START_NODE_DESC,
       T.END_AREA_CODE,
       T.DELETE_NAME,
       T.DEMAND_DESC,
       T.TRAN_CLASS_CODE,
       T.SCRAP_QTY_VAL,
       T.CAR_USE_CODE,
       T.CAR_USE_DESC,
       T.MATERIALS_SPEC,
       T.OFFLINE_QTY_VAL,
       T.EXECUTE_SQE,
       T.BATCH_NO,
       T.HEIGHT_VAL,
       T.LEN_MIN_VAL,
       T.LEN_MAX_VAL,
       T.PREVIOUS_JOB_NO,
       T.ARCHIVE_NO,
       T.DEMAND_WT_VAL,
       T.UPDATE_USERID,
       T.LOGO_NO,
       T.OFFLINE_WT_VAL,
       T.UPDATE_NAME,
       T.END_NODE_DESC,
       T.SCRAP_WT_VAL,
       T.START_NODE_CODE,
       TO_CHAR(T.TRANSPORT_END_TIME, 'YYYY-MM-DD HH24:MI:SS') TRANSPORT_END_TIME,
       T.SOURCE_SIGN,
       T.WEIGHING_IF,
       T.CREATE_USERID,
       T.ARCHIVE_DATE,
       T.URGENCY_TYPE_DESC,
       T.TRAN_CLASS_DESC,
       T.COST_TYPE_CODE,
       T.REFE_TYPE_CODE,
       T.CAR_TYPE_DESC,
       T.WIDE_VAL,
       T.LEN_VAL,
       T.CALCULATE_CAR_VAL,
       T.PRO_ORDER_NO,
       T.CAR_TYPE_CODE,
       T.MEMO,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.MATERIALS_DESC,
       T.REFE_NO,
       T.START_AREA_CODE,
       S.PLN_QTY_VAL,
       S.PLN_WT_VAL
 FROM TMS_DEMAND_M T LEFT JOIN TMS_PLN_C S ON T.DEMAND_NO = S.DEMAND_NO
 WHERE 1 = 1
 AND T.IS_SURE = '1'

]]>
    </query>
<query id = "FrmFilpOutStorage.doQueryStorageNo" desc = "查询目标库">
SELECT T.STORAGE_NAME,T.STORAGE_NO FROM YDM_BS_STORAGE T WHERE T.STORAGE_TYPE_NO IN ('800202','800205') AND T.VALIDFLAG = '1'
</query>
<query id = "FrmFilpOutStorage.updateGoWhere" desc = "修改去向">
<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM (SELECT T.MAT_NO
                          FROM MAT_BC_M T, YDM_BC_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 S.STORAGE_NO = '#STORAGE_NO#'
                           AND T.PLINE_CODE = '#PLINE_CODE#'
                           AND T.QCM_STAUS = '#QCM_STAUS#'
                           AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
                           AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/')
                           AND NVL(T.MAT_GOWHERE_CODE,'/') = NVL('#MAT_GOWHERE_CODE#','/')
                           AND NVL(T.FLAG_STOVE_NO_ZG,'/') = NVL('#FLAG_STOVE_NO_ZG#','/')
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= #ACT_COUNT#) LOOP
    UPDATE MAT_BC_M T
       SET T.MAT_GOWHERE_CODE = '#UPDATE_GO_WHERE_CODE#',
           T.MAT_GOWHERE_NAME = '#UPDATE_GO_WHERE#'
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND T.PLINE_CODE = '#PLINE_CODE#';
  END LOOP;
END;
]]>
</query>
<query id = "FrmFilpOutStorage.updateFalgStove" desc = "修改标识炉号">
<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM (SELECT T.MAT_NO
                          FROM MAT_BC_M T, YDM_BC_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 S.STORAGE_NO = '#STORAGE_NO#'
                           AND T.PLINE_CODE = '#PLINE_CODE#'
                           AND T.QCM_STAUS = '#QCM_STAUS#'
                           AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
                           AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/')
                           AND NVL(T.FLAG_STOVE_NO_ZG,'/') = NVL('#FLAG_STOVE_NO_ZG#','/')
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= #ACT_COUNT#) LOOP
    UPDATE MAT_BC_M T
       SET T.FLAG_STOVE_NO_ZG = '#UPDATE_FLAG_STOVE#'
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND T.PLINE_CODE = '#PLINE_CODE#';
  END LOOP;
END;
]]>
</query>
<query id = "FrmFilpOutStorage.getOutDoc" desc = "不写卡生成倒库单号">
SELECT ?|| TO_CHAR(SYSDATE, 'YYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(OUTSTOCK_DOC, 11)), 0) + 1, 5, 0) OUTSTOCK_DOC
    FROM YDM_BC_OUTLISTDOC T
   WHERE T.OUTSTOCK_DOC LIKE ?|| TO_CHAR(SYSDATE, 'YYMMDD')|| '_____'
</query>
<query id = "FrmFilpOutStorage.getOutDoc1" desc = "写卡取倒库单号">
SELECT ?|| TO_CHAR(SYSDATE, 'YYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(OUTSTOCK_DOC, 11)), 0), 5, 0) OUTSTOCK_DOC
    FROM YDM_BC_OUTLISTDOC T
   WHERE T.OUTSTOCK_DOC LIKE ?|| TO_CHAR(SYSDATE, 'YYMMDD')|| '_____'
</query>
<query id = "" desc = "生成入库单号">
SELECT 'IC' || TO_CHAR(?, 'YYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(T.INSTOCK_DOC, 9)), 0) + 1, 5, 0) INSTOCK_DOC
    FROM YDM_BC_INLIST T
   WHERE T.INSTOCK_TYPE_CODE = ?
     AND TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') =
         TO_CHAR(?, 'YYYY-MM-DD')
</query>
<query id = "FrmFilpOutStorage.doQueryMatBcCount" desc = "查询库存支数">
SELECT NVL(SUM(T.ACT_COUNT),'0')ACOUNT
  FROM MAT_BC_M T, YDM_BC_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 S.STORAGE_NO = '#STORAGE_NO#'
   AND T.PLINE_CODE = '#PLINE_CODE#'
   AND T.QCM_STAUS = '#QCM_STAUS#'
   AND T.BELONG_CODE = '#BELONG_CODE#'
   AND NVL(T.PRO_PLAN_ID_NEXT, '/') = NVL('#PRO_PLAN_ID_NEXT#', '/')
   AND NVL(T.GX_PLAN_NO_NEXT, '/') = NVL('#GX_PLAN_NO_NEXT#', '/')
   --AND NVL(T.MAT_GOWHERE_CODE, '/') = NVL('#MAT_GOWHERE_CODE#', '/')
   AND NVL(T.FLAG_STOVE_NO_ZG, '/') = NVL('#FLAG_STOVE_NO_ZG#', '/')
   AND NVL(T.SUBCONTRACT_NO,'/') = NVL('#SUBCONTRACT_NO#','/')
   AND NVL(T.SUBCONTRACT_NO_SEQ,'/') = NVL('#SUBCONTRACT_NO_SEQ#','/')
    AND NVL(T.OFFLINE_DOC,'/') = NVL('#OFFLINE_DOC#','/')
    AND NVL(T.MEMO,'/') = NVL('#MEMO#','/')
</query>
    <query id = "FrmFilpOutStorage.doQueryMatBcScrap" desc = "查询废品是否审核">
        <![CDATA[
        SELECT NVL(SUM(T.ACT_COUNT),'0')ACOUNT
        FROM MAT_BC_M T, YDM_BC_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 S.STORAGE_NO = '#STORAGE_NO#'
        AND T.PLINE_CODE = '#PLINE_CODE#'
        AND T.QCM_STAUS = '#QCM_STAUS#'
        AND T.BELONG_CODE = '#BELONG_CODE#'
        AND T.SCRAP_FRIM_FLAG <> '2'
        ]]>
    </query>
<query id = "FrmFilpOutStorage.doQueryMatZcCount" desc = "查询库存支数">
SELECT NVL(SUM(T.ACT_COUNT),'0')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 S.STORAGE_NO = '#STORAGE_NO#'
   AND T.PLINE_CODE = '#PLINE_CODE#'
   AND T.BELONG_CODE = '#BELONG_CODE#'
   AND T.PRODUCT_FLAG = '#PRODUCT_FLAG#'
   AND NVL(T.SUBCONTRACT_NO,'/') = NVL('#SUBCONTRACT_NO#','/')
   AND NVL(T.SUBCONTRACT_NO_SEQ,'/') = NVL('#SUBCONTRACT_NO_SEQ#','/')
</query>
<query id = "FrmFilpOutStorage.getPCode" desc = "查询产线集合">
SELECT T.PLINE_CODE,T.PLINE_NAME FROM COM_BASE_PLINE T WHERE T.VALIDFLAG='1'
</query>
<query id = "FrmFilpOutStorage.doQueryMilPlan" desc = "查询炉计划">
<![CDATA[
SELECT ID,
       SEQ,
       STOVE_NO,
       JUDGE_STOVE_NO,
       LOT_NO,
       CONTRACT_NO,
       IMP_PROCESS,
       PLINE_CODE,
       (SELECT T1.PLINE_NAME FROM COM_BASE_PLINE T1 WHERE T1.PLINE_CODE = T.PLINE_CODE)PLINE_NAME,
       STATUS,
       PRODUCER,
       PROCESS_STATUS,
       DB_LENGTH,
       DB_HEIGHT,
       ROLL_LENGTH,
       SAW_NUM,
       TARGET_LENGTH,
       FINISH_USER,
       TARGET_LIABRARY,
       VARIETIES,
       PIPE_SIZE,
       BUCKLE_TYPE,
       LENGTH_RANGE,
       ROLL_STANDRAD,
       PIPE_SECTION,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       STEEL_STANDRAD,
       TARGET,
       BRANCH,
       TON,
       CUT_TARGET,
       CUT_LENGTH,
       CUT_WEIGHT,
       DB_NUM,
       START_TIME,
       END_TIME,
       TOM,
       TOC,
       DECODE(NODE_STATUS,
              '70',
              '管排距结炉',
              '80',
              '矫直结炉',
              '90',
              '探伤结炉',
              '96',
              '表检结炉') NODE_STATUS,
       CUT_HEAD_LENGTHP,
       CUT_TRAIL_LENGTHP,
       CONTROL_THICKP,
       OFFLINE_FLAG,
       IS_BATCH,
       OFFLINE_DATE,
       CUT_TYPE,
       ROLLING_STATUS,
       PRODUCE_STANDRAD,
       SIMPLE_PROCESS,
       BACK_LINE_FLAG,
       BACK_PLAN_FLAG,
       FEED_SEQ,
       FEED_TIME,
       LOT_SEQ,
       FEED_HEAT_NO,
       LENGTHCP,
       CUT_HEAD_LENGTHA,
       CUT_TRAIL_LENGTHA,
       ORDER_LENGTHA,
       HOT_CHECK_FLAG,
       BACK_SLAB_FLAG,
       BACK_SLAB_TIME,
       BATCH_MAX,
       CODE_SAMPLE_FLAG,
       VARIETIES_CODE,
       PIPE_SIZE_CODE,
       BUCKLE_TYPE_CODE,
       ROLL_STANDRAD_CODE,
       STD_STYLE,
       STD_STYLE_DESC,
       CHECK_NO,
       ORD_LN_DLY_PK,
       PRT_FLAG,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       TUBE_TYPE,
       TUBE_SUORCE,
       PREDICT_PIECE,
       PREDICT_TON,
       TYPE,
       IS_LOAD,
       COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       USER_ID,
       BAL_YEAR_MONTH,
       (SELECT NVL(SUM(T1.ACT_COUNT),0)
          FROM PORT_MIL_BATCH_SAMPLE_RESULT T1
         WHERE T1.PLAN_ID = T.ID
           AND T1.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T1.STATUS = '0') ACT_COUNT,
       (SELECT NVL(SUM(T1.ACT_COUNT),0)
          FROM PORT_MIL_BATCH_SAMPLE_RESULT T1
         WHERE T1.PLAN_ID = T.ID
           AND T1.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T1.STATUS = '0') LX_COUNT,
       (SELECT NVL(SUM(T1.ACT_COUNT),0)
          FROM PORT_MIL_BATCH_SAMPLE_RESULT T1
         WHERE T1.PLAN_ID = T.ID
           AND T1.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T1.STATUS = '3') OFF_COUNT,
       (SELECT NVL(SUM(T1.ACT_COUNT),0)
          FROM PORT_MIL_BATCH_SAMPLE_RESULT T1
         WHERE T1.PLAN_ID = T.ID
           AND T1.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T1.STATUS = '3') HT_COUNT
  FROM MIL_PLAN T
 WHERE T.NODE_STATUS >= '70'
   AND T.NODE_STATUS < '99'
   ]]>
</query>
<query id = "FrmFilpOutStorage.SelectMilNode" desc = "查询结炉状态">
SELECT T.NODE_STATUS,T.STATUS FROM MIL_PLAN T WHERE T.ID = '#ID#' AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
</query>
<query id = "FrmFilpOutStorage.SelectQualifiedCount" desc = "查询合格支数">
SELECT NVL(SUM(T.ACT_COUNT),0)ACOUNT
  FROM PORT_MIL_BATCH_SAMPLE_RESULT T
 WHERE T.PLAN_ID = '#ID#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.STATUS = '0'
</query>
<query id = "FrmFilpOutStorage.doQueryStoreNo" desc = "查询仓库">
SELECT S.STORAGE_NO, S.STORAGE_TYPE_NO, S.STORAGE_TYPE_NAME
  FROM COM_BASE_PLINE T, YDM_BS_STORAGE S
 WHERE T.DEPARTMENT_CODE = S.MANAGEMENT_NO
   AND T.PLINE_CODE = ?
</query>
<query id = "FrmFilpOutStorage.OfflineResultSql" desc = "离线">
<![CDATA[
DECLARE
  V_OFFCOUNT      MIL_OFFLINE_RESLUT.OFFLINE_NUM%TYPE := NULL;
  V_RESULTCOUNT   MIL_STRAIGHTENING_RESULT.OFFLINE_NUM_TOTAL%TYPE := NULL;
  V_QUALIFIED_NUM MIL_STRAIGHTENING_RESULT.QUALIFIED_NUM%TYPE := NULL;
  V_COUNT         MIL_INSTORE_RESULT.QUALIFIED_NUM%TYPE := NULL;
BEGIN
  SELECT COUNT(1)
    INTO V_OFFCOUNT
    FROM MIL_OFFLINE_RESLUT T
   WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.PLINE_CODE = '#PLINE_CODE#'
     AND T.OFFLINE_PRO = '#OFFLINE_PRO#';

  IF (V_OFFCOUNT > 0) THEN
    UPDATE MIL_OFFLINE_RESLUT T
       SET T.OFFLINE_NUM = TO_NUMBER(T.OFFLINE_NUM) +
                           TO_NUMBER('#OFFLINE_NUM#')
     WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.OFFLINE_PRO = '#OFFLINE_PRO#';
  ELSE
    INSERT INTO MIL_OFFLINE_RESLUT
      (RECHECK_NUM,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       ACT_LEN_RANGE,
       CONTRACT_NO,
       PRODUCCODE,
       INSTORAGE_NUM,
       QUALIFIED_NUM,
       SCRAP_NUM,
       ZP_M_LH,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       DIAMETER,
       THICKNESS,
       LENGTH,
       PLINE_CODE,
       OFFLINE_PRO,
       REAL_TIME_STATUS,
       OFFLINE_NUM,
       BACKLINE_NUM,
       GROUP_NUM,
       FINAL_NUM,
       ZP_FLAG,
       STATUS,
       TYPE_FLAG,
       OFFLINE_TIME,
       REMARK,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       OFFLINE_TYPE,
       ZP_HEIGHT,
       TARGET,
       IMP_PROCESS,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    VALUES
      ('0',
       '#PRODUCNAME#',
       '#STEELCODE#',
       '#STEELNAME#',
       '#GRADECODE#',
       '#GRADENAME#',
       '#SPEC_CODE#',
       '#SPEC_NAME#',
       '#MODEL_CODE#',
       '#MODEL_DESC#',
       '#STD_CODE#',
       '#STD_NAME#',
       '#STD_STYLE#',
       '#STD_STYLE_DESC#',
       '#ACT_LEN_RANGE#',
       '#CONTRACT_NO#',
       '#PRODUCCODE#',
       '0',
       '0',
       '0',
       '',
       '#LOT_NO#',
       '#STOVE_NO#',
       '#JUDGE_STOVE_NO#',
       '#DIAMETER#',
       '#THICKNESS#',
       '#LENGTH#',
       '#PLINE_CODE#',
       '#OFFLINE_PRO#',
       '0',
       '#OFFLINE_NUM#',
       '0',
       '0',
       '0',
       '0',
       '0',
       '0',
       TO_DATE('#OFFLINE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '',
       '#COL_USER#',
       '#COL_SHIFT#',
       '#COL_GROUP#',
       '#OFFLINE_TYPE#',
       '#ZP_HEIGHT#',
       '#TARGET#',
       '#IMP_PROCESS#',
       '#PRO_PLAN_ID#',
       '#GX_PLAN_NO#');
  END IF;
  IF ('#OFFLINE_PRO#' = 'JZ') THEN
    UPDATE MIL_STRAIGHTENING_RESULT T
       SET T.OFFLINE_NUM_TOTAL = TO_NUMBER(T.OFFLINE_NUM_TOTAL) +
                                 TO_NUMBER('#OFFLINE_NUM#'),
           T.QUALIFIED_NUM     = TO_NUMBER(T.QUALIFIED_NUM) -
                                 TO_NUMBER('#OFFLINE_NUM#')
     WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.PLINE_CODE = '#PLINE_CODE#';
    FOR MYROW IN (SELECT *
                    FROM (SELECT T.SEQ
                            FROM MIL_STRAIGH_RACK T
                           WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                             AND T.PLINE_CODE = '#PLINE_CODE#'
                             AND T.OFFLINE_FLAG = '0'
                             AND T.STATUS = '0'
                           ORDER BY T.SEQ ASC)
                   WHERE ROWNUM <= #OFFLINE_NUM#) LOOP
      UPDATE MIL_STRAIGH_RACK T
         SET T.OFFLINE_FLAG = '1',
             T.STATUS       = '3',
             T.OFFLINE_TIME = TO_DATE('#OFFLINE_TIME#',
                                      'YYYY-MM-DD HH24:MI:SS')
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.PLINE_CODE = '#PLINE_CODE#'
         AND T.SEQ = MYROW.SEQ;
         INSERT INTO MIL_SLAB_SCRAP_SEQ
      (COL_NO,
       COL_TYPE,
       JUDGE_STOVE_NO,
       PROCESS_NO,
       SEQ,
       TIME,
       FLAG,
       COL_MODE,
       COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       RESULT_NO,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    VALUES
      ('1',
       '1',
       '#JUDGE_STOVE_NO#',
       '9',
       MYROW.SEQ,
       TO_DATE('#OFFLINE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '0',
       '0',
       TO_DATE('#OFFLINE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '#COL_USER#',
       '#COL_SHIFT#',
       '#COL_GROUP#',
       '#ID#',
       '#PRO_PLAN_ID#',
       '#GX_PLAN_NO#');
    END LOOP;
  ELSIF ('#OFFLINE_PRO#' = 'TS') THEN
    IF ('#PLINE_CODE#' = 'C010') THEN
      UPDATE MIL_ET_RESULT T
         SET T.OFFLINE_NUM = TO_NUMBER(T.OFFLINE_NUM) +
                             TO_NUMBER('#OFFLINE_NUM#')
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.PLINE_CODE = '#PLINE_CODE#';
    ELSE
      UPDATE MIL_MT_RESULT T
         SET T.OFFLINE_NUM = TO_NUMBER(T.OFFLINE_NUM) +
                             TO_NUMBER('#OFFLINE_NUM#')
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.PLINE_CODE = '#PLINE_CODE#';
    END IF;
    FOR MYROW IN (SELECT *
                    FROM (SELECT T.SEQ
                            FROM MIL_TESTING_RACK T
                           WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                             AND T.PLINE_CODE = '#PLINE_CODE#'
                             AND T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
                             AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
                             AND T.OFFLINE_FLAG = '0'
                             AND T.STATUS = '0'
                             AND T.SUSPECT_FLAG = '0'
                           ORDER BY T.SEQ ASC)
                   WHERE ROWNUM <= #OFFLINE_NUM#) LOOP
      UPDATE MIL_TESTING_RACK T
         SET T.OFFLINE_FLAG = '1',
             T.OFFLINE_TYPE = '1',
             T.OFFLINE_TIME = TO_DATE('#OFFLINE_TIME#',
                                      'YYYY-MM-DD HH24:MI:SS')
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
         AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
         AND T.PLINE_CODE = '#PLINE_CODE#'
         AND T.SEQ = MYROW.SEQ;
         INSERT INTO MIL_SLAB_SCRAP_SEQ
      (COL_NO,
       COL_TYPE,
       JUDGE_STOVE_NO,
       PROCESS_NO,
       SEQ,
       TIME,
       FLAG,
       COL_MODE,
       COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       RESULT_NO,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    VALUES
      ('1',
       '1',
       '#JUDGE_STOVE_NO#',
       '10',
       MYROW.SEQ,
       TO_DATE('#OFFLINE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '0',
       '0',
       TO_DATE('#OFFLINE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '#COL_USER#',
       '#COL_SHIFT#',
       '#COL_GROUP#',
       '#ID#',
       '#PRO_PLAN_ID#',
       '#GX_PLAN_NO#');
    END LOOP;
  ELSIF ('#OFFLINE_PRO#' = 'ZJ') THEN
    UPDATE MIL_SURFACE_RESULT T
       SET T.OFFLINE_QUANTITY = TO_NUMBER(T.OFFLINE_QUANTITY) +
                                TO_NUMBER('#OFFLINE_NUM#')
     WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
       AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/');
    FOR MYROWOFFLINE IN (SELECT *
                           FROM (SELECT T.SEQ, T.JUDGE_STOVE_NO
                                   FROM MIL_QA_RACK T
                                  WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                                    AND T.OFFLINE_FLAG = '0'
                                    AND T.STATUS = '0'
                                  ORDER BY T.SEQ ASC)
                          WHERE ROWNUM <= #OFFLINE_NUM#) LOOP
      UPDATE MIL_QA_RACK T
         SET T.OFFLINE_FLAG = '1', T.STATUS = '2'
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
         AND T.SEQ = MYROWOFFLINE.SEQ;
         INSERT INTO MIL_SLAB_SCRAP_SEQ
      (COL_NO,
       COL_TYPE,
       JUDGE_STOVE_NO,
       PROCESS_NO,
       SEQ,
       TIME,
       FLAG,
       COL_MODE,
       COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       RESULT_NO,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    VALUES
      ('0',
       '1',
       '#JUDGE_STOVE_NO#',
       '11',
       MYROWOFFLINE.SEQ,
       TO_DATE('#OFFLINE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '0',
       '0',
       TO_DATE('#OFFLINE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '#COL_USER#',
       '#COL_SHIFT#',
       '#COL_GROUP#',
       '#ID#',
       '#PRO_PLAN_ID#',
       '#GX_PLAN_NO#');
    END LOOP;
  ELSIF ('#OFFLINE_PRO#' = 'XX') THEN
    SELECT COUNT(1)
      INTO V_COUNT
      FROM MIL_INSTORE_RESULT T
     WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
       AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
       AND T.RESULT_NO = '#ID#';
    IF (V_COUNT > 0) THEN
    
      UPDATE MIL_INSTORE_RESULT T
         SET T.OFFLINE_NUM = TO_NUMBER(NVL(OFFLINE_NUM, 0)) + TO_NUMBER('#OFFLINE_NUM#')
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
         AND T.RESULT_NO = '#ID#';
    ELSE
      INSERT INTO MIL_INSTORE_RESULT
        (RESULT_NO,
         JUDGE_STOVE_NO,
         LOT_NO,
         PLINE_CODE,
         TYPE,
         TARGET_DIAMETER,
         TARGET_THICKNESS,
         TARGET_LENGTH,
         QUALIFIED_NUM,
         QUALIFIED_TONS,
         SCRAP_NUM,
         SCRAP_TONS,
         OFFLINE_NUM,
         OFFLINE_TONS,
         PRO_PLAN_ID,
         GX_PLAN_NO)
      VALUES
        ('#ID#',
         '#JUDGE_STOVE_NO#',
         '#LOT_NO#',
         '#PLINE_CODE#',
         '#GRADENAME#',
         '',
         '',
         '#ACT_LEN_RANGE#',
         '',
         '',
         '',
         '',
         '#OFFLINE_NUM#',
         '',
         '#PRO_PLAN_ID#',
         '#GX_PLAN_NO#');
    END IF;
  END IF;
END;
]]>
</query>
<query id = "FrmFilpOutStorage.queryMatNoM" desc = "查询材料号">
<![CDATA[
	 SELECT ? || ? ||
       LPAD(NVL(MAX(SUBSTR(T.MAT_NO, LENGTH(T.MAT_NO) - 3)), 0) + 1, 4, 0) MAT_NO
  FROM (SELECT MAX(T1.MAT_NO) MAT_NO
          FROM MAT_BC_M T1
         WHERE T1.JUDGE_STOVE_NO = ?
           AND T1.BATCH_NO = ?
        UNION ALL
        SELECT MAX(T3.MAT_NO) MAT_NO
          FROM MAT_ZC_BACKUP T3
         WHERE T3.JUDGE_STOVE_NO = ?
           AND T3.BATCH_NO = ?
        UNION ALL
        SELECT MAX(T4.MAT_NO) MAT_NO
          FROM YDM_BC_INLIST T4
         WHERE T4.JUDGE_STOVE_NO = ?
           AND T4.BATCH_NO = ?) T
		]]>
</query>
<query id = "FrmFilpOutStorage.insertMatSql" desc = "离线入库存">
DECLARE
  V_TIME MIL_OFFLINE_RESLUT.OFFLINE_TIME%TYPE := SYSDATE;
BEGIN
  INSERT INTO YDM_BC_BUTTRESS
    (JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     STORAGE_NO,
     LOCATION_NO,
     STORAGE_TYPE_NO,
     STORAGE_TYPE_NAME,
     CREATE_NAME,
     MAT_NO,
     CREATE_TIME,
     MANAGEMENT_NO,
     MANAGEMENT_NAME,
     DEPARTMENT_CODE,
     DEPARTMENT_DESC)
  VALUES
    ('#JUDGE_STOVE_NO#',
     '#BATCH_NO#',
     '#BATCH_GROUD_NO#',
     '#STORAGE_NO#',
     '#LOCATION_NO#',
     '#STORAGE_TYPE_NO#',
     '#STORAGE_TYPE_NAME#',
     '#CREATE_NAME#',
     '#MAT_NO#',
     TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
     '#MANAGEMENT_NO#',
     '#MANAGEMENT_NAME#',
     '#DEPARTMENT_CODE#',
     '#DEPARTMENT_DESC#');
  INSERT INTO MAT_BC_M
    (JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     ACT_COUNT,
     ACT_WEIGHT,
     CREATE_TIME,
     MAT_NO,
     PRODUCT_FLAG,
     MAT_STATUS,
     PLINE_CODE,
     PLINE_NAME,
     QCM_STAUS,
     HEAT_PLAN_NO,
     ZG_STOVE_SQE,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     SPEC_CODE,
     SPEC_NAME,
     GRADECODE,
     GRADENAME,
     MODEL_CODE,
     MODEL_DESC,
     STD_CODE,
     STD_NAME,
     BELONG_CODE,
     BELONG_NAME,
     STD_STYLE,
     STD_STYLE_DESC,
     ACT_DIMATER,
     ACT_HEIGHT,
     ACT_LEN_MIN,
     ACT_LEN_MAX,
     LOT_NO,
     PRO_ORDER_NO,
     ACT_LEN,
     TARGET,
     PROCESS_STATUS,
     FLAG_STOVE_NO_ZG,
     INSTOCK_TIME,
     STOVE_NO)
  VALUES
    ('#JUDGE_STOVE_NO#',
     '#BATCH_NO#',
     '#BATCH_GROUD_NO#',
     '#ACT_COUNT#',
     '#ACT_WEIGHT#',
     TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
     '#MAT_NO#',
     '#PRODUCT_FLAG#',
     '#MAT_STATUS#',
     '#PLINE_CODE#',
     '#PLINE_NAME#',
     '#QCM_STAUS#',
     '#HEAT_PLAN_NO#',
     '#ZG_STOVE_SQE#',
     '#PRODUCCODE#',
     '#PRODUCNAME#',
     '#STEELCODE#',
     '#STEELNAME#',
     '#SPEC_CODE#',
     '#SPEC_NAME#',
     '#GRADECODE#',
     '#GRADENAME#',
     '#MODEL_CODE#',
     '#MODEL_DESC#',
     '#STD_CODE#',
     '#STD_NAME#',
     '#BELONG_CODE#',
     '#BELONG_NAME#',
     '#STD_STYLE#',
     '#STD_STYLE_DESC#',
     '#ACT_DIMATER#',
     '#ACT_HEIGHT#',
     '#ACT_LEN_MIN#',
     '#ACT_LEN_MAX#',
     '#LOT_NO#',
     '#PRO_ORDER_NO#',
     '#ACT_LEN#',
     '#TARGET#',
     '#PROCESS_STATUS#',
     '#JUDGE_STOVE_NO#',
     TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
     '#STOVE_NO#');
END;
</query>
<query id = "FrmFilpOutStorage.insertCheckDeatil" desc = "插入表检详细表">
DECLARE
  V_COUNT MIL_CHECK_DEATIL_SIMPLE.OFFLINE_PRODUCT%TYPE := NULL;
BEGIN
  SELECT NVL(COUNT(1),0)
    INTO V_COUNT
    FROM MIL_CHECK_DEATIL_SIMPLE T
   WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.RESULT_NO = '#RESULT_NO#'
     AND T.DEFECT_CODE = '#DEFECT_CODE#';
  IF (V_COUNT > 0) THEN
    UPDATE MIL_CHECK_DEATIL_SIMPLE T
       SET T.OFFLINE_PRODUCT = TO_NUMBER(NVL(T.OFFLINE_PRODUCT, 0)) +
                               TO_NUMBER('#OFFLINE_PRODUCT#')
     WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.RESULT_NO = '#RESULT_NO#'
       AND T.DEFECT_CODE = '#DEFECT_CODE#';
  ELSE
    INSERT INTO MIL_CHECK_DEATIL_SIMPLE
      (JUDGE_STOVE_NO,
       DEFECT_ITEM,
       OFFLINE_PRODUCT,
       DEFECT_CODE,
       RESULT_NO,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    VALUES
      ('#JUDGE_STOVE_NO#',
       '#DEFECT_ITEM#',
       '#OFFLINE_PRODUCT#',
       '#DEFECT_CODE#',
       '#RESULT_NO#',
       '#PRO_PLAN_ID#',
       '#GX_PLAN_NO#');
  END IF;
END;
</query>
<query id = "FrmFilpOutStorage.getStoreAll" desc = "查询所有仓库">
SELECT T.STORAGE_NO,T.STORAGE_NAME FROM YDM_BS_STORAGE T WHERE T.STORAGE_TYPE_NO IN('800202','800205') AND T.VALIDFLAG = '1' and t.seam_area = '1'
</query>

<query id = "FrmFilpOutStorage.doAdd" desc = "票据倒库">
<![CDATA[
DECLARE
  V_OUTSTOCK_DOC YDM_BC_OUTLIST.OUTSTOCK_DOC%TYPE := NULL; --出库单号
  V_OUTSTOCK_SQE YDM_BC_OUTLIST.OUTSTOCK_SQE%TYPE := NULL; --出库流水

  V_MEMO        COM_BASE_INFO.MEMO%TYPE := NULL;
  V_BASENAME    COM_BASE_INFO.BASENAME%TYPE := NULL;
  V_OCOUNT      NUMBER := 1;
  V_TIME        YDM_BC_OUTLIST.CREATE_TIME%TYPE := SYSDATE;
  V_BATHYEAR    MAT_BC_M.BAL_YEAR_MONTH%TYPE := TO_CHAR(SYSDATE, 'YYYYMM');
  V_DATA_SOURCE YDM_BC_OUTLIST.DATA_SUORCE%TYPE := NULL;
  V_COUNT YDM_BC_OUTLIST.ACT_COUNT%TYPE :=NULL;
BEGIN
  SELECT COUNT(1)INTO V_COUNT FROM YDM_BC_OUTLISTDOC T WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
  --生成出库单号
  V_OUTSTOCK_DOC := '#OUTSTOCK_DOC#';
  SELECT MEMO, BASENAME
    INTO V_MEMO, V_BASENAME
    FROM COM_BASE_INFO
   WHERE BASECODE = '#OUTSTOCK_TYPE_CODE#';
  SELECT TO_NUMBER(LPAD((NVL(MAX(SUBSTR(T.OUTSTOCK_SQE, 16)), 0) + 1), 4, 0)) OUTSTOCK_SQE
    INTO V_OCOUNT
    FROM YDM_BC_OUTLIST T
   WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
  IF ('#BAR_CODE#' = '0') THEN
    V_DATA_SOURCE := '0';
    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_BC_M T, YDM_BC_BUTTRESS S
                   WHERE T.MAT_NO = S.MAT_NO

                     AND NVL(T.LOT_NO,'/') = NVL('#LOT_NO#','/')
                     AND NVL(T.STOVE_NO, '/') = NVL('#STOVE_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.PRODUCT_FLAG = '#PRODUCT_FLAG#'
                     AND T.MAT_STATUS = '#MAT_STATUS_CODE#'
                     AND NVL(S.STORAGE_NO, '/') = NVL('#STORAGE_NO#', '/')
                     AND T.QCM_STAUS = '#QCM_STAUS#'
                     AND NVL(S.LOCATION_NO, '/') = NVL('#LOCATION_NO#', '/')
                     AND NVL(S.LARY_NO, '1') = NVL('#LARY_NO#', '1')
                     AND NVL(T.PRO_PLAN_ID_NEXT, '/') =
                         NVL('#PRO_PLAN_ID_NEXT#', '/')
                     AND NVL(T.GX_PLAN_NO_NEXT, '/') =
                         NVL('#GX_PLAN_NO_NEXT#', '/')
                     AND T.BELONG_CODE = '#BELONG_CODE#'
                     AND NVL(T.SUBCONTRACT_NO,'/') = NVL('#SUBCONTRACT_NO#','/')
                     AND NVL(T.SUBCONTRACT_NO_SEQ,'/') = NVL('#SUBCONTRACT_NO_SEQ#','/')
                     AND NVL(T.FLAG_STOVE_NO_ZG,'/') = NVL('#FLAG_STOVE_NO_ZG#','/')
                     AND S.STORAGE_NO IS NOT NULL
                     AND NVL(T.OFFLINE_DOC,'/') = NVL('#OFFLINE_DOC#','/')
                     AND NVL(T.MEMO,'/') = NVL('#MEMO#','/')
                     AND NVL(T.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
                     AND NVL(T.MEMO1,'/') = NVL('#MEMO1#','/')
                     AND ROWNUM <= #ACT_COUNT#
                   ORDER BY T.MAT_NO DESC) LOOP
      V_OUTSTOCK_SQE := V_OUTSTOCK_DOC || LPAD(V_OCOUNT, 4, 0);
      INSERT INTO YDM_BC_OUTLIST
        (OUTSTOCK_SQE,
         OUTSTOCK_DOC,
         OUTSTOCK_TYPE_CODE,
         OUTSTOCK_TYPE_NAME,
         ICCAR_NO,
         VEHICLE_NO,
         MAT_NO,
         LOT_NO,
         STOVE_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,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         TAR_STORAGE_NO,
         TAR_REC_FLAG,
         INSTOCK_TIME,
         OUTSTOCK_TIME,
         OUT_BC,
         OUT_BZ,
         CREATE_NAME,
         CREATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         JUDGE_STD_NAME,
         BAL_YEAR_MONTH,
         DATA_SUORCE,
         QCM_STAUS,
         LEAVE_FACTORY_FLAG,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         DRIVER,
         OUT_TYPE,
         FLAG_STOVE_NO_ZG，
         SUPERVISOR_NAME，
         SUPERVISOR_CALL,
         PRO_ORDER_ID,
         GX_PLAN_NO,
         PIPMEMO,
         MEMO
         )
      VALUES
        (V_OUTSTOCK_SQE,
         V_OUTSTOCK_DOC,
         '#OUTSTOCK_TYPE_CODE#',
         '#OUTSTOCK_TYPE_NAME#',
         '#ICCAR_NO#',
         '#VEHICLE_NO#',
         MYROW.MAT_NO,
         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.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.ACT_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.LARY_NO,
         MYROW.LOC_NO,
         MYROW.STORAGE_ATTR,
         MYROW.STORAGE_ATTR_NAME,
         MYROW.STORAGE_TYPE_NO,
         MYROW.STORAGE_TYPE_NAME,
         '#TAR_STORAGE_NO#',
         '0',
         MYROW.INSTOCK_TIME,
         V_TIME,
         '#OUT_BC#',
         '#OUT_BZ#',
         '#CREATE_NAME#',
         V_TIME,
         MYROW.ORD_PK,
         MYROW.ORD_LN_PK,
         MYROW.ORD_LN_DLY_PK,
         MYROW.ORDER_NO,
         MYROW.ORDER_SEQ,
         MYROW.ORDER_SEQ_NO,
         MYROW.PRODUCT_FLAG,
         MYROW.MAT_STATUS,
         MYROW.JUDGE_STD_DES,
         V_BATHYEAR,
         V_DATA_SOURCE,
         MYROW.QCM_STAUS,
         '0',
         (SELECT T1.DEPARTMENT_CODE_P FROM COM_BASE_PLINE T1 WHERE T1.PLINE_CODE = MYROW.PLINE_CODE),
         (SELECT T2.DEPARTMENT_DESC_P FROM COM_BASE_PLINE T2 WHERE T2.PLINE_CODE = MYROW.PLINE_CODE),
         '#DRIVER#',
         '#OUT_TYPE#',
         MYROW.FLAG_STOVE_NO_ZG，
         '#SUPERVISOR_NAME#',
         '#SUPERVISOR_CALL#',
         MYROW.PRO_ORDER_ID,
         MYROW.GX_PLAN_NO,
         MYROW.PIPMEMO,
         MYROW.MEMO
         );
      UPDATE YDM_BC_BUTTRESS T SET T.STORAGE_NO = '',T.LOCATION_NO = '',T.LARY_NO = '' WHERE T.MAT_NO = MYROW.MAT_NO;
      --UPDATE MAT_BC_M T
         --SET T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#',
          --   T.MAT_GOWHERE_NAME = '#MAT_GOWHERE_NAME#'
       --WHERE T.MAT_NO = MYROW.MAT_NO;
      V_OCOUNT := V_OCOUNT + 1;
    END LOOP;
  ELSE
    V_DATA_SOURCE := '1';
    FOR MYROW IN (SELECT F.*,S1.BILL_NO
  FROM (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 NVL(T.LOT_NO, '/') = NVL('#LOT_NO#', '/')
           AND NVL(T.STOVE_NO, '/') = NVL('#STOVE_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.PRODUCT_FLAG = '#PRODUCT_FLAG#'
           AND T.MAT_STATUS = '#MAT_STATUS_CODE#'
           AND NVL(S.STORAGE_NO, '/') = NVL('#STORAGE_NO#', '/')
           AND NVL(S.LOCATION_NO, '/') = NVL('#LOCATION_NO#', '/')
           AND NVL(S.LARY_NO, '1') = NVL('#LARY_NO#', '1')
           AND T.BELONG_CODE = '#BELONG_CODE#'
           AND NVL(T.SUBCONTRACT_NO, '/') = NVL('#SUBCONTRACT_NO#', '/')
           AND NVL(T.SUBCONTRACT_NO_SEQ, '/') =
               NVL('#SUBCONTRACT_NO_SEQ#', '/')
           AND NVL(T.FLAG_STOVE_NO_ZG,'/') = NVL('#FLAG_STOVE_NO_ZG#','/')
           AND S.STORAGE_NO IS NOT NULL
           AND T.LOCK_BILL_FLAG = '0'
           AND NVL(T.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
           AND NVL(T.MEMO1,'/') = NVL('#MEMO1#','/')
           AND NVL(T.MEMO,'/') = NVL('#MEMO#','/')
           AND ROWNUM <= #ACT_COUNT#
         ORDER BY T.MAT_NO DESC) F
  LEFT JOIN YDM_ZC_BILL_C S1
    ON F.MAT_NO = S1.MAT_NO
    AND S1.EDIT_FLAG  = '0') LOOP
      V_OUTSTOCK_SQE := V_OUTSTOCK_DOC || LPAD(V_OCOUNT, 4, 0);
      INSERT INTO YDM_BC_OUTLIST
        (OUTSTOCK_SQE,
         OUTSTOCK_DOC,
         OUTSTOCK_TYPE_CODE,
         OUTSTOCK_TYPE_NAME,
         ICCAR_NO,
         VEHICLE_NO,
         MAT_NO,
         LOT_NO,
         STOVE_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,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         
         TAR_STORAGE_NO,
         TAR_REC_FLAG,
         INSTOCK_TIME,
         OUTSTOCK_TIME,
         OUT_BC,
         OUT_BZ,
         CREATE_NAME,
         CREATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         BAL_YEAR_MONTH,
         DATA_SUORCE,
         QCM_STAUS,
         LEAVE_FACTORY_FLAG,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         DRIVER,
         OUT_TYPE,
         FLAG_STOVE_NO_ZG,
         M_BILL_NO,
         SUPERVISOR_NAME,
         SUPERVISOR_CALL,
         PRO_ORDER_ID,
         GX_PLAN_NO,
         PIPMEMO,
         MEMO)
      VALUES
        (V_OUTSTOCK_SQE,
         V_OUTSTOCK_DOC,
         '#OUTSTOCK_TYPE_CODE#',
         '#OUTSTOCK_TYPE_NAME#',
         '#ICCAR_NO#',
         '#VEHICLE_NO#',
         MYROW.MAT_NO,
         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.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.ACT_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.LARY_NO,
         MYROW.LOC_NO,
         MYROW.STORAGE_ATTR,
         MYROW.STORAGE_ATTR_NAME,
         MYROW.STORAGE_TYPE_NO,
         MYROW.STORAGE_TYPE_NAME,
         
         '#TAR_STORAGE_NO#',
         '0',
         MYROW.INSTOCK_TIME,
         V_TIME,
         '#OUT_BC#',
         '#OUT_BZ#',
         '#CREATE_NAME#',
         V_TIME,
         MYROW.ORD_PK,
         MYROW.ORD_LN_PK,
         MYROW.ORD_LN_DLY_PK,
         MYROW.ORDER_NO,
         MYROW.ORDER_SEQ,
         MYROW.ORDER_SEQ_NO,
         MYROW.PRODUCT_FLAG,
         MYROW.MAT_STATUS,
         MYROW.JUDGE_STD_NAME,
         MYROW.JUDGE_STD_CODE,
         V_BATHYEAR,
         V_DATA_SOURCE,
         '00',
         '0',
         (SELECT T1.DEPARTMENT_CODE_P FROM COM_BASE_PLINE T1 WHERE T1.PLINE_CODE = MYROW.PLINE_CODE),
         (SELECT T2.DEPARTMENT_DESC_P FROM COM_BASE_PLINE T2 WHERE T2.PLINE_CODE = MYROW.PLINE_CODE),
         '#DRIVER#',
         '#OUT_TYPE#',
         MYROW.FLAG_STOVE_NO_ZG,
         MYROW.BILL_NO,
         '#SUPERVISOR_NAME#',
         '#SUPERVISOR_CALL#',
         MYROW.PRO_ORDER_ID,
         MYROW.GX_PLAN_NO,
         MYROW.PIPMEMO,
         MYROW.MEMO);
      UPDATE YDM_ZC_BUTTRESS T SET T.STORAGE_NO = '',T.LOCATION_NO = '',T.LARY_NO = '' WHERE T.MAT_NO = MYROW.MAT_NO;
      V_OCOUNT := V_OCOUNT + 1;
    END LOOP;
  END IF;
  IF(V_COUNT = 0)THEN
  INSERT INTO YDM_BC_OUTLISTDOC (OUTSTOCK_DOC)VALUES ('#OUTSTOCK_DOC#');
  END IF;
END;
]]>
</query>
<query id = "FrmFilpOutStorage.doAddMat" desc = "按支倒库">
<![CDATA[
DECLARE
  V_OUTSTOCK_DOC YDM_BC_OUTLIST.OUTSTOCK_DOC%TYPE := NULL; --出库单号
  V_OUTSTOCK_SQE YDM_BC_OUTLIST.OUTSTOCK_SQE%TYPE := NULL; --出库流水

  V_MEMO        COM_BASE_INFO.MEMO%TYPE := NULL;
  V_BASENAME    COM_BASE_INFO.BASENAME%TYPE := NULL;
  V_OCOUNT      NUMBER := 1;
  V_TIME        YDM_BC_OUTLIST.CREATE_TIME%TYPE := SYSDATE;
  V_BATHYEAR    MAT_BC_M.BAL_YEAR_MONTH%TYPE := TO_CHAR(SYSDATE, 'YYYYMM');
  V_DATA_SOURCE YDM_BC_OUTLIST.DATA_SUORCE%TYPE := NULL;
  V_COUNT YDM_BC_OUTLIST.ACT_COUNT%TYPE :=NULL;
BEGIN
  SELECT COUNT(1)INTO V_COUNT FROM YDM_BC_OUTLISTDOC T WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
  --生成出库单号
  V_OUTSTOCK_DOC := '#OUTSTOCK_DOC#';
  SELECT MEMO, BASENAME
    INTO V_MEMO, V_BASENAME
    FROM COM_BASE_INFO
   WHERE BASECODE = '#OUTSTOCK_TYPE_CODE#';
  SELECT TO_NUMBER(LPAD((NVL(MAX(SUBSTR(T.OUTSTOCK_SQE, 16)), 0) + 1), 4, 0)) OUTSTOCK_SQE
    INTO V_OCOUNT
    FROM YDM_BC_OUTLIST T
   WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
  IF ('#BAR_CODE#' = '0') THEN
    V_DATA_SOURCE := '0';
    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_BC_M T, YDM_BC_BUTTRESS S
                   WHERE T.MAT_NO = S.MAT_NO
                     AND T.MAT_NO = '#MAT_NO_S#'
                     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                     AND T.BATCH_NO = '#BATCH_NO#'
                     AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                     AND S.STORAGE_NO IS NOT NULL) LOOP
      V_OUTSTOCK_SQE := V_OUTSTOCK_DOC || LPAD(V_OCOUNT, 4, 0);
      INSERT INTO YDM_BC_OUTLIST
        (OUTSTOCK_SQE,
         OUTSTOCK_DOC,
         OUTSTOCK_TYPE_CODE,
         OUTSTOCK_TYPE_NAME,
         ICCAR_NO,
         VEHICLE_NO,
         MAT_NO,
         LOT_NO,
         STOVE_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,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         TAR_STORAGE_NO,
         TAR_REC_FLAG,
         INSTOCK_TIME,
         OUTSTOCK_TIME,
         OUT_BC,
         OUT_BZ,
         CREATE_NAME,
         CREATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         JUDGE_STD_NAME,
         BAL_YEAR_MONTH,
         DATA_SUORCE,
         QCM_STAUS,
         LEAVE_FACTORY_FLAG,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         DRIVER,
         OUT_TYPE,
         FLAG_STOVE_NO_ZG,
         SUPERVISOR_NAME,
         SUPERVISOR_CALL,
         PRO_ORDER_ID,
         GX_PLAN_NO)
      VALUES
        (V_OUTSTOCK_SQE,
         V_OUTSTOCK_DOC,
         '#OUTSTOCK_TYPE_CODE#',
         '#OUTSTOCK_TYPE_NAME#',
         '#ICCAR_NO#',
         '#VEHICLE_NO#',
         MYROW.MAT_NO,
         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.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.ACT_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.LARY_NO,
         MYROW.LOC_NO,
         MYROW.STORAGE_ATTR,
         MYROW.STORAGE_ATTR_NAME,
         MYROW.STORAGE_TYPE_NO,
         MYROW.STORAGE_TYPE_NAME,
         '#TAR_STORAGE_NO#',
         '0',
         MYROW.INSTOCK_TIME,
         V_TIME,
         '#OUT_BC#',
         '#OUT_BZ#',
         '#CREATE_NAME#',
         V_TIME,
         MYROW.ORD_PK,
         MYROW.ORD_LN_PK,
         MYROW.ORD_LN_DLY_PK,
         MYROW.ORDER_NO,
         MYROW.ORDER_SEQ,
         MYROW.ORDER_SEQ_NO,
         MYROW.PRODUCT_FLAG,
         MYROW.MAT_STATUS,
         MYROW.JUDGE_STD_DES,
         V_BATHYEAR,
         V_DATA_SOURCE,
         MYROW.QCM_STAUS,
         '0',
         (SELECT T1.DEPARTMENT_CODE_P FROM COM_BASE_PLINE T1 WHERE T1.PLINE_CODE = MYROW.PLINE_CODE),
         (SELECT T2.DEPARTMENT_DESC_P FROM COM_BASE_PLINE T2 WHERE T2.PLINE_CODE = MYROW.PLINE_CODE),
         '#DRIVER#',
         '#OUT_TYPE#',
         MYROW.FLAG_STOVE_NO_ZG,
         '#SUPERVISOR_NAME#',
         '#SUPERVISOR_CALL#',
         MYROW.PRO_ORDER_ID,
         MYROW.GX_PLAN_NO);
      UPDATE YDM_BC_BUTTRESS T SET T.STORAGE_NO = '',T.LOCATION_NO = '',T.LARY_NO = '' WHERE T.MAT_NO = MYROW.MAT_NO;
      UPDATE MAT_GP_M T
         SET T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#',
             T.MAT_GOWHERE_NAME = '#MAT_GOWHERE_NAME#'
       WHERE T.MAT_NO = MYROW.MAT_NO;
    END LOOP;
  ELSE
    V_DATA_SOURCE := '1';
    FOR MYROW IN (SELECT F.*,S1.BILL_NO
  FROM (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_S#'
           AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
           AND T.BATCH_NO = '#BATCH_NO#'
           AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
           AND S.STORAGE_NO IS NOT NULL
           AND T.LOCK_BILL_FLAG = '0') F
  LEFT JOIN YDM_ZC_BILL_C S1
    ON F.MAT_NO = S1.MAT_NO
     AND S1.EDIT_FLAG  = '0') LOOP
      V_OUTSTOCK_SQE := V_OUTSTOCK_DOC || LPAD(V_OCOUNT, 4, 0);
      INSERT INTO YDM_BC_OUTLIST
        (OUTSTOCK_SQE,
         OUTSTOCK_DOC,
         OUTSTOCK_TYPE_CODE,
         OUTSTOCK_TYPE_NAME,
         ICCAR_NO,
         VEHICLE_NO,
         MAT_NO,
         LOT_NO,
         STOVE_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,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         
         TAR_STORAGE_NO,
         TAR_REC_FLAG,
         INSTOCK_TIME,
         OUTSTOCK_TIME,
         OUT_BC,
         OUT_BZ,
         CREATE_NAME,
         CREATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         BAL_YEAR_MONTH,
         DATA_SUORCE,
         QCM_STAUS,
         LEAVE_FACTORY_FLAG,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         DRIVER,
         OUT_TYPE,
         FLAG_STOVE_NO_ZG,
         M_BILL_NO,
         SUPERVISOR_NAME,
         SUPERVISOR_CALL,
         PRO_ORDER_ID,
         GX_PLAN_NO)
      VALUES
        (V_OUTSTOCK_SQE,
         V_OUTSTOCK_DOC,
         '#OUTSTOCK_TYPE_CODE#',
         '#OUTSTOCK_TYPE_NAME#',
         '#ICCAR_NO#',
         '#VEHICLE_NO#',
         MYROW.MAT_NO,
         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.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.ACT_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.LARY_NO,
         MYROW.LOC_NO,
         MYROW.STORAGE_ATTR,
         MYROW.STORAGE_ATTR_NAME,
         MYROW.STORAGE_TYPE_NO,
         MYROW.STORAGE_TYPE_NAME,
         
         '#TAR_STORAGE_NO#',
         '0',
         MYROW.INSTOCK_TIME,
         V_TIME,
         '#OUT_BC#',
         '#OUT_BZ#',
         '#CREATE_NAME#',
         V_TIME,
         MYROW.ORD_PK,
         MYROW.ORD_LN_PK,
         MYROW.ORD_LN_DLY_PK,
         MYROW.ORDER_NO,
         MYROW.ORDER_SEQ,
         MYROW.ORDER_SEQ_NO,
         MYROW.PRODUCT_FLAG,
         MYROW.MAT_STATUS,
         MYROW.JUDGE_STD_NAME,
         MYROW.JUDGE_STD_CODE,
         V_BATHYEAR,
         V_DATA_SOURCE,
         '00',
         '0',
         (SELECT T1.DEPARTMENT_CODE_P FROM COM_BASE_PLINE T1 WHERE T1.PLINE_CODE = MYROW.PLINE_CODE),
         (SELECT T2.DEPARTMENT_DESC_P FROM COM_BASE_PLINE T2 WHERE T2.PLINE_CODE = MYROW.PLINE_CODE),
         '#DRIVER#',
         '#OUT_TYPE#',
         MYROW.FLAG_STOVE_NO_ZG,
         MYROW.BILL_NO,
         '#SUPERVISOR_NAME#',
         '#SUPERVISOR_CALL#',
         MYROW.PRO_ORDER_ID,
         MYROW.GX_PLAN_NO);
      UPDATE YDM_ZC_BUTTRESS T SET T.STORAGE_NO = '',T.LOCATION_NO = '',T.LARY_NO = '' WHERE T.MAT_NO = MYROW.MAT_NO;
    END LOOP;
  END IF;
  IF(V_COUNT = 0)THEN
  INSERT INTO YDM_BC_OUTLISTDOC (OUTSTOCK_DOC)VALUES ('#OUTSTOCK_DOC#');
  END IF;
END;
]]>
</query>
<query id = "FrmFilpOutStorage.selectYdmOutTarFlag" desc = "查询倒运记录是否已接收">
SELECT COUNT(1)ACOUNT
  FROM YDM_BC_OUTLIST T
 WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
   --AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   --AND T.BATCH_NO = '#BATCH_NO#'
  -- AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND T.TAR_REC_FLAG = '1'
   --AND T.QCM_STAUS = '#QCM_STAUS#'
</query>
<query id = "FrmFilpOutStorage.doDelte" desc = "撤销倒运">
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM YDM_BC_OUTLIST T
                 WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
                   --AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   --AND T.BATCH_NO = '#BATCH_NO#'
                   --AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                   --AND T.QCM_STAUS = '#QCM_STAUS#'
                   AND T.VALIDFLAG = '1'
                 ORDER BY T.MAT_NO ASC) LOOP
    IF (MYROW.DATA_SUORCE = '0') THEN
      IF (MYROW.QCM_STAUS = '22') THEN
        UPDATE YDM_BC_BUTTRESS S
           SET S.STORAGE_NO  = MYROW.STORAGE_NO,
               S.LOCATION_NO = MYROW.LOCATION_NO,
               S.LARY_NO     = MYROW.LARY_NO
         WHERE S.MAT_NO = MYROW.MAT_NO
           AND S.STORAGE_NO IS NULL;
      
      ELSE
        UPDATE YDM_BC_BUTTRESS S
           SET S.STORAGE_NO  = MYROW.STORAGE_NO,
               S.LOCATION_NO = MYROW.LOCATION_NO,
               S.LARY_NO     = MYROW.LARY_NO
         WHERE S.MAT_NO = MYROW.MAT_NO
           AND S.STORAGE_NO IS NULL;
      
      END IF;
    ELSE
      UPDATE YDM_ZC_BUTTRESS S
         SET S.STORAGE_NO  = MYROW.STORAGE_NO,
             S.LOCATION_NO = MYROW.LOCATION_NO,
             S.LARY_NO     = MYROW.LARY_NO
       WHERE S.MAT_NO = MYROW.MAT_NO
         AND S.STORAGE_NO IS NULL;
    END IF;
    DELETE FROM YDM_BC_OUTLIST T
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND T.OUTSTOCK_DOC = MYROW.OUTSTOCK_DOC;
  END LOOP;
  DELETE FROM YDM_BC_OUTLISTDOC T WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
END;
</query>
<query id = "FrmFilpOutStorage.selectOutBcWgt" desc= "查询倒运支数重量">
<![CDATA[
SELECT SUM(T.ACT_WEIGHT)ACT_WEIGHT
  FROM MAT_BC_M T, YDM_BC_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 T.QCM_STAUS = '#QCM_STAUS#'
   AND NVL(T.PRO_PLAN_ID_NEXT, '/') = NVL('#PRO_PLAN_ID_NEXT#', '/')
   AND NVL(T.GX_PLAN_NO_NEXT, '/') = NVL('#GX_PLAN_NO_NEXT#', '/')
   AND S.STORAGE_NO = '#STORAGE_NO#'
   AND S.LOCATION_NO = '#LOCATION_NO#'
   AND NVL(S.LARY_NO,'/') = NVL('#LARY_NO#','/')
   WHERE ROWNUM <= #ACOUNT#
   ]]>
</query>
<query id = "FrmFilpOutStorage.selectOutZcWgt" desc = "查询成品倒运支数重量">
<![CDATA[
SELECT SUM(T.ACT_WEIGHT)ACT_WEIGHT
  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 S.STORAGE_NO = '#STORAGE_NO#'
   AND S.LOCATION_NO = '#LOCATION_NO#'
   AND NVL(S.LARY_NO,'/') = NVL('#LARY_NO#','/')
   WHERE ROWNUM <= #ACOUNT#
]]>
</query>
<query id = "FrmFilpOutStorage.doQueryTarDepart" desc = "查询仓库对应科室">
SELECT T.MANAGEMENT_NO,T.MANAGEMENT_NAME FROM YDM_BS_STORAGE T WHERE T.STORAGE_NO = ?
</query>
<query id = "FrmFilpOutStorage.doQueryCount" desc = "查询单号下未接收">
SELECT NVL(SUM(T.ACT_COUNT), 0) ACT_COUNT
  FROM YDM_BC_OUTLIST T
 WHERE T.OUTSTOCK_DOC = ?
   AND T.TAR_REC_FLAG = '0'
   AND T.QCM_STAUS IN('00','11')
</query>
    <query id = "FrmFilpOutStorage.insertOutdoc" desc = "保存倒库单号">
        INSERT INTO YDM_BC_OUTLISTDOC (OUTSTOCK_DOC) VALUES (?)
    </query>
    <query id = "FrmFilpOutStorage.deleteDoc" desc = "删除倒库单号">
    DELETE FROM YDM_BC_OUTLISTDOC T WHERE T.OUTSTOCK_DOC = ?
    </query>
    <query id = "FrmFilpOutStorage.doQueryMatBcCountMatNo" desc = "查询材料号是否在库">
    SELECT NVL(COUNT(1),'0') ACOUNT
  FROM MAT_BC_M T, YDM_BC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
   AND T.MAT_NO = '#MAT_NO#'
   AND S.STORAGE_NO = '#STORAGE_NO#'
    </query>
    <query id = "FrmFilpOutStorage.doQueryMatZcCountMatNo" desc = "查询材料号是否在库">
    SELECT NVL(COUNT(1),'0') ACOUNT
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
   AND T.MAT_NO = '#MAT_NO#'
   AND S.STORAGE_NO = '#STORAGE_NO#'
    </query>
    <query id = "FrmFilpOutStorage.getBcMatNo" desc = "查询BC队列">
    SELECT T.*
  FROM MAT_BC_M T, YDM_BC_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.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
   AND T.QCM_STAUS = '#QCM_STAUS#'
   AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
   AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/')
   AND T.PLINE_CODE = '#PLINE_CODE#'
   AND T.MAT_STATUS = '#MAT_STATUS_CODE#'
   AND T.BELONG_CODE = '#BELONG_CODE#'
   AND S.STORAGE_NO = '#STORAGE_NO#'
   AND NVL(T.SUBCONTRACT_NO,'/') = NVL('#SUBCONTRACT_NO#','/')
   AND NVL(T.SUBCONTRACT_NO_SEQ,'/') = NVL('#SUBCONTRACT_NO_SEQ#','/')
   AND NVL(T.OFFLINE_DOC,'/') = NVL('#OFFLINE_DOC#','/')
   AND NVL(T.MEMO,'/') = NVL('#MEMO#','/')
        AND NVL(T.MEMO1,'/') = NVL('#MEMO1#','/')
        AND NVL(T.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
   ORDER BY TO_NUMBER(T.MEASURING_SEQ) ASC
    </query>
    <query id = "FrmFilpOutStorage.getZcMatNo" desc = "查询ZC队列">
    SELECT T.*
  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.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
   AND T.BELONG_CODE = '#BELONG_CODE#'
   AND T.PLINE_CODE = '#PLINE_CODE#'
   AND T.MAT_STATUS = '#MAT_STATUS_CODE#'
    AND S.STORAGE_NO = '#STORAGE_NO#'
   AND NVL(T.SUBCONTRACT_NO,'/') = NVL('#SUBCONTRACT_NO#','/')
   AND NVL(T.SUBCONTRACT_NO_SEQ,'/') = NVL('#SUBCONTRACT_NO_SEQ#','/')
        AND NVL(T.MEMO,'/') = NVL('#MEMO#','/')
        AND NVL(T.MEMO1,'/') = NVL('#MEMO1#','/')
        AND NVL(T.PIPMEMO,'/') = NVL('#PIPMEMO#','/')
   ORDER BY TO_NUMBER(T.MEASURING_SEQ) ASC
    </query>
    <query id = "FrmFilpOutStorage.getSuperName" desc = "加载监装人">
        SELECT T1.SUPERVISOR_CODE, T1.SUPERVISOR_NAME
        FROM YDM_BC_SUPERVISOR T1,
        (SELECT T.PLINE_CODE FROM COM_BASE_PLINE T WHERE T.PROCESS_CODE NOT IN('A','B','C')
    </query>
    <query id = "FrmFilpOutStorage.selectSuper" desc = "查询监装人">
        SELECT T.SUPERVISOR_NAME,T.SUPERVISOR_CALL FROM YDM_BC_SUPERVISOR T WHERE T.SUPERVISOR_CODE = ?
    </query>
    <query id = "FrmFilpOutStorage.selectWayBill" desc  = "查询司机是否有接单记录">
        SELECT NVL(COUNT(1),0) ACOUNT,MAX(S.END_AREA_CODE)END_AREA_CODE,MAX(T.WAYBILL_NO)WAYBILL_NO
        FROM TMS_WAYBILL_M T,TMS_PLN_C S,TMS_PLN_M P
        WHERE T.PLN_NO = S.PLN_NO
        AND T.PLN_NO = P.PLN_NO
        AND S.PLN_NO = P.PLN_NO
        AND S.HEAT_NO = ?
        AND S.START_AREA_CODE = ?
        AND T.CAR_LICENSE = ?
        AND T.VALIDFLAG IN('20','35')
        AND P.STATUS = '20'
    </query>
    <query id = "FrmFilpOutStorage.SelectWayM" desc = "查询运单主表信息">
        SELECT T.*,S.START_NODE_CODE
        FROM TMS_WAYBILL_M T,TMS_COM_LINE_M S
        WHERE T.LINE_CODE = S.LINE_CODE
        AND T.CAR_LICENSE = ?
        AND T.VALIDFLAG IN('20','35')
    </query>
    <query id = "FrmFilpOutStorage.selectWgt" desc = "查询对应支数重量">
        SELECT T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME,
        T.SPEC_NAME,
        T.ACT_DIMATER,
        T.ACT_HEIGHT,
        T.FLAG_STOVE_NO_ZG,
        T.SUPERVISOR_NAME,
        T.SUPERVISOR_CALL,
        T.OUTSTOCK_DOC,
        T.PRODUCT_FLAG,
        T.MAT_STATUS,
        T.STORAGE_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.PRODUCCODE,
        T.PRODUCNAME,
        T.QCM_STAUS,
        T.PRODUCT_FLAG,
        T.MAT_STATUS,
        (SELECT T1.PRODUC_HEAD FROM COM_BASE_PRODUCT T1 WHERE T1.PRODUCCODE = T.PRODUCCODE)PRODUCT_CODE,
        (SELECT S.BASENAME FROM COM_BASE_PRODUCT T2,COM_BASE_INFO S WHERE T2.PRODUC_HEAD = S.BASECODE AND T2.PRODUCCODE = T.PRODUCCODE)PRODUCT_NAME,
        MAX(T.SUPERVISOR_NAME)SUPERVISOR_NAME,
        MAX(T.SUPERVISOR_CALL)SUPERVISOR_CALL,
        SUM(T.ACT_COUNT) ACT_COUNT,
        SUM(T.ACT_WEIGHT) ACT_WEIGHT
        FROM YDM_BC_OUTLIST T
        WHERE T.OUTSTOCK_DOC = ?
        GROUP BY T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME,
        T.SPEC_NAME,
        T.ACT_DIMATER,
        T.ACT_HEIGHT,
        T.FLAG_STOVE_NO_ZG,
        T.SUPERVISOR_NAME,
        T.SUPERVISOR_CALL,
        T.OUTSTOCK_DOC,
        T.PRODUCT_FLAG,
        T.MAT_STATUS,
        T.STORAGE_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.PRODUCCODE,
        T.PRODUCNAME,
        T.QCM_STAUS,
        T.PRODUCT_FLAG,
        T.MAT_STATUS
    </query>
    <query id = "FrmFilpOutStorage.insertWayC" desc = "新增运单子表信息">
        DECLARE
        V_WAYBILL_SQE TMS_WAYBILL_C.WAYBILL_SQE%TYPE := NULL;
        BEGIN
        SELECT LPAD(NVL(MAX(SUBSTR(T.WAYBILL_SQE,0)), 0) + 1,3,0)
        INTO V_WAYBILL_SQE
        FROM TMS_WAYBILL_C T
        WHERE T.WAYBILL_NO = '#WAYBILL_NO#';

        INSERT INTO TMS_WAYBILL_C
        (MATERIALS_DIMATER,
        MATERIALS_HEIGHT,
        MAT_STATUS,
        SUPERVISOR_NAME,
        SUPERVISOR_CALL,
        PRODUCT_FLAG,
        MAT_TYPE,
        WAYBILL_NO,
        WAYBILL_SQE,
        PLN_NO,
        PLN_SQE,
        HEAT_NO,
        BATCH_NO,
        LOGO_NO,
        GROUP_NO,
        MATERIALS_CODE,
        MATERIALS_DESC,
        MATERIALS_SPEC,
        WAYBILL_QTY_VAL,
        WAYBILL_WT_VAL,
        REF_PLN_NO,
        START_NODE_CODE,
        START_NODE_DESC,
        START_AREA_CODE,
        START_AREA_DESC,
        END_NODE_CODE,
        END_NODE_DESC,
        END_AREA_CODE,
        END_AREA_DESC,
        PLINE_CODE,
        PLINE_NAME,
        PROCESS_CDOE,
        PROCESS_DESC,
        PRODUCCODE,
        PRODUCNAME,
        PRODUCT_CODE,
        PRODUCT_NAME,
        QCM_STAUS,
        DEMAND_ORG_CODE,
        DEMAND_ORG_DESC
        )
        VALUES
        ('#MATERIALS_DIMATER#',
        '#MATERIALS_HEIGHT#',
        '#MAT_STATUS#',
        '#SUPERVISOR_NAME#',
        '#SUPERVISOR_CALL#',
        '#PRODUCT_FLAG#',
        '#MAT_TYPE#',
        '#WAYBILL_NO#',
        V_WAYBILL_SQE,
        '#PLN_NO#',
        V_WAYBILL_SQE,
        '#HEAT_NO#',
        '#BATCH_NO#',
        '#LOGO_NO#',
        '#GROUP_NO#',
        '#MATERIALS_CODE#',
        '#MATERIALS_DESC#',
        '#MATERIALS_SPEC#',
        '#WAYBILL_QTY_VAL#',
        '#WAYBILL_WT_VAL#',
        '#REF_PLN_NO#',
        '#START_NODE_CODE#',
        '#START_NODE_DESC#',
        '#START_AREA_CODE#',
        '#START_AREA_DESC#',
        '#END_NODE_CODE#',
        '#END_NODE_DESC#',
        '#END_AREA_CODE#',
        '#END_AREA_DESC#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#PROCESS_CDOE#',
        '#PROCESS_DESC#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#PRODUCT_CODE#',
        '#PRODUCT_NAME#',
        '#QCM_STAUS#',
        '#DEMAND_ORG_CODE#',
        '#DEMAND_ORG_DESC#');
        END;
    </query>
    <query id = "FrmFilpOutStorage.insertExcute" desc = "新增装车实绩表">

        DECLARE
        V_EXECUTE_NO TMS_EXECUTE_B.EXECUTE_NO%TYPE := NULL;
        BEGIN
        SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') ||
        LPAD(NVL(MAX(SUBSTR(T.EXECUTE_NO,9)), 0) + 1, 5, 0)
        INTO V_EXECUTE_NO
        FROM TMS_EXECUTE_B T
        WHERE EXECUTE_NO  LIKE TO_CHAR(SYSDATE, 'YYYYMMDD')|| '_____';
        INSERT INTO TMS_EXECUTE_B
        (EXECUTE_NO,
        UNLOADING_CODE,
        CAR_LICENSE,
        PLN_NO,
        WAYBILL_NO,
        EXECUTE_TIME,
        REFE_NO,
        ACCOUNT_YEAR_MONTH,
        CREATE_TIME)
        VALUES
        ( V_EXECUTE_NO,
        '#UNLOADING_CODE#',
        '#CAR_LICENSE#',
        '#PLN_NO#',
        '#WAYBILL_NO#',
        SYSDATE,
        '#REFE_NO#',
        '#ACCOUNT_YEAR_MONTH#',
        SYSDATE);
        END;

    </query>
    <query id = "FrmFilpOutStorage.updateWayM" desc = "修改运单主表状态">
        UPDATE TMS_WAYBILL_M T SET T.VALIDFLAG = '#VALIDFLAG#' WHERE T.WAYBILL_NO = '#WAYBILL_NO#'
    </query>
    <query id = "FrmFilpOutStorage.insertCraneWayC" desc = "新增吊车运单子表">


        INSERT INTO TMS_WAYBILL_C
        (WAYBILL_NO,
        WAYBILL_SQE,
        PLN_NO,
        PLN_SQE,
        HEAT_NO,
        BATCH_NO,
        LOGO_NO,
        GROUP_NO,
        MATERIALS_CODE,
        MATERIALS_DESC,
        MATERIALS_SPEC,
        WAYBILL_QTY_VAL,
        WAYBILL_WT_VAL,
        UOM_CODE,
        UOM_DESC,
        PRO_ORDER_NO,
        PRO_ORDER_SQE,
        CURRENT_JOB_NO,
        NEXT_JOB_NO,
        MEMO,
        REF_PLN_NO,
        REF_PLN_SQE,
        REFE_NO,
        CAR_LICENSE,
        AFFIRM_TIME,
        MATERIALS_DIMATER,
        MATERIALS_HEIGHT,
        IS_SORT,
        SUPERVISOR_NAME,
        SUPERVISOR_CALL,
        PRODUCT_FLAG,
        MAT_STATUS,
        MAT_TYPE,
        START_NODE_CODE,
        START_NODE_DESC,
        END_NODE_CODE,
        END_NODE_DESC,
        START_AREA_CODE,
        START_AREA_DESC,
        END_AREA_DESC,
        END_AREA_CODE,
        PLINE_CODE,
        PLINE_NAME,
        PROCESS_CDOE,
        PROCESS_DESC,
        PRODUCCODE,
        PRODUCNAME,
        PRODUCT_CODE,
        PRODUCT_NAME,
        QCM_STAUS,
        DEMAND_ORG_CODE,
        DEMAND_ORG_DESC)
        SELECT  '#CRANE_WAYBILL_NO#',
        (SELECT NVL(MAX(TO_NUMBER(WAYBILL_SQE)), 0)
        FROM TMS_WAYBILL_C
        WHERE WAYBILL_NO = '#CRANE_WAYBILL_NO#' ) + ROWNUM,
        (SELECT PLN_NO FROM TMS_WAYBILL_M WHERE WAYBILL_NO = '#CRANE_WAYBILL_NO#'),
        '1',
        HEAT_NO,
        BATCH_NO,
        LOGO_NO,
        GROUP_NO,
        MATERIALS_CODE,
        MATERIALS_DESC,
        MATERIALS_SPEC,
        WAYBILL_QTY_VAL,
        WAYBILL_WT_VAL,
        UOM_CODE,
        UOM_DESC,
        PRO_ORDER_NO,
        PRO_ORDER_SQE,
        CURRENT_JOB_NO,
        NEXT_JOB_NO,
        MEMO,
        PLN_NO,
        PLN_SQE,
        '#WAYBILL_NO#',
        (SELECT CAR_LICENSE FROM TMS_WAYBILL_M WHERE WAYBILL_NO = '#WAYBILL_NO#'),
        SYSDATE,
        MATERIALS_DIMATER,
        MATERIALS_HEIGHT,
        IS_SORT,
        SUPERVISOR_NAME,
        SUPERVISOR_CALL,
        PRODUCT_FLAG,
        MAT_STATUS,
        MAT_TYPE,
        START_NODE_CODE,
        START_NODE_DESC,
        START_NODE_CODE,
        START_NODE_DESC,
        START_AREA_CODE,
        START_AREA_DESC,
        START_AREA_DESC,
        START_AREA_CODE,
        PLINE_CODE,
        PLINE_NAME,
        PROCESS_CDOE,
        PROCESS_DESC,
        PRODUCCODE,
        PRODUCNAME,
        PRODUCT_CODE,
        PRODUCT_NAME,
        QCM_STAUS,
        DEMAND_ORG_CODE,
        DEMAND_ORG_DESC
        FROM TMS_WAYBILL_C T
        WHERE T.WAYBILL_NO =  '#WAYBILL_NO#'
        AND T. START_NODE_CODE= '#NODE_CODE#'
    </query>
    <query id = "FrmFilpOutStorage.insertTraceM" desc = "写跟踪记录">
        INSERT INTO TMS_TRACE_M
        (WAYBILL_NO,
        TRACE_NO,
        NODE_CODE,
        NODE_DESC,
        NODE_TYPE_CODE,
        NODE_TYPE_DESC,
        REFE_NO,
        EVENT_CODE,
        EVENT_DESC,
        EVENT_TIME
        )
        VALUES
        ('#WAYBILL_NO#',
        (SELECT TO_NUMBER(MAX(T.TRACE_NO), 0) + 1
        FROM TMS_TRACE_M T
        WHERE T.WAYBILL_NO = '#WAYBILL_NO#'),
        '#NODE_CODE#',
        '#NODE_DESC#',
        '#NODE_TYPE_CODE#',
        '#NODE_TYPE_DESC#',
        '#REFE_NO#',
        '#EVENT_CODE#',
        '#EVENT_DESC#',
        SYSDATE
        )
    </query>
    <query id = "FrmFilpOutStorage.selectWayBillStaus" desc = "查询运单状态">
        SELECT T.VALIDFLAG,T.WAYBILL_NO,T.PLN_NO
        FROM TMS_WAYBILL_M T, TMS_WAYBILL_C S
        WHERE T.WAYBILL_NO = S.WAYBILL_NO
        AND S.REF_PLN_NO = ?
        AND ROWNUM = 1
    </query>
    <query id = "FrmFilpOutStorage.cancelLoadFrim" desc = "撤销装车确认">
        DECLARE
        V_FLAG TMS_TRACE_M.EVENT_CODE%TYPE := NULL;
        BEGIN
        DELETE FROM TMS_WAYBILL_C T
        WHERE (T.WAYBILL_NO = '#WAYBILL_NO#' AND T.LOGO_NO = '#LOGO_NO#' AND
        T.REF_PLN_NO = '#REFE_NO#')
        OR (T.REFE_NO = '#WAYBILL_NO#' AND T.START_NODE_CODE = '#NODE_CODE#');
        DELETE FROM TMS_EXECUTE_B T
        WHERE T.WAYBILL_NO = '#WAYBILL_NO#'
        AND T.REFE_NO = '#REFE_NO#'
        AND T.REFE_NO = '#REFE_NO#';
        DELETE FROM TMS_TRACE_M T
        WHERE T.WAYBILL_NO = '#WAYBILL_NO#'
        AND T.REFE_NO = '#REFE_NO#'
        AND T.EVENT_CODE IN ('RC04', 'RC14');
        SELECT T.EVENT_CODE INTO V_FLAG
        FROM TMS_TRACE_M T
        WHERE T.WAYBILL_NO = '#WAYBILL_NO#'
        AND T.TRACE_NO = (SELECT MAX(T1.TRACE_NO)
        FROM TMS_TRACE_M T1
        WHERE T1.WAYBILL_NO = '#WAYBILL_NO#');
        IF(V_FLAG = 'RC18')THEN
        UPDATE
        TMS_WAYBILL_M T SET T.VALIDFLAG = '35'
        WHERE T.WAYBILL_NO = '#WAYBILL_NO#';
        ELSE
        UPDATE
        TMS_WAYBILL_M T SET T.VALIDFLAG = '20'
        WHERE T.WAYBILL_NO = '#WAYBILL_NO#';
        END IF;
        END;
    </query>
    <query id = "FrmFilpOutStorage.SelectStorageIsCarUser" desc = "查询是否限制了一车一卡">
        SELECT T.IS_CAR_TAKING,T.IS_CAR_TAKING_BILL FROM YDM_BS_STORAGE T WHERE T.STORAGE_NO = ?
    </query>
    <query id = "FrmFilpOutStorage.selectStartArea" desc = "查询起点、区域">
        SELECT T.START_NODE_CODE,
        T.START_NODE_DESC,
        T.START_AREA_CODE,
        T.START_AREA_DESC,
        T.END_NODE_CODE,
        T.END_NODE_DESC,
        T.END_AREA_CODE,
        T.END_AREA_DESC,
        S.DEMAND_ORG_CODE,
        S.DEMAND_ORG_DESC
        FROM TMS_PLN_C T,TMS_DEMAND_M S
        WHERE T.DEMAND_NO = S.DEMAND_NO
        AND T.PLN_NO = ?
        AND T.HEAT_NO = ?
        AND T.START_AREA_CODE = ?
    </query>
    <query id = "FrmFilpOutStorage.selectLineCount" desc = "查询计划线路条数">
        SELECT COUNT(1) ACOUNT
        FROM (SELECT T.START_NODE_CODE,
        T.START_NODE_DESC,
        T.START_AREA_CODE,
        T.START_AREA_DESC,
        T.END_NODE_CODE,
        T.END_NODE_DESC,
        T.END_AREA_CODE,
        T.END_NODE_DESC
        FROM TMS_PLN_C T
        WHERE T.PLN_NO = ?
        AND T.START_AREA_CODE = ?
        GROUP BY T.START_NODE_CODE,
        T.START_NODE_DESC,
        T.START_AREA_CODE,
        T.START_AREA_DESC,
        T.END_NODE_CODE,
        T.END_NODE_DESC,
        T.END_AREA_CODE,
        T.END_NODE_DESC)
    </query>
    <query id = "FrmFilpOutStorage.selectTmsWCount" desc = "查询实际打卡出库线路条数">
        SELECT COUNT(1) ACOUNT
        FROM (SELECT T.START_NODE_CODE,
        T.START_NODE_DESC,
        T.START_AREA_CODE,
        T.START_AREA_DESC,
        T.END_NODE_CODE,
        T.END_NODE_DESC,
        T.END_AREA_CODE,
        T.END_AREA_DESC
        FROM TMS_WAYBILL_C T
        WHERE T.WAYBILL_NO = ?
        AND T.START_AREA_CODE = ?
        GROUP BY T.START_NODE_CODE,
        T.START_NODE_DESC,
        T.START_AREA_CODE,
        T.START_AREA_DESC,
        T.END_NODE_CODE,
        T.END_NODE_DESC,
        T.END_AREA_CODE,
        T.END_AREA_DESC)
    </query>
    <query id = "FrmFilpOutStorage.selectTmsWayRealation" desc = "查询拖车、吊车关系表">
        SELECT T.* FROM TMS_WAYBILL_RELATION T WHERE T.WAYBILL_NO = '#WAYBILL_NO#' AND T.NODE_CODE = '#NODE_CODE#'
    </query>
    <query id = "FrmFilpOutStorage.doQueryDataCarMat" desc = "根据车号查询库存">
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.PRO_ORDER_NO) PRO_ORDER_NO,
        MAX(T.PROCESS_CDOE) PROCESS_CDOE,
        MAX(T.PROCESS_DESC) PROCESS_DESC,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        T.PIPMEMO,
        T.MEMO1,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '废品') QCM_STAUS,
        MAX(T.TARGET) TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT T1.ORDER_NO || '/' || T1.ORDER_SEQ
        FROM PLN_ORDER_DBK_S T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT T2.ORDER_NO || '/' || T2.ORDER_SEQ
        FROM PLN_ORDER_RCL_S T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT T3.ORDER_NO || '/' || T3.ORDER_SEQ
        FROM PLN_ORDER_JGX_S T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        ELSE
        NULL
        END) ORDER_NO_NEXT,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,

        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT (SELECT T5.STORAGE_NAME
        FROM COM_BASE_PLINE T4, YDM_BS_STORAGE T5
        WHERE T4.IN_REPOSITORY = T5.STORAGE_NO
        AND T4.PLINE_CODE = T1.PLINE_CODE)
        FROM PLN_ZY_DBK_M T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT (SELECT T7.STORAGE_NAME
        FROM COM_BASE_PLINE T6, YDM_BS_STORAGE T7
        WHERE T6.IN_REPOSITORY = T7.STORAGE_NO
        AND T6.PLINE_CODE = T2.PLINE_CODE)
        FROM PLN_ZY_RCL_M T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT (SELECT T9.STORAGE_NAME
        FROM COM_BASE_PLINE T8, YDM_BS_STORAGE T9
        WHERE T8.IN_REPOSITORY = T9.STORAGE_NO
        AND T8.PLINE_CODE = T3.PLINE_CODE)
        FROM PLN_ZY_JGX_M T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        ELSE
        NULL
        END) DIRECTION,
        '0' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        '否' LOCK_BILL_FLAG,
        T.OFFLINE_DOC,
        T.MEMO
        FROM MAT_BC_M T, YDM_BC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.PRODUCT_FLAG = '801401' #JUDGE_STOVE_NO# #STORAGE_NO#
        #JUDGE_STOVE_NO1#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.MAT_GOWHERE_CODE,
        T.MAT_GOWHERE_NAME,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        T.JUDGE_RESULT,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.OFFLINE_DOC,
        T.MEMO,
        T.PIPMEMO,
        T.MEMO1,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
        UNION ALL
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.PRO_ORDER_NO) PRO_ORDER_NO,
        MAX(T.PROCESS_CDOE) PROCESS_CDOE,
        MAX(T.PROCESS_DESC) PROCESS_DESC,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        T.PIPMEMO,
        T.MEMO1,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '废品') QCM_STAUS,
        MAX(T.TARGET) TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT T1.ORDER_NO || '/' || T1.ORDER_SEQ
        FROM PLN_ORDER_DBK_S T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT T2.ORDER_NO || '/' || T2.ORDER_SEQ
        FROM PLN_ORDER_RCL_S T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT T3.ORDER_NO || '/' || T3.ORDER_SEQ
        FROM PLN_ORDER_JGX_S T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT)
        ELSE
        NULL
        END) ORDER_NO_NEXT,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        (CASE
        WHEN T.NEXT_PROCESS_CDOE = 'E' THEN
        (SELECT (SELECT T5.STORAGE_NAME
        FROM COM_BASE_PLINE T4, YDM_BS_STORAGE T5
        WHERE T4.IN_REPOSITORY = T5.STORAGE_NO
        AND T4.PLINE_CODE = T1.PLINE_CODE)
        FROM PLN_ZY_DBK_M T1
        WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T1.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'F' THEN
        (SELECT (SELECT T7.STORAGE_NAME
        FROM COM_BASE_PLINE T6, YDM_BS_STORAGE T7
        WHERE T6.IN_REPOSITORY = T7.STORAGE_NO
        AND T6.PLINE_CODE = T2.PLINE_CODE)
        FROM PLN_ZY_RCL_M T2
        WHERE T2.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T2.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        WHEN T.NEXT_PROCESS_CDOE = 'G' THEN
        (SELECT (SELECT T9.STORAGE_NAME
        FROM COM_BASE_PLINE T8, YDM_BS_STORAGE T9
        WHERE T8.IN_REPOSITORY = T9.STORAGE_NO
        AND T8.PLINE_CODE = T3.PLINE_CODE)
        FROM PLN_ZY_JGX_M T3
        WHERE T3.PRO_PLAN_ID = T.PRO_PLAN_ID_NEXT
        AND T3.GX_PLAN_NO = T.GX_PLAN_NO_NEXT
        AND ROWNUM = 1)
        ELSE
        NULL
        END) DIRECTION,
        '0' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        '否' LOCK_BILL_FLAG,
        T.OFFLINE_DOC,
        T.MEMO
        FROM MAT_BC_M T, YDM_BC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.PRODUCT_FLAG = '801402' #JUDGE_STOVE_NO# #STORAGE_NO#
        #JUDGE_STOVE_NO1#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.MAT_GOWHERE_CODE,
        T.MAT_GOWHERE_NAME,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.PRO_PLAN_ID_NEXT,
        T.GX_PLAN_NO_NEXT,
        T.JUDGE_RESULT,
        T.NEXT_PROCESS_CDOE,
        T.NEXT_PROCESS_DESC,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.OFFLINE_DOC,
        T.MEMO,
        T.PIPMEMO,
        T.MEMO1,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
        UNION ALL
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.ORDER_NO || '/' || T.ORDER_SEQ) PRO_ORDER_NO,
        '' PROCESS_CDOE,
        '' PROCESS_DESC,
        '' NEXT_PROCESS_CDOE,
        '' NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        T.PIPMEMO,
        T.MEMO1,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        '合格' QCM_STAUS,
        '' TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        '' ORDER_NO_NEXT,
        '' PRO_PLAN_ID_NEXT,
        '' GX_PLAN_NO_NEXT,
        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        '' PRO_PLAN_ID_NEXT,
        '' GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        '' DIRECTION,
        '1' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        DECODE(T.LOCK_BILL_FLAG, '0', '否', '1', '是') LOCK_BILL_FLAG,
        '' OFFLINE_DOC,
        T.MEMO
        FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.BELONG_CODE IN ('100101', '100102', '100103')
        AND T.PRODUCT_FLAG = '801402' #JUDGE_STOVE_NO# #STORAGE_NO#
        #JUDGE_STOVE_NO1#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.JUDGE_RESULT,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.LOCK_BILL_FLAG,
        T.MEMO,
        T.PIPMEMO,
        T.MEMO1,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
        UNION ALL
        SELECT (SELECT T2.BASENAME
        FROM COM_BASE_INFO T2
        WHERE T2.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
        (SELECT T1.BASENAME
        FROM COM_BASE_INFO T1
        WHERE T1.BASECODE = T.MAT_STATUS) MAT_STATUS,
        T.MAT_STATUS AS MAT_STATUS_CODE,
        T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.MATERIAL_NO,
        T.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_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
        MAX(T.ORDER_NO || '/' || T.ORDER_SEQ) PRO_ORDER_NO,
        '' PROCESS_CDOE,
        '' PROCESS_DESC,
        '' NEXT_PROCESS_CDOE,
        '' NEXT_PROCESS_DESC,
        T.PLINE_CODE,
        T.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,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.JUDGE_RESULT,
        T.PIPMEMO,
        T.MEMO1,
        MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
        MAX(T.JUDGE_MAKER) JUDGE_MAKER,
        MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
        '合格' QCM_STAUS,
        '' TARGET,
        T.FLAG_STOVE_NO_ZG,
        T.FLAG_STOVE_NO_ZG AS UPDATE_FLAG_STOVE,
        '' ORDER_NO_NEXT,
        '' PRO_PLAN_ID_NEXT,
        '' GX_PLAN_NO_NEXT,
        S.STORAGE_NO,
        S.LOCATION_NO,
        (SELECT S2.LOCATION_NAME
        FROM YDM_BS_LOCATION S2
        WHERE S2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
        S.LARY_NO,
        S.LOC_NO,
        '' PRO_PLAN_ID_NEXT,
        '' GX_PLAN_NO_NEXT,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
        '' DIRECTION,
        '1' BAR_CODE,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        DECODE(T.LOCK_BILL_FLAG, '0', '否', '1', '是') LOCK_BILL_FLAG,
        '' OFFLINE_DOC,
        T.MEMO
        FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.BELONG_CODE IN ('100101', '100102', '100103')
        AND T.PRODUCT_FLAG = '801403' #JUDGE_STOVE_NO# #STORAGE_NO#
        #JUDGE_STOVE_NO1#
        GROUP BY T.LOT_NO,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.MAT_STATUS,
        T.QCM_STAUS,
        T.BELONG_CODE,
        T.BELONG_NAME,
        T.FLAG_STOVE_NO_ZG,
        S.STORAGE_NO,
        S.LOCATION_NO,
        S.LARY_NO,
        S.LOC_NO,
        T.JUDGE_RESULT,
        T.PRODUCT_FLAG,
        T.SUBCONTRACT_NO,
        T.SUBCONTRACT_NO_SEQ,
        T.LOCK_BILL_FLAG,
        T.MEMO,
        T.PIPMEMO,
        T.MEMO1,
        T.MATERIAL_NO,
        T.MATERIAL_NAME
    </query>
    <query id = "FrmFilpOutStorage.doQueryJudgeNo" desc = "根据车号查询炉号">
        SELECT S.*
        FROM TMS_PLN_M T, TMS_PLN_C S
        WHERE T.PLN_NO = S.PLN_NO
        AND T.CAR_LICENSE LIKE '%'||?||'%'
        AND T.VALIDFLAG = '30'
    </query>
    <query id = "FrmFilpOutStorage.selectTmsPlanCount" desc = "查询装车点是否都已装车完毕">
        SELECT COUNT(1)ACOUNT
        FROM TMS_WAYBILL_C S
        WHERE S.START_AREA_CODE = '#START_AREA_CODE#'
        AND S.WAYBILL_NO = '#WAYBILL_NO#'
    </query>
    <query id = "FrmFilpOutStorage.selectTmsPlnC" desc = "查询运单计划表信息">
        SELECT T.*,S. WAYBILL_NO FROM TMS_PLN_C T,TMS_WAYBILL_M S WHERE T.PLN_NO = S.PLN_NO
        AND S.WAYBILL_NO = '#WAYBILL_NO#'
    </query>
    <query id = "FrmFilpOutStorage.selectTraceM" desc = "查询最大事件代码">
        SELECT T.EVENT_CODE FROM TMS_TRACE_M T WHERE T.WAYBILL_NO = '#WAYBILL_NO#' ORDER BY T.TRACE_NO DESC
    </query>
    <query id = "FrmFilpOutStorage.selectTraceMNode" desc = "查询跟踪表最大的点">
        SELECT T.NODE_CODE FROM TMS_TRACE_M T WHERE T.WAYBILL_NO = '#WAYBILL_NO#' ORDER BY T.TRACE_NO DESC
    </query>
    <query id = "FrmFilpOutStorage.selectTraceMUnload" desc = "查询到达点">
        SELECT S.UNLOADING_AREA_CODE
        FROM TMS_TRACE_M T, TMS_COM_UNLOADING S
        WHERE T.NODE_CODE = S.UNLOADING_CODE
        AND T.WAYBILL_NO = ?
        ORDER BY T.TRACE_NO DESC
    </query>
    <query id = "FrmFilpOutStorage.selectProcess" desc = "查询工序代码">
        SELECT T.PROCESS_CODE,T.PROCESS_DESC FROM COM_BASE_PLINE T WHERE T.PLINE_CODE = ?
    </query>
    <query id = "FrmFilpOutStorage.selectLoadingFlag" desc = "查询装点是否需要吊车">
        SELECT T.IS_CRANE_LOADING,T.IS_CRANE_UNLOADING FROM YDM_BS_STORAGE T WHERE T.STORAGE_NO = '#STORAGE_NO#'
    </query>
    <query id = "FrmFilpOutStorage.selectTmsRelation" desc = "查询装点是否吊车已扫码">
        SELECT COUNT(1)ACOUNT FROM TMS_WAYBILL_RELATION T WHERE T.WAYBILL_NO = ? AND T.AREA_CODE = ?
    </query>
    <query id = "FrmFilpOutStorage.queryStoreArea" desc = "查询仓库所属区域">
        SELECT T.SEAM_AREA FROM YDM_BS_STORAGE T WHERE T.STORAGE_NO = ?
    </query>
    <query id = "FrmFilpOutStorage.doQueryCarNo" desc = "查询已过皮重车辆">
        SELECT DISTINCT T.CAR_NO,T.CAR_NO AS CAR_NO1
        FROM CMM_WEIGHT_RECORD T
        WHERE T.VALIDFLAG = '1'
        AND T.WT_TYPE = '0'
        ORDER BY T.CAR_NO ASC
    </query>
</queryMap>