<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc=" 热处理排产信息">

	<query id="BaseHelper.initPline" desc="初始化产线">
             <![CDATA[
                   SELECT T.PLINE_CODE,T.PLINE_NAME FROM COM_BASE_PLINE T WHERE T.PROCESS_CODE=?  AND T.VALIDFLAG='1'
                 ]]>
	</query>
<query id="BaseHelper.initPlineB" desc="初始化铸造产线">
             <![CDATA[
  SELECT T.PLINE_CODE, T.PLINE_NAME
  FROM COM_BASE_PLINE T
 WHERE T.PROCESS_CODE ='B'
   AND T.VALIDFLAG = '1'
   AND T.PLINE_CODE NOT IN ('C063')
                 ]]>
	</query>
	<query id="BaseHelper.initPlineA" desc="初始化电炉产线">
             <![CDATA[
  SELECT T.PLINE_CODE, T.PLINE_NAME
  FROM COM_BASE_PLINE T
 WHERE T.PROCESS_CODE ='A'
   AND T.VALIDFLAG = '1'
   ORDER BY T.PLINE_CODE ASC
                 ]]>
	</query>
	<query id="BaseHelper.initGroup" desc="初始化计划分组">
             <![CDATA[
                    SELECT T.BASECODE,T.BASENAME FROM COM_BASE_INFO T WHERE T.SORTCODE=? ORDER BY T.BASECODE
                 ]]>
	</query>
	
		<query id="BaseHelper.queryZzPlin" desc="查询铸造产线">
             <![CDATA[
                   SELECT B.PLINE_CODE, B.PLINE_NAME
  FROM CRAFT_ORD_DESIGN_MSC_PL_GX_PRL B,
       COM_BASE_PLINE                 B2,
       PLN_ORDER_ZG_S                 S,
       PLN_SALEORD                    T,
       CRAFT_ORD_DESIGN               D
 WHERE B.PROCESS_CODE = 'B'
   AND B.VALIDFLAG = '1'
   AND B.PLINE_CODE = B2.PLINE_CODE
   AND T.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
   AND T.ORD_LN_PK = D.ORD_LN_PK
   AND S.CRAFT_SEQ = D.CRAFT_SEQ
   AND B2.VALIDFLAG = '1'
   AND B.DESGIN_KEY = D.DESGIN_KEY
   AND B.MSC_PLINE = S.INDEX_SEQ
   AND S.PRO_PLAN_ID = ?
   AND S.GX_PLAN_NO = ?
                 ]]>
	</query>
<query id="BaseHelper.queryZgSuM" desc="查询轧管生产，下线，判定支吨">
             <![CDATA[
  SELECT (SELECT SUM(NVL(Z.PREDICT_PIECE, 0))
          FROM MIL_PLAN Z
         WHERE Z.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND Z.GX_PLAN_NO = T.GX_PLAN_NO
           AND SUBSTR(Z.JUDGE_STOVE_NO, -3, 3) = '-01') FINISHNUM,
       (SELECT SUM(NVL(Z.PREDICT_TON, 0)) PREDICT_TON
          FROM MIL_PLAN Z
         WHERE Z.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND Z.GX_PLAN_NO = T.GX_PLAN_NO
           AND SUBSTR(Z.JUDGE_STOVE_NO, -3, 3) = '-01') FINISHWEIGHT,
       (SELECT SUM(NVL(M1.QUALIFIED_NUM, 0))
          FROM MIL_INSTORE_RESULT M1
         WHERE M1.NODE_FUR_FLAG = '1'
           AND M1.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND M1.GX_PLAN_NO = T.GX_PLAN_NO) QUALIFIED_NUM,
       (SELECT SUM(NVL(M1.QUALIFIED_TONS, 0))
          FROM MIL_INSTORE_RESULT M1
         WHERE M1.NODE_FUR_FLAG = '1'
           AND M1.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND M1.GX_PLAN_NO = T.GX_PLAN_NO) QUALIFIED_TONS,
       (SELECT SUM(NVL(Q.ACT_COUNT, 0))
          FROM QCM_ZG_JUGDE_APPLY Q
         WHERE Q.VALIDFLAG = '20'
           AND Q.PRO_ORDER_ID = T.PRO_PLAN_ID
           AND Q.GX_PLAN_NO = T.GX_PLAN_NO) ACT_COUNT,
       (SELECT SUM(CASE
                     WHEN NVL(Q.ACT_WEIGHT, 0) = '0' THEN
                      NVL(Q.ACT_THEORY_WEIGHT, 0)
                     ELSE
                      NVL(Q.ACT_WEIGHT, 0)
                   END)
          FROM QCM_ZG_JUGDE_APPLY Q
         WHERE Q.VALIDFLAG = '20'
           AND Q.PRO_ORDER_ID = T.PRO_PLAN_ID
           AND Q.GX_PLAN_NO = T.GX_PLAN_NO) ACT_WEIGHT,
       T.PRO_PLAN_ID || '/' || T.GX_PLAN_NO PRO_PLAN_ID,
       T.NUM_S,
       T.WEIGTH_S,
       T.PLINE_NAME,
       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
  FROM PLN_ORDER_ZG_S T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
 ORDER BY T.PLAN_TIME_B ASC
                ]]>
	</query>
		<query id="BaseHelper.queryPassCode" desc="查询720旋扩孔型">
             <![CDATA[
                 SELECT T.BASECODE,T.BASENAME FROM COM_BASE_INFO T WHERE T.SORTCODE='4096' AND T.VALIDFLAG='1'
                 ]]>
	</query>
	<query id = "addPlnFurn.selectState" desc = "查询交货状态">
		SELECT T.BASECODE, T.BASENAME
		FROM COM_BASE_INFO T
		WHERE T.BASECODE = (SELECT GET_SHIPPED_STATE(?,?,?) SORTCODE
		FROM DUAL)
		AND T.SORTCODE='4100'
	</query>
	<query id = "addPlnFurn.SelectDesignKey" desc = "查询desKey">
		SELECT T.DESGIN_KEY
		FROM CRAFT_ORD_DESIGN T
		WHERE T.CRAFT_NO = ?
		AND T.CRAFT_SEQ = ?
	</query>
</queryMap>