<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="人工质检">

        <query id="SurFace_Insp.SurFaceQuery" desc="人工质检 信息查询">
        <![CDATA[
      SELECT 
       RESULT_NO,
       JUDGE_STOVE_NO,
       LOT_NO,
       PLINE_CODE,                                                                                                           
       TYPE,
       TARGET_DIAMETER,
       TARGET_THICKNESS,
       TARGET_LENGTH,
       PIPE_DIAM_MIN,
       PIPE_THICKNESS_MAX,
       PIPE_DIAM_MAX,
       PIPE_THICKNESS_MIN,
       NON_ROUNDNESS,
       UNEVEN_DEGREE,
       LENGTH,
       WEIGHT,
       DIRECTOR_QUANTITY,
       OFFLINE_QUANTITY,
       INSPECTOR,
       WASTE_QUANTITY,
       QUALIFIED_BRANCH,
       QUALIFIED_TONS,
       HEAD_STRAIGHT,
       BODY_STRAIGHT,
       ELLIPSE_DEGREE,
       PATTERN_NUMBER,
       PHY_PROPERTIES,
       EXECUTIVE_PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       PRODUCER_TEL,
       REMARK,
       CASE COL_MODE
       WHEN '0' THEN '接口采集'
       WHEN '1' THEN '人工录入'
       END AS COL_MODE,
       QA_TYPE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP，
       TO_CHAR(START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       NODE_FUR_FLAG,
       SIMPLE_RATE
       FROM MIL_SURFACE_RESULT WHERE 
       LOT_NO 	|| '&' LIKE '%' || ? || '%' 
       AND JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
        ]]>
	</query>


     <query id="SurFace_Insp.GetQAResult" desc="人工质检 信息查询">
        <![CDATA[
       SELECT T.RESULT_NO,
       T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.PLINE_CODE,
       T.TYPE,
       T.TARGET_DIAMETER,
       T.TARGET_THICKNESS,
       T.TARGET_LENGTH,
       T.PIPE_DIAM_MIN,
       T.PIPE_THICKNESS_MAX,
       T.PIPE_DIAM_MAX,
       T.PIPE_THICKNESS_MIN,
       T.NON_ROUNDNESS,
       T.UNEVEN_DEGREE,
       T.LENGTH,
       T.WEIGHT,
       T.DIRECTOR_QUANTITY,
       T.OFFLINE_QUANTITY,
       T.INSPECTOR,
       T.WASTE_QUANTITY,
       T.QUALIFIED_BRANCH,
       T.QUALIFIED_TONS,
       T.HEAD_STRAIGHT,
       T.BODY_STRAIGHT,
       T.ELLIPSE_DEGREE,
       T.PATTERN_NUMBER,
       T.PHY_PROPERTIES,
       T.EXECUTIVE_PRODUCER,
       TO_CHAR(T.PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       T.PRODUCER_TEL,
       T.REMARK,
       T.COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       T.COL_SHIFT,
       T.COL_GROUP,
       TO_CHAR(T.START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(T.END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       T.NODE_FUR_FLAG,
       T.SIMPLE_RATE,
       TO_CHAR(T.QA_TIME, 'YYYY-MM-DD HH24:MI:SS') QA_TIME,
       T.HEIGHT_RATE,
       DECODE(T.SIZE_CHECK,'0','尺寸未抽检','1','尺寸已抽检')SIZE_CHECK
 FROM MIL_SURFACE_RESULT T
 WHERE

 T.JUDGE_STOVE_NO = ?
  AND T.RESULT_NO = ?
  AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
        ]]>
	</query>

	<query id="SurFace_Insp.ADD_SurFaceQuery" desc="开始质检">
        <![CDATA[
        INSERT INTO MIL_SURFACE_RESULT(
        RESULT_NO,
        LOT_NO,
        JUDGE_STOVE_NO,
        PLINE_CODE,
        START_TIME,
        SIZE_CHECK,
        PRO_PLAN_ID,
        GX_PLAN_NO
        )
 VALUES( 
 '#RESULT_NO#',
        '#ROLL_LOT_NO#',
        '#HEAT_NO#',
         '#PLINE_CODE#',
        SYSDATE,
        '#SIZE_CHECK#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#'
        )
        ]]>
	</query>
	
	<query id="SurFace_Insp.Upd_SurFaceQuery_1" desc="开始质检改变上料信息表状态">
        <![CDATA[
        UPDATE MIL_PLAN SET   
        STATUS='#STATUS#' 
        WHERE 
        JUDGE_STOVE_NO='#JUDGE_STOVE_NO#' AND 
        LOT_NO='#LOT_NO#'
        AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
     AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
        ]]>
	</query>
	
	
	<query id="SurFace_Insp.ZLXSQuery" desc="开始质检改变上料信息表状态">
        <![CDATA[
       SELECT HEIGHT_RATE,OFFLINE_QUANTITY,WASTE_QUANTITY  FROM MIL_SURFACE_RESULT WHERE JUDGE_STOVE_NO = ? AND RESULT_NO = ? AND DEFECT_CHECK = '1'
        ]]>
	</query>
	
	 
	<query id="SurFace_Insp.Upd_SurFaceQuery" desc="保存质检信息">
	<![CDATA[
	UPDATE MIL_SURFACE_RESULT
   SET REMARK = '#REMARK#' , COL_SHIFT = '#COL_SHIFT#' ,
                COL_GROUP = '#COL_GROUP#' , COL_USER = '#COL_USER#' ,
                DIRECTOR_QUANTITY = '#DIRECTOR_QUANTITY#' ,
                QUALIFIED_TONS = '#QUALIFIED_TONS#' ,
                WASTE_QUANTITY = '#WASTE_QUANTITY#' ,
                OFFLINE_QUANTITY = '#OFFLINE_QUANTITY#' ,
                EXECUTIVE_PRODUCER = '#EXECUTIVE_PRODUCER#' ,
                UNEVEN_DEGREE = '#UNEVEN_DEGREE#',
                NON_ROUNDNESS = '#NON_ROUNDNESS#' ,
                PIPE_DIAM_MAX = '#PIPE_DIAM_MAX#' ,
                PIPE_DIAM_MIN = '#PIPE_DIAM_MIN#' ,
                PIPE_THICKNESS_MAX = '#PIPE_THICKNESS_MAX#' ,
                PIPE_THICKNESS_MIN = '#PIPE_THICKNESS_MIN#' ,
                HEAD_STRAIGHT = '#HEAD_STRAIGHT#' ,
                BODY_STRAIGHT = '#BODY_STRAIGHT#' , LENGTH = '#LENGTH#' ,
                QUALIFIED_BRANCH = '#QUALIFIED_BRANCH#' ,
                WEIGHT = '#WEIGHT#'
 WHERE LOT_NO = '#ROLL_LOT_NO#'
   AND JUDGE_STOVE_NO = '#HEAT_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
	]]>
	</query>
	
	
	<query id="SurFace_Insp.Node_SurFaceQuery" desc="结炉">
	<![CDATA[
        UPDATE MIL_SURFACE_RESULT
   SET NODE_FUR_FLAG = '#NODE_FLAG#',
       COL_GROUP     = '#COL_GROUP#',
       COL_SHIFT     = '#COL_SHIFT#',
       COL_USER      = '#COL_USER#',
       END_TIME      = SYSDATE,
       USER_ID       = '#USER_ID#'
 WHERE LOT_NO = '#ROLL_LOT_NO#'
   AND JUDGE_STOVE_NO = '#HEAT_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
        ]]>
	</query>
	<query id="SurFace_Insp.Upd_Node_SurFaceQuery" desc="改变结炉状态">
        <![CDATA[
        UPDATE MIL_PLAN
   SET NODE_STATUS = '#NODE_STATUS#'
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND LOT_NO = '#LOT_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
        ]]>
	</query>
	<query id = "SurFace_Insp.updateGroup" desc = "结炉写班次班组">
	<![CDATA[
	DECLARE
  V_SEQ MIL_TESTING_RACK.SEQ%TYPE := 0;
BEGIN
  SELECT NVL(MAX(T.SEQ), 0)
    INTO V_SEQ
    FROM MIL_QA_RACK T
   WHERE T.JUDGE_STOVE_NO = '#HEAT_NO#'
     AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
     AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
     AND T.CHANGE_FLAG = '1';
  UPDATE MIL_QA_RACK T
     SET T.COL_SHIFT = '#COL_SHIFT#', T.COL_GROUP = '#COL_GROUP#'
   WHERE T.JUDGE_STOVE_NO = '#HEAT_NO#'
     AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
     AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
     AND T.OFFLINE_FLAG = '1'
     AND T.COL_SHIFT IS NULL
     AND T.COL_GROUP IS NULL;
  UPDATE MIL_QA_RACK T
     SET T.COL_SHIFT = '#COL_SHIFT#', T.COL_GROUP = '#COL_GROUP#'
   WHERE T.JUDGE_STOVE_NO = '#HEAT_NO#'
     AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
     AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
     AND T.OFFLINE_FLAG = '0'
     AND T.COL_SHIFT IS NULL
     AND T.COL_GROUP IS NULL
     AND T.SEQ >= 1
     AND ROWNUM <= #QUALIFIED_BRANCH# - V_SEQ;
  UPDATE MIL_SURFACE_RESULT T
     SET T.COL_SHIFT = '#COL_SHIFT#', T.COL_GROUP = '#COL_GROUP#'
   WHERE T.JUDGE_STOVE_NO = '#HEAT_NO#'
     AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
     AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/');
END;
   ]]>
	</query>
	<query id = "SurFace_Insp.updatePortSample" desc = "结炉写黄狗腿那边的取样分批表">
	DECLARE
BEGIN
  FOR MYROW IN (SELECT ROWNUM SEQ,T1.MAT_NO FROM (SELECT MAT_NO
                  FROM MIL_QA_RACK T
                 WHERE T.JUDGE_STOVE_NO = '#HEAT_NO#'
                   AND T.RESULT_NO = '#RESULT_NO#'
                   AND T.MAT_NO IS NOT NULL
                   AND T.OFFLINE_FLAG = '0'
                   AND T.STATUS = '0'
                 ORDER BY T.SEQ ASC)T1) LOOP
    UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
       SET T.MAT_NO = MYROW.MAT_NO
     WHERE T.JUDGE_STOVE_NO = '#HEAT_NO#'
       AND T.PLAN_ID = '#RESULT_NO#'
       AND T.SEQ = MYROW.SEQ;
  END LOOP;
END;
	</query>
	<query id="SurFace_Insp.SurfaceResult_query" desc="人工质检实绩信息查询">
        <![CDATA[
      SELECT 
       RESULT_NO,
       JUDGE_STOVE_NO,
       LOT_NO,
       PLINE_CODE,                                                                                                           
       TYPE,
       TARGET_DIAMETER,
       TARGET_THICKNESS,
       TARGET_LENGTH,
       PIPE_DIAM_MIN,
       PIPE_THICKNESS_MAX,
       PIPE_DIAM_MAX,
       PIPE_THICKNESS_MIN,
       NON_ROUNDNESS,
       UNEVEN_DEGREE,
       LENGTH,
       WEIGHT,
       DIRECTOR_QUANTITY,
       OFFLINE_QUANTITY,
       INSPECTOR,
       WASTE_QUANTITY,
       QUALIFIED_BRANCH,
       QUALIFIED_TONS,
       HEAD_STRAIGHT,
       BODY_STRAIGHT,
       ELLIPSE_DEGREE,
       PATTERN_NUMBER,
       PHY_PROPERTIES,
       EXECUTIVE_PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       PRODUCER_TEL,
       REMARK,
       CASE COL_MODE
       WHEN '0' THEN '接口采集'
       WHEN '1' THEN '人工录入'
       END AS COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       
       CASE COL_SHIFT 
        WHEN '0' THEN '常白班'
       WHEN '1' THEN '早班'
       WHEN '2' THEN '中班'
       WHEN '3' THEN '晚班'
       END AS COL_SHIFT,
       
       CASE COL_GROUP 
       WHEN '1' THEN '甲'
       WHEN '2' THEN '乙'
       WHEN '3' THEN '丙'
       WHEN '4' THEN '丁'
       END AS COL_GROUP,
       
       TO_CHAR(START_TIME,'YYYY-MM-SS HH24:MI:SS')START_TIME,
       TO_CHAR(END_TIME,'YYYY-MM-SS HH24:MI:SS')END_TIME,
       NODE_FUR_FLAG
       FROM MIL_SURFACE_RESULT WHERE 
       PLINE_CODE=? AND 
       COL_SHIFT=? AND 
       COL_GROUP=? AND 
       END_TIME BETWEEN TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') AND
       NODE_FUR_FLAG='1'
        ]]>
	</query>
	<query id="SurFace_Insp.getSurfaceRackSeq" desc="质检上料管号队列">
	 <![CDATA[
	  SELECT 
       SIMPLE_LOT_NO,
       MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       case STATUS when
       '0' then '正常轧制' when
       '1' then '剔除' when
       --'2' then '二检剔除' when
       '2' then '下线' when
       '4' then '最终下线' 
       END AS STATUS,
       QA_FLAG,
       SCRAP_REASON,
       TO_CHAR(START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       DECODE(OFFLINE_FLAG,'0','未下线','1','下线')OFFLINE_FLAG,
       TO_CHAR(OFFLINE_TIME, 'YYYY-MM-DD HH24:MI:SS') OFFLINE_TIME,
       FOLLOW_FLAG,
       FOLLOW_HEAT_NO,
       TO_CHAR(FOLLOW_TIME, 'YYYY-MM-DD HH24:MI:SS') FOLLOW_TIME,
       GROUP_FLAG,
       BEFORE_HEAT_NO,
       BEFORE_MAT_NO,
       REMARK,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       case COL_GROUP 
       WHEN '1' THEN '甲'
       WHEN '2' THEN '乙'
       WHEN '3' THEN '丙'
       WHEN '4' THEN '丁' end as COL_GROUP,
       case COL_SHIFT
       WHEN '0' THEN '常白班'
       WHEN '1' THEN '早班'
       WHEN '2' THEN '中班'
       WHEN '3' THEN '晚班'
      end as COL_SHIFT,
       SEQ,
       TO_CHAR(QA_TIME, 'YYYY-MM-DD HH24:MI:SS') QA_TIME,
       CASE CHANGE_FLAG
       WHEN '0' THEN ''
	   WHEN '1' THEN '确认交班'
       WHEN '2' THEN '待接班确认'
	END AS CHANGE_FLAG,
	'交班'CHANGE_GROUP,
	'接班'TAKE_OVER
 FROM MIL_QA_RACK
 WHERE JUDGE_STOVE_NO=?  order by SEQ ASC
	 ]]>
	</query>
	
	
	<query id="SurFace_Insp.getSurfaceRackSeq1" desc="质检上料管号队列">
	 <![CDATA[
	  SELECT 
       SIMPLE_LOT_NO,
       MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       case STATUS when
       '0' then '正常轧制' when
       '1' then '一检剔除' when
       '2' then '二检剔除' when
       '3' then '下线' when
       '4' then '最终下线' 
       END AS STATUS,
       case OFFLINE_FLAG_F when
        '0' then '正常轧制' when
       '1' then '一检下线' WHEN
        '2' then '剔除' 
       END AS OFFLINE_FLAG_F,
       QA_FLAG,
       SCRAP_REASON,
       TO_CHAR(START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       OFFLINE_FLAG,
       TO_CHAR(OFFLINE_TIME, 'YYYY-MM-DD HH24:MI:SS') OFFLINE_TIME,
       FOLLOW_FLAG,
       FOLLOW_HEAT_NO,
       TO_CHAR(FOLLOW_TIME, 'YYYY-MM-DD HH24:MI:SS') FOLLOW_TIME,
       GROUP_FLAG,
       BEFORE_HEAT_NO,
       BEFORE_MAT_NO,
       REMARK,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       case COL_GROUP 
       WHEN '1' THEN '甲'
       WHEN '2' THEN '乙'
       WHEN '3' THEN '丙'
       WHEN '4' THEN '丁' end as COL_GROUP,
       case COL_SHIFT
       WHEN '0' THEN '常白班'
       WHEN '1' THEN '早班'
       WHEN '2' THEN '中班'
       WHEN '3' THEN '晚班'
      end as COL_SHIFT,
       SEQ,
       TO_CHAR(QA_TIME, 'YYYY-MM-DD HH24:MI:SS') QA_TIME
 FROM MIL_QA_RACK
 WHERE JUDGE_STOVE_NO=? order by OFFLINE_FLAG_F desc
	 ]]>
	</query>
	
	<query id="SurFace_Insp.PipeDefectQuery" desc="管号队列缺陷项查询">
	 <![CDATA[
	  SELECT 
       DEFECT_NAME1,
       DEFECT_NAME2,
       DEFECT_NAME3,
       DEFECT_NAME4,
       DEFECT_NAME5
      
 FROM MIL_QA_DEFECT
 WHERE
          JUDGE_STOVE_NO = ? 
   and    RESULT_NO = ?
   and    SAMPLE_PIPE_SEQ = ?
   and    FLAG = ?
	 ]]>
	</query>
	
	<query id="SurFace_Insp.AddMIL_QA_DEFECT" desc="抽检表插入">
	 <![CDATA[
	 insert into MIL_QA_DEFECT
	 (
	 JUDGE_STOVE_NO,
	 SAMPLE_PIPE_NO,
	 DEFECT,
	 SAMPLE_PIPE_SEQ
	 ) 
	 values
	 (
	 '#JUDGE_STOVE_NO#',
	 '#SAMPLE_PIPE_NO#',
	 '#DEFECT#',
	  '#SAMPLE_PIPE_SEQ#'
	 )
	 ]]>
	</query>
	<query id="SurFace_Insp.getDefect" desc="获取质检缺陷项列表">
	 <![CDATA[
	 select * from MIL_QA_DEFECT where JUDGE_STOVE_NO=? order by SAMPLE_PIPE_SEQ,DEFECT,defect
	 ]]>
	</query>
	
	
		<query id="SurFace_Insp.UpdateSurfaceResultNumF" desc="抽检后更新质检实绩信息  总检量，合格支，合格吨,废品量，下线量，重量系数">
	 <![CDATA[
	UPDATE MIL_SURFACE_RESULT T
   SET T.DIRECTOR_QUANTITY = '#DIRECTOR_QUANTITY#',
       T.OFFLINE_QUANTITY  = '#OFFLINE_QUANTITY#',
       T.INSPECTOR         = '#INSPECTOR#',
       T.WASTE_QUANTITY    = '#WASTE_QUANTITY#',
       T.QUALIFIED_BRANCH  = '#QUALIFIED_BRANCH#',
       T.QUALIFIED_TONS    = '#QUALIFIED_TONS#',
       T.HEIGHT_RATE       = '#HEIGHT_RATE#'
 WHERE T.RESULT_NO = '#RESULT_NO#'
   AND T.JUDGE_STOVE_NO = '#HEAT_NO#'
   AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
	 ]]>
	</query>
	
	
			<query id="SurFace_Insp.UpdateSurfaceResultNumS" desc="抽检后更新质检实绩信息  总检量，合格支，合格吨,废品量，下线量，重量系数">
	 <![CDATA[
	UPDATE MIL_SURFACE_RESULT T
   SET T.DIRECTOR_QUANTITY = '#DIRECTOR_QUANTITY#',
       T.OFFLINE_QUANTITY  = '#OFFLINE_QUANTITY#',
       T.INSPECTOR         = '#INSPECTOR#',
       T.WASTE_QUANTITY    = '#WASTE_QUANTITY#',
       T.QUALIFIED_BRANCH  = '#QUALIFIED_BRANCH#',
       T.QUALIFIED_TONS    = '#QUALIFIED_TONS#',
       T.HEIGHT_RATE       = '#HEIGHT_RATE#'
 WHERE T.RESULT_NO = '#RESULT_NO#'
   AND T.JUDGE_STOVE_NO = '#HEAT_NO#'
   AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
	 ]]>
	</query>
	
	<query id="SurFace_Insp.UpdMIL_QA_DEFECT" desc="修改质检结果">
        <![CDATA[
        UPDATE MIL_QA_DEFECT SET   
        IS_QUELIFIED='#IS_QUELIFIED#' 
        WHERE 
        JUDGE_STOVE_NO='#JUDGE_STOVE_NO#' AND 
        SAMPLE_PIPE_SEQ='#SAMPLE_PIPE_SEQ#' AND 
        DEFECT='#DEFECT#'
        ]]>
	</query>
	
	<query id="SurFace_Insp.getDefect_by_MIL_QA_DEFECT" desc="查询上料管号缺陷项抽检记录">
        <![CDATA[
        select  DEFECT,
        CASE IS_QUELIFIED 
        WHEN 0 THEN '不合格' 
        WHEN 1 THEN '合格'
        END AS IS_QUELIFIED
        from MIL_QA_DEFECT where JUDGE_STOVE_NO='#JUDGE_STOVE_NO#' AND SAMPLE_PIPE_SEQ='#SAMPLE_PIPE_SEQ#'
        ]]>
	</query>
	<query id="SurFace_Insp.getMIL_SIZE_CHECK_DEATIL" desc="几何尺寸抽查记录">
        <![CDATA[
       select * from mil_size_check_deatil where JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
        ]]>
	</query>
	<query id="SurFace_Insp.getDefect_statistics" desc="抽检统计">
        <![CDATA[
select defect,sum(IS_QUELIFIED) as QUELIFIED,(count(defect)-sum(IS_QUELIFIED)) as unQUELIFIED,count(defect)   from mil_qa_defect t where judge_stove_no=? group by defect 
        ]]>
	</query>
	<query id="SurFace_Insp.Upd_MIL_SIZE_CHECK_DEATIL" desc="新增几何尺寸抽查记录">
	 <![CDATA[
	 INSERT INTO MIL_SIZE_CHECK_DEATIL
  (RESULT_NO,
   JUDGE_STOVE_NO,
   SAMPLE_PIPE_NO,
   D1,
   D2,
   S1,
   S2,
   S3,
   S4,
   NON_ROUNDNESS,
   UNEVEN_DEGREE,
   LOCATION,
   SAMPLE_PIPE_SEQ,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#RESULT_NO#',
   '#JUDGE_STOVE_NO#',
   '#SAMPLE_PIPE_NO#',
   '#D1#',
   '#D2#',
   '#S1#',
   '#S2#',
   '#S3#',
   '#S4#',
   '#NON_ROUNDNESS#',
   '#UNEVEN_DEGREE#',
   '#LOCATION#',
   '#SAMPLE_PIPE_SEQ#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')

	 ]]>
	</query>
	<query id="SurFace_Insp.AddMilSizeCheckDeatilEntity" desc="更新几何尺寸抽查记录">
	 <![CDATA[
	 INSERT INTO MIL_SIZE_CHECK_DEATIL
	 ( 
     JUDGE_STOVE_NO,
	 SAMPLE_PIPE_NO,
	 SAMPLE_PIPE_SEQ
	 )
	  VALUES
	 (
	 '#JUDGE_STOVE_NO#',
	 '#SAMPLE_PIPE_NO#',
	 '#SAMPLE_PIPE_SEQ#'
	 )
	 ]]>
	</query>
	
	<query id="SurFace_Insp.get_Chk_Active" desc="获取上料表选中的抽检项">
        <![CDATA[
      select * from MIL_QA_DEFECT where JUDGE_STOVE_NO=?
        ]]>
	</query>
	<query id="SurFace_Insp.DelMIL_QA_DEFECT" desc="删除质检缺陷项表相应炉号记录">
        <![CDATA[
      delete from MIL_QA_DEFECT Where JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
        ]]>
	</query>
	<query id="SurFace_Insp.DelMilSizeCheckDeatilEntity" desc="删除相应炉号的管号抽检项">
        <![CDATA[
      delete from MIL_SIZE_CHECK_DEATIL Where JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
        ]]>
	</query>
    <query id="SurFace_Insp.Upd_MIL_SURFACE_RESULT_ChkRate" desc="保存抽检率到质检表MIL_SURFACE_RESULT">
        <![CDATA[
      Update MIL_SURFACE_RESULT set SIMPLE_RATE='#SIMPLE_RATE#' Where JUDGE_STOVE_NO='#HEAT_NO#'
        ]]>
	</query>	
	 <query id="SurFace_Insp.update_SurFace_QUALIFIED_BRANCH" desc="更新质检合格支">
        <![CDATA[
      Update MIL_SURFACE_RESULT set QUALIFIED_BRANCH=? Where JUDGE_STOVE_NO=?
        ]]>
	</query>	 
	
	<query id="SurFace_Insp.getMIL_CHECK_DEATIL" desc="查询质检抽检数据">
        <![CDATA[
      select * from mil_check_deatil where JUDGE_STOVE_NO=?
        ]]>
	</query>	 
	<query id="SurFace_Insp.SaveMIL_CHECK_DEATIL" desc="更新质检抽检数据">
        <![CDATA[
      Update MIL_CHECK_DEATIL set WASTE_BRANCH='#WASTE_BRANCH#',WASTE_TONS='#WASTE_TONS#',OFFLINE_PRODUCT='#OFFLINE_PRODUCT#' 
       Where JUDGE_STOVE_NO='#JUDGE_STOVE_NO#' and DEFECT_ITEM='#DEFECT_ITEM#'
        ]]>
        </query>	
        <query id="SurFace_Insp.getMIL_CHECK_DEATIL_Statictis" desc="统计废品量">
        <![CDATA[
      select sum(WASTE_BRANCH) WASTE_BRANCH ,sum(OFFLINE_PRODUCT) OFFLINE_PRODUCT from mil_check_deatil where JUDGE_STOVE_NO=?
        ]]>
        </query>	
         <query id="SurFace_Insp.getMIL_MT_RESULT" desc="查询MT总检量">
        <![CDATA[
      select QUALIFIED_NUM from mil_mt_result where JUDGE_STOVE_NO=? and NODE_FUR_FLAG='1'
        ]]>
        </query>	
	   <query id="SurFace_Insp.getMIL_ET_RESULT" desc="查询ET总检量">
        <![CDATA[
      select QUALIFIED_NUM from mil_et_result where JUDGE_STOVE_NO=? and NODE_FUR_FLAG='1'
        ]]>
        </query>	
        <query id="SurFace_Insp.getMIL_BASE_DEFECT_ITEM" desc="查询缺陷项信息">
        <![CDATA[
           select DEFECT_ITEM_CODE,DEFECT_ITEM_NAME,decode(defect_level,'0','常用','1','不常用') defect_level from mil_base_defect_item t
        ]]>
        </query>	
        <query id="SurFace_Insp.AddMIL_BASE_DEFECT_ITEM" desc="添加缺陷项">
        <![CDATA[
           insert into   MIL_BASE_DEFECT_ITEM  values(?,?,?,?)
        ]]>
        </query>	
        <query id="SurFace_Insp.UpdMIL_BASE_DEFECT_ITEM" desc="更新缺陷项">
        <![CDATA[
           update   mil_base_defect_item set DEFECT_ITEM_CODE=?, DEFECT_ITEM_NAME=?,DEFECT_LEVEL=?,PLINE_CODE=? where DEFECT_ITEM_CODE=?
        ]]>
        </query>	
        <query id="SurFace_Insp.DelMIL_BASE_DEFECT_ITEM" desc="删除缺陷项">
        <![CDATA[
           delete  from mil_base_defect_item where DEFECT_ITEM_CODE=?
        ]]>
        </query>	
        
        <query id="SurFace_Insp.getMIL_BASE_INSPECTOR" desc="查询质检员信息">
        <![CDATA[
          select  INSPECTOR_CODE,INSPECTOR_NAME,PLINE_CODE,decode(COL_SHIFT,'0','早','1','中','2','晚') COL_SHIFT,decode(COL_GROUP,'0','甲','1','乙','2','丙','3','丁') COL_GROUP from mil_base_inspector t
        ]]>
        </query>	
        <query id="SurFace_Insp.AddMIL_BASE_INSPECTOR" desc="添加质检员">
        <![CDATA[
           insert into   mil_base_inspector  values(?,?,?,?,?)
        ]]>
        </query>	
        <query id="SurFace_Insp.UpdMIL_BASE_INSPECTOR" desc="更新质检员">
        <![CDATA[
           update   mil_base_inspector set INSPECTOR_CODE=?, INSPECTOR_NAME=?,COL_SHIFT=?,COL_GROUP=?,PLINE_CODE=? where INSPECTOR_CODE=?
        ]]>
        </query>	
        <query id="SurFace_Insp.DelMIL_BASE_INSPECTOR" desc="删除质检员">
        <![CDATA[
           delete  from mil_base_inspector where INSPECTOR_CODE=?
        ]]>
        </query>	
         <query id="SurFace_Insp.DelMIL_CHECK_DEATIL" desc="删除相应炉号的抽检项">
        <![CDATA[
           delete  from MIL_CHECK_DEATIL where JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
        ]]>
        </query>	
        <query id="SurFace_Insp.InsMIL_QA_DEFECT" desc="添加相应炉号的抽检项">
        <![CDATA[
           insert into   MIL_CHECK_DEATIL values('#JUDGE_STOVE_NO#','#DEFECT_ITEM#','#WASTE_BRANCH#','#WASTE_TONS#','#OFFLINE_PRODUCT#','#DEFECT_CODE#')
        ]]>
        </query>	
        
        
           <query id="SurFace_Insp.checkedDefectItemQuery" desc="缺陷项查询">
        <![CDATA[
 select t.basename,
       t.basecode,
       t.sortcode,
       '添加' ADD_ITEM,
       '0' WASTENUM,
       '0' OFFNUM,
       case t.memo
         WHEN '0' THEN
          '常用'
         WHEN '1' THEN
          '不常用'
       END AS memo
  from com_base_info t
 where t.SORTCODE = 5003
 AND T.VALIDFLAG = '1'
   and t.memo || '&' LIKE '%' || ? || '%'
   and t.basename || '&' LIKE '%' || ? || '%'
        ]]>
        </query>
        
        
             <query id="SurFace_Insp.ItemQuery" desc="缺陷项查询">
        <![CDATA[
		SELECT DEFECT_ITEM,
       WASTE_BRANCH,
       WASTE_TONS,
       OFFLINE_PRODUCT,
       DEFECT_CODE,
       SUM(NVL(WASTE_BRANCH, 0)) TWASTE_BRANCH,
       SUM(NVL(WASTE_TONS, 0)) TWASTE_TONS,
       SUM(NVL(OFFLINE_PRODUCT, 0)) TOFFLINE_PRODUCT,
       JUDGE_STOVE_NO
  FROM MIL_CHECK_DEATIL_SIMPLE
 WHERE JUDGE_STOVE_NO = ?
   AND RESULT_NO = ?
 GROUP BY DEFECT_ITEM,
          WASTE_BRANCH,
          WASTE_TONS,
          OFFLINE_PRODUCT,
          DEFECT_CODE,
          JUDGE_STOVE_NO
          
        ]]>
        </query>		
        
         	   <query id="SurFace_Insp.SizeCheckQuery" desc="查询抽检管记录">
        <![CDATA[
          SELECT a.SAMPLE_PIPE_NO,
       a.D1,
       a.D2,
       a.S1,
       a.S2,
       a.S3,
       a.S4,
       A.NON_ROUNDNESS,
       A.UNEVEN_DEGREE,
       --case a.LOCATION 
       --WHEN '1' THEN '管体'
       --WHEN '0' THEN '管端'
       --END AS LOCATION,
       a.LOCATION,
       a.SAMPLE_PIPE_SEQ,
       '删除' AS BTN_DELETE
  FROM MIL_SIZE_CHECK_DEATIL a
 WHERE a.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
   AND NVL(A.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(A.GX_PLAN_NO, '/') = NVL(?, '/')
--and a.result_no = ?
        ]]>
        </query>	
        
        
       <query id="SurFace_Insp.checkMatNoQuery" desc="查询质检管号队列">
        <![CDATA[
           SELECT a.SEQ, a.MAT_NO
  FROM MIL_QA_RACK a
 WHERE a.JUDGE_STOVE_NO = ?
   and a.RESULT_NO = ?
   AND NVL(A.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(A.GX_PLAN_NO, '/') = NVL(?, '/')
        ]]>
        </query>	
        
        
            
       <query id="SurFace_Insp.GetQAResult1" desc="查询质检实绩">
        <![CDATA[
            SELECT 
       T.RESULT_NO,
       T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.PLINE_CODE,
       T.TYPE,
       T.TARGET_DIAMETER,
       T.TARGET_THICKNESS,
       T.TARGET_LENGTH,
       T.PIPE_DIAM_MIN,
       T.PIPE_THICKNESS_MAX,
       T.PIPE_DIAM_MAX,
       T.PIPE_THICKNESS_MIN,
       T.NON_ROUNDNESS,
       T.UNEVEN_DEGREE,
       T.LENGTH,
       T.WEIGHT,
       T.DIRECTOR_QUANTITY,
       T.OFFLINE_QUANTITY,
       T.INSPECTOR,
       T.WASTE_QUANTITY,
       T.QUALIFIED_BRANCH,
       T.QUALIFIED_TONS,
       T.HEAD_STRAIGHT,
       T.BODY_STRAIGHT,
       T.ELLIPSE_DEGREE,
       T.PATTERN_NUMBER,
       T.PHY_PROPERTIES,
       T.EXECUTIVE_PRODUCER,
       TO_CHAR(T.PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       T.PRODUCER_TEL,
       T.REMARK,
       T.COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       T.COL_SHIFT,
       T.COL_GROUP,
       TO_CHAR(T.START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(T.END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       T.NODE_FUR_FLAG,
       T.SIMPLE_RATE,
       TO_CHAR(T.QA_TIME, 'YYYY-MM-DD HH24:MI:SS') QA_TIME,
       T.HEIGHT_RATE,
       T.DEFECT_CHECK,
       T.SIZE_CHECK,
       T.QA_TYPE,
       T.DIRECTOR_QUANTITY_F,
       T.OFFLINE_QUANTITY_F,
       T.INSPECTOR_F,
       T.WASTE_QUANTITY_F,
       T.QUALIFIED_BRANCH_F,
       T.QUALIFIED_TONS_F,
       T.DIRECTOR_QUANTITY_S,
       T.OFFLINE_QUANTITY_S,
       T.INSPECTOR_S,
       T.WASTE_QUANTITY_S,
       T.QUALIFIED_BRANCH_S,
       T.QUALIFIED_TONS_S
 FROM MIL_SURFACE_RESULT T
 WHERE
T.RESULT_NO = '#RESULT_NO#'
AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
        ]]>
        </query>	
        
        
        	<query id="SurFace_Insp.InsertDefectData" desc="缺陷项数据插入">
	<![CDATA[
         INSERT INTO MIL_CHECK_DEATIL(
        JUDGE_STOVE_NO,
        RESULT_NO,
        DEFECT_ITEM,
        WASTE_BRANCH,
        WASTE_TONS,
        OFFLINE_PRODUCT,
        DEFECT_CODE,
        FLAG)
 VALUES( 
        '#JUDGE_STOVE_NO#',
        '#RESULT_NO#',
        '#DEFECT_ITEM#',
        '#WASTE_BRANCH#',
        '#WASTE_TONS#',     
        '#OFFLINE_PRODUCT#',
        '#DEFECT_CODE#',
        '#FLAG#')
        ]]>
	</query>
	
	    
        	<query id="SurFace_Insp.InsertDefectDataSimple" desc="缺陷项数据插入">
	<![CDATA[
         INSERT INTO MIL_CHECK_DEATIL_SIMPLE(
        JUDGE_STOVE_NO,
        RESULT_NO,
        DEFECT_ITEM,
        WASTE_BRANCH,
        WASTE_TONS,
        OFFLINE_PRODUCT,
        SIMPLE_LOT_NO,
        DEFECT_CODE)
 VALUES( 
        '#JUDGE_STOVE_NO#',
        '#RESULT_NO#',
        '#DEFECT_ITEM#',
        '#WASTE_BRANCH#',
        '#WASTE_TONS#',     
        '#OFFLINE_PRODUCT#',
        '#SIMPLE_LOT_NO#',
        '#DEFECT_CODE#')
        ]]>
	</query>
	      	<query id="SurFace_Insp.DeleteDefectData" desc="缺陷项数据删除">
	<![CDATA[
        DELETE MIL_CHECK_DEATIL WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' and Result_no = '#RESULT_NO#'
    
        ]]>
	</query>
	<query id = "SurfaceInspectionResult.getDefectData" desc = "查询缺陷项">
	SELECT T.JUDGE_STOVE_NO,
       T.DEFECT_ITEM,
       T.WASTE_BRANCH,
       T.WASTE_TONS,
       T.SIMPLE_LOT_NO,
       T.OFFLINE_PRODUCT
  FROM MIL_CHECK_DEATIL_SIMPLE T
 WHERE T.JUDGE_STOVE_NO = ?
	</query>
	<query id = "SurfaceInspectionResult.doInsetDefectData" desc = "登记缺陷项">
	<![CDATA[
DECLARE
  V_COUNT          MIL_OFFLINE_RESLUT.OFFLINE_NUM%TYPE := NULL;
  V_JUDGE_STOVE_NO MIL_OFFLINE_RESLUT.JUDGE_STOVE_NO%TYPE := ?;
  V_PRO_PLAN_ID    MIL_OFFLINE_RESLUT.PRO_PLAN_ID%TYPE := ?;
  V_GX_PLAN_NO     MIL_OFFLINE_RESLUT.GX_PLAN_NO%TYPE := ?;
BEGIN

  INSERT INTO MIL_CHECK_DEATIL_SIMPLE
    (JUDGE_STOVE_NO,
     DEFECT_ITEM,
     WASTE_BRANCH,
     WASTE_TONS,
     OFFLINE_PRODUCT,
     DEFECT_CODE,
     RESULT_NO,
     SIMPLE_LOT_NO,
     PRO_PLAN_ID,
     GX_PLAN_NO)
  VALUES
    (V_JUDGE_STOVE_NO, ?, ?, ?, ?, ?, ?, '', V_PRO_PLAN_ID, V_GX_PLAN_NO);
  UPDATE MIL_SURFACE_RESULT T
     SET T.OFFLINE_QUANTITY = TO_NUMBER(T.OFFLINE_QUANTITY) + TO_NUMBER(?),
         T.WASTE_QUANTITY   = TO_NUMBER(T.WASTE_QUANTITY) + TO_NUMBER(?)
   WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
     AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
     AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/');
  FOR MYROWOFFLINE IN (SELECT *
                         FROM (SELECT T.SEQ,
                                      T.JUDGE_STOVE_NO,
                                      TO_NUMBER(DECODE(T.SEQ,
                                                       '1',
                                                       '9999',
                                                       '2',
                                                       '9999',
                                                       T.SEQ)) RN
                                 FROM MIL_QA_RACK T
                                WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                                     --AND T.COL_SHIFT IS NULL
                                     --AND T.COL_GROUP IS NULL
                                  AND T.OFFLINE_FLAG = '0'
                                  AND T.STATUS = '0'
                                ORDER BY NVL(T.MAT_NO, 0) DESC, RN)
                        WHERE ROWNUM <= ?) LOOP
    UPDATE MIL_QA_RACK T
       SET T.OFFLINE_FLAG = '1', T.STATUS = '2'
     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
       AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
       AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/')
       AND T.SEQ = MYROWOFFLINE.SEQ;
    INSERT INTO MIL_SLAB_SCRAP_SEQ
      (JUDGE_STOVE_NO,
       PROCESS_NO,
       SEQ,
       TIME,
       FLAG,
       REMARK,
       COL_MODE,
       COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       COL_NO,
       COL_TYPE,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    VALUES
      (MYROWOFFLINE.JUDGE_STOVE_NO,
       '11',
       MYROWOFFLINE.SEQ,
       SYSDATE,
       '0',
       '',
       '1',
       SYSDATE,
       ?,
       ?,
       ?,
       '0',
       '1',
       V_PRO_PLAN_ID,
       V_GX_PLAN_NO);
  END LOOP;
  FOR MYROWSCRAP IN (SELECT *
                       FROM (SELECT T.SEQ,
                                    T.JUDGE_STOVE_NO,
                                    TO_NUMBER(DECODE(T.SEQ,
                                                     '1',
                                                     '9999',
                                                     '2',
                                                     '9999',
                                                     T.SEQ)) RN
                               FROM MIL_QA_RACK T
                              WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                                AND NVL(T.PRO_PLAN_ID, '/') =
                                    NVL(V_PRO_PLAN_ID, '/')
                                AND NVL(T.GX_PLAN_NO, '/') =
                                    NVL(V_GX_PLAN_NO, '/')
                                   --AND T.COL_SHIFT IS NULL
                                   --AND T.COL_GROUP IS NULL
                                AND T.OFFLINE_FLAG = '0'
                                AND T.STATUS = '0'
                              ORDER BY NVL(T.MAT_NO, 0) DESC, RN)
                      WHERE ROWNUM <= ?) LOOP
    UPDATE MIL_QA_RACK T
       SET T.STATUS = '1'
     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
       AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
       AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/')
       AND T.SEQ = MYROWSCRAP.SEQ;
    INSERT INTO MIL_SLAB_SCRAP_SEQ
      (JUDGE_STOVE_NO,
       PROCESS_NO,
       SEQ,
       TIME,
       FLAG,
       REMARK,
       COL_MODE,
       COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       COL_NO,
       COL_TYPE,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    VALUES
      (MYROWSCRAP.JUDGE_STOVE_NO,
       '11',
       MYROWSCRAP.SEQ,
       SYSDATE,
       '0',
       '',
       '1',
       SYSDATE,
       ?,
       ?,
       ?,
       '0',
       '0',
       V_PRO_PLAN_ID,
       V_GX_PLAN_NO);
  END LOOP;
  IF (to_number(?) > 0) THEN
    SELECT COUNT(1)
      INTO V_COUNT
      FROM MIL_OFFLINE_RESLUT T
     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
       AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
       AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/')
       AND T.STATUS = '0'
       AND T.OFFLINE_PRO = 'ZJ';
    IF (V_COUNT > 0) THEN
      UPDATE MIL_OFFLINE_RESLUT T
         SET T.OFFLINE_NUM = TO_NUMBER(T.OFFLINE_NUM) + TO_NUMBER(?)
       WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
         AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/')
         AND T.STATUS = '0'
         AND T.OFFLINE_PRO = 'ZJ';
    ELSE
      FOR MYROW IN (SELECT *
                      FROM MIL_PLAN T
                     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                       AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
                       AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/')) LOOP
        INSERT INTO MIL_OFFLINE_RESLUT
          (RECHECK_NUM,
           PRODUCNAME,
           STEELCODE,
           STEELNAME,
           GRADECODE,
           GRADENAME,
           SPEC_CODE,
           SPEC_NAME,
           MODEL_CODE,
           MODEL_DESC,
           STD_CODE,
           STD_NAME,
           STD_STYLE,
           STD_STYLE_DESC,
           ACT_LEN_RANGE,
           CONTRACT_NO,
           PRODUCCODE,
           INSTORAGE_NUM,
           QUALIFIED_NUM,
           SCRAP_NUM,
           ZP_M_LH,
           LOT_NO,
           STOVE_NO,
           JUDGE_STOVE_NO,
           DIAMETER,
           THICKNESS,
           LENGTH,
           PLINE_CODE,
           OFFLINE_PRO,
           REAL_TIME_STATUS,
           OFFLINE_NUM,
           BACKLINE_NUM,
           GROUP_NUM,
           FINAL_NUM,
           ZP_FLAG,
           STATUS,
           TYPE_FLAG,
           OFFLINE_TIME,
           REMARK,
           COL_USER,
           COL_SHIFT,
           COL_GROUP,
           ZP_HEIGHT,
           TARGET,
           IMP_PROCESS,
           PRO_PLAN_ID,
           GX_PLAN_NO,
           OFFLINE_DOC,
           LOAD_JUDGE_STOVE_NO)
        VALUES
          ('0',
           MYROW.VARIETIES,
           MYROW.STEELCODE,
           MYROW.STEELNAME,
           MYROW.GRADECODE,
           MYROW.GRADENAME,
           MYROW.PIPE_SIZE_CODE,
           REPLACE(MYROW.PIPE_SIZE, '*', 'x'),
           MYROW.BUCKLE_TYPE_CODE,
           MYROW.BUCKLE_TYPE,
           MYROW.ROLL_STANDRAD_CODE,
           MYROW.ROLL_STANDRAD,
           MYROW.STD_STYLE,
           MYROW.STD_STYLE_DESC,
           MYROW.LENGTH_RANGE,
           MYROW.CONTRACT_NO,
           MYROW.VARIETIES_CODE,
           '0',
           '0',
           '0',
           '',
           MYROW.LOT_NO,
           MYROW.STOVE_NO,
           MYROW.JUDGE_STOVE_NO,
           SUBSTR(MYROW.PIPE_SIZE, 0, INSTR(MYROW.PIPE_SIZE, '*') - 1),
           SUBSTR(MYROW.PIPE_SIZE, INSTR(MYROW.PIPE_SIZE, '*') + 1),
           MYROW.TARGET_LENGTH,
           MYROW.PLINE_CODE,
           'ZJ',
           '0',
           ?,
           '0',
           '0',
           '0',
           '0',
           '0',
           '0',
           SYSDATE,
           '',
           ?,
           ?,
           ?,
           to_number(substr(0.02466 *
                            SUBSTR(MYROW.PIPE_SIZE,
                                   INSTR(MYROW.PIPE_SIZE, '*') + 1) *
                            (SUBSTR(MYROW.PIPE_SIZE,
                                    0,
                                    INSTR(MYROW.PIPE_SIZE, '*') - 1) -
                            SUBSTR(MYROW.PIPE_SIZE,
                                    INSTR(MYROW.PIPE_SIZE, '*') + 1)) / 1000,
                            0,
                            instr(0.02466 *
                                  SUBSTR(MYROW.PIPE_SIZE,
                                         INSTR(MYROW.PIPE_SIZE, '*') + 1) *
                                  (SUBSTR(MYROW.PIPE_SIZE,
                                          0,
                                          INSTR(MYROW.PIPE_SIZE, '*') - 1) -
                                  SUBSTR(MYROW.PIPE_SIZE,
                                          INSTR(MYROW.PIPE_SIZE, '*') + 1)) / 1000,
                                  '.') + 3)) * to_number(?) *
           to_number(MYROW.TARGET_LENGTH),
           MYROW.TARGET,
           MYROW.IMP_PROCESS,
           V_PRO_PLAN_ID,
           V_GX_PLAN_NO,
           ?,
           MYROW.FEED_HEAT_NO);
      END LOOP;
    END IF;
  END IF;
END;

]]>
	</query>
	<query id = "doInsetDefectData.selectDefect" desc = "查询是否已存在该缺陷">
	SELECT NVL(COUNT(1), 0) ACOUNT
  FROM MIL_CHECK_DEATIL_SIMPLE T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.DEFECT_CODE = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
	</query>
	<query id = "SurfaceInspectionResult.doDeleteDefect" desc = "移除缺陷项">
	<![CDATA[
	DECLARE
  V_COUNT            MIL_OFFLINE_RESLUT.OFFLINE_NUM%TYPE := NULL;
  V_COUNT2           MIL_OFFLINE_RESLUT.OFFLINE_NUM%TYPE := NULL;
  V_JUDGE_STOVE_NO   MIL_CHECK_DEATIL_SIMPLE.JUDGE_STOVE_NO%TYPE := ?;
  V_DEFECT_CODE      MIL_CHECK_DEATIL_SIMPLE.DEFECT_CODE%TYPE := ?;
  V_OFFLINE_QUANTITY MIL_CHECK_DEATIL_SIMPLE.OFFLINE_PRODUCT%TYPE := ?;
  V_WASTE_QUANTITY   MIL_CHECK_DEATIL_SIMPLE.WASTE_BRANCH%TYPE := ?;
BEGIN
  SELECT TO_NUMBER(OFFLINE_PRODUCT) - TO_NUMBER(V_OFFLINE_QUANTITY)
    INTO V_COUNT2
    FROM MIL_CHECK_DEATIL_SIMPLE T
   WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
     AND T.DEFECT_CODE = V_DEFECT_CODE;
  IF (V_COUNT2 > 0) THEN
    UPDATE MIL_CHECK_DEATIL_SIMPLE T
       SET T.OFFLINE_PRODUCT = TO_NUMBER(T.OFFLINE_PRODUCT) -
                               TO_NUMBER(V_OFFLINE_QUANTITY),
           T.WASTE_BRANCH    = TO_NUMBER(T.WASTE_BRANCH) -
                               TO_NUMBER(V_OFFLINE_QUANTITY)
     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
       AND T.DEFECT_CODE = V_DEFECT_CODE;
  ELSE
    DELETE FROM MIL_CHECK_DEATIL_SIMPLE T
     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
       AND T.DEFECT_CODE = V_DEFECT_CODE;
  END IF;
  UPDATE MIL_SURFACE_RESULT T
     SET T.OFFLINE_QUANTITY = TO_NUMBER(T.OFFLINE_QUANTITY) -
                              TO_NUMBER(V_OFFLINE_QUANTITY),
         T.WASTE_QUANTITY   = TO_NUMBER(T.WASTE_QUANTITY) -
                              TO_NUMBER(V_OFFLINE_QUANTITY)
   WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO;
  UPDATE MIL_OFFLINE_RESLUT T
     SET T.OFFLINE_NUM = TO_NUMBER(T.OFFLINE_NUM) -
                         TO_NUMBER(V_OFFLINE_QUANTITY),
         T.ZP_HEIGHT   = TO_NUMBER(T.ZP_HEIGHT) -
                         TO_NUMBER(TO_NUMBER(T.ZP_HEIGHT) *
                                   TO_NUMBER(V_OFFLINE_QUANTITY) /
                                   TO_NUMBER(T.OFFLINE_NUM))
   WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
     AND T.OFFLINE_PRO = 'ZJ'
     AND T.STATUS = '0';
  IF (V_OFFLINE_QUANTITY > 0) THEN
    FOR OFFROW IN (SELECT *
                     FROM (SELECT T.SEQ
                             FROM MIL_SLAB_SCRAP_SEQ T
                            WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                              AND T.PROCESS_NO = '11'
                              AND T.COL_TYPE = '1'
                            ORDER BY T.SEQ DESC)
                    WHERE ROWNUM <= V_OFFLINE_QUANTITY) LOOP
      UPDATE MIL_QA_RACK T
         SET T.OFFLINE_FLAG = '0', T.STATUS = '0'
       WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
         AND T.SEQ = OFFROW.SEQ;
      DELETE FROM MIL_SLAB_SCRAP_SEQ T
       WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
         AND T.SEQ = OFFROW.SEQ;
    END LOOP;
  END IF;
  IF (V_WASTE_QUANTITY > 0) THEN
    FOR SCRAPROW IN (SELECT *
                       FROM (SELECT T.SEQ
                               FROM MIL_SLAB_SCRAP_SEQ T
                              WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                                AND T.PROCESS_NO = '11'
                                AND T.COL_TYPE = '0'
                              ORDER BY T.SEQ DESC)
                      WHERE ROWNUM <= V_WASTE_QUANTITY) LOOP
      UPDATE MIL_QA_RACK T
         SET T.STATUS = '0'
       WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
         AND T.SEQ = SCRAPROW.SEQ;
      DELETE FROM MIL_SLAB_SCRAP_SEQ T
       WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
         AND T.SEQ = SCRAPROW.SEQ;
    END LOOP;
  END IF;
  IF (V_OFFLINE_QUANTITY > 0) THEN
    SELECT T.OFFLINE_NUM
      INTO V_COUNT
      FROM MIL_OFFLINE_RESLUT T
     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
       AND T.STATUS = '0'
       AND T.OFFLINE_PRO = 'ZJ';
    IF (V_COUNT = 0) THEN
      DELETE FROM MIL_OFFLINE_RESLUT T
       WHERE JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
         AND T.STATUS = '0'
         AND OFFLINE_PRO = 'ZJ';
    END IF;
  END IF;
END;

]]>
	</query>
	<query id = "SurfaceInspectionResult.getTestingResult" desc = "查询探伤是否已结炉支数验证">
	SELECT NODE_FUR_FLAG, QUALIFIED_NUM
  FROM (SELECT T.NODE_FUR_FLAG, T.QUALIFIED_NUM
          FROM MIL_MT_RESULT T
         WHERE T.JUDGE_STOVE_NO = ?
           AND T.LOT_NO = ?
           AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
           AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
        UNION ALL
        SELECT T.NODE_FUR_FLAG, T.QUALIFIED_NUM
          FROM MIL_ET_RESULT T
         WHERE T.JUDGE_STOVE_NO = ?
           AND T.LOT_NO = ?
           AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
           AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
        UNION ALL
        SELECT T.NODE_FUR_FLAG, T.QUALIFIED_NUM
          FROM MIL_UL_RESUL T
         WHERE T.JUDGE_STOVE_NO = ?
           AND T.LOT_NO = ?
           AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
           AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/'))
	</query>
	<query id = "SurfaceInspectionResult.doDeleteMatData" desc = "删除虚拟库存">
	<![CDATA[
	DECLARE
  V_COUNT        MIL_OFFLINE_RESLUT.OFFLINE_NUM%TYPE := NULL;
  V_ZG_STOVE_SQE MAT_BC_M.ZG_STOVE_SQE%TYPE := ?;
BEGIN
  FOR MYROW IN (SELECT *
                  FROM (SELECT T.MAT_NO
                          FROM MAT_BC_M T, YDM_BC_BUTTRESS S
                         WHERE T.MAT_NO = S.MAT_NO
                           AND T.ZG_STOVE_SQE = V_ZG_STOVE_SQE
                           AND T.QCM_STAUS = '11'
                           AND (S.STORAGE_NO =
                               (SELECT C.OUT_REPOSITORY
                                   FROM COM_BASE_PLINE C
                                  WHERE C.PLINE_CODE = T.PLINE_CODE) OR
                               S.STORAGE_NO IN ('BZJ1', 'BZJ2'))
                         ORDER BY T.MAT_NO DESC)
                 WHERE ROWNUM <= ?) LOOP
    DELETE FROM MAT_BC_M T
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND T.ZG_STOVE_SQE = V_ZG_STOVE_SQE
       AND ROWNUM = 1;
    DELETE FROM YDM_BC_BUTTRESS T
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND ROWNUM = 1;
    DELETE FROM YDM_BC_INLIST T
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND ROWNUM = 1;
  END LOOP;
END;
]]>
	</query>
	
	<query id = "SurfaceInspectionResult.doQueryCount" desc = "查询待处理是否已有转移的支数">
	<![CDATA[
	SELECT NVL(MAX(CASE
                 WHEN S.STORAGE_NO = C.OUT_REPOSITORY THEN
                  0
                 ELSE
                  1
               END),
           0) ISOK
  FROM MAT_BC_M T, YDM_BC_BUTTRESS S, COM_BASE_PLINE C
 WHERE T.MAT_NO = S.MAT_NO
   AND T.PLINE_CODE = C.PLINE_CODE
   AND T.QCM_STAUS = '11'
   AND T.ZG_STOVE_SQE = ?
   AND T.OFFLINE_DOC = ?
]]>
</query>
<query id = "SurfaceInspectionResult.doQueryBackCount" desc = "查询可撤销的支数">
	<![CDATA[
	SELECT COUNT(*) ACOUNT
  FROM MAT_BC_M T, YDM_BC_BUTTRESS S, COM_BASE_PLINE C
 WHERE T.MAT_NO = S.MAT_NO
   AND T.PLINE_CODE = C.PLINE_CODE
   AND T.QCM_STAUS = '11'
   AND (S.STORAGE_NO = C.OUT_REPOSITORY OR S.STORAGE_NO IN ('BZJ1', 'BZJ2'))
   AND T.ZG_STOVE_SQE = ?
   
]]>
	</query>
	<query id = "SurfaceInspectionResult.doQueryOffCount" desc = "查询离线的支数">
	<![CDATA[
	SELECT COUNT(*) ACOUNT
  FROM MAT_BC_M T, YDM_BC_BUTTRESS S, COM_BASE_PLINE C
 WHERE T.MAT_NO = S.MAT_NO
   AND T.PLINE_CODE = C.PLINE_CODE
   AND T.QCM_STAUS = '11'
   AND T.ZG_STOVE_SQE = ?
]]>
	</query>
	<query id = "SurfaceInspectionResult.getSurfaceResult" desc = "查询表检支数">
	SELECT NVL(T.OFFLINE_QUANTITY, 0) + NVL(T.WASTE_QUANTITY, 0) +
       NVL(T.QUALIFIED_BRANCH, 0) AS SURFACENUM
  FROM MIL_SURFACE_RESULT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.LOT_NO = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
	</query>
	<query id = "SurfaceInspectionResult.doQueryOffline" desc = "查询下线支数是否已进行处理">
	SELECT T.OFFLINE_NUM 
  FROM MIL_OFFLINE_RESLUT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
   AND T.OFFLINE_PRO = 'ZJ'
   AND T.STATUS = '0'
	</query>
	<query id = "SurfaceInspectionResult.getCheckDetail" desc = "移除缺陷时查询该缺陷是否已保存">
	SELECT * FROM MIL_CHECK_DEATIL_SIMPLE T WHERE T.JUDGE_STOVE_NO = ? AND T.DEFECT_CODE = ?
	</query>
	<query id = "SurFace_Insp.doQueryRollCard" desc = "查询复检流通卡">
	SELECT M.QUALIFIED_BRANCH AS QUALIFIED_BRANCH,
       M.OFFLINE_QUANTITY AS OFFLINE_QUANTITY,
       M.WASTE_QUANTITY   AS WASTE_QUANTITY
  FROM mil_surface_result M
 WHERE M.JUDGE_STOVE_NO = ?
   AND NVL(M.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(M.GX_PLAN_NO, '/') = NVL(?, '/')
	</query>
	<query id = "SurFace_Insp.doQueryRollCardTest" desc = "查询探伤返线流通卡">
	SELECT I.SCRAP_NUM          AS SCRAP_STRAIGHT,
       I.Qualified_Num      AS QUALIFIED_STRAIGHT,
       I.OFFLINE_NUM_TOTAL  AS OFFLINE_STRAIGHT,
       I.BACKLINE_NUM_TOTAL AS BACKLINE_STRAIGHT,
       K.SCRAP_NUM          AS SCRAP_TESTING,
       K.QUALIFIED_NUM      AS QUALIFIED_TESTING,
       K.OFFLINE_NUM        AS OFFLINE_TESTING,
       K.BACKLINE_NUM       AS BACKLINE_TESTING,
       M.QUALIFIED_BRANCH   AS QUALIFIED_BRANCH,
       M.OFFLINE_QUANTITY   AS OFFLINE_QUANTITY,
       M.WASTE_QUANTITY     AS WASTE_QUANTITY
  FROM MIL_STRAIGHTENING_RESULT I, MIL_MT_RESULT K, mil_surface_result M
 WHERE I.JUDGE_STOVE_NO = K.JUDGE_STOVE_NO(+)
   AND I.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO(+)
   AND I.JUDGE_STOVE_NO = ?
   AND NVL(I.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(I.GX_PLAN_NO, '/') = NVL(?, '/') 
	</query>
	<query id = "SurFace_Insp.getRollCard168Test" desc = "168探伤返线流通卡">
	SELECT 
	    I.SCRAP_NUM AS SCRAP_STRAIGHT,
        I.Qualified_Num AS QUALIFIED_STRAIGHT,
        I.OFFLINE_NUM_TOTAL AS OFFLINE_STRAIGHT,
        I.BACKLINE_NUM_TOTAL AS BACKLINE_STRAIGHT,
	    K.SCRAP_NUM AS SCRAP_TESTING,      
        K.QUALIFIED_NUM AS QUALIFIED_TESTING,
        K.OFFLINE_NUM   AS OFFLINE_TESTING,
        K.BACKLINE_NUM AS BACKLINE_TESTING,
        M.QUALIFIED_BRANCH AS QUALIFIED_BRANCH,
        M.OFFLINE_QUANTITY AS OFFLINE_QUANTITY,
        M.WASTE_QUANTITY AS WASTE_QUANTITY
        FROM MIL_STRAIGHTENING_RESULT I,
        MIL_ET_RESULT K,
        mil_surface_result M
        WHERE I.JUDGE_STOVE_NO = K.JUDGE_STOVE_NO(+)
        AND I.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO(+)
        AND I.JUDGE_STOVE_NO = ? 
        AND NVL(I.PRO_PLAN_ID, '/') = NVL(?, '/')
        AND NVL(I.GX_PLAN_NO, '/') = NVL(?, '/')  
	</query>
	<query id = "SurFace_Insp.getRollingCardTest" desc = "超声探伤返线流通卡">
	SELECT 
	    I.SCRAP_NUM AS SCRAP_STRAIGHT,
        I.Qualified_Num AS QUALIFIED_STRAIGHT,
        I.OFFLINE_NUM_TOTAL AS OFFLINE_STRAIGHT,
        I.BACKLINE_NUM_TOTAL AS BACKLINE_STRAIGHT,
	    K.SCRAP_NUM AS SCRAP_TESTING,      
        K.QUALIFIED_NUM AS QUALIFIED_TESTING,
        K.OFFLINE_NUM   AS OFFLINE_TESTING,
        K.BACKLINE_NUM AS BACKLINE_TESTING,
        M.QUALIFIED_BRANCH AS QUALIFIED_BRANCH,
        M.OFFLINE_QUANTITY AS OFFLINE_QUANTITY,
        M.WASTE_QUANTITY AS WASTE_QUANTITY
        FROM MIL_STRAIGHTENING_RESULT I,
        MIL_UL_RESUL K,
        mil_surface_result M
        WHERE I.JUDGE_STOVE_NO = K.JUDGE_STOVE_NO(+)
        AND I.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO(+)
        AND I.JUDGE_STOVE_NO = ?  
        AND NVL(I.PRO_PLAN_ID, '/') = NVL(?, '/')
        AND NVL(I.GX_PLAN_NO, '/') = NVL(?, '/')  
	</query>
	<query id = "SurFace_Insp.getMilPlan" desc = "查询返线计划表支" >
	SELECT T.BRANCH, T.TON
  FROM MIL_PLAN T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.ID = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
	</query>
	<query id = "doInsetDefectData.selectMilPlanSpece" desc = "查询计划规格、长度">
	SELECT T.PIPE_SIZE, T.TARGET_LENGTH
  FROM MIL_PLAN T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
	</query>
	<query id = "SurfaceInspectionResult.selectBackLineNum" desc = "查询管号队列中是否有生成质检委托">
	<![CDATA[
	select t.*
  from mil_offline_result_detia t
 where t.id = ?
   and t.judge_stove_no = ?
   AND T.JUDGE_STOVE_NO <> T.BACK_JUDGE_STOVE_NO
   and t.operation_type <> '1'
    ]]>
	</query>
	<query id = "SurfaceInspectionResult.doQueryTestResult" desc = "查询探伤合格支数">
	SELECT T.QUALIFIED_NUM FROM #TABLENAME# T WHERE T.RESULT_NO = ?
	</query>
	<query id = "SurfaceInspectionResult.doQuerySufaceD" desc = "查询表面检验D1\D2最大最小">
	<![CDATA[
	SELECT MAX(M1)M1,MIN(M2)M2
  FROM (SELECT MAX(T.D1) M1,MIN(T.D1)M2
          FROM MIL_SIZE_CHECK_DEATIL T
         WHERE T.JUDGE_STOVE_NO like  ? || '%'
        UNION ALL (SELECT MAX(T.D2) M1,MIN(T.D2)M2
                    FROM MIL_SIZE_CHECK_DEATIL T
                   WHERE T.JUDGE_STOVE_NO like  ? || '%'))
                   ]]>
	</query>
	<query id = "SurfaceInspectionResult.doQuerySufaceS" desc = "查询表检检验壁厚最大最小">
	<![CDATA[
	SELECT MAX(S1)S1,MIN(S2)S2
  FROM (SELECT MAX(T.S1) S1,MIN(T.S1)S2
          FROM MIL_SIZE_CHECK_DEATIL T
         WHERE T.JUDGE_STOVE_NO like  ? || '%'
        UNION ALL (SELECT MAX(T.S2) S2,MIN(T.S2)S2
                    FROM MIL_SIZE_CHECK_DEATIL T
                   WHERE T.JUDGE_STOVE_NO like  ? || '%')
                   UNION ALL
                   SELECT MAX(T.S3)S1,MIN(T.S3)S2 FROM MIL_SIZE_CHECK_DEATIL T WHERE T.JUDGE_STOVE_NO like  ? || '%'
                   UNION ALL
                   SELECT MAX(T.S4)S1,MIN(T.S4)S2 FROM MIL_SIZE_CHECK_DEATIL T WHERE T.JUDGE_STOVE_NO like  ? || '%'
                   )
                   ]]>
	</query>
	<query id = "SurfaceInspectionResult.selectMinMaxD" desc = "获取平均值外径">
	SELECT (TO_NUMBER(NVL(M1, 0)) + TO_NUMBER(NVL(M2, 0))) / 2 AS DIMATER
  FROM (SELECT MAX(M1) M1, MIN(M2) M2
          FROM (SELECT MAX(T.D1) M1, MIN(T.D1) M2
                  FROM MIL_SIZE_CHECK_DEATIL T
                 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
                UNION ALL (SELECT MAX(T.D2) M1, MIN(T.D2) M2
                            FROM MIL_SIZE_CHECK_DEATIL T
                           WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?)))
	</query>
	<query id = "SurfaceInspectionResult.selectMinMaxS" desc = "获取平均值壁厚">
	SELECT (TO_NUMBER(NVL(S1,0))+TO_NUMBER(NVL(S2,0)))/2 AS HEIGHT
FROM (
SELECT MAX(S1) S1, MIN(S2) S2
  FROM (SELECT MAX(T.S1) S1, MIN(T.S1) S2
          FROM MIL_SIZE_CHECK_DEATIL T
         WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
        UNION ALL (SELECT MAX(T.S2) S2, MIN(T.S2) S2
                    FROM MIL_SIZE_CHECK_DEATIL T
                   WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?)
        UNION ALL
        SELECT MAX(T.S3) S1, MIN(T.S3) S2
          FROM MIL_SIZE_CHECK_DEATIL T
         WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
        UNION ALL
        SELECT MAX(T.S4) S1, MIN(T.S4) S2
          FROM MIL_SIZE_CHECK_DEATIL T
         WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?)
         )
	</query>
	<query id = "SurfaceInspectionResult.updateActWgt" desc = "修改重量">
	UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
   SET T.ACT_THEORY_WEIGHT = ROUND(0.02466 * TO_NUMBER(?) *
                             (TO_NUMBER(?) - TO_NUMBER(?)) *
                             TO_NUMBER(NVL(T.ORDER_LENGTH,0))/1000,3)
 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
	</query>
	<query id = "SurfaceInspectionResult.doQueryBackFlag" desc = "查询计划是否为返线计划">
	SELECT T.BACK_PLAN_FLAG
  FROM MIL_PLAN T
 WHERE T.ID = ?
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
	</query>
	<query id = "SurfaceInspectionResult.doQueryPlanBratch" desc = "查询计划支数">
	SELECT T.BRANCH AS QUALIFIED_NUM FROM MIL_PLAN T WHERE T.ID = ? AND T.PLINE_CODE = ?
	</query>
	<query id = "SurfaceInspectionResult.doQueryProcessNum" desc = "查询进程表支数">
	SELECT SUM(T.ACT_COUNT)ACT_COUNT
  FROM PORT_MIL_BATCH_SAMPLE_RESULT T
 WHERE T.PLAN_ID = ?
   AND T.JUDGE_STOVE_NO = ?
   AND (T.STATUS = '0' OR (T.STATUS IN ('2','3') AND T.OP_PROCESS = '11'))
	</query>
	<query id = "SurfaceInspectionResult.doInsetMatData" desc = "表检下线入虚拟库存">
	DECLARE
  V_TIME              MIL_OFFLINE_RESLUT.OFFLINE_TIME%TYPE := SYSDATE;
  V_JUDGE_STOVE_NO    MIL_PLAN.JUDGE_STOVE_NO%TYPE := ?;
  V_BATCH_NO          PORT_MIL_BATCH_SAMPLE_RESULT.BATCH_NO%TYPE := ?;
  V_JUDGE_STOVE_NO_ZP MIL_PLAN.JUDGE_STOVE_NO%TYPE := NULL; --组炉炉号
  V_COUNT             MIL_PLAN.CRAFT_SEQ%TYPE := 0;

BEGIN

  select COUNT(1)
    INTO V_COUNT
    from MIL_OFFLINE_GROUP t
   WHERE REGEXP_REPLACE(T.ZP_JUDGE_STOVE_NO, '-.*', '') = V_JUDGE_STOVE_NO;

  IF (V_COUNT > 0) THEN
    select REGEXP_REPLACE(T.ZP_M_LH, '-.*', '')
      INTO V_JUDGE_STOVE_NO_ZP
      from MIL_OFFLINE_GROUP t
     WHERE REGEXP_REPLACE(T.ZP_JUDGE_STOVE_NO, '-.*', '') =
           V_JUDGE_STOVE_NO
       AND ROWNUM = 1;
  END IF;

  INSERT INTO YDM_BC_BUTTRESS
    (JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     STORAGE_NO,
     LOCATION_NO,
     STORAGE_TYPE_NO,
     STORAGE_TYPE_NAME,
     CREATE_NAME,
     MAT_NO,
     CREATE_TIME,
     MANAGEMENT_NO,
     MANAGEMENT_NAME,
     DEPARTMENT_CODE,
     DEPARTMENT_DESC)
  VALUES
    (V_JUDGE_STOVE_NO, V_BATCH_NO, ?, ?, ?, ?, ?, ?, ?, V_TIME, ?, ?, ?, ?);

  FOR MYROW IN (SELECT A.*,
                       B.ORD_PK,
                       B.ORD_LN_PK,
                       (SELECT MAX(M.PIPE_SIZE_CODE)
                          FROM MIL_PLAN M
                         WHERE REGEXP_REPLACE(JUDGE_STOVE_NO, '-.*', '') =
                               A.FEED_HEAT_NO) SPEC_CODE,
                       (SELECT MAX(M.ROLL_STANDRAD_CODE)
                          FROM MIL_PLAN M
                         WHERE REGEXP_REPLACE(JUDGE_STOVE_NO, '-.*', '') =
                               A.FEED_HEAT_NO) STD_CODE,
                       (SELECT MAX(M.STD_STYLE)
                          FROM MIL_PLAN M
                         WHERE REGEXP_REPLACE(JUDGE_STOVE_NO, '-.*', '') =
                               A.FEED_HEAT_NO) STD_STYLE,
                       (SELECT DECODE(H.ORDER_TYP, '120108', '1', '0')
                          FROM SLM_ORDER_HEAD H
                         WHERE H.ORD_PK = B.ORD_PK) ORDER_TYP
                  FROM PLN_ZY_ZG_M A, SLM_ORDER_LINE_DELIVERY B
                 WHERE A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK(+)
                   AND A.IF_FLAG = '0'
                   AND A.PLANSTATUS > '00'
                   AND A.FEED_HEAT_NO =
                       NVL(V_JUDGE_STOVE_NO_ZP, V_JUDGE_STOVE_NO)) LOOP
    INSERT INTO MAT_BC_M
      (JUDGE_STOVE_NO,
       STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       ACT_COUNT,
       ACT_WEIGHT,
       CREATE_TIME,
       MAT_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       PLINE_CODE,
       PLINE_NAME,
       QCM_STAUS,
       HEAT_PLAN_NO,
       ZG_STOVE_SQE,
       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,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       LOT_NO,
       PRO_ORDER_NO,
       ACT_LEN,
       TARGET,
       PROCESS_STATUS,
       FLAG_STOVE_NO_ZG,
       INSTOCK_TIME,
       PRO_ORDER_ID,
       GX_PLAN_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       INPUT_MATERIAL_NO,
       INPUT_MATERIAL_NAME,
       CIC,
       JUDGE_STD_DES,
       CRAFT_SEQ,
       PROCESS_CDOE,
       PROCESS_DESC,
       ORDER_NO,
       ORDER_SEQ,
       ORDER_SEQ_NO,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       OFFLINE_DOC,
       IS_DEALER,
       MAT_GOWHERE_CODE,
       MAT_GOWHERE_NAME,
       BELONG_CODE_RESPONSE,
       BELONG_NAME_RESPONSE)
    VALUES
      (?,
       MYROW.Stove_No,
       ?,
       ?,
       ?,
       ?,
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       NVL(?, MYROW.PRODUCCODE),
       ?,
       NVL(?, MYROW.STEELCODE),
       ?,
       NVL(?, MYROW.SPEC_CODE),
       ?,
       NVL(?, MYROW.GRADECODE),
       ?,
       NVL(?, MYROW.MODEL_CODE),
       ?,
       NVL(?, MYROW.STD_CODE),
       ?,
       ?,
       ?,
       NVL(?, MYROW.STD_STYLE),
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       SYSDATE,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       ?,
       'D',
       '轧制',
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.DELIVERY_NO,
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,
       ?,
       MYROW.ORDER_TYP,
       NVL(MYROW.GOWHERE_CODE, '/'),
       NVL(MYROW.GOWHERE_NAME, '/'),
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME);
  END LOOP;
END;
	</query>
	<query id = "SurfaceInspectionResult.selectMilPlanData" desc = "查询炉计划信息">
	SELECT T.*
  FROM MIL_PLAN T
 WHERE T.ID = ?
   AND T.JUDGE_STOVE_NO = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
	</query>
	<query id = "SurfaceInspectionResult.doQueryPort" desc = "查询进程合格状态支数">
	SELECT NVL(SUM(T.ACT_COUNT), 0) QUALIFIED_NUM
  FROM PORT_MIL_BATCH_SAMPLE_RESULT T
 WHERE T.PLAN_ID = ?
   AND T.PLINE_CODE = ?
   AND T.STATUS = '0'
   --AND T.INSTORE_FLAG = '0'
	</query>
	<query id = "SurfaceInspectionResult.doQueryNodeS" desc = "查询是否结炉">
	SELECT T.NODE_FUR_FLAG FROM #RESULT# T WHERE T.RESULT_NO = ?
	</query>
	<query id = "SurfaceInspectionResult.doQueryPortWgt" desc = "获取进程重量">
	<![CDATA[
	SELECT NVL(SUM(T.ACT_THEORY_WEIGHT), 0) ACT_THEORY_WEIGHT
  FROM PORT_MIL_BATCH_SAMPLE_RESULT T
 WHERE T.PLAN_ID = ?
   AND T.STATUS = '0'
   AND ROWNUM <= ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
   ]]>
	</query>
	<query id = "SurfaceInspectionResult.doQueryChcekSize" desc = "查询几何尺寸">
	<![CDATA[
	SELECT T.JUDGE_STOVE_NO
  FROM MIL_SIZE_CHECK_DEATIL T
 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
	]]>
	</query>
	<query id = "SurfaceInspectionResult.doDeleteSlabScrap" desc = "删除slab表">
	<![CDATA[
	DELETE FROM MIL_SLAB_SCRAP T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   AND T.PROCESS_NO = '10'
   ]]>
	</query>
	<query id = "SurfaceInspectionResult.doQueryProcessSeq" desc = "全程途径码最后一道工序">
	SELECT SUBSTR(T.PROCESS_SEQ,INSTR(T.PROCESS_SEQ,'-',-1,1)+1)PROCESS_SEQ FROM PLN_SALEORD_PROC T WHERE T.ORD_LN_DLY_PK ||'-'||T.PLN_DIVIDE_ID = ?
	</query>
	<query id = "startBack.selectMilOfflineZp" desc = "查询是否为组炉信息">
	SELECT T.ZP_FLAG
  FROM MIL_OFFLINE_RESLUT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
   AND T.OFFLINE_PRO = 'ZJ'
	</query>
	<query id = "SurFace_Insp.getIsAgain" desc = "是否跟队（天淮）">
	<![CDATA[
	select COUNT(1) ACOUNT
  from MIL_SURFACE_RESULT t
 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
   AND T.PLINE_CODE = ?
   ]]>
	</query>
	</queryMap>
