<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="加工线电子签名维护">
	<query id="FrmGroupSetting.doQuery" desc="查询">
	 <![CDATA[ 
         SELECT 'True' Chk, T.* FROM MCH_GROUPNO T WHERE ORDER_NO =? ORDER BY  GROUP_NO
	  ]]>
	</query>

	<query id="FrmGroupSetting.doDelete" desc="查询">
		<![CDATA[
         DELETE FROM MCH_GROUPNO  WHERE ORDER_NO =?
	  ]]>
	</query>

	<query id="FrmGroupSetting.doQueryOffLine" desc="查询">
		<![CDATA[
        SELECT SUM(OFFLINE_NUM) OFFLINE_NUM,
       MAX(OFFLINE_MAX) OFFLINE_MAX,
       MIN(OFFLINE_MIN) OFFLINE_MIN
  FROM (SELECT PRO_ORDER_NO,
               BATCH_GROUD_NO,
               NVL(COUNT(1), 0) OFFLINE_NUM,
               MAX(ACT_LEN) OFFLINE_MAX,
               MIN(ACT_LEN) OFFLINE_MIN
          FROM MAT_BC_M
         WHERE QCM_STAUS = '00'
           AND PROCESS_CDOE = 'G'
           AND PRO_ORDER_NO = ?
           AND BATCH_GROUD_NO = ?
        UNION ALL
        SELECT PRO_ORDER_NO,
               BATCH_GROUD_NO,
               NVL(COUNT(1), 0) OFFLINE_NUM,
               MAX(ACT_LEN) OFFLINE_MAX,
               MIN(ACT_LEN) OFFLINE_MIN
          FROM MAT_BC_BACKUP
         WHERE QCM_STAUS = '00'
           AND PROCESS_CDOE = 'G'
           AND PRO_ORDER_NO = ?
           AND BATCH_GROUD_NO = ?)
	  ]]>
	</query>

	<query id="FrmGroupSetting.doAdd" desc="查询">
		<![CDATA[
        	INSERT INTO MCH_GROUPNO
	(ORDER_NO,
	GROUP_MAX,
	GROUP_MIN,
	GROUP_NO,
	OFFLINE_NUM,
	OFFLINE_MAX,
	OFFLINE_MIN,
	PROCESS_CODE,
	GROUP_MAX_SIGN,
	GROUP_MIN_SIGN)
	VALUES
	('#ORDER_NO#',
	'#GROUP_MAX#',
	'#GROUP_MIN#',
	'#GROUP_NO#',
	'#OFFLINE_NUM#',
	'#OFFLINE_MAX#',
	'#OFFLINE_MIN#',
	'#PROCESS_CODE#',
	'#GROUP_MAX_SIGN#',
	'#GROUP_MIN_SIGN#')
	  ]]>
	</query>

	<query id="FrmGroupSetting.DeleteGroupNo" desc="">
		<![CDATA[
      DELETE FROM   mch_groupno WHERE flag = 0  AND Offline_Num IS NULL AND ORDER_no =?
        ]]>
	</query>

	<query id="FrmGroupSetting.SelectLessGroup" desc="">
		<![CDATA[
 	SELECT *
	FROM MCH_GROUPNO
	WHERE ORDER_NO =?
	AND GROUP_MAX <= ?
	AND GROUP_NO <> '001'
	ORDER BY GROUP_MAX
        ]]>
	</query>

	<query id="FrmGroupSetting.InsertGroup" desc="">
	<![CDATA[
INSERT INTO MCH_GROUPNO T
  (ORDER_NO,
   GROUP_MAX,
   GROUP_MIN,
   GROUP_NO,
   GROUP_MAX_SIGN,
   GROUP_MIN_SIGN)
  SELECT ?, ?, ?, LPAD(MAX(TO_NUMBER(GROUP_NO)) + 1, 3, '0'), ?, ?
    FROM MCH_GROUPNO
   WHERE ORDER_NO = ?
        ]]>
	</query>

	<query id="FrmGroupSetting.DeleteLessGroup" desc="">
		<![CDATA[
	  DELETE  FROM  MCH_GROUPNO WHERE FLAG='1' AND GROUP_NO <> '001' AND OFFLINE_NUM IS NULL AND ORDER_NO =?

        ]]>
	</query>

	<query id="FrmGroupSetting.UpdateLessGroup" desc="">
		<![CDATA[
	  UPDATE  MCH_GROUPNO SET GROUP_MIN=?, FLAG = ? WHERE  GROUP_NO <> '001'  AND ORDER_NO =? AND GROUP_NO = ?

        ]]>
	</query>


</queryMap>