<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="镦拔扩上料实绩">
	<query id="FrmVrpLoading.GetQueryDbkPlan" desc="查询墩拔扩计划">
        <![CDATA[
     SELECT T3.*,
       TO_NUMBER(T3.IN_NUM) - TO_NUMBER(T3.PRO_NUM) MATERIAL_COUNT,
       TO_NUMBER(T3.IN_WT) - TO_NUMBER(T3.PRO_WT) MATERIAL_WT　
  FROM (SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO ORDER_NO_SEQ,
               T.HEAT_PLAN_NO,
                T2.HEAT_PLAN_SQE,
               T.ZY_BATCH_ID,
               --T.PROD_INDEX,
               t.GX_PRO_SEQ,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.UPPER_HEATPLAN_ID,
               T.JUDGE_STOVE_NO,
               T.FEED_HEAT_NO,
               T2.BATCH_NO,
               T2.BATCH_GROUD_NO,
               T2.JUGDE_APPLY_CODE,
               DECODE(T.ISENDGX,'0','否','1','是','否') ISENDGX,
               T.ORDER_SOURCE,
               T.ORD_LN_DLY_PK,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.DELIVERY_NO,
               T.REQ_BL_ID,
               T.GRADECODE,
               T.GRADENAME,
               T.AIMOUTDIAMETER,
               T.AIMWALLTHICK,
               T.AIMLENGTH,
               T.OUTDIAMETER_IN,
               T.WALLTHICK_IN,
               T.LENGTH_IN,
               T.LENGTHMAX_IN,
               T.LENGTHMIN_IN,
               T.LEN_CUTHEAD,
               T.LEN_CUTEND,
               T.DECISION,
               T.INWL_ID,
               T.INWL_DESC,
               T.NEXT_PROCESS_CODE,
               NVL(T2.PLAN_INDOUBLE_WT, 0) IN_WT,
               NVL(T2.PLAN_INDOUBLE_NUM, 0) IN_NUM,
               DECODE(T.IF_MATCH_ODD,'1','是','0','否','否') IF_WL_MATCHED,
               T.OUTWL_ID,
               T.OUTWL_DESC,
              -- NVL(T.OUT_WT, 0) OUT_WT,
             --  NVL(T.OUT_NUM, 0) OUT_NUM,
               DECODE(T.IF_MONITOR,'0','否','1','是','否') IF_MONITOR_DBK,
               T.MONITOR_POINT,
               T.CRAFT_FILE_MAN,
               T.CRAFT_SEQ,
               T.STATION_ROAD,
               NVL(T2.REAL_INDOUBLE_WT, 0) IN_WT_REAL,
               NVL(T2.REAL_INDOUBLE_NUM, 0) IN_NUM_REAL,
               NVL(T2.REAL_OUTDOUBLE_WT, 0) OUT_WT_REAL,
               NVL(T2.REAL_OUTDOUBLE_NUM, 0) OUT_NUM_REAL,
               T2.OUTNUM_CUT,
               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,
               DECODE(T.PLANSTATUS,
                      '00',
                      '计划',
                      '10',
                      '下发',
                      '20',
                      '生产中',
                      '30',
                      '生产完成',
                      '40',
                      '关闭') PLANSTATUS,
               T.CRAFT_FILE_NO,
               T.PRDCR_NO,
               (SELECT NVL(SUM(T1.PRO_NUM), 0)
                  FROM VRP_LOADING_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_NUM,
               (SELECT NVL(SUM(T1.PRO_WT), 0)
                  FROM VRP_LOADING_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_WT,
               NVL((SELECT SUM(M.ACT_COUNT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                       AND NVL(M.JUGDE_APPLY_CODE,'/') = NVL(T2.Jugde_Apply_Code,'/')
                      AND  M.JUDGE_STOVE_NO = T.FEED_HEAT_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
          --                AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
            --  AND STORAGE_ATTR = '800302'
                AND M.NEXT_PROCESS_CDOE = 'E'),
                   0) ACT_COUNT,
               NVL((SELECT SUM(NVL(M.PONDER_GROSS_WT,M.ACT_WEIGHT))
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                AND NVL(M.JUGDE_APPLY_CODE,'/') = NVL(T2.Jugde_Apply_Code,'/')
                      AND M.JUDGE_STOVE_NO = T.FEED_HEAT_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
         --                 AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
    --  AND STORAGE_ATTR = '800302'
      AND M.NEXT_PROCESS_CDOE = 'E'),
                   0) ACT_WEIGHT,
               DECODE(T.BESIDE_STATUS,
                      '00',
                      '上料结炉',
                      '10',
                      '旋扩结炉',
                      '20',
                      '均整结炉',
                      '30',
                      '定径结炉',
                      '40',
                      '表检结炉',
                      '50',
                      '生产点结炉',
                      '60',
                      '交库结炉') BESIDE_STATUS,
               DECODE(T.PER_STATUS,
                      '00',
                      '上料开始',
                      '10',
                      '旋扩开始',
                      '20',
                      '均整开始',
                      '30',
                      '定径开始',
                      '40',
                      '表检开始',
                      '50',
                      '生产点开始',
                      '60',
                      '交库开始') PER_STATUS
          FROM PLN_ZY_DBK_M T,PLN_ZY_DBK_C T2
         WHERE  t.heat_plan_no = t2.heat_plan_no
        ]]>
	</query>

	<query id="FrmVrpLoading.GetQueryDbkPlan1" desc="查询墩拔扩计划支数">
        <![CDATA[
      SELECT NVL(SUM(T1.PRO_NUM), 0) PRO_NUM      
  FROM PLN_ZY_DBK_M T, VRP_LOADING_RESULT T1
 WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO(+)
        ]]>
	</query>
	
	<query id="FrmVrpLoading.CopyBackup" desc="复制MAT_BC_BACKUP表到物料主表">
        <![CDATA[
      INSERT INTO  MAT_BC_M SELECT * FROM MAT_BC_BACKUP T WHERE T.Mat_No= ? AND T.NEXT_PROCESS_CDOE = 'E'
        ]]>
	</query>
	
	<query id="FrmVrpLoading.DeteleBackup" desc="删除MAT_BC_BACKUP表">
        <![CDATA[
      DELETE MAT_BC_BACKUP WHERE Mat_No= ? AND NEXT_PROCESS_CDOE = 'E'
        ]]>
	</query>
	
	<query id="FrmVrpLoading.querypronum" desc="查询墩拔扩计划从表支数和">
        <![CDATA[
SELECT NVL(SUM(T.PLAN_INDOUBLE_NUM), 0) PRO_NUM
  FROM PLN_ZY_DBK_C T
 WHERE HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmVrpLoading.AddVrpshangliao" desc="新增上料实绩">
        <![CDATA[    
INSERT INTO VRP_LOADING_RESULT
  (RESULT_NO, HEAT_PLAN_NO, ZY_BATCH_ID, PRO_PLAN_ID, GX_PLAN_NO, PLINE_CODE, PLINE_NAME, PRO_NUM, PRO_WT, FAIL_NUM, FAIL_WT, OFFLINE_NUM, OFFLINE_WT, RE_NUM, RE_WT, MONITORDEMAND, IF_MONITOR_DBK, PRODUCER, PRDCR_NO, PRODUCER_TIME, LOAD_TIME, LOAD_SHIFT, LOAD_GROUP, LOAD_USER, COL_MODE, CREATE_TIME,BAL_YEAR_MONTH)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?,  TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?)
        ]]>
	</query>
	<query id="FrmVrpLoading.updatevrpshangliao" desc="修改镦拔扩计划从表">
        <![CDATA[
        UPDATE pln_zy_dbk_c
   SET REAL_INDOUBLE_NUM = TO_NUMBER(NVL(REAL_INDOUBLE_NUM, 0)) + TO_NUMBER(?),
       REAL_INDOUBLE_WT  = TO_NUMBER(NVL(REAL_INDOUBLE_WT, 0)) + TO_NUMBER(?)
 WHERE HEAT_PLAN_NO = ? AND BATCH_NO = ? AND BATCH_GROUD_NO =?
        ]]>
	</query>
		<query id="FrmVrpLoading.updatePlnZyRclMpln" desc="修改镦拔扩计划主表">
        <![CDATA[
     UPDATE PLN_ZY_DBK_M
    SET  PLANSTATUS = '20',
        PER_STATUS='00'
  WHERE HEAT_PLAN_NO = ?
        ]]>
	</query>
	
	<query id="FrmVrpLoading.UpdatePlnVrp" desc="修改炉计划是否分批">
        <![CDATA[
   UPDATE PLN_ZY_DBK_M
    SET  IS_BATCH = ?
  WHERE HEAT_PLAN_NO = ?
        ]]>
	</query>

	<query id="FrmVrpLoading.AddvrpResult" desc="判断是否有过上料实绩">
        <![CDATA[
INSERT INTO VRP_EXPAND_RESULT
  (RESULT_NO, HEAT_PLAN_NO, ZY_BATCH_ID, PRO_PLAN_ID, GX_PLAN_NO, PLINE_CODE, PLINE_NAME, SPEC_CODE, SPEC_NAME, DIMATER, HEIGHT, HOL_DIMATER, HOL_HEIGHT, ROLL_DISTANCE, GUIDE_DISTANCE, PLUG_SIZE, PLUG_BAR_D, PLUG_POSITION, MOTOR_SPEED, PRO_NUM, PRO_WT, FAIL_NUM, FAIL_WT, FAIL_REASON, OFFLINE_NUM, OFFLINE_WT, RE_NUM, RE_WT, MONITORDEMAND, IF_MONITOR_DBK, PRODUCER, PRDCR_NO, PRODUCER_TIME, LOAD_TIME, LOAD_SHIFT, LOAD_GROUP, LOAD_USER, COL_MODE, CREATE_TIME, UPDATE_TIME, UPDATE_NAME)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?);

        ]]>
	</query>
	<query id="FrmVrpLoading.GetQuery" desc="上料实绩">
        <![CDATA[
   SELECT T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       NVL(T.PRO_NUM, 0) PRO_NUM,
       NVL(T.PRO_WT, 0) PRO_WT,
       NVL(T.FAIL_NUM, 0) FAIL_NUM,
       NVL(T.FAIL_WT, 0) FAIL_WT,
       NVL(T.OFFLINE_NUM, 0) OFFLINE_NUM,
       NVL(T.OFFLINE_WT, 0) OFFLINE_WT,
       NVL(T.RE_NUM, 0) RE_NUM,
       NVL(T.RE_WT, 0) RE_WT,
       T.MONITORDEMAND,
       DECODE(T.IF_MONITOR_DBK, '1', '是', '0', '否','否') IF_MONITOR_DBK,
       T.PRODUCER,
       T.PRDCR_NO,
       TO_CHAR(T.PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       TO_CHAR(T.LOAD_TIME, 'YYYY-MM-DD HH24:MI:SS') LOAD_TIME,
       T.LOAD_SHIFT,
       T.LOAD_GROUP,
       T.LOAD_USER,
       T.COL_MODE,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.UPDATE_NAME,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS
  FROM VRP_LOADING_RESULT T, VRP_COM_INFO B
 WHERE T.RESULT_NO = B.RESULT_NO
   AND T.HEAT_PLAN_NO = B.HEAT_PLAN_NO
   AND T.HEAT_PLAN_NO = ?
        ]]>
	</query>

	<query id="FrmVrpLoading.GetQuery1" desc="查询上料支数总和">
        <![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM VRP_LOADING_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmVrpLoading.ReturnVrpLoadingResult" desc="撤销上料实绩">
		<![CDATA[
		DELETE VRP_LOADING_RESULT WHERE RESULT_NO = ?
		]]>
	</query>

	<query id="FrmVrpLoading.deleteVrpResult" desc="撤销上料公共实绩">
		<![CDATA[
		DELETE VRP_COM_INFO WHERE RESULT_NO = ?
		]]>
	</query>

	<query id="FrmVrpLoading.queryKEY" desc="判断是否有过上料实绩">
        <![CDATA[
	SELECT ? ||
	LPAD(SUBSTR(NVL(MAX(T.RESULT_NO),'000000'),-6,6) + 1, 6, '0') AS RESULT_NO
	FROM VRP_LOADING_RESULT T
	WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') = ?
	AND T.PLINE_CODE= ?
        ]]>
	</query>

	<query id="FrmVrpLoading.getQueryWeight" desc="根据上料支数查询重量">
	<![CDATA[
	SELECT  NVL(SUM(T1.ACT_WEIGHT),0) ACT_WEIGHT
  FROM (SELECT NVL(T.PONDER_GROSS_WT,T.ACT_WEIGHT) ACT_WEIGHT
          FROM MAT_BC_M T, YDM_BC_BUTTRESS B
         WHERE T.MAT_NO = B.MAT_NO
           AND T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150103'
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
           AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
        --       AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
     -- AND STORAGE_ATTR = '800302'
      AND T.NEXT_PROCESS_CDOE = 'E'
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?

			]]>
	</query>
	
	<query id="FrmVrpLoading.getquerymaternum" desc="查询相同炉计划ID下待上料支数总和">
        <![CDATA[
SELECT SUM(PLAN_INDOUBLE_NUM) - SUM(REAL_INDOUBLE_NUM) NUM,
	   SUM(PLAN_INDOUBLE_wt) - SUM(REAL_INDOUBLE_wt) WT
  FROM PLN_ZY_DBK_C
 WHERE HEAT_PLAN_NO = ?

        ]]>
	</query>
	<query id="FrmVrpLoading.updateVrpPlan" desc="修改时修改热处理计划表">
		<![CDATA[
UPDATE PLN_ZY_DBK_M
   SET IN_NUM_REAL = ?,
       IN_WT_REAL  = ?
 WHERE HEAT_PLAN_NO = ?
		]]>
	</query>

	<query id="FrmVrpLoading.deleteDbkPlanM" desc="删除时修改镦拔扩计划表">
		<![CDATA[
UPDATE PLN_ZY_DBK_M
   SET PLANSTATUS  = ?,
       PER_STATUS=''
 WHERE HEAT_PLAN_NO = ?
		]]>
	</query>
	<query id="FrmVrpLoading.deleteDbkPlanC" desc="删除时修改镦拔扩计划从表">
		<![CDATA[
UPDATE pln_zy_dbk_c
   SET REAL_INDOUBLE_NUM = ?,
       REAL_INDOUBLE_WT  = ?
 WHERE HEAT_PLAN_NO = ? and FEED_HEAT_NO = ? and BATCH_NO = ? and  BATCH_GROUD_NO= ?
		]]>
	</query>
	<query id="FrmVrpLoading.queryCountVrp" desc="查询计划下剩余上料支、吨">
		<![CDATA[
SELECT COUNT(*) COUN,
       NVL(SUM(T.PRO_NUM), 0) PRO_NUM,
       NVL(SUM(T.PRO_WT), 0) PRO_WT
  FROM VRP_LOADING_RESULT T
 WHERE HEAT_PLAN_NO = ?
		]]>
	</query>
	<query id="FrmVrpLoading.queryMatZc" desc="查询新增物料信息">
		<![CDATA[
SELECT T1.*
  FROM (SELECT T.MAT_NO,
               T.PRODUCT_FLAG,
               T.MAT_STATUS,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.BATCH_GROUD_NO,
               T.MATERIAL_NO,
               T.MATERIAL_NAME,
               T.PRODUCCODE,
               T.PRODUCNAME,
               T.STEELCODE,
               T.STEELNAME,
               T.GRADECODE,
               T.GRADENAME,
               T.SPEC_CODE,
               T.SPEC_NAME,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STD_CODE,
               T.STD_NAME,
               T.STD_STYLE,
               T.STD_STYLE_DESC,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.ORDER_SEQ_NO,
               T.PROCESS_CDOE,
               T.PROCESS_DESC,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.MAT_ORIGIN_CODE,
               T.MAT_ORIGIN_NAME,
               T.ACT_DIMATER,
               T.ACT_HEIGHT,
               T.ACT_LEN,
               T.ACT_LEN_MIN,
               T.ACT_LEN_MAX,
               T.ACT_COUNT,
               NVL(T.PONDER_GROSS_WT,T.ACT_WEIGHT) ACT_WEIGHT,
               T.ACT_THEORY_WEIGHT,
               T.BELONG_CODE,
               T.BELONG_NAME,
               T.LOCK_FLAG,
               T.ORD_PK,
               T.ORD_LN_PK,
               SUBSTR(T.ORD_LN_DLY_PK, 0, INSTR(T.ORD_LN_DLY_PK, '-') - 1) ORD_LN_DLY_PK,
               T.BAL_YEAR_MONTH,
               T.JUDGE_STD_NAME,
               T.JUDGE_STD_DES,
               T.SOURE_CODE,
               T.SOURE_NAME,
               T.MNG_LOCK_FLAG,
               B.STORAGE_NO,
               B.LOCATION_NO,
               B.LARY_NO,
               B.LOC_NO,
               B.STORAGE_ATTR,
               B.STORAGE_ATTR_NAME,
               B.STORAGE_TYPE_NO,
               B.STORAGE_TYPE_NAME,
               B.MANAGEMENT_NO,
               B.MANAGEMENT_NAME,
               B.DEPARTMENT_CODE,
               B.DEPARTMENT_DESC,
               T.STOVE_NO
          FROM MAT_BC_M T, YDM_BC_BUTTRESS B
         WHERE T.MAT_NO = B.MAT_NO
           AND T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150103'
            AND NVL(T.JUGDE_APPLY_CODE,'/') = NVL(?,'/')
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
           AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
     --      AND  B.MANAGEMENT_NO IN
    --   (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
   --AND STORAGE_ATTR = '800302'
      AND T.NEXT_PROCESS_CDOE = 'E'
         ORDER BY  DECODE(B.STORAGE_NO,?,0,1), NVL(T.LOCK_FLAG,'0'),NVL(T.MNG_LOCK_FLAG,'0'), T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
		]]>
	</query>

	<query id="FrmVrpLoading.queryMatZc1" desc="查询新增物料信息里的材料号">
		<![CDATA[
SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM MAT_BC_M T, YDM_BC_BUTTRESS B
         WHERE T.MAT_NO = B.MAT_NO
           AND T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150102'
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
		]]>
	</query>



	<query id="FrmVrpLoading.UpdatePath" desc="修改队列表工艺路径">
		<![CDATA[
UPDATE PORT_VRP_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,0) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,2, LENGTH(T.PRC_TECHNOLOGY_PATH))
 WHERE T.HEAT_PLAN_NO = ? AND T.MAT_NO = ?
			]]>
	</query>

	<query id="FrmVrpLoading.queryOutList" desc="查询出库单号">
	<![CDATA[
SELECT (SELECT S.MEMO
          FROM COM_BASE_INFO S
         WHERE S.BASECODE = ?) || OUTSTOCK_DOC OUTSTOCK_DOC
  FROM (SELECT TO_CHAR(SYSDATE, 'YYMMDD') ||
               LPAD(NVL(MAX(SUBSTR(T.OUTSTOCK_DOC, 9)), 0) + 1, 5, 0) OUTSTOCK_DOC
          FROM YDM_BC_OUTLIST T
         WHERE T.OUTSTOCK_TYPE_CODE = ?
           AND TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') =
               TO_CHAR(SYSDATE, 'YYYY-MM-DD'))
	]]>
	</query>
		<query id="FrmVrpLoading.CopyBcMat" desc="把物料主表复制到List表">
	<![CDATA[
   INSERT INTO MAT_BC_BACKUP SELECT * FROM MAT_BC_M T WHERE T.MAT_NO = ?
	]]>
	</query>
		<query id="FrmVrpLoading.DeteleBcMat" desc="删除物料主表">
	<![CDATA[
   DELETE MAT_BC_M WHERE MAT_NO = ?
	]]>
	</query>
	<query id="FrmVrpLoading.queryOut" desc="查询出库流水号">
	<![CDATA[
      SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.OUTSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS OUTSTOCK_SQE
    FROM YDM_BC_OUTLIST T
   WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') =  TO_CHAR(SYSDATE, 'YYYY-MM-DD')
     AND T.OUTSTOCK_DOC = ?
	]]>
	</query>
	<query id="FrmVrpLoading.deleteButter" desc="删除位置表">
	<![CDATA[
 DELETE YDM_BC_BUTTRESS WHERE MAT_NO = ?
	]]>
	</query>
	<query id="FrmVrpLoading.AddOutList" desc="新增出库记录投料出库">
	<![CDATA[
INSERT INTO YDM_BC_OUTLIST
  (OUTSTOCK_SQE,
   OUTSTOCK_PLAN_NO,
   OUTSTOCK_DOC,
   OUTSTOCK_TYPE_CODE,
   OUTSTOCK_TYPE_NAME,
   MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   PRODUCNAME,
   STD_CODE,
   STD_NAME,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   STD_STYLE,
   STD_STYLE_DESC,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   PLINE_CODE,
   PLINE_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   RPO_TIME,
   PRO_BC,
   PRO_BZ,
   OUTSTOCK_TIME,
   OUT_BC,
   OUT_BZ,
   CREATE_NAME,
   CREATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   JUDGE_STD_CODE,
   JUDGE_STD_NAME,
   LOT_NO,
   STOVE_NO,
   LOAD_PLINE_CODE,
   LOAD_PLINE_NAME,
   PRO_ORDER_NO,
   BAL_YEAR_MONTH,
   PROCESS_CDOE,
   PROCESS_DESC)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   (SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = ?),
   ?,
   ?,
   ?,
   ?)

	]]>
	</query>
	<query id="FrmVrpLoading.AddOutListQuan" desc="新增出库记录产权出库">
	<![CDATA[
INSERT INTO YDM_BC_OUTLIST
  (OUTSTOCK_SQE,
   OUTSTOCK_PLAN_NO,
   OUTSTOCK_DOC,
   OUTSTOCK_TYPE_CODE,
   OUTSTOCK_TYPE_NAME,
   MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   PRODUCNAME,
   STD_CODE,
   STD_NAME,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   STD_STYLE,
   STD_STYLE_DESC,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   PLINE_CODE,
   PLINE_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   RPO_TIME,
   PRO_BC,
   PRO_BZ,
   OUTSTOCK_TIME,
   OUT_BC,
   OUT_BZ,
   CREATE_NAME,
   CREATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   JUDGE_STD_CODE,
   JUDGE_STD_NAME,
   LOT_NO,
   STOVE_NO,
   LOAD_PLINE_CODE,
   LOAD_PLINE_NAME,
   PRO_ORDER_NO,
   BAL_YEAR_MONTH,
   PROCESS_CDOE,
   PROCESS_DESC)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   (SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = ?),
   ?,
   ?,
   ?,
   ?)

	]]>
	</query>
	<query id="FrmVrpLoading.updateMatZcPlan" desc="修改MAT_BC_M状态">
	<![CDATA[
   UPDATE MAT_BC_M T SET T.MAT_STATUS = ? WHERE T.MAT_NO = ?
	]]>
	</query>
<query id="FrmVrpLoading.updateMatZcPlanStuts" desc="修改MAT_BC_BACKUP状态">
	<![CDATA[
   UPDATE MAT_BC_BACKUP T SET T.MAT_STATUS = ? WHERE T.MAT_NO = ?
	]]>
	</query>

	<query id="FrmVrpLoading.qureymatno" desc="查询管号队列里的材料号">
	<![CDATA[
   SELECT count(1) count
  FROM PORT_VRP_BATCH_SAMPLE_RESULT T
 WHERE T.MAT_NO = ?
   AND T.HEAT_PLAN_NO = ?
	]]>
	</query>
<query id="FrmVrpLoading.queryCheckNoShort" desc="产线基础表里的检验委托号">
	<![CDATA[
   select NVL(T.CHECK_NO_SHORT,0) CHECK_NO_SHORT from COM_BASE_PLINE t WHERE T.PLINE_CODE = ? AND T.VALIDFLAG = '1'
	]]>
	</query>

	<query id="FrmVrpLoading.AddPortVrp" desc="新增管号队列">
	<![CDATA[
INSERT INTO PORT_VRP_BATCH_SAMPLE_RESULT (HEAT_PLAN_NO, MAT_NO, M_MAT_NO, 
M_M_MAT_NO, LOT_NO, LOT_NO_SQE, PLINE_CODE, PLINE_NAME, JUDGE_STOVE_NO, 
BATCH_NO, GROUP_NO, STOVE_NO, ACT_DIMATER, ACT_HEIGHT, ACT_LEN, 
ACT_LEN_MIN, ACT_LEN_MAX, ACT_COUNT, ACT_WEIGHT, ACT_THEORY_WEIGHT, OP_PROCESS, LEVE_LOG, PRO_USER, PRO_SHIFT, 
PRO_GROUP, PRO_TIME,PRC_TECHNOLOGY_PATH,FLAG_STOVE_NO,PHY_BATCH_NO,FEED_HEAT_NO,HEAT_PLAN_SQE,BAL_YEAR_MONTH) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?)
	]]>
	</query>
	<query id="FrmVrpLoading.addButter" desc="新增位置表">
		<![CDATA[
   insert into YDM_BC_BUTTRESS(mat_no, judge_stove_no, batch_no, batch_groud_no, 
storage_no, location_no, lary_no, loc_no, storage_attr, storage_attr_name, 
storage_type_no, storage_type_name, management_no, management_name, create_name, 
create_time, department_code, department_desc) values(?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?)
		]]>
	</query>
	<query id="FrmVrpLoading.DeleteOutList" desc="删除出库记录投料出库">
		<![CDATA[
      DELETE YDM_BC_OUTLIST WHERE OUTSTOCK_SQE = ?  AND OUTSTOCK_TYPE_CODE = '800801'
		]]>
	</query>
	<query id="FrmVrpLoading.OutlistMonth" desc="查询出库表结算日期">
		<![CDATA[
      SELECT T.BAL_YEAR_MONTH FROM YDM_BC_OUTLIST T WHERE T.OUTSTOCK_SQE = ?
		]]>
	</query>
		<query id="FrmVrpLoading.DeleteOutListQuan" desc="删除出库记录产权出库">
		<![CDATA[
      DELETE YDM_BC_OUTLIST WHERE MAT_NO = ?  AND OUTSTOCK_TYPE_CODE = '800809' AND  OUTSTOCK_PLAN_NO = ?
		]]>
	</query>
	<query id="FrmVrpLoading.DeletePortVrp" desc="删除管号队列记录">
		<![CDATA[
DELETE PORT_VRP_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO = ?
   AND MAT_NO = ?
		]]>
	</query>
	<query id="FrmVrpLoading.queryYdmOut" desc="查询出库信息投料出库">
	<![CDATA[
SELECT OUTSTOCK_SQE,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       ACT_WEIGHT
  FROM (SELECT *
          FROM YDM_BC_OUTLIST
         WHERE OUTSTOCK_TYPE_CODE = '800801'
           AND JUDGE_STOVE_NO = ?
           AND NVL(BATCH_NO,'/') = NVL(?,'/')
           AND OUTSTOCK_PLAN_NO = ?
         ORDER BY MAT_NO DESC)
 WHERE ROWNUM < ? 
	]]>
	</query>
	<query id="FrmVrpLoading.queryYdmOutlist" desc="查询出库信息产出出库">
	<![CDATA[
SELECT OUTSTOCK_SQE,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       ACT_WEIGHT
  FROM (SELECT *
          FROM YDM_BC_OUTLIST
         WHERE OUTSTOCK_TYPE_CODE = '800809'
           AND JUDGE_STOVE_NO = ?
           AND NVL(BATCH_NO,'/') = NVL(?,'/')
           AND OUTSTOCK_PLAN_NO = ?
         ORDER BY MAT_NO DESC)
 WHERE ROWNUM < ? 
	]]>
	</query>
	<query id="FrmVrpLoading.getQueryInfoPlan" desc="查询是否存在上料之后的数据">
	<![CDATA[
	SELECT T.STATION_CODE, T.STATION_DESC
  FROM VRP_COM_INFO T
 WHERE  T.STATION_CODE !=?
 AND T.HEAT_PLAN_NO = ?
	]]>
	</query>
	<query id="FrmVrpLoading.doPlnBeside" desc="修改计划表结炉状态">
	<![CDATA[
 UPDATE PLN_ZY_DBK_M SET BESIDE_STATUS = ? WHERE HEAT_PLAN_NO = ?
	]]>
	</query>
	<query id="FrmVrpLoading.updateMatNoStuts" desc="修改材料表状态">
	<![CDATA[
 UPDATE MAT_BC_M
   SET MAT_STATUS       = '80150102',
       HANGING_FLAG     = '0',
       LOCK_LIKU        = '0',
       ORDER_NO         = '',
       ORDER_SEQ        = '',
       ORDER_SEQ_NO     = '',
       ORD_PK           = '',
       ORD_LN_PK        = '',
       ORD_LN_DLY_PK    = '',
       PRO_PLAN_ID_NEXT = '',
       GX_PLAN_NO_NEXT  = ''
 WHERE JUDGE_STOVE_NO = ?
   AND BATCH_NO = ?
   AND BATCH_GROUD_NO = ?
   AND JUGDE_APPLY_CODE = ?
   AND PRODUCT_FLAG = '801401'
         AND MAT_STATUS = '80150103'
    --     AND  B.MANAGEMENT_NO IN
    --   (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
    --  AND STORAGE_ATTR = '800302'
      AND NEXT_PROCESS_CDOE = 'E'
	]]>
	</query>
	<query id="FrmVrpLoading.getQueryOrderDbkS" desc="查询是否上料行">
	<![CDATA[
	SELECT MIN(NVL(T2.GX_PRO_SEQ,0)) GX_PRO_SEQ
  FROM (SELECT TO_NUMBER(T1.GX_PRO_SEQ) GX_PRO_SEQ
          FROM PLN_ORDER_DBK_S T1
         WHERE T1.PLINE_CODE = ?
           AND T1.EXE_STATUS = '0'
           AND T1.IF_STOVE_ISSUED = '1'
           AND TO_NUMBER(T1.GX_PRO_SEQ) >
               (SELECT MAX(TO_NUMBER(T.GX_PRO_SEQ)) GX_PRO_SEQ
                  FROM PLN_ORDER_DBK_S T
                 WHERE T.EXE_STATUS = '1'
                   AND T.PLINE_CODE = ?
                   AND T.IF_STOVE_ISSUED = '1')) T2
	]]>
	</query>
	
	<query id="FrmVrpLoading.SelectSyncFlag" desc="查询财务系统同步状态">
	<![CDATA[
	select T.*
  from FMIS_BC_OUTLIST t
 WHERE T.OUTSTOCK_TYPE_CODE = '800809'
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
   AND T.OUTSTOCK_PLAN_NO = ?
   AND T.ACT_COUNT = ?
	]]>
	</query>
	<query id="FrmVrpLoading.deleteFmis" desc="删除财务系统接口数据">
	<![CDATA[
	DELETE from FMIS_BC_OUTLIST t
 WHERE T.OUTSTOCK_TYPE_CODE = '800809'
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
   AND T.OUTSTOCK_PLAN_NO = ?
   AND T.ACT_COUNT = ?
	]]>
	</query>
</queryMap>