<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "调整入库记录结转年月">
<query id = "FrmInListAdjustYear.doQueryInList" desc = "查询红冲记录">
<![CDATA[
 SELECT 
       t.INSTOCK_TYPE_CODE,
       t.INSTOCK_TYPE_NAME,
       t.LOT_NO,
       t.PRO_ORDER_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.STEELCODE,
       t.STEELNAME,
       t.STD_STYLE,
       t.STD_STYLE_DESC,
       t.SPEC_CODE,
       t.SPEC_NAME,
       t.MODEL_CODE,
       t.MODEL_DESC,
       t.ACT_DIMATER,
       t.ACT_HEIGHT,
       to_char(t.ACT_LEN_MIN,'FM999990.00') AS ACT_LEN_MIN,
       to_char(t.ACT_LEN_MAX,'FM999990.00') AS ACT_LEN_MAX,
       to_char(t.ACT_LEN_MIN,'FM999990.00')||'-'||to_char(t.ACT_LEN_MAX,'FM999990.00') as LEN,
       sum(t.ACT_COUNT) as ACT_COUNT,
       to_char(sum(t.ACT_WEIGHT),'FM999999990.000') as ACT_WEIGHT,
       sum(nvl(t.ACT_LEN,0)) as ACT_LEN,
       t.BELONG_CODE,
       t.BELONG_NAME,
       s.STORAGE_NAME,
       t.MEMO,
       t.STORAGE_NO,
       max(to_char(t.INSTOCK_TIME,'YYYY-MM-DD HH24:MI:SS')) as INSTOCK_TIME,
       max(to_char(t.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS')) as CREATE_TIME,
       max(to_char(t.IN_TIME_F,'YYYY-MM-DD HH24:MI:SS')) AS IN_TIME_F,
       to_char(to_date(t.BAL_YEAR_MONTH,'YYYY-MM'),'yyyy-MM') as BAL_YEAR_MONTH,
       t.ORDER_NO,
     t.ORDER_SEQ,
     t.DELIVERY_NO,
     t.JUDGE_STD_CODE,
     t.JUDGE_STD_NAME,
     t.PLINE_CODE,
     t.PLINE_NAME,
     t.GRADECODE,
     t.GRADENAME,
     t.PRODUCT_FLAG,
     t.MAT_STATUS,
     t.ZB_RCDID,
       t.ORD_LN_PK,
       t.ORD_LN_DLY_PK,
       t.INSTOCK_DOC
 FROM YDM_ZC_INLIST t
  left join  ydm_bs_storage s
  on t.STORAGE_NO = s.STORAGE_NO
 where t.INSTOCK_TYPE_CODE ='800701'
 ]]>
</query>
<query id = "FrmInListAdjustYea.adjustBalYearMoth" desc = "调整结转年月">
<![CDATA[
DECLARE
  V_MAT_NO MAT_ZC_M.ZG_MAT_NO%TYPE := NULL;
  V_JUDGE_STOVE_NO  MAT_ZC_M.ZG_STOVE_SQE%TYPE := NULL;
BEGIN
  FOR MYROW IN (SELECT *
                  FROM (SELECT T.*
                          FROM YDM_ZC_INLIST T
                         WHERE NVL(T.LOT_NO, '/') = NVL('#LOT_NO#', '/')
                           AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                           AND T.BATCH_NO = '#BATCH_NO#'
                           AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                           AND T.INSTOCK_TYPE_CODE = '#INSTOCK_TYPE_CODE#'
                           AND T.PRO_ORDER_NO = '#PRO_ORDER_NO#'
                           AND T.STORAGE_NO = '#STORAGE_NO#'
                           AND T.INSTOCK_DOC = '#INSTOCK_DOC#'
                           AND T.BELONG_CODE || '&' LIKE (UPPER(?) || '%')
                         ORDER BY T.MAT_NO DESC)
                 WHERE ROWNUM <= #ACT_COUNT#) LOOP
                 IF('#BATCH_NO#'<> 'X')THEN
    SELECT T.ZG_MAT_NO,T.ZG_STOVE_SQE
      INTO V_MAT_NO,V_JUDGE_STOVE_NO
      FROM MAT_ZC_M T
     WHERE T.MAT_NO = MYROW.MAT_NO;
    UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
       SET T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
     WHERE T.MAT_NO = V_MAT_NO
     AND T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO;
     END IF;
    UPDATE YDM_ZC_INLIST T
       SET T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#',
           T.INSTOCK_TIME   = TO_DATE('#INSTOCK_TIME#',
                                      'YYYY-MM-DD HH24:MI:SS')
     WHERE NVL(T.LOT_NO, '/') = NVL('#LOT_NO#', '/')
       AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.BATCH_NO = '#BATCH_NO#'
       AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
       AND T.INSTOCK_TYPE_CODE = '#INSTOCK_TYPE_CODE#'
       AND T.PRO_ORDER_NO = '#PRO_ORDER_NO#'
       AND T.STORAGE_NO = '#STORAGE_NO#'
       AND T.BELONG_CODE || '&' LIKE (UPPER(?) || '%')
       AND T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;
 ]]>
</query>
</queryMap>