<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍交库作业实绩">
	<query id="FrmInLibrary.doQueryZygNo" desc="作业计划简单查询">
        <![CDATA[
  SELECT T.ZY_PLAN_ID,
       T.WO_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PLAN_JG_NUM,
       T.FAIL_CUT_NUM,
       T.LOAD_PIECES,
       T.LOAD_WEIGHT,
       T.JG_ORDERNO_ALL,
       DECODE(T.STATION_STATUS, '1', '未结炉', '2', '已结炉') STATION_STATUS,
       TO_NUMBER(PLAN_JG_NUM) - TO_NUMBER(T.FAIL_CUT_NUM) SJ_NUM,
       T.LH_NUM SJ_NUM1,
       T.PLINE_CODE,
       T.PLINE_NAME,
       TO_NUMBER(PLAN_JG_NUM) - TO_NUMBER(T.FAIL_CUT_NUM) LL_NUM,
       TO_NUMBER(PLAN_JG_NUM) - TO_NUMBER(T.FAIL_CUT_NUM) ACT_NUM,
       TO_NUMBER(PLAN_JG_NUM) - TO_NUMBER(T.FAIL_CUT_NUM) -
       TO_NUMBER(PLAN_JG_NUM) + TO_NUMBER(T.FAIL_CUT_NUM) CLC_NUM,
       T.FAIL_CUT_NUM FAIL_CUT_NUM1,
       T.CUT_NUM,
       T.CJG_NUM,
       T.YY_NUM,
       T.CS_NUM,
       T.TS_NUM,
       T.PS_NUM,
       T.LH_NUM,
       T.CJ_NUM,
       T.PB_NUM,
       T.CUT_FAIL_NUM,
       T.CJG_FAIL_NUM,
       T.YY_FAIL_NUM,
       T.CS_FAIL_NUM,
       T.TS_FAIL_NUM,
       T.PS_FAIL_NUM,
       T.CJ_FAIL_NUM,
       T.PB_FAIL_NUM,
       T.LH_FAIL_NUM
  FROM (SELECT T1.HEAT_PLAN_NO ZY_PLAN_ID,
               T1.WO_ID,
               T1.JUDGE_STOVE_NO,
               T1.BATCH_NO,
               T1.PLAN_JG_NUM,
               T1.PLINE_CODE,
               T1.PLINE_NAME,
               T1.JG_ORDERNO_ALL,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE != '700313'
                      AND T.WO_ID = T1.WO_ID),
                   0) FAIL_CUT_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700301'
                      AND T.WO_ID = T1.WO_ID),
                   0) LOAD_PIECES,
               NVL((SELECT SUM(T.PRO_WT)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700301'
                      AND T.WO_ID = T1.WO_ID),
                   0) LOAD_WEIGHT,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700306'
                      AND T.WO_ID = T1.WO_ID),
                   0) SJ_NUM,
               (SELECT T.STATION_STATUS
                  FROM COUPLING_COM_INFO T
                 WHERE T.STATION_CODE = '700313'
                   AND T.WO_ID = T1.WO_ID) STATION_STATUS,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700302'
                      AND T.WO_ID = T1.WO_ID),
                   0) CUT_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700303'
                      AND T.WO_ID = T1.WO_ID),
                   0) CJG_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700304'
                      AND T.WO_ID = T1.WO_ID),
                   0) YY_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700305'
                      AND T.WO_ID = T1.WO_ID),
                   0) CS_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700307'
                      AND T.WO_ID = T1.WO_ID),
                   0) TS_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700308'
                      AND T.WO_ID = T1.WO_ID),
                   0) PS_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700309'
                      AND T.WO_ID = T1.WO_ID),
                   0) CJ_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700310'
                      AND T.WO_ID = T1.WO_ID),
                   0) LH_NUM,
               NVL((SELECT SUM(T.PRO_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700311'
                      AND T.WO_ID = T1.WO_ID),
                   0) PB_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700302'
                      AND T.WO_ID = T1.WO_ID),
                   0) CUT_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700303'
                      AND T.WO_ID = T1.WO_ID),
                   0) CJG_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700304'
                      AND T.WO_ID = T1.WO_ID),
                   0) YY_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700305'
                      AND T.WO_ID = T1.WO_ID),
                   0) CS_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700307'
                      AND T.WO_ID = T1.WO_ID),
                   0) TS_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700308'
                      AND T.WO_ID = T1.WO_ID),
                   0) PS_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700309'
                      AND T.WO_ID = T1.WO_ID),
                   0) CJ_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700310'
                      AND T.WO_ID = T1.WO_ID),
                   0) LH_FAIL_NUM,
               NVL((SELECT SUM(T.FAIL_NUM)
                     FROM COUPLING_COM_INFO T
                    WHERE T.STATION_CODE = '700311'
                      AND T.WO_ID = T1.WO_ID),
                   0) PB_FAIL_NUM
          FROM PLN_ZY_JG_WORKBILL T1
         WHERE T1.WO_ID LIKE '%' || ? || '%'
           AND T1.HEAT_PLAN_NO LIKE '%' || ? || '%'
           AND T1.JUDGE_STOVE_NO LIKE '%' || ? || '%' 
           AND T1.ZY_BILL_STATUS IN ('2','3')) T

        ]]>
	</query>
	<query id="FrmInLibrary.doQueryMatNo" desc="查询接箍材料信息">
        <![CDATA[
   SELECT B.DEAL_ORDE,
       M.WO_ID,
       DECODE(M.DETER_STATUS, '0', '未判定', '1', '申请判定', '2', '已判定') DETER_STATUS,
       M.DETER_NO,
       DECODE(M.DETER_RESULTS, '0', '合格', '1', '不合格') DETER_RESULTS,
       M.ZY_PLAN_ID,
       M.JUDGE_STOVE_NO,
       M.BATCH_NO,
       B.PIECES,
       M.PLINE_CODE,
       B.WEIGHT,M.RESULT_NO,M.PLINE_NAME
  FROM COUPLING_MAT_M M, COUPLING_MAT_BUTTRESS B
 WHERE M.MAT_NO = B.MAT_NO
   AND M.WO_ID IS NOT NULL
   AND M.PLINE_CODE = ?
   AND M.WO_ID = ?

        ]]>
	</query>

	<query id="FrmInLibrary.selectQcmApp" desc="查询是否送判">
		SELECT COUNT(1) ACOUNT
		FROM COUPLING_MAT_M T
		WHERE T.WO_ID = ?
		AND T.DETER_NO IS NULL
	</query>

	<query id="FrmInLibrary.doQueryMatNoCount" desc="查询接箍材料信息数量">
        <![CDATA[
   SELECT COUNT(*) COUNT
  FROM COUPLING_MAT_M M, COUPLING_MAT_BUTTRESS B
 WHERE M.MAT_NO = B.MAT_NO
   AND M.WO_ID IS NOT NULL
   AND M.PLINE_CODE = ?
   AND M.WO_ID = ?
   AND M.QCM_STAUS=?

        ]]>
	</query>
	<query id="FrmInLibrary.query" desc="框号下拉内容">
        <![CDATA[   
        SELECT T.KEP_NO,T.KEP_TYPE 
        FROM  COUPLING_APP_BOX_MAIN T
        ORDER BY T.KEP_NO ASC
         ]]>
	</query>

	<query id="FrmInLibrary.QueryMatNo" desc="查询材料表材料号">
        <![CDATA[   
        SELECT T.MAT_NO FROM COUPLING_MAT_M T WHERE T.WO_ID = ? AND T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? AND T.QCM_STAUS='22'
         ]]>
	</query>
	<query id="FrmInLibrary.QueryMatNoDo" desc="查询材料表材料号">
        <![CDATA[   
        SELECT T.MAT_NO,T.SINGLEWEIGHT FROM COUPLING_MAT_M T WHERE T.WO_ID = ? AND T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? AND T.QCM_STAUS='00'
         ]]>
	</query>
	<query id="FrmInLibrary.queryStorage" desc="查询仓库">
        <![CDATA[   
        SELECT T.STORAGE_NO, T.STORAGE_NAME
   FROM YDM_BS_STORAGE T
   ORDER BY T.STORAGE_NAME ASC
         ]]>
	</query>
	<query id="FrmInLibrary.queryLoadRESULT" desc="生成实绩编号">
	 <![CDATA[  
SELECT ? || 'J' || ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '00000'), -5, 5) + 1, 5, '0') AS RESULT_NO
  FROM COUPLING_LIBRARY_RESULT T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
   AND T.Wo_Id=?
   ]]>
	</query>
	<query id="FrmInLibrary.UpdateMatStutsBut" desc="修改位置表支數">
        <![CDATA[   
        UPDATE COUPLING_MAT_BUTTRESS T
   SET T.PIECES=TO_NUMBER(T.PIECES)+TO_NUMBER(?),T.WEIGHT=TO_NUMBER(T.WEIGHT)+TO_NUMBER(?)
 WHERE  T.MAT_NO = ?
         ]]>
	</query>
	<query id="FrmInLibrary.UpdateMatStuts" desc="修改材料表支數">
        <![CDATA[   
 UPDATE COUPLING_MAT_M T SET T.PRO_NUM=TO_NUMBER(T.PRO_NUM)-TO_NUMBER(?),T.PRO_WT=TO_NUMBER(T.PRO_WT)-TO_NUMBER(?) WHERE T.MAT_NO=?
         ]]>
	</query>
	<query id="FrmInLibrary.UpdateDeal" desc="修改交易表支數">
        <![CDATA[   
        UPDATE COUPLING_MAT_DEAL
   SET DEAL_NUM = ?, DEAL_WT = ?
 WHERE  DEAL_ORDE = ?
         ]]>
	</query>


	<query id="FrmInLibrary.UpdateJGPln" desc="修改计划表支数">
	 <![CDATA[ 
UPDATE PLN_ZY_JG_WORKBILL
   SET OUT_NUM = TO_NUMBER(NVL(OUT_NUM,0))+TO_NUMBER(?),
       OUT_WT  = TO_NUMBER(NVL(OUT_WT,0))+TO_NUMBER(?)
 WHERE WO_ID = ?
]]>
	</query>

	<query id="FrmInLibrary.selectBelong" desc="查询产线对应所属权">
		SELECT T.DEPARTMENT_CODE,T.DEPARTMENT_DESC FROM COM_BASE_PLINE T WHERE
		T.PLINE_CODE = ?
	</query>
	<query id="FrmInLibrary.AddMatM" desc="新增接箍材料表">
	 <![CDATA[ 
	 INSERT INTO COUPLING_MAT_M (MAT_NO, RESULT_NO, ZY_PLAN_ID, WO_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,  
 PRO_NUM, PRO_WT, RRO_TIME, PRO_SHIFT, PRO_GROUP, COL_OPERATOR, 
CREATE_NAME, CREATE_TIME,F_IN_TIME,BELONG_CODE,BELONG_NAME,QCM_STAUS,CRAFT_SEQ,CODE_JG_BL,STOVE_NO,
FLAG_STOVE_NO,PRODUCCODE_JG,PRODUCCODE_JG_DESC) 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="FrmInLibrary.AddMatButters" desc="新增位置表">
	 <![CDATA[ 
  INSERT INTO COUPLING_MAT_BUTTRESS (MAT_NO, MAT_NO_XH, PRODUCT_FLAG, MAT_STATUS, PRO_PLAN_ID, PIECES, 
WEIGHT,
CUST_ALPHA_NO, ORDER_SPECIAL_DESC, ALPHA_CODE, STORAGE_NO, LOCATION_NO, 
STORAGE_ATTR, STORAGE_ATTR_NAME, STORAGE_TYPE_NO, STORAGE_TYPE_NAME, 
MANAGEMENT_NO, MANAGEMENT_NAME, MEMO, CREATE_NAME, CREATE_TIME, OFFLINE_LOG, 
JG_GROUP_ID, DEAL_ORDE,MACH_NO,MACH_NM,KEP_NO,SOURE_CODE,SOURE_NAME) VALUES (?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?,?,?,?,'801302','产线' )
	  ]]>
	</query>
	<query id="FrmInLibrary.AddMatDeal" desc="新增交易表">
	 <![CDATA[ 
	  INSERT INTO COUPLING_MAT_DEAL (DEAL_TYPE_CODE, DEAL_TYPE_NAME, SOURCE_CODE, 
SOURCE_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, HAND_FLAG, MEMO, 
CREATE_NAME, CREATE_TIME, DEMAND_COPPER, DEMAND_DETECTION, DEMAND_BLAST, 
DEMAND_BONDERIZING, CUST_ALPHA_NO, ORDER_SPECIAL_DESC, ALPHA_CODE, COL_OPERATOR, 
TAR_REC_FLAG,WO_ID,DEAL_ORDE,JG_GROUP_ID,SOURE_CODE,SOURE_NAME,F_IN_TIME,QCM_STAUS,MAT_NO_XH) SELECT '800701', '产出入库', ?, ?, ?, 
?, ?, ?,'', T.PLINE_CODE, T.PLINE_NAME, T.JUDGE_STOVE_NO, T.BATCH_NO, 
T.BL_WL_ID, T.BL_WL_DESC, ?,?,T.CODE_JG, 
T.GRADECODE, T.GRADENAME, T.STEELCODE, T.STEELNAME, T.MODEL_CODE, T.MODEL_DESC, ?, 
?, T.SPEC_JG, T.SPEC_JG_DESC, T.STYLE_JG, ?, ?, ?,
T.SINGLEWEIGHT, '', T.IF_MONITOR_JG, T.PRDCR_NO, ?, ?, T.LATHE_GRP_NO, 
T.LATHE_GRP_NM, ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?, ?, ?, 
'0', ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), T.DEMAND_COPPER, 
T.DEMAND_DETECTION, T.DEMAND_BLAST, T.DEMAND_BONDERIZING, '', 
'', '', ?,'1',T.WO_ID,?,'','801302','产线',TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),?,? FROM 
PLN_ZY_JG_WORKBILL T WHERE T.WO_ID=?
	  ]]>
	</query>
	<query id="FrmInLibrary.queryPlanJg" desc="查询工单状态">
	 <![CDATA[ 
SELECT T.ZY_BILL_STATUS,
       T.INSTORE_STATUS,
       T.CUT_STATUS,
       T.LATHE_STATUS,
       T.THREAD_CHK_STATUS,
       T.DETECT_STATUS,
       T.BLAST_STATUS,
       T.PLT_CU_STATUS,
       T.PHOS_STATUS,
       T.IF_BLAST,
       T.IF_PLATE_CU,
       T.IF_PHOSPHATING,
       T.IF_OUT_COAT
  FROM PLN_ZY_JG_WORKBILL T
 WHERE T.ZY_PLAN_ID = ?
   AND T.WO_ID = ?
	  ]]>
	</query>
	<query id="FrmInLibrary.queryComPlanJg" desc="查询公共表结炉状态">
	 <![CDATA[ 
   SELECT T.STATION_STATUS, T.STATION_DESC
     FROM COUPLING_COM_INFO T
    WHERE T.WO_ID = ?
      AND T.STATION_CODE NOT IN ('700307','700310','700311','700303','700304','700309') 
   
	  ]]>
	</query>
	<query id="FrmInLibrary.queryComPlanJgCode" desc="查询公共表工序">
	 <![CDATA[ 
   SELECT T.STATION_CODE, T.STATION_DESC
     FROM COUPLING_COM_INFO T
    WHERE T.WO_ID = ?
      AND (T.STATION_CODE != '700313' and T.STATION_CODE !='700301')
   
	  ]]>
	</query>

	<query id="FrmInLibrary.queryCutPieces" desc="查询锯切个数">
	 <![CDATA[ 
   SELECT NVL(SUM(T.PRO_NUM),0) PRO_NUM FROM COUPLING_COM_INFO T WHERE T.WO_ID = ? AND T.STATION_CODE = '700302'
	  ]]>
	</query>
	
	<query id="FrmInLibrary.QueryOffCut" desc="查询委外锯切个数">
	 <![CDATA[ 
 SELECT NVL(SUM(R.INCISION_NUM),0) INCISION_NUM
  FROM HTT_ENTRUST_RESULT R, HTT_ENTRUST T, COUPLING_OFFLINE_RESULT O
 WHERE R.SUBCONTRACT_NO = T.SUBCONTRACT_NO
   AND R.SUBCONTRACT_NO_SEQ = T.SUBCONTRACT_NO_SEQ
   AND PROJECT_CODE = '70220305'
   AND O.RESULT_NO || '_' || O.OFF_XH = T.RESULT_NO
   AND O.WO_ID =?
	  ]]>
	</query>

	<query id="FrmInLibrary.queryPhosPieces" desc="查询磷化个数">
	 <![CDATA[ 
   SELECT NVL(SUM(T.PRO_NUM),0) PRO_NUM FROM COUPLING_COM_INFO T WHERE T.WO_ID = ? AND T.STATION_CODE = '700310'
	  ]]>
	</query>

	<query id="FrmInLibrary.queryComPieces" desc="查询废品和磷化个数和">
	 <![CDATA[ 
   SELECT TO_NUMBER(SUM(FAIL_NUM))+TO_NUMBER(PRO_NUM)  FAIL_NUM
  FROM (SELECT NVL(T.FAIL_NUM,0) FAIL_NUM,
               (SELECT SUM(T1.PRO_NUM)
                  FROM COUPLING_COM_INFO T1
                 WHERE T1.WO_ID = T.WO_ID
                   AND T1.STATION_CODE = '700310') PRO_NUM
          FROM COUPLING_COM_INFO T
         WHERE T.WO_ID = ?
           AND T.STATION_CODE NOT IN ('700301', '700302', '700313'))
 GROUP BY PRO_NUM
	  ]]>
	</query>
	<query id="FrmInLibrary.queryComPlanJgCodeCut" desc="查询工序支数与废品和">
	 <![CDATA[ 
  SELECT TO_NUMBER(SUM(T.PRO_NUM)) PRO_NUM
     FROM COUPLING_COM_INFO T
    WHERE T.WO_ID = ?
      AND T.STATION_CODE = ?
   
	  ]]>
	</query>
	<query id="FrmInLibrary.queryComPlanJg1" desc="查询是否交库">
	 <![CDATA[ 
   SELECT COUNT(1) COUNT
     FROM COUPLING_COM_INFO T
    WHERE T.WO_ID = ?
      AND T.STATION_CODE = '700313'
   
	  ]]>
	</query>
	<query id="FrmInLibrary.queryStorageType" desc="查询库位信息">
	 <![CDATA[ 
SELECT T.STORAGE_NO,
	   T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME
  FROM YDM_BS_STORAGE T
 WHERE T.STORAGE_NO in (SELECT T1.IN_REPOSITORY FROM COM_BASE_PLINE T1 WHERE T1.PLINE_CODE=?)
 AND T.VALIDFLAG='1'
	  ]]>
	</query>
	<query id="FrmInLibrary.queryMaxMatNo" desc="查询最大材料号">
	 <![CDATA[  
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.MAT_NO), '000'), -3, 3) + 1, 3, '0') AS MAT_NO
  FROM COUPLING_MAT_M T
 WHERE  T.WO_ID = ? AND T.MAT_NO NOT LIKE 'JG%' AND T.QCM_STAUS='00'
   ]]>
	</query>

	<query id="FrmInLibrary.selectInCount" desc="查询接箍库下线是否有数据">
		<![CDATA[
	SELECT T.Mat_No,nvl(t.SINGLEWEIGHT,0) SINGLEWEIGHT  FROM COUPLING_MAT_M T WHERE T.JUDGE_STOVE_NO= ? AND T.BATCH_NO=? AND T.WO_ID=? AND T.QCM_STAUS='00'
		]]>
	</query>

	<query id="FrmInLibrary.selectMatCount" desc="查询接箍库总支数">
		<![CDATA[
	SELECT NVL(SUM(T.PRO_NUM),0) PRO_NUM FROM COUPLING_MAT_M T WHERE T.JUDGE_STOVE_NO= ? AND T.BATCH_NO=? AND T.WO_ID=? AND T.QCM_STAUS='00'
		]]>
	</query>

	<query id="FrmInLibrary.selectFailCount" desc="查询接箍库下线是否有数据">
		<![CDATA[
	SELECT T.Mat_No,nvl(t.SINGLEWEIGHT,0) SINGLEWEIGHT  FROM COUPLING_MAT_M T WHERE T.JUDGE_STOVE_NO= ? AND T.BATCH_NO=? AND T.WO_ID=? AND T.QCM_STAUS='22'
		]]>
	</query>
	<query id="FrmInLibrary.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=? AND T.DEAL_ORDE NOT LIKE 'JJG%'
   ]]>
	</query>
	<query id="FrmInLibrary.doQueryInfoResult" desc="查询接箍公共信息">		
        <![CDATA[
  SELECT RESULT_NO,
       ZY_PLAN_ID,
       PRO_PLAN_ID,
       CODE_JG_BL,
       JG_GROUP_ID, 
        DECODE( IF_OUT_RPO,'1', '是', '0', '否') IF_OUT_RPO,
       PLINE_CODE,
       PLINE_NAME,
       STATION_CODE,
       STATION_DESC,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BL_WL_ID,
       BL_WL_DESC,
       MIN_D,
       MIN_H,
       AIMLENGTH_BL,
       AIM_CUT_LEN,
       LENGTH_MIN,
       LENGTH_MAX,
       TAPER,
       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,
       DECODE(IF_MONITOR_JG, '1', '是', '0', '否') IF_MONITOR_JG,
       PRDCR_NO,
       PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       MACH_NO,
       MACH_NM,
       PRO_NUM,
       PRO_WT,
       FAIL_NUM,
       FAIL_WT,
       OFFLINE_NUM,
       OFFLINE_WT,
       DECODE(STATION_STATUS, '1', '交库中', '2', '交库完成') STATION_STATUS,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(RRO_TIME, 'YYYY-MM-DD') RRO_TIME,
       COL_OPERATOR,
       RRO_TIME_NU,
       PRO_USER,
       DECODE(PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       DECODE(PRO_SHIFT, '0', '常白', '1', '早', '2', '中', '3', '晚') PRO_SHIFT,
       DECODE(IF_ALL_OUT_WORK, '1', '是', '0', '否') IF_ALL_OUT_WORK,
       WO_ID
  FROM COUPLING_COM_INFO
  WHERE ZY_PLAN_ID=?
  AND WO_ID=?
  AND STATION_CODE='700313'
  ORDER BY CREATE_TIME DESC
        ]]>
	</query>
	<query id="FrmInLibrary.DeleteComInfoResult" desc="删除comInfo表">		
        <![CDATA[
 DELETE COUPLING_COM_INFO  WHERE WO_ID = ? AND RESULT_NO=? AND STATION_CODE = ?  
          ]]>
	</query>
	<query id="FrmInLibrary.QUERYMATDELV" desc="查询交易表是否变化">		
        <![CDATA[
SELECT MAX(T.DETER_STATUS) DETER_STATUS
  FROM COUPLING_MAT_M T, COUPLING_MAT_DEAL T1
 WHERE T.MAT_NO = T1.MAT_NO
   AND T1.DEAL_ORDE = ?
          ]]>
	</query>
	<query id="FrmInLibrary.DeleteMatMDoBeside" desc="删除接箍材料表">		
        <![CDATA[
DELETE COUPLING_MAT_M T
 WHERE T.WO_ID = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.QCM_STAUS = '00'
          ]]>
	</query>
	<query id="FrmInLibrary.DeleteMatM" desc="删除接箍材料表废品数据">		
        <![CDATA[
DELETE COUPLING_MAT_M T
 WHERE T.WO_ID = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.QCM_STAUS = '22'
          ]]>
	</query>
	<query id="FrmInLibrary.DeleteMatButters" desc="删除位置表">		
        <![CDATA[
DELETE COUPLING_MAT_BUTTRESS T
 WHERE T.DEAL_ORDE = ?
          ]]>
	</query>

	<query id="FrmInLibrary.DeleteMatMFail" desc="删除材料表">		
        <![CDATA[
DELETE COUPLING_MAT_M T
 WHERE T.WO_ID = ? AND T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? AND T.QCM_STAUS = '22'
          ]]>
	</query>

	<query id="FrmInLibrary.DeleteMatButtersDoBeside" desc="删除位置表">		
        <![CDATA[
DELETE COUPLING_MAT_BUTTRESS T
 WHERE T.MAT_NO = ?
          ]]>
	</query>

	<query id="FrmInLibrary.DeleteMatButtersFail" desc="删除位置表">		
        <![CDATA[
DELETE COUPLING_MAT_BUTTRESS T
 WHERE T.MAT_NO = ?
          ]]>
	</query>
	<query id="FrmInLibrary.DeleteMatDeal" desc="删除交易表">		
        <![CDATA[
DELETE COUPLING_MAT_DEAL T
 WHERE T.DEAL_ORDE=? AND T.RESULT_NO=?
          ]]>
	</query>
	<query id="FrmInLibrary.DeleteMatDealFail" desc="删除交易表">		
        <![CDATA[
DELETE COUPLING_MAT_DEAL T
 WHERE T.MAT_NO = ?
          ]]>
	</query>
	<query id="FrmInLibrary.DeleteLinResult" desc="删除交库实绩表">		
        <![CDATA[
DELETE COUPLING_LIBRARY_RESULT T
 WHERE T.WO_ID = ?
   AND T.RESULT_NO = ?
          ]]>
	</query>
	<query id="FrmInLibrary.QUERYInfoRestlu" desc="查询交库实绩是否还有数据">		
        <![CDATA[
SELECT COUNT(*) COUNT FROM COUPLING_COM_INFO T 
WHERE T.ZY_PLAN_ID=? AND T.STATION_CODE='700313'
          ]]>
	</query>
	<query id="FrmInLibrary.doBeside" desc="结炉">
		UPDATE COUPLING_COM_INFO T
		SET T.STATION_STATUS = '2'
		WHERE T.STATION_CODE = ?
		AND T.WO_ID = ?
	</query>
	<query id="FrmInLibrary.unDoBeside" desc="撤销结炉">
		UPDATE COUPLING_COM_INFO T
		SET T.STATION_STATUS = '1'
		WHERE T.STATION_CODE = ?
		AND T.WO_ID = ?
	</query>
	<query id="FrmInLibrary.selectComInfo" desc="查询是否已存在该单号的实绩">
	  <![CDATA[
		SELECT T.PRO_NUM FROM COUPLING_COM_INFO T WHERE T.STATION_CODE = ? AND T.WO_ID=?
	]]>
	</query>
	<query id="FrmInLibrary.UpdateMatButters" desc="修改位置表">
	  <![CDATA[
UPDATE COUPLING_MAT_BUTTRESS
   SET KEP_NO            = ?,
       STORAGE_NO        = ?,
       LOCATION_NO       = ?,
       STORAGE_ATTR      = ?,
       STORAGE_ATTR_NAME = ?,
       STORAGE_TYPE_NO   = ?,
       STORAGE_TYPE_NAME = ?,
       UPDATE_NAME       = ?,
       UPDATE_TIME       = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE MAT_NO = ?
   AND ZY_PLAN_ID = ? 
   AND RESULT_NO = ?

	]]>
	</query>
	<query id="FrmInLibrary.Query" desc="框号下拉内容">
        <![CDATA[   
        SELECT T.KEP_NO,T.KEP_TYPE 
        FROM  COUPLING_APP_BOX_MAIN T
        ORDER BY T.KEP_NO ASC
         ]]>
	</query>
	<query id="FrmInLibrary.AddLibraryResult" desc="新增交库实绩表">
        <![CDATA[   
INSERT INTO COUPLING_LIBRARY_RESULT
  (RESULT_NO, PLINE_CODE, ZY_PLAN_ID, WO_ID, SPRAY_COUNT, REJECTED_PCS, REJECTED_REASON, COL_USER, COL_SHIFT, COL_GROUP, MEMO, CREATE_TIME,PLINE_NAME)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),?)
         ]]>
	</query>
	<query id="FrmInLibrary.UpdateMatDeal" desc="修改交易表">
	  <![CDATA[
UPDATE COUPLING_MAT_DEAL
   SET KEP_NO            = ?,
       STORAGE_NO        = ?,
       LOCATION_NO       = ?,
       STORAGE_ATTR      = ?,
       STORAGE_ATTR_NAME = ?,
       STORAGE_TYPE_NO   = ?,
       STORAGE_TYPE_NAME = ?,
       UPDATE_NAME       = ?,
       UPDATE_TIME       = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE MAT_NO = ?
   AND ZY_PLAN_ID = ? 
   AND RESULT_NO = ?
	]]>
	</query>
	<query id="FrmInLibrary.UpdateButtersStrat" desc="修改材料从表判定状态">
	  <![CDATA[
	  UPDATE COUPLING_MAT_BUTTRESS
   SET DETER_STATUS = ?,
       DETER_NO     = ?,
       UPDATE_NAME  = ?,
       UPDATE_TIME  = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE --MAT_NO = ?
 --WO_ID = ?
   --AND ZY_PLAN_ID = ?
 DEAL_ORDE = ?
	  ]]>
	</query>
	<query id="FrmInLibrary.AddPlnZyJgMidd" desc="新增接箍工单详细表">
	  <![CDATA[
	INSERT INTO PLN_ZY_JG_MIDDLE
  (WO_ID,
   JG_ORDERNO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PLINE_CODE,
   PLINE_NAME,
   DEMAND_COPPER,
   DEMAND_DETECTION,
   DEMAND_BLAST,
   DEMAND_BONDERIZING,
   PLAN_NUM,
   PLAN_WT,
   STOVE_NO,
   FLAG_STOVE_NO,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_JG_DESC,
   SPEC_JG,
   STYLE_JG,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRODUCCODE_JG,
   PRODUCCODE_JG_DESC,
   CODE_JG,
   MODEL_CODE,
   MODEL_DESC,
   IF_MONITOR_JG,
   PRDCR_NO,
   STATUS,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,MAT_NO,CRAFT_SEQ_ORD,CRAFT_FILE_NO_ORD,MAT_NO_XH)
  SELECT T.WO_ID,
         ?,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.BATCH_GROUD_NO,
         T.PLINE_CODE,
         T.PLINE_NAME,
         T.DEMAND_COPPER,
         T.DEMAND_DETECTION,
         T.DEMAND_BLAST,
         T.DEMAND_BONDERIZING,
         ?,
         ?,
         T.STOVE_NO,
         T.FLAG_STOVE_NO,
         T.STEELCODE,
         T.STEELNAME,
         T.GRADECODE,
         T.GRADENAME,
         T.SPEC_JG_DESC,
         T.SPEC_JG,
         T.STYLE_JG,
         T.STD_CODE,
         T.STD_NAME,
         T.STD_STYLE,
         T.STD_STYLE_DESC,
         T.PRODUCCODE_JG,
         T.PRODUCCODE_JG_DESC,
         T.CODE_JG,
         T.MODEL_CODE,
         T.MODEL_DESC,
         T.IF_MONITOR_JG,
         T.PRDCR_NO,
         '0',
         ?,
         ?,
         SYSDATE,
         ?,
         ?,
         ?,
         ?,
         ?,
         ?,?,?,?,?
    FROM PLN_ZY_JG_WORKBILL T
   WHERE T.WO_ID = ?
	   ]]>
	</query>
	<query id="FrmInLibrary.AddPlnZyJgMiddSp" desc="新增接箍工单详细表(送判用)">
	  <![CDATA[
	INSERT INTO PLN_ZY_JG_MIDDLE_SP
  (WO_ID,
   JG_ORDERNO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PLINE_CODE,
   PLINE_NAME,
   DEMAND_COPPER,
   DEMAND_DETECTION,
   DEMAND_BLAST,
   DEMAND_BONDERIZING,
   PLAN_NUM,
   PLAN_WT,
   STOVE_NO,
   FLAG_STOVE_NO,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_JG_DESC,
   SPEC_JG,
   STYLE_JG,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRODUCCODE_JG,
   PRODUCCODE_JG_DESC,
   CODE_JG,
   MODEL_CODE,
   MODEL_DESC,
   IF_MONITOR_JG,
   PRDCR_NO,
   STATUS,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,MAT_NO,CRAFT_SEQ_ORD,CRAFT_FILE_NO_ORD,MAT_NO_XH)
  SELECT T.WO_ID,
         ?,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.BATCH_GROUD_NO,
         T.PLINE_CODE,
         T.PLINE_NAME,
         T.DEMAND_COPPER,
         T.DEMAND_DETECTION,
         T.DEMAND_BLAST,
         T.DEMAND_BONDERIZING,
         ?,
         ?,
         T.STOVE_NO,
         T.FLAG_STOVE_NO,
         T.STEELCODE,
         T.STEELNAME,
         T.GRADECODE,
         T.GRADENAME,
         T.SPEC_JG_DESC,
         T.SPEC_JG,
         T.STYLE_JG,
         T.STD_CODE,
         T.STD_NAME,
         T.STD_STYLE,
         T.STD_STYLE_DESC,
         T.PRODUCCODE_JG,
         T.PRODUCCODE_JG_DESC,
         T.CODE_JG,
         T.MODEL_CODE,
         T.MODEL_DESC,
         T.IF_MONITOR_JG,
         T.PRDCR_NO,
         '0',
         ?,
         ?,
         SYSDATE,
         ?,
         ?,
         ?,
         ?,
         ?,
         ?,?,?,?,?
    FROM PLN_ZY_JG_WORKBILL T
   WHERE T.WO_ID = ?
	   ]]>
	</query>
	<query id="FrmInLibrary.QueryWorkCpOrder" desc="查询工单对应接箍成品合同">
	  <![CDATA[
	  
SELECT T.JG_ORDERNO,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.BUYER_ID,
       T.BUYER_NAME,
       TO_CHAR(T.DELVRY_BDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_BDATE,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       T.ORDERCONTACT,
       T.MONITORDEMAND,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       T.PSC,
       T.MSC,
       T.INDEX_SEQ,
       T.CODE_JG,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMWALLTHICK,
       T.MODEL_CODE,
       T.AIMLENGTH,
       T.SINGLEWEIGHT,
       T.ORDERWEIGHT,
       T.ORDERNUM,
       TO_CHAR(T.LATEST_PROD_DATE, 'YYYY-MM-DD HH24:MI:SS') LATEST_PROD_DATE,
       T.MATCHWEIGHT,
       T.MATCHNUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLANWEIGHT,
       T.BUYPLANNUM,
       T.JGORDERSTATUS,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.GROUP_JGX,
       T.JGWT_BLREQ,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.MODEL_DESC,
       T.STYLE_JG,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.ORD_LN_DLY_PK,
       T.DEMAND_DETECTION,
       T.DEMAND_BONDERIZING,
       T.DEMAND_COPPER,
       T.DEMAND_BLAST,
       T.PRO_PLAN_ID,
       T.KEY_JG,
       T.JG_GROUP_ID,
       T.FINAL_USER,
       T.FINAL_USER_DESC,
       T.IF_JG_SALEORD,
       T.PRO_PLAN_ID_S,
       T.WO_ID,
       T.KEY,
       T.STATUS,
       NVL(T.HANGKC_NUM, 0) HANGKC_NUM,
      (SELECT MAX(T1.CRAFT_FILE_NO) FROM PLN_SALEORD_PROC T1 WHERE T1.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK) CRAFT_FILE_NO,
      (SELECT MAX(T1.CRAFT_SEQ) FROM PLN_SALEORD_PROC T1 WHERE T1.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK) CRAFT_SEQ
  FROM PLN_ORDER_JG T
 WHERE INSTR((SELECT W.JG_ORDERNO_ALL
               FROM PLN_ZY_JG_WORKBILL W
              WHERE W.WO_ID = ?),
             T.JG_ORDERNO) > 0
	    ]]>
	</query>
	<query id="FrmInLibrary.updatePlnZyJgMidd" desc="修改接箍工单详情">
	  <![CDATA[
UPDATE PLN_ZY_JG_MIDDLE T
   SET T.PLAN_NUM = TO_NUMBER(NVL(T.PLAN_NUM, 0)) + TO_NUMBER(?),
       T.PLAN_WT  = TO_NUMBER(NVL(T.PLAN_WT, 0)) + TO_NUMBER(?)
 WHERE T.WO_ID = ?
   AND T.ORD_LN_DLY_PK = ?
   AND T.MAT_NO = ?
   AND T.MAT_NO_XH=?
   AND T.STATUS='0'
	   ]]>
	</query>

</queryMap>