<?xml version="1.0" encoding="UTF-8"?>

<queryMap desc="组批信息">
	<query id="FrmZPResult.SingleQuery" desc="查询下线炉信息">
	<![CDATA[    
 SELECT 
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       DIAMETER,
       THICKNESS,
       LENGTH,
       PLINE_CODE,
       SEQ,
       OFFLINE_PRO,
       REAL_TIME_STATUS,
       OFFLINE_NUM,
       BACKLINE_NUM,
       GROUP_NUM,
       FINAL_NUM,
       MAT_LOCATION,
       HANDLE_METHOD,
       ZP_FLAG,
       OFF_LEVEL,
       STATUS,
       TYPE_FLAG,
       TO_CHAR(OFFLINE_TIME, 'YYYY-MM-DD HH24:MI:SS') OFFLINE_TIME,
       REMARK,
       COL_USER,
       COL_SHIFT,
       COL_GROUP
 FROM MIL_OFFLINE_RESLUT
 WHERE
		LOT_NO  || '&' LIKE '%' || ? || '%'
	   AND JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
	   AND OFFLINE_TIME  between  to_date(?, 'yyyy-mm-dd hh24:mi:ss')  AND  to_date(?, 'yyyy-mm-dd hh24:mi:ss')
	   AND STATUS = '0' 
	   AND  OFFLINE_PRO = 'ZJ']]>
	</query>
	
<query id="FrmZPResult.GroupResultQuery" desc="查询组批信息">	
<![CDATA[   
	 SELECT 
       ZP_JUDGE_STOVE_NO,
       ZP_LOT_NO,
       COUNT,
       QUALIFIED_NUM,
       SCRAP_NUM,
       ZP_STANDRAD,
       ZP_STEEL,
       ZP_GRADE,
       ZP_LENGTH,
       ZP_HEIGHT,
       ZP_LENGTH_MAX,
       ZP_LEVEL,
       ZP_LENGTH_MIN,
       ZP_SIZE,
       ZP_M_LH,
       ZP_S_LH,
       ZP_M_PH,
       TO_CHAR(ZP_TIME, 'YYYY-MM-DD HH24:MI:SS') ZP_TIME,
       REMARK,
       COL_USER,
       COL_SHIFT,
       COL_GROUP
 FROM MIL_OFFLINE_GROUP
 WHERE
 1=1
 AND
		ZP_LOT_NO  || '&' LIKE '%' || ? || '%'
	   AND ZP_JUDGE_STOVE_NO  || '&' LIKE '%' || ? || '%'
	   AND ZP_TIME  between  "%" || ? || "%" AND "%" || ? || "%"
	   ]]>
	</query>
<query id="FrmZPResult.GroupResultQueryForZS" desc="查询组批追溯炉号信息">		
<![CDATA[   
	select a.JUDGE_STOVE_NO,a.SIMPLE_LOT_NO,a.GROUP_NO,min(b.LOT_NO),sum(a.COUNT),sum(a.QUALIFIED_NUM),sum(a.SCRAP_NUM) from 
   MIL_OFFLINE_GROUP_RESUME a , mil_plan b where a.JUDGE_STOVE_NO = b.JUDGE_STOVE_NO 
   and b.LOT_NO || '&' LIKE '%' || ? || '%'
   AND a.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
   AND a.SIMPLE_LOT_NO || '&' LIKE '%' || ? || '%'
   AND a.GROUP_NO  || '&' LIKE '%' || ? || '%'
   ]]>
	</query>
<query id="FrmZPResult.SimpleQuery" desc="查询下线炉性能批信息">
		
 SELECT 
       JUDGE_STOVE_NO,
       SIMPLE_LOT_NO,
       OFFLINE_FLAG,
       START_NO,
       END_NO,
       REMARK,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       PLINE_CODE,
       ZP_FLAG
 FROM MIL_SIMPLE_RESULT
 WHERE
  JUDGE_STOVE_NO = ?
  AND OFFLINE_FLAG = '1'
	</query>
	
	<query id="FrmZPResult.SimpleDetailQuery" desc="查询下线炉性能批分组信息">
	 SELECT 
       JUDGE_STOVE_NO,
       SIMPLE_LOT_NO,
       GROUP_NO,
       COUNT,
       START_NO,
       END_NO,
       STATUS,
       REMARK,
       COL_USER,
       COL_SHIFT,
       '分组' GROUPING, 
       COL_GROUP
 FROM MIL_SIMPLE_DETAIL
 WHERE
 JUDGE_STOVE_NO = ?
 AND STATUS >1
	
	</query>
	
	<query id="FrmZPResult.waitZPQuery" desc="查询待组性能批">
	
	 SELECT 
	 false HEATNO,
	 false SIMPLE,
       JUDGE_STOVE_NO,
       SIMPLE_LOT_NO,
       GROUP_NO,
       COUNT,
       START_NO,
       END_NO,
       STATUS,
       REMARK,
       COL_USER,
       COL_SHIFT,
       COL_GROUP
 FROM MIL_SIMPLE_DETAIL
 WHERE
 JUDGE_STOVE_NO = ?
 AND STATUS =2
	</query>
	
	
	<query id="FrmZPResult.UpdateSimpleGroupStatus" desc="修改性能批分组状态  1-下线 2-待组批">
	update MIL_SIMPLE_DETAIL set status = ? where JUDGE_STOVE_NO = ? and SIMPLE_LOT_NO = ? and GROUP_NO = ?
	
	</query>
	
	
		<query id="FrmZPResult.UpdateSimpleGroupStatusForEntity" desc="修改性能批分组状态  4-组批完成">
	 UPDATE MIL_SIMPLE_DETAIL
   SET 
      
        STATUS = '#STATUS#'
	WHERE 
	  JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND
        SIMPLE_LOT_NO = '#SIMPLE_LOT_NO#' AND
        GROUP_NO = '#GROUP_NO#'
	</query>
	
	<query id="FrmZPResult.InsertGroupResume" desc="查询待组性能批">
		 INSERT INTO MIL_OFFLINE_GROUP_RESUME(
        ZP_TIME,
        REMARK,
        COL_USER,
        COL_SHIFT,
        COL_GROUP,
        JUDGE_STOVE_NO,
        SIMPLE_LOT_NO,
        GROUP_NO,
        ZP_JUDGE_STOVE_NO,
        COUNT,
        QUALIFIED_NUM,
        SCRAP_NUM)
 VALUES( 
        SYSDATE,
        '#REMARK#',
        '#COL_USER#',
        '#COL_SHIFT#',
        '#COL_GROUP#',
        '#JUDGE_STOVE_NO#',
        '#SIMPLE_LOT_NO#',
        '#GROUP_NO#',
        '#ZP_JUDGE_STOVE_NO#',
        '#COUNT#',
        '#QUALIFIED_NUM#',
        '#SCRAP_NUM#')
	
	</query>
	
	<query id="FrmZPResult.InsertGroup" desc="查询待组性能批">
	
	 INSERT INTO MIL_OFFLINE_GROUP(
        JUDGE_STOVE_NO,
        GROUP_NO,
        ZP_SIZE,
        ZP_JUDGE_STOVE_NO,
        SIMPLE_LOT_NO,
        COUNT,
        QUALIFIED_NUM,
        SCRAP_NUM,
        ZP_STANDRAD,
        ZP_STEEL,
        ZP_GRADE,
        ZP_LENGTH,
        ZP_HEIGHT,
        ZP_LENGTH_MAX,
        ZP_LEVEL,
        ZP_LENGTH_MIN,
        ZP_M_LH,
        ZP_S_LH,
        ZP_M_PH,
        ZP_TIME,
        REMARK,
        COL_USER,
        COL_SHIFT,
        COL_GROUP)
 VALUES( 
        '#JUDGE_STOVE_NO#',
        '#GROUP_NO#',
        '#ZP_SIZE#',
        '#ZP_JUDGE_STOVE_NO#',
        '#SIMPLE_LOT_NO#',
        '#COUNT#',
        '#QUALIFIED_NUM#',
        '#SCRAP_NUM#',
        '#ZP_STANDRAD#',
        '#ZP_STEEL#',
        '#ZP_GRADE#',
        '#ZP_LENGTH#',
        '#ZP_HEIGHT#',
        '#ZP_LENGTH_MAX#',
        '#ZP_LEVEL#',
        '#ZP_LENGTH_MIN#',
        '#ZP_M_LH#',
        '#ZP_S_LH#',
        '#ZP_M_PH#',
        SYSDATE,
        '#REMARK#',
        '#COL_USER#',
        '#COL_SHIFT#',
        '#COL_GROUP#')
	
	</query>
</queryMap>
