<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="提单退货红冲">
<query id="FrmCasReturnDashed.QueryBillC" desc="查询装车材料表数据">
	<![CDATA[ 
SELECT  T3.ORDER_SEQ_NO1,
T3.REALINVOICENO,
       T3.JUDGE_STOVE_NO,
       T3.BATCH_NO,
       T3.GROUP_NO,
       T3.ORDER_NO,
       T3.ORDER_SEQ,
       T3.ORDER_SEQ_NO,
       --T3.LOADVEHICLE_NO,
       T3.BILL_NO,
       --T3.TALLYSHEET_NO,
       --T3.VEHICLE_NO,
       T3.MATERIAL_NAME,
       T3.PRODUCNAME,
       T3.GRADENAME,
       T3.STEELNAME,
       T3.SPEC_NAME,
       T3.MODEL_DESC,
       T3.STORAGE_NO,
       T3.STD_NAME,
       T3.STD_STYLE_DESC,
       T3.ORD_LN_DLY_PK,
       T3.LENFW,
       T3.STORAGE_NAME,
       --T3.PONDER_NO,
       T3.WEIGH_FLAG,
       T3.ACT_LEN,
       T3.ACT_WEIGHT,
       T3.PONDER_GROSS_WT,
       T3.ACT_COUNT,
       T3.SEND_NUM,
       NVL(SUM(O.ACT_COUNT), 0) AS OUTACTCOUNT,
       NVL(SUM(O.ACT_WEIGHT), 0) AS OUTACTWT,
       NVL(SUM(O.PONDER_GROSS_WT), 0) AS OUTPONDER_GROSS_WT,
       NVL(SUM(O.SEND_NUM),0) AS OUTSENDNUM
  FROM (SELECT T1.REALINVOICENO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.GROUP_NO,
               T.ORDER_NO || '/' || T.ORDER_SEQ AS ORDER_SEQ_NO1,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.ORDER_SEQ_NO,
               --T.LOADVEHICLE_NO,
               T.BILL_NO,
               --T.TALLYSHEET_NO,
               --T.VEHICLE_NO,
               T.MATERIAL_NAME,
               T.PRODUCNAME,
               T.GRADENAME,
               T.STEELNAME,
               T.SPEC_NAME,
               T.MODEL_DESC,
               T.STORAGE_NO,
               (SELECT B.STORAGE_NAME
                  FROM YDM_BS_STORAGE B
                 WHERE B.STORAGE_NO = T.STORAGE_NO) STORAGE_NAME,
               T.STD_NAME,
               T.STD_STYLE_DESC,
               --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.BILL_NO
                         AND B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                         AND NVL(B.BATCH_NO,'/') = NVL(T.BATCH_NO,'/')
                         AND B.GROUP_NO = T.GROUP_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,
               TO_CHAR(NVL(SUM(T.ACT_WEIGHT), 0), 'FM999999990.000') AS ACT_WEIGHT,
               TO_CHAR(NVL(SUM(T.PONDER_GROSS_WT), '0'), 'FM999999990.000') AS PONDER_GROSS_WT,
               NVL(SUM(T.SEND_NUM),0) AS SEND_NUM
          FROM (SELECT M.ORD_LN_DLY_PK,
                       M.BILL_NO,
                       CASE
                         WHEN M.REALINVOICENO IS NOT NULL AND
                              M.REALINVOICENO1 IS NOT NULL THEN
                          M.REALINVOICENO || '/' || M.REALINVOICENO1
                         WHEN M.REALINVOICENO IS NULL THEN
                          M.REALINVOICENO1
                         WHEN M.REALINVOICENO1 IS NULL THEN
                          M.REALINVOICENO
                       END AS REALINVOICENO
                  FROM YDM_ZC_BILL_M M
                 GROUP BY M.ORD_LN_DLY_PK,
                          M.REALINVOICENO,
                          M.REALINVOICENO1,
                          M.BILL_NO) T1,
               YDM_ZC_LOADVEHICLE_MAT T
         WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
           AND T.BILL_NO = T1.BILL_NO
           AND T.BILL_NO = ?
         GROUP BY T1.REALINVOICENO,
                  T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.GROUP_NO,
                  T.ORDER_NO,
                  T.ORDER_SEQ,
                  T.ORDER_SEQ_NO,
                  --T.LOADVEHICLE_NO,
                  T.BILL_NO,
                  --T.TALLYSHEET_NO,
                  --T.VEHICLE_NO,
                  T.MATERIAL_NAME,
                  T.PRODUCNAME,
                  T.GRADENAME,
                  T.STEELNAME,
                  T.SPEC_NAME,
                  T.MODEL_DESC,
                  T.STORAGE_NO,
                  T.STD_NAME,
                  T.STD_STYLE_DESC,
                  T.ORD_LN_DLY_PK,
                  T.ACT_LEN_MIN,
                  T.ACT_LEN_MAX) T3,
       YMD_GP_OUTLIST O
 WHERE T3.JUDGE_STOVE_NO = O.JUDGE_STOVE_NO(+)
   AND  NVL(T3.BATCH_NO,'/0') = NVL(O.BATCH_NO(+),'/')
   AND T3.GROUP_NO = O.GROUD_NO(+)
   AND T3.BILL_NO = O.M_BILL_NO(+)
   AND T3.ORD_LN_DLY_PK = O.ORD_LN_DLY_PK(+)
   AND (O.OUTSTOCK_TYPE_CODE = '800806' OR O.OUTSTOCK_TYPE_CODE IS NULL)
  -- AND T3.VEHICLE_NO=O.VEHICLE_NO(+)
 GROUP BY T3.REALINVOICENO,
 T3.ORDER_SEQ_NO1,
          T3.JUDGE_STOVE_NO,
          T3.BATCH_NO,
          T3.GROUP_NO,
          T3.ORDER_NO,
          T3.ORDER_SEQ,
          T3.ORDER_SEQ_NO,
          --T3.LOADVEHICLE_NO,
          T3.BILL_NO,
          --T3.TALLYSHEET_NO,
          --T3.VEHICLE_NO,
          T3.MATERIAL_NAME,
          T3.PRODUCNAME,
          T3.GRADENAME,
          T3.STEELNAME,
          T3.SPEC_NAME,
          T3.MODEL_DESC,
          T3.STORAGE_NO,
          T3.STD_NAME,
          T3.STD_STYLE_DESC,
          T3.ORD_LN_DLY_PK,
          T3.LENFW,
          T3.STORAGE_NAME,
          --T3.PONDER_NO,
          T3.WEIGH_FLAG,
          T3.ACT_LEN,
          T3.ACT_WEIGHT,
          T3.PONDER_GROSS_WT,
          T3.ACT_COUNT, 
          T3.SEND_NUM
 ORDER BY T3.ORDER_NO,
          T3.ORDER_SEQ,
          T3.ORDER_SEQ_NO,
          T3.JUDGE_STOVE_NO,
          T3.BATCH_NO,
          T3.GROUP_NO ASC
	]]>
	</query>
	<query id="FrmCasReturnDashed.QueryLoadC" desc="查询发货材料表信息">
		<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUD_NO AS BATCH_GROUD_NO,
       T.ORDER_NO || '/' || T.ORDER_SEQ AS ORDER_SEQ_NO1,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.ORDER_SEQ_NO AS DELIVERY_NO,
       T.M_BILL_NO,
       T.MATERIAL_NAME,
       T.PRODUCNAME,
       T.JUDGE_GRADENAME AS GRADENAME,
       T.SPEC_NAME,
       T.STORAGE_NO,
       B.STORAGE_NAME,
       T.JUDGE_STD_NAME AS STD_NAME,
       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,
       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 NVL(B.BATCH_NO,'/') = NVL(T.BATCH_NO,'/')
                 AND B.GROUP_NO = T.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,
       TO_CHAR(NVL(SUM(T.ACT_WEIGHT), 0), 'FM999999990.000') AS ACT_WEIGHT,
       TO_CHAR(NVL(SUM(T.PONDER_GROSS_WT), '0'), 'FM999999990.000') AS PONDER_GROSS_WT,
       Nvl(SUM(T.SEND_NUM), 0) AS SEND_NUM
  FROM YMD_GP_OUTLIST T
  LEFT JOIN YDM_BS_STORAGE B
    ON B.STORAGE_NO = T.STORAGE_NO
 WHERE T.M_BILL_NO = ?
   AND T.OUTSTOCK_TYPE_CODE = '800806'
     	]]>
	</query>
	<query id="FrmCasReturnDashed.checkMatWeight" desc="验证数据">
	<![CDATA[
  SELECT SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT, SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
  SUM(NVL(T1.PONDER_GROSS_WT,0)) AS PONDER_GROSS_WT FROM (
SELECT T.MAT_NO, T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_LEN,
       T.PONDER_GROSS_WT
  FROM YDM_ZC_LOADVEHICLE_MAT T
 WHERE T.BILL_NO = ?
 AND T.TALLYSHEET_NO=?
 AND T.LOADVEHICLE_NO=?
 AND T.VEHICLE_NO=?
 AND NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
 AND T.STORAGE_NO=?
 AND T.LOCATION_NO=?
 AND T.JUDGE_STOVE_NO=?
 AND NVL(T.BATCH_NO,'/')=NVL(?,'/')
 AND T.GROUP_NO=?
 ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM< ?
		]]>
	</query>
	<query id="FrmCasReturnDashed.queryLoadReturn" desc="查询要退货的装车材料记录">
	<![CDATA[
  SELECT T1.LOADVEHICLE_NO,
       T1.BILL_NO,
       T1.TALLYSHEET_NO,
       T1.VEHICLE_NO,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.PRO_ORDER_NO,
       T1.MAT_NO,
       T1.LOT_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.GROUP_NO,
       T1.STOVE_NO,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.GRADECODE,
       T1.GRADENAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.PROCESS_CDOE,
       T1.PROCESS_DESC,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       NVL(T1.ACT_LEN, 0) ACT_LEN,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       NVL(T1.ACT_COUNT, 0) ACT_COUNT,
       NVL(T1.ACT_WEIGHT, 0) ACT_WEIGHT,
       NVL(T1.ACT_THEORY_WEIGHT, 0) ACT_THEORY_WEIGHT,
       NVL(T1.SEND_NUM,0) AS SEND_NUM,
       T1.JUDGE_RESULT_CODE,
       T1.PRO_BC,
       T1.PRO_BZ,
       T1.RPO_TIME,      
       T1.SALE_ORG,
       T1.SALE_ORG_DESC,
       T1.SALE_AREA,
       T1.STORAGE_TYPE_NO,
       T1.STORAGE_TYPE_NAME,
       T1.MANAGEMENT_NO,
       T1.MANAGEMENT_NAME,
       T1.UPLOAD_WEB_FLAG,
       T1.STORAGE_NO,
       T1.LOCATION_NO,
       T1.LARY_NO,
       T1.LOC_NO,
       T1.TRANS_TPE,
       T1.RECEIV_NO,
       T1.RECEIV_NM,
       T1.STATION_NO,
       T1.STATION_NM,
       T1.SPCL_LN_NO,
       T1.SPCL_LN_NM,
       T1.PORT_NO,
       T1.PLANT,
       T1.PLANT_DESC,
       T1.VSTEL,
       T1.VSTEL_DESC,
       T1.CARRY_COMPANY_CODE,
       T1.CARRY_COMPANY_NAME,
       T1.OUT_STOCK_CODE,
       T1.DELIVY_PLACE_CODE,
       T1.DELIVY_PLACE_NAME,
       T1.STLMT_UNIT_NO,
       T1.STLMT_UNIT_NM,
       T1.DELIVY_TIME,
       T1.VALIDFLAG,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.DEPARTMENT_CODE,
       T1.DEPARTMENT_DESC,
       T1.PONDER_NO,
       NVL(T1.PONDER_GROSS_WT, 0) PONDER_GROSS_WT,
       T1.JUDGE_STD_NAME,
       T1.JUDGE_STD_CODE,
       T1.ACT_FIX_NUM,
       T1.ACT_FIX_LEN
  FROM (SELECT T.*
          FROM YDM_ZC_LOADVEHICLE_MAT T
         WHERE T.BILL_NO = ?
           --AND T.TALLYSHEET_NO = ?
           --AND T.LOADVEHICLE_NO = ?
           --AND T.VEHICLE_NO = ?
           AND NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
           AND T.STORAGE_NO = ?
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
           AND T.GROUP_NO = ?
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < #RUMCONT#
		]]>
	</query>
	<query id="FrmCasReturnDashed.addOutReturn" desc="插入到出库表">
	<![CDATA[
	INSERT INTO YMD_GP_OUTLIST (OUTSTOCK_SQE, OUTSTOCK_DOC, 
		OUTSTOCK_TYPE_CODE, OUTSTOCK_TYPE_NAME, VEHICLE_NO, MAT_NO, LOT_NO, STOVE_NO, 
		JUDGE_STOVE_NO, BATCH_NO, GROUD_NO, MATERIAL_NO, MATERIAL_NAME, 
		PRODUCCODE, PRODUCNAME, JUDGE_STD_CODE, JUDGE_STD_NAME, JUDGE_GRADECODE, JUDGE_GRADENAME, SPEC_CODE, SPEC_NAME,  PLINE_CODE, PLINE_NAME, ACT_DIMATER, ACT_HEIGHT, 
		ACT_LEN, ACT_LEN_MIN, ACT_LEN_MAX, ACT_COUNT, ACT_WEIGHT, ACT_THEORY_WEIGHT, 
		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, OUTSTOCK_TIME, OUT_BC, 
		OUT_BZ, CREATE_NAME, CREATE_TIME, ORD_PK, ORD_LN_PK, ORD_LN_DLY_PK,ORDER_NO,ORDER_SEQ,ORDER_SEQ_NO,DEPARTMENT_CODE,DEPARTMENT_DESC,
		BELONG_CODE,BELONG_NAME,PONDER_NO,PONDER_GROSS_WT,M_BILL_NO,SEND_NUM,VSTEL,VSTEL_DESC,HAND_FLAG,PRODUCT_FLAG,MAT_STATUS,RECEIV_NO,RECEIV_NM,MEMO,ACT_FIX_NUM,ACT_FIX_LEN) VALUES (?, 
		?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
		?, TO_NUMBER(?), ?, ?, ?, TO_NUMBER(?), TO_NUMBER(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
		TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, 
		?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?,?,?,?,?,?,?,?,?,TO_NUMBER(?),?,TO_NUMBER(?),?,?,?,?,?,?,?,?,TO_NUMBER(?),TO_NUMBER(?))
		]]>
	</query>
	<query id="FrmCasReturnDashed.updateLoadReturn" desc="修改装车实绩表量">
	<![CDATA[
	UPDATE YDM_ZC_LOADVEHICLE T
   SET T.STACKING_PIECE    = TO_NUMBER(NVL(T.STACKING_PIECE, 0)) +
                             TO_NUMBER(?),
       T.STACKING_WT       = TO_NUMBER(NVL(T.STACKING_WT, 0)) + TO_NUMBER(?),
       T.STACKING_TOTL_LEN = TO_NUMBER(NVL(T.STACKING_TOTL_LEN, 0)) +
                             TO_NUMBER(?)
 WHERE T.LOADVEHICLE_NO = ?
		]]>
	</query>
	<query id="FrmCasReturnDashed.qureyFlag" desc="查询提单状态">
	<![CDATA[
	SELECT T.BILL_STATUS,
       T.ISPRECLOSE,
       T.LOADVEHICLE_TYPE,
       T.REALINVOICENO,
       T.REALINVOICENO1
  FROM YDM_ZC_BILL_M T
 WHERE T.BILL_NO = ?
AND NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
 GROUP BY T.BILL_STATUS,
          T.ISPRECLOSE,
          T.LOADVEHICLE_TYPE,
          T.REALINVOICENO,
          T.REALINVOICENO1
		]]>
	</query>
	<query id="FrmCasReturnDashed.queryOutList" desc="查询出库单号">
	<![CDATA[
   SELECT MAX(OUTSTOCK_DOC) AS OUTSTOCK_DOC
    FROM YMD_GP_OUTLIST
   WHERE OUTSTOCK_TYPE_CODE = ?
    AND TO_CHAR(CREATE_TIME,'YYYY-MM-DD') =?
	]]>
	</query>
	<query id="FrmCasReturnDashed.queryMatNoMax" desc="查询出最大材料号">
	<![CDATA[
 SELECT ? || ? ||
        LPAD(SUBSTR(NVL(MAX(T.MAT_NO), '0000'), -4, 4) + 1, 4, '0') AS MAT_NO
   FROM MAT_GP_M T
  WHERE T.JUDGE_STOVE_NO = ?
    AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
	]]>
	</query>
	<query id="FrmCasReturnDashed.addMatNoReturn" desc="新增材料表">
	<![CDATA[
	INSERT INTO MAT_GP_M (MAT_NO, PRODUCT_FLAG, MAT_STATUS, LOT_NO, STOVE_NO, 
JUDGE_STOVE_NO, BATCH_NO, GROUD_NO, MATERIAL_NO, MATERIAL_NAME, 
PRODUCCODE, PRODUCNAME, JUDGE_GRADECODE, JUDGE_GRADENAME, SPEC_CODE, 
SPEC_NAME, JUDGE_STD_CODE, JUDGE_STD_NAME, PRO_ORDER_NO, ORDER_NO, ORDER_SEQ, ORDER_SEQ_NO, PROCESS_CDOE, 
PROCESS_DESC, 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, INSTOCK_TIME, INSTOCK_FLAG, PRO_BC, PRO_BZ, RPO_TIME, CREATE_NAME, 
CREATE_TIME, ORD_PK, ORD_LN_PK, ORD_LN_DLY_PK ,
PONDER_NO, PONDER_GROSS_WT,ACT_FIX_NUM,ACT_FIX_LEN) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
 ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_NUMBER(?), ?, 
 ?, TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
 ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), 
 ?, ?, ?, ?, TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?))
	]]>
	</query>
	<query id="FrmCasReturnDashed.addMatNoReturn1" desc="新增材料表">
	<![CDATA[
	INSERT INTO MAT_GP_M (MAT_NO, PRODUCT_FLAG, MAT_STATUS, LOT_NO, STOVE_NO, 
JUDGE_STOVE_NO, BATCH_NO, GROUD_NO, MATERIAL_NO, MATERIAL_NAME, 
PRODUCCODE, PRODUCNAME, JUDGE_GRADECODE, JUDGE_GRADENAME, SPEC_CODE, 
SPEC_NAME, JUDGE_STD_CODE, JUDGE_STD_NAME, PRO_ORDER_NO, OLD_ORDER_NO, OLD_ORDER_SEQ, OLD_ORDER_SEQ_NO, PROCESS_CDOE, 
PROCESS_DESC, 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, INSTOCK_TIME, INSTOCK_FLAG, PRO_BC, PRO_BZ, RPO_TIME, CREATE_NAME, 
CREATE_TIME, ORD_PK, ORD_LN_PK, ORD_LN_DLY_PK , 
PONDER_NO, PONDER_GROSS_WT) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
 ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_NUMBER(?), ?, 
 ?, TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
 ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), 
 ?, ?, ?, ?, TO_NUMBER(?))
	]]>
	</query>
	<query id="FrmCasReturnDashed.addButterReturn" desc="新增位置表">
	<![CDATA[
	INSERT INTO YDM_GP_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   CREATE_NAME,
   CREATE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?)
	]]>
	</query>
	<query id="FrmCasReturnDashed.queryInList" desc="查询入库单号">
	<![CDATA[
    SELECT 'IT' || ? ||
        LPAD(SUBSTR(NVL(MAX(T.INSTOCK_DOC), '00000'), -5, 5) + 1, 5, '0') AS INSTOCK_DOC
   FROM YDM_ZC_INLIST T
  WHERE T.INSTOCK_TYPE_CODE = ?
     AND TO_CHAR(CREATE_TIME,'YYYY-MM-DD') =?
	]]>
	</query>
	<query id="FrmCasReturnDashed.queryLoadMat" desc="查询装车材料号">
	<![CDATA[
 SELECT SUM(T.ACT_COUNT) AS ACT_COUNT,
        SUM(T.ACT_LEN) AS ACT_LEN,
        SUM(T.ACT_WEIGHT) AS ACT_WEIGHT
   FROM YDM_ZC_LOADVEHICLE_MAT T
  WHERE T.BILL_NO = ?
    AND T.LOADVEHICLE_NO = ?
    AND T.JUDGE_STOVE_NO = ?
    AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
    AND T.GROUP_NO = ?
    AND NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
    AND T.RETURN_FLAG = '1'
 
	]]>
	</query>
	<query id="FrmCasReturnDashed.deleteLoadReturn" desc="删除装车材料表">
	<![CDATA[
	DELETE YDM_ZC_LOADVEHICLE_MAT T WHERE T.BILL_NO = ?  AND T.LOADVEHICLE_NO = ? AND T.RETURN_FLAG = '1'
	]]>
	</query>
	<query id="FrmCasReturnDashed.deleteOutReturn" desc="删除出库表">
	<![CDATA[
	DELETE YMD_GP_OUTLIST T
 WHERE T.M_BILL_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
   AND T.GROUD_NO = ?
   AND NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
   AND T.OUTSTOCK_TYPE_CODE = '800806'
	]]>
	</query>
	<query id="FrmCasReturnDashed.updateLoadReturn1" desc="修改装车实绩表支数，重量">
	<![CDATA[
		UPDATE YDM_ZC_LOADVEHICLE T
   SET T.STACKING_PIECE    = TO_NUMBER(NVL(T.STACKING_PIECE, 0)) -
                             TO_NUMBER(?),
       T.STACKING_WT       = TO_NUMBER(NVL(T.STACKING_WT, 0)) - TO_NUMBER(?),
       T.STACKING_TOTL_LEN = TO_NUMBER(NVL(T.STACKING_TOTL_LEN, 0)) -
                             TO_NUMBER(?)
 WHERE T.LOADVEHICLE_NO = ?
	]]>
	</query>
	<query id="FrmCasReturnDashed.deleteMatNoReturn" desc="删除材料表">
	<![CDATA[
	DELETE MAT_GP_M T
 WHERE T.MAT_NO IN (SELECT L.MAT_NO
                      FROM YMD_GP_OUTLIST L
                     WHERE L.M_BILL_NO = ?
                       AND L.JUDGE_STOVE_NO = ?
                       AND NVL(L.BATCH_NO,'/') = NVL(?,'/')
                       AND L.GROUD_NO = ?
                       AND NVL(L.ORD_LN_DLY_PK,'/')=NVL(?,'/')
                       AND L.MAT_NO = T.MAT_NO
                       AND L.OUTSTOCK_TYPE_CODE = '800806')
	]]>
	</query>
	<query id="FrmCasReturnDashed.deleteButterReturn" desc="删除位置表">
	<![CDATA[
	   DELETE YDM_GP_BUTTRESS T
    WHERE T.MAT_NO IN (SELECT L.MAT_NO
                      FROM YMD_GP_OUTLIST L
                     WHERE L.M_BILL_NO = ?
                       AND L.JUDGE_STOVE_NO = ?
                       AND NVL(L.BATCH_NO,'/') = NVL(?,'/')
                       AND L.GROUD_NO = ?
                       AND NVL(L.ORD_LN_DLY_PK,'/')=NVL(?,'/')
                       AND L.MAT_NO = T.MAT_NO
                       AND L.OUTSTOCK_TYPE_CODE = '800806')
	]]>
	</query>
	<query id="FrmCasReturnDashed.queryYdmLoadMat" desc="查询装车表剩余退货数">
	<![CDATA[
 SELECT NVL(SUM(T.ACT_COUNT), 0) AS ACT_COUNT,
          NVL(SUM(T.ACT_WEIGHT), 0) AS ACT_WEIGHT,
          NVL(SUM(T.PONDER_GROSS_WT), 0) AS PONDER_GROSS_WT
     FROM YDM_ZC_LOADVEHICLE_MAT T
    WHERE T.BILL_NO = ?
      AND T.JUDGE_STOVE_NO = ?
      AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
      AND T.GROUP_NO = ?
      AND NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
     -- AND T.VEHICLE_NO = ?
	]]>
	</query>
	<query id="FrmCasReturnDashed.queryOutLoadMat" desc="查询装车表已退货数">
	<![CDATA[
    SELECT COUNT(1) AS COUNNUM,NVL(SUM(T.ACT_COUNT), 0) AS ACT_COUNT,
          NVL(SUM(T.ACT_WEIGHT), 0) AS ACT_WEIGHT,
          NVL(SUM(T.PONDER_GROSS_WT), 0) AS PONDER_GROSS_WT,
          NVL(SUM(T.SEND_NUM),0) AS SEND_NUM,
          NVL(SUM(T.ACT_LEN),0) AS ACT_LEN
     FROM YMD_GP_OUTLIST T
    WHERE T.M_BILL_NO = ?
      AND T.JUDGE_STOVE_NO = ?
      AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
      AND T.Groud_No = ?
      AND NVL(T.ORD_LN_DLY_PK,'/') = NVL(?,'/')
     -- AND T.VEHICLE_NO = ?
      AND T.OUTSTOCK_TYPE_CODE = '800806'
	]]>
	</query>
		<query id="FrmCasReturnDashed.updateProOrd" desc="退货回写进程表">
	<![CDATA[
	UPDATE PROCESS_ORDER_M T
   SET T.NEG_OUT_NUM = NVL(TO_NUMBER(T.NEG_OUT_NUM), 0) + TO_NUMBER(?),
       T.NEG_OUT_WGT = NVL(TO_NUMBER(T.NEG_OUT_WGT), 0) + TO_NUMBER(?),
       T.NEG_OUT_LEN = NVL(TO_NUMBER(T.NEG_OUT_LEN), 0) + TO_NUMBER(?)
 WHERE  NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
	]]>
	</query>
		<query id="FrmCasReturnDashed.deleteProOrd" desc="退货撤销回写进程表">
	<![CDATA[
	UPDATE PROCESS_ORDER_M T
   SET T.NEG_OUT_NUM = NVL(TO_NUMBER(T.NEG_OUT_NUM), 0) - TO_NUMBER(?),
       T.NEG_OUT_WGT = NVL(TO_NUMBER(T.NEG_OUT_WGT), 0) - TO_NUMBER(?),
       T.NEG_OUT_LEN = NVL(TO_NUMBER(T.NEG_OUT_LEN), 0) - TO_NUMBER(?)
 WHERE  NVL(T.ORD_LN_DLY_PK,'/')=NVL(?,'/')
	]]>
	</query>
	<query id="FrmCasReturnDashed.queryOutListBill" desc="查询退货提单号">
	<![CDATA[
SELECT T.M_BILL_NO,MAX(T.CREATE_TIME) AS CREATE_TIME,T.HAND_FLAG
  FROM YMD_GP_OUTLIST T
 WHERE T.M_BILL_NO LIKE '%'||?||'%'
   AND T.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   AND T.JUDGE_STOVE_NO LIKE '%'||?||'%'
   AND T.OUTSTOCK_TYPE_CODE = '800806'
	]]>
	</query>
	<query id="FrmCasReturnDashed.createBillNo" desc="生成提单号">
 <![CDATA[
SELECT 'B'||'TH' || ? || TO_CHAR(SYSDATE, 'YYMMDD') ||
       LPAD(TO_CHAR(NVL(SUBSTR(MAX(T.BILL_NO), 11), 0) + 1), 4, 0) BILL_NO
  FROM YDM_ZC_BILL_NO T
 WHERE INSTR(T.BILL_NO, ? || TO_CHAR(SYSDATE, 'YYMMDD')) > 0
  AND T.BILL_NO LIKE '#BILLNO#%'
 ]]>
	</query>
	<query id="FrmCasReturnDashed.queryMatZcNo" desc="查询材料表材料状态">
 <![CDATA[
SELECT  COUNT(*) COUNT,
         MAX(T.MAT_STATUS) MAT_STATUS,
         MAX(T.LOCK_FLAG) LOCK_FLAG
        FROM MAT_GP_M T WHERE T.MAT_NO IN (SELECT L.MAT_NO
                      FROM YMD_GP_OUTLIST L
                     WHERE L.M_BILL_NO = ?
                       AND L.JUDGE_STOVE_NO = ?
                       AND NVL(L.BATCH_NO,'/') = NVL(?,'/')
                       AND L.GROUD_NO = ?
                       AND NVL(L.ORD_LN_DLY_PK,'/')=NVL(?,'/')
                       AND L.MAT_NO = T.MAT_NO
                       AND L.OUTSTOCK_TYPE_CODE = '800806')
 ]]>
	</query>
</queryMap>