<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="探伤标准">

	<query id="IMscDeteDao.getExamineDic" desc="查询审批探伤索引号">
         <![CDATA[
    SELECT P.DIC, P.MSC, P.MODEL_CODE
  FROM (SELECT T.DIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE, MSC
          FROM COM_MSC_STD_DETECTION T
         WHERE T.MSC = ?
           AND T.CODE_JG IS NULL
           AND T.VALIDFLAG = 3) P
 WHERE INSTR(P.MODEL_CODE, ?) > 0
    OR (P.MODEL_CODE = 'C001' AND NOT EXISTS
        (SELECT 1
           FROM (SELECT T.DIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE, MSC
                   FROM COM_MSC_STD_DETECTION T
                  WHERE T.MSC = ?
                    AND T.CODE_JG IS NULL
                    AND T.VALIDFLAG = 3) Q
          WHERE INSTR(Q.MODEL_CODE, ?) > 0))
 ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="IMscDeteDao.getValidDic" desc="查询有效探伤索引号">
         <![CDATA[
    SELECT P.DIC, P.MSC, P.MODEL_CODE
  FROM (SELECT T.DIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE, MSC
          FROM COM_MSC_STD_DETECTION T
         WHERE T.MSC = ?
           AND T.CODE_JG IS NULL
           AND T.VALIDFLAG != 0) P
 WHERE INSTR(P.MODEL_CODE, ?) > 0
    OR (P.MODEL_CODE = 'C001' AND NOT EXISTS
        (SELECT 1
           FROM (SELECT T.DIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE, MSC
                   FROM COM_MSC_STD_DETECTION T
                  WHERE T.MSC = ?
                    AND T.CODE_JG IS NULL
                    AND T.VALIDFLAG != 0) Q
          WHERE INSTR(Q.MODEL_CODE, ?) > 0))
 ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="IMscDeteDao.getDeteByDic" desc="查詢交付探伤标准">
         <![CDATA[
    SELECT 
       MAX_D,
       MIN_H,
       MAX_H,
       DIC,
       XH,
       PHY_CODE,
       PHY_NAME,
       POSITION_CODE,
       POSITION_DESC,
       STD_DESC,
       LV_CODE,
       GROOVE_POS,
       GROOVE_DIR,
       LV_DESC,
       COVERAGE,
       MEMO,
       RATE,
       DESC_RATE,
       DESC_VAL,
       GROUP_SEQ,
       MIN_D
 FROM COM_MSC_STD_DETECTION_C T
 WHERE  T.DIC=? AND T.VALIDFLAG='1'
             ]]>
	</query>

	<query id="IMscDeteDao.saveDic" desc="保存质量设计探伤标准">
         <![CDATA[
         INSERT INTO SLM_ORD_DESIGN_STD_DIC(
        MIN_D,
        MAX_D,
        MIN_H,
        MAX_H,
        DESGIN_KEY,
        DIC,
        USE_CODE,
        USE_DESC,
        SPECL_FL,
        XH,
        PHY_CODE,
        PHY_NAME,
        POSITION_CODE,
        POSITION_DESC,
        STD_DESC,
        LV_CODE,
        LV_DESC,
        GROOVE_POS,
        GROOVE_DIR,
        COVERAGE,
        RATE,
        DESC_RATE,
        DESC_VAL,
        GROUP_SEQ,
        MEMO)
 VALUES( 
        '#MIN_D#',
        '#MAX_D#',
        '#MIN_H#',
        '#MAX_H#',
        '#DESGIN_KEY#',
        '#DIC#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#SPECL_FL#',
        '#XH#',
        '#PHY_CODE#',
        '#PHY_NAME#',
        '#POSITION_CODE#',
        '#POSITION_DESC#',
        '#STD_DESC#',
        '#LV_CODE#',
        '#LV_DESC#',
        '#GROOVE_POS#',
        '#GROOVE_DIR#',
        '#COVERAGE#',
        '#RATE#',
        '#DESC_RATE#',
        '#DESC_VAL#',
        '#GROUP_SEQ#',
        '#MEMO#')
             ]]>
	</query>

	<query id="IMscDeteDao.updateDesignStd" desc="修改交付标准索引号">
         <![CDATA[
      UPDATE SLM_ORD_DESIGN_STD SET DIC = ? WHERE DESGIN_KEY = ?
             ]]>
	</query>

	<query id="IMscDeteDao.getPhyStyle" desc="查询探伤检验项的类型">
         <![CDATA[
     SELECT T2.PHY_CODE, T2.PHY_TYPE, T1.PHY_CODE, T1.PHY_NAME
  FROM COM_BASE_PHY T1, COM_BASE_PHY_B T2
 WHERE T1.PHY_TYPE = T2.PHY_CODE
   AND T1.PHY_CODE = ?
   AND T1.VALIDFLAG = '1'
   AND T2.VALIDFLAG = '1'
             ]]>
	</query>

	<query id="IMscDeteDao.getStationByPhyCode" desc="查询探伤检验项的类型">
         <![CDATA[
    SELECT PHY_CODE,
       PHY_NAME,
       STATION_CODE,
       STATION_DESC,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       VALIDFLAG,
       MEMO
  FROM COM_BASE_PHY_R_STATION T
 WHERE T.PHY_CODE = ?
   AND T.VALIDFLAG = '1'
             ]]>
	</query>

</queryMap>