<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="离线管理">
	<query id="FrmVrpDownLineManage.doQueryOffLine" desc="查询离线实绩">
	  <![CDATA[
	 SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO PROCESS_ORDER,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.ORD_LN_DLY_PK,
       T.RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       NVL(T.ACT_LEN, 0) ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ZP_JUDGE_STOVE_NO,
       T.ZP_BATCH_NO,
       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,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       NVL(T.GROUP_WT, 0) GROUP_WT,
       NVL(T.SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_NUM, 0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT, 0) SUBCONTRACTCOMPLETE_WT,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       TO_CHAR(TO_DATE(T.PRO_YEAR_MONTH_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_YEAR_MONTH_DAY,
       T.PRO_USER,
       T.ZY_BATCH_ID1,
       T.BATCH_GROUD_NO,
       T.FLAG_STOVE_NO,
       T.MEMO,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜') PRO_SHIFT,
       DECODE(T.PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       DECODE(T.GROUP_LOG, '1', '已组炉', '0', '未组炉') GROUP_LOG,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT
  FROM VRP_OFFLINE_RESULT T
 WHERE 1=1
 AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) >0
	  ]]>
	</query>
	<query id = "FrmVrpDownLineManage.insertVrpTakeReslut" desc = "插入脱单实绩表,脱单,回写PLN_ORDER_ZG_S">
<![CDATA[
DECLARE
  v_JUDGE_STOVE_NO VRP_OFFLINE_RESULT.JUDGE_STOVE_NO%TYPE := ?;
  v_STATION_CODE    VRP_OFFLINE_RESULT.STATION_CODE%TYPE := ?;
  v_PLINE_CODE     VRP_OFFLINE_RESULT.PLINE_CODE%TYPE :=?;

  v_ID           VRP_TAKE_RESULT.ID%TYPE := NULL;
  v_OFFLINE_PRO1 VRP_OFFLINE_RESULT.STATION_CODE%TYPE := NULL;
  v_NMB          VRP_TAKE_RESULT.ID%TYPE := NULL;
BEGIN
  --生成ID
  --SELECT TO_CHAR(SYSDATE, 'YYMMDD') || v_PLINE_CODE ||
   --      LPAD(NVL(MAX(SUBSTR(T.ID, 11)), 0) + 1, 3, 0) DI
   -- INTO v_ID
  -- FROM VRP_TAKE_RESULT T
 --  WHERE T.PLINE_CODE = v_PLINE_CODE
  -- AND INSTR(T.ID, '-') = 0
 --    AND TO_CHAR(T.TAKE_TIME, 'YYYY-MM-DD') =
   --      TO_CHAR(SYSDATE, 'YYYY-MM-DD');

  FOR MYROW IN (SELECT *
                  FROM VRP_OFFLINE_RESULT T
                 WHERE T.JUDGE_STOVE_NO = v_JUDGE_STOVE_NO
                   AND T.STATION_CODE = v_STATION_CODE
                   AND T.PLINE_CODE = v_PLINE_CODE) LOOP
                   
                    SELECT TO_CHAR(SYSDATE, 'YYMMDD') || v_PLINE_CODE ||
          LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.ID, LENGTH(T.ID) - 2))), 0) + 1,
               3,
               '0') ID  INTO v_ID
     FROM VRP_TAKE_RESULT T
    WHERE ID LIKE TO_CHAR(SYSDATE, 'YYMMDD') || v_PLINE_CODE || '___';
  
   insert into vrp_take_result
  (id,
   result_no,
   pline_code,
   pline_name,
   station_code,
   station_desc,
   heat_plan_no,
   zy_batch_id,
   pro_plan_id,
   gx_plan_no,
   judge_stove_no,
   batch_no,
   produccode,
   producname,
   steelcode,
   steelname,
   gradecode,
   gradename,
   model_code,
   model_desc,
   std_code,
   std_name,
   std_style,
   std_style_desc,
   act_dimater,
   act_height,
   act_len,
   act_len_min,
   act_len_max,
   zp_judge_stove_no,
   zp_batch_no,
   offline_num,
   offline_wt,
   re_num,
   re_wt,
   group_num,
   group_wt,
   subcontract_num,
   subcontractcomplete_num,
   subcontractcomplete_wt,
   subcontract_no,
   subcontract_no_seq,
   pro_year_month_day,
   pro_user,
   pro_shift,
   pro_group,
   pro_time,
   group_log,
   group_id,
   ord_ln_dly_pk,
   order_no,
   order_seq,
   delivery_no,
   update_time,
   update_name,
   return_process,
   subcontract_wt,
   re_time,
   re_name,
   subcontract_time,
   subcontract_name,
   subcontractcomplete_time,
   subcontractcomplete_name,
   hb_fp_num,
   hb_fp_wt,
   bal_year_month,
   zy_batch_id1,
   batch_groud_no,
   flag_stove_no,
   flag,
   take_time,
   take_user,
   take_num)
values
  (v_id,
   MYROW.result_no,
   MYROW.pline_code,
   MYROW.pline_name,
   MYROW.station_code,
   MYROW.station_desc,
   MYROW.heat_plan_no,
   MYROW.zy_batch_id,
   MYROW.pro_plan_id,
   MYROW.gx_plan_no,
   MYROW.judge_stove_no,
   MYROW.batch_no,
   MYROW.produccode,
   MYROW.producname,
   MYROW.steelcode,
   MYROW.steelname,
   MYROW.gradecode,
   MYROW.gradename,
   MYROW.model_code,
   MYROW.model_desc,
   MYROW.std_code,
   MYROW.std_name,
   MYROW.std_style,
   MYROW.std_style_desc,
   MYROW.act_dimater,
   MYROW.act_height,
   MYROW.act_len,
   MYROW.act_len_min,
   MYROW.act_len_max,
   MYROW.zp_judge_stove_no,
   MYROW.zp_batch_no,
   MYROW.offline_num,
   MYROW.offline_wt,
   MYROW.re_num,
   MYROW.re_wt,
   MYROW.group_num,
   MYROW.group_wt,
   MYROW.subcontract_num,
   MYROW.subcontractcomplete_num,
   MYROW.subcontractcomplete_wt,
   MYROW.subcontract_no,
   MYROW.subcontract_no_seq,
   MYROW.pro_year_month_day,
   MYROW.pro_user,
   MYROW.pro_shift,
   MYROW.pro_group,
   MYROW.pro_time,
   MYROW.group_log,
   MYROW.group_id,
   MYROW.ord_ln_dly_pk,
   MYROW.order_no,
   MYROW.order_seq,
   MYROW.delivery_no,
   MYROW.update_time,
   MYROW.update_name,
   MYROW.return_process,
   MYROW.subcontract_wt,
   MYROW.re_time,
   MYROW.re_name,
   MYROW.subcontract_time,
   MYROW.subcontract_name,
   MYROW.subcontractcomplete_time,
   MYROW.subcontractcomplete_name,
   MYROW.hb_fp_num,
   MYROW.hb_fp_wt,
   MYROW.bal_year_month,
   MYROW.zy_batch_id1,
   MYROW.batch_groud_no,
   MYROW.flag_stove_no,
   MYROW.flag,
   SYSDATE,
   ?,
   NVL(MYROW.OFFLINE_NUM, 0) - NVL(MYROW.GROUP_NUM, 0) -
   NVL(MYROW.RE_NUM, 0));

    UPDATE VRP_OFFLINE_RESULT T
       SET T.PRO_PLAN_ID = '', T.GX_PLAN_NO = '', T.Order_No = '',t.order_seq ='',t.DELIVERY_NO =''
     WHERE T.JUDGE_STOVE_NO = v_JUDGE_STOVE_NO
       AND T.PLINE_CODE = v_PLINE_CODE
       AND T.STATION_CODE = v_STATION_CODE;
  END LOOP;
END;
]]>
</query>
<query id = "FrmVrpDownLineManage.doQueryTake" desc = "查询是否已脱单">
<![CDATA[
select count(1) ACOUNT
  from vrp_TAKE_RESulT t
 where t.judge_stove_no = ?
   and t.ZY_BATCH_ID = ?
   and t.STATION_CODE = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
]]>
</query>

<query id = "FrmVrpDownLineManage.doQueryTake2" desc = "查询是否已脱单">
<![CDATA[
select COUNT(1) ACOUNT
  from vrp_OFFLINE_RESulT t
 WHERE T.IS_TAKE = '1'
   AND T.JUDGE_STOVE_NO = ?
   AND T.LOT_NO = ?
   AND T.PLINE_CODE = ?
]]>
</query>
	<query id="FrmVrpDownLineManage.doQueryOffLineNum" desc="查询离线实绩">
	  <![CDATA[
	 SELECT 
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       abs((TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)))) TOTALCOUNT
  FROM VRP_OFFLINE_RESULT T
 WHERE 1=1 and t.HEAT_PLAN_NO = ? AND T.RESULT_NO = ?
 AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0))) <>0
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.deteleVrpPort" desc="删除管号队列新增数据">
	  <![CDATA[
	DELETE port_vrp_batch_sample_result T where T.MAT_NO = ? AND t.HEAT_PLAN_NO = ?
	and t.OP_PROCESS = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.queryVrpMatNo" desc="查询待处理的材料号">
	  <![CDATA[
	SELECT T.MAT_NO MAT_NO FROM port_vrp_batch_sample_result T where t.RESULT_nO = ? AND T.MAT_STATUS='00'
	order by t.MAT_NO DESC
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.doQueryOffLine2" desc="查询离线实绩">
		<![CDATA[
	 SELECT T.*,       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT
  FROM VRP_OFFLINE_RESULT T
 WHERE RESULT_NO = ?
  AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) <>0
	  ]]>
	</query>
<query id="FrmVrpDownLineManage.GetQueryVrpPort" desc="查询对应的管号队列数据">
        <![CDATA[
     	SELECT T.HEAT_PLAN_NO,
       T.MAT_NO,
       T.M_MAT_NO,
       T.M_M_MAT_NO,
       T.LOT_NO,
       T.LOT_NO_SQE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.STOVE_NO,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       DECODE(T.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       T.SAMPLE_PIPE_LEN,
       T.GET_SAMPLE_SHIFT,
       T.GET_SAMPLE_CLASS,
       T.GET_SAMPLE_NAME,
       TO_CHAR(T.GET_SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') GET_SAMPLE_TIME,
       T.OLD_JUDGE_STOVE_NO,
       DECODE(T.GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.OP_PROCESS
           AND T1.VALIDFLAG = '1') OP_PROCESS,
       DECODE(T.MAT_STATUS, '00', '合格', '10', '剔除', '20', '待处理','30','另组炉','40','委外废品') MAT_STATUS,
       DECODE(T.LEVE_LOG, '00', '无', '10', '离线', '20', '返线') LEVE_LOG,
       DECODE(T.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
       T.PRO_USER,
       DECODE(T.PRO_SHIFT, 1, '早', 2, '中', 3, '夜', 0, '常白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.REMARK,
      T.PRC_TECHNOLOGY_PATH,
      t.FEED_HEAT_NO,
      t.HEAT_PLAN_SQE
  FROM PORT_VRP_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ? and t.JUDGE_STOVE_NO =? and t.BATCH_NO = ?
 ORDER BY T.MAT_NO ASC
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.GetQueryVrpPortCount" desc="查询对应的管号队列数据支数">
        <![CDATA[
     	SELECT count(*) COUNT
  FROM PORT_VRP_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ? and t.JUDGE_STOVE_NO =? and t.BATCH_NO = ? AND T.LEVE_LOG in ('10','20')
 ORDER BY T.MAT_NO ASC
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.doQueryOffLineGroup" desc="查询组炉实绩">
	  <![CDATA[
	 SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO PROCESS_ORDER,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.ORD_LN_DLY_PK,
       T.RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       NVL(T.ACT_LEN, 0) ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ZP_JUDGE_STOVE_NO,
       T.ZP_BATCH_NO,
       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,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       NVL(T.GROUP_WT, 0) GROUP_WT,
       NVL(T.SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_NUM, 0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT, 0) SUBCONTRACTCOMPLETE_WT,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       TO_CHAR(TO_DATE(T.PRO_YEAR_MONTH_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_YEAR_MONTH_DAY,
       T.PRO_USER,
       T.ZY_BATCH_ID1,
       T.FLAG_STOVE_NO,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜') PRO_SHIFT,
       DECODE(T.PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       DECODE(T.GROUP_LOG, '1', '已组炉', '0', '未组炉') GROUP_LOG,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT,
       T.GROUP_ID
  FROM VRP_OFFLINE_RESULT T
 WHERE 1=1
 AND T.GROUP_LOG='1'
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.doQueryReturnLine" desc="查询返线实绩">
	  <![CDATA[
	 SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO PROCESS_ORDER,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.ORD_LN_DLY_PK,
       T.RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       NVL(T.ACT_LEN, 0) ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ZP_JUDGE_STOVE_NO,
       T.ZP_BATCH_NO,
       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,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       NVL(T.GROUP_WT, 0) GROUP_WT,
       NVL(T.SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_NUM, 0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT, 0) SUBCONTRACTCOMPLETE_WT,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       TO_CHAR(TO_DATE(T.PRO_YEAR_MONTH_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_YEAR_MONTH_DAY,
       T.PRO_USER,
       T.ZY_BATCH_ID1,
       T.FLAG_STOVE_NO,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜') PRO_SHIFT,
       DECODE(T.PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       DECODE(T.GROUP_LOG, '1', '已组炉', '0', '未组炉') GROUP_LOG,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT,
       T.GROUP_ID,
       T.RETURN_PROCESS,
       T.FLAG
  FROM VRP_OFFLINE_RESULT T
 WHERE 1=1
 AND TO_NUMBER(NVL(T.RE_NUM, 0)) <>0
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.getOrder" desc="查询合同信息">
<![CDATA[
SELECT T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '已生产',
              '3',
              '关闭A',
              '') EXE_STATUS,    
       T2.*
  FROM PLN_ORDER_DBK_S T,
       (SELECT Q1.PRODUCCODE,
               Q1.PRODUCNAME,
               Q1.STD_CODE,
               Q1.STD_NAME,
               Q1.STD_STYLE,
               Q1.STD_STYLE_DESC,
               Q1.ORDER_SPEC_CODE,
               Q1.ORDER_SPEC_DESC,
               Q1.SPEC_CODE,
               Q1.SPEC_NAME,
               Q2.ORD_LN_DLY_PK  ORD_LN_DLY_PK1, 
               Q2.ORD_LN_PK,
               Q1.STEELCODE,
               Q1.STEELNAME,
               Q1.DELVRY_RANGE_TPE,
               Q1.DELVRY_RANGE_MAX,
               Q1.DELVRY_RANGE_MIN,
               Q2.DELVRY_QTY,
               Q3.CRAFT_SEQ,
               Q3.CRAFT_NO,
               Q4.CRAFT_NAME,
               NVL(Q1.DIMATER, 0) DIMATER,
               NVL(Q1.HEIGHT, 0) HEIGHT,
               NVL(Q3.CRAFT_PATH,
                   (SELECT C1.CRAFT_PATH
                      FROM CRAFT_ORD_DESIGN C2, CRAFT_ORD_DESIGN_FILE C1
                     WHERE C1.CRAFT_NO = C2.CRAFT_NO
                       AND C1.CRAFT_NO_V = C2.CRAFT_NO_V
                       AND C1.VALIDFLAG = '1'
                       AND C2.VALIDFLAG = '1'
                       AND C2.ORD_LN_PK = Q1.ORD_LN_PK)) AS CRAFT_PATH,
               Q3.CRAFT_FILE_LV2_E
          FROM SLM_ORDER_LINE           Q1,
               SLM_ORDER_LINE_DELIVERY  Q2,
               CRAFT_ORD_DESIGN         Q3,
               CRAFT_ORD_DESIGN_APPOINT Q4
         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
           AND Q1.ORD_LN_PK = Q3.ORD_LN_PK(+)
           AND Q1.ORD_LN_PK = Q4.ORD_LN_PK(+)
           AND Q3.VALIDFLAG(+) = '1') T2
 WHERE T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK1(+)
   AND T.EXE_STATUS IN ('0', '1')
   AND T.PLINE_CODE = ?
    AND (T.PRO_PLAN_ID NOT IN (?) OR
       T.GX_PLAN_NO NOT IN (?))
   AND T.ORDER_NO || '&' LIKE ('%' || ?|| '%')

   ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryOffLineMaxResultNo" desc="查询最大离线实绩编号">
        <![CDATA[
                    	SELECT ? ||
	LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
	0) + 1,
	6,
	'0') RESULT_NO
	FROM VRP_OFFLINE_RESULT
	WHERE RESULT_NO LIKE ? || '______'
        ]]>
	</query>

	
	<query id="FrmVrpDownLineManage.QueryGroupResult" desc="查询组操作Id">
        <![CDATA[
	SELECT ? ||
  LPAD(SUBSTR(NVL(MAX(T.GROUP_ID),'000000'),-6,6) + 1, 6, '0') AS GROUP_ID
  FROM VRP_GROUP_RESULT T
  WHERE TO_CHAR(T.PRO_TIME,'YYYY-MM-DD') = ?
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryOffLineGroupStart" desc="查询是否组炉">
        <![CDATA[
SELECT T.GROUP_LOG,
       T.GROUP_ID,
       NVL(T.OFFLINE_NUM, 0) OFFLINE_NUM,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) COUNT_NUM,
       TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) RE_NUM,
       TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) SUBCONTRACT_NUM,
       FLAG
  FROM VRP_OFFLINE_RESULT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
   AND T.RESULT_NO = ?
   AND NVL(T.HEAT_PLAN_NO,'/') = NVL(?,'/')
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryOffLineGroupId" desc="查询组炉信息">
        <![CDATA[
SELECT COUNT(1) COUNT
  FROM VRP_OFFLINE_RESULT T
 WHERE T.GROUP_LOG = '1'
   AND T.RESULT_NO = ?
   AND T.GROUP_ID = ?
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.AddOffLineResu" desc="新增组炉实绩">
        <![CDATA[
INSERT INTO VRP_OFFLINE_RESULT (RESULT_NO, PLINE_CODE, PLINE_NAME, STATION_CODE, 
STATION_DESC, HEAT_PLAN_NO, ZY_BATCH_ID, PRO_PLAN_ID, GX_PLAN_NO, 
JUDGE_STOVE_NO, BATCH_NO, PRODUCCODE, PRODUCNAME, STEELCODE, STEELNAME, 
GRADECODE, GRADENAME, MODEL_CODE, MODEL_DESC, STD_CODE, STD_NAME, STD_STYLE, 
STD_STYLE_DESC, ACT_DIMATER, ACT_HEIGHT, ACT_LEN, ACT_LEN_MIN, ACT_LEN_MAX, 
ZP_JUDGE_STOVE_NO, ZP_BATCH_NO, OFFLINE_NUM, OFFLINE_WT, PRO_USER, PRO_SHIFT, 
PRO_GROUP, PRO_TIME, GROUP_LOG, GROUP_ID, ORD_LN_DLY_PK, ORDER_NO, ORDER_SEQ, 
DELIVERY_NO,ZY_BATCH_ID1,BATCH_GROUD_NO) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), '1', ?, ?, ?, ?, ?,?,?)
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.UpdateOffLineResu" desc="修改离线组炉支，吨">
        <![CDATA[    
 DECLARE
BEGIN
  UPDATE VRP_OFFLINE_RESULT
     SET GROUP_NUM = TO_NUMBER(NVL(GROUP_NUM, 0)) + TO_NUMBER(?),
         GROUP_WT  = TO_NUMBER(NVL(GROUP_WT, 0)) + TO_NUMBER(?),
         UPDATE_TIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
         UPDATE_NAME=?
   WHERE RESULT_NO = ?;
  INSERT INTO VRP_GROUP_RESULT
    (GROUP_ID,
     GROUP_XH,
     ZP_JUDGE_STOVE_NO,
     ZP_BATCH_NO,
     JUDGE_STOVE_NO,
     BATCH_NO,
     GROUP_NUM,
     GROUP_WT,
     PRO_USER,
     PRO_SHIFT,
     PRO_GROUP,
     PRO_TIME,
     LX_RESULT_NO)
  VALUES
    (?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?);
END;
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.UpdateOffLineComm" desc="修改离线表数据（改判）">
        <![CDATA[ 
        UPDATE VRP_OFFLINE_RESULT
   SET PRODUCCODE     = ?,
       PRODUCNAME     = ?,
       STEELCODE      = ?,
       STEELNAME      = ?,
       MODEL_CODE     = ?,
       MODEL_DESC     = ?,
       STD_CODE       = ?,
       STD_NAME       = ?,
       STD_STYLE      = ?,
       STD_STYLE_DESC = ?,
       ACT_DIMATER    = ?,
       ACT_HEIGHT     = ?,
       ACT_LEN        = ?,
       ORD_LN_DLY_PK  = ?,
       ORDER_NO       = ?,
       ORDER_SEQ      = ?,
       DELIVERY_NO    = ?,
       UPDATE_TIME    = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME    = ?,
       PRO_PLAN_ID    = ?,
       GX_PLAN_NO     = ?
 WHERE RESULT_NO = ?  
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.DaeleteGroupResu" desc="修改离线组炉支，吨,删除组炉履历表">
        <![CDATA[    
 DECLARE
BEGIN
  UPDATE VRP_OFFLINE_RESULT
     SET GROUP_NUM = TO_NUMBER(NVL(GROUP_NUM, 0)) - TO_NUMBER(?),
         GROUP_WT  = TO_NUMBER(NVL(GROUP_WT, 0)) - TO_NUMBER(?),
         UPDATE_TIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
         UPDATE_NAME=?
   WHERE RESULT_NO = ?;
  DELETE VRP_GROUP_RESULT
   WHERE GROUP_ID = ?
     AND GROUP_XH = ?;
END;
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.DeleteOffLineResu" desc="删除离线表组炉记录">
        <![CDATA[    
DELETE VRP_OFFLINE_RESULT
 WHERE RESULT_NO = ?
 AND GROUP_ID=?
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryGroupVrpResult" desc="查询组炉履历表信息">
        <![CDATA[    
SELECT GROUP_ID,
       GROUP_XH,
       ZP_JUDGE_STOVE_NO,
       ZP_BATCH_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       GROUP_NUM,
       GROUP_WT,
       PRO_YEAR_MONTH_DAY,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       LX_RESULT_NO
  FROM VRP_GROUP_RESULT
 WHERE GROUP_ID = ?
        ]]>
	</query>
	
	<query id="FrmVrpDownLineManage.doQuery" desc="查询工序点">
        <![CDATA[    
SELECT T.BASECODE,T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   AND T.VALIDFLAG = '1'
   AND T.BASENAME NOT IN ('分批取样', '交库')
   ORDER BY T.BASECODE ASC
        ]]>
	</query>
			<query id="FrmVrpDownLineManage.queryheatsqe" desc="镦拔扩上料行ID">
        <![CDATA[    
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.HEAT_PLAN_SQE), '00'), -2, 2) + 1, 2, '0') AS HEAT_PLAN_SQE
  FROM PLN_ZY_DBK_C T
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.AddReturnResu" desc="新增镦拔扩计划表">
        <![CDATA[    
INSERT INTO PLN_ZY_DBK_M (HEAT_PLAN_NO, ZY_BATCH_ID, PRO_PLAN_ID, 
GX_PLAN_NO, PLINE_CODE, PLINE_NAME, UPPER_HEATPLAN_ID, JUDGE_STOVE_NO, BATCH_NO, 
 ISENDGX, ORDER_SOURCE, ORD_LN_DLY_PK, ORDER_NO, ORDER_SEQ, 
DELIVERY_NO, REQ_BL_ID, GRADECODE, GRADENAME, AIMOUTDIAMETER, AIMWALLTHICK, 
AIMLENGTH, OUTDIAMETER_IN, WALLTHICK_IN, LENGTH_IN, LENGTHMAX_IN, LENGTHMIN_IN, 
LEN_CUTHEAD, LEN_CUTEND, INWL_ID, INWL_DESC,IF_MATCH_ODD, 
OUTWL_ID, OUTWL_DESC, IF_MONITOR, PRDCR_NO, MONITOR_POINT, 
CRAFT_FILE_NO, CRAFT_FILE_MAN, CRAFT_SEQ, SEC_CRAFT_FILE_NO, STATION_ROAD, 
PLANSTATUS, CREATE_NAME, CREATE_TIME,PRODUCCODE,PRODUCNAME) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?,?)
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.AddReturnResuC" desc="新增镦拔扩计划从表">
        <![CDATA[    
DECLARE
BEGIN
  FOR MROW IN (SELECT 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,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.WEIGTH_S,
       T.NUM_S,
       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.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.ISENDGX,
       T.IF_MONITOR_DBK,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.GRADECODE,
       T.GRADENAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       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.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.MEMO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.REAL_BATCH_WT,
       T.REAL_BATCH_NUM
                 FROM PLN_ORDER_DBK_S T
                WHERE T.PRO_PLAN_ID = ?
                  AND T.GX_PLAN_NO = ?) LOOP
    INSERT INTO PLN_ZY_DBK_C
      (HEAT_PLAN_NO,
       ZY_BATCH_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       HEAT_PLAN_SQE,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       PLINE_CODE,
       PLINE_NAME,
       OUTDIAMETER_IN,
       WALLTHICK_IN,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       PLAN_INDOUBLE_NUM,
       PLAN_INDOUBLE_WT,
       REAL_INDOUBLE_NUM,
       REAL_INDOUBLE_WT
       )
    VALUES
      (?,
       MROW.ZY_BATCH_ID,
       MROW.PRO_PLAN_ID,
       MROW.GX_PLAN_NO,
       ?,
       ?,
       ?,
       ?,
       MROW.PLINE_CODE,
       MROW.PLINE_NAME,
       MROW.OUTDIAMETER,
       MROW.WALLTHICK,
       MROW.LENGTHMAX_IN,
       MROW.LENGTHMIN_IN,
       ?,
       ?,
       ?,
       ?
       );
  END LOOP;
END;
        ]]>
	</query>
	<query id="FrmVrpDownLineManage.UpdatePortVrpReturn" desc="修改管号队列表">
        <![CDATA[          
UPDATE PORT_VRP_BATCH_SAMPLE_RESULT
   SET MAT_STATUS          = ?,
       LEVE_LOG            = ?,
       PRC_TECHNOLOGY_PATH = ?,
       RETURN_PROCESS      = ?,
       FLAG_STOVE_NO       = ?,
       INSTORE_FLAG = ?
 WHERE HEAT_PLAN_NO = ?
   AND MAT_NO = ?
         ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryOffMatNo" desc="查询管号队列离线材料号">
        <![CDATA[  
        SELECT *
  FROM (SELECT T.MAT_NO,T.PHY_BATCH_NO,T.IS_SAMPLE_PIPE,T.ACT_COUNT
          FROM port_vrp_batch_sample_result T
         WHERE T.MAT_STATUS = '20'
           AND T.HEAT_PLAN_NO = ?
           AND T.OP_PROCESS = ?
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM < ?
          ]]>
	</query>

	<query id="FrmVrpDownLineManage.QueryOffMatNo2" desc="查询管号队列离线材料号">
		<![CDATA[
        SELECT *
  FROM (SELECT *
          FROM port_vrp_batch_sample_result T
         WHERE T.MAT_STATUS = '20'
           AND T.RESULT_NO =?
         ORDER BY T.MAT_NO ASC)
          ]]>
	</query>

	<query id="FrmVrpDownLineManage.QueryNewFurnMatNo" desc="查询管号队列另组炉材料号">
		<![CDATA[
        SELECT T.MAT_NO
          FROM port_vrp_batch_sample_result T
         WHERE T.MAT_STATUS = '30'
            AND T.RESULT_NO =?
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>

	<query id="FrmVrpDownLineManage.QueryReturnMatNo" desc="查询管号队列返线的材料号">
        <![CDATA[  
      SELECT T.MAT_NO
          FROM port_vrp_batch_sample_result T
         WHERE T.LEVE_LOG = '20'
           AND T.RESULT_NO =?
           AND MAT_STATUS = '00'
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>
	<query id="FrmVrpDownLineManage.AddPortVrpReturn" 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, FLAG_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,RETURN_PROCESS,MAT_STATUS,PHY_BATCH_NO,FEED_HEAT_NO,HEAT_PLAN_SQE,INSTORE_FLAG
,BAL_YEAR_MONTH) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?)
         ]]>
	</query>
		<query id="FrmVrpDownLineManage.getQueryMatNo" desc="查询管号队列对应最大的材料号">
        <![CDATA[
SELECT MAX(T.MAT_NO) MAT_NO
  FROM PORT_VRP_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?

        ]]>
	</query>
	<query id="FrmVrpDownLineManage.UpdateMatReturn" desc="修改材料表">
        <![CDATA[         
UPDATE MAT_BC_M T
   SET T.MAT_STATUS     = ?,
       T.QCM_STAUS      = ?,
       T.PRODUCCODE     = ?,
       T.PRODUCNAME     = ?,
       T.STEELCODE      = ?,
       T.STEELNAME      = ?,
       T.MODEL_CODE     = ?,
       T.MODEL_DESC     = ?,
       T.STD_CODE       = ?,
       T.STD_NAME       = ?,
       T.STD_STYLE      = ?,
       T.STD_STYLE_DESC = ?,
       T.ACT_DIMATER    = ?,
       T.ACT_HEIGHT     = ?,
       T.ACT_LEN        = ?,
       T.ORD_LN_DLY_PK  = ?,
       T.ORDER_NO       = ?,
       T.ORDER_SEQ      = ?,
       T.ORDER_SEQ_NO   = ?,
       T.ORD_PK         = ?,
       T.ORD_LN_PK      = ?
 WHERE T.MAT_NO = ?
 
         ]]>
	</query>


	<query id="FrmVrpDownLineManage.queryMatNoM" desc="自动生存材料号">
		<![CDATA[
	SELECT ? || ? ||
       LPAD(NVL(MAX(SUBSTR(T2.MAT_NO, LENGTH(T2.MAT_NO) - 3)), 0) + 1, 4, 0) MAT_NO
  FROM (SELECT MAX(T.MAT_NO) MAT_NO
          FROM MAT_BC_M T
         WHERE T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
        UNION ALL
        SELECT MAX(T1.MAT_NO) MAT_NO
          FROM YDM_BC_INLIST T1
         WHERE T1.JUDGE_STOVE_NO = ?
           AND T1.BATCH_NO = ?
        UNION ALL
        SELECT MAX(T3.MAT_NO) MAT_NO
          FROM MAT_ZC_BACKUP T3
         WHERE T3.JUDGE_STOVE_NO = ?
           AND T3.BATCH_NO = ?) T2
		]]>
	</query>
	<query id="FrmVrpDownLineManage.AddMatReturn" desc="新增材料表">
        <![CDATA[   
     INSERT INTO MAT_BC_M
    (JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     ACT_COUNT,
     ACT_WEIGHT,
     CREATE_NAME,
     CREATE_TIME,
     MAT_NO,
     PRODUCT_FLAG,
     MAT_STATUS,
     PLINE_CODE,
     PLINE_NAME,
     QCM_STAUS,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     SPEC_CODE,
     SPEC_NAME,
     GRADECODE,
     GRADENAME,
     MODEL_CODE,
     MODEL_DESC,
     STD_CODE,
     STD_NAME,
     BELONG_CODE,
     BELONG_NAME,
     STD_STYLE,
     STD_STYLE_DESC,
     ACT_DIMATER,
     ACT_HEIGHT,ORD_LN_DLY_PK,ORDER_NO,ORDER_SEQ,ORDER_SEQ_NO,ORD_PK,ORD_LN_PK)
  VALUES
    (?,
     ?,
     ?,
     ?,
     ?,?,
     TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
         ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryPlnOrig" desc="查询原计划">
        <![CDATA[   
        SELECT 
       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,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.WEIGTH_S,
       T.NUM_S,
       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.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.ISENDGX,
       T.IF_MONITOR_DBK,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.GRADECODE,
       T.GRADENAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       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.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.MEMO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.REAL_BATCH_WT,
       T.REAL_BATCH_NUM
 FROM PLN_ORDER_DBK_S T
 WHERE
T.PRO_PLAN_ID = ?
AND T.GX_PLAN_NO = ?
AND T.EXE_STATUS IN ('0','1')  
         ]]>
	</query>
	<query id="FrmVrpDownLineManage.queryPlanMaxNo" desc="获取最大计划编号">
	<![CDATA[
     SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.HEAT_PLAN_NO), '0000'), -4,4) + 1, 4, '0') AS HEAT_PLAN_NO
  FROM PLN_ZY_DBK_M T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
	]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryPortBatch" desc="查询管号队列炉计划ID">
	<![CDATA[
    SELECT T.HEAT_PLAN_NO
  FROM PORT_VRP_BATCH_SAMPLE_RESULT T
 WHERE T.OP_PROCESS = ?
   AND T.MAT_STATUS = '20'
   AND T.LEVE_LOG = '10'
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.GROUP_NO = ?
	]]>
	</query>
	<query id="FrmVrpDownLineManage.UpdateOff" desc=" 修改离线表返线支数">
	<![CDATA[
UPDATE VRP_OFFLINE_RESULT
   SET RE_NUM      =  ?,
       RE_WT       = ?,
       RE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       RE_NAME = ?,
       RETURN_PROCESS=?,
       HEAT_PLAN_NO=?
 WHERE RESULT_NO = ?
	]]>
	</query>
		<query id="FrmVrpDownLineManage.UpdateStatus" desc=" 修改组炉返线材料状态">
	<![CDATA[
UPDATE PORT_VRP_BATCH_SAMPLE_RESULT
   SET MAT_STATUS = '30',LEVE_LOG = '00', BAL_YEAR_MONTH_FAIL =TO_CHAR(SYSDATE , 'YYYYMM'),IS_FAIL_CHECK='1'
 WHERE  HEAT_PLAN_NO = ?
   AND MAT_NO = ?
	]]>
	</query>
	<query id="FrmVrpDownLineManage.UpdateStatus1" desc=" 修改组炉返线材料状态">
	<![CDATA[
UPDATE PORT_VRP_BATCH_SAMPLE_RESULT
   SET MAT_STATUS = '20',LEVE_LOG = '10', BAL_YEAR_MONTH_FAIL= '',IS_FAIL_CHECK='0'
 WHERE  HEAT_PLAN_NO = ?
        AND MAT_NO =?
	]]>
	</query>
	<query id="FrmVrpDownLineManage.queryStorageType" desc="查询库位信息">
	 <![CDATA[ 
SELECT T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC
  FROM YDM_BS_STORAGE T
 WHERE T.STORAGE_NO = ?
 AND T.VALIDFLAG='1'
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.AddButtReturn" desc=" 新增位置表">
	<![CDATA[
INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_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="FrmVrpDownLineManage.DeletePortVrpReturn" desc="删除管号队列表">
	 <![CDATA[ 
DELETE PORT_VRP_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.DeleteReturnResu" desc="删除计划表">
	 <![CDATA[ 
DELETE PLN_ZY_DBK_M WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.DeleteReturnResuC" desc="删除计划从表">
	 <![CDATA[ 
DELETE PLN_ZY_DBK_C WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.DeleteMatReturn" desc="删除材料表">
	 <![CDATA[ 
DELETE MAT_BC_M WHERE MAT_NO = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryComVrpRes" desc="查询返线后是否存在实绩">
	 <![CDATA[ 
SELECT COUNT(1) COUNT FROM VRP_COM_INFO T WHERE T.HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.QueryButtMatNo" desc="查询材料表材料号">
	 <![CDATA[ 
SELECT   T1.MAT_NO  FROM (SELECT T.MAT_NO
               FROM MAT_BC_M T
              WHERE T.JUDGE_STOVE_NO = ?
                AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
                AND T.PRODUCT_FLAG = '801401'
              ORDER BY T.MAT_NO) T1
 WHERE ROWNUM < ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.doQueryOutSourc" desc="委外实绩查询">
	 <![CDATA[ 
SELECT T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.CRAFT_FILE_NO,
       T.SUBCONTRACT_NUM,
       T.SUBCONTRACT_WT,
       T.HB_COMPLETE_NUM,
       T.HB_COMPLETE_WT,
       T.SUBCONTRACT_USER,
       DECODE(T.SUBCONTRACT_SHIFT, '1', '早', '2', '中', '3', '夜') SUBCONTRACT_SHIFT,
       DECODE(T.SUBCONTRACT_GROUP,
              '1',
              '甲',
              '2',
              '乙',
              '3',
              '丙',
              '4',
              '丁') SUBCONTRACT_GROUP,
       TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
       T.SP_USER,
       TO_CHAR(T.SP_TIME, 'YYYY-MM-DD HH24:MI:SS') SP_TIME,
       DECODE(T.SUBCONTRACT_LOG,
              '00',
              '委外申请',
              '10',
              '审核通过',
              '20',
              '审核不通过',
              '30',
              '回报完毕') SUBCONTRACT_LOG,
       T.SUBCONTRACT_PLINE_CODE,
       T.SUBCONTRACT_PLINE_NAME,
       T.SUBCONTRACT_NOTE,
       T.HB_FP_NUM,
       T.HB_FP_WT,
       T.SP_NOTE,
       T.RESULT_NO
  FROM VRP_ENTRUSTED_BILL T
 WHERE 1=1
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.AddOutSourc" desc="新增委外加工表">
	 <![CDATA[
	 INSERT INTO VRP_ENTRUSTED_BILL (SUBCONTRACT_NO, SUBCONTRACT_NO_SEQ, PLINE_CODE, 
PLINE_NAME, STATION_CODE, STATION_DESC, HEAT_PLAN_NO, ZY_BATCH_ID, PRO_PLAN_ID, 
GX_PLAN_NO, JUDGE_STOVE_NO, BATCH_NO, PRODUCCODE, PRODUCNAME, STEELCODE, 
STEELNAME, GRADECODE, GRADENAME, MODEL_CODE, MODEL_DESC, STD_CODE, STD_NAME, 
STD_STYLE, STD_STYLE_DESC, ACT_DIMATER, ACT_HEIGHT, ACT_LEN, ACT_LEN_MIN, 
ACT_LEN_MAX, CRAFT_FILE_NO, SUBCONTRACT_NUM, SUBCONTRACT_WT, SUBCONTRACT_USER, 
SUBCONTRACT_SHIFT, SUBCONTRACT_GROUP, SUBCONTRACT_TIME, SUBCONTRACT_LOG, 
SUBCONTRACT_NOTE,RESULT_NO,SUBCONTRACT_PLINE_CODE,SUBCONTRACT_PLINE_NAME,SUBCONTRACT_TYPE,SUBCONTRACT_GX,BATCH_GROUD_NO) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?,?,?,?,?,?,?)
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.UpdateOffOutSourc" desc="修改离线表委外支数">
	 <![CDATA[
	 UPDATE VRP_OFFLINE_RESULT
   SET SUBCONTRACT_NUM      = ?,
       SUBCONTRACT_WT       = ?,
       SUBCONTRACT_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       SUBCONTRACT_NAME = ?,
       SUBCONTRACT_NO=?,
       SUBCONTRACT_NO_SEQ=?
 WHERE RESULT_NO = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.deleteOutSourc" desc="删除委外加工表">
	 <![CDATA[
	DELETE VRP_ENTRUSTED_BILL
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
	  ]]>
	</query>
	<query id="FrmVrpDownLineManage.queryEntrustrMax" desc="获取最大委外单号">
	<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.SUBCONTRACT_NO), '0000'), -4,4) + 1, 4, '0') AS SUBCONTRACT_NO
  FROM VRP_ENTRUSTED_BILL T
 WHERE TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD') = ?
	]]>
	</query>
	<query id="FrmVrpDownLineManage.QuerySubConStart" desc="查询委托状态">
	<![CDATA[
SELECT T.SUBCONTRACT_LOG
  FROM VRP_ENTRUSTED_BILL T
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
	]]>
	</query>
	<query id="FrmVrpDownLineManage.doQueryPlanStrat" desc="查询计划是否结炉">
	<![CDATA[
SELECT T.PLANSTATUS FROM PLN_ZY_DBK_M T WHERE T.HEAT_PLAN_NO = ?
	]]>
	</query>
	<query id="FrmVrpDownLineManage.doQueryComInfo" desc="查询返线最大实绩">
	<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM VRP_COM_INFO T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
   AND T.PLINE_CODE = ?

	]]>
	</query>
	<query id="FrmVrpDownLineManage.doUpdateFlagStoveNo" desc="修改离线标识炉号">
	<![CDATA[
	UPDATE VRP_OFFLINE_RESULT T
   SET T.FLAG_STOVE_NO = ?
 WHERE T.RESULT_NO = ?
	]]>
	</query>


	<query id="FrmVrpDownLineManage.UpdatePlanStatus" desc="全组炉返线, 关闭原计划">
		<![CDATA[
UPDATE PLN_ZY_DBK_M T
   SET PLANSTATUS = DECODE((SELECT COUNT(1)
                             FROM PORT_VRP_BATCH_SAMPLE_RESULT
                            WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
                              AND MAT_STATUS <> '10'
                              AND MAT_STATUS <> '30'
                              AND MAT_STATUS <> '40'),
                           0,
                           '40',
                           '20')
 WHERE T.HEAT_PLAN_NO =?
	]]>
	</query>

	<query id="FrmVrpDownLineManage.queryHttM" desc="新增组炉实绩">
		<![CDATA[
               SELECT * FROM VRP_GROUP_RESULT  WHERE ZP_JUDGE_STOVE_NO =?
        ]]>
	</query>
</queryMap>