<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍切割作业实绩">
	<query id="OfflineHelper.QueryHttCanOffLineData" desc="产线">
		<![CDATA[
  SELECT M.*, T1.PHY_BATCH_NO, T1.ACT_COUNT, T1.ACT_WEIGHT
  FROM PLN_ZY_RCL_M M
  LEFT JOIN (SELECT NVL(COUNT(1), 0) ACT_COUNT,
                    SUM(ACT_WEIGHT) ACT_WEIGHT,
                    HEAT_PLAN_NO,
                    PROCESS_SEQ,
                    PHY_BATCH_NO
               FROM PORT_HTT_BATCH_SAMPLE_RESULT T
              WHERE MAT_STATUS = '00'
              GROUP BY T.HEAT_PLAN_NO, T.PROCESS_SEQ, PHY_BATCH_NO) T1
    ON T1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
   AND M.REAL_PROCESS_SEQ = T1.PROCESS_SEQ
 WHERE PLANSTATUS = '20'
   AND ACT_COUNT > 0
		]]>
	</query>

	<query id="OfflineHelper.QueryVrpCanOffLineData" desc="产线">
		<![CDATA[
SELECT M.*, T1.PHY_BATCH_NO, T1.ACT_COUNT, T1.ACT_WEIGHT
  FROM PLN_ZY_DBK_M M
  LEFT JOIN (SELECT NVL(COUNT(1), 0) ACT_COUNT,
                    SUM(ACT_WEIGHT) ACT_WEIGHT,
                    HEAT_PLAN_NO,
                    PHY_BATCH_NO
               FROM PORT_VRP_BATCH_SAMPLE_RESULT T
              WHERE MAT_STATUS = '00'
              GROUP BY T.HEAT_PLAN_NO, PHY_BATCH_NO) T1
    ON T1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
 WHERE PLANSTATUS = '20'
   AND ACT_COUNT > 0
		]]>
	</query>

	<query id="OfflineHelper.QueryReturnLineCount" desc="产线">
		<![CDATA[
SELECT NVL(SUM(RE_NUM),0) COUNT
  FROM HTT_OFFLINE_RESULT
 WHERE HEAT_PLAN_NO = ?
   AND PROCESS_SEQ =?
   AND Return_Process <= ?
   AND station_code >= ?
   AND  RETURN_PROCESS <> STATION_CODE
  AND GROUP_LOG = '0'
		]]>
	</query>

	<query id="OfflineHelper.QueryReturnLineCount2" desc="产线">
		<![CDATA[
SELECT NVL(SUM(RE_NUM),0) COUNT
  FROM HTT_OFFLINE_RESULT
 WHERE HEAT_PLAN_NO = ?
   AND PROCESS_SEQ =?
   AND Return_Process <= ?
   AND station_code >= ?
  AND BATCH_NO =?   
  AND  RETURN_PROCESS <> STATION_CODE
  AND GROUP_LOG = '0'
		]]>
	</query>

	<query id="OfflineHelper.getMatBcM" desc="">
		<![CDATA[
SELECT M.*, B.STORAGE_NO, T.IS_RETURN  FLAG
  FROM YDM_BC_BUTTRESS B, MAT_BC_M M
  LEFT JOIN HTT_ENTRUST T
    ON M.SUBCONTRACT_NO = T.SUBCONTRACT_NO
   AND M.SUBCONTRACT_NO_SEQ = T.SUBCONTRACT_NO_SEQ
 WHERE M.MAT_NO = B.MAT_NO
   AND M.MAT_NO = ?

		]]>
	</query>


	<query id="OfflineHelper.getMatZcM" desc="">
		<![CDATA[
SELECT M.*, B.STORAGE_NO
  FROM YDM_ZC_BUTTRESS B, MAT_ZC_M M
 WHERE M.MAT_NO = B.MAT_NO
   AND M.MAT_NO = ?
	]]>
	</query>

		<query id="OfflineHelper.getMatBcMJg" desc="">
		<![CDATA[
SELECT * FROM coupling_mat_m WHERE WO_ID = ? and RESULT_NO = ?
		]]>
	</query>

	<query id="OfflineHelper.InsertMchOffline" desc="">
		<![CDATA[
INSERT INTO MCH_OFFLINE_RESULT
  (RESULT_NO,
   PLINE_CODE,
   PLINE_NAME,
   STATION_CODE,
   STATION_DESC,
   HEAT_PLAN_NO,
   ZY_BATCH_ID1,
   ZY_BATCH_ID,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   FLAG_STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ZP_JUDGE_STOVE_NO,
   ZP_BATCH_NO,
   OFFLINE_NUM,
   OFFLINE_WT,
   ORD_LN_DLY_PK,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   OUTNUM_CUT,
   MEMO,
   LOAD_JUDGE_STOVE_NO)
  SELECT ?,
         ?,
         ?,
         ?,
         (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ?),
         M.HEAT_PLAN_NO,
         M.ZY_BATCH_ID,
         M.ZY_BATCH_ID,
         M.PRO_PLAN_ID,
         M.GX_PLAN_NO,
         T.FLAG_STOVE_NO,
         T.JUDGE_STOVE_NO,
         NVL(T.PHY_BATCH_NO,T.BATCH_NO),
         T.GROUP_NO,
         M.PRODUCCODE,
         M.PRODUCNAME,
         M.STEELCODE,
         M.STEELNAME,
         M.GRADECODE,
         M.GRADENAME,
         M.MODEL_CODE,
         M.MODEL_DESC,
         M.STD_CODE,
         M.STD_NAME,
         M.STD_STYLE,
         M.STD_STYLE_DESC,
         T.ACT_DIMATER,
         T.ACT_HEIGHT,
         T.ACT_LEN,
         NVL(?, T.ACT_LEN_MIN),
         NVL(?, T.ACT_LEN_MAX),
         '',
         '',
         ?,
         ?,
         M.ORD_LN_DLY_PK,
         M.ORDER_NO,
         M.ORDER_SEQ,
         M.DELIVERY_NO,
         ?,
         ?,
         ?,
         SYSDATE,
         T.OUTNUM_CUT,
         ?,
         M.FEED_HEAT_NO
    FROM PLN_ZY_JGX_M M
    LEFT JOIN PORT_MCH_BATCH_SAMPLE_RESULT T
      ON T.HEAT_PLAN_NO = M.HEAT_PLAN_NO
     AND T.MAT_NO = ?
   WHERE T.HEAT_PLAN_NO = ?

		]]>
	</query>


	<query id="OfflineHelper.queryPortMch" desc="查询管号队列合格数据">
		<![CDATA[
        SELECT T.*
          FROM PORT_MCH_BATCH_SAMPLE_RESULT T
         WHERE  T.MAT_STATUS = '00'
           AND T.INSTORE_FLAG = '0'
           AND T.HEAT_PLAN_NO = ?
           AND NVL(PHY_BATCH_NO,'/') = NVL(?,'/')
			]]>
	</query>

	<query id="OfflineHelper.UpdatePathPortMch" desc="修改队列表材料状态，工序状态,离线状态">
		<![CDATA[
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT T
   SET
       T.MAT_STATUS          = ?,
       T.LEVE_LOG            = ?,
       T.OP_PROCESS          = ?,
       RESULT_NO             = ?
 WHERE T.HEAT_PLAN_NO = ?
   AND T.MAT_NO=?
   AND MAT_STATUS = '00'

			]]>
	</query>

	<query id="OfflineHelper.queryOffMaxRESULT1" desc="查询离线最大实绩编号">
		<![CDATA[
                 	SELECT ? ||
	LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
	0) + 1,
	6,
	'0') RESULT_NO
	FROM MCH_OFFLINE_RESULT
	WHERE RESULT_NO LIKE ? || '______'
		]]>
	</query>


	<query id="OfflineHelper.QueryMchOffLineData" desc="查询离线最大实绩编号">
		<![CDATA[
                 	SELECT *
	FROM MCH_OFFLINE_RESULT
	WHERE HEAT_PLAN_NO=? AND BATCH_NO =?
		]]>
	</query>
</queryMap>