<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍公共信息">
	<query id="FrmCollarOutBound.queryInventory" desc="查询接箍材料信息">		
        <![CDATA[
  SELECT T.MAT_NO,
       T.RESULT_NO,
       T.ZY_PLAN_ID,
       T1.PRO_PLAN_ID,
       T.PLINE_NAME,
       T.PLINE_CODE,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BL_WL_DESC,
       T.MIN_D,
       T.MIN_H,
       T.GRADENAME,
       T.STEELNAME,
       T.MODEL_DESC,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.SPEC_JG_DESC,
       NVL(T.AIMLENGTH, 0) AIMLENGTH,
       NVL(T.SINGLEWEIGHT, 0) SINGLEWEIGHT,
       NVL(T1.PIECES, 0) PRO_NUM,
       NVL(T1.WEIGHT, 0) PRO_WT,
       NVL(T1.PIECES, 0) PLA_COUNT,
       NVL(T1.WEIGHT, 0) PLA_WEIGHT,
       TO_CHAR(T.RRO_TIME, 'YYYY-MM-DD HH24:MI:SS') RRO_TIME,
       DECODE(T.PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       DECODE(T.PRO_SHIFT, '0', '常白', '1', '早', '2', '中', '3', '晚') PRO_SHIFT,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.KEP_NO,
       T1.STORAGE_NO,
       (SELECT B.STORAGE_NAME
          FROM YDM_BS_STORAGE B
         WHERE B.STORAGE_NO = T1.STORAGE_NO
           AND B.VALIDFLAG = '1') STORAGE_NAME,
       T1.LOCATION_NO,
       T.WO_ID,
       T1.MAT_NO_XH
  FROM COUPLING_MAT_M T, COUPLING_MAT_BUTTRESS T1
 WHERE T.MAT_NO = T1.MAT_NO
 AND T.QCM_STAUS NOT IN ('11', '22', '12')
     /*AND T1.MAT_STATUS in ('80150102', '80150202')*/
        ]]>
	</query>
	<query id="FrmCollarOutBound.queryOutPerfo" desc="查询交易表倒库实绩">		
        <![CDATA[
SELECT MACH_NM,
       NVL(DEAL_NUM,0) DEAL_NUM,
       NVL(DEAL_WT,0) 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,
       NVL(SINGLEWEIGHT,0) 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 t
 WHERE 1 = 1 
       ]]>
	</query>
	<query id="FrmInformation.getQueryGX" desc="查询工序">
		<![CDATA[
		SELECT
          T.BASECODE,
       T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = '7003'
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	<query id="FrmCollarOutBound.QUERYMatButterResult" desc="查询新增信息">
		<![CDATA[
		SELECT T.MAT_NO,
       T.RESULT_NO,
       T.WO_ID,
       T.ZY_PLAN_ID,
       B.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,
       B.MACH_NO,
       B.MACH_NM,
       nvl(B.PIECES,0)            PRO_NUM,
       nvl(B.WEIGHT,0)           PRO_WT,
       T.RRO_TIME,
       T.PRO_SHIFT,
       T.PRO_GROUP,
       T.DEMAND_COPPER,
       T.DEMAND_DETECTION,
       T.DEMAND_BLAST,
       T.DEMAND_BONDERIZING,
       B.CUST_ALPHA_NO,
       B.ORDER_SPECIAL_DESC,
       B.ALPHA_CODE,
       T.COL_OPERATOR,
       B.KEP_NO,
       B.STORAGE_NO,
       B.LOCATION_NO,
       B.STORAGE_ATTR,
       B.STORAGE_ATTR_NAME,
       B.STORAGE_TYPE_NO,
       B.STORAGE_TYPE_NAME,
       B.MANAGEMENT_NO,
       B.MANAGEMENT_NAME,
       B.PRODUCT_FLAG,
       B.MAT_STATUS,
       T.DETER_STATUS,
       T.CODE_JG_BL,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.COAT_TYPE,T.STOVE_NO,T.FLAG_STOVE_NO
  FROM COUPLING_MAT_M T, COUPLING_MAT_BUTTRESS B
 WHERE T.MAT_NO = B.MAT_NO
   AND B.MAT_NO_XH = ?
   AND T.MAT_NO=?
		]]>
	</query>
	<query id="FrmCollarOutBound.AddDealResult" desc="新增交易信息">
		<![CDATA[
INSERT INTO COUPLING_MAT_DEAL(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, 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,TAR_KEP_NO,WO_ID,DEAL_ORDE,PRODUCT_FLAG,MAT_STATUS,DETER_STATUS,CODE_JG_BL,CRAFT_FILE_NO,CRAFT_SEQ,BELONG_CODE,BELONG_NAME,COAT_TYPE,STOVE_NO,FLAG_STOVE_NO,OUTSTOCK_DOC) 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="FrmCollarOutBound.AddButterResult" desc="新增位置表">
		<![CDATA[
DECLARE
BEGIN
  INSERT INTO COUPLING_MAT_BUTTRESS
    (KEP_NO,
     MAT_NO,
     PRO_PLAN_ID,
     PIECES,
     WEIGHT,
     STORAGE_NO,
     LOCATION_NO,
     STORAGE_ATTR,
     STORAGE_ATTR_NAME,
     STORAGE_TYPE_NO,
     STORAGE_TYPE_NAME,
     MANAGEMENT_NO,
     MANAGEMENT_NAME,
     CREATE_NAME,
     CREATE_TIME,
     CUST_ALPHA_NO,
     ORDER_SPECIAL_DESC,
     ALPHA_CODE,
     MAT_NO_XH,
     PRODUCT_FLAG,
     MAT_STATUS)
    SELECT T.KEP_NO,
           T.MAT_NO,
           T.PRO_PLAN_ID,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
           T.CUST_ALPHA_NO,
           T.ORDER_SPECIAL_DESC,
           T.ALPHA_CODE,
           ?,
           T.PRODUCT_FLAG,
           T.MAT_STATUS
      FROM COUPLING_MAT_BUTTRESS T
     WHERE T.MAT_NO = ?
       AND T.MAT_NO_XH = ?;
  UPDATE COUPLING_MAT_BUTTRESS
     SET PIECES      = TO_NUMBER(Nvl(PIECES, 0)) - TO_NUMBER(?),
         WEIGHT      = TO_NUMBER(Nvl(WEIGHT, 0)) - TO_NUMBER(?),
         UPDATE_NAME = ?,
         UPDATE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE MAT_NO_XH = ?
     AND MAT_NO = ?;
END;
	]]>
	</query>
	
	<query id="FrmCollarOutBound.AddButterResult2" desc="新增位置表">
		<![CDATA[
DECLARE
BEGIN
  INSERT INTO COUPLING_MAT_BUTTRESS
    (KEP_NO,
     MAT_NO,
     PRO_PLAN_ID,
     PIECES,
     WEIGHT,
     STORAGE_NO,
     LOCATION_NO,
     STORAGE_ATTR,
     STORAGE_ATTR_NAME,
     STORAGE_TYPE_NO,
     STORAGE_TYPE_NAME,
     MANAGEMENT_NO,
     MANAGEMENT_NAME,
     CREATE_NAME,
     CREATE_TIME,
     CUST_ALPHA_NO,
     ORDER_SPECIAL_DESC,
     ALPHA_CODE,
     MAT_NO_XH,
     PRODUCT_FLAG,
     MAT_STATUS)
    SELECT T.KEP_NO,
           T.MAT_NO,
           T.PRO_PLAN_ID,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           ?,
           TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
           T.CUST_ALPHA_NO,
           T.ORDER_SPECIAL_DESC,
           T.ALPHA_CODE,
           ?,
           T.PRODUCT_FLAG,
           T.MAT_STATUS
      FROM COUPLING_MAT_BUTTRESS T
     WHERE T.MAT_NO = ?
       AND T.MAT_NO_XH = ?;
 
END;
	]]>
	</query>
	<query id="FrmCollarOutBound.updateButter" desc="修改位置表">
		<![CDATA[
UPDATE COUPLING_MAT_BUTTRESS
   SET 
       STORAGE_NO        = ?,
       LOCATION_NO       = ?,
       STORAGE_ATTR      = ?,
       STORAGE_ATTR_NAME = ?,
       STORAGE_TYPE_NO   = ?,
       STORAGE_TYPE_NAME = ?,
       MANAGEMENT_NO     = ?,
       MANAGEMENT_NAME   = ?,
       UPDATE_NAME       = ?,
       UPDATE_TIME       = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE MAT_NO = ?
   AND MAT_NO_XH=?
	]]>
	</query>
	<query id="FrmCollarOutBound.deleteDealResult" desc="删除交易信息">
		<![CDATA[
		DELETE COUPLING_MAT_DEAL WHERE DEAL_ORDE = ?
		]]>
	</query>
	<query id="FrmCollarOutBound.deleteButterResult" desc="删除位置表">
		<![CDATA[
DECLARE
BEGIN
 DELETE COUPLING_MAT_BUTTRESS
 WHERE  STORAGE_NO = ?
   AND MAT_NO = ?;
  UPDATE COUPLING_MAT_BUTTRESS
     SET PIECES      = TO_NUMBER(Nvl(PIECES,0)) + TO_NUMBER(?),
         WEIGHT      = TO_NUMBER(Nvl(WEIGHT,0)) + TO_NUMBER(?),
         UPDATE_NAME = ?,
         UPDATE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE  STORAGE_NO = ?
     AND MAT_NO = ?;
END;
	]]>
	</query>
	<query id="FrmCollarOutBound.queryDealCount" desc="查询位置表该数据存在几条">
		<![CDATA[
SELECT COUNT(*) COUNT
  FROM COUPLING_MAT_BUTTRESS T
 WHERE T.MAT_NO = ?
		]]>
	</query>
	<query id="FrmCollarOutBound.queryRecFalg" desc="查询交易表该数据接收状态">
		<![CDATA[
		SELECT T.TAR_REC_FLAG FROM COUPLING_MAT_DEAL T WHERE T.DEAL_ORDE = ?
			]]>
	</query>
	<query id="FrmCollarOutBound.updateButter1" desc="修改位置表">
		<![CDATA[
DECLARE
BEGIN
UPDATE COUPLING_MAT_BUTTRESS
   SET 
       STORAGE_NO        = ?,
       LOCATION_NO       = ?,
       STORAGE_ATTR      = ?,
       STORAGE_ATTR_NAME = ?,
       STORAGE_TYPE_NO   = ?,
       STORAGE_TYPE_NAME = ?,
       MANAGEMENT_NO     = ?,
       MANAGEMENT_NAME   = ?,
       UPDATE_NAME       = ?,
       UPDATE_TIME       = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE STORAGE_NO = ?
     AND MAT_NO = ?;
     END;
	]]>
	</query>
		<query id="FrmCollarOutBound.queryMaxDealOrde" desc="查询最大交易单号">
	 <![CDATA[  
SELECT ? || ? ||
       LPAD(SUBSTR(NVL(MAX(T.DEAL_ORDE), '000'), -3, 3) + 1, 3, '0') AS DEAL_ORDE
  FROM COUPLING_MAT_DEAL T
 WHERE  TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD')=?
 AND T.DEAL_TYPE_CODE=?
   ]]>
	</query>
		<query id="FrmCollarOutBound.queryMaxButter" desc="查询最大交易单号">
	 <![CDATA[  
SELECT LPAD(SUBSTR(NVL(MAX(T.MAT_NO_XH), '0000'), -4, 4) + 1, 4, '0') AS MAT_NO_XH
  FROM COUPLING_MAT_BUTTRESS T
 WHERE T.MAT_NO = ?
   ]]>
	</query>

	<query id="FrmCollarOutBound.getOutDoc" desc="生成出库单号">
		SELECT ?|| TO_CHAR(SYSDATE, 'YYMMDD') ||
		LPAD(NVL(MAX(SUBSTR(OUTSTOCK_DOC, 11)), 0) + 1, 5, 0) OUTSTOCK_DOC
		FROM YDM_BC_OUTLISTDOC T
		WHERE T.OUTSTOCK_DOC LIKE ?|| TO_CHAR(SYSDATE, 'YYMMDD')|| '_____'
	</query>


	<query id="FrmCollarOutBound.insertOutdoc" desc="保存倒库单号">
		INSERT INTO YDM_BC_OUTLISTDOC (OUTSTOCK_DOC) VALUES (?)
	</query>

	<query id="FrmCollarOutBound.getWarehousePermissionsStore"
		   desc="获取仓库权限">
		<![CDATA[
	      SELECT T.STORAGE_NO, T.STORAGE_NAME
  FROM YDM_BS_STORAGE T
 WHERE  T.VALIDFLAG='1'
		]]>
	</query>

	<query id="FrmCollarOutBound.getDepartmentBySectionID" desc="查询科室对应的部门">
		<![CDATA[
            SELECT T.DEPARTNAME, T.DEPARTID
			  FROM CORE_APP_DEPARTMENT T, CORE_APP_DEPARTMENT A
			 WHERE A.PID = T.DEPARTID
			   AND A.DEPARTID = ?
        ]]>
	</query>

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

	<query id = "FrmCollarOutBound.SelectStorageIsCarUser" desc = "查询是否限制了一车一卡">
		SELECT T.IS_CAR_TAKING,T.IS_CAR_TAKING_BILL FROM YDM_BS_STORAGE T WHERE T.STORAGE_NO = ?
	</query>

</queryMap>