<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍合同利库">
	<query id="FrmJgOrderLk.queryJgOrder" desc="查询接箍合同">
		<![CDATA[
SELECT distinct T2.*
  FROM (SELECT T.JG_ORDERNO,
               T.ORDER_NO || '/' || T.ORDER_SEQ 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,
               DECODE(T.IF_MONITOR_JG, '1', '是', '/') 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,
               NVL(T.ORDERWEIGHT, 0) ORDERWEIGHT,
               NVL(T.ORDERNUM, 0) ORDERNUM,
               TO_CHAR(T.LATEST_PROD_DATE, 'YYYY-MM-DD HH24:MI:SS') LATEST_PROD_DATE,
               NVL(T.MATCHWEIGHT, 0) MATCHWEIGHT,
               NVL(T.MATCHNUM, 0) MATCHNUM,
               T.IFBUYPLAN,
               KH1.ABRVITION BUYPLANID,
               NVL(T.BUYPLANWEIGHT, 0) BUYPLANWEIGHT,
               NVL(T.BUYPLANNUM, 0) BUYPLANNUM,
               DECODE(T.JGORDERSTATUS,
                      '0',
                      '待处理',
                      '1',
                      '已组订单',
                      '2',
                      '已完成') 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,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T.DEMAND_DETECTION
                   AND B.VALIDFLAG = '1') DEMAND_DETECTION,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T.DEMAND_BONDERIZING
                   AND B.VALIDFLAG = '1') DEMAND_BONDERIZING,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T.DEMAND_COPPER
                   AND B.VALIDFLAG = '1') DEMAND_COPPER,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T.DEMAND_BLAST
                   AND B.VALIDFLAG = '1') DEMAND_BLAST,
               T.PRO_PLAN_ID,
               T.KEY_JG,
               T.JG_GROUP_ID,
               T.FINAL_USER,
               KH.ABRVITION FINAL_USER_DESC,
               DECODE(T.IF_JG_SALEORD, '1', '是', '/') IF_JG_SALEORD,
               T.PRO_PLAN_ID_S,
               (SELECT NVL(SUM(C.OFFLINE_NUM), 0)
                  FROM COUPLING_COM_INFO C
                 WHERE C.JG_ORDERNO = T.JG_ORDERNO
                   AND C.STATION_CODE = '700313'
                   AND C.STATION_STATUS = '2') COUNT_FINISH,
               NVL((SELECT NVL(SUM(M.PRO_NUM), 0) -
                          SUM((SELECT NVL(SUM(B.PLAN_NUM), 0)
                                FROM PLN_ZY_JG_MIDDLE B
                               WHERE B.MAT_NO = M.MAT_NO))
                     FROM COUPLING_MAT_M M
                    WHERE M.CODE_JG = T.CODE_JG),
                   0) KC_COUNT,
               DECODE((SELECT GET_PROCESS_STATUS(T1.ORD_LN_DLY_PK,
                                                T1.PROCESS_SEQ)
                        FROM DUAL),
                      '0',
                      '计划',
                      '1',
                      '生产中',
                      '2',
                      '生产完成',
                      '3',
                      '关闭') EXE_STATUS,
               (SELECT GET_PROCESS_TIME(T1.ORD_LN_DLY_PK, T1.PROCESS_SEQ)
                  FROM DUAL) TIME_CP,
               
               DECODE(T.STATUS, '0', '计划', '1', '下发', '2', '完成') STATUS,
               (SELECT DECODE(B.PRODUC_TYPE,
                              'A',
                              '钢管（管坯）',
                              'B',
                              '钢管+接箍',
                              'C',
                              '短节+附件',
                              'D',
                              '接箍',
                              'E',
                              '双公短节')
                  FROM COM_BASE_PRODUCT B
                 WHERE B.PRODUCCODE = S.PRODUCCODE) PRODUC_TYPE,
               S.PRODUCNAME,
               (SELECT NVL(SUM(Z.PLANS_NUM), 0) PLANS_NUM
                  FROM PLN_ORDER_ZG_S Z
                 WHERE Z.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK) PLANS_NUM,
               (SELECT NVL(SUM(YJ.PLN_OUTSINGLE_NUM), 0)
                  FROM PLN_ZY_ZG_M YJ, PLN_ORDER_ZG_S Z
                 WHERE YJ.PRO_PLAN_ID = Z.PRO_PLAN_ID
                   AND YJ.GX_PLAN_NO = Z.GX_PLAN_NO
                   AND Z.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK) EXPECT_NUM,
             /*  (SELECT NVL(SUM(M.PLN_INSINGLE_NUM), 0)
                  FROM PLN_ZY_JGX_M M
                 WHERE m.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) PLN_INSINGLE_NUM,
               (SELECT GET_PROCESS_NUM_S(T1.ORD_LN_DLY_PK,
                                         T1.PLN_DIVIDE_ID,
                                         T1.PROCESS_SEQ)
                  FROM DUAL) NUM_S,*/
               NVL(JGX.PLAN_INDOUBLE_NUM, 0) PLAN_INDOUBLE_NUM,
               NVL(JGX.REAL_OUTDOUBLE_NUM，0) REAL_OUTDOUBLE_NUM,
               TO_NUMBER(NVL((SELECT SUM(B.PIECES) PIECES
                     FROM COUPLING_MAT_M M, COUPLING_MAT_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.CODE_JG = T.CODE_JG),
                   0))+TO_NUMBER(NVL((SELECT SUM(TO_NUMBER((MD.DEAL_NUM)) - TO_NUMBER(NVL(MD.USED_NUM, 0)) -
       TO_NUMBER(NVL(MD.FAILL_NUM, 0))) FROM COUPLING_MAT_DEAL MD WHERE MD.OUT_FLAG='2' AND MD.CODE_JG= T.CODE_JG),0)) KC_ALL_COUNT,
               (SELECT NVL(SUM(C.QUALIFIED_NUMBER), 0)
                  FROM PLN_ZY_JG_WORKBILL B, COUPLING_CUT_RESULT C
                 WHERE C.WO_ID = B.WO_ID
                   AND B.CODE_JG = T.CODE_JG
                   AND B.ZY_BILL_STATUS IN ('2')) transit_Count
          FROM PLN_ORDER_JG T,
               PLN_SALEORD_PROC T1,
               PLN_SALEORD S,
               SLM_BASE_CUSTOMER KH,
               SLM_BASE_CUSTOMER KH1,
               (SELECT SUM(JGXC.PLAN_INDOUBLE_NUM) PLAN_INDOUBLE_NUM,
                       SUM(JGXC.REAL_OUTDOUBLE_NUM) REAL_OUTDOUBLE_NUM,
                       JGXS.ORD_LN_DLY_PK
                  FROM PLN_ZY_JGX_C JGXC, PLN_ORDER_JGX_S JGXS
                 WHERE JGXC.PRO_PLAN_ID = JGXS.PRO_PLAN_ID
                   AND JGXC.GX_PLAN_NO = JGXS.GX_PLAN_NO
                 GROUP BY JGXS.ORD_LN_DLY_PK) JGX 
         WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
           AND S.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
           AND T.ORD_LN_DLY_PK = JGX.ORD_LN_DLY_PK(+)
           AND T.FINAL_USER = KH.CUSTOMER_NO(+)
           AND T.BUYER_ID = KH1.CUSTOMER_NO(+)
           AND T1.ORDER_SOURCE <> '备料需求') T2
 WHERE 1 = 1
		]]>
	</query>
	<query id="FrmJgOrderLk.QueryMatM" desc="查询可利库库存">
		<![CDATA[
SELECT * FROM (SELECT M.PLINE_NAME,
       M.JUDGE_STOVE_NO,
       M.BATCH_NO,
       M.CODE_JG,
       M.GRADENAME,
       M.STEELNAME,
       M.MODEL_DESC,
       M.SPEC_JG_DESC,
       (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE= M.STYLE_JG) STYLE_JG,
       M.DIAMETER,
       M.CHECK_J_VAL,
       M.AIMLENGTH,
       M.SINGLEWEIGHT,
       DECODE(M.IF_MONITOR_JG,'1','是','/') IF_MONITOR_JG,
       M.PRDCR_NO,
       M.MONITORDEMAND,
       M.PRODUCER,
       TO_CHAR(M.F_IN_TIME,'YYYY-MM-DD HH24:MI:SS') F_IN_TIME,
       M.MEMO,
       M.OUTDIAMETER,M.WALLTHICK,
      (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=B.PRODUCT_FLAG) PRODUCT_FLAG,
      (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=B.MAT_STATUS) MAT_STATUS,
      (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=M.DEMAND_COPPER) DEMAND_COPPER,
      (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=M.DEMAND_DETECTION) DEMAND_DETECTION,
      (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=M.DEMAND_BLAST) DEMAND_BLAST,
      (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=M.DEMAND_BONDERIZING) DEMAND_BONDERIZING,
      (SELECT T.STORAGE_NAME FROM YDM_BS_STORAGE T WHERE T.STORAGE_NO=B.STORAGE_NO) STORAGE_NO,
      M.CREATE_NAME,
      TO_CHAR(M.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
      DECODE(B.LOCK_LIKU,'1','是','否') LOCK_LIKU,
      DECODE(M.DETER_STATUS,'0','未申请','1','申请判定','2','已判定') DETER_STATUS,
      TO_NUMBER(NVL(B.PIECES, 0)) -
      TO_NUMBER((SELECT NVL(SUM(T1.PLAN_NUM), 0)
                   FROM PLN_ZY_JG_MIDDLE T1
                  WHERE T1.MAT_NO = M.MAT_NO)) PIECES,
      TO_NUMBER(NVL(B.WEIGHT, 0)) -
      TO_NUMBER((SELECT NVL(SUM(T1.PLAN_WT), 0)
                   FROM PLN_ZY_JG_MIDDLE T1
                  WHERE T1.MAT_NO = M.MAT_NO)) WEIGHT,
      TO_NUMBER(NVL(B.PIECES, 0)) -
      TO_NUMBER((SELECT NVL(SUM(T1.PLAN_NUM), 0)
                   FROM PLN_ZY_JG_MIDDLE T1
                  WHERE T1.MAT_NO = M.MAT_NO)) Kore_Num,
      TO_NUMBER(NVL(B.WEIGHT, 0)) -TO_NUMBER((SELECT NVL(SUM(T1.PLAN_WT), 0)
                   FROM PLN_ZY_JG_MIDDLE T1
                  WHERE T1.MAT_NO = M.MAT_NO)) Kore_Wt,
      B.CUST_ALPHA_NO,
      B.ORDER_SPECIAL_DESC,
      DECODE(B.OFFLINE_LOG,'1','是','否') OFFLINE_LOG,
      M.DETER_NO,
      (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=M.DETER_RESULTS) DETER_RESULTS,
      B.KEP_NO, M.MAT_NO, B.MAT_NO_XH,M.CODE_JG_BL,
      DECODE(M.COAT_TYPE,'1','镀铜','2','磷化','4','钝化','3','镀铜及磷化','/') COAT_TYPE
  FROM COUPLING_MAT_M M, COUPLING_MAT_BUTTRESS B
 WHERE M.MAT_NO = B.MAT_NO
 AND M.QCM_STAUS NOT IN ('11', '22', '12')
			]]>
	</query>
	<query id="FrmJgOrderLk.AddMatButtLk" desc="新增库存位置利库">
		<![CDATA[
		  INSERT INTO COUPLING_MAT_BUTTRESS
  (MAT_NO,
   MAT_NO_XH,
   PRODUCT_FLAG,
   MAT_STATUS,
   PRO_PLAN_ID,
   JG_GROUP_ID,
   PRO_PLAN_ID1,
   JG_GROUP_ID1,
   MACH_NO,
   MACH_NM,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   SOURE_CODE,
   SOURE_NAME,
   PIECES,
   WEIGHT,
   CUST_ALPHA_NO,
   ORDER_SPECIAL_DESC,
   ALPHA_CODE,
   OFFLINE_LOG,
   DEMAND_COPPER_LK,
   DEMAND_DETECTION_LK,
   DEMAND_BLAST_LK,
   DEMAND_BONDERIZING_LK,
   IMPRESS_DEAL_STATUS,
   COPPER_DEAL_STATUS,
   DETECT_DEAL_STATUS,
   BLAST_DEAL_STATUS,
   PLT_CU_DEAL_STATUS,
   PHOS_DEAL_STATUS,
   LOCK_LIKU,
   DEAL_ORDE,
   KEP_NO,
   STORAGE_NO,
   LOCATION_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME)
VALUES
  ('#MAT_NO#',
   '#MAT_NO_XH#',
   '#PRODUCT_FLAG#',
   '#MAT_STATUS#',
   '#PRO_PLAN_ID#',
   '#JG_GROUP_ID#',
   '#PRO_PLAN_ID1#',
   '#JG_GROUP_ID1#',
   '#MACH_NO#',
   '#MACH_NM#',
   '#MAT_ORIGIN_CODE#',
   '#MAT_ORIGIN_NAME#',
   '#SOURE_CODE#',
   '#SOURE_NAME#',
   '#PIECES#',
   '#WEIGHT#',
   '#CUST_ALPHA_NO#',
   '#ORDER_SPECIAL_DESC#',
   '#ALPHA_CODE#',
   '#OFFLINE_LOG#',
   '#DEMAND_COPPER_LK#',
   '#DEMAND_DETECTION_LK#',
   '#DEMAND_BLAST_LK#',
   '#DEMAND_BONDERIZING_LK#',
   '#IMPRESS_DEAL_STATUS#',
   '#COPPER_DEAL_STATUS#',
   '#DETECT_DEAL_STATUS#',
   '#BLAST_DEAL_STATUS#',
   '#PLT_CU_DEAL_STATUS#',
   '#PHOS_DEAL_STATUS#',
   '#LOCK_LIKU#',
   '#DEAL_ORDE#',
   '#KEP_NO#',
   '#STORAGE_NO#',
   '#LOCATION_NO#',
   '#STORAGE_ATTR#',
   '#STORAGE_ATTR_NAME#',
   '#STORAGE_TYPE_NO#',
   '#STORAGE_TYPE_NAME#',
   '#MANAGEMENT_NO#',
   '#MANAGEMENT_NAME#',
   '#MEMO#',
   '#CREATE_NAME#',
   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'))	
			]]>
	</query>
	<query id="FrmJgOrderLk.getQureyJgOrder" 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 T.JG_ORDERNO=?
	    ]]>
	</query>
	
	<query id="FrmJgOrderLk.getQureyMatMidd" desc="查询可利库余材个">
	  <![CDATA[
SELECT TO_NUMBER(T1.PRO_NUM) - TO_NUMBER(T1.PLAN_NUM) PRO_NUM,
       T1.SINGLEWEIGHT
  FROM (SELECT NVL(B.PIECES, 0) PRO_NUM,
               NVL(T.SINGLEWEIGHT, 0) SINGLEWEIGHT,
               (SELECT NVL(SUM(T1.PLAN_NUM), 0)
                  FROM PLN_ZY_JG_MIDDLE T1
                 WHERE T1.MAT_NO = T.MAT_NO
                   AND T1.MAT_NO_XH = B.MAT_NO_XH) PLAN_NUM
          FROM COUPLING_MAT_M T, COUPLING_MAT_BUTTRESS B
         WHERE T.MAT_NO = B.MAT_NO
           AND T.MAT_NO = ?
           AND B.MAT_NO_XH = ?) T1
	    ]]>
	</query>
	<query id="FrmJgOrderLk.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,
   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, 
   DEMAND_COPPER,
   DEMAND_DETECTION,
   DEMAND_BLAST,
   DEMAND_BONDERIZING)
  SELECT T.WO_ID,
         ?,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         '',
         T.PLINE_CODE,
         T.PLINE_NAME,
         ?,
         TO_NUMBER(?)*(TO_NUMBER(T.SINGLEWEIGHT)/1000),
         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,
         T1.STD_CODE,
         T1.STD_NAME,
         T1.STD_STYLE,
         T1.STD_STYLE_DESC,
         T1.PRODUCCODE_JG,
         T1.PRODUCCODE_JG_DESC,
         T.CODE_JG,
         T.MODEL_CODE,
         T.MODEL_DESC,
         T.IF_MONITOR_JG,
         T.PRDCR_NO,
         '1',
         ?,
         ?,
         SYSDATE,
         ?,
         ?,
         ?,
         ?,
         ?,
         ?,T.MAT_NO,?,?,?,    
         ?,
         ?,
         ?,
         ?
    FROM COUPLING_MAT_M T,COM_MSC_JG T1
   WHERE T.CODE_JG=T1.CODE_JG(+)
     AND T.MAT_NO = ?
	   ]]>
	</query>
		<query id="FrmJgOrderLk.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 NVL(T.WO_ID,'/') = NVL(?,'/')
   AND T.ORD_LN_DLY_PK = ?
   AND T.MAT_NO = ?
   AND T.MAT_NO_XH=?
   AND T.STATUS='1'
	   ]]>
	</query>
		<query id="FrmJgOrderLk.QueryMatJgOrder" desc="查询已利库挂合同接箍">
	  <![CDATA[
	  SELECT M.PLINE_NAME,
       M.JUDGE_STOVE_NO,
       M.BATCH_NO,
       M.CODE_JG,
       M.GRADENAME,
       M.STEELNAME,
       M.MODEL_DESC,
       M.SPEC_JG_DESC,
       (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE = M.STYLE_JG) STYLE_JG,
       M.DIAMETER,
       M.CHECK_J_VAL,
       M.AIMLENGTH,
       M.SINGLEWEIGHT,
       DECODE(M.IF_MONITOR_JG, '1', '是', '/') IF_MONITOR_JG,
       M.PRDCR_NO,
       M.MONITORDEMAND,
       M.PRODUCER,
       TO_CHAR(M.F_IN_TIME, 'YYYY-MM-DD HH24:MI:SS') F_IN_TIME,
       M.MEMO,
       M.OUTDIAMETER,
       M.WALLTHICK,
       (SELECT T.BASENAME
          FROM COM_BASE_INFO T
         WHERE T.BASECODE = B.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T.BASENAME
          FROM COM_BASE_INFO T
         WHERE T.BASECODE = B.MAT_STATUS) MAT_STATUS,
       (SELECT T.BASENAME
          FROM COM_BASE_INFO T
         WHERE T.BASECODE = M.DEMAND_COPPER) DEMAND_COPPER,
       (SELECT T.BASENAME
          FROM COM_BASE_INFO T
         WHERE T.BASECODE = M.DEMAND_DETECTION) DEMAND_DETECTION,
       (SELECT T.BASENAME
          FROM COM_BASE_INFO T
         WHERE T.BASECODE = M.DEMAND_BLAST) DEMAND_BLAST,
       (SELECT T.BASENAME
          FROM COM_BASE_INFO T
         WHERE T.BASECODE = M.DEMAND_BONDERIZING) DEMAND_BONDERIZING,
       (SELECT T.STORAGE_NAME
          FROM YDM_BS_STORAGE T
         WHERE T.STORAGE_NO = B.STORAGE_NO) STORAGE_NO,
       P.CREATE_NAME,
       TO_CHAR(P.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       DECODE(M.DETER_STATUS, '0', '未申请', '1', '申请判定', '2', '已判定') DETER_STATUS,
       DECODE(P.STATUS, '1', '利库', '正常交库') STATUS,
       P.PLAN_NUM,
       P.PLAN_WT,
       M.DETER_NO,
       (SELECT T.BASENAME
          FROM COM_BASE_INFO T
         WHERE T.BASECODE = M.DETER_RESULTS) DETER_RESULTS,
       M.MAT_NO,
       M.CODE_JG_BL,
       DECODE(M.COAT_TYPE,
              '1',
              '镀铜',
              '2',
              '磷化',
              '4',
              '钝化',
              '3',
              '镀铜及磷化',
              '/') COAT_TYPE, B.MAT_NO_XH,M.WO_ID,P.JG_ORDERNO,P.GUID,P.ORDER_NO||'/'||P.ORDER_SEQ ORDER_NO_SEQ
  FROM COUPLING_MAT_M M, COUPLING_MAT_BUTTRESS B, PLN_ZY_JG_MIDDLE P
 WHERE M.MAT_NO = B.MAT_NO
   AND M.MAT_NO = P.MAT_NO 
   AND B.MAT_NO_XH=P.MAT_NO_XH
  
	    ]]>
	</query>
</queryMap>