<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="加工实绩">

  <query id="MchGroupNo.insertComInfo" desc = "新增长度范围">
  <![CDATA[
	     INSERT INTO MCH_GROUPNO
		  (ORDER_NO,
		   GROUP_MAX,
		   GROUP_MIN,
		   GROUP_NO,
		   GROUP_MAX_SIGN,
		   GROUP_MIN_SIGN,
		   FLAG)
		VALUES
		  (?, ?, ?, ?, '<=', '>=', '1')

  ]]>
  </query>
  
  <query id="MchGroupNo.updateComInfo" desc = "新增长度范围">
  <![CDATA[
    UPDATE MCH_GROUPNO
     set GROUP_MAX = ? and GROUP_MIN = ?
   where ORDER_NO = ?
     and GROUP_NO = ?

  ]]>
  </query>
  

	<query id="MchComm.queryComInfo" desc="查询公共信息">
		<![CDATA[
		SELECT *
  FROM MCH_COM_INFO T
 WHERE T.HEAT_PLAN_NO =?
   AND T.BATCH_NO =?
   AND T.STATION_CODE =?
			]]>
	</query>

	<query id="MchComm.queryLoadNewResultNo" desc="查询上料实绩最大实绩编号">
		<![CDATA[
		  SELECT ? || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM  MCH_LOADING_RESULT
   WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
			]]>
	</query>


	<query id="MchComm.queryMatInfo" desc="查询库存信息">
		<![CDATA[
		 SELECT T1.*
	FROM (SELECT T.MAT_NO,
	T.PRODUCT_FLAG,
	T.MAT_STATUS,
	T.JUDGE_STOVE_NO,
	T.BATCH_NO,
	T.BATCH_GROUD_NO,
	T.MATERIAL_NO,
	T.MATERIAL_NAME,
	T.PRODUCCODE,
	T.PRODUCNAME,
	T.STEELCODE,
	T.STEELNAME,
	T.GRADECODE,
	T.GRADENAME,
	T.SPEC_CODE,
	T.SPEC_NAME,
	T.MODEL_CODE,
	T.MODEL_DESC,
	T.STD_CODE,
	T.STD_NAME,
	T.STD_STYLE,
	T.STD_STYLE_DESC,
	T.ORDER_NO,
	T.ORDER_SEQ,
	T.ORDER_SEQ_NO,
	T.PROCESS_CDOE,
	T.PROCESS_DESC,
	T.PLINE_CODE,
	T.PLINE_NAME,
	T.MAT_ORIGIN_CODE,
	T.MAT_ORIGIN_NAME,
	T.ACT_DIMATER,
	T.ACT_HEIGHT,
	T.ACT_LEN,
	T.ACT_LEN_MIN,
	T.ACT_LEN_MAX,
	T.ACT_COUNT,
	T.ACT_WEIGHT,
	T.ACT_THEORY_WEIGHT,
	T.BELONG_CODE,
	T.BELONG_NAME,
	T.LOCK_FLAG,
	T.ORD_PK,
	T.ORD_LN_PK,
	SUBSTR(T.ORD_LN_DLY_PK, 0, INSTR(T.ORD_LN_DLY_PK, '-') - 1) ORD_LN_DLY_PK,
	T.BAL_YEAR_MONTH,
	T.JUDGE_STD_NAME,
	T.JUDGE_STD_DES,
	T.SOURE_CODE,
	T.SOURE_NAME,
	T.MNG_LOCK_FLAG,
	B.STORAGE_NO,
	B.LOCATION_NO,
	B.LARY_NO,
	B.LOC_NO,
	B.STORAGE_ATTR,
	B.STORAGE_ATTR_NAME,
	B.STORAGE_TYPE_NO,
	B.STORAGE_TYPE_NAME,
	B.MANAGEMENT_NO,
	B.MANAGEMENT_NAME,
	B.DEPARTMENT_CODE,
	B.DEPARTMENT_DESC,
	T.STOVE_NO
	FROM MAT_BC_M T, YDM_BC_BUTTRESS B
	WHERE T.MAT_NO = B.MAT_NO
	AND T.PRODUCT_FLAG = '801401'
	AND T.MAT_STATUS = '80150103'
	AND T.JUDGE_STOVE_NO = ?
	AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
	AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
	--    AND  B.MANAGEMENT_NO IN
	-- (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
	-- AND STORAGE_ATTR = '800302'
	AND T.NEXT_PROCESS_CDOE = 'G'
	ORDER BY NVL(T.LOCK_FLAG,'0'),NVL(T.MNG_LOCK_FLAG,'0'),  T.MAT_NO ASC) T1
	WHERE ROWNUM < ?
			]]>
	</query>


	<query id="MchComm.doBeside" desc="修改工序状态为结炉">
		<![CDATA[
		UPDATE MCH_COM_INFO
 SET STATION_STATUS = ?,
  BESIDE_TIME =NULL,
  UPDATE_NAME = ''
WHERE HEAT_PLAN_NO = ?
 AND BATCH_NO = ?
 AND STATION_CODE = ?

			]]>
	</query>
	<query id="MchComm.doBeside1" desc="修改工序状态为结炉">
		<![CDATA[
		UPDATE MCH_COM_INFO
 SET STATION_STATUS = ?,
  BESIDE_TIME = SYSDATE,
  UPDATE_NAME = ?
WHERE HEAT_PLAN_NO = ?
 AND BATCH_NO = ?
 AND STATION_CODE = ?

			]]>
	</query>


	<query id="MchComm.doPlnBeside" desc="修改计划表结炉状态">
		<![CDATA[
 UPDATE pln_zy_jgx_c SET BESIDE_STATUS = ? WHERE HEAT_PLAN_NO = ? AND BATCH_NO =?
	]]>
	</query>


	<query id="MchComm.doPlnBeside1" desc="修改计划表结炉状态">
		<![CDATA[
 UPDATE pln_zy_jgx_c T SET CHECK_RESULT =  ? WHERE HEAT_PLAN_NO = ? AND BATCH_NO =?
	]]>
	</query>


	<query id="MchComm.canBeside" desc="查询检验状态">
		<![CDATA[
 SELECT    (DECODE((SELECT COUNT(1)
                 FROM MCH_FINAL_CHECK_TREATMENT
                WHERE RESULT_NO IN
                      (SELECT RESULT_NO
                         FROM MCH_FINAL_CHECK_RESULT
                        WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
                          AND BATCH_NO = T.BATCH_NO)
                  AND APPROVAL_STATUS != '2'),
               0,
               DECODE((SELECT COUNT(1)
                        FROM PORT_MCH_BATCH_SAMPLE_RESULT
                       WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
                         AND BATCH_NO = T.BATCH_NO
                         AND IS_FINALCHECK = '0'
                         AND VALIDFLAG ='1'
                         AND (MAT_STATUS = '00' OR MAT_STATUS = '20')),
                      0,
                      DECODE((SELECT COUNT(1)
                               FROM MCH_FINAL_CHECK_TREATMENT
                              WHERE RESULT_NO IN
                                    (SELECT RESULT_NO
                                       FROM MCH_FINAL_CHECK_RESULT
                                      WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
                                        AND BATCH_NO = T.BATCH_NO)
                                AND APPROVAL_STATUS = '2'),
                             0,
                             '1',
                             '2'),
                      ''),
               '0'))  STATUS FROM PLN_ZY_JGX_C T  WHERE HEAT_PLAN_NO = ? AND BATCH_NO =?  AND ROWNUM =1
	]]>
	</query>

	<query id="MchComm.doPlnBeside2" desc="修改计划表结炉状态">
		<![CDATA[
 UPDATE pln_zy_jgx_c SET CHECK_RESULT = '' WHERE HEAT_PLAN_NO = ? AND BATCH_NO =?
	]]>
	</query>

	<query id="MchComm.GetMchPrcoess" desc="修改计划表结炉状态">
		<![CDATA[
         SELECT * FROM MCH_COM_SETPLINE WHERE PLINE_CODE =?
	]]>
	</query>

	<query id="MchComm.getUnCheckCout" desc="修改计划表结炉状态">
		<![CDATA[
         SELECT COUNT(1) COUNT
  FROM PORT_MCH_BATCH_SAMPLE_RESULT P
 WHERE HEAT_PLAN_NO = ?
   AND BATCH_NO = ?
   AND (SELECT COUNT(1)
          FROM MCH_FINAL_CHECK_RESULT R, MCH_FINAL_CHECK_RESULT_MAT_NO R1
         WHERE R.RESULT_NO = R1.RESULT_NO
           AND R.HEAT_PLAN_NO = P.HEAT_PLAN_NO
           AND R.BATCH_NO = P.PHY_BATCH_NO
           AND P.MAT_NO = R1.MAT_NO) = '0'
   AND VALIDFLAG = '1'
   AND (MAT_STATUS = '00' OR MAT_STATUS = '20')

	]]>
	</query>


</queryMap>