<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质量设计探伤">
	<query id="CraftOrdDesignStdDicDAL.query" desc="查询质量设计探伤">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.DIC,
       T.USE_CODE,
       T.USE_DESC,
       T.SPECL_FL,
       T.XH,
       T.PHY_CODE,
       T.PHY_NAME,
       T.POSITION_CODE,
       T.POSITION_DESC,
       T.STD_DESC,
       T.LV_CODE,
       T.LV_DESC,
       T.GROOVE_POS,
       T.GROOVE_DIR,
       T.COVERAGE,
       T.RATE,
       T.DESC_RATE,
       T.DESC_VAL,
       T.GROUP_SEQ,
       T.MEMO,
       T.MIN_D,
       T.MAX_D,
       T.MIN_H,
       T.MAX_H
 FROM Craft_ORD_DESIGN_STD_DIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#DIC#', T.DIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdDicDAL.queryByDesignKeyDic" desc="查询质量设计探伤">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.DIC,
       T.USE_CODE,
       T.USE_DESC,
       SPECL_FL,
       T.XH,
       T.PHY_CODE,
       T.PHY_NAME,
       T.POSITION_CODE,
       T.POSITION_DESC,
       T.STD_DESC,
       T.LV_CODE,
       T.LV_DESC,
       T.GROOVE_POS,
       T.GROOVE_DIR,
       T.COVERAGE,
       T.RATE,
       T.DESC_RATE,
       T.DESC_VAL,
       T.GROUP_SEQ,
       T.MEMO,
       T.MIN_D,
       T.MAX_D,
       T.MIN_H,
       T.MAX_H,
       T.MSC_PLINE,
       T.PROCESS_CODE,
       A.PROCESS_DESC_C,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       CRAFT_SOURCE,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
  FROM CRAFT_ORD_DESIGN_STD_DIC T
  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC A
    ON A.DESGIN_KEY = T.DESGIN_KEY
   AND A.MSC_PLINE = T.MSC_PLINE
   AND A.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
      AND  DECODE({3},'','1',T.DIC) = DECODE({3},'','1',{3})
   ORDER BY T.DIC, T.XH
		]]>
	</query>
	
	<query id="CraftOrdDesignStdDicDAL.queryDicByDesignKey" desc="查询质量设计探伤">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.DIC
 FROM Craft_ORD_DESIGN_STD_DIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#DIC#', T.DIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdDicDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO CRAFT_ORD_DESIGN_STD_DIC
  (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,
   MIN_D,
   MAX_D,
   MIN_H,
   MAX_H,
   MSC_PLINE,
   PROCESS_CODE,
   CREATE_NAME,
   CREATE_TIME,
   CRAFT_SOURCE)
VALUES
  ('#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#',
   '#MIN_D#',
   '#MAX_D#',
   '#MIN_H#',
   '#MAX_H#',
   '#MSC_PLINE#',
   '#PROCESS_CODE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdDicDAL.Update" desc="修改">
        <![CDATA[
UPDATE CRAFT_ORD_DESIGN_STD_DIC T
   SET T.DESGIN_KEY    = '#DESGIN_KEY#',
       T.DIC           = '#DIC#',
       T.USE_CODE      = '#USE_CODE#',
       T.USE_DESC      = '#USE_DESC#',
       T.SPECL_FL      = '#SPECL_FL#',
       T.XH            = '#XH#',
       T.PHY_CODE      = '#PHY_CODE#',
       T.PHY_NAME      = '#PHY_NAME#',
       T.POSITION_CODE = '#POSITION_CODE#',
       T.POSITION_DESC = '#POSITION_DESC#',
       T.STD_DESC      = '#STD_DESC#',
       T.LV_CODE       = '#LV_CODE#',
       T.LV_DESC       = '#LV_DESC#',
       T.GROOVE_POS    = '#GROOVE_POS#',
       T.GROOVE_DIR    = '#GROOVE_DIR#',
       T.COVERAGE      = '#COVERAGE#',
       T.RATE          = '#RATE#',
       T.DESC_RATE     = '#DESC_RATE#',
       T.DESC_VAL      = '#DESC_VAL#',
       T.GROUP_SEQ     = '#GROUP_SEQ#',
       T.MEMO          = '#MEMO#',
       T.MIN_D         = '#MIN_D#',
       T.MAX_D         = '#MAX_D#',
       T.MIN_H         = '#MIN_H#',
       T.MAX_H         = '#MAX_H#',
       T.MSC_PLINE     = '#MSC_PLINE#',
       T.PROCESS_CODE  = '#PROCESS_CODE#',
       T.CRAFT_SOURCE  = '#CRAFT_SOURCE#',
       T.UPDATE_NAME   = '#UPDATE_NAME#',
       T.UPDATE_TIME   = SYSDATE
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.DIC = '#DIC#'
   AND T.XH = '#XH#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdDicDAL.GetMaxIndex" desc="获取最大序号">
        <![CDATA[
SELECT NVL(MAX(XH), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_DESIGN_STD_DIC T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.DIC = '#DIC#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdDicDAL.Delete" desc="删除">
        <![CDATA[
DELETE FROM (SELECT *
               FROM CRAFT_ORD_DESIGN_STD_DIC T
              WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
                AND T.DIC = '#DIC#'
                AND T.XH = '#XH#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdDicDAL.getCraftMscPline" desc="获取工艺评审制程">
        <![CDATA[
SELECT A.MSC_PLINE          MSCPLINE,
       A.WHOLE_BACKLOG      WHOLEBACKLOG,
       A.WHOLE_BACKLOG_DESC WHOLEBACKLOGDESC,
       B.PROCESS_CODE       PROCESSCODE,
       B.PROCESS_DESC       PROCESSDESC,
       B.PROCESS_CODE_C     PROCESSCODEC,
       B.PROCESS_DESC_C     PROCESSDESCC,
       C.DIC                DIC,
       A.DESGIN_KEY         DESIGNKEY
  FROM CRAFT_ORD_DESIGN_MSC_PL A,
       CRAFT_ORD_DESIGN_MSC_PL_PRC B,
       (SELECT C.DIC, MSC_PLINE, PROCESS_CODE
          FROM CRAFT_ORD_DESIGN_STD_DIC C
         WHERE C.DESGIN_KEY = {0}
         GROUP BY C.DIC, C.MSC_PLINE, C.PROCESS_CODE) C
 WHERE A.DESGIN_KEY = {0}
   AND B.PROCESS_CODE = {1}
   AND B.DESGIN_KEY = A.DESGIN_KEY
   AND B.MSC_PLINE = A.MSC_PLINE
   AND C.MSC_PLINE = A.MSC_PLINE
   AND C.PROCESS_CODE = B.PROCESS_CODE
        ]]>
    </query>
</queryMap>