<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "退货明细">
<query id = "FrmReturnSub.getQueryReturnDataB" desc = "退货明细">
<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.ORDER_NO || '/' || T.ORDER_SEQ AS ORDER_SEQ_NO1,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.M_BILL_NO,
       --T.VEHICLE_NO,
       T.MATERIAL_NAME,
       T.PRODUCNAME,
       T.GRADENAME,
       T.STEELNAME,
       T.SPEC_NAME,
       T.MODEL_DESC,
       T.STORAGE_NO,
       B.STORAGE_NAME,
       T.STD_NAME,
       T.STD_STYLE_DESC,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.CREATE_NAME,
       T.RECEIV_NM,
       T.MEMO,
       TO_CHAR(MAX(T.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') AS CREATE_TIME,
       --MAX(T.PONDER_NO) AS PONDER_NO,
       T.ORD_LN_DLY_PK,
       TO_CHAR(T.ACT_LEN_MIN, 'FM990.00') || '-' ||
       TO_CHAR(T.ACT_LEN_MAX, 'FM990.00') AS LENFW,
       DECODE((SELECT MAX(B.PRT_FLAG)
                FROM YDM_ZC_BILL_C B
               WHERE B.BILL_NO = T.M_BILL_NO
                 AND B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                 AND B.BATCH_NO = T.BATCH_NO
                 AND B.GROUP_NO = T.BATCH_GROUD_NO
                 AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                 AND B.VALIDFLAG = '1'),
              '0',
              '否',
              '1',
              '是') AS WEIGH_FLAG,
       TO_CHAR(NVL(SUM(T.ACT_LEN), 0), 'FM999999990.00') AS ACT_LEN,
       NVL(SUM(T.ACT_COUNT), 0) AS ACT_COUNT,
       CASE
         WHEN MAX(T.PONDER_NO) IS NOT NULL THEN
          TO_CHAR(NVL(SUM(T.PONDER_GROSS_WT), '0'), 'FM999999990.000')
         ELSE
          TO_CHAR(NVL(SUM(T.ACT_WEIGHT), 0), 'FM999999990.000')
       END ACT_WEIGHT,
       Nvl(SUM(T.SEND_NUM),0) AS SEND_NUM,
         (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.IN_MOLD AND ROWNUM = 1) IN_MOLD,
           DECODE(T.FINISHPRO_MOLD,'801801','合同变更','801802','超交货期','801803','超载甩量',
           '801804','成品备库','801805','质量异议待处理') FINISHPRO_MOLD,
      (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.RETURN_TYPE) RETURN_TYPE,
       T.RETURN_CODE,T.BAL_YEAR_MONTH

  FROM YDM_ZC_OUTLIST T
  LEFT JOIN YDM_BS_STORAGE B
    ON B.STORAGE_NO = T.STORAGE_NO
 WHERE T.OUTSTOCK_TYPE_CODE = '800806' 
 AND T.CREATE_TIME BETWEEN TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
 AND TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
 ]]>
</query>
</queryMap>