<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="轧管调度日志">
	<query id="FrmVrpControlLog.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,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_CODE,
       T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.CONTRACT_NO,
       T.CRAFT_FILE_NO,
       T.PRDCR_NO,
       T.VARIETIES,
       T.PIPE_SIZE,
       T.BUCKLE_TYPE,
       T.LENGTH_RANGE,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PRO_BC,
       T.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,
          T.STOP_TYPE,
       (SELECT BASENAME FROM com_base_info WHERE  BASECODE=T.STOP_REASON ) STOP_REASON,
       T.STOP_REASON  STOP_REASON_CODE,
       TO_CHAR(T.USER_DATE, 'YYYY-MM-DD HH24:MI:SS') USER_DATE,
       T.USER_NAME,
       T.USER_ID,
      (SELECT BASENAME FROM com_base_info WHERE  BASECODE=T.STOP_SMALL ) STOP_SMALL,
      T.STOP_SMALL STOP_SMALL_CODE,
       TO_CHAR(T.CONFIRM_TIME, 'YYYY-MM-DD HH24:MI:SS') CONFIRM_TIME,
       T.CONFIRM_NAME,
       DECODE(T.CONFIRM_FLAG, '0', '未确认', '1', '已确认') CONFIRM_FLAG,
       T.MEMO,
       T.BAL_YEAR_MONTH,
       T.PROC_DATE,
       DECODE(T.NODE_FLAG, '0', '未结炉', '1', '已结炉') NODE_FLAG,
       T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO
  FROM VRP_CONTROL_LOG T
 WHERE 1 = 1
   ]]>
	</query>
	<query id="FrmVrpControlLog.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,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_CODE,
       T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.CONTRACT_NO,
       T.CRAFT_FILE_NO,
       T.PRDCR_NO,
       T.VARIETIES,
       T.PIPE_SIZE,
       T.BUCKLE_TYPE,
       T.LENGTH_RANGE,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       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,
       T.STOP_TYPE,
       (SELECT BASENAME FROM com_base_info WHERE  BASECODE=T.STOP_REASON ) STOP_REASON,
       TO_CHAR(T.USER_DATE, 'YYYY-MM-DD HH24:MI:SS') USER_DATE,
       T.USER_NAME,
       T.USER_ID,
         (SELECT BASENAME FROM com_base_info WHERE  BASECODE=T.STOP_SMALL ) 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,
       T.MEMO,
       T.BAL_YEAR_MONTH,
       T.PROC_DATE,
       DECODE(T.NODE_FLAG, '0', '未结炉', '1', '已结炉') NODE_FLAG,
       T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO
  FROM VRP_CONTROL_LOG T
 WHERE 1 = 1
   ]]>
	</query>
	<query id="FrmVrpControlLog.doStopQuery" 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,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_CODE,
       T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.CONTRACT_NO,
       T.CRAFT_FILE_NO,
       T.PRDCR_NO,
       T.VARIETIES,
       T.PIPE_SIZE,
       T.BUCKLE_TYPE,
       T.LENGTH_RANGE,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       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 BASENAME FROM com_base_info WHERE  BASECODE=T.STOP_TYPE ) STOP_TYPE,
       (SELECT BASENAME FROM com_base_info WHERE  BASECODE=T.STOP_REASON ) STOP_REASON,
       TO_CHAR(T.USER_DATE, 'YYYY-MM-DD HH24:MI:SS') USER_DATE,
       T.USER_NAME,
       T.USER_ID,
      (SELECT BASENAME FROM com_base_info WHERE  BASECODE=T.STOP_SMALL ) 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,
       T.MEMO,
       T.BAL_YEAR_MONTH,
       T.PROC_DATE,
       DECODE(T.NODE_FLAG, '0', '未结炉', '1', '已结炉') NODE_FLAG,
       T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO
  FROM VRP_CONTROL_LOG T
 WHERE 1 = 1
 AND T.PRO_TYPE='2'
   ]]>
	</query>
	<query id="FrmVrpControlLog.addMilControlLog" desc="新增日志">
<![CDATA[ 
INSERT INTO VRP_CONTROL_LOG
  (LOGS_BEG, LOGS_END, USER_DATE, USER_NAME, PRO_TYPE,PRO_BC,PRO_BZ,PLINE_CODE,BAL_YEAR_MONTH,PROC_DATE)
VALUES
  (?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, '2',?,?,?,?,?)
  ]]>
	</query>
	<query id="FrmVrpControlLog.queryPlanJg" desc="查询是否存在要新增的记录">
<![CDATA[ 
SELECT COUNT(*) COUNTS
  FROM VRP_CONTROL_LOG T
 WHERE T.LOGS_BEG = ?
  ]]>
	</query>
	<query id="FrmVrpControlLog.updateControlLog" desc="修改日志表记录">
<![CDATA[ 
UPDATE VRP_CONTROL_LOG
   SET LOGS_BEG = ?,
       LOGS_END = ?,
       PLINE_CODE = ?,
       STOP_TYPE = ?,
       STOP_REASON = ?,
       QUALIFIED_NUM = ?,
       QUALIFIED_WT = ?,
       SCRAP_NUM = ?,
       SCRAP_WT = ?,
       PRO_BC = ?,
       PRO_BZ = ?,
       STOP_SMALL = ?,
       MEMO=?,
       Proc_Date = CASE   
                   WHEN (substr(?,9,4)> '1200'   
                        AND substr(?,9,4)<= '2400') AND PRO_BC = '3'  THEN  TO_CHAR(TRUNC(to_date(?,'YYYY-MM-DD HH24:MI:SS'))+1,'YYYYMMDD')   
                   WHEN (substr(?,9,4) >='0000'   
                        AND substr(?,9,4)< '1200') AND PRO_BC = '3'  THEN TO_CHAR(TRUNC(to_date(?,'YYYY-MM-DD HH24:MI:SS')),'YYYYMMDD')   
                   ELSE TO_CHAR(TRUNC(to_date(?,'YYYY-MM-DD HH24:MI:SS')),'YYYYMMDD')END,   
                     Bal_Year_Month = CASE   
                   WHEN (substr(?,9,4)> '1200'  
                        AND substr(?,9,4)<= '2400') AND PRO_BC ='3'  THEN  TO_CHAR(TRUNC(to_date(?,'YYYY-MM-DD HH24:MI:SS'))+1,'YYYYMM')   
                   WHEN (substr(?,9,4) >='0000'  
                        AND substr(?,9,4)< '1200') AND PRO_BC = '3'  THEN TO_CHAR(TRUNC(to_date(?,'YYYY-MM-DD HH24:MI:SS')),'YYYYMM')   
             ELSE TO_CHAR(TRUNC(to_date(?,'YYYY-MM-DD HH24:MI:SS')),'YYYYMM')END 
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmVrpControlLog.updateControlLogDown" desc="修改选中行下一条数据">
<![CDATA[ 
UPDATE VRP_CONTROL_LOG
   SET LOGS_BEG = ? 
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmVrpControlLog.updateControlLogUp" desc="修改选中行上一条数据">
<![CDATA[ 
UPDATE VRP_CONTROL_LOG
   SET LOGS_END = ?
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmVrpControlLog.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 VRP_CONTROL_LOG T
 WHERE T.LOGS_BEG <
       (SELECT T1.LOGS_BEG
          FROM VRP_CONTROL_LOG T1
         WHERE T1.CONTROL_ID = ?)
         AND T.PRO_BC=?
         AND T.PRO_BZ=?
 ORDER BY T.LOGS_BEG DESC
  ]]>
	</query>
	<query id="FrmVrpControlLog.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 VRP_CONTROL_LOG T
 WHERE T.LOGS_BEG >
       (SELECT T1.LOGS_BEG
          FROM VRP_CONTROL_LOG T1
         WHERE T1.CONTROL_ID = ?)
         AND T.PRO_BC=?
         AND T.PRO_BZ=?
 ORDER BY T.LOGS_BEG ASC
  ]]>
	</query>
	<query id="FrmVrpControlLog.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 VRP_CONTROL_LOG T
 WHERE T.CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmVrpControlLog.getComBaseInfo" desc="停机分类">
<![CDATA[ 
SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   AND T.VALIDFLAG = '1'
]]>
	</query>
	<query id="FrmVrpControlLog.queryContfirm" desc="确认状态">
<![CDATA[ 
SELECT T.CONFIRM_FLAG FROM VRP_CONTROL_LOG T WHERE T.CONTROL_ID=?
]]>
	</query>
	<query id="FrmVrpControlLog.queryCountLoag" desc="查询选中行数据前是否有数据">
<![CDATA[ 
SELECT T.CONTROL_ID
  FROM VRP_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="FrmVrpControlLog.queryCountLoag1" desc="查询选中行数据后是否有数据">
<![CDATA[ 
SELECT T.CONTROL_ID
  FROM VRP_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="FrmVrpControlLog.confirmMilControlLog" desc="修改确认标志">
<![CDATA[ 
UPDATE VRP_CONTROL_LOG
   SET CONFIRM_FLAG = '1',
       CONFIRM_NAME = ?,
       CONFIRM_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE CONTROL_ID = ?
]]>
	</query>
	<query id="FrmVrpControlLog.UpConfirmMilControlLog" desc="取消确认标志">
<![CDATA[ 
UPDATE VRP_CONTROL_LOG
   SET CONFIRM_FLAG = '0',
       CONFIRM_NAME = '',
       CONFIRM_TIME = TO_DATE('', 'YYYY-MM-DD HH24:MI:SS')
 WHERE CONTROL_ID = ?
]]>
	</query>
	<query id="FrmVrpControlLog.DeleteControlLog" desc="删除停机记录">
<![CDATA[ 
DELETE VRP_CONTROL_LOG WHERE CONTROL_ID = ?
]]>
	</query>
	<query id="FrmVrpControlLog.OneKeyProcesMilControlLog" desc="一键处理新增轧管日志">
<![CDATA[ 
INSERT INTO VRP_CONTROL_LOG
  (LOGS_BEG, LOGS_END, USER_DATE, USER_NAME, PRO_BC,PRO_BZ,PLINE_CODE,PRO_TYPE,STOP_TYPE,STOP_SMALL,STOP_REASON,BAL_YEAR_MONTH,PROC_DATE)
VALUES
  (?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?,?,?,?,?,?,?,?,?)
  ]]>
	</query>
	<query id="FrmVrpControlLog.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 VRP_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 VRP_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 VRP_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 VRP_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 VRP_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="FrmVrpControlLog.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 VRP_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 VRP_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 VRP_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 VRP_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 VRP_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="FrmVrpControlLog.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 VRP_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 VRP_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 VRP_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 VRP_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 VRP_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="FrmVrpControlLog.OneKeyUpdateMilControlLog" desc="一键修改">
<![CDATA[
UPDATE VRP_CONTROL_LOG T SET T.LOGS_END = ? WHERE T.CONTROL_ID = ?
 ]]>
	</query>
	
	<query id = "FrmVrpControlLog.UpdataPROCDATE" desc = "更新调度中的生产年月">
<![CDATA[
      	  UPDATE VRP_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 = "FrmVrpControlLog.doMinutesQuery" desc = "查询调度生产运行停机时间">
<![CDATA[

]]>
</query>
</queryMap>