<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="钢管倒库入库管理">
	<query id="FrmPipeMoveIn.queryOutPerfo" desc="查询倒库实绩">
    <![CDATA[
	SELECT T.OUTSTOCK_DOC,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NAME,
       T.PRODUCNAME,
       T.STD_NAME,
       T.GRADENAME,
       T.STEELNAME,
       T.STD_STYLE_DESC,
       T.SPEC_NAME,
       T.MODEL_DESC,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.BELONG_NAME,
       MIN(TO_CHAR(T.RPO_TIME, 'YYYY-MM-DD HH24:MI:SS')) AS RPO_TIME,
       T.PRO_BC,
       T.PRO_BZ,
       T.TAR_STORAGE_NO,
       T.TAR_LOCATION_NO,
       B.STORAGE_NAME,
       T.TAR_STORAGE_ATTR_NAME,
       T.TAR_STORAGE_TYPE_NAME,
       T.MANAGEMENT_NAME,
       T.CREATE_NAME,
       MIN(TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS')) AS CREATE_TIME,
       DECODE(T.TAR_REC_FLAG, '0', '未接受', '1', '已接受') AS TAR_REC_FLAG,
       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_outlist T
  LEFT JOIN YDM_BS_STORAGE B ON B.STORAGE_NO=T.TAR_STORAGE_NO
  where  T.VALIDFLAG = '1'
  AND T.TAR_REC_FLAG='0'
     ]]>
	</query>
	<query id="FrmPipeMoveIn.queryInList" desc="查询入库流水号">
	<![CDATA[
   SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.INSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS INSTOCK_SQE
    FROM YDM_ZC_INLIST T
   WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') =?
     AND T.INSTOCK_DOC = ?
	]]>
	</query>
	<query id="FrmPipeMoveIn.queryInDocList" desc="查询入库单号">
	<![CDATA[
   SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.INSTOCK_DOC), '00000'), -5, 5) + 1, 5, '0') AS INSTOCK_DOC
    FROM YDM_ZC_INLIST T
   WHERE TRUNC(T.CREATE_TIME) = TRUNC(SYSDATE)
     AND T.INSTOCK_TYPE_CODE =?
	]]>
	</query>
	<query id="FrmPipeMoveIn.queryOutSqe" desc="根据炉批组号查询出库实绩主键">
	<![CDATA[
SELECT MAT_NO
  FROM YDM_ZC_INLIST T
 WHERE T.VALIDFLAG = '1'
   AND T.INSTOCK_TYPE_CODE = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND T.INSTOCK_DOC = ?

	]]>
	</query>
	<query id="FrmPipeMoveIn.queryTager" desc="查询目标库号信息">
	<![CDATA[
	SELECT b.ROW_NO,b.COL_NO,t.STORAGE_ATTR,t.STORAGE_ATTR_NAME,t.STORAGE_TYPE_NO,t.STORAGE_TYPE_NAME,
		t.MANAGEMENT_NO,t.MANAGEMENT_NAME,b.location_no FROM ydm_bs_storage t
		left join YDM_BS_LOCATION b on t.STORAGE_NO=b.storage_no
   WHERE t.STORAGE_NO=? and b.location_no=?
	]]>
	</query>
	<query id="FrmPipeMoveIn.QueryAdd" desc="查询要新增的入库信息">
	<![CDATA[
	SELECT OUTSTOCK_SQE,
       OUTSTOCK_DOC,
       VEHICLE_NO,
       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,
       TAR_STORAGE_NO,
       TAR_LOCATION_NO,
       TAR_LARY_NO,
       TAR_LOC_NO,
       TAR_STORAGE_ATTR,
       TAR_STORAGE_ATTR_NAME,
       TAR_STORAGE_TYPE_NO,
       TAR_STORAGE_TYPE_NAME,
       TAR_MANAGEMENT_NO,
       TAR_MANAGEMENT_NAME,
       TAR_DEPARTMENT_CODE,
       TAR_DEPARTMENT_DESC,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       FINISHPRO_MOLD,
       IN_MOLD
  FROM YDM_ZC_OUTLIST
 WHERE VALIDFLAG = '1'
   AND TAR_REC_FLAG = '0'
   AND OUTSTOCK_TYPE_CODE='800803'
   AND JUDGE_STOVE_NO = ?
   AND BATCH_NO = ?
   AND BATCH_GROUD_NO = ?
   AND OUTSTOCK_DOC = ?
   ORDER BY OUTSTOCK_SQE ASC
	]]>
	</query>
	<query id="FrmPipeMoveIn.AddMoveList" desc="新增到入库实绩表">
	<![CDATA[
	INSERT INTO YDM_ZC_INLIST (
    INSTOCK_SQE, INSTOCK_DOC, INSTOCK_TYPE_CODE, 
    INSTOCK_TYPE_NAME, VEHICLE_NO, 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, INSTOCK_TIME, CREATE_TIME,DEPARTMENT_CODE,DEPARTMENT_DESC,ORD_PK,ORD_LN_PK ,
    ORD_LN_DLY_PK ,ORDER_NO ,ORDER_SEQ ,DELIVERY_NO,PRODUCT_FLAG,MAT_STATUS,IN_TIME_F,AFFIRM_LOG, FINISHPRO_MOLD ,IN_MOLD 
    ) 
  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'),?,?,?,?,
      ?,?,?,?,?,?,TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),'1',?,?)
  ]]>
	</query>
	<query id="FrmPipeMoveIn.queryInListInfo" desc="查询入库实绩表">
	<![CDATA[
      SELECT T.INSTOCK_DOC,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NAME,
       T.PRODUCNAME,
       T.STD_NAME,
       T.GRADENAME,
       T.STEELNAME,
       T.STD_STYLE_DESC,
       T.SPEC_NAME,
       T.MODEL_DESC,
       T.PRO_ORDER_NO,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.BELONG_NAME,
       T.STORAGE_NO,
       T.LOCATION_NO,
       B.STORAGE_NAME,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NAME,
       MIN(TO_CHAR(T.RPO_TIME, 'YYYY-MM-DD HH24:MI:SS')) AS RPO_TIME,
       T.CREATE_NAME,
       MIN(TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH:MM:SS')) 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 B
    ON B.STORAGE_NO = T.STORAGE_NO
  where  T.VALIDFLAG='1'
  
	]]>
	</query>
	
	<query id="FrmPipeMoveIn.queryInListInfo1" desc="查询半成品入库实绩表">
	<![CDATA[
      SELECT T.INSTOCK_DOC,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NAME,
       T.PRODUCNAME,
       T.STD_NAME,
       T.GRADENAME,
       T.STEELNAME,
       T.STD_STYLE_DESC,
       T.SPEC_NAME,
       T.MODEL_DESC,
       T.PRO_ORDER_NO,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.BELONG_NAME,
       T.STORAGE_NO,
       T.LOCATION_NO,
       B.STORAGE_NAME,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NAME,
       MIN(TO_CHAR(T.RPO_TIME, 'YYYY-MM-DD HH24:MI:SS')) AS RPO_TIME,
       T.CREATE_NAME,
       MIN(TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH:MM:SS')) 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 MAT_ZC_M S,YDM_ZC_INLIST T
  LEFT JOIN YDM_BS_STORAGE B
    ON B.STORAGE_NO = T.STORAGE_NO
  where  S.MAT_NO = T.MAT_NO AND T.VALIDFLAG='1'
  
	]]>
	</query>
	
	<query id="FrmPipeMoveIn.queryOutCount" desc="查询库存是否在库">
	<![CDATA[  
  SELECT  M.MAT_STATUS
    FROM MAT_ZC_M M, YDM_ZC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
     AND M.JUDGE_STOVE_NO = ?
     AND M.BATCH_NO = ?
     AND M.BATCH_GROUD_NO = ?
     GROUP BY M.MAT_STATUS
	]]>
	</query>
	<query id="FrmPipeMoveIn.queryOutListSend" desc="根据出库单号查询出库实绩表">
	<![CDATA[
	select  t.OUTSTOCK_DOC,
       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.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,
       max(t.rpo_time) as rpo_time,
       max(t.pro_bc) as pro_bc,
       max(t.pro_bz) as pro_bz,
       t.TAR_STORAGE_NO,
       t.TAR_LOCATION_NO,
       max(B.storage_naem) as storage_name,
       max(t.TAR_STORAGE_ATTR_NAME) as TAR_STORAGE_ATTR_NAME ,
       max(t.TAR_STORAGE_TYPE_NAME) as TAR_STORAGE_TYPE_NAME,
       max(t.management_name) as management_name,
       max(t.create_name) as create_name,
       max(t.create_time) as create_time,
       decode(t.TAR_REC_FLAG,'0','未接受','1','已接受') as TAR_REC_FLAG,
       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_outlist t
  LEFT JOIN YDM_BS_STORAGE B ON B.STORAGE_NO=t.TAR_STORAGE_NO
  where  1=1 
   
  
	]]>
	</query>
	<query id="FrmPipeMoveIn.AddButressList" desc="新增位置表信息">
	<![CDATA[
		INSERT INTO
		YDM_ZC_BUTTRESS
		(MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		CREATE_NAME,
		CREATE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		LARY_NO,
		LOC_NO)
		VALUES
		(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?)
		]]>
	</query>
	<query id="FrmPipeMoveIn.updateOutfalgList" desc="修改倒库标志">
	<![CDATA[
UPDATE YDM_ZC_OUTLIST
   SET TAR_REC_FLAG = ?,
       INSTOCK_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       IN_BC        = ?,
       IN_BZ        = ?,
       UPDATE_NAME  = ?,
       UPDATE_TIME  = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE OUTSTOCK_SQE = ?

		]]>
	</query>
	<query id="FrmPipeMoveIn.updateOutfalgList1" desc="修改倒库标志">
	<![CDATA[
UPDATE YDM_ZC_OUTLIST
   SET TAR_REC_FLAG = ?,
       INSTOCK_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       IN_BC        = ?,
       IN_BZ        = ?,
       UPDATE_NAME  = ?,
       UPDATE_TIME  = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE MAT_NO = ?
 AND OUTSTOCK_TYPE_CODE=?
		]]>
	</query>
	<query id="FrmPipeMoveIn.deleteMoveList" desc="删除入库表">
	<![CDATA[
DELETE YDM_ZC_INLIST T
 WHERE T.VALIDFLAG = '1'
   AND T.INSTOCK_TYPE_CODE = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND T.INSTOCK_DOC = ?
		]]>
	</query>
	<query id="FrmPipeMoveIn.deleteButressList" desc="删除位置表">
	<![CDATA[
DELETE FROM YDM_ZC_BUTTRESS T WHERE T.MAT_NO=?
		]]>
	</query>
</queryMap>