<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="探伤要求管理">

 <query id="ComMSCStdDetection.CancelGroupSeq" desc="更新分组索引号">
        <![CDATA[      
            UPDATE COM_MSC_STD_DETECTION_C  SET GROUP_SEQ=''
            WHERE DIC=? AND XH=? AND VALIDFLAG='1'
	     ]]>
</query>
	  
 <query id="ComMSCStdDetection.SetGroupSeq" desc="更新分组索引号">
        <![CDATA[      
            UPDATE COM_MSC_STD_DETECTION_C  SET GROUP_SEQ=?
            WHERE DIC=? AND XH=? AND VALIDFLAG='1'
	     ]]>
</query>
<query id="ComMSCStdDetection.GetGroupSeq" desc="取得分组索引号">
        <![CDATA[      
            SELECT MAX(GROUP_SEQ) GROUP_SEQ FROM COM_MSC_STD_DETECTION_C WHERE DIC=?   
	     ]]>
</query>
	  
	<query id="ComMSCStdDetection.GETMAXDICG" desc="主表 查询最大探伤索引号 交付标准">
		<![CDATA[
SELECT MAX(SUBSTR(DIC, 5, 6)) DIC FROM COM_MSC_STD_DETECTION WHERE STDSTYLE IN ('G','X')
		]]>
	</query>
	
	<query id="ComMSCStdDetection.GETMAXDICN" desc="主表 查询最大探伤索引号 内控标准">
		<![CDATA[
SELECT MAX(SUBSTR(DIC, 5, 6)) DIC FROM COM_MSC_STD_DETECTION WHERE STDSTYLE='N'
		]]>
	</query>
	
	<query id="ComMSCStdDetection.GETMAXDICL" desc="主表 查询最大探伤索引号 内控标准">
		<![CDATA[
		SELECT DIC
          FROM COM_MSC_STD_DETECTION
         WHERE DIC = (SELECT MAX(DIC) DIC FROM COM_MSC_STD_DETECTION WHERE STDSTYLE='N')
		]]>
	</query>
	
	<query id="ComMSCStdDetection.GETMAXDICK" desc="主表 查询最大探伤索引号 Alpha">
		<![CDATA[
SELECT MAX(SUBSTR(DIC, 5, 6)) DIC FROM COM_MSC_STD_DETECTION WHERE STDSTYLE='K'
		]]>
	</query>
	
	<query id="ComMSCStdDetection.GETMAXDICS" desc="主表 查询最大探伤索引号 其它标准">
		<![CDATA[
SELECT MAX(SUBSTR(DIC, 5, 6)) DIC FROM COM_MSC_STD_DETECTION WHERE STDSTYLE IN ('P','S')
		]]>
	</query>
	
    <query id="ComMSCStdDetection.QUERYG" desc="主表 查询交付标准">
		<![CDATA[
SELECT *
  FROM (SELECT D.DIC,
               D.PSC,
               D.MSC,
               NVL(P.PSC_DESC,
                   E.PRODUCNAME || ',' || E.STD_NAME || ',' || E.STEELNAME || ',' ||
                   E.STD_STYLE_DESC || ',' || E.MODEL_DESC || ',' || E.MIN_D || ',' ||
                   E.MIN_H || ',' || E.USE_DESC) PSC_DESC,
               DECODE(D.STDSTYLE, 'G', '订货标准', '协议标准') STDSTYLE,
               D.PROCESS_CODE,
               D.PROCESS_DESC,
               D.MODEL_CODE,
               D.MODEL_DESC,
               D.CREATE_NAME,
               TO_CHAR(D.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
               D.UPDATE_NAME,
               TO_CHAR(D.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
               D.DELETE_NAME,
               TO_CHAR(D.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
               DECODE(D.VALIDFLAG, '1', '录入状态','0', '无效','2','提交审核','3','已审核') VALIDFLAG,
               D.MEMO,
               D.PRODUC_HEAD,
               NVL(P.PRODUCNAME, E.PRODUCNAME) PRODUCNAME,
               NVL(P.STD_NAME, E.STD_NAME) STD_NAME,
               NVL(P.STEELNAME, E.STEELNAME) STEELNAME,
               NVL(P.STD_STYLE_DESC, E.STD_STYLE_DESC) STD_STYLE_DESC
          FROM COM_MSC_STD_DETECTION D
          LEFT JOIN COM_PSC P ON D.PSC = P.PSC
          LEFT JOIN COM_MSC_BL E ON d.PSC = E.PSC_BL 
         WHERE LOWER(D.MSC) || '&' LIKE '%' || LOWER('#MSC#') || '%' AND
          D.VALIDFLAG IN ('1','2','3', '#VALIDFLAG#') AND D.STDSTYLE IN ('G', 'X') 
          AND DECODE('#STD_CODE_NK#', NULL, '1', D.STD_CODE_NK) = DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
          AND DECODE('#DIC#', NULL, '1', D.DIC) = DECODE('#DIC#', NULL, '1', '#DIC#')
          AND DECODE('#MSC2#', NULL, '1', D.MSC) = DECODE('#MSC2#', NULL, '1', '#MSC2#')
          AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', D.CODE_JG) = DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
          AND DECODE('#CODE_JG#', NULL, D.CODE_JG, NULL) IS NULL)
 WHERE LOWER(STD_NAME) || '&' LIKE '%' || LOWER('#STD_NAME#') || '%'
 ORDER BY DIC
		]]>
	</query>
	
	<query id="ComMSCStdDetection.QUERYN" desc="主表 查询内控标准">
		<![CDATA[
SELECT DIC,
       DECODE(STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       PROCESS_CODE,
       PROCESS_DESC,
       STD_CODE_NK,
       STD_NAME_NK,
       MODEL_CODE,
       MODEL_DESC,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       MEMO,
       PRODUC_HEAD,
       STEELCODE_NK,
       STEELNAME_NK,
       MODEL_CODE_NK,
       MODEL_DESC_NK,
       PRODUCCODE_NK,
       PRODUCNAME_NK,
       STD_CODE_S_NK,
       STD_NAME_S_NK,
       STD_STYLE_S_NK,
       STD_STYLE_DESC_S_NK
  FROM COM_MSC_STD_DETECTION T
 WHERE lower(STD_NAME_NK) || '&' LIKE '%' || lower('#STD_NAME_NK#') || '%'
   AND VALIDFLAG in ('1', '2', '3', '#VALIDFLAG#')
   AND DECODE('#STD_CODE_NK#', NULL, '1', STD_CODE_NK) =
       DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
   AND DECODE('#DIC#', NULL, '1', DIC) =
       DECODE('#DIC#', NULL, '1', '#DIC#')
   AND DECODE('#MSC2#', NULL, '1', MSC) =
       DECODE('#MSC2#', NULL, '1', '#MSC2#')
   AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', CODE_JG) =
       DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
   AND DECODE('#CODE_JG#', NULL, CODE_JG, NULL) IS NULL
   AND NVL(INSTR(PRODUCCODE_NK, '#PRODUCCODE_NK#'), 1) > 0
   AND NVL(INSTR(STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
   AND NVL(INSTR(STD_CODE_S_NK, '#STD_CODE_S_NK#'), 1) > 0
   AND NVL(INSTR(PROCESS_CODE, '#PROCESS_CODE#'), 1) > 0
   AND NVL(INSTR(T.MODEL_CODE_NK, '#MODEL_CODE_NK#'), 1) > 0
   AND (NVL(INSTR(STD_STYLE_S_NK, NVL('#STD_STYLE_S_NK#', '1')), 1) > 0 OR
        (STD_STYLE_S_NK IS NULL AND '#STD_STYLE_S_NK#' IS NULL) OR
        '#IS_NK_EDITE#' = '1')
   AND STDSTYLE IN
       (DECODE('#STDSTYLE#', '2', 'N', '3', 'K', 'P'),
        DECODE('#STDSTYLE#', '2', '', '3', '', 'S'))
 ORDER BY DIC
		]]>
	</query>
	
	<query id="ComMSCStdDetection.QUERYK" desc="主表 查询Alpha标准">
		<![CDATA[
		SELECT DIC,
               DECODE(STDSTYLE,'K','Alpha','') STDSTYLE,
               PROCESS_CODE,
               PROCESS_DESC,
               STD_CODE_NK,
               STD_NAME_NK,
               MODEL_CODE,
               MODEL_DESC,
               CREATE_NAME,
               TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
               UPDATE_NAME,
               TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
               DELETE_NAME,
               TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
               DECODE(VALIDFLAG, '1', '录入状态','0', '无效','2','提交审核','3','已审核') VALIDFLAG,
               MEMO
          FROM COM_MSC_STD_DETECTION
         WHERE lower(STD_NAME_NK) || '&' LIKE '%' || lower(?) || '%'
           AND VALIDFLAG in ('1','2','3', ?)
           AND STDSTYLE='K'
      ORDER BY DIC
		]]>
	</query>
	
	<query id="ComMSCStdDetection.QUERYS" desc="主表 查询其它标准">
		<![CDATA[
		SELECT DIC,
               DECODE(STDSTYLE,'P','成分偏差标准','试验标准') STDSTYLE,
               PROCESS_CODE,
               PROCESS_DESC,
               STD_CODE_NK,
               STD_NAME_NK,
               MODEL_CODE,
               MODEL_DESC,
               CREATE_NAME,
               TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
               UPDATE_NAME,
               TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
               DELETE_NAME,
               TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
               DECODE(VALIDFLAG, '1', '录入状态','0', '无效','2','提交审核','3','已审核') VALIDFLAG,
               MEMO
          FROM COM_MSC_STD_DETECTION
         WHERE lower(STD_NAME_NK) || '&' LIKE '%' || lower(?) || '%'
           AND VALIDFLAG in ('1','2','3', ?)
           AND STDSTYLE IN ('P','S')
      ORDER BY DIC
		]]>
	</query>
	
	<query id="ComMSCStdDetection.ADD" desc="主表 增加">
		<![CDATA[
		INSERT INTO COM_MSC_STD_DETECTION
                    (DIC,
                     PSC,
                     MSC,
                     STDSTYLE,
                     PROCESS_CODE,
                     PROCESS_DESC,
                     STD_CODE_NK,
                     STD_NAME_NK,
                     MODEL_CODE,
                     MODEL_DESC,
                     CREATE_NAME,
                     CREATE_TIME,
                     VALIDFLAG,
                     MEMO,
                     PRODUC_HEAD,
                     CODE_JG,
                     STEELCODE_NK,
                     STEELNAME_NK,
                     MODEL_CODE_NK,
                     MODEL_DESC_NK,
                     PRODUCCODE_NK,
                     PRODUCNAME_NK,
                     STD_CODE_S_NK,
                     STD_NAME_S_NK,
                     STD_STYLE_S_NK,
                     STD_STYLE_DESC_S_NK)
              VALUES
                     (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, DEFAULT, ?, ?,?,
                     ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
		]]>
	</query>
	
	
    <query id="ComMSCStdDetection.UPDATE" desc="主表修改">
		<![CDATA[
		UPDATE COM_MSC_STD_DETECTION
   SET DIC          = ?,
       PSC          = ?,
       MSC          = ?,
       STDSTYLE     = ?,
       PROCESS_CODE = ?,
       PROCESS_DESC = ?,
       STD_CODE_NK  = ?,
       STD_NAME_NK  = ?,
       MODEL_CODE   = ?,
       MODEL_DESC   = ?,
       UPDATE_NAME  = ?,
       UPDATE_TIME  =SYSDATE,
       MEMO         = ?,
       PRODUC_HEAD = ?,
       CODE_JG = ?,
       STEELCODE_NK = ?,
       STEELNAME_NK = ?,
       MODEL_CODE_NK = ?,
       MODEL_DESC_NK = ?,
       PRODUCCODE_NK = ?,
       PRODUCNAME_NK = ?,
       STD_CODE_S_NK = ?,
       STD_NAME_S_NK = ?,
       STD_STYLE_S_NK = ?,
       STD_STYLE_DESC_S_NK = ?
 WHERE DIC = ?
		]]>
	</query>
	
	<query id="ComMSCStdDetection.DELETE" desc="主表刪除">
		<![CDATA[
		UPDATE COM_MSC_STD_DETECTION
   SET VALIDFLAG = '0', DELETE_NAME = ?, DELETE_TIME = SYSDATE
 WHERE DIC = ?  AND VALIDFLAG ='1'			
		]]>
	</query>
	
	<query id="ComMSCStdDetection.RESUME" desc="主表恢復">
		<![CDATA[
		UPDATE COM_MSC_STD_DETECTION
   SET VALIDFLAG = '1', DELETE_NAME = '', DELETE_TIME =NULL
 WHERE DIC = ?	AND VALIDFLAG ='0'	
		]]>
	</query>
	
	
	<query id="ComMSCStdDetection.QUERYOTHERC" desc="从表查询">
		<![CDATA[
SELECT A.DIC,
       A.XH,
       A.PHY_CODE,
       A.PHY_NAME,
       A.POSITION_CODE,
       A.POSITION_DESC,
       A2.BASENAME STD_DESC,
       A.STD_DESC STD_CODE,
       A.LV_CODE,
       A.LV_DESC,
       A.COVERAGE,
       A.GROOVE_POS,
       A.GROOVE_DIR,
       A.RATE,
       A.DESC_RATE,
       A.DESC_VAL,
       A.GROUP_SEQ,
       A.MIN_D,
       A.MAX_D,
       A.MIN_H,
       A.MAX_H,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
       A.MEMO
  FROM COM_MSC_STD_DETECTION_C A
  LEFT JOIN COM_BASE_INFO A2
  ON A2.BASECODE = A.STD_DESC
 WHERE A.VALIDFLAG IN ('1', '#VALIDFLAG#')
   AND EXISTS
 (SELECT 1
          FROM COM_MSC_STD_DETECTION B
         WHERE B.VALIDFLAG IN ('1', '2', '3', '#VALIDFLAG#')
           AND DECODE('#STD_CODE_NK#', NULL, '1', B.STD_CODE_NK) =
               DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
           AND DECODE('#MSC#', NULL, '1', B.MSC) =
               DECODE('#MSC#', NULL, '1', '#MSC#')
           AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', B.CODE_JG) =
               DECODE('#CODE_JG#',
                      NULL,
                      '1',
                      'DefaultValue',
                      '1',
                      '#CODE_JG#')
           AND DECODE('#CODE_JG#', NULL, B.CODE_JG, NULL) IS NULL
           AND NVL(INSTR(B.PRODUCCODE_NK, '#PRODUCCODE_NK#'), 1) > 0
           AND NVL(INSTR(B.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
           AND NVL(INSTR(B.PROCESS_CODE, '#PROCESS_CODE#'), 1) > 0
           AND NVL(INSTR(B.MODEL_CODE_NK, '#MODEL_CODE_NK#'), 1) > 0
           AND B.STDSTYLE NOT IN ('G', 'X')
           AND A.DIC = B.DIC)
		]]>
	</query>
	
	<query id="ComMSCStdDetection.QUERYGC" desc="从表查询">
		<![CDATA[
		SELECT A.DIC,
       A.XH,
       A.PHY_CODE,
       A.PHY_NAME,
       A.POSITION_CODE,
       A.POSITION_DESC,
       A2.BASENAME STD_DESC,
       A.STD_DESC STD_CODE,
       A.LV_CODE,
       A.LV_DESC,
       A.COVERAGE,
       A.GROOVE_POS,
       A.GROOVE_DIR,
       A.RATE,
       A.DESC_RATE,
       A.DESC_VAL,
       A.GROUP_SEQ,
       A.MIN_D,
       A.MAX_D,
       A.MIN_H,
       A.MAX_H,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME,'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME,'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(A.VALIDFLAG,'1','有效','无效') VALIDFLAG,
       A.MEMO
  FROM COM_MSC_STD_DETECTION_C A
  LEFT JOIN COM_BASE_INFO A2
  ON A2.BASECODE = A.STD_DESC
  WHERE A.VALIDFLAG IN ('1', '#VALIDFLAG#')
  AND EXISTS
    (SELECT 1
       FROM COM_MSC_STD_DETECTION B
      WHERE B.VALIDFLAG IN ('1','2','3', '#VALIDFLAG#')
        AND DECODE('#STD_CODE_NK#', NULL, '1', B.STD_CODE_NK) = DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
        AND DECODE('#MSC#', NULL, '1', B.MSC) = DECODE('#MSC#', NULL, '1', '#MSC#')
        AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', B.CODE_JG) = DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
	    AND DECODE('#CODE_JG#', NULL, B.CODE_JG, NULL) IS NULL
	    AND NVL(INSTR(B.PRODUCCODE_NK, '#PRODUCCODE_NK#'), 1) > 0
	    AND NVL(INSTR(B.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
	    AND B.STDSTYLE IN ('G', 'X')
        AND A.DIC = B.DIC)
		]]>
	</query>
	
	<query id="ComMSCStdDetection.GETMAXXH" desc="从表查询最大序号">
		<![CDATA[
		SELECT XH
          FROM COM_MSC_STD_DETECTION_C
         WHERE XH = (SELECT MAX(XH) XH FROM COM_MSC_STD_DETECTION_C WHERE DIC=?)
		]]>
	</query>
	
	<query id="ComMSCStdDetection.ADD1" desc="从表增加">
		<![CDATA[
		INSERT INTO COM_MSC_STD_DETECTION_C
  (DIC,
   XH,
   PHY_CODE,
   PHY_NAME,
   POSITION_CODE,
   POSITION_DESC,
   STD_DESC,
   LV_CODE,
   LV_DESC,
   COVERAGE,
   GROOVE_POS,
   GROOVE_DIR,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO,
   RATE,
   DESC_RATE,
   DESC_VAL,
   MIN_D,
   MAX_D,
   MIN_H,
   MAX_H,
   GROUP_SEQ
   )
VALUES
  (?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?,?, SYSDATE, DEFAULT, ?,?,?,?,
  ?, ?, ?, ?, ?)
		]]>
	</query>
	
	<query id="ComMSCStdDetection.UPDATE1" desc="从表修改">
		<![CDATA[
		UPDATE COM_MSC_STD_DETECTION_C
   SET DIC           = ?,
       XH            = ?,
       PHY_CODE      = ?,
       PHY_NAME      = ?,
       POSITION_CODE = ?,
       POSITION_DESC = ?,
       STD_DESC      = ?,
       LV_CODE       = ?,
       LV_DESC       = ?,
       COVERAGE      = ?,
       GROOVE_POS    = ?,
       GROOVE_DIR    = ?,
       UPDATE_NAME   = ?,
       UPDATE_TIME   = SYSDATE,
       MEMO          = ?,
       RATE          = ?,
       DESC_RATE     = ?,
       DESC_VAL      = ?,
       MIN_D = ?,
       MAX_D = ?,
       MIN_H = ?,
       MAX_H = ?,
       GROUP_SEQ = ?
 WHERE DIC = ?  AND XH = ? AND VALIDFLAG='1'
		]]>
	</query>
	
	<query id="ComMSCStdDetection.DELETE1" desc="从表删除">
		<![CDATA[
		UPDATE COM_MSC_STD_DETECTION_C
   SET VALIDFLAG = '0', DELETE_NAME = ?, DELETE_TIME =SYSDATE
   WHERE DIC = ?	AND XH=?  AND VALIDFLAG='1'
   AND (SELECT VALIDFLAG FROM COM_MSC_STD_DETECTION 
       WHERE DIC = ?) IN ('1', '0')
		]]>
	</query>
	
	<query id="ComMSCStdDetection.RESUME1" desc="从表恢复">
		<![CDATA[
		UPDATE COM_MSC_STD_DETECTION_C
    SET VALIDFLAG = '1', DELETE_NAME ='', DELETE_TIME =NULL
    WHERE DIC = ?	AND XH=? AND VALIDFLAG!='1'
		]]>
	</query>
	
	<query id="ComMSCStdDetection.getComDicByDic" desc="通过DIC查询探伤表">
		<![CDATA[
SELECT * FROM Com_Msc_Std_Detection T WHERE T.DIC = '#DIC#'
		]]>
	</query>
	
	<query id="ComMSCStdDetection.getStationByPhyCode" desc="通过检验项获取工序点">
		<![CDATA[
SELECT DISTINCT A.PROCESS_CODE, A.PROCESS_DESC
  FROM COM_BASE_PHY_R_STATION T, COM_BASE_STATION A
 WHERE T.PHY_CODE = '#PHY_CODE#'
   AND T.STATION_CODE = A.STATION_CODE
		]]>
	</query>
	<query id="ComMSCStdDetection.getPurchaseAgreementDic" desc="获取采购的探伤主表">
		<![CDATA[
SELECT A.DIC,
       DECODE(A.STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       A.PROCESS_CODE,
       A.PROCESS_DESC,
       A.STD_CODE_NK,
       A.STD_NAME_NK,
       A.MODEL_CODE,
       A.MODEL_DESC,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(A.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       A.MEMO,
       A.PRODUC_HEAD,
       A.STEELCODE_NK,
       A.STEELNAME_NK,
       A.MODEL_CODE_NK,
       A.MODEL_DESC_NK,
       A.PRODUCCODE_NK,
       A.PRODUCNAME_NK,
       A.STD_CODE_S_NK,
       A.STD_NAME_S_NK,
       A.STD_STYLE_S_NK,
       A.STD_STYLE_DESC_S_NK
  FROM COM_MSC_STD_DETECTION A, COM_BASE_STD C
 WHERE C.PURCHASE_STD = '1'
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE = A.STD_CODE_NK
   AND A.VALIDFLAG = '1'
   AND A.STD_CODE_NK = {0}
 ORDER BY DIC
		]]>
	</query>
	<query id="ComMSCStdDetection.getPurchaseAgreementDetec" desc="获取采购的探伤从表">
		<![CDATA[
SELECT A.DIC,
       A.XH,
       A.PHY_CODE,
       A.PHY_NAME,
       A.POSITION_CODE,
       A.POSITION_DESC,
       A.STD_DESC,
       A.LV_CODE,
       A.LV_DESC,
       A.COVERAGE,
       A.GROOVE_POS,
       A.GROOVE_DIR,
       A.RATE,
       A.DESC_RATE,
       A.DESC_VAL,
       A.GROUP_SEQ,
       A.MIN_D,
       A.MAX_D,
       A.MIN_H,
       A.MAX_H,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
       A.MEMO
  FROM COM_MSC_STD_DETECTION_C A, COM_MSC_STD_DETECTION B, COM_BASE_STD C
 WHERE C.PURCHASE_STD = '1'
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE = B.STD_CODE_NK
   AND B.VALIDFLAG = '1'
   AND B.DIC = A.DIC
   AND A.VALIDFLAG = '1'
   AND B.STD_CODE_NK = {0}
		]]>
	</query>

	<query id="ComMSCStdDetection.getComDetectionNK" desc="主表 查询内控标准">
		<![CDATA[
SELECT DIC,
       DECODE(STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       PROCESS_CODE,
       PROCESS_DESC,
       STD_CODE_NK,
       STD_NAME_NK,
       MODEL_CODE,
       MODEL_DESC,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       MEMO,
       PRODUC_HEAD,
       STEELCODE_NK,
       STEELNAME_NK,
       MODEL_CODE_NK,
       MODEL_DESC_NK,
       PRODUCCODE_NK,
       PRODUCNAME_NK,
       STD_CODE_S_NK,
       STD_NAME_S_NK,
       STD_STYLE_S_NK,
       STD_STYLE_DESC_S_NK
  FROM COM_MSC_STD_DETECTION T
 WHERE 	VALIDFLAG = '1'
	AND DIC IN (
	SELECT
		TO_CHAR( REGEXP_SUBSTR( DIC, '[^,]+', 1, LEVEL ) ) DIC
	FROM
		( SELECT WM_CONCAT ( DIC ) DIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = 'MSC0005573032' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( DIC, ',' ) + 1
		AND MSC = PRIOR MSC
	AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
	)
 ORDER BY DIC
		]]>
	</query>

	<query id="ComMSCStdDetection.getComDetectionNKC" desc="从表查询">
		<![CDATA[
SELECT A.DIC,
       A.XH,
       A.PHY_CODE,
       A.PHY_NAME,
       A.POSITION_CODE,
       A.POSITION_DESC,
       A2.BASENAME STD_DESC,
       A.STD_DESC STD_CODE,
       A.LV_CODE,
       A.LV_DESC,
       A.COVERAGE,
       A.GROOVE_POS,
       A.GROOVE_DIR,
       A.RATE,
       A.DESC_RATE,
       A.DESC_VAL,
       A.GROUP_SEQ,
       A.MIN_D,
       A.MAX_D,
       A.MIN_H,
       A.MAX_H,
       A.MEMO
  FROM COM_MSC_STD_DETECTION_C A
  LEFT JOIN COM_BASE_INFO A2
  ON A2.BASECODE = A.STD_DESC
 WHERE a.VALIDFLAG = '1'
	AND a.DIC IN (
	SELECT
		TO_CHAR( REGEXP_SUBSTR( DIC, '[^,]+', 1, LEVEL ) ) DIC
	FROM
		( SELECT WM_CONCAT ( DIC ) DIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = 'MSC0005573032' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( DIC, ',' ) + 1
		AND MSC = PRIOR MSC
	AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
	)
		]]>
	</query>
</queryMap>