<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "手工判定">

<query id = "FrmHandleJuge.doQueryApplyJudge" desc = "查询炉信息">
SELECT 
       T.JUGDE_APPLY_CODE,
       T.JUDGE_STOVE_NO,
       T.PROCESS_CODE,
       T.PLINE_CODE,
       SUM(T.ACT_COUNT)ACT_COUNT,
       SUM(T.ACT_WEIGHT)ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT)ACT_THEORY_WEIGHT,
       MAX(T.PRO_ORDER_ID)PRO_ORDER_ID,
       MAX(DECODE(T.VALIDFLAG,'00','待判','20','已判','正在处理'))VALIDFLAG,
       MAX(T.APPLY_NAME)APPLY_NAME,
       MAX(TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS')) APPLY_TIME,
       MAX(T.MEMO)MEMO,
       MAX(T.MATERIAL_NO)MATERIAL_NO,
       MAX(T.MATERIAL_NAME)MATERIAL_NAME,
       MAX(T.PRODUCCODE)PRODUCCODE,
       MAX(T.PRODUCNAME)PRODUCNAME,
       MAX(T.STEELCODE)STEELCODE,
       MAX(T.STEELNAME)STEELNAME,
       MAX(T.GRADECODE)GRADECODE,
       MAX(T.GRADENAME)GRADENAME,
       MAX(T.SPEC_CODE)SPEC_CODE,
       MAX(T.SPEC_NAME)SPEC_NAME,
       MAX(T.MODEL_CODE)MODEL_CODE,
       MAX(T.MODEL_DESC)MODEL_DESC,
       MAX(T.STD_CODE)STD_CODE,
       MAX(T.STD_NAME)STD_NAME,
       MAX(T.STD_STYLE)STD_STYLE,
       MAX(T.STD_STYLE_DESC)STD_STYLE_DESC,
       MAX(T.CRAF_NO)CRAF_NO,
       T.LOT_NO,
       T.PLINE_NAME,
       T.PRO_ORDER_NO,
       MAX(T.TARGET)TARGET,
       MAX(T.PROCESS_STATUS)PROCESS_STATUS,
       MAX(T.ACT_DIMATER)ACT_DIMATER,
       MAX(T.ACT_HEIGHT)ACT_HEIGHT,
       MAX(T.ACT_LEN_MIN)ACT_LEN_MIN,
       MAX(T.ACT_LEN_MAX)ACT_LEN_MAX,
       MAX(T.JUDGE_RESULT_CODE)JUDGE_RESULT_CODE,
       MAX(T.JUDGE_RESULT)JUDGE_RESULT,
       MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
       MAX(T.JUDGE_MAKER)JUDGE_MAKER,
       MAX(T.TESTING_GRADE)TESTING_GRADE,
       MAX(T.TESTING_TYPE)TESTING_TYPE,
       MAX(T.TESTING_GRADE1)TESTING_GRADE1,
       MAX(T.TESTING_TYPE1)TESTING_TYPE1,
       MAX(T.DETECT_RESULT_CODE1)DETECT_RESULT_CODE1,
       MAX(T.DETECT_RESULT_PATH1)DETECT_RESULT_PATH1,
       MAX(T.ORD_LN_DLY_PK)ORD_LN_DLY_PK,
       MAX(T.APPLY_FLAG)APPLY_FLAG,
       MAX(T.BACK_JUGDE_MEMO)BACK_JUGDE_MEMO,
       MAX(T.BELONG_CODE)BELONG_CODE,
       MAX(T.BELONG_NAME)BELONG_NAME,
       MAX(DECODE(T.INSTOCK_FLAG,'0','未确认','1','已确认'))INSTOCK_FLAG,
       MAX(T.NEXT_PROCESS_CDOE)NEXT_PROCESS_CDOE,
       MAX(T.BELONG_CODE_JUGDE)BELONG_CODE_JUGDE,
       MAX(T.BELONG_NAME_JUGDE)BELONG_NAME_JUGDE,
       MAX(T.BAL_YEAR_MONTH)BAL_YEAR_MONTH,
       MAX(F.MAT_ACT_COUNT)MAT_ACT_COUNT
 FROM QCM_ZG_JUGDE_APPLY T
 LEFT JOIN (SELECT SUM(T1.ACT_COUNT)MAT_ACT_COUNT, T1.JUDGE_STOVE_NO, T1.PROCESS_CDOE
               FROM MAT_BC_M T1, YDM_BC_BUTTRESS S
              WHERE T1.MAT_NO = S.MAT_NO
               GROUP BY T1.JUDGE_STOVE_NO, T1.PROCESS_CDOE)F
               ON T.JUDGE_STOVE_NO = F.JUDGE_STOVE_NO
               AND NVL(T.PROCESS_CODE,'/') = NVL(F.PROCESS_CDOE,'/')
 WHERE 1=1
 --AND T.BELONG_CODE_JUGDE = '002001001'
 AND T.IS_FLAG = '0'
 AND T.IS_ALL_SCRAP = '0'
 AND (T.VALIDFLAG = '20' OR T.VALIDFLAG = '00' AND T.PLINE_CODE IN('C065','C066'))
 AND T.TARGET IN('B','C')
 AND (T.BAL_YEAR_MONTH > '201802' OR T.BAL_YEAR_MONTH IS NULL)
 AND (T.JUDGE_RESULT_CODE IS NULL OR T.JUDGE_RESULT_CODE IN('40740701','40740706'))
</query>
<query id = "FrmHandleJuge.doQueryApplyData" desc = "查询炉批信息">
 SELECT 
       T.JUGDE_APPLY_CODE,
       T.JUGDE_APPLY_SEQUENO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       MAX(T.PROCESS_CODE)PROCESS_CODE,
       MAX(T.PLINE_CODE)PLINE_CODE,
       SUM(T.ACT_COUNT)ACT_COUNT,
       SUM(T.ACT_WEIGHT)ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT)ACT_THEORY_WEIGHT,
       MAX(T.PRO_ORDER_ID)PRO_ORDER_ID,
       MAX(T.FACE_RESULT_CODE)FACE_RESULT_CODE,
       MAX(T.SPEC_RESULT_CODE)SPEC_RESULT_CODE,
       MAX(T.CHEM_RESULT_CODE)CHEM_RESULT_CODE,
       MAX(T.PHY_RESULT_CODE)PHY_RESULT_CODE,
       MAX(T.DETECT_RESULT_CODE)DETECT_RESULT_CODE,
       MAX(T.WPRESSURE_RESULT_CODE)WPRESSURE_RESULT_CODE,
       MAX(T.PROCESS_RESULT_CODE)PROCESS_RESULT_CODE,
       MAX(T.FACE_RESULT_PATH)FACE_RESULT_PATH,
       MAX(T.SPEC_RESULT_PATH)SPEC_RESULT_PATH,
       MAX(T.CHEM_RESULT_PATH)CHEM_RESULT_PATH,
       MAX(T.PHY_RESULT_PATH)PHY_RESULT_PATH,
       MAX(T.DETECT_RESULT_PATH)DETECT_RESULT_PATH,
       MAX(T.WPRESSURE_RESULT_PATH)WPRESSURE_RESULT_PATH,
       MAX(T.PROCESS_RESULT_PATH)PROCESS_RESULT_PATH,
       MAX(DECODE(T.VALIDFLAG,'00','待判','20','已判','正在处理'))VALIDFLAG,
       MAX(T.APPLY_NAME)APPLY_NAME,
       MAX(TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS')) APPLY_TIME,
       MAX(T.MEMO)MEMO,
       MAX(T.QUALITY_GROUP)QUALITY_GROUP,
       MAX(T.MATERIAL_NO)MATERIAL_NO,
       MAX(T.MATERIAL_NAME)MATERIAL_NAME,
       MAX(T.PRODUCCODE)PRODUCCODE,
       MAX(T.PRODUCNAME)PRODUCNAME,
       MAX(T.STEELCODE)STEELCODE,
       MAX(T.STEELNAME)STEELNAME,
       MAX(T.GRADECODE)GRADECODE,
       MAX(T.GRADENAME)GRADENAME,
       MAX(T.SPEC_CODE)SPEC_CODE,
       MAX(T.SPEC_NAME)SPEC_NAME,
       MAX(T.MODEL_CODE)MODEL_CODE,
       MAX(T.MODEL_DESC)MODEL_DESC,
       MAX(T.STD_CODE)STD_CODE,
       MAX(T.STD_NAME)STD_NAME,
       MAX(T.STD_STYLE)STD_STYLE,
       MAX(T.STD_STYLE_DESC)STD_STYLE_DESC,
       MAX(T.CRAF_NO)CRAF_NO,
       MAX(T.LOT_NO)LOT_NO,
       MAX(T.PLINE_NAME)PLINE_NAME,
       MAX(T.PRO_ORDER_NO)PRO_ORDER_NO,
       MAX(T.TARGET)TARGET,
       MAX(T.PROCESS_STATUS)PROCESS_STATUS,
       MAX(T.MAT_GOWHERE_CODE)MAT_GOWHERE_CODE,
       MAX(T.MAT_GOWHERE_NAME)MAT_GOWHERE_NAME,
       MAX(T.ACT_DIMATER)ACT_DIMATER,
       MAX(T.ACT_HEIGHT)ACT_HEIGHT,
       MAX(T.ACT_LEN_MIN)ACT_LEN_MIN,
       MAX(T.ACT_LEN_MAX)ACT_LEN_MAX,
       MAX(T.JUDGE_RESULT_CODE)JUDGE_RESULT_CODE,
       MAX(T.JUDGE_RESULT)JUDGE_RESULT,
       MAX(TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) JUDGE_RESULT_TIME,
       MAX(T.JUDGE_MAKER)JUDGE_MAKER,
       MAX(T.IF_SET_ZY_PLAN)IF_SET_ZY_PLAN,
       MAX(T.TESTING_GRADE)TESTING_GRADE,
       MAX(T.TESTING_TYPE)TESTING_TYPE,
       MAX(T.TESTING_GRADE1)TESTING_GRADE1,
       MAX(T.TESTING_TYPE1)TESTING_TYPE1,
       MAX(T.DETECT_RESULT_CODE1)DETECT_RESULT_CODE1,
       MAX(T.DETECT_RESULT_PATH1)DETECT_RESULT_PATH1,
       MAX(T.ORD_LN_DLY_PK)ORD_LN_DLY_PK,
       MAX(T.APPLY_FLAG)APPLY_FLAG,
       MAX(T.BACK_JUGDE_MEMO)BACK_JUGDE_MEMO,
       MAX(T.BELONG_CODE)BELONG_CODE,
       MAX(T.BELONG_NAME)BELONG_NAME,
       MAX(DECODE(T.INSTOCK_FLAG,'0','未确认','1','已确认'))INSTOCK_FLAG,
       MAX(T.BELONG_NAME_JUGDE)BELONG_NAME_JUGDE,
       MAX(T.BELONG_CODE_JUGDE)BELONG_CODE_JUGDE
       --T.PRO_PLAN_ID_NEXT,
       --T.GX_PLAN_NO_NEXT
 FROM QCM_ZG_JUGDE_APPLY T
 WHERE 1=1
 AND T.JUGDE_APPLY_CODE = ?
 AND T.JUDGE_STOVE_NO = ?
 GROUP BY T.JUGDE_APPLY_CODE,
       T.JUGDE_APPLY_SEQUENO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO
</query>
<query id = "doHandleApply.SelectApplyData" desc = "查询申判信息是否已判">
<![CDATA[
SELECT COUNT(1)ACOUNT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.VALIDFLAG <> '#VALIDFLAG#'
   ]]>
</query>
<query id = "doHandleApply.SelectBathYear" desc = "查询申判信息是否已判">
<![CDATA[
SELECT MAX(T.VALIDFLAG)VALIDFLAG, MAX(T.BAL_YEAR_MONTH)BAL_YEAR_MONTH
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
   AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#'
   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.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
   --AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/')
   ]]>
</query>
<query id = "doHandleApply.SelectComfirmApplyData" desc = "查询判定信息是否已确认">
SELECT COUNT(1)ACOUNT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.PROCESS_CODE = '#PROCESS_CODE#'
   AND T.INSTOCK_FLAG = '1'
</query>
<query id = "FrmHandleJuge.doHandleApply" desc = "手工判定">
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_M T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                   AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
                   AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#'
                   --AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
                   --AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/')
                   AND T.BELONG_CODE = '#BELONG_CODE#'
                 ORDER BY T.MAT_NO ASC) LOOP
    UPDATE MAT_BC_M T
       SET T.JUDGE_RESULT_CODE = '#JUDGE_RESULT_CODE#',
           T.JUDGE_RESULT      = '#JUDGE_RESULT#',
           T.JUDGE_RESULT_TIME = SYSDATE,
           T.JUDGE_MAKER = '#JUDGE_MAKER#',
           T.MAT_STATUS        = '80150102',
           T.JUGDE_APPLY_FLAG  = '1',
           T.BELONG_CODE       = '#BELONG_CODE_JUGDE#',
           T.BELONG_NAME       = '#BELONG_NAME_JUGDE#'
     WHERE T.MAT_NO = MYROW.MAT_NO
     AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#';
  END LOOP;
  UPDATE QCM_ZG_JUGDE_APPLY T
     SET T.VALIDFLAG         = '20',
         T.JUDGE_RESULT_CODE = '#JUDGE_RESULT_CODE#',
         T.JUDGE_RESULT      = '#JUDGE_RESULT#',
         T.JUDGE_RESULT_TIME = SYSDATE,
         T.JUDGE_MAKER = '#JUDGE_MAKER#',
         T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
   WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.BATCH_NO = '#BATCH_NO#'
     AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
     AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
     AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#';
     --AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
     --AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/');
END;
</query>
<query id = "FrmHandleJuge.doCancelHandleApply" desc = "撤销判定">
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_M T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                   AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
                   AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#'
                   --AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
                   --AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/')
                 ORDER BY T.MAT_NO ASC) LOOP
    UPDATE MAT_BC_M T
       SET T.JUDGE_RESULT_CODE = '',
           T.JUDGE_RESULT      = '',
           T.JUDGE_RESULT_TIME = '',
           T.JUDGE_MAKER = '',
           T.MAT_STATUS        = '80150101',
           T.JUGDE_APPLY_FLAG = '0'
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#';
  END LOOP;
  UPDATE QCM_ZG_JUGDE_APPLY T
     SET T.VALIDFLAG         = '00',
         T.JUDGE_RESULT_CODE = '',
         T.JUDGE_RESULT      = '',
         T.JUDGE_RESULT_TIME = '',
         T.JUDGE_MAKER = ''
   WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.BATCH_NO = '#BATCH_NO#'
     AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
     AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
     AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#';
     --AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
     --AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/');
END;
</query>
<query id = "FrmHandleJuge.doComfirm" desc = "确认缴库">
DECLARE
  v_inListDoc YDM_BC_INLIST.INSTOCK_DOC%TYPE := NULL;
  v_inListDocSeq YDM_BC_INLIST.INSTOCK_SQE%TYPE := NULL;
  vCount         NUMBER := 1;
BEGIN
  SELECT NVL(MAX(SUBSTR(T.INSTOCK_SQE, LENGTH(T.INSTOCK_SQE) - 3)), 0) + 1
    INTO vCount
    FROM YDM_BC_INLIST T
   WHERE TRUNC(T.CREATE_TIME) = TRUNC(SYSDATE)
     AND T.INSTOCK_DOC = '#INSTOCK_DOC#';
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_M T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                   AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
                   AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#'
                   AND T.BELONG_CODE = '002001001'
                   --AND NVL(T.PRO_PLAN_ID_NEXT,'/') = NVL('#PRO_PLAN_ID_NEXT#','/')
                   --AND NVL(T.GX_PLAN_NO_NEXT,'/') = NVL('#GX_PLAN_NO_NEXT#','/')
                   AND T.PROCESS_CDOE = '#PROCESS_CODE#'
                 ORDER BY T.MAT_NO ASC) LOOP
    v_inListDocSeq := '#INSTOCK_DOC#' || LPAD(vCount, 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,

         CREATE_NAME,
         INSTOCK_TIME,
         CREATE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         IN_TIME_F,
         AFFIRM_LOG,
         QCM_STAUS,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         BAL_YEAR_MONTH
         )
      VALUES
        (v_inListDocSeq,
         '#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,
         (CASE WHEN MYROW.PONDER_GROSS_WT IS NULL THEN
         MYROW.ACT_WEIGHT
         ELSE
         MYROW.PONDER_GROSS_WT
         END),
         (CASE WHEN MYROW.PONDER_GROSS_WT IS NULL THEN
         MYROW.ACT_THEORY_WEIGHT
         ELSE
         MYROW.PONDER_GROSS_WT
         END),
         '#BELONG_CODE_JUGDE#',
         '#BELONG_NAME_JUGDE#',
         MYROW.MAT_GOWHERE_CODE,
         MYROW.MAT_GOWHERE_CODE || '10101',
         '#APPLY_NAME#',
         TO_DATE('#APPLY_TIME#','YYYY-MM-DD HH24:MI:SS'),
         TO_DATE('#APPLY_TIME#','YYYY-MM-DD HH24:MI:SS'),
         (SELECT F.DEPARTMENT_CODE FROM YDM_BS_STORAGE F WHERE F.STORAGE_NO = MYROW.MAT_GOWHERE_CODE),
         (SELECT F.DEPARTMENT_DESC FROM YDM_BS_STORAGE F WHERE F.STORAGE_NO = MYROW.MAT_GOWHERE_CODE),
         MYROW.ORD_PK,
         MYROW.ORD_LN_PK,
         MYROW.ORD_LN_DLY_PK,
         MYROW.ORDER_NO,
         MYROW.ORDER_SEQ,
         MYROW.ORDER_SEQ_NO,
         MYROW.PRODUCT_FLAG,
         MYROW.MAT_STATUS,
         TO_DATE('#APPLY_TIME#','YYYY-MM-DD HH24:MI:SS'),
         '1',
         MYROW.QCM_STAUS,
         MYROW.PRO_ORDER_ID,
         MYROW.GX_PLAN_NO,
         '#BAL_YEAR_MONTH#'
         );
         UPDATE MAT_BC_M T SET T.INSTOCK_FLAG = '1' WHERE T.MAT_NO = MYROW.MAT_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE;
      vCount := vCount + 1;
  END LOOP;
  UPDATE QCM_ZG_JUGDE_APPLY T
     SET T.INSTOCK_FLAG  = '1'
   WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.BATCH_NO = '#BATCH_NO#'
     AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
     AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
     AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#';
END;
</query>
<quert id = "FrmHandleJuge.getInListDoc" desc = "获取入库单号">
SELECT (SELECT S.MEMO
          FROM COM_BASE_INFO S
         WHERE S.BASECODE = ?) || INSTOCK_DOC INSTOCK_DOC
  FROM (SELECT 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 = ?
           AND TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') =
               TO_CHAR(SYSDATE, 'YYYY-MM-DD'))
</quert>
<query id = "FrmHandleJuge.doCancelComfirm" desc = "取消确认">
DECLARE
  V_BELONG_CODE MAT_BC_M.BELONG_CODE%TYPE := NULL;
  V_BELONG_NAME MAT_BC_M.BELONG_NAME%TYPE := NULL;
BEGIN
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_M T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
                 ORDER BY T.MAT_NO ASC) LOOP
    UPDATE MAT_BC_M T SET T.INSTOCK_FLAG = '0' WHERE T.MAT_NO = MYROW.MAT_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE;
    DELETE FROM YDM_BC_INLIST T WHERE T.MAT_NO = MYROW.MAT_NO AND T.INSTOCK_TYPE_CODE = '800709';
  END LOOP;
  UPDATE QCM_ZG_JUGDE_APPLY T
     SET T.Instock_Flag         = '0'
   WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#';
END;
</query>
<query id = "doHandleApply.SelectInStorageFlag" desc = "查询是否已确认">
<![CDATA[
SELECT COUNT(1) ACOUNT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
     AND T.INSTOCK_FLAG = '1'
   ]]>
</query>
</queryMap>