<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍上料实绩">
	<query id="FrmDownLineManage.doQueryOffLine" desc="离线实绩查询">
        <![CDATA[
  SELECT 
       T.RESULT_NO,
       T.PLINE_CODE,
       T.ZY_PLAN_ID,
       T.WO_ID,
       T.STATION_CODE,
       T.STATION_DESC,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       NVL(T.OFFLINE_NUM,0) OFFLINE_NUM, 
       NVL(T.OFFLINE_WT,0) OFFLINE_WT,
       DECODE(T.IF_ALL_OUT_WORK,'1','是','2','全工序','/') IF_ALL_OUT_WORK,
       DECODE(T.HARSH_TYPE,'0','扒皮','1','镗孔','2','锯切','3','扒皮、镗孔','4','锯切、扒皮','5','锯切、镗孔','6','锯切、扒皮、镗孔','/') HARSH_TYPE,
     DECODE(T.COATING_TYPE,'2','磷化','1','镀铜','/') COATING_TYPE,
       T.MACHINE_NO,
       DECODE(T.COL_MODE,'0','接口采集','1','人工录入') COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       DECODE(T.COL_SHIFT,'1', '早', '2', '中', '3', '夜','0','白') COL_SHIFT,
       DECODE(T.COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.OFF_XH,
       NVL(T.RE_NUM,0) RE_NUM,
       NVL(T.RE_WT,0) RE_WT,
       T.RETURN_PROCESS,
       TO_CHAR(T.RE_TIME, 'YYYY-MM-DD HH24:MI:SS') RE_TIME,
       T.RE_NAME,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
        NVL(T.SUBCONTRACT_NUM,0) SUBCONTRACT_NUM,
        NVL(T.SUBCONTRACT_WT,0) SUBCONTRACT_WT,
       TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
       T.SUBCONTRACT_NAME,
        NVL(T.SUBCONTRACTCOMPLETE_NUM,0) SUBCONTRACTCOMPLETE_NUM,
       NVL( T.SUBCONTRACTCOMPLETE_WT,0) SUBCONTRACTCOMPLETE_WT,
       NVL(T.HB_FP_NUM,0) HB_FP_NUM,
       NVL( T.HB_FP_WT，0) HB_FP_WT,
       TO_CHAR(T.SUBCONTRACTCOMPLETE_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACTCOMPLETE_TIME,
       T.SUBCONTRACTCOMPLETE_NAME,
       T.MEMO,
       T.BATCH_GROUD_NO,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
       TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) Offline_Num_Bj,
        (SELECT BASENAME FROM  COM_BASE_INFO WHERE BASECODE = T.RETURN_PROCESS)  RETURN_PROCESS_DES
 FROM COUPLING_OFFLINE_RESULT T
 WHERE 1=1
 AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
       TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)))<>'0'
        ]]>
	</query>
	<query id="FrmDownLineManage.doQueryReturnLine" desc="返线实绩查询">
        <![CDATA[
  SELECT 
       T.RESULT_NO,
       T.PLINE_CODE,
       T.ZY_PLAN_ID,
       T.WO_ID,
       T.STATION_CODE,
       T.STATION_DESC,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.OFFLINE_NUM,
       T.OFFLINE_WT,
       DECODE(T.IF_ALL_OUT_WORK,'1','是','2','全工序','/') IF_ALL_OUT_WORK,
 DECODE(T.HARSH_TYPE,'0','扒皮','1','镗孔','2','锯切','3','扒皮、镗孔','4','锯切、扒皮','5','锯切、镗孔','6','锯切、扒皮、镗孔','/') HARSH_TYPE,
    DECODE(T.COATING_TYPE,'2','磷化','1','镀铜','/') COATING_TYPE,
       T.MACHINE_NO,
       DECODE(T.COL_MODE,'0','接口采集','1','人工录入') COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       DECODE(T.COL_SHIFT,'1', '早', '2', '中', '3', '夜','0','白') COL_SHIFT,
       DECODE(T.COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.OFF_XH,
       T.RE_NUM,
       T.RE_WT,
       T.RETURN_PROCESS,
       TO_CHAR(T.RE_TIME, 'YYYY-MM-DD HH24:MI:SS') RE_TIME,
       T.RE_NAME,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       T.SUBCONTRACT_NUM,
       T.SUBCONTRACT_WT,
       TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
       T.SUBCONTRACT_NAME,
       T.SUBCONTRACTCOMPLETE_NUM,
       T.SUBCONTRACTCOMPLETE_WT,
       T.HB_FP_NUM,
       T.HB_FP_WT,
       TO_CHAR(T.SUBCONTRACTCOMPLETE_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACTCOMPLETE_TIME,
       T.SUBCONTRACTCOMPLETE_NAME,
       T.MEMO,
       T.BATCH_GROUD_NO,
        (SELECT BASENAME FROM  COM_BASE_INFO WHERE BASECODE = T.RETURN_PROCESS)  RETURN_PROCESS_DES
 FROM COUPLING_OFFLINE_RESULT T
 WHERE 1=1
  AND TO_NUMBER(NVL(T.RE_NUM, 0)) <>0
        ]]>
	</query>
	<query id="FrmDownLineManage.QueryworkBill" desc="查询工单信息">
		<![CDATA[
		 SELECT 
       T.WO_ID,
       T.HEAT_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.IF_ALL_OUT_WORK,
       T.IF_OUT_CUT,
       T.IF_OUT_CJG,
       T.IF_OUT_IMPRESS,
       T.IF_OUT_LATHE,
       T.IF_OUT_DETECT,
       T.IF_OUT_BLAST,
       T.IF_OUT_COAT,
       T.COAT_TYPE,
        NVL(T.PLAN_JG_NUM,0) PLAN_JG_NUM,
        NVL(T.CS_JG_NUM,0) CS_JG_NUM,
        NVL(T.XQ_JG_NUM,0) XQ_JG_NUM,
       T.DEMAND_COPPER,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       T.DEMAND_DETECTION,
       T.DEMAND_BLAST,
       T.DEMAND_BONDERIZING,
       T.ZY_BILL_STATUS,
       T.MEMO,
       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.IF_OUT_COPPER,
       TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       NVL(T.PLAN_BL_NUM,0) PLAN_BL_NUM,
        NVL(T.PLAN_BL_WT,0) PLAN_BL_WT,
       T.IF_OUT_THREAD,
        NVL(T.REAL_BL_NUM,0) REAL_BL_NUM,
        NVL(T.REAL_BL_WT,0) REAL_BL_WT,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
        NVL(T.OUT_NUM,0) OUT_NUM,
        NVL(T.OUT_WT,0) OUT_WT,
       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.CODE_JG_BL,
       T.CODE_BL_ALL,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       T.HEAT_PLAN_SQE,
       T.KEY,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.SINGLE_CUT_NUN,
       T.SINGLEWEIGHT,
       T.PER_STATUS,
       T.BESIDE_STATUS,
       T.JG_ORDERNO_ALL,
       T.CRAFT_NO_JG2,
       T.CRAFT_SEQ2,
       T.CRAFT_PATH,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.LATHE_CUT_NM,
       T.GX_PRO_SEQ,
       T.BUYER_ID,
       T.BUYER_NAME,
       T.MONITOR_POINT,
       T.MIN_D,
       T.DECISION,
       T.INDEX_SEQ,
       T.CRAFT_SEQ,
       T.CRAFT_FILE_NO,
       T.MIN_H,T.MONITORDEMAND
 FROM PLN_ZY_JG_WORKBILL T
 WHERE  1=1
			]]>
	</query>
	<query id="FrmDownLineManage.QueryMatWt" desc="查询库存可拆吨">
		<![CDATA[
SELECT SUM(T.ACT_WEIGHT) ACT_WEIGHT
  FROM MAT_BC_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND NVL(T.JUGDE_APPLY_CODE,'/') = NVL((SELECT T.JUGDE_APPLY_CODE FROM PLN_ZY_JG_C C WHERE C.HEAT_PLAN_NO=? AND C.HEAT_PLAN_SQE=?),'/')
   AND T.HEAT_PLAN_NO_NEXT = ?
   AND T.NEXT_PROCESS_CDOE = 'H'
   AND T.QCM_STAUS = '00'
   AND T.MAT_STATUS = '80150103'
   AND ROWNUM <= ?  
			]]>
	</query>
	<query id="FrmDownLineManage.queryLoadRESULT" desc="查询最大实绩编号 ">
	<![CDATA[
  SELECT ? || ? || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM  COUPLING_LOADING_RESULT
   WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
	]]>
	</query>
	<query id="FrmDownLineManage.AddLoad" desc="新增上料信息">
		<![CDATA[
 INSERT INTO COUPLING_LOADING_RESULT
   (RESULT_NO,
    WO_ID,
    JUDGE_STOVE_NO,
    BATCH_NO,
    BATCH_GROUD_NO,
    LOAD_PIECES,
    LOAD_WEIGHT,
    LOAD_SHIFT,
    LOAD_GROUP,
    LOAD_USER,
    LOAD_TIME,
    PLINE_CODE,
    PLINE_NAME,
    CREATE_TIME,
    PRO_TIME,
    GRADECODE,
    GRADENAME,
    STEELCODE,
    STEELNAME,
    SPEC_JG_DESC,
    SPEC_JG,
    STYLE_JG,
    STD_CODE,
    STD_NAME,
    STD_STYLE,
    STD_STYLE_DESC,
    PRODUCCODE_JG,
    PRODUCCODE_JG_DESC,
    CODE_JG,
    CODE_JG_BL,
    MODEL_CODE,
    MODEL_DESC,
    IF_MONITOR_JG,
    PRDCR_NO,
    MEMO,
    CONFIRM)
    SELECT 
    ?,
    ?,
    T.JUDGE_STOVE_NO,
    T.BATCH_NO,
    T.BATCH_GROUD_NO,
    ?,
    ?,
    T.LOAD_SHIFT,
    T.LOAD_GROUP,
    T.LOAD_USER,
    T.LOAD_TIME,
    T.PLINE_CODE,
    T.PLINE_NAME,
    T.CREATE_TIME,
    T.PRO_TIME,
    T.GRADECODE,
    T.GRADENAME,
    T.STEELCODE,
    T.STEELNAME,
    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.CODE_JG_BL,
    T.MODEL_CODE,
    T.MODEL_DESC,
    T.IF_MONITOR_JG,
    T.PRDCR_NO,
    T.MEMO,
    T.CONFIRM
    FROM COUPLING_LOADING_RESULT T WHERE T.RESULT_NO = ?
			]]>
	</query>
	
	<query id="FrmDownLineManage.AddOffline" desc="新增离线信息">
		<![CDATA[
    INSERT INTO COUPLING_OFFLINE_RESULT
    (RESULT_NO,
     PLINE_CODE,
     WO_ID,
     STATION_CODE,
     STATION_DESC,
     JUDGE_STOVE_NO,
     BATCH_NO,
     OFFLINE_NUM,
     OFFLINE_WT,
     IF_ALL_OUT_WORK,
     HARSH_TYPE,
     COATING_TYPE,
     COL_TIME,
     COL_USER,
     COL_SHIFT,
     COL_GROUP,
     CREATE_TIME,OFF_XH,
     MEMO,
     BATCH_GROUD_NO,
     PLINE_NAME)
 SELECT 
     ?,
     T.PLINE_CODE,
     ?,
     T.STATION_CODE,
     T.STATION_DESC,
     T.JUDGE_STOVE_NO,
     T.BATCH_NO,
     ?,
     ?,
     T.IF_ALL_OUT_WORK,
     T.HARSH_TYPE,
     T.COATING_TYPE,
     T.COL_TIME,
     T.COL_USER,
     T.COL_SHIFT,
     T.COL_GROUP,
     T.CREATE_TIME,OFF_XH,
     T.MEMO,
     T.BATCH_GROUD_NO,
     T.PLINE_NAME
     FROM COUPLING_OFFLINE_RESULT T WHERE T.WO_ID = ?
			]]>
	</query>
	<query id="FrmDownLineManage.AddWork" desc="新增接箍工单信息">
		<![CDATA[
		INSERT INTO PLN_ZY_JG_WORKBILL
  (WO_ID,
   HEAT_PLAN_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PLINE_CODE,
   PLINE_NAME, 
   COAT_TYPE,
   PLAN_JG_NUM,
   CS_JG_NUM,
   XQ_JG_NUM,
   DEMAND_COPPER,
   LATHE_GRP_NO,
   LATHE_GRP_NM,
   DEMAND_DETECTION,
   DEMAND_BLAST,
   DEMAND_BONDERIZING,
   ZY_BILL_STATUS,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   PLAN_BL_NUM,
   PLAN_BL_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,
   CODE_JG_BL,
   CODE_BL_ALL,
   MODEL_CODE,
   MODEL_DESC,
   IF_MONITOR_JG,
   PRDCR_NO,
   HEAT_PLAN_SQE,
   KEY,
    BL_WL_ID,
        BL_WL_DESC,
        OUTWL_ID,
        OUTWL_DESC,
        AIMLENGTH_BL,
        AIM_CUT_LEN,SINGLE_CUT_NUN,SINGLEWEIGHT,JG_ORDERNO_ALL,CRAFT_NO_JG2,CRAFT_SEQ2,CRAFT_PATH,
        ORDER_NO,ORDER_SEQ,DELIVERY_NO,ORD_LN_DLY_PK,LATHE_CUT_NM,DECISION,INDEX_SEQ,CRAFT_SEQ,CRAFT_FILE_NO,GX_PRO_SEQ,
       BUYER_ID,BUYER_NAME,MONITOR_POINT,MIN_D,MIN_H,MONITORDEMAND,IFSPLIT,REAL_BL_NUM,REAL_BL_WT )
VALUES
  ('#WO_ID#',
   '#HEAT_PLAN_NO#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#BATCH_GROUD_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#COAT_TYPE#',
   '#PLAN_JG_NUM#',
   '#CS_JG_NUM#',
   '#XQ_JG_NUM#',
   '#DEMAND_COPPER#',
   '#LATHE_GRP_NO#',
   '#LATHE_GRP_NM#',
   '#DEMAND_DETECTION#',
   '#DEMAND_BLAST#',
   '#DEMAND_BONDERIZING#',
   '2',
   '#MEMO#',
   '#CREATE_NAME#',
   TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),   
   '#PLAN_BL_NUM#',
   '#PLAN_BL_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#',
   '#CODE_JG_BL#',
   '#CODE_BL_ALL#',
   '#MODEL_CODE#',
   '#MODEL_DESC#',
   '#IF_MONITOR_JG#',
   '#PRDCR_NO#',
   '#HEAT_PLAN_SQE#',
   '#KEY#','#BL_WL_ID#',
   '#BL_WL_DESC#',
   '#OUTWL_ID#',
   '#OUTWL_DESC#',
   '#AIMLENGTH_BL#',
   '#AIM_CUT_LEN#','#SINGLE_CUT_NUN#','#SINGLEWEIGHT#',
   '#JG_ORDERNO_ALL#','#CRAFT_NO_JG2#',
   '#CRAFT_SEQ2#','#CRAFT_PATH#','#ORDER_NO#',
   '#ORDER_SEQ#','#DELIVERY_NO#','#ORD_LN_DLY_PK#','#LATHE_CUT_NM#','#DECISION#',
   '#INDEX_SEQ#','#CRAFT_SEQ#','#CRAFT_FILE_NO#','#GX_PRO_SEQ#',
   '#BUYER_ID#','#BUYER_NAME#','#MONITOR_POINT#','#MIN_D#','#MIN_H#','#MONITORDEMAND#','1','#REAL_BL_NUM#','#REAL_BL_WT#')
		]]>
	</query>
	<query id="FrmDownLineManage.doQueryOutSourc" desc="查询委外实绩">
        <![CDATA[
 SELECT T.ENTRUSTED_NO,
       T.PLINE_CODE,
       T.WO_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.ENTRUSTED_NUM1,
       T.ENTRUSTED_WT1,
       DECODE(T.ENTRUSTED_LOG,
              '1',
              '未申请',
              '2',
              '已申请',
              '3',
              '审批通过',
              '4',
              '审核不通过','5','回报完毕') ENTRUSTED_LOG,
 DECODE(T.HARSH_TYPE,'0','扒皮','1','镗孔','2','锯切','3','扒皮、镗孔','4','锯切、扒皮','5','锯切、镗孔','6','锯切、扒皮、镗孔','/') HARSH_TYPE,
        DECODE(T.COATING_TYPE,'2','磷化','1','镀铜','/') COATING_TYPE,
       T.COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       DECODE(T.COL_SHIFT, '1', '早', '2', '中', '3', '夜', '0', '白') COL_SHIFT,
       DECODE(T.COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
         NVL(T.SUBCONTRACTCOMPLETE_NUM,0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT,0) SUBCONTRACTCOMPLETE_WT, 
       NVL(T.HB_FP_NUM,0) HB_FP_NUM,
       NVL(T.HB_FP_WT,0) HB_FP_WT,
       T.SUBCONTRACTCOMPLETE_NAME,
       TO_CHAR(T.SUBCONTRACTCOMPLETE_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACTCOMPLETE_TIME,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.MEMO,
       T.RESULT_NO,
       T.OFF_XH,
       T.AUDIT_NAME,
       TO_CHAR(T.AUDIT_TIME, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME,
       T1.STEELNAME,
       T1.GRADENAME,
       T1.SPEC_JG_DESC,
       T1.STD_NAME,
       T1.STD_STYLE_DESC,
       T1.PRODUCCODE_JG_DESC,
       T1.CODE_JG,
       T1.CODE_JG_BL,
       T1.MODEL_DESC,
      (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.STYLE_JG
           AND B.VALIDFLAG = '1') STYLE_JG,
             (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_DETECTION
           AND B.VALIDFLAG = '1') DEMAND_DETECTION,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_BONDERIZING
           AND B.VALIDFLAG = '1') DEMAND_BONDERIZING,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_COPPER
           AND B.VALIDFLAG = '1') DEMAND_COPPER,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_BLAST
           AND B.VALIDFLAG = '1') DEMAND_BLAST
  FROM COUPLING_OUTSOURC_RESULT T, PLN_ZY_JG_WORKBILL T1
 WHERE T.WO_ID = T1.WO_ID

        ]]>
	</query>
	<query id="FrmDownLineManage.doQueryOutResult" desc="查询委外实绩">
        <![CDATA[
         SELECT  T.* FROM COUPLING_OUTSOURC_RESULT T WHERE T.ENTRUSTED_NO=?
        ]]>
	</query>
	<query id="FrmDownLineManage.doQuery" desc="查询工序点">
        <![CDATA[    
SELECT T.BASECODE,T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE =?
   AND T.VALIDFLAG = '1'
   AND T.BASECODE NOT IN ('700312', '700313')
        ]]>
	</query>

	<query id="FrmDownLineManage.doQueryOffLine2" desc="查询离线实绩">
		<![CDATA[SELECT T.*,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
       TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT
  FROM COUPLING_OFFLINE_RESULT T
 WHERE 1 = 1
   AND T.RESULT_NO = ?
   AND T.OFF_XH = ?
   AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
       TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) <> 0

	  ]]>
	</query>
	<query id="FrmDownLineManage.QueryOffLineReNum" desc="查询是可返线个">
        <![CDATA[
SELECT TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) RE_NUM,
       TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) -
       TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) SUBCONTRACT_NUM,
       TO_NUMBER(NVL(T.OFFLINE_WT, 0)) OFFLINE_WT
  FROM COUPLING_OFFLINE_RESULT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
   AND T.RESULT_NO = ?
   AND T.OFF_XH = ?
   AND T.WO_ID = ?
        ]]>
	</query>
	
		<query id="FrmDownLineManage.QueryOffLineSubCount" desc="查询委外回报和委外支数">
        <![CDATA[
SELECT COUNT(*) COUNT
  FROM COUPLING_OFFLINE_RESULT T
 WHERE  T.WO_ID = ?
 AND (T.SUBCONTRACTCOMPLETE_NUM-T.SUBCONTRACT_NUM)>0
        ]]>
	</query>

	<query id="FrmDownLineManage.QueryWoIdJg" desc="查询工单信息">
        <![CDATA[ SELECT 
       T.WO_ID,
       T.HEAT_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.IF_ALL_OUT_WORK,
       T.IF_OUT_CUT,
       T.IF_OUT_CJG,
       T.IF_OUT_IMPRESS,
       T.IF_OUT_LATHE,
       T.IF_OUT_DETECT,
       T.IF_OUT_BLAST,
       T.IF_OUT_COAT,
       T.COAT_TYPE,
       T.PLAN_JG_NUM,
       T.CS_JG_NUM,
       T.XQ_JG_NUM,
       T.DEMAND_COPPER,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       T.DEMAND_DETECTION,
       T.DEMAND_BLAST,
       T.DEMAND_BONDERIZING,
       T.ZY_BILL_STATUS,
       T.MEMO,
       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.IF_OUT_COPPER,
       TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       T.PLAN_BL_NUM,
       T.PLAN_BL_WT,
       T.IF_OUT_THREAD,
       T.REAL_BL_NUM,
       T.REAL_BL_WT,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.OUT_NUM,
       T.OUT_WT,
       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.CODE_JG_BL,
       T.CODE_BL_ALL,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       T.HEAT_PLAN_SQE,
       T.KEY,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.SINGLE_CUT_NUN,
       T.SINGLEWEIGHT,
       T.PER_STATUS,
       T.BESIDE_STATUS,
       T.JG_ORDERNO_ALL,
       T.CRAFT_NO_JG2,
       T.CRAFT_SEQ2,
       T.CRAFT_PATH,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.LATHE_CUT_NM
 FROM PLN_ZY_JG_WORKBILL T
 WHERE T.WO_ID = ? 
        
          ]]>
	</query>
	<query id="FrmDownLineManage.QueryOffMatNo" desc="查询半成品材料离线记录">
        <![CDATA[
SELECT *
  FROM (SELECT T.MAT_NO
          FROM MAT_BC_M T
         WHERE T.QCM_STAUS = '11'
           AND T.PROCESS_CDOE = 'H'
           AND T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
           AND T.BATCH_GROUD_NO = ?
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM < ?         
         ]]>
	</query>
	<query id="FrmDownLineManage.QueryOffCoupMat" desc="查询接箍库存离线个数">
        <![CDATA[
      SELECT T.MAT_NO,NVL(T.PRO_NUM,0) PRO_NUM,nvl(T.PRO_WT,0) PRO_WT
          FROM COUPLING_MAT_M T
         WHERE T.QCM_STAUS = '11'
           AND T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
           AND T.WO_ID = ?
         ORDER BY T.MAT_NO ASC
         ]]>
	</query>
	<query id="FrmDownLineManage.UpdateOff" desc="修改离线实绩返线个数">
        <![CDATA[
        UPDATE COUPLING_OFFLINE_RESULT T
   SET T.RE_NUM         = TO_NUMBER(NVL(T.RE_NUM, 0)) + TO_NUMBER(?),
       T.RE_WT          = TO_NUMBER(NVL(T.RE_WT, 0)) + TO_NUMBER(?),
       T.RETURN_PROCESS = ?,
       T.RE_TIME        = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       T.RE_NAME        = ?
 WHERE T.RESULT_NO = ?
   AND T.OFF_XH = ?
          ]]>
	</query>
	<query id="FrmDownLineManage.deleteMatBc" desc="删除材料表废品新增数据">
		<![CDATA[
  DELETE MAT_BC_M T  WHERE T.MAT_NO = ?
        ]]>
	</query>

	<query id="FrmDownLineManage.deleteMatBut" desc="删除材料表废品新增数据">
		<![CDATA[
  DELETE YDM_BC_BUTTRESS T  WHERE T.MAT_NO = ?
        ]]>
	</query>
	<query id="FrmDownLineManage.UpdatePortVrpReturn" desc="修改队列表返线状态">
        <![CDATA[
  UPDATE PORT_JG_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS = ?, LEVE_LOG = ?, RETURN_PROCESS = ?
 WHERE WO_ID = ?
   AND MAT_NO = ?  
          ]]>
	</query>

	<query id="FrmDownLineManage.QueryReturnMatNo" desc="查询管号队列返线的材料号">
        <![CDATA[  
   SELECT *
  FROM (SELECT T.MAT_NO
          FROM PORT_JG_BATCH_SAMPLE_RESULT T
         WHERE T.LEVE_LOG = '20'
           AND T.WO_ID = ?
           AND T.RETURN_PROCESS = ?
           AND T.VALIDFLAG='1'
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM < ?
          ]]>
	</query>
	<query id="FrmDownLineManage.AddJgOfflineMat" desc="增加材料表">
		<![CDATA[
          INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   FLAG_STOVE_NO_ZG,
   CUT_NUM,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   SCRAP_REASON)
SELECT
   P.MAT_NO,
   '801401',
   '80150101',
  '',
   T.STOVE_NO,
   T.JUDGE_STOVE_NO,
   T.BATCH_NO,
   P.GROUP_NO,
   '0',
   TM.BL_WL_ID,
   TM.BL_WL_DESC,
   '',
   '',
   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.ORDER_NO,
   T.ORDER_SEQ,
   '',
   TM.CRAFT_FILE_NO,
   A.PROCESS_CODE,
   A.PROCESS_DESC,
   'H',
   '接箍',
   T.PLINE_CODE,
   T.PLINE_NAME,
   '801302',
   T.PLINE_NAME,
   T.ACT_DIMATER,
   T.ACT_HEIGHT,
   T.ACT_LEN,
   T.ACT_LEN_MIN,
   T.ACT_LEN_MAX,
   P.ACT_COUNT,
   P.ACT_WEIGHT,
   P.ACT_THEORY_WEIGHT,
   '0',
   C.DEPARTMENT_CODE,
   C.DEPARTMENT_DESC,
   '0',
 '',
  '',
   '',
   '0',
   '0',
   '0',
   '1',
   SYSDATE,
   '',
   ?,
   ?,
   SYSDATE,
   '',
   NULL,
   '',
   '',
   T.ORD_LN_DLY_PK,
   TO_CHAR(SYSDATE,'YYYYMM'),
   '',
   '',
   D.BASECODE,
   D.BASENAME,
   '',
   '',
   '',
   '0',
   ?,
   '',
   T.HEAT_PLAN_NO,
   T.JUDGE_STOVE_NO ,
   '',
   '',
   T.TARGET,
  NVL(?,P.FLAG_STOVE_NO),
   '',
   E.BASECODE,
   E.BASENAME,
   ?
   FROM PLN_ZY_JG_WORKBILL T1 LEFT JOIN PORT_JG_BATCH_SAMPLE_RESULT P ON T1.WO_ID = P.WO_ID AND P.MAT_NO =?
   LEFT JOIN MAT_BC_BACKUP T ON T.MAT_NO=DECODE(P.M_MAT_NO,'',P.MAT_NO,P.M_MAT_NO)
   LEFT JOIN PLN_ZY_JG_M TM ON TM.HEAT_PLAN_NO=T1.HEAT_PLAN_NO
   LEFT JOIN COM_BASE_PROCESS A ON A.PROCESS_CODE =TM.UPPER_PROCESS_CODE
   LEFT JOIN COM_BASE_PLINE C ON C.PLINE_CODE = T.PLINE_CODE
   LEFT JOIN COM_BASE_INFO D  ON D.BASECODE =?
   LEFT JOIN COM_BASE_INFO E ON E.BASECODE = ?
   WHERE T1.WO_ID =?
        ]]>
	</query>

	<query id="FrmDownLineManage.AddJgBut" desc="增加位置表">
		<![CDATA[
      INSERT INTO YDM_BC_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,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
  SELECT T.MAT_NO,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.GROUP_NO,
         Y.STORAGE_NO,
         NULL,
         NULL,
         NULL,
         Y.STORAGE_ATTR,
         Y.STORAGE_ATTR_NAME,
         Y.STORAGE_TYPE_NO,
         Y.STORAGE_TYPE_NAME,
         Y.MANAGEMENT_NO,
         Y.MANAGEMENT_NAME,
         '',
         ?,
         SYSDATE,
         NULL,
         NULL,
         NULL,
         NULL,
         Y.DEPARTMENT_CODE,
         Y.DEPARTMENT_DESC
    FROM PORT_JG_BATCH_SAMPLE_RESULT T
LEFT JOIN (SELECT C.PLINE_CODE,C.PLINE_NAME,B.* FROM COM_BASE_PLINE C,Ydm_Bs_Storage B WHERE C.OUT_REPOSITORY = B.STORAGE_NO) Y
      ON Y.PLINE_CODE = T.PLINE_CODE
     AND ROWNUM = 1
   WHERE T.WO_ID = ?
     AND T.MAT_NO = ?
        ]]>
	</query>

	<query id="FrmDownLineManage.queryEntrustrMax" desc="获取最大委外单号">
	<![CDATA[
	SELECT 'W'||? ||
       LPAD(SUBSTR(NVL(MAX(T.ENTRUSTED_NO), '0000'), -4,4) + 1, 4, '0') AS ENTRUSTED_NO
  FROM COUPLING_OUTSOURC_RESULT T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
		]]>
	</query>

	<query id="FrmDownLineManage.updateJgOffLine" desc="修改接箍离线表产线">
		<![CDATA[
UPDATE COUPLING_OFFLINE_RESULT T
   SET PLINE_CODE = ?, PLINE_NAME = ?
 WHERE WO_ID = ?
   AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
       TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) > 0

               ]]>
	</query>
	<query id="FrmDownLineManage.updateJgPort" desc="修改队列表产线">
		<![CDATA[
UPDATE PORT_JG_BATCH_SAMPLE_RESULT T
   SET PLINE_CODE   =?,
       PLINE_NAME   = ?
 WHERE WO_ID = ?
 AND MAT_STATUS ='20'
               ]]>
	</query>

	<query id="FrmDownLineManage.updateJGMPlan" desc="修改工单产线">
		<![CDATA[
UPDATE PLN_ZY_JG_WORKBILL
   SET PLINE_CODE_W = DECODE(?, PLINE_CODE, '', ?),
       PLINE_NAME_W = DECODE(?, PLINE_NAME, '', ?)
 WHERE WO_ID = ?
               ]]>
	</query>
	<query id="FrmHttDownLineManage.AddOutSourc" desc=" 新增委外加工表">
		<![CDATA[
		 INSERT INTO COUPLING_OUTSOURC_RESULT(
        ENTRUSTED_NO,
        PLINE_CODE,
        WO_ID,
        JUDGE_STOVE_NO,
        BATCH_NO,
        ENTRUSTED_NUM1,
        ENTRUSTED_WT1,
        ENTRUSTED_LOG,
        HARSH_TYPE,
        COATING_TYPE,
        COL_MODE,
        COL_TIME,
        COL_USER,
        COL_SHIFT,
        COL_GROUP,
        CREATE_TIME,
        PLINE_NAME,
        STATION_CODE,
        STATION_DESC,MEMO,RESULT_NO,OFF_XH,STATION_UNIT_CODE,STATION_UNIT_DESC)
 VALUES( 
        '#ENTRUSTED_NO#',
        '#PLINE_CODE#',
        '#WO_ID#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#ENTRUSTED_NUM1#',
        '#ENTRUSTED_WT1#',
        '#ENTRUSTED_LOG#',
        '#HARSH_TYPE#',
        '#COATING_TYPE#',
        '#COL_MODE#',
        SYSDATE,
        '#COL_USER#',
        '#COL_SHIFT#',
        '#COL_GROUP#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#PLINE_NAME#',
        '#STATION_CODE#',
        '#STATION_DESC#','#MEMO#','#RESULT_NO#','#OFF_XH#','#STATION_UNIT_CODE#','#STATION_UNIT_DESC#')
		 ]]>
	</query>
	<query id="FrmHttDownLineManage.UpdateOffOutSourc" desc="修改离线委外信息">
		<![CDATA[
		UPDATE COUPLING_OFFLINE_RESULT T
   SET T.SUBCONTRACT_NO     = ?,
       T.SUBCONTRACT_NUM    = TO_NUMBER(NVL(T.SUBCONTRACT_NUM,0))+TO_NUMBER(?),
       T.SUBCONTRACT_WT     = TO_NUMBER(NVL(T.SUBCONTRACT_WT,0))+TO_NUMBER(?),
       T.SUBCONTRACT_TIME =TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
       T.SUBCONTRACT_NAME   = ?
 WHERE T.RESULT_NO = ?
   AND T.OFF_XH = ?
		
		 ]]>
	</query>
	<query id="FrmDownLineManage.QueryHttEntrustResult" desc="查询委托实绩">
		<![CDATA[
		select T.PRO_NUM, INSTR(T.PROJECT_NAME, '成品加工') isCpjg, T.RETURN_FLAG
   from HTT_ENTRUST_RESULT t
  WHERE T.SUBCONTRACT_NO = ?
		 ]]>
	</query>
</queryMap>