<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="利库">
	<query id="FrmPlanMaterialSelection.queryMaterial" desc="查询库存管坯物料">
            <![CDATA[
    SELECT T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.STOVE_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       CASE
         WHEN T.PRO_PLAN_ID_ZG IS NULL THEN
          ''
         ELSE
          T.PRO_PLAN_ID_ZG || '/' || T.GX_PLAN_NO_ZG
       END PRO_PLAN_ID_ZG,
       T.GX_PLAN_NO_ZG,
       T.GRADECODE,
       T.GRADENAME,
       T.DIMATER,
       T.ACT_LEN- NVL(T.CUT_YU_LONG,0) ACT_LEN,
       T.FIX_NUM,
       T.FIX_LEN,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.DB_ACT_COUNT) DB_ACT_COUNT,
       (SELECT I.BASENAME
          FROM COM_BASE_INFO I
         WHERE I.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT I.BASENAME
          FROM COM_BASE_INFO I
         WHERE I.BASECODE = T.MAT_STATUS) MAT_STATUS,
       T.CHEM_JUDGE_ID,
       MIN(T.INSTOCK_TIME) INSTOCK_TIME,
       S.AIMLENGTH,
       S.ROLL_LENGTH,
       S.LEN_CUTHEAD,
       S.LEN_CUTEND,
       S.OUTNUM_CUT,
       T.ACT_LEN- NVL(T.CUT_YU_LONG,0) ACT_LEN_TAKE,
       SUM(T.ACT_COUNT) TAKE_COUNT,
       SUM(T.ACT_WEIGHT) TAKE_WEIGHT,
       NVL(T.CUT_YU_LONG,0) CUT_YU_LONG,T.MAT_STATUS MAT_STATUS1,
       '不切' Cut_Tybe,
       '正常计划' PLN_TYPE,
       DECODE(t.HANGING_FLAG,'1','是','/') HANGING_FLAG,T.CIC,T.FIX_NUM CUT_NUM_GP,T.BELONG_NAME,
       T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO,
       (select GET_GP_BUTTRESS(T.JUDGE_STOVE_NO) from dual) STORAGE_NAME,
       T.SUPPLY_UNIT_CODE,
       T.SUPPLY_UNIT,
       DECODE(T.IS_DEALER,'0','否','1','双经销','3','定销订购','4','否')IS_DEALER
FROM MAT_GP_M T, PLN_ORDER_ZG_S S
WHERE  T.PRO_PLAN_ID_ZG = S.PRO_PLAN_ID(+)
   AND T.GX_PLAN_NO_ZG = S.GX_PLAN_NO(+)
   AND T.PRODUCT_FLAG = '801401'
   AND ((T.MAT_STATUS = '80150102' AND T.JUDGE_RESULT_CODE = '40740701') OR (T.INSTANCY_FLAG = '1'))
   AND T.QCM_STAUS='00'
   AND T.DIMATER NOT LIKE '%t%'
   AND T.MNG_LOCK_FLAG='0'
   AND T.LOCK_FLAG='0'
   AND INSTR(?, T.DIMATER) > 0
   
              ]]>
	</query>
	<query id="FrmPlanMaterialSelection.addPlnZyZgM" 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,
        FLAG_STOVE_NO,
        INDEX_SEQ,PLN_TYPE,REDUCED_WT)
 VALUES( 
        '#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#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'), 
        '#FLAG_STOVE_NO#',
        '#INDEX_SEQ#','#PLN_TYPE#','#REDUCED_WT#')
             ]]>
	</query>
	<query id="FrmPlanMaterialSelection.addPlnZyZgC" desc="新增轧管实际炉计划">
             <![CDATA[  
              INSERT INTO PLN_ZY_ZG_C(
        HEAT_PLAN_NO,
        HEAT_PLAN_SQE,
        JUGDE_APPLY_CODE,
        ZY_BATCH_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        PLINE_CODE,
        PLINE_NAME,
        DIAMETER,
        LEN_GP_SINGLE,
        WT_GP_SINGLE,
        CUT_NUM_GP,
        LENGTH_M,
        WEIGHT_M,
        PLAN_INDOUBLE_NUM,
        PLAN_INDOUBLE_WT,
        REAL_INDOUBLE_NUM,
        REAL_INDOUBLE_WT,
        FLAG_STOVE_NO,
        CREATE_NAME,
        CREATE_TIME,CUT_TARGET,CUT_LENGTH,CUT_WEIGHT,CUT_NUM_OLD,LEN_GP_SINGLE_OLD,LENGTH_M_OLD,PLAN_WEIGTH)
 VALUES( 
        '#HEAT_PLAN_NO#',
        '#HEAT_PLAN_SQE#',
        '#JUGDE_APPLY_CODE#',
        '#ZY_BATCH_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#DIAMETER#',
        '#LEN_GP_SINGLE#',
        '#WT_GP_SINGLE#',
        '#CUT_NUM_GP#',
        '#LENGTH_M#',
        '#WEIGHT_M#',
        '#PLAN_INDOUBLE_NUM#',
        '#PLAN_INDOUBLE_WT#',
        '#REAL_INDOUBLE_NUM#',
        '#REAL_INDOUBLE_WT#',
        '#FLAG_STOVE_NO#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),'#CUT_TARGET#','#CUT_LENGTH#',
        '#CUT_WEIGHT#','#CUT_NUM_OLD#','#LEN_GP_SINGLE_OLD#','#LENGTH_M_OLD#','#PLAN_WEIGTH#')
              ]]>
	</query>
	<query id="FrmPlanMaterialSelection.UpdateMatGp" desc="修改坯子库存信息">
             <![CDATA[     
    UPDATE MAT_GP_M T
       SET T.MAT_STATUS     = ?,
           T.HANGING_FLAG   = ?,
           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.CUT_YU_LONG    =?,
           T.LK_FLAG        =?,
           T.CIC=?,
           t.PIC=?,
           T.SIC=?,
           T.DIC=?
     WHERE T.MAT_NO =?
       AND T.MNG_LOCK_FLAG='0'
       AND T.LOCK_FLAG='0'
             ]]>
	</query>
	<query id="FrmPlanMaterialSelection.QueryMatGp" desc="查询管坯物料状态">
             <![CDATA[ 
Select * from (SELECT T.*
  FROM MAT_GP_M T
 WHERE T.QCM_STAUS = '00'
   AND T.HANGING_FLAG='0'
   AND T.MNG_LOCK_FLAG='0'
   AND T.LOCK_FLAG='0'
   AND T.JUDGE_STOVE_NO = ?
   AND ((T.MAT_STATUS = '80150102' AND T.JUDGE_RESULT_CODE = '40740701') OR (T.INSTANCY_FLAG = '1'))
              ]]>
	</query>
	<query id="FrmPlanMaterialSelection.UpdatePlnOrderZgS" desc="修改轧管利库支吨">
             <![CDATA[  
UPDATE PLN_ORDER_ZG_S T
   SET T.STATE_SINGLE  = ?,
       T.BATCHED_WT_G  = TO_NUMBER(NVL(T.BATCHED_WT_G, 0)) + TO_NUMBER(?),
       T.BATCHED_NUM_G = TO_NUMBER(NVL(T.BATCHED_NUM_G, 0)) + TO_NUMBER(?),
       T.MATCH_WT_IN  = TO_NUMBER(NVL(T.MATCH_WT_IN, 0)) + TO_NUMBER(?),
       T.MATCH_NUM_IN = TO_NUMBER(NVL(T.MATCH_NUM_IN, 0)) + TO_NUMBER(?)
 WHERE T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ? 
             ]]>
	</query>
	<query id="FrmPlanMaterialSelection.QueryZgPlanM" desc="查询是否生成虚拟炉计划">
             <![CDATA[  
             SELECT T.*
  FROM PLN_ZY_ZG_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?        
               ]]>
	</query>
	<query id="FrmPlanMaterialSelection.addMatGpTrack" desc="新增利库，脱单日志表">
             <![CDATA[  
              INSERT INTO MAT_GP_TRACK(
        RESUME_SEQ,
        EVENT_ID,
        EVENT_DESC,
        FORM_NAME,
        CALL_FUNC_CODING,
        KEYVALUE_1,
        KEYVALUE_1_DESC,
        KEYVALUE_2,
        KEYVALUE_2_DESC2,
        KEYVALUE_3,
        KEYVALUE_3_DESC3,
        KEYVALUE_4,
        KEYVALUE_4_DESC4,
        KEYVALUE_5,
        KEYVALUE_5_DESC5,
        KEYVALUE_6,
        KEYVALUE_6_DESC6,
        KEYVALUE_7,
        KEYVALUE_7_DESC7,
        MAT_NO,
        MAT_SQE_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        STOVE_NO,
        FLAG_STOVE_NO,
        LOT_NO,
        JUDGE_STOVE_NO,
        GROUD_NO,
        BATCH_NO,
        CAST_NO,
        CCMID,
        GRADECODE,
        GRADENAME,
        STD_CODE,
        STD_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_FIX_NUM,
        ACT_FIX_LEN,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        PRO_ORDER_NO,
        PRO_ORDER_ID,
        PRO_ORDER_NO1,
        PRO_ORDER_ID1,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        OLD_ORD_PK,
        OLD_ORD_LN_PK,
        OLD_ORD_LN_DLY_PK,
        OLD_ORDER_NO,
        OLD_ORDER_SEQ,
        OLD_ORDER_SEQ_NO,
        BELONG_CODE,
        BELONG_NAME,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        DEPARTMENT_CODE,
        DEPARTMENT_DESC,
        MANAGEMENT_NO,
        MANAGEMENT_NAME,
        OLD_JUDGE_STOVE_NO,
        OLD_GROUD_NO,
        OLD_BATCH_NO,
        OLD_GRADECODE,
        OLD_GRADENAME,
        OLD_STD_CODE,
        OLD_STD_NAME,
        OLD_STOVE_NO)
 VALUES( 
        '#RESUME_SEQ#',
        '#EVENT_ID#',
        '#EVENT_DESC#',
        '#FORM_NAME#',
        '#CALL_FUNC_CODING#',
        '#KEYVALUE1#',
        '#KEYVALUE1_DESC#',
        '#KEYVALUE2#',
        '#KEYVALUE2_DESC2#',
        '#KEYVALUE3#',
        '#KEYVALUE3_DESC3#',
        '#KEYVALUE4#',
        '#KEYVALUE4_DESC4#',
        '#KEYVALUE5#',
        '#KEYVALUE5_DESC5#',
        '#KEYVALUE6#',
        '#KEYVALUE6_DESC6#',
        '#KEYVALUE7#',
        '#KEYVALUE7_DESC7#',
        '#MAT_NO#',
        '#MAT_SQE_NO#',
        '#PRODUCT_FLAG#',
        '#MAT_STATUS#',
        '#STOVE_NO#',
        '#FLAG_STOVE_NO#',
        '#LOT_NO#',
        '#JUDGE_STOVE_NO#',
        '#GROUD_NO#',
        '#BATCH_NO#',
        '#CAST_NO#',
        '#CCMID#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#ACT_DIMATER#',
        '#ACT_HEIGHT#',
        '#ACT_LEN#',
        '#ACT_LEN_MIN#',
        '#ACT_LEN_MAX#',
        '#ACT_FIX_NUM#',
        '#ACT_FIX_LEN#',
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        '#ACT_THEORY_WEIGHT#',
        '#PRO_ORDER_NO#',
        '#PRO_ORDER_ID#',
        '#PRO_ORDER_NO1#',
        '#PRO_ORDER_ID1#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORD_LN_DLY_PK#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#ORDER_SEQ_NO#',
        '#OLD_ORD_PK#',
        '#OLD_ORD_LN_PK#',
        '#OLD_ORD_LN_DLY_PK#',
        '#OLD_ORDER_NO#',
        '#OLD_ORDER_SEQ#',
        '#OLD_ORDER_SEQ_NO#',
        '#BELONG_CODE#',
        '#BELONG_NAME#',
        '#MEMO#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#DEPARTMENT_CODE#',
        '#DEPARTMENT_DESC#',
        '#MANAGEMENT_NO#',
        '#MANAGEMENT_NAME#',
        '#OLD_JUDGE_STOVE_NO#',
        '#OLD_GROUD_NO#',
        '#OLD_BATCH_NO#',
        '#OLD_GRADECODE#',
        '#OLD_GRADENAME#',
        '#OLD_STD_CODE#',
        '#OLD_STD_NAME#',
        '#OLD_STOVE_NO#')
              ]]>
	</query>
	<query id="FrmPlanMaterialSelection.queryZgMSStatus" desc="查询轧管订单排产">
		<![CDATA[
	SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.EXE_STATUS,
       T.GPREQ_ID,
       NVL(T.WEIGTH_S, 0) WEIGTH_S,
       NVL(T.WEIGTH_S_MIN, 0) WEIGTH_S_MIN,
       T.NUM_S,
       NVL(T.ADD_WT_IN, 0) ADD_WT_IN,
       T.CIC_GROUP_GP,
       T.CIC_GP,
       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.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.DIAMETER_GP,
       T.LEN_GP_SINGLE,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.PLINE_CODE,
       T.PLINE_NAME,
       NVL(B.LENGTH_COLDBED,0) LENGTH_COLDBED,
       NVL(T.ROLL_LENGTH,0) ROLL_LENGTH,
       NVL(B.LENGTH_MAX_RING, 0) LENGTH_MAX_RING,
       NVL(B.BURNOUT_RATE,0) BURNOUT_RATE,
       NVL(B.LENGTH_MAX_TUBE, 0) LENGTH_MAX_TUBE,
       NVL(B.LENGTH_MIN_TUBE, 0) LENGTH_MIN_TUBE,
       NVL(B.TOLERANCE_ZONE, 0) TOLERANCE_ZONE,
       T1.MODEL_DESC,
       NVL(T1.SIGL_LEN, 0) SIGL_LEN,
       T1.SHRT_STOVE,
       NVL(T1.SHRT_LEN_RATO, 0) SHRT_LEN_RATO,
       NVL(T1.SHORTEST, 0) SHORTEST,
       NVL(T.LEN_ROLL_MAX, 0) LENGTHMAX,
       NVL(T.LEN_ROLL_MIN, 0) LENGTHMIN,
       NVL(T1.OUTDIAMETER, 0) OUTDIAMETER,
       NVL(T1.WALLTHICK, 0) WALLTHICK,
       T1.TOTLENGTH,
       T1.ORDER_UNIT,
       T1.LEN_NO,
       NVL(T1.AVG_LEN_MIN, 0) AVG_LEN_MIN,
       J.CHECK_J_VAL,
       L.INSPECTION_VALUE,
       NVL(T.DIAMETER_MANDREL, 0) DIAMETER_MANDREL,
       T.PASS_NAME,
       NVL(T.AIMWALLTHICK_OLD, 0) AIMWALLTHICK_OLD,
       NVL(T.WEIGTH_S_OLD, 0) WEIGTH_S_OLD,
       NVL(T.NUM_S_OLD, 0) NUM_S_OLD,
       (SELECT DESGIN_KEY
          FROM CRAFT_ORD_DESIGN O
         WHERE O.ORD_LN_PK = T1.ORD_LN_PK
           AND O.CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
       T.INDEX_SEQ,
       NVL(T1.ENDLEN_SPECSTD, 0) ENDLEN_SPECSTD,
       NVL(T.OUTNUM_CUT, 0) OUTNUM_CUT,
       NVL(T.AIMLENGTH, 0) AIMLENGTH,
       T.SIC_GP,
       T.SIC,
       T.PRO_MONTH,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.OUTS_BILLET_FL,
       L.OUTS_STL_PIPE_FL,
       L.LEN_DESC,
       L.LEN_MIN,
       L.LEN_MAX,
       L.CREATE_NAME FOUNDER_NAME,
       T1.LEN_NO_N,
       T.IS_PLAN_OK,
       T.IF_STOVE_ISSUED,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.ORDER_SOURCE,
       T1.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T1.LENGTHDISC_N,
       T.PASSIVE,
       T.VERIFY1,
       T.TUBE_END_RATIO,
       T.BOM,
       T.INDEX_SEQ,
       T.WHOLE_BACKLOG_DESC
  FROM PLN_ORDER_ZG_S T
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = T.PLINE_CODE
  LEFT JOIN PLN_SALEORD T1
    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
  LEFT JOIN SLM_ORDER_LINE L
    ON L.ORD_LN_PK = T1.ORD_LN_PK
  LEFT JOIN COM_MSC_JG J
    ON J.CODE_JG = T1.CODE_JG
 WHERE T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	<query id="FrmPlanMaterialSelection.queryBaseMaterialDPl" desc="查询轧管投入产出-产线能力">
		<![CDATA[
SELECT IN_MATERIAL_NO,
       OUT_MATERIAL_NO,
       PLINE_CODE,
       PLINE_NAME,
       NVL(HR_CAPCTY, 0) HR_CAPCTY,
       NVL(PRD_RATE, 0) PRD_RATE,
       NVL(DBL_LEN_MAX, 0) DBL_LEN_MAX,
       NVL(ROL_LEN_MIN, 0) ROL_LEN_MIN,
       NVL(ROL_LEN_MAX, 0) ROL_LEN_MAX,
       CROP_END,
       NVL(MANDREL_SIZE, 0) MANDREL_SIZE,
       DISABLE_FL,
       CROP_HEAD,
       NVL(WASTE_RATE, 0) WASTE_RATE,
       TUBE_END_RATIO
  FROM SLM_BASE_MATERIAL_D_PL T
			 WHERE T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND T.PLINE_CODE = ?
			   AND (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
		]]>
	</query>
	<query id="FrmPlanMaterialSelection.updatePlnZgM" 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_ZG_C T
                 WHERE T.HEAT_PLAN_NO = ?) LOOP
    UPDATE PLN_ZY_ZG_M T1
       SET T1.PLN_INSINGLE_NUM  = MYROW.V_NUM,
           T1.PLN_INSINGLE_WT   = MYROW.V_WT,
           T1.PLN_OUTSINGLE_NUM =MYROW.V_NUM*T1.OUTNUM_CUT ,
           T1.PLN_OUTSINGLE_W   = MYROW.V_NUM*?,
           T1.REDUCED_WT   = MYROW.V_NUM*?
     WHERE T1.HEAT_PLAN_NO = ?;
  END LOOP;
END;
		]]>
	</query>
	<query id="FrmPlanMaterialSelection.queryMatWeigth" desc="查询库存吨数">
		<![CDATA[
		SELECT NVL(SUM(T1.ACT_WEIGHT), 0) ACT_WEIGHT
  FROM (SELECT T.ACT_WEIGHT
          FROM MAT_GP_M T
         WHERE T.MAT_STATUS = '80150102'
           AND T.JUDGE_STOVE_NO = ?
           AND T.FIX_NUM = TO_NUMBER(?)
           AND T.ACT_LEN = TO_NUMBER(?)
           AND T.FIX_LEN = TO_NUMBER(?)
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM <= ?
		]]>
	</query>
	<query id="FrmPlanMaterialSelection.queryCastS" 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,
       NVL(T.PLAN_NUM_SOLD,0) PLAN_NUM_SOLD,
       NVL(T.PLAN_WT_SOLD,0) PLAN_WT_SOLD
  FROM PLN_ORDER_CAST_S T
 WHERE T.PRO_PLAN_ID = ?
   AND T.EXE_STATUS IN ('0', '1')
   
			]]>
	</query>
	<query id="FrmPlanMaterialSelection.queryOrdStee" desc="通过判定炉号,管坯需求号查询组炉信息">
		<![CDATA[
		SELECT COUNT(*) COUNT
  FROM PLN_STEELFOR_ORD T,
       (SELECT M.PRO_PLAN_ID, M.GX_PLAN_NO, M.MERGE_NO
          FROM PLN_STEELFOR_MERGE M
         GROUP BY M.PRO_PLAN_ID, M.GX_PLAN_NO, M.MERGE_NO) T1
 WHERE T.MERGE_NO = T1.MERGE_NO(+)
   AND T.SURPLUSFLAG = '0'
   AND T.PRO_PLAN_ID = ?
   AND T.JUDGE_STOVE_NO = ?
			]]>
	</query>
		<query id="FrmPlanMaterialSelection.UpdateOrdStee" desc="修改铸造订单利库浪">
		<![CDATA[
		UPDATE PLN_ORDER_CAST_S T
   SET T.PLAN_NUM_SOLD = TO_NUMBER(NVL(T.PLAN_NUM_SOLD, 0)) + TO_NUMBER(?),
       T.PLAN_WT_SOLD  = TO_NUMBER(NVL(T.PLAN_WT_SOLD, 0)) + TO_NUMBER(?)
 WHERE T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
		
			]]>
	</query>
	<query id="FrmPlanMaterialSelection.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.GRADENAME = ?
   AND T.PRO_PLAN_ID =?
   AND T.GX_PLAN_NO = ?
		]]>
	</query>
	<query id = "FrmPlanMaterialSelection.UpdateMatGp" desc = "修改管坯库存">

	</query>
	<query id = "FrmPlanMaterialSelection.queryMatGpInfo" desc = "查询详细库存信息">
		SELECT T.STOVE_NO,
		T.JUDGE_STOVE_NO,
		SUM(T.ACT_COUNT) ACT_COUNT,
		SUM(T.ACT_WEIGHT) ACT_WEIGHT,
		DECODE(T.IS_DEALER, '0', '自用', '1', '双经销', '2', '来料加工') IS_DEALER,
		DECODE(T.MAT_STATUS,
		'80150101',
		'材料产出待判',
		'80150102',
		'材料产出(已判定)') MAT_STATUS,
		(SELECT T1.STORAGE_NAME
		FROM YDM_BS_STORAGE T1
		WHERE T1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME,
		(SELECT T2.LOCATION_NAME
		FROM YDM_BS_LOCATION T2
		WHERE T2.LOCATION_NO = S.LOCATION_NO) LOCATION_NAME,
		S.LARY_NO,
		T.ACT_LEN,
		T.CIC,
		T.CHEM_JUDGE_ID,
		S.LOCATION_NO
		FROM MAT_GP_M T
		LEFT JOIN YDM_GP_BUTTRESS S
		ON T.MAT_NO = S.MAT_NO
		WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
		AND T.IS_DEALER IN( #IS_DEALER#)
		AND T.MAT_STATUS = '#MAT_STATUS#'
		AND T.ACT_LEN = '#ACT_LEN#'
		AND NVL(T.CIC,'/') = NVL('#CIC#','/')
		AND NVL(T.CHEM_JUDGE_ID,'/') = NVL('#CHEM_JUDGE_ID#','/')
		AND T.ORDER_NO||'/'||T.ORDER_SEQ = '#ORDER_NO#'
		GROUP BY T.STOVE_NO,
		T.JUDGE_STOVE_NO,
		T.IS_DEALER,
		T.MAT_STATUS,
		S.STORAGE_NO,
		S.LOCATION_NO,
		S.LARY_NO,
		T.ACT_LEN,
		T.CIC,
		T.CHEM_JUDGE_ID
	</query>
	<query id = "FrmPlanMaterialSelection.queryGpMatNo" desc = "查询详细材料号">
		<![CDATA[
		SELECT T.MAT_NO
		FROM MAT_GP_M T
		LEFT JOIN YDM_GP_BUTTRESS S
		ON T.MAT_NO = S.MAT_NO
		WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
		AND T.MAT_STATUS = '#MAT_STATUS#'
		AND T.ACT_LEN = '#ACT_LEN#'
		AND NVL(T.CIC,'/') = NVL('#CIC#','/')
		AND NVL(T.CHEM_JUDGE_ID,'/') = NVL('#CHEM_JUDGE_ID#','/')
		AND NVL(S.LOCATION_NO,'/') = NVL('#LOCATION_NO#','/')
		AND T.QCM_STAUS = '00'
		AND ROWNUM <= #ACT_COUNT#
		]]>
	</query>
	<query id = "FrmPlanMaterialSelection.insertMatNoNew" desc = "新插入套尺剩余长度、吨位">
		DECLARE
		V_MAT_NO        MAT_GP_M.MAT_NO%TYPE := NULL;
		V_LOCATION_NO   YDM_GP_BUTTRESS.LOCATION_NO%TYPE := NULL;
		V_LOCATION_NAME YDM_GP_BUTTRESS.LOCATION_NAME%TYPE := NULL;
		BEGIN
		IF ('#DIMATER#' = '500') THEN
		V_LOCATION_NO   := 'TTH100187';
		V_LOCATION_NAME := 'ST500A';
		ELSIF ('#DIMATER#' = '450') THEN
		V_LOCATION_NO   := 'TTH100186';
		V_LOCATION_NAME := 'ST450A';
		ELSIF ('#DIMATER#' = '400') THEN
		V_LOCATION_NO   := 'TTH100185';
		V_LOCATION_NAME := 'ST400A';
		ELSIF ('#DIMATER#' = '390') THEN
		V_LOCATION_NO   := 'TTH100184';
		V_LOCATION_NAME := 'ST390A';
		ELSIF ('#DIMATER#' = '380') THEN
		V_LOCATION_NO   := 'TTH100183';
		V_LOCATION_NAME := 'ST380A';
		ELSIF ('#DIMATER#' = '310') THEN
		V_LOCATION_NO   := 'TTH100182';
		V_LOCATION_NAME := 'ST310A';
		END IF;

		SELECT SUBSTR('#MAT_NO_OLD#', 0, LENGTH('#MAT_NO_OLD#') - 3) ||
		LPAD(NVL(MAX(SUBSTR(T1.MAT_NO, LENGTH(T1.MAT_NO) - 2)), 0) + 1,
		3,
		0)
		INTO V_MAT_NO
		FROM (SELECT MAT_NO
		FROM MAT_GP_M T
		WHERE T.STOVE_NO = '#STOVE_NO#'
		UNION ALL
		SELECT MAT_NO
		FROM MAT_GP_M_HISTORY T
		WHERE T.STOVE_NO = '#STOVE_NO#') T1;
		INSERT INTO MAT_GP_M
		SELECT V_MAT_NO,
		PRODUCT_FLAG,
		MAT_STATUS,
		STOVE_NO,
		FLAG_STOVE_NO,
		JUDGE_STOVE_NO,
		CAST_NO,
		CCMID,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		SOURE_CODE,
		SOURE_NAME,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		INPUT_ORIGIN_CODE,
		GRADECODE,
		GRADENAME,
		STD_CODE,
		STD_NAME,
		PRO_ORDER_NO,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		DIMATER,
		HEIGHT,
		'#ACT_LEN#',
		'#FIX_NUM#',
		'#FIX_LEN#',
		ACT_COUNT,
		'#ACT_WEIGHT#',
		ACT_THEORY_WEIGHT,
		PONDER_NO,
		PONDER_GROSS_WT,
		MEASURE_FLAG,
		STOVE_PRINT_FLAG,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		BELONG_CODE,
		BELONG_NAME,
		LOCK_FLAG,
		MNG_LOCK_FLAG,
		MNG_LOCK_RSN_CODE,
		MNG_LOCK_TIME,
		MNG_LOCK_MAKER,
		MNG_LOCK_REMARK,
		LOCK_RSN_CODE,
		LOCK_TIME,
		LOCK_MAKER,
		LOCK_REMARK,
		UNLOCK_TIME,
		UNLOCK_MAKER,
		UNLOCK_REMARK,
		OLD_ORDER_NO,
		OLD_ORDER_SEQ,
		OLD_ORDER_SEQ_NO,
		OLD_MATERIAL_NO,
		OLD_MATERIAL_NAME,
		REMAIN_RSN_CODE,
		REMAIN_JUGDE_TIME,
		REMAIN_JUGDE_MAKER,
		REMAIN_JUGDE_CODE,
		REMAIN_REMARK,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		JUGDE_SCAN_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_REPORT_NO,
		DETECT_RESULT_CODE,
		BUG_NO,
		BUG_DEAL,
		OUTSOURCING_DOC,
		OUTSOURCING_FLAG,
		SAMPLING_FLAG,
		SAMPLING_TYPE,
		SAMPLING_NO,
		CHECKOUT_NO,
		CHEM_STCHECK_NO,
		CHEM_PROCHECK_NO,
		INSTOCK_FLAG,
		SYSDATE,
		OUTSTOCK_TIME,
		PRO_BC,
		PRO_BZ,
		RPO_TIME,
		BAR_CODE,
		BEGINNING_FLAG,
		BAL_YEAR_MONTH,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		GROUD_NO,
		BUG_DEAL_CODE,
		SURFACE_CHECK_NO,
		CHEM_JUDGE_ID,
		PHY_JUDGE_ID,
		PHY_RESULT_ID,
		OLD_JUDGE_STOVE_NO,
		OLD_GROUD_NO,
		OLD_GRADECODE,
		OLD_GRADENAME,
		OLD_STD_CODE,
		OLD_STD_NAME,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		OLD_STOVE_NO,
		PRINT_STOVE_NO,
		PRO_PLAN_ID,
		GX_PLAN_NO,
		GPREQ_ID,
		DB_ACT_COUNT,
		CIC,
		PIC,
		SIC,
		DIC,
		GPTYPE,
		SEQUENCENO,
		FURNACENO,
		QCM_STAUS,
		HANGING_FLAG,
		LG_CRAFT_NO,
		ISENDGX,
		PRODUCCODE,
		PRODUCNAME,
		CRAFTNO,
		PLAN_ROUTE,
		PRO_PLAN_ID_ZG,
		GX_PLAN_NO_ZG,
		STEELCODE,
		STEELNAME,
		CUT_YU_LONG,
		LK_FLAG,
		STEEL_STANDRAD,
		JUDGE_ID,
		EF_PLINE_CODE,
		EF_PLINE_NAME,
		INSTANCY_FLAG,
		JUDGE_STOVE_NO_LG,
		OLD_CIC,
		JUDGE_FLAG,
		JUDGE_STOVE_NO_OLD,
		HEAT_PLAN_NO_NEXT,
		CUT_NUM,
		IS_DEALER,
		SUPPLY_UNIT_CODE,
		SUPPLY_UNIT,
		'2',
		'#MAT_NO_OLD#',
		'#IS_SETFOOT#',
		'#SETFOOT_SEQ#',
		PLAN_MEMO
		FROM MAT_GP_M T
		WHERE T.MAT_NO = '#MAT_NO#';

		INSERT INTO YDM_GP_BUTTRESS
		SELECT V_MAT_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		JUDGE_STOVE_NO,
		STORAGE_NO,
		V_LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		GROUD_NO,
		V_LOCATION_NAME,
		JUDGE_STOVE_NO_LG
		FROM YDM_GP_BUTTRESS
		WHERE MAT_NO = '#MAT_NO#';
		END;
	</query>
</queryMap>