<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍工单">
	<query id="FrmPlnZyJgWorkBill.queryPlanStoveReadyH" desc="查询接箍炉计划">
		<![CDATA[
SELECT HEAT_PLAN_NO,
       PRO_PLAN_ID,
       JG_GROUP_ID,
       GX_PLAN_NO,
       JUDGE_STOVE_NO,
       PLINE_CODE,
       PLINE_NAME,
       CODE_JG_BL,
       BL_WL_ID,
       BL_WL_DESC,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       MIN_D,
       MIN_H,
       AIMLENGTH_BL,
       AIM_CUT_LEN,
       LENGTH_MIN,
       LENGTH_MAX,
       TAPER,
       CODE_JG,
       MODEL_CODE,
       MODEL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       SPEC_JG,
       SPEC_JG_DESC,
       STYLE_JG,
       DIAMETER,
       CHECK_J_VAL,
       AIMLENGTH,
       SINGLEWEIGHT,
       COAT_TYPE,
       PLAN_JG_NUM,
       PLAN_BL_NUM,
       PLAN_BL_WT,
       MONITORDEMAND,
       IF_MONITOR_JG,
       PRDCR_NO,
       CUT_MACH_GRP_NO,
       CUT_MACH_GRP_NM,
       DEMAND_COPPER,
       LATHE_GRP_NO,
       LATHE_GRP_NM,
       PLANSTATUS,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       CUST_ALPHA_NO,
       ORDER_SPECIAL_DESC,
       ALPHA_CODE,
       CRAFT_FILE_NO,
       CRAFT_SEQ,
       ORD_LN_DLY_PK,
       SINGLE_CUT_NUN,
       IF_MATCH_ODD,
       IF_DO_HEAT_PLAN,
       OUTWL_ID,
       OUTWL_DESC,
       STOVE_NO,
       FLAG_STOVE_NO,
       FEED_HEAT_NO,
       GX_PRO_SEQ,
       PRO_DAY,
       BAL_YEAR_MONTH,
       PROD_STANDARD,
       OUTPUT_STANDARD,
       UPPER_HEATPLAN_ID,
       PLANSTATUS_GX,
       UPPER_PROCESS_CODE,
       HEAT_PLAN_SQE,
       JUGDE_APPLY_CODE,
       OUT_JG_NUM,
       USE_BL_NUM,
       USE_BL_WT,
       REAL_INDOUBLE_NUM,
       REAL_INDOUBLE_WT,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       PRODUCCODE_JG,
       PRODUCCODE_JG_DESC,
       BATCH_NO,
       BATCH_GROUD_NO,
       EXE_STATUS,
       WASTE_RATE,
       EXE_STATUS_DD,
       EXE_STATUS,
       WASTE_RATE,
       EXE_STATUS,
        (SELECT NVL(SUM(M.ACT_COUNT), 0)
          FROM MAT_BC_M M
         WHERE M.JUDGE_STOVE_NO =  JG.JUDGE_STOVE_NO
           AND M.BATCH_NO = JG.BATCH_NO
           AND M.BATCH_GROUD_NO =  JG.BATCH_GROUD_NO
           AND M.QCM_STAUS = '00') NUM_JGL
  FROM (SELECT T.HEAT_PLAN_NO,
       T.PRO_PLAN_ID,
       T.JG_GROUP_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CODE_JG_BL,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MIN_D,
       T.MIN_H,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.TAPER,
       T.CODE_JG,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.STYLE_JG
           AND T1.VALIDFLAG = '1') STYLE_JG,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.AIMLENGTH,
       T.SINGLEWEIGHT,
       T.COAT_TYPE,
       NVL(T.PLAN_JG_NUM, 0) PLAN_JG_NUM,
       NVL(T.PLAN_BL_NUM, 0) PLAN_BL_NUM,
       NVL(T.PLAN_BL_WT, 0) PLAN_BL_WT,
       T.MONITORDEMAND,
       DECODE(T.IF_MONITOR_JG, '1', '是', '/') IF_MONITOR_JG,
       T.PRDCR_NO,
       T.CUT_MACH_GRP_NO,
       T.CUT_MACH_GRP_NM,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.DEMAND_COPPER
           AND T1.VALIDFLAG = '1') DEMAND_COPPER,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       DECODE(T.PLANSTATUS,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS,
       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.CUST_ALPHA_NO,
       T.ORDER_SPECIAL_DESC,
       T.ALPHA_CODE,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.ORD_LN_DLY_PK,
       T.SINGLE_CUT_NUN,
       DECODE(T.IF_MATCH_ODD, '0', '正常计划', '利库计划') IF_MATCH_ODD,
       DECODE(T.IF_DO_HEAT_PLAN, '1', '是', '/') IF_DO_HEAT_PLAN,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.FEED_HEAT_NO,
       T.GX_PRO_SEQ,
       T.PRO_DAY,
       T.BAL_YEAR_MONTH,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       T.UPPER_HEATPLAN_ID,
       DECODE(CASE
                WHEN T.UPPER_PROCESS_CODE = 'D' THEN
                 (SELECT MAX(Z.PLANSTATUS)
                    FROM PLN_ZY_ZG_M Z
                   WHERE Z.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO)
                WHEN T.UPPER_PROCESS_CODE = 'E' THEN
                 (SELECT MAX(Z.PLANSTATUS)
                    FROM PLN_ZY_DBK_M Z
                   WHERE Z.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO)
                WHEN T.UPPER_PROCESS_CODE = 'F' THEN
                 (SELECT MAX(Z.PLANSTATUS)
                    FROM PLN_ZY_RCL_M Z
                   WHERE Z.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO)
                WHEN T.UPPER_PROCESS_CODE = 'G' THEN
                 (SELECT MAX(Z.PLANSTATUS)
                    FROM PLN_ZY_JGX_M Z
                   WHERE Z.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO)
              END,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS_GX,
       T.UPPER_PROCESS_CODE,
       T1.HEAT_PLAN_SQE,
       T1.JUGDE_APPLY_CODE,
       NVL(T1.OUT_JG_NUM, 0) OUT_JG_NUM,
       NVL(T1.USE_BL_NUM, 0) USE_BL_NUM,
       NVL(T1.USE_BL_WT, 0) USE_BL_WT,
       NVL(T1.REAL_INDOUBLE_NUM, 0) REAL_INDOUBLE_NUM,
       NVL(T1.REAL_INDOUBLE_WT, 0) REAL_INDOUBLE_WT,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PRODUCCODE_JG,
       T.PRODUCCODE_JG_DESC,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       (SELECT DECODE(MIN(S1.EXE_STATUS),
                      '0',
                      '计划',
                      '1',
                      '生产中',
                      '2',
                      '已生产',
                      '3',
                      '关闭')
          FROM PLN_ORDER_JGX_S S1,PLN_ORDER_JG J
         WHERE J.PRO_PLAN_ID_S=S.PRO_PLAN_ID AND S1.ORD_LN_DLY_PK = J.ORD_LN_DLY_PK) EXE_STATUS,
       NVL((SELECT H.WASTE_RATE
          FROM SLM_BASE_MATERIAL_H_PL H
         WHERE H.PLINE_CODE = T.PLINE_CODE
           AND H.IN_MATERIAL_NO = T.BL_WL_ID
           AND H.OUT_MATERIAL_NO = T.OUTWL_ID),0) WASTE_RATE,
           DECODE(S.EXE_STATUS, '0',
                      '计划',
                      '1',
                      '生产中',
                      '2',
                      '已生产',
                      '3',
                      '关闭') EXE_STATUS_DD
  FROM PLN_ZY_JG_M T, PLN_ZY_JG_C T1, PLN_GX_JG_PROP_S S
 
		]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.queryOrderPlnJg" desc="通过炉计划查询接箍成品合同">
		<![CDATA[
	SELECT '/' TYPE,
	   '0' XQ_JG_NUM,
       JGS.PRO_PLAN_ID,
       JGS.JG_GROUP_ID,
       JGS.GX_PLAN_NO,
       JGS.PLINE_CODE,
       JGS.PLINE_NAME,
       JGS.CODE_JG,
       JGS.SPEC_JG_DESC,
       JGS.CODE_JG_BL,
       JGS.STEELNAME,
       JGS.GRADENAME,
       JGS.BL_WL_DESC,
       JGS.AIM_CUT_LEN,
       JGS.MODEL_DESC,
       JGS.SINGLE_CUT_NUN,
       DECODE(JGS.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '生产完成',
              '3',
              '关闭A') EXE_STATUS,
       DECODE(JGS.IS_STOVE_ISSUED, '1', '是', '/') IS_STOVE_ISSUED,
       DECODE(JGS.IF_MONITOR_JG, '1', '是', '/') IF_MONITOR_JG,
       JGS.PRDCR_NO,
       JGS.OUTWL_DESC,
       JGS.MONITOR_POINT,
       JGS.CRAFT_FILE_NO,
       JGS.CRAFT_FILE_MAN,
       JGS.CRAFT_SEQ,
       JGS.STATION_ROAD,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGS.STYLE_JG
           AND B.VALIDFLAG = '1') STYLE_JG,
       JGS.STD_NAME,
       JGS.STD_STYLE_DESC,
       JGS.PRODUCCODE_JG_DESC,
       JGS.CODE_BL_ALL,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_DETECTION
           AND B.VALIDFLAG = '1') DEMAND_DETECTION,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_BONDERIZING
           AND B.VALIDFLAG = '1') DEMAND_BONDERIZING,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_COPPER
           AND B.VALIDFLAG = '1') DEMAND_COPPER,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_BLAST
           AND B.VALIDFLAG = '1') DEMAND_BLAST,
       NVL(JGC.GROUP_NUM_S, 0) GROUP_NUM_S,
       NVL(JGC.GROUP_WT_S, 0) GROUP_WT_S,
       NVL(JGC.PLAN_NUM, 0) PLAN_NUM,
       NVL(JGC.PLAN_WT, 0) PLAN_WT,
       JGS.ORD_LN_DLY_PK,
       TO_CHAR(T2.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       NVL(T2.PLANS_NUM, 0) PLANS_NUM,
       JGC.KEY,
       NVL((SELECT SUM(W.PLAN_BL_NUM)
             FROM PLN_ZY_JG_WORKBILL W
            WHERE W.KEY = JGC.KEY
              AND W.ZY_BILL_STATUS IN ('0', '1', '2')),
           0) WORK_NUM_TRANT,
       NVL((SELECT SUM(W.PLAN_JG_NUM)
             FROM PLN_ZY_JG_WORKBILL W
            WHERE W.KEY = JGC.KEY
              AND W.ZY_BILL_STATUS IN ('0', '1', '2')),
           0) WORK_NUM_TRANTA,
        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 = JGS.CODE_JG),
                   0) KC_COUNT,
       T2.PRO_PLAN_ID_JGX,
       T2.PLINE_NAME_JGX,
       T2.ORDER_NO_SEQ,
       NVL(T2.NUM_S,0) NUM_S,
       NVL(T2.PLN_INSINGLE_NUM,0) PLN_INSINGLE_NUM,
       T2.FINAL_USER_DESC,
       T2.PRODUCNAME,
      (SELECT COUNT(*)
          FROM PLN_ZY_JG_M W
         WHERE W.PRO_PLAN_ID = JGS.PRO_PLAN_ID
           AND W.GX_PLAN_NO = JGS.GX_PLAN_NO) Judge_Count,
       C1.CRAFT_PATH,
       C1.CRAFT_NO_JG2,
       C1.CRAFT_SEQ2,
       NVL(CASE
         WHEN (SELECT COUNT(*)
                 FROM PLN_ZY_JGX_C M
                WHERE M.PRO_PLAN_ID || '/' || M.GX_PLAN_NO =
                      T2.PRO_PLAN_ID_JGX) <> '0' THEN
          (SELECT SUM(M.PLAN_INDOUBLE_NUM)
             FROM PLN_ZY_JGX_C M
            WHERE M.PRO_PLAN_ID || '/' || M.GX_PLAN_NO = T2.PRO_PLAN_ID_JGX)
         ELSE
          (SELECT SUM(M.PLN_OUTSINGLE_NUM)
             FROM PLN_ZY_JGX_M M
            WHERE M.PRO_PLAN_ID || '/' || M.GX_PLAN_NO = T2.PRO_PLAN_ID_JGX)
       END,0) EXPECT_NUM,
    NVL(T2.PLAN_INDOUBLE_NUM,0) PLAN_INDOUBLE_NUM,
          DECODE(T2.EXE_STATUS,'0',
                      '计划',
                      '1',
                      '生产中',
                      '2',
                      '生产完成',
                      '3',
                      '关闭') Cp_EXE_STATUS,
    nvl((SELECT SUM(M.PLAN_BL_NUM)  FROM PLN_ZY_JG_M M WHERE M.CODE_JG_BL=JGS.CODE_JG_BL AND M.PLANSTATUS='00'),0) PLAN_BL_NUM,
    T2.JG_ORDERNO 
       
  FROM PLN_GX_JG_PROP_S JGS,
       PLN_GX_JG_PROP_C JGC,
       (SELECT C.KEY, C.CRAFT_PATH, C.CRAFT_NO_JG2, C.CRAFT_SEQ2
          FROM CRAFT_FILE_JG2 C
         WHERE C.VALIDFLAG = '1') C1,
       (SELECT JS.PLAN_TIME_B,
               SUM((SELECT NVL(SUM(ZG.PLANS_NUM), 0)
                     FROM PLN_ORDER_ZG_S ZG
                    WHERE ZG.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
                      AND ZG.PLN_DIVIDE_ID = S.PLN_DIVIDE_ID)) PLANS_NUM,
               T1.KEY,
               JS.PRO_PLAN_ID || '/' || JS.GX_PLAN_NO PRO_PLAN_ID_JGX,
               JS.PLINE_NAME PLINE_NAME_JGX,
               JS.ORDER_NO || '/' || JS.ORDER_SEQ ORDER_NO_SEQ,
               JS.NUM_S,
               (SELECT SUM(M.PLN_INSINGLE_NUM)
                  FROM PLN_ZY_JGX_M M
                 WHERE M.PRO_PLAN_ID = JS.PRO_PLAN_ID
                   AND M.GX_PLAN_NO = JS.GX_PLAN_NO) PLN_INSINGLE_NUM,
                   (SELECT SUM(M.PLAN_INDOUBLE_NUM)
                  FROM PLN_ZY_JGX_C M
                 WHERE M.PRO_PLAN_ID = JS.PRO_PLAN_ID
                   AND M.GX_PLAN_NO = JS.GX_PLAN_NO) PLAN_INDOUBLE_NUM,
               JS.FINAL_USER_DESC,
               S1.PRODUCNAME,
               MIN(JS.EXE_STATUS) EXE_STATUS,J.JG_ORDERNO
          FROM PLN_SALEORD_PROC S,
               PLN_ORDER_JG     J,
               PLN_ORDER_JGX_S  JS,
               PLN_GX_JG_PROP_C T1,
               PLN_SALEORD      S1
         WHERE S.ORD_LN_DLY_PK = J.ORD_LN_DLY_PK
           AND S1.ORD_LN_DLY_PK = JS.ORD_LN_DLY_PK
           AND JS.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
           AND JS.PLN_DIVIDE_ID = S.PLN_DIVIDE_ID
           AND JS.EXE_STATUS IN ('0','1','2')
           AND J.KEY = T1.KEY
		]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.queryOrderPlnJgCp" desc="通过炉计划查询成品接箍">
		<![CDATA[
		SELECT '是' TYPE,
       T1.PLAN_NUM_D PLANS_NUM,
       '0' EXPECT_NUM,
       '0' WORK_NUM_TRANT,
       '0' XQ_JG_NUM,
        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 = JGS.CODE_JG),
                   0) KC_COUNT,
       JGS.PRO_PLAN_ID,
       JGS.JG_GROUP_ID,
       JGS.GX_PLAN_NO,
       JGS.PLINE_CODE,
       JGS.PLINE_NAME,
       JGS.CODE_JG,
       JGS.SPEC_JG_DESC,
       JGS.CODE_JG_BL,
       JGS.STEELNAME,
       JGS.GRADENAME,
       JGS.BL_WL_DESC,
       JGS.AIM_CUT_LEN,
       JGS.MODEL_DESC,
       JGS.SINGLE_CUT_NUN,
       DECODE(JGS.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '生产完成',
              '3',
              '关闭A') EXE_STATUS,
       DECODE(JGS.IS_STOVE_ISSUED, '1', '是', '/') IS_STOVE_ISSUED,
       DECODE(JGS.IF_MONITOR_JG, '1', '是', '/') IF_MONITOR_JG,
       JGS.PRDCR_NO,
       JGS.OUTWL_DESC,
       JGS.MONITOR_POINT,
       JGS.CRAFT_FILE_NO,
       JGS.CRAFT_FILE_MAN,
       JGS.CRAFT_SEQ,
       JGS.STATION_ROAD,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGS.STYLE_JG
           AND B.VALIDFLAG = '1') STYLE_JG,
       JGS.STD_NAME,
       JGS.STD_STYLE_DESC,
       JGS.PRODUCCODE_JG_DESC,
       JGS.CODE_BL_ALL,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_DETECTION
           AND B.VALIDFLAG = '1') DEMAND_DETECTION,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_BONDERIZING
           AND B.VALIDFLAG = '1') DEMAND_BONDERIZING,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_COPPER
           AND B.VALIDFLAG = '1') DEMAND_COPPER,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = JGC.DEMAND_BLAST
           AND B.VALIDFLAG = '1') DEMAND_BLAST,
       NVL(JGC.GROUP_NUM_S, 0) GROUP_NUM_S,
       NVL(JGC.GROUP_WT_S, 0) GROUP_WT_S,
       NVL(JGC.PLAN_NUM, 0) PLAN_NUM,
       NVL(JGC.PLAN_WT, 0) PLAN_WT,
       JGS.ORD_LN_DLY_PK,
       JGC.KEY,
       NVL((SELECT SUM(W.PLAN_BL_NUM)
             FROM PLN_ZY_JG_WORKBILL W
            WHERE W.KEY = JGC.KEY
              AND W.ZY_BILL_STATUS IN ('0', '1', '2')),
           0) WORK_NUM_TRANT,
       NVL((SELECT SUM(W.PLAN_JG_NUM)
             FROM PLN_ZY_JG_WORKBILL W
            WHERE W.KEY = JGC.KEY
              AND W.ZY_BILL_STATUS IN ('0', '1', '2')),
           0) WORK_NUM_TRANTA,
       T1.PRODUCNAME,
       T1.FINAL_USER_DESC,
       T1.ORDER_NO_SEQ,     
        (SELECT COUNT(*)
          FROM PLN_ZY_JG_M W
         WHERE W.PRO_PLAN_ID = JGS.PRO_PLAN_ID
           AND W.GX_PLAN_NO = JGS.GX_PLAN_NO) Judge_Count,
       C1.CRAFT_PATH,
       C1.CRAFT_NO_JG2,
       C1.CRAFT_SEQ2,
       nvl((SELECT SUM(M.PLAN_BL_NUM)  FROM PLN_ZY_JG_M M WHERE M.CODE_JG_BL=JGS.CODE_JG_BL AND M.PLANSTATUS='00'),0) PLAN_BL_NUM,
       T1.JG_ORDERNO
  FROM PLN_GX_JG_PROP_S JGS,
       PLN_GX_JG_PROP_C JGC,
    (SELECT C.KEY, C.CRAFT_PATH, C.CRAFT_NO_JG2, C.CRAFT_SEQ2
          FROM CRAFT_FILE_JG2 C
         WHERE C.VALIDFLAG = '1') C1,
       (SELECT J.KEY,
               SUM(NVL(S.PLAN_NUM_D, 0)) PLAN_NUM_D,
               S.ORDER_NO || '/' || S.ORDER_SEQ ORDER_NO_SEQ,
               S1.PRODUCNAME,
               S1.FINAL_USER_DESC,J.JG_ORDERNO
          FROM PLN_SALEORD_PROC S,
               PLN_ORDER_JG     J,
               PLN_GX_JG_PROP_C JGC,
               PLN_SALEORD      S1
         WHERE S.ORD_LN_DLY_PK = J.ORD_LN_DLY_PK
           AND S1.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
           AND J.KEY = JGC.KEY
           AND S.PROCESS_SEQ = 'H'
         GROUP BY J.KEY,
                  S.ORDER_NO,
                  S.ORDER_SEQ,
                  S1.PRODUCNAME,
                  S1.FINAL_USER_DESC,J.JG_ORDERNO) T1
 WHERE JGS.PRO_PLAN_ID = JGC.PRO_PLAN_ID
   AND JGC.KEY = T1.KEY
   AND JGC.KEY = C1.KEY(+)
			]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.queryPlnZyWorkBill" desc="通过炉计划查询工单">
		<![CDATA[
		SELECT T.WO_ID,
       T.HEAT_PLAN_NO,
       T.HEAT_PLAN_SQE,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       DECODE(T.IF_ALL_OUT_WORK, '1', '是', '/') IF_ALL_OUT_WORK,
       DECODE(T.IF_OUT_CUT, '1', '是', '/') IF_OUT_CUT,
       DECODE(T.IF_OUT_CJG, '1', '是', '/') IF_OUT_CJG,
       DECODE(T.IF_OUT_IMPRESS, '1', '是', '/') IF_OUT_IMPRESS,
       DECODE(T.IF_OUT_LATHE, '1', '是', '/') IF_OUT_LATHE,
       DECODE(T.IF_OUT_DETECT, '1', '是', '/') IF_OUT_DETECT,
       DECODE(T.IF_OUT_BLAST, '1', '是', '/') IF_OUT_BLAST,
       DECODE(T.IF_OUT_COAT, '1', '镀铜','2','磷化','3','镀铜及磷化', '/') IF_OUT_COAT,
       DECODE(T.COAT_TYPE, '1', '镀铜','2','磷化','3','镀铜及磷化', '/') COAT_TYPE,
       T.PLAN_JG_NUM,
       T.CS_JG_NUM,
       T.XQ_JG_NUM,
       (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE=T.DEMAND_COPPER AND B.VALIDFLAG='1') DEMAND_COPPER,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       (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_BLAST AND B.VALIDFLAG='1') DEMAND_BLAST,
       (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE=T.DEMAND_BONDERIZING AND B.VALIDFLAG='1') DEMAND_BONDERIZING,
       DECODE(T.ZY_BILL_STATUS,'0','计划','1','下发','2','生产中','3','生产完成','关闭') 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,
       DECODE(T.IF_OUT_COPPER, '1', '是', '/') IF_OUT_COPPER,
       TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       T.PLAN_BL_NUM,
       T.PLAN_BL_WT,
       DECODE(T.IF_OUT_THREAD, '1', '是', '/') 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,
       T.OUT_NUM,
       T.OUT_WT,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_JG_DESC,
       T.SPEC_JG,
       (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE=T.STYLE_JG AND B.VALIDFLAG='1') 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,
       DECODE(T.IF_MONITOR_JG, '1', '是', '/') IF_MONITOR_JG,
       T.PRDCR_NO,T.JG_ORDERNO_ALL,T.CRAFT_PATH,T.CRAFT_NO_JG2,T.CRAFT_SEQ2,
       T.ORD_LN_DLY_PK,
       T.LATHE_CUT_NM,
       T.DELIVERY_NO,
       T.ORDER_NO ORDER_NO_SEQ,
       T.GX_PRO_SEQ,
       T.BUYER_ID,
       T.BUYER_NAME,
       T.MONITOR_POINT,
       T.MIN_D,
       T.MIN_H,T.MONITORDEMAND,
      (SELECT B.STEELNAME FROM COM_MSC_BL B WHERE B.PSC_BL=T.CODE_JG_BL AND B.VALIDFLAG='1') STEELNAME_BL
  FROM PLN_ZY_JG_WORKBILL T
 WHERE 1 = 1		
		]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.updateWork" desc="修改接箍工单信息">
		<![CDATA[
		 UPDATE PLN_ZY_JG_WORKBILL T
    SET T.PLAN_BL_NUM = TO_NUMBER(NVL(T.PLAN_BL_NUM, 0)) + TO_NUMBER('#PLAN_BL_NUM#'),
        T.PLAN_BL_WT  = TO_NUMBER(NVL(T.PLAN_BL_WT, 0)) + TO_NUMBER('#PLAN_BL_WT#'),
        T.ORDER_NO  = '#ORDER_NO#',
        T.BUYER_ID='#BUYER_ID#',
        T.BUYER_NAME='#BUYER_NAME#',
        T.PLAN_JG_NUM= TO_NUMBER(NVL(T.PLAN_JG_NUM, 0)) + TO_NUMBER('#PLAN_JG_NUM#'),
        T.CS_JG_NUM= TO_NUMBER(NVL(T.CS_JG_NUM, 0)) + TO_NUMBER('#CS_JG_NUM#'),
        T.XQ_JG_NUM= TO_NUMBER(NVL(T.XQ_JG_NUM, 0)) + TO_NUMBER('#XQ_JG_NUM#')
  WHERE T.WO_ID = '#WO_ID#'
			]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.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 )
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#',
   '0',
   '#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#')
		]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.queryPlnZyC" desc="查询接箍实际炉计划">
		<![CDATA[
		 SELECT 
       T.HEAT_PLAN_NO,
       T.HEAT_PLAN_SQE,
       T.JUGDE_APPLY_CODE,
       T.ZY_BATCH_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.FLAG_STOVE_NO,
       NVL(T.OUT_JG_NUM,0) OUT_JG_NUM,
       NVL(T.USE_BL_NUM,0) USE_BL_NUM,
       NVL(T.USE_BL_WT,0) USE_BL_WT,
       NVL(T.REAL_INDOUBLE_NUM,0) REAL_INDOUBLE_NUM,
       NVL(T.REAL_INDOUBLE_WT,0) REAL_INDOUBLE_WT,
       T1.PLANSTATUS,
       NVL(t1.SINGLEWEIGHT,0) SINGLEWEIGHT,
       NVL(t1.SINGLE_CUT_NUN,0) SINGLE_CUT_NUN,T1.MONITORDEMAND,
       T1.GRADECODE,
       T1.GRADENAME
 FROM PLN_ZY_JG_C T,PLN_ZY_JG_M T1
 WHERE T.HEAT_PLAN_NO=T1.HEAT_PLAN_NO	
		]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.getQureyPropS" desc="查询接箍排产订单7+1">
		<![CDATA[
		SELECT T.PRO_PLAN_ID,
       T.JG_GROUP_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GX_PRO_SEQ,
       T.CODE_JG,
       T.SPEC_JG_DESC,
       T.CODE_JG_BL,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.MIN_D,
       T.MIN_H,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.TAPER,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.DEMAND_DETECTION,
       T.DEMAND_BONDERIZING,
       T.DEMAND_COPPER,
       T.DEMAND_BLAST,
       T.GROUP_NUM_S,
       T.SINGLE_CUT_NUN,
       T.GROUP_BL_NUM_S,
       T.GROUP_BL_WT_S,
       T.IS_PLAN_OK,
       T.MATCHNUM_JG,
       T.PRO_MONTH,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.MATCHWT_BL,
       T.MATCHNUM_BL,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.BATCHED_NUM_OUT,
       T.REAL_BATCHED_WT,
       T.REAL_BATCHED_NUM,
       T.PRODUCED_NUM,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.IS_STOVE_ISSUED,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.SPEC_JG,
       T.GROUP_WT_S,
       T.REQ_BL_ID,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.MONITOR_POINT,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.VERSION_NO,
       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_BL_ALL,
       C1.JG_ORDERNO_ALL,
         T2.INDEX_SEQ,
         T1.BUYER_ID,T1.BUYER_NAME,T.DECISION
  FROM PLN_GX_JG_PROP_S T,
       (SELECT LISTAGG(C.JG_ORDERNO, ',') WITHIN GROUP(ORDER BY C.JG_ORDERNO ASC) JG_ORDERNO_ALL,
               C.PRO_PLAN_ID_S
          FROM (SELECT J.JG_ORDERNO, J.PRO_PLAN_ID_S FROM PLN_ORDER_JG J) C
         GROUP BY C.PRO_PLAN_ID_S) C1,PLN_SALEORD_PROC T2,
         PLN_SALEORD T1 
 WHERE T.PRO_PLAN_ID = C1.PRO_PLAN_ID_S
  AND T.ORD_LN_DLY_PK=T2.ORD_LN_DLY_PK(+)
  AND T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK
		
		]]>
	</query>

	<query id="FrmPlnZyJgWorkBill.getQureyPropC" desc="查询接箍工单7+4">
		<![CDATA[
	
SELECT T.*,
       C1.CRAFT_NO_JG2,
       C1.CRAFT_SEQ2,
       C1.CRAFT_PATH,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.DELIVERY_NO,
       T1.ORD_LN_DLY_PK,
       T1.JG_ORDERNO
  FROM PLN_GX_JG_PROP_C T,
       (SELECT C.KEY, C.CRAFT_PATH, C.CRAFT_NO_JG2, C.CRAFT_SEQ2
          FROM CRAFT_FILE_JG2 C
         WHERE C.VALIDFLAG = '1') C1,
       (SELECT J.KEY,
               SUM(NVL(S.PLAN_NUM_D, 0)) PLAN_NUM_D,
               S.ORDER_NO,
               S.ORDER_SEQ,
               S.DELIVERY_NO,
               S.ORD_LN_DLY_PK,
               J.JG_ORDERNO
          FROM PLN_SALEORD_PROC S,
               PLN_ORDER_JG     J,
               PLN_GX_JG_PROP_C JGC,
               PLN_SALEORD      S1
         WHERE S.ORD_LN_DLY_PK = J.ORD_LN_DLY_PK
           AND S1.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
           AND J.KEY = JGC.KEY
         GROUP BY J.KEY,
                  S.ORDER_NO,
                  S.ORDER_SEQ,
                  S.DELIVERY_NO,
                  S.ORD_LN_DLY_PK,J.JG_ORDERNO) T1
 WHERE T.KEY = C1.KEY(+)
   AND T.KEY = T1.KEY(+)
		]]>
	</query>

	<query id="FrmPlnZyJgWorkBill.queryMach" desc="查询车丝机床编号">
		<![CDATA[
		SELECT T.MACHINE_NAME,T.MACHINE_NO,T.MACHINE_GROUP,T.PLINE_NO FROM COUPLING_MACHINE_USER T WHERE 1=1
			]]>
	</query>
	<query id="FrmPlnZyJgWorkBill.queryMachC" desc="查询切管机床编号">
		<![CDATA[
		SELECT T.MACHINE_NAME,T.MACHINE_NO,T.PLINE_CODE FROM Coupling_Machine_Cut_User T WHERE 1=1
			]]>
	</query>

	<query id="FrmPlnZyJgWorkBill.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="FrmPlnZyJgWorkBill.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.MIN_H,T.MONITORDEMAND
 FROM PLN_ZY_JG_WORKBILL T
 WHERE  1=1
			]]>
	</query>

	<query id="FrmPlnZyJgWorkBill.UpdateMatBc" desc="修改库存炉计划ID">
		<![CDATA[
   DECLARE
BEGIN
  FOR MYROW IN (SELECT MAT_NO
                  FROM (SELECT T.MAT_NO
                          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(?, '/')
                           AND T.HEAT_PLAN_NO_NEXT = ?
                           AND T.NEXT_PROCESS_CDOE = ?
                           AND T.QCM_STAUS = '00'
                           AND T.MAT_STATUS = '80150103'
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= ?) LOOP
    UPDATE MAT_BC_M T
       SET T.HEAT_PLAN_NO_NEXT = ? WHERE T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;
			]]>
	</query>
	<query id = "FrmPlnZyJgWorkBill.updateStatus" desc = "修改工单状态">
		UPDATE PLN_ZY_JG_WORKBILL T SET T.ZY_BILL_STATUS = '3' WHERE T.WO_ID = '#WO_ID#'
	</query>
</queryMap>