<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="汽运出厂计划">

	<query id="FrmLocInfo.queryLocInfo" desc="合同查询">
		<![CDATA[	 
				SELECT T.BILL_NO,
	       T.TALLYSHEET_NO,
	       T.LOADVEHICLE_NO,
	       T.ORDER_NO,
	       T.JUDGE_STOVE_NO,
	       T.BATCH_NO,
	       T.GROUP_NO,
	       T.GRADENAME,
	       T.SPEC_NAME,
	       T.STOVE_NO,
	       T.ORD_LN_DLY_PK,
	       T.STORAGE_NO,
	       SUM(NVL(T.ACT_COUNT,0)) ACT_COUNT,
		   SUM(NVL(T.ACT_WEIGHT,0)) ACT_WEIGHT,
	       (SELECT S.STORAGE_NAME
	          FROM YDM_BS_STORAGE S
	         WHERE S.STORAGE_NO = T.STORAGE_NO) STORAGE_NAME,
	       T.LOCATION_NO,
	       (SELECT S.LOCATION_NAME
	          FROM YDM_BS_LOCATION S
	         WHERE S.LOCATION_NO = T.LOCATION_NO) LOCATION_NAME
	  FROM YDM_ZC_LOADVEHICLE_MAT T
	 WHERE T.LOADVEHICLE_NO = ?
	 AND T.JUDGE_STOVE_NO = ?
	 AND T.BATCH_NO = ?
	 AND T.GROUP_NO = ?
	 AND T.ORD_LN_DLY_PK = ?
	 GROUP BY T.BILL_NO,
	          T.TALLYSHEET_NO,
	          T.LOADVEHICLE_NO,
	          T.ORDER_NO,
	          T.JUDGE_STOVE_NO,
	          T.BATCH_NO,
	          T.GROUP_NO,
	          T.GRADENAME,
	          T.SPEC_NAME,
	          T.STOVE_NO,
	          T.STORAGE_NO,
	          T.LOCATION_NO,
	          T.ORD_LN_DLY_PK
		]]>
	</query>

	<query id="FrmLocInfo.queryMatInfo" desc="用户获取">
		<![CDATA[
			       SELECT T.JUDGE_STOVE_NO,
		       T.BATCH_NO,
		       T.BATCH_GROUD_NO,
		       T.ORD_LN_DLY_PK,
		       T.GRADENAME,
		       T.SPEC_NAME,
		       T2.BILL_NO,
		       T3.TALLYSHEET_NO,
		       SUM(NVL(T.ACT_COUNT,0)) ACT_COUNT,
		       SUM(NVL(T.ACT_WEIGHT,0)) ACT_WEIGHT,
		       T1.STORAGE_NO,
		       (SELECT S.STORAGE_NAME
		          FROM YDM_BS_STORAGE S
		         WHERE S.STORAGE_NO = T1.STORAGE_NO) STORAGE_NAME,
		       T1.LOCATION_NO,
		       (SELECT S.LOCATION_NAME
		          FROM YDM_BS_LOCATION S
		         WHERE S.LOCATION_NO = T1.LOCATION_NO) LOCATION_NAME
		  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS T1
		  LEFT JOIN YDM_ZC_BILL_C T2
		  ON T1.MAT_NO = T2.MAT_NO
		  LEFT JOIN YDM_ZC_TALLYSHEET_C T3
		  ON T1.MAT_NO = T3.MAT_NO
		 WHERE T.MAT_NO = T1.MAT_NO
		   AND T.MNG_LOCK_FLAG = '0'
		   AND T.LOCK_FLAG = '0'
		   AND T.LOCK_LIKU = '0'
		   AND T.MAT_STATUS IN ('80150301','80150302')
		   AND T.MAT_NO NOT IN (SELECT L.MAT_NO FROM YDM_ZC_LOADVEHICLE_MAT L WHERE 
		    L.JUDGE_STOVE_NO = ?
		   AND L.BATCH_NO = ?
		   AND L.GROUP_NO = ?
		   AND L.ORD_LN_DLY_PK = ?)
		   AND (T.JUDGE_RESULT_CODE IS NULL OR
		       T.JUDGE_RESULT_CODE IN ('40740701', '40740709'))
		   AND T.JUDGE_STOVE_NO = ?
		   AND T.BATCH_NO = ?
		   AND T.BATCH_GROUD_NO = ?
		   AND T.ORD_LN_DLY_PK = ?
		 GROUP BY T.JUDGE_STOVE_NO,
		          T.BATCH_NO,
		          T.BATCH_GROUD_NO,
		          T.ORD_LN_DLY_PK,
		          T.GRADENAME,
		          T.SPEC_NAME,
		          T1.STORAGE_NO,
		          T1.LOCATION_NO,
		          T2.BILL_NO,
		       	  T3.TALLYSHEET_NO

		]]>
	</query>

		<query id="FrmLocInfo.queryLocMatInfo" desc="合同查询">
		<![CDATA[	 
		SELECT T.MAT_NO
		  FROM YDM_ZC_LOADVEHICLE_MAT T
		 WHERE T.LOADVEHICLE_NO = ?
		 AND T.JUDGE_STOVE_NO = ?
		 AND T.BATCH_NO = ?
		 AND T.GROUP_NO = ?
		 AND T.ORD_LN_DLY_PK = ?
		 AND T.STORAGE_NO = ?
		 AND T.LOCATION_NO = ?
		 AND ROWNUM <= ?    
		]]>
	</query>
	
	<query id="FrmLocInfo.queryMatInfoByNum" desc="用户获取">
		<![CDATA[
			  SELECT T.MAT_NO
		  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS T1
		 WHERE T.MAT_NO = T1.MAT_NO
		   AND T.MNG_LOCK_FLAG = '0'
		   AND T.LOCK_FLAG = '0'
		   AND T.LOCK_LIKU = '0'
		   AND T.MAT_STATUS IN ('80150301','80150302')
		   AND T.MAT_NO NOT IN (SELECT L.MAT_NO FROM YDM_ZC_LOADVEHICLE_MAT L WHERE 
		    L.JUDGE_STOVE_NO = ?
		   AND L.BATCH_NO = ?
		   AND L.GROUP_NO = ?
		   AND L.ORD_LN_DLY_PK = ?)
		   AND (T.JUDGE_RESULT_CODE IS NULL OR
		       T.JUDGE_RESULT_CODE IN ('40740701', '40740709'))
		   AND T.JUDGE_STOVE_NO = ?
		   AND T.BATCH_NO = ?
		   AND T.BATCH_GROUD_NO = ?
		   AND T.ORD_LN_DLY_PK = ?
		   AND T1.STORAGE_NO = ?
		   AND T1.LOCATION_NO = ?
		    
		]]>
	</query>
	
	<query id="FrmLocInfo.updateLoadMatInfo" desc="用户获取">
		<![CDATA[
			  UPDATE YDM_ZC_LOADVEHICLE_MAT T 
			  SET T.LOCATION_NO=?
			  WHERE T.MAT_NO=?
		]]>
	</query>
	
	<query id="FrmLocInfo.updateTallInfo" desc="用户获取">
		<![CDATA[
			  UPDATE YDM_ZC_TALLYSHEET_C T 
			  SET T.LOCATION_NO=?
			  WHERE T.MAT_NO=?
		]]>
	</query>
	
	<query id="FrmLocInfo.updateBillInfo" desc="用户获取">
		<![CDATA[
			  UPDATE YDM_ZC_BILL_C T  
			  SET T.LOCATION_NO=?
			  WHERE T.MAT_NO=?
		]]>
	</query>
	
		<query id="FrmLocInfo.updateStoge" desc="用户获取">
		<![CDATA[
			  UPDATE YDM_ZC_BUTTRESS T 
			  SET T.LOCATION_NO=?
			  WHERE T.MAT_NO=?
		]]>
	</query>
	
</queryMap>