<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="炉计划利库">
	<query id="FrmRollTubeLibraryJgx.queryPlanStoveD" desc="查询加工线虚拟炉计划">
            <![CDATA[
       SELECT T.HEAT_PLAN_NO,
       T.GX_PRO_SEQ,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       DECODE(T.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭') PLANSTATUS,
      DECODE(T.PER_STATUS,
              '00',
              '上料开始',
              '10',
              '探伤开始',
              '20',
              '切管开始',
              '30',
              '车丝开始',
              '40',
              '螺纹检验开始',
              '50',
              '拧接开始',
              '60',
              '通径开始',
              '70',
              '水压开始',
              '80',
              '倒凌开始',
              '90',
              '测量点开始','11','交库开始','') PER_STATUS,
       DECODE(T.BESIDE_STATUS,
              '00',
              '上料结束',
              '10',
              '探伤结束',
              '20',
              '切管结束',
              '30',
              '车丝结束',
              '40',
              '螺纹检验结束',
              '50',
              '拧接结束',
              '60',
              '通径结束',
              '70',
              '水压结束',
              '80',
              '倒凌结束',
              '90',
              '测量点结束','11','交库结束','') BESIDE_STATUS,
       T.UPPER_HEATPLAN_ID,
       T.PRO_PLAN_ID,
       T.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,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       DECODE(T.ISENDGX,'1','是','/') ISENDGX,
       DECODE(T.IF_MATCH_ODD, '1', '利库计划','2','组炉计划','3','精整利库','4','精整返线计划','5','合并计划','正常计划') IF_MATCH_ODD,
       DECODE(T.IF_DO_HEAT_PLAN,'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,
       TO_CHAR(TO_DATE(T.PRO_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_DAY,
       TO_CHAR(TO_DATE(T.BAL_YEAR_MONTH, 'YYYY-MM'), 'YYYY-MM') BAL_YEAR_MONTH,
       DECODE(T.IF_MONITOR,'1','是','/') IF_MONITOR,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.BOM,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.STATION_ROAD,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.SEC_CRAFT_FILE_NO,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.OUTNUM_CUT,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMIN,
       T.LENGTHMAX,
       T.PLN_INSINGLE_NUM,
       T.PLN_INSINGLE_WT,
       T.PLN_INDOUBLE_NUM,
       T.PLN_INDOUBLE_WT,
       T.PLN_OUTSINGLE_NUM,
       T.PLN_OUTSINGLE_W,
       T.PLN_OUTDOUBLE_NUM,
       T.PLN_OUTDOUBLE_W,
       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,
       T.INDEX_SEQ,S.PLN_DIVIDE_ID,S.ZY_BATCH_ID,
       T.DECISION,
        CASE WHEN T.UPPER_PROCESS_CODE='D' THEN
       (SELECT MAX(DECODE(Z.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭')) FROM PLN_ZY_ZG_M Z WHERE Z.FEED_HEAT_NO=T.FEED_HEAT_NO) 
       WHEN T.UPPER_PROCESS_CODE='E' THEN 
          (SELECT MAX(DECODE(Z.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭')) FROM PLN_ZY_DBK_M Z WHERE Z.JUDGE_STOVE_NO=T.FEED_HEAT_NO) 
           WHEN T.UPPER_PROCESS_CODE='F' THEN 
          (SELECT MAX(DECODE(Z.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭')) FROM PLN_ZY_RCL_M Z WHERE Z.JUDGE_STOVE_NO=T.FEED_HEAT_NO) 
         ELSE
           ''
           END PLANSTATUS_GX,T.FLAG_STOVE_NO,T.FEED_HEAT_NO
  FROM PLN_ZY_JGX_M T, PLN_ORDER_JGX_S S
 WHERE T.PRO_PLAN_ID = S.PRO_PLAN_ID
   AND T.GX_PLAN_NO = S.GX_PLAN_NO
              ]]>
	</query>
	<query id="FrmRollTubeLibraryJgx.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.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.OUTNUM_CUT,
       T.LENGTH_IN,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.PLAN_INDOUBLE_NUM,
       T.PLAN_INDOUBLE_WT,
       T.REAL_INDOUBLE_NUM,
       T.REAL_INDOUBLE_WT,
       T.REAL_OUTDOUBLE_NUM,
       T.REAL_OUTDOUBLE_WT,T.FLAG_STOVE_NO,T.FEED_HEAT_NO
 FROM PLN_ZY_JGX_C T,PLN_ORDER_JGX_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="FrmRollTubeLibraryJgx.queryPlanOrderD1" desc="查询加工线排产(界面)">
		<![CDATA[
   SELECT CASE
         WHEN TO_NUMBER(NVL(JGX.WEIGTH_S, 0)) -
              TO_NUMBER(NVL(JGX.BATCHED_WT, 0)) < 0 THEN
          0
         ELSE
          TO_NUMBER(NVL(JGX.WEIGTH_S, 0)) - TO_NUMBER(NVL(JGX.BATCHED_WT, 0))
       END REALL_WT, (SELECT COUNT(Q1.MAT_NO)
                  FROM MAT_BC_M Q1
                 WHERE Q1.PRODUCT_FLAG = '801401'
                   AND (Q1.MAT_STATUS ='80150102' AND Q1.INSTOCK_FLAG='1'  AND Q1.JUDGE_RESULT_CODE IN ('40740701','40740709') OR Q1.MAT_STATUS ='80150101'AND Q1.INSTANCY_FLAG='1')
                   AND Q1.QCM_STAUS = '00'
                    --AND Q1.LOCK_FLAG='0' AND Q1.MNG_LOCK_FLAG='0'
                     AND INSTR((CASE
                    WHEN JGX.WHOLE_BACKLOG_DESC LIKE '%热处理%' THEN
                  'F,G'
                    WHEN JGX.WHOLE_BACKLOG_DESC LIKE '%镦拔扩%' THEN
                  'E,G'
                 WHEN JGX.WHOLE_BACKLOG_DESC LIKE '%轧制%' THEN
                  'D,G'
                 ELSE
                   'D,E,F,G'
               END), Q1.PROCESS_CDOE)>0
                   AND INSTR((CASE
                       WHEN JGX.PRODUC_TYPE != 'C' and JGX.PRODUC_TYPE != 'E' THEN
                        DECODE(JGX.G_IN_MATERIAL_NO,
                               '',
                               JGX.INWL_ID,
                               JGX.G_IN_MATERIAL_NO)
                       else
                        Q1.MATERIAL_NO
                     end), Q1.MATERIAL_NO) > 0) AS STOCK_NUM_LIKU,
       JGX.*
  FROM (SELECT
                  (SELECT LISTAGG(B4.I_IN_MATERIAL_NO, ',') WITHIN GROUP(ORDER BY B4.I_IN_MATERIAL_NO ASC)
                   FROM (SELECT B.I_IN_MATERIAL_DESC,B.I_IN_MATERIAL_NO,B3.ORD_LN_DLY_PK,B.MSC_PLINE,B2.CRAFT_SEQ
                  FROM SLM_ORD_DESIGN_BOM B,
                       CRAFT_ORD_LINE_BOM B1,
                       CRAFT_ORD_DESIGN   B2,
                       PLN_SALEORD        B3
                 WHERE B.BOM = B1.BOM
                   AND B1.DESGIN_KEY = B2.DESGIN_KEY
                   AND B2.ORD_LN_PK =B3.ORD_LN_PK
                  AND B2.VALIDFLAG!='0'
                   ) B4 WHERE B4.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK AND B4.MSC_PLINE=T.INDEX_SEQ AND B4.CRAFT_SEQ=T.CRAFT_SEQ) G_IN_MATERIAL_NO,
       T.IF_EXPORT,
       T.PROCESS_DESC_C_ZG,
       T.GROUP_ROLL_NAME,
       TO_CHAR(T.BEGIN_TIME_ZG, 'YYYY-MM-DD HH24:MI:SS') BEGIN_TIME_ZG,
       T.PRDCR_ADVC_DAY,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       (SELECT T9.BASENAME
          FROM COM_BASE_INFO T9
         WHERE T9.BASECODE = T.PRIORITY) PRIORITY,
       T.PRIORITY_MEMO,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T.STATION_NM,
       T.OUTLINE_SITE_250,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/') PRO_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/') ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.SIGL_LEN,
       T.ENDLEN_SPECSTD,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       DECODE(T.IF_MONITOR_JGX, '1', '是', '/') IF_MONITOR_JGX,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.STATION_ROAD,
       T.GX_PRO_SEQ,
       (SELECT listagg (D.CRAFT_NO, ',') WITHIN GROUP (ORDER BY D.CRAFT_NO)  FROM Craft_ORD_DESIGN_MSC    A,
       Craft_ORD_DESIGN_MSC_BL B,
       CRAFT_ORD_DESIGN        D
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.Ord_Ln_Pk = SUBSTR(T.ORD_LN_DLY_PK,0,length(t.ord_ln_dly_pk)-3)
   and a.validflag='1'
   AND D.DESGIN_KEY = B.DESGIN_KEY_BL)BL_CRAFT_NO,
       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,
     (SELECT SUM(NVL(M.PLN_INSINGLE_WT,0)) FROM PLN_ZY_JGX_M M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') BATCHED_WT,
      (SELECT SUM(NVL(M.PLN_INSINGLE_NUM,0)) FROM PLN_ZY_JGX_M M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') BATCHED_NUM,
      (SELECT SUM(NVL(M.PLAN_INDOUBLE_WT,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Batch_Wt,
      (SELECT SUM(NVL(M.PLAN_INDOUBLE_NUM,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Batch_Num,
      (SELECT SUM(NVL(M.REAL_INDOUBLE_WT,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Indouble_Wt,
      (SELECT SUM(NVL(M.REAL_INDOUBLE_NUM,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Indouble_Num,
      (SELECT SUM(NVL(M.REAL_OUTDOUBLE_WT,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') FINISHWEIGHT,
      (SELECT SUM(NVL(M.REAL_OUTDOUBLE_NUM,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') 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,
       T.ZY_BATCH_ID,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T1.GROUP_JGX,
       T.FINAL_USER_DESC,
       T2.SALE_ORG_DESC,
       S.PRODUCCODE,
       S.PRODUCNAME,
       S.STD_CODE,
       S.STD_NAME,
       S.STD_STYLE_DESC,
       T2.ORDER_SPEC_CODE,
       T2.ORDER_SPEC_DESC,
       S.SPEC_CODE,
       S.SPEC_NAME,
       (SELECT CD.CRAFT_PATH
          FROM CRAFT_ORD_DESIGN CD
         WHERE CD.ORD_LN_PK = T2.ORD_LN_PK
           AND CD.CRAFT_SEQ = T.CRAFT_SEQ) CRAFT_PATH,
       T.CRAFT_SEQ,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       (SELECT LV.CRAFT_PATH
          FROM CRAFT_FILE_LV2 LV
         WHERE INSTR(T2.CRAFT_FILE_LV2_G, LV.PK) > 0
           AND INSTR(LV.PLINE_CODE, T.PLINE_CODE) > 0
           AND LV.VALIDFLAG = '1'
           AND LV.PROCESS_CODE = 'G') CRAFT_FILE_LV2_G,
       T3.ADD_ASK1,
       T3.ADD_ASK2,
       T3.ADD_ASK3,
       T3.ADD_ASK4,
       T3.ADD_ASK5,
       T3.ADD_ASK6,
       T3.ADD_ASK7,
       T3.ADD_ASK8,
       T3.ADD_ASK9,
       T3.ADD_ASK10,
       T3.ADD_ASK11,
       T3.ADD_ASK12,
       T3.ADD_ASK13,
       (SELECT SUM(NVL(ZG.PLANS_NUM, 0))
          FROM PLN_ORDER_ZG_S ZG
         WHERE ZG.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND ZG.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID) OUTPUT_NUM,
       (SELECT TO_CHAR(MIN(Z.PLAN_TIME_B), 'YYYY-MM-DD HH24:MI:SS')
          FROM PLN_ORDER_ZG_S Z
         WHERE Z.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND Z.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID) ZG_START_TIME,
       NVL((SELECT SUM(M.PREDICT_TON)
             FROM MIL_PLAN M, PLN_ORDER_ZG_S Z
            WHERE M.PRO_PLAN_ID = Z.PRO_PLAN_ID
              AND M.GX_PLAN_NO = Z.GX_PLAN_NO
              AND Z.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
              AND Z.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
              AND SUBSTR(M.JUDGE_STOVE_NO, -2) = '01'),
           0) EXPECT_WT,
       NVL((SELECT SUM(M.PREDICT_PIECE)
             FROM MIL_PLAN M, PLN_ORDER_ZG_S Z
            WHERE M.PRO_PLAN_ID = Z.PRO_PLAN_ID
              AND M.GX_PLAN_NO = Z.GX_PLAN_NO
              AND Z.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
              AND Z.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
              AND SUBSTR(M.JUDGE_STOVE_NO, -2) = '01'),
           0) EXPECT_NUM,
       (SELECT Z1.GRADENAME
          FROM (SELECT Z.GRADENAME, Z.ORD_LN_DLY_PK, Z.PLN_DIVIDE_ID
                  FROM PLN_ORDER_ZG_S Z
                 ORDER BY TO_NUMBER(Z.GX_PRO_SEQ)) Z1
         WHERE ROWNUM = 1
           AND Z1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND Z1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID) GRADENAME,
       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.ISSUED_MAN,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN, T.DECISION,(SELECT P.PRODUC_TYPE
                  FROM COM_BASE_PRODUCT P
                 WHERE P.PRODUCCODE = S.PRODUCCODE) PRODUC_TYPE
  FROM PLN_ORDER_JGX_S T,
       PLN_GX_JGX_M T1,
       (SELECT Q1.ORDER_SPEC_CODE,
               Q1.ORDER_SPEC_DESC,
               Q2.ORD_LN_DLY_PK,
               Q2.ORD_LN_PK,
               Q1.DELVRY_RANGE_TPE,
               Q1.DELVRY_RANGE_MAX,
               Q1.DELVRY_RANGE_MIN,
               Q2.DELVRY_QTY,
               Q4.CRAFT_NAME,
               Q5.SALE_ORG_DESC,
               Q1.FINAL_USER_DESC,
               Q3.CRAFT_FILE_LV2_G
          FROM SLM_ORDER_LINE           Q1,
               SLM_ORDER_LINE_DELIVERY  Q2,
               CRAFT_ORD_DESIGN         Q3,
               CRAFT_ORD_DESIGN_APPOINT Q4,
               SLM_ORDER_HEAD           Q5
         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
           AND Q1.ORD_LN_PK = Q4.ORD_LN_PK(+)
           AND Q1.ORD_PK = Q5.ORD_PK
           AND Q1.ORD_LN_PK = Q3.ORD_LN_PK(+)
           AND Q3.VALIDFLAG(+) = '1') T2,
       (SELECT *
          FROM (SELECT Q.ASK_ITME_DESC,
                       Q.ASK_SUB_ITME_VAL_DESC,
                       Q.ORD_LN_DLY_PK
                  FROM (SELECT Q3.ASK_ITME_DESC,
                               Q1.ORD_LN_DLY_PK,
                               LISTAGG(Q3.ASK_SUB_ITME_VAL_DESC, ' ** ') WITHIN GROUP(ORDER BY Q3.ASK_ITME) ASK_SUB_ITME_VAL_DESC
                          FROM SLM_ORDER_LINE_DELIVERY Q1,
                               SLM_ORDER_LINE          Q2,
                               SLM_ORDER_ADD_ASK       Q3
                         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
                           AND Q2.ADD_ASK_NO = Q3.ADD_ASK_NO
                           AND Q1.VALIDFLAG = '1'
                           AND Q2.VALIDFLAG = '1'
                           AND Q2.CREATE_NAME IS NOT NULL
                           AND Q3.VALIDFLAG = '1'
                         GROUP BY Q3.ASK_ITME_DESC, Q1.ORD_LN_DLY_PK) Q)
                         PIVOT(MAX(ASK_SUB_ITME_VAL_DESC)
                         FOR ASK_ITME_DESC  IN('喷标' AS ADD_ASK1,
                               '涂漆' AS ADD_ASK2,
                               '保护帽' AS ADD_ASK3,
                               '丝扣油' AS ADD_ASK4,
                               '计重方式' AS ADD_ASK5,
                               '包装要求' AS ADD_ASK6,
                               '质量' AS ADD_ASK7,
                               '交货材料' AS ADD_ASK8,
                               '发货结算约定' AS ADD_ASK9,
                               '特殊通径' AS ADD_ASK10,
                               '特殊端部加工' AS ADD_ASK11,
                               '取样备注' AS ADD_ASK12,
                               '表面质量' AS ADD_ASK13))) T3,
  PLN_SALEORD S
 WHERE T.PRO_PLAN_ID = T1.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK(+)
   AND T.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK(+)
   AND T.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK

               ]]>
	</query>
	<query id="FrmRollTubeLibraryJgx.queryPlanOrderD" desc="查询加工线排产(界面)">
             <![CDATA[  
   SELECT CASE
         WHEN TO_NUMBER(NVL(JGX.WEIGTH_S, 0)) -
              TO_NUMBER(NVL(JGX.BATCHED_WT, 0)) < 0 THEN
          0
         ELSE
          TO_NUMBER(NVL(JGX.WEIGTH_S, 0)) - TO_NUMBER(NVL(JGX.BATCHED_WT, 0))
       END REALL_WT, (SELECT COUNT(Q1.MAT_NO)
                  FROM MAT_BC_M Q1
                 WHERE Q1.PRODUCT_FLAG = '801401'
                   AND (Q1.MAT_STATUS ='80150102' AND Q1.INSTOCK_FLAG='1'  AND Q1.JUDGE_RESULT_CODE IN ('40740701','40740709') OR Q1.MAT_STATUS ='80150101'AND Q1.INSTANCY_FLAG='1')
                   AND Q1.QCM_STAUS = '00'  
                    --AND Q1.LOCK_FLAG='0' AND Q1.MNG_LOCK_FLAG='0'
                     AND INSTR((CASE   
                    WHEN JGX.WHOLE_BACKLOG_DESC LIKE '%热处理%' THEN
                  'F,G'
                    WHEN JGX.WHOLE_BACKLOG_DESC LIKE '%镦拔扩%' THEN
                  'E,G'
                 WHEN JGX.WHOLE_BACKLOG_DESC LIKE '%轧制%' THEN
                  'D,G'
                 ELSE
                   'D,E,F,G'
               END), Q1.PROCESS_CDOE)>0 
                   AND INSTR((CASE
                       WHEN JGX.PRODUC_TYPE != 'C' and JGX.PRODUC_TYPE != 'E' THEN
                        DECODE(JGX.G_IN_MATERIAL_NO,
                               '',
                               JGX.INWL_ID,
                               JGX.G_IN_MATERIAL_NO)
                       else
                        Q1.MATERIAL_NO
                     end), Q1.MATERIAL_NO) > 0) AS STOCK_NUM_LIKU,
       JGX.*
  FROM (SELECT 
                  (SELECT LISTAGG(B4.I_IN_MATERIAL_NO, ',') WITHIN GROUP(ORDER BY B4.I_IN_MATERIAL_NO ASC) 
                   FROM (SELECT B.I_IN_MATERIAL_DESC,B.I_IN_MATERIAL_NO,B3.ORD_LN_DLY_PK,B.MSC_PLINE,B2.CRAFT_SEQ
                  FROM SLM_ORD_DESIGN_BOM B,
                       CRAFT_ORD_LINE_BOM B1,
                       CRAFT_ORD_DESIGN   B2,
                       PLN_SALEORD        B3
                 WHERE B.BOM = B1.BOM
                   AND B1.DESGIN_KEY = B2.DESGIN_KEY
                   AND B2.ORD_LN_PK =B3.ORD_LN_PK
                  AND B2.VALIDFLAG!='0'
                   ) B4 WHERE B4.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK AND B4.MSC_PLINE=T.INDEX_SEQ AND B4.CRAFT_SEQ=T.CRAFT_SEQ) G_IN_MATERIAL_NO,
       T.IF_EXPORT,
       T.PROCESS_DESC_C_ZG,
       T.GROUP_ROLL_NAME,
       TO_CHAR(T.BEGIN_TIME_ZG, 'YYYY-MM-DD HH24:MI:SS') BEGIN_TIME_ZG,
       T.PRDCR_ADVC_DAY,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       (SELECT T9.BASENAME
          FROM COM_BASE_INFO T9
         WHERE T9.BASECODE = T.PRIORITY) PRIORITY,
       T.PRIORITY_MEMO,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T.STATION_NM,
       T.OUTLINE_SITE_250,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/') PRO_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/') ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.SIGL_LEN,
       T.ENDLEN_SPECSTD,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       DECODE(T.IF_MONITOR_JGX, '1', '是', '/') IF_MONITOR_JGX,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.STATION_ROAD,
       T.GX_PRO_SEQ,
       (SELECT listagg (D.CRAFT_NO, ',') WITHIN GROUP (ORDER BY D.CRAFT_NO)  FROM Craft_ORD_DESIGN_MSC    A,
       Craft_ORD_DESIGN_MSC_BL B,
       CRAFT_ORD_DESIGN        D
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.Ord_Ln_Pk = SUBSTR(T.ORD_LN_DLY_PK,0,length(t.ord_ln_dly_pk)-3)
   --and a.validflag='1'
   AND D.DESGIN_KEY = B.DESGIN_KEY_BL)BL_CRAFT_NO,
       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,
     (SELECT SUM(NVL(M.PLN_INSINGLE_WT,0)) FROM PLN_ZY_JGX_M M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') BATCHED_WT,
      (SELECT SUM(NVL(M.PLN_INSINGLE_NUM,0)) FROM PLN_ZY_JGX_M M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') BATCHED_NUM,
      (SELECT SUM(NVL(M.PLAN_INDOUBLE_WT,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Batch_Wt,
      (SELECT SUM(NVL(M.PLAN_INDOUBLE_NUM,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Batch_Num,
      (SELECT SUM(NVL(M.REAL_INDOUBLE_WT,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Indouble_Wt,
      (SELECT SUM(NVL(M.REAL_INDOUBLE_NUM,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') Real_Indouble_Num,
      (SELECT SUM(NVL(M.REAL_OUTDOUBLE_WT,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') FINISHWEIGHT,
      (SELECT SUM(NVL(M.REAL_OUTDOUBLE_NUM,0)) FROM PLN_ZY_JGX_C M WHERE M.PRO_PLAN_ID=T.PRO_PLAN_ID AND M.GX_PLAN_NO=T.GX_PLAN_NO AND M.IF_FLAG='0') 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,
       T.ZY_BATCH_ID,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T1.GROUP_JGX,
       T.FINAL_USER_DESC,
       T2.SALE_ORG_DESC,
       S.PRODUCCODE,
       S.PRODUCNAME,
       S.STD_CODE,
       S.STD_NAME,
       S.STD_STYLE_DESC,
       T2.ORDER_SPEC_CODE,
       T2.ORDER_SPEC_DESC,
       S.SPEC_CODE,
       S.SPEC_NAME,
       (SELECT CD.CRAFT_PATH
          FROM CRAFT_ORD_DESIGN CD
         WHERE CD.ORD_LN_PK = T2.ORD_LN_PK
           AND CD.CRAFT_SEQ = T.CRAFT_SEQ) CRAFT_PATH,
       T.CRAFT_SEQ,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       (SELECT LV.CRAFT_PATH
          FROM CRAFT_FILE_LV2 LV
         WHERE INSTR(T2.CRAFT_FILE_LV2_G, LV.PK) > 0
           AND INSTR(LV.PLINE_CODE, T.PLINE_CODE) > 0
           AND LV.VALIDFLAG = '1'
           AND LV.PROCESS_CODE = 'G') CRAFT_FILE_LV2_G,
       T3.ADD_ASK1,
       T3.ADD_ASK2,
       T3.ADD_ASK3,
       T3.ADD_ASK4,
       T3.ADD_ASK5,
       T3.ADD_ASK6,
       T3.ADD_ASK7,
       T3.ADD_ASK8,
       T3.ADD_ASK9,
       T3.ADD_ASK10,
       T3.ADD_ASK11,
       T3.ADD_ASK12,
       T3.ADD_ASK13,
       (SELECT SUM(NVL(ZG.PLANS_NUM, 0))
          FROM PLN_ORDER_ZG_S ZG
         WHERE ZG.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND ZG.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID) OUTPUT_NUM,
       (SELECT TO_CHAR(MIN(Z.PLAN_TIME_B), 'YYYY-MM-DD HH24:MI:SS')
          FROM PLN_ORDER_ZG_S Z
         WHERE Z.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND Z.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID) ZG_START_TIME,
       NVL((SELECT SUM(M.PREDICT_TON)
             FROM MIL_PLAN M, PLN_ORDER_ZG_S Z
            WHERE M.PRO_PLAN_ID = Z.PRO_PLAN_ID
              AND M.GX_PLAN_NO = Z.GX_PLAN_NO
              AND Z.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
              AND Z.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
              AND SUBSTR(M.JUDGE_STOVE_NO, -2) = '01'),
           0) EXPECT_WT,
       NVL((SELECT SUM(M.PREDICT_PIECE)
             FROM MIL_PLAN M, PLN_ORDER_ZG_S Z
            WHERE M.PRO_PLAN_ID = Z.PRO_PLAN_ID
              AND M.GX_PLAN_NO = Z.GX_PLAN_NO
              AND Z.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
              AND Z.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
              AND SUBSTR(M.JUDGE_STOVE_NO, -2) = '01'),
           0) EXPECT_NUM,
       (SELECT Z1.GRADENAME
          FROM (SELECT Z.GRADENAME, Z.ORD_LN_DLY_PK, Z.PLN_DIVIDE_ID
                  FROM PLN_ORDER_ZG_S Z
                 ORDER BY TO_NUMBER(Z.GX_PRO_SEQ)) Z1
         WHERE ROWNUM = 1
           AND Z1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND Z1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID) GRADENAME,
       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.ISSUED_MAN,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN, T.DECISION,(SELECT P.PRODUC_TYPE
                  FROM COM_BASE_PRODUCT P
                 WHERE P.PRODUCCODE = S.PRODUCCODE) PRODUC_TYPE
  FROM PLN_ORDER_JGX_S T,
       PLN_GX_JGX_M T1,
       (SELECT Q1.ORDER_SPEC_CODE,
               Q1.ORDER_SPEC_DESC,     
               Q2.ORD_LN_DLY_PK,
               Q2.ORD_LN_PK,     
               Q1.DELVRY_RANGE_TPE,
               Q1.DELVRY_RANGE_MAX,
               Q1.DELVRY_RANGE_MIN,
               Q2.DELVRY_QTY,
               Q4.CRAFT_NAME,
               Q5.SALE_ORG_DESC,
               Q1.FINAL_USER_DESC,
               Q3.CRAFT_FILE_LV2_G
          FROM SLM_ORDER_LINE           Q1,
               SLM_ORDER_LINE_DELIVERY  Q2,
               CRAFT_ORD_DESIGN         Q3,
               CRAFT_ORD_DESIGN_APPOINT Q4,
               SLM_ORDER_HEAD           Q5
         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
           AND Q1.ORD_LN_PK = Q4.ORD_LN_PK(+)
           AND Q1.ORD_PK = Q5.ORD_PK
           AND Q1.ORD_LN_PK = Q3.ORD_LN_PK(+)
           AND Q3.VALIDFLAG(+) = '1') T2,
       (SELECT *
          FROM (SELECT Q.ASK_ITME_DESC,
                       Q.ASK_SUB_ITME_VAL_DESC,
                       Q.ORD_LN_DLY_PK
                  FROM (SELECT Q3.ASK_ITME_DESC,
                               Q1.ORD_LN_DLY_PK,
                               LISTAGG(Q3.ASK_SUB_ITME_VAL_DESC, ' ** ') WITHIN GROUP(ORDER BY Q3.ASK_ITME) ASK_SUB_ITME_VAL_DESC
                          FROM SLM_ORDER_LINE_DELIVERY Q1,
                               SLM_ORDER_LINE          Q2,
                               SLM_ORDER_ADD_ASK       Q3
                         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
                           AND Q2.ADD_ASK_NO = Q3.ADD_ASK_NO
                           AND Q1.VALIDFLAG = '1'
                           AND Q2.VALIDFLAG = '1'
                           AND Q2.CREATE_NAME IS NOT NULL
                           AND Q3.VALIDFLAG = '1'
                         GROUP BY Q3.ASK_ITME_DESC, Q1.ORD_LN_DLY_PK) Q) 
                         PIVOT(MAX(ASK_SUB_ITME_VAL_DESC) 
                         FOR ASK_ITME_DESC  IN('喷标' AS ADD_ASK1,
                               '涂漆' AS ADD_ASK2,
                               '保护帽' AS ADD_ASK3,
                               '丝扣油' AS ADD_ASK4,
                               '计重方式' AS ADD_ASK5,
                               '包装要求' AS ADD_ASK6,
                               '质量' AS ADD_ASK7,
                               '交货材料' AS ADD_ASK8,
                               '发货结算约定' AS ADD_ASK9,
                               '特殊通径' AS ADD_ASK10,
                               '特殊端部加工' AS ADD_ASK11,
                               '取样备注' AS ADD_ASK12,
                               '表面质量' AS ADD_ASK13))) T3,
  PLN_SALEORD S
 WHERE T.PRO_PLAN_ID = T1.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK(+)
   AND T.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK(+)
   AND T.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
               ]]>
	</query>
	<query id="FrmRollTubeLibraryJgx.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="FrmRollTubeLibraryJgx.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="FrmRollTubeLibraryJgx.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.VALIDFLAG = '1'
   AND T1.JUDGE_STOVE_NO = ?
   AND T1.CHEM_JUDGE_ID= ?
 ORDER BY T2.CREATE_TIME DESC
             ]]>
	</query>
	<query id="FrmRollTubeLibraryJgx.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,
       (SELECT I.BASENAME
          FROM COM_BASE_INFO I
         WHERE I.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT I.BASENAME
          FROM COM_BASE_INFO I
         WHERE I.BASECODE = T.MAT_STATUS) MAT_STATUS,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.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.PROCESS_CDOE,
       T.GRADECODE,
       T.GRADENAME
 FROM MAT_BC_TRACK T
 WHERE T.EVENT_ID like '%'||? ||'%' AND T.JUDGE_STOVE_NO like '%'||? ||'%' 
 AND T.PROCESS_CDOE='G'
 ORDER BY T.CREATE_NAME DESC
             ]]>
	</query>

	<query id="FrmRollTubeLibraryJgx.getPlnMatBcDbk" desc="查询加工线信息">
            <![CDATA[
SELECT *
  FROM (SELECT T.*
          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.QCM_STAUS = '00'
           AND T.HANGING_FLAG = '1'
           AND T.HEAT_PLAN_NO_NEXT=?
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM <= ?
             ]]>
	</query>
</queryMap>