<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="装车作业管理sql">
	<query id="FrmPipeSendList.QueryCustomer" desc="客户信息获取">
		<![CDATA[
	       SELECT CUSTOMER_NM,CUSTOMER_NO FROM SLM_BASE_CUSTOMER WHERE VALIDFLAG='1' ORDER  BY  CUSTOMER_NM ASC
		]]>
	</query>
	<query id="FrmPipeSendList.QueryProductName" desc="品名信息获取">
		<![CDATA[
	          SELECT PRODUCNAME,PRODUCCODE FROM COM_BASE_PRODUCT WHERE VALIDFLAG='1' ORDER  BY  PRODUCNAME ASC
		]]>
	</query>
	<query id="FrmPipeSendList.QueryPrivateSid" desc="专用线信息获取">
		<![CDATA[
	       SELECT SPCL_LN_NM,SPCL_LN_NO FROM SLM_BASE_SPCL_LN WHERE VALIDFLAG='1' ORDER  BY  SPCL_LN_NM ASC
		]]>
	</query>
	<query id="FrmPipeSendList.QueryArriveStation" desc="到站信息获取">
		<![CDATA[
	      SELECT STATION_NM,STATION_NO FROM SLM_BASE_STATION WHERE VALIDFLAG='1' ORDER  BY  STATION_NM ASC
		]]>
	</query>
	<query id="FrmPipeSendList.QuerySendList" desc="理货单号获取">
		<![CDATA[ 
     SELECT A.CREATE_TIME ,A.LOADVEHICLE_NO FROM ydm_zc_loadvehicle A 
      where  A.CREATE_TIME LIKE '%'||TO_DATE(?,'YYYY/MM/DD')||'%' 
      order by a.CREATE_TIME desc 
      ]]>
	</query>
	<query id="FrmPipeSendList.queryPerformance" desc="根据提单号查询装车实绩信息">
		<![CDATA[
	  SELECT T.loadvehicle_no,
		     decode(T.loadvehicle_type,'2','虚拟','1','实际') as loadvehicle_type,
		     decode(T.affirm_flag,'0','未确认','1','已确认') as affirm_flag,
		     T.vehicle_no,
		     decode(T.weigh_flag,'0','未过磅','1','已过磅') as weigh_flag,
		    decode(T.VALIDFLAG,'0','无效','1','有效') as VALIDFLAG,
		     t.PICKUP_NO 
		 FROM ydm_zc_loadvehicle T 
			   WHERE T.PICKUP_NO=?  and T.VALIDFLAG='1'
			   order by t.loadvehicle_no desc
		]]>
    </query>
   <query id="FrmPipeSendList.queryPerforInfo" desc="根据理货单号查询装车实绩是否有对应的理货单信息">
		<![CDATA[
	     SELECT T.loadvehicle_no,t.AFFIRM_FLAG,t.VALIDFLAG,t.pickup_no FROM ydm_zc_loadvehicle T WHERE T.loadvehicle_no=?
		]]>
	</query>
	<query id="FrmPipeSendList.queryMaterial" desc="根据理货单号查询装车材料表支数、重量、长度信息">
		<![CDATA[
       select sum(ACT_COUNT) AS ACT_COUNT,SUM(ACT_WEIGHT) AS ACT_WEIGHT,SUM(ACT_LEN) AS ACT_LEN FROM ydm_zc_loadvehicle_mat 
       WHERE LOADVEHICLE_NO= ? AND VALIDFLAG!='0'
		]]>
	</query>
	<query id="FrmPipeSendList.QuerySendSql" desc="查詢裝車序號信息">
		<![CDATA[
	    SELECT  MAX(A.LOADVEHICLE_SQE) AS LOADVEHICLE_SQE FROM Ydm_Zc_Loadvehicle_Mat A WHERE A.LOADVEHICLE_NO  = ?
		]]>
	</query>
	<query id="FrmPipeSendList.QueryBillSql" desc="按炉批行和提单号查询未理货提单材料主键">
		<![CDATA[
		SELECT BILL_SQE FROM YDM_ZC_BILL_C WHERE BILL_NO=? AND JUDGE_STOVE_NO=? AND BATCH_NO= ? AND GROUP_NO= ?  AND ROWNUM< ? AND EDIT_FLAG='0'
		]]>
	</query>
	<query id="FrmPipeSendList.QuerySqlBill" desc="按炉批行和提单号查询理货提单材料主键">
		<![CDATA[
		SELECT BILL_SQE FROM YDM_ZC_BILL_C WHERE BILL_NO=? AND JUDGE_STOVE_NO=? AND BATCH_NO= ? AND GROUP_NO= ?  AND ROWNUM< ? AND EDIT_FLAG='1'
		]]>
	</query>
	<query id="FrmPipeSendList.QueryLoadSql" desc="按炉批行和提单号查询装车材料主键">
		<![CDATA[
		 select LOADVEHICLE_SQE from Ydm_Zc_Loadvehicle_Mat where PICKUP_NO=? and JUDGE_STOVE_NO= ?  and  
		 BATCH_NO=? and GROUP_NO =?  and rownum<? AND VALIDFLAG = '1'
		]]>
	</query>
	<query id="FrmPipeSendList.QueryBillInfo" desc="查詢提單信息">
		<![CDATA[
	   select T.bill_no,T.send_plan_no,T.order_no ,T.order_seq,T.delivery_no,T.vstel_code,T.vstel_desc,
	      T.plan_trans_type,T.act_trans_type,T.station_no,T.station_nm,
		  T.spcl_ln_no,T.spcl_ln_nm,T.port_no,T.port_desc,T.delivy_place_code,
		  T.delivy_place_name,T.receiv_no,T.receiv_nm,T.carry_company_code,T.carry_company_name,
		  T.produccode,T.producname,T.plan_wt,T.plan_num,T.plan_totl_len,T.memo,t.STLMT_UNIT_NO,t.stlmt_unit_nm,
		  T.create_name,T.create_time, decode(T.BILL_STATUS,'0','关闭','1','下发') BILL_STATUS,
		  decode(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,t.CUSTOMER_NO,t.CUSTOMER_NM  from YDM_ZC_BILL_M T
        where T.BILL_NO LIKE '%'||?||'%'
        AND  T.CUSTOMER_NO  LIKE '%'||?||'%' 
        AND T.PRODUCCODE  LIKE '%'||?||'%' 
        AND T.SPCL_LN_NO  LIKE '%'||?||'%'
        AND T.DELIVY_PLACE_CODE  LIKE '%'||?||'%'
        AND T.STATION_NO LIKE '%'||?||'%'
        AND PLAN_START_TIME BETWEEN TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
        AND TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')  ORDER BY BILL_NO
		]]>
	</query>
	<query id="FrmPipeSendList.QueryMatInfo" desc="查詢物料信息">
		<![CDATA[
   SELECT A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO,max(A.BILL_NO) as BILL_NO ,max(A.PRODUCNAME) as PRODUCNAME,max(A.GRADENAME) as GRADENAME,
		 max(A.STEELNAME) as STEELNAME,max(A.SPEC_NAME) as SPEC_NAME ,max(A.MATERIAL_NAME) as MATERIAL_NAME,max(A.MODEL_DESC) as MODEL_DESC, 
		 max(decode(A.EDIT_FLAG,'0','未理货','1','已理货')) as  EDIT_FLAG,SUM(A.ACT_COUNT) AS PLAN_NUM,SUM(A.ACT_WEIGHT) AS PLAN_WT,
        SUM(A.ACT_LEN) AS PLAN_TOTL_LEN,SUM(A.ACT_LEN) AS ACT_LEN ,
        SUM(A.ACT_COUNT) AS ACT_COUNT,SUM(A.ACT_WEIGHT) AS ACT_WEIGHT        
	    FROM ydm_zc_bill_c A
	    LEFT JOIN ydm_zc_bill_m B ON B.BILL_NO=A.BILL_NO
	  WHERE B.BILL_NO = ? AND A.EDIT_FLAG='0'
    GROUP BY A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO
		]]>
	</query>
	<query id="FrmPipeSendList.QueryMatInfo1" desc="根据订单号、炉、批、组号查询库存支数">
		<![CDATA[
   SELECT A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO,max(A.BILL_NO) as BILL_NO ,max(A.PRODUCNAME) as PRODUCNAME,max(A.GRADENAME) as GRADENAME,
		 max(A.STEELNAME) as STEELNAME,max(A.SPEC_NAME) as SPEC_NAME ,max(A.MATERIAL_NAME) as MATERIAL_NAME,max(A.MODEL_DESC) as MODEL_DESC, 
		 max(decode(A.EDIT_FLAG,'0','未理货','1','已理货')) as  EDIT_FLAG,SUM(A.ACT_COUNT) AS PLAN_NUM,SUM(A.ACT_WEIGHT) AS PLAN_WT,
        SUM(A.ACT_LEN) AS PLAN_TOTL_LEN,SUM(A.ACT_LEN) AS ACT_LEN ,
        SUM(A.ACT_COUNT) AS ACT_COUNT,SUM(A.ACT_WEIGHT) AS ACT_WEIGHT        
    FROM ydm_zc_bill_c A
    LEFT JOIN ydm_zc_bill_m B ON B.BILL_NO=A.BILL_NO
    WHERE 
	    B.BILL_NO = ? 
   	    AND A.EDIT_FLAG='0'
   	 	AND A.JUDGE_STOVE_NO=?
        AND A.BATCH_NO=?
        AND A.GROUP_NO=?
    GROUP BY A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO
		]]>
	</query>
	<query id="FrmPipeSendList.QueryTallyInfo" desc="查詢理货信息">
		<![CDATA[
      SELECT max(A.LOADVEHICLE_NO) AS LOADVEHICLE_NO,A.PICKUP_NO,A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO,max(A.MATERIAL_NAME) AS MATERIAL_NAME,
		  max(A.PRODUCNAME) AS PRODUCNAME,max(A.GRADENAME) AS GRADENAME, max(A.STEELNAME) AS STEELNAME,max(A.ACT_DIMATER) AS ACT_DIMATER,max(A.ACT_HEIGHT) AS ACT_HEIGHT,
		  max(A.ACT_LEN_MIN) AS ACT_LEN_MIN,max(A.ACT_LEN_MAX) AS ACT_LEN_MAX,max(A.ACT_THEORY_WEIGHT) AS ACT_THEORY_WEIGHT,max(A.JUDGE_RESULT_CODE) AS JUDGE_RESULT_CODE,
		  max(A.PRO_BC) AS PRO_BC,max(A.PRO_BZ) AS PRO_BZ,max(A.RPO_TIME) AS RPO_TIME, max(decode(A.VALIDFLAG,'0','发运无效','1','发运有效','2','确认有效')) AS  VALIDFLAG,
		  max(A.MEMO) AS MEMO, max( A.CREATE_NAME) AS CREATE_NAME ,A.CREATE_TIME,max(a.TRANS_TPE) as TRANS_TPE,
		  sum(A.ACT_COUNT) AS ACT_COUNT,SUM(A.ACT_LEN) AS ACT_LEN ,SUM(A.ACT_WEIGHT) AS ACT_WEIGHT 
		  FROM Ydm_Zc_Loadvehicle_Mat A 
		  LEFT JOIN YDM_ZC_BILL_M B ON A.PICKUP_NO=B.BILL_NO
		  WHERE A.PICKUP_NO LIKE '%'||?||'%' AND A.LOADVEHICLE_NO LIKE '%'||?||'%' AND A.VALIDFLAG !='0'
 	 GROUP BY A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO,A.PICKUP_NO,A.CREATE_TIME
		]]>
	</query>
	<query id="FrmPipeSendList.QueryTallyInfo2" desc="查詢理货信息">
		<![CDATA[
	SELECT max(A.LOADVEHICLE_NO) AS LOADVEHICLE_NO,A.PICKUP_NO,A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO,max(A.MATERIAL_NAME) AS MATERIAL_NAME,
		  max(A.PRODUCNAME) AS PRODUCNAME,max(A.GRADENAME) AS GRADENAME, max(A.STEELNAME) AS STEELNAME,max(A.ACT_DIMATER) AS ACT_DIMATER,max(A.ACT_HEIGHT) AS ACT_HEIGHT,
		  max(A.ACT_LEN_MIN) AS ACT_LEN_MIN,max(A.ACT_LEN_MAX) AS ACT_LEN_MAX,max(A.ACT_THEORY_WEIGHT) AS ACT_THEORY_WEIGHT,max(A.JUDGE_RESULT_CODE) AS JUDGE_RESULT_CODE,
		  max(A.PRO_BC) AS PRO_BC,max(A.PRO_BZ) AS PRO_BZ,max(A.RPO_TIME) AS RPO_TIME, max(decode(A.VALIDFLAG,'0','发运无效','1','发运有效','2','确认有效','3','已传送到销售和质检')) AS  VALIDFLAG,
		  max(A.MEMO) AS MEMO, max( A.CREATE_NAME) AS CREATE_NAME ,A.CREATE_TIME,max(a.TRANS_TPE) as TRANS_TPE,
		  sum(A.ACT_COUNT) AS ACT_COUNT,SUM(A.ACT_LEN) AS ACT_LEN ,SUM(A.ACT_WEIGHT) AS ACT_WEIGHT 
		  FROM Ydm_Zc_Loadvehicle_Mat A 
		  LEFT JOIN YDM_ZC_BILL_M B ON A.PICKUP_NO=B.BILL_NO
    WHERE A.PICKUP_NO LIKE '%'||?||'%'
        AND B.CUSTOMER_NO  LIKE '%'||?||'%' 
        AND B.PRODUCCODE  LIKE '%'||?||'%' 
        AND B.SPCL_LN_NO  LIKE '%'||?||'%'
        AND B.DELIVY_PLACE_CODE  LIKE '%'||?||'%'
        AND B.STATION_NO LIKE '%'||?||'%'
        AND A.CREATE_TIME BETWEEN TO_DATE(?,'YYYY/MM/DD HH24:MI:SS')
        AND TO_DATE(?,'YYYY/MM/DD HH24:MI:SS')
        AND A.VALIDFLAG !='0'
     GROUP BY A.JUDGE_STOVE_NO,A.BATCH_NO,A.GROUP_NO,A.PICKUP_NO,A.CREATE_TIME  
		]]>
	</query>
	<query id="FrmPipeSendList.QueryAddSend" desc="查询要新增的数据">
		<![CDATA[
		select A.ORDER_NO,A.ORDER_SEQ,A.DELIVERY_NO,B.MAT_NO,B.LOT_NO,B.JUDGE_STOVE_NO,B.BATCH_NO,B. GROUP_NO
			,B.STOVE_NO,B.MATERIAL_NO,B.MATERIAL_NAME,B.PRODUCCODE,B.PRODUCNAME,B.STD_CODE,B.STD_NAME,B.GRADECODE,
			 B.GRADENAME,B.STEELCODE,B.STEELNAME,B.STD_STYLE,B.STD_STYLE_DESC,B.SPEC_CODE,B.SPEC_NAME,B.MODEL_CODE,
			 B.MODEL_DESC,B.PLINE_CODE,B.PLINE_NAME,B.ACT_DIMATER,B.ACT_HEIGHT,B.ACT_LEN_MIN,B.ACT_LEN_MAX,
			 B.ACT_LEN,B.ACT_COUNT,B.ACT_WEIGHT,B.ACT_THEORY_WEIGHT,B.JUDGE_RESULT_CODE,B.PRO_BC,B.PRO_BZ,
			 to_char(B.RPO_TIME,'yyyy/MM/dd hh24:mi:ss') as RPO_TIME,
			 A.SALE_ORG,A.SALE_ORG_DESC,A.ACT_TRANS_TYPE,A.RECEIV_NO,A.RECEIV_NM,A.STATION_NO,A.STATION_NM,
			 A.SPCL_LN_NO,A.SPCL_LN_NM,A.PORT_DESC,A.VSTEL_CODE,A.VSTEL_DESC,A.CARRY_COMPANY_CODE,A.CARRY_COMPANY_NAME,
			 A.DELIVY_PLACE_CODE,A.DELIVY_PLACE_NAME,A.STLMT_UNIT_NO,A.STLMT_UNIT_NM  
			from ydm_zc_bill_M A
			LEFT JOIN ydm_zc_bill_C B ON B.BILL_NO=A.BILL_NO 
		WHERE A.BILL_NO = ?  AND B.BILL_SQE = ?
		]]>
	</query>
	<query id="FrmPipeSendList.AddTallyInfo" desc="新增理货信息">
		<![CDATA[
    insert into ydm_zc_loadvehicle_mat (loadvehicle_sqe,loadvehicle_no,pickup_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,pline_code,pline_name ,act_dimater,act_height,act_len_min ,act_len_max ,act_len,act_count,act_weight,act_theory_weight,
			judge_result_code ,pro_bc,pro_bz
			,rpo_time
			,sale_org,sale_org_desc,trans_tpe,receiv_no ,receiv_nm,station_no,station_nm,spcl_ln_no,
			spcl_ln_nm,port,vstel ,vstel_desc ,carry_company_code,carry_company_name ,delivy_place_code,delivy_place_name ,stlmt_unit_no ,
			stlmt_unit_nm ,memo,create_name ,create_time
			)
	values
	(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
	--,?
	,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
	,to_date(?,'YYYY/MM/DD HH24:MI:SS')
	,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE
	)
		]]>
	</query>
	<query id="FrmPipeSendList.addPerformance" desc="新增装车实绩表信息">
		<![CDATA[
       insert into ydm_zc_loadvehicle
		  (loadvehicle_no,
		   loadvehicle_type,
		   pickup_no,
		   vehicle_no,
		   trans_type,
		   receiv_no,
		   receiv_nm,
		   station_no,
		   station_nm,
		   spcl_ln_no,
		   spcl_ln_nm,
		   port,
		   vstel_code,
		   vstel_desc,
		   carry_company_code,
		   carry_company_name,
		   stacking_wt,
		   stacking_piece,
		   stacking_totl_len,
		   weigh_flag,
		   delivy_place_code,
		   delivy_place_name,
		   stlmt_unit_no,
		   stlmt_unit_nm,
		   load_time,
		   create_name,
		   create_time)
		values
		  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,?,SYSDATE) 
		]]>
	</query>
	<query id="FrmPipeSendList.DeleteTaly" desc="修改理货信息状态标志">
		<![CDATA[
		UPDATE YDM_ZC_LOADVEHICLE_MAT SET VALIDFLAG = '0',DELETE_NAME=?,DELETE_TIME=sysdate WHERE LOADVEHICLE_SQE IN(?)
		]]>
	</query>
	<query id="FrmPipeSendList.updatePerformance" desc="修改装车实绩表的支数、重量、总长度">
		<![CDATA[
		update ydm_zc_loadvehicle
		   set 
		       stacking_wt = ?,
		       stacking_piece = ?,
		       stacking_totl_len = ?
		 where LOADVEHICLE_NO= ? and  AFFIRM_FLAG='0'
		]]>
	</query>
	<query id="FrmPipeSendList.updatePerfor" desc="修改装车实绩表状态位">
		<![CDATA[
		 update ydm_zc_loadvehicle set VALIDFLAG='0'  where LOADVEHICLE_NO= ? and  AFFIRM_FLAG='0' 
		]]>
	</query>
	<query id="FrmPipeSendList.updateMaterial" desc="修改装车材料表状态位">
		<![CDATA[
		 update ydm_zc_loadvehicle_mat set 
             VALIDFLAG='0'
         where  LOADVEHICLE_NO=? and PICKUP_NO=? and  VALIDFLAG='1'
		]]>
	</query>
	<query id="FrmPipeSendList.querySendAll" desc="查询理货信息">
		<![CDATA[
	select t.loadvehicle_sqe,
		t.loadvehicle_no,
		t.pickup_no,
		t.mat_no,
		t.judge_stove_no,
		t.batch_no,
		t.group_no   
	from ydm_zc_loadvehicle_mat t 
	 where t.PICKUP_NO=? and t.LOADVEHICLE_NO=? 
		]]>
	</query>
	<query id="FrmPipeSendList.updateMatAll" desc="修改订单材料表状态位">
		<![CDATA[
	  update YDM_ZC_BILL_C set EDIT_FLAG='0' where BILL_NO=? and MAT_NO=?
		]]>
	</query>
</queryMap>