<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="炼钢调度日志">
	<query id="FrmStlControlLog.doQueryPlan" desc="查询日志">
<![CDATA[
SELECT T.CONTROL_ID,
       TO_CHAR(TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_BEG,
       TO_CHAR(TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_END,
       TO_CHAR((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
               TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60,
               'FM999999999990') SJC,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.CIC,
       T.MOULDBALEWGT,
       T.PRO_BC,
       T.PRO_BZ,
       DECODE(T.PRO_TYPE, '1', '正常', '2', '停机') PRO_TYPE,
       T.STOP_TYPE,
       T.STOP_REASON,
       TO_CHAR(T.USER_DATE, 'YYYY-MM-DD HH24:MI:SS') USER_DATE,
       T.USER_NAME,
       T.STOP_SMALL,
       TO_CHAR(T.CONFIRM_TIME, 'YYYY-MM-DD HH24:MI:SS') CONFIRM_TIME,
       T.CONFIRM_NAME,
       DECODE(T.CONFIRM_FLAG, '0', '未确认', '1', '已确认') CONFIRM_FLAG,
       (select b.BASENAME
          from com_base_info b
         where b.BASECODE = t.stop_reason
           and b.VALIDFLAG = '1') stop_reasonm,
       (select b.BASENAME
          from com_base_info b
         where b.BASECODE = t.stop_small
           and b.VALIDFLAG = '1') stop_smallm,
       T.MEMO,
       T.BAL_YEAR_MONTH,
       TO_CHAR(TO_DATE(T.PROC_DATE, 'YYYY-MM-DD'), 'YYYY-MM-DD') PROC_DATE,
       T.STOVE_NO
  FROM STL_CONTROL_LOG T
 WHERE 1 = 1
   ]]>
	</query>
	<query id="FrmStlControlLog.doQueryPlanPro" desc="生产详情">
<![CDATA[
SELECT T.CONTROL_ID,
       TO_CHAR(TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_BEG,
       TO_CHAR(TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_END,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.CIC,
       T.MOULDBALEWGT,
       DECODE(T.PRO_BC,'1','早班','2','中班','3','夜班') PRO_BC,
       DECODE(T.PRO_BZ,'1','甲','2','乙','3','丙','4','丁') PRO_BZ,
       DECODE(T.PRO_TYPE, '1', '正常', '2', '停机') PRO_TYPE,
       (select b.BASENAME
          from com_base_info b
         where b.BASECODE = T.STOP_TYPE
           and b.VALIDFLAG = '1') STOP_TYPE,
       T.STOP_REASON,
       TO_CHAR(T.USER_DATE, 'YYYY-MM-DD HH24:MI:SS') USER_DATE,
       T.USER_NAME,
       T.STOP_SMALL,
       TO_CHAR(T.CONFIRM_TIME, 'YYYY-MM-DD HH24:MI:SS') CONFIRM_TIME,
       T.CONFIRM_NAME,
       DECODE(T.CONFIRM_FLAG, '0', '未确认', '1', '已确认') CONFIRM_FLAG,
       (select b.BASENAME
          from com_base_info b
         where b.BASECODE = t.stop_reason
           and b.VALIDFLAG = '1') stop_reasonm,
       (select b.BASENAME
          from com_base_info b
         where b.BASECODE = t.stop_small
           and b.VALIDFLAG = '1') stop_smallm,
       T.MEMO,
       T.BAL_YEAR_MONTH,
       TO_CHAR(TO_DATE(T.PROC_DATE, 'YYYY-MM-DD'), 'YYYY-MM-DD') PROC_DATE,
       T.STOVE_NO
  FROM STL_CONTROL_LOG T
 WHERE 1 = 1
   ]]>
	</query>
	<query id="FrmStlControlLog.doStopQuery" desc="查询日志停机记录">
<![CDATA[
SELECT TO_CHAR(TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_BEG,
       TO_CHAR(TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_END,
       TO_CHAR(TO_DATE(T.PROC_DATE, 'YYYY-MM-DD'),
               'YYYY-MM-DD') PROC_DATE,
       (SELECT B.PLINE_NAME FROM COM_BASE_PLINE B WHERE B.PLINE_CODE=T.PLINE_CODE) PLINE_CODE,
       T.STOVE_NO,
       REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       T.LOT_NO,
       T.CONTRACT_NO,
       T.IMP_PROCESS,
       T.PRODUCER,
       T.FINISH_USER,
       T.TARGET_LIABRARY,
       T.VARIETIES,
       T.PIPE_SIZE,
       T.BUCKLE_TYPE,
       T.LENGTH_RANGE,
       T.ROLL_STANDRAD,
       T.PIPE_SECTION,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEEL_STANDRAD,
       T.TARGET,
       DECODE(T.PRO_BC,'1','早班','2','中班','3','夜班') PRO_BC,
       DECODE(T.PRO_BZ,'1','甲','2','乙','3','丙','4','丁') PRO_BZ,    
       NVL(T.QUALIFIED_NUM,0) QUALIFIED_NUM,
       NVL(T.QUALIFIED_WT,0) QUALIFIED_WT,
       NVL(T.SCRAP_NUM,0) SCRAP_NUM,
       NVL(T.SCRAP_WT,0) SCRAP_WT,
       DECODE(T.PRO_TYPE,'1','正常','2','停机') PRO_TYPE,
             (select b.BASENAME
          from com_base_info b
         where b.BASECODE = T.STOP_TYPE
           and b.VALIDFLAG = '1') STOP_TYPE,
       T.STOP_REASON,
       T.USER_NAME,
       T.STOP_SMALL,
       TO_CHAR(T.USER_DATE, 'YYYY-MM-DD') USER_DATE,
       T.USER_ID,
       T.CONTROL_ID,
       (select b.BASENAME from com_base_info b where  b.BASECODE=t.stop_reason and b.VALIDFLAG='1') stop_reasonm,
       (select b.BASENAME from com_base_info b where  b.BASECODE=t.stop_small and b.VALIDFLAG='1') stop_smallm,
       T.CONFIRM_NAME,
       TO_CHAR(T.CONFIRM_TIME,'YYYY-MM-DD HH24:MI:SS') CONFIRM_TIME,
       DECODE(T.CONFIRM_FLAG,'0','未确认','1','已确认') CONFIRM_FLAG
  FROM STL_CONTROL_LOG T
 WHERE 1 = 1
 AND T.PRO_TYPE='2'
   ]]>
	</query>
	<query id="FrmStlControlLog.addMilControlLog" desc="新增日志">
<![CDATA[ 
INSERT INTO STL_CONTROL_LOG
  (LOGS_BEG,
   LOGS_END,
   EF_PLINE_CODE,
   EF_PLINE_NAME,
   PLINE_CODE,
   PLINE_NAME,
   PRO_BC,
   PRO_BZ,
   PRO_TYPE,
   STOP_TYPE,
   STOP_REASON,
   USER_DATE,
   USER_NAME,
   STOP_SMALL,
   MEMO,
   BAL_YEAR_MONTH,
   PROC_DATE,
   STOVE_NO,
   GRADECODE,
   GRADENAME)
VALUES
  ('#LOGS_BEG#',
   '#LOGS_END#',
   '#EF_PLINE_CODE#',
   '#EF_PLINE_NAME#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#PRO_BC#',
   '#PRO_BZ#',
   '2',
   '#STOP_TYPE#',
   '#STOP_REASON#',
   SYSDATE,
   '#USER_NAME#',
   '#STOP_SMALL#',
   '#MEMO#',
   
   CASE WHEN(substr('#LOGS_BEG#', 9, 4) >= '2100' AND
        substr('#LOGS_BEG#', 9, 4) <= '2400') THEN
   TO_CHAR(TRUNC(to_date('#LOGS_BEG#', 'YYYY-MM-DD HH24:MI:SS')) + 1,
           'YYYYMM') ELSE
   TO_CHAR(TRUNC(to_date('#LOGS_BEG#', 'YYYY-MM-DD HH24:MI:SS')), 'YYYYMM') END,
   
   CASE WHEN(substr('#LOGS_BEG#', 9, 4) >= '2100' AND
        substr('#LOGS_BEG#', 9, 4) <= '2400') THEN
   TO_CHAR(TRUNC(to_date('#LOGS_BEG#', 'YYYY-MM-DD HH24:MI:SS')) + 1,
           'YYYYMMDD') ELSE
   TO_CHAR(TRUNC(to_date('#LOGS_BEG#', 'YYYY-MM-DD HH24:MI:SS')),
           'YYYYMMDD') END,
   '#STOVE_NO#',
   '#GRADECODE#',
   '#GRADENAME#')
  ]]>
	</query>
	<query id="FrmStlControlLog.queryPlanJg" desc="查询是否存在要新增的记录">
<![CDATA[ 
SELECT COUNT(*) COUNTS
  FROM STL_CONTROL_LOG T
 WHERE T.LOGS_BEG = ?
  ]]>
	</query>
	<query id="FrmStlControlLog.updateControlLog" desc="修改日志表记录">
<![CDATA[ 
UPDATE STL_CONTROL_LOG T
   SET T.LOGS_BEG       = '#LOGS_BEG#',
       T.LOGS_END       = '#LOGS_END#',
       T.STOP_TYPE      = '#STOP_TYPE#',
       T.STOP_REASON    = '#STOP_REASON#',
       T.USER_NAME      = '#USER_NAME#',
       T.USER_DATE      = SYSDATE,
       T.STOP_SMALL     = '#STOP_SMALL#',
       T.BAL_YEAR_MONTH = CASE
                            WHEN (substr('#LOGS_BEG#', 9, 4) >= '2100' AND
                                 substr('#LOGS_BEG#', 9, 4) <= '2400') THEN
                             TO_CHAR(TRUNC(to_date('#LOGS_BEG#',
                                                   'YYYY-MM-DD HH24:MI:SS')) + 1,
                                     'YYYYMM')
                            ELSE
                             TO_CHAR(TRUNC(to_date('#LOGS_BEG#',
                                                   'YYYY-MM-DD HH24:MI:SS')),
                                     'YYYYMM')
                          END,
       T.PROC_DATE = CASE
                       WHEN (substr('#LOGS_BEG#', 9, 4) >= '2100' AND
                            substr('#LOGS_BEG#', 9, 4) <= '2400') THEN
                        TO_CHAR(TRUNC(to_date('#LOGS_BEG#',
                                              'YYYY-MM-DD HH24:MI:SS')) + 1,
                                'YYYYMMDD')
                       ELSE
                        TO_CHAR(TRUNC(to_date('#LOGS_BEG#',
                                              'YYYY-MM-DD HH24:MI:SS')),
                                'YYYYMMDD')
                     END,
       
       T.MEMO = '#MEMO#'
 WHERE T.CONTROL_ID = '#CONTROL_ID#'
  ]]>
	</query>
	<query id="FrmStlControlLog.updateControlLogDown" desc="修改选中行下一条数据">
<![CDATA[ 
UPDATE STL_CONTROL_LOG
   SET LOGS_BEG = ? 
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmStlControlLog.updateControlLogUp" desc="修改选中行上一条数据">
<![CDATA[ 
UPDATE STL_CONTROL_LOG
   SET LOGS_END = ?
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmStlControlLog.queryStratTime" desc="查询修改上一行记录">
<![CDATA[ 
SELECT TO_CHAR(TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_BEG,
       TO_CHAR(TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_END,
       T.CONTROL_ID
  FROM STL_CONTROL_LOG T
 WHERE T.LOGS_BEG <
       (SELECT T1.LOGS_BEG
          FROM STL_CONTROL_LOG T1
         WHERE T1.CONTROL_ID = ?)
         AND T.PRO_BC=?
         AND T.PRO_BZ=?
 ORDER BY T.LOGS_BEG DESC
  ]]>
	</query>
	<query id="FrmStlControlLog.queryEndTime" desc="查询修改下一行记录">
<![CDATA[ 
SELECT TO_CHAR(TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_BEG,
       TO_CHAR(TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_END,
       T.CONTROL_ID
  FROM STL_CONTROL_LOG T
 WHERE T.LOGS_BEG >
       (SELECT T1.LOGS_BEG
          FROM STL_CONTROL_LOG T1
         WHERE T1.CONTROL_ID = ?)
         AND T.PRO_BC=?
         AND T.PRO_BZ=?
 ORDER BY T.LOGS_BEG ASC
  ]]>
	</query>
	<query id="FrmStlControlLog.queryTime" desc="查询修改下一行记录">
<![CDATA[ 
SELECT TO_CHAR(TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_BEG,
       TO_CHAR(TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_END,
       T.CONTROL_ID
  FROM STL_CONTROL_LOG T
 WHERE T.CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmStlControlLog.getComBaseInfo" desc="停机分类">
<![CDATA[ 
SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   AND T.VALIDFLAG = '1'
]]>
	</query>
	<query id="FrmStlControlLog.queryContfirm" desc="确认状态">
<![CDATA[ 
SELECT T.CONFIRM_FLAG FROM STL_CONTROL_LOG T WHERE T.CONTROL_ID=?
]]>
	</query>
	<query id="FrmStlControlLog.queryCountLoag" desc="查询选中行数据前是否有数据">
<![CDATA[ 
SELECT T.CONTROL_ID
  FROM STL_CONTROL_LOG T
 WHERE T.CONFIRM_FLAG='0'
   AND T.LOGS_BEG <= ?
   AND T.PLINE_CODE = ?
   AND T.PRO_BC =?
   AND T.PRO_BZ = ?
   AND T.LOGS_END >= ?
   AND T.LOGS_END <= ?
   ORDER BY T.LOGS_BEG
]]>
	</query>
	<query id="FrmStlControlLog.queryCountLoag1" desc="查询选中行数据后是否有数据">
<![CDATA[ 
SELECT T.CONTROL_ID
  FROM STL_CONTROL_LOG T
 WHERE T.CONFIRM_FLAG='1'
   AND T.LOGS_BEG >= ?
   AND T.PLINE_CODE = ?
   AND T.PRO_BC =?
   AND T.PRO_BZ = ?
   AND T.LOGS_END >= ?
   AND T.LOGS_END <= ?
   ORDER BY T.LOGS_BEG
]]>
	</query>
	
	<query id="FrmStlControlLog.confirmMilControlLog" desc="修改确认标志">
	<![CDATA[ 
	UPDATE STL_CONTROL_LOG T
   SET CONFIRM_FLAG = '1', CONFIRM_NAME = ?, CONFIRM_TIME = SYSDATE
 WHERE T.STOVE_NO = ?
   AND T.PLINE_CODE = ?
   AND T.EF_PLINE_CODE = ?
	]]>
	</query>
	
	<query id="FrmStlControlLog.updatePlnOrder" desc="确认时，修改PLN_ORDER_ZG_S表数据 ">
	<![CDATA[ 
	UPDATE PLN_ORDER_ZG_S T
   SET T.FINISHNUM    = NVL(T.FINISHNUM, 0) +
                        (SELECT NVL(SUM(A.QUALIFIED_NUM), 0)
                           FROM STL_CONTROL_LOG A
                          WHERE A.JUDGE_STOVE_NO = ?
                            AND A.PRO_BC = ?
                            AND A.PRO_BZ = ?
                            AND A.CONFIRM_FLAG = '1'),
       T.FINISHWEIGHT = NVL(T.FINISHWEIGHT, 0) +
                        (SELECT NVL(SUM(A.QUALIFIED_WT), 0)
                           FROM STL_CONTROL_LOG A
                          WHERE A.JUDGE_STOVE_NO = ?
                            AND A.PRO_BC = ?
                            AND A.PRO_BZ = ?
                            AND A.CONFIRM_FLAG = '1')
 WHERE T.PRO_PLAN_ID || '-' || T.GX_PLAN_NO =
       (SELECT M.SEQ FROM MIL_PLAN M WHERE M.JUDGE_STOVE_NO = ?)

	]]>
	</query>
	
	<query id="FrmStlControlLog.updatePlnOrderBack" desc="取消确认时，修改PLN_ORDER_ZG_S表数据 ">
	<![CDATA[ 
	UPDATE PLN_ORDER_ZG_S T
   SET T.FINISHNUM    = NVL(T.FINISHNUM, 0) -
                        (SELECT NVL(SUM(A.QUALIFIED_NUM), 0)
                           FROM STL_CONTROL_LOG A
                          WHERE A.JUDGE_STOVE_NO = ?
                            AND A.PRO_BC = ?
                            AND A.PRO_BZ = ?
                            AND A.CONFIRM_FLAG = '1'),
       T.FINISHWEIGHT = NVL(T.FINISHWEIGHT, 0) -
                        (SELECT NVL(SUM(A.QUALIFIED_WT), 0)
                           FROM STL_CONTROL_LOG A
                          WHERE A.JUDGE_STOVE_NO = ?
                            AND A.PRO_BC = ?
                            AND A.PRO_BZ = ?
                            AND A.CONFIRM_FLAG = '1')
 WHERE T.PRO_PLAN_ID || '-' || T.GX_PLAN_NO =
       (SELECT M.SEQ FROM MIL_PLAN M WHERE M.JUDGE_STOVE_NO = ?)

	]]>
	</query>
	
	<query id="FrmStlControlLog.UpConfirmMilControlLog" desc="取消确认标志">
	<![CDATA[ 
	UPDATE STL_CONTROL_LOG T
   SET CONFIRM_FLAG = '0', CONFIRM_NAME = '', CONFIRM_TIME = ''
 WHERE T.STOVE_NO = ?
   AND T.PLINE_CODE = ?
   AND T.EF_PLINE_CODE = ?
	]]>
	</query>
	<query id="FrmStlControlLog.DeleteControlLog" desc="删除停机记录">
<![CDATA[ 
DELETE STL_CONTROL_LOG WHERE CONTROL_ID = ?
]]>
	</query>
	<query id="FrmStlControlLog.OneKeyProcesMilControlLog" desc="一键处理新增轧管日志">
<![CDATA[ 
INSERT INTO STL_CONTROL_LOG
  (LOGS_BEG, LOGS_END, USER_DATE, USER_NAME, PRO_BC,PRO_BZ,PLINE_CODE,PRO_TYPE,STOP_TYPE,STOP_SMALL,STOP_REASON,PLINE_NAME)
VALUES
  (?, ?, TO_DATE(?,'YYYY-MM-DD'), ?, ?,?,?,?,?,?,?,?)
  ]]>
	</query>
	<query id="FrmStlControlLog.doQueryActual" desc="统计当班生产实绩">
<![CDATA[ 
SELECT T2.JUDGE_STOVE_NO,
       T2.QUALIFIED_NUM,
       T2.QUALIFIED_WT,
       (SELECT round(NVL(((CASE
                          WHEN TRUNC(TO_DATE(?, 'YYYY-MM-DD')) =
                               TRUNC(SYSDATE) AND ? = GET_CurrentBC() THEN
                           SYSDATE
                          ELSE
                           TO_DATE(MAX(T.LOGS_END), 'YYYY-MM-DD HH24:MI')
                        END -
                        TO_DATE(MIN(T.LOGS_BEG), 'YYYY-MM-DD HH24:MI')) * 24 * 60),
                   0)) YOUMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PRO_BC = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1') YOUMINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) MINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PRO_BC = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2'
           AND (T.STOP_TYPE = '500601' OR T.STOP_TYPE = '500602')) MINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) ABSMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PRO_BC = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2'
           AND T.STOP_TYPE = '500603') ABSMINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) SUMMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PRO_BC = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2') SUMMINUTES
  FROM (SELECT COUNT(1) JUDGE_STOVE_NO,
               NVL(SUM(T1.QUALIFIED_NUM), 0) QUALIFIED_NUM,
               NVL(SUM(T1.QUALIFIED_WT), 0) QUALIFIED_WT
          FROM (SELECT T.JUDGE_STOVE_NO,
                       NVL(SUM(T.QUALIFIED_NUM), 0) QUALIFIED_NUM,
                       NVL(SUM(T.QUALIFIED_WT), 0) QUALIFIED_WT
                  FROM STL_CONTROL_LOG T
                 WHERE T.PROC_DATE = ?
                   AND T.PRO_BC = ?
                   AND T.PLINE_CODE = ?
                   AND T.CONFIRM_FLAG = '1'
                   AND T.PRO_TYPE = '1'
                 GROUP BY T.JUDGE_STOVE_NO) T1) T2
  ]]>
	</query>
	<query id="FrmStlControlLog.doQueryMonthActual" desc="统计月生产实绩">
<![CDATA[ 
SELECT T2.JUDGE_STOVE_NO,
       T2.QUALIFIED_NUM,
       T2.QUALIFIED_WT,
       (SELECT round(NVL(((CASE
                          WHEN ? = TO_CHAR(TRUNC(SYSDATE), 'YYYYMM') THEN
                           SYSDATE
                          ELSE
                           TO_DATE(MAX(T.LOGS_END), 'YYYY-MM-DD HH24:MI')
                        END -
                        TO_DATE(MIN(T.LOGS_BEG), 'YYYY-MM-DD HH24:MI')) * 24 * 60),
                   0)) YOUMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.BAL_YEAR_MONTH = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1') YOUMINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) MINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.BAL_YEAR_MONTH = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2'
           AND (T.STOP_TYPE = '500601' OR T.STOP_TYPE = '500602')) MINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) ABSMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.BAL_YEAR_MONTH = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2'
           AND T.STOP_TYPE = '500603') ABSMINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) SUMMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.BAL_YEAR_MONTH = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2') SUMMINUTES
  FROM (SELECT COUNT(1) JUDGE_STOVE_NO,
               NVL(SUM(T1.QUALIFIED_NUM), 0) QUALIFIED_NUM,
               NVL(SUM(T1.QUALIFIED_WT), 0) QUALIFIED_WT
          FROM (SELECT T.JUDGE_STOVE_NO,
                       NVL(SUM(T.QUALIFIED_NUM), 0) QUALIFIED_NUM,
                       NVL(SUM(T.QUALIFIED_WT), 0) QUALIFIED_WT
                  FROM STL_CONTROL_LOG T
                 WHERE T.BAL_YEAR_MONTH = ?
                   AND T.PLINE_CODE = ?
                   AND T.CONFIRM_FLAG = '1'
                   AND T.PRO_TYPE = '1'
                 GROUP BY T.JUDGE_STOVE_NO) T1) T2
  ]]>
	</query>
	<query id="FrmStlControlLog.doQueryDayActual" desc="统计日">
<![CDATA[ SELECT T2.JUDGE_STOVE_NO,
       T2.QUALIFIED_NUM,
       T2.QUALIFIED_WT,
       (SELECT round(NVL(((CASE
                          WHEN TRUNC(TO_DATE(?, 'YYYY-MM-DD')) =
                               TRUNC(SYSDATE) THEN
                           SYSDATE
                          ELSE
                           TO_DATE(MAX(T.LOGS_END), 'YYYY-MM-DD HH24:MI')
                        END -
                        TO_DATE(MIN(T.LOGS_BEG), 'YYYY-MM-DD HH24:MI')) * 24 * 60),
                   0)) YOUMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1') YOUMINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) MINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2'
           AND (T.STOP_TYPE = '500601' OR T.STOP_TYPE = '500602')) MINUTES,
       
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) ABSMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2'
           AND T.STOP_TYPE = '500603') ABSMINUTES,
       (SELECT round(NVL(SUM(((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60)),
                   0)) SUMMINUTES
          FROM STL_CONTROL_LOG T
         WHERE T.PROC_DATE = ?
           AND T.PLINE_CODE = ?
           AND T.CONFIRM_FLAG = '1'
           AND T.PRO_TYPE = '2') SUMMINUTES
  FROM (SELECT COUNT(1) JUDGE_STOVE_NO,
               NVL(SUM(T1.QUALIFIED_NUM), 0) QUALIFIED_NUM,
               NVL(SUM(T1.QUALIFIED_WT), 0) QUALIFIED_WT
          FROM (SELECT T.JUDGE_STOVE_NO,
                       NVL(SUM(T.QUALIFIED_NUM), 0) QUALIFIED_NUM,
                       NVL(SUM(T.QUALIFIED_WT), 0) QUALIFIED_WT
                  FROM STL_CONTROL_LOG T
                 WHERE T.PROC_DATE = ?
                   AND T.PLINE_CODE = ?
                   AND T.CONFIRM_FLAG = '1'
                   AND T.PRO_TYPE = '1'
                 GROUP BY T.JUDGE_STOVE_NO) T1) T2
  ]]>
	</query>
	<query id="FrmStlControlLog.OneKeyUpdateMilControlLog" desc="一键修改">
<![CDATA[
UPDATE STL_CONTROL_LOG T SET T.LOGS_END = ? WHERE T.CONTROL_ID = ?
 ]]>
	</query>
	
	<query id = "FrmStlControlLog.UpdataPROCDATE" desc = "更新调度中的生产年月">
<![CDATA[
      	  UPDATE STL_CONTROL_LOG T  
                     SET T.Proc_Date = CASE   
                   WHEN (substr(t.logs_beg,9,4)> '1200'   
                        AND substr(t.logs_beg,9,4)<= '2400') AND T.PRO_BC = '3'  THEN  TO_CHAR(TRUNC(to_date(t.logs_beg,'YYYY-MM-DD HH24:MI:SS'))+1,'YYYYMMDD')   
                   WHEN (substr(t.logs_beg,9,4) >='0000'   
                        AND substr(t.logs_beg,9,4)< '1200') AND T.PRO_BC = '3'  THEN TO_CHAR(TRUNC(to_date(t.logs_beg,'YYYY-MM-DD HH24:MI:SS')),'YYYYMMDD')   
                   ELSE TO_CHAR(TRUNC(to_date(t.logs_beg,'YYYY-MM-DD HH24:MI:SS')),'YYYYMMDD')END,   
                     T.Bal_Year_Month = CASE   
                   WHEN (substr(t.logs_beg,9,4)> '1200'  
                        AND substr(t.logs_beg,9,4)<= '2400') AND T.PRO_BC = '3'  THEN  TO_CHAR(TRUNC(to_date(t.logs_beg,'YYYY-MM-DD HH24:MI:SS'))+1,'YYYYMM')   
                   WHEN (substr(t.logs_beg,9,4) >='0000'  
                        AND substr(t.logs_beg,9,4)< '1200') AND T.PRO_BC = '3'  THEN TO_CHAR(TRUNC(to_date(t.logs_beg,'YYYY-MM-DD HH24:MI:SS')),'YYYYMM')   
             ELSE TO_CHAR(TRUNC(to_date(t.logs_beg,'YYYY-MM-DD HH24:MI:SS')),'YYYYMM')END  
             WHERE T.Proc_Date IS NULL		    
        ]]>
</query>
	<query id = "FrmStlControlLog.doQueryPlineName" desc = "查询产线">
<![CDATA[
SELECT T.PLINE_NAME FROM COM_BASE_PLINE T WHERE T.PLINE_CODE = ?
]]>
</query>

<query id = "FrmStlControlLog.doQueryPlanCollect" desc = "调度数据汇总">
<![CDATA[
SELECT T.CONTROL_ID,
       TO_CHAR(TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_BEG,
       TO_CHAR(TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') LOGS_END,
       TO_CHAR((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
               TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60,
               'FM99990') SJC,
       T1.tjsc,
       TO_CHAR((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
               TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60 -
               NVL(T1.tjsc, 0),
               'FM99990') sczq,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.WLID_IN,
       T.WLDESC_IN || CASE
         WHEN T2.BASKETETNUM > 0 THEN
          '料兰数量(' || T2.BASKETETNUM || ') 废钢量（' ||
          (NVL(T2.BASKETETNO1WGT, 0) + NVL(T2.BASKETETNO2WGT, 0) +
          NVL(T2.BASKETETNO3WGT, 0) + NVL(T2.BASKETETNO4WGT, 0)) || ')'
       END || CASE
         WHEN T2.POTNUM > 0 THEN
          '铁水罐数量(' || T2.POTNUM || ') 铁水量（' ||
          (NVL(T2.POT1WGT, 0) + NVL(T2.POT2WGT, 0) + NVL(T2.POT3WGT, 0)) || ')'
       END WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.CIC,
       T.MOULDBALEWGT,
       T.PRO_BC,
       T.PRO_BZ,
       DECODE(T.PRO_TYPE, '1', '正常', '2', '停机') PRO_TYPE,
       T.STOP_TYPE,
       T.STOP_REASON,
       TO_CHAR(T.USER_DATE, 'YYYY-MM-DD HH24:MI:SS') USER_DATE,
       T.USER_NAME,
       T.STOP_SMALL,
       TO_CHAR(T.CONFIRM_TIME, 'YYYY-MM-DD HH24:MI:SS') CONFIRM_TIME,
       T.CONFIRM_NAME,
       DECODE(T.CONFIRM_FLAG, '0', '未确认', '1', '已确认') CONFIRM_FLAG,
       (select b.BASENAME
          from com_base_info b
         where b.BASECODE = t.stop_reason
           and b.VALIDFLAG = '1') stop_reasonm,
       (select b.BASENAME
          from com_base_info b
         where b.BASECODE = t.stop_small
           and b.VALIDFLAG = '1') stop_smallm,
       T.MEMO,
       T.BAL_YEAR_MONTH,
       TO_CHAR(TO_DATE(T.PROC_DATE, 'YYYY-MM-DD'), 'YYYY-MM-DD') PROC_DATE,
       T.STOVE_NO
  FROM STL_CONTROL_LOG T,
       STL_EAF_OPTINFO T2,
       (SELECT T1.STOVE_NO,
               T1.EF_PLINE_CODE,
               SUM(TO_CHAR((TO_DATE(T1.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                           TO_DATE(T1.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60,
                           'FM99990')) tjsc
          FROM STL_CONTROL_LOG T1
         WHERE T1.PRO_TYPE = '2' #SOMETHING1#
         GROUP BY T1.STOVE_NO, T1.EF_PLINE_CODE) T1
 WHERE T.PRO_TYPE = '1'
   AND T.STOVE_NO = T1.STOVE_NO(+)
   AND T.STOVE_NO = T2.STOVE_NO(+)
   AND T.EF_PLINE_CODE = T1.EF_PLINE_CODE(+) #SOMETHING2#
 ORDER BY T.EF_PLINE_CODE, T.LOGS_BEG, T.LOGS_END ASC
]]>
</query>

</queryMap>