<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">	

	<query id="CoreOrderDelivery.clearSlmOrderDeliveryTransit" desc="清除运输线路信息">
		<![CDATA[
				DELETE SLM_ORDER_DELIVERY_TRANSIT WHERE ORD_LN_DLY_PK=?
		]]>
	</query>

	<query id="CoreOrderDelivery.UpdateTransitMnyDesc" desc="更新总费用和运输信息描述">
		<![CDATA[
			UPDATE SLM_ORDER_LINE_DELIVERY
			SET
            TRANSIT_MNY=?,
            TRANSIT_PLAN=?,
            AGENCY_FL=?
            WHERE ORD_LN_PK=? AND ORD_LN_DLY_PK=?
		]]>
	</query>

	<query id="CoreOrderDelivery.GetDeliveryWTQty" desc="获取交换量">
		<![CDATA[
		   SELECT nvl(SUM(DELVRY_QTY),'0') FROM SLM_ORDER_LINE_DELIVERY WHERE ORD_LN_PK=? AND VALIDFLAG = '1'
		]]>
	</query>


	<query id="CoreOrderDelivery.GetDelEnd" desc="获取最新交货日期">
		<![CDATA[
			SELECT DELVRY_EDATE FROM SLM_ORDER_LINE_DELIVERY
            WHERE ORD_LN_PK=?
           	ORDER BY DELVRY_EDATE DESC
		]]>
	</query>

	<query id="CoreOrderDelivery.BindUnit" desc="收货单位">
		<![CDATA[
	 SELECT DISTINCT A.CUSTOMER_NO, A.CUSTOMER_NM

  FROM SLM_BASE_CUSTOMER    A,
       SLM_BASE_CUSTM_RIGHT B,
       SLM_BASE_CUSTM_USE   C,
       SLM_BASE_RECEIV_UNIT D

 WHERE A.CUSTOMER_NO = B.CUSTOMER_NO
   AND A.CUSTOMER_NO = C.CUSTOMER_NO
   AND A.CUSTOMER_NO = D.CUSTOMER_NO
   AND C.CUSTM_USE = ?
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND C.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
			 
		]]>
	</query>

	<query id="CoreOrderDelivery.BindUnitAddRess" desc="查询收货单位地址">
		<![CDATA[
			SELECT DECODE ((SELECT ADDRESS
                  FROM SLM_BASE_RECEIV_UNIT
                 WHERE CUSTOMER_NO = ER.CUSTOMER_NO AND SALE_ORG = ?),
	               ' ', (SELECT ADDRESS
	                       FROM SLM_BASE_ORDER_UNIT
	                      WHERE CUSTOMER_NO = ER.CUSTOMER_NO AND SALE_ORG = ?),
	               (SELECT ADDRESS
	                  FROM SLM_BASE_RECEIV_UNIT
	                 WHERE CUSTOMER_NO = ER.CUSTOMER_NO AND SALE_ORG = ?)
	              )ADDRESS
			  FROM SLM_BASE_CUSTOMER ER
			 WHERE CUSTOMER_NO = ?
		]]>
	</query>

	<query id="CoreOrderDelivery.BindType" desc="收货单位">
		<![CDATA[
			SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE SORTCODE='1208' ORDER BY BASECODE
		]]>
	</query>

	<query id="CoreOrderDelivery.getOrdLnLikuState" desc="利库信息">
		<![CDATA[
			SELECT t.* FROM MAT_ZC_M T WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CoreOrderDelivery.BindAddress" desc="收货单位">
		<![CDATA[
			SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE SORTCODE='1106' 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getOrderFirstUnit" desc="收货单位">
		<![CDATA[
			select t.supply_unit from SLM_ORDER_HEAD t where t.ord_pk=(select l.ord_pk from slm_order_line l where l.ord_ln_pk=? and l.validflag='1') and t.validflag='1'
		]]>
	</query>





	<query id="CoreOrderDelivery.doQuery" desc="查询">
		<![CDATA[
SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       TO_CHAR(DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       T.VALIDFLAG,
       T.CREATE_NAME,
       T.CREATE_TIME,
       TRANSIT_TYP,
       DECODE(EXTRA_FLAG,'1','是','否') EXTRA_FLAG,
       DECODE(IS_ADD,'1','是','否') IS_ADD,
       IS_ADD IS_ADD_CODE,
       A.BASENAME TRANSIT_TYP_NM
  FROM SLM_ORDER_LINE_DELIVERY T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.TRANSIT_TYP
 WHERE ORD_LN_PK = ?
 ORDER BY DELVRY_EDATE DESC
		]]>
	</query>
	
	
	
	
	
	<query id="CoreOrderDelivery.doQuery_Mode" desc="方案表查询">
		<![CDATA[
			SELECT 
			TRANSIT_NO,
			MODE_NO,
			MODE_DESC,
			TRANSIT_MNY,
			VALIDFLAG,
			CREATE_NAME,
			CREATE_TIME,
			UPDATE_NAME,
			UPDATE_TIME,
			DELETE_NAME,
			DELETE_TIME 
			FROM 
			SLM_BASE_TRANSIT_MODE WHERE TRANSIT_NO=? ORDER BY MODE_NO

		]]>
	</query>
	
	
	<query id="CoreOrderDelivery.GetSpclNo" desc="专用线">
		<![CDATA[
			SELECT SPCL_LN_NO,SPCL_LN_NM FROM SLM_BASE_SPCL_LN ORDER BY SPCL_LN_NO
		]]>
	</query>
	
	<query id="CoreOrderDelivery.GetYsfs" desc="运输方式">
		<![CDATA[
			SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE SORTCODE='1105' ORDER BY BASECODE
		]]>
	</query>
	
	<query id="CoreOrderDelivery.GetCydw" desc="承运单位">
		<![CDATA[
			SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE SORTCODE='1109' ORDER BY BASECODE
		]]>
	</query>
	
	<query id="CoreOrderDelivery.GetType" desc="地域类型数据源绑定">
		<![CDATA[
			SELECT BASECODE,
				   BASENAME 
				   FROM 
				   COM_BASE_INFO 
				   WHERE 
				   SORTCODE='1107' 
				   ORDER BY BASECODE
		]]>
	</query>
	<query id="CoreOrderDelivery.GetStation" desc="获取到站信息">
		<![CDATA[
			SELECT 
			STATION_NO,
			STATION_NM 
			FROM 
			SLM_BASE_STATION 
			ORDER BY 
			STATION_NO
		]]>
	</query>
	<query id="CoreOrderDelivery.GetPort" desc="获取港口码头">
		<![CDATA[
			SELECT 
			BASECODE,
			BASENAME 
			FROM 
			COM_BASE_INFO 
			WHERE 
			SORTCODE='1108' 
			ORDER BY BASECODE
		]]>
	</query>
	<query id="CoreOrderDelivery.isRepeatMain" desc="验证主线路是否已存在">
		<![CDATA[
			SELECT 
			REGION_NO_B,
			REGION_NO_E 
			FROM 
			SLM_BASE_TRANSIT 
			WHERE 
			LOWER(REGION_NO_B)=LOWER(?) 
			AND 
			LOWER(REGION_NO_E)=LOWER(?)
		]]>
	</query>
	
	<query id="CoreOrderDelivery.isRepeatModeLine" desc="验证明细表，线路是否已存在。">
		<![CDATA[
			SELECT 
			REGION_NO_B,
			REGION_NO_E 
			FROM 
			SLM_BASE_TRANSIT_MODE_LINE 
			WHERE 
	        TRANSIT_NO=? AND MODE_NO=? AND REGION_NO_B = ? AND REGION_NO_E = ?
		]]>
	</query>
	
	
	<query id="CoreOrderDelivery.isRepeatMode" desc="验证方案描述是否已存在">
		<![CDATA[
			SELECT 
			MODE_DESC 
			FROM 
			SLM_BASE_TRANSIT_MODE 
			WHERE 
			TRANSIT_NO=? 
			AND 
			MODE_DESC=?
			
		]]>
	</query>
	
	
	<query id="CoreOrderDelivery.GetMaxCode_Main" desc="获取最大主线路编号">
		<![CDATA[
			SELECT 
			MAX(TRANSIT_NO) 
			FROM 
			SLM_BASE_TRANSIT 
			WHERE 
			TRANSIT_NO LIKE ?||'%'
		]]>
	</query>
	
	<query id="CoreOrderDelivery.GetMaxIndexSeq" desc="获取最大顺序号">
		<![CDATA[
			SELECT MAX(INDEX_SEQ) FROM SLM_BASE_TRANSIT_MODE_LINE WHERE TRANSIT_NO=? AND MODE_NO=?
		]]>
	</query>
	
	<query id="CoreOrderDelivery.GetMaxCode_Mode" desc="获取当前主线路下最大方案编号">
		<![CDATA[
			SELECT 
			MAX(MODE_NO) 
			FROM 
			SLM_BASE_TRANSIT_MODE 
			WHERE 
			TRANSIT_NO=?
		]]>
	</query>
	
	
	
	<query id="CoreOrderDelivery.doAdd" desc="交货信息新增">
		<![CDATA[
			INSERT INTO SLM_ORDER_LINE_DELIVERY(
					            ORD_PK,ORD_LN_PK,ORD_LN_DLY_PK,DELIVERY_NO,
					            DELVRY_EDATE,DELVRY_QTY,ORDER_UNIT,
					            WGT_ESTMT,ENSU_TOTL_LEN,RECEIV_NO,RECEIV_NM,
					            DELVRY_ADDR,AGENCY_FL,RECEIV_ADDR,TRANSIT_PLAN,
					            TRANSIT_MNY,VALIDFLAG,CREATE_NAME,CREATE_TIME,
					            TRANSIT_TYP,DELIVERY_STATUS,EXTRA_FLAG,IS_ADD
								) 
					            VALUES
					            (?,?,(SELECT DECODE (MAX (ORD_LN_DLY_PK),
								                '', ? || '001',
								                   MAX (ORD_LN_PK)
								                || LPAD (SUBSTR (MAX (ORD_LN_DLY_PK), 36) + 1, 3, '0')
								               )
								   FROM SLM_ORDER_LINE_DELIVERY
								  WHERE ORD_LN_PK = ?),
								( SELECT LPAD(TO_NUMBER(NVL(MAX(A.DELIVERY_NO), '0')) + 1, 3, '0') DLY_NO
                                     FROM SLM_ORDER_LINE_DELIVERY A
                                   WHERE ORD_LN_PK = ?),
					            TO_DATE(?,'YYYY-MM-DD'),?,?,
					            ROUND(?,3),?,?,?,
					            ?,?,?,?,
					            ?,1,?,SYSDATE,
					            ?,'12020101',?,?)

		]]>
	</query>
	
	<query id="CoreOrderDelivery.doUpdate" desc="交货信息修改">
		<![CDATA[
			UPDATE 
			SLM_ORDER_LINE_DELIVERY 
			SET 
            DELVRY_EDATE=TO_DATE(?,'YYYY/MM/DD'),DELVRY_QTY=?,ORDER_UNIT=?,
            WGT_ESTMT=ROUND(?,3),ENSU_TOTL_LEN=?,RECEIV_NO=?,RECEIV_NM=?,
            DELVRY_ADDR=?,AGENCY_FL=?,RECEIV_ADDR=?,TRANSIT_PLAN=?,
            TRANSIT_MNY=?,UPDATE_NAME=?,UPDATE_TIME=SYSDATE,
            TRANSIT_TYP = ?,EXTRA_FLAG = ?
			WHERE
			ORD_PK=? AND ORD_LN_PK=? AND ORD_LN_DLY_PK=?
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doAdd_ModeLine" desc="线路明细新增">
		<![CDATA[		
			INSERT INTO SLM_BASE_TRANSIT_MODE_LINE(
										TRANSIT_NO,
										MODE_NO,
										MODE_DESC,
										INDEX_SEQ,
										AGENCY_FL,
										TRANSIT_TYP,
										REGION_NO_B_TYP,
										REGION_NO_B,
										REGION_NO_E_TYP,
										REGION_NO_E,
										SPCL_LN_NO,
										CARRIER_UNIT,
										RECEIVOR,
										TRANSIT_LN_MNY,
										VALIDFLAG,
										CREATE_NAME,
										CREATE_TIME
										)
										VALUES
										(?,?,?,?,?,
										?,?,?,?,?,
										?,?,?,?,1,
										?,SYSDATE)

		]]>
	</query>
	
	<query id="CoreOrderDelivery.doUpdate_Main" desc="主线路修改">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT SET
							TRANSIT_DESC=?,
							REGION_NO_B_TYP=?,
							REGION_NO_B=?,
							REGION_NO_E_TYP=?,
							REGION_NO_E=?,
							UPDATE_NAME=?,
							UPDATE_TIME=SYSDATE 
							WHERE 
							TRANSIT_NO=?

		]]>
	</query>
	
	<query id="CoreOrderDelivery.doUpdate_Mode" desc="方案修改">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE SET
							MODE_DESC=?,
							UPDATE_NAME=?,
							UPDATE_TIME=SYSDATE 
							WHERE TRANSIT_NO=? AND MODE_NO=?

		]]>
	</query>
	
	<query id="CoreOrderDelivery.doUpdate_ModeLine" desc="线路明细修改">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE_LINE SET
                                  AGENCY_FL=?,
                                  TRANSIT_TYP=?,
                                  REGION_NO_B_TYP=?,
                                  REGION_NO_B=?,
                                  REGION_NO_E_TYP=?,
                                  REGION_NO_E=?,
                                  SPCL_LN_NO=?,
                                  CARRIER_UNIT=?,
                                  RECEIVOR=?,
                                  TRANSIT_LN_MNY=?,
                                  UPDATE_NAME=?,
                                  UPDATE_TIME=SYSDATE 
                                  WHERE TRANSIT_NO=? AND MODE_NO=? AND INDEX_SEQ=?

		]]>
	</query>
	
	<query id="CoreOrderDelivery.doQuery_ModeLine" desc="线路明细查询">
		<![CDATA[
			SELECT
			TRANSIT_NO,MODE_NO,MODE_DESC,INDEX_SEQ,AGENCY_FL,
			TRANSIT_TYP,REGION_NO_B_TYP,REGION_NO_B,
			REGION_NO_E_TYP,REGION_NO_E,SPCL_LN_NO,CARRIER_UNIT,
			RECEIVOR,TRANSIT_LN_MNY，VALIDFLAG,CREATE_NAME,
			CREATE_TIME,UPDATE_NAME,UPDATE_TIME,
			DELETE_NAME,DELETE_TIME
			FROM SLM_BASE_TRANSIT_MODE_LINE
			WHERE TRANSIT_NO=? AND MODE_NO=?

		]]>
	</query>
	
	<query id="CoreOrderDelivery.GetTransitMny" desc="总费用">
		<![CDATA[
			SELECT 
			SUM(TRANSIT_LN_MNY) 
			FROM 
			SLM_BASE_TRANSIT_MODE_LINE 
			WHERE 
			TRANSIT_NO=?
			AND MODE_NO=?
			AND VALIDFLAG=1
		]]>
	</query>
	
	<query id="CoreOrderDelivery.UpdateTransitMny" desc="总费用更新">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE SET TRANSIT_MNY=? WHERE TRANSIT_NO=? AND MODE_NO=?
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doDelete_ModeLine" desc="废除线路明细">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE_LINE 
			SET 
			VALIDFLAG=0,
			DELETE_NAME=?,
			DELETE_TIME=SYSDATE
			WHERE 
			TRANSIT_NO=? 
			AND MODE_NO=? 
			AND INDEX_SEQ=?
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doResume_ModeLine" desc="废除线路明细">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE_LINE 
			SET 
			VALIDFLAG=1,
			DELETE_NAME=?,
			DELETE_TIME=''
			WHERE 
			TRANSIT_NO=? 
			AND MODE_NO=? 
			AND INDEX_SEQ=?
		]]>
	</query>
	
	
	<query id="CoreOrderDelivery.doDelete_Mode" desc="废除方案">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE
			SET 
			VALIDFLAG=0,
			DELETE_NAME=?,
			DELETE_TIME=SYSDATE
			WHERE 
			TRANSIT_NO=? 
			AND MODE_NO=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doResume_Mode" desc="恢复方案">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE
			SET 
			VALIDFLAG=1,
			DELETE_NAME=?,
			DELETE_TIME=''
			WHERE 
			TRANSIT_NO=? 
			AND MODE_NO=? 
		]]>
	</query>
	
	
	<query id="CoreOrderDelivery.doDelete_Mode_Item" desc="废除方案子记录">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE_LINE
			SET 
			VALIDFLAG=0,
			DELETE_NAME=?,
			DELETE_TIME=SYSDATE
			WHERE 
			TRANSIT_NO=? 
			AND MODE_NO=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doResume_Mode_Item" desc="恢复方案子记录">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE_LINE
			SET 
			VALIDFLAG=1,
			DELETE_NAME=?,
			DELETE_TIME=''
			WHERE 
			TRANSIT_NO=? 
			AND MODE_NO=? 
		]]>
	</query>
	
	
	<query id="CoreOrderDelivery.doDelete_Main_Mode_Line" desc="删除当前线路全部线路明细">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE_LINE
			SET 
			VALIDFLAG=0,
			DELETE_NAME=?,
			DELETE_TIME=SYSDATE
			WHERE 
			TRANSIT_NO=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doResume_Main_Mode_Line" desc="删除当前线路全部线路明细">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE_LINE
			SET 
			VALIDFLAG=1,
			DELETE_NAME=?,
			DELETE_TIME=''
			WHERE 
			TRANSIT_NO=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doDelete_Main_Mode" desc="废除当前线路下，全部方案">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE
			SET 
			VALIDFLAG=0,
			DELETE_NAME=?,
			DELETE_TIME=SYSDATE
			WHERE 
			TRANSIT_NO=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doResume_Main_Mode" desc="恢复当前线路下，全部方案">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT_MODE
			SET 
			VALIDFLAG=1,
			DELETE_NAME=?,
			DELETE_TIME=''
			WHERE 
			TRANSIT_NO=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doDelete_Main" desc="废除当前线路">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT
			SET 
			VALIDFLAG=0,
			DELETE_NAME=?,
			DELETE_TIME=SYSDATE
			WHERE 
			TRANSIT_NO=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.doResume_Main" desc="恢复当前线路">
		<![CDATA[
			UPDATE SLM_BASE_TRANSIT
			SET 
			VALIDFLAG=1,
			DELETE_NAME=?,
			DELETE_TIME=''
			WHERE 
			TRANSIT_NO=? 
		]]>
	</query>
	
	
	
	<query id="CoreOrderDelivery.addOrderDeliveryTransit" desc="运输线路新增">
		<![CDATA[
				INSERT INTO SLM_ORDER_DELIVERY_TRANSIT(
					            MANAG_NO,ORDER_NO,ORDER_SEQ,DELIVERY_NO,
					            INDEX_SEQ,AGENCY_FL,TRANSIT_TYP,
					            DESTINATION,STATION_NO,STATION_NM,SPCL_LN_NO,
					            SPCL_LN_NM,PORT_NO,PORT_DESC,CARRIER_UNIT,
					            RECEIVOR,TRANSIT_LN_MNY,VALIDFLAG,CREATE_NAME,
					            CREATE_TIME
								) 
					            VALUES
					            (
					            ?,?,?,?,
					            ?,?,?,
					            ?,?,?,?,
					            ?,?,?,?,
					            ?,?,?,?,
					            SYSDATE)
		]]>
	</query>
	
	<query id="CoreOrderDelivery.clearTransit" desc="清除运输线路信息">
		<![CDATA[
				DELETE SLM_ORDER_DELIVERY_TRANSIT WHERE ORD_LN_DLY_PK=? 
		]]>
	</query>
	
	<query id="CoreOrderDelivery.deleteDelivery" desc="删除当前选中交货信息行">
		<![CDATA[
				DELETE SLM_ORDER_LINE_DELIVERY WHERE ORD_LN_DLY_PK=? 
		]]>
	</query>
	
	
	<query id="CoreOrderDelivery.GetMaxDeliveryNo" desc="获取最大交货编号">
		<![CDATA[
			SELECT MAX(DELIVERY_NO) 
			FROM 
			SLM_ORDER_LINE_DELIVERY 
			WHERE 
			ORD_LN_PK=?
		]]>
	</query>
	
	<query id="CoreOrderDelivery.GetTransitByDeliveryNo" desc="获取运输线路信息">
		<![CDATA[
			SELECT MAX(DELIVERY_NO) 
			FROM 
			SLM_ORDER_LINE_DELIVERY 
			WHERE 
			ORD_LN_PK=?
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getDeliveryTransit" desc="查询合同行交货运输方案">
		<![CDATA[
SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       INDEX_SEQ,
       AGENCY_FL,
       DECODE(AGENCY_FL, '1', 'True', '2', 'True', 'False') AGENCY_FL2,
       TRANSIT_TYP,
       DESTINATION,
       STATION_NO,
       STATION_NM,
       SPCL_LN_NO,
       SPCL_LN_NM,
       PORT_NO,
       PORT_DESC,
       CARRIER_UNIT,
       RECEIVOR,
       TRANSIT_LN_MNY,
       VALIDFLAG,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME
  FROM SLM_ORDER_DELIVERY_TRANSIT T
 WHERE T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND (T.AGENCY_FL = '#AGENCY_FL#' OR DECODE('#AGENCY_FL#', '2', T.AGENCY_FL, '1') = DECODE('#AGENCY_FL#', '2', '0', '2'))
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderDelivery.insertDeliveryTransit" desc="新增运输线路信息">
		<![CDATA[
INSERT INTO SLM_ORDER_DELIVERY_TRANSIT
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   INDEX_SEQ,
   AGENCY_FL,
   TRANSIT_TYP,
   DESTINATION,
   STATION_NO,
   STATION_NM,
   SPCL_LN_NO,
   SPCL_LN_NM,
   PORT_NO,
   PORT_DESC,
   CARRIER_UNIT,
   RECEIVOR,
   TRANSIT_LN_MNY,
   CREATE_NAME,
   CREATE_TIME)
VALUES
  ('#ORD_PK#',
   '#ORD_LN_PK#',
   '#ORD_LN_DLY_PK#',
   '#INDEX_SEQ#',
   '#AGENCY_FL#',
   '#TRANSIT_TYP#',
   '#DESTINATION#',
   '#STATION_NO#',
   '#STATION_NM#',
   '#SPCL_LN_NO#',
   '#SPCL_LN_NM#',
   '#PORT_NO#',
   '#PORT_DESC#',
   '#CARRIER_UNIT#',
   '#RECEIVOR#',
   '#TRANSIT_LN_MNY#',
   '#CREATE_NAME#',
   SYSDATE)
		]]>
	</query>
	
		<query id="CoreOrderDelivery.updateDeliveryTransit" desc="修改运输线路信息">
		<![CDATA[
UPDATE SLM_ORDER_DELIVERY_TRANSIT T
   SET ORD_PK         = '#ORD_PK#',
       ORD_LN_PK      = '#ORD_LN_PK#',
       ORD_LN_DLY_PK  = '#ORD_LN_DLY_PK#',
       INDEX_SEQ      = '#INDEX_SEQ#',
       AGENCY_FL      = '#AGENCY_FL#',
       TRANSIT_TYP    = '#TRANSIT_TYP#',
       DESTINATION    = '#DESTINATION#',
       STATION_NO     = '#STATION_NO#',
       STATION_NM     = '#STATION_NM#',
       SPCL_LN_NO     = '#SPCL_LN_NO#',
       SPCL_LN_NM     = '#SPCL_LN_NM#',
       PORT_NO        = '#PORT_NO#',
       PORT_DESC      = '#PORT_DESC#',
       CARRIER_UNIT   = '#CARRIER_UNIT#',
       RECEIVOR       = '#RECEIVOR#',
       TRANSIT_LN_MNY = '#TRANSIT_LN_MNY#',
       UPDATE_NAME    = '#UPDATE_NAME#',
       UPDATE_TIME    = SYSDATE
 WHERE T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getDeliveryTransitCnt" desc="获取运输线路信息数目">
		<![CDATA[
SELECT COUNT(1) COUNT
  FROM SLM_ORDER_DELIVERY_TRANSIT T
 WHERE T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getDeliveryTransitMxIndx" desc="获取运输线路信息最大序号+1">
		<![CDATA[
		SELECT NVL(MAX(to_number(T.INDEX_SEQ)), 0) + 1  MAX_VALUE
		  FROM SLM_ORDER_DELIVERY_TRANSIT T
		 WHERE T.ORD_PK = '#ORD_PK#'
		   AND T.ORD_LN_PK = '#ORD_LN_PK#'
		   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
		]]>
	</query>
	
		<query id="CoreOrderDelivery.deleteDeliveryTransit" desc="删除运输线路信息">
		<![CDATA[
UPDATE SLM_ORDER_DELIVERY_TRANSIT T
   SET T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE,
       T.VALIDFLAG   = '0'
 WHERE T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getOrdLnState" desc="删除运输线路信息">
		<![CDATA[
SELECT T.ORDER_LN_STATUS
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
		<query id="CoreOrderDelivery.saveOrderDlyHis" desc="删除运输线路信息">
		<![CDATA[
  	INSERT INTO CHGE_SLM_ORDER_DELIVERY_H
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DELIVERY_NO,
   DELVRY_BDATE,
   DELVRY_EDATE,
   DELVRY_QTY,
   ORDER_UNIT,
   WGT_ESTMT,
   ENSU_TOTL_LEN,
   RECEIV_NO,
   RECEIV_NM,
   DELVRY_ADDR,
   AGENCY_FL,
   RECEIV_ADDR,
   TRANSIT_TYP,
   TRANSIT_PLAN,
   TRANSIT_MNY,
   BE_DELIVERY_STATUS,
   BE_OBJ_STS_OP,
   DELIVERY_STATUS,
   OBJ_STS_OP,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME)

  SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DELIVERY_NO,
         DELVRY_BDATE,
         DELVRY_EDATE,
         DELVRY_QTY,
         ORDER_UNIT,
         WGT_ESTMT,
         ENSU_TOTL_LEN,
         RECEIV_NO,
         RECEIV_NM,
         DELVRY_ADDR,
         AGENCY_FL,
         RECEIV_ADDR,
         TRANSIT_TYP,
         TRANSIT_PLAN,
         TRANSIT_MNY,
         BE_DELIVERY_STATUS,
         BE_OBJ_STS_OP,
         DELIVERY_STATUS,
         OBJ_STS_OP,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME
    FROM SLM_ORDER_LINE_DELIVERY T
   WHERE T.ORD_LN_DLY_PK = ?
  	
		]]>
	</query>
	
	<query id="CoreOrderDelivery.queryQtyEnLen" desc="删除运输线路信息">
		<![CDATA[
 			SELECT ORDER_QTY,ORD_ENSU_TOTL_LEN
 			FROM SLM_ORDER_LINE 
 			WHERE ORD_LN_PK = ? AND VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderDelivery.queryDeliveryCount" desc="删除运输线路信息">
		<![CDATA[
 			  SELECT COUNT(1) FROM SLM_ORDER_LINE_DELIVERY T
 			  WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getOrderDlyLine" desc="删除运输线路信息">
		<![CDATA[
 			  SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       TRANSIT_TYP,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       EXTRA_FLAG

  FROM SLM_ORDER_LINE_DELIVERY T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.VALIDFLAG = '1'
 			  
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getOrderDlyLineTransit" desc="删除运输线路信息">
		<![CDATA[
 			 SELECT AGENCY_FL

  FROM SLM_ORDER_DELIVERY_TRANSIT T
  WHERE T.ORD_LN_DLY_PK = ?
  AND T.VALIDFLAG = '1'

		]]>
	</query>
	
		<query id="CoreOrderDelivery.getOrderDlyLineTransitChge" desc="删除运输线路信息">
		<![CDATA[
 			 SELECT AGENCY_FL

  FROM CHGE_SLM_ORDER_TRANSIT T
  WHERE T.ORD_LN_DLY_PK = ?
  AND T.VALIDFLAG = '1'

		]]>
	</query>
	
	<query id="CoreOrderDelivery.getOrderDlyLineChge" desc="删除运输线路信息">
		<![CDATA[
 			  SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       TRANSIT_TYP,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       EXTRA_FLAG

  FROM CHGE_SLM_ORDER_DELIVERY T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.VALIDFLAG = '1'
 			  
		]]>
	</query>
	
	<query id="CoreOrderDelivery.getOrdLnDlyPk" desc="获取交货行PK值">
		<![CDATA[
			 SELECT  MAX(T.ORD_LN_DLY_PK)  ORD_LN_DLY_PK
			 FROM  SLM_ORDER_LINE_DELIVERY T
			 WHERE T.ORD_LN_PK = ?
			  
		]]>
	</query>
	
	<query id = "CoreOrderDelivery.CopyDlyTransit" desc = "复制交货发运数据">
	
	<![CDATA[
	
	INSERT INTO SLM_ORDER_DELIVERY_TRANSIT
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   INDEX_SEQ,
   AGENCY_FL,
   TRANSIT_TYP,
   DESTINATION,
   STATION_NO,
   STATION_NM,
   SPCL_LN_NO,
   SPCL_LN_NM,
   PORT_NO,
   PORT_DESC,
   CARRIER_UNIT,
   RECEIVOR,
   TRANSIT_LN_MNY,
   CREATE_NAME,
   CREATE_TIME
   
   )

  SELECT ORD_PK,
         ORD_LN_PK,
         ?,
         INDEX_SEQ,
         AGENCY_FL,
         TRANSIT_TYP,
         DESTINATION,
         STATION_NO,
         STATION_NM,
         SPCL_LN_NO,
         SPCL_LN_NM,
         PORT_NO,
         PORT_DESC,
         CARRIER_UNIT,
         RECEIVOR,
         TRANSIT_LN_MNY,
         CREATE_NAME,
         CREATE_TIME

    FROM SLM_ORDER_DELIVERY_TRANSIT T
   WHERE T.ORD_LN_PK = ?
     AND T.ORD_LN_DLY_PK = (SELECT MIN(A.ORD_LN_DLY_PK)
                              FROM SLM_ORDER_DELIVERY_TRANSIT A
                             WHERE A.ORD_LN_PK = ?
                               AND A.VALIDFLAG = '1')
     AND T.VALIDFLAG = '1'

	
	]]>
	
	</query>
	
	 
	 
</queryMap>