<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "产权出库年月调整">
<query id = "FrmOutListAdjustYear.getOutList" desc = "查询">
SELECT 
       to_char(to_date(t.BAL_YEAR_MONTH,'YYYY-MM'),'yyyy-MM') as BAL_YEAR_MONTH,
       
       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.PRO_ORDER_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       sum(T.ACT_COUNT) ACT_COUNT,
       sum(T.ACT_WEIGHT)ACT_WEIGHT,
       sum(T.ACT_THEORY_WEIGHT)ACT_THEORY_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       
       T.STORAGE_NO,
       max(TO_CHAR(T.OUTSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) OUTSTOCK_TIME,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       
       T.JUDGE_STD_NAME,
       T.JUDGE_STD_CODE,
       T.PONDER_NO,
       sum(T.PONDER_GROSS_WT)PONDER_GROSS_WT,
       T.OUTSTOCK_PLAN_NO,
       T.OUTSTOCK_DOC,
       T.OUTSTOCK_TYPE_CODE,
       T.OUTSTOCK_TYPE_NAME,
       T.VEHICLE_NO,
       s.storage_name
 FROM YDM_ZC_OUTLIST t,ydm_bs_storage s
 WHERE t.storage_no = s.storage_no
 AND t.OUTSTOCK_TYPE_CODE = '800809'
</query>
<query id = "FrmOutListAdjustYear.updateYear" desc= "修改结转年月">
<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT T.MAT_NO
                  FROM YDM_ZC_OUTLIST T
                 WHERE T.OUTSTOCK_DOC = ?
                   AND T.JUDGE_STOVE_NO = ?
                   AND T.BATCH_NO = ?
                   AND T.BATCH_GROUD_NO = ?
                   AND NVL(T.VEHICLE_NO,'/') = NVL(?,'/')
                   AND T.OUTSTOCK_TYPE_CODE = ?
                   AND T.BELONG_CODE = ?
                 ORDER BY T.MAT_NO DESC) LOOP
    UPDATE YDM_ZC_OUTLIST S
       SET S.BAL_YEAR_MONTH = ?,
           S.OUTSTOCK_TIME  = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
     WHERE S.MAT_NO = MYROW.MAT_NO
     AND S.OUTSTOCK_TYPE_CODE = '800809'
     AND S.BELONG_CODE = ?;
  END LOOP;
END;
]]>
</query>
<query id = "FrmOutListAdjustYear.selectYearMoth" desc = "查询">
SELECT COUNT(1) ACOUNT
  FROM YDM_ZC_INITIAL_ZG T
 WHERE T.BAL_YEAR_MONTH = ?
</query>
</queryMap>