<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="轧管调度日志">
	<query id="FrmMilControlLog.doQueryPlan" 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,
       (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,
       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.DEPT,
       T.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,
       TO_CHAR(TO_DATE(T.PROC_DATE, 'YYYY-MM-DD'),
               'YYYY-MM-DD') PROC_DATE,
       DECODE(T.CHANGE_SHIFT_FLAG,'0','无','1','交班','2','接班') CHANGE_SHIFT_FLAG,
       DECODE(T.NODE_FLAG,'0','未结炉','1','已结炉') NODE_FLAG,
       MEMO
  FROM MIL_CONTROL_LOG T
 WHERE 1 = 1
   ]]>
	</query>
	<query id="FrmMilControlLog.doQueryPlanPro" 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,
       (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,
       TO_CHAR(TO_DATE(T.PROC_DATE, 'YYYY-MM-DD'),
               'YYYY-MM-DD') PROC_DATE,
       MEMO
  FROM MIL_CONTROL_LOG T
 WHERE 1 = 1
   ]]>
	</query>
	<query id="FrmMilControlLog.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 MIL_CONTROL_LOG T
 WHERE 1 = 1
 AND T.PRO_TYPE='2'
   ]]>
	</query>
	<query id="FrmMilControlLog.ZCQuery" 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.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,
			   T.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,
			   T.PRO_BC,
			   T.PRO_BZ,
			   T.QUALIFIED_NUM,
			   T.QUALIFIED_WT,
			   T.SCRAP_NUM,
			   T.SCRAP_WT,
			   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.USER_ID,
			   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,
			   T.MEMO,
			   T.BAL_YEAR_MONTH,
			   DECODE(T.CHANGE_SHIFT_FLAG,'0','无','1','交班','2','接班') CHANGE_SHIFT_FLAG,
			   DECODE(T.NODE_FLAG,'0','未结炉','1','已结炉') NODE_FLAG,
			   T.PRO_PLAN_ID,
			   T.GX_PLAN_NO,
			   T.DEPT,
			   T.UPDATENAME,
			   TO_CHAR(TO_DATE(T.UPDATEDATE, 'YYYY-MM-DD HH24:MI'),
               'YYYY-MM-DD HH24:MI') UPDATEDATE
		 FROM MIL_CONTROL_LOG T
		 WHERE
		T.PRO_TYPE=1
]]>
	</query>
	<query id="FrmMilControlLog.addMilControlLog" desc="新增日志">
<![CDATA[ 
INSERT INTO MIL_CONTROL_LOG
  (LOGS_BEG, LOGS_END, USER_DATE, USER_NAME, PRO_TYPE,PRO_BC,PRO_BZ,PLINE_CODE)
VALUES
  (?, ?, TO_DATE(?, 'YYYY-MM-DD'), ?, '2',?,?,?)
  ]]>
	</query>
	<query id="FrmMilControlLog.queryPlanJg" desc="查询是否存在要新增的记录">
<![CDATA[ 
SELECT COUNT(*) COUNTS
  FROM MIL_CONTROL_LOG T
 WHERE T.LOGS_BEG = ?
  ]]>
	</query>
	<query id="FrmMilControlLog.updateControlLog" desc="修改日志表记录">
<![CDATA[ 
UPDATE MIL_CONTROL_LOG T
   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           = ?,
       T.DEPT         = ?,
       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 T.PLINE_CODE = 'C072' THEN
                           CASE
                             WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                  TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                          '-24 15:59:59',
                                          'YYYY-MM-DD hh24:mi:ss') THEN
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss') + 10,
                                      'YYYYMM')
                             ELSE
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss'),
                                      'YYYYMM')
                           END
                          ELSE
                           CASE
                             WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                  TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                          '-25 11:59:59',
                                          'YYYY-MM-DD hh24:mi:ss') THEN
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss') + 10,
                                      'YYYYMM')
                             ELSE
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss'),
                                      'YYYYMM')
                           END
                        END
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	
	<query id="FrmMilControlLog.updateControlLog2" desc="修改停机调度日志">
<![CDATA[ 
UPDATE MIL_CONTROL_LOG
   SET STOP_TYPE = ?, STOP_REASON = ?, STOP_SMALL = ?, MEMO = ?
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmMilControlLog.updateControlLogZC" desc="修改正常调度日志">
		<![CDATA[
		 UPDATE MIL_CONTROL_LOG T
   SET
        T.LOGS_BEG = ?,
        T.LOGS_END = ?,
        T.PROC_DATE = ?,
        T.BAL_YEAR_MONTH = ?,
        T.QUALIFIED_NUM = ?,
        T.QUALIFIED_WT = ?,
        T.SCRAP_NUM = ?,
        T.SCRAP_WT = ?,
        T.PRO_BC = ?,
        T.PRO_BZ = ?,
        T.UPDATENAME = ?,
        T.UPDATEDATE = ?
		 WHERE
		T.CONTROL_ID = ?
		]]>
	</query>
	<query id="FrmMilControlLog.updateControlLogDown" desc="修改选中行下一条数据">
<![CDATA[ 
UPDATE MIL_CONTROL_LOG
   SET LOGS_BEG = ? 
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmMilControlLog.updateControlLogUp" desc="修改选中行上一条数据">
<![CDATA[ 
UPDATE MIL_CONTROL_LOG
   SET LOGS_END = ?
 WHERE CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmMilControlLog.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 MIL_CONTROL_LOG T
 WHERE T.LOGS_BEG <
       (SELECT T1.LOGS_BEG
          FROM MIL_CONTROL_LOG T1
         WHERE T1.CONTROL_ID = ?)
         AND T.PRO_BC=?
         AND T.PRO_BZ=?
 ORDER BY T.LOGS_BEG DESC
  ]]>
	</query>
	<query id="FrmMilControlLog.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 MIL_CONTROL_LOG T
 WHERE T.LOGS_BEG >
       (SELECT T1.LOGS_BEG
          FROM MIL_CONTROL_LOG T1
         WHERE T1.CONTROL_ID = ?)
         AND T.PRO_BC=?
         AND T.PRO_BZ=?
 ORDER BY T.LOGS_BEG ASC
  ]]>
	</query>
	<query id="FrmMilControlLog.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 MIL_CONTROL_LOG T
 WHERE T.CONTROL_ID = ?
  ]]>
	</query>
	<query id="FrmMilControlLog.getComBaseInfo" desc="停机分类">
<![CDATA[ 
SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   AND T.VALIDFLAG = '1'
]]>
	</query>
	<query id="FrmMilControlLog.queryContfirm" desc="确认状态">
<![CDATA[ 
SELECT T.CONFIRM_FLAG FROM MIL_CONTROL_LOG T WHERE T.CONTROL_ID=?
]]>
	</query>
	<query id="FrmMilControlLog.queryCountLoag" desc="查询选中行数据前是否有数据">
<![CDATA[ 
SELECT T.CONTROL_ID
  FROM MIL_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="FrmMilControlLog.queryCountLoag1" desc="查询选中行数据后是否有数据">
<![CDATA[ 
SELECT T.CONTROL_ID
  FROM MIL_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="FrmMilControlLog.confirmMilControlLog" desc="修改确认标志">
	<![CDATA[ 
UPDATE MIL_CONTROL_LOG t
   SET CONFIRM_FLAG   = '1',
       CONFIRM_NAME   = ?,
       CONFIRM_TIME   = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       BAL_YEAR_MONTH = CASE
                          WHEN T.PLINE_CODE = 'C072' THEN
                           CASE
                             WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                  TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                          '-24 15:59:59',
                                          'YYYY-MM-DD hh24:mi:ss') THEN
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss') + 10,
                                      'YYYYMM')
                             ELSE
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss'),
                                      'YYYYMM')
                           END
                          ELSE
                           CASE
                             WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                  TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                          '-25 11:59:59',
                                          'YYYY-MM-DD hh24:mi:ss') THEN
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss') + 10,
                                      'YYYYMM')
                             ELSE
                              TO_CHAR(TO_DATE(T.LOGS_BEG,
                                              'YYYY-MM-DD hh24:mi:ss'),
                                      'YYYYMM')
                           END
                        END
 WHERE CONTROL_ID = ?
	]]>
	</query>
	
	<query id="FrmMilControlLog.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 MIL_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 MIL_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="FrmMilControlLog.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 MIL_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 MIL_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="FrmMilControlLog.UpConfirmMilControlLog" desc="取消确认标志">
	<![CDATA[ 
	UPDATE MIL_CONTROL_LOG
	   SET CONFIRM_FLAG = '0',
	       CONFIRM_NAME = '',
	       CONFIRM_TIME = TO_DATE('', 'YYYY-MM-DD HH24:MI:SS')
	 WHERE CONTROL_ID = ?
	]]>
	</query>
	<query id="FrmMilControlLog.DeleteControlLog" desc="删除停机记录">
<![CDATA[ 
DELETE MIL_CONTROL_LOG WHERE CONTROL_ID = ?
]]>
	</query>
	<query id="FrmMilControlLog.OneKeyProcesMilControlLog" desc="一键处理新增轧管日志">
<![CDATA[ 
INSERT INTO MIL_CONTROL_LOG
  (LOGS_BEG, LOGS_END, USER_DATE, USER_NAME, PRO_BC,PRO_BZ,PLINE_CODE,PRO_TYPE,STOP_TYPE,STOP_SMALL,STOP_REASON)
VALUES
  (?, ?, TO_DATE(?,'YYYY-MM-DD'), ?, ?,?,?,?,?,?,?)
  ]]>
	</query>
	<query id="FrmMilControlLog.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 MIL_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 MIL_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 MIL_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 MIL_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 MIL_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="FrmMilControlLog.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 MIL_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 MIL_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 MIL_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 MIL_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 MIL_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="FrmMilControlLog.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 MIL_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 MIL_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 MIL_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 MIL_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 MIL_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="FrmMilControlLog.OneKeyUpdateMilControlLog" desc="一键修改">
<![CDATA[
UPDATE MIL_CONTROL_LOG T SET T.LOGS_END = ? WHERE T.CONTROL_ID = ?
 ]]>
	</query>
	
	<query id = "FrmMilControlLog.UpdataPROCDATE" desc = "更新调度中的生产年月">
<![CDATA[
      	UPDATE MIL_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 T.PLINE_CODE = 'C072' THEN
                             CASE
                               WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                    TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                            '-24 15:59:59',
                                            'YYYY-MM-DD hh24:mi:ss') THEN
                                TO_CHAR(TO_DATE(T.LOGS_BEG,
                                                'YYYY-MM-DD hh24:mi:ss') + 10,
                                        'YYYYMM')
                               ELSE
                                TO_CHAR(TO_DATE(T.LOGS_BEG,
                                                'YYYY-MM-DD hh24:mi:ss'),
                                        'YYYYMM')
                             END
                            ELSE
                             CASE
                               WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                    TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                            '-25 11:59:59',
                                            'YYYY-MM-DD hh24:mi:ss') THEN
                                TO_CHAR(TO_DATE(T.LOGS_BEG,
                                                'YYYY-MM-DD hh24:mi:ss') + 10,
                                        'YYYYMM')
                               ELSE
                                TO_CHAR(TO_DATE(T.LOGS_BEG,
                                                'YYYY-MM-DD hh24:mi:ss'),
                                        'YYYYMM')
                             END
                          END

 WHERE T.Proc_Date IS NULL    
        ]]>
</query>
	<query id = "FrmMilControlLog.doMinutesQuery" desc = "查询调度生产运行停机时间">
<![CDATA[

]]>
</query>
</queryMap>