<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质量设计水压">
	<query id="CraftOrdDesignStdWicDAL.query" desc="查询质量设计水压">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.WIC,
       T.USE_CODE,
       T.USE_DESC,
       T.SPECL_FL,
       T.INDEX_SEQ,
       T.PRESSURE_Y,
       T.PRESSURE,
       T.FORMULA,
       T.SAVE_TIME,
       T.GET_MAXVALUE,
       T.GET_MINVALUE,
       T.RATIO_STD,
       T.RATIO_REPLACE,
       T.MAX_PRESS
 FROM Craft_ORD_DESIGN_STD_WIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#WIC#', T.WIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdWicDAL.queryDesignKeyWic" desc="查询质量设计水压">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.WIC,
       T.USE_CODE,
       T.USE_DESC,
       SPECL_FL,
       T.INDEX_SEQ,
       T.PRESSURE_Y,
       T.PRESSURE,
       T.FORMULA,
       T.SAVE_TIME,
       DECODE(T.GET_MAXVALUE, '0', 'False', 'True') GET_MAXVALUE,
       DECODE(T.GET_MINVALUE, '0', 'False', 'True') GET_MINVALUE,
       T.RATIO_STD,
       T.RATIO_REPLACE,
       T.MAX_PRESS,
       T.MSC_PLINE,
       T.PROCESS_CODE,
       A.PROCESS_DESC,
       B.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_WIC T
  LEFT JOIN COM_BASE_PROCESS A
    ON A.PROCESS_CODE = T.PROCESS_CODE
  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC B
    ON B.DESGIN_KEY = T.DESGIN_KEY
   AND B.MSC_PLINE = T.MSC_PLINE
   AND B.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.WIC) = DECODE({3},'','1',{3})
   ORDER BY T.WIC, T.INDEX_SEQ
		]]>
	</query>
	
	<query id="CraftOrdDesignStdWicDAL.queryWicByDesignKey" desc="查询质量设计水压">
		<![CDATA[
 SELECT
       T.DESGIN_KEY,
       T.WIC
 FROM Craft_ORD_DESIGN_STD_WIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#WIC#', T.WIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdWicDAL.Insert" desc="新增">
        <![CDATA[
INSERT INTO CRAFT_ORD_DESIGN_STD_WIC
  (DESGIN_KEY,
   WIC,
   USE_CODE,
   USE_DESC,
   SPECL_FL,
   INDEX_SEQ,
   PRESSURE_Y,
   PRESSURE,
   FORMULA,
   SAVE_TIME,
   GET_MAXVALUE,
   GET_MINVALUE,
   RATIO_STD,
   RATIO_REPLACE,
   MAX_PRESS,
   MSC_PLINE,
   PROCESS_CODE,
   CREATE_NAME,
   CREATE_TIME,
   CRAFT_SOURCE)
VALUES
  ('#DESGIN_KEY#',
   '#WIC#',
   '#USE_CODE#',
   '#USE_DESC#',
   '#SPECL_FL#',
   '#INDEX_SEQ#',
   '#PRESSURE_Y#',
   '#PRESSURE#',
   '#FORMULA#',
   '#SAVE_TIME#',
   '#GET_MAXVALUE#',
   '#GET_MINVALUE#',
   '#RATIO_STD#',
   '#RATIO_REPLACE#',
   '#MAX_PRESS#',
   '#MSC_PLINE#',
   '#PROCESS_CODE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdWicDAL.Update" desc="修改">
        <![CDATA[
UPDATE CRAFT_ORD_DESIGN_STD_WIC T
   SET T.DESGIN_KEY    = '#DESGIN_KEY#',
       T.WIC           = '#WIC#',
       T.USE_CODE      = '#USE_CODE#',
       T.USE_DESC      = '#USE_DESC#',
       T.SPECL_FL      = '#SPECL_FL#',
       T.INDEX_SEQ     = '#INDEX_SEQ#',
       T.PRESSURE_Y    = '#PRESSURE_Y#',
       T.PRESSURE      = '#PRESSURE#',
       T.FORMULA       = '#FORMULA#',
       T.SAVE_TIME     = '#SAVE_TIME#',
       T.GET_MAXVALUE  = '#GET_MAXVALUE#',
       T.GET_MINVALUE  = '#GET_MINVALUE#',
       T.RATIO_STD     = '#RATIO_STD#',
       T.RATIO_REPLACE = '#RATIO_REPLACE#',
       T.MAX_PRESS     = '#MAX_PRESS#',
       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.WIC = '#WIC#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdWicDAL.GetMaxIndex" desc="获取最大序号">
        <![CDATA[
SELECT NVL(MAX(INDEX_SEQ), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_DESIGN_STD_WIC T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.WIC = '#WIC#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdWicDAL.Delete" desc="删除">
        <![CDATA[
DELETE FROM (SELECT *
               FROM CRAFT_ORD_DESIGN_STD_WIC T
              WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
                AND T.WIC = '#WIC#'
                AND T.INDEX_SEQ = '#INDEX_SEQ#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdWicDAL.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.WIC                WIC,
       A.DESGIN_KEY         DESIGNKEY
  FROM CRAFT_ORD_DESIGN_MSC_PL A,
       CRAFT_ORD_DESIGN_MSC_PL_PRC B,
       (SELECT C.WIC, C.MSC_PLINE, C.PROCESS_CODE
          FROM CRAFT_ORD_DESIGN_STD_WIC C
         WHERE C.DESGIN_KEY = {0}
         GROUP BY C.WIC, 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>