<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="精整作业实绩">

	<query id="FinishingService.QueryHlstraightenResult" desc="查询热矫实绩">
        <![CDATA[
         SELECT T.RESULT_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ROLL_NUM1,
       T.ROLL_NUM2,
       T.ROLL_NUM3,
       T.BEND_RATE,
       T.LSTRAIGHTEN_TEMP,
       T.PRO_NUM,
       T.PRO_WT,
       T.FAIL_NUM,
       T.FAIL_WT,
       T.OFFLINE_NUM,
       T.OFFLINE_WT,
       T.RE_NUM,
       T.RE_WT,
       DECODE(T.COL_MODE,'1','人工录入','0','接口采集') COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       T.COL_SHIFT,
       T.COL_GROUP,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.HEAT_PLAN_NO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.UPDATE_NAME,
       T.PROCESS_SEQ,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS,
       T.DEFLECTION,
       T.ANGLE,
       TO_CHAR(T.END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       T.PRE_LSTRAIGHTEN_TEMP,
       T.AFTER_LSTRAIGHTEN_TEMP
  FROM HTT_HLSTRAIGHTEN_RESULT T,HTT_COM_INFO B
 WHERE T.RESULT_NO = B.RESULT_NO
   AND T.HEAT_PLAN_NO = B.HEAT_PLAN_NO
 AND T.HEAT_PLAN_NO = ?
 ORDER BY T.COL_TIME DESC
        ]]>
	</query>
	
	<query id="FinishingService.doQuery" desc="查询工序点">
        <![CDATA[    
SELECT T.BASECODE,T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   AND T.VALIDFLAG = '1'
   AND T.BASENAME IN ('定径', '热矫','冷矫')
        ]]>
	</query>
		<query id="FinishingService.getQueryExpandResult1" desc="查询热矫合格支数的和">
        <![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM HTT_HLSTRAIGHTEN_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
			<query id="FinishingService.getQueryExpandResult2" desc="查询冷矫合格支数的和">
        <![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM HTT_CLSTRAIGHTEN_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
			<query id="FinishingService.getQueryExpandResult3" desc="查询定径合格支数的和">
        <![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM HTT_SIZING_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
		<query id="FinishingService.getQueryExpandResultStuts" desc="查询相同炉计划ID下定径状态">
		<![CDATA[
SELECT B.STATION_STATUS 
  FROM htt_sizing_result T INNER JOIN htt_COM_INFO B ON T.RESULT_NO=B.RESULT_NO
 WHERE T.HEAT_PLAN_NO = ? AND T.PLINE_CODE =?
			]]>
	</query>
	
	<query id="FinishingService.getQueryExpandResultStuts1" desc="查询相同炉计划ID下热矫状态">
		<![CDATA[
SELECT B.STATION_STATUS 
  FROM htt_hlstraighten_result T INNER JOIN htt_COM_INFO B ON T.RESULT_NO=B.RESULT_NO
 WHERE T.HEAT_PLAN_NO = ? AND T.PLINE_CODE =?
			]]>
	</query>
	<query id="FinishingService.getQueryExpandResultStuts2" desc="查询相同炉计划ID下冷矫状态">
		<![CDATA[
SELECT B.STATION_STATUS 
  FROM htt_clstraighten_result T INNER JOIN htt_COM_INFO B ON T.RESULT_NO=B.RESULT_NO
 WHERE T.HEAT_PLAN_NO = ? AND T.PLINE_CODE =?
			]]>
	</query>
	<query id="FinishingService.QueryClstraightenResult" desc="查询冷矫实绩">
        <![CDATA[
       SELECT T.RESULT_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ROLL_NUM1,
       T.ROLL_NUM2,
       T.ROLL_NUM3,
       T.BEND_RATE,
       T.LSTRAIGHTEN_TEMP,
       T.LSTRAIGHTEN_TIME,
       T.PRO_NUM,
       T.PRO_WT,
       T.FAIL_NUM,
       T.FAIL_WT,
       T.OFFLINE_NUM,
       T.OFFLINE_WT,
       T.RE_NUM,
       T.RE_WT,
       T.COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       T.COL_SHIFT,
       T.COL_GROUP,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.HEAT_PLAN_NO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.UPDATE_NAME,
       T.PROCESS_SEQ,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS
  FROM HTT_CLSTRAIGHTEN_RESULT T,HTT_COM_INFO B 
  WHERE  T.RESULT_NO = B.RESULT_NO
   AND T.HEAT_PLAN_NO = B.HEAT_PLAN_NO
 AND T.HEAT_PLAN_NO = ?
 ORDER BY T.COL_TIME DESC
        ]]>
	</query>
	<query id="FinishingService.QuerySizingResult" desc="定径实绩查询">
        <![CDATA[
         SELECT T.RESULT_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PRO_NUM,
       T.PRO_WT,
       T.FAIL_NUM,
       T.FAIL_WT,
       T.OFFLINE_NUM,
       T.OFFLINE_WT,
       T.RE_NUM,
       T.RE_WT,
       T.COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       T.COL_SHIFT,
       T.COL_GROUP,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.HEAT_PLAN_NO,    
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.UPDATE_NAME,
       T.PROCESS_SEQ,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS，
      T.TEMPERATURE_BEFORE_SIZING,
      T.TEMPERATURE_AFTER_SIZING,
      T.SIZE_AFTER_SIZING,
      T.MEMO
  FROM HTT_SIZING_RESULT T,HTT_COM_INFO B
 WHERE  T.RESULT_NO = B.RESULT_NO
   AND T.HEAT_PLAN_NO = B.HEAT_PLAN_NO
 AND T.HEAT_PLAN_NO = ?
 ORDER BY T.COL_TIME DESC
        ]]>
	</query>

	<query id="FinishingService.AddHlstraightenResult" desc="新增热矫实绩">
        <![CDATA[
         INSERT INTO HTT_HLSTRAIGHTEN_RESULT (RESULT_NO, ZY_BATCH_ID,  
PRO_PLAN_ID, GX_PLAN_NO, ROLL_NUM1, ROLL_NUM2, ROLL_NUM3, BEND_RATE, 
LSTRAIGHTEN_TEMP, PRO_NUM, PRO_WT, COL_MODE, COL_TIME, COL_USER, COL_SHIFT, 
COL_GROUP, PLINE_CODE, PLINE_NAME, HEAT_PLAN_NO, CREATE_TIME,FAIL_NUM,FAIL_WT,
PROCESS_SEQ,DEFLECTION,ANGLE,END_TIME,PRE_LSTRAIGHTEN_TEMP,AFTER_LSTRAIGHTEN_TEMP)
 VALUES
 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?, ?,
?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?, (SELECT  NVL(SUM(DEF_FILL_WT),0) FROM HTT_WASTE_RESULT WHERE RESULT_NO = ? ), ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?)
        ]]>
	</query>
	<query id="FinishingService.AddClstraightenResult" desc="新增冷矫实绩">
        <![CDATA[
        INSERT INTO HTT_CLSTRAIGHTEN_RESULT (RESULT_NO, ZY_BATCH_ID, 
PRO_PLAN_ID, GX_PLAN_NO, ROLL_NUM1, ROLL_NUM2, ROLL_NUM3, BEND_RATE, 
LSTRAIGHTEN_TEMP, PRO_NUM, PRO_WT,  COL_MODE, COL_TIME, 
COL_USER, COL_SHIFT, COL_GROUP, PLINE_CODE, PLINE_NAME, HEAT_PLAN_NO, 
CREATE_TIME,FAIL_NUM,FAIL_WT,PROCESS_SEQ)
 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
  ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?, (SELECT  NVL(SUM(DEF_FILL_WT),0) FROM HTT_WASTE_RESULT WHERE RESULT_NO = ? ),?)

        ]]>
	</query>
	<query id="FinishingService.UpdatePath" desc="修改队列表工艺路径">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,8) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,10, LENGTH(T.PRC_TECHNOLOGY_PATH))
 WHERE T.HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no)
 AND MAT_STATUS='00'
			]]>
	</query>	
	<query id="FinishingService.UpdatePath1" desc="修改队列表工艺路径">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,10) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,12, LENGTH(T.PRC_TECHNOLOGY_PATH))
 WHERE T.HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no)
 AND MAT_STATUS='00'
			]]>
	</query>	
	<query id="FinishingService.UpdatePath2" desc="修改队列表工艺路径">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,12) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,14, LENGTH(T.PRC_TECHNOLOGY_PATH))
 WHERE T.HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no)
 AND MAT_STATUS='00'
			]]>
	</query>	

<query id="FinishingService.queryExpandFailNUM1" desc="查询工序废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.FAIL_NUM),0) FAIL_NUM FROM HTT_HLSTRAIGHTEN_RESULT T
WHERE  T.HEAT_PLAN_NO=? 
			]]>
	</query>
	<query id="FinishingService.queryExpandFailNUM2" desc="查询工序废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.FAIL_NUM),0) FAIL_NUM FROM HTT_CLSTRAIGHTEN_RESULT T
WHERE  T.HEAT_PLAN_NO=? 
			]]>
	</query>
	<query id="FinishingService.queryExpandFailNUM3" desc="查询工序废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.FAIL_NUM),0) FAIL_NUM FROM HTT_SIZING_RESULT T
WHERE  T.HEAT_PLAN_NO=? 
			]]>
	</query>

	
	<query id="FinishingService.AddSizingResult" desc="新增定径实绩">
        <![CDATA[
        INSERT INTO HTT_SIZING_RESULT (RESULT_NO, ZY_BATCH_ID, PRO_PLAN_ID, 
GX_PLAN_NO, PRO_NUM, PRO_WT, COL_MODE, COL_TIME, COL_USER, COL_SHIFT, COL_GROUP, 
PLINE_CODE, PLINE_NAME, HEAT_PLAN_NO, CREATE_TIME,FAIL_NUM,FAIL_WT,PROCESS_SEQ,
TEMPERATURE_BEFORE_SIZING,TEMPERATURE_AFTER_SIZING,SIZE_AFTER_SIZING,MEMO)
VALUES (?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
 ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?, (SELECT  NVL(SUM(DEF_FILL_WT),0) FROM HTT_WASTE_RESULT WHERE RESULT_NO = ? ),?,?,?,?,?)
        ]]>
	</query>
	<query id="FinishingService.queryHlsMaxResultNo" desc="查询最大热矫实绩编号">
		<![CDATA[
      SELECT ? ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM HTT_HLSTRAIGHTEN_RESULT
   WHERE RESULT_NO LIKE ? || '______'
			]]>
	</query>
	<query id="FinishingService.queryClsMaxResultNo" desc="查询最大冷矫实绩编号">
		<![CDATA[
     SELECT ? ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM HTT_CLSTRAIGHTEN_RESULT
   WHERE RESULT_NO LIKE ? || '______'
			]]>
	</query>
	<query id="FinishingService.querySizMaxResultNo" desc="查询最大定径实绩编号">
		<![CDATA[
   SELECT ? ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM HTT_SIZING_RESULT
   WHERE RESULT_NO LIKE ? || '______'
			]]>
	</query>
	<query id="FinishingService.updateHlstraightenResult" desc="修改热矫实绩">
		<![CDATA[
UPDATE HTT_HLSTRAIGHTEN_RESULT
   SET ROLL_NUM1        = ?,
       ROLL_NUM2        = ?,
       ROLL_NUM3        = ?,
       BEND_RATE        = ?,
       LSTRAIGHTEN_TEMP = ?,
       PRO_NUM          = ?,
       PRO_WT           = ?,      
       COL_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),  
       COL_SHIFT = ?,
       COL_GROUP = ?,    
       UPDATE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME = ?
 WHERE RESULT_NO = ?
			]]>
	</query>
	<query id="FinishingService.updateClstraightenResult" desc="修改冷矫实绩">
		<![CDATA[
UPDATE HTT_CLSTRAIGHTEN_RESULT
   SET ROLL_NUM1        = ?,
       ROLL_NUM2        = ?,
       ROLL_NUM3        = ?,
       BEND_RATE        = ?,
       LSTRAIGHTEN_TEMP = ?,
       PRO_NUM          = ?,
       PRO_WT           = ?,      
       COL_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),  
       COL_SHIFT = ?,
       COL_GROUP = ?,    
       UPDATE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME = ?
 WHERE RESULT_NO = ?
			]]>
	</query>
	<query id="FinishingService.updateSizingResult" desc="修改定径实绩">
		<![CDATA[
UPDATE HTT_SIZING_RESULT
   SET PRO_NUM     = ?,
       PRO_WT      = ?,
       COL_TIME    = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       COL_SHIFT   = ?,
       COL_GROUP   = ?,
       UPDATE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME = ?
 WHERE RESULT_NO = ?
			]]>
	</query>
	
	<query id="FinishingService.deleteHlstraightenResult" desc="删除热矫实绩">
		<![CDATA[
DELETE HTT_HLSTRAIGHTEN_RESULT WHERE RESULT_NO = ?
			]]>
	</query>
	<query id="FinishingService.deleteClstraightenResult" desc="删除冷矫实绩">
		<![CDATA[
DELETE HTT_CLSTRAIGHTEN_RESULT WHERE RESULT_NO = ?
			]]>
	</query>
	<query id="FinishingService.deleteSizingResult" desc="删除定径实绩">
		<![CDATA[
DELETE HTT_SIZING_RESULT WHERE RESULT_NO = ?
			]]>
	</query>

	<query id="FinishingService.GetSizeResult" desc="热处理定径实绩查询">
		<![CDATA[
          SELECT *
 FROM HTT_SIZING_RESULT
        ]]>
	</query>

	<query id="FinishingService.GetHighResult" desc="热处理热矫实绩查询">
		<![CDATA[
          SELECT *
 FROM HTT_HLSTRAIGHTEN_RESULT
        ]]>
	</query>

	<query id="FinishingService.GetClsResult" desc="热处理冷矫实绩查询">
		<![CDATA[
          SELECT *
 FROM HTT_CLSTRAIGHTEN_RESULT
        ]]>
	</query>

	<query id="FinishingService.getClsOKCountByProcessSeq" desc="查询低温炉合格支数的和">
		<![CDATA[
   SELECT (SELECT NVL(SUM(ACT_COUNT), 0)
          FROM PORT_HTT_BATCH_SAMPLE_RESULT
         WHERE HEAT_PLAN_NO = ?
           AND ((NVL(PROCESS_SEQ, 1) = ? AND (MAT_STATUS = '00' OR OP_PROCESS>= ?)) OR
               NVL(PROCESS_SEQ, 1) > ?)) -
       (SELECT NVL(SUM(PRO_NUM), 0)
          FROM htt_clstraighten_result
         WHERE HEAT_PLAN_NO =?
           AND NVL(PROCESS_SEQ, 1) = ?) COUNT
  FROM DUAL
        ]]>
	</query>

	<query id="FinishingService.getHlsOKCountByProcessSeq" desc="查询低温炉合格支数的和">
		<![CDATA[
   SELECT (SELECT NVL(SUM(ACT_COUNT), 0)
          FROM PORT_HTT_BATCH_SAMPLE_RESULT
         WHERE HEAT_PLAN_NO = ?
           AND ((NVL(PROCESS_SEQ, 1) = ? AND (MAT_STATUS = '00' OR OP_PROCESS>= ?)) OR
               NVL(PROCESS_SEQ, 1) > ?)) -
       (SELECT NVL(SUM(PRO_NUM), 0)
          FROM HTT_HLSTRAIGHTEN_RESULT
         WHERE HEAT_PLAN_NO =?
           AND NVL(PROCESS_SEQ, 1) = ?) COUNT
  FROM DUAL
        ]]>
	</query>

	<query id="FinishingService.getSizeOKCountByProcessSeq" desc="查询低温炉合格支数的和">
		<![CDATA[
   SELECT (SELECT NVL(SUM(ACT_COUNT), 0)
          FROM PORT_HTT_BATCH_SAMPLE_RESULT
         WHERE HEAT_PLAN_NO = ?
           AND ((NVL(PROCESS_SEQ, 1) = ? AND (MAT_STATUS = '00' OR OP_PROCESS>= ?)) OR
               NVL(PROCESS_SEQ, 1) > ?)) -
       (SELECT NVL(SUM(PRO_NUM), 0)
          FROM HTT_SIZING_RESULT
         WHERE HEAT_PLAN_NO =?
           AND NVL(PROCESS_SEQ, 1) = ?) COUNT
  FROM DUAL
        ]]>
	</query>

</queryMap>
