<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="炼钢调度">

	<query id="FrmSteelManagement.SelectPlnSteelforcastEntity" desc="查询浇次信息表">
             <![CDATA[
                  SELECT * FROM PLN_STEELFORCAST
	WHERE 1=1 {0}
	ORDER BY   PLINE_CODE,CAST_SEQ
	]]>
</query>

	<query id="FrmSteelManagement.SelectPlnSteelforcastEntity1" desc="查询浇次信息表">
		<![CDATA[
                  SELECT A.*
  FROM PLN_STEELFORCAST A,(
SELECT CAST_NO, MIN(FURNACENO_SEQ) FURNACENO_SEQ
  FROM PLN_STEELFORFURNACE B
 WHERE 1=1 {0}
       GROUP BY CAST_NO)  C WHERE A.CAST_NO = C.CAST_NO
       ORDER BY C.FURNACENO_SEQ

	]]>
	</query>

	<query id="FrmSteelManagement.SelectMaxCastSeq" desc="找最大浇次号">
		<![CDATA[
               	SELECT NVL(MAX(CAST_SEQ),0) +1 CAST_SEQ
	FROM PLN_STEELFORCAST
	WHERE STATUS <> '00'
	AND PLINE_CODE = ?
	]]>
	</query>


	<query id="FrmSteelManagement.SelectMaxFurnace" desc="">
		<![CDATA[
               	SELECT NVL(MAX(FURNACENO_SEQ),0) +1  FURNACENO_SEQ,
               	MAX(PLN_ENDTIME) PLN_ENDTIME
	FROM PLN_STEELFORFURNACE
	WHERE STATUS <> '00'
	AND EF_PLINE_CODE = ?
	]]>
	</query>


	<query id="FrmSteelManagement.SelectMaxCCMSeq1" desc="">
		<![CDATA[
               	SELECT NVL(MAX(CCM_SEQ),0) +1 CCM_SEQ
	FROM PLN_STEELFOR_ORD
	WHERE STATUS <> '00'
	AND PLINE_CODE = ?
	]]>
	</query>


	<query id="FrmSteelManagement.SelectLastEndTime" desc="找浇次最后一炉生产结束时间,线别">
		<![CDATA[
          SELECT MAX(PLN_ENDTIME) PLN_ENDTIME,
       MAX(A.EF_PLINE_CODE) EF_PLINE_CODE,
       MAX(A.EF_PLINE_NAME) EF_PLINE_NAME,
       NVL(MAX(A.FURNACENO_SEQ),0) +1 FURNACENO_SEQ
  FROM PLN_STEELFORFURNACE A,
       (SELECT CAST_NO,
               CASE PLINE_CODE
                 WHEN 'C002' THEN
                  'C001'
                 WHEN 'C004' THEN
                  'C003'
                 WHEN 'C007' THEN
                  'C006'
               END EF_PLINE_CODE
          FROM PLN_STEELFORCAST
         WHERE PLINE_CODE = ?
               AND CAST_SEQ <= ?) B
 WHERE A.CAST_NO = B.CAST_NO
       AND A.EF_PLINE_CODE = B.EF_PLINE_CODE
	]]>
	</query>





	<query id="FrmSteelManagement.UpdatePlnSteelforcastEntityStatus" desc="更改浇次表状态">
		<![CDATA[
                  UPDATE PLN_STEELFORCAST
     SET STATUS = ? ,
      MANFORTOL2 = ? , TIMEFORTOL2 = SYSDATE
   WHERE CAST_NO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdatePlnSteelforcastEntityByFurnace" desc="浇次表根据该浇次下的炉计划是否全部是编制状态来取消下发">
		<![CDATA[
                 UPDATE PLN_STEELFORCAST A
   SET A.STATUS = '00', MANFORTOL2 = ?, TIMEFORTOL2 = SYSDATE
 WHERE (SELECT COUNT(1)
          FROM PLN_STEELFORFURNACE T
         WHERE T.STATUS <> '00'
               AND T.CAST_NO = A.CAST_NO) = 0
       AND A.CAST_NO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.ClosePlnSteelforcastEntity" desc="关闭浇次表状态">
    <![CDATA[
                  UPDATE PLN_STEELFORCAST
     SET STATUS = '40' ,
      CLOSEMAN = ? , CLOSETIME = SYSDATE
   WHERE CAST_NO = ?
	]]>
</query>




	<query id="FrmSteelManagement.UpdateCastCastSeq" desc="更改浇次表浇次顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFORCAST
     SET CAST_SEQ = ?,
     STARTTIME=TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     ENDTIME= TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss')
   WHERE CAST_NO =?
	]]>
	</query>

    <query id="FrmSteelManagement.SelectMaxSeq" desc="根据铸造产线找最大的序号">
    <![CDATA[

SELECT NVL(MAX(CAST_SEQ), 0) + 1 CAST_SEQ
  FROM PLN_STEELFORCAST
 WHERE PLINE_CODE =?

	]]>
</query>

    <query id="FrmSteelManagement.SelectMaxCCMSeq" desc="根据铸造产线找最大的连铸序号">
    <![CDATA[

SELECT NVL(MAX(CCM_SEQ), 0) + 1 CCM_SEQ
  FROM PLN_STEELFOR_ORD
 WHERE PLINE_CODE =?

	]]>
</query>


    <query id="FrmSteelManagement.SelectMinCCMSeq" desc="根据铸造产线和浇次号找最小的连铸序号">
	<![CDATA[

SELECT NVL(MIN(CCM_SEQ), 1) CCM_SEQ
  FROM PLN_STEELFOR_ORD
 WHERE CAST_NO=?
    AND PLINE_CODE =?

	]]>
</query>

	<query id="FrmSteelManagement.UpdateCastQty" desc="更新浇次计划支数重量">
		<![CDATA[
UPDATE PLN_STEELFORCAST A
   SET (FURNACENUMBER, TOT_NUM, TOT_WT, STARTTIME, ENDTIME) =
       (SELECT COUNT(1),
               SUM(C.TOT_MUM_M),
               SUM(C.TOT_WEIGHT_M),
               MIN(PLN_STARTTIME),
               MAX(PLN_ENDTIME +
                   NVL((SELECT T.HR_CAPCTY
                         FROM SLM_BASE_MATERIAL_B_PL T
                        WHERE T.PLINE_CODE = B.PLINE_CODE
                              AND T.OUT_MATERIAL_NO = C.MATERIAL_NO
                              AND
                              (T.DISABLE_FL IS NULL OR T.DISABLE_FL = '0')
                              AND T.IN_MATERIAL_NO = C.WLID_IN),
                       50) / 24 / 60)
          FROM PLN_STEELFORFURNACE B
          LEFT JOIN (SELECT FURNACENO,
                           SUM(TOT_MUM_M) TOT_MUM_M,
                           SUM(TOT_WEIGHT_M) TOT_WEIGHT_M,
                           MAX(WLID_IN) WLID_IN,
                           MAX(MATERIAL_NO) MATERIAL_NO
                      FROM PLN_STEELFOR_ORD
                     GROUP BY FURNACENO) C
            ON C.FURNACENO = B.FURNACENO
         WHERE B.CAST_NO = A.CAST_NO)
 WHERE A.CAST_NO =?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateCastQty2" desc="更新浇次计划支数重量">
		<![CDATA[
UPDATE PLN_STEELFORCAST A
   SET (FURNACENUMBER, TOT_NUM, TOT_WT, STARTTIME, ENDTIME) =
       (SELECT COUNT(1),
               SUM(C.TOT_MUM_M),
               SUM(C.TOT_WEIGHT_M),
               MIN(PLN_STARTTIME),
               MAX(PLN_ENDTIME +
                   NVL((SELECT T.HR_CAPCTY
                         FROM SLM_BASE_MATERIAL_B_PL T
                        WHERE T.PLINE_CODE = B.PLINE_CODE
                              AND T.OUT_MATERIAL_NO = C.MATERIAL_NO
                              AND
                              (T.DISABLE_FL IS NULL OR T.DISABLE_FL = '0')
                              AND T.IN_MATERIAL_NO = C.WLID_IN),
                       50) / 24 / 60)
          FROM PLN_STEELFORFURNACE B
          LEFT JOIN (SELECT FURNACENO,
                           SUM(TOT_MUM_M) TOT_MUM_M,
                           SUM(TOT_WEIGHT_M) TOT_WEIGHT_M,
                           MAX(WLID_IN) WLID_IN,
                           MAX(MATERIAL_NO) MATERIAL_NO
                      FROM PLN_STEELFOR_ORD
                     GROUP BY FURNACENO) C
            ON C.FURNACENO = B.FURNACENO
         WHERE B.CAST_NO = A.CAST_NO),
         CAST_SEQ=?
 WHERE A.CAST_NO=?
	]]>
	</query>


	<query id="FrmSteelManagement.UpdateCastQty3" desc="更新浇次计划支数重量">
		<![CDATA[
UPDATE PLN_STEELFORCAST A
   SET (CAST_SEQ, FURNACENUMBER, TOT_NUM, TOT_WT,PRO_MONTH, STARTTIME, ENDTIME) =
       (SELECT NVL(MAX(CAST_SEQ),A.CAST_SEQ), COUNT(1),
               SUM(C.TOT_MUM_M),
               SUM(C.TOT_WEIGHT_M),
               to_char(MIN(PLN_STARTTIME)  + 3/24,'YYYYMMDD'),
               MIN(PLN_STARTTIME),
               MAX(PLN_ENDTIME +
                   NVL((SELECT T.HR_CAPCTY
                         FROM SLM_BASE_MATERIAL_B_PL T
                        WHERE T.PLINE_CODE = B.PLINE_CODE
                              AND T.OUT_MATERIAL_NO = C.MATERIAL_NO
                              AND
                              (T.DISABLE_FL IS NULL OR T.DISABLE_FL = '0')
                              AND T.IN_MATERIAL_NO = C.WLID_IN),
                       50) / 24 / 60)
          FROM PLN_STEELFORFURNACE B
          LEFT JOIN (SELECT FURNACENO,
                           SUM(TOT_MUM_M) TOT_MUM_M,
                           SUM(TOT_WEIGHT_M) TOT_WEIGHT_M,
                           MAX(WLID_IN) WLID_IN,
                           MAX(MATERIAL_NO) MATERIAL_NO
                      FROM PLN_STEELFOR_ORD
                     GROUP BY FURNACENO) C
            ON C.FURNACENO = B.FURNACENO
         WHERE B.CAST_NO = A.CAST_NO)
 WHERE A.CAST_NO= ?
	]]>
	</query>

	<query id="FrmSteelManagement.CloseCast" desc="更新浇次计划支数重量">
		<![CDATA[
        UPDATE PLN_STEELFORCAST T SET STATUS = '40'   WHERE NOT EXISTS (SELECT 1 FROM PLN_STEELFORFURNACE WHERE CAST_NO =T.CAST_NO ) AND CAST_NO =?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateCastQty4" desc="更新浇次出钢量">
		<![CDATA[
UPDATE PLN_STEELFORCAST
   SET AIM_STEEL_QTY = CEIL(TOT_WT/FURNACENUMBER)
 WHERE CAST_NO= ? AND STATUS='00'
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateFurnaceQty4" desc="更新浇次出钢量">
		<![CDATA[
UPDATE PLN_STEELFORFURNACE A
   SET AIM_STEEL_QTY = (SELECT AIM_STEEL_QTY FROM PLN_STEELFORCAST WHERE CAST_NO =A.CAST_NO )
 WHERE CAST_NO= ? AND STATUS ='00'
	]]>
	</query>


	<query id="FrmSteelManagement.UpdateFurnaceNoQty" desc="更新浇次计划支数重量">
		<![CDATA[

UPDATE PLN_STEELFORFURNACE A
   SET (QUANTITY, WEIGHT) =
       (SELECT  SUM(TOT_MUM_M) TOT_MUM_M,
               SUM(TOT_WEIGHT_M) TOT_WEIGHT_M
          FROM PLN_STEELFOR_ORD
         WHERE FURNACENO = A.FURNACENO)
 WHERE FURNACENO = ?
	]]>
	</query>



	<query id="FrmSteelManagement.InsertCastByCopyCast" desc="根据旧浇次复制生成新的浇次">
		<![CDATA[
                 INSERT INTO PLN_STEELFORCAST(
CAST_NO,
       CAST_SEQ,
       CCMID,
       PLINE_CODE,
       PLINE_NAME,
       STATUS,
       FURNACENUMBER,
       TOT_NUM,
       TOT_WT,
       IF_CONNECT_GRADE,
       WATER_GROUP_CODE,
       ADD_WT_BEGIN,
       ADD_WT_END,
       ADD_WT_CONN_AHEAD,
       ADD_WT_CONN_NEXT,
       START_GRADECODE,
       END_GRADECODE,
        STARTTIME,
       ENDTIME,
       MAKEMAN,
       MAKETIME,
       MANFORTOL2,
       TIMEFORTOL2,
       MEMO,
       FLOWNUMBER,
       PRO_MONTH,
       CLOSEMAN,
       CLOSETIME)
SELECT ? CAST_NO,
       ? CAST_SEQ,
         CCMID,
         PLINE_CODE,
        PLINE_NAME,
       '10' STATUS,
       B.FURNACENUMBER,
       C.TOT_NUM,
       C.TOT_WT,
       IF_CONNECT_GRADE,
       WATER_GROUP_CODE,
       ADD_WT_BEGIN,
       ADD_WT_END,
       ADD_WT_CONN_AHEAD,
       ADD_WT_CONN_NEXT,
       START_GRADECODE,
       END_GRADECODE,
      TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') STARTTIME,
      TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') ENDTIME,
       MAKEMAN,
       MAKETIME,
       MANFORTOL2,
       TIMEFORTOL2,
       MEMO,
       FLOWNUMBER,
       PRO_MONTH,
       CLOSEMAN,
       CLOSETIME
  FROM PLN_STEELFORCAST A
  LEFT JOIN (SELECT COUNT(1) FURNACENUMBER FROM pln_steelforfurnace WHERE  CAST_NO=?  ) B ON 1=1
  LEFT JOIN (SELECT SUM(TOT_MUM_M) TOT_NUM,SUM(TOT_WEIGHT_M) TOT_WT FROM PLN_STEELFOR_ORD WHERE CAST_NO=?) C ON 1=1
  WHERE CAST_NO=?
	]]>
	</query>


	<query id="FrmSteelManagement.InsertCastByCopyCast2" desc="根据旧浇次复制生成新的浇次">
		<![CDATA[
                 INSERT INTO PLN_STEELFORCAST(
CAST_NO,
       CAST_SEQ,
       CCMID,
       PLINE_CODE,
       PLINE_NAME,
       STATUS,
       FURNACENUMBER,
       TOT_NUM,
       TOT_WT,
       IF_CONNECT_GRADE,
       WATER_GROUP_CODE,
       ADD_WT_BEGIN,
       ADD_WT_END,
       ADD_WT_CONN_AHEAD,
       ADD_WT_CONN_NEXT,
       START_GRADECODE,
       END_GRADECODE,
        STARTTIME,
       ENDTIME,
       MAKEMAN,
       MAKETIME,
       MANFORTOL2,
       TIMEFORTOL2,
       MEMO,
       FLOWNUMBER,
       PRO_MONTH,
       CLOSEMAN,
       CLOSETIME,
       DIAMETER,
       IF_CONFIRM)
SELECT ? CAST_NO,
        CAST_SEQ,
         CCMID,
         PLINE_CODE,
        PLINE_NAME,
       '10' STATUS,
        ? FURNACENUMBER,
       TOT_NUM,
       TOT_WT,
       IF_CONNECT_GRADE,
       WATER_GROUP_CODE,
       ADD_WT_BEGIN,
       ADD_WT_END,
       ADD_WT_CONN_AHEAD,
       ADD_WT_CONN_NEXT,
       START_GRADECODE,
       END_GRADECODE,
       STARTTIME,
       ENDTIME,
       MAKEMAN,
       MAKETIME,
       MANFORTOL2,
       TIMEFORTOL2,
       MEMO,
       FLOWNUMBER,
       PRO_MONTH,
       CLOSEMAN,
       CLOSETIME,
       DIAMETER,
       '1'
  FROM PLN_STEELFORCAST A
  WHERE CAST_NO=?
	]]>
	</query>

	<query id="FrmSteelManagement.InsertFurnaceByCopyFurnace" desc="根据炉次复制生成新的炉次">
		<![CDATA[
                INSERT INTO PLN_STEELFORFURNACE
  (FURNACENO,
   FURNACENO_SEQ,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   STOVE_NO,
   BOF_TYPE,
   STATUS,
   HEAT_STATE,
   CASTINGTYPE,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   EF_AGE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   CIC,
   PLN_STARTTIME,
   PLN_ENDTIME,
   AIM_STEEL_QTY,
   QUANTITY,
   WEIGHT,
   OLD_FURNACENO,
   OLD_STOVE_NO,
   PLAN_ROUTE,
   FACT_ROUTE,
   STARTTIME,
   ENDTIME,
   BOF_STARTTIME,
   BOF_ENDTIME,
   CAS_STARTTIME,
   CAS_ENDTIME,
   VD_STARTTIME,
   VD_ENDTIME,
   RH_STARTTIME,
   RH_ENDTIME,
   LFS_STARTTIME,
   LFS_ENDTIME,
   CCM_STARTTIME,
   CCM_ENDTIME,
   SURPLUSFLAG,
   IF_MONITOR_LG,
   PRDCR_NO,
   CHEM_JUDGE_ID,
   PLANREMARK,
   REMARK,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   PRO_MONTH,
   CLOSEMAN,
   CLOSETIME,
   CRAFT_NO,
   CRAFT_PATH,
   IF_CONFIRM,
   BATCHING_CODE,
   BATCHING_NAME,
   HOTMETAL_NUM,
   IRON_NUM,
   STEELSCRAP_NUM,
   JUDGE_FLAG)
  SELECT
        ? FURNACENO,
         FURNACENO_SEQ,
         CAST_NO,
         CAST_SEQ,
        ? CAST_STOVE_SEQ,
         STOVE_NO,
        ? BOF_TYPE,
         STATUS,
         HEAT_STATE,
         CASTINGTYPE,
         EF_PLINE_CODE,
         EF_PLINE_NAME,
         EF_AGE,
         PLINE_CODE,
         PLINE_NAME,
         CCMID,
         WLID_IN,
         WLDESC_IN,
         MATERIAL_NO,
         MATERIAL_NAME,
         GRADECODE,
         GRADENAME,
         CIC,
         PLN_STARTTIME,
         PLN_ENDTIME,
         AIM_STEEL_QTY,
         QUANTITY,
         WEIGHT,
         OLD_FURNACENO,
         OLD_STOVE_NO,
         PLAN_ROUTE,
         FACT_ROUTE,
         STARTTIME,
         ENDTIME,
         BOF_STARTTIME,
         BOF_ENDTIME,
         CAS_STARTTIME,
         CAS_ENDTIME,
         VD_STARTTIME,
         VD_ENDTIME,
         RH_STARTTIME,
         RH_ENDTIME,
         LFS_STARTTIME,
         LFS_ENDTIME,
         CCM_STARTTIME,
         CCM_ENDTIME,
         SURPLUSFLAG,
         IF_MONITOR_LG,
         PRDCR_NO,
         CHEM_JUDGE_ID,
         PLANREMARK,
         REMARK,
         ? MAKEMAN,
         SYSDATE MAKETIME,
         DOWNMAN,
         DOWNTIME,
         PRO_MONTH,
         CLOSEMAN,
         CLOSETIME,
         CRAFT_NO,
         CRAFT_PATH,
         IF_CONFIRM,
         BATCHING_CODE,
         BATCHING_NAME,
         HOTMETAL_NUM,
         IRON_NUM,
         STEELSCRAP_NUM,
         JUDGE_FLAG
    FROM PLN_STEELFORFURNACE
   WHERE FURNACENO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.InsertOrderByCopyOrder" desc="根据炉次复制生成新的炉次">
		<![CDATA[
            INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   EXCESS_WT,
   EXCESS_NUM,
   PRO_MONTH,
   ISENDGX,
   STATE_LK,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   IF_MONITOR_LG,
   PRDCR_NO,
   MERGE_NO,
   PDEPT_NAME,
   PRDCR_MAN)
  SELECT ? FURNACENO,
         ? SEQUENCENO,
         FURNACENO_SEQ,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         CAST_NO,
         CAST_SEQ,
         CAST_STOVE_SEQ,
         CCM_SEQ,
         '',
         '',
         '',
         '',
         '10',
         GPTYPE,
         CASTINGTYPE,
         PLINE_CODE,
         PLINE_NAME,
         CCMID,
         FLOWNO,
         EF_PLINE_CODE,
         EF_PLINE_NAME,
         WLID_IN,
         WLDESC_IN,
         MATERIAL_NO,
         MATERIAL_NAME,
         GRADECODE,
         GRADENAME,
         DIAMETER,
         LEN_GP_SINGLE,
         CUT_NUM_GP,
         LENGTH_M,
         WEIGHT_GP_ONE,
         WEIGHT_M,
         TOT_MUM_M,
         TOT_WEIGHT_M,
         ACT_WEIGHT_M,
         ACT_MUM_M,
         SURPLUSFLAG,
         SURPLUS_TYPE,
         IF_SURPLUS_ALLOTED,
         CIC,
         PIC,
         SIC,
         DIC,
         MEMO,
         MAKEMAN,
         MAKETIME,
         DOWNMAN,
         DOWNTIME,
         CHEM_JUDGE_ID,
         PHY_JUDGE_ID,
         COLLIGATE_JUDGE_ID,
         EXCESS_WT,
         EXCESS_NUM,
         PRO_MONTH,
         ISENDGX,
         STATE_LK,
         ORDER_NO,
         FINAL_USER_DESC,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
         GOWHERE_CODE,
         GOWHERE_NAME,
         IF_MONITOR_LG,
         PRDCR_NO,
         MERGE_NO,
         PDEPT_NAME,
         PRDCR_MAN
    FROM PLN_STEELFOR_ORD
   WHERE FURNACENO = ?
         AND SEQUENCENO = ?


	]]>
	</query>

	<query id="FrmSteelManagement.SelectMaxSequenceNo" desc="">
	<![CDATA[
    SELECT MAX(SEQUENCENO) SEQUENCENO
            FROM PLN_STEELFOR_ORD
           WHERE FURNACENO = ?
                 AND SURPLUSFLAG = 0
	]]>
</query>


	<query id="FrmSteelManagement.SelectMaxSequenceNo1" desc="">
		<![CDATA[
	SELECT NVL(MAX(SEQUENCENO), 0) + 1 SEQUENCENO
	FROM PLN_STEELFOR_ORD
	WHERE FURNACENO = B.FURNACENO AND SEQUENCENO<>99
	]]>
	</query>



	<query id="FrmSteelManagement.InsertOrderByCopyFurnace" desc="">
	<![CDATA[
        INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   CUT_NUM,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   EXCESS_WT,
   EXCESS_NUM,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   PRO_MONTH,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   ISENDGX,
   STATE_LK,
   IF_MONITOR_LG,
   PRDCR_NO,
   MERGE_NO,
   PDEPT_NAME,
   PRDCR_MAN)
  SELECT ? FURNACENO,
         ? SEQUENCENO,
         ? CUT_NUM,
         T.FURNACENO_SEQ,
          DECODE(T.MERGE_NO, NULL, T.PRO_PLAN_ID, T1.PRO_PLAN_ID),
            DECODE(T.MERGE_NO, NULL, T.GX_PLAN_NO, T1.GX_PLAN_NO),
         T.CAST_NO,
         T.CAST_SEQ,
         T.CAST_STOVE_SEQ,
         T.CCM_SEQ +1,
         T.STOVE_NO,
         T.JUDGE_STOVE_NO,
         T.JUDGE_STOVE_NO_SEQ,
         T.FLAG_STOVE_NO,
        DECODE(T.STATUS,'00','00','10'),
         T.GPTYPE,
         T.CASTINGTYPE,
         T.PLINE_CODE,
         T.PLINE_NAME,
         T.CCMID,
         T.FLOWNO,
         T.EF_PLINE_CODE,
         T.EF_PLINE_NAME,
         T.WLID_IN,
         T.WLDESC_IN,
         T.MATERIAL_NO,
         T.MATERIAL_NAME,
         T.GRADECODE,
         T.GRADENAME,
         T.DIAMETER,
         T.LEN_GP_SINGLE,
         T.CUT_NUM_GP,
         T.LENGTH_M,
         T.WEIGHT_GP_ONE,
         T.WEIGHT_M,
         T.TOT_MUM_M,
         T.TOT_WEIGHT_M,
         T.ACT_WEIGHT_M,
         T.ACT_MUM_M,
         1 SURPLUSFLAG,
         T.EXCESS_WT,
         T.EXCESS_NUM,
         6 SURPLUS_TYPE,
         T.IF_SURPLUS_ALLOTED,
                  DECODE(T.MERGE_NO, NULL, T.CIC, T1.CIC),
            DECODE(T.MERGE_NO, NULL, T.PIC, T1.PIC),
            DECODE(T.MERGE_NO, NULL, T.SIC, T1.SIC),
            DECODE(T.MERGE_NO, NULL, T.DIC, T1.DIC),
         T.CHEM_JUDGE_ID,
         T.PHY_JUDGE_ID,
         T.COLLIGATE_JUDGE_ID,
         T.MEMO,
         ? MAKEMAN,
         SYSDATE MAKETIME,
         T.DOWNMAN,
         T.DOWNTIME,
         T.PRO_MONTH,
         ? ORDER_NO,
         '备料' FINAL_USER_DESC,
        '' STEELCODE,
        '' STEELNAME,
       ''  PRODUCCODE,
       '' PRODUCNAME,
        '' GOWHERE_CODE,
        '离线库' GOWHERE_NAME,
         T.ISENDGX,
        '0' STATE_LK,
        '' IF_MONITOR_LG,
        '' PRDCR_NO,
       ''  MERGE_NO,
        '' PDEPT_NAME,
        '' PRDCR_MAN
    FROM PLN_STEELFOR_ORD T
     LEFT JOIN (SELECT T2.*,
                         RANK() OVER(PARTITION BY MERGE_NO ORDER BY MERGE_SEQ DESC) RK
                    FROM PLN_STEELFOR_MERGE T2) T1
         ON T1.MERGE_NO = T.MERGE_NO
        AND RK = 1
   WHERE
    T.FURNACENO = ? AND  T.SEQUENCENO=?


	]]>
</query>

	<query id="FrmSteelManagement.InsertOrderByCopyFurnace2" desc="">
		<![CDATA[
       INSERT INTO PLN_STEELFOR_ORD
    (FURNACENO,
     SEQUENCENO,
     CUT_NUM,
     FURNACENO_SEQ,
     PRO_PLAN_ID,
     GX_PLAN_NO,
     CAST_NO,
     CAST_SEQ,
     CAST_STOVE_SEQ,
     CCM_SEQ,
     STOVE_NO,
     JUDGE_STOVE_NO,
     JUDGE_STOVE_NO_SEQ,
     FLAG_STOVE_NO,
     STATUS,
     GPTYPE,
     CASTINGTYPE,
     PLINE_CODE,
     PLINE_NAME,
     CCMID,
     FLOWNO,
     EF_PLINE_CODE,
     EF_PLINE_NAME,
     WLID_IN,
     WLDESC_IN,
     MATERIAL_NO,
     MATERIAL_NAME,
     GRADECODE,
     GRADENAME,
     DIAMETER,
     LEN_GP_SINGLE,
     CUT_NUM_GP,
     LENGTH_M,
     WEIGHT_GP_ONE,
     WEIGHT_M,
     TOT_MUM_M,
     TOT_WEIGHT_M,
     ACT_WEIGHT_M,
     ACT_MUM_M,
     SURPLUSFLAG,
     EXCESS_WT,
     EXCESS_NUM,
     SURPLUS_TYPE,
     IF_SURPLUS_ALLOTED,
     CIC,
     PIC,
     SIC,
     DIC,
     CHEM_JUDGE_ID,
     PHY_JUDGE_ID,
     COLLIGATE_JUDGE_ID,
     MEMO,
     MAKEMAN,
     MAKETIME,
     DOWNMAN,
     DOWNTIME,
     PRO_MONTH,
     ORDER_NO,
     FINAL_USER_DESC,
     STEELCODE,
     STEELNAME,
     PRODUCCODE,
     PRODUCNAME,
     GOWHERE_CODE,
     GOWHERE_NAME,
     ISENDGX,
     STATE_LK,
     IF_MONITOR_LG,
     PRDCR_NO,
     MERGE_NO,
     PDEPT_NAME,
     PRDCR_MAN)
       SELECT ? FURNACENO,
            (SELECT NVL(MAX(SEQUENCENO), 0) + 1
               FROM PLN_STEELFOR_ORD
              WHERE FURNACENO = T.FURNACENO
                AND (SURPLUS_TYPE <> 3 OR SURPLUS_TYPE IS NULL)) SEQUENCENO,
            ? CUT_NUM,
            FURNACENO_SEQ,
            DECODE(T.MERGE_NO, NULL, T.PRO_PLAN_ID, T1.PRO_PLAN_ID),
            DECODE(T.MERGE_NO, NULL, T.GX_PLAN_NO, T1.GX_PLAN_NO),
            CAST_NO,
            CAST_SEQ,
            CAST_STOVE_SEQ,
            CCM_SEQ + 1,
            STOVE_NO,
            ? JUDGE_STOVE_NO,
            ? JUDGE_STOVE_NO_SEQ,
            ? FLAG_STOVE_NO,
           DECODE(STATUS,'00','00','10'),
            GPTYPE,
            CASTINGTYPE,
            PLINE_CODE,
            PLINE_NAME,
            CCMID,
            FLOWNO,
            EF_PLINE_CODE,
            EF_PLINE_NAME,
            WLID_IN,
            WLDESC_IN,
            MATERIAL_NO,
            MATERIAL_NAME,
            GRADECODE,
            GRADENAME,
            DIAMETER,
            T.LEN_GP_SINGLE,
            T.CUT_NUM_GP,
            T.LENGTH_M,
            T.WEIGHT_GP_ONE,
            T.WEIGHT_M,
            T.TOT_MUM_M,
            T.TOT_WEIGHT_M,
            ACT_WEIGHT_M,
            ACT_MUM_M,
            1 SURPLUSFLAG,
            EXCESS_WT,
            EXCESS_NUM,
            6 SURPLUS_TYPE,
            IF_SURPLUS_ALLOTED,
            DECODE(T.MERGE_NO, NULL, T.CIC, T1.CIC),
            DECODE(T.MERGE_NO, NULL, T.PIC, T1.PIC),
            DECODE(T.MERGE_NO, NULL, T.SIC, T1.SIC),
            DECODE(T.MERGE_NO, NULL, T.DIC, T1.DIC),
            CHEM_JUDGE_ID,
            PHY_JUDGE_ID,
            COLLIGATE_JUDGE_ID,
            MEMO,
            ? MAKEMAN,
            SYSDATE MAKETIME,
            DOWNMAN,
            DOWNTIME,
            PRO_MONTH,
            ? ORDER_NO,
            '备料' FINAL_USER_DESC,
            '' STEELCODE,
            '' STEELNAME,
            '' PRODUCCODE,
            '' PRODUCNAME,
            '' GOWHERE_CODE,
            '离线库' GOWHERE_NAME,
            ISENDGX,
            '0' STATE_LK,
            '' IF_MONITOR_LG,
            '' PRDCR_NO,
            '' MERGE_NO,
            '' PDEPT_NAME,
            '' PRDCR_MAN
       FROM PLN_STEELFOR_ORD T
       LEFT JOIN (SELECT T2.*,
                         RANK() OVER(PARTITION BY MERGE_NO ORDER BY MERGE_SEQ DESC) RK
                    FROM PLN_STEELFOR_MERGE T2) T1
         ON T1.MERGE_NO = T.MERGE_NO
        AND RK = 1
      WHERE T.FURNACENO = ?
        AND T.SEQUENCENO = ?


	]]>
	</query>

	<query id="FrmSteelManagement.UpdateFurnaceCastSeq" desc="更改炉次表浇次顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFORFURNACE A
     SET CAST_NO=?,
     CAST_SEQ = ?,
     CAST_STOVE_SEQ =?,
     FURNACENO_SEQ = ?,
     PLN_STARTTIME = TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     PLN_ENDTIME = TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     STOVE_NO=?,
     PRO_MONTH=?,
     BOF_TYPE=?,
     STATUS=?,
     HEAT_STATE=?,
      STARTTIME=TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     ENDTIME=TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     (QUANTITY, WEIGHT) =
       (SELECT  SUM(TOT_MUM_M) TOT_MUM_M,
               SUM(TOT_WEIGHT_M) TOT_WEIGHT_M
          FROM PLN_STEELFOR_ORD
         WHERE FURNACENO = A.FURNACENO)
   WHERE FURNACENO = ?
	]]>
	</query>

    <query id="FrmSteelManagement.UpdateFurnaceCast" desc="更改炉次表浇次顺序号和浇次号">
        <![CDATA[
                  UPDATE PLN_STEELFORFURNACE
   SET CAST_NO = ?, CAST_SEQ = ?,PLINE_CODE=?,PLINE_NAME=?,CCMID=?
 WHERE FURNACENO = ?

	]]>
    </query>

    <query id="FrmSteelManagement.UpdateOrderCastSeq" desc="更改订单表浇次顺序号">
        <![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  CAST_NO=?,
     FURNACENO=?,
     CAST_SEQ = ?,
     CAST_STOVE_SEQ=?,
     FURNACENO_SEQ=?,
      CCM_SEQ=?,
      STOVE_NO=?,
      FLAG_STOVE_NO=?,
      JUDGE_STOVE_NO=?,
       JUDGE_STOVE_NO_SEQ=?,
       SURPLUS_TYPE=?,
       PRO_MONTH=?,
       CUT_NUM=?
   WHERE FURNACENO = ?
      AND SEQUENCENO=?
	]]>
    </query>


	<query id="FrmSteelManagement.UpdateOrderNo" desc="">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  ORDER_NO=?
   WHERE FURNACENO = ?
      AND SEQUENCENO=?
	]]>
	</query>




	<query id="FrmSteelManagement.UpdateOrderCast" desc="更改订单表浇次号">
        <![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET CAST_NO=?,
     CAST_SEQ = ?,
      CCM_SEQ=?,
      PLINE_CODE=?,PLINE_NAME=?,CCMID=?
   WHERE FURNACENO = ?
      AND SEQUENCENO=?
	]]>
    </query>




	<query id="FrmSteelManagement.UpdateCCMSeq" desc="更改订单表连铸顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  CCM_SEQ=?,
      CUT_NUM=?,
      FLAG_STOVE_NO = ?,
      JUDGE_STOVE_NO=?,
      JUDGE_STOVE_NO_SEQ=?
   WHERE FURNACENO = ?
      AND SEQUENCENO=?
	]]>
	</query>


	<query id="FrmSteelManagement.UpdateCCMSeq1" desc="更改订单表连铸顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  CCM_SEQ=?,
     CAST_SEQ =?
   WHERE FURNACENO = ?
      AND SEQUENCENO=?
	]]>
	</query>


	<query id="FrmSteelManagement.UpdateFirstCutNumStove" desc="更改订单表连铸顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  FLAG_STOVE_NO = ?,
      JUDGE_STOVE_NO=?,
      JUDGE_STOVE_NO_SEQ=?
   WHERE FURNACENO = ?
      AND CUT_NUM=1
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateCCMSeqByLine" desc="根据铸造产线更改铸造顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  CCM_SEQ=CCM_SEQ+?
   WHERE CCM_SEQ >= ?
      AND PLINE_CODE=?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateCCMSeqByLine2" desc="根据铸造产线更改铸造顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  CCM_SEQ=CCM_SEQ+?
   WHERE CCM_SEQ >= ?
      AND CCM_SEQ<=?
      AND PLINE_CODE=?
	]]>
	</query>



	<query id="FrmSteelManagement.UpdateCastSeq" desc="">
		<![CDATA[
                  UPDATE PLN_STEELFORCAST
     SET  CAST_SEQ=CAST_SEQ+ ?
   WHERE  PLINE_CODE= ? AND CAST_SEQ >= ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateCastSeqByCastNo" desc="">
		<![CDATA[
                  UPDATE PLN_STEELFORCAST
     SET  CAST_SEQ=  ?
   WHERE  CAST_NO=?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateFurnace" desc="">
	<![CDATA[
                  UPDATE PLN_STEELFORFURNACE A
     SET  FURNACENO_SEQ=FURNACENO_SEQ+?,
      CAST_SEQ = (SELECT CAST_NO FROM PLN_STEELFORCAST WHERE CAST_NO=A.CAST_NO )
   WHERE  EF_PLINE_CODE=? AND FURNACENO_SEQ >= ?
	]]>
</query>

	<query id="FrmSteelManagement.UpdateOrder" desc="">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD A
     SET  CCM_SEQ=CCM_SEQ+?,
      (CAST_NO,FURNACENO_SEQ) = (SELECT CAST_NO,FURNACENO_SEQ FROM PLN_STEELFORFURNACE WHERE FURNACENO=A.FURNACENO )
   WHERE PLINE_CODE=? AND CCM_SEQ >= ?
	]]>
	</query>




	<query id="FrmSteelManagement.UpdateSEQUENCENO" desc="">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET  SEQUENCENO=SEQUENCENO+?
   WHERE SEQUENCENO>=? AND
      FURNACENO=?
       AND (SURPLUS_TYPE IS NULL OR (SURPLUS_TYPE != 3 AND SURPLUS_TYPE != 2))
	]]>
	</query>

	<query id="FrmSteelManagement.DeleteOrder" desc="">
		<![CDATA[
              DELETE PLN_STEELFOR_ORD
 WHERE FURNACENO =?
       AND SEQUENCENO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.UpdateCutNum" desc="">
		<![CDATA[
              UPDATE PLN_STEELFOR_ORD SET CUT_NUM= CUT_NUM -1
 WHERE FURNACENO =?
     AND CUT_NUM>?
     AND CUT_NUM <> '99'

	]]>
	</query>

	<query id="FrmSteelManagement.UpdateFurnaceCastAndCastStoveSeq" desc="更改炉次表炉次炉内顺序号">
	<![CDATA[
                  UPDATE PLN_STEELFORFURNACE
     SET
           FURNACENO_SEQ = ?,
           EF_PLINE_CODE=?,
           EF_PLINE_NAME=?
   WHERE FURNACENO = ?
	]]>
</query>




	<query id="FrmSteelManagement.UpdateFurnaceCastStoveSeq" desc="更改炉次表炉次炉内顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFORFURNACE
     SET FURNACENO_SEQ = ?
   WHERE FURNACENO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateOrderCastStoveSeq" desc="更改订单表炉次炉内顺序号">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET FURNACENO_SEQ = ?,
           CAST_STOVE_SEQ = ?,
           CCM_SEQ=?
   WHERE FURNACENO = ?
      AND SEQUENCENO=?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateFurnaceByCast" desc="通过浇次同步炉次表和订单表的数据">
		<![CDATA[
                       UPDATE PLN_STEELFORFURNACE T
       SET (CAST_SEQ, PLINE_CODE, PLINE_NAME) =
           (SELECT CAST_SEQ, PLINE_CODE, PLINE_NAME
              FROM PLN_STEELFORCAST
             WHERE CAST_NO = T.CAST_NO)
     WHERE CAST_NO = ?

	]]>
	</query>





	<query id="FrmSteelManagement.UpdateOrderByFurnaceNo" desc="通过炉次号同步炉次表和订单表的数据">
		<![CDATA[
                    UPDATE PLN_STEELFOR_ORD T
      SET (FURNACENO_SEQ, CAST_NO, CAST_SEQ, CAST_STOVE_SEQ, STOVE_NO,EF_PLINE_CODE,EF_PLINE_NAME) =
          (SELECT FURNACENO_SEQ, CAST_NO, CAST_SEQ, CAST_STOVE_SEQ, STOVE_NO,EF_PLINE_CODE,EF_PLINE_NAME
             FROM PLN_STEELFORFURNACE
            WHERE FURNACENO = T.FURNACENO)
    WHERE FURNACENO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateOrderByFurnaceNo2" desc="通过炉次号同步炉次表和订单表的数据">
		<![CDATA[
                    UPDATE PLN_STEELFOR_ORD T
      SET (FURNACENO_SEQ, CAST_NO, CAST_SEQ, CAST_STOVE_SEQ, STOVE_NO,EF_PLINE_CODE,EF_PLINE_NAME,PRO_MONTH) =
          (SELECT FURNACENO_SEQ, CAST_NO, CAST_SEQ, CAST_STOVE_SEQ, STOVE_NO,EF_PLINE_CODE,EF_PLINE_NAME,PRO_MONTH
             FROM PLN_STEELFORFURNACE
            WHERE FURNACENO = T.FURNACENO),
            CCM_SEQ =?,
   JUDGE_STOVE_NO=?,
   JUDGE_STOVE_NO_SEQ=?,
   FLAG_STOVE_NO =?
    WHERE FURNACENO = ?
    AND SEQUENCENO=?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateOrderQty" desc="通过炉次号同步炉次表和订单表的数据">
		<![CDATA[
                    UPDATE PLN_STEELFOR_ORD
      SET TOT_MUM_M = TOT_MUM_M + ?,
      TOT_WEIGHT_M = TOT_WEIGHT_M + ? * WEIGHT_M
       WHERE FURNACENO = ?
         AND SEQUENCENO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateOrderQty2" desc="通过炉次号同步炉次表和订单表的数据">
		<![CDATA[
                    UPDATE PLN_STEELFOR_ORD
      SET TOT_MUM_M = TOT_MUM_M + ?,
      TOT_WEIGHT_M = TOT_WEIGHT_M + ?
       WHERE FURNACENO = ?
         AND SEQUENCENO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.InsertIntoHandOverPlanByOrderCast" desc="">
		<![CDATA[
                INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   CUT_NUM,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   CCM_STATE,
   CCM_PLN_TYPE,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   EXCESS_WT,
   EXCESS_NUM,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   PRO_MONTH,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   ISENDGX,
   STATE_LK,
   IF_MONITOR_LG,
   PRDCR_NO)
  SELECT  B.FURNACENO,
         (SELECT NVL(MAX(SEQUENCENO), 0) + 1
            FROM PLN_STEELFOR_ORD
           WHERE FURNACENO = B.FURNACENO AND SEQUENCENO<>99) SEQUENCENO,
              (SELECT NVL(MAX(CUT_NUM), 0) + 1
            FROM PLN_STEELFOR_ORD
           WHERE FURNACENO = B.FURNACENO AND CUT_NUM<>99) CUT_NUM,
         B.FURNACENO_SEQ,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         B.CAST_NO,
         B.CAST_SEQ,
         B.CAST_STOVE_SEQ,
         ? CCM_SEQ,
         B.STOVE_NO,
         ? JUDGE_STOVE_NO,
         ? JUDGE_STOVE_NO_SEQ,
         ? FLAG_STOVE_NO,
         '10' STATUS,
         '00' CCM_STATE,
         '00' CCM_PLN_TYPE,
         A.GPTYPE,
         A.CASTINGTYPE,
         B.PLINE_CODE,
         B.PLINE_NAME,
         B.CCMID,
         '' FLOWNO,
         EF_PLINE_CODE,
         EF_PLINE_NAME,
         A.WLID_IN,
         A.WLDESC_IN,
         A.MATERIAL_NO,
         A.MATERIAL_NAME,
         A.GRADECODE,
         A.GRADENAME,
         A.DIAMETER_LZ DIAMETER,
         LEN_GP_SINGLE,
         CUT_NUM_GP,
         A.LENGTH_LZ LENGTH_M,
         ? WEIGHT_GP_ONE,
         ?  WEIGHT_M,
         ? TOT_MUM_M,
         ?  TOT_WEIGHT_M,
         '' ACT_WEIGHT_M,
         '' ACT_MUM_M,
         0 SURPLUSFLAG,
         '' EXCESS_WT,
         '' EXCESS_NUM,
         '' SURPLUS_TYPE,
         '' IF_SURPLUS_ALLOTED,
         A.CIC,
         A. PIC,
         A.SIC,
         A.DIC,
         '' CHEM_JUDGE_ID,
         '' PHY_JUDGE_ID,
         '' COLLIGATE_JUDGE_ID,
         MEMO,
         ? MAKEMAN,
         SYSDATE MAKETIME,
         ? DOWNMAN,
         SYSDATE DOWNTIME,
         B.PRO_MONTH,
         ORDER_NO,
         FINAL_USER_DESC,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
         A.GOWHERE_CODE,
         A.GOWHERE_NAME,
         '0' ISENDGX,
         '0' STATE_LK,
         DECODE(A.IF_MONITOR_LG,'1','是','/'),
         A.PRDCR_NO
    FROM PLN_ORDER_CAST_S A
    LEFT JOIN PLN_STEELFORFURNACE B
      ON B.FURNACENO = ?
      LEFT JOIN (SELECT MAX(Y.ABRVITION) FINAL_USER_DESC,
                      MAX(S.ORDER_NO || '/' || S.ORDER_SEQ) ORDER_NO,
                      Z.GPREQ_ID,
                      MAX(S.PRODUCNAME) PRODUCNAME,
                      MAX(S.PRODUCCODE) PRODUCCODE,
                      MAX(S.STEELNAME) STEELNAME,
                      MAX(S.STEELCODE) STEELCODE
                 FROM PLN_ORDER_ZG_S    Z,
                      PLN_SALEORD       S,
                      SLM_BASE_CUSTOMER Y
                WHERE Z.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
                      AND S.FINAL_USER = Y.CUSTOMER_NO
                GROUP BY Z.GPREQ_ID) C
      ON A.PRO_PLAN_ID = C.GPREQ_ID
           WHERE PRO_PLAN_ID=?
     AND GX_PLAN_NO=?


	]]>
	</query>

	<query id="FrmSteelManagement.InsertIntoHandOverPlan" desc="">
		<![CDATA[
INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   CUT_NUM,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   CCM_STATE,
   CCM_PLN_TYPE,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   EXCESS_WT,
   EXCESS_NUM,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   PRO_MONTH,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   ISENDGX,
   STATE_LK,
   IF_MONITOR_LG,
   PRDCR_NO)
  SELECT B.FURNACENO,
         (SELECT NVL(MAX(SEQUENCENO), 0) + 1
            FROM PLN_STEELFOR_ORD
           WHERE FURNACENO = ? AND SEQUENCENO<>99) SEQUENCENO,
              (SELECT NVL(MAX(CUT_NUM), 0) + 1
            FROM PLN_STEELFOR_ORD
           WHERE FURNACENO = ? AND SEQUENCENO<>99) CUT_NUM,
         B.FURNACENO_SEQ,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         B.CAST_NO,
         B.CAST_SEQ,
         B.CAST_STOVE_SEQ,
         ? CCM_SEQ,
         B.STOVE_NO,
         ? JUDGE_STOVE_NO,
         ? JUDGE_STOVE_NO_SEQ,
        ? FLAG_STOVE_NO,
         A.STATUS,
         A.CCM_STATE,
         A.CCM_PLN_TYPE,
         A.GPTYPE,
         A.CASTINGTYPE,
         B.PLINE_CODE,
         B.PLINE_NAME,
         B. CCMID,
         FLOWNO,
         B.EF_PLINE_CODE,
         B.EF_PLINE_NAME,
         A.WLID_IN,
         A.WLDESC_IN,
         A.MATERIAL_NO,
         A.MATERIAL_NAME,
         A.GRADECODE,
         A.GRADENAME,
         DIAMETER,
         LEN_GP_SINGLE,
         CUT_NUM_GP,
         LENGTH_M,
         WEIGHT_GP_ONE,
         WEIGHT_M,
         ? TOT_MUM_M,
         ? * WEIGHT_M TOT_WEIGHT_M,
         ACT_WEIGHT_M,
         ACT_MUM_M,
         A.SURPLUSFLAG,
         EXCESS_WT,
         EXCESS_NUM,
         SURPLUS_TYPE,
         IF_SURPLUS_ALLOTED,
         A.CIC,
         A.PIC,
         A.SIC,
         A.DIC,
         A.CHEM_JUDGE_ID,
         A.PHY_JUDGE_ID,
         A.COLLIGATE_JUDGE_ID,
         MEMO,
         A.MAKEMAN,
         A.MAKETIME,
         A.DOWNMAN,
         A.DOWNTIME,
         B.PRO_MONTH,
         ORDER_NO,
         FINAL_USER_DESC,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
         GOWHERE_CODE,
         GOWHERE_NAME,
         ISENDGX,
         STATE_LK,
   A.IF_MONITOR_LG,
   A.PRDCR_NO
    FROM PLN_STEELFOR_ORD A
    LEFT JOIN PLN_STEELFORFURNACE B
      ON B.FURNACENO = ?
   WHERE A.FURNACENO = ?
         AND A.SEQUENCENO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.InsertOrder" desc="">
		<![CDATA[
INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   CCM_STATE,
   CCM_PLN_TYPE,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   EXCESS_WT,
   EXCESS_NUM,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   PRO_MONTH,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   ISENDGX,
   STATE_LK,
   IF_MONITOR_LG,
   PRDCR_NO,
   MERGE_NO,
   PDEPT_NAME,
   PRDCR_MAN,
   CUT_NUM)
  SELECT T.FURNACENO,
        ? SEQUENCENO,
         T.FURNACENO_SEQ,
        ? PRO_PLAN_ID,
        ? GX_PLAN_NO,
        T.CAST_NO  CAST_NO,
        T.CAST_SEQ,
         T.CAST_STOVE_SEQ,
         ? CCM_SEQ,
         T.STOVE_NO,
        ? JUDGE_STOVE_NO,
        ? JUDGE_STOVE_NO_SEQ,
        ? FLAG_STOVE_NO,
         '10' STATUS,
         '00' CCM_STATE,
         '00' CCM_PLN_TYPE,
         ? GPTYPE,
         ? CASTINGTYPE,
         T.PLINE_CODE,
          T.PLINE_NAME,
          T.PLINE_NAME CCMID,
         ? FLOWNO,
          T.EF_PLINE_CODE,
          T.EF_PLINE_NAME,
         ? WLID_IN,
         ? WLDESC_IN,
         ? MATERIAL_NO,
        ? MATERIAL_NAME,
        ? GRADECODE,
        ? GRADENAME,
        ? DIAMETER,
        ? LEN_GP_SINGLE,
        ? CUT_NUM_GP,
        ? LENGTH_M,
        ? WEIGHT_GP_ONE,
        ? WEIGHT_M,
        ? TOT_MUM_M,
        ? TOT_WEIGHT_M,
        ? ACT_WEIGHT_M,
        ? ACT_MUM_M,
        ? SURPLUSFLAG,
        ? EXCESS_WT,
        ? EXCESS_NUM,
        ? SURPLUS_TYPE,
        ? IF_SURPLUS_ALLOTED,
        ? CIC,
        ? PIC,
        ? SIC,
        ? DIC,
        ? CHEM_JUDGE_ID,
        ? PHY_JUDGE_ID,
        ? COLLIGATE_JUDGE_ID,
        ? MEMO,
        ? MAKEMAN,
        to_date(?,'yyyy-mm-dd hh24:mi:ss') MAKETIME,
        ? DOWNMAN,
        to_date(?,'yyyy-mm-dd hh24:mi:ss') DOWNTIME,
         T.PRO_MONTH,
        ? ORDER_NO,
        ? FINAL_USER_DESC,
        ? STEELCODE,
        ? STEELNAME,
        ? PRODUCCODE,
        ? PRODUCNAME,
        ? GOWHERE_CODE,
        ? GOWHERE_NAME,
        '0' ISENDGX,
        ? STATE_LK,
        ? IF_MONITOR_LG,
        ? PRDCR_NO,
        ? MERGE_NO,
        ? PDEPT_NAME,
        ? PRDCR_MAN,
        ? CUT_NUM
    FROM PLN_STEELFORFURNACE T
   WHERE FURNACENO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.UpdateChangeOrderPlan" desc="">
		<![CDATA[
UPDATE pln_steelfor_ord
   SET   ccm_seq = ?,
       pro_plan_id = ?,
       gx_plan_no = ?,
       judge_stove_no = ?,
       judge_stove_no_seq = ?,
       flag_stove_no = ?,
       tot_mum_m = ?,
       tot_weight_m=?,
       cic = ?,
       pic = ?,
       sic = ?,
       dic = ?,
       order_no = ?,
       final_user_desc = ?,
       prdcr_no = ?,
       merge_no = ?,
       pdept_name = ?,
       prdcr_man = ?,
       cut_num = ?,
       STATE_LK=?
 WHERE furnaceno = ?
   AND sequenceno = ?
	]]>
	</query>

	<query id="FrmSteelManagement.InsertOrderByCopyOrder2" desc="">
		<![CDATA[
INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   CCM_STATE,
   CCM_PLN_TYPE,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   EXCESS_WT,
   EXCESS_NUM,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   PRO_MONTH,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   ISENDGX,
   STATE_LK,
   IF_MONITOR_LG,
   PRDCR_NO)
  SELECT B.FURNACENO,
         ? SEQUENCENO,
         B.FURNACENO_SEQ,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         B.CAST_NO,
         B.CAST_SEQ,
         B.CAST_STOVE_SEQ,
         ? CCM_SEQ,
         B.STOVE_NO,
         ? JUDGE_STOVE_NO,
         ? JUDGE_STOVE_NO_SEQ,
        ? FLAG_STOVE_NO,
         A.STATUS,
         A.CCM_STATE,
         A.CCM_PLN_TYPE,
         A.GPTYPE,
         A.CASTINGTYPE,
         B.PLINE_CODE,
         B.PLINE_NAME,
         B. CCMID,
         FLOWNO,
         B.EF_PLINE_CODE,
         B.EF_PLINE_NAME,
         A.WLID_IN,
         A.WLDESC_IN,
         A.MATERIAL_NO,
         A.MATERIAL_NAME,
         A.GRADECODE,
         A.GRADENAME,
         DIAMETER,
         LEN_GP_SINGLE,
         CUT_NUM_GP,
         LENGTH_M,
         WEIGHT_GP_ONE,
         WEIGHT_M,
         ? TOT_MUM_M,
         ? TOT_WEIGHT_M,
         ACT_WEIGHT_M,
         ACT_MUM_M,
         A.SURPLUSFLAG,
         EXCESS_WT,
         EXCESS_NUM,
         SURPLUS_TYPE,
         IF_SURPLUS_ALLOTED,
         A.CIC,
         A.PIC,
         A.SIC,
         A.DIC,
         A.CHEM_JUDGE_ID,
         A.PHY_JUDGE_ID,
         A.COLLIGATE_JUDGE_ID,
         MEMO,
         A.MAKEMAN,
         A.MAKETIME,
         A.DOWNMAN,
         A.DOWNTIME,
         B.PRO_MONTH,
         ORDER_NO,
         FINAL_USER_DESC,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
         GOWHERE_CODE,
         GOWHERE_NAME,
         ISENDGX,
         STATE_LK,
   A.IF_MONITOR_LG,
   A.PRDCR_NO
    FROM PLN_STEELFOR_ORD A
    LEFT JOIN PLN_STEELFORFURNACE B
      ON B.FURNACENO = ?
   WHERE A.FURNACENO = ?
         AND A.SEQUENCENO = ?

	]]>
	</query>


	<query id="FrmSteelManagement.ChangeHandOverOrderPlan" desc="">
		<![CDATA[
  UPDATE PLN_STEELFOR_ORD
     SET (SEQUENCENO,CUT_NUM) =
         (SELECT NVL(MAX(SEQUENCENO), 0) + 1,  NVL(MAX(CUT),0) +1
            FROM PLN_STEELFOR_ORD
           WHERE FURNACENO = ? AND SEQUENCENO<>99),
         (FURNACENO,
          FURNACENO_SEQ,
          CAST_NO,
          CAST_SEQ,
          CAST_STOVE_SEQ,
          STOVE_NO,
          EF_PLINE_CODE,
          EF_PLINE_NAME) =
         (SELECT
               FURNACENO,
                FURNACENO_SEQ,
                 CAST_NO,
                 CAST_SEQ,
                 CAST_STOVE_SEQ,
                 STOVE_NO,
                 EF_PLINE_CODE,
                 EF_PLINE_NAME
            FROM PLN_STEELFORFURNACE
           WHERE FURNACENO = ?),
         CCM_SEQ = ?,
         JUDGE_STOVE_NO = ?,
           JUDGE_STOVE_NO_SEQ = ?,
         FLAG_STOVE_NO = ?
   WHERE FURNACENO = ?
         AND SEQUENCENO = ?
	]]>
	</query>






	<query id="FrmSteelManagement.UpdatePlnSteelforfurnaceEntityStatus" desc="更改炉次表状态">
		<![CDATA[
                   UPDATE PLN_STEELFORFURNACE
     SET STATUS = ? ,
      DOWNMAN = ? , DOWNTIME = SYSDATE
   WHERE CAST_NO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.ClosePlnSteelforfurnaceEntity" desc="关闭炉次表">
		<![CDATA[
                   UPDATE PLN_STEELFORFURNACE
     SET STATUS = '40' ,
	CLOSEMAN = ? , CLOSETIME = SYSDATE
   WHERE FURNACENO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.AbolishPlnSteelforfurnaceEntity" desc="废除炉次表">
		<![CDATA[
                   UPDATE PLN_STEELFORFURNACE
     SET BOF_TYPE = '05'
   WHERE FURNACENO =?
	]]>
	</query>


	<query id="FrmSteelManagement.HandOverFurnace" desc="更改转交炉计划">
		<![CDATA[
                   UPDATE PLN_STEELFORFURNACE
     SET CAST_NO=?,
          CAST_SEQ=?,
          FURNACENO_SEQ=?,
          CAST_STOVE_SEQ=?,
          EF_PLINE_CODE=?,
          EF_PLINE_NAME=?,
      STATUS =?,
     BOF_TYPE=?,
     STOVE_NO=?,
     OLD_STOVE_NO=?,
     PLN_STARTTIME=TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     PLN_ENDTIME=TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     HEAT_STATE=?,
     FACT_ROUTE=?,
     STARTTIME=TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     ENDTIME=TO_DATE(?, 'yyyy-mm-dd hh24-mi-ss'),
     PRO_MONTH=?
   WHERE FURNACENO =?
	]]>
	</query>

	<query id="FrmSteelManagement.DeleteFurnacePlan" desc="删除炉计划">
		<![CDATA[
                Delete from PLN_STEELFORFURNACE where  FURNACENO =?
	]]>
	</query>


	<query id="FrmSteelManagement.HandOverOrder" desc="更改转交铸造计划">
		<![CDATA[
                   UPDATE PLN_STEELFOR_ORD
      SET  STOVE_NO=?,
      JUDGE_STOVE_NO=?,
      JUDGE_STOVE_NO_SEQ=?,
      FLAG_STOVE_NO=?
   WHERE FURNACENO = ?
   AND SEQUENCENO=?
	]]>
	</query>

	<query id="FrmSteelManagement.ChangeOrderFurnaceNo" desc="更改铸造计划">
		<![CDATA[
            	UPDATE PLN_STEELFOR_ORD
	SET FURNACENO = ? , SEQUENCENO = ?
	WHERE FURNACENO = ?
	AND SEQUENCENO = ?
	]]>
	</query>





	<query id="FrmSteelManagement.UpdatePlnSteelforfurnaceEntityStatusByFurnaceNo" desc="更改炉次表状态">
		<![CDATA[
		 UPDATE PLN_STEELFORFURNACE
		SET STATUS   = ?,
        STOVE_NO = ?,
        DOWNMAN  = ?,
        DOWNTIME = SYSDATE
  WHERE FURNACENO = ?
	]]>
	</query>


	<query id="FrmSteelManagement.UpdatePlnPlnSteelforOrdEntityStatus" desc="更改订单表状态">
		<![CDATA[
                  UPDATE PLN_STEELFOR_ORD
     SET STATUS = ? ,
      DOWNMAN = ? , DOWNTIME = SYSDATE
   WHERE CAST_NO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdatePlnPlnSteelforOrdEntityStatusByFurnaceNo" desc="更改订单表状态">
		<![CDATA[
          UPDATE PLN_STEELFOR_ORD A
      SET (STATUS, STOVE_NO, DOWNMAN, DOWNTIME) =
          (SELECT STATUS, STOVE_NO, DOWNMAN, DOWNTIME
             FROM PLN_STEELFORFURNACE
            WHERE FURNACENO = A.FURNACENO)
    WHERE FURNACENO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdatePlnPlnSteelforOrdEntityStatusAndJudge" desc="更改订单表状态">
		<![CDATA[
        	UPDATE PLN_STEELFOR_ORD A
	SET (STATUS, STOVE_NO, DOWNMAN, DOWNTIME) =
	(SELECT STATUS, STOVE_NO, DOWNMAN, DOWNTIME
	FROM PLN_STEELFORFURNACE
	WHERE FURNACENO = A.FURNACENO),
	FLAG_STOVE_NO = ?,
	JUDGE_STOVE_NO = ?,
	JUDGE_STOVE_NO_SEQ=?
	WHERE FURNACENO = ? AND
	SEQUENCENO =?
	]]>
	</query>


	<query id="FrmSteelManagement.SelectPlnSteelforfurnaceEntity" desc="查询炉计划信息表">
		<![CDATA[
 SELECT A.*,
        B.QUANTITYSUM,
        B.WEIGHTSUM,
        C.CIC_GID,
        A.STARTTIME + 18/24 plan_Judge_Time,
        D.DIAMETER,
        (SELECT MAX(CCM_STATE) FROM PLN_STEELFOR_ORD WHERE FURNACENO = A.FURNACENO) CCM_STATE,
		(SELECT DISTINCT
			(PRDCR_ADVC_DAY || '','' || PRDCR_MAN || '','' || PRDCR_MAN_PHONE)
		FROM
			SLM_ORDER_LINE_PRDCR T
			LEFT JOIN SLM_ORDER_LINE_PRDCR_LST S ON T.PRDCR_NO = S.PRDCR_NO
			AND T.PRDCR_INDEX = S.PRDCR_INDEX
		WHERE
			S.PROCESS_CODE IN ( ''A'', ''B'' )
			AND T.PRDCR_NO = A.PRDCR_NO
			AND T.CODE_JG IS NULL
			AND T.CODE_BL IS NULL
			AND ROWNUM = 1
		) PRDCR_DAY_MAN_PHONE
   FROM PLN_STEELFORFURNACE A
   LEFT JOIN (SELECT FURNACENO,
                     SUM(TOT_MUM_M) QUANTITYSUM,
                     SUM(TOT_WEIGHT_M) WEIGHTSUM,
                     MAX(DIAMETER) DIAMETER
                FROM PLN_STEELFOR_ORD
               WHERE SURPLUSFLAG = '0'
               GROUP BY FURNACENO) B
     ON A.FURNACENO = B.FURNACENO
   LEFT JOIN CRAFT_LG2_M C
     ON C.CRAFT_NO = A.CRAFT_NO
   LEFT JOIN PLN_STEELFORCAST D
     ON D.CAST_NO = A.CAST_NO
  WHERE 1 = 1 {0}
  ORDER BY A.EF_PLINE_CODE, A.FURNACENO_SEQ
                            ]]>
	</query>



	<query id="FrmSteelManagement.SelectPlnSteelforOrdEntity" desc="查询炉订单信息表">
		<![CDATA[
SELECT T.IS_NOTICE_USER,
       TO_CHAR(T.IS_NOTICE_TIME, 'YYYY-MM-DD HH24:MI:SS') IS_NOTICE_TIME,
       DECODE(T.IS_NOTICE_EP,'0','未通知','1','已通知','未通知')IS_NOTICE_EP,
       T.OLD_CIC,
       T.TOT_MUM_M,
       T.TOT_WEIGHT_M,
       T.ACT_WEIGHT_M,
       T.ACT_MUM_M,
       T.SURPLUSFLAG,
       T.EXCESS_WT,
       T.EXCESS_NUM,
       T.SURPLUS_TYPE,
       T.IF_SURPLUS_ALLOTED,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.CHEM_JUDGE_ID,
       T.PHY_JUDGE_ID,
       T.COLLIGATE_JUDGE_ID,
       T.MEMO,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.PRO_MONTH,
       T.IF_MONITOR_LG,
       T.ORDER_NO,
       T.PRDCR_NO,
       T.MERGE_NO,
       T.STEELCODE,
       T.STEELNAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       T.PDEPT_NAME,
       T.FINAL_USER_DESC,
       T.ISENDGX,
       T.STATE_LK,
       T.PRDCR_MAN,
       T.CUT_NUM,
       T.FURNACENO,
       T.SEQUENCENO,
       T.FURNACENO_SEQ,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.CAST_NO,
       T.CAST_SEQ,
       T.CAST_STOVE_SEQ,
       T.CCM_SEQ,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.JUDGE_STOVE_NO_SEQ,
       T.FLAG_STOVE_NO,
       T.STATUS,
       T.CCM_STATE,
       T.CCM_PLN_TYPE,
       T.GPTYPE,
       T.CASTINGTYPE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CCMID,
       T.FLOWNO,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.DIAMETER,
       T.LEN_GP_SINGLE,
       T.CUT_NUM_GP,
       T.LENGTH_M,
       T.WEIGHT_GP_ONE,
       T.WEIGHT_M,
       T2.PDEPT_NAME,
       T2.PRDCR_MAN,
       T2.PRDCR_NO,
       T3.PLN_STARTTIME,
          GET_ONHFLAG(T.PRO_PLAN_ID,T.CIC, T.MERGE_NO) COLLIGATE_JUDGE_ID
  FROM PLN_STEELFOR_ORD T
  LEFT JOIN (SELECT MAX(J.PDEPT_NAME) PDEPT_NAME,
                    MAX(J.PRDCR_MAN) PRDCR_MAN,
                    Z.PRDCR_NO,
                    C.PRO_PLAN_ID
               FROM SLM_ORDER_LINE_PRDCR_LST J,
                    PLN_STEELFOR_ORD         C,
                    PLN_ORDER_CAST_S         Z
              WHERE J.PRDCR_NO = Z.PRDCR_NO
                    AND Z.PRO_PLAN_ID = C.PRO_PLAN_ID
                    AND J.PROCESS_CODE = 'A'
                    AND J.PROCESS_CODE_C = 'B001'
              GROUP BY Z.PRDCR_NO, C.PRO_PLAN_ID) T2
    ON T.PRO_PLAN_ID = T2.PRO_PLAN_ID
    LEFT JOIN PLN_STEELFORFURNACE T3 ON  T3.FURNACENO = T.FURNACENO
  WHERE CCM_PLN_TYPE='00' {0}
 ORDER BY T.PLINE_CODE, T.CAST_SEQ, T.CCM_SEQ, T.FURNACENO_SEQ
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectPlnSteelforOrdEntityPlus" desc="查询炉订单信息表">
		<![CDATA[
SELECT *
  FROM PLN_STEELFOR_ORD A
  LEFT JOIN (SELECT DISTINCT ORD_LN_DLY_PK,
                             CRAFT_SEQ CRAFT_SEQ,
                             GPREQ_ID,
                             RANK() OVER(PARTITION BY GPREQ_ID ORDER BY ORD_LN_DLY_PK) RK
               FROM PLN_ORDER_ZG_S) B
    ON A.PRO_PLAN_ID = B.GPREQ_ID
       AND B.RK = 1
  LEFT JOIN PLN_SALEORD C
    ON C.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
  LEFT JOIN CRAFT_ORD_DESIGN D
    ON D.CRAFT_SEQ = B.CRAFT_SEQ
       AND D.ORD_LN_PK = C.ORD_LN_PK
 WHERE A.FURNACENO = ?
                            ]]>
	</query>


	<query id="FrmSteelManagement.SelectPlnSteelforMergeEntity" desc="查询订单合并信息">
		<![CDATA[
SELECT *
  FROM PLN_STEELFOR_MERGE  WHERE 1=1 {0}
  ORDER BY MERGE_SEQ
                            ]]>
	</query>


	<query id="FrmSteelManagement.SelectMinFurnaceSeq" desc="查询最小炉次顺序号">
		<![CDATA[
                    SELECT NVL(MIN(FURNACENO_SEQ), 1) FURNACENO_SEQ,
           NVL(MIN(PLN_STARTTIME), SYSDATE) PLN_STARTTIME,
             NVL(MIN(STOVE_NO), '') STOVE_NO
      FROM PLN_STEELFORFURNACE
     WHERE FURNACENO_SEQ IS NOT NULL
           AND CAST_NO IN (SELECT CAST_NO
                             FROM PLN_STEELFORCAST
                            WHERE CAST_SEQ >= ?
                                  AND PLINE_CODE = ?)
           AND EF_PLINE_CODE = ?

                            ]]>
	</query>


	<query id="FrmSteelManagement.SelectMinStove" desc="查询最小炉次顺序号">
		<![CDATA[
                    SELECT
             NVL(MIN(STOVE_NO), '') STOVE_NO
      FROM PLN_STEELFORFURNACE
     WHERE FURNACENO_SEQ IS NOT NULL
           AND CAST_NO IN (SELECT CAST_NO
                             FROM PLN_STEELFORCAST
                            WHERE CAST_SEQ >= ?
                                  AND PLINE_CODE = ?)
                            ]]>
	</query>



	<query id="FrmSteelManagement.SelectMinStoveByFurnaceSeq" desc="查询最小炉次顺序号">
		<![CDATA[
                    SELECT
             NVL(MIN(STOVE_NO), '') STOVE_NO
      FROM PLN_STEELFORFURNACE
     WHERE FURNACENO IN
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectMinStartDateByFurnaceSeq" desc="查询最小炉次顺序号">
		<![CDATA[
                    SELECT
              MIN(PLN_STARTTIME) PLN_STARTTIME,
              NVL(MIN(FURNACENO_SEQ), 1) FURNACENO_SEQ
      FROM PLN_STEELFORFURNACE
     WHERE EF_PLINE_CODE= @Line
      AND FURNACENO IN
                            ]]>
	</query>


	<query id="FrmSteelManagement.SelectMinCCMSeqByLine" desc="查询最小铸机序号">
		<![CDATA[
                    SELECT MIN(CCM_SEQ) CCM_SEQ,
                    MIN(CAST_SEQ) CAST_SEQ
      FROM PLN_STEELFOR_ORD
     WHERE PLINE_CODE= @Line
      AND FURNACENO IN
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectPlnSteelforOrdEntityByLineAndCastSeq" desc="查询最小铸机序号">
		<![CDATA[
                  SELECT  NVL(MAX(CCM_SEQ),0)   CCM_SEQ
                   FROM PLN_STEELFOR_ORD
                    WHERE   CAST_SEQ <? AND
                     CCM_SEQ IS NOT NULL AND
                    PLINE_CODE = ?
                            ]]>
	</query>


	<query id="FrmSteelManagement.SelectMinJudgeStove" desc="查询最小判定炉号">
	<![CDATA[
                 SELECT   NVL(MIN(JUDGE_STOVE_NO),'')   JUDGE_STOVE_NO
                   FROM PLN_STEELFOR_ORD
                    WHERE   CAST_SEQ >=? AND
                   JUDGE_STOVE_NO LIKE TO_CHAR(SYSDATE,'YY') || '____' AND
                    PLINE_CODE = ?
                            ]]>
</query>


	<query id="FrmSteelManagement.SelectMinJudgeStove2" desc="查询最小判定炉号">
		<![CDATA[
                 SELECT   NVL(MIN(JUDGE_STOVE_NO),'')   JUDGE_STOVE_NO
                   FROM PLN_STEELFOR_ORD
                    WHERE   CCM_SEQ >=? AND
                   JUDGE_STOVE_NO LIKE TO_CHAR(SYSDATE,'YY') || '____' AND
                    PLINE_CODE = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectLastOrder" desc="查询最后一个订单计划">
		<![CDATA[
SELECT *
  FROM PLN_STEELFOR_ORD A
 WHERE FURNACENO = ?
       AND SEQUENCENO = (SELECT MAX(SEQUENCENO)
                           FROM PLN_STEELFOR_ORD
                          WHERE FURNACENO = A.FURNACENO
                                 AND (SURPLUS_TYPE IS NULL OR (SURPLUS_TYPE != 3 AND SURPLUS_TYPE != 2)))
                            ]]>
	</query>






	<query id="FrmSteelManagement.SelectJudgeStove" desc="查询判定炉号">
		<![CDATA[

	SELECT  DISTINCT JUDGE_STOVE_NO FROM  PLN_STEELFOR_ORD  WHERE
	 JUDGE_STOVE_NO IS NOT NULL   AND
	  JUDGE_STOVE_NO LIKE TO_CHAR(SYSDATE,'YY') || '____' AND
	 FURNACENO=?
	 ORDER BY JUDGE_STOVE_NO
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectMinJudgeStove1" desc="查询最小判定炉号">
		<![CDATA[
                 SELECT   NVL(MIN(JUDGE_STOVE_NO),'')   JUDGE_STOVE_NO
                   FROM PLN_STEELFOR_ORD
                    WHERE   CAST_SEQ =? AND
                   JUDGE_STOVE_NO LIKE TO_CHAR(SYSDATE,'YY') || '____' AND
                    PLINE_CODE = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectMinJudgeStoveByFurnace" desc="查询最小判定炉号">
		<![CDATA[
   SELECT   NVL(MIN(JUDGE_STOVE_NO),'')   JUDGE_STOVE_NO
                   FROM PLN_STEELFOR_ORD
                    WHERE   FURNACENO IN
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectPlnSteelforOrdEntityByCastAndCastStoveSeq" desc="查询最小铸机序号">
		<![CDATA[
                  SELECT NVL(MAX(CCM_SEQ),0)  CCM_SEQ FROM PLN_STEELFOR_ORD
                    WHERE   CAST_STOVE_SEQ <? AND
                    CCM_SEQ IS NOT NULL AND
                    CAST_NO = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectDistinctLenGpSingle" desc="查询最小铸机序号">
		<![CDATA[
              SELECT DISTINCT (LEN_GP_SINGLE)
  FROM PLN_STEELFOR_ORD
 WHERE FURNACENO = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectPlnSteelforOrdEntityByCast" desc="查询最小铸机序号">
		<![CDATA[
                               SELECT NVL(MAX(CCM_SEQ), 0)  CCM_SEQ
                      FROM PLN_STEELFOR_ORD
                     WHERE CAST_SEQ <
                           (SELECT CAST_SEQ
                              FROM PLN_STEELFORCAST
                             WHERE CAST_NO = ?)
                           AND CCM_SEQ IS NOT NULL
                           AND PLINE_CODE =
                           (SELECT PLINE_CODE
                                  FROM PLN_STEELFORCAST
                                 WHERE CAST_NO = ?)

                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectMaxFurnacenoSeqByCast" desc="查浇次内最大的炉次顺序号">
		<![CDATA[
                        SELECT NVL(MAX(FURNACENO_SEQ), 0) FURNACENO_SEQ,
       NVL(MAX(PLN_ENDTIME), SYSDATE) PLN_ENDTIME
  FROM PLN_STEELFORFURNACE A
 WHERE FURNACENO NOT IN
       (SELECT FURNACENO
          FROM PLN_STEELFOR_ORD
         WHERE (SURPLUS_TYPE = 3 )
               AND FURNACENO = A.FURNACENO)
       AND EF_PLINE_CODE = ?
       AND CAST_NO = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectMinFurnacenoSeqByCast" desc="查浇次内最大的炉次顺序号">
		<![CDATA[
                        SELECT NVL(MIN(FURNACENO_SEQ), 0) FURNACENO_SEQ
  FROM PLN_STEELFORFURNACE A
 WHERE  EF_PLINE_CODE = ?
       AND CAST_NO = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.SelectMaxCastStoveSeqByCast" desc="查浇次内最大的炉内顺序号">
		<![CDATA[
                           SELECT NVL(MAX(CAST_STOVE_SEQ),0) CAST_STOVE_SEQ
  FROM PLN_STEELFORFURNACE A
 WHERE  FURNACENO  NOT IN (SELECT FURNACENO FROM PLN_STEELFOR_ORD WHERE (SURPLUS_TYPE = 3) AND   FURNACENO= A.FURNACENO)
     AND CAST_NO = ?

                            ]]>
	</query>


	<query id="FrmSteelManagement.UpdateFurnaceSeq1" desc="更新炉次顺序号">
	<![CDATA[
                         UPDATE PLN_STEELFORFURNACE
   SET FURNACENO_SEQ = FURNACENO_SEQ + 1,
        CAST_STOVE_SEQ  = CAST_STOVE_SEQ+DECODE(CAST_NO,?,1,0),
        PLN_STARTTIME= PLN_STARTTIME+?/24/60,
        PLN_ENDTIME = PLN_ENDTIME+?/24/60
 WHERE FURNACENO =?
                            ]]>
</query>

	<query id="FrmSteelManagement.UpdateFurnaceSeq2" desc="更新炉次顺序号">
		<![CDATA[
                       UPDATE PLN_STEELFOR_ORD
	SET FURNACENO_SEQ = FURNACENO_SEQ + 1
	WHERE FURNACENO = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.NewFurnace" desc="新炉次号">
		<![CDATA[
  SELECT ? ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(FURNACENO, LENGTH(FURNACENO) - 1))),
                  0) + 1,
              2,
              '0') FURNACENO
    FROM PLN_STEELFORFURNACE
   WHERE FURNACENO LIKE ? || '__'

                            ]]>
	</query>

	<query id="FrmSteelManagement.NewCastNo" desc="新浇次号">
		<![CDATA[

      SELECT 'JC' || ? || TO_CHAR(SYSDATE, 'YYMM') ||
             LPAD(NVL(MIN(TO_NUMBER(SUBSTR(CAST_NO, LENGTH(CAST_NO) - 2))),
                      0) + 1,
                  3,
                  '0') CAST_NO
        FROM PLN_STEELFORCAST
       WHERE TO_NUMBER(SUBSTR(CAST_NO, LENGTH(CAST_NO) - 2)) + 1 NOT IN
             (SELECT TO_NUMBER(SUBSTR(CAST_NO, LENGTH(CAST_NO) - 2))
                FROM PLN_STEELFORCAST
               WHERE CAST_NO LIKE
                     'JC' || ? || TO_CHAR(SYSDATE, 'YYMM') || '___')
             AND CAST_NO LIKE
             'JC' || ? || TO_CHAR(SYSDATE, 'YYMM') || '___'

                            ]]>
	</query>

	<query id="FrmSteelManagement.GetWeightPerMeterFormula" desc="获取米单重公式">
		<![CDATA[
                      SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = '405202'
                            ]]>
	</query>

	<query id="FrmSteelManagement.SaveSupplementOrder" desc="修改补炉订单">
		<![CDATA[

UPDATE PLN_STEELFOR_ORD
   SET LEN_GP_SINGLE = ?,
       CUT_NUM_GP    = ?,
       LENGTH_M      = ?,
       WEIGHT_GP_ONE = ?,
       WEIGHT_M      = ?,
       TOT_MUM_M     = ?,
       TOT_WEIGHT_M  = ?,
       GOWHERE_CODE =?,
       GOWHERE_NAME = DECODE(?,'','离线库',(SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE=?))
 WHERE FURNACENO = ?
       AND SEQUENCENO = ?
                            ]]>
	</query>

	<query id="FrmSteelManagement.UpdateResmeltOrder" desc="更改重炼原订单表,清空合同信息">
		<![CDATA[
   UPDATE PLN_STEELFOR_ORD T
   SET PRO_PLAN_ID     = DECODE(T.MERGE_NO,
                                NULL,
                                T.PRO_PLAN_ID,
                                (SELECT PRO_PLAN_ID
                                   FROM PLN_STEELFOR_MERGE
                                  WHERE MERGE_NO = T.MERGE_NO
                                    AND ROWNUM = 1)),
       GX_PLAN_NO      = DECODE(T.MERGE_NO,
                                NULL,
                                T.GX_PLAN_NO,
                                (SELECT GX_PLAN_NO
                                   FROM PLN_STEELFOR_MERGE
                                  WHERE MERGE_NO = T.MERGE_NO
                                    AND ROWNUM = 1)),
       SURPLUSFLAG     = '1',
       SURPLUS_TYPE    = '7',
       ORDER_NO        =?,
       FINAL_USER_DESC = '备料',
       STEELCODE       = '',
       STEELNAME       = '',
       PRODUCCODE      = '',
       PRODUCNAME      = '',
       GOWHERE_CODE    = '',
       GOWHERE_NAME    = '离线库',
       PRDCR_NO        = '',
       MERGE_NO        = '',
       STATE_LK        = '0',
       PDEPT_NAME      = '',
       PRDCR_MAN       = '',
       CIC             = DECODE(T.MERGE_NO,
                                NULL,
                                T.CIC,
                                (SELECT CIC
                                   FROM PLN_STEELFOR_MERGE
                                  WHERE MERGE_NO = T.MERGE_NO
                                    AND ROWNUM = 1)),
       PIC             = DECODE(T.MERGE_NO,
                                NULL,
                                T.PIC,
                                (SELECT PIC
                                   FROM PLN_STEELFOR_MERGE
                                  WHERE MERGE_NO = T.MERGE_NO
                                    AND ROWNUM = 1)),
       DIC             = DECODE(T.MERGE_NO,
                                NULL,
                                T.DIC,
                                (SELECT DIC
                                   FROM PLN_STEELFOR_MERGE
                                  WHERE MERGE_NO = T.MERGE_NO
                                    AND ROWNUM = 1)),
       SIC             = DECODE(T.MERGE_NO,
                                NULL,
                                T.SIC,
                                (SELECT SIC
                                   FROM PLN_STEELFOR_MERGE
                                  WHERE MERGE_NO = T.MERGE_NO
                                    AND ROWNUM = 1))
 WHERE T.FURNACENO = ?
   AND T.SEQUENCENO = ?


	]]>
	</query>


	<query id="FrmSteelManagement.InsertResmeltOrder" desc="增加重炼的订单表">
		<![CDATA[
INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   CCM_STATE,
   CCM_PLN_TYPE,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   EXCESS_WT,
   EXCESS_NUM,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   PRO_MONTH,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   ISENDGX)

  SELECT B.FURNACENO,
         SEQUENCENO,
         B.FURNACENO_SEQ,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         B.CAST_NO,
         B.CAST_SEQ,
         B.CAST_STOVE_SEQ,
         ? CCM_SEQ,
         B.STOVE_NO,
         ? JUDGE_STOVE_NO,
         ? JUDGE_STOVE_NO_SEQ,
         ? FLAG_STOVE_NO,
         B.STATUS,
         B.CCM_STATE,
         CCM_PLN_TYPE,
         GPTYPE,
         CASTINGTYPE,
         PLINE_CODE,
         PLINE_NAME,
         CCMID,
         FLOWNO,
         ? EF_PLINE_CODE,
         ? EF_PLINE_NAME,
         WLID_IN,
         WLDESC_IN,
         MATERIAL_NO,
         MATERIAL_NAME,
         GRADECODE,
         GRADENAME,
         DIAMETER,
         LEN_GP_SINGLE,
         CUT_NUM_GP,
         LENGTH_M,
         WEIGHT_GP_ONE,
         WEIGHT_M,
         TOT_MUM_M,
         TOT_WEIGHT_M,
         ACT_WEIGHT_M,
         ACT_MUM_M,
         SURPLUSFLAG,
         EXCESS_WT,
         EXCESS_NUM,
         SURPLUS_TYPE,
         IF_SURPLUS_ALLOTED,
         CIC,
         PIC,
         SIC,
         DIC,
         CHEM_JUDGE_ID,
         PHY_JUDGE_ID,
         COLLIGATE_JUDGE_ID,
         MEMO,
         B.MAKEMAN,
         B.MAKETIME,
         B.DOWNMAN,
         B.DOWNTIME,
         PRO_MONTH,
         ORDER_NO,
         FINAL_USER_DESC,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
         GOWHERE_CODE,
         GOWHERE_NAME,
         ISENDGX
    FROM PLN_STEELFOR_ORD A
    LEFT JOIN (SELECT FURNACENO,
                      FURNACENO_SEQ,
                      CAST_NO,
                      CAST_SEQ,
                      CAST_STOVE_SEQ,
                      STOVE_NO,
                      STATUS,
                      MAKEMAN,
                      MAKETIME,
                      DOWNMAN,
                      DOWNTIME,
                      '00' CCM_STATE
                 FROM PLN_STEELFORFURNACE
                WHERE FURNACENO = ?) B
      ON 1 = 1
   WHERE A.FURNACENO = ?
         AND A.SEQUENCENO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.InsertNoneOrderPlan" desc="增加余材订单表">
		<![CDATA[
INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   CCM_STATE,
   CCM_PLN_TYPE,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   EXCESS_WT,
   EXCESS_NUM,
   PRO_MONTH,
   ISENDGX,
   STATE_LK,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   IF_MONITOR_LG,
   PRDCR_NO,
   MERGE_NO,
   PDEPT_NAME,
   PRDCR_MAN)
  SELECT ? FURNACENO,
         ? SEQUENCENO,
         FURNACENO_SEQ,
          PRO_PLAN_ID,
          GX_PLAN_NO,
         CAST_NO,
         CAST_SEQ,
         CAST_STOVE_SEQ,
        ? CCM_SEQ,
         STOVE_NO,
        ? JUDGE_STOVE_NO,
        ? JUDGE_STOVE_NO_SEQ,
        ? FLAG_STOVE_NO,
         STATUS,
         CCM_STATE,
         CCM_PLN_TYPE,
         GPTYPE,
         CASTINGTYPE,
         PLINE_CODE,
         PLINE_NAME,
         CCMID,
         FLOWNO,
         EF_PLINE_CODE,
         EF_PLINE_NAME,
         WLID_IN,
         WLDESC_IN,
         MATERIAL_NO,
         MATERIAL_NAME,
         GRADECODE,
         GRADENAME,
         DIAMETER,
         LEN_GP_SINGLE,
         CUT_NUM_GP,
         LENGTH_M,
         WEIGHT_GP_ONE,
         WEIGHT_M,
        ?  TOT_MUM_M,
        ?*WEIGHT_M  TOT_WEIGHT_M,
         ACT_WEIGHT_M,
         ACT_MUM_M,
        '1' SURPLUSFLAG,
         ? SURPLUS_TYPE,
         IF_SURPLUS_ALLOTED,
         CIC,
         PIC,
         SIC,
         DIC,
         MEMO,
         MAKEMAN,
         MAKETIME,
         DOWNMAN,
         DOWNTIME,
         CHEM_JUDGE_ID,
         PHY_JUDGE_ID,
         COLLIGATE_JUDGE_ID,
         EXCESS_WT,
         EXCESS_NUM,
         PRO_MONTH,
         ISENDGX,
         STATE_LK,
       ''  ORDER_NO,
       ''  FINAL_USER_DESC,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
        '' GOWHERE_CODE,
        '离线库' GOWHERE_NAME,
         IF_MONITOR_LG,
         PRDCR_NO,
         MERGE_NO,
         PDEPT_NAME,
         PRDCR_MAN
    FROM PLN_STEELFOR_ORD
   WHERE FURNACENO = ?
         AND SEQUENCENO = ?
	]]>
	</query>


	<query id="FrmSteelManagement.InsertResmeltOrder1" desc="增加重炼的订单表">
		<![CDATA[
INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   ACT_WEIGHT_M,
   ACT_MUM_M,
   SURPLUSFLAG,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   MEMO,
   MAKEMAN,
   MAKETIME,
   DOWNMAN,
   DOWNTIME,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   EXCESS_WT,
   EXCESS_NUM,
   PRO_MONTH,
   ISENDGX,
   STATE_LK,
   ORDER_NO,
   FINAL_USER_DESC,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   GOWHERE_CODE,
   GOWHERE_NAME,
   IF_MONITOR_LG,
   PRDCR_NO,
   MERGE_NO,
   PDEPT_NAME,
   PRDCR_MAN,
   CUT_NUM)
  SELECT ? FURNACENO,
         ? SEQUENCENO,
         T.FURNACENO_SEQ,
       DECODE(T.MERGE_NO, NULL, T.PRO_PLAN_ID, T1.PRO_PLAN_ID),
            DECODE(T.MERGE_NO, NULL, T.GX_PLAN_NO, T1.GX_PLAN_NO),
         T.CAST_NO,
         T.CAST_SEQ,
         T.CAST_STOVE_SEQ,
         T.CCM_SEQ,
         ? STOVE_NO,
         ? JUDGE_STOVE_NO,
         ? JUDGE_STOVE_NO_SEQ,
         ? FLAG_STOVE_NO,
          DECODE(T.STATUS,'00','00','10'),
         T.GPTYPE,
         T.CASTINGTYPE,
         T.PLINE_CODE,
         T.PLINE_NAME,
         T.CCMID,
         T.FLOWNO,
         T.EF_PLINE_CODE,
         T.EF_PLINE_NAME,
         T.WLID_IN,
         T.WLDESC_IN,
         T.MATERIAL_NO,
         T.MATERIAL_NAME,
         T.GRADECODE,
         T.GRADENAME,
         T.DIAMETER,
         T.LEN_GP_SINGLE,
         T.CUT_NUM_GP,
         T.LENGTH_M,
         T.WEIGHT_GP_ONE,
         T.WEIGHT_M,
         T.TOT_MUM_M,
         T.TOT_WEIGHT_M,
         T.ACT_WEIGHT_M,
         T.ACT_MUM_M,
        '1' SURPLUSFLAG,
        '7' SURPLUS_TYPE,
         T.IF_SURPLUS_ALLOTED,
           DECODE(T.MERGE_NO, NULL, T.CIC, T1.CIC),
            DECODE(T.MERGE_NO, NULL, T.PIC, T1.PIC),
            DECODE(T.MERGE_NO, NULL, T.SIC, T1.SIC),
            DECODE(T.MERGE_NO, NULL, T.DIC, T1.DIC),
         T.MEMO,
         T.MAKEMAN,
         T.MAKETIME,
         T.DOWNMAN,
         T.DOWNTIME,
         T.CHEM_JUDGE_ID,
         T.PHY_JUDGE_ID,
         T.COLLIGATE_JUDGE_ID,
         T.EXCESS_WT,
         T.EXCESS_NUM,
         T.PRO_MONTH,
         T.ISENDGX,
         '0' STATE_LK,
         ? ORDER_NO,
         '备料' FINAL_USER_DESC,
         '' STEELCODE,
        '' STEELNAME,
        '' PRODUCCODE,
        '' PRODUCNAME,
        '' GOWHERE_CODE,
        '离线库' GOWHERE_NAME,
         T.IF_MONITOR_LG,
         '' PRDCR_NO,
         '' MERGE_NO,
         '' PDEPT_NAME,
         '' PRDCR_MAN,
         '1'
    FROM PLN_STEELFOR_ORD T
     LEFT JOIN (SELECT T2.*,
                         RANK() OVER(PARTITION BY MERGE_NO ORDER BY MERGE_SEQ DESC) RK
                    FROM PLN_STEELFOR_MERGE T2) T1
         ON T1.MERGE_NO = T.MERGE_NO
        AND RK = 1
   WHERE T.FURNACENO = ? AND T.SEQUENCENO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.InsertSupplementStoveOrder" desc="增加铸造订单表数据">
		<![CDATA[
INSERT INTO PLN_STEELFOR_ORD
  (FURNACENO,
   SEQUENCENO,
   FURNACENO_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   CCM_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   JUDGE_STOVE_NO_SEQ,
   FLAG_STOVE_NO,
   STATUS,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   FLOWNO,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   DIAMETER,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   LENGTH_M,
   WEIGHT_GP_ONE,
   WEIGHT_M,
   TOT_MUM_M,
   TOT_WEIGHT_M,
   SURPLUSFLAG,
   SURPLUS_TYPE,
   IF_SURPLUS_ALLOTED,
   CIC,
   PIC,
   SIC,
   DIC,
   MEMO,
   MAKEMAN,
   MAKETIME,
   CHEM_JUDGE_ID,
   PHY_JUDGE_ID,
   COLLIGATE_JUDGE_ID,
   EXCESS_WT,
   EXCESS_NUM,
   PRO_MONTH)
  SELECT B.FURNACENO,
         ?,
         B.FURNACENO_SEQ,
         DECODE(?,'',A.PRO_PLAN_ID,?),
          DECODE(?,'',A.GX_PLAN_NO,?),
         B.CAST_NO,
         B.CAST_SEQ,
         B.CAST_STOVE_SEQ,
         ? CCM_SEQ,
         B.STOVE_NO,
         ? JUDGE_STOVE_NO,
         ? JUDGE_STOVE_NO_SEQ,
        DECODE(B.STOVE_NO,NULL,'','','', '1' || SUBSTR(B.STOVE_NO,LENGTH(B.STOVE_NO)-5))   FLAG_STOVE_NO,
        '10' STATUS,
         B.CASTINGTYPE,
         B.PLINE_CODE,
         B.PLINE_NAME,
         B.CCMID,
         A.FLOWNO,
         B.EF_PLINE_CODE,
         B.EF_PLINE_NAME,
         B.WLID_IN,
         B.WLDESC_IN,
         B.MATERIAL_NO,
         B.MATERIAL_NAME,
         B.GRADECODE,
         B.GRADENAME,
         A.DIAMETER,
         A.LEN_GP_SINGLE,
         A.CUT_NUM_GP,
         A.LENGTH_M,
         A.WEIGHT_GP_ONE,
          A.WEIGHT_M,
          DECODE(?,'',A.TOT_MUM_M,?),
          DECODE(?,'',A.TOT_WEIGHT_M,?),
         ? SURPLUSFLAG,
         ? SURPLUS_TYPE,
         '0' IF_SURPLUS_ALLOTED,
         A.CIC,
         A.PIC,
         A.SIC,
         A.DIC,
         A.MEMO,
         ? MAKEMAN,
         SYSDATE MAKETIME,
         A.CHEM_JUDGE_ID,
         A.PHY_JUDGE_ID,
         A.COLLIGATE_JUDGE_ID,
         A.EXCESS_WT,
         A.EXCESS_NUM,
         A.PRO_MONTH
    FROM (SELECT *
            FROM PLN_STEELFOR_ORD
           WHERE ROWNUM = 1
                 AND FURNACENO = ?) A,
         (SELECT * FROM PLN_STEELFORFURNACE WHERE FURNACENO = ?) B

	]]>
	</query>

	<query id="FrmSteelManagement.InsertNewFurnacePlan" desc="更加旧炉计划生成新的炉计划数据">
		<![CDATA[
                      INSERT INTO PLN_STEELFORFURNACE
  (FURNACENO,
   FURNACENO_SEQ,
   CAST_NO,
   CAST_SEQ,
   CAST_STOVE_SEQ,
   STOVE_NO,
   BOF_TYPE,
   STATUS,
   HEAT_STATE,
   CASTINGTYPE,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   EF_AGE,
   PLINE_CODE,
   PLINE_NAME,
   CCMID,
   WLID_IN,
   WLDESC_IN,
   MATERIAL_NO,
   MATERIAL_NAME,
   GRADECODE,
   GRADENAME,
   CIC,
   PLN_STARTTIME,
   PLN_ENDTIME,
   AIM_STEEL_QTY,
   QUANTITY,
   WEIGHT,
   OLD_FURNACENO,
   OLD_STOVE_NO,
   PLAN_ROUTE,
   STARTTIME,
   ENDTIME,
   BOF_STARTTIME,
   BOF_ENDTIME,
   CAS_STARTTIME,
   CAS_ENDTIME,
   VD_STARTTIME,
   VD_ENDTIME,
   RH_STARTTIME,
   RH_ENDTIME,
   LFS_STARTTIME,
   LFS_ENDTIME,
   CCM_STARTTIME,
   CCM_ENDTIME,
   SURPLUSFLAG,
   IF_MONITOR_LG,
   PRDCR_NO,
   CHEM_JUDGE_ID,
   PLANREMARK,
   REMARK,
   MAKEMAN,
   MAKETIME,
   PRO_MONTH,
   CRAFT_NO,
   CRAFT_PATH)
  SELECT ? FURNACENO,
         ? FURNACENO_SEQ,
         ? CAST_NO,
         ? CAST_SEQ,
         ? CAST_STOVE_SEQ,
         ? STOVE_NO,
         ? BOF_TYPE,
         ? STATUS,
         '00' HEAT_STATE,
         CASTINGTYPE,
         ? EF_PLINE_CODE,
         ? EF_PLINE_NAME,
         EF_AGE,
         PLINE_CODE,
         PLINE_NAME,
         CCMID,
         WLID_IN,
         WLDESC_IN,
         MATERIAL_NO,
         MATERIAL_NAME,
         GRADECODE,
         GRADENAME,
         CIC,
         TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') PLN_STARTTIME,
         TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') PLN_ENDTIME,
         AIM_STEEL_QTY,
         QUANTITY,
         WEIGHT,
        DECODE(?,'1',FURNACENO,'') OLD_FURNACENO,
         DECODE(?,'1',STOVE_NO,'') OLD_STOVE_NO,
         PLAN_ROUTE,
         null ,
         null ,
         BOF_STARTTIME,
         BOF_ENDTIME,
         CAS_STARTTIME,
         CAS_ENDTIME,
         VD_STARTTIME,
         VD_ENDTIME,
         RH_STARTTIME,
         RH_ENDTIME,
         LFS_STARTTIME,
         LFS_ENDTIME,
         CCM_STARTTIME,
         CCM_ENDTIME,
         SURPLUSFLAG,
         IF_MONITOR_LG,
         PRDCR_NO,
         CHEM_JUDGE_ID,
         PLANREMARK,
         REMARK,
         ? MAKEMAN,
         SYSDATE MAKETIME,
         PRO_MONTH,
         CRAFT_NO,
         CRAFT_PATH
    FROM PLN_STEELFORFURNACE T
   WHERE FURNACENO = ?

                            ]]>
	</query>




	<query id="FrmSteelManagement.SelectOrderCastS" desc="">
		<![CDATA[
          	SELECT *
	FROM PLN_ORDER_CAST_S
	WHERE PRO_PLAN_ID = ?
	AND GX_PLAN_NO = ?

	]]>
	</query>


	<query id="FrmSteelManagement.SelectOrderCastS1" desc="">
		<![CDATA[
          	SELECT *
	FROM PLN_ORDER_CAST_S
	WHERE 1=1
		AND PLANED_WT< PLAN_WT_MIN
	AND  PLAN_NUM_S>PLANED_NUM
	AND EXE_STATUS = 0
	 AND PRO_PLAN_ID = ?
	AND GX_PLAN_NO = ?
	]]>
	</query>

	<query id="FrmSteelManagement.UpdateOrderCastS" desc="">
		<![CDATA[
            UPDATE PLN_ORDER_CAST_S
     SET PLANED_NUM = NVL(PLANED_NUM, 0) + ?,
         PLANED_WT  = NVL(PLANED_WT, 0) + ?
   WHERE PRO_PLAN_ID = ?
         AND GX_PLAN_NO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.UpdateOrderCastS2" desc="">
		<![CDATA[
           UPDATE PLN_ORDER_CAST_S
     SET PLAN_WT_S = PLANED_WT,
         PLAN_NUM_S  = PLANED_NUM,
         PLAN_WT_MIN = PLAN_WT_MIN* PLANED_NUM/PLAN_NUM_S
   WHERE PRO_PLAN_ID = ?
         AND GX_PLAN_NO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.InsertOrderCastSByCopy" desc="">
		<![CDATA[
        INSERT INTO PLN_ORDER_CAST_S
  (PRO_PLAN_ID,
   GX_PLAN_NO,
   GPREQ_ID,
   GPTYPE,
   CASTINGTYPE,
   PLINE_CODE,
   PLINE_NAME,
   PLINE_CODE_A,
   PLINE_NAME_A,
   GRADECODE,
   GRADENAME,
   DIAMETER_LZ,
   LEN_GP_SINGLE,
   CUT_NUM_GP,
   CUT_LOSE_LEN,
   LENGTH_LZ,
   MATERIAL_NO,
   MATERIAL_NAME,
   WLID_IN,
   WLDESC_IN,
   CIC,
   PIC,
   SIC,
   DIC,
   WIC,
   GIC,
   IF_MONITOR_LG,
   PRDCR_NO,
   MONITOR_POINT,
   WT_CAST_ONE,
   PLAN_WT_S,
   PLAN_NUM_S,
   CAST_NUM_CALC,
   FURNACE_NUM_CALC,
   FURNACE_WT,
   GX_PRO_SEQ,
   PRO_MONTH,
   PLAN_USETIME,
   PLAN_TIME_B,
   PLAN_TIME_E,
   PLANED_WT,
   PLANED_NUM,
   FINISHWEIGHT,
   FINISH_NUM,
   EXE_STATUS,
   IS_REPAIR_PLN,
   REPAIR_TYPE,
   IS_PLAN_OK,
   CAST_NUM,
   FURNACE_NUM,
   ADD_WT_BEGIN,
   ADD_WT_END,
   IF_CONNECT_AHEAD,
   ADD_WT_AHEAD,
   IF_CONNECT_NEXT,
   ADD_WT_NEXT,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ISSUED_TIME,
   ISSUED_MAN,
   LAST_UNDOWN_TIME,
   LAST_UNDOWN_MAN,
   PROCESSING_COST_A,
   TOTAL_COST_A,
   PROCESSING_COST_B,
   TOTAL_COST_B,
   IF_CRAFT_LOCKED,
   CAST_NO_ALL,
   PROGY_MEMO,
   CRAFT_NO,
   CRAFT_PATH,
   IF_CONFIRM,
   PLAN_WT_MIN,
   GOWHERE_NAME,
   GOWHERE_CODE,
   STEEL_JUDGEMENT,
   PLAN_WT_SOLD,
   PLAN_NUM_SOLD)
  SELECT PRO_PLAN_ID,
         (SELECT  NVL(MAX(GX_PLAN_NO),0) +1 FROM PLN_ORDER_CAST_S WHERE PRO_PLAN_ID=A.PRO_PLAN_ID )  GX_PLAN_NO,
         GPREQ_ID,
         GPTYPE,
         CASTINGTYPE,
         PLINE_CODE,
         PLINE_NAME,
         PLINE_CODE_A,
         PLINE_NAME_A,
         GRADECODE,
         GRADENAME,
         DIAMETER_LZ,
         LEN_GP_SINGLE,
         CUT_NUM_GP,
         CUT_LOSE_LEN,
         LENGTH_LZ,
         MATERIAL_NO,
         MATERIAL_NAME,
         WLID_IN,
         WLDESC_IN,
         CIC,
         PIC,
         SIC,
         DIC,
         WIC,
         GIC,
         IF_MONITOR_LG,
         PRDCR_NO,
         MONITOR_POINT,
         WT_CAST_ONE,
        PLAN_WT_S-PLANED_WT PLAN_WT_S,
        PLAN_NUM_S-PLANED_NUM PLAN_NUM_S,
         CAST_NUM_CALC,
         FURNACE_NUM_CALC,
         FURNACE_WT,
         GX_PRO_SEQ,
         PRO_MONTH,
         PLAN_USETIME,
         PLAN_TIME_B,
         PLAN_TIME_E,
        0  PLANED_WT,
        0  PLANED_NUM,
         FINISHWEIGHT,
         FINISH_NUM,
         EXE_STATUS,
         IS_REPAIR_PLN,
         REPAIR_TYPE,
         IS_PLAN_OK,
         CAST_NUM,
         FURNACE_NUM,
         ADD_WT_BEGIN,
         ADD_WT_END,
         IF_CONNECT_AHEAD,
         ADD_WT_AHEAD,
         IF_CONNECT_NEXT,
         ADD_WT_NEXT,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ISSUED_TIME,
         ISSUED_MAN,
         LAST_UNDOWN_TIME,
         LAST_UNDOWN_MAN,
         PROCESSING_COST_A,
         TOTAL_COST_A,
         PROCESSING_COST_B,
         TOTAL_COST_B,
         IF_CRAFT_LOCKED,
         CAST_NO_ALL,
         PROGY_MEMO,
         CRAFT_NO,
         CRAFT_PATH,
         IF_CONFIRM,
        PLAN_WT_MIN* (PLAN_NUM_S-PLANED_NUM)/PLAN_NUM_S  PLAN_WT_MIN,
         GOWHERE_NAME,
         GOWHERE_CODE,
         STEEL_JUDGEMENT,
        '0' PLAN_WT_SOLD,
        '0' PLAN_NUM_SOLD
    FROM PLN_ORDER_CAST_S A
    WHERE
    PRO_PLAN_ID=? AND
    GX_PLAN_NO=?
	]]>
	</query>

	<query id="FrmSteelManagement.SelectOrderByProID" desc="">
		<![CDATA[
          	SELECT *
  FROM PLN_STEELFOR_ORD
 WHERE PRO_PLAN_ID = ?
       AND GX_PLAN_NO = ?
       AND FURNACENO = ?

	]]>
	</query>


	<query id="FrmSteelManagement.SelectPlnSteelforfurnaceByCasts" desc="">
	<![CDATA[
SELECT *
  FROM PLN_STEELFORFURNACE
 WHERE EF_PLINE_CODE = ?
       AND FURNACENO_SEQ >= (SELECT MIN(FURNACENO_SEQ)
                               FROM PLN_STEELFORFURNACE
                              WHERE CAST_NO = ?
                                    OR CAST_NO = ?)
       AND FURNACENO_SEQ <= (SELECT MAX(FURNACENO_SEQ)
                               FROM PLN_STEELFORFURNACE
                              WHERE CAST_NO = ?
                                    OR CAST_NO = ?)
 ORDER BY FURNACENO_SEQ

	]]>
</query>




	<query id="FrmSteelManagement.NeedUpdateCast" desc="">
	<![CDATA[
SELECT *
  FROM PLN_STEELFORCAST T
 WHERE CAST_NO IN
       (SELECT CAST_NO
          FROM PLN_STEELFORFURNACE
         WHERE EF_PLINE_CODE = (SELECT EF_PLINE_CODE
                                  FROM PLN_STEELFORFURNACE
                                 WHERE CAST_NO = ?
                                       AND ROWNUM = 1)
               AND FURNACENO_SEQ <=
               (SELECT MAX(FURNACENO_SEQ)
                      FROM PLN_STEELFORFURNACE
                     WHERE CAST_NO = ?))
                     AND STATUS = '00'
                      ORDER BY (SELECT MAX(FURNACENO_SEQ) FROM PLN_STEELFORFURNACE  WHERE CAST_NO=T.CAST_NO )
	]]>
</query>

	<query id="FrmSteelManagement.NeedUpdateOrder" desc="">
		<![CDATA[
SELECT *
  FROM PLN_STEELFOR_ORD T
 WHERE CAST_NO IN
       (SELECT CAST_NO
          FROM PLN_STEELFORFURNACE
         WHERE EF_PLINE_CODE = (SELECT EF_PLINE_CODE
                                  FROM PLN_STEELFORFURNACE
                                 WHERE CAST_NO = ?
                                       AND ROWNUM = 1)
               AND FURNACENO_SEQ <=
               (SELECT MAX(FURNACENO_SEQ)
                      FROM PLN_STEELFORFURNACE
                     WHERE CAST_NO = ?))
                     AND STATUS = '00'
                      ORDER BY (SELECT MAX(FURNACENO_SEQ) FROM PLN_STEELFORFURNACE  WHERE CAST_NO=T.CAST_NO )
	]]>
	</query>

	<query id="FrmSteelManagement.NeedUpdateCast2" desc="">
		<![CDATA[
SELECT *
  FROM PLN_STEELFORCAST T
 WHERE CAST_NO IN
       (SELECT CAST_NO
          FROM PLN_STEELFORFURNACE
         WHERE EF_PLINE_CODE = (SELECT EF_PLINE_CODE
                                  FROM PLN_STEELFORFURNACE
                                 WHERE CAST_NO = ?
                                       AND ROWNUM = 1)
               AND FURNACENO_SEQ >=
               (SELECT MAX(FURNACENO_SEQ)
                      FROM PLN_STEELFORFURNACE
                     WHERE CAST_NO = ?))
                      ORDER BY (SELECT MAX(FURNACENO_SEQ) FROM PLN_STEELFORFURNACE  WHERE CAST_NO=T.CAST_NO )
	]]>
	</query>

	<query id="FrmSteelManagement.CheckUpdate1" desc="">
		<![CDATA[
SELECT JUDGE_STOVE_NO FROM (
SELECT JUDGE_STOVE_NO,
       DECODE(GPTYPE,
              1,
              (SELECT COUNT(1)
                 FROM PLN_ZY_ZG_M
                WHERE PLANSTATUS <> '00'
                      AND
                      UPPER_HEATPLAN_ID = T.FURNACENO || '/' || T.SEQUENCENO),
              (SELECT COUNT(1)
                 FROM PLN_ZY_ZG_M
                WHERE PLANSTATUS <> '00'
                      AND UPPER_HEATPLAN_ID IN
                      (SELECT HEAT_PLAN_NO
                             FROM PLN_ZY_DZ_M
                            WHERE UPPER_HEATPLAN_ID =
                                  T.FURNACENO || '/' || T.SEQUENCENO))) CT
  FROM PLN_STEELFOR_ORD T
 WHERE CAST_NO IN
       (SELECT CAST_NO
          FROM PLN_STEELFORFURNACE
         WHERE EF_PLINE_CODE = (SELECT EF_PLINE_CODE
                                  FROM PLN_STEELFORFURNACE
                                 WHERE CAST_NO = ?
                                       AND ROWNUM = 1)
               AND
               FURNACENO_SEQ >= (SELECT MAX(FURNACENO_SEQ)
                                   FROM PLN_STEELFORFURNACE
                                  WHERE CAST_NO = ?))
 ORDER BY (SELECT MAX(FURNACENO_SEQ)
             FROM PLN_STEELFORFURNACE
            WHERE CAST_NO = T.CAST_NO))
 WHERE CT > 0
	]]>
	</query>

	<query id="FrmSteelManagement.CheckUpdate2" desc="">
		<![CDATA[
SELECT *
  FROM (SELECT FURNACENO,
               LEN_GP_SINGLE,
               GOWHERE_NAME,
               COUNT(1) CT
          FROM PLN_STEELFOR_ORD T
         WHERE CAST_NO IN
               (SELECT CAST_NO
                  FROM PLN_STEELFORFURNACE
                 WHERE EF_PLINE_CODE =
                       (SELECT EF_PLINE_CODE
                          FROM PLN_STEELFORFURNACE
                         WHERE CAST_NO = ?
                               AND ROWNUM = 1)
                       AND FURNACENO_SEQ <=
                       (SELECT MAX(FURNACENO_SEQ)
                              FROM PLN_STEELFORFURNACE
                             WHERE CAST_NO = ?))
               AND STATUS = '00'
               AND (T.SURPLUS_TYPE IS NULL OR
               (T.SURPLUS_TYPE <> 3 AND T.SURPLUS_TYPE <> 2))
         GROUP BY FURNACENO, LEN_GP_SINGLE, GOWHERE_NAME)
 WHERE CT > 1

	]]>
	</query>

	<query id="FrmSteelManagement.FindMinMaxFurnaceNoSeq" desc="查询最小炉次顺序号">
		<![CDATA[
               SELECT EF_PLINE_CODE,MIN(FURNACENO_SEQ) FURNACENO_SEQ_MIN,
               MAX(FURNACENO_SEQ) FURNACENO_SEQ_MAX,
  FROM PLN_STEELFORFURNACE
	]]>
	</query>


	<query id="FrmSteelManagement.FindLastFurnace" desc="找浇次最后一炉">
		<![CDATA[
               SELECT *
  FROM PLN_STEELFORFURNACE
 WHERE CAST_STOVE_SEQ =
       (SELECT MAX(CAST_STOVE_SEQ)
          FROM PLN_STEELFORFURNACE
         WHERE CAST_NO = ?)
       AND CAST_NO = ?

	]]>
	</query>

	<query id="FrmSteelManagement.FindLastOrder" desc="找炉次最后一个非尾炉加量订单">
		<![CDATA[
              SELECT *
   FROM PLN_STEELFOR_ORD
  WHERE furnaceno = ?
        AND CUT_NUM = (SELECT MAX(CUT_NUM)
                            FROM PLN_STEELFOR_ORD
                           WHERE furnaceno = ?
                                 AND (SURPLUS_TYPE <> 3 OR SURPLUS_TYPE IS NULL))

	]]>
	</query>


	<query id="FrmSteelManagement.FindJudgeStove" desc="找同定尺判定炉号">
		<![CDATA[
SELECT JUDGE_STOVE_NO
	FROM PLN_STEELFOR_ORD
	WHERE FURNACENO = ?
	AND LEN_GP_SINGLE = ?

	]]>
	</query>

	<query id="FrmSteelManagement.FindMaxMinCastStoveSeq" desc="">
		<![CDATA[
SELECT MAX(CAST_STOVE_SEQ) MAXC, MIN(CAST_STOVE_SEQ) MINC
  FROM PLN_STEELFORFURNACE
 WHERE CAST_NO = ?

	]]>
	</query>


	<query id="FrmSteelManagement.UpdateLastOrFirstFurnace" desc="">
		<![CDATA[
UPDATE PLN_STEELFOR_ORD
	SET FURNACENO = ?
	WHERE
	FURNACENO =? AND (
	SURPLUS_TYPE = 2
	OR SURPLUS_TYPE = 3)

	]]>
	</query>

	<query id="FrmSteelManagement.getMaxMegerNo" desc="查询炉次订单合并编号">
		<![CDATA[
      SELECT ? || LPAD(SUBSTR(NVL(MAX(T.MERGE_NO), '00'), -2, 2) + 1, 2, '0') AS MERGE_NO
  FROM PLN_STEELFOR_MERGE T
 WHERE MERGE_NO LIKE ? || '%'
      ]]>
	</query>

	<query id="FrmSteelManagement.deleteMegerNo" desc="删除">
		<![CDATA[
     DELETE FROM PLN_STEELFOR_MERGE WHERE MERGE_NO=?
      ]]>
	</query>

	<query id="FrmSteelManagement.addMegerNo" desc="新增炉次订单合并记录">
		<![CDATA[
 INSERT INTO PLN_STEELFOR_MERGE(
        MERGE_NO,
        MERGE_SEQ,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        LEN_GP_SINGLE,
        CUT_NUM_GP,
        WEIGHT_GP_ONE,
        TOT_MUM_M,
        TOT_WEIGHT_M,
        CIC,
        PIC,
        SIC,
        DIC,
        MAKEMAN,
        MAKETIME,
        ORDER_NO,
        FINAL_USER_DESC,
        STEELCODE,
        STEELNAME,
        PRODUCCODE,
        PRODUCNAME,
        IF_MONITOR_LG,
        PRDCR_NO,FURNACENO,PDEPT_NAME,PRDCR_MAN,STATE_LK)
 VALUES(
        ?,
        ?,
        ?,
      ?,
       ?,
      ?,
        ?,
      ?,
       ?,
       ?,
        ?,
        ?,
      ?,
      ?,
        SYSDATE,
       ?,
       ?,
      ?,
       ?,
     ?,
       ?,
      ?,
       ?,
      ?,
      ?,
     ?,
     ?)
      ]]>
	</query>


	<query id="FrmSteelManagement.selectPlnZyZgM" desc="">
		<![CDATA[
     SELECT * FROM PLN_ZY_ZG_M T WHERE T.UPPER_HEATPLAN_ID = ? || '/' || ?
       AND CCM_PRO_PLAN_ID = ?
       AND CCM_GX_PLAN_NO = ?
 ORDER BY GX_PRO_SEQ
      ]]>
	</query>

	<query id="FrmSteelManagement.selectPlnZyDZM" desc="">
		<![CDATA[
     SELECT * FROM PLN_ZY_DZ_M T WHERE T.UPPER_HEATPLAN_ID = ? || '/' || ?
       AND CCM_PRO_PLAN_ID = ?
       AND CCM_GX_PLAN_NO = ?
 ORDER BY GX_PRO_SEQ
      ]]>
	</query>

	<query id="FrmSteelManagement.UpdatePlnZyZgM" desc="">
		<![CDATA[
		UPDATE PLN_ZY_ZG_M SET UPPER_HEATPLAN_ID = ? || '/' || ? WHERE HEAT_PLAN_NO=?
      ]]>
	</query>

	<query id="FrmSteelManagement.UpdatePlnZyDzM" desc="">
		<![CDATA[
		UPDATE PLN_ZY_DZ_M SET UPPER_HEATPLAN_ID = ? || '/' || ? WHERE HEAT_PLAN_NO=?
      ]]>
	</query>


	<query id="FrmSteelManagement.UpdatePlnZyZgM2" desc="">
		<![CDATA[
		UPDATE PLN_ZY_ZG_M SET
PLN_INSINGLE_NUM = PLN_INSINGLE_NUM- ?,
PLN_INSINGLE_WT = PLN_INSINGLE_WT-?,
PLN_OUTSINGLE_NUM = PLN_OUTSINGLE_NUM-?,
PLN_OUTSINGLE_W = PLN_OUTSINGLE_W-?,
REDUCED_WT =REDUCED_WT-?
 WHERE HEAT_PLAN_NO=?
      ]]>
	</query>


	<query id="FrmSteelManagement.UpdatePlnZyDzM2" desc="">
		<![CDATA[
		UPDATE PLN_ZY_DZ_M SET
		PLN_INSINGLE_NUM = PLN_INSINGLE_NUM-? * CUT_NUM_GP,
		PLN_INSINGLE_WT = PLN_INSINGLE_WT - ? * CUT_NUM_GP,
		PLN_INDOUBLE_NUM = PLN_INDOUBLE_NUM-?,
		PLN_INDOUBLE_WT = PLN_INDOUBLE_WT-?,
		PLN_OUTSINGLE_NUM = PLN_OUTSINGLE_NUM - ?* CUT_NUM_OUT,
		PLN_OUTSINGLE_W = PLN_OUTSINGLE_W- ? * CUT_NUM_OUT,
		PLN_OUTDOUBLE_NUM = PLN_OUTDOUBLE_NUM-?,
		PLN_OUTDOUBLE_W = PLN_OUTDOUBLE_W-?
 WHERE HEAT_PLAN_NO=?
      ]]>
	</query>

	<query id="FrmSteelManagement.DeletePlnZyZgM" desc="">
		<![CDATA[
		DELETE  PLN_ZY_ZG_M WHERE HEAT_PLAN_NO=?
      ]]>
	</query>

	<query id="FrmSteelManagement.DeletePlnZyDzM" desc="">
		<![CDATA[
		DELETE  PLN_ZY_DZ_M WHERE HEAT_PLAN_NO=?
      ]]>
	</query>

	<query id="FrmSteelManagement.InsertPlnZyZgM" desc="">
		<![CDATA[
		INSERT INTO PLN_ZY_ZG_M
  (HEAT_PLAN_NO,
   GX_PRO_SEQ,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   PLANSTATUS,
   UPPER_HEATPLAN_ID,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CCM_PRO_PLAN_ID,
   CCM_GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   PROCESS_CODE_C,
   PROCESS_DESC_C,
   UPPER_PROCESS_CODE,
   NEXT_PROCESS_CODE,
   ISENDGX,
   IF_MATCH_ODD,
   IF_DO_HEAT_PLAN,
   ORDER_SOURCE,
   ORD_LN_DLY_PK,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   REQ_BL_ID,
   IF_EXPORT,
   PRIORITY,
   PRIORITY_MEMO,
   PRO_MONTH,
   IF_LEN_CONTROL,
   IF_MINUS_SIC_ROLL,
   PROD_STANDARD,
   OUTPUT_STANDARD,
   DECISION,
   PROGY_MEMO,
   GOWHERE_CODE,
   GOWHERE_NAME,
   OUTS_BILLET_FL,
   GPTYPE,
   INWL_ID,
   INWL_DESC,
   OUTWL_ID,
   OUTWL_DESC,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   MODEL_CODE,
   MODEL_DESC,
   DIAMETER,
   LEN_GP_SINGLE,
   WT_GP_SINGLE,
   PLN_INSINGLE_NUM,
   PLN_INSINGLE_WT,
   PLN_OUTSINGLE_NUM,
   PLN_OUTSINGLE_W,
   OUTDIAMETER,
   WALLTHICK,
   OUTDIAMETER_ZG,
   WALLTHICK_ZG,
   AIMOUTDIAMETER,
   AIMWALLTHICK,
   THICKNESS_WALL,
   LEN_ROLL_MAX,
   LEN_ROLL_MIN,
   AIMLENGTH,
   ROLL_LENGTH,
   OUTNUM_CUT,
   CUT_TYPE,
   LEN_CUTEND,
   LEN_CUTHEAD,
   DIAMETER_MANDREL,
   PASS_CODE,
   PASS_NAME,
   IF_MONITOR,
   PRDCR_NO,
   MONITOR_POINT,
   BOM,
   WHOLE_BACKLOG,
   WHOLE_BACKLOG_DESC,
   CIC,
   PIC,
   SIC,
   DIC,
   CRAFT_FILE_NO,
   CRAFT_FILE_MAN,
   CRAFT_SEQ,
   SEC_CRAFT_FILE_NO,
   STATION_ROAD,
   PRO_DAY,
   BAL_YEAR_MONTH,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DOWNMAN,
   DOWNTIME,
   IS_LOAD,
   PLN_TYPE,
   FLAG_STOVE_NO,
   INDEX_SEQ,
   MEMO,
   FEED_HEAT_NO,
   REDUCED_WT)
  SELECT (SELECT T.PRO_PLAN_ID || T.GX_PLAN_NO ||  LPAD(NVL(MAX(TO_NUMBER(SUBSTR(HEAT_PLAN_NO, LENGTH(HEAT_PLAN_NO) - 1))),
                      0) + 1,
                  2,
                  '0') FROM PLN_ZY_ZG_M WHERE HEAT_PLAN_NO LIKE T.PRO_PLAN_ID || T.GX_PLAN_NO || '__' ),
         GX_PRO_SEQ,
         ZY_BATCH_ID,
         STOVE_NO,
         JUDGE_STOVE_NO,
         PLANSTATUS,
         ? || '/' || ? UPPER_HEATPLAN_ID,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         CCM_PRO_PLAN_ID,
         CCM_GX_PLAN_NO,
         PLINE_CODE,
         PLINE_NAME,
         PROCESS_CODE_C,
         PROCESS_DESC_C,
         UPPER_PROCESS_CODE,
         NEXT_PROCESS_CODE,
         ISENDGX,
         IF_MATCH_ODD,
         IF_DO_HEAT_PLAN,
         ORDER_SOURCE,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         REQ_BL_ID,
         IF_EXPORT,
         PRIORITY,
         PRIORITY_MEMO,
         PRO_MONTH,
         IF_LEN_CONTROL,
         IF_MINUS_SIC_ROLL,
         PROD_STANDARD,
         OUTPUT_STANDARD,
         DECISION,
         PROGY_MEMO,
         GOWHERE_CODE,
         GOWHERE_NAME,
         OUTS_BILLET_FL,
         GPTYPE,
         INWL_ID,
         INWL_DESC,
         OUTWL_ID,
         OUTWL_DESC,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
         MODEL_CODE,
         MODEL_DESC,
         DIAMETER,
         LEN_GP_SINGLE,
         WT_GP_SINGLE,
        ? PLN_INSINGLE_NUM,
        ? PLN_INSINGLE_WT,
        ? PLN_OUTSINGLE_NUM,
        ? PLN_OUTSINGLE_W,
         OUTDIAMETER,
         WALLTHICK,
         OUTDIAMETER_ZG,
         WALLTHICK_ZG,
         AIMOUTDIAMETER,
         AIMWALLTHICK,
         THICKNESS_WALL,
         LEN_ROLL_MAX,
         LEN_ROLL_MIN,
         AIMLENGTH,
         ROLL_LENGTH,
         OUTNUM_CUT,
         CUT_TYPE,
         LEN_CUTEND,
         LEN_CUTHEAD,
         DIAMETER_MANDREL,
         PASS_CODE,
         PASS_NAME,
         IF_MONITOR,
         PRDCR_NO,
         MONITOR_POINT,
         BOM,
         WHOLE_BACKLOG,
         WHOLE_BACKLOG_DESC,
         CIC,
         PIC,
         SIC,
         DIC,
         CRAFT_FILE_NO,
         CRAFT_FILE_MAN,
         CRAFT_SEQ,
         SEC_CRAFT_FILE_NO,
         STATION_ROAD,
         PRO_DAY,
         BAL_YEAR_MONTH,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DOWNMAN,
         DOWNTIME,
         IS_LOAD,
         PLN_TYPE,
         FLAG_STOVE_NO,
         INDEX_SEQ,
         MEMO,
         FEED_HEAT_NO,
        ? REDUCED_WT
    FROM PLN_ZY_ZG_M T
   WHERE HEAT_PLAN_NO = ?
      ]]>
	</query>

	<query id="FrmSteelManagement.InsertPlnZyDzM" desc="">
		<![CDATA[
INSERT INTO PLN_ZY_DZ_M
  (HEAT_PLAN_NO,
   GX_PRO_SEQ,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   FLAG_STOVE_NO,
   UPPER_HEATPLAN_ID,
   PLANSTATUS,
   NODE_ESTATUS,
   UPPER_PROCESS_CODE,
   NEXT_PROCESS_CODE,
   ISENDGX,
   IF_MATCH_ODD,
   IF_DO_HEAT_PLAN,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CCM_PRO_PLAN_ID,
   CCM_GX_PLAN_NO,
   GOWHERE_CODE,
   GOWHERE_NAME,
   PLINE_CODE,
   PLINE_NAME,
   CASTINGTYPE,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   WLID_IN,
   WLDESC_IN,
   OUTWL_ID,
   OUTWL_DESC,
   PROD_STANDARD,
   OUTPUT_STANDARD,
   DIAMETER_IN,
   LENGTH_IN,
   WT_ONE_IN,
   LEN_GP_SINGLE,
   WT_GP_SINGLE,
   PLN_INSINGLE_NUM,
   PLN_INSINGLE_WT,
   CUT_NUM_GP,
   PLN_INDOUBLE_NUM,
   PLN_INDOUBLE_WT,
   DIAMETER_OUT,
   LENGTH_OUT,
   OUT_WT_ONE,
   PLN_OUTSINGLE_NUM,
   PLN_OUTSINGLE_W,
   CUT_NUM_OUT,
   PLN_OUTDOUBLE_NUM,
   PLN_OUTDOUBLE_W,
   LEN_CUTHEAD,
   LEN_CUTEND,
   ORDER_SOURCE,
   ORD_LN_DLY_PK,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   REQ_BL_ID,
   IF_EXPORT,
   PRIORITY,
   PRIORITY_MEMO,
   PRO_MONTH,
   IF_MONITOR,
   PRDCR_NO,
   MONITOR_POINT,
   BOM,
   INDEX_SEQ,
   WHOLE_BACKLOG,
   WHOLE_BACKLOG_DESC,
   CIC,
   PIC,
   SIC,
   DIC,
   CRAFT_FILE_NO,
   CRAFT_FILE_MAN,
   CRAFT_SEQ,
   SEC_CRAFT_FILE_NO,
   STATION_ROAD,
   PRO_DAY,
   BAL_YEAR_MONTH,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DOWNMAN,
   DOWNTIME,
   SUBCONTRACT_FLAG,
   LEN_GP_SINGLE_OUT)
  SELECT  (SELECT T.PRO_PLAN_ID || T.GX_PLAN_NO ||  LPAD(NVL(MAX(TO_NUMBER(SUBSTR(HEAT_PLAN_NO, LENGTH(HEAT_PLAN_NO) - 1))),
                      0) + 1,
                  2,
                  '0') FROM PLN_ZY_ZG_M WHERE HEAT_PLAN_NO LIKE T.PRO_PLAN_ID || T.GX_PLAN_NO || '__' ),
         GX_PRO_SEQ,
         ZY_BATCH_ID,
         STOVE_NO,
         JUDGE_STOVE_NO,
         FLAG_STOVE_NO,
         ? || '/' || ? UPPER_HEATPLAN_ID,
         PLANSTATUS,
         NODE_ESTATUS,
         UPPER_PROCESS_CODE,
         NEXT_PROCESS_CODE,
         ISENDGX,
         IF_MATCH_ODD,
         IF_DO_HEAT_PLAN,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         CCM_PRO_PLAN_ID,
         CCM_GX_PLAN_NO,
         GOWHERE_CODE,
         GOWHERE_NAME,
         PLINE_CODE,
         PLINE_NAME,
         CASTINGTYPE,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         WLID_IN,
         WLDESC_IN,
         OUTWL_ID,
         OUTWL_DESC,
         PROD_STANDARD,
         OUTPUT_STANDARD,
         DIAMETER_IN,
         LENGTH_IN,
         WT_ONE_IN,
         LEN_GP_SINGLE,
         WT_GP_SINGLE,
        ?  PLN_INSINGLE_NUM,
        ? PLN_INSINGLE_WT,
         CUT_NUM_GP,
        ? PLN_INDOUBLE_NUM,
        ? PLN_INDOUBLE_WT,
         DIAMETER_OUT,
         LENGTH_OUT,
         OUT_WT_ONE,
        ? PLN_OUTSINGLE_NUM,
        ? PLN_OUTSINGLE_W,
         CUT_NUM_OUT,
        ? PLN_OUTDOUBLE_NUM,
        ? PLN_OUTDOUBLE_W,
         LEN_CUTHEAD,
         LEN_CUTEND,
         ORDER_SOURCE,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         REQ_BL_ID,
         IF_EXPORT,
         PRIORITY,
         PRIORITY_MEMO,
         PRO_MONTH,
         IF_MONITOR,
         PRDCR_NO,
         MONITOR_POINT,
         BOM,
         INDEX_SEQ,
         WHOLE_BACKLOG,
         WHOLE_BACKLOG_DESC,
         CIC,
         PIC,
         SIC,
         DIC,
         CRAFT_FILE_NO,
         CRAFT_FILE_MAN,
         CRAFT_SEQ,
         SEC_CRAFT_FILE_NO,
         STATION_ROAD,
         PRO_DAY,
         BAL_YEAR_MONTH,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DOWNMAN,
         DOWNTIME,
         SUBCONTRACT_FLAG,
         LEN_GP_SINGLE_OUT
    FROM PLN_ZY_DZ_M
    WHERE HEAT_PLAN_NO =?
      ]]>
	</query>
<query id = "FrmSteelManagement.selectNoticeFlag" desc = "查询订单的监制通知标识">
	SELECT T.IS_NOTICE_EP FROM PLN_STEELFOR_ORD T WHERE T.FURNACENO = '#FURNACENO#' AND T.SEQUENCENO = '#SEQUENCENO#'
</query>
	<query id = "FrmSteelManagement.noticeFlag" desc = "修改监制标识">
		UPDATE PLN_STEELFOR_ORD T
		SET T.IS_NOTICE_USER = '#IS_NOTICE_USER#',
		T.IS_NOTICE_TIME = TO_DATE('#IS_NOTICE_TIME#',
		'YYYY-MM-DD HH24:MI:SS'),
		T.IS_NOTICE_EP   = '#IS_NOTICE_EP#'
		WHERE T.FURNACENO = '#FURNACENO#'
		AND T.SEQUENCENO = '#SEQUENCENO#'
	</query>

	<query id = "FrmSteelManagement.doAddLgLog" desc = "操作记录">
		INSERT INTO IMP_FRMDISPATCH @TG_LG_LINK(
		PRO_MONTH,
		CAST_NO,
		CAST_SEQ,
		HEATNO,
		HEAT_LINE,
		CMM_LINE,
		MEMO,
		HEAT_STATE,
		OPTPERSONNEL,
		OPERATIONDATE,
		MSG_ID,
		MSG_TIME,
		MSG_FLAG,
		READ_FLAG,
		FAIL_REASON)
		VALUES(
		'#PRO_MONTH#',
		'#CAST_NO#',
		'#CAST_SEQ#',
		'#HEATNO#',
		'#HEAT_LINE#',
		'#CMM_LINE#',
		'#MEMO#',
		'#HEAT_STATE#',
		'#OPTPERSONNEL#',
		SYSDATE,
		SYS_GUID(),
		SYSDATE,
		'#MSG_FLAG#',
		'#READ_FLAG#',
		'#FAIL_REASON#')
	</query>
</queryMap>