<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="生产订单类">

	<query id="ControlOrderPlan.getOrderBInfo" desc="查询铸造生产订单信息">
             <![CDATA[
                SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       TO_NUMBER(NVL(T.PLAN_WT_S, '0')) - TO_NUMBER(NVL(T.PLANED_WT, '0'))-TO_NUMBER(NVL(T.PLAN_WT_SOLD, '0')) AS CAN_WGT,
       TO_NUMBER(NVL(T.PLAN_NUM_S, '0')) -
       TO_NUMBER(NVL(T.PLANED_NUM, '0'))-TO_NUMBER(NVL(T.PLAN_NUM_SOLD, '0')) AS CAN_NUM,
       DECODE(T.GPTYPE, '1', '铸坯', '2', '锻坯', '') GPTYPE,
       DECODE(T.CASTINGTYPE, '1', '连铸', '2', '模铸', '') CASTINGTYPE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PLINE_CODE_A,
       T.PLINE_NAME_A,
       T.GRADECODE,
       T.GRADENAME,
       CASE
         WHEN T.CASTINGTYPE = '2' THEN
          T.DIAMETER_LZ || 't'
         ELSE
          T.DIAMETER_LZ
       END DIAMETER_LZ,
       T.LEN_GP_SINGLE,
       T.CUT_NUM_GP,
       T.CUT_LOSE_LEN,
       T.LENGTH_LZ,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       DECODE(T.IF_MONITOR_LG, '1', '是', '/') IF_MONITOR_LG,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.WT_CAST_ONE,
       T.PLAN_WT_S,
       T.PLAN_NUM_S,
       T.CAST_NUM_CALC,
       T.FURNACE_NUM_CALC,
       T.FURNACE_WT,
       T.GX_PRO_SEQ,
       T.PRO_MONTH,
       TO_CHAR(ROUND(TO_NUMBER(NVL(T.PLAN_USETIME, '0')) / 60, 2)) PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       NVL(T.PLANED_WT, 0) PLANED_WT,
       NVL(T.PLANED_NUM, 0) PLANED_NUM,
       T.FINISHWEIGHT,
       T.FINISH_NUM,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '已生产',
              '3',
              '关闭A',
              '异常') EXE_STATUS,
       DECODE(T.IS_REPAIR_PLN, '1', '是', '/') IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       DECODE(T.IS_PLAN_OK, '1', '是', '/') IS_PLAN_OK,
       T.CAST_NUM,
       T.FURNACE_NUM,
       T.ADD_WT_BEGIN,
       T.ADD_WT_END,
       DECODE(T.IF_CONNECT_AHEAD, '1', '是', '/') IF_CONNECT_AHEAD,
       T.ADD_WT_AHEAD,
       DECODE(T.IF_CONNECT_NEXT, '1', '是', '/') IF_CONNECT_NEXT,
       T.ADD_WT_NEXT,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.FINAL_USER_DESC,
       T1.ORDER_SEQ_NO,
       T2.PDEPT_NAME,
       T2.PRDCR_NO,
       T1.PRODUCNAME,
       DECODE(T.CASTINGTYPE, '2', 'ELVI', T3.STATION_DESC) STATION_DESC,
       T.CAST_NO_ALL,
       T1.EXE_STATUS_ZG,
       T.PROGY_MEMO,
       T.CRAFT_NO,
       DECODE(T.IF_CONFIRM, '1', '是', '/') IF_CONFIRM,
       T.CRAFT_PATH,
       (SELECT TO_CHAR(MIN(SZ.PLAN_TIME_B), 'YYYY-MM-DD HH24:MI:SS')
          FROM PLN_ORDER_ZG_S SZ
         WHERE SZ.GPREQ_ID = T.PRO_PLAN_ID
           AND SZ.EXE_STATUS IN ('0', '1')) PLAN_TIME_B_ZG,
        CASE
         WHEN T.GPTYPE = '1' THEN
          (SELECT LISTAGG(PLINE_NAME, ',') WITHIN GROUP(ORDER BY PLINE_NAME ASC) GOWHERE_NAME
             FROM (SELECT ZG.PLINE_NAME, CS.PRO_PLAN_ID
                     FROM PLN_ORDER_ZG_S ZG, PLN_ORDER_CAST_S CS
                    WHERE ZG.GPREQ_ID = CS.PRO_PLAN_ID
                    GROUP BY ZG.PLINE_NAME, CS.PRO_PLAN_ID) T4
            WHERE T4.PRO_PLAN_ID = T.PRO_PLAN_ID)
         ELSE
          '快锻'
       END GOWHERE_NAME,
       '成分标准生成或修改时间：' || T1.CREATE_TIME_CIC || ',标准卡生成时间：' ||
       TO_CHAR(M.MARK_DATE, 'YYYY-MM-DD HH24:MI:SS') || (CASE
         WHEN T.CRAFT_NO IS NULL THEN
          ''
         ELSE
          (CASE
            WHEN T1.CREATE_TIME_CIC IS NOT NULL AND
                  TO_DATE(T1.CREATE_TIME_CIC, 'YYYY-MM-DD HH24:MI:SS') >M.MARK_DATE THEN
             ',生产标准卡时间早于成分标准生产或修改时间'
            ELSE
             ''
          END)
       END) CHANGE_INDE,  NVL(T.PLAN_WT_MIN,0) PLAN_WT_MIN,
       NVL(T.PLAN_NUM_SOLD,0) PLAN_NUM_SOLD,
       NVL(T.PLAN_WT_SOLD,0) PLAN_WT_SOLD
  FROM PLN_ORDER_CAST_S T,
       (SELECT MAX(J.PDEPT_NAME) PDEPT_NAME,
               MAX(J.PRDCR_MAN) PRDCR_MAN,
               C.PRDCR_NO
          FROM SLM_ORDER_LINE_PRDCR_LST J, PLN_ORDER_CAST_S C
         WHERE J.PRDCR_NO = C.PRDCR_NO
           AND J.PROCESS_CODE = 'A'
           AND J.PROCESS_CODE_C = 'B001'
         GROUP BY C.PRDCR_NO) T2,
       (SELECT MAX(Y.ABRVITION) FINAL_USER_DESC,
               MAX(S.ORDER_NO || '/' || S.ORDER_SEQ) ORDER_SEQ_NO,
               Z.GPREQ_ID,
               MAX(S.PRODUCNAME) PRODUCNAME,
               MAX(S.PRODUCCODE) PRODUCCODE,
               DECODE(MIN(Z.EXE_STATUS),
                      '0',
                      '计划',
                      '1',
                      '生产中',
                      '2',
                      '生产完成',
                      '3',
                      '关闭A') EXE_STATUS_ZG,
               MAX(TO_CHAR(CASE
                             WHEN CIC.UPDATE_TIME IS NULL THEN
                              CIC.CREATE_TIME
                             ELSE
                              CIC.UPDATE_TIME
                           END,
                           'YYYY-MM-DD HH24:MI:SS')) CREATE_TIME_CIC            
          FROM PLN_ORDER_ZG_S           Z,
               PLN_SALEORD              S,
               PLN_ORDER_CAST_S         C,
               SLM_BASE_CUSTOMER        Y,
               CRAFT_ORD_DESIGN         DE,
               CRAFT_ORD_DESIGN_STD_CIC CIC
         WHERE Z.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
           AND Z.GPREQ_ID = C.PRO_PLAN_ID
           AND S.FINAL_USER = Y.CUSTOMER_NO
           AND DE.ORD_LN_PK = S.ORD_LN_PK
           AND DE.CRAFT_SEQ = Z.CRAFT_SEQ
           AND CIC.DESGIN_KEY = DE.DESGIN_KEY
           AND CIC.MSC_PLINE = Z.INDEX_SEQ
           AND CIC.SPECL_FL = '2'
           AND CIC.VALIDFLAG = '1'
         GROUP BY Z.GPREQ_ID) T1,
       (SELECT LISTAGG(STATION_DESC, '') WITHIN GROUP(ORDER BY STATION_CODE) STATION_DESC,
               GPREQ_ID
          FROM (SELECT DISTINCT CASE
                                  WHEN S.STATION_DESC = '电炉' THEN
                                   'E'
                                  WHEN S.STATION_DESC = '炉外精炼' THEN
                                   'L'
                                  WHEN T.PLINE_CODE_A = 'C006' AND
                                       S.STATION_DESC = '真空处理' THEN
                                   'R'
                                  WHEN T.PLINE_CODE_A = 'C001' AND
                                       S.STATION_DESC = '真空处理' THEN
                                   'V'
                                  WHEN T.PLINE_CODE_A = 'C003' AND
                                       S.STATION_DESC = '真空处理' THEN
                                   'V'
                                  WHEN S.STATION_DESC = '熔炼成分' THEN
                                   'C'
                                  ELSE
                                   ''
                                END STATION_DESC,
                                S.STATION_CODE,
                                T4.GPREQ_ID
                  FROM CRAFT_ORD_DESIGN_MSC_PL_STI S,
                       CRAFT_ORD_DESIGN            C,
                       CRAFT_ORD_DESIGN_MSC_PL_PRC C1,
                       PLN_SALEORD                 T1,
                       PLN_ORDER_ZG_S              T4,
                       PLN_ORDER_CAST_S            T
                 WHERE T1.ORD_LN_DLY_PK = T4.ORD_LN_DLY_PK
                   AND S.DESGIN_KEY = C1.DESGIN_KEY
                   AND S.MSC_PLINE = C1.MSC_PLINE
                   AND S.PROCESS_CODE = C1.PROCESS_CODE
                   AND C.ORD_LN_PK = T1.ORD_LN_PK
                   AND C.CRAFT_SEQ = T4.CRAFT_SEQ
                   AND C1.DESGIN_KEY = C.DESGIN_KEY
                   AND C1.MSC_PLINE = T4.INDEX_SEQ
                   AND T.PRO_PLAN_ID = T4.GPREQ_ID
                   AND C1.PROCESS_CODE IN ('A')
                 GROUP BY T4.GPREQ_ID,
                          S.STATION_DESC,
                          S.STATION_CODE,
                          T.PLINE_CODE_A)
         GROUP BY GPREQ_ID) T3,
       CRAFT_LG2_M M
 WHERE 1 = 1
   AND T.PRO_PLAN_ID = T1.GPREQ_ID(+)
   AND T.PRDCR_NO = T2.PRDCR_NO(+)
   AND T.PRO_PLAN_ID = T3.GPREQ_ID(+)
   AND T.CRAFT_NO = M.CRAFT_NO(+)
                 ]]>
	</query>


	<query id="ControlOrderPlan.getOrderCastById" desc="查询铸造生产订单信息">
             <![CDATA[
 SELECT TO_NUMBER(NVL(T.PLAN_WT_S, '0')) - TO_NUMBER(NVL(T.PLANED_WT, '0'))-TO_NUMBER(NVL(T.PLAN_WT_SOLD, '0')) AS CAN_WGT,
       TO_NUMBER(NVL(T.PLAN_NUM_S, '0')) -
       TO_NUMBER(NVL(T.PLANED_NUM, '0'))-TO_NUMBER(NVL(T.PLAN_NUM_SOLD, '0')) AS CAN_NUM,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.GPREQ_ID,
       T.GPTYPE,
       T.CASTINGTYPE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PLINE_CODE_A,
       T.PLINE_NAME_A,
       T.GRADECODE,
       T.GRADENAME,
         CASE
         WHEN T.CASTINGTYPE = '2' THEN
          T.DIAMETER_LZ || 't'
         ELSE
          T.DIAMETER_LZ
       END DIAMETER_LZ,
       T.LEN_GP_SINGLE,
       T.CUT_NUM_GP,
       T.CUT_LOSE_LEN,
       T.LENGTH_LZ,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.IF_MONITOR_LG,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.WT_CAST_ONE,
       NVL(T.PLAN_WT_S, 0) PLAN_WT_S,
       NVL(T.PLAN_NUM_S, 0) PLAN_NUM_S,
       NVL(T.CAST_NUM_CALC, 0) CAST_NUM_CALC,
       NVL(T.FURNACE_NUM_CALC, 0) FURNACE_NUM_CALC,
       NVL(T.FURNACE_WT, 0) FURNACE_WT,
       T.GX_PRO_SEQ,
       T.PRO_MONTH,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       TO_NUMBER(NVL(T.PLANED_WT, 0)) PLANED_WT,
       TO_NUMBER(NVL(T.PLANED_NUM, 0)) PLANED_NUM,
       NVL(T.FINISHWEIGHT, 0) FINISHWEIGHT,
       NVL(T.FINISH_NUM, 0) FINISH_NUM,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.IS_PLAN_OK,
       T.CAST_NUM,
       T.FURNACE_NUM,
       T.ADD_WT_BEGIN,
       T.ADD_WT_END,
       T.IF_CONNECT_AHEAD,
       T.ADD_WT_AHEAD,
       T.IF_CONNECT_NEXT,
       T.ADD_WT_NEXT,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.CAST_NO_ALL,
       T.PROGY_MEMO,
       T.CRAFT_NO,
       T.IF_CONFIRM,
       T.CRAFT_PATH, NVL(T.PLAN_WT_MIN,0) PLAN_WT_MIN,
       NVL(T.PLAN_WT_SOLD, '0') PLAN_WT_SOLD,
       NVL(T.PLAN_NUM_SOLD, '0') PLAN_NUM_SOLD,
  T3.STATION_DESC
  FROM PLN_ORDER_CAST_S T, (SELECT LISTAGG(STATION_DESC, '') WITHIN GROUP(ORDER BY STATION_CODE) STATION_DESC,
               GPREQ_ID
          FROM (SELECT DISTINCT CASE
                                  WHEN S.STATION_DESC = '电炉' THEN
                                   'E'
                                  WHEN S.STATION_DESC = '炉外精炼' THEN
                                   'L'
                                  WHEN T.PLINE_CODE_A = 'C006' AND
                                       S.STATION_DESC = '真空处理' THEN
                                   'R'
                                  WHEN T.PLINE_CODE_A = 'C001' AND
                                       S.STATION_DESC = '真空处理' THEN
                                   'V'
                                  WHEN T.PLINE_CODE_A = 'C003' AND
                                       S.STATION_DESC = '真空处理' THEN
                                   'V'
                                  WHEN S.STATION_DESC = '熔炼成分' THEN
                                   'C'
                                  ELSE
                                   ''
                                END STATION_DESC,
                                S.STATION_CODE,
                                T4.GPREQ_ID
                  FROM CRAFT_ORD_DESIGN_MSC_PL_STI S,
                       CRAFT_ORD_DESIGN            C,
                       CRAFT_ORD_DESIGN_MSC_PL_PRC C1,
                       PLN_SALEORD                 T1,
                       PLN_ORDER_ZG_S              T4,
                       PLN_ORDER_CAST_S            T
                 WHERE T1.ORD_LN_DLY_PK = T4.ORD_LN_DLY_PK
                   AND S.DESGIN_KEY = C1.DESGIN_KEY
                   AND S.MSC_PLINE = C1.MSC_PLINE
                   AND S.PROCESS_CODE = C1.PROCESS_CODE
                   AND C.ORD_LN_PK = T1.ORD_LN_PK
                   AND C.CRAFT_SEQ = T4.CRAFT_SEQ
                   AND C1.DESGIN_KEY = C.DESGIN_KEY
                   AND C1.MSC_PLINE = T4.INDEX_SEQ
                   AND T.PRO_PLAN_ID = T4.GPREQ_ID
                   AND C1.PROCESS_CODE IN ('A')
                 GROUP BY T4.GPREQ_ID,
                          S.STATION_DESC,
                          S.STATION_CODE,
                          T.PLINE_CODE_A)
         GROUP BY GPREQ_ID) T3
 WHERE 1 = 1    AND T.PRO_PLAN_ID = T3.GPREQ_ID(+)
                 ]]>
	</query>
	<query id="ControlOrderPlan.queryPlineCode" desc="根据断面查询铸造产线">
             <![CDATA[
             SELECT * FROM (
 SELECT C.PLINE_CODE, C.PLINE_NAME
  FROM COM_MSC_PLINE_R_SPEC C
 WHERE C.VALIDFLAG = '1'
   AND C.WELL_CODE = 'J002'

                ]]>
	</query>
	<query id="ControlOrderPlan.updatePlnOrdeCastCutNum" desc="修改倍尺数">
             <![CDATA[
UPDATE PLN_ORDER_CAST_S T
   SET T.CUT_NUM_GP  = ?,
       T.LENGTH_LZ   = ?,
       T.WT_CAST_ONE = ?,
       T.PLAN_NUM_S  = ?
 WHERE T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
                ]]>
	</query>
	<query id="ControlOrderPlan.getCastProPlanId" desc="查询浇次下铸造订单信息">
             <![CDATA[
  SELECT T1.PRO_PLAN_ID
  FROM (SELECT CASE
                 WHEN T.MERGE_NO IS NULL THEN
                  T.PRO_PLAN_ID || '/' || T.GX_PLAN_NO
                 ELSE
                  M.PRO_PLAN_ID || '/' || M.GX_PLAN_NO
               END PRO_PLAN_ID
          FROM PLN_STEELFOR_ORD T, PLN_STEELFOR_MERGE M
         WHERE T.MERGE_NO = M.MERGE_NO(+)
           AND T.CAST_NO = ?
           AND T.SURPLUSFLAG = '0'
           AND T.PRO_PLAN_ID NOT LIKE '%ZG%') T1
 GROUP BY T1.PRO_PLAN_ID           
             ]]>
	</query>
	<query id="ControlOrderPlan.getCastProPlanIdNum" desc="查询铸造订单已做炉计划数(订单+序号)">
             <![CDATA[
 SELECT SUM(T1.TOT_MUM_M) TOT_MUM_M, SUM(T1.TOT_WEIGHT_M) TOT_WEIGHT_M
  FROM (SELECT CASE
                 WHEN T.MERGE_NO IS NULL THEN
                  T.PRO_PLAN_ID || '/' || T.GX_PLAN_NO
                 ELSE
                  M.PRO_PLAN_ID || '/' || M.GX_PLAN_NO
               END PRO_PLAN_ID,
               CASE
                 WHEN T.MERGE_NO IS NULL THEN
                  T.TOT_MUM_M
                 ELSE
                  M.TOT_MUM_M
               END TOT_MUM_M,
               CASE
                 WHEN T.MERGE_NO IS NULL THEN
                  T.TOT_WEIGHT_M
                 ELSE
                  M.TOT_WEIGHT_M
               END TOT_WEIGHT_M
          FROM PLN_STEELFOR_ORD T, PLN_STEELFOR_MERGE M
         WHERE T.MERGE_NO = M.MERGE_NO(+)
           AND T.SURPLUSFLAG = '0'
           AND T.STATE_LK='0'
           AND T.PRO_PLAN_ID NOT LIKE '%ZG%') T1
 WHERE T1.PRO_PLAN_ID = ?
             ]]>
	</query>
	<query id="ControlOrderPlan.getCastProPlanIdNumAll" desc="查询铸造订单已做炉计划数(订单号)">
             <![CDATA[
 SELECT SUM(T1.TOT_MUM_M) TOT_MUM_M, SUM(T1.TOT_WEIGHT_M) TOT_WEIGHT_M
  FROM (SELECT CASE
                 WHEN T.MERGE_NO IS NULL THEN
                  T.PRO_PLAN_ID
                 ELSE
                  M.PRO_PLAN_ID
               END PRO_PLAN_ID,
               CASE
                 WHEN T.MERGE_NO IS NULL THEN
                  T.TOT_MUM_M
                 ELSE
                  M.TOT_MUM_M
               END TOT_MUM_M,
               CASE
                 WHEN T.MERGE_NO IS NULL THEN
                  T.TOT_WEIGHT_M
                 ELSE
                  M.TOT_WEIGHT_M
               END TOT_WEIGHT_M
          FROM PLN_STEELFOR_ORD T, PLN_STEELFOR_MERGE M
         WHERE T.MERGE_NO = M.MERGE_NO(+)
           AND T.SURPLUSFLAG = '0'
           AND T.STATE_LK='0'
           AND T.PRO_PLAN_ID NOT LIKE '%ZG%') T1
 WHERE T1.PRO_PLAN_ID = ?
             ]]>
	</query>
	<query id="ControlOrderPlan.getCastProPlanIdZg" desc="查询铸造订单对应轧管订单炉计划量">
             <![CDATA[
 SELECT NVL(SUM(T2.PLN_INSINGLE_WT), 0) PLN_INSINGLE_WT
  FROM (SELECT NVL(SUM(T1.PLN_INSINGLE_WT), 0) PLN_INSINGLE_WT
          FROM PLN_ZY_ZG_M T1
         WHERE T1.PRO_PLAN_ID || '/' || T1.GX_PLAN_NO IN
               (SELECT T.PRO_PLAN_ID || '/' || T.GX_PLAN_NO
                  FROM PLN_ORDER_ZG_S T
                 WHERE T.GPREQ_ID = ?)
                 AND T1.IF_MATCH_ODD IN ('2', '3', '4')) T2              
               ]]>
	</query>
	<query id="ControlOrderPlan.UpdatePlanCast" desc="修改铸造订单">
             <![CDATA[
             UPDATE PLN_ORDER_CAST_S T
   SET T.PLAN_WT_S   = '#PLAN_WT_S#',
       T.PLAN_NUM_S  = '#PLAN_NUM_S#',
       T.PLAN_WT_MIN = '#PLAN_WT_MIN#',
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = TO_DATE('#UPDATE_TIME#', 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
             
                   ]]>
	</query>
	
	<query id="ControlOrderPlan.doLimitProcessAll" desc="刷新工艺卡">
             <![CDATA[
DECLARE
  V_CAST_NO PLN_STEELFORFURNACE.CAST_NO%TYPE := ?;
BEGIN
  FOR MYROW IN (SELECT T2.CIC_GID, T.*
                  FROM PLN_STEELFORFURNACE T, CRAFT_LG2_M T2
                 WHERE T.CRAFT_NO = T2.CRAFT_NO
                   AND T.CAST_NO = V_CAST_NO) LOOP
    --保存原始标准值
    UPDATE CRAFT_LG2_CIC T1
       SET T1.STDMIN_OLD = T1.STDMIN, T1.STDMAX_OLD = T1.STDMAX
     WHERE T1.CIC_GID = MYROW.CIC_GID;
  
    --比较原始标准值
    FOR MYROW1 IN (select t1.CHEM_NAME,
                          t1.CHEM_TYPE,
                          MIN(t1.STDMAX_OLD) STDMAX,
                          MAX(t1.STDMIN_OLD) STDMIN
                     from CRAFT_LG2_CIC       t1,
                          CRAFT_LG2_M         T2,
                          PLN_STEELFORFURNACE T3
                    where t1.cic_gid = T2.cic_gid
                      and T2.craft_no = T3.CRAFT_NO
                      AND T3.CAST_NO = V_CAST_NO
                      AND T3.CAST_STOVE_SEQ IN
                          (MYROW.CAST_STOVE_SEQ,
                           MYROW.CAST_STOVE_SEQ - 1,
                           MYROW.CAST_STOVE_SEQ + 1)
                    GROUP BY t1.CHEM_NAME, t1.CHEM_TYPE) LOOP
    
      UPDATE CRAFT_LG2_CIC T1
         SET T1.STDMAX = MYROW1.STDMAX, T1.STDMIN = MYROW1.STDMIN
       WHERE T1.CIC_GID = MYROW.CIC_GID
         AND T1.CHEM_NAME = MYROW1.CHEM_NAME;
    
    END LOOP;
  END LOOP;
END;
                   ]]>
	</query>

</queryMap>