<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="炼钢利库">
	<query id="FrmPlanSteelMakMod.queryMaterial" desc="查询库存管坯物料">
            <![CDATA[
       SELECT DECODE(T.PRODUCT_FLAG,'801401','在制品','801402','成品','801403','商品') PRODUCT_FLAG,
       DECODE(T.MAT_STATUS,'80150101','材料产出待判','80150102','材料产出(已判定)','80150103','材料已编计划','80150104','材料待处理','80150105','材料加工') MAT_STATUS,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.CAST_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.INPUT_MATERIAL_NAME,
       T.INPUT_MATERIAL_NO,
       T.GRADECODE,
       T.GRADENAME,
       T.ORDER_NO ||'/'||T.ORDER_SEQ ORDER_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.DIMATER,
       T.HEIGHT,
       T.ACT_LEN,
       T.FIX_NUM,
       T.FIX_LEN,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
       T.BELONG_NAME,
       T.BELONG_CODE,
       MIN(T.CREATE_NAME) CREATE_NAME,
       MIN(TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS')) CREATE_TIME,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       DECODE(T.GPTYPE,'1','铸坯','2','锻坯') GPTYPE,
       T.SEQUENCENO,
       T.FURNACENO,
       DECODE(T.QCM_STAUS,'00','合格','11','待处理','22','判废','10','处理合格','12','处理判废') QCM_STAUS,
       T.LG_CRAFT_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.PLAN_ROUTE,
       T.PRO_PLAN_ID_ZG,
       T.GX_PLAN_NO_ZG,
       SUM(T.ACT_COUNT) TAKE_COUNT,
       SUM(T.ACT_WEIGHT) TAKE_WEIGHT,
      (select GET_GP_BUTTRESS(T.JUDGE_STOVE_NO) from dual) STORAGE_NAME,
             (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.JUDGE_RESULT_CODE) JUDGE_RESULT_CODE,
         DECODE(T.JUDGE_FLAG,'1','是','/') JUDGE_FLAG,
        T.JUDGE_STOVE_NO_OLD
  FROM MAT_GP_M T
 WHERE 1 = 1
   AND T.MAT_ORIGIN_CODE != '801301'
   AND T.MNG_LOCK_FLAG = '0'
   AND T.LOCK_FLAG='0'
   AND T.OUTSOURCING_FLAG='0'
              ]]>
	</query>
	<query id="FrmPlanSteelMakMod.QueryMatGp" desc="查询管坯物料状态">
             <![CDATA[ 
SELECT *
  FROM (SELECT T.*
          FROM MAT_GP_M T
         WHERE T.MNG_LOCK_FLAG = '0'
           AND T.LOCK_FLAG = '0'
           AND T.HANGING_FLAG='0'
           AND T.OUTSOURCING_FLAG='0'
           AND T.QCM_STAUS='00'
           AND T.JUDGE_STOVE_NO = ?
           AND T.ACT_LEN = ?
           AND T.FIX_LEN = ?
           AND T.FIX_NUM = ?
              ]]>
	</query>
	<query id="FrmPlanSteelMakMod.QueryMatGpTD" desc="查询管坯物料状态（脱单）">
             <![CDATA[ 
SELECT T.* FROM MAT_GP_M T
         WHERE T.MAT_STATUS IN ('80150101','80150102')
           AND T.QCM_STAUS='00'
           AND T.JUDGE_STOVE_NO = ?
           AND T.ACT_LEN = ?
           AND T.FIX_LEN = ?
           AND T.FIX_NUM = ?
              ]]>
	</query>
	<query id="FrmPlanSteelMakMod.UpdateMatGp" desc="修改坯子库存信息">
             <![CDATA[     
    UPDATE MAT_GP_M T
       SET T.PRO_PLAN_ID_ZG = ?,
           T.GX_PLAN_NO_ZG  = ?,
           T.ORDER_NO       =?,
           T.ORDER_SEQ      =?,
           T.ORDER_SEQ_NO   =?,
           T.ORD_PK         =?,
           T.ORD_LN_PK      =?,
           T.ORD_LN_DLY_PK  =?,
           T.LK_FLAG        =?,
           T.PRO_PLAN_ID    =?,
           T.GX_PLAN_NO     =?,
           T.MAT_STATUS     =?,
           T.HANGING_FLAG     =?
             ]]>
	</query>
	<!--  T.MATERIAL_NO         = ?,
       T.MATERIAL_NAME       = ?,
       T.INPUT_MATERIAL_NAME = ?,
       T.INPUT_MATERIAL_NO   = ?,
       T.GRADECODE           = ?,
       T.GRADENAME           = ?,
       T.CIC                 = ?,
       T.OLD_GRADECODE       = ?,
       T.OLD_GRADENAME       = ?,
       T.OLD_CIC             = ?,
       T.OLD_MATERIAL_NO     =?,
       T.OLD_MATERIAL_NAME   =? -->
	<query id="FrmPlanSteelMakMod.UpdateMatGpOld" desc="利不同钢种修改坯子库存信息">
             <![CDATA[     
   UPDATE MAT_GP_M T
   SET T.PRO_PLAN_ID_ZG      = ?,
       T.GX_PLAN_NO_ZG       = ?,
       T.ORDER_NO            = ?,
       T.ORDER_SEQ           = ?,
       T.ORDER_SEQ_NO        = ?,
       T.ORD_PK              = ?,
       T.ORD_LN_PK           = ?,
       T.ORD_LN_DLY_PK       = ?,
       T.LK_FLAG             = ?,
       T.PRO_PLAN_ID         = ?,
       T.GX_PLAN_NO          = ?,
       T.MAT_STATUS          = ?,
       T.HANGING_FLAG        = ?
       
             ]]>
	</query>
	<query id="FrmPlanSteelMakMod.selectPlnOrderZgS" desc="查询轧管订单">
             <![CDATA[
         SELECT ZG.* FROM (SELECT 
           (SELECT LISTAGG(C1.GRADECODE, ',') WITHIN GROUP(ORDER BY C1.PRIORITY ASC, C1.GRADECODE)
  FROM (SELECT DISTINCT B.GRADENAME,
                        B.GRADECODE,
                        B.PRIORITY,
                        C.CRAFT_SEQ,
                        S.ORD_LN_DLY_PK,
                        B.MSC_PLINE
          FROM CRAFT_ORD_DESIGN_MSC_PL_GZ B,
               CRAFT_ORD_DESIGN_MSC_PL    B1,
               pln_saleord                s,
               CRAFT_ORD_DESIGN           c
         WHERE B.DESGIN_KEY = B1.DESGIN_KEY
           AND B.MSC_PLINE = B1.MSC_PLINE
           AND C.ORD_LN_PK = S.ORD_LN_PK
           AND B.DESGIN_KEY = C.DESGIN_KEY
         ORDER BY B.PRIORITY ASC, B.GRADECODE ASC) C1
 WHERE C1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND C1.CRAFT_SEQ =T.CRAFT_SEQ
   AND C1.MSC_PLINE=T.INDEX_SEQ) GRADE_ALL,
           T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.DIAMETER_GP,
       T.LEN_GP_SINGLE,
       T.ROLL_LENGTH,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.OUTNUM_CUT,
       T.DIAMETER_MANDREL,
       T.PASS_CODE,
       T.PASS_NAME,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       NVL(T.WEIGTH_S,0) WEIGTH_S,
       NVL(T.NUM_S,0) NUM_S,
       NVL(T.MATCH_WT_IN,0) MATCH_WT_IN,
       NVL(T.MATCH_NUM_IN,0) MATCH_NUM_IN,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.PRO_MONTH,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       DECODE(T.IS_PLAN_OK, '1', '是', '/') IS_PLAN_OK,
       DECODE(T.GPREQ_IF_OK, '1', '是', '/') GPREQ_IF_OK,
       DECODE(T.GPREQ_IF_DZ, '1', '是', '/') GPREQ_IF_DZ,
       T.GPREQ_ID,
       T.ZY_BATCH_ID,
       T.CIC_GROUP_GP,
       T.PIC_GROUP_GP,
       T.SIC_GROUP_GP,
       T.DIC_GROUP_GP,
       T.WIC_GROUP_GP,
       T.GIC_GROUP_GP,
       T.CIC_GP,
       T.PIC_GP,
       T.SIC_GP,
       T.DIC_GP,
       T.WIC_GP,
       T.GIC_GP,
       T.TUBE_END_RATIO,
       T.GPREQ_NUM,
       T.GPREQ_WEIGHT,
       NVL(T.GPREQ_WEIGHT_MIN,0) GPREQ_WEIGHT_MIN,
       T.PLANS_NUM,
       T.WEIGTH_S_MIN,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       DECODE(T.OUTS_BILLET_FL, '0', '自炼', '1', '外购') OUTS_BILLET_FL,
       T.WHOLE_BACKLOG_DESC,
       T.PLINE_NAME_ZZ,
       T.OUTDIAMETER_ZG,
       T.WALLTHICK_ZG,
       T2.GRADECODE_ALL,
       (SELECT C.ABRVITION
          FROM SLM_BASE_CUSTOMER C
         WHERE C.CUSTOMER_NO = T1.FINAL_USER) FINAL_USER_DESC,
       T3.STATION_DESC STATION_ROAD_LG,
       DECODE((SELECT TO_CHAR(WM_CONCAT(PRL.STATION_CODE))
                FROM SLM_ORDER_LINE_PRDCR_LST PRL, SLM_ORDER_LINE_PRDCR PR
               WHERE PRL.PRDCR_NO = PR.PRDCR_NO
                 AND PRL.PRDCR_INDEX = PR.PRDCR_INDEX
                 AND PRL.PROCESS_CODE = 'A'
                 AND PR.PRDCR_NO = T.PRDCR_NO
                 AND PR.CODE_JG IS NULL
                 AND PR.CODE_BL IS NULL
                 AND PR.MSC_PLINE = T2.INDEX_SEQ),
              NULL,
              '否',
              '是') IF_MONITOR_LG,
       T1.PRODUCNAME,
       Q1.CRAFT_PATH,
       DECODE(T.STATE_SINGLE, '0', '正常', '1', '利库', '2', '脱单') STATE_SINGLE,
       T.GRADECODE_LK,
       T.GRADENAME_LK,
       T.CIC_GROUP_LK,
       (SELECT GET_GP_MAT_WT_ZL(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) FurnWt,
       (SELECT GET_GP_MAT_NUM_ZL(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) FurnNum,
       (SELECT GET_GP_PLNZGM_NUM(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) LJNUM,
       (SELECT GET_GP_PLNZGM_WT(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) LJWEIGHT,
       (SELECT GET_GP_WT_CK(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) OUT_WT,
       (SELECT GET_GP_NUM_CK(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) OUT_NUM,
       (SELECT GET_ZG_REDUCED_WT(T.PRO_PLAN_ID, T.GX_PLAN_NO) FROM DUAL) REDUCED_WT
  FROM PLN_ORDER_ZG_S T,
       PLN_SALEORD T1,
       PLN_SALEORD_PROC T2,
       CRAFT_ORD_DESIGN Q1,
       (SELECT LISTAGG(STATION_DESC, '') WITHIN GROUP(ORDER BY STATION_CODE) STATION_DESC,
               PRO_PLAN_ID,
               GX_PLAN_NO
          FROM (SELECT DISTINCT CASE
                                  WHEN S.STATION_DESC = '电炉' THEN
                                   'E'
                                  WHEN S.STATION_DESC = '炉外精炼' THEN
                                   'L'
                                  WHEN S.STATION_DESC = '真空处理' THEN
                                   'V'
                                  WHEN S.STATION_DESC = '熔炼成分' THEN
                                   'C'
                                  ELSE
                                   ''
                                END STATION_DESC,
                                S.STATION_CODE,
                                T4.PRO_PLAN_ID,
                                T4.GX_PLAN_NO
                  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
                 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 C1.PROCESS_CODE IN ('A')
                 GROUP BY T4.PRO_PLAN_ID,
                          S.STATION_DESC,
                          S.STATION_CODE,
                          T4.GX_PLAN_NO)
         GROUP BY PRO_PLAN_ID, GX_PLAN_NO) T3
 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
   AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
   AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
   AND T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
   AND Q1.ORD_LN_PK = T1.ORD_LN_PK
   AND Q1.CRAFT_SEQ = T.CRAFT_SEQ
   AND T.PRO_PLAN_ID = T3.PRO_PLAN_ID(+)
   AND T.GX_PLAN_NO = T3.GX_PLAN_NO(+)             
                 ]]>
	</query>
	<query id="FrmPlanSteelMakMod.getOrderBInfo" desc="查询铸造生产订单信息">
             <![CDATA[
                SELECT H.*
  FROM (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,
               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,
               T1.FINAL_USER_DESC,
               T1.ORDER_SEQ_NO,
               T2.PDEPT_NAME,
               T1.PRODUCNAME,
               T.CAST_NO_ALL,
               T1.EXE_STATUS_ZG,
               T.PROGY_MEMO,
               T.CRAFT_NO,
               DECODE(T.IF_CONFIRM, '1', '是', '/') IF_CONFIRM,
               T.CRAFT_PATH,
               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,
               B6.GRADECODEZG
          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
                  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(GZ.GRADECODE, ',') WITHIN GROUP(ORDER BY GZ.GRADECODE) GRADECODEZG,
                       GZ.GPREQ_ID
                  FROM (SELECT B.GPREQ_ID, B4.GRADECODE, B4.GRADENAME
                          FROM PLN_ORDER_ZG_S             B,
                               PLN_ORDER_CAST_S           B1,
                               PLN_SALEORD                B2,
                               CRAFT_ORD_DESIGN           B3,
                               CRAFT_ORD_DESIGN_MSC_PL_GZ B4,
                               CRAFT_ORD_DESIGN_MSC_PL    B5
                         WHERE B.GPREQ_ID = B1.PRO_PLAN_ID
                           AND B2.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
                           AND B3.ORD_LN_PK = B2.ORD_LN_PK
                           AND B3.CRAFT_SEQ = B.CRAFT_SEQ
                           AND B4.DESGIN_KEY = B3.DESGIN_KEY
                           AND B5.DESGIN_KEY = B3.DESGIN_KEY
                           AND B4.DESGIN_KEY = B5.DESGIN_KEY
                           AND B5.MSC_PLINE = B.INDEX_SEQ
                           AND B4.MSC_PLINE = B5.MSC_PLINE
                           AND B.EXE_STATUS = '0'
                           AND B1.EXE_STATUS = '0'
                         GROUP BY B.GPREQ_ID, B4.GRADECODE, B4.GRADENAME) GZ
                 GROUP BY GZ.GPREQ_ID) B6
         WHERE 1 = 1
           AND T.PRO_PLAN_ID = T1.GPREQ_ID(+)
           AND T.PRDCR_NO = T2.PRDCR_NO(+)
           AND T.PRO_PLAN_ID = B6.GPREQ_ID(+)

                 ]]>
	</query>
	<query id="FrmPlanSteelMakMod.queryMatWeigth" desc="查询库存吨数">
		<![CDATA[
		SELECT NVL(SUM(T1.ACT_WEIGHT), 0) ACT_WEIGHT
  FROM (SELECT T.ACT_WEIGHT
          FROM MAT_GP_M T
         WHERE 1=1     
		]]>
	</query>
	<query id="FrmPlanSteelMakMod.updatePlnDzM" desc="修改锻造虚拟炉计划">
		<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (select SUM(T.PLAN_INDOUBLE_NUM * T.CUT_NUM_GP) V_NUM,
                       SUM(T.PLAN_INDOUBLE_WT) V_WT
                  from PLN_ZY_DZ_C T
                 where T.HEAT_PLAN_NO = ?) LOOP
    UPDATE PLN_ZY_DZ_M T
       SET T.PLN_INSINGLE_NUM  = MYROW.V_NUM,
           T.PLN_INSINGLE_WT   = MYROW.V_WT,
           T.PLN_INDOUBLE_NUM  = MYROW.V_NUM,
           T.PLN_INDOUBLE_WT   = MYROW.V_WT,
           T.PLN_OUTSINGLE_NUM = MYROW.V_NUM,
           T.PLN_OUTSINGLE_W   = MYROW.V_WT,
           T.PLN_OUTDOUBLE_NUM = MYROW.V_NUM,
           T.PLN_OUTDOUBLE_W   = MYROW.V_WT
     WHERE T.HEAT_PLAN_NO = ?;
  END LOOP;
END;
		]]>
	</query>
	<query id="FrmPlanSteelMakMod.getOrderBInfoByContionDz" desc="查询锻造生产订单信息">
             <![CDATA[
SELECT CASE
         WHEN TO_NUMBER(T3.NUM_S) - TO_NUMBER(T3.BATCHED_NUM) <= 0 THEN
          0
         ELSE
          TO_NUMBER(T3.NUM_S) - TO_NUMBER(T3.BATCHED_NUM)
       END NUM_LK,
       CASE
         WHEN TO_NUMBER(T3.NUM_S) - TO_NUMBER(T3.BATCHED_NUM) <= 0 THEN
          0
         ELSE
          TO_NUMBER(T3.WEIGTH_S) - TO_NUMBER(T3.BATCHED_WT)
       END WEIGHT_LK,
 T3.* FROM (SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       DECODE(T.CASTINGTYPE, '1', '连铸', '2', '模铸', '') CASTINGTYPE,
       T.GRADECODE,
       T.GRADENAME,
       T.DIAMETER_OUT,
       T.LENGTH_OUT,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.OUT_WT_ONE,
       T.OUT_WT_TOT,
       T.OUT_NUM_TOT,
       T.DIAMETER_IN,
       T.LENGTH_IN,
       T.WT_ONE_IN,
       T.WLID_IN,
       T.WLDESC_IN,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.DZ_LOSE_ADD,
       T.DZ_CUT_HEAD_END,
       T.DZ_BURN_LOSE,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       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,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       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.ZY_BATCH_ID,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.GPREQ_ID,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       (SELECT TO_CHAR(WM_CONCAT(S1.ORDER_NO_SEQ)) ORDER_NO_SEQ
          FROM (SELECT S.ORDER_NO || '/' || S.ORDER_SEQ ORDER_NO_SEQ,
                       S.GPREQ_ID
                  FROM PLN_ORDER_ZG_S S, PLN_ORDER_DZ_S T1
                 WHERE S.GPREQ_ID IS NOT NULL
                   AND S.GPREQ_ID = T1.PRO_PLAN_ID
                 GROUP BY S.GPREQ_ID, S.ORDER_NO, S.ORDER_SEQ) S1
         WHERE S1.GPREQ_ID = T.PRO_PLAN_ID) ORDER_NO_SEQ,
       (SELECT NVL(SUM(T1.PLN_INSINGLE_NUM), 0)
          FROM PLN_ZY_DZ_M T1
         WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND T1.GX_PLAN_NO = T.GX_PLAN_NO) BATCHED_NUM,
       (SELECT NVL(SUM(T1.PLN_INSINGLE_WT), 0)
          FROM PLN_ZY_DZ_M T1
         WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND T1.GX_PLAN_NO = T.GX_PLAN_NO) BATCHED_WT
  FROM PLN_ORDER_DZ_S T
 WHERE 1 = 1
             
             ]]>
	</query>
	<query id="FrmPlanSteelMakMod.getOrderZz" desc="查询锻造订单对应铸造订单">
             <![CDATA[          
SELECT T2.* FROM (
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
  FROM PLN_ORDER_CAST_S T
 WHERE T.PRO_PLAN_ID = ?) T2
 WHERE T2.CAN_WGT>0
 ORDER BY T2.CAN_WGT ASC
               ]]>
	</query>
	<query id="FrmPlanSteelMakMod.updateZgM" desc="修改轧管虚拟炉计划量">
             <![CDATA[ 
             UPDATE PLN_ZY_ZG_M T set
 T.PLN_INSINGLE_NUM = TO_NUMBER(T.PLN_INSINGLE_NUM) + TO_NUMBER(?),
 T.PLN_INSINGLE_WT = TO_NUMBER(T.PLN_INSINGLE_WT) + TO_NUMBER(?),
 T.PLN_OUTSINGLE_NUM = TO_NUMBER(T.PLN_OUTSINGLE_NUM) + TO_NUMBER(?),
 T.PLN_OUTSINGLE_W = TO_NUMBER(T.PLN_OUTSINGLE_W) + TO_NUMBER(?),
 T.REDUCED_WT = TO_NUMBER(T.REDUCED_WT) + TO_NUMBER(?)
 WHERE T.HEAT_PLAN_NO = ?
             
              ]]>
	</query>   
	<query id="FrmPlanSteelMakMod.queryCic" desc="获取炼钢CIC">
		<![CDATA[
SELECT DISTINCT C.CIC, D.GRADECODE
  FROM PLN_ORDER_ZG_S           T,
       PLN_SALEORD              T1,
       CRAFT_ORD_DESIGN         M,
       CRAFT_ORD_DESIGN_STD_CIC C,
       COM_MSC_STD_CIC          D
 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND M.ORD_LN_PK = T1.ORD_LN_PK
   AND M.CRAFT_SEQ = T.CRAFT_SEQ
   AND C.DESGIN_KEY = M.DESGIN_KEY
   AND C.MSC_PLINE = T.INDEX_SEQ
   AND C.PROCESS_CODE IN ('A')
   AND C.CIC = D.CIC
   AND D.GRADECODE = ?
   AND T.PRO_PLAN_ID =?
   AND T.GX_PLAN_NO = ?
		]]>
	</query>
	<query id = "FrmPlanSteelMakMod.UpdatePlnOrdCic" desc = "修改连铸计划CIC">
		UPDATE PLN_STEELFOR_ORD T
		SET T.OLD_CIC = T.CIC, T.CIC = ?
		WHERE T.PRO_PLAN_ID = ?
		AND T.GX_PLAN_NO = ?
		AND T.JUDGE_STOVE_NO = ?
	</query>
</queryMap>