<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="计划轧管表">
	<query id="JdgPlnOrderZgS.queryByGpreqId" desc="查询计划轧管表">
		<![CDATA[
SELECT (T.PRO_PLAN_ID || T.GX_PLAN_NO) PRO_PLAN_ID
  FROM PLN_ORDER_ZG_S T
 WHERE T.GPREQ_ID = {0}
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryCraftCicByGpreqId" desc="查询工艺DesignKey">
		<![CDATA[
SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, CIC
  FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
               FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
               A.CIC_GP CIC
          FROM PLN_ORDER_ZG_S A, PLN_SALEORD B, CRAFT_ORD_DESIGN C
         WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
           AND B.ORD_LN_PK = C.ORD_LN_PK
           AND A.CRAFT_SEQ = C.CRAFT_SEQ
           AND A.GPREQ_ID IN {0})
 GROUP BY CIC
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryCraftCicByZgProPlanId" desc="查询坯子工艺成分信息">
		<![CDATA[
 SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, CIC
   FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
                FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
                D.cic
           FROM PLN_ORDER_ZG_S           A,
                PLN_SALEORD              B,
                CRAFT_ORD_DESIGN         C,
                CRAFT_ORD_DESIGN_STD_CIC D
          WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
            AND B.ORD_LN_PK = C.ORD_LN_PK
            AND A.CRAFT_SEQ = C.CRAFT_SEQ
            AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
            AND D.DESGIN_KEY = C.DESGIN_KEY
            AND D.PROCESS_CODE = 'A'
            AND ({1} = '0' OR D.CIC IN {2}))
  GROUP BY CIC
		]]>
	</query>
	
		<query id="JdgPlnOrderZgS.queryCraftCicByZgProPlanIdNoFirst" desc="查询坯子工艺成分信息">
		<![CDATA[
 SELECT  DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, CIC
   FROM (SELECT C.DESGIN_KEY DESGIN_KEY,
                A.INDEX_SEQ MSC_PLINE,
                D.cic
           FROM PLN_ORDER_ZG_S           A,
                PLN_SALEORD              B,
                CRAFT_ORD_DESIGN         C,
                CRAFT_ORD_DESIGN_STD_CIC D
          WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
            AND B.ORD_LN_PK = C.ORD_LN_PK
            AND A.CRAFT_SEQ = C.CRAFT_SEQ
            AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
            AND D.DESGIN_KEY = C.DESGIN_KEY
            AND D.PROCESS_CODE = 'A'
            AND ({1} = '0' OR D.CIC IN {2}))
  GROUP BY DESGIN_KEY,CIC
		]]>
	</query>
	
		<query id="JdgPlnOrderZgS.queryCraftCicByZgProPlanIdNew" desc="查询坯子工艺成分信息">
		<![CDATA[
 SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, CIC
   FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
                FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
                D.cic
           FROM PLN_ORDER_ZG_S           A,
                PLN_SALEORD              B,
                CRAFT_ORD_DESIGN         C,
                CRAFT_ORD_DESIGN_STD_CIC D
          WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
            AND B.ORD_LN_PK = C.ORD_LN_PK
            AND A.CRAFT_SEQ = C.CRAFT_SEQ
            AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
            AND D.DESGIN_KEY = C.DESGIN_KEY
            AND D.PROCESS_CODE = 'A')
  GROUP BY CIC
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryZgCraftCicByZgProPlanId" desc="查询轧管工艺成分信息">
		<![CDATA[
SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, CIC
  FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.CIC ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
               FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.CIC ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
               A.CIC CIC
          FROM PLN_ZY_ZG_M A, PLN_SALEORD B, CRAFT_ORD_DESIGN C
         WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
           AND B.ORD_LN_PK = C.ORD_LN_PK
           AND A.CRAFT_SEQ = C.CRAFT_SEQ
           AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
           AND A.JUDGE_STOVE_NO = {1})
 GROUP BY CIC
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryCraftPicByZgProPlanId" desc="查询工艺DesignKey">
		<![CDATA[
 SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, PIC
   FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.PIC_GP ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
                FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.PIC_GP ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
                A.PIC_GP PIC
           FROM PLN_ORDER_ZG_S A, PLN_SALEORD B, CRAFT_ORD_DESIGN C
          WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
            AND B.ORD_LN_PK = C.ORD_LN_PK
            AND A.CRAFT_SEQ = C.CRAFT_SEQ
            AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0})
  GROUP BY PIC
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryZgCraftPicByZgProPlanId" desc="查询工艺DesignKey">
		<![CDATA[
 SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, PIC
   FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.PIC ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
                FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.PIC ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
                A.PIC PIC
           FROM PLN_ZY_ZG_M A, PLN_SALEORD B, CRAFT_ORD_DESIGN C
          WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
            AND B.ORD_LN_PK = C.ORD_LN_PK
            AND A.CRAFT_SEQ = C.CRAFT_SEQ
            AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
            AND A.JUDGE_STOVE_NO = {1})
  GROUP BY PIC
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryCraftNoByZgProPlanId" desc="查询工艺DesignKey">
		<![CDATA[
SELECT C.CRAFT_NO, C.CRAFT_PATH ,C.DESGIN_KEY
  FROM PLN_ORDER_ZG_S A, PLN_SALEORD B, CRAFT_ORD_DESIGN C
 WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
   AND B.ORD_LN_PK = C.ORD_LN_PK
   AND A.CRAFT_SEQ = C.CRAFT_SEQ
   AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
 GROUP BY C.CRAFT_NO, C.CRAFT_PATH,C.DESGIN_KEY
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryOrderNoByZgProPlanId" desc="查询工艺DesignKey">
		<![CDATA[
SELECT A.ORDER_NO || '/' || A.ORDER_SEQ || '/' || A.DELIVERY_NO ORDER_NO
  FROM PLN_ORDER_ZG_S A
 WHERE A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
 GROUP BY (A.ORDER_NO || '/' || A.ORDER_SEQ || '/' || A.DELIVERY_NO)
		]]>
	</query>
	
	<query id="JdgPlnOrderZgS.queryByPk" desc="通过主键查询">
		<![CDATA[
SELECT * FROM PLN_ORDER_ZG_S T WHERE T.PRO_PLAN_ID = {0} AND T.GX_PLAN_NO = {1}
		]]>
	</query>

	<query id="JdgPlnOrderZgS.getProPlanIdByDlyPk" desc="通过主键查询">
		<![CDATA[
SELECT T.PRO_PLAN_ID, T.GX_PLAN_NO, T.GPREQ_ID
  FROM PLN_ORDER_ZG_S T
 WHERE T.ORD_LN_DLY_PK = {0}
		]]>
	</query>
</queryMap>