<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "基础信息管理">
	<query id="FmisTool.addGpOutList" desc="增加管坯出库记录">
		<![CDATA[
	     DECLARE
  V_HEAT_PLAN_NO   PLN_ZY_ZG_M.HEAT_PLAN_NO%type := ?;
BEGIN
  FOR MYROW2 IN (SELECT *
                   FROM PLN_ZY_ZG_M T1
                  WHERE T1.HEAT_PLAN_NO = V_HEAT_PLAN_NO
                    AND T1.IS_LOAD = '1') LOOP
    FOR MYROW IN (SELECT T.OUTSTOCK_PLAN_NO,
                         T.OUTSTOCK_DOC,
                         T.OUTSTOCK_TYPE_CODE,
                         T.OUTSTOCK_TYPE_NAME,
                         T.ICCAR_NO,
                         T.VEHICLE_NO,
                         T.PRODUCT_FLAG,
                         T.MAT_STATUS,
                         T.STOVE_NO,
                         T.FLAG_STOVE_NO,
                         T.JUDGE_STOVE_NO,
                         T.CAST_NO,
                         T.CCMID,
                         T.MATERIAL_NO,
                         T.MATERIAL_NAME,
                         T.GRADECODE,
                         T.GRADENAME,
                         T.STD_CODE,
                         T.STD_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.PONDER_NO,
                         SUM(NVL(T.PONDER_GROSS_WT, 0)) PONDER_GROSS_WT,
                         T.PLINE_CODE,
                         T.PLINE_NAME,
                         T.PRO_ORDER_NO,
                         T.ORDER_NO,
                         T.ORDER_SEQ,
                         T.ORDER_SEQ_NO,
                         T.ORD_PK,
                         T.ORD_LN_PK,
                         T.ORD_LN_DLY_PK,
                         T.BELONG_CODE,
                         T.BELONG_NAME,
                         T.BAR_CODE,
                         T.STORAGE_NO,
                         T.LOCATION_NO,
                         T.LARY_NO,
                         T.LOC_NO,
                         T.DEPARTMENT_CODE,
                         T.DEPARTMENT_DESC,
                         T.MANAGEMENT_NO,
                         T.MANAGEMENT_NAME,
                         T.TAR_STORAGE_NO,
                         T.TAR_LOCATION_NO,
                         T.TAR_LARY_NO,
                         T.TAR_LOC_NO,
                         T.TAR_DEPARTMENT_CODE,
                         T.TAR_DEPARTMENT_DESC,
                         T.TAR_MANAGEMENT_NO,
                         T.TAR_MANAGEMENT_NAME,
                         T.TAR_REC_FLAG,
                         T.VSTEL,
                         T.VSTEL_DESC,
                         T.RPO_TIME,
                         T.PRO_BC,
                         T.PRO_BZ,
                         T.BAL_YEAR_MONTH,
                         T.INSTOCK_TIME,
                         T.IN_BC,
                         T.IN_BZ,
                         T.OUTSTOCK_TIME,
                         T.OUT_BC,
                         T.OUT_BZ,
                         T.STORAGE_ATTR,
                         T.STORAGE_ATTR_NAME,
                         T.STORAGE_TYPE_NO,
                         T.STORAGE_TYPE_NAME,
                         T.HAND_FLAG,
                         T.VALIDFLAG,
                         T.MEMO,
                         T.CREATE_NAME,
                         T.CREATE_TIME,
                         T.UPDATE_NAME,
                         T.UPDATE_TIME,
                         T.DELETE_NAME,
                         T.DELETE_TIME,
                         T.GROUD_NO,
                         T.SEND_NUM,
                         T.RECEIV_NO,
                         T.RECEIV_NM,
                         T.M_BILL_NO,
                         T.PRINT_STOVE_NO,
                         T.PRO_PLAN_ID,
                         T.GX_PLAN_NO,
                         T.FURNACENO,
                         T.SEQUENCENO,
                         T.GPTYPE,
                         T.CIC,
                         T.PIC,
                         T.SIC,
                         T.DIC,
                         T.PRODUCCODE,
                         T.PRODUCNAME,
                         T.PRO_PLAN_ID_ZG,
                         T.GX_PLAN_NO_ZG,
                         T.DRIVER,
                         T.MAT_GOWHERE_CODE,
                         T.MAT_GOWHERE_NAME,
                         T.LEAVE_FACTORY_NAME,
                         T.LEAVE_FACTORY_TIME,
                         T.LEAVE_FACTORY_FLAG,
                         T.LEAVE_MANAGEMENT_NO,
                         T.LEAVE_MANAGEMENT_NAME,
                         T.SUPERVISOR_NAME,
                         T.SUPERVISOR_CALL,
                         T.OUT_TYPE,
                         T.CUT_NUM,
                         T.SUPPLY_UNIT_CODE,
                         T.SUPPLY_UNIT,
                         T.GPREQ_ID,
                         T.LOT_NO,
                         T.SOURE_CODE,
                         T.SOURE_NAME,
                         T.IS_DEALER,
                         T.BACK_FLAG,
                         T.BALANCE_NO
                    FROM YDM_GP_OUTLIST T
                   WHERE T.JUDGE_STOVE_NO = MYROW2.JUDGE_STOVE_NO
                     AND T.PRO_PLAN_ID_ZG = MYROW2.PRO_PLAN_ID
                     AND T.GX_PLAN_NO_ZG = MYROW2.GX_PLAN_NO
                     AND T.OUTSTOCK_TYPE_CODE = '800809'
                   GROUP BY T.OUTSTOCK_PLAN_NO,
                            T.OUTSTOCK_DOC,
                            T.OUTSTOCK_TYPE_CODE,
                            T.OUTSTOCK_TYPE_NAME,
                            T.ICCAR_NO,
                            T.VEHICLE_NO,
                            T.PRODUCT_FLAG,
                            T.MAT_STATUS,
                            T.STOVE_NO,
                            T.FLAG_STOVE_NO,
                            T.JUDGE_STOVE_NO,
                            T.CAST_NO,
                            T.CCMID,
                            T.MATERIAL_NO,
                            T.MATERIAL_NAME,
                            T.GRADECODE,
                            T.GRADENAME,
                            T.STD_CODE,
                            T.STD_NAME,
                            T.DIMATER,
                            T.HEIGHT,
                            T.ACT_LEN,
                            T.FIX_NUM,
                            T.FIX_LEN,
                            T.PONDER_NO,
                            T.PLINE_CODE,
                            T.PLINE_NAME,
                            T.PRO_ORDER_NO,
                            T.ORDER_NO,
                            T.ORDER_SEQ,
                            T.ORDER_SEQ_NO,
                            T.ORD_PK,
                            T.ORD_LN_PK,
                            T.ORD_LN_DLY_PK,
                            T.BELONG_CODE,
                            T.BELONG_NAME,
                            T.BAR_CODE,
                            T.STORAGE_NO,
                            T.LOCATION_NO,
                            T.LARY_NO,
                            T.LOC_NO,
                            T.DEPARTMENT_CODE,
                            T.DEPARTMENT_DESC,
                            T.MANAGEMENT_NO,
                            T.MANAGEMENT_NAME,
                            T.TAR_STORAGE_NO,
                            T.TAR_LOCATION_NO,
                            T.TAR_LARY_NO,
                            T.TAR_LOC_NO,
                            T.TAR_DEPARTMENT_CODE,
                            T.TAR_DEPARTMENT_DESC,
                            T.TAR_MANAGEMENT_NO,
                            T.TAR_MANAGEMENT_NAME,
                            T.TAR_REC_FLAG,
                            T.VSTEL,
                            T.VSTEL_DESC,
                            T.RPO_TIME,
                            T.PRO_BC,
                            T.PRO_BZ,
                            T.BAL_YEAR_MONTH,
                            T.INSTOCK_TIME,
                            T.IN_BC,
                            T.IN_BZ,
                            T.OUTSTOCK_TIME,
                            T.OUT_BC,
                            T.OUT_BZ,
                            T.STORAGE_ATTR,
                            T.STORAGE_ATTR_NAME,
                            T.STORAGE_TYPE_NO,
                            T.STORAGE_TYPE_NAME,
                            T.HAND_FLAG,
                            T.VALIDFLAG,
                            T.MEMO,
                            T.CREATE_NAME,
                            T.CREATE_TIME,
                            T.UPDATE_NAME,
                            T.UPDATE_TIME,
                            T.DELETE_NAME,
                            T.DELETE_TIME,
                            T.GROUD_NO,
                            T.SEND_NUM,
                            T.RECEIV_NO,
                            T.RECEIV_NM,
                            T.M_BILL_NO,
                            T.PRINT_STOVE_NO,
                            T.PRO_PLAN_ID,
                            T.GX_PLAN_NO,
                            T.FURNACENO,
                            T.SEQUENCENO,
                            T.GPTYPE,
                            T.CIC,
                            T.PIC,
                            T.SIC,
                            T.DIC,
                            T.PRODUCCODE,
                            T.PRODUCNAME,
                            T.PRO_PLAN_ID_ZG,
                            T.GX_PLAN_NO_ZG,
                            T.DRIVER,
                            T.MAT_GOWHERE_CODE,
                            T.MAT_GOWHERE_NAME,
                            T.LEAVE_FACTORY_NAME,
                            T.LEAVE_FACTORY_TIME,
                            T.LEAVE_FACTORY_FLAG,
                            T.LEAVE_MANAGEMENT_NO,
                            T.LEAVE_MANAGEMENT_NAME,
                            T.SUPERVISOR_NAME,
                            T.SUPERVISOR_CALL,
                            T.OUT_TYPE,
                            T.CUT_NUM,
                            T.SUPPLY_UNIT_CODE,
                            T.SUPPLY_UNIT,
                            T.GPREQ_ID,
                            T.LOT_NO,
                            T.SOURE_CODE,
                            T.SOURE_NAME,
                            T.IS_DEALER,
                            T.BACK_FLAG,
                            T.BALANCE_NO) LOOP
    
      INSERT INTO FMIS_GP_OUTLIST
        (OUTSTOCK_PLAN_NO,
         OUTSTOCK_DOC,
         OUTSTOCK_TYPE_CODE,
         OUTSTOCK_TYPE_NAME,
         ICCAR_NO,
         VEHICLE_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         STOVE_NO,
         FLAG_STOVE_NO,
         JUDGE_STOVE_NO,
         CAST_NO,
         CCMID,
         MATERIAL_NO,
         MATERIAL_NAME,
         GRADECODE,
         GRADENAME,
         STD_CODE,
         STD_NAME,
         DIMATER,
         HEIGHT,
         ACT_LEN,
         FIX_NUM,
         FIX_LEN,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         PONDER_NO,
         PONDER_GROSS_WT,
         PLINE_CODE,
         PLINE_NAME,
         PRO_ORDER_NO,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BELONG_CODE,
         BELONG_NAME,
         BAR_CODE,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         TAR_STORAGE_NO,
         TAR_LOCATION_NO,
         TAR_LARY_NO,
         TAR_LOC_NO,
         TAR_DEPARTMENT_CODE,
         TAR_DEPARTMENT_DESC,
         TAR_MANAGEMENT_NO,
         TAR_MANAGEMENT_NAME,
         TAR_REC_FLAG,
         VSTEL,
         VSTEL_DESC,
         RPO_TIME,
         PRO_BC,
         PRO_BZ,
         BAL_YEAR_MONTH,
         INSTOCK_TIME,
         IN_BC,
         IN_BZ,
         OUTSTOCK_TIME,
         OUT_BC,
         OUT_BZ,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         HAND_FLAG,
         VALIDFLAG,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         GROUD_NO,
         SEND_NUM,
         RECEIV_NO,
         RECEIV_NM,
         M_BILL_NO,
         PRINT_STOVE_NO,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         FURNACENO,
         SEQUENCENO,
         GPTYPE,
         CIC,
         PIC,
         SIC,
         DIC,
         PRODUCCODE,
         PRODUCNAME,
         PRO_PLAN_ID_ZG,
         GX_PLAN_NO_ZG,
         DRIVER,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         LEAVE_FACTORY_NAME,
         LEAVE_FACTORY_TIME,
         LEAVE_FACTORY_FLAG,
         LEAVE_MANAGEMENT_NO,
         LEAVE_MANAGEMENT_NAME,
         SUPERVISOR_NAME,
         SUPERVISOR_CALL,
         OUT_TYPE,
         CUT_NUM,
         SUPPLY_UNIT_CODE,
         SUPPLY_UNIT,
         GPREQ_ID,
         LOT_NO,
         SOURE_CODE,
         SOURE_NAME,
         IS_DEALER,
         BACK_FLAG,
         BALANCE_NO)
      VALUES
        (MYROW.OUTSTOCK_PLAN_NO,
         MYROW.OUTSTOCK_DOC,
         MYROW.OUTSTOCK_TYPE_CODE,
         MYROW.OUTSTOCK_TYPE_NAME,
         MYROW.ICCAR_NO,
         MYROW.VEHICLE_NO,
         MYROW.PRODUCT_FLAG,
         MYROW.MAT_STATUS,
         MYROW.STOVE_NO,
         MYROW.FLAG_STOVE_NO,
         MYROW.JUDGE_STOVE_NO,
         MYROW.CAST_NO,
         MYROW.CCMID,
         MYROW.MATERIAL_NO,
         MYROW.MATERIAL_NAME,
         MYROW.GRADECODE,
         MYROW.GRADENAME,
         MYROW.STD_CODE,
         MYROW.STD_NAME,
         MYROW.DIMATER,
         MYROW.HEIGHT,
         MYROW.ACT_LEN,
         MYROW.FIX_NUM,
         MYROW.FIX_LEN,
         MYROW.ACT_COUNT,
         MYROW.ACT_WEIGHT,
         MYROW.ACT_THEORY_WEIGHT,
         MYROW.PONDER_NO,
         MYROW.PONDER_GROSS_WT,
         MYROW.PLINE_CODE,
         MYROW.PLINE_NAME,
         MYROW.PRO_ORDER_NO,
         MYROW.ORDER_NO,
         MYROW.ORDER_SEQ,
         MYROW.ORDER_SEQ_NO,
         MYROW.ORD_PK,
         MYROW.ORD_LN_PK,
         MYROW.ORD_LN_DLY_PK,
         MYROW.BELONG_CODE,
         MYROW.BELONG_NAME,
         MYROW.BAR_CODE,
         MYROW.STORAGE_NO,
         MYROW.LOCATION_NO,
         MYROW.LARY_NO,
         MYROW.LOC_NO,
         MYROW.DEPARTMENT_CODE,
         MYROW.DEPARTMENT_DESC,
         MYROW.MANAGEMENT_NO,
         MYROW.MANAGEMENT_NAME,
         MYROW.TAR_STORAGE_NO,
         MYROW.TAR_LOCATION_NO,
         MYROW.TAR_LARY_NO,
         MYROW.TAR_LOC_NO,
         MYROW.TAR_DEPARTMENT_CODE,
         MYROW.TAR_DEPARTMENT_DESC,
         MYROW.TAR_MANAGEMENT_NO,
         MYROW.TAR_MANAGEMENT_NAME,
         MYROW.TAR_REC_FLAG,
         MYROW.VSTEL,
         MYROW.VSTEL_DESC,
         MYROW.RPO_TIME,
         MYROW.PRO_BC,
         MYROW.PRO_BZ,
         MYROW.BAL_YEAR_MONTH,
         MYROW.INSTOCK_TIME,
         MYROW.IN_BC,
         MYROW.IN_BZ,
         MYROW.OUTSTOCK_TIME,
         MYROW.OUT_BC,
         MYROW.OUT_BZ,
         MYROW.STORAGE_ATTR,
         MYROW.STORAGE_ATTR_NAME,
         MYROW.STORAGE_TYPE_NO,
         MYROW.STORAGE_TYPE_NAME,
         MYROW.HAND_FLAG,
         MYROW.VALIDFLAG,
         MYROW.MEMO,
         MYROW.CREATE_NAME,
         MYROW.CREATE_TIME,
         MYROW.UPDATE_NAME,
         MYROW.UPDATE_TIME,
         MYROW.DELETE_NAME,
         MYROW.DELETE_TIME,
         MYROW.GROUD_NO,
         MYROW.SEND_NUM,
         MYROW.RECEIV_NO,
         MYROW.RECEIV_NM,
         MYROW.M_BILL_NO,
         MYROW.PRINT_STOVE_NO,
         MYROW.PRO_PLAN_ID,
         MYROW.GX_PLAN_NO,
         MYROW.FURNACENO,
         MYROW.SEQUENCENO,
         MYROW.GPTYPE,
         MYROW.CIC,
         MYROW.PIC,
         MYROW.SIC,
         MYROW.DIC,
         MYROW.PRODUCCODE,
         MYROW.PRODUCNAME,
         MYROW.PRO_PLAN_ID_ZG,
         MYROW.GX_PLAN_NO_ZG,
         MYROW.DRIVER,
         MYROW.MAT_GOWHERE_CODE,
         MYROW.MAT_GOWHERE_NAME,
         MYROW.LEAVE_FACTORY_NAME,
         MYROW.LEAVE_FACTORY_TIME,
         MYROW.LEAVE_FACTORY_FLAG,
         MYROW.LEAVE_MANAGEMENT_NO,
         MYROW.LEAVE_MANAGEMENT_NAME,
         MYROW.SUPERVISOR_NAME,
         MYROW.SUPERVISOR_CALL,
         MYROW.OUT_TYPE,
         MYROW.CUT_NUM,
         MYROW.SUPPLY_UNIT_CODE,
         MYROW.SUPPLY_UNIT,
         MYROW.GPREQ_ID,
         MYROW.LOT_NO,
         MYROW.SOURE_CODE,
         MYROW.SOURE_NAME,
         MYROW.IS_DEALER,
         MYROW.BACK_FLAG,
         MYROW.BALANCE_NO);
    
    END LOOP;
  END LOOP;
END;

		]]>
	</query>
	
	<query id = "FmisTool.deleteGpOutList" desc = "删除管坯出库记录">
	<![CDATA[
	DECLARE
  V_HEAT_PLAN_NO PLN_ZY_ZG_M.HEAT_PLAN_NO%type := ?;
BEGIN
  FOR MYROW2 IN (SELECT *
                   FROM PLN_ZY_ZG_M T1
                  WHERE T1.HEAT_PLAN_NO = V_HEAT_PLAN_NO
                    AND T1.IS_LOAD = '1') LOOP
    FOR MYROW IN (SELECT T.OUTSTOCK_DOC, T.JUDGE_STOVE_NO
                    FROM YDM_GP_OUTLIST T
                   WHERE T.JUDGE_STOVE_NO = MYROW2.JUDGE_STOVE_NO
                     AND T.PRO_PLAN_ID_ZG = MYROW2.PRO_PLAN_ID
                     AND T.GX_PLAN_NO_ZG = MYROW2.GX_PLAN_NO
                     AND T.OUTSTOCK_TYPE_CODE = '800809'
                   GROUP BY T.OUTSTOCK_DOC T.JUDGE_STOVE_NO) LOOP
    
      DELETE FROM FMIS_GP_OUTLIST T
       WHERE T.OUTSTOCK_DOC = MYROW.OUTSTOCK_DOC
         AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO;
    END LOOP;
  END LOOP;
END;
	]]>
	</query> 
</queryMap>