<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="钢管倒垛管理">
	<query id="FrmPipeStow.queryStorage" desc="查询库存实绩">
	<![CDATA[
	 select max(T.mat_no) as mat_no,
       T.judge_stove_no,
       T.batch_no,
       T.batch_groud_no,
       max(t.STEELNAME) as STEELNAME,
       max(t.GRADENAME) as GRADENAME,
       max(T.act_dimater) as act_dimater,
       max(T.act_height) as act_height,    
       max(T.act_len_min) as act_len_min,
       max(T.act_len_max) as act_len_max,   
       C.STORAGE_NAME,
       B.STORAGE_NO,
       B.LOCATION_NO,
       nvl(sum(T.act_count),0) as act_count
  from mat_zc_m T,YDM_ZC_BUTTRESS B
  --,YDM_BS_STORAGE C
  LEFT JOIN YDM_BS_STORAGE C ON C.STORAGE_NO = B.STORAGE_NO
  WHERE T.MAT_NO=B.MAT_NO
  --AND B.STORAGE_NO = C.STORAGE_NO
  AND B.STORAGE_NO LIKE '%'||?||'%'
  AND B.LOCATION_NO LIKE '%'||?||'%'
  AND T.judge_stove_no LIKE '%'||?||'%'
  
	]]>
	</query>
	<!-- AND T.batch_no LIKE '%'||?||'%'
  AND T.batch_groud_no LIKE '%'||?||'%'
  AND T.CREATE_NAME=?
  -->
    <query id="FrmPipeStow.queryStow" desc="查询当前料位信息">
	<![CDATA[
	 SELECT max(t.storage_no) as storage_no, t.LOCATION_NO,sum(a.ACT_COUNT) as ACT_COUNT
		FROM ydm_zc_buttress t
		,MAT_ZC_M a
		where 
		t.mat_no=a.mat_no
		and t.storage_no=?
		and t.JUDGE_STOVE_NO=?
		and t.BATCH_NO=?
		--and t.BATCH_GROUD_NO=?
		and t.location_no like '%'||?||'%'
		group by t.LOCATION_NO
		order by t.LOCATION_NO asc
	]]>
	</query>
	<query id="FrmPipeStow.queryLibrary" desc="查询材料表主键信息">
	<![CDATA[
	SELECT  t.mat_no
		FROM ydm_zc_buttress t,MAT_ZC_M a
		where 
		t.mat_no=a.mat_no
		and t.storage_no=?
		and t.JUDGE_STOVE_NO=?
		and t.BATCH_NO=?
		--and t.BATCH_GROUD_NO=?
		and t.LOCATION_NO=?
		and rownum<?
		order by t.mat_no asc
	]]>
	</query>
	<query id="FrmPipeStow.queryTager" desc="查询目标料位对应的层号，位置信息">
	<![CDATA[ 
	  select t.location_no,t.row_no,t.col_no from ydm_bs_location t
	  where t.location_no=?
	]]>
	</query>
	<query id="FrmPipeStow.queryLocaTarget" desc="查询目标料位信息">
	<![CDATA[ 
	 select LOCATION_NO from YDM_BS_LOCATION where storage_no LIKE '%'|| ? ||'%' and LOCATION_NO not in(?) order by LOCATION_NO asc
	]]>
	</query>
	<query id="FrmPipeStow.querySqeList" desc="查询倒垛流水号">
	<![CDATA[
   select t.stow_sqe from ydm_zc_stowlist t where t.MAT_NO=? order by t.stow_sqe desc
	]]>
	</query>
	<query id="FrmPipeStow.QueryAdd" desc="查询要倒垛的信息">
	<![CDATA[
	select T.MAT_NO,
       t.lot_no,
       t.stove_no,
       t.judge_stove_no,
       t.batch_no,
       t.batch_groud_no, 
       t.material_no,
       t.material_name,  
       t.produccode,
       t.producname,
       t.steelcode,
       t.steelname,
       t.gradecode,
       t.gradename,
       t.spec_code,
       t.spec_name,
       t.model_code,
       t.model_desc,
       t.std_code,
       t.std_name,
       t.std_style,
       t.std_style_desc,
       t.pro_order_no,
       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.belong_code,
       t.belong_name,
       t.pro_bc,
       t.pro_bz,
       t.rpo_time,
       b.STORAGE_NO,
       b.location_no,
       b.lary_no,
       b.loc_no,
       b.storage_attr,
       b.storage_attr_name, 
       b.storage_type_no,
       b.storage_type_name,
       b.management_no,
       b.management_name        
  from mat_zc_m t,ydm_zc_buttress b
  where t.mat_no=b.mat_no
  and  b.mat_no=?
	]]>
	</query>
	<query id="FrmPipeStow.AddStowList" desc="新增倒垛的信息">
	<![CDATA[ 
	insert into ydm_zc_stowlist (
		stow_sqe, 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, pro_order_no, 
		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, 
		rpo_time, pro_bc, pro_bz, stow_bc, stow_bz, location_no, lary_no, 
		loc_no, old_location_no, old_lary_no, old_loc_no, storage_attr, 
		storage_attr_name, storage_type_no, storage_type_name, management_no, 
		management_name,DEPARTMENT_CODE,DEPARTMENT_DESC, create_name,stow_time,create_time )
		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'))	
	]]>
	</query>
	<query id="FrmPipeStow.queryStowList" desc="查询新增倒垛的信息">
	<![CDATA[ 
	SELECT 
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       MAX(T.MATERIAL_NAME) AS MATERIAL_NAME,
       MAX(T.PRODUCNAME) AS PRODUCNAME,
       MAX(T.STD_NAME) AS STD_NAME,
       MAX(T.GRADENAME) AS GRADENAME,
       MAX(T.STEELNAME) AS STEELNAME,
       MAX(T.STD_STYLE_DESC) AS STD_STYLE_DESC,
       MAX(T.SPEC_NAME) AS SPEC_NAME,
       MAX(T.MODEL_DESC) AS MODEL_DESC,
       MAX(T.PRO_ORDER_NO) AS PRO_ORDER_NO,
       MAX(T.PLINE_NAME) AS PLINE_NAME,
       MAX(T.ACT_DIMATER) AS ACT_DIMATER,
       MAX(T.ACT_HEIGHT)AS ACT_HEIGHT, 
       MAX(T.ACT_LEN_MIN) AS MAXACT_LEN_MIN,
       MAX(T.ACT_LEN_MAX)AS ACT_LEN_MAX,    
       MAX(T.BELONG_NAME) AS BELONG_NAME,
       MAX(T.RPO_TIME) AS RPO_TIME,
       MAX(T.PRO_BC) AS PRO_BC,
       MAX(T.PRO_BZ) AS PRO_BZ,
       T.STOW_TIME,
       T.LOCATION_NO,
       MAX(T.LARY_NO) AS LARY_NO,
       MAX(T.LOC_NO) AS LOC_NO,
       T.OLD_LOCATION_NO,
       MAX(T.OLD_LARY_NO) AS OLD_LARY_NO,
       MAX(T.OLD_LOC_NO) AS OLD_LOC_NO,
       MAX(T.STORAGE_ATTR_NAME) AS STORAGE_ATTR_NAME,
       MAX(T.STORAGE_TYPE_NAME) AS STORAGE_TYPE_NAME,
       MAX(T.MANAGEMENT_NAME) AS MANAGEMENT_NAME,
       MAX(T.CREATE_NAME) AS CREATE_NAME,
       MAX(T.CREATE_TIME) AS CREATE_TIME,
       B.STORAGE_NO,
       MAX(C.storage_name) AS STORAGE_NAME,
       NVL(SUM(T.ACT_LEN),0) AS ACT_LEN,
       NVL(SUM(T.ACT_COUNT),0) AS ACT_COUNT,
       NVL(SUM(T.ACT_WEIGHT),0) AS ACT_WEIGHT,
       NVL(SUM(T.ACT_THEORY_WEIGHT),0) AS ACT_THEORY_WEIGHT
  FROM YDM_ZC_STOWLIST T
  LEFT JOIN YDM_ZC_BUTTRESS B ON T.MAT_NO=B.MAT_NO
  LEFT JOIN YDM_BS_STORAGE C ON C.STORAGE_NO=B.STORAGE_NO
  WHERE B.STORAGE_NO LIKE '%'||?||'%'
  AND T.LOCATION_NO LIKE '%'||?||'%'
  AND T.JUDGE_STOVE_NO LIKE '%'||?||'%'
  

  
	]]>
	</query>
	<!--   AND T.CREATE_NAME=?
	AND T.BATCH_NO LIKE '%'||?||'%'
  AND T.BATCH_GROUD_NO LIKE '%'||?||'%' -->
</queryMap>