<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="FrmRollTubeLibraryZg.queryPlanStoveD" desc="查询轧管虚拟炉计划">
            <![CDATA[
        SELECT T.HEAT_PLAN_NO,
       T.GX_PRO_SEQ,
       T1.ZY_BATCH_ID,
       CASE
         WHEN T.STOVE_NO IS NULL AND T.UPPER_PROCESS_CODE = 'B' THEN
          (SELECT O.STOVE_NO
             FROM PLN_STEELFOR_ORD O
            WHERE O.FURNACENO || '/' || O.SEQUENCENO = T.UPPER_HEATPLAN_ID)
       
         ELSE
          T.STOVE_NO
       END STOVE_NO,
         CASE
         WHEN T.JUDGE_STOVE_NO IS NULL AND T.UPPER_PROCESS_CODE = 'B' THEN
          (SELECT O.JUDGE_STOVE_NO
             FROM PLN_STEELFOR_ORD O
            WHERE O.FURNACENO || '/' || O.SEQUENCENO = T.UPPER_HEATPLAN_ID) 
        
         ELSE
          T.JUDGE_STOVE_NO
       END JUDGE_STOVE_NO,
        CASE
         WHEN T.FLAG_STOVE_NO IS NULL AND T.UPPER_PROCESS_CODE = 'B' THEN
          (SELECT O.FLAG_STOVE_NO
             FROM PLN_STEELFOR_ORD O
            WHERE O.FURNACENO || '/' || O.SEQUENCENO = T.UPPER_HEATPLAN_ID)
        
         ELSE
          T.FLAG_STOVE_NO
       END FLAG_STOVE_NO,
       DECODE(T.PLANSTATUS,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭A') PLANSTATUS,
       T.UPPER_HEATPLAN_ID,
       T.PRO_PLAN_ID||'/'||T.GX_PLAN_NO PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.CCM_PRO_PLAN_ID ||'/'||T.CCM_GX_PLAN_NO CCM_PRO_PLAN_ID,
       T.CCM_GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.UPPER_PROCESS_CODE,
       T.NEXT_PROCESS_CODE,
       DECODE(T.ISENDGX, '0', '/', '1', '是') ISENDGX,
       DECODE(T.IF_MATCH_ODD, '0', '/', '1', '前轧管利库','4','后轧管利库','6','本工序精整利库','炼钢利库') IF_MATCH_ODD,
       DECODE(T.IF_DO_HEAT_PLAN, '0', '/', '1', '是') IF_DO_HEAT_PLAN,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO ||'/'||T.ORDER_SEQ ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.IF_EXPORT,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PRO_MONTH,
       DECODE(T.IF_LEN_CONTROL, '0', '/', '1', '是') IF_LEN_CONTROL,
       DECODE(T.IF_MINUS_SIC_ROLL, '0', '/', '1', '是') IF_MINUS_SIC_ROLL,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       T.DECISION,
       T.PROGY_MEMO,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       DECODE(T.OUTS_BILLET_FL, '1', '外购', '0', '自炼') OUTS_BILLET_FL,
       DECODE(T.GPTYPE, '1', '铸坯', '2', '锻坯') GPTYPE,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.DIAMETER,
       T.LEN_GP_SINGLE,
       T.WT_GP_SINGLE,
       T.PLN_INSINGLE_NUM,
       T.PLN_INSINGLE_WT,
       T.PLN_OUTSINGLE_NUM,
       T.PLN_OUTSINGLE_W,
       T.REDUCED_WT,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.OUTDIAMETER_ZG,
       T.WALLTHICK_ZG,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.THICKNESS_WALL,
       T.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.AIMLENGTH,
       T.ROLL_LENGTH,
       T.OUTNUM_CUT,
       DECODE(T.CUT_TYPE, '0', '被动', '1', '主动') CUT_TYPE,
       T1.LEN_CUTEND,
       T1.LEN_CUTHEAD,
       T1.DIAMETER_MANDREL,
       T1.PASS_CODE,
       T1.PASS_NAME,
       DECODE(T.IF_MONITOR, '0', '/', '1', '轧管利库','2','炼钢利库') IF_MONITOR,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T1.BOM,
       T.WHOLE_BACKLOG,
       T1.WHOLE_BACKLOG_DESC,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T1.CRAFT_FILE_NO,
       T1.CRAFT_FILE_MAN,
       T1.CRAFT_SEQ,
       T.SEC_CRAFT_FILE_NO,
       T.STATION_ROAD,
       T.PRO_DAY,
       T.BAL_YEAR_MONTH,
       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.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       DECODE(T.IS_LOAD, '0', '未上料', '1', '已上料') IS_LOAD,
       DECODE(T.PLN_TYPE, '0', '正常计划', '1', '试轧料') PLN_TYPE,   
       T.INDEX_SEQ,T.FEED_HEAT_NO
  FROM PLN_ZY_ZG_M T,PLN_ORDER_ZG_S T1
 WHERE 1 = 1
  AND T.PRO_PLAN_ID=T1.PRO_PLAN_ID
 AND T.GX_PLAN_NO=T1.GX_PLAN_NO
              ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.queryPlanStoveDc" desc="查询轧管实际炉计划">
            <![CDATA[
             SELECT 
       T.HEAT_PLAN_NO,
       T.HEAT_PLAN_SQE,
       T.JUGDE_APPLY_CODE,
       T1.ZY_BATCH_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.DIAMETER,
       T.LEN_GP_SINGLE,
       T.WT_GP_SINGLE,
       T.CUT_NUM_GP,
       T.LENGTH_M,
       T.WEIGHT_M,
       T.PLAN_INDOUBLE_NUM,
       T.PLAN_INDOUBLE_WT,
       T.REAL_INDOUBLE_NUM,
       T.REAL_INDOUBLE_WT,
       T.FLAG_STOVE_NO,
       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.FEED_HEAT_NO,T.CUT_TARGET,T.CUT_LENGTH,T.CUT_WEIGHT
 FROM PLN_ZY_ZG_C T,PLN_ORDER_ZG_S T1
 WHERE 1=1
  AND T.PRO_PLAN_ID=T1.PRO_PLAN_ID
 AND T.GX_PLAN_NO=T1.GX_PLAN_NO
              ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.queryPlanOrderD" desc="查询轧管排产(界面)">
             <![CDATA[  
             SELECT S.*,DECODE((SELECT COUNT(*) GPCOUNT
                FROM MAT_GP_M GP
               WHERE GP.PRODUCT_FLAG = '801401'
                 AND ((GP.MAT_STATUS = '80150102' AND GP.JUDGE_RESULT_CODE = '40740701') OR INSTANCY_FLAG = '1')
                 AND GP.QCM_STAUS = '00'
                 AND GP.DIMATER NOT LIKE '%t%'
                 AND GP.MNG_LOCK_FLAG = '0'
                 AND GP.LOCK_FLAG = '0'
                 AND GP.BELONG_CODE IN('002001001','002023005')
                 AND INSTR(S.GRADE_ALL, GP.GRADENAME) > 0
                 AND DECODE(GP.DIMATER,'251','250',GP.DIMATER) = DECODE(TO_CHAR(TO_NUMBER(S.DIAMETER_GP)),'251','250',TO_CHAR(TO_NUMBER(S.DIAMETER_GP)))
                 AND S.IS_REPAIR_PLN = '/'),
              '0',
              '无库存',
              '有库存') GPCOUNT FROM (
      SELECT 
      (SELECT LISTAGG(C1.GRADENAME, ',') WITHIN GROUP(ORDER BY C1.PRIORITY ASC, C1.GRADECODE)
  FROM (SELECT DISTINCT B.GRADENAME,
                        B.GRADECODE,
                        B.PRIORITY,
                        C.CRAFT_SEQ,
                        S.ORD_LN_DLY_PK,
                        S.SUPPLY_UNIT_CODE,
                        S.SUPPLY_UNIT
          FROM CRAFT_ORD_DESIGN_MSC_PL_GZ B,
               CRAFT_ORD_DESIGN_MSC_PL    B1,
               pln_saleord                s,
               CRAFT_ORD_DESIGN           c
         WHERE B.DESGIN_KEY = B1.DESGIN_KEY
           AND B.MSC_PLINE = B1.MSC_PLINE
           AND C.ORD_LN_PK = S.ORD_LN_PK
           AND B.DESGIN_KEY = C.DESGIN_KEY
         ORDER BY B.PRIORITY ASC, B.GRADECODE ASC) C1
 WHERE C1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND C1.CRAFT_SEQ =T.CRAFT_SEQ) GRADE_ALL,
       D.TRANSIT_TYP,
       D.DELVRY_ADDR,
       D.VALIDFLAG,
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       DECODE(T.ISENDGX,
              '1',
              NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/'),
              T.PRO_PLAN_ID) PRO_PLAN_NO,
       NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/') ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.DIAMETER_GP,
       T.LEN_GP_SINGLE,
       T.ROLL_LENGTH,
       NVL(T.LEN_CUTHEAD,0) LEN_CUTHEAD,
       NVL(T.LEN_CUTEND,0) LEN_CUTEND,
       T.OUTNUM_CUT,
       T.DIAMETER_MANDREL,
       T.PASS_CODE,
       T.PASS_NAME,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       DECODE(T.ISENDGX, '1', '是', '/') ISENDGX,
       DECODE(T.IF_MONITOR_ZG, '1', '是', '/') IF_MONITOR_ZG,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.STATION_ROAD,
       T.PRO_MONTH,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.GX_PRO_SEQ,
       TO_CHAR(ROUND(TO_NUMBER(NVL(T.PLAN_USETIME, '0')) / 60, 2)) 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.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '已生产',
              '3' , '关闭A' , '') EXE_STATUS,
       DECODE(T.IS_REPAIR_PLN, '1', '是', '/') IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       DECODE(T.IS_PLAN_OK, '1', '是', '/') IS_PLAN_OK,
       DECODE(T.GPREQ_IF_OK, '1', '是', '/') GPREQ_IF_OK,
       T.GPREQ_ID,
       T.ZY_BATCH_ID,
       T.CIC_GROUP_GP,
       T.PIC_GROUP_GP,
       T.SIC_GROUP_GP,
       T.DIC_GROUP_GP,
       T.WIC_GROUP_GP,
       T.GIC_GROUP_GP,
       T.CIC_GP,
       T.PIC_GP,
       T.SIC_GP,
       T.DIC_GP,
       T.WIC_GP,
       T.GIC_GP,
       T.IF_EXPORT,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       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.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       DECODE(T.IF_STOVE_ISSUED, '1', '是', '/') IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.IS_ONLOAD_LINE,
       T.OUTDIAMETER_ZG,
       T.WALLTHICK_ZG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       (SELECT S1.CRAFT_PATH
          FROM CRAFT_FILE_LV2 S1
         WHERE INSTR(T1.CRAFT_FILE_LV2_D, S1.PK) > 0
           AND INSTR(S1.PLINE_CODE, T.PLINE_CODE) > 0
           AND S1.VALIDFLAG = '1'
           AND S1.PROCESS_CODE = 'D') CRAFT_FILE_LV2_G,
      (SELECT CD.CRAFT_PATH  FROM CRAFT_ORD_DESIGN CD WHERE CD.ORD_LN_PK=T1.ORD_LN_PK AND CD.CRAFT_SEQ=T.CRAFT_SEQ) CRAFT_PATH,
       T.CRAFT_SEQ,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STD_STYLE_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_DESC,
       DECODE(T.IF_LEN_CONTROL, '1', '是', '0', '/') IF_LEN_CONTROL,
       DECODE(T.IF_MINUS_SIC_ROLL, '1', '是', '0', '/') IF_MINUS_SIC_ROLL,
       T.TUBE_END_RATIO,
       T.GPREQ_NUM,
       T.GPREQ_WEIGHT,
       T.VERIFY1,
       T.VERIFY2,
       T.VERIFY3,
       NVL(T.WEIGTH_S_MIN, 0) WEIGTH_S_MIN,
       (SELECT T9.BASENAME
          FROM COM_BASE_INFO T9
         WHERE T9.BASECODE = T.PRIORITY) PRIORITY,
       T.PRIORITY_MEMO,
       NVL(T.PLANS_NUM, 0) PLANS_NUM,
       T.ORIGINAL_NUMBER,
       T1.FINAL_USER_DESC,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       T.THICKNESS_WALL,
       T.DECISION,
       T.PROCESS_DESC_C,
       T.APPLY_NO,
       DECODE(T.APPLY_STATUS,
              '00',
              '作废',
              '10',
              '申请',
              '20',
              '审批通过',
              '30',
              '审批不通过') APPLY_STATUS,
       T.ISSUED_MEMO,
       DECODE(T.OUTS_BILLET_FL, '0', '自炼', '1', '外购') OUTS_BILLET_FL,
       T1.OUTS_STL_PIPE_FL,
       T1.LEN_NO,
       T1.LENGTHDISC_N,
       T1.LEN_NO_N,
       T.PROGY_MEMO,
       (SELECT P.GRADECODE_ALL
          FROM PLN_SALEORD_PROC P
         WHERE P.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND P.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID) GRADECODE_ALL,
       T1.PRD_CLS,
       T1.ORDERFROM,
       T1.PRODUCE_SORT,
       (SELECT SP.HR_CAPCTY
          FROM SLM_BASE_MATERIAL_D_PL SP
         WHERE SP.PLINE_CODE = T.PLINE_CODE
           AND SP.IN_MATERIAL_NO = T.INWL_ID
           AND SP.OUT_MATERIAL_NO = T.OUTWL_ID) HR_CAPCTY,
       NVL((SELECT SUM(M.PREDICT_TON)
             FROM MIL_PLAN M
            WHERE M.PRO_PLAN_ID = T.PRO_PLAN_ID
              AND M.GX_PLAN_NO = T.GX_PLAN_NO
              AND SUBSTR(M.JUDGE_STOVE_NO, -2) = '01'),
           0) EXPECT_WT,
       NVL((SELECT SUM(M.PREDICT_PIECE)
             FROM MIL_PLAN M
            WHERE M.PRO_PLAN_ID = T.PRO_PLAN_ID
              AND M.GX_PLAN_NO = T.GX_PLAN_NO
              AND SUBSTR(M.JUDGE_STOVE_NO, -2) = '01'),
           0) EXPECT_NUM,
           DECODE(T.PASSIVE,'1','主动','0','被动') PASSIVE,
           DECODE(B.CODE_JG_BL,'',B.CODE_DJ_BL,B.CODE_JG_BL) REQ_BL_ID,
           T.GRADECODE_LK,T.GRADENAME_LK,T.CIC_GROUP_LK,
        
       (SELECT GET_GP_MAT_NUM_ZL(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) FURNA_NUM,
       (SELECT GET_GP_MAT_WT_ZL(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) FURNA_WEIGHT,
       (SELECT GET_GP_PLNZGM_NUM(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) LJ_NUM,
       (SELECT GET_GP_PLNZGM_WT(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) LJ_WEIGHT,
        (SELECT GET_GP_MAT_NUM(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) PEND_NUM,
       (SELECT GET_GP_MAT_WT(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) PEND_WEIGHT,
        (SELECT GET_GP_WT_CK(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) CK_WEIGHT,
       (SELECT GET_GP_NUM_CK(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) CK_NUM,
       (SELECT GET_ZG_REDUCED_WT(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) REDUCED_WT,
       T1.SUPPLY_UNIT_CODE,
       T1.SUPPLY_UNIT,
       DECODE(T1.TYPE_FLAG,'0','非双经销','1','双经销','2','定销订购','4','来料加工')TYPE_FLAG
  FROM PLN_ORDER_ZG_S T,
       (SELECT Q1.PRODUCCODE,
               Q1.PRODUCNAME,
               Q1.STD_CODE,
               Q1.STD_NAME,
               Q1.STD_STYLE_DESC,
               Q1.SPEC_CODE,
               Q1.SPEC_NAME,
               Q1.ORD_LN_DLY_PK,
               Q1.ORD_LN_PK,
               Q1.STEELCODE,
               Q1.STEELNAME,
               Q1.DELVRY_RANGE_TPE,
               Q1.DELVRY_RANGE_MAX,
               Q1.DELVRY_RANGE_MIN,
               Q1.DELVRY_QTY,
               Q1.MODEL_DESC,
               Q4.ABRVITION FINAL_USER_DESC,
               Q1.LENGTHMAX,
               Q1.LENGTHMIN,
               Q1.OUTS_BILLET_FL,
               Q1.OUTS_STL_PIPE_FL,
               Q1.LENGTHDISC_N,
               Q1.LEN_NO_N,
               Q1.LEN_NO,
               Q2.CRAFT_FILE_LV2_D,
               (SELECT A.PRODUC_DESC
                  FROM COM_BASE_PRODUCT A
                 WHERE A.PRODUCCODE = Q1.PRODUCCODE
                   AND A.VALIDFLAG = '1') PRD_CLS,
               (SELECT A.BASENAME
                  FROM COM_BASE_INFO A
                 WHERE A.BASECODE = Q1.ORDERFROM) ORDERFROM,
               Q1.PRODUCE_SORT,
               Q1.SUPPLY_UNIT_CODE,
               Q1.SUPPLY_UNIT,
               Q1.TYPE_FLAG
          FROM PLN_SALEORD              Q1,
               CRAFT_ORD_DESIGN         Q2,
               CRAFT_ORD_DESIGN_APPOINT Q3,
               SLM_BASE_CUSTOMER        Q4
         WHERE Q1.ORD_LN_PK = Q3.ORD_LN_PK(+)
           AND Q1.FINAL_USER = Q4.CUSTOMER_NO(+)
           AND Q1.ORD_LN_PK = Q2.ORD_LN_PK(+)
           AND Q2.VALIDFLAG(+) = '1') T1,
       (SELECT MIN(S.NEXT_GX) NEXT_GX,
               S.PRO_PLAN_ID,
               MIN(S.PLAN_GROUP_ID) PLAN_GROUP_ID
          FROM PLN_ORDER_ZG S
         GROUP BY S.PRO_PLAN_ID) T2,
       SLM_ORDER_LINE_DELIVERY D,PLN_PORDER_BL_REQ B
 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK(+)
   AND T.PRO_PLAN_ID = T2.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK(+)
   AND T.ORD_LN_DLY_PK=B.REQ_BL_ID(+)
   AND T.IS_PLAN_OK='1'
               ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.getStlChemicalStd" desc="查询轧管对应内控成分元素">
            <![CDATA[
             SELECT V.CHEM_CODE,
             V.CHEM_NAME,
             V.CHEM_TYPE,
             V.CHEM_FORMULA,
             V.STDMIN_SIGN || V.STDMIN STDMIN_SIGN,
             V.STDMAX_SIGN || V.STDMAX STDMAX_SIGN,
             V.STDTARGET,
             C.CHEM_SEQ,V.CIC
        FROM CRAFT_ORD_DESIGN_STD_CIC V, COM_BASE_CHEM C
       WHERE V.CHEM_CODE = C.CHEM_CODE
          --AND INSTR(?, V.CIC) > 0
         AND V.PROCESS_CODE = 'A'
         AND V.DESGIN_KEY = ?
         AND V.MSC_PLINE = ?
         AND V.SPECL_FL = '2'
         AND V.VALIDFLAG = '1'
         ORDER BY V.CIC,C.CHEM_SEQ ASC
             ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.getPlnOrderZg" desc="查询轧管信息">
            <![CDATA[
            SELECT D.DESGIN_KEY, T.CRAFT_SEQ, T.CIC_GP, T.INDEX_SEQ,T.OUTWL_ID,T.INWL_ID,T.PLINE_CODE, T.CIC_GROUP_LK
                  FROM PLN_ORDER_ZG_S T, PLN_SALEORD T1, CRAFT_ORD_DESIGN D
                 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                   AND D.ORD_LN_PK = T1.ORD_LN_PK
                   AND D.CRAFT_SEQ = T.CRAFT_SEQ
                   AND T.PRO_PLAN_ID =?
                   AND T.GX_PLAN_NO = ?
             ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.getStlChemicalData" desc="查询判定表成分元素">
            <![CDATA[
           SELECT T2.C,
       T2.SI,
       T2.MN,
       T2.P,
       T2.S,
       T2.NI,
       T2.CR,
       T2.CU,
       T2.ASN,
       T2.TI,
       T2.V,
       T2.MO,
       T2.B,
       T2.W,
       T2.AL,
       T2.ZN,
       T2.PB,
       T2.SN,
       T2.CA,
       T2.LA,
       T2.SB,
       T2.CE,
       T2.SE,
       T2.MG,
       T2.NB,
       T2.CD,
       T2.BI,
       T2.N,
       T2.H,
       T2.O,
       T2.FE,
       T2.ALT,
       T2.ALS,
       T2.ALINS,
       T2.BS,
       T2.BN,
       T2.MGO,
       T2.SIO2,
       T2.AL2O3,
       T2.TFEO,
       T2.FE2O3,
       T2.H2O,
       T2.CAF2,
       T2.P2O5,
       T2.TFE,
       T2.CR2O3,
       T2.TIO2,
       T2.MNO,
       T2.V2O5,
       T2.FEO,
       T2.CAO,
       T2.ZR,
       T2.CO,
       T2.SAMPLE_NO,
       T2.ASSAYNO,
       T2.STOVE_NO
  FROM QCM_JHY_ELEMENTS T2,
       QCM_LG_CHEMJUDGE T1,
       (SELECT T.JUDGE_STOVE_NO, T.CHEM_JUDGE_ID
          FROM MAT_GP_M T
         WHERE T.CHEM_JUDGE_ID IS NOT NULL
         GROUP BY T.JUDGE_STOVE_NO, T.CHEM_JUDGE_ID) M
 WHERE M.CHEM_JUDGE_ID= T1.CHEM_JUDGE_ID
   AND M.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
   AND T1.ASSAYNO=T2.ASSAYNO
   AND T2.VALIDFLAG = '1'
   AND T1.JUDGE_STOVE_NO = ?
   AND T1.CHEM_JUDGE_ID= ?
 ORDER BY T2.CREATE_TIME DESC
             ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.queryMatGpTrack" desc="查询脱单利库记录">
            <![CDATA[
SELECT T.EVENT_ID,
       T.EVENT_DESC,
       T.FORM_NAME,
       T.CALL_FUNC_CODING,
       T.KEYVALUE_1,
       T.KEYVALUE_1_DESC,
       T.KEYVALUE_2,
       T.KEYVALUE_2_DESC2,
       T.KEYVALUE_3,
       T.KEYVALUE_3_DESC3,
       T.KEYVALUE_4,
       T.KEYVALUE_4_DESC4,
       T.KEYVALUE_5,
       T.KEYVALUE_5_DESC5,
       T.KEYVALUE_6,
       T.KEYVALUE_6_DESC6,
       T.KEYVALUE_7,
       T.KEYVALUE_7_DESC7,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.LOT_NO,
       T.JUDGE_STOVE_NO,
       T.GROUD_NO,
       T.BATCH_NO,
       T.CAST_NO,
       T.CCMID,
       T.GRADECODE,
       T.GRADENAME,
       T.STD_CODE,
       T.STD_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_FIX_NUM,
       T.ACT_FIX_LEN,
       SUM(NVL(T.ACT_COUNT, 0)) ACT_COUNT,
       SUM(NVL(T.ACT_WEIGHT, 0)) ACT_WEIGHT,
       SUM(NVL(T.ACT_THEORY_WEIGHT, 0)) ACT_THEORY_WEIGHT,
       T.PRO_ORDER_NO,
       T.PRO_ORDER_ID,
       T.PRO_ORDER_NO1,
       T.PRO_ORDER_ID1,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.ORDER_SEQ_NO,
       T.OLD_ORD_PK,
       T.OLD_ORD_LN_PK,
       T.OLD_ORD_LN_DLY_PK,
       T.OLD_ORDER_NO,
       T.OLD_ORDER_SEQ,
       T.OLD_ORDER_SEQ_NO,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       T.OLD_JUDGE_STOVE_NO,
       T.OLD_GROUD_NO,
       T.OLD_BATCH_NO,
       T.OLD_GRADECODE,
       T.OLD_GRADENAME,
       T.OLD_STD_CODE,
       T.OLD_STD_NAME,
       T.OLD_STOVE_NO
  FROM MAT_GP_TRACK T
 WHERE 1=1
             ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.queryPlanMZg" desc="查询轧管炉计划主">
            <![CDATA[
            SELECT * FROM PLN_ZY_ZG_M T WHERE 1=1
            ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.queryPlanCZg" 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.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.DIAMETER,
       T.LEN_GP_SINGLE,
       T.WT_GP_SINGLE,
       T.CUT_NUM_GP,
       T.LENGTH_M,
       T.WEIGHT_M,
       T.PLAN_INDOUBLE_NUM,
       T.PLAN_INDOUBLE_WT,
       T.REAL_INDOUBLE_NUM,
       T.REAL_INDOUBLE_WT,
       T.FLAG_STOVE_NO,
       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.CUT_TARGET,NVL(T.CUT_LENGTH,0) CUT_LENGTH,NVL(T.CUT_WEIGHT,0) CUT_WEIGHT,T.LENGTH_M_OLD,T.PLAN_WEIGTH,T.CUT_NUM_OLD
 FROM PLN_ZY_ZG_C T
 WHERE 1=1
            ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.queryPline" desc="查询产线环形炉最小">
            <![CDATA[
            SELECT NVL(T.LENGTH_MIN_RING,0) LENGTH_MIN_RING,NVL(T.LENGTH_MIN_RING,0) LENGTH_MAX_RINGM,T.PLINE_CODE,T.PLINE_NAME FROM COM_BASE_PLINE T WHERE T.PLINE_CODE=?
             ]]>
	</query>
	<query id="FrmRollTubeLibraryZg.updatePlnZgMOld" desc="修改该虚拟炉计划量">
            <![CDATA[
            UPDATE PLN_ZY_ZG_M T SET
 T.PLN_INSINGLE_NUM = TO_NUMBER(T.PLN_INSINGLE_NUM) - TO_NUMBER(?),
 T.PLN_INSINGLE_WT = TO_NUMBER(T.PLN_INSINGLE_WT) - TO_NUMBER(?),
 T.PLN_OUTSINGLE_NUM = TO_NUMBER(T.PLN_OUTSINGLE_NUM) - TO_NUMBER(?),
 T.PLN_OUTSINGLE_W = TO_NUMBER(T.PLN_OUTSINGLE_W) - TO_NUMBER(?)
 WHERE T.HEAT_PLAN_NO = ?
             ]]>
	</query>
	<query id = "FrmRollTubeLibraryZg.selectMatSetfoot" desc = "查询该材料号套尺材料">
		SELECT T.MAT_NO, T1.PLANSTATUS, T.SETFOOT_SEQ,T.MAT_STATUS
		FROM MAT_GP_M T
		LEFT JOIN PLN_ZY_ZG_M T1
		ON T.PRO_PLAN_ID_ZG = T1.PRO_PLAN_ID
		AND T.GX_PLAN_NO_ZG = T1.GX_PLAN_NO
		AND T.HEAT_PLAN_NO_NEXT = T1.HEAT_PLAN_NO
		WHERE T.MAT_NO_OLD = ?
		AND T.SETFOOT_SEQ > ?
		ORDER BY T.SETFOOT_SEQ ASC
	</query>
	<query id = "FrmRollTubeLibraryZg.deleteMatSetFoot" desc = "删除大于该套尺顺序号虚拟材料信息">
		DECLARE
		BEGIN
		DELETE FROM MAT_GP_M T WHERE T.MAT_NO = '#MAT_NO#';
		DELETE FROM YDM_GP_BUTTRESS T WHERE T.MAT_NO = '#MAT_NO#';
		END;
	</query>
</queryMap>