<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="首日检水压标准">
	<query id="CraftOrdFdWic.query" desc="查询">
		<![CDATA[
SELECT T.ORD_LN_PK,
       T.INDEX_SEQ,
       T.PRESSURE_Y,
       T.PRESSURE,
       T.FORMULA,
       T.SAVE_TIME,
       DECODE(T.GET_MAXVALUE, '1', 'True', 'False') GET_MAXVALUE,
       DECODE(T.GET_MINVALUE, '1', 'True', 'False') GET_MINVALUE,
       T.RATIO_STD,
       T.RATIO_REPLACE,
       T.MAX_PRESS,
       T.MSC_PLINE,
       T.PROCESS_CODE,
       A.PROCESS_DESC,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.WIC_MEMO,
       T.ROUND_RULE,
       T.MEMO,
       T.ORD_SEQ,
       T.WIC,
       T.OUTPUT_STYLE
  FROM CRAFT_ORD_FD_WIC T
  LEFT JOIN COM_BASE_PROCESS A
    ON A.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.ORD_LN_PK = {0}
 AND T.MSC_PLINE = {1}
 AND T.PROCESS_CODE = {2}
 AND WIC = {3}
		]]>
	</query>
	
	<query id="CraftOrdFdWic.queryM" desc="查询">
		<![CDATA[
SELECT T.MSC_PLINE, T.PROCESS_CODE, T2.PROCESS_DESC, T.WIC, MIN(T.WIC_MEMO) WIC_MEMO
  FROM CRAFT_ORD_FD_WIC T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.ORD_LN_PK = {0}
 GROUP BY T.MSC_PLINE, T.PROCESS_CODE, T2.PROCESS_DESC, T.WIC
		]]>
	</query>
	
	<query id="CraftOrdFdWic.GetMscPlineProcess" desc="获取制程工序">
        <![CDATA[
SELECT T.MSC_PLINE,
       MIN(T.WHOLE_BACKLOG) WHOLE_BACKLOG,
       MIN(T.WHOLE_BACKLOG_DESC) WHOLE_BACKLOG_DESC,
       T.PROCESS_CODE,
       MIN(T.PROCESS_DESC) PROCESS_DESC,
       A.WIC
  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T, CRAFT_ORD_DESIGN_STD_WIC A
 WHERE T.DESGIN_KEY = {0}
   AND A.DESGIN_KEY = T.DESGIN_KEY
   AND A.MSC_PLINE = T.MSC_PLINE
   AND A.PROCESS_CODE = T.PROCESS_CODE
   AND A.CRAFT_SOURCE = '0'
 GROUP BY T.MSC_PLINE, T.PROCESS_CODE, A.WIC
 ORDER BY T.MSC_PLINE, T.PROCESS_CODE, A.WIC
        ]]>
    </query>
	
	 <query id="CraftOrdFdWic.Insert" desc="新增">
        <![CDATA[
 INSERT INTO CRAFT_ORD_FD_WIC
  (ORD_LN_PK,
   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,
   UPDATE_NAME,
   UPDATE_TIME,
   WIC_MEMO,
   ROUND_RULE,
   MEMO,
   ORD_SEQ,
   WIC,
   OUTPUT_STYLE)
VALUES
  ('#ORD_LN_PK#',
   (SELECT NVL(MAX(T.INDEX_SEQ), 0) + 1
      FROM CRAFT_ORD_FD_WIC T
     WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
       AND T.MSC_PLINE = '#MSC_PLINE#'
       AND T.PROCESS_CODE = '#PROCESS_CODE#'),
   '#PRESSURE_Y#',
   '#PRESSURE#',
   '#FORMULA#',
   '#SAVE_TIME#',
   '#GET_MAXVALUE#',
   '#GET_MINVALUE#',
   '#RATIO_STD#',
   '#RATIO_REPLACE#',
   '#MAX_PRESS#',
   '#MSC_PLINE#',
   '#PROCESS_CODE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#UPDATE_NAME#',
   SYSDATE,
   '#WIC_MEMO#',
   '#ROUND_RULE#',
   '#MEMO#',
   (SELECT NVL(MAX(T.ORD_SEQ), 0) + 1
      FROM CRAFT_ORD_FD_WIC T
     WHERE T.ORD_LN_PK = '#ORD_LN_PK#'),
   '#WIC#',
   '#OUTPUT_STYLE#')
        ]]>
    </query>
    
     <query id="CraftOrdFdWic.Update" desc="修改">
        <![CDATA[
 UPDATE CRAFT_ORD_FD_WIC T
   SET
        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.CREATE_NAME = '#CREATE_NAME#',
        T.CREATE_TIME = SYSDATE,
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.WIC_MEMO = '#WIC_MEMO#',
        T.ROUND_RULE = '#ROUND_RULE#',
        T.MEMO = '#MEMO#',
        T.WIC = '#WIC#',
        T.OUTPUT_STYLE = '#OUTPUT_STYLE#'
 WHERE
       T.ORD_LN_PK = '#ORD_LN_PK#'
       AND T.ORD_SEQ = '#ORD_SEQ#'
        ]]>
    </query>
	
	<query id="CraftOrdFdWic.Delete" desc="删除">
        <![CDATA[
DELETE FROM (SELECT *
               FROM CRAFT_ORD_FD_WIC T
              WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
                AND T.ORD_SEQ = '#ORD_SEQ#')
        ]]>
    </query>
    
    <query id="CraftOrdFdWic.setOrdSeq" desc="更新SEQ">
        <![CDATA[
UPDATE CRAFT_ORD_FD_WIC T
   SET T.ORD_SEQ = T.ORD_SEQ - 1
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_SEQ > '#ORD_SEQ#'
        ]]>
    </query>
    
    <query id="CraftOrdFdWic.setIndexSeq" desc="更新SEQ">
        <![CDATA[
UPDATE CRAFT_ORD_FD_WIC T
      SET T.INDEX_SEQ = T.INDEX_SEQ - 1
    WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
      AND T.MSC_PLINE = '#MSC_PLINE#'
      AND T.PROCESS_CODE = '#PROCESS_CODE#'
      AND T.INDEX_SEQ > '#INDEX_SEQ#'
        ]]>
    </query>
    
    <query id="CraftOrdFdWic.getCraftWic" desc="获取工艺记录">
        <![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_WIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND T.WIC = {3}
   AND T.SPECL_FL = '2'
   AND T.CRAFT_SOURCE = '0'
        ]]>
    </query>
    
    <query id="CraftOrdFdWic.DeleteAll" desc="删除制程工序下的所有水压">
        <![CDATA[
DELETE FROM (SELECT *
               FROM CRAFT_ORD_FD_WIC T
              WHERE T.ORD_LN_PK = {0}
                AND T.MSC_PLINE = {1}
                AND T.PROCESS_CODE = {2})
        ]]>
    </query>
    
    <query id="CraftOrdFdWic.updateFdWicMemo" desc="修改首日检索引码备注">
        <![CDATA[
UPDATE CRAFT_ORD_FD_WIC T
   SET T.WIC_MEMO = {3}
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
        ]]>
    </query>
</queryMap>