<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "剔废管理">
<query id = "FrmScrapOutList.doQueryMat" desc = "查询库存信息">
<![CDATA[
SELECT T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.GRADECODE,
       T1.GRADENAME,
       sum(T1.ACT_COUNT)ACT_COUNT,
       to_char(sum(T1.Act_Weight),'FM999999990.000')Act_Weight,
       sum(nvl(T1.ACT_LEN,0)) as ACT_LEN,
       to_char(T1.ACT_LEN_MIN,'FM999990.00') AS ACT_LEN_MIN,
       to_char(T1.ACT_LEN_MAX,'FM999990.00') AS ACT_LEN_MAX,
       max(to_char(T1.INSTOCK_TIME,'YYYY-MM-DD')) INSTOCK_TIME,
       S.STORAGE_NAME,
       S.STORAGE_NO,
       T1.MEMO,
       T1.JUDGE_STD_CODE,
       T1.JUDGE_STD_NAME,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.OLD_ORDER_NO,
       T1.MAT_STATUS,
       T1.PRODUCT_FLAG,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 LEFT JOIN ydm_bs_storage S ON S.STORAGE_NO=T2.STORAGE_NO
 WHERE T1.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T1.BATCH_NO = T2.BATCH_NO
    AND T1.MAT_NO=T2.MAT_NO
    AND T1.MAT_STATUS <>'80150302'
    ]]>
</query>
<query id = "FrmScrapOutList.doQueryOutList" desc = "查询出库记录">
 SELECT 
       T.OUTSTOCK_DOC,
       T.OUTSTOCK_TYPE_CODE,
       T.OUTSTOCK_TYPE_NAME,
       T.ICCAR_NO,
       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,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       SUM(T.ACT_LEN)ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       SUM(T.ACT_COUNT)ACT_COUNT,
       SUM(T.ACT_WEIGHT)ACT_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       TO_CHAR(T.OUTSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') OUTSTOCK_TIME,
       T.CREATE_NAME,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.JUDGE_STD_NAME,
       SUM(T.PONDER_GROSS_WT)PONDER_GROSS_WT,
       T.BAL_YEAR_MONTH
 FROM YDM_ZC_OUTLIST T
 WHERE T.OUTSTOCK_TYPE_CODE = '800804'
</query>
<query id = "FrmScrapOutList.scrapMat" desc = "回废出库">
<![CDATA[
DECLARE
  V_OUTDOC    YDM_ZC_OUTLIST.OUTSTOCK_DOC%TYPE := NULL;
  V_OUTDOCSEQ YDM_ZC_OUTLIST.OUTSTOCK_SQE%TYPE := NULL;
BEGIN
  FOR MYROW IN (SELECT G.*
                  FROM (SELECT T.*,
                               S.STORAGE_NO,
                               S.LOCATION_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.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                                                   AND T.BATCH_NO = '#BATCH_NO#'
                                                   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                                                   AND NVL(T.ORDER_NO, '/') = NVL('#ORDER_NO#', '/')
                                                   AND NVL(T.ORDER_SEQ, '/') =
                                                       NVL('#ORDER_SEQ#', '/')
                                                   AND NVL(T.ORDER_SEQ_NO, '/') =
                                                       NVL('#ORDER_SEQ_NO#', '/')
                                                   AND T.PRODUCT_FLAG = '#PRODUCT_FLAG#'
                                                   AND T.MAT_STATUS = '#MAT_STATUS#'
                                                   AND S.STORAGE_NO = '#STORAGE_NO#'
                         ORDER BY T.MAT_NO DESC) G
                WHERE ROWNUM <= TO_NUMBER(#ACT_COUNT#)
                ) LOOP
    SELECT 'OD' ||'#OUTSTOCK_DOC#'||
          LPAD(NVL(MAX(SUBSTR(T.OUTSTOCK_SQE, LENGTH(T.OUTSTOCK_SQE) - 4)),
                   0) + 1,
               5,
               0) OUTSTOCK_SQE INTO V_OUTDOCSEQ
     FROM YDM_ZC_OUTLIST T
    WHERE TRUNC(T.CREATE_TIME) = TRUNC(SYSDATE)
      AND T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
    INSERT INTO YDM_ZC_OUTLIST
      (OUTSTOCK_SQE,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       GRADECODE,
       GRADENAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       PRO_ORDER_NO,
       PLINE_CODE,
       PLINE_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       BELONG_CODE,
       BELONG_NAME,
       STORAGE_NO,
       LOCATION_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       OUTSTOCK_TIME,
       CREATE_NAME,
       CREATE_TIME,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       BAL_YEAR_MONTH,
       FINISHPRO_MOLD,
       IN_MOLD,
       SUPPLY_UNIT_CODE,
       SUPPLY_UNIT,
       IS_DEALER,
       PROCESS_CDOE,
       PROCESS_DESC)
    VALUES
      (V_OUTDOCSEQ,
       '#OUTSTOCK_DOC#',
       '800804',
       '回废出库',
       MYROW.MAT_NO,
       MYROW.Judge_Stove_No,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.MATERIAL_NO,
       MYROW.MATERIAL_NAME,
       MYROW.PRODUCCODE,
       MYROW.PRODUCNAME,
       MYROW.STD_CODE,
       MYROW.STD_NAME,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.STD_STYLE,
       MYROW.STD_STYLE_DESC,
       MYROW.SPEC_CODE,
       MYROW.SPEC_NAME,
       MYROW.MODEL_CODE,
       MYROW.MODEL_DESC,
       MYROW.PRO_ORDER_NO,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.ACT_DIMATER,
       MYROW.HEIGHT,
       MYROW.ACT_LEN,
       MYROW.ACT_LEN_MIN,
       MYROW.ACT_LEN_MAX,
       MYROW.ACT_COUNT,
       MYROW.ACT_WEIGHT,
       MYROW.ACT_THEORY_WEIGHT,
       MYROW.BELONG_CODE,
       MYROW.BELONG_NAME,
       MYROW.STORAGE_NO,
       MYROW.LOCATION_NO,
       MYROW.STORAGE_ATTR,
       MYROW.STORAGE_ATTR_NAME,
       MYROW.STORAGE_TYPE_NO,
       MYROW.STORAGE_TYPE_NAME,
       '#MANAGEMENT_NO#',
       '#MANAGEMENT_NAME#',
       TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
       '#CREATE_NAME#',
       TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,
       '#DEPARTMENT_CODE#',
       '#DEPARTMENT_DESC#',
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.ORDER_SEQ_NO,
       MYROW.PRODUCT_FLAG,
       MYROW.MAT_STATUS,
       MYROW.JUDGE_STD_NAME,
       MYROW.JUDGE_STD_CODE,
       '#BAL_YEAR_MONTH#',
       MYROW.FINISHPRO_MOLD,
       MYROW.IN_MOLD,
       '#SUPPLY_UNIT_CODE#',
       '#SUPPLY_UNIT#',
       MYROW.IS_DEALER,
       MYROW.PROCESS_CDOE,
       MYROW.PROCESS_DESC);
       INSERT INTO MAT_ZC_BACKUP(
        MAT_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MAT_SQE_NO,
        SAMPLE_FLAG,
        CUTTING_FLAG,
        ORIGIN_MAT_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        INPUT_MATERIAL_NAME,
        INPUT_MATERIAL_NO,
        INPUT_ORIGIN_CODE,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        GRADECODE,
        GRADENAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        PRO_ORDER_NO,
        PRO_ORDER_NO1,
        PRO_ORDER_ID,
        PRO_ORDER_ID1,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        CRAF_NO,
        PROCESS_CDOE,
        PROCESS_DESC,
        NEXT_PROCESS_CDOE,
        NEXT_PROCESS_DESC,
        PLINE_CODE,
        PLINE_NAME,
        MAT_ORIGIN_CODE,
        MAT_ORIGIN_NAME,
        DIMATER,
        HEIGHT,
        LEN_NO,
        LEN_DESC,
        LEN_UNIT,
        LEN_MIN,
        LEN_MAX,
        TARG_DIMATER,
        TARG_HEIGHT,
        TARG_LEN_MIN,
        TARG_LEN_MAX,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        MEASURE_FLAG,
        BELONG_CODE,
        BELONG_NAME,
        PACK_FLAG,
        PACK_TYPE_CODE,
        PACK_TYPE_NAME,
        PACK_NO,
        PACK_TIME,
        PACK_MAT_WT,
        MAT_GROSS_WT,
        MAT_GOWHERE_CODE,
        MAT_GOWHERE_NAME,
        COOL_HOT_FLAG,
        MAT_RETURN_FLAG,
        HEAT_TREAT_NO,
        POST_FLAG,
        LOCK_FLAG,
        MNG_LOCK_RSN_CODE,
        MNG_LOCK_TIME,
        MNG_LOCK_MAKER,
        MNG_LOCK_REMARK,
        LOCK_RSN_CODE,
        LOCK_TIME,
        LOCK_MAKER,
        LOCK_REMARK,
        UNLOCK_TIME,
        UNLOCK_MAKER,
        UNLOCK_REMARK,
        OLD_ORDER_NO,
        OLD_ORDER_SEQ,
        OLD_ORDER_SEQ_NO,
        OLD_MATERIAL_NO,
        OLD_MATERIAL_NAME,
        REMAIN_RSN_CODE,
        REMAIN_JUGDE_TIME,
        REMAIN_JUGDE_MAKER,
        REMAIN_JUGDE_CODE,
        REMAIN_REMARK,
        JUGDE_APPLY_FLAG,
        JUGDE_APPLY_CODE,
        JUGDE_APPLY_TIME,
        JUGDE_SCAN_TIME,
        FACE_RESULT_CODE,
        FACE_RESULT_TIME,
        FACE_MAKER,
        SPEC_RESULT_CODE,
        SPEC_RESULT_TIME,
        SPEC_MAKER,
        CHEM_RESULT_CODE,
        CHEM_RESULT_TIME,
        CHEM_MAKER,
        PHY_RESULT_CODE,
        PHY_RESULT_TIME,
        PHY_MAKER,
        DETECT_REPORT_NO,
        DETECT_RESULT_CODE,
        WPRESSURE_REPORT_NO,
        WPRESSURE_RESULT_CODE,
        JUDGE_RESULT_CODE,
        JUDGE_RESULT,
        JUDGE_RESULT_TIME,
        JUDGE_MAKER,
        BUG_NO,
        BUG_DEAL,
        REPAIR_FLAG,
        REPAIR_REMARK,
        SAMPLING_FLAG,
        SAMPLING_TYPE,
        SAMPLING_NO,
        CHECKOUT_NO,
        CHEM_STCHECK_NO,
        CHEM_PROCHECK_NO,
        SH_CHECK_NO,
        COME_PROC_FLAG,
        CONFM_FLAG,
        INSTOCK_FLAG,
        INSTOCK_TIME,
        OUTSTOCK_TIME,
        PRO_BC,
        PRO_BZ,
        RPO_TIME,
        BAR_CODE,
        BEGINNING_FLAG,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        REQ_BL_ID,
        IF_BATCHED_JG,
        COUPCUT_BATCH_ID,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        OLD_ORD_PK,
        OLD_ORD_LN_PK,
        OLD_ORD_LN_DLY_PK,
        BAL_YEAR_MONTH,
        JUDGE_STD_NAME,
        JUDGE_STD_CODE,
        JUDGE_GRADE,
        PIPMEMO,
        TEST,
        SOURE_CODE,
        SOURE_NAME,
        PONDER_NO,
        PONDER_GROSS_WT,
        MEMO1,
        JUDGE_ID,
        MNG_LOCK_FLAG,
        LOCK_ID,
        PRO_NO,
        LOCK_LIKU,
        PLN_GRADECODE,
        PLN_GRADENAME,
        PLN_STEELCODE,
        PLN_STEELNAME,
        QCM_STAUS,
        OUTSTOCK_DOC,
        HEAT_PLAN_NO,
        ZG_STOVE_SQE,
        GX_PLAN_NO,
        ZG_MAT_NO,
        FINISHPRO_MOLD,
        IN_MOLD,
        IN_TYPE,
        TARGET,
        PROCESS_STATUS,
        JUGDE_CONVICTED,
        GX_PLAN_NO1,
        FIXTYPE_CODE,
        QUALITY_GROUP_ZG,
        FLAG_STOVE_NO_ZG,
        ZG_PHY_RESULT_PATH,
        ZG_FACE_RESULT_PATH,
        ZG_SPEC_RESULT_PATH,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT,
        IS_DEALER,
        PROCESS_CDOE,
        PROCESS_DESC)
 VALUES( 
        MYROW.MAT_NO,
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        MYROW.LOT_NO,
        MYROW.STOVE_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.MAT_SQE_NO,
        MYROW.SAMPLE_FLAG,
        MYROW.CUTTING_FLAG,
        MYROW.ORIGIN_MAT_NO,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.INPUT_MATERIAL_NAME,
        MYROW.INPUT_MATERIAL_NO,
        MYROW.INPUT_ORIGIN_CODE,
        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.PRO_ORDER_NO,
        MYROW.PRO_ORDER_NO1,
        MYROW.PRO_ORDER_ID,
        MYROW.PRO_ORDER_ID1,
        MYROW.ORDER_NO,
        MYROW.ORDER_SEQ,
        MYROW.ORDER_SEQ_NO,
        MYROW.CRAF_NO,
        MYROW.PROCESS_CDOE,
        MYROW.PROCESS_DESC,
        MYROW.NEXT_PROCESS_CDOE,
        MYROW.NEXT_PROCESS_DESC,
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        MYROW.MAT_ORIGIN_CODE,
        MYROW.MAT_ORIGIN_NAME,
        MYROW.DIMATER,
        MYROW.HEIGHT,
        MYROW.LEN_NO,
        MYROW.LEN_DESC,
        MYROW.LEN_UNIT,
        MYROW.LEN_MIN,
        MYROW.LEN_MAX,
        MYROW.TARG_DIMATER,
        MYROW.TARG_HEIGHT,
        MYROW.TARG_LEN_MIN,
        MYROW.TARG_LEN_MAX,
        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.MEASURE_FLAG,
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        MYROW.PACK_FLAG,
        MYROW.PACK_TYPE_CODE,
        MYROW.PACK_TYPE_NAME,
        MYROW.PACK_NO,
        MYROW.PACK_TIME,
        MYROW.PACK_MAT_WT,
        MYROW.MAT_GROSS_WT,
        MYROW.MAT_GOWHERE_CODE,
        MYROW.MAT_GOWHERE_NAME,
        MYROW.COOL_HOT_FLAG,
        MYROW.MAT_RETURN_FLAG,
        MYROW.HEAT_TREAT_NO,
        MYROW.POST_FLAG,
        MYROW.LOCK_FLAG,
        MYROW.MNG_LOCK_RSN_CODE,
        MYROW.MNG_LOCK_TIME,
        MYROW.MNG_LOCK_MAKER,
        MYROW.MNG_LOCK_REMARK,
        MYROW.LOCK_RSN_CODE,
        MYROW.LOCK_TIME,
        MYROW.LOCK_MAKER,
        MYROW.LOCK_REMARK,
        MYROW.UNLOCK_TIME,
        MYROW.UNLOCK_MAKER,
        MYROW.UNLOCK_REMARK,
        MYROW.OLD_ORDER_NO,
        MYROW.OLD_ORDER_SEQ,
        MYROW.OLD_ORDER_SEQ_NO,
        MYROW.OLD_MATERIAL_NO,
        MYROW.OLD_MATERIAL_NAME,
        MYROW.REMAIN_RSN_CODE,
        MYROW.REMAIN_JUGDE_TIME,
        MYROW.REMAIN_JUGDE_MAKER,
        MYROW.REMAIN_JUGDE_CODE,
        MYROW.REMAIN_REMARK,
        MYROW.JUGDE_APPLY_FLAG,
        MYROW.JUGDE_APPLY_CODE,
        MYROW.JUGDE_APPLY_TIME,
        MYROW.JUGDE_SCAN_TIME,
        MYROW.FACE_RESULT_CODE,
        MYROW.FACE_RESULT_TIME,
        MYROW.FACE_MAKER,
        MYROW.SPEC_RESULT_CODE,
        MYROW.SPEC_RESULT_TIME,
        MYROW.SPEC_MAKER,
        MYROW.CHEM_RESULT_CODE,
        MYROW.CHEM_RESULT_TIME,
        MYROW.CHEM_MAKER,
        MYROW.PHY_RESULT_CODE,
        MYROW.PHY_RESULT_TIME,
        MYROW.PHY_MAKER,
        MYROW.DETECT_REPORT_NO,
        MYROW.DETECT_RESULT_CODE,
        MYROW.WPRESSURE_REPORT_NO,
        MYROW.WPRESSURE_RESULT_CODE,
        MYROW.JUDGE_RESULT_CODE,
        MYROW.JUDGE_RESULT,
        MYROW.JUDGE_RESULT_TIME,
        MYROW.JUDGE_MAKER,
        MYROW.BUG_NO,
        MYROW.BUG_DEAL,
        MYROW.REPAIR_FLAG,
        MYROW.REPAIR_REMARK,
        MYROW.SAMPLING_FLAG,
        MYROW.SAMPLING_TYPE,
        MYROW.SAMPLING_NO,
        MYROW.CHECKOUT_NO,
        MYROW.CHEM_STCHECK_NO,
        MYROW.CHEM_PROCHECK_NO,
        MYROW.SH_CHECK_NO,
        MYROW.COME_PROC_FLAG,
        MYROW.CONFM_FLAG,
        MYROW.INSTOCK_FLAG,
        MYROW.INSTOCK_TIME,
        MYROW.OUTSTOCK_TIME,
        MYROW.PRO_BC,
        MYROW.PRO_BZ,
        MYROW.RPO_TIME,
        MYROW.BAR_CODE,
        MYROW.BEGINNING_FLAG,
        MYROW.MEMO,
        MYROW.CREATE_NAME,
        MYROW.CREATE_TIME,
        MYROW.UPDATE_NAME,
        MYROW.UPDATE_TIME,
        MYROW.REQ_BL_ID,
        MYROW.IF_BATCHED_JG,
        MYROW.COUPCUT_BATCH_ID,
        MYROW.ORD_PK,
        MYROW.ORD_LN_PK,
        MYROW.ORD_LN_DLY_PK,
        MYROW.OLD_ORD_PK,
        MYROW.OLD_ORD_LN_PK,
        MYROW.OLD_ORD_LN_DLY_PK,
        MYROW.BAL_YEAR_MONTH,
        MYROW.JUDGE_STD_NAME,
        MYROW.JUDGE_STD_CODE,
        MYROW.JUDGE_GRADE,
        MYROW.PIPMEMO,
        MYROW.TEST,
        MYROW.SOURE_CODE,
        MYROW.SOURE_NAME,
        MYROW.PONDER_NO,
        MYROW.PONDER_GROSS_WT,
        MYROW.MEMO1,
        MYROW.JUDGE_ID,
        MYROW.MNG_LOCK_FLAG,
        MYROW.LOCK_ID,
        MYROW.PRO_NO,
        MYROW.LOCK_LIKU,
        MYROW.PLN_GRADECODE,
        MYROW.PLN_GRADENAME,
        MYROW.PLN_STEELCODE,
        MYROW.PLN_STEELNAME,
        MYROW.QCM_STAUS,
        MYROW.OUTSTOCK_DOC,
        MYROW.HEAT_PLAN_NO,
        MYROW.ZG_STOVE_SQE,
        MYROW.GX_PLAN_NO,
        MYROW.ZG_MAT_NO,
        MYROW.FINISHPRO_MOLD,
        MYROW.IN_MOLD,
        MYROW.IN_TYPE,
        MYROW.TARGET,
        MYROW.PROCESS_STATUS,
        MYROW.JUGDE_CONVICTED,
        MYROW.GX_PLAN_NO1,
        MYROW.FIXTYPE_CODE,
        MYROW.QUALITY_GROUP_ZG,
        MYROW.FLAG_STOVE_NO_ZG,
        MYROW.ZG_PHY_RESULT_PATH,
        MYROW.ZG_FACE_RESULT_PATH,
        MYROW.ZG_SPEC_RESULT_PATH,
       '#SUPPLY_UNIT_CODE#',
       '#SUPPLY_UNIT#',
       MYROW.IS_DEALER,
       MYROW.PROCESS_CDOE,
       MYROW.PROCESS_DESC);
    DELETE FROM MAT_ZC_M T WHERE T.MAT_NO = MYROW.MAT_NO;
    DELETE FROM YDM_ZC_BUTTRESS S WHERE S.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;
]]>
</query>
<query id = "FrmScrapOutList.cancelScrapMat" desc = "撤销回废出库">
DECLARE
BEGIN
  FOR MYROW IN (SELECT S.*,
                       T.STORAGE_NO,
                       T.LOCATION_NO,
                       T.STORAGE_ATTR,
                       T.STORAGE_ATTR_NAME,
                       T.STORAGE_TYPE_NO,
                       T.STORAGE_TYPE_NAME,
                       T.MANAGEMENT_NO,
                       T.MANAGEMENT_NAME,
                       T.DEPARTMENT_CODE,
                       T.DEPARTMENT_DESC
                  FROM YDM_ZC_OUTLIST T, MAT_ZC_BACKUP S
                 WHERE T.MAT_NO = S.MAT_NO
                   AND 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.OUTSTOCK_TYPE_CODE = '800804'
                 ORDER BY T.MAT_NO ASC) LOOP
    INSERT INTO MAT_ZC_M
      (MAT_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MAT_SQE_NO,
       SAMPLE_FLAG,
       CUTTING_FLAG,
       ORIGIN_MAT_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       INPUT_MATERIAL_NAME,
       INPUT_MATERIAL_NO,
       INPUT_ORIGIN_CODE,
       PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       PRO_ORDER_NO,
       PRO_ORDER_NO1,
       PRO_ORDER_ID,
       PRO_ORDER_ID1,
       ORDER_NO,
       ORDER_SEQ,
       ORDER_SEQ_NO,
       CRAF_NO,
       PROCESS_CDOE,
       PROCESS_DESC,
       NEXT_PROCESS_CDOE,
       NEXT_PROCESS_DESC,
       PLINE_CODE,
       PLINE_NAME,
       MAT_ORIGIN_CODE,
       MAT_ORIGIN_NAME,
       DIMATER,
       HEIGHT,
       LEN_NO,
       LEN_DESC,
       LEN_UNIT,
       LEN_MIN,
       LEN_MAX,
       TARG_DIMATER,
       TARG_HEIGHT,
       TARG_LEN_MIN,
       TARG_LEN_MAX,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       MEASURE_FLAG,
       BELONG_CODE,
       BELONG_NAME,
       PACK_FLAG,
       PACK_TYPE_CODE,
       PACK_TYPE_NAME,
       PACK_NO,
       PACK_TIME,
       PACK_MAT_WT,
       MAT_GROSS_WT,
       MAT_GOWHERE_CODE,
       MAT_GOWHERE_NAME,
       COOL_HOT_FLAG,
       MAT_RETURN_FLAG,
       HEAT_TREAT_NO,
       POST_FLAG,
       LOCK_FLAG,
       MNG_LOCK_RSN_CODE,
       MNG_LOCK_TIME,
       MNG_LOCK_MAKER,
       MNG_LOCK_REMARK,
       LOCK_RSN_CODE,
       LOCK_TIME,
       LOCK_MAKER,
       LOCK_REMARK,
       UNLOCK_TIME,
       UNLOCK_MAKER,
       UNLOCK_REMARK,
       OLD_ORDER_NO,
       OLD_ORDER_SEQ,
       OLD_ORDER_SEQ_NO,
       OLD_MATERIAL_NO,
       OLD_MATERIAL_NAME,
       REMAIN_RSN_CODE,
       REMAIN_JUGDE_TIME,
       REMAIN_JUGDE_MAKER,
       REMAIN_JUGDE_CODE,
       REMAIN_REMARK,
       JUGDE_APPLY_FLAG,
       JUGDE_APPLY_CODE,
       JUGDE_APPLY_TIME,
       JUGDE_SCAN_TIME,
       FACE_RESULT_CODE,
       FACE_RESULT_TIME,
       FACE_MAKER,
       SPEC_RESULT_CODE,
       SPEC_RESULT_TIME,
       SPEC_MAKER,
       CHEM_RESULT_CODE,
       CHEM_RESULT_TIME,
       CHEM_MAKER,
       PHY_RESULT_CODE,
       PHY_RESULT_TIME,
       PHY_MAKER,
       DETECT_REPORT_NO,
       DETECT_RESULT_CODE,
       WPRESSURE_REPORT_NO,
       WPRESSURE_RESULT_CODE,
       JUDGE_RESULT_CODE,
       JUDGE_RESULT,
       JUDGE_RESULT_TIME,
       JUDGE_MAKER,
       BUG_NO,
       BUG_DEAL,
       REPAIR_FLAG,
       REPAIR_REMARK,
       SAMPLING_FLAG,
       SAMPLING_TYPE,
       SAMPLING_NO,
       CHECKOUT_NO,
       CHEM_STCHECK_NO,
       CHEM_PROCHECK_NO,
       SH_CHECK_NO,
       COME_PROC_FLAG,
       CONFM_FLAG,
       INSTOCK_FLAG,
       INSTOCK_TIME,
       OUTSTOCK_TIME,
       PRO_BC,
       PRO_BZ,
       RPO_TIME,
       BAR_CODE,
       BEGINNING_FLAG,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       REQ_BL_ID,
       IF_BATCHED_JG,
       COUPCUT_BATCH_ID,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       OLD_ORD_PK,
       OLD_ORD_LN_PK,
       OLD_ORD_LN_DLY_PK,
       BAL_YEAR_MONTH,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       JUDGE_GRADE,
       PIPMEMO,
       TEST,
       SOURE_CODE,
       SOURE_NAME,
       PONDER_NO,
       PONDER_GROSS_WT,
       MEMO1,
       JUDGE_ID,
       MNG_LOCK_FLAG,
       LOCK_ID,
       PRO_NO,
       LOCK_LIKU,
       PLN_GRADECODE,
       PLN_GRADENAME,
       PLN_STEELCODE,
       PLN_STEELNAME,
       QCM_STAUS,
       OUTSTOCK_DOC,
       HEAT_PLAN_NO,
       ZG_STOVE_SQE,
       GX_PLAN_NO,
       ZG_MAT_NO,
       FINISHPRO_MOLD,
       IN_MOLD,
       TARGET,
       PROCESS_STATUS,
       JUGDE_CONVICTED,
       GX_PLAN_NO1,
       FIXTYPE_CODE,
       QUALITY_GROUP_ZG,
       FLAG_STOVE_NO_ZG,
       ZG_PHY_RESULT_PATH,
       ZG_FACE_RESULT_PATH,
       ZG_SPEC_RESULT_PATH)
    VALUES
      (MYROW.MAT_NO,
       MYROW.PRODUCT_FLAG,
       MYROW.MAT_STATUS,
       MYROW.LOT_NO,
       MYROW.STOVE_NO,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.MAT_SQE_NO,
       MYROW.SAMPLE_FLAG,
       MYROW.CUTTING_FLAG,
       MYROW.ORIGIN_MAT_NO,
       MYROW.MATERIAL_NO,
       MYROW.MATERIAL_NAME,
       MYROW.INPUT_MATERIAL_NAME,
       MYROW.INPUT_MATERIAL_NO,
       MYROW.INPUT_ORIGIN_CODE,
       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.PRO_ORDER_NO,
       MYROW.PRO_ORDER_NO1,
       MYROW.PRO_ORDER_ID,
       MYROW.PRO_ORDER_ID1,
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.ORDER_SEQ_NO,
       MYROW.CRAF_NO,
       MYROW.PROCESS_CDOE,
       MYROW.PROCESS_DESC,
       MYROW.NEXT_PROCESS_CDOE,
       MYROW.NEXT_PROCESS_DESC,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.MAT_ORIGIN_CODE,
       MYROW.MAT_ORIGIN_NAME,
       MYROW.DIMATER,
       MYROW.HEIGHT,
       MYROW.LEN_NO,
       MYROW.LEN_DESC,
       MYROW.LEN_UNIT,
       MYROW.LEN_MIN,
       MYROW.LEN_MAX,
       MYROW.TARG_DIMATER,
       MYROW.TARG_HEIGHT,
       MYROW.TARG_LEN_MIN,
       MYROW.TARG_LEN_MAX,
       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.MEASURE_FLAG,
       MYROW.BELONG_CODE,
       MYROW.BELONG_NAME,
       MYROW.PACK_FLAG,
       MYROW.PACK_TYPE_CODE,
       MYROW.PACK_TYPE_NAME,
       MYROW.PACK_NO,
       MYROW.PACK_TIME,
       MYROW.PACK_MAT_WT,
       MYROW.MAT_GROSS_WT,
       MYROW.MAT_GOWHERE_CODE,
       MYROW.MAT_GOWHERE_NAME,
       MYROW.COOL_HOT_FLAG,
       MYROW.MAT_RETURN_FLAG,
       MYROW.HEAT_TREAT_NO,
       MYROW.POST_FLAG,
       MYROW.LOCK_FLAG,
       MYROW.MNG_LOCK_RSN_CODE,
       MYROW.MNG_LOCK_TIME,
       MYROW.MNG_LOCK_MAKER,
       MYROW.MNG_LOCK_REMARK,
       MYROW.LOCK_RSN_CODE,
       MYROW.LOCK_TIME,
       MYROW.LOCK_MAKER,
       MYROW.LOCK_REMARK,
       MYROW.UNLOCK_TIME,
       MYROW.UNLOCK_MAKER,
       MYROW.UNLOCK_REMARK,
       MYROW.OLD_ORDER_NO,
       MYROW.OLD_ORDER_SEQ,
       MYROW.OLD_ORDER_SEQ_NO,
       MYROW.OLD_MATERIAL_NO,
       MYROW.OLD_MATERIAL_NAME,
       MYROW.REMAIN_RSN_CODE,
       MYROW.REMAIN_JUGDE_TIME,
       MYROW.REMAIN_JUGDE_MAKER,
       MYROW.REMAIN_JUGDE_CODE,
       MYROW.REMAIN_REMARK,
       MYROW.JUGDE_APPLY_FLAG,
       MYROW.JUGDE_APPLY_CODE,
       MYROW.JUGDE_APPLY_TIME,
       MYROW.JUGDE_SCAN_TIME,
       MYROW.FACE_RESULT_CODE,
       MYROW.FACE_RESULT_TIME,
       MYROW.FACE_MAKER,
       MYROW.SPEC_RESULT_CODE,
       MYROW.SPEC_RESULT_TIME,
       MYROW.SPEC_MAKER,
       MYROW.CHEM_RESULT_CODE,
       MYROW.CHEM_RESULT_TIME,
       MYROW.CHEM_MAKER,
       MYROW.PHY_RESULT_CODE,
       MYROW.PHY_RESULT_TIME,
       MYROW.PHY_MAKER,
       MYROW.DETECT_REPORT_NO,
       MYROW.DETECT_RESULT_CODE,
       MYROW.WPRESSURE_REPORT_NO,
       MYROW.WPRESSURE_RESULT_CODE,
       MYROW.JUDGE_RESULT_CODE,
       MYROW.JUDGE_RESULT,
       MYROW.JUDGE_RESULT_TIME,
       MYROW.JUDGE_MAKER,
       MYROW.BUG_NO,
       MYROW.BUG_DEAL,
       MYROW.REPAIR_FLAG,
       MYROW.REPAIR_REMARK,
       MYROW.SAMPLING_FLAG,
       MYROW.SAMPLING_TYPE,
       MYROW.SAMPLING_NO,
       MYROW.CHECKOUT_NO,
       MYROW.CHEM_STCHECK_NO,
       MYROW.CHEM_PROCHECK_NO,
       MYROW.SH_CHECK_NO,
       MYROW.COME_PROC_FLAG,
       MYROW.CONFM_FLAG,
       MYROW.INSTOCK_FLAG,
       MYROW.INSTOCK_TIME,
       MYROW.OUTSTOCK_TIME,
       MYROW.PRO_BC,
       MYROW.PRO_BZ,
       MYROW.RPO_TIME,
       MYROW.BAR_CODE,
       MYROW.BEGINNING_FLAG,
       MYROW.MEMO,
       MYROW.CREATE_NAME,
       MYROW.CREATE_TIME,
       MYROW.UPDATE_NAME,
       MYROW.UPDATE_TIME,
       MYROW.REQ_BL_ID,
       MYROW.IF_BATCHED_JG,
       MYROW.COUPCUT_BATCH_ID,
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,
       MYROW.OLD_ORD_PK,
       MYROW.OLD_ORD_LN_PK,
       MYROW.OLD_ORD_LN_DLY_PK,
       MYROW.BAL_YEAR_MONTH,
       MYROW.JUDGE_STD_NAME,
       MYROW.JUDGE_STD_CODE,
       MYROW.JUDGE_GRADE,
       MYROW.PIPMEMO,
       MYROW.TEST,
       MYROW.SOURE_CODE,
       MYROW.SOURE_NAME,
       MYROW.PONDER_NO,
       MYROW.PONDER_GROSS_WT,
       MYROW.MEMO1,
       MYROW.JUDGE_ID,
       MYROW.MNG_LOCK_FLAG,
       MYROW.LOCK_ID,
       MYROW.PRO_NO,
       MYROW.LOCK_LIKU,
       MYROW.PLN_GRADECODE,
       MYROW.PLN_GRADENAME,
       MYROW.PLN_STEELCODE,
       MYROW.PLN_STEELNAME,
       MYROW.QCM_STAUS,
       MYROW.OUTSTOCK_DOC,
       MYROW.HEAT_PLAN_NO,
       MYROW.ZG_STOVE_SQE,
       MYROW.GX_PLAN_NO,
       MYROW.ZG_MAT_NO,
       MYROW.FINISHPRO_MOLD,
       MYROW.IN_MOLD,
       MYROW.TARGET,
       MYROW.PROCESS_STATUS,
       MYROW.JUGDE_CONVICTED,
       MYROW.GX_PLAN_NO1,
       MYROW.FIXTYPE_CODE,
       MYROW.QUALITY_GROUP_ZG,
       MYROW.FLAG_STOVE_NO_ZG,
       MYROW.ZG_PHY_RESULT_PATH,
       MYROW.ZG_FACE_RESULT_PATH,
       MYROW.ZG_SPEC_RESULT_PATH);
       
       INSERT INTO MAT_ZC_M_XS
      (MAT_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MAT_SQE_NO,
       SAMPLE_FLAG,
       CUTTING_FLAG,
       ORIGIN_MAT_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       INPUT_MATERIAL_NAME,
       INPUT_MATERIAL_NO,
       INPUT_ORIGIN_CODE,
       PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       PRO_ORDER_NO,
       PRO_ORDER_NO1,
       PRO_ORDER_ID,
       PRO_ORDER_ID1,
       ORDER_NO,
       ORDER_SEQ,
       ORDER_SEQ_NO,
       CRAF_NO,
       PROCESS_CDOE,
       PROCESS_DESC,
       NEXT_PROCESS_CDOE,
       NEXT_PROCESS_DESC,
       PLINE_CODE,
       PLINE_NAME,
       MAT_ORIGIN_CODE,
       MAT_ORIGIN_NAME,
       DIMATER,
       HEIGHT,
       LEN_NO,
       LEN_DESC,
       LEN_UNIT,
       LEN_MIN,
       LEN_MAX,
       TARG_DIMATER,
       TARG_HEIGHT,
       TARG_LEN_MIN,
       TARG_LEN_MAX,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       MEASURE_FLAG,
       BELONG_CODE,
       BELONG_NAME,
       PACK_FLAG,
       PACK_TYPE_CODE,
       PACK_TYPE_NAME,
       PACK_NO,
       PACK_TIME,
       PACK_MAT_WT,
       MAT_GROSS_WT,
       MAT_GOWHERE_CODE,
       MAT_GOWHERE_NAME,
       COOL_HOT_FLAG,
       MAT_RETURN_FLAG,
       HEAT_TREAT_NO,
       POST_FLAG,
       LOCK_FLAG,
       MNG_LOCK_RSN_CODE,
       MNG_LOCK_TIME,
       MNG_LOCK_MAKER,
       MNG_LOCK_REMARK,
       LOCK_RSN_CODE,
       LOCK_TIME,
       LOCK_MAKER,
       LOCK_REMARK,
       UNLOCK_TIME,
       UNLOCK_MAKER,
       UNLOCK_REMARK,
       OLD_ORDER_NO,
       OLD_ORDER_SEQ,
       OLD_ORDER_SEQ_NO,
       OLD_MATERIAL_NO,
       OLD_MATERIAL_NAME,
       REMAIN_RSN_CODE,
       REMAIN_JUGDE_TIME,
       REMAIN_JUGDE_MAKER,
       REMAIN_JUGDE_CODE,
       REMAIN_REMARK,
       JUGDE_APPLY_FLAG,
       JUGDE_APPLY_CODE,
       JUGDE_APPLY_TIME,
       JUGDE_SCAN_TIME,
       FACE_RESULT_CODE,
       FACE_RESULT_TIME,
       FACE_MAKER,
       SPEC_RESULT_CODE,
       SPEC_RESULT_TIME,
       SPEC_MAKER,
       CHEM_RESULT_CODE,
       CHEM_RESULT_TIME,
       CHEM_MAKER,
       PHY_RESULT_CODE,
       PHY_RESULT_TIME,
       PHY_MAKER,
       DETECT_REPORT_NO,
       DETECT_RESULT_CODE,
       WPRESSURE_REPORT_NO,
       WPRESSURE_RESULT_CODE,
       JUDGE_RESULT_CODE,
       JUDGE_RESULT,
       JUDGE_RESULT_TIME,
       JUDGE_MAKER,
       BUG_NO,
       BUG_DEAL,
       REPAIR_FLAG,
       REPAIR_REMARK,
       SAMPLING_FLAG,
       SAMPLING_TYPE,
       SAMPLING_NO,
       CHECKOUT_NO,
       CHEM_STCHECK_NO,
       CHEM_PROCHECK_NO,
       SH_CHECK_NO,
       COME_PROC_FLAG,
       CONFM_FLAG,
       INSTOCK_FLAG,
       INSTOCK_TIME,
       OUTSTOCK_TIME,
       PRO_BC,
       PRO_BZ,
       RPO_TIME,
       BAR_CODE,
       BEGINNING_FLAG,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       REQ_BL_ID,
       IF_BATCHED_JG,
       COUPCUT_BATCH_ID,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       OLD_ORD_PK,
       OLD_ORD_LN_PK,
       OLD_ORD_LN_DLY_PK,
       BAL_YEAR_MONTH,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       JUDGE_GRADE,
       PIPMEMO,
       TEST,
       SOURE_CODE,
       SOURE_NAME,
       PONDER_NO,
       PONDER_GROSS_WT,
       MEMO1,
       JUDGE_ID,
       MNG_LOCK_FLAG,
       LOCK_ID,
       PRO_NO,
       LOCK_LIKU,
       PLN_GRADECODE,
       PLN_GRADENAME,
       PLN_STEELCODE,
       PLN_STEELNAME,
       QCM_STAUS,
       OUTSTOCK_DOC,
       HEAT_PLAN_NO,
       ZG_STOVE_SQE,
       GX_PLAN_NO,
       ZG_MAT_NO,
       FINISHPRO_MOLD,
       IN_MOLD,
       TARGET,
       PROCESS_STATUS,
       JUGDE_CONVICTED,
       GX_PLAN_NO1,
       FIXTYPE_CODE,
       QUALITY_GROUP_ZG,
       FLAG_STOVE_NO_ZG,
       ZG_PHY_RESULT_PATH,
       ZG_FACE_RESULT_PATH,
       ZG_SPEC_RESULT_PATH)
    VALUES
      (MYROW.MAT_NO,
       MYROW.PRODUCT_FLAG,
       MYROW.MAT_STATUS,
       MYROW.LOT_NO,
       MYROW.STOVE_NO,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.MAT_SQE_NO,
       MYROW.SAMPLE_FLAG,
       MYROW.CUTTING_FLAG,
       MYROW.ORIGIN_MAT_NO,
       MYROW.MATERIAL_NO,
       MYROW.MATERIAL_NAME,
       MYROW.INPUT_MATERIAL_NAME,
       MYROW.INPUT_MATERIAL_NO,
       MYROW.INPUT_ORIGIN_CODE,
       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.PRO_ORDER_NO,
       MYROW.PRO_ORDER_NO1,
       MYROW.PRO_ORDER_ID,
       MYROW.PRO_ORDER_ID1,
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.ORDER_SEQ_NO,
       MYROW.CRAF_NO,
       MYROW.PROCESS_CDOE,
       MYROW.PROCESS_DESC,
       MYROW.NEXT_PROCESS_CDOE,
       MYROW.NEXT_PROCESS_DESC,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.MAT_ORIGIN_CODE,
       MYROW.MAT_ORIGIN_NAME,
       MYROW.DIMATER,
       MYROW.HEIGHT,
       MYROW.LEN_NO,
       MYROW.LEN_DESC,
       MYROW.LEN_UNIT,
       MYROW.LEN_MIN,
       MYROW.LEN_MAX,
       MYROW.TARG_DIMATER,
       MYROW.TARG_HEIGHT,
       MYROW.TARG_LEN_MIN,
       MYROW.TARG_LEN_MAX,
       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.MEASURE_FLAG,
       MYROW.BELONG_CODE,
       MYROW.BELONG_NAME,
       MYROW.PACK_FLAG,
       MYROW.PACK_TYPE_CODE,
       MYROW.PACK_TYPE_NAME,
       MYROW.PACK_NO,
       MYROW.PACK_TIME,
       MYROW.PACK_MAT_WT,
       MYROW.MAT_GROSS_WT,
       MYROW.MAT_GOWHERE_CODE,
       MYROW.MAT_GOWHERE_NAME,
       MYROW.COOL_HOT_FLAG,
       MYROW.MAT_RETURN_FLAG,
       MYROW.HEAT_TREAT_NO,
       MYROW.POST_FLAG,
       MYROW.LOCK_FLAG,
       MYROW.MNG_LOCK_RSN_CODE,
       MYROW.MNG_LOCK_TIME,
       MYROW.MNG_LOCK_MAKER,
       MYROW.MNG_LOCK_REMARK,
       MYROW.LOCK_RSN_CODE,
       MYROW.LOCK_TIME,
       MYROW.LOCK_MAKER,
       MYROW.LOCK_REMARK,
       MYROW.UNLOCK_TIME,
       MYROW.UNLOCK_MAKER,
       MYROW.UNLOCK_REMARK,
       MYROW.OLD_ORDER_NO,
       MYROW.OLD_ORDER_SEQ,
       MYROW.OLD_ORDER_SEQ_NO,
       MYROW.OLD_MATERIAL_NO,
       MYROW.OLD_MATERIAL_NAME,
       MYROW.REMAIN_RSN_CODE,
       MYROW.REMAIN_JUGDE_TIME,
       MYROW.REMAIN_JUGDE_MAKER,
       MYROW.REMAIN_JUGDE_CODE,
       MYROW.REMAIN_REMARK,
       MYROW.JUGDE_APPLY_FLAG,
       MYROW.JUGDE_APPLY_CODE,
       MYROW.JUGDE_APPLY_TIME,
       MYROW.JUGDE_SCAN_TIME,
       MYROW.FACE_RESULT_CODE,
       MYROW.FACE_RESULT_TIME,
       MYROW.FACE_MAKER,
       MYROW.SPEC_RESULT_CODE,
       MYROW.SPEC_RESULT_TIME,
       MYROW.SPEC_MAKER,
       MYROW.CHEM_RESULT_CODE,
       MYROW.CHEM_RESULT_TIME,
       MYROW.CHEM_MAKER,
       MYROW.PHY_RESULT_CODE,
       MYROW.PHY_RESULT_TIME,
       MYROW.PHY_MAKER,
       MYROW.DETECT_REPORT_NO,
       MYROW.DETECT_RESULT_CODE,
       MYROW.WPRESSURE_REPORT_NO,
       MYROW.WPRESSURE_RESULT_CODE,
       MYROW.JUDGE_RESULT_CODE,
       MYROW.JUDGE_RESULT,
       MYROW.JUDGE_RESULT_TIME,
       MYROW.JUDGE_MAKER,
       MYROW.BUG_NO,
       MYROW.BUG_DEAL,
       MYROW.REPAIR_FLAG,
       MYROW.REPAIR_REMARK,
       MYROW.SAMPLING_FLAG,
       MYROW.SAMPLING_TYPE,
       MYROW.SAMPLING_NO,
       MYROW.CHECKOUT_NO,
       MYROW.CHEM_STCHECK_NO,
       MYROW.CHEM_PROCHECK_NO,
       MYROW.SH_CHECK_NO,
       MYROW.COME_PROC_FLAG,
       MYROW.CONFM_FLAG,
       MYROW.INSTOCK_FLAG,
       MYROW.INSTOCK_TIME,
       MYROW.OUTSTOCK_TIME,
       MYROW.PRO_BC,
       MYROW.PRO_BZ,
       MYROW.RPO_TIME,
       MYROW.BAR_CODE,
       MYROW.BEGINNING_FLAG,
       MYROW.MEMO,
       MYROW.CREATE_NAME,
       MYROW.CREATE_TIME,
       MYROW.UPDATE_NAME,
       MYROW.UPDATE_TIME,
       MYROW.REQ_BL_ID,
       MYROW.IF_BATCHED_JG,
       MYROW.COUPCUT_BATCH_ID,
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,
       MYROW.OLD_ORD_PK,
       MYROW.OLD_ORD_LN_PK,
       MYROW.OLD_ORD_LN_DLY_PK,
       MYROW.BAL_YEAR_MONTH,
       MYROW.JUDGE_STD_NAME,
       MYROW.JUDGE_STD_CODE,
       MYROW.JUDGE_GRADE,
       MYROW.PIPMEMO,
       MYROW.TEST,
       MYROW.SOURE_CODE,
       MYROW.SOURE_NAME,
       MYROW.PONDER_NO,
       MYROW.PONDER_GROSS_WT,
       MYROW.MEMO1,
       MYROW.JUDGE_ID,
       MYROW.MNG_LOCK_FLAG,
       MYROW.LOCK_ID,
       MYROW.PRO_NO,
       MYROW.LOCK_LIKU,
       MYROW.PLN_GRADECODE,
       MYROW.PLN_GRADENAME,
       MYROW.PLN_STEELCODE,
       MYROW.PLN_STEELNAME,
       MYROW.QCM_STAUS,
       MYROW.OUTSTOCK_DOC,
       MYROW.HEAT_PLAN_NO,
       MYROW.ZG_STOVE_SQE,
       MYROW.GX_PLAN_NO,
       MYROW.ZG_MAT_NO,
       MYROW.FINISHPRO_MOLD,
       MYROW.IN_MOLD,
       MYROW.TARGET,
       MYROW.PROCESS_STATUS,
       MYROW.JUGDE_CONVICTED,
       MYROW.GX_PLAN_NO1,
       MYROW.FIXTYPE_CODE,
       MYROW.QUALITY_GROUP_ZG,
       MYROW.FLAG_STOVE_NO_ZG,
       MYROW.ZG_PHY_RESULT_PATH,
       MYROW.ZG_FACE_RESULT_PATH,
       MYROW.ZG_SPEC_RESULT_PATH);
       
    INSERT INTO YDM_ZC_BUTTRESS
      (MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       CREATE_NAME,
       CREATE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC)
    VALUES
      (MYROW.MAT_NO,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.STORAGE_NO,
       MYROW.LOCATION_NO,
       MYROW.STORAGE_ATTR,
       MYROW.STORAGE_ATTR_NAME,
       MYROW.STORAGE_TYPE_NO,
       MYROW.STORAGE_TYPE_NAME,
       MYROW.MANAGEMENT_NO,
       MYROW.MANAGEMENT_NAME,
       MYROW.CREATE_NAME,
       MYROW.CREATE_TIME,
       MYROW.DEPARTMENT_CODE,
       MYROW.DEPARTMENT_DESC);
    DELETE FROM YDM_ZC_OUTLIST T
     WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
       AND T.MAT_NO = MYROW.MAT_NO
       AND T.OUTSTOCK_TYPE_CODE = '800804';
    DELETE FROM YDM_ZC_OUTLIST_XS T
     WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
       AND T.MAT_NO = MYROW.MAT_NO
       AND T.OUTSTOCK_TYPE_CODE = '800804';
    DELETE FROM FMIS_ZC_OUTLIST T
    WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
    AND T.MAT_NO = MYROW.MAT_NO
    AND T.OUTSTOCK_TYPE_CODE = '800804'
    AND T.SYNC_FLAG = '0';
    DELETE FROM MAT_ZC_BACKUP T WHERE T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;
</query>
<query id = "FrmScrapOutList.SelectYdmOutList" desc = "查询出库表信息">
SELECT T.MAT_NO
  FROM YDM_ZC_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.OUTSTOCK_TYPE_CODE = '800804'
</query>
 <query id = "FrmScrapOutList.GetFmisOutList" desc = "查询财务出库中间表表信息">
  SELECT T.*
  FROM FMIS_ZC_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.OUTSTOCK_TYPE_CODE = '800804'
  AND T.SYNC_FLAG = '1'
 </query>
<query id = "FrmScrapOutList.updateYdmOutList" desc = "修改过磅量">
UPDATE YDM_ZC_OUTLIST T
   SET T.PONDER_GROSS_WT = '#PONDER_GROSS_WT#',
   T.PONDER_NO = '#PONDER_NO#'
 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.OUTSTOCK_TYPE_CODE = '800804'
   AND T.MAT_NO = '#MAT_NO#'
</query>
<query id = "FrmScrapOutList.querySendSqlDoc" desc = "生成出库单号">
SELECT ? || TO_CHAR(SYSDATE, 'YYMMDD') ||
       LPAD(NVL(MAX(SUBSTR(T.OUTSTOCK_DOC, LENGTH(T.OUTSTOCK_DOC) - 4)), 0) + 1,
            5,
            0) OUTSTOCK_DOC
  FROM YDM_ZC_OUTLIST T
 WHERE TRUNC(T.CREATE_TIME) = TRUNC(SYSDATE)
   AND T.OUTSTOCK_TYPE_CODE = ?
   AND T.BELONG_CODE IN ('100101', '100103', '100102','100105')
</query>
</queryMap>
