<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="分析断面钢种钢种索引码">
	<query id="FrmGradeAnalysis.getdoQueryGrade" desc="查询断面钢种钢种索引码">
		<![CDATA[	
SELECT T.GRADECODE,
       T.GRADENAME,
       T.DIAMETER_GP,
       T.CIC_GP,
       T.PLINE_CODE_ZZ,
       T.PLINE_NAME_ZZ,
       (SELECT COUNT(*)
          FROM (SELECT T1.LEN_GP_SINGLE,
                       T1.GRADECODE,
                       T1.DIAMETER_GP,
                       T1.CIC_GP
                  FROM PLN_ORDER_ZG_S T1
                 WHERE T1.EXE_STATUS = '0'
                       AND T1.OUTS_BILLET_FL = '0'
                       AND T1.GPREQ_ID IS NULL
                       AND T1.GPREQ_WEIGHT IS NOT NULL
                 GROUP BY T1.GRADECODE,
                          T1.DIAMETER_GP,
                          T1.CIC_GP,
                          T1.LEN_GP_SINGLE) T2
         WHERE T2.GRADECODE = T.GRADECODE
               AND T2.DIAMETER_GP = T.DIAMETER_GP
               AND T2.CIC_GP = T.CIC_GP) SINGLE_NUMBER,
       COUNT(*) ORDER_NUM,
       (SELECT LISTAGG(CRAFT_NO, ',') WITHIN GROUP(ORDER BY GRADECODE, CIC)
          FROM CRAFT_LG2_M
         WHERE GRADECODE = T.GRADECODE
               AND CIC = T.CIC_GP) CRAFT_NO
  FROM PLN_ORDER_ZG_S T
 WHERE T.EXE_STATUS = '0'
       AND T.GPREQ_ID IS NULL
       AND T.OUTS_BILLET_FL = '0'
       AND T.GPREQ_WEIGHT IS NOT NULL
 GROUP BY T.GRADECODE,
          T.GRADENAME,
          T.DIAMETER_GP,
          T.CIC_GP,
          T.PLINE_CODE_ZZ,
          T.PLINE_NAME_ZZ
		]]>
	</query>
	<query id="FrmGradeAnalysis.doPlnZgQuery" desc="查询工序订单排产计划">
		<![CDATA[
			SELECT 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,
			       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       T.REQ_BL_ID,
			       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,
			       T.LEN_CUTHEAD,
			       T.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,
			       NVL(T.MATCH_WT_IN,0) MATCH_WT_IN,
			       NVL(T.MATCH_NUM_IN,0) MATCH_NUM_IN,
			       T.PRDCR_NO,
			       T.MONITOR_POINT,
			       T.CRAFT_FILE_NO,
			       T.CRAFT_FILE_MAN,
			       T.CRAFT_SEQ,
			       T.STATION_ROAD,
			       T.PRO_MONTH,
			       T.CIC,
			       T.PIC,
			       T.SIC,
			       T.DIC,
			       T.WIC,
			       T.GIC,
			       T.GX_PRO_SEQ,
			       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.BATCHED_WT,
			       T.BATCHED_NUM,
			       T.FINISHWEIGHT,
			       T.FINISHNUM,
			       DECODE(T.EXE_STATUS, '0', '计划', '1', '生产中', '2', '完成') EXE_STATUS,
			       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.TUBE_END_RATIO,
			       T.GPREQ_NUM,
			       T.GPREQ_WEIGHT,
			       T.PLANS_NUM,
			       T.WEIGTH_S_MIN,
			       T.PRIORITY,
                   T.PRIORITY_MEMO,
			       DECODE(T.OUTS_BILLET_FL,'0','自炼','1','外购') OUTS_BILLET_FL,
                  T.WHOLE_BACKLOG_DESC,
       T2.GRADECODE_ALL,
       (SELECT C.ABRVITION FROM SLM_BASE_CUSTOMER C WHERE C.CUSTOMER_NO=T1.FINAL_USER )FINAL_USER_DESC,
        (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S,
               CRAFT_ORD_DESIGN            C,
               CRAFT_ORD_DESIGN_MSC_PL_PRC C1
         WHERE S.DESGIN_KEY = C1.DESGIN_KEY
           AND S.MSC_PLINE = C1.MSC_PLINE
           AND S.PROCESS_CODE = C1.PROCESS_CODE
           AND C.ORD_LN_PK = T1.ORD_LN_PK
           AND C.CRAFT_SEQ = T2.CRAFT_SEQ
           AND C1.DESGIN_KEY = C.DESGIN_KEY
           AND C1.MSC_PLINE = T2.INDEX_SEQ
           AND C1.PROCESS_CODE IN ('A','B','C')) STATION_ROAD_LG,
       DECODE((SELECT TO_CHAR(WM_CONCAT(PRL.STATION_CODE))
                FROM SLM_ORDER_LINE_PRDCR_LST PRL, SLM_ORDER_LINE_PRDCR PR
               WHERE PRL.PRDCR_NO = PR.PRDCR_NO
                 AND PRL.PRDCR_INDEX = PR.PRDCR_INDEX
                 AND PRL.PROCESS_CODE < 'D'
                 AND PR.PRDCR_NO = T.PRDCR_NO
                 AND PR.CODE_JG IS NULL
                 AND PR.CODE_BL IS NULL
                 AND PR.MSC_PLINE = T2.INDEX_SEQ),
              NULL,
              '否',
              '是') IF_MONITOR_LG,
              T1.PRODUCNAME,Q1.CRAFT_PATH,T.PLINE_CODE_ZZ,T.PLINE_NAME_ZZ,
                (SELECT GET_GP_MAT_NUM_ZL(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) FURNANUM,
       (SELECT GET_GP_MAT_WT_ZL(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) FURNAWEIGHT,
       (SELECT GET_GP_PLNZGM_NUM(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) LJNUM,
       (SELECT GET_GP_PLNZGM_WT(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) LJWEIGHT,
          (SELECT GET_GP_WT_CK(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) OUT_WT,
       (SELECT GET_GP_NUM_CK(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) OUT_NUM,
       (SELECT GET_ZG_REDUCED_WT(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) REDUCED_WT
  FROM PLN_ORDER_ZG_S T, PLN_SALEORD T1, PLN_SALEORD_PROC T2,CRAFT_ORD_DESIGN Q1
 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
   AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
   AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
   AND T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
   AND Q1.ORD_LN_PK=T1.ORD_LN_PK
   AND Q1.CRAFT_SEQ=T.CRAFT_SEQ
   AND T.OUTS_BILLET_FL='0'
   AND T.EXE_STATUS ='0'  AND T.GPREQ_ID IS NULL
   AND T.DIAMETER_GP=TO_NUMBER(?)
  

		]]>
	</query>
	<query id="FrmGradeAnalysis.doPlnZgQuerySingle" desc="查询钢种索引码成分元素">
		<![CDATA[
		SELECT T.CHEM_CODE,T.CHEM_NAME,T.STDMIN_SIGN,T.STDMIN,T.STDMAX_SIGN,T.STDMAX
  FROM CRAFT_ORD_DESIGN_STD_CIC T,
       (SELECT T1.ORD_LN_PK, D.DESGIN_KEY, T2.INDEX_SEQ
          FROM PLN_SALEORD T1, PLN_ORDER_ZG_S T2, CRAFT_ORD_DESIGN D
         WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
           AND T1.ORD_LN_PK = D.ORD_LN_PK
           AND T2.CRAFT_SEQ = D.CRAFT_SEQ
           AND T2.PRO_PLAN_ID = ?
           AND T2.GX_PLAN_NO = ?) B
 WHERE T.PROCESS_CODE = 'A'
   AND T.DESGIN_KEY = B.DESGIN_KEY
   AND T.MSC_PLINE = B.INDEX_SEQ
   AND T.CIC = ?
   AND T.VALIDFLAG = '1'
   AND T.SPECL_FL='2'
 ORDER BY T.INDEX_SEQ ASC
		]]>
	</query>
	<query id="FrmGradeAnalysis.doQueryGradecOll" desc="查询钢种索引码成分元素">
		<![CDATA[		
SELECT T.CIC,
       T.CHEM_NAME,
       T.STDMIN,
       T.STDMAX
  FROM CRAFT_ORD_DESIGN_STD_CIC T, COM_BASE_CHEM C
 WHERE T.PROCESS_CODE = 'A'
   AND T.CHEM_CODE = C.CHEM_CODE
   AND T.VALIDFLAG = '1'
   AND T.SPECL_FL = '2'
		]]>
	</query>
	<query id="FrmGradeAnalysis.queryLZDataZg" desc="查询炼轧记录">
		<![CDATA[
		SELECT [订单号]
      ,[序号]
      ,[LJ支]
      ,[LJ吨]
      ,[装炉支]
      ,[装炉吨]
      ,[出库支]
      ,[出库吨]
  FROM [TPCO_CXPLAN].[dbo].[V_ZG_DOWN_LOG-FORJYHRQ-Tab_ZLPlan-new] where [订单号]=? and [序号]=?
		]]>
	</query>
	<query id="FrmGradeAnalysis.doPlnZgQueryHj" desc="查询合计">
		<![CDATA[
	SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NVL(T.GPREQ_WEIGHT,0) GPREQ_WEIGHT,
       T2.GRADECODE_ALL,
       T.CIC_GROUP_GP,
       T.DIAMETER_GP,
       T.GRADECODE,
       T.GRADENAME,
        NVL(T.GPREQ_NUM,0) GPREQ_NUM,
       NVL(T.MATCH_WT_IN,0) MATCH_WT_IN,
		NVL(T.MATCH_NUM_IN,0) MATCH_NUM_IN,
       T.CIC_GP,NVL(T.GPREQ_NUM,0) GPREQ_NUM,T.GPREQ_WEIGHT,T.PLINE_CODE_ZZ,T.PLINE_NAME_ZZ,
       (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,
       BATCHED_WT CK_NUM,
       BATCHED_NUM CK_WEIGHT
  FROM PLN_ORDER_ZG_S T, PLN_SALEORD_PROC T2
 WHERE T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
   AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
   AND T.EXE_STATUS = '0'
   AND T.GPREQ_ID IS NULL	
		]]>
	</query>
	<query id="FrmGradeAnalysis.doPlnZgQueryDesKEY" desc="查询订单DESGIN_KEY">
		<![CDATA[
	SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NVL(T.GPREQ_WEIGHT, 0) GPREQ_WEIGHT,
       T2.GRADECODE_ALL,
       T.CIC_GROUP_GP,
       T.DIAMETER_GP,
       T.GRADECODE,
       T.GRADENAME,
       NVL(T.GPREQ_NUM, 0) GPREQ_NUM,
       T.CIC_GP,
       NVL(T.GPREQ_NUM, 0) GPREQ_NUM,
       T.GPREQ_WEIGHT,
       T.PLINE_CODE_ZZ,
       T.PLINE_NAME_ZZ,
       (SELECT B.DESGIN_KEY
          FROM CRAFT_ORD_DESIGN B
         WHERE B.ORD_LN_PK = T3.ORD_LN_PK
           AND B.CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
       T.INDEX_SEQ
  FROM PLN_ORDER_ZG_S T, PLN_SALEORD_PROC T2, PLN_SALEORD T3
 WHERE T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
   AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
   AND T3.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
   AND T.EXE_STATUS = '0'
   AND T.GPREQ_ID IS NULL
   AND T.DIAMETER_GP=TO_NUMBER(?)
		]]>
	</query>
		<query id="FrmGradeAnalysis.doUpadatePlin" desc="修改铸造产线">
		<![CDATA[
	UPDATE PLN_ORDER_ZG_S T
   SET T.PLINE_CODE_ZZ = ?, T.PLINE_NAME_ZZ = ?
 WHERE T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
		]]>
	</query>
	<query id="FrmGradeAnalysis.getBasePlineLg" desc="查询炼钢基础数据">
             <![CDATA[
 SELECT 
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PROCESS_CODE,
       T.PROCESS_DESC,
       T.EF_MAX_LIFE,
       T.STD_OUT_WT,
       T.EF_WT_LEFT,
       NVL(T.OUT_WT_MAX,0) OUT_WT_MAX,
       NVL(T.OUT_WT_MIN,0) OUT_WT_MIN,
       T.EF_AGE_NOW,
       T.EF_RESET_MAN,
       TO_CHAR(T.EF_RESET_TIME, 'YYYY-MM-DD HH24:MI:SS') EF_RESET_TIME,
       T.SCHEDULE_CODE,
       TO_CHAR(T.CREAT_TIME, 'YYYY-MM-DD HH24:MI:SS') CREAT_TIME
 FROM PLN_BASE_PLINE_LG T
 WHERE
T.PLINE_CODE = ?
                  ]]>
	</query>
	<query id="FrmGradeAnalysis.doPlnZgQueryFurnace" desc="连铸规格切头尾参数表">
             <![CDATA[
 SELECT 
       T.CUT_PARA_ID,
       T.DIAMETER_LZ,
       NVL(T.CUT_LEN_BEGIN,0)CUT_LEN_BEGIN,
       NVL(T.CUT_LEN_END_UNCH,0) CUT_LEN_END_UNCH,
       NVL(T.CUT_LEN_END_CH,0) CUT_LEN_END_CH,
       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
 FROM PLN_BASE_LZ_SPEC_CUT T
 WHERE 
T.Diameter_Lz=to_number(?)
                  ]]>
	</query>
	<query id="FrmGradeAnalysis.doPlnZgQueryMaxJc" desc="连铸规格切头尾参数表">
             <![CDATA[
             SELECT T.STOVE_CNT
  FROM SLM_BASE_MATERIAL_B_PL T
 WHERE T.PLINE_CODE = ?
   AND T.IN_MATERIAL_NO = ?
   AND T.OUT_MATERIAL_NO = ?
                ]]>
	</query>
</queryMap>