<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "管坯表面检验">
<query id = "FrmStuffSurfaceInspection.doQueryMat" desc = "查询收料实绩">
<![CDATA[
SELECT 
       MAX(TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) INSTOCK_TIME,
       T.MEMO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUD_NO,
       T.CAST_NO,
       T.CCMID,
       T.SAMPLE_FLAG,
       T.CUTTING_FLAG,
       T.CUTTING_NUM,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.JUDGE_GRADECODE,
       T.JUDGE_GRADENAME,
       T.JUDGE_STD_CODE,
       T.JUDGE_STD_NAME,
       T.PRO_ORDER_NO,
       T.PRO_ORDER_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       SUM(nvl(T.ACT_LEN,'0'))ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_FIX_NUM,
       T.ACT_FIX_LEN,
       SUM(T.ACT_COUNT)ACT_COUNT,
       SUM(T.ACT_THEORY_WEIGHT)ACT_THEORY_WEIGHT,
       '0' QUALIFIED_COUNT,
       '0' NO_QUALIFIED_COUNT,
       '0' QUANTITY,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.BUG_NO,
       DECODE(T.FACE_RESULT_CODE,'40740601','合格','40740602','不合格','','未检') FACE_RESULT_CODE
 FROM MAT_GP_M T
 WHERE T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
 ]]>
</query>
<query id = "FrmStuffSurfaceInspection.doQuerySurFace" desc = "查询表检信息">
<![CDATA[
 SELECT 
       SURFACE_CHECK_NO,
       JUDGE_STOVE_NO,
       GROUD_NO,
       STOVE_NO,
       JUDGE_GRADECODE,
       JUDGE_GRADENAME,
       JUDGE_STD_CODE,
       JUDGE_STD_NAME,
       TARG_GRADECODE,
       TARG_GRADENAME,
       TARG_STD_CODE,
       TARG_STD_NAME,
       TARG_DIMATER,
       TARG_HEIGHT,
       TARG_LEN,
       TARG_LEN_MIN,
       TARG_LEN_MAX,
       TARG_FIX_NUM,
       TARG_FIX_LEN,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_FIX_NUM,
       ACT_FIX_LEN,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       BUG_NO,
       CHECK_RESULT,
       QUANTITY,
       ELIGIBLEQUTY,
       PRO_ORDER_NO,
       PRO_ORDER_ID,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       VALIDFLAG,
       MEMO,
       PLINE_CODE,
       PLINE_NAME
       
 FROM QCM_LG_SURFACE_M
 WHERE JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
 ]]>
</query>
<query id = "FrmStuffSurfaceInspection.doQueryMatC" desc = "查询收料明细">
<![CDATA[
SELECT T.MAT_NO,
       T.GROUD_NO,
       T.MEMO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.ACT_COUNT,
       T.ACT_THEORY_WEIGHT,
       T.BUG_NO,
       T.SURFACE_CHECK_NO,
       S.BUG_POS_CODE,
       S.BUG_POS_NAME,
       S.BUG_CODE1,
       S.BUG_NAME1,
       S.BUG_CODE2,
       S.BUG_NAME2,
       S.BUG_CODE3,
       S.BUG_NAME3,
       S.BUG_CODE4,
       S.BUG_NAME4,
       S.BUG_CODE5,
       S.BUG_NAME5,
       T.ACT_DIMATER,
       S.CHECK_DIMATER,
       T.ACT_LEN,
       S.CHECK_LEN,
       DECODE(T.FACE_RESULT_CODE,'40740601','合格','40740602','不合格','未检')FACE_RESULT_CODE
 FROM MAT_GP_M T
 LEFT JOIN QCM_LG_SURFACE_C S
 ON T.MAT_NO = S.MAT_NO
 AND T.BUG_NO = S.BUG_NO
 WHERE 
 --S.VALIDFLAG = '1'
  T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
 ]]>
</query>
<query id = "FrmStuffSurfaceInspection.doQuerySufaceC" desc = "查询缺陷信息">
SELECT 
       BUG_NO,
       MAT_NO,
       BUG_CODE1,
       BUG_NAME1,
       BUG_CODE2,
       BUG_NAME2,
       BUG_CODE3,
       BUG_NAME3,
       BUG_CODE4,
       BUG_NAME4,
       BUG_CODE5,
       BUG_NAME5,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DECODE(VALIDFLAG,'0','无效','1','有效')VALIDFLAG,
       MEMO,
       BUG_POS_CODE,
       BUG_POS_NAME,
       ACT_DIMATER,
       CHECK_DIMATER,
       ACT_LEN,
       CHECK_LEN
 FROM QCM_LG_SURFACE_C
 WHERE 1=1
</query>
<query id = "FrmStuffSurfaceInspection.getBugLocation" desc = "获取缺陷位置">
SELECT T.BASENAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '4082'
</query>
<query id = "FrmStuffSurfaceInspection.getBugName" desc = "获取缺陷名称">
SELECT T.BASENAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '4083'
</query>
<query id = "FrmStuffSurfaceInspection.getCheckNo" desc = "生成检验编号、缺陷编号">
<![CDATA[
select 'CFG' || ? || to_char(sysdate, 'yymmdd') ||
       Lpad(NVL(MAX(substr(t.surface_check_no,
                           length(t.surface_check_no) - 3)),
                0) + 1,
            4,
            0) SURFACE_CHECK_NO,
       'CFG' || ? || to_char(sysdate, 'yymmdd') ||
       Lpad(NVL(MAX(substr(t.surface_check_no,
                           length(t.surface_check_no) - 3)),
                0) + 1,
            4,
            0) || Lpad(NVL(MAX(substr(t.surface_check_no,
                                      length(t.surface_check_no) - 2)),
                           0) + 1,
                       3,
                       0) BUG_NO
  from Qcm_Lg_Surface_m t
 where t.PLINE_CODE = ?
   AND to_char(t.CREATE_TIME, 'YYYY-MM-DD') =
       to_char(sysdate, 'YYYY-MM-DD')
]]>
</query>
<query id = "ensureBug.CheckNo" desc = "插入检验主信息">
INSERT INTO QCM_LG_SURFACE_M
    (SURFACE_CHECK_NO,
     JUDGE_STOVE_NO,
     GROUD_NO,
     STOVE_NO,
     JUDGE_GRADECODE,
     JUDGE_GRADENAME,
     JUDGE_STD_CODE,
     JUDGE_STD_NAME,
     ACT_DIMATER,
     ACT_HEIGHT,
     ACT_LEN,
     ACT_LEN_MIN,
     ACT_LEN_MAX,
     ACT_FIX_NUM,
     ACT_FIX_LEN,
     ACT_COUNT,
     ACT_WEIGHT,
     ACT_THEORY_WEIGHT,
     BUG_NO,
     QUANTITY,
     ELIGIBLEQUTY,
     PRO_ORDER_NO,
     PRO_ORDER_ID,
     CREATE_NAME,
     CREATE_TIME,
     PLINE_CODE,
     PLINE_NAME)
  VALUES
    (?,
     ?, 
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     '0',
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?)
</query>
<query id = "ensureBug.BugNo" desc = "插入表检从记录">
 INSERT INTO QCM_LG_SURFACE_C(
        BUG_NO,
        MAT_NO,
        BUG_CODE1,
        BUG_NAME1,
        BUG_CODE2,
        BUG_NAME2,
        BUG_CODE3,
        BUG_NAME3,
        BUG_CODE4,
        BUG_NAME4,
        BUG_CODE5,
        BUG_NAME5,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        CREATE_NAME,
        CREATE_TIME,
        BUG_POS_CODE,
        BUG_POS_NAME,
        ACT_DIMATER,
        CHECK_DIMATER,
        ACT_LEN,
        CHECK_LEN)
 VALUES( 
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        '',
        ?,
        ?,
        TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
        ?,
        ?,
        ?,?,?,?)
</query>
<query id = "ensureBug.updateMat" desc = "回写材料表缺陷编号重量">
UPDATE MAT_GP_M T
     SET T.SURFACE_CHECK_NO = ?,
         T.BUG_NO            = ?,
         T.ACT_THEORY_WEIGHT = ?,
         T.ACT_DIMATER       = ?,
         T.ACT_LEN           = ?,
         T.FACE_RESULT_CODE = '40740602'
   WHERE T.MAT_NO = ?
</query>
<query id = "ensureBug.updateMatAll" desc = "回写检验编号">
UPDATE MAT_GP_M T
     SET T.SURFACE_CHECK_NO = ?,
         T.ACT_THEORY_WEIGHT = ?,
         T.ACT_DIMATER       = ?,
         T.ACT_LEN           = ?,
         T.FACE_RESULT_CODE = '40740601'
   WHERE T.MAT_NO  = ?
</query>
<query id = "ensureBug.SelectSurFace" desc = "查询该支是否已表检">
SELECT COUNT(1)ACOUNT FROM QCM_LG_SURFACE_C T  WHERE T.MAT_NO = ? AND T.VALIDFLAG = '1'
</query>
<query id = "ensureBug.deleteSurFace" desc = "作废上次表捡信息">
DECLARE
BEGIN
    UPDATE QCM_LG_SURFACE_C S
       SET S.VALIDFLAG = '0'
       WHERE S.MAT_NO = ?;
END;
</query>
<query id = "FrmStuffSurfaceInspection.doQueryOrders" desc = "查询炼钢炉计划订单信息">
SELECT T.*,S.STOVE_NO FROM PLN_STEELFOR_ORD T,PLN_STEELFORFURNACE S WHERE T.FURNACENO = S.FURNACENO AND T.FURNACENO = ?
</query>
<query id = "FrmStuffSurfaceInspection.doQueryPlan" desc = "查询炼钢炉计划">
SELECT T.*
  FROM PLN_STEELFORFURNACE T 
 WHERE T.STATUS IN ('2','3')
</query>
<query id = "FrmStuffSurfaceInspection.doQueryRack" desc = "查询管坯队列">
 SELECT 
       T.MAT_NO,
       T.STOVE_NO,
       T.CCMSTOVENO,
       T.JUDGE_STOVE_NO,
       T.CAST_NO,
       T.HEATCNT,
       T.CCMID,
       T.FLOWNO,
       T.CUTSEQNO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.BATCH_GROUD_NO,
       T.FLAG_STOVE_NO,
       T.ORDER_SEQ,
       T.ORDER_NO,
       T.DELIVERY_NO,
       T.PRODORDERNO,
       T.STANDARDSCODE,
       T.STANDARDREMAK,
       T.DIAMETER,
       T.LEN_MIN,
       T.LEN_MAX,
       T.FIX_NUM,
       T.FIX_LEN,
       T.LENGTH,
       T.ACT_COUNT,
       T.WEIGHT,
       T.RECIVE_FLAG,
       DECODE(T.STATUS,'0','合格','1','待处理','2','剔除','3','返线')STATUS,
       TO_CHAR(T.CUTTIME, 'YYYY-MM-DD HH24:MI:SS') CUTTIME,
       T.AFFIRM_FLAG,
       T.SCRAP_REASON,
       T.OLD_MAT_NO,
       T.RESULT_NO,
       T.OLD_RESULT_NO,
       T.ALARM_REASON,
       T.TEST_COUNT,
       T.IS_VALID,
       T.FURNACENO,
       '管坯剔除' AS SCRAP,
       '剔除回退' AS SCRAP_BACK,
       '离线' AS ALARM,
       '离线回退'AS ALARM_BACK,
       ROWNUM SEQ
 FROM STL_LG_PROGRRSS T
 WHERE T.FURNACENO = ?
 AND T.STOVE_NO = ?
 AND T.IS_VALID = '0'
 ORDER BY T.MAT_NO ASC
</query>
<query id = "FrmStuffSurfaceInspection.getPCode" desc = "获取产线代码">
select t.pline_code 
	from COM_BASE_PLINE t 
	where t.department_desc=?
</query>
<query id = "FrmStuffSurfaceInspection.doQueryResult" desc = "查询表检实绩">
SELECT * FROM STL_LG_SURFACE_M T WHERE T.FURNACENO = ?
</query>
<query id = "FrmStuffSurfaceInspection.doQueryStausSum" desc = "查询支数">
SELECT SUM(T.ACT_COUNT) ACOUNT FROM STL_LG_PROGRRSS T WHERE T.FURNACENO = ?
</query>
<query id = "FrmStuffSurfaceInspection.doQueryStausSum1" desc = "查询废品支数">
SELECT SUM(T.ACT_COUNT) ACOUNT FROM STL_LG_PROGRRSS T WHERE T.FURNACENO = ? AND T.STATUS = '2'
</query>
<query id = "FrmStuffSurfaceInspection.doQueryStausSum2" desc = "查询离线品支数">
SELECT SUM(T.ACT_COUNT) ACOUNT FROM STL_LG_PROGRRSS T WHERE T.FURNACENO = ? AND T.STATUS = '1'
</query>
<query id = "FrmStuffSurfaceInspection.doQueryStausSum3" desc = "查询合格支数重量">
SELECT SUM(T.ACT_COUNT) ACOUNT,SUM(T.WEIGHT)ACT_WEGHT FROM STL_LG_PROGRRSS T WHERE T.FURNACENO = ? AND T.STATUS = '0'
</query>
<query id = "FrmStuffSurfaceInspection.doQueryRackStaus" desc = "查询当前材料状态">
SELECT T.STATUS FROM STL_LG_PROGRRSS T WHERE T.MAT_NO = ?
</query>
<query id = "FrmStuffSurfaceInspection.updateRackStaus" desc = "修改材料状态">
UPDATE STL_LG_PROGRRSS T SET T.STATUS = ?,T.SCRAP_REASON = ? WHERE T.MAT_NO = ?
</query>
<query id = "FrmStuffSurfaceInspection.saveSurfaceResult" desc = "保存实绩">
DECLARE
  v_SURFACE_CHECK_NO STL_LG_SURFACE_M.SURFACE_CHECK_NO%TYPE := NULL;
  v_COUNT            STL_LG_SURFACE_M.ACT_COUNT%TYPE := NULL;
  v_QUANTITY         STL_LG_SURFACE_M.QUANTITY%TYPE := NULL; --检验支数
  v_ELIGIBLEQUTY     STL_LG_SURFACE_M.ELIGIBLEQUTY%TYPE := NULL; --合格支数
  v_OFFLINE_NUM      STL_LG_SURFACE_M.OFFLINE_NUM%TYPE := NULL; --下线支数
  v_SCRAP_NUM        STL_LG_SURFACE_M.SCRAP_NUM%TYPE := NULL; --废品支数
  v_WEIGHT           STL_LG_SURFACE_M.ACT_WEIGHT%TYPE := NULL; --合格吨
  v_NODE_FLAG        STL_LG_SURFACE_M.NODE_FUR_FLAG%TYPE := NULL;
BEGIN

  FOR MYROW IN (SELECT T.FURNACENO, T.FIX_NUM
                  FROM STL_LG_PROGRRSS T
                 WHERE T.FURNACENO = '#FURNACENO#'
                 GROUP BY T.FURNACENO, T.FIX_NUM) LOOP
  
    SELECT '#PLINE_CODE#' || TO_CHAR(SYSDATE, 'YYMMDD') ||
           LPAD(NVL(MAX(SUBSTR(T.SURFACE_CHECK_NO, 11)), 0) + 1, 4, 0)
      INTO v_SURFACE_CHECK_NO
      FROM STL_LG_SURFACE_M T
     WHERE TRUNC(T.CREATE_TIME) = TRUNC(SYSDATE)
       AND T.PLINE_CODE = '#PLINE_CODE#';
  
    SELECT COUNT(1)
      INTO v_COUNT
      FROM STL_LG_SURFACE_M T
     WHERE T.FURNACENO = MYROW.FURNACENO
       AND T.ACT_FIX_NUM = MYROW.FIX_NUM;
  
    SELECT SUM(T1.ACT_COUNT)
      INTO v_QUANTITY
      FROM STL_LG_PROGRRSS T1
     WHERE T1.FURNACENO = MYROW.FURNACENO
       AND T1.FIX_NUM = MYROW.FIX_NUM;
    SELECT SUM(T1.WEIGHT)
      INTO v_WEIGHT
      FROM STL_LG_PROGRRSS T1
     WHERE T1.FURNACENO = MYROW.FURNACENO
       AND T1.FIX_NUM = MYROW.FIX_NUM
       AND T1.STATUS = '0';
    SELECT SUM(T1.ACT_COUNT)
      INTO v_ELIGIBLEQUTY
      FROM STL_LG_PROGRRSS T1
     WHERE T1.FURNACENO = MYROW.FURNACENO
       AND T1.FIX_NUM = MYROW.FIX_NUM
       AND T1.STATUS IN ('0','4');
  
    SELECT SUM(T1.ACT_COUNT)
      INTO v_OFFLINE_NUM
      FROM STL_LG_PROGRRSS T1
     WHERE T1.FURNACENO = MYROW.FURNACENO
       AND T1.FIX_NUM = MYROW.FIX_NUM
       AND T1.STATUS = '1';
  
    SELECT SUM(T1.ACT_COUNT)
      INTO v_SCRAP_NUM
      FROM STL_LG_PROGRRSS T1
     WHERE T1.FURNACENO = MYROW.FURNACENO
       AND T1.FIX_NUM = MYROW.FIX_NUM
       AND T1.STATUS = '2';
  
    SELECT T3.NODE_FUR_FLAG
      INTO v_NODE_FLAG
      FROM STL_LG_SURFACE_M T3
     WHERE T3.FURNACENO = MYROW.FURNACENO
     AND ROWNUM = 1;
    IF (v_COUNT > 0) THEN
      IF (v_NODE_FLAG = 1) THEN
        UPDATE STL_LG_SURFACE_M T
           SET T.CHECK_RESULT     = '#CHECK_RESULT#',
               T.MEMO             = '#MEMO#',
               T.FLOW_NO1         = '#FLOW_NO1#',
               T.FLOW_NO11        = '#FLOW_NO11#',
               T.FLOW_NO2         = '#FLOW_NO2#',
               T.FLOW_NO21        = '#FLOW_NO21#',
               T.FLOW_NO3         = '#FLOW_NO3#',
               T.FLOW_NO31        = '#FLOW_NO31#',
               T.FLOW_NO4         = '#FLOW_NO4#',
               T.FLOW_NO41        = '#FLOW_NO41#',
               T.FLOW_NO5         = '#FLOW_NO5#',
               T.FLOW_NO51        = '#FLOW_NO51#',
               T.FLOW_NO6         = '#FLOW_NO6#',
               T.FLOW_NO61        = '#FLOW_NO61#',
               T.MIN_DIAMETER1    = '#MIN_DIAMETER1#',
               T.MIN_DIAMETER11   = '#MIN_DIAMETER11#',
               T.MIN_DIAMETER2    = '#MIN_DIAMETER2#',
               T.MIN_DIAMETER21   = '#MIN_DIAMETER21#',
               T.MIN_DIAMETER3    = '#MIN_DIAMETER3#',
               T.MIN_DIAMETER31   = '#MIN_DIAMETER31#',
               T.MIN_DIAMETER4    = '#MIN_DIAMETER4#',
               T.MIN_DIAMETER41   = '#MIN_DIAMETER41#',
               T.MIN_DIAMETER5    = '#MIN_DIAMETER5#',
               T.MIN_DIAMETER51   = '#MIN_DIAMETER51#',
               T.MIN_DIAMETER6    = '#MIN_DIAMETER6#',
               T.MIN_DIAMETER61   = '#MIN_DIAMETER61#',
               T.MAX_DIAMETER1    = '#MAX_DIAMETER1#',
               T.MAX_DIAMETER11   = '#MAX_DIAMETER11#',
               T.MAX_DIAMETER2    = '#MAX_DIAMETER2#',
               T.MAX_DIAMETER21   = '#MAX_DIAMETER21#',
               T.MAX_DIAMETER3    = '#MAX_DIAMETER3#',
               T.MAX_DIAMETER31   = '#MAX_DIAMETER31#',
               T.MAX_DIAMETER4    = '#MAX_DIAMETER4#',
               T.MAX_DIAMETER41   = '#MAX_DIAMETER41#',
               T.MAX_DIAMETER5    = '#MAX_DIAMETER5#',
               T.MAX_DIAMETER51   = '#MAX_DIAMETER51#',
               T.MAX_DIAMETER6    = '#MAX_DIAMETER6#',
               T.MAX_DIAMETER61   = '#MAX_DIAMETER61#',
               T.CASTING_LENGTH1  = '#CASTING_LENGTH1#',
               T.CASTING_LENGTH11 = '#CASTING_LENGTH11#',
               T.CASTING_LENGTH2  = '#CASTING_LENGTH2#',
               T.CASTING_LENGTH21 = '#CASTING_LENGTH21#',
               T.CASTING_LENGTH3  = '#CASTING_LENGTH3#',
               T.CASTING_LENGTH31 = '#CASTING_LENGTH31#',
               T.CASTING_LENGTH4  = '#CASTING_LENGTH4#',
               T.CASTING_LENGTH41 = '#CASTING_LENGTH41#',
               T.CASTING_LENGTH5  = '#CASTING_LENGTH5#',
               T.CASTING_LENGTH51 = '#CASTING_LENGTH51#',
               T.CASTING_LENGTH6  = '#CASTING_LENGTH6#',
               T.CASTING_LENGTH61 = '#CASTING_LENGTH61#',
               T.CHAMFERCUT1      = '#CHAMFERCUT1#',
               T.WITHIN1          = '#WITHIN1#',
               T.STRAIGHTNESS1    = '#STRAIGHTNESS1#',
               T.INSPECTION       = '#INSPECTION#',
               T.TREATING_RESULT  = '#TREATING_RESULT#',
               T.CHAMFERCUT11     = '#CHAMFERCUT11#',
               T.CHAMFERCUT2      = '#CHAMFERCUT2#',
               T.CHAMFERCUT21     = '#CHAMFERCUT21#',
               T.CHAMFERCUT3      = '#CHAMFERCUT3#',
               T.CHAMFERCUT31     = '#CHAMFERCUT31#',
               T.CHAMFERCUT4      = '#CHAMFERCUT4#',
               T.CHAMFERCUT41     = '#CHAMFERCUT41#',
               T.CHAMFERCUT5      = '#CHAMFERCUT5#',
               T.CHAMFERCUT51     = '#CHAMFERCUT51#',
               T.CHAMFERCUT6      = '#CHAMFERCUT6#',
               T.CHAMFERCUT61     = '#CHAMFERCUT61#',
               T.WITHIN11         = '#WITHIN11#',
               T.WITHIN2          = '#WITHIN2#',
               T.WITHIN21         = '#WITHIN21#',
               T.WITHIN3          = '#WITHIN3#',
               T.WITHIN31         = '#WITHIN31#',
               T.WITHIN4          = '#WITHIN4#',
               T.WITHIN41         = '#WITHIN41#',
               T.WITHIN5          = '#WITHIN5#',
               T.WITHIN51         = '#WITHIN51#',
               T.WITHIN6          = '#WITHIN6#',
               T.WITHIN61         = '#WITHIN61#',
               T.STRAIGHTNESS11   = '#STRAIGHTNESS11#',
               T.STRAIGHTNESS2    = '#STRAIGHTNESS2#',
               T.STRAIGHTNESS21   = '#STRAIGHTNESS21#',
               T.STRAIGHTNESS3    = '#STRAIGHTNESS3#',
               T.STRAIGHTNESS31   = '#STRAIGHTNESS31#',
               T.STRAIGHTNESS4    = '#STRAIGHTNESS4#',
               T.STRAIGHTNESS41   = '#STRAIGHTNESS41#',
               T.STRAIGHTNESS5    = '#STRAIGHTNESS5#',
               T.STRAIGHTNESS51   = '#STRAIGHTNESS51#',
               T.STRAIGHTNESS6    = '#STRAIGHTNESS6#',
               T.STRAIGHTNESS61   = '#STRAIGHTNESS61#'
         WHERE T.FURNACENO = MYROW.FURNACENO;
      ELSE
        UPDATE STL_LG_SURFACE_M T
           SET T.QUANTITY         = v_QUANTITY,
               T.ACT_WEIGHT       = v_WEIGHT,
               T.CHECK_RESULT     = '#CHECK_RESULT#',
               T.ELIGIBLEQUTY     = v_ELIGIBLEQUTY,
               T.MEMO             = '#MEMO#',
               T.FLOW_NO1         = '#FLOW_NO1#',
               T.FLOW_NO11        = '#FLOW_NO11#',
               T.FLOW_NO2         = '#FLOW_NO2#',
               T.FLOW_NO21        = '#FLOW_NO21#',
               T.FLOW_NO3         = '#FLOW_NO3#',
               T.FLOW_NO31        = '#FLOW_NO31#',
               T.FLOW_NO4         = '#FLOW_NO4#',
               T.FLOW_NO41        = '#FLOW_NO41#',
               T.FLOW_NO5         = '#FLOW_NO5#',
               T.FLOW_NO51        = '#FLOW_NO51#',
               T.FLOW_NO6         = '#FLOW_NO6#',
               T.FLOW_NO61        = '#FLOW_NO61#',
               T.MIN_DIAMETER1    = '#MIN_DIAMETER1#',
               T.MIN_DIAMETER11   = '#MIN_DIAMETER11#',
               T.MIN_DIAMETER2    = '#MIN_DIAMETER2#',
               T.MIN_DIAMETER21   = '#MIN_DIAMETER21#',
               T.MIN_DIAMETER3    = '#MIN_DIAMETER3#',
               T.MIN_DIAMETER31   = '#MIN_DIAMETER31#',
               T.MIN_DIAMETER4    = '#MIN_DIAMETER4#',
               T.MIN_DIAMETER41   = '#MIN_DIAMETER41#',
               T.MIN_DIAMETER5    = '#MIN_DIAMETER5#',
               T.MIN_DIAMETER51   = '#MIN_DIAMETER51#',
               T.MIN_DIAMETER6    = '#MIN_DIAMETER6#',
               T.MIN_DIAMETER61   = '#MIN_DIAMETER61#',
               T.MAX_DIAMETER1    = '#MAX_DIAMETER1#',
               T.MAX_DIAMETER11   = '#MAX_DIAMETER11#',
               T.MAX_DIAMETER2    = '#MAX_DIAMETER2#',
               T.MAX_DIAMETER21   = '#MAX_DIAMETER21#',
               T.MAX_DIAMETER3    = '#MAX_DIAMETER3#',
               T.MAX_DIAMETER31   = '#MAX_DIAMETER31#',
               T.MAX_DIAMETER4    = '#MAX_DIAMETER4#',
               T.MAX_DIAMETER41   = '#MAX_DIAMETER41#',
               T.MAX_DIAMETER5    = '#MAX_DIAMETER5#',
               T.MAX_DIAMETER51   = '#MAX_DIAMETER51#',
               T.MAX_DIAMETER6    = '#MAX_DIAMETER6#',
               T.MAX_DIAMETER61   = '#MAX_DIAMETER61#',
               T.CASTING_LENGTH1  = '#CASTING_LENGTH1#',
               T.CASTING_LENGTH11 = '#CASTING_LENGTH11#',
               T.CASTING_LENGTH2  = '#CASTING_LENGTH2#',
               T.CASTING_LENGTH21 = '#CASTING_LENGTH21#',
               T.CASTING_LENGTH3  = '#CASTING_LENGTH3#',
               T.CASTING_LENGTH31 = '#CASTING_LENGTH31#',
               T.CASTING_LENGTH4  = '#CASTING_LENGTH4#',
               T.CASTING_LENGTH41 = '#CASTING_LENGTH41#',
               T.CASTING_LENGTH5  = '#CASTING_LENGTH5#',
               T.CASTING_LENGTH51 = '#CASTING_LENGTH51#',
               T.CASTING_LENGTH6  = '#CASTING_LENGTH6#',
               T.CASTING_LENGTH61 = '#CASTING_LENGTH61#',
               T.CHAMFERCUT1      = '#CHAMFERCUT1#',
               T.WITHIN1          = '#WITHIN1#',
               T.STRAIGHTNESS1    = '#STRAIGHTNESS1#',
               T.INSPECTION       = '#INSPECTION#',
               T.TREATING_RESULT  = '#TREATING_RESULT#',
               T.OFFLINE_NUM      = v_OFFLINE_NUM,
               T.SCRAP_NUM        = v_SCRAP_NUM,
               T.FURNACENO        = MYROW.FURNACENO,
               T.CHAMFERCUT11     = '#CHAMFERCUT11#',
               T.CHAMFERCUT2      = '#CHAMFERCUT2#',
               T.CHAMFERCUT21     = '#CHAMFERCUT21#',
               T.CHAMFERCUT3      = '#CHAMFERCUT3#',
               T.CHAMFERCUT31     = '#CHAMFERCUT31#',
               T.CHAMFERCUT4      = '#CHAMFERCUT4#',
               T.CHAMFERCUT41     = '#CHAMFERCUT41#',
               T.CHAMFERCUT5      = '#CHAMFERCUT5#',
               T.CHAMFERCUT51     = '#CHAMFERCUT51#',
               T.CHAMFERCUT6      = '#CHAMFERCUT6#',
               T.CHAMFERCUT61     = '#CHAMFERCUT61#',
               T.WITHIN11         = '#WITHIN11#',
               T.WITHIN2          = '#WITHIN2#',
               T.WITHIN21         = '#WITHIN21#',
               T.WITHIN3          = '#WITHIN3#',
               T.WITHIN31         = '#WITHIN31#',
               T.WITHIN4          = '#WITHIN4#',
               T.WITHIN41         = '#WITHIN41#',
               T.WITHIN5          = '#WITHIN5#',
               T.WITHIN51         = '#WITHIN51#',
               T.WITHIN6          = '#WITHIN6#',
               T.WITHIN61         = '#WITHIN61#',
               T.STRAIGHTNESS11   = '#STRAIGHTNESS11#',
               T.STRAIGHTNESS2    = '#STRAIGHTNESS2#',
               T.STRAIGHTNESS21   = '#STRAIGHTNESS21#',
               T.STRAIGHTNESS3    = '#STRAIGHTNESS3#',
               T.STRAIGHTNESS31   = '#STRAIGHTNESS31#',
               T.STRAIGHTNESS4    = '#STRAIGHTNESS4#',
               T.STRAIGHTNESS41   = '#STRAIGHTNESS41#',
               T.STRAIGHTNESS5    = '#STRAIGHTNESS5#',
               T.STRAIGHTNESS51   = '#STRAIGHTNESS51#',
               T.STRAIGHTNESS6    = '#STRAIGHTNESS6#',
               T.STRAIGHTNESS61   = '#STRAIGHTNESS61#'
         WHERE T.FURNACENO = MYROW.FURNACENO
           AND T.ACT_FIX_NUM = MYROW.FIX_NUM;
      END IF;
    ELSE
      INSERT INTO STL_LG_SURFACE_M
        (SURFACE_CHECK_NO,
         JUDGE_STOVE_NO,
         STOVE_NO,
         ACT_WEIGHT,
         CHECK_RESULT,
         QUANTITY,
         ELIGIBLEQUTY,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         CREATE_NAME,
         CREATE_TIME,
         MEMO,
         PLINE_CODE,
         FLOW_NO1,
         FLOW_NO11,
         FLOW_NO2,
         FLOW_NO21,
         FLOW_NO3,
         FLOW_NO31,
         FLOW_NO4,
         FLOW_NO41,
         FLOW_NO5,
         FLOW_NO51,
         FLOW_NO6,
         FLOW_NO61,
         MIN_DIAMETER1,
         MIN_DIAMETER11,
         MIN_DIAMETER2,
         MIN_DIAMETER21,
         MIN_DIAMETER3,
         MIN_DIAMETER31,
         MIN_DIAMETER4,
         MIN_DIAMETER41,
         MIN_DIAMETER5,
         MIN_DIAMETER51,
         MIN_DIAMETER6,
         MIN_DIAMETER61,
         MAX_DIAMETER1,
         MAX_DIAMETER11,
         MAX_DIAMETER2,
         MAX_DIAMETER21,
         MAX_DIAMETER3,
         MAX_DIAMETER31,
         MAX_DIAMETER4,
         MAX_DIAMETER41,
         MAX_DIAMETER5,
         MAX_DIAMETER51,
         MAX_DIAMETER6,
         MAX_DIAMETER61,
         CASTING_LENGTH1,
         CASTING_LENGTH11,
         CASTING_LENGTH2,
         CASTING_LENGTH21,
         CASTING_LENGTH3,
         CASTING_LENGTH31,
         CASTING_LENGTH4,
         CASTING_LENGTH41,
         CASTING_LENGTH5,
         CASTING_LENGTH51,
         CASTING_LENGTH6,
         CASTING_LENGTH61,
         CHAMFERCUT1,
         WITHIN1,
         STRAIGHTNESS1,
         INSPECTION,
         TREATING_RESULT,
         REMARKS,
         COL_SHIFT,
         COL_GROUP,
         FLAG_STOVE_NO,
         RESULT_NO,
         OFFLINE_NUM,
         SCRAP_NUM,
         FURNACENO,
         CHAMFERCUT11,
         CHAMFERCUT2,
         CHAMFERCUT21,
         CHAMFERCUT3,
         CHAMFERCUT31,
         CHAMFERCUT4,
         CHAMFERCUT41,
         CHAMFERCUT5,
         CHAMFERCUT51,
         CHAMFERCUT6,
         CHAMFERCUT61,
         WITHIN11,
         WITHIN2,
         WITHIN21,
         WITHIN3,
         WITHIN31,
         WITHIN4,
         WITHIN41,
         WITHIN5,
         WITHIN51,
         WITHIN6,
         WITHIN61,
         STRAIGHTNESS11,
         STRAIGHTNESS2,
         STRAIGHTNESS21,
         STRAIGHTNESS3,
         STRAIGHTNESS31,
         STRAIGHTNESS4,
         STRAIGHTNESS41,
         STRAIGHTNESS5,
         STRAIGHTNESS51,
         STRAIGHTNESS6,
         STRAIGHTNESS61,
         ACT_FIX_NUM)
      VALUES
        (v_SURFACE_CHECK_NO,
         '#JUDGE_STOVE_NO#',
         '#STOVE_NO#',
         v_WEIGHT,
         
         '#CHECK_RESULT#',
         v_QUANTITY,
         v_ELIGIBLEQUTY,
         '#PRO_ORDER_NO#',
         '#PRO_ORDER_ID#',
         '#CREATE_NAME#',
         SYSDATE,
         '#MEMO#',
         '#PLINE_CODE#',
         '#FLOW_NO1#',
         '#FLOW_NO11#',
         '#FLOW_NO2#',
         '#FLOW_NO21#',
         '#FLOW_NO3#',
         '#FLOW_NO31#',
         '#FLOW_NO4#',
         '#FLOW_NO41#',
         '#FLOW_NO5#',
         '#FLOW_NO51#',
         '#FLOW_NO6#',
         '#FLOW_NO61#',
         '#MIN_DIAMETER1#',
         '#MIN_DIAMETER11#',
         '#MIN_DIAMETER2#',
         '#MIN_DIAMETER21#',
         '#MIN_DIAMETER3#',
         '#MIN_DIAMETER31#',
         '#MIN_DIAMETER4#',
         '#MIN_DIAMETER41#',
         '#MIN_DIAMETER5#',
         '#MIN_DIAMETER51#',
         '#MIN_DIAMETER6#',
         '#MIN_DIAMETER61#',
         '#MAX_DIAMETER1#',
         '#MAX_DIAMETER11#',
         '#MAX_DIAMETER2#',
         '#MAX_DIAMETER21#',
         '#MAX_DIAMETER3#',
         '#MAX_DIAMETER31#',
         '#MAX_DIAMETER4#',
         '#MAX_DIAMETER41#',
         '#MAX_DIAMETER5#',
         '#MAX_DIAMETER51#',
         '#MAX_DIAMETER6#',
         '#MAX_DIAMETER61#',
         '#CASTING_LENGTH1#',
         '#CASTING_LENGTH11#',
         '#CASTING_LENGTH2#',
         '#CASTING_LENGTH21#',
         '#CASTING_LENGTH3#',
         '#CASTING_LENGTH31#',
         '#CASTING_LENGTH4#',
         '#CASTING_LENGTH41#',
         '#CASTING_LENGTH5#',
         '#CASTING_LENGTH51#',
         '#CASTING_LENGTH6#',
         '#CASTING_LENGTH61#',
         '#CHAMFERCUT1#',
         '#WITHIN1#',
         '#STRAIGHTNESS1#',
         '#INSPECTION#',
         '#TREATING_RESULT#',
         '#REMARKS#',
         '#COL_SHIFT#',
         '#COL_GROUP#',
         '#FLAG_STOVE_NO#',
         '#RESULT_NO#',
         v_OFFLINE_NUM,
         v_SCRAP_NUM,
         '#FURNACENO#',
         '#CHAMFERCUT11#',
         '#CHAMFERCUT2#',
         '#CHAMFERCUT21#',
         '#CHAMFERCUT3#',
         '#CHAMFERCUT31#',
         '#CHAMFERCUT4#',
         '#CHAMFERCUT41#',
         '#CHAMFERCUT5#',
         '#CHAMFERCUT51#',
         '#CHAMFERCUT6#',
         '#CHAMFERCUT61#',
         '#WITHIN11#',
         '#WITHIN2#',
         '#WITHIN21#',
         '#WITHIN3#',
         '#WITHIN31#',
         '#WITHIN4#',
         '#WITHIN41#',
         '#WITHIN5#',
         '#WITHIN51#',
         '#WITHIN6#',
         '#WITHIN61#',
         '#STRAIGHTNESS11#',
         '#STRAIGHTNESS2#',
         '#STRAIGHTNESS21#',
         '#STRAIGHTNESS3#',
         '#STRAIGHTNESS31#',
         '#STRAIGHTNESS4#',
         '#STRAIGHTNESS41#',
         '#STRAIGHTNESS5#',
         '#STRAIGHTNESS51#',
         '#STRAIGHTNESS6#',
         '#STRAIGHTNESS61#',
         MYROW.FIX_NUM);
    END IF;
  END LOOP;
END;
</query>
<query id = "FrmStuffSurfaceInspection.insertOffine" desc = "离线时插入离线表">
DECLARE
  v_COUNT STL_LG_PROGRRSS.ACT_COUNT%TYPE := NULL;

BEGIN
  SELECT COUNT(1)
    INTO v_COUNT
    FROM STL_LG_OFFLINE T
   WHERE T.FURNACENO = '#FURNACENO#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.FIX_NUM = '#FIX_NUM#';
  FOR MYROW IN (SELECT *
                  FROM STL_LG_PROGRRSS T
                 WHERE T.MAT_NO = '#MAT_NO#'
                   AND T.FURNACENO = '#FURNACENO#') LOOP
    IF (v_COUNT > 0) THEN
      UPDATE STL_LG_OFFLINE T
         SET T.OFFLINE_NUM = TO_NUMBER(T.OFFLINE_NUM) +
                             TO_NUMBER(MYROW.ACT_COUNT),
             T.ZP_WEIGHT   = TO_NUMBER(T.ZP_WEIGHT) +
                             TO_NUMBER(MYROW.WEIGHT)
       WHERE T.FURNACENO = MYROW.FURNACENO
         AND T.FIX_NUM = MYROW.FIX_NUM;
    ELSE
      INSERT INTO STL_LG_OFFLINE
        (FURNACENO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         DIAMETER,
         LENGTH,
         FIX_NUM,
         FIX_LEN,
         PLINE_CODE,
         OFFLINE_NUM,
         BACKLINE_NUM,
         ZP_FLAG,
         ZP_WEIGHT,
         MATERIAL_NO,
         MATERIAL_NAME,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         COL_USER,
         COL_SHIFT,
         COL_GROUP,
         OFFLINE_TIME
         )
      VALUES
        (MYROW.FURNACENO,
         MYROW.STOVE_NO,
         MYROW.JUDGE_STOVE_NO,
         MYROW.DIAMETER,
         MYROW.LENGTH,
         MYROW.FIX_NUM,
         MYROW.FIX_LEN,
         MYROW.PLINE_CODE,
         MYROW.ACT_COUNT,
         '0',
         '0',
         MYROW.WEIGHT,
         MYROW.MATERIAL_NO,
         MYROW.MATERIAL_NAME,
         '',
         '',
         '',
         '',
         MYROW.GRADECODE,
         MYROW.GRADENAME,
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '#COL_USER#',
         '#COL_SHIFT#',
         '#COL_GROUP#',
         SYSDATE
         );
    END IF;
    UPDATE STL_LG_PROGRRSS T SET T.STATUS = '1' WHERE T.MAT_NO = MYROW.MAT_NO AND T.FIX_NUM = MYROW.FIX_NUM; 
  END LOOP;
END;
</query>
<query id= "FrmStuffSurfaceInspection.insertOffineBack" desc = "表检离线回退">
<![CDATA[
DECLARE
  V_NUM STL_LG_OFFLINE.OFFLINE_NUM%TYPE := NULL;
BEGIN
  FOR MYROW IN (SELECT *
                  FROM STL_LG_PROGRRSS T
                 WHERE T.MAT_NO = '#MAT_NO#'
                   AND T.FURNACENO = '#FURNACENO#') LOOP
    UPDATE STL_LG_OFFLINE T
       SET T.OFFLINE_NUM = TO_NUMBER(T.OFFLINE_NUM) -
                           TO_NUMBER(MYROW.ACT_COUNT),
           T.ZP_WEIGHT   = TO_NUMBER(T.ZP_WEIGHT) - TO_NUMBER(MYROW.WEIGHT)
     WHERE T.FURNACENO = MYROW.FURNACENO
       AND T.FIX_NUM = MYROW.FIX_NUM;
       UPDATE STL_LG_PROGRRSS T SET T.STATUS = '0' WHERE T.MAT_NO = MYROW.MAT_NO AND T.FIX_NUM = MYROW.FIX_NUM;
    SELECT T.OFFLINE_NUM
      INTO V_NUM
      FROM STL_LG_OFFLINE T
     WHERE T.FURNACENO = '#FURNACENO#'
       AND T.FIX_NUM = '#FIX_NUM#';
       IF(V_NUM <1)THEN
       DELETE FROM STL_LG_OFFLINE T WHERE T.FURNACENO = '#FURNACENO#' AND T.FIX_NUM = '#FIX_NUM#';
       END IF;
  END LOOP;
END;
]]>
</query>
<query id = "FrmStuffSurfaceInspection.doQueryOffline" desc = "查询是否存在未处理管坯">
SELECT COUNT(1)ACOUNT FROM STL_LG_PROGRRSS T WHERE T.FURNACENO = ? AND T.IS_VALID = '0' AND T.STATUS = '1'
</query>
<query id = "FrmStuffSurfaceInspection.doBaside" desc = "结炉">
UPDATE STL_LG_SURFACE_M T SET T.NODE_FUR_FLAG = '1' WHERE T.FURNACENO = ?
</query>
<query id= "FrmStuffSurfaceInspection.doBasideBack" desc = "结炉回退">
UPDATE STL_LG_SURFACE_M T SET T.NODE_FUR_FLAG = '0' WHERE T.FURNACENO = ?
</query>
</queryMap>