<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="下线库钢管入库管理">
	<query id="FrmPipePayIn.queryStorage" desc="查询库存实绩">
	<![CDATA[
	  select 
	   max(t.mat_no) as mat_no,
       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.STEELNAME) as STEELNAME,
       max(t.GRADENAME) as GRADENAME,
       max(t.SPEC_NAME) as SPEC_NAME,
       max(t.MODEL_DESC) as MODEL_DESC,
       max(t.STD_NAME) as STD_NAME,
       max(t.STD_STYLE_DESC) as STD_STYLE_DESC,
       max(t.PRO_ORDER_NO) as PRO_ORDER_NO,
       t.PLINE_CODE,
       max(t.PLINE_NAME) as PLINE_NAME,
       max(t.CREATE_NAME) as CREATE_NAME,
       max(t.CREATE_TIME) as CREATE_TIME,
       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,   
       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 mat_zc_m T
  WHERE 1=1 and t.INSTOCK_FLAG='0'
	]]>
	</query>
    <query id="FrmPipePayIn.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="FrmPipePayIn.queryLibrary" desc="查询材料表主键信息">
	<![CDATA[
	SELECT mat_no FROM MAT_ZC_M 
	    where JUDGE_STOVE_NO=?
	    and BATCH_NO=?
	    --and BATCH_GROUD_NO=?
	    and PLINE_CODE=?
	    and rownum<?
    order by mat_no asc
	]]>
	</query>
	<query id="FrmPipePayIn.queryTager" desc="查询目标料位对应的层号，位置信息">
	<![CDATA[ 
	  SELECT 
		T.ROW_NO,T.COL_NO,B.STORAGE_ATTR,B.STORAGE_ATTR_NAME,B.STORAGE_TYPE_NO,
		B.STORAGE_TYPE_NAME,B.MANAGEMENT_NO,
		B.MANAGEMENT_NAME FROM YDM_BS_LOCATION T 
		LEFT JOIN YDM_BS_STORAGE B ON 
		T.STORAGE_NO=B.STORAGE_NO AND T.VALIDFLAG=B.VALIDFLAG
		WHERE B.STORAGE_NO=? 
		AND T.LOCATION_NO=? 
		AND T.VALIDFLAG='1'
	]]>
	</query>	
	<query id="FrmPipePayIn.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   
  from mat_zc_m t
  where t.mat_no=?
	]]>
	</query>
	<query id="FrmPipePayIn.AddSInList" desc="新增入库信息">
	<![CDATA[ 
	insert into ydm_zc_inlist (
		instock_sqe, instock_doc, instock_type_code, 
		instock_type_name, 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, 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, 
		in_bc, in_bz, create_name, create_time, instock_time 
		) 
	values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
		    ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
		    ?, to_date(?,'YYYY/MM/DD HH24:MI:SS'), ?, ?, ?, ?, ?, SYSDATE, SYSDATE )
	]]>
	</query>
	<query id="FrmPipePayIn.AddButtList" 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,
	create_name, create_time )
	values 
	(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE)
	]]>
	</query>
	<query id="FrmPipePayIn.querySqeList" desc="查询入库流水号">
	<![CDATA[
    select t.INSTOCK_SQE from ydm_zc_INLIST t where t.MAT_NO=? order by t.INSTOCK_SQE desc
	]]>
	</query>
	<query id="FrmPipePayIn.queryInList" desc="查询入库信息">
	<![CDATA[
   select
       t.judge_stove_no,
       t.batch_no,
       t.batch_groud_no,
       max(t.INSTOCK_TYPE_CODE) as INSTOCK_TYPE_CODE,
       max(t.INSTOCK_TYPE_NAME) as INSTOCK_TYPE_NAME,
       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 act_len_min,
       max(t.act_len_max) as act_len_max,    
       max(t.belong_name) as belong_name,
       t.storage_no ,
       t.location_no,
       max(c.storage_name) as storage_name,
       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.rpo_time) as rpo_time,
       max(t.create_name) as create_name,
       max(t.create_time) as create_time,
       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_inlist t
  LEFT JOIN YDM_BS_STORAGE C ON C.STORAGE_NO=t.STORAGE_NO
  where t.judge_stove_no LIKE '%' || ? || '%'
  --AND t.batch_no LIKE '%' || ? || '%' 
 --AND t.batch_groud_no LIKE '%' || ? || '%' 
  AND DECODE(?, NULL, '1', t.create_time) BETWEEN DECODE(?, NULL, '1', to_date(?, 'YYYY/MM/DD HH24:MI:SS')) 
  AND DECODE(?, NULL, '1', to_date(?, 'YYYY/MM/DD HH24:MI:SS')) 
  --AND DECODE(?, NULL, '1', t.rpo_time) BETWEEN DECODE(?, NULL, '1', to_date(?, 'YYYY/MM/DD HH24:MI:SS'))
  --AND DECODE(?, NULL, '1', to_date(?, 'YYYY/MM/DD HH24:MI:SS'))
  AND T.CREATE_NAME=?
  AND t.STORAGE_NO LIKE '%' || ? || '%' 
  AND t.LOCATION_NO LIKE '%' || ? || '%' 
  AND T.INSTOCK_TYPE_CODE=?
  AND T.VALIDFLAG='1'
  group by t.judge_stove_no,
           t.batch_no,
           t.batch_groud_no,
           t.storage_no,
           t.location_no
  order by t.judge_stove_no desc  
	]]>
	</query>
	<query id="FrmPipePayIn.queryInMat" desc="查询入库材料编码信息">
	<![CDATA[
	select INSTOCK_SQE,MAT_NO from ydm_zc_inlist 
     where JUDGE_STOVE_NO=?
		 and BATCH_NO=? 
		 and BATCH_GROUD_NO=? 
		 and instock_type_code=? 
		 and rownum <?
		 and VALIDFLAG='1'
     order by mat_no asc
	]]>
	</query>
</queryMap>