<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍收料">
	<query id="FrmCollarInBound.queryOutPerfo" desc="查询交易表倒库实绩">		
        <![CDATA[
        SELECT MACH_NM,
       DEAL_NUM,
       DEAL_WT,
       TO_CHAR(DEAL_TIME, 'YYYY-MM-DD HH24:MI:SS') DEAL_TIME,
       STORAGE_NO,
       LOCATION_NO,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NAME,
       TAR_STORAGE_NO,
       TAR_LOCATION_NO,
       TAR_STORAGE_ATTR_NAME,
       TAR_STORAGE_TYPE_NAME,
       DECODE(TAR_REC_FLAG, '0', '未接收', '1', '已接收') TAR_REC_FLAG,
       DECODE(HAND_FLAG, '0', '自动', '1', '人工') HAND_FLAG,
       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,
       DEAL_ORDE,
       DEAL_TYPE_CODE,
       DEAL_TYPE_NAME,
       SOURCE_CODE,
       SOURCE_NAME,
       TAR_CODE,
       TAR_NAME,
       KEP_NO,
       TAR_KEP_NO,
       MAT_NO,
       RESULT_NO,
       ZY_PLAN_ID,
       PRO_PLAN_ID,
       PLINE_CODE,
       PLINE_NAME,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BL_WL_DESC,
       MIN_D,
       MIN_H,
       CODE_JG,
       GRADENAME,     
       STEELNAME,     
       MODEL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       SPEC_JG_DESC,
       STYLE_JG,
       DIAMETER,
       CHECK_J_VAL,
       AIMLENGTH,
       SINGLEWEIGHT,
       MONITORDEMAND,
       IF_MONITOR_JG,
       PRDCR_NO,
       PRODUCER,
       WO_ID,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME
  FROM COUPLING_MAT_DEAL
 WHERE 1 = 1  
       ]]>
	</query>
	<query id="FrmCollarInBound.queryInPerfo" desc="查询交易表入库实绩">		
        <![CDATA[
        SELECT MACH_NM,
       DEAL_NUM,
       DEAL_WT,
       TO_CHAR(DEAL_TIME, 'YYYY-MM-DD HH24:MI:SS') DEAL_TIME,
       STORAGE_NO,
       LOCATION_NO,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NAME,
       TAR_STORAGE_NO,
       TAR_LOCATION_NO,
       TAR_STORAGE_ATTR_NAME,
       TAR_STORAGE_TYPE_NAME,
       DECODE(TAR_REC_FLAG, '0', '未接收', '1', '已接收') TAR_REC_FLAG,
       DECODE(HAND_FLAG, '0', '自动', '1', '人工') HAND_FLAG,
       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,
       DEAL_ORDE,
       DEAL_TYPE_CODE,
       DEAL_TYPE_NAME,
       SOURCE_CODE,
       SOURCE_NAME,
       TAR_CODE,
       TAR_NAME,
       KEP_NO,
       TAR_KEP_NO,
       MAT_NO,
       RESULT_NO,
       ZY_PLAN_ID,
       PRO_PLAN_ID,
       PLINE_CODE,
       PLINE_NAME,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BL_WL_DESC,
       MIN_D,
       MIN_H,
       CODE_JG,
       GRADENAME,     
       STEELNAME,     
       MODEL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       SPEC_JG_DESC,
       STYLE_JG,
       DIAMETER,
       CHECK_J_VAL,
       AIMLENGTH,
       SINGLEWEIGHT,
       MONITORDEMAND,
       IF_MONITOR_JG,
       PRDCR_NO,
       PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       WO_ID
  FROM COUPLING_MAT_DEAL
 WHERE 1 = 1
       ]]>
	</query>
	<query id="FrmCollarInBound.AddDealResult" desc="新增交易信息">
		<![CDATA[
DECLARE
BEGIN
		INSERT INTO COUPLING_MAT_DEAL (DEAL_TYPE_CODE, DEAL_TYPE_NAME, SOURCE_CODE, 
SOURCE_NAME, TAR_CODE, TAR_NAME, KEP_NO, MAT_NO, RESULT_NO, ZY_PLAN_ID, 
PRO_PLAN_ID, PLINE_CODE, PLINE_NAME, JUDGE_STOVE_NO, BATCH_NO, BL_WL_ID, 
BL_WL_DESC, MIN_D, MIN_H, CODE_JG, GRADECODE, 
GRADENAME, STEELCODE, STEELNAME, MODEL_CODE, MODEL_DESC, OUTDIAMETER, WALLTHICK, 
SPEC_JG, SPEC_JG_DESC, STYLE_JG, DIAMETER, CHECK_J_VAL, AIMLENGTH, SINGLEWEIGHT, 
MONITORDEMAND, IF_MONITOR_JG, PRDCR_NO, PRODUCER, PRODUCER_TIME, MACH_NO, 
MACH_NM, DEAL_NUM, DEAL_WT, DEAL_TIME, STORAGE_NO, LOCATION_NO, STORAGE_ATTR, 
STORAGE_ATTR_NAME, STORAGE_TYPE_NO, STORAGE_TYPE_NAME, TAR_STORAGE_NO, 
TAR_LOCATION_NO, TAR_STORAGE_ATTR, TAR_STORAGE_ATTR_NAME, TAR_STORAGE_TYPE_NO, 
TAR_STORAGE_TYPE_NAME, TAR_REC_FLAG, HAND_FLAG, DEMAND_COPPER, DEMAND_DETECTION, 
DEMAND_BLAST, DEMAND_BONDERIZING, CUST_ALPHA_NO, ORDER_SPECIAL_DESC, ALPHA_CODE, 
COL_OPERATOR, MEMO, CREATE_NAME, 
CREATE_TIME, TAR_KEP_NO,WO_ID,DEAL_ORDE) SELECT  ?, ?, T.SOURCE_CODE, T.SOURCE_NAME, T.TAR_CODE, 
T.TAR_NAME, T.KEP_NO, T.MAT_NO, T.RESULT_NO, T.ZY_PLAN_ID, T.PRO_PLAN_ID, 
T.PLINE_CODE, T.PLINE_NAME, T.JUDGE_STOVE_NO, T.BATCH_NO, T.BL_WL_ID, 
T.BL_WL_DESC, T.MIN_D, T.MIN_H,T.CODE_JG, 
T.GRADECODE, T.GRADENAME, T.STEELCODE, T.STEELNAME, T.MODEL_CODE, T.MODEL_DESC, 
T.OUTDIAMETER, T.WALLTHICK, T.SPEC_JG, T.SPEC_JG_DESC, T.STYLE_JG, T.DIAMETER, 
T.CHECK_J_VAL, T.AIMLENGTH, T.SINGLEWEIGHT, T.MONITORDEMAND, T.IF_MONITOR_JG, 
T.PRDCR_NO, T.PRODUCER, T.PRODUCER_TIME, T.MACH_NO, T.MACH_NM, T.DEAL_NUM, 
T.DEAL_WT, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), T.STORAGE_NO, T.LOCATION_NO, 
T.STORAGE_ATTR, T.STORAGE_ATTR_NAME, T.STORAGE_TYPE_NO, T.STORAGE_TYPE_NAME, 
T.TAR_STORAGE_NO, T.TAR_LOCATION_NO, T.TAR_STORAGE_ATTR, 
T.TAR_STORAGE_ATTR_NAME, T.TAR_STORAGE_TYPE_NO, T.TAR_STORAGE_TYPE_NAME, '1', 
'0', T.DEMAND_COPPER, T.DEMAND_DETECTION, T.DEMAND_BLAST, T.DEMAND_BONDERIZING, 
T.CUST_ALPHA_NO, T.ORDER_SPECIAL_DESC, T.ALPHA_CODE, T.COL_OPERATOR,  '', ?,
 TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), T.TAR_KEP_NO,?,? FROM COUPLING_MAT_DEAL T 
 WHERE T.DEAL_ORDE = ?;
 UPDATE COUPLING_MAT_DEAL 
     SET TAR_REC_FLAG='1', 
         UPDATE_NAME  = ?,
         UPDATE_TIME  = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE DEAL_ORDE=?;
    END;
	]]>
	</query>
	<query id="FrmCollarInBound.updateButter" desc="修改位置表">
		<![CDATA[
UPDATE COUPLING_MAT_BUTTRESS
   SET UPDATE_NAME       = ?,
       UPDATE_TIME       = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE STORAGE_NO = ?
     AND MAT_NO = ?
	]]>
	</query>
	<query id="FrmCollarInBound.deleteDealResult" desc="删除交易信息">
		<![CDATA[	
	DECLARE
BEGIN
  DELETE COUPLING_MAT_DEAL WHERE  DEAL_TYPE_CODE = '800703' AND DEAL_ORDE = ? ;
  UPDATE COUPLING_MAT_DEAL T
     SET TAR_REC_FLAG = '0',
         UPDATE_NAME  = ?,
         UPDATE_TIME  = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.DEAL_TYPE_CODE = '800803'
     AND T.TAR_STORAGE_NO = ?
     AND T.MAT_NO = ?;
END;
		]]>
	</query>
	<query id="FrmCollarInBound.queryRecFalg" desc="查询交易表该数据接收状态">
		<![CDATA[
		SELECT T.TAR_REC_FLAG FROM COUPLING_MAT_DEAL T WHERE T.DEAL_ORDE = ?
			]]>
	</query>
	<query id="FrmCollarInBound.queryDeleteRecFalg" desc="查询交易表该数据接收状态">
		<![CDATA[
		SELECT T.TAR_REC_FLAG
  FROM COUPLING_MAT_DEAL T
 WHERE T.DEAL_TYPE_CODE = '800803'
   AND T.TAR_STORAGE_NO = ?
   AND T.MAT_NO = ?
			]]>
	</query>

	<query id = "FrmCollarInBound.doQueryCount" desc = "查询单号下未接收">
		SELECT NVL(SUM(T.DEAL_WT), 0) DEAL_WT
		FROM COUPLING_MAT_DEAL T
		WHERE T.DEAL_ORDE = ?
		AND T.TAR_REC_FLAG = '0'
		AND T.QCM_STAUS IN('00','11')
	</query>

</queryMap>