<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "钢管收料作业">
<qeury id = "FrmFilpInStorage.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 = "FrmFilpInStorage.doQueryOutList" desc = "查询出库信息(根据IC卡)">
 SELECT T.OUTSTOCK_DOC,
       MAX(T.OUTSTOCK_TYPE_CODE) OUTSTOCK_TYPE_CODE,
       MAX(T.OUTSTOCK_TYPE_NAME) OUTSTOCK_TYPE_NAME,
       T.ICCAR_NO,
       T.VEHICLE_NO,
       MAX(T.LOT_NO) LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       MAX(T.PRODUCCODE) PRODUCCODE,
       MAX(T.PRODUCNAME) PRODUCNAME,
       MAX(T.STD_CODE) STD_CODE,
       MAX(T.STD_NAME) STD_NAME,
       MAX(T.GRADECODE) GRADECODE,
       MAX(T.GRADENAME) GRADENAME,
       MAX(T.STEELCODE) STEELCODE,
       MAX(T.STEELNAME) STEELNAME,
       MAX(T.STD_STYLE) STD_STYLE,
       MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
       MAX(T.SPEC_CODE) SPEC_CODE,
       MAX(T.SPEC_NAME) SPEC_NAME,
       MAX(T.MODEL_CODE) MODEL_CODE,
       MAX(T.MODEL_DESC) MODEL_DESC,
       T.PRO_ORDER_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       MAX(T.ACT_DIMATER) ACT_DIMATER,
       MAX(T.ACT_HEIGHT) ACT_HEIGHT,
       SUM(T.ACT_LEN) ACT_LEN,
       --MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
       --MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.PONDER_GROSS_WT) PONDER_GROSS_WT,
       MAX(METER_WEIGHT) METER_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.STORAGE_NO,
       (SELECT T1.STORAGE_NAME
          FROM YDM_BS_STORAGE T1
         WHERE T1.STORAGE_NO = T.STORAGE_NO) STORAGE_NAME,
       T.TAR_STORAGE_NO,
       (SELECT T1.STORAGE_NAME
          FROM YDM_BS_STORAGE T1
         WHERE T1.STORAGE_NO = T.TAR_STORAGE_NO) TAR_STORAGE_NAME,
       DECODE(T.TAR_REC_FLAG, '0', '未接收', '1', '已接收') TAR_REC_FLAG,
       MAX(TO_CHAR(T.OUTSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) OUTSTOCK_TIME,
       --MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
       T.JUDGE_STD_NAME,
       T.DATA_SUORCE,
       DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '判废') QCM_STAUS,
       MAX(DECODE(T.PRODUCT_FLAG,
                  '801401',
                  '在制品',
                  '801402',
                  '成品',
                  '801403',
                  '商品')) PRODUCT_FLAG,
       MAX(DECODE(T.OUT_TYPE,
                  '0',
                  '写卡倒运',
                  '1',
                  '票据倒运',
                  '2',
                  '纠错倒运',
                  '3',
                  '外委倒运',
                  '4',
                  '装车皮倒运')) OUT_TYPE,
       MAX(T.FLAG_STOVE_NO_ZG) FLAG_STOVE_NO_ZG,
       T.PIPMEMO,
       T.MEMO
  FROM YDM_BC_OUTLIST T
  LEFT JOIN METER_WORK_CAR_ACTUAL_FIRST@TGJL_120_LINK
    ON T.OUTSTOCK_DOC = NOTICE_NO
   AND WEIGHT_TYPE = '0'
 WHERE T.OUTSTOCK_DOC = ?
   AND T.VALIDFLAG = '1'
   AND T.TAR_REC_FLAG = '0'
 GROUP BY T.OUTSTOCK_DOC,
          T.ICCAR_NO,
          T.VEHICLE_NO,
          --T.LOT_NO,
          T.STOVE_NO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PRO_ORDER_NO,
          T.PLINE_CODE,
          T.PLINE_NAME,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.STORAGE_NO,
          T.TAR_STORAGE_NO,
          T.DATA_SUORCE,
          T.QCM_STAUS,
          T.TAR_REC_FLAG,
          T.JUDGE_STD_NAME,
          T.ACT_LEN_MIN,
          T.ACT_LEN_MAX,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PIPMEMO,
          T.MEMO
</query>
<query id = "FrmFilpInStorage.doQueryOutList1" desc = "查询出库信息">
SELECT T.OUTSTOCK_DOC,
       MAX(T.OUTSTOCK_TYPE_CODE) OUTSTOCK_TYPE_CODE,
       MAX(T.OUTSTOCK_TYPE_NAME) OUTSTOCK_TYPE_NAME,
       T.ICCAR_NO,
       T.VEHICLE_NO,
       MAX(T.LOT_NO) LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       MAX(T.PRODUCCODE) PRODUCCODE,
       MAX(T.PRODUCNAME) PRODUCNAME,
       MAX(T.STD_CODE) STD_CODE,
       MAX(T.STD_NAME) STD_NAME,
       MAX(T.GRADECODE) GRADECODE,
       MAX(T.GRADENAME) GRADENAME,
       MAX(T.STEELCODE) STEELCODE,
       MAX(T.STEELNAME) STEELNAME,
       MAX(T.STD_STYLE) STD_STYLE,
       MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
       MAX(T.SPEC_CODE) SPEC_CODE,
       MAX(T.SPEC_NAME) SPEC_NAME,
       MAX(T.MODEL_CODE) MODEL_CODE,
       MAX(T.MODEL_DESC) MODEL_DESC,
       T.PRO_ORDER_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       MAX(T.ACT_DIMATER) ACT_DIMATER,
       MAX(T.ACT_HEIGHT) ACT_HEIGHT,
       SUM(T.ACT_LEN) ACT_LEN,
       --MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
       --MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.PONDER_GROSS_WT) PONDER_GROSS_WT,
       -- tzh 24.7.9注释 
       --MAX(METER_WEIGHT) METER_WEIGHT,
       0 METER_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.STORAGE_NO,
       (SELECT T1.STORAGE_NAME
          FROM YDM_BS_STORAGE T1
         WHERE T1.STORAGE_NO = T.STORAGE_NO) STORAGE_NAME,
       T.TAR_STORAGE_NO,
       (SELECT T1.STORAGE_NAME
          FROM YDM_BS_STORAGE T1
         WHERE T1.STORAGE_NO = T.TAR_STORAGE_NO) TAR_STORAGE_NAME,
       DECODE(T.TAR_REC_FLAG, '0', '未接收', '1', '已接收') TAR_REC_FLAG,
       MAX(TO_CHAR(T.OUTSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) OUTSTOCK_TIME,
       --MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
       T.JUDGE_STD_NAME,
       T.DATA_SUORCE,
       DECODE(T.QCM_STAUS, '00', '合格', '11', '待处理', '22', '判废') QCM_STAUS,
       MAX(DECODE(T.PRODUCT_FLAG,
                  '801401',
                  '在制品',
                  '801402',
                  '成品',
                  '801403',
                  '商品')) PRODUCT_FLAG,
       MAX(DECODE(T.OUT_TYPE,
                  '0',
                  '写卡倒运',
                  '1',
                  '票据倒运',
                  '2',
                  '纠错倒运',
                  '3',
                  '外委倒运',
                  '4',
                  '装车皮倒运')) OUT_TYPE,
       MAX(T.FLAG_STOVE_NO_ZG) FLAG_STOVE_NO_ZG,
       MAX(T.CREATE_NAME) CREATE_NAME,
       MAX(TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS')) CREATE_TIME,
       T.PIPMEMO,
       T.MEMO
  FROM YDM_BC_OUTLIST T
  -- tzh 24.7.9 天淮没有这个计量表  注销
  /* LEFT JOIN METER_WORK_CAR_ACTUAL_FIRST@TGJL_120_LINK
    ON T.OUTSTOCK_DOC = NOTICE_NO
   AND WEIGHT_TYPE = '0' */
 WHERE T.OUTSTOCK_TYPE_CODE = '800803'
   AND T.VALIDFLAG = '1'
   AND T.TAR_REC_FLAG = '0'
</query>
<query id = "FrmFilpInStorage.douQueryInList" desc = "查询入库信息">
SELECT T.INSTOCK_DOC,
       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,
       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.PIPMEMO) PIPMEMO,
       T.PRO_ORDER_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       MAX(T.ACT_DIMATER) ACT_DIMATER,
       MAX(T.ACT_HEIGHT) ACT_HEIGHT,
       SUM(T.ACT_LEN) ACT_LEN,
       --MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
       --MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
    T.ACT_LEN_MIN,
    T.ACT_LEN_MAX,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
      SUM(T.PONDER_GROSS_WT) PONDER_GROSS_WT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.STORAGE_NO,
       MAX((SELECT T2.STORAGE_NAME FROM YDM_BS_STORAGE T2 WHERE T2.STORAGE_NO = T.STORAGE_NO))STORAGE_NAME,
       T.LOCATION_NO,
       (SELECT T1.LOCATION_NAME FROM YDM_BS_LOCATION T1 WHERE T1.LOCATION_NO = T.LOCATION_NO)LOCATION_NAME,
       T.LARY_NO,
       MAX(TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) INSTOCK_TIME,
       MAX(TO_CHAR(T.OUTSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) OUTSTOCK_TIME,
       MAX(TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS')) CREATE_TIME,
       MAX(T.CREATE_NAME)CREATE_NAME，
       --MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
    T.JUDGE_STD_NAME,
       DECODE(T.QCM_STAUS,'00','合格','11','待处理','22','判废')QCM_STAUS,
       T.DATA_SUORCE,
       MAX(T.OUTSTOCK_DOC)OUTSTOCK_DOC,
       MAX(DECODE(T.OUT_TYPE,'0','写卡倒运','1','票据倒运','2','纠错倒运','3','外委倒运','4','装车皮倒运'))OUT_TYPE,
       MAX(T.SOURE_CODE)SOURE_CODE,
       MAX(T.SOURE_NAME)SOURE_NAME,
       MAX(T.FLAG_STOVE_NO_ZG)FLAG_STOVE_NO_ZG,
       MAX(T.OUTSTOCK_DOC)OUTSTOCK_DOC,
       T.M_BILL_NO,
       case
         when (SELECT sum(q.act_count)
                 from qcm_zg_jugde_apply q
                where q.judge_stove_no = t.judge_stove_no
                  and q.batch_no = t.batch_no
                  and q.batch_groud_no = t.batch_groud_no
                  and q.pline_code = t.pline_code) > 0 then
          '已送判'
         ELSE
          ''
       END SFSP,
		(CASE WHEN T.IN_BC ='1'
		  THEN '白班'
		    WHEN T.IN_BC ='2'
		  THEN '中班'
		    WHEN T.IN_BC ='3'
		  THEN '晚班' end)  IN_BC,
		 (CASE WHEN T.IN_BZ ='1'
		  THEN '甲'
		    WHEN T.IN_BZ ='2'
		  THEN '乙'
		    WHEN T.IN_BZ ='3'
		  THEN '丙'
		     WHEN T.IN_BZ ='4'
		  THEN '丁' end)  IN_BZ
  FROM YDM_BC_INLIST T
  WHERE T.INSTOCK_TYPE_CODE = '800703'
</query>
<query id = "FrmFilpInStorage.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>
<query id = "FrmFilpInStorage.getInDoc" desc = "生成入库单号">
SELECT 'IC' || 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 = '800703'
     AND T.INSTOCK_DOC LIKE 'IC' || TO_CHAR(SYSDATE, 'YYMMDD') || '_____'
</query>
    <query id = "FrmFilpInStorage.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 = "FrmFilpInStorage.getOutDocCq" desc = "生成产权出库单号">
        SELECT 'CQ' || TO_CHAR(SYSDATE, 'YYMMDD') ||
        LPAD(NVL(MAX(SUBSTR(T.OUTSTOCK_DOC, 9)), 0) + 1, 5, 0) OUTSTOCK_DOC
        FROM YDM_BC_OUTLIST T
        WHERE T.OUTSTOCK_TYPE_CODE = '800809'
        AND T.OUTSTOCK_DOC LIKE 'CQ' || TO_CHAR(SYSDATE, 'YYMMDD') || '_____'
    </query>
<query id = "FrmFilpInStorage.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 := TO_DATE('#CREATE_TIME#',
                                                           'YYYY-MM-DD HH24:MI:SS');
  V_BATHYEAR     YDM_BC_INLIST.BAL_YEAR_MONTH%TYPE := TO_CHAR(SYSDATE,
                                                              'YYYYMM');
  V_STORAGE_NAME YDM_BS_STORAGE.STORAGE_NAME%TYPE := NULL;
  V_COUNT        MAT_ZC_M.ACT_COUNT%TYPE := NULL;
  V_LOAD_TYPE    YDM_ZC_BILL_M.PLAN_TRANS_TYPE%TYPE := NULL;
BEGIN
  SELECT T.STORAGE_NAME
    INTO V_STORAGE_NAME
    FROM YDM_BS_STORAGE T
   WHERE T.STORAGE_NO = '#TAR_STORAGE_NO#';

  --生成入库单号
  V_INSTOCK_DOC := '#INSTOCK_DOC#';
  SELECT MEMO, BASENAME
    INTO V_IMEMO, V_BASENAME
    FROM COM_BASE_INFO
   WHERE BASECODE = '#INSTOCK_TYPE_CODE#';
  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_BC_OUTLIST T
                         WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
                           AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                           AND T.BATCH_NO = '#BATCH_NO#'
                           AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                           AND T.STORAGE_NO = '#STORAGE_NO#'
                           AND T.BELONG_CODE = '#BELONG_CODE#'
                           AND NVL(T.MATERIAL_NO, '/') =
                               NVL('#MATERIAL_NO#', '/')
                           AND NVL(T.PRODUCCODE, '/') =
                               NVL('#PRODUCCODE#', '/')
                           AND NVL(T.STEELCODE, '/') =
                               NVL('#STEELCODE#', '/')
                           AND NVL(T.SPEC_CODE, '/') =
                               NVL('#SPEC_CODE#', '/')
                           AND NVL(T.STD_STYLE, '/') =
                               NVL('#STD_STYLE#', '/')
                           AND NVL(T.MODEL_CODE, '/') =
                               NVL('#MODEL_CODE#', '/')
                           --AND NVL(T.STD_CODE, '/') = NVL('#STD_CODE#', '/')
                           AND NVL(T.JUDGE_STD_NAME, '/') =
                               NVL('#JUDGE_STD_NAME#', '/')
                           AND NVL(T.ACT_LEN_MIN, '0') =
                               NVL('#ACT_LEN_MIN#', '0')
                           AND NVL(T.ACT_LEN_MAX, '0') =
                               NVL('#ACT_LEN_MAX#', '0')
                           AND T.TAR_REC_FLAG = '0'
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= #ACT_COUNT#) LOOP
    IF (MYROW.DATA_SUORCE = '0') THEN
      UPDATE YDM_BC_BUTTRESS S
         SET S.STORAGE_NO  = '#TAR_STORAGE_NO#',
             S.LOCATION_NO = '#TAR_LOCATION_NO#',
             S.LARY_NO     = '#TAR_LARY_NO#',

             S.BATCH_NO       = MYROW.BATCH_NO,
             S.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
       WHERE S.MAT_NO = MYROW.MAT_NO
         AND S.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;
    ELSE

      UPDATE YDM_ZC_BUTTRESS S
         SET S.STORAGE_NO     = '#TAR_STORAGE_NO#',
             S.LOCATION_NO    = '#TAR_LOCATION_NO#',
             S.LARY_NO        = '#TAR_LARY_NO#',
             S.BATCH_NO       = MYROW.BATCH_NO,
             S.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
       WHERE S.MAT_NO = MYROW.MAT_NO
         AND S.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;

      SELECT COUNT(1)
        INTO V_COUNT
        FROM YDM_ZC_BILL_M T, YDM_ZC_BILL_C S
       WHERE T.BILL_NO = S.BILL_NO
         AND S.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND S.BATCH_NO = '#BATCH_NO#'
         AND S.GROUP_NO = '#BATCH_GROUD_NO#'
         AND S.MAT_NO = MYROW.MAT_NO;
      IF (V_COUNT > 0) THEN
        SELECT T.PLAN_TRANS_TYPE
          INTO V_LOAD_TYPE
          FROM YDM_ZC_BILL_M T, YDM_ZC_BILL_C S
         WHERE T.BILL_NO = S.BILL_NO
           AND S.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
           AND S.BATCH_NO = '#BATCH_NO#'
           AND S.GROUP_NO = '#BATCH_GROUD_NO#'
           AND S.MAT_NO = MYROW.MAT_NO
           AND ROWNUM = 1;
        IF (V_LOAD_TYPE = '110501') THEN
          UPDATE YDM_ZC_BILL_C T
             SET T.STORAGE_NO  = '#TAR_STORAGE_NO#',
                 T.LOCATION_NO = '#TAR_LOCATION_NO#',
                 T.VSTEL       = '#TAR_STORAGE_NO#',
                 T.VSTEL_DESC  = V_STORAGE_NAME
           WHERE T.MAT_NO = MYROW.MAT_NO
             AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;
          UPDATE YDM_ZC_LOADVEHICLE_MAT T
             SET T.STORAGE_NO  = '#TAR_STORAGE_NO#',
                 T.LOCATION_NO = '#TAR_LOCATION_NO#'
           WHERE T.MAT_NO = MYROW.MAT_NO
             AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;
          UPDATE YDM_ZC_TALLYSHEET_C T
             SET T.STORAGE_NO  = '#TAR_STORAGE_NO#',
                 T.LOCATION_NO = '#TAR_LOCATION_NO#'
           WHERE T.MAT_NO = MYROW.MAT_NO
             AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;

        ELSE
          UPDATE YDM_ZC_BILL_C T
             SET T.STORAGE_NO  = '#TAR_STORAGE_NO#',
                 T.LOCATION_NO = '#TAR_LOCATION_NO#'
           WHERE T.MAT_NO = MYROW.MAT_NO
             AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;
        END IF;
      END IF;
    END IF;
    V_INSTOCK_SQE := V_INSTOCK_DOC || LPAD(V_ICOUNT, 4, 0);
    INSERT INTO YDM_BC_INLIST
      (INSTOCK_SQE,
       INSTOCK_DOC,
       INSTOCK_TYPE_CODE,
       INSTOCK_TYPE_NAME,
       ICCAR_NO,
       VEHICLE_NO,
       MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       GRADECODE,
       GRADENAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       PRO_ORDER_NO,
       PLINE_CODE,
       PLINE_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       BELONG_CODE,
       BELONG_NAME,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       INSTOCK_TIME,
       IN_BC,
       IN_BZ,
       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,
       IN_TIME_F,
       BAL_YEAR_MONTH,
       QCM_STAUS,
       DATA_SUORCE,
       OUTSTOCK_DOC,
       OUT_TYPE,
       SOURE_CODE,
       SOURE_NAME,
       FLAG_STOVE_NO_ZG,
       OUTSTOCK_TIME,
       PONDER_GROSS_WT,
       M_BILL_NO)
    VALUES
      (V_INSTOCK_SQE,
       V_INSTOCK_DOC,
       '800703',
       '倒库入库',
       MYROW.ICCAR_NO,
       MYROW.VEHICLE_NO,
       MYROW.MAT_NO,
       MYROW.LOT_NO,
       MYROW.STOVE_NO,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.MATERIAL_NO,
       MYROW.MATERIAL_NAME,
       MYROW.PRODUCCODE,
       MYROW.PRODUCNAME,
       MYROW.STD_CODE,
       MYROW.STD_NAME,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.STD_STYLE,
       MYROW.STD_STYLE_DESC,
       MYROW.SPEC_CODE,
       MYROW.SPEC_NAME,
       MYROW.MODEL_CODE,
       MYROW.MODEL_DESC,
       MYROW.PRO_ORDER_NO,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.ACT_DIMATER,
       MYROW.ACT_HEIGHT,
       MYROW.ACT_LEN,
       MYROW.ACT_LEN_MIN,
       MYROW.ACT_LEN_MAX,
       MYROW.ACT_COUNT,
       MYROW.ACT_WEIGHT,
       MYROW.ACT_THEORY_WEIGHT,
       MYROW.BELONG_CODE,
       MYROW.BELONG_NAME,
       '#TAR_STORAGE_NO#',
       '#TAR_LOCATION_NO#',
       '#TAR_LARY_NO#',
       '',
       '#MANAGEMENT_NO#',
       '#MANAGEMENT_NAME#',
       V_TIME,
       '#IN_BC#',
       '#IN_BZ#',
       '#CREATE_NAME#',
       V_TIME,
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,
       '#DEPARTMENT_CODE#',
       '#DEPARTMENT_DESC#',
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.DELIVERY_NO,
       MYROW.PRODUCT_FLAG,
       MYROW.MAT_STATUS,
       MYROW.JUDGE_STD_NAME,
       MYROW.JUDGE_STD_CODE,
       V_TIME,
       '#BAL_YEAR_MONTH#',
       MYROW.QCM_STAUS,
       MYROW.DATA_SUORCE,
       MYROW.OUTSTOCK_DOC,
       MYROW.OUT_TYPE,
       MYROW.STORAGE_NO,
       (SELECT T1.STORAGE_NAME
          FROM YDM_BS_STORAGE T1
         WHERE T1.STORAGE_NO = MYROW.STORAGE_NO),
       MYROW.FLAG_STOVE_NO_ZG,
       MYROW.OUTSTOCK_TIME,
       MYROW.PONDER_GROSS_WT,
       MYROW.M_BILL_NO);
    UPDATE YDM_BC_OUTLIST T
       SET T.TAR_REC_FLAG        = '1',
           T.TAR_DEPARTMENT_CODE = '#DEPARTMENT_CODE#',
           T.TAR_DEPARTMENT_DESC = '#DEPARTMENT_DESC#',
           T.TAR_MANAGEMENT_NO   = '#MANAGEMENT_NO#',
           T.TAR_MANAGEMENT_NAME = '#MANAGEMENT_NAME#',
           T.INSTOCK_TIME        = V_TIME,
           T.LOAD_PLINE_CODE     = '#TAR_STORAGE_NO#',
           T.LOAD_PLINE_NAME     = V_STORAGE_NAME
     WHERE T.OUTSTOCK_SQE = MYROW.OUTSTOCK_SQE;
    IF (MYROW.DATA_SUORCE = '0') THEN
      UPDATE MAT_BC_M T
         SET T.MAT_GOWHERE_CODE = '#TAR_STORAGE_NO#',
             T.MAT_GOWHERE_NAME = V_STORAGE_NAME,
             T.IN_BC = '#IN_BC#',
             T.IN_BZ = '#IN_BZ#'
       WHERE T.MAT_NO = MYROW.MAT_NO
         AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.BATCH_NO = MYROW.BATCH_NO
         AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO;
    ELSE
    UPDATE MAT_ZC_M T
         SET T.IN_BC = '#IN_BC#',
             T.IN_BZ = '#IN_BZ#'
       WHERE T.MAT_NO = MYROW.MAT_NO
         AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.BATCH_NO = MYROW.BATCH_NO
         AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO;
    END IF;
    V_ICOUNT := V_ICOUNT + 1;
  END LOOP;
END;
]]>
</query>
<query id = "FrmFilpInStorage.selectOutListData" desc = "查询出库实绩是否已接收">
SELECT COUNT(1) ACOUNT
  FROM YDM_BC_OUTLIST T
 WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND T.STORAGE_NO = '#STORAGE_NO#'
   AND T.BELONG_CODE = '#BELONG_CODE#'
   AND NVL(T.MATERIAL_NO, '/') = NVL('#MATERIAL_NO#', '/')
                           AND NVL(T.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
                           AND NVL(T.STEELCODE,'/') = NVL('#STEELCODE#','/')
                           AND NVL(T.SPEC_CODE,'/') = NVL('#SPEC_CODE#','/')
                           AND NVL(T.STD_STYLE, '/') = NVL('#STD_STYLE#','/')
                           AND NVL(T.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
                           AND NVL(T.STD_CODE, '/') = NVL('#STD_CODE#', '/')
                           AND NVL(T.JUDGE_STD_NAME, '/') = NVL('#JUDGE_STD_NAME#', '/')
                           AND NVL(T.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
                           AND NVL(T.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
   AND T.TAR_REC_FLAG = '1'
   
</query>
<query id = "FrmFilpInStorage.doAddBcScrap" desc = "收料新增废品清单">
DECLARE
  V_TIME       YDM_BC_INLIST.CREATE_TIME%TYPE := TO_DATE('#CRATE_TIME#',
                                                         'YYYY-MM-DD HH24:MI:SS');
  V_BATHYEAR   YDM_BC_INLIST.BAL_YEAR_MONTH%TYPE := TO_CHAR(SYSDATE,
                                                            'YYYYMM');
  V_COUNT      YDM_BC_OUTLIST.ACT_COUNT%TYPE := NULL;
  V_ACT_COUNT  YDM_BC_SCRAPOUTLIST.ACT_COUNT%TYPE := NULL;
  V_ACT_WEIGHT YDM_BC_SCRAPOUTLIST.ACT_WEIGHT%TYPE := NULL;
  V_POSS_WGT   YDM_BC_OUTLIST.PONDER_GROSS_WT%TYPE := NULL;
BEGIN
  SELECT COUNT(1)
    INTO V_COUNT
    FROM YDM_BC_SCRAPOUTLIST T
   WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
  IF (V_COUNT = 0) THEN
    SELECT SUM(T.ACT_COUNT), SUM(T.ACT_WEIGHT),SUM(T.PONDER_GROSS_WT)
      INTO V_ACT_COUNT, V_ACT_WEIGHT,V_POSS_WGT
      FROM YDM_BC_OUTLIST T
     WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
    INSERT INTO YDM_BC_SCRAPOUTLIST
      (OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       FLAG_STOVE_NO,
       ACT_COUNT,
       ACT_WEIGHT,
       CRATE_NAME,
       CRATE_TIME,
       BAL_YEAR_MONTH,
       PONDER_GROSS_WT)
    VALUES
      ('#OUTSTOCK_DOC#',
       '800803',
       '倒库出库',
       '000000',
       V_ACT_COUNT,
       V_ACT_WEIGHT,
       '#CRATE_NAME#',
       V_TIME,
       '#BAL_YEAR_MONTH#',
       V_POSS_WGT);
    FOR MYROW IN (SELECT *
                    FROM YDM_BC_OUTLIST T
                   WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
                     AND T.QCM_STAUS = '22'
                   ORDER BY T.MAT_NO ASC) LOOP
      INSERT INTO MAT_BC_BACKUP
        SELECT *
          FROM MAT_BC_M T
         WHERE T.MAT_NO = MYROW.MAT_NO
           AND T.PLINE_CODE = MYROW.PLINE_CODE;
      DELETE FROM MAT_BC_M T
       WHERE T.MAT_NO = MYROW.MAT_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE;
      DELETE FROM YDM_BC_BUTTRESS S
       WHERE S.MAT_NO = MYROW.MAT_NO
         AND S.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND S.BATCH_NO = MYROW.BATCH_NO
         AND S.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO;
    END LOOP;
  END IF;
END;
</query>
<query id = "FrmFilpInStorage.selectInListData" desc = "查询收料支数">
SELECT COUNT(1) ACOUNT
  FROM YDM_BC_INLIST F,
       (SELECT T.MAT_NO
          FROM  MAT_BC_M T, YDM_BC_BUTTRESS S
         WHERE T.MAT_NO = S.MAT_NO
           AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
           AND T.BATCH_NO = '#BATCH_NO#'
           AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
           AND S.STORAGE_NO = '#STORAGE_NO#'
           AND NVL(T.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
           AND NVL(T.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
    AND NVL(T.JUDGE_STD_DES, '/') = NVL('#JUDGE_STD_NAME#', '/')
    --AND NVL(T.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
    --AND NVL(T.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
           ) T1
 WHERE F.MAT_NO = T1.MAT_NO
   AND F.INSTOCK_DOC = '#INSTOCK_DOC#'
   AND F.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND F.BATCH_NO = '#BATCH_NO#'
   AND F.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND NVL(F.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
   AND NVL(F.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
    AND NVL(F.JUDGE_STD_NAME, '/') = NVL('#JUDGE_STD_NAME#', '/')
    --AND NVL(F.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
   -- AND NVL(F.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
</query>
<query id = "FrmFilpInStorage.selectInListDataZc" desc = "查询成品收料支数">
SELECT COUNT(1) ACOUNT
  FROM YDM_BC_INLIST F,
       (SELECT T.MAT_NO
          FROM  MAT_ZC_M T, YDM_ZC_BUTTRESS S
         WHERE T.MAT_NO = S.MAT_NO
           AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
           AND T.BATCH_NO = '#BATCH_NO#'
           AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
           AND S.STORAGE_NO = '#STORAGE_NO#'
           AND NVL(T.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
           AND NVL(T.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
    AND NVL(T.JUDGE_STD_NAME, '/') = NVL('#JUDGE_STD_NAME#', '/')
    --AND NVL(T.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
    --AND NVL(T.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
           ) T1
 WHERE F.MAT_NO = T1.MAT_NO
   AND F.INSTOCK_DOC = '#INSTOCK_DOC#'
   AND F.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND F.BATCH_NO = '#BATCH_NO#'
   AND F.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND NVL(F.PRODUCCODE,'/') = NVL('#PRODUCCODE#','/')
   AND NVL(F.MODEL_CODE,'/') = NVL('#MODEL_CODE#','/')
    AND NVL(F.JUDGE_STD_NAME, '/') = NVL('#JUDGE_STD_NAME#', '/')
    --AND NVL(F.ACT_LEN_MIN,'0') = NVL('#ACT_LEN_MIN#','0')
    --AND NVL(F.ACT_LEN_MAX,'0') = NVL('#ACT_LEN_MAX#','0')
</query>
<query id = "FrmFilpInStorage.deleteInListData" desc = "撤销收料">
    DECLARE
    V_STORAGE_NO_AREA    YDM_BS_STORAGE.SEAM_AREA%TYPE := NULL;
    V_TARSTORAGE_NO_AREA YDM_BS_STORAGE.SEAM_AREA%TYPE := NULL;
    BEGIN
    SELECT S.SEAM_AREA
    INTO V_TARSTORAGE_NO_AREA
    FROM YDM_BC_INLIST T, YDM_BS_STORAGE S
    WHERE T.STORAGE_NO = S.STORAGE_NO
    AND T.INSTOCK_DOC = '#INSTOCK_DOC#'
    AND ROWNUM = 1;
    SELECT S.SEAM_AREA
    INTO V_STORAGE_NO_AREA
    FROM YDM_BC_INLIST T, YDM_BS_STORAGE S
    WHERE T.SOURE_CODE = S.STORAGE_NO
    AND T.INSTOCK_DOC = '#INSTOCK_DOC#'
    AND ROWNUM = 1;
    FOR MYROW IN (SELECT T.*
    FROM YDM_BC_INLIST T
    WHERE T.INSTOCK_DOC = '#INSTOCK_DOC#'
    AND T.INSTOCK_TYPE_CODE = '800703'
    ORDER BY T.MAT_NO DESC) LOOP
    UPDATE YDM_BC_OUTLIST S
    SET S.TAR_REC_FLAG = '0'
    WHERE S.MAT_NO = MYROW.MAT_NO
    AND S.PLINE_CODE = MYROW.PLINE_CODE
    AND S.OUTSTOCK_TYPE_CODE = '800803'
    AND S.OUTSTOCK_DOC = MYROW.OUTSTOCK_DOC;
    --判断数据来源
    IF (MYROW.DATA_SUORCE = '0') THEN
    UPDATE YDM_BC_BUTTRESS S
    SET S.STORAGE_NO = '', S.LOCATION_NO = '', S.LARY_NO = ''
    WHERE S.MAT_NO = MYROW.MAT_NO
    AND S.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
    AND S.BATCH_NO = MYROW.BATCH_NO
    AND S.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO;

    IF (V_STORAGE_NO_AREA = 0 AND V_TARSTORAGE_NO_AREA = 1) THEN
    DELETE FROM YDM_BC_OUTLIST T
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.LOAD_PLINE_CODE = '120504'
    AND T.OUTSTOCK_TYPE_CODE = '800809';
    DELETE FROM YDM_BC_INLIST T
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.SOURE_CODE = '120501'
    AND T.INSTOCK_TYPE_CODE = '800709';
    UPDATE MAT_BC_M T
    SET T.BELONG_CODE = '002001001', T.BELONG_NAME = '生产计划部'
    WHERE T.MAT_NO = MYROW.MAT_NO;
    ELSIF (V_STORAGE_NO_AREA = 1 AND V_TARSTORAGE_NO_AREA = 0) THEN
    DELETE FROM YDM_BC_OUTLIST T
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.LOAD_PLINE_CODE = '120501'
    AND T.OUTSTOCK_TYPE_CODE = '800809';
    DELETE FROM YDM_BC_INLIST T
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.SOURE_CODE = '120504'
    AND T.INSTOCK_TYPE_CODE = '800709';
    UPDATE MAT_BC_M T
    SET T.BELONG_CODE = '002023005', T.BELONG_NAME = '产品制造部'
    WHERE T.MAT_NO = MYROW.MAT_NO;
    END IF;

    IF (MYROW.QCM_STAUS = '22' AND
    ('#STORAGE_NO#' = 'LFG1' OR '#STORAGE_NO#' = 'LYY1' OR
    '#STORAGE_NO#' = 'LFG2')) THEN
    INSERT INTO MAT_BC_M
    SELECT *
    FROM MAT_BC_BACKUP T
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.PLINE_CODE = MYROW.PLINE_CODE;
    DELETE FROM MAT_BC_BACKUP T
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.PLINE_CODE = MYROW.PLINE_CODE;
    INSERT INTO YDM_BC_BUTTRESS
    (MAT_NO,
    JUDGE_STOVE_NO,
    BATCH_NO,
    BATCH_GROUD_NO,
    CREATE_NAME,
    CREATE_TIME)
    VALUES
    (MYROW.MAT_NO,
    MYROW.JUDGE_STOVE_NO,
    MYROW.BATCH_NO,
    MYROW.BATCH_GROUD_NO,
    '#CREATE_NAME#',
    TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'));
    END IF;
    ELSE
    UPDATE YDM_ZC_BUTTRESS S
    SET S.STORAGE_NO = '', S.LOCATION_NO = '', S.LARY_NO = ''
    WHERE S.MAT_NO = MYROW.MAT_NO
    AND S.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;
    UPDATE YDM_ZC_BILL_C T
    SET T.STORAGE_NO = MYROW.SOURE_CODE
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;
    END IF;

    DELETE YDM_BC_INLIST T
    WHERE T.MAT_NO = MYROW.MAT_NO
    AND T.INSTOCK_SQE = MYROW.INSTOCK_SQE
    AND T.LOCATION_NO = MYROW.LOCATION_NO
    AND T.LARY_NO = MYROW.LARY_NO;
    END LOOP;
    IF ('#QCM_STAUS#' = '22' AND
    ('#STORAGE_NO#' = 'LFG1' OR '#STORAGE_NO#' = 'LYY1' OR
    '#STORAGE_NO#' = 'LFG2')) THEN
    DELETE FROM YDM_BC_SCRAPOUTLIST T
    WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
    END IF;
    END; 
</query>
<query id = "FrmFilpInStorage.selectOutPossWgt" desc = "查询过磅重量">
SELECT TO_CHAR(NVL(S.NET_WEIGHT/1000,0),'FM999999990.000')SUTTLE FROM METER_WORK_CAR_ACTUAL S WHERE S.NOTICE_NO = '#OUTSTOCK_DOC#'
    AND S.METER_TYPE_NO IN( '001006003','001006009','001006010','001006011','001006012')  --中控倒运（新）
</query>
<query id = "FrmFilpInStorage.selectOutMatNo" desc = "查询出库单所有材料号">
    SELECT T.MAT_NO
    FROM YDM_BC_OUTLIST T
    LEFT JOIN MAT_BC_M S
    ON T.MAT_NO = S.MAT_NO
    WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
    AND S.PLINE_CODE = '#PLINE_CODE#'
    AND S.JUGDE_APPLY_CODE IS NULL
</query>
<query id = "FrmFilpInStorage.selectMatTH" desc = "查询可以获取过磅重量的支数（天淮）">
<![CDATA[
    select count(1) acount
  from MAT_ZC_M t, Ydm_Bc_Outlist t1
 where t.judge_stove_no = '#JUDGE_STOVE_NO#'
   and t.judge_stove_no = t1.judge_stove_no
   and t.mat_no = t1.mat_no
   and T1.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
   and t.ponder_no is null
   and t.mat_status = '80150301'
   ]]>
</query>
<query id = "FrmFilpInStorage.selectMatBcTH" desc = "查询可以获取过磅重量的支数（天淮）">
<![CDATA[
    select count(1) acount
  from MAT_BC_M t, Ydm_Bc_Outlist t1
 where t.judge_stove_no = '#JUDGE_STOVE_NO#'
   and t.judge_stove_no = t1.judge_stove_no
   and t.mat_no = t1.mat_no
   and T1.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
   ]]>
</query>
<query id = "FrmFilpInStorage.selectOutCount" desc = "查询出库单支数">
SELECT SUM(T.ACT_COUNT)ACOUNT FROM YDM_BC_OUTLIST T WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
</query>
<query id = "FrmFilpInStorage.UpdatePossWgt" desc = "修改过磅重量">
DECLARE
BEGIN
  UPDATE YDM_BC_OUTLIST T
     SET T.PONDER_GROSS_WT = '#PONDER_GROSS_WT#'
   WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
     AND T.MAT_NO = '#MAT_NO#';
  UPDATE MAT_BC_M T
     SET T.PONDER_GROSS_WT = '#PONDER_GROSS_WT#',
     T.ACT_WEIGHT = '#PONDER_GROSS_WT#'
   WHERE T.MAT_NO = '#MAT_NO#';
END;
</query>
<query id = "FrmFilpInStorage.getPossWgt" desc = "收料后获取过磅重量">
DECLARE
BEGIN
  UPDATE YDM_BC_OUTLIST T
     SET T.PONDER_GROSS_WT = '#PONDER_GROSS_WT#'
   WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
     AND T.MAT_NO = '#MAT_NO#';
  UPDATE YDM_BC_INLIST T
     SET T.PONDER_GROSS_WT = '#PONDER_GROSS_WT#'
   WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
     --AND T.INSTOCK_DOC = '#INSTOCK_DOC#'
     AND T.MAT_NO = '#MAT_NO#';
  UPDATE MAT_BC_M T
     SET T.PONDER_GROSS_WT = '#PONDER_GROSS_WT#',
    T.ACT_WEIGHT = '#PONDER_GROSS_WT#'
   WHERE T.MAT_NO = '#MAT_NO#';
END;
</query>
<query id = "FrmFilpInStorage.UpdateScrapWgt" desc = "修改废品过磅重量">
UPDATE YDM_BC_SCRAPOUTLIST T SET T.PONDER_GROSS_WT = '#PONDER_GROSS_WT#' WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
</query>
    <query id = "FrmFilpInStorage.insertTmsDoc" desc = "插入收料的出库单号">
        <![CDATA[
        DECLARE
        V_COUNT NUMBER := 0;
        BEGIN
        SELECT COUNT(1) INTO V_COUNT FROM TMS_YDM_OUT T WHERE T.OUTSTOCK_DOC = ?;
        IF (V_COUNT = 0) THEN
        INSERT INTO TMS_YDM_OUT (OUTSTOCK_DOC,INSTOCK_DOC,PONDER_GROSS_WT) VALUES (?,?,?);
        END IF;
        END;
        ]]>
    </query>
    <query id = "FrmFilpInStorage.selectUnLoadingFlag" desc = "查询卸点是否需要吊车">
        SELECT T.IS_CRANE_UNLOADING FROM YDM_BS_STORAGE T WHERE T.STORAGE_NO = ?
    </query>
    <query id = "FrmFilpInStorage.queryCkStoreArea" desc = "查询出库仓库所属区域">
        SELECT S.SEAM_AREA,T.TAR_STORAGE_NO
        FROM YDM_BC_OUTLIST T, YDM_BS_STORAGE S
        WHERE T.STORAGE_NO = S.STORAGE_NO
        AND T.OUTSTOCK_DOC = ?
        AND ROWNUM = 1
    </query>
    <query id = "FrmFilpInStorage.doAddInListDataCq" desc = "收料新增出库入所属权信息">
        <![CDATA[
        DECLARE
  V_INSTOCK_DOC  YDM_BC_INLIST.INSTOCK_DOC%TYPE := NULL; --入库单号
  V_INSTOCK_SQE  YDM_BC_INLIST.INSTOCK_SQE%TYPE := NULL; --入库流水
  V_OUTSTOCK_DOC  YDM_BC_OUTLIST.OUTSTOCK_DOC%TYPE := NULL; --出库单号
  V_OUTSTOCK_SQE  YDM_BC_OUTLIST.OUTSTOCK_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 := TO_DATE('#CREATE_TIME#',
                                                           'YYYY-MM-DD HH24:MI:SS');
  V_BATHYEAR     YDM_BC_INLIST.BAL_YEAR_MONTH%TYPE := TO_CHAR(SYSDATE,
                                                              'YYYYMM');
  V_STORAGE_NAME YDM_BS_STORAGE.STORAGE_NAME%TYPE := NULL;
  V_COUNT        MAT_ZC_M.ACT_COUNT%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#';
 --生成出库单号
  V_OUTSTOCK_DOC := '#OUTSTOCK_DOCCQ#';
  FOR MYROW IN (SELECT *
                  FROM (SELECT T.*,S.PROCESS_CDOE AS PROCESS_CDOE_M,S.PROCESS_DESC AS PROCESS_DESC_M
                          FROM YDM_BC_OUTLIST T,MAT_BC_M 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.STORAGE_NO = '#STORAGE_NO#'
                           AND NVL(T.MATERIAL_NO, '/') =
                               NVL('#MATERIAL_NO#', '/')
                           AND NVL(T.PRODUCCODE, '/') =
                               NVL('#PRODUCCODE#', '/')
                           AND NVL(T.STEELCODE, '/') =
                               NVL('#STEELCODE#', '/')
                           AND NVL(T.SPEC_CODE, '/') =
                               NVL('#SPEC_CODE#', '/')
                           AND NVL(T.STD_STYLE, '/') =
                               NVL('#STD_STYLE#', '/')
                           AND NVL(T.MODEL_CODE, '/') =
                               NVL('#MODEL_CODE#', '/')
                           AND NVL(T.JUDGE_STD_NAME, '/') =
                               NVL('#JUDGE_STD_NAME#', '/')
                           AND NVL(T.ACT_LEN_MIN, '0') =
                               NVL('#ACT_LEN_MIN#', '0')
                           AND NVL(T.ACT_LEN_MAX, '0') =
                               NVL('#ACT_LEN_MAX#', '0')
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= '#ACT_COUNT#') LOOP
     V_OUTSTOCK_SQE := V_OUTSTOCK_DOC || LPAD(V_ICOUNT, 4, 0);
     INSERT INTO YDM_BC_OUTLIST(
        FLAG_STOVE_NO_ZG,
        OUTSTOCK_SQE,
        OUTSTOCK_DOC,
        OUTSTOCK_TYPE_CODE,
        OUTSTOCK_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,
        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,
        OUTSTOCK_TIME,
        CREATE_NAME,
        CREATE_TIME,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        JUDGE_STD_NAME,
        BAL_YEAR_MONTH,
        LOAD_PLINE_CODE,
        LOAD_PLINE_NAME,
        PROCESS_CDOE,
        PROCESS_DESC)
 VALUES(
        MYROW.FLAG_STOVE_NO_ZG,
        V_OUTSTOCK_SQE,
        V_OUTSTOCK_DOC,
        '800809',
        '产权出库',
        MYROW.MAT_NO,
        MYROW.LOT_NO,
        MYROW.STOVE_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.GRADECODE,
        MYROW.GRADENAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.PRO_ORDER_NO,
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        MYROW.ACT_DIMATER,
        MYROW.ACT_HEIGHT,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        MYROW.ACT_THEORY_WEIGHT,
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        MYROW.STORAGE_NO,
        MYROW.LOCATION_NO,
        V_TIME,
        '#CREATE_NAME#',
        V_TIME,
        MYROW.ORD_PK,
        MYROW.ORD_LN_PK,
        MYROW.ORD_LN_DLY_PK,
        MYROW.ORDER_NO,
        MYROW.ORDER_SEQ,
        MYROW.DELIVERY_NO,
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        MYROW.JUDGE_STD_NAME,
        '#BAL_YEAR_MONTH#',
        '#MAT_GOWHERE_CODE#',
        '#MAT_GOWHERE_NAME#',
        MYROW.PROCESS_CDOE_M,
        MYROW.PROCESS_DESC_M);
    V_INSTOCK_SQE := V_INSTOCK_DOC || LPAD(V_ICOUNT, 4, 0);
    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,
       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,


       INSTOCK_TIME,

       CREATE_NAME,
       CREATE_TIME,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,

       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       JUDGE_STD_NAME,

       IN_TIME_F,
       BAL_YEAR_MONTH,
       QCM_STAUS,
       OUTSTOCK_DOC,
       OUT_TYPE,
       SOURE_CODE,
       SOURE_NAME,
       FLAG_STOVE_NO_ZG,
       OUTSTOCK_TIME,
       PROCESS_CDOE,
       PROCESS_DESC)
    VALUES
      (V_INSTOCK_SQE,
       V_INSTOCK_DOC,
       '800709',
       '产权入库',

       MYROW.MAT_NO,
       MYROW.LOT_NO,
       MYROW.STOVE_NO,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.MATERIAL_NO,
       MYROW.MATERIAL_NAME,
       MYROW.PRODUCCODE,
       MYROW.PRODUCNAME,
       MYROW.STD_CODE,
       MYROW.STD_NAME,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.STD_STYLE,
       MYROW.STD_STYLE_DESC,
       MYROW.SPEC_CODE,
       MYROW.SPEC_NAME,
       MYROW.MODEL_CODE,
       MYROW.MODEL_DESC,
       MYROW.PRO_ORDER_NO,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.ACT_DIMATER,
       MYROW.ACT_HEIGHT,
       MYROW.ACT_LEN,
       MYROW.ACT_LEN_MIN,
       MYROW.ACT_LEN_MAX,
       MYROW.ACT_COUNT,
       MYROW.PONDER_GROSS_WT,
       MYROW.PONDER_GROSS_WT,
       '#BELONG_CODE#',
       '#BELONG_NAME#',
       '#TAR_STORAGE_NO#',
       '#TAR_LOCATION_NO#',

       V_TIME,

       '#CREATE_NAME#',
       V_TIME,
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,

       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.DELIVERY_NO,
       MYROW.PRODUCT_FLAG,
       MYROW.MAT_STATUS,
       MYROW.JUDGE_STD_NAME,

       V_TIME,
       '#BAL_YEAR_MONTH#',
       MYROW.QCM_STAUS,

       MYROW.OUTSTOCK_DOC,
       MYROW.OUT_TYPE,
       '#SOURE_CODE#',
       '#SOURE_NAME#',
       MYROW.FLAG_STOVE_NO_ZG,
       MYROW.OUTSTOCK_TIME,
       MYROW.PROCESS_CDOE_M,
       MYROW.PROCESS_DESC_M
       );
      UPDATE MAT_BC_M T
         SET T.BELONG_CODE = '#BELONG_CODE#',
             T.BELONG_NAME = '#BELONG_NAME#',
             T.ACT_WEIGHT = MYROW.PONDER_GROSS_WT,
             T.ACT_THEORY_WEIGHT = MYROW.PONDER_GROSS_WT
       WHERE T.MAT_NO = MYROW.MAT_NO
         AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.BATCH_NO = MYROW.BATCH_NO
         AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO;
    V_ICOUNT := V_ICOUNT + 1;
  END LOOP;
END;
        ]]>
    </query>
    <query id = "FrmFilpInStorage.doQueryCmmWeight" desc = "查询天淮过磅信息">
        <![CDATA[
        select t1.car_no, t1.record_date2, t.*, t.rowid
  from Cmm_Weight_Mat t, cmm_weight_result t1
 WHERE t.result_no = t1.result_no
   and t.act_weight > 0
   and T.Judge_Stove_No = ?
   and t.act_count = ?
   AND not exists
 (SELECT *
          FROM Cmm_Weight_Mat M
         WHERE M.RECORD_NO = t.RECORD_NO
           AND (M.act_weight = 0 OR M.act_weight IS NULL))
        ]]>
    </query>
    <query id = "FrmFilpInStorage.updatePossWtTH" desc = "获取过磅重量（天淮）">
        <![CDATA[
     DECLARE
  V_result_no      cmm_weight_mat.result_no%TYPE := ?;
  V_INPUT_WEIGHT   PORT_MIL_BATCH_SAMPLE_RESULT.INPUT_WEIGHT%TYPE := NULL; --平均值
  V_INPUT_WEIGHT1  PORT_MIL_BATCH_SAMPLE_RESULT.INPUT_WEIGHT%TYPE := NULL; --余数
  V_instock_doc_AI ydm_zc_inlist.instock_doc%TYPE := NULL;
  V_instock_doc_IA ydm_zc_inlist.instock_doc%TYPE := NULL;
  V_ICOUNT         NUMBER := 1;
  V_ACT_WEIGHT     PORT_MIL_BATCH_SAMPLE_RESULT.INPUT_WEIGHT%TYPE := '#ACT_WEIGHT#';
  V_ACT_COUNT      PORT_MIL_BATCH_SAMPLE_RESULT.ACT_COUNT%TYPE := '#ACT_COUNT#';

BEGIN
  --产出红冲入库单号
  SELECT 'AI' || TO_CHAR(sysdate, 'YYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(T.Instock_Doc, 9)), 0) + 1, 5, 0) DI
    INTO V_instock_doc_AI
    FROM ydm_zc_inlist T
   WHERE T.Instock_Doc LIKE 'AI' || TO_CHAR(sysdate, 'YYMMDD') || '_____'
     and t.instock_type_code = '800704';

  --产出入库入库单号
  SELECT 'IA' || TO_CHAR(sysdate, 'YYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(T.Instock_Doc, 9)), 0) + 1, 5, 0) DI
    INTO V_instock_doc_IA
    FROM ydm_zc_inlist T
   WHERE T.Instock_Doc LIKE 'IA' || TO_CHAR(sysdate, 'YYMMDD') || '_____'
     and t.instock_type_code = '800701';

  SELECT TRUNC(V_ACT_WEIGHT / V_ACT_COUNT, 3)
    INTO V_INPUT_WEIGHT
    FROM DUAL;
  SELECT V_ACT_WEIGHT - V_ACT_COUNT * V_INPUT_WEIGHT
    INTO V_INPUT_WEIGHT1
    FROM DUAL;

  FOR MYROW IN (SELECT T.*
                  FROM MAT_zC_M T, ydm_bc_outlist t1
                 WHERE T.JUDGE_STOVE_NO = t1.judge_stove_no
                   and t.mat_no = t1.mat_no
                   AND T1.Outstock_Doc = '#OUTSTOCK_DOC#'
                   and t1.judge_stove_no = '#JUDGE_STOVE_NO#'
                   AND T1.BATCH_NO = '#BATCH_NO#'
                   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#') LOOP
  
    IF (V_INPUT_WEIGHT1 >= 0.001) THEN
      V_INPUT_WEIGHT1 := V_INPUT_WEIGHT1 - 0.001;
      UPDATE MAT_zC_M T
         SET T.ACT_WEIGHT      = V_INPUT_WEIGHT + 0.001,
             T.PONDER_GROSS_WT = V_INPUT_WEIGHT + 0.001,
             t.ponder_no       = V_result_no,
             T.PIPMEMO         = '已称重'
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.BATCH_NO = '#BATCH_NO#'
         AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
         AND T.MAT_NO = MYROW.MAT_NO;
    ELSE
      UPDATE MAT_zC_M T
         SET T.ACT_WEIGHT      = V_INPUT_WEIGHT,
             T.PONDER_GROSS_WT = V_INPUT_WEIGHT,
             t.ponder_no       = V_result_no,
             T.PIPMEMO         = '已称重'
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.BATCH_NO = '#BATCH_NO#'
         AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
         AND T.MAT_NO = MYROW.MAT_NO;
    END IF;
  END LOOP;

  FOR MYROW2 IN (SELECT T.*
                   FROM MAT_zC_M T, ydm_bc_outlist t1
                  WHERE T.JUDGE_STOVE_NO = t1.judge_stove_no
                    and t.mat_no = t1.mat_no
                    AND T1.Outstock_Doc = '#OUTSTOCK_DOC#'
                    and t1.judge_stove_no = '#JUDGE_STOVE_NO#'
                    AND T1.BATCH_NO = '#BATCH_NO#'
                    AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#') LOOP
  
    UPDATE YDM_BC_OUTLIST T
       SET T.PONDER_GROSS_WT = MYROW2.Act_Weight, t.ponder_no = V_result_no
     WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
       AND T.MAT_NO = MYROW2.Mat_No;
    UPDATE YDM_BC_INLIST T
       SET T.PONDER_GROSS_WT = MYROW2.Act_Weight, T.PIPMEMO = '已称重'
     WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
       AND T.MAT_NO = MYROW2.Mat_No;
  
    FOR MYROW3 IN (SELECT T.*
                     FROM ydm_zc_inlist T
                    WHERE t.judge_stove_no = '#JUDGE_STOVE_NO#'
                      AND T.BATCH_NO = '#BATCH_NO#'
                      AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                      AND T.Mat_No = MYROW2.Mat_No) LOOP
    
      INSERT INTO YDM_ZC_INLIST
        (INSTOCK_SQE,
         INSTOCK_DOC,
         INSTOCK_TYPE_CODE,
         INSTOCK_TYPE_NAME,
         INSTOCK_BAR_CODE,
         ICCAR_NO,
         VEHICLE_NO,
         MAT_NO,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         MATERIAL_NO,
         MATERIAL_NAME,
         PRODUCCODE,
         PRODUCNAME,
         STD_CODE,
         STD_NAME,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         STD_STYLE,
         STD_STYLE_DESC,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         PRO_ORDER_NO,
         PLINE_CODE,
         PLINE_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         BELONG_CODE,
         BELONG_NAME,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         RPO_TIME,
         PRO_BC,
         PRO_BZ,
         INSTOCK_TIME,
         IN_BC,
         IN_BZ,
         BAR_CODE,
         HAND_FLAG,
         MEMO,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         ZB_RCDID,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         IN_TIME_F,
         BAL_YEAR_MONTH,
         LEN_NO,
         LEN_DESC,
         LEN_UNIT,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         AFFIRM_LOG,
         M_BILL_NO,
         ZG_STOVE_SQE,
         FINISHPRO_MOLD,
         IN_MOLD,
         PACK_NO,
         QCM_STAUS,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         SUBCONTRACT_NO,
         JUGDE_APPLY_CODE,
         SUPPLY_UNIT_CODE,
         SUPPLY_UNIT,
         IS_DEALER,
         PROCESS_CDOE,
         PROCESS_DESC,
         IS_ALL_SCRAP)
      VALUES
        (V_instock_doc_AI || LPAD(V_ICOUNT, 4, 0),
         V_instock_doc_AI,
         '800704',
         '产出红冲',
         MYROW3.INSTOCK_BAR_CODE,
         MYROW3.ICCAR_NO,
         MYROW3.VEHICLE_NO,
         MYROW3.MAT_NO,
         MYROW3.LOT_NO,
         MYROW3.STOVE_NO,
         MYROW3.JUDGE_STOVE_NO,
         MYROW3.BATCH_NO,
         MYROW3.BATCH_GROUD_NO,
         MYROW3.MATERIAL_NO,
         MYROW3.MATERIAL_NAME,
         MYROW3.PRODUCCODE,
         MYROW3.PRODUCNAME,
         MYROW3.STD_CODE,
         MYROW3.STD_NAME,
         MYROW3.GRADECODE,
         MYROW3.GRADENAME,
         MYROW3.STEELCODE,
         MYROW3.STEELNAME,
         MYROW3.STD_STYLE,
         MYROW3.STD_STYLE_DESC,
         MYROW3.SPEC_CODE,
         MYROW3.SPEC_NAME,
         MYROW3.MODEL_CODE,
         MYROW3.MODEL_DESC,
         MYROW3.PRO_ORDER_NO,
         MYROW3.PLINE_CODE,
         MYROW3.PLINE_NAME,
         MYROW3.ACT_DIMATER,
         MYROW3.ACT_HEIGHT,
         -MYROW3.ACT_LEN,
         MYROW3.ACT_LEN_MIN,
         MYROW3.ACT_LEN_MAX,
         -MYROW3.ACT_COUNT,
         -MYROW3.ACT_WEIGHT,
         MYROW3.ACT_THEORY_WEIGHT,
         MYROW3.BELONG_CODE,
         MYROW3.BELONG_NAME,
         MYROW3.STORAGE_NO,
         MYROW3.LOCATION_NO,
         MYROW3.LARY_NO,
         MYROW3.LOC_NO,
         MYROW3.STORAGE_ATTR,
         MYROW3.STORAGE_ATTR_NAME,
         MYROW3.STORAGE_TYPE_NO,
         MYROW3.STORAGE_TYPE_NAME,
         MYROW3.MANAGEMENT_NO,
         MYROW3.MANAGEMENT_NAME,
         SYSDATE,
         MYROW3.PRO_BC,
         MYROW3.PRO_BZ,
         SYSDATE,
         MYROW3.IN_BC,
         MYROW3.IN_BZ,
         MYROW3.BAR_CODE,
         MYROW3.HAND_FLAG,
         '过磅',
         MYROW3.VALIDFLAG,
         MYROW3.CREATE_NAME,
         SYSDATE,
         MYROW3.UPDATE_NAME,
         SYSDATE,
         MYROW3.DELETE_NAME,
         SYSDATE,
         MYROW3.ORD_PK,
         MYROW3.ORD_LN_PK,
         MYROW3.ORD_LN_DLY_PK,
         MYROW3.DEPARTMENT_CODE,
         MYROW3.DEPARTMENT_DESC,
         MYROW3.ORDER_NO,
         MYROW3.ORDER_SEQ,
         MYROW3.DELIVERY_NO,
         MYROW3.PRODUCT_FLAG,
         MYROW3.MAT_STATUS,
         MYROW3.ZB_RCDID,
         MYROW3.JUDGE_STD_NAME,
         MYROW3.JUDGE_STD_CODE,
         SYSDATE,
         --MYROW3.BAL_YEAR_MONTH,
         '#BAL_YEAR_MONTH#',
         MYROW3.LEN_NO,
         MYROW3.LEN_DESC,
         MYROW3.LEN_UNIT,
         MYROW3.PIPMEMO,
         MYROW3.SOURE_CODE,
         MYROW3.SOURE_NAME,
         MYROW3.MAT_ORIGIN_CODE,
         MYROW3.MAT_ORIGIN_NAME,
         MYROW3.AFFIRM_LOG,
         MYROW3.M_BILL_NO,
         MYROW3.ZG_STOVE_SQE,
         MYROW3.FINISHPRO_MOLD,
         MYROW3.IN_MOLD,
         MYROW3.PACK_NO,
         MYROW3.QCM_STAUS,
         MYROW3.PRO_PLAN_ID,
         MYROW3.GX_PLAN_NO,
         MYROW3.SUBCONTRACT_NO,
         MYROW3.JUGDE_APPLY_CODE,
         MYROW3.SUPPLY_UNIT_CODE,
         MYROW3.SUPPLY_UNIT,
         MYROW3.IS_DEALER,
         MYROW3.PROCESS_CDOE,
         MYROW3.PROCESS_DESC,
         MYROW3.IS_ALL_SCRAP);
    
      INSERT INTO YDM_ZC_INLIST
        (INSTOCK_SQE,
         INSTOCK_DOC,
         INSTOCK_TYPE_CODE,
         INSTOCK_TYPE_NAME,
         INSTOCK_BAR_CODE,
         ICCAR_NO,
         VEHICLE_NO,
         MAT_NO,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         MATERIAL_NO,
         MATERIAL_NAME,
         PRODUCCODE,
         PRODUCNAME,
         STD_CODE,
         STD_NAME,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         STD_STYLE,
         STD_STYLE_DESC,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         PRO_ORDER_NO,
         PLINE_CODE,
         PLINE_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         BELONG_CODE,
         BELONG_NAME,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         RPO_TIME,
         PRO_BC,
         PRO_BZ,
         INSTOCK_TIME,
         IN_BC,
         IN_BZ,
         BAR_CODE,
         HAND_FLAG,
         MEMO,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         ZB_RCDID,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         IN_TIME_F,
         BAL_YEAR_MONTH,
         LEN_NO,
         LEN_DESC,
         LEN_UNIT,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         AFFIRM_LOG,
         M_BILL_NO,
         ZG_STOVE_SQE,
         FINISHPRO_MOLD,
         IN_MOLD,
         PACK_NO,
         QCM_STAUS,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         SUBCONTRACT_NO,
         JUGDE_APPLY_CODE,
         SUPPLY_UNIT_CODE,
         SUPPLY_UNIT,
         IS_DEALER,
         PROCESS_CDOE,
         PROCESS_DESC,
         IS_ALL_SCRAP)
      VALUES
        (V_instock_doc_IA || LPAD(V_ICOUNT, 4, 0),
         V_instock_doc_IA,
         '800701',
         '产出入库',
         MYROW3.INSTOCK_BAR_CODE,
         MYROW3.ICCAR_NO,
         MYROW3.VEHICLE_NO,
         MYROW3.MAT_NO,
         MYROW3.LOT_NO,
         MYROW3.STOVE_NO,
         MYROW3.JUDGE_STOVE_NO,
         MYROW3.BATCH_NO,
         MYROW3.BATCH_GROUD_NO,
         MYROW3.MATERIAL_NO,
         MYROW3.MATERIAL_NAME,
         MYROW3.PRODUCCODE,
         MYROW3.PRODUCNAME,
         MYROW3.STD_CODE,
         MYROW3.STD_NAME,
         MYROW3.GRADECODE,
         MYROW3.GRADENAME,
         MYROW3.STEELCODE,
         MYROW3.STEELNAME,
         MYROW3.STD_STYLE,
         MYROW3.STD_STYLE_DESC,
         MYROW3.SPEC_CODE,
         MYROW3.SPEC_NAME,
         MYROW3.MODEL_CODE,
         MYROW3.MODEL_DESC,
         MYROW3.PRO_ORDER_NO,
         MYROW3.PLINE_CODE,
         MYROW3.PLINE_NAME,
         MYROW3.ACT_DIMATER,
         MYROW3.ACT_HEIGHT,
         MYROW3.ACT_LEN,
         MYROW3.ACT_LEN_MIN,
         MYROW3.ACT_LEN_MAX,
         MYROW3.ACT_COUNT,
         MYROW2.ACT_WEIGHT,
         MYROW3.ACT_THEORY_WEIGHT,
         MYROW3.BELONG_CODE,
         MYROW3.BELONG_NAME,
         MYROW3.STORAGE_NO,
         MYROW3.LOCATION_NO,
         MYROW3.LARY_NO,
         MYROW3.LOC_NO,
         MYROW3.STORAGE_ATTR,
         MYROW3.STORAGE_ATTR_NAME,
         MYROW3.STORAGE_TYPE_NO,
         MYROW3.STORAGE_TYPE_NAME,
         MYROW3.MANAGEMENT_NO,
         MYROW3.MANAGEMENT_NAME,
         SYSDATE,
         MYROW3.PRO_BC,
         MYROW3.PRO_BZ,
         SYSDATE,
         MYROW3.IN_BC,
         MYROW3.IN_BZ,
         MYROW3.BAR_CODE,
         MYROW3.HAND_FLAG,
         '过磅',
         MYROW3.VALIDFLAG,
         MYROW3.CREATE_NAME,
         SYSDATE,
         MYROW3.UPDATE_NAME,
         SYSDATE,
         MYROW3.DELETE_NAME,
         SYSDATE,
         MYROW3.ORD_PK,
         MYROW3.ORD_LN_PK,
         MYROW3.ORD_LN_DLY_PK,
         MYROW3.DEPARTMENT_CODE,
         MYROW3.DEPARTMENT_DESC,
         MYROW3.ORDER_NO,
         MYROW3.ORDER_SEQ,
         MYROW3.DELIVERY_NO,
         MYROW3.PRODUCT_FLAG,
         MYROW3.MAT_STATUS,
         MYROW3.ZB_RCDID,
         MYROW3.JUDGE_STD_NAME,
         MYROW3.JUDGE_STD_CODE,
         SYSDATE,
         --MYROW3.BAL_YEAR_MONTH,
         '#BAL_YEAR_MONTH#',
         MYROW3.LEN_NO,
         MYROW3.LEN_DESC,
         MYROW3.LEN_UNIT,
         MYROW3.PIPMEMO,
         MYROW3.SOURE_CODE,
         MYROW3.SOURE_NAME,
         MYROW3.MAT_ORIGIN_CODE,
         MYROW3.MAT_ORIGIN_NAME,
         MYROW3.AFFIRM_LOG,
         MYROW3.M_BILL_NO,
         MYROW3.ZG_STOVE_SQE,
         MYROW3.FINISHPRO_MOLD,
         MYROW3.IN_MOLD,
         MYROW3.PACK_NO,
         MYROW3.QCM_STAUS,
         MYROW3.PRO_PLAN_ID,
         MYROW3.GX_PLAN_NO,
         MYROW3.SUBCONTRACT_NO,
         MYROW3.JUGDE_APPLY_CODE,
         MYROW3.SUPPLY_UNIT_CODE,
         MYROW3.SUPPLY_UNIT,
         MYROW3.IS_DEALER,
         MYROW3.PROCESS_CDOE,
         MYROW3.PROCESS_DESC,
         MYROW3.IS_ALL_SCRAP);
    
      --CRM
      insert into crm_zc_inlist
        (instock_sqe,
         instock_doc,
         order_no,
         order_seq,
         delivery_no,
         ord_pk,
         ord_ln_pk,
         ord_ln_dly_pk,
         product_flag,
         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_len,
         act_len_min,
         act_len_max,
         act_count,
         act_weight,
         storage_no,
         in_mold,
         pack_no,
         instock_time,
         data_status,
         --is_flag,
         -- synchro_time,
         mat_no,
         storage_name,
         create_time,
         --initial_id,
         --problem_msg,
         supply_unit_code,
         supply_unit,
         bal_year_month,
         act_dimater,
         act_height,
         belong_code,
         belong_name,
         INSTOCK_TYPE_CODE,
         INSTOCK_TYPE_NAME)
      values
        (V_instock_doc_AI || LPAD(V_ICOUNT, 4, 0),
         V_instock_doc_AI,
         MYROW3.order_no,
         MYROW3.order_seq,
         MYROW3.delivery_no,
         MYROW3.ord_pk,
         MYROW3.ord_ln_pk,
         MYROW3.ord_ln_dly_pk,
         MYROW3.product_flag,
         MYROW3.judge_stove_no,
         MYROW3.batch_no,
         MYROW3.batch_groud_no,
         MYROW3.material_no,
         MYROW3.material_name,
         MYROW3.produccode,
         MYROW3.producname,
         MYROW3.std_code,
         MYROW3.std_name,
         MYROW3.gradecode,
         MYROW3.gradename,
         MYROW3.steelcode,
         MYROW3.steelname,
         MYROW3.std_style,
         MYROW3.std_style_desc,
         MYROW3.spec_code,
         MYROW3.spec_name,
         MYROW3.model_code,
         MYROW3.model_desc,
         MYROW3.pline_code,
         MYROW3.pline_name,
         -MYROW3.act_len,
         MYROW3.act_len_min,
         MYROW3.act_len_max,
         -MYROW3.act_count,
         -MYROW3.act_weight,
         MYROW3.storage_no,
         MYROW3.in_mold,
         MYROW3.pack_no,
         sysdate,
         '0',
         --MYROW3.is_flag,
         --MYROW3.synchro_time,
         MYROW3.mat_no,
         MYROW3.SOURE_NAME,
         sysdate,
         -- MYROW3.initial_id,
         --MYROW3.problem_msg,
         MYROW3.supply_unit_code,
         MYROW3.supply_unit,
         '#BAL_YEAR_MONTH#',
         MYROW3.act_dimater,
         MYROW3.act_height,
         MYROW3.belong_code,
         MYROW3.belong_name,
         '800704',
         '产出红冲');
    
      insert into crm_zc_inlist
        (instock_sqe,
         instock_doc,
         order_no,
         order_seq,
         delivery_no,
         ord_pk,
         ord_ln_pk,
         ord_ln_dly_pk,
         product_flag,
         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_len,
         act_len_min,
         act_len_max,
         act_count,
         act_weight,
         storage_no,
         in_mold,
         pack_no,
         instock_time,
         data_status,
         --is_flag,
         -- synchro_time,
         mat_no,
         storage_name,
         create_time,
         --initial_id,
         --problem_msg,
         supply_unit_code,
         supply_unit,
         bal_year_month,
         act_dimater,
         act_height,
         belong_code,
         belong_name,
         INSTOCK_TYPE_CODE,
         INSTOCK_TYPE_NAME)
      values
        (V_instock_doc_IA || LPAD(V_ICOUNT, 4, 0),
         V_instock_doc_IA,
         MYROW3.order_no,
         MYROW3.order_seq,
         MYROW3.delivery_no,
         MYROW3.ord_pk,
         MYROW3.ord_ln_pk,
         MYROW3.ord_ln_dly_pk,
         MYROW3.product_flag,
         MYROW3.judge_stove_no,
         MYROW3.batch_no,
         MYROW3.batch_groud_no,
         MYROW3.material_no,
         MYROW3.material_name,
         MYROW3.produccode,
         MYROW3.producname,
         MYROW3.std_code,
         MYROW3.std_name,
         MYROW3.gradecode,
         MYROW3.gradename,
         MYROW3.steelcode,
         MYROW3.steelname,
         MYROW3.std_style,
         MYROW3.std_style_desc,
         MYROW3.spec_code,
         MYROW3.spec_name,
         MYROW3.model_code,
         MYROW3.model_desc,
         MYROW3.pline_code,
         MYROW3.pline_name,
         MYROW3.act_len,
         MYROW3.act_len_min,
         MYROW3.act_len_max,
         MYROW3.act_count,
         MYROW2.act_weight,
         MYROW3.storage_no,
         MYROW3.in_mold,
         MYROW3.pack_no,
         sysdate,
         '0',
         --MYROW3.is_flag,
         --MYROW3.synchro_time,
         MYROW3.mat_no,
         MYROW3.SOURE_NAME,
         sysdate,
         -- MYROW3.initial_id,
         --MYROW3.problem_msg,
         MYROW3.supply_unit_code,
         MYROW3.supply_unit,
         '#BAL_YEAR_MONTH#',
         MYROW3.act_dimater,
         MYROW3.act_height,
         MYROW3.belong_code,
         MYROW3.belong_name,
         '800701',
         '产出入库');
    
      V_ICOUNT := V_ICOUNT + 1;
    END LOOP;
  END LOOP;
END;

        ]]>
    </query>
    <query id = "FrmFilpInStorage.updatePossWtBcTH" desc = "获取过磅重量（天淮）">
        <![CDATA[
      DECLARE
  V_result_no      cmm_weight_mat.result_no%TYPE := ?;
  V_INPUT_WEIGHT   PORT_MIL_BATCH_SAMPLE_RESULT.INPUT_WEIGHT%TYPE := NULL; --平均值
  V_INPUT_WEIGHT1  PORT_MIL_BATCH_SAMPLE_RESULT.INPUT_WEIGHT%TYPE := NULL; --余数
  V_instock_doc_AI ydm_zc_inlist.instock_doc%TYPE := NULL;
  V_instock_doc_IA ydm_zc_inlist.instock_doc%TYPE := NULL;
  V_ICOUNT         NUMBER := 1;
  V_ACT_WEIGHT     PORT_MIL_BATCH_SAMPLE_RESULT.INPUT_WEIGHT%TYPE := '#ACT_WEIGHT#';
  V_ACT_COUNT      PORT_MIL_BATCH_SAMPLE_RESULT.ACT_COUNT%TYPE := '#ACT_COUNT#';

BEGIN

  SELECT TRUNC(V_ACT_WEIGHT / V_ACT_COUNT, 3)
    INTO V_INPUT_WEIGHT
    FROM DUAL;
  SELECT V_ACT_WEIGHT - V_ACT_COUNT * V_INPUT_WEIGHT
    INTO V_INPUT_WEIGHT1
    FROM DUAL;

  FOR MYROW IN (SELECT T.*
                  FROM MAT_bC_M T, ydm_bc_outlist t1
                 WHERE T.JUDGE_STOVE_NO = t1.judge_stove_no
                   and t.mat_no = t1.mat_no
                   AND T.TARGET = 'A'
                   AND T1.Outstock_Doc = '#OUTSTOCK_DOC#'
                   and t1.judge_stove_no = '#JUDGE_STOVE_NO#'
                   AND T1.BATCH_NO = '#BATCH_NO#'
                   AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#') LOOP
  
    IF (V_INPUT_WEIGHT1 >= 0.001) THEN
      V_INPUT_WEIGHT1 := V_INPUT_WEIGHT1 - 0.001;
      UPDATE MAT_bC_M T
         SET T.ACT_WEIGHT      = V_INPUT_WEIGHT + 0.001,
             T.PONDER_GROSS_WT = V_INPUT_WEIGHT + 0.001,
             t.ponder_no       = V_result_no,
             T.PIPMEMO         = '已称重'
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.BATCH_NO = '#BATCH_NO#'
         AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
         AND T.TARGET = 'A'
         AND T.MAT_NO = MYROW.MAT_NO;
    ELSE
      UPDATE MAT_bC_M T
         SET T.ACT_WEIGHT      = V_INPUT_WEIGHT,
             T.PONDER_GROSS_WT = V_INPUT_WEIGHT,
             t.ponder_no       = V_result_no,
             T.PIPMEMO         = '已称重'
       WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
         AND T.BATCH_NO = '#BATCH_NO#'
         AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
         AND T.TARGET = 'A'
         AND T.MAT_NO = MYROW.MAT_NO;
    END IF;
  END LOOP;

  FOR MYROW2 IN (SELECT T.*
                   FROM MAT_bC_M T, ydm_bc_outlist t1
                  WHERE T.JUDGE_STOVE_NO = t1.judge_stove_no
                    and t.mat_no = t1.mat_no
                    AND T.TARGET = 'A'
                    AND T1.Outstock_Doc = '#OUTSTOCK_DOC#'
                    and t1.judge_stove_no = '#JUDGE_STOVE_NO#'
                    AND T1.BATCH_NO = '#BATCH_NO#'
                    AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#') LOOP
  
    UPDATE YDM_BC_OUTLIST T
       SET T.PONDER_GROSS_WT = MYROW2.Act_Weight, t.ponder_no = V_result_no
     WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
       AND T.MAT_NO = MYROW2.Mat_No;
    UPDATE YDM_BC_INLIST T
       SET T.PONDER_GROSS_WT = MYROW2.Act_Weight, T.PIPMEMO = '已称重'
     WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#'
       AND T.MAT_NO = MYROW2.Mat_No;
  
  END LOOP;
END;
        ]]>
    </query>
</queryMap>