<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="装车作业管理sql">
	<query id="FrmPipeEntruck.QueryTallyInfo" desc="查询理货单信息">
	<![CDATA[
	SELECT T.TALLYSHEET_NO,T.BILL_NO,T.ACCBATCH_RECY,M.SUPPLY_UNIT,
	DECODE(T.LOADVEHICLE_FLAG,'0','未装车','1','装车执行','2','理货关闭') AS LOADVEHICLE_FLAG, 
	TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') AS CREATE_TIME,
	TO_CHAR(T.END_TIME,'YYYY-MM-DD HH24:MI:SS') AS END_TIME
	FROM YDM_ZC_TALLYSHEET_M  T
	LEFT JOIN YDM_ZC_BILL_M M ON T.BILL_NO=M.BILL_NO
	 WHERE T.BILL_NO LIKE '%'||?||'%'
	 AND T.TALLYSHEET_NO LIKE '%'||?||'%'
	 AND DECODE(?, NULL, SYSDATE,T.CREATE_TIME) BETWEEN DECODE(?, NULL, SYSDATE,TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'))
	 AND DECODE(?, NULL, SYSDATE,TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')) 
	 AND T.VALIDFLAG ='1'
	]]>
	</query>
	<query id="FrmPipeEntruck.QueryTallyInfoMat" desc="查詢理货材料信息">
   <![CDATA[
SELECT T1.* FROM (SELECT T.TALLYSHEET_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.ORDER_NO||'/'||T.ORDER_SEQ AS ORDER_SEQ_NO,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.STOVE_NO,
       T.MATERIAL_NAME,
       T.PRODUCNAME,
       T.STD_NAME,
       T.GRADENAME,
       T.STEELNAME,
       T.STD_STYLE_DESC,
       T.SPEC_NAME,
       T.MODEL_DESC,
       T.PROCESS_DESC,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.JUDGE_RESULT_CODE,
       T.CREATE_NAME,
       T.STORAGE_NO,
       T.LOCATION_NO,
       T.MEMO,
       (SELECT S.STORAGE_NAME
          FROM YDM_BS_STORAGE S
         WHERE S.STORAGE_NO = T.STORAGE_NO) AS STORAGE_NAME,
        (SELECT T1.LOCATION_NAME FROM YDM_BS_LOCATION T1 WHERE T1.LOCATION_NO = T.LOCATION_NO)LOCATION_NAME,
       TO_CHAR(MAX(T.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') AS CREATE_TIME,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.VSTEL_DESC,
       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.ACT_LEN), '0'),'FM999999990.00') AS ACT_LEN,
       TO_CHAR(NVL(SUM(T.ACT_THEORY_WEIGHT), '0'),'FM999999990.000') AS ACT_THEORY_WEIGHT,
       NVl(SUM(CASE
                 WHEN T.LOADVEHICLE_FLAG = '1' THEN
                  T.ACT_COUNT
                 ELSE
                  0
               END),
           '0') AS BEEN_COUNT,
       TO_CHAR(NVl(SUM(CASE
                 WHEN T.LOADVEHICLE_FLAG = '1' THEN
                  T.ACT_WEIGHT
                 ELSE
                  0
               END),
           '0'),'FM999999990.000') AS BEEN_WEIGHT,
       TO_CHAR(NVl(SUM(CASE
                 WHEN T.LOADVEHICLE_FLAG = '1' THEN
                  T.ACT_LEN
                 ELSE
                  0
               END),
           '0'),'FM999999990.00') AS BEEN_LEN,
       NVl(SUM(CASE
                 WHEN T.LOADVEHICLE_FLAG = '0' THEN
                  T.ACT_COUNT
                 ELSE
                  0
               END),
           '0') AS PREP_COUNT,
       TO_CHAR(NVl(SUM(CASE
                 WHEN T.LOADVEHICLE_FLAG = '0' THEN
                  T.ACT_WEIGHT
                 ELSE
                  0
               END),
           '0'),'FM999999990.000') AS PREP_WEIGHT,
       TO_CHAR(NVl(SUM(CASE
                 WHEN T.LOADVEHICLE_FLAG = '0' THEN
                  T.ACT_LEN
                 ELSE
                  0
               END),
           '0'),'FM999999990.00') AS PREP_LEN,
            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
  FROM YDM_ZC_TALLYSHEET_C T
 WHERE T.BILL_NO = ?
   AND T.TALLYSHEET_NO = ?
   AND T.VALIDFLAG = '1'
    ]]>
	</query>
	<query id="FrmPipeEntruck.QueryTallyIn" desc="查詢理货主信息">
		<![CDATA[
    SELECT VEHICLE_NO FROM YDM_ZC_TALLYSHEET_T WHERE TALLYSHEET_NO=? ORDER BY VEHICLE_NO
		]]>
	</query>
	<query id="FrmPipeEntruck.QueryTallyCar" desc="查询承运单位">
		<![CDATA[
    SELECT CARRY_COMPANY_CODE,CARRY_COMPANY_NAME FROM YDM_ZC_TALLYSHEET_T WHERE TALLYSHEET_NO=? AND VEHICLE_NO=? ORDER BY VEHICLE_NO
		]]>
	</query>
	<query id="FrmPipeEntruck.QuerySendList" desc="获取装车单号">
	<![CDATA[ 
   SELECT ? ||
  LPAD(SUBSTR(NVL(MAX(T.LOADVEHICLE_NO),'0000'),-4,4) + 1, 4, '0') AS LOADVEHICLE_NO
	FROM YDM_ZC_LOADVEHICLE T
	WHERE T.TALLYSHEET_NO = ?
      ]]>
	</query>
	<query id="FrmPipeEntruck.QueryAddSendMat" desc="获取要新增的材料数据">
	<![CDATA[ 
   SELECT T.MAT_NO, T.PRO_ORDER_NO, T.LOT_NO, T.GROUP_NO, T.STOVE_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.PROCESS_CDOE, T.PROCESS_DESC, T.PLINE_CODE, T.PLINE_NAME, T.ACT_DIMATER, 
		T.ACT_HEIGHT, T.ACT_LEN, T.ACT_LEN_MIN, T.ACT_LEN_MAX, T.ACT_COUNT, 
		T.ACT_WEIGHT, T.ACT_THEORY_WEIGHT, T.JUDGE_RESULT_CODE, T.PRO_BC, T.PRO_BZ, 
		T.RPO_TIME, T.SALE_ORG, T.SALE_ORG_DESC, T.SALE_AREA, T.STORAGE_NO, 
		T.LOCATION_NO, T.STORAGE_TYPE_NO, T.STORAGE_TYPE_NAME, T.MANAGEMENT_NO, 
		T.MANAGEMENT_NAME, M.LOADVEHICLE_TYPE, M.TRANS_TYPE, M.RECEIV_NO, M.RECEIV_NM, 
		M.STATION_NO, M.STATION_NM, M.SPCL_LN_NO, M.SPCL_LN_NM, M.PORT_No, M.SHIP_LOT_NO, 
		M.PLANT, M.PLANT_DESC, T.VSTEL, T.VSTEL_DESC, M.CARRIER_NO, 
		M.CARRY_COMPANY_CODE, M.CARRY_COMPANY_NAME, M.DELIVY_PLACE_CODE, 
		M.DELIVY_PLACE_NAME, M.STLMT_UNIT_NO, M.STLMT_UNIT_NM,T.DELIVERY_NO,T.ORDER_NO,T.ORDER_SEQ,T.ORD_PK,T.ORD_LN_PK,T.ORD_LN_DLY_PK
		FROM YDM_ZC_TALLYSHEET_C T 
		LEFT JOIN YDM_ZC_TALLYSHEET_M M ON T.TALLYSHEET_NO = M.TALLYSHEET_NO 
		WHERE M.BILL_NO = ? 
		AND M.TALLYSHEET_NO = ?
		AND T.JUDGE_STOVE_NO = ? 
		AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
		AND T.MAT_NO=?
	    AND T.GROUP_NO = ? 
		AND M.VALIDFLAG = '1'
		AND T.LOADVEHICLE_FLAG='0'
		ORDER BY T.MAT_NO ASC
      ]]>
	</query>
	<query id="FrmPipeEntruck.QueryAddSend" desc="获取要新增的数据">
	<![CDATA[
	SELECT M.MANAGEMENT_NO,M.MANAGEMENT_NAME, M.LOADVEHICLE_TYPE, M.TRANS_TYPE, M.RECEIV_NO, M.RECEIV_NM, 
	    M.STATION_NO, M.STATION_NM, M.SPCL_LN_NO, M.SPCL_LN_NM, M.SHIP_LOT_NO, 
	    M.PLANT, M.PLANT_DESC, M.VSTEL_CODE, M.VSTEL_DESC, M.CARRIER_NO, 
	    M.CARRY_COMPANY_CODE, M.CARRY_COMPANY_NAME, M.DELIVY_PLACE_CODE,
	    M.DELIVY_PLACE_NAME, M.STLMT_UNIT_NO, M.STLMT_UNIT_NM ,M.OUT_STOCK_CODE,M.PRD_CLS
	    FROM  YDM_ZC_TALLYSHEET_M M
	    WHERE M.BILL_NO = ? 
	    AND M.TALLYSHEET_NO = ?
	    AND M.VALIDFLAG = '1'
     ]]>
	</query>
	<query id="FrmPipeEntruck.AddLoadMat" desc="新增到装车材料表">
	<![CDATA[ 
	insert into ydm_zc_loadvehicle_mat (loadvehicle_sqe, loadvehicle_no, bill_no, 
		tallysheet_no, vehicle_no, order_no, order_seq, order_seq_no, pro_order_no, 
		mat_no, lot_no, judge_stove_no, batch_no, group_no, stove_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, 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, judge_result_code, pro_bc, pro_bz, rpo_time, 
		sen_bc, sen_bz, sale_org,sale_org_desc, sale_area, storage_type_no, storage_type_name, 
		management_no, management_name, storage_no, location_no, create_name, create_time, sen_time,ORD_PK,ORD_LN_PK,ORD_LN_DLY_PK,CARRY_COMPANY_CODE,CARRY_COMPANY_NAME,
		TRANS_TPE,RECEIV_NO  ,RECEIV_NM ,STATION_NO ,STATION_NM ,SPCL_LN_NO ,SPCL_LN_NM ,PORT_NO ,VSTEL ,VSTEL_DESC ,DELIVY_PLACE_CODE ,DELIVY_PLACE_NAME,
		DEPARTMENT_CODE,DEPARTMENT_DESC,VALIDFLAG,BAL_YEAR_MONTH,PORT_DESC,
		CREDIT_NO,SEND_NUM,ACT_FIX_NUM,ACT_FIX_LEN,FINISHPRO_MOLD,IN_MOLD,JUDGE_STD_NAME,JUDGE_STD_CODE,MEASURING_SEQ,MEMO,IN_TYPE)
		values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
		        ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
		        ?, ?, ?, ?, ?, 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="FrmPipeEntruck.QuerySendSl" desc="查询装车材料表序号">
	<![CDATA[
	 SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(LOADVEHICLE_SQE), '000000'), -6, 6) + 1, 6, '0') AS LOADVEHICLE_SQE
  FROM YDM_ZC_LOADVEHICLE_MAT T
 WHERE LOADVEHICLE_NO = ?
	 ]]>
	</query>
	<query id="FrmPipeEntruck.QueryBillSql" desc="查询理货材料号">
	<![CDATA[
  SELECT T1.* FROM (SELECT T.MAT_NO, T.PRO_ORDER_NO, T.LOT_NO, T.GROUP_NO, T.STOVE_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.PROCESS_CDOE, T.PROCESS_DESC, T.PLINE_CODE, T.PLINE_NAME, T.ACT_DIMATER, 
    T.ACT_HEIGHT, T.ACT_LEN, T.ACT_LEN_MIN, T.ACT_LEN_MAX, T.ACT_COUNT, 
    T.ACT_WEIGHT, T.ACT_THEORY_WEIGHT, T.JUDGE_RESULT_CODE, T.PRO_BC, T.PRO_BZ, 
    T.RPO_TIME, T.SALE_ORG, T.SALE_ORG_DESC, T.SALE_AREA, T.STORAGE_NO, 
    T.LOCATION_NO, T.STORAGE_TYPE_NO, T.STORAGE_TYPE_NAME, T.MANAGEMENT_NO, 
    T.MANAGEMENT_NAME, M.LOADVEHICLE_TYPE, M.TRANS_TYPE, M.RECEIV_NO, M.RECEIV_NM, 
    M.STATION_NO, M.STATION_NM, M.SPCL_LN_NO, M.SPCL_LN_NM, M.SHIP_LOT_NO, 
    M.PLANT, M.PLANT_DESC, T.VSTEL, T.VSTEL_DESC, M.CARRIER_NO, 
    M.CARRY_COMPANY_CODE, M.CARRY_COMPANY_NAME, M.DELIVY_PLACE_CODE, 
    M.DELIVY_PLACE_NAME, M.STLMT_UNIT_NO, M.STLMT_UNIT_NM,T.DELIVERY_NO AS ORDER_SEQ_NO,T.ORDER_NO,T.ORDER_SEQ,T.ORD_PK,T.ORD_LN_PK,T.ORD_LN_DLY_PK,
    M.PORT_NO,M.PORT_DESC,M.CREDIT_NO,T.SEND_NUM,T.ACT_FIX_NUM,T.ACT_FIX_LEN,T.FINISHPRO_MOLD,T.IN_MOLD,T.in_TYPE,  ZC.MEASURING_SEQ,
    ZC.SUPPLY_UNIT_CODE
    FROM YDM_ZC_TALLYSHEET_C T 
    LEFT JOIN YDM_ZC_TALLYSHEET_M M ON T.TALLYSHEET_NO = M.TALLYSHEET_NO AND T.BILL_NO=M.BILL_NO AND T.order_no||t.order_seq=m.order_no||m.order_seq ,MAT_ZC_M ZC
     WHERE T.MAT_NO=ZC.MAT_NO
           AND T.BILL_NO = ?
           AND T.TALLYSHEET_NO = ?
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
           AND T.STORAGE_NO =?
           AND T.order_no||t.order_seq = ?  
           AND T.GROUP_NO= ?
           AND T.LOCATION_NO = ?
           AND NVL(T.MEMO,'/') = NVl(?,'/')
           AND T.LOADVEHICLE_FLAG = '0'
           AND M.VALIDFLAG = '1'
           AND T.VALIDFLAG = '1'
	 ORDER BY T.MAT_NO ASC) T1
   WHERE  ROWNUM<#rumCont#
	 ]]>
	</query>
	<query id="FrmPipeEntruck.QueryLoadSql" desc="查询理货单序号">
	<![CDATA[
	SELECT T.TALLYSHEET_SQE FROM YDM_ZC_TALLYSHEET_M T
	 WHERE T.BILL_NO=?
	 AND T.TALLYSHEET_NO=?
	 AND T.VALIDFLAG = '1'
	 ORDER BY T.TALLYSHEET_SQE ASC
	 ]]>
	</query>
	<query id="FrmPipeEntruck.AddLoadPerf" desc="新增到装车实绩表">
	<![CDATA[ 
	INSERT INTO YDM_ZC_LOADVEHICLE (LOADVEHICLE_NO, BILL_NO, TALLYSHEET_NO, 
		LOADVEHICLE_TYPE, VEHICLE_NO, TRANS_TYPE, RECEIV_NO, RECEIV_NM, STATION_NO, 
		STATION_NM, SPCL_LN_NO, SPCL_LN_NM, SHIP_LOT_NO, PLANT, PLANT_DESC, 
		VSTEL_CODE, VSTEL_DESC, CARRY_COMPANY_CODE, CARRY_COMPANY_NAME, 
		STACKING_WT, STACKING_PIECE, STACKING_TOTL_LEN, DELIVY_PLACE_CODE, 
		DELIVY_PLACE_NAME, STLMT_UNIT_NO, STLMT_UNIT_NM, MANAGEMENT_NO, MANAGEMENT_NAME, 
		CREATE_NAME,LOAD_TIME, CREATE_TIME,OUT_STOCK_CODE,DEPARTMENT_CODE,DEPARTMENT_DESC,ZOUT_FLAG,AFFIRM_FLAG,PRD_CLS,CARRIER_CODE,CARRIER_NAME,CAR_LICENSE,DRIVER_CODE,DRIVER_NAME )
		VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,  ?, ?, ?, ?,
                ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
                 TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,?,?,?)
	]]>
	</query>
	<query id="FrmPipeEntruck.queryDelivery" desc="查询发货实绩表信息">
		<![CDATA[
		SELECT T.LOADVEHICLE_NO,
	       T.TALLYSHEET_NO,
	       DECODE(T.LOADVEHICLE_TYPE, '1', '实际', '2', '虚拟') AS LOADVEHICLE_TYPE,
	       DECODE(T.AFFIRM_FLAG, '0', '未确认', '1', '确认') AS AFFIRM_FLAG,
	       T.BILL_NO,
	       T.VEHICLE_NO,
	      (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.TRANS_TYPE) AS TRANS_TYPE,
	       T.RECEIV_NO,
	       T.RECEIV_NM,
	       T.STATION_NO,
	       T.STATION_NM,
	       T.SPCL_LN_NO,
	       T.SPCL_LN_NM,
	       T.SHIP_LOT_NO,
	       T.PLANT,
	       T.PLANT_DESC,
	       T.VSTEL_CODE,
	       T.VSTEL_DESC,
	       T.CARRIER_NO,
	       T.CARRY_COMPANY_CODE,
	       T.CARRY_COMPANY_NAME,
	       TO_CHAR(NVL(T.STACKING_WT,0),'FM999999990.000') AS STACKING_WT,
	       NVL(T.STACKING_PIECE,0) AS STACKING_PIECE,
	       TO_CHAR(NVL(T.STACKING_TOTL_LEN,0),'FM999999990.00') AS STACKING_TOTL_LEN,
	       DECODE(T.WEIGH_FLAG, '0', '否', '1', '是') AS WEIGH_FLAG,
	       T.PONDER_NO,
	       T.PONDER_GROSS_WT,
	       T.OUT_STOCK_CODE,
	       T.DELIVY_PLACE_CODE,
	       T.DELIVY_PLACE_NAME,
	       T.STLMT_UNIT_NO,
	       T.STLMT_UNIT_NM,
	       T.INFACTORY_TIME,
	       T.LOAD_TIME LOAD_TIME1,
	       T.DELIVY_TIME,
	       T.MEMO,
	       T.PRINT_NUM,
	       DECODE(T.VALIDFLAG, '0', '无效', '1', '有效') AS VALIDFLAG,
	       T.CREATE_NAME,
	       TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') AS CREATE_TIME1
	  FROM YDM_ZC_LOADVEHICLE T
	 WHERE T.BILL_NO LIKE '%' || ? || '%'
	   AND T.TALLYSHEET_NO LIKE '%' || ? || '%'
	   AND DECODE(?, NULL, SYSDATE, T.CREATE_TIME) BETWEEN
	       DECODE(?, NULL, SYSDATE, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')) AND
	       DECODE(?, NULL, SYSDATE, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'))
	   AND T.LOADVEHICLE_NO || '&' LIKE ('%' || ? || '%')
       AND T.AFFIRM_FLAG || '&' LIKE ('%' || ? || '%')
       AND T.VEHICLE_NO || '&' LIKE ('%' || ? || '%')
	   AND T.VALIDFLAG = '1'
	   AND T.ZOUT_FLAG='0'	
	   AND T.RETURN_FLAG='0'
     	]]>
	</query>
	<query id="FrmPipeEntruck.queryMativery" desc="查询发货实绩表理货单号对应的材料信息">
		<![CDATA[
	SELECT 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_NO,
       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.CREATE_NAME,
       TO_CHAR(MAX(T.Create_Time),'YYYY-MM-DD HH24:MI:SS') AS CREATE_TIME,
       MAX(T.PONDER_NO) AS PONDER_NO,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.VSTEL_DESC,
       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
  FROM YDM_ZC_LOADVEHICLE_MAT T
  LEFT JOIN YDM_BS_STORAGE B
    ON B.STORAGE_NO = T.STORAGE_NO
   WHERE T.LOADVEHICLE_NO = ?
   AND T.BILL_NO = ?
   AND T.VEHICLE_NO = ?
   AND T.TALLYSHEET_NO = ?
   AND T.RETURN_FLAG='0'
     	]]>
	</query>
	<query id="FrmPipeEntruck.queryLoadvehMat" desc="查询装车实绩表主键">
		<![CDATA[
		SELECT LOADVEHICLE_SQE,MAT_NO,ACT_COUNT,ACT_WEIGHT
  		FROM YDM_ZC_LOADVEHICLE_MAT
		 WHERE LOADVEHICLE_NO = ?
		   AND BILL_NO = ?
		   AND TALLYSHEET_NO = ?
		   AND VEHICLE_NO = ?      
		   AND VALIDFLAG = '1'
		 ORDER BY LOADVEHICLE_SQE ASC
		]]>
	</query>
	<query id="FrmPipeEntruck.queryLoadvehMatCount" desc="查询装车材料表支，吨总量">
		<![CDATA[
	SELECT T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       NVL(SUM(T.ACT_COUNT), '0') AS ACT_COUNT,
       NVL(SUM(T.ACT_WEIGHT), '0') AS ACT_WEIGHT,
        NVL(SUM(T.ACT_LEN), '0') AS ACT_LEN
  FROM YDM_ZC_LOADVEHICLE_MAT T
 WHERE T.LOADVEHICLE_NO = ?
   AND T.BILL_NO = ?
   AND T.TALLYSHEET_NO = ?
   AND T.VEHICLE_NO =?
   AND VALIDFLAG = '1'
 GROUP BY T.ORDER_NO,
          T.ORDER_SEQ,
          T.ORDER_SEQ_NO,
          T.ORD_PK,
          T.ORD_LN_PK,
          T.ORD_LN_DLY_PK
 ORDER BY T.ORDER_NO, T.ORDER_SEQ, T.ORDER_SEQ_NO
		]]>
	</query>
	<query id="FrmPipeEntruck.QueryYDMzcLoad" desc="查询装车实绩表是否还存在已装车的数据">
		<![CDATA[
		SELECT T.LOADVEHICLE_NO FROM YDM_ZC_LOADVEHICLE_MAT T WHERE T.BILL_NO=? AND T.TALLYSHEET_NO=?  AND T.VALIDFLAG>'0'
		]]>
	</query>
	<query id="FrmPipeEntruck.queryTallyMat" desc="查询理货单下是否还有装车单号">
		<![CDATA[
SELECT LOADVEHICLE_NO FROM YDM_ZC_LOADVEHICLE WHERE BILL_NO=? AND TALLYSHEET_NO=? AND VALIDFLAG='1'
		]]>
	</query>
	<query id="FrmPipeEntruck.queryAppFlag" desc="查询确认标志">
	<![CDATA[
    select T.AFFIRM_FLAG  from YDM_ZC_LOADVEHICLE t where T.LOADVEHICLE_NO=?
	]]>
	</query>
	<query id="FrmPipeEntruck.insertOutList" desc="插入出库表">
	<![CDATA[
	INSERT INTO YDM_ZC_OUTLIST (OUTSTOCK_SQE, OUTSTOCK_DOC, 
		OUTSTOCK_TYPE_CODE, OUTSTOCK_TYPE_NAME, VEHICLE_NO, 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, 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,DELIVERY_NO,DEPARTMENT_CODE,DEPARTMENT_DESC,
		BELONG_CODE,BELONG_NAME,BAL_YEAR_MONTH,FINISHPRO_MOLD,IN_MOLD,supply_unit_code,supply_unit,IS_DEALER,
		PROCESS_CDOE,PROCESS_DESC,PRO_ORDER_NO,BILL_NO) VALUES (?,
		?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
		?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
		TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, 
		?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?,?,?,?,?,?,?,?,?,?,?,
		(SELECT A.SUPPLY_UNIT_CODE FROM MAT_ZC_M A WHERE A.MAT_NO=?),(SELECT A.SUPPLY_UNIT FROM MAT_ZC_M A WHERE A.MAT_NO=?),
		(SELECT A.IS_DEALER FROM MAT_ZC_M A WHERE A.MAT_NO=?),(SELECT A.PROCESS_CDOE FROM MAT_ZC_M A WHERE A.MAT_NO=?),
		(SELECT A.PROCESS_DESC FROM MAT_ZC_M A WHERE A.MAT_NO=?),(SELECT A.PRO_ORDER_NO FROM MAT_ZC_M A WHERE A.MAT_NO=?),?)
	]]>
	</query>
	<query id="FrmPipeEntruck.queryTager" desc="查询目标库号信息">
	<![CDATA[
	SELECT T.STORAGE_NO,
       B.LAY_MAX_NUM,
       B.COL_MAX_NUM,
       T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       B.LOCATION_NO
  FROM YDM_BS_STORAGE T
  LEFT JOIN YDM_BS_LOCATION B
    ON T.STORAGE_NO = B.STORAGE_NO
 WHERE T.STORAGE_NO = ?
	]]>
	</query>
	<query id="FrmPipeEntruck.queryOutList" desc="查询出库单号">
	<![CDATA[
    --SELECT OUTSTOCK_DOC  FROM YDM_ZC_OUTLIST WHERE OUTSTOCK_TYPE_CODE LIKE '%' || ? || '%'  ORDER BY OUTSTOCK_SQE DESC
     SELECT MAX(OUTSTOCK_DOC) AS OUTSTOCK_DOC
    FROM YDM_ZC_OUTLIST
   WHERE OUTSTOCK_TYPE_CODE = ?
    AND TO_CHAR(CREATE_TIME,'YYYY-MM-DD') =?
	]]>
	</query>
	
	<query id="FrmPipeEntruck.queryOutListNew" desc="查询出库单号">
	<![CDATA[
     SELECT MAX(OUTSTOCK_DOC) AS OUTSTOCK_DOC
    FROM YDM_ZC_OUTLIST
   WHERE OUTSTOCK_TYPE_CODE = ?
    AND OUTSTOCK_DOC LIKE ? || '%'
	]]>
	</query>
	
	<query id="FrmPipeEntruck.queryOut" desc="查询出库流水号">
	<![CDATA[
   -- SELECT OUTSTOCK_SQE FROM YDM_ZC_OUTLIST  WHERE   CREATE_TIME LIKE '%'|| TO_DATE(?,'YYYY-MM-DD')||'%' 
    --AND OUTSTOCK_TYPE_CODE LIKE '%'|| ? ||'%'  AND OUTSTOCK_DOC =?   ORDER BY OUTSTOCK_SQE DESC
      SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.OUTSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS OUTSTOCK_SQE
    FROM YDM_ZC_OUTLIST T
   WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') =?
     --AND T.OUTSTOCK_TYPE_CODE =?
      --AND T.OUTSTOCK_DOC = ?
	]]>
	</query>
	
	<query id="FrmPipeEntruck.queryOutListNewXs" desc="查询出库单号">
	<![CDATA[
     SELECT MAX(OUTSTOCK_DOC) AS OUTSTOCK_DOC
    FROM YDM_ZC_OUTLIST_XS
   WHERE (OUTSTOCK_TYPE_CODE = ?or 1=1)
    AND OUTSTOCK_DOC LIKE ? || '%' 
	]]>
	</query>
	
	<query id="FrmPipeEntruck.queryOutXs" desc="查询出库流水号">
	<![CDATA[
   -- SELECT OUTSTOCK_SQE FROM YDM_ZC_OUTLIST_XS  WHERE   CREATE_TIME LIKE '%'|| TO_DATE(?,'YYYY-MM-DD')||'%' 
    --AND OUTSTOCK_TYPE_CODE LIKE '%'|| ? ||'%'  AND OUTSTOCK_DOC =?   ORDER BY OUTSTOCK_SQE DESC
      SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.OUTSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS OUTSTOCK_SQE
    FROM YDM_ZC_OUTLIST_XS T
   WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') =?
     AND (T.OUTSTOCK_TYPE_CODE = ?or 1=1)
     AND T.OUTSTOCK_DOC = ?
	]]>
	</query>
	
	<query id="FrmPipeEntruck.queryCar" desc="该车船号是是否确认">
	<![CDATA[
SELECT T.AFFIRM_FLAG FROM YDM_ZC_LOADVEHICLE T WHERE T.BILL_NO=? AND T.TALLYSHEET_NO=? AND T.VEHICLE_NO=?
	]]>
	</query>
	<query id="FrmPipeEntruck.queryCarTaly" desc="查询装车单号是否存在">
	<![CDATA[
SELECT T.VEHICLE_NO FROM YDM_ZC_LOADVEHICLE T WHERE T.LOADVEHICLE_NO=?
	]]>
	</query>
	<query id="FrmPipeEntruck.queryTalyBill" desc="查询装车单号是否存在">
	<![CDATA[
SELECT LOADVEHICLE_NO  FROM YDM_ZC_LOADVEHICLE WHERE LOADVEHICLE_NO=? AND VEHICLE_NO=? AND BILL_NO=? AND TALLYSHEET_NO =? 
	]]>
	</query>
	<query id="FrmPipeEntruck.QueryBillC" desc="查询理货子表是否装车完毕">
	<![CDATA[
	SELECT T.TALLYSHEET_SQE FROM YDM_ZC_TALLYSHEET_C T WHERE T.BILL_NO=? AND T.TALLYSHEET_NO=? AND  T.LOADVEHICLE_FLAG='0'
	]]>
	</query>
	<query id="FrmPipeEntruck.QueryBillType" desc="查询提单表状态">
	<![CDATA[
	SELECT 
      DECODE(T.BILL_STATUS,
              '0',
              '提单编制',
              '1',
              '提单下发',    
              '3',
              '提单执行',
              '4',
              '提单关闭',
              '5',
              '结算接收') AS BILL_STATUS
  FROM YDM_ZC_BILL_M T
 WHERE T.BILL_NO = ?
   AND T.VALIDFLAG='1'
     ]]>
	</query>
	<query id="FrmPipeEntruck.QueryOutListMat" desc="查询出库信息">
	<![CDATA[
SELECT T.MAT_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.STORAGE_NO,
       T.LOCATION_NO,
       T.LARY_NO,
       T.LOC_NO,
       T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC
  FROM YDM_ZC_OUTLIST T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
   AND T.BATCH_GROUD_NO = ?
   AND T.ORD_LN_DLY_PK = ?
   AND T.VEHICLE_NO = ?
   AND T.OUTSTOCK_TYPE_CODE = '800805'
   AND T.VALIDFLAG='1'
   ORDER BY MAT_NO ASC
     ]]>
	</query>
	<query id="FrmPipeEntruck.AddButtress" desc="新增位置表">
	<![CDATA[
	INSERT INTO YDM_ZC_BUTTRESS (MAT_NO, JUDGE_STOVE_NO, BATCH_NO, BATCH_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, 
		DEPARTMENT_CODE, DEPARTMENT_DESC, CREATE_NAME, CREATE_TIME) VALUES (?, ?, ?, ?, 
		?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'))	
	 ]]>
	</query>
	<query id="FrmPipeEntruck.queryAmount" desc="查询理货库存支数">
	<![CDATA[
SELECT NVL(SUM(T.ACT_COUNT), '0') AS ACT_COUNT
  FROM YDM_ZC_TALLYSHEET_C T
 WHERE T.BILL_NO = ?
   AND T.TALLYSHEET_NO = ?
   AND T.order_no||t.order_seq = ?
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
   AND T.STORAGE_NO = ?
   AND T.GROUP_NO = ?
   AND T.LOCATION_NO = ?
   AND NVL(T.MEMO,'/') = NVl(?,'/')
   AND T.VALIDFLAG = '1'
   AND T.LOADVEHICLE_FLAG = '0'

	]]>
	</query>
	<query id="FrmPipeEntruck.queryTallType" desc="查询理货单是否装车完毕">
	<![CDATA[
SELECT DISTINCT T.LOADVEHICLE_FLAG,T.TRANS_TYPE,T.RECEIV_NO,T.STATION_NO,T.SPCL_LN_NO,T.BILL_NO
  FROM YDM_ZC_TALLYSHEET_M T
 WHERE T.BILL_NO = ?
   AND T.TALLYSHEET_NO = ?
    AND T.VALIDFLAG='1'
	]]>
	</query>
	<query id="FrmPipeEntruck.queryCarLoad" desc="查询车号对应的装车单号">
	<![CDATA[
SELECT T.LOADVEHICLE_NO
  FROM YDM_ZC_LOADVEHICLE T
 WHERE T.BILL_NO = ?
   AND T.TALLYSHEET_NO = ?
   AND T.VEHICLE_NO = ?
   AND T.AFFIRM_FLAG='0'
   AND T.VALIDFLAG = '1'
	]]>
	</query>
	<query id="FrmPipeEntruck.queryMatTallyC" desc="查询理货材料表每支材料重量">
	<![CDATA[
SELECT NVL(SUM(T1.ACT_WEIGHT), '0') AS ACT_WEIGHT,NVL(SUM(T1.ACT_LEN),0) AS ACT_LEN
  FROM (SELECT T.TALLYSHEET_SQE, T.MAT_NO, T.ACT_WEIGHT,T.ACT_LEN
          FROM YDM_ZC_TALLYSHEET_C T
         WHERE T.BILL_NO = ?
           AND T.TALLYSHEET_NO = ?
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
           AND T.STORAGE_NO = ?
           AND T.ORD_LN_DLY_PK = ?  
           AND T.GROUP_NO=?         
           AND T.LOADVEHICLE_FLAG = '0'
           AND T.VALIDFLAG = '1'
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
	]]>
	</query>
	<query id="FrmPipeEntruck.queryTallyC" desc="查询理货材料表理货，材料主键">
	<![CDATA[
SELECT T.TALLYSHEET_SQE,T.MAT_NO,NVL(T.ACT_COUNT,0) AS ACT_COUNT,NVL(T.ACT_WEIGHT,0) AS ACT_WEIGHT,NVL(T.ACT_LEN,0) AS ACT_LEN,T.LOADVEHICLE_FLAG
  FROM YDM_ZC_TALLYSHEET_C T
 WHERE T.TALLYSHEET_NO = ?
   AND T.BILL_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
   AND T.GROUP_NO = ?
   AND T.ORD_LN_DLY_PK = ?
   AND T.LOADVEHICLE_FLAG='0'
   AND T.VALIDFLAG='1'
   ORDER BY  T.TALLYSHEET_SQE,T.MAT_NO
	]]>
	</query>
	<query id="FrmPipeEntruck.queryTallyCLoadType" desc="查询理货单材料表是否还有未装车记录">
	<![CDATA[
SELECT COUNT(1)
  FROM YDM_ZC_TALLYSHEET_C T
 WHERE T.TALLYSHEET_NO = ?
   AND T.BILL_NO = ?
   AND T.LOADVEHICLE_FLAG='0'
   AND T.VALIDFLAG='1'
	]]>
	</query>
	<query id="FrmPipeEntruck.queryTallyCLoadTypeALL" desc="查询理货单材料表是否未装车">
	<![CDATA[
SELECT COUNT(1)
  FROM YDM_ZC_TALLYSHEET_C T
 WHERE T.TALLYSHEET_NO = ?
   AND T.BILL_NO = ?
   AND T.LOADVEHICLE_FLAG IN ('1','2')
   AND T.VALIDFLAG='1'
	]]>
	</query>
	<query id="FrmPipeEntruck.updateTallM1" desc="修改理货主表装车状态">
	<![CDATA[
UPDATE YDM_ZC_TALLYSHEET_M SET LOADVEHICLE_FLAG = '2',
UPDATE_NAME=?,
UPDATE_TIME=SYSDATE,
END_TIME=SYSDATE
 WHERE BILL_NO=?
  AND TALLYSHEET_NO=?
	]]>
	</query>
	<query id="FrmPipeEntruck.updateTallM2" desc="修改理货主表装车状态">
	<![CDATA[
UPDATE YDM_ZC_TALLYSHEET_M SET LOADVEHICLE_FLAG = '1',
UPDATE_NAME=?,
UPDATE_TIME=SYSDATE 
 WHERE BILL_NO=?
  AND TALLYSHEET_NO=?
	]]>
	</query>
	<query id="FrmPipeEntruck.deleteButtress" desc="删除位置表">
	<![CDATA[
DELETE YDM_ZC_BUTTRESS C
 WHERE C.MAT_NO IN ((SELECT T.MAT_NO
                      FROM YDM_ZC_LOADVEHICLE_MAT T
                     WHERE T.BILL_NO = ?
                       AND T.LOADVEHICLE_NO = ?
                       AND T.TALLYSHEET_NO = ?
                       AND T.VEHICLE_NO = ?
                       AND T.MAT_NO = C.MAT_NO))

	]]>
	</query>
	<query id="FrmPipeEntruck.updateBillC" desc="修改提单材料表装车状态">
	<![CDATA[
--UPDATE YDM_ZC_BILL_C SET LOADVEHICLE_FLAG='1' 
--WHERE  MAT_NO=?
 UPDATE YDM_ZC_BILL_C T2
   SET T2.LOADVEHICLE_FLAG = '1'
 WHERE T2.MAT_NO IN ((SELECT T1.MAT_NO
                       FROM (SELECT T.MAT_NO
                               FROM YDM_ZC_TALLYSHEET_C T
                              WHERE T.BILL_NO = ?
                                AND T.TALLYSHEET_NO = ?
                                AND T.JUDGE_STOVE_NO = ?
                                AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
                                AND T.STORAGE_NO = ?
                                AND T.order_no||t.order_seq =?
                                AND T.GROUP_NO = ?
                                AND T.LOCATION_NO = ?
                                AND NVL(T.MEMO,'/') = NVl(?,'/')
                                AND T.LOADVEHICLE_FLAG = '0'
                              ORDER BY T.MAT_NO ASC) T1
                      WHERE ROWNUM < ?))

	]]>
	</query>
	<query id="FrmPipeEntruck.updateTallC" desc="修改理货材料表装车标志">
	<![CDATA[
--UPDATE YDM_ZC_TALLYSHEET_C SET LOADVEHICLE_FLAG = '1'
--WHERE MAT_NO=?

UPDATE YDM_ZC_TALLYSHEET_C T2
   SET T2.LOADVEHICLE_FLAG = '1'
 WHERE T2.MAT_NO IN ((SELECT T1.MAT_NO
                       FROM (SELECT T.MAT_NO
                               FROM YDM_ZC_TALLYSHEET_C T
                              WHERE T.BILL_NO = ?
                                AND T.TALLYSHEET_NO = ?
                                AND T.JUDGE_STOVE_NO = ?
                                AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
                                AND T.STORAGE_NO = ?
                                AND T.order_no||t.order_seq =?
                                AND T.GROUP_NO = ?
                                AND T.LOCATION_NO = ?
                                AND NVL(T.MEMO,'/') = NVl(?,'/')
                                AND T.LOADVEHICLE_FLAG = '0'
                              ORDER BY T.MAT_NO ASC) T1
                      WHERE ROWNUM < ?))
	]]>
	</query>
	<query id="FrmPipeEntruck.updateMatNo" desc="修改材料表材料状态">
	<![CDATA[
UPDATE MAT_ZC_M SET MAT_STATUS='80150303' WHERE MAT_NO=?
	]]>
	</query>
	<query id="FrmPipeEntruck.updateMatNo1" desc="修改材料表材料状态">
	<![CDATA[
UPDATE MAT_ZC_M SET MAT_STATUS='80150302' WHERE MAT_NO=?
	]]>
	</query>
	<query id="FrmPipeEntruck.updateBillM" desc=" 修改提单主表装车标志">
	<![CDATA[
UPDATE YDM_ZC_BILL_M SET ACT_NUM = TO_NUMBER(NVL(ACT_NUM,'0')) - TO_NUMBER(?),
 ACT_WT = TO_NUMBER(NVL(ACT_WT,'0')) - TO_NUMBER(?),
 ACT_TOTL_LEN= TO_NUMBER(NVL(ACT_TOTL_LEN,'0'))-TO_NUMBER(?)
 WHERE BILL_NO=? 
 AND ORD_LN_DLY_PK=?
 	]]>
	</query>
	<query id="FrmPipeEntruck.updateTallC1" desc="修改理货材料表装车标志">
	<![CDATA[
 MERGE INTO YDM_ZC_TALLYSHEET_C AA USING YDM_ZC_LOADVEHICLE_MAT BB
 ON(BB.LOADVEHICLE_NO = ?
       AND BB.BILL_NO = ?
       AND BB.TALLYSHEET_NO = ?
       AND BB.VEHICLE_NO = ?
       AND BB.VALIDFLAG = '1'
       AND AA.MAT_NO = BB.MAT_NO) WHEN MATCHED THEN UPDATE
   SET AA.LOADVEHICLE_FLAG = '0'

 	]]>
	</query>
	<query id="FrmPipeEntruck.updateBillC1" desc="修改提单材料表装车标志">
	<![CDATA[
 MERGE INTO YDM_ZC_BILL_C AA USING YDM_ZC_LOADVEHICLE_MAT BB
 ON(BB.LOADVEHICLE_NO =?
       AND BB.BILL_NO = ?
       AND BB.TALLYSHEET_NO =?
       AND BB.VEHICLE_NO =?
       AND BB.VALIDFLAG = '1'
       AND AA.MAT_NO = BB.MAT_NO) WHEN MATCHED THEN UPDATE
   SET AA.LOADVEHICLE_FLAG = '0'

	]]>
	</query>
	<query id = "FrmPipeEntruck.cancelLoadVie" desc = "撤销装车">
		DECLARE
		BEGIN
		FOR MYROW IN (SELECT *
		FROM YDM_ZC_LOADVEHICLE_MAT T
		WHERE T.BILL_NO = ?
		AND T.TALLYSHEET_NO = ?
		AND T.LOADVEHICLE_NO = ?
		AND T.VEHICLE_NO = ?) LOOP
		UPDATE YDM_ZC_TALLYSHEET_C T1
		SET T1.LOADVEHICLE_FLAG = '0'
		WHERE T1.MAT_NO = MYROW.MAT_NO
		AND T1.TALLYSHEET_NO = MYROW.TALLYSHEET_NO;
		UPDATE YDM_ZC_BILL_C T2
		SET T2.LOADVEHICLE_FLAG = '0'
		WHERE T2.MAT_NO = MYROW.MAT_NO
		AND T2.BILL_NO = MYROW.BILL_NO;
		END LOOP;
		END;
	</query>
	<query id="FrmPipeEntruck.deleteOut" desc="删除出库表销售出库对应记录">
	<![CDATA[
--DELETE YDM_ZC_OUTLIST  WHERE OUTSTOCK_TYPE_CODE='800805' AND MAT_NO =?
DELETE YDM_ZC_OUTLIST C
 WHERE C.OUTSTOCK_TYPE_CODE = '800805'
   AND C.MAT_NO IN ((SELECT T.MAT_NO
                    FROM YDM_ZC_LOADVEHICLE_MAT T
                   WHERE T.BILL_NO = ?
                     AND T.LOADVEHICLE_NO = ?
                     AND T.TALLYSHEET_NO = ?
                     AND T.VEHICLE_NO = ?
                     AND T.MAT_NO=C.MAT_NO))
   and decode(c.Bill_no,null,'1',c.Bill_no)=decode(c.Bill_no,null,'1',?)
	]]>
	</query>

	<query id="FrmPipeEntruck.getZcOutlist" desc="查询出库数据是否已被财务系统接收">
		<![CDATA[
		SELECT
			F.OUTSTOCK_DOC,
			F.JUDGE_STOVE_NO,
			F.BATCH_NO,
			F.BATCH_GROUD_NO
		FROM
			YDM_ZC_OUTLIST C
			INNER JOIN FMIS_ZC_OUTLIST F ON C.OUTSTOCK_DOC = F.OUTSTOCK_DOC
			AND C.JUDGE_STOVE_NO = F.JUDGE_STOVE_NO
			AND C.BATCH_NO = F.BATCH_NO
			AND C.BATCH_GROUD_NO = F.BATCH_GROUD_NO
		WHERE
			C.OUTSTOCK_TYPE_CODE = '800805'
			AND C.MAT_NO IN ((
				SELECT
					T.MAT_NO
				FROM
					YDM_ZC_LOADVEHICLE_MAT T
				WHERE
					T.BILL_NO = {0}
					AND T.LOADVEHICLE_NO = {1}
					AND T.TALLYSHEET_NO = {2}
					AND T.VEHICLE_NO = {3}
					AND T.MAT_NO = C.MAT_NO
				))
			AND decode( c.Bill_no, NULL, '1', c.Bill_no ) = decode( c.Bill_no, NULL, '1', {0} )
			AND F.SYNC_FLAG = '1'
		GROUP BY
			F.OUTSTOCK_DOC,
			F.JUDGE_STOVE_NO,
			F.BATCH_NO,
			F.BATCH_GROUD_NO
	]]>
	</query>
	<query id="FrmPipeEntruck.delZcOutlist" desc="删除财务系统中间表">
		<![CDATA[
		 DECLARE
		    BEGIN
				FOR MYROW IN
                    (SELECT
						F.OUTSTOCK_DOC,
						F.JUDGE_STOVE_NO,
						F.BATCH_NO,
						F.BATCH_GROUD_NO
					FROM
						YDM_ZC_OUTLIST C
						INNER JOIN FMIS_ZC_OUTLIST F ON C.OUTSTOCK_DOC = F.OUTSTOCK_DOC
						AND C.JUDGE_STOVE_NO = F.JUDGE_STOVE_NO
						AND C.BATCH_NO = F.BATCH_NO
						AND C.BATCH_GROUD_NO = F.BATCH_GROUD_NO
					WHERE
						C.OUTSTOCK_TYPE_CODE = '800805'
						AND C.MAT_NO IN ((
							SELECT
								T.MAT_NO
							FROM
								YDM_ZC_LOADVEHICLE_MAT T
							WHERE
								T.BILL_NO = ?
								AND T.LOADVEHICLE_NO = ?
								AND T.TALLYSHEET_NO = ?
								AND T.VEHICLE_NO = ?
								AND T.MAT_NO = C.MAT_NO
							))
						AND decode( c.Bill_no, NULL, '1', c.Bill_no ) = decode( c.Bill_no, NULL, '1', ? )
						AND F.SYNC_FLAG = '0'
					GROUP BY
						F.OUTSTOCK_DOC,
						F.JUDGE_STOVE_NO,
						F.BATCH_NO,
						F.BATCH_GROUD_NO) LOOP
                 DELETE FROM FMIS_ZC_OUTLIST D
                 WHERE D.OUTSTOCK_DOC = MYROW.OUTSTOCK_DOC
                    AND D.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
                    AND D.BATCH_NO = MYROW.BATCH_NO
                    AND D.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO;
            END LOOP;
          END;
	]]>
	</query>
	<query id="FrmPipeEntruck.deleteTallC" desc="删除理货材料表">
	<![CDATA[
DELETE YDM_ZC_TALLYSHEET_C T  WHERE T.TALLYSHEET_NO = ?
   AND T.BILL_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO,'/') = NVl(?,'/')
   AND T.GROUP_NO = ?
   AND T.ORD_LN_DLY_PK = ?
   AND T.LOADVEHICLE_FLAG='0'
   AND T.VALIDFLAG='1'
	]]>
	</query>
	<query id="FrmPipeEntruck.updateBillC3" desc="修改提单材料表状态">
	<![CDATA[
UPDATE YDM_ZC_BILL_C  SET EDIT_FLAG = '0' WHERE  BILL_NO = ?  
 AND ORD_LN_DLY_PK = ?
 AND JUDGE_STOVE_NO = ?
 AND NVL(BATCH_NO,'/') = NVl(?,'/')
 AND GROUP_NO = ?
 AND LOADVEHICLE_FLAG='0'
 AND VALIDFLAG='1'
	]]>
	</query>
	<query id="FrmPipeEntruck.queryLoadvehMatC" desc="查询装车材料表信息">
	<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.ORD_LN_DLY_PK,
       T.VEHICLE_NO
  FROM YDM_ZC_LOADVEHICLE_MAT T
 WHERE T.LOADVEHICLE_NO = ?
   AND T.BILL_NO = ?
   AND T.TALLYSHEET_NO= ?
   AND T.VEHICLE_NO = ?
   AND T.VALIDFLAG = '1'
 GROUP BY T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.GROUP_NO,
          T.ORD_LN_DLY_PK,
          T.VEHICLE_NO

	]]>
	</query>
	<query id="FrmPipeEntruck.addTallCar" desc="追加车号">
	<![CDATA[
	INSERT INTO YDM_ZC_TALLYSHEET_T
  (BILL_NO,TALLYSHEET_NO, VEHICLE_NO, CARRY_COMPANY_CODE, CARRY_COMPANY_NAME, ASK_DAY_NO, TRAIN_TYPE )
VALUES
  (?, ?, ?, ?, ?, ?, ?)
		]]>
	</query>
	<query id="FrmPipeEntruck.QueryTallCar" desc="查询同一理货单下是否有相同车号">
		<![CDATA[
	SELECT T.TALLYSHEET_NO, T.VEHICLE_NO FROM YDM_ZC_TALLYSHEET_T T WHERE T.TALLYSHEET_NO=? AND T.VEHICLE_NO=?
		]]>
	</query>
	<query id="FrmPipeEntruck.QueryTallDay" desc="查询请车数">
		<![CDATA[
  SELECT COUNT(1) AS VADAY FROM YDM_ZC_TALLYSHEET_T T WHERE T.TALLYSHEET_NO=? AND T.ASK_DAY_NO=?
		]]>
	</query>
	<query id = "FrmPipeEntruck.doQueryCrane" desc = "查询吊车车牌">
		SELECT T.CAR_NO,T.CAR_LICENSE,T.CARRIER_CODE,T.CARRIER_NAME FROM TMS_CAR_BASE T WHERE T.CAR_TYPE_CODE IN('CAR03','CAR04') ORDER BY T.CAR_NO ASC
	</query>
	<query id = "FrmPipeEntruck.doQueryDrive" desc = "查询司机信息">
		SELECT T.DRIVER_CODE,T.DRIVER_NAME FROM TMS_COM_DRIVER T WHERE T.VALIDFLAG = '1'
	</query>
</queryMap>