<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "钢管提单接收">
    <qeury id = "FrmBillInStorage.doQuery" desc = "未接受查询">
        SELECT
        M.BILL_NO_SEQ,
        T.BILL_NO,
        T.JUDGE_STOVE_NO,
        T.STOVE_NO,
        T.BATCH_NO,
        T.GROUP_NO,
        T.ORD_PK,
        T.ORD_LN_PK,
        T.ORD_LN_DLY_PK,
        MAX(S.TG_ORDER_NO_SEQ) TG_ORDER_NO_SEQ,
        MAX(t.ORDER_NO ||'/'||t.ORDER_SEQ ) ORDER_NO_SEQ,
        MAX( M.ORDER_NO ) ORDER_NO,
        MAX( M.ORDER_SEQ ) ORDER_SEQ,
        MAX( T.MATERIAL_NO ) MATERIAL_NO,
        MAX( T.MATERIAL_NAME ) 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.ACT_LEN_MIN ) ACT_LEN_MIN,
        MAX( T.ACT_LEN_MAX ) ACT_LEN_MAX,
        SUM( T.ACT_LEN ) ACT_LEN,
        SUM( T.ACT_COUNT ) ACT_COUNT,
        SUM( W.ACT_WEIGHT ) ACT_WEIGHT,
        MAX( T.CREATE_NAME ) CREATE_NAME,
        MAX( to_char(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') ) CREATE_TIME,
        MAX( T.PLINE_CODE ) PLINE_CODE,
        MAX( T.PLINE_NAME ) PLINE_NAME,
        MAX( B.STORAGE_NO ) STORAGE_NO,
        MAX( B.STORAGE_NAME ) STORAGE_NAME,
        (SELECT
        '天淮判定支数：' || SUM(ACT_COUNT)
        FROM
        QCM_ZG_JUGDE_APPLY
        WHERE
        TARGET = 'A'
        AND JUDGE_TOLRESULT_CODE = '40740701'
        AND JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
        AND BATCH_NO = t.BATCH_NO
        AND ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) MEMO
        FROM
        YDM_ZC_BILL_C T
        INNER JOIN (SELECT NVL(PONDER_GROSS_WT,ACT_WEIGHT) ACT_WEIGHT,MAT_NO,BILL_NO FROM YDM_ZC_LOADVEHICLE_MAT ) W ON t.MAT_NO = W.MAT_NO AND t.BILL_NO = W.BILL_NO
        LEFT JOIN YDM_BS_STORAGE B ON T.STORAGE_NO = B.STORAGE_NO
        LEFT JOIN (SELECT max(ORDER_NO)||'/'||max(ORDER_SEQ) as TG_ORDER_NO_SEQ,TH_ORDER_NO_SEQ FROM PLN_ORDER_ZG_S GROUP BY TH_ORDER_NO_SEQ) S ON  T.ORDER_NO||'/'||T.ORDER_SEQ = S.TH_ORDER_NO_SEQ,
        YDM_ZC_BILL_M M
        WHERE
        T.BILL_NO = M.BILL_NO
        AND T.ORD_PK = M.ORD_PK
        AND T.ORD_LN_PK = M.ORD_LN_PK
        AND T.ORD_LN_DLY_PK = M.ORD_LN_DLY_PK
        AND T.VALIDFLAG = '1'
        AND T.LOADVEHICLE_FLAG = '1'
        AND T.RECEIVE_FLAG = '0'
        #condition#
        AND EXISTS (
        SELECT 1 FROM SLM_ORDER_HEAD
        WHERE ORD_PK = T.ORD_PK AND FST_DRAWEE_UNIT = '120607'
        AND STLMT_UNIT_NO IN ( '1010101184', '8000000001','1012800159' )
        AND ORDER_NO NOT LIKE 'TH%'
        AND ORDER_NO LIKE 'HG%'
        )
        AND EXISTS (
        SELECT 1 FROM PLN_ORDER_ZG_S WHERE TH_ORDER_NO_SEQ LIKE '%'||M.ORDER_NO || '/' || M.ORDER_SEQ||'%'  AND PRODUCTION_TH_FLAG = '123506'
        )
        GROUP BY
        M.BILL_NO_SEQ,
        T.BILL_NO,
        T.ORD_PK,
        T.ORD_LN_PK,
        T.ORD_LN_DLY_PK,
        T.JUDGE_STOVE_NO,
        T.STOVE_NO,
        T.BATCH_NO,
        T.GROUP_NO
    </qeury>
    <qeury id = "FrmBillInStorage.doQuery1" desc = "已接受查询">
        SELECT
        TT.*,
        (SELECT
        '天淮判定支数：' || SUM(ACT_COUNT)
        FROM
        QCM_ZG_JUGDE_APPLY
        WHERE
        TARGET = 'A'
        AND JUDGE_TOLRESULT_CODE = '40740701'
        AND JUDGE_STOVE_NO = TT.FLAG_STOVE_NO_ZG
        AND BATCH_NO = TT.BATCH_NO
        AND ORD_LN_DLY_PK = TT.ORD_LN_DLY_PK) as MEMO,
        DECODE(	( SELECT 1 FROM QCM_ZG_JUGDE_APPLY WHERE JUDGE_STOVE_NO = tT.JUDGE_STOVE_NO AND BATCH_NO = tT.BATCH_NO AND BATCH_GROUD_NO = tT.BATCH_GROUD_NO AND PLINE_CODE in( 'C065','C066' ) and rownum = 1) ,'1','是','否')sfsp,
        (SELECT MIN(JUDGE_RESULT) FROM QCM_ZG_JUGDE_APPLY WHERE JUDGE_STOVE_NO = tT.JUDGE_STOVE_NO AND BATCH_NO = tT.BATCH_NO AND BATCH_GROUD_NO = tT.BATCH_GROUD_NO AND PLINE_CODE in( 'C065','C066' ) ) PDJG
        FROM
        (
        SELECT
            T.INSTOCK_DOC,
            T.JUDGE_STOVE_NO,
            T.BATCH_NO,
            T.BATCH_GROUD_NO,
            MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK,
            MAX( T.MATERIAL_NO ) MATERIAL_NO,
            MAX( T.MATERIAL_NAME ) 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.ACT_LEN_MIN ) ACT_LEN_MIN,
            MAX( T.ACT_LEN_MAX ) ACT_LEN_MAX,
            SUM( T.ACT_LEN ) ACT_LEN,
            SUM( T.ACT_COUNT ) ACT_COUNT,
            SUM( T.ACT_WEIGHT ) ACT_WEIGHT,
            MAX( T.CREATE_NAME ) CREATE_NAME,
            MAX( T.CREATE_TIME ) CREATE_TIME,
            MAX ( c.BILL_NO ) M_BILL_NO,
            MAX(T.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
            MAX(T.PROCESS_CDOE) PROCESS_CDOE,
            MAX(T.PROCESS_DESC) PROCESS_DESC,
            MAX(T.STORAGE_NO) STORAGE_NO,
            MAX(B.STORAGE_NAME) STORAGE_NAME,
            MAX(T.BELONG_CODE) BELONG_CODE,
            MAX(T.BELONG_NAME) BELONG_NAME,
            MAX(T.PRO_PLAN_ID) PRO_PLAN_ID,
            MAX(T.GX_PLAN_NO) GX_PLAN_NO,
            MAX(T.ORDER_NO) ORDER_NO,
            MAX(T.ORDER_SEQ) ORDER_SEQ,
            MAX(T.LARY_NO) LARY_NO,
            MAX(T.LOC_NO) LOC_NO,
            MAX(T.FLAG_STOVE_NO_ZG) FLAG_STOVE_NO_ZG,
            MAX(T.LOCATION_NO) LOCATION_NO
        FROM
        YDM_BC_INLIST T
        INNER JOIN
            ( SELECT BILL_NO, RECEIVE_FLAG, JUDGE_STOVE_NO, BATCH_NO, GROUP_NO FROM YDM_ZC_BILL_C GROUP BY BILL_NO, RECEIVE_FLAG,JUDGE_STOVE_NO, BATCH_NO, GROUP_NO ) C
            ON T.BILL_NO = C.BILL_NO AND T.INSTOCK_DOC = C.RECEIVE_FLAG
                and t.FLAG_STOVE_NO_ZG = c.JUDGE_STOVE_NO
                and T.BATCH_NO = C.BATCH_NO  and T.BATCH_NO = C.BATCH_NO
        LEFT JOIN YDM_BS_STORAGE B ON B.STORAGE_NO = T.STORAGE_NO
        WHERE
        T.BATCH_NO = C.BATCH_NO
        #condition#
        GROUP BY
        T.INSTOCK_DOC,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO
        ) TT
    </qeury>

    <qeury id = "FrmBillInStorage.queryMativery" desc = "已接受查询">
        SELECT
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.GROUP_NO,
        T.ORDER_NO || '/' || T.ORDER_SEQ AS ORDER_SEQ_NO1,
        T.ORDER_NO,
        T.ORDER_SEQ,
        T.ORDER_SEQ_NO,
        T.BILL_NO,
        T.VEHICLE_NO,
        MAX( T.MATERIAL_NO ) MATERIAL_NO,
        MAX( T.PRODUCNAME ) PRODUCNAME,
        MAX( T.GRADENAME ) GRADENAME,
        MAX( T.STEELNAME ) STEELNAME,
        MAX( T.SPEC_NAME ) SPEC_NAME,
        MAX( T.MODEL_DESC ) MODEL_DESC,
        MAX( T.STORAGE_NO ) STORAGE_NO,
        MAX( B.STORAGE_NAME ) STORAGE_NAME,
        MAX( T.STD_CODE ) STD_CODE,
        MAX( T.STD_NAME ) STD_NAME,
        MAX( T.STD_STYLE_DESC ) STD_STYLE_DESC,
        MAX( T.CREATE_NAME ) CREATE_NAME,
        MAX( T.CREDIT_NO ) CREDIT_NO,
        MAX( T.PORT_DESC ) PORT_DESC,
        TO_CHAR( MAX( T.Create_Time ), 'YYYY-MM-DD HH24:MI:SS' ) AS CREATE_TIME,
        MAX( T.PONDER_NO ) AS PONDER_NO,
        T.ORD_PK,
        T.ORD_LN_PK,
        T.ORD_LN_DLY_PK,
        MAX( T.VSTEL_DESC ) VSTEL_DESC,
        -- 	TO_CHAR( T.ACT_LEN_MIN, 'FM990.00' ) || '-' || TO_CHAR( T.ACT_LEN_MAX, 'FM990.00' ) AS LENFW,
        DECODE(
        (
        SELECT
        MAX( B.PRT_FLAG )
        FROM
        YDM_ZC_BILL_C B
        WHERE
        B.BILL_NO = T.BILL_NO
        AND B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
        AND NVL( B.BATCH_NO, '/' ) = NVL( T.BATCH_NO, '/' )
        AND B.GROUP_NO = T.GROUP_NO
        AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
        AND B.VALIDFLAG = '1'
        ),
        '0',
        '否',
        '1',
        '是'
        ) AS WEIGH_FLAG,
        TO_CHAR( NVL( SUM( T.ACT_LEN ), 0 ), 'FM999999990.00' ) AS ACT_LEN,
        NVL( SUM( T.ACT_COUNT ), 0 ) AS ACT_COUNT,
        TO_CHAR( NVL( SUM( T.ACT_WEIGHT ), 0 ), 'FM999999990.000' ) AS ACT_WEIGHT,
        TO_CHAR( NVL( SUM( T.PONDER_GROSS_WT ), '0' ), 'FM999999990.000' ) AS PONDER_GROSS_WT,
        NVL( SUM( T.SEND_NUM ), 0 ) AS SEND_NUM,
        MAX( S.SUPPLY_UNIT ) SUPPLY_UNIT,
        TO_CHAR( MAX( W.RECORD_DATE2 ), 'YYYY-MM-DD HH24:MI:SS' ) RECORD_DATE2
        FROM
        YDM_ZC_LOADVEHICLE_MAT T
        LEFT JOIN YDM_BS_STORAGE B ON B.STORAGE_NO = T.STORAGE_NO
        LEFT JOIN SLM_ORDER_HEAD S ON S.ORD_PK = T.ORD_PK
        LEFT JOIN CMM_WEIGHT_RESULT W ON W.RESULT_NO = T.PONDER_NO
        WHERE
        T.BILL_NO = ?
        AND T.JUDGE_STOVE_NO = ?
        AND T.BATCH_NO = ?
        AND T.GROUP_NO = ?
        AND T.RETURN_FLAG = '0'
        GROUP BY
        T.BILL_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.GROUP_NO,
        T.VEHICLE_NO,
        T.ORD_PK,
        T.ORD_LN_PK,
        T.ORD_LN_DLY_PK,
        T.ORDER_NO,
        T.ORDER_SEQ,
        T.ORDER_SEQ_NO
    </qeury>

    <qeury id = "FrmBillInStorage.doQueryCount" desc = "查询">
        SELECT
        B.*
        FROM
        YDM_ZC_BILL_M M,
        YDM_ZC_BILL_C T
        INNER JOIN YDM_BC_INLIST B ON T.MAT_NO = B.MAT_NO
        WHERE
        T.BILL_NO = M.BILL_NO
        AND T.ORD_PK = M.ORD_PK
        AND T.ORD_LN_PK = M.ORD_LN_PK
        AND T.ORD_LN_DLY_PK = M.ORD_LN_DLY_PK
        AND T.BILL_NO = ''
        AND T.ORD_PK = ''
        AND T.ORD_LN_PK = ''
        AND T.ORD_LN_DLY_PK = ''
        AND T.JUDGE_STOVE_NO = ''
        AND T.BATCH_NO = ''
        AND T.GROUP_NO = ''
    </qeury>

    <qeury id = "FrmBillInStorage.SelectMatZcCount" desc = "查询">

        SELECT COUNT(1)ACT_COUNT
        FROM MAT_BC_M T, YDM_BC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.BELONG_CODE = '002001001'
        AND T.JUDGE_STOVE_NO = ?
        AND T.BATCH_NO = ?
        AND T.BATCH_GROUD_NO = ?
        AND T.ORDER_NO = ?
    </qeury>

    <query id = "FrmBillInStorage.SelectApplyMatZcCount" desc = "查询库存支数">
        SELECT COUNT(1)APPLY_ACT_COUNT
        FROM MAT_BC_M T
        WHERE T.BELONG_CODE = '002001001'
        AND T.JUDGE_STOVE_NO = ?
        AND T.BATCH_NO = ?
        AND T.BATCH_GROUD_NO = ?
        AND T.ORDER_NO = ?
        AND T.JUGDE_APPLY_CODE IS NOT NULL
    </query>

    <query id = "FrmBillInStorage.doAddInListData" desc = "接收">
        <![CDATA[
        DECLARE
            V_INSTOCK_DOC YDM_BC_INLIST.INSTOCK_DOC % TYPE := NULL;--入库单号
            V_INSTOCK_SQE YDM_BC_INLIST.INSTOCK_SQE % TYPE := NULL;--入库流水
            V_IMEMO COM_BASE_INFO.MEMO % TYPE := NULL;
            V_BASENAME COM_BASE_INFO.BASENAME % TYPE := NULL;
            V_ICOUNT NUMBER := 1;
            V_TIME YDM_BC_INLIST.CREATE_TIME % TYPE := SYSDATE;
            V_BATHYEAR YDM_BC_INLIST.BAL_YEAR_MONTH % TYPE := TO_CHAR( SYSDATE, 'YYYYMM' );
            V_COUNT MAT_ZC_M.ACT_COUNT % TYPE := NULL;
            V_MAT_NO MAT_ZC_M.MAT_NO % TYPE := NULL;
        BEGIN
                -- 入库单号
                V_INSTOCK_DOC := '#INSTOCK_DOC#';
                -- 入库流水
                SELECT
                    TO_NUMBER(
                        LPAD( ( NVL( MAX( SUBSTR( T.INSTOCK_SQE, 14 ) ), 0 ) + 1 ), 4, 0 )
                    ) INSTOCK_SQE INTO V_ICOUNT
                FROM
                    YDM_BC_INLIST T
                WHERE
                    T.INSTOCK_DOC = '#INSTOCK_DOC#';

                FOR MYROW IN (
                    SELECT
                        *
                    FROM
                        (
                        SELECT
                            T.*
                        FROM
                            YDM_ZC_BILL_M M,
                            YDM_ZC_BILL_C T
                        WHERE
                            T.BILL_NO = M.BILL_NO
                            AND T.ORD_PK = M.ORD_PK
                            AND T.ORD_LN_PK = M.ORD_LN_PK
                            AND T.ORD_LN_DLY_PK = M.ORD_LN_DLY_PK
                            AND T.BILL_NO = '#BILL_NO#'
                            AND T.ORD_PK = '#ORD_PK#'
                            AND T.ORD_LN_PK = '#ORD_LN_PK#'
                            AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
                            AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                            AND T.BATCH_NO = '#BATCH_NO#'
                            AND T.GROUP_NO = '#GROUP_NO#'
                            AND T.VALIDFLAG = '1'
                            AND T.LOADVEHICLE_FLAG = '1'
                            AND T.RECEIVE_FLAG = '0'
                        ORDER BY
                            T.MAT_NO ASC
                        )
                    WHERE
                        ROWNUM <= '#ACT_COUNT#' ORDER BY MAT_NO
                    )
                    LOOP
                    V_INSTOCK_SQE := V_INSTOCK_DOC || LPAD( V_ICOUNT, 4, 0 );
                SELECT
                    '#JUDGE_NO#'
                    || MYROW.BATCH_NO
                    || LPAD(NVL( MAX( SUBSTR( T.MAT_NO, LENGTH( T.MAT_NO ) - 3 ) ), 0 ) + 1,4,0) MAT_NO
                    INTO V_MAT_NO
                FROM
                    (
                    SELECT
                        MAX( T1.MAT_NO ) MAT_NO
                    FROM
                        MAT_BC_M T1
                    WHERE
                        T1.JUDGE_STOVE_NO = '#JUDGE_NO#'
                        AND T1.BATCH_NO = MYROW.BATCH_NO UNION ALL
                    SELECT
                        MAX( T4.MAT_NO ) MAT_NO
                    FROM
                        YDM_BC_INLIST T4
                    WHERE
                        T4.JUDGE_STOVE_NO = '#JUDGE_NO#'
                        AND T4.BATCH_NO = MYROW.BATCH_NO
                    ) T;
                INSERT INTO YDM_BC_INLIST (
                    INSTOCK_SQE,
                    INSTOCK_DOC,
                    INSTOCK_TYPE_CODE,
                    INSTOCK_TYPE_NAME,
                    MAT_NO,
                    LOT_NO,
                    STOVE_NO,
                    JUDGE_STOVE_NO,
                    BATCH_NO,
                    BATCH_GROUD_NO,
                    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,
                    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,
                    INSTOCK_TIME,
                    CREATE_NAME,
                    CREATE_TIME,
                    PRODUCT_FLAG,
                    MAT_STATUS,
                    JUDGE_STD_NAME,
                    IN_TIME_F,
                    BAL_YEAR_MONTH,
                    SOURE_CODE,
                    SOURE_NAME,
                    FLAG_STOVE_NO_ZG,
                    PROCESS_CDOE,
                    PROCESS_DESC,
                    ORD_PK,
                    ORD_LN_PK,
                    ORD_LN_DLY_PK,
                    ORDER_NO,
                    ORDER_SEQ,
                    PRO_ORDER_NO,
                    PRO_PLAN_ID,
                    GX_PLAN_NO,
                    BILL_NO
                )
                VALUES
                    (
                        V_INSTOCK_SQE,
                        V_INSTOCK_DOC,
                        '800701',
                        '产出入库',
                        V_MAT_NO,
                        MYROW.LOT_NO,
                        '#JUDGE_NO#',
                        '#JUDGE_NO#',
                        MYROW.BATCH_NO,
                        MYROW.GROUP_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,
                        '#MODEL_CODE#',
                        '#MODEL_DESC#',
                        '#PLINE_CODE#',
                        '#PLINE_NAME#',
                        MYROW.ACT_DIMATER,
                        MYROW.ACT_HEIGHT,
                        MYROW.ACT_LEN,
                        MYROW.ACT_LEN_MIN,
                        MYROW.ACT_LEN_MAX,
                        MYROW.ACT_COUNT,
                        (SELECT NVL(PONDER_GROSS_WT,ACT_WEIGHT) FROM YDM_ZC_LOADVEHICLE_MAT WHERE MAT_NO = MYROW.MAT_NO AND BILL_NO = '#BILL_NO#'),
                        MYROW.ACT_THEORY_WEIGHT,
                        '#BELONG_CODE#',
                        '#BELONG_NAME#',
                        '#STORAGE_NO#',
                        '#LOCATION_NO#',
                        '#LARY_NO#',
                        V_TIME,
                        '#CREATE_NAME#',
                        V_TIME,
                        '801401',
                        '80150101',
                        '',
                        V_TIME,
                        V_BATHYEAR,
                        '801301',
                        '外购',
                        '#JUDGE_STOVE_NO#',
                        'D',
                        '轧制',
                        '#ORD_PK_NEW#',
                        '#ORD_LN_PK_NEW#',
                        '#ORD_LN_DLY_PK_NEW#',
                        '#ORDER_NO_NEW#',
                        '#ORDER_SEQ_NEW#',
                        '#PRO_ORDER_NO#',
                        '#PRO_ORDER_ID#',
                        '#GX_PLAN_NO#',
                        '#BILL_NO#'
                    );
                INSERT INTO YDM_BC_BUTTRESS (
                    JUDGE_STOVE_NO,
                    BATCH_NO,
                    BATCH_GROUD_NO,
                    STORAGE_NO,
                    LOCATION_NO,
                    CREATE_NAME,
                    MAT_NO,
                    CREATE_TIME
                )
                VALUES
                    (
                        '#JUDGE_NO#',
                        MYROW.BATCH_NO,
                        MYROW.GROUP_NO,
                        '#STORAGE_NO#',
                        '#LOCATION_NO#',
                        '#CREATE_NAME#',
                        V_MAT_NO,
                        V_TIME
                    );
                INSERT INTO MAT_BC_M (
                    STOVE_NO,
                    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,
                    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,
                    ACT_LEN,
                    TARGET,
                    INSTOCK_TIME,
                    ORD_PK,
                    ORD_LN_PK,
                    ORD_LN_DLY_PK,
                    ORDER_NO,
                    ORDER_SEQ,
                    PROCESS_CDOE,
                    PROCESS_DESC,
                    NEXT_PROCESS_CDOE,
                    NEXT_PROCESS_DESC,
                    MAT_ORIGIN_CODE,
                    MAT_ORIGIN_NAME,
                    CRAF_NO,
                    CRAFT_SEQ,
                    PRO_ORDER_NO,
                    PRO_ORDER_ID,
                    GX_PLAN_NO,
                    MATERIAL_NO,
                    MATERIAL_NAME,
                    ACT_THEORY_WEIGHT,
                    MAT_GOWHERE_CODE,
                    MAT_GOWHERE_NAME,
                    FLAG_STOVE_NO_ZG
                )
                VALUES
                    (
                        '#JUDGE_NO#',
                        '#JUDGE_NO#',
                        MYROW.BATCH_NO,
                        MYROW.GROUP_NO,
                        MYROW.ACT_COUNT,
                       (SELECT NVL(PONDER_GROSS_WT,ACT_WEIGHT) FROM YDM_ZC_LOADVEHICLE_MAT WHERE MAT_NO = MYROW.MAT_NO AND BILL_NO = '#BILL_NO#'),
                        V_TIME,
                        V_MAT_NO,
                        '801401',
                        '80150101',
                        '#PLINE_CODE#',
                        '#PLINE_NAME#',
                        '00',
                        MYROW.PRODUCCODE,
                        MYROW.PRODUCNAME,
                        MYROW.STEELCODE,
                        MYROW.STEELNAME,
                        MYROW.SPEC_CODE,
                        MYROW.SPEC_NAME,
                        MYROW.GRADECODE,
                        MYROW.GRADENAME,
                        '#MODEL_CODE#',
                        '#MODEL_DESC#',
                        MYROW.STD_CODE,
                        MYROW.STD_NAME,
                        '#BELONG_CODE#',
                        '#BELONG_NAME#',
                        MYROW.STD_STYLE,
                        MYROW.STD_STYLE_DESC,
                        MYROW.ACT_DIMATER,
                        MYROW.ACT_HEIGHT,
                        MYROW.ACT_LEN_MIN,
                        MYROW.ACT_LEN_MAX,
                        MYROW.LOT_NO,
                        MYROW.ACT_LEN,
                        'B',
                        V_TIME,
                        '#ORD_PK_NEW#',
                        '#ORD_LN_PK_NEW#',
                        '#ORD_LN_DLY_PK_NEW#',
                        '#ORDER_NO_NEW#',
                        '#ORDER_SEQ_NEW#',
                        'D',
                        '轧制',
                        '#NEXT_PROCESS_CDOE#',
                        '#NEXT_PROCESS_NAME#',
                        '801301',
                        '外购',
                        '#CRAFT_FILE_NO#',
                        '#CRAFT_SEQ#',
                        '#PRO_ORDER_NO#',
                        '#PRO_ORDER_ID#',
                        '#GX_PLAN_NO#',
                        MYROW.MATERIAL_NO,
                        MYROW.MATERIAL_NAME,
                        MYROW.ACT_THEORY_WEIGHT,
                        '#STORAGE_NO#',
                        '#STORAGE_NAME#',
                        '#JUDGE_STOVE_NO#'
                    );
                UPDATE
                    YDM_ZC_BILL_C T
                SET
                    T.RECEIVE_FLAG = V_INSTOCK_DOC
                WHERE
                    T.RECEIVE_FLAG = '0'
                    AND T.VALIDFLAG = '1'
                    AND T.LOADVEHICLE_FLAG = '1'
                    AND T.BILL_NO = '#BILL_NO#'
                    AND T.ORD_PK = '#ORD_PK#'
                    AND T.ORD_LN_PK = '#ORD_LN_PK#'
                    AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
                    AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                    AND T.BATCH_NO = '#BATCH_NO#'
                    AND T.GROUP_NO = '#GROUP_NO#'
                    and t.MAT_NO = MYROW.MAT_NO;
                V_ICOUNT := V_ICOUNT + 1;

            END LOOP;
            END;
        ]]>
    </query>
    <query id = "FrmBillInStorage.doDeleteInListData" desc = "撤销接收">
        <![CDATA[
        DECLARE
            V_CHECK_NO QCM_ZC_CHECKCONSIGN.CHECK_NO % TYPE := NULL;--检验编号
            V_CHECK_NO_COUNT integer;
            BEGIN
                FOR MYROW IN (
                    SELECT
                        *
                    FROM
                        (
                        SELECT
                            B.*
                        FROM
                            YDM_BC_INLIST B
                        WHERE
                            B.INSTOCK_DOC = '#INSTOCK_DOC#' and B.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                        ORDER BY
                            B.MAT_NO ASC
                        )
                    WHERE
                        ROWNUM <= '#ACT_COUNT#'
                    )
                    LOOP
                    DELETE FROM YDM_BC_INLIST WHERE MAT_NO = MYROW.MAT_NO;
                    DELETE FROM MAT_BC_M WHERE MAT_NO = MYROW.MAT_NO;
                    DELETE FROM YDM_BC_BUTTRESS WHERE MAT_NO = MYROW.MAT_NO;
                END LOOP;
                SELECT COUNT(1) INTO V_CHECK_NO_COUNT FROM QCM_ZC_CHECKCONSIGN WHERE
                        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                        AND BATCH_NO = '#BATCH_NO#';
                    IF V_CHECK_NO_COUNT > 0 THEN
                        SELECT CHECK_NO INTO V_CHECK_NO FROM QCM_ZC_CHECKCONSIGN WHERE
                            JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                            AND BATCH_NO = '#BATCH_NO#'
                            GROUP BY CHECK_NO;
                        DELETE FROM QCM_ZC_CHECKCONSIGN WHERE CHECK_NO = V_CHECK_NO;
                        DELETE FROM QCM_ZC_CHECKCONSIGN_DETAIL WHERE CHECK_NO = V_CHECK_NO;
                        DELETE FROM QCM_JHY_PHYRESULT WHERE SAMPLE_ID = V_CHECK_NO;
                        DELETE FROM QCM_JHY_ELEMENTS WHERE SAMPLE_ID = V_CHECK_NO;
                    END IF;
                    UPDATE YDM_ZC_BILL_C SET RECEIVE_FLAG = '0' WHERE RECEIVE_FLAG = '#INSTOCK_DOC#' AND BILL_NO = '#M_BILL_NO#';
                    DELETE FROM MIL_INSTORE_RESULT T WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#' AND T.GX_PLAN_NO = '#GX_PLAN_NO#';
                    DELETE FROM MIL_MT_RESULT T WHERE RESULT_NO = '#JUDGE_STOVE_NO#' AND JUDGE_STOVE_NO LIKE '#JUDGE_STOVE_NO#' || '%';
                    UPDATE PLN_ORDER_ZG_S T
                        SET T.FINISHNUM    = TO_NUMBER(NVL(T.FINISHNUM,0)) - TO_NUMBER('#ACT_COUNT#'),
                       T.FINISHWEIGHT = TO_NUMBER(NVL(T.FINISHWEIGHT,0)) -
                                        TO_NUMBER('#ACT_WEIGHT#')
                    WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
                    AND T.GX_PLAN_NO = '#GX_PLAN_NO#';
            END;
    ]]>
</query>

    <qeury id = "FrmBillInStorage.doQueryOrderZgS" desc = "查询轧管订单表">
        SELECT T.WHOLE_BACKLOG_DESC,
            T.PRO_ORDER_NO,
            T.PRO_PLAN_ID,
            T.GX_PLAN_NO,
            T.DECISION,
            T.PLAN_GROUP_ID,
            T.ORDER_SOURCE,
            T.ORD_LN_DLY_PK,
            T.PLN_DIVIDE_ID,
            T.ORDER_NO,
            T.ORDER_SEQ,
            T.DELIVERY_NO,
            T.REQ_BL_ID,
            T.PLINE_CODE,
            T.PLINE_NAME,
            T.GRADECODE,
            T.GRADENAME,
            T.OUTDIAMETER,
            T.WALLTHICK,
            T.LENGTHDISC,
            T.INWL_ID,
            T.INWL_DESC,
            T.OUTWL_ID,
            T.OUTWL_DESC,
            T.LEN_ROLL_MAX,
            T.LEN_ROLL_MIN,
            T.AIMOUTDIAMETER,
            T.AIMWALLTHICK,
            T.AIMLENGTH,
            T.DIAMETER_GP,
            T.LEN_GP_SINGLE,
            T.ROLL_LENGTH,
            T.LEN_CUTHEAD,
            T.LEN_CUTEND,
            T.OUTNUM_CUT,
            T.DIAMETER_MANDREL,
            T.PASS_CODE,
            T.PASS_NAME,
            T.IN_WEIGHT_S,
            T.IN_NUM_S,
            T.WEIGTH_S,
            T.NUM_S,
            T.ADD_WT_IN,
            T.ADD_NUM_IN,
            T.MATCH_WT_IN,
            T.MATCH_NUM_IN,
            T.ISENDGX,
            T.IF_MONITOR_ZG,
            T.PRDCR_NO,
            T.MONITOR_POINT,
            T.CRAFT_FILE_NO,
            T.CRAFT_FILE_MAN,
            T.CRAFT_SEQ,
            T.STATION_ROAD,
            T.PRO_MONTH,
            T.CIC,
            T.PIC,
            T.SIC,
            T.DIC,
            T.WIC,
            T.GIC,
            T.GX_PRO_SEQ,
            T.PLAN_USETIME,
            TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
            TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
            T.BATCHED_WT,
            T.BATCHED_NUM,
            T.FINISHWEIGHT,
            T.FINISHNUM,
            DECODE(T.EXE_STATUS,'0','计划','1','生产中','2','生产完成','3','关闭')EXE_STATUS,
            T.IS_REPAIR_PLN,
            T.REPAIR_TYPE,
            T.IS_PLAN_OK,
            T.GPREQ_IF_OK,
            T.GPREQ_ID,
            T.ZY_BATCH_ID,
            T.CIC_GROUP_GP,
            T.PIC_GROUP_GP,
            T.SIC_GROUP_GP,
            T.DIC_GROUP_GP,
            T.WIC_GROUP_GP,
            T.GIC_GROUP_GP,
            T.CIC_GP,
            T.PIC_GP,
            T.SIC_GP,
            T.DIC_GP,
            T.WIC_GP,
            T.GIC_GP,
            T.IF_EXPORT,
            TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
            T.MEMO,
            TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
            T.ISSUED_MAN,
            TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
            T.LAST_UNDOWN_MAN,
            T.VERSION_NO,
            T.PROCESSING_COST,
            T.TOTAL_COST,
            T.IF_STOVE_ISSUED,
            TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
            T.STOVE_ISSUED_MAN,
            T.IS_ONLOAD_LINE,
            S.STD_CODE,
            S.STD_NAME,
            S.MATERIAL_NO,
            S.MATERIAL_DESC,
            S.PRODUCCODE,
            S.PRODUCNAME,
            S.STEELCODE,
            S.STEELNAME,
            S.SPEC_CODE,
            S.SPEC_NAME,
            S.MODEL_CODE,
            S.MODEL_DESC,
            S.STD_STYLE_DESC,
            T.INDEX_SEQ
        FROM PLN_ORDER_ZG_S T,PLN_SALEORD S
        WHERE T.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK AND T.TH_ORDER_NO_SEQ like '%'|| {0} ||'%' AND T.PRODUCTION_TH_FLAG = '123506'
    </qeury>
    <query id = "FrmBillInStorage.getInDocCq" desc = "生成产权入库单号">
        SELECT 'IQ' || TO_CHAR(SYSDATE, '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 = '800709'
        AND T.INSTOCK_DOC LIKE 'IQ' || TO_CHAR(SYSDATE, 'YYMMDD') || '_____'
    </query>
    <query id = "FrmBillInStorage.doQueryLocation" desc = "查询库位信息">
        SELECT T.LOCATION_NAME,T.LOCATION_NO FROM YDM_BS_LOCATION T WHERE T.STORAGE_NO = ? ORDER BY T.LOCATION_NO ASC
    </query>
    <qeury id = "FrmBillInStorage.doQueryStorageArr" 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'
    </qeury>
    <query id="FrmBillInStorage.getWarehousePermissionsStore" desc="获取仓库权限">
        <![CDATA[
	      SELECT T.STORAGE_NO, T.STORAGE_NAME
              FROM YDM_BS_STORAGE T
             WHERE  T.VALIDFLAG='1'
		]]>
    </query>

    <query id="FrmBillInStorage.doFlagHeatNo" desc="获取喷印炉号">
        <![CDATA[
	      SELECT FLAG_HEAT_NO AS FLAG_STOVE_NO FROM PLN_ZY_ZG_M WHERE JUDGE_STOVE_NO = {0} or FEED_HEAT_NO = {0}
		]]>
    </query>

    <query id="FrmBillInStorage.doGetJudgeStoveNo" desc="查询是否已生成炉号">
        <![CDATA[
	      SELECT JUDGE_STOVE_NO AS FLAG_STOVE_NO FROM YDM_BC_INLIST
	      WHERE
	      INSTOCK_TYPE_CODE = '800701' AND FLAG_STOVE_NO_ZG = {0}
	      AND BILL_NO = {1} AND ROWNUM = 1
		]]>
    </query>


    <qeury id = "FrmBillInStorage.doCopyCheck" desc = "复制性能">
        <![CDATA[
  DECLARE
    V_CHECK_NO_OLD QCM_ZC_CHECKCONSIGN.CHECK_NO % TYPE := NULL;--检验编号
    V_CHECK_NO_NEW QCM_ZC_CHECKCONSIGN.CHECK_NO % TYPE := NULL;--检验编号
    V_COUNT_MT INTEGER;
    V_COUNT_STOVE_NO  INTEGER;
    V_CHECK_NO_COUNT  INTEGER;
    V_STOVE_NO QCM_ZC_CHECKCONSIGN.STOVE_NO % TYPE := NULL;--熔炼炉号
     BEGIN
        V_COUNT_MT := 0;
        V_CHECK_NO_COUNT  := 0;
        SELECT STOVE_NO INTO V_STOVE_NO FROM QCM_ZG_JUGDE_APPLY
            WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
            AND BATCH_NO = '#BATCH_NO#' AND IS_FLAG = '0' AND TARGET = 'A' AND ROWNUM = 1;
        FOR MYROW IN (
            SELECT
            CHECK_NO AS CHECK_NO_OLD,
            'TH65' || '#JUDGE_NO#' || ROWNUM AS CHECK_NO,
            T.LOT_NO,
            '#JUDGE_NO#' AS JUDGE_STOVE_NO,
            T.BATCH_NO,
            '#JUDGE_NO#' AS STOVE_NO,
            'D' PROCESS_CODE,
            '#PLINE_CODE#' AS PLINE_CODE,
            '#PLINE_NAME#' AS PLINE_NAME,
            T.ACT_COUNT,
            T.ACT_WEIGHT,
            T.ACT_THEORY_WEIGHT,
            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.ACT_DIMATER,
            T.ACT_HEIGHT,
            T.ACT_LEN_MIN,
            T.ACT_LEN_MAX,
            '#PRO_ORDER_ID#' AS PRO_ORDER_ID,
            '1' AS GX_PLAN_NO,
            '#ORD_LN_DLY_PK#' AS ORD_LN_DLY_PK,
            '#CRAF_NO#' AS CRAF_NO,
            '1' AS CRAFT_SEQ,
            '#INDEX_SEQ#' AS INDEX_SEQ,
            T.STEEL_STANDRAD,
            '#CIC#' as CIC,
            '#PIC#' as PIC,
            TO_CHAR(SYSDATE,'YYYYMM') AS BAL_YEAR_MONTH,
            '00' AS VALIDFLAG,
            'TH' AS CONSIGN_NAME,
            SYSDATE CONSIGN_TIME,
            '0' AS IS_FLAG,
            'B' AS TARGET,
            T.CRAFT_SOURCE
            FROM
                QCM_ZC_CHECKCONSIGN T
            WHERE
                T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                AND T.BATCH_NO = '#BATCH_NO#'
            )
            LOOP
            V_CHECK_NO_OLD := MYROW.CHECK_NO_OLD;
            SELECT COUNT(1) INTO V_CHECK_NO_COUNT FROM QCM_ZC_CHECKCONSIGN WHERE CHECK_NO = MYROW.CHECK_NO
                        and JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
                        AND BATCH_NO = MYROW.BATCH_NO;
            IF V_CHECK_NO_COUNT = 0 THEN
                INSERT INTO QCM_ZC_CHECKCONSIGN (
                    CHECK_NO,
                    LOT_NO,
                    JUDGE_STOVE_NO,
                    BATCH_NO,
                    STOVE_NO,
                    PROCESS_CODE,
                    PLINE_CODE,
                    PLINE_NAME,
                    ACT_COUNT,
                    ACT_WEIGHT,
                    ACT_THEORY_WEIGHT,
                    MATERIAL_NO,
                    MATERIAL_NAME,
                    PRODUCCODE,
                    PRODUCNAME,
                    STEELCODE,
                    STEELNAME,
                    GRADECODE,
                    GRADENAME,
                    SPEC_CODE,
                    SPEC_NAME,
                    MODEL_CODE,
                    MODEL_DESC,
                    STD_CODE,
                    STD_NAME,
                    STD_STYLE,
                    STD_STYLE_DESC,
                    ACT_DIMATER,
                    ACT_HEIGHT,
                    ACT_LEN_MIN,
                    ACT_LEN_MAX,
                    PRO_ORDER_ID,
                    GX_PLAN_NO,
                    ORD_LN_DLY_PK,
                    CRAF_NO,
                    CRAFT_SEQ,
                    INDEX_SEQ,
                    STEEL_STANDRAD,
                    CIC,
                    PIC,
                    BAL_YEAR_MONTH,
                    VALIDFLAG,
                    CONSIGN_NAME,
                    CONSIGN_TIME,
                    IS_FLAG,
                    TARGET,
                    CRAFT_SOURCE
                )
            VALUES
                (
                    MYROW.CHECK_NO,
                    MYROW.LOT_NO,
                    MYROW.JUDGE_STOVE_NO,
                    MYROW.BATCH_NO,
                    MYROW.STOVE_NO,
                    MYROW.PROCESS_CODE,
                    MYROW.PLINE_CODE,
                    MYROW.PLINE_NAME,
                    MYROW.ACT_COUNT,
                    MYROW.ACT_WEIGHT,
                    MYROW.ACT_THEORY_WEIGHT,
                    MYROW.MATERIAL_NO,
                    MYROW.MATERIAL_NAME,
                    MYROW.PRODUCCODE,
                    MYROW.PRODUCNAME,
                    MYROW.STEELCODE,
                    MYROW.STEELNAME,
                    MYROW.GRADECODE,
                    MYROW.GRADENAME,
                    MYROW.SPEC_CODE,
                    MYROW.SPEC_NAME,
                    MYROW.MODEL_CODE,
                    MYROW.MODEL_DESC,
                    MYROW.STD_CODE,
                    MYROW.STD_NAME,
                    MYROW.STD_STYLE,
                    MYROW.STD_STYLE_DESC,
                    MYROW.ACT_DIMATER,
                    MYROW.ACT_HEIGHT,
                    MYROW.ACT_LEN_MIN,
                    MYROW.ACT_LEN_MAX,
                    MYROW.PRO_ORDER_ID,
                    MYROW.GX_PLAN_NO,
                    MYROW.ORD_LN_DLY_PK,
                    MYROW.CRAF_NO,
                    MYROW.CRAFT_SEQ,
                    MYROW.INDEX_SEQ,
                    MYROW.STEEL_STANDRAD,
                    MYROW.CIC,
                    MYROW.PIC,
                    MYROW.BAL_YEAR_MONTH,
                    MYROW.VALIDFLAG,
                    MYROW.CONSIGN_NAME,
                    MYROW.CONSIGN_TIME,
                    MYROW.IS_FLAG,
                    MYROW.TARGET,
                    MYROW.CRAFT_SOURCE
                );
             INSERT INTO QCM_ZC_CHECKCONSIGN_DETAIL(
                CHECK_NO,
                BATCH_NO,
                SAMPLE_NO,
                PHY_CODE_MAX,
                PHY_NAME_MAX,
                VALIDFLAG,
                IS_MAIN,
                CREATE_TIME)
          SELECT
               MYROW.CHECK_NO CHECK_NO,
               T.BATCH_NO,
               T.SAMPLE_NO,
               T.PHY_CODE_MAX,
               T.PHY_NAME_MAX,
               T.VALIDFLAG,
               T.IS_MAIN,
               SYSDATE CREATE_TIME
         FROM QCM_ZC_CHECKCONSIGN_DETAIL T
         WHERE
        T.CHECK_NO = V_CHECK_NO_OLD and BATCH_NO = MYROW.BATCH_NO;
         INSERT INTO QCM_JHY_PHYRESULT(
                SAMPLE_ID,
                SAMPLE_NO,
                INDEX_SEQ,
                LOT_NO,
                STOVE_NO,
                JUDGE_STOVE_NO,
                BATCH_NO,
                SAMPLE_TYPE,
                CONSIGNER,
                PLINE_CODE,
                PHY_CODE_MAX,
                PHY_NAME_MAX,
                PHY_CODE_MIN,
                PHY_NAME_MIN,
                PHY_CODE,
                PHY_NAME,
                ITEM_CODE_F,
                ITEM_NAME_F,
                ITEM_CODE_W,
                ITEM_NAME_W,
                ITEM_CODE_S,
                ITEM_NAME_S,
                VALUE1,
                VALUE2,
                VALUE3,
                VALUE4,
                VALUE5,
                VALUE6,
                VALUE7,
                VALUE8,
                VALUE9,
                VALUE10,
                VALUE11,
                VALUE12,
                VALUE13,
                VALUE14,
                VALUE15,
                AVERAGE,
                CREATE_NAME,
                CREATE_TIME,
                FILE_PATH,
                JUDGE_FLAG,
                VALIDFLAG,
                FOR_CHECK_NO,
                ORIGINAL_AREA,
                IS_GOOD,
                IS_DEFECT,
                ISRCL,
                BAR_CODE,
                CHECK_TEMP,
                HARDNESS_TYPE,
                PHY_CODE_DIR,
                PHY_NAME_DIR,
                SAMPLE_STYLE,
                SAMPLE_SIZE,
                LOT_NO_GROUP,
                CHECK_TEMP_CODE,
                SAMPLE_SIZE_CODE)
                 SELECT
                             MYROW.CHECK_NO SAMPLE_ID,
                             T.SAMPLE_NO,
                             T.INDEX_SEQ,
                             T.LOT_NO,
                             MYROW.JUDGE_STOVE_NO,
                             MYROW.JUDGE_STOVE_NO,
                             T.BATCH_NO,
                             T.SAMPLE_TYPE,
                             T.CONSIGNER,
                             '#PLINE_CODE#',
                             T.PHY_CODE_MAX,
                             T.PHY_NAME_MAX,
                             T.PHY_CODE_MIN,
                             T.PHY_NAME_MIN,
                             T.PHY_CODE,
                             T.PHY_NAME,
                             T.ITEM_CODE_F,
                             T.ITEM_NAME_F,
                             T.ITEM_CODE_W,
                             T.ITEM_NAME_W,
                             T.ITEM_CODE_S,
                             T.ITEM_NAME_S,
                             T.VALUE1,
                             T.VALUE2,
                             T.VALUE3,
                             T.VALUE4,
                             T.VALUE5,
                             T.VALUE6,
                             T.VALUE7,
                             T.VALUE8,
                             T.VALUE9,
                             T.VALUE10,
                             T.VALUE11,
                             T.VALUE12,
                             T.VALUE13,
                             T.VALUE14,
                             T.VALUE15,
                             T.AVERAGE,
                             T.CREATE_NAME,
                             SYSDATE CREATE_TIME,
                             T.FILE_PATH,
                             '00' JUDGE_FLAG,
                             '1' VALIDFLAG,
                             T.FOR_CHECK_NO,
                             T.ORIGINAL_AREA,
                             T.IS_GOOD,
                             T.IS_DEFECT,
                             T.ISRCL,
                             T.BAR_CODE,
                             T.CHECK_TEMP,
                             T.HARDNESS_TYPE,
                             T.PHY_CODE_DIR,
                             T.PHY_NAME_DIR,
                             T.SAMPLE_STYLE,
                             T.SAMPLE_SIZE,
                             T.LOT_NO_GROUP,
                             T.CHECK_TEMP_CODE,
                             T.SAMPLE_SIZE_CODE
                 FROM QCM_JHY_PHYRESULT T
                 WHERE
                SAMPLE_ID = V_CHECK_NO_OLD;
            INSERT INTO QCM_JHY_ELEMENTS(
                ASSAYNO,
                STOVE_NO,
                JUDGE_STOVE_NO,
                BATCH_NO,
                ASSAYTYPE,
                FLAG,
                C,
                SI,
                MN,
                P,
                S,
                NI,
                CR,
                CU,
                ASN,
                TI,
                V,
                MO,
                B,
                W,
                AL,
                ZN,
                PB,
                SN,
                CA,
                LA,
                SB,
                CE,
                SE,
                MG,
                NB,
                CD,
                BI,
                N,
                H,
                O,
                FE,
                ALT,
                ALS,
                ALINS,
                BS,
                BN,
                MGO,
                SIO2,
                AL2O3,
                TFEO,
                FE2O3,
                H2O,
                CAF2,
                P2O5,
                TFE,
                CR2O3,
                TIO2,
                MNO,
                V2O5,
                FEO,
                CAO,
                SAMPLE_ID,
                XH,
                MACHINE,
                CREATE_NAME,
                CREATE_TIME,
                VALIDFLAG,
                MEMO,
                SAMPLE_NO,
                PLINE_CODE,
                JUDGE_FLAG,
                ZR,
                LG_JUDGE_FLAG,
                CO,
                SAMPLE_TYPE,
                BAR_CODE,
                TA)
           SELECT
               MYROW.CHECK_NO || '_' || T.SAMPLE_NO || '_C' ASSAYNO,
               MYROW.STOVE_NO,
               MYROW.JUDGE_STOVE_NO,
               T.BATCH_NO,
               MYROW.TARGET ASSAYTYPE,
               T.FLAG,
               T.C,
               T.SI,
               T.MN,
               T.P,
               T.S,
               T.NI,
               T.CR,
               T.CU,
               T.ASN,
               T.TI,
               T.V,
               T.MO,
               T.B,
               T.W,
               T.AL,
               T.ZN,
               T.PB,
               T.SN,
               T.CA,
               T.LA,
               T.SB,
               T.CE,
               T.SE,
               T.MG,
               T.NB,
               T.CD,
               T.BI,
               T.N,
               T.H,
               T.O,
               T.FE,
               T.ALT,
               T.ALS,
               T.ALINS,
               T.BS,
               T.BN,
               T.MGO,
               T.SIO2,
               T.AL2O3,
               T.TFEO,
               T.FE2O3,
               T.H2O,
               T.CAF2,
               T.P2O5,
               T.TFE,
               T.CR2O3,
               T.TIO2,
               T.MNO,
               T.V2O5,
               T.FEO,
               T.CAO,
               MYROW.CHECK_NO SAMPLE_ID,
               T.XH,
               T.MACHINE,
               T.CREATE_NAME,
               SYSDATE CREATE_TIME,
               '1' VALIDFLAG,
               T.MEMO,
               T.SAMPLE_NO,
               MYROW.PLINE_CODE,
               '00'JUDGE_FLAG,
               T.ZR,
               '20'LG_JUDGE_FLAG,
               T.CO,
               T.SAMPLE_TYPE,
               T.BAR_CODE,
               T.TA
         FROM QCM_JHY_ELEMENTS T
         WHERE
        T.SAMPLE_ID = V_CHECK_NO_OLD and BATCH_NO = MYROW.BATCH_NO;
        END IF;
        SELECT COUNT(1) INTO V_COUNT_STOVE_NO FROM QCM_JHY_ELEMENTS WHERE STOVE_NO = '#JUDGE_NO#' AND SAMPLE_NO = '601';
        IF V_COUNT_STOVE_NO = 0 THEN
        INSERT INTO QCM_JHY_ELEMENTS(
                    ASSAYNO,
                    STOVE_NO,
                    JUDGE_STOVE_NO,
                    BATCH_NO,
                    ASSAYTYPE,
                    FLAG,
                    C,
                    SI,
                    MN,
                    P,
                    S,
                    NI,
                    CR,
                    CU,
                    ASN,
                    TI,
                    V,
                    MO,
                    B,
                    W,
                    AL,
                    ZN,
                    PB,
                    SN,
                    CA,
                    LA,
                    SB,
                    CE,
                    SE,
                    MG,
                    NB,
                    CD,
                    BI,
                    N,
                    H,
                    O,
                    FE,
                    ALT,
                    ALS,
                    ALINS,
                    BS,
                    BN,
                    MGO,
                    SIO2,
                    AL2O3,
                    TFEO,
                    FE2O3,
                    H2O,
                    CAF2,
                    P2O5,
                    TFE,
                    CR2O3,
                    TIO2,
                    MNO,
                    V2O5,
                    FEO,
                    CAO,
                    SAMPLE_ID,
                    XH,
                    MACHINE,
                    CREATE_NAME,
                    CREATE_TIME,
                    VALIDFLAG,
                    MEMO,
                    SAMPLE_NO,
                    PLINE_CODE,
                    JUDGE_FLAG,
                    ZR,
                    LG_JUDGE_FLAG,
                    CO,
                    SAMPLE_TYPE,
                    BAR_CODE,
                    TA)
                    SELECT
                   MYROW.STOVE_NO || '_' || SAMPLE_NO || '_S' ASSAYNO,
                   MYROW.STOVE_NO,
                   MYROW.JUDGE_STOVE_NO,
                   T.BATCH_NO,
                   'A' ASSAYTYPE,
                   T.FLAG,
                   T.C,
                   T.SI,
                   T.MN,
                   T.P,
                   T.S,
                   T.NI,
                   T.CR,
                   T.CU,
                   T.ASN,
                   T.TI,
                   T.V,
                   T.MO,
                   T.B,
                   T.W,
                   T.AL,
                   T.ZN,
                   T.PB,
                   T.SN,
                   T.CA,
                   T.LA,
                   T.SB,
                   T.CE,
                   T.SE,
                   T.MG,
                   T.NB,
                   T.CD,
                   T.BI,
                   T.N,
                   T.H,
                   T.O,
                   T.FE,
                   T.ALT,
                   T.ALS,
                   T.ALINS,
                   T.BS,
                   T.BN,
                   T.MGO,
                   T.SIO2,
                   T.AL2O3,
                   T.TFEO,
                   T.FE2O3,
                   T.H2O,
                   T.CAF2,
                   T.P2O5,
                   T.TFE,
                   T.CR2O3,
                   T.TIO2,
                   T.MNO,
                   T.V2O5,
                   T.FEO,
                   T.CAO,
                   MYROW.CHECK_NO SAMPLE_ID,
                   T.XH,
                   T.MACHINE,
                   T.CREATE_NAME,
                   SYSDATE CREATE_TIME,
                   '1' VALIDFLAG,
                   T.MEMO,
                   T.SAMPLE_NO,
                   'C001',
                   '00'JUDGE_FLAG,
                   T.ZR,
                   '20'LG_JUDGE_FLAG,
                   T.CO,
                   T.SAMPLE_TYPE,
                   T.BAR_CODE,
                   T.TA
        FROM
            QCM_JHY_ELEMENTS T
        WHERE
            STOVE_NO = V_STOVE_NO
            AND SAMPLE_NO = '601';
            END IF;
    END LOOP;
    SELECT COUNT(1) INTO V_COUNT_MT FROM MIL_MT_RESULT WHERE RESULT_NO = '#JUDGE_NO#';
	IF V_COUNT_MT = 0 THEN
         INSERT INTO MIL_MT_RESULT(
                RESULT_NO,
                LOT_NO,
                STOVE_NO,
                JUDGE_STOVE_NO,
                PLINE_CODE,
                PRODUCT_STANDARDS,
                LO_SURFACE,
                LI_SURFACE,
                TO_SURFACE,
                TI_SURFACE,
                GROOVE_SHAPE,
                INSPECTION_STANDARD,
                LONGITUDINAL_CURRENT1,
                TRANSVERSE_CURRENT1,
                LONGITUDINAL_CURRENT2,
                TRANSVERSE_CURRENT2,
                SPEED1,
                SPEED2,
                DETECTION_SPEED1,
                DETECTION_SPEED2,
                DETECTION_NUM,
                ALARM_NUM,
                SUSPICIOUS_REASON,
                REINSPECTION_NUM,
                REINSPECTION_QUALIFIED_NUM,
                SCRAP_NUM,
                SCRAP_REASON,
                QUALIFIED_NUM,
                USERID,
                SIGNID,
                START_TIME,
                END_TIME,
                EXECUTIVE_PRODUCER,
                PRODUCER_TIME,
                PRODUCER_TEL,
                NODE_FUR_FLAG,
                REMARK,
                COL_MODE,
                COL_TIME,
                COL_USER,
                COL_SHIFT,
                COL_GROUP,
                OFFLINE_NUM,
                COL_NO,
                BACKLINE_NUM,
                SCRAP_NUM2,
                QUALIFIED_NUM2,
                REINSPECTION_NUM2,
                REINSPECTION_QUALIFIED_NUM2,
                OFFLINE_NUM2,
                BACKLINE_NUM2,
                SCRAP_NUM1,
                QUALIFIED_NUM1,
                REINSPECTION_NUM1,
                REINSPECTION_QUALIFIED_NUM1,
                OFFLINE_NUM1,
                BACKLINE_NUM1,
                DETECTION_NUM1,
                DETECTION_NUM2,
                SUSPECT_PRODUCT_NUM1,
                SUSPECT_PRODUCT_NUM2,
                NODE_FUR_FLAG1,
                NODE_FUR_FLAG2,
                QA_TON,
                RECUT_NUM1,
                RECUT_NUM2,
                RECUT_NUM,
                CHANGE_NUM,
                SAMPLE_NUM,
                INSPECTIONED_OFFLINE_NUM,
                REMARK1,
                SIGNID_GRADE,
                USERID1,
                USERID2,
                USERID_GRADE1,
                USERID_GRADE2,
                STANDARDS_NO,
                PRO_PLAN_ID,
                GX_PLAN_NO,
                NOTCH_INFO,
                NOTCH_LENGTH,
                NOTCH_WIDTH,
                NOTCH_DEPTH,
                SAMPLE_NO,
                NOTCH_FX,
                COVERAGE,
                TESTING_POSITION)
         SELECT
              '#JUDGE_NO#',
               T.LOT_NO,
               T.STOVE_NO,
               '#JUDGE_NO#' || '-01',
               '#PLINE_CODE#',
               T.PRODUCT_STANDARDS,
               T.LO_SURFACE,
               T.LI_SURFACE,
               T.TO_SURFACE,
               T.TI_SURFACE,
               T.GROOVE_SHAPE,
               T.INSPECTION_STANDARD,
               T.LONGITUDINAL_CURRENT1,
               T.TRANSVERSE_CURRENT1,
               T.LONGITUDINAL_CURRENT2,
               T.TRANSVERSE_CURRENT2,
               T.SPEED1,
               T.SPEED2,
               T.DETECTION_SPEED1,
               T.DETECTION_SPEED2,
               T.DETECTION_NUM,
               T.ALARM_NUM,
               T.SUSPICIOUS_REASON,
               T.REINSPECTION_NUM,
               T.REINSPECTION_QUALIFIED_NUM,
               T.SCRAP_NUM,
               T.SCRAP_REASON,
               T.QUALIFIED_NUM,
               T.USERID,
               T.SIGNID,
               T.START_TIME,
               T.END_TIME,
               T.EXECUTIVE_PRODUCER,
               T.PRODUCER_TIME,
               T.PRODUCER_TEL,
               T.NODE_FUR_FLAG,
               T.REMARK,
               T.COL_MODE,
               T.COL_TIME,
               T.COL_USER,
               T.COL_SHIFT,
               T.COL_GROUP,
               T.OFFLINE_NUM,
               T.COL_NO,
               T.BACKLINE_NUM,
               T.SCRAP_NUM2,
               T.QUALIFIED_NUM2,
               T.REINSPECTION_NUM2,
               T.REINSPECTION_QUALIFIED_NUM2,
               T.OFFLINE_NUM2,
               T.BACKLINE_NUM2,
               T.SCRAP_NUM1,
               T.QUALIFIED_NUM1,
               T.REINSPECTION_NUM1,
               T.REINSPECTION_QUALIFIED_NUM1,
               T.OFFLINE_NUM1,
               T.BACKLINE_NUM1,
               T.DETECTION_NUM1,
               T.DETECTION_NUM2,
               T.SUSPECT_PRODUCT_NUM1,
               T.SUSPECT_PRODUCT_NUM2,
               T.NODE_FUR_FLAG1,
               T.NODE_FUR_FLAG2,
               T.QA_TON,
               T.RECUT_NUM1,
               T.RECUT_NUM2,
               T.RECUT_NUM,
               T.CHANGE_NUM,
               T.SAMPLE_NUM,
               T.INSPECTIONED_OFFLINE_NUM,
               T.REMARK1,
               T.SIGNID_GRADE,
               T.USERID1,
               T.USERID2,
               T.USERID_GRADE1,
               T.USERID_GRADE2,
               T.STANDARDS_NO,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.NOTCH_INFO,
               T.NOTCH_LENGTH,
               T.NOTCH_WIDTH,
               T.NOTCH_DEPTH,
               T.SAMPLE_NO,
               T.NOTCH_FX,
               T.COVERAGE,
               T.TESTING_POSITION
         FROM MIL_MT_RESULT T
         WHERE
         T.JUDGE_STOVE_NO like '#JUDGE_STOVE_NO#' || '%'
        and rownum = 1;
    END IF;
    END;
        ]]>
    </qeury>


</queryMap>