<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="首日检理化标准">
	<query id="CraftOrdFdPic.query" desc="查询">
		<![CDATA[
SELECT T.ord_ln_pk,
       T.index_seq,
       T.phy_code_max,
       T.phy_name_max,
       T.phy_code_min,
       T.phy_name_min,
       T.phy_code,
       T.phy_name,
       T.item_code_f,
       T.item_name_f,
       T.item_code_w,
       T.item_name_w,
       T.item_code_s,
       T.item_name_s,
       DECODE(T.ischeck, '1', 'True', 'False') ischeck,
       DECODE(T.isquote, '1', 'True', 'False') isquote,
       T.result_count,
       decode(T.isjudge, '1', 'True', 'False') isjudge,
       DECODE(T.phy_type, '1', 'True', 'False') phy_type,
       T.phy_formula,
       T.stdmin_sign,
       T.stdmin,
       T.stdmax_sign,
       T.stdmax,
       T.judge_basis,
       T.stdmemo,
       T.addcondition,
       T.addstdcon_code,
       T.addstd_min_sign,
       T.addstd_min,
       T.addstd_max_sign,
       T.addstd_max,
       T.addpercent,
       T.stdmin_sign2,
       T.stdmin2,
       T.stdmax_sign2,
       T.stdmax2,
       T.std_choose,
       T.msc_pline,
       T.process_code,
       DECODE(T.billet_sample, '1', 'True', 'False') billet_sample,
       T.create_name,
       TO_CHAR(T.create_time, 'YYYY-MM-DD HH24:MI:SS') create_time,
       T.update_name,
       TO_CHAR(T.update_time, 'YYYY-MM-DD HH24:MI:SS') update_time,
       T.ord_seq,
       T2.PROCESS_DESC,
       T.PIC
  FROM CRAFT_ORD_FD_PIC T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.ORD_LN_PK = {0}
 AND T.MSC_PLINE = {1}
 AND T.PROCESS_CODE = {2}
 AND T.PIC = {3}
 ORDER BY T.phy_name_max, T.phy_name_min, T.phy_name
		]]>
	</query>
	
	<query id="CraftOrdFdPic.queryM" desc="查询">
		<![CDATA[
SELECT T.MSC_PLINE, T.PROCESS_CODE, T2.PROCESS_DESC, T.PIC, MIN(T.PIC_MEMO) PIC_MEMO
  FROM CRAFT_ORD_FD_PIC 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.PIC
		]]>
	</query>
	
	<query id="CraftOrdFdPic.Insert" desc="新增">
        <![CDATA[
INSERT INTO CRAFT_ORD_FD_PIC
  (ORD_LN_PK,
   ORD_SEQ,
   INDEX_SEQ,
   PHY_CODE_MAX,
   PHY_NAME_MAX,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   PHY_CODE,
   PHY_NAME,
   ITEM_CODE_F,
   ITEM_NAME_F,
   ITEM_CODE_W,
   ITEM_NAME_W,
   ITEM_CODE_S,
   ITEM_NAME_S,
   ISCHECK,
   ISQUOTE,
   RESULT_COUNT,
   ISJUDGE,
   PHY_TYPE,
   PHY_FORMULA,
   STDMIN_SIGN,
   STDMIN,
   STDMAX_SIGN,
   STDMAX,
   JUDGE_BASIS,
   STDMEMO,
   ADDCONDITION,
   ADDSTDCON_CODE,
   ADDSTD_MIN_SIGN,
   ADDSTD_MIN,
   ADDSTD_MAX_SIGN,
   ADDSTD_MAX,
   ADDPERCENT,
   STDMIN_SIGN2,
   STDMIN2,
   STDMAX_SIGN2,
   STDMAX2,
   STD_CHOOSE,
   MSC_PLINE,
   PROCESS_CODE,
   BILLET_SAMPLE,
   CREATE_NAME,
   CREATE_TIME,
   PIC,
   PIC_MEMO)
VALUES
  ('#ORD_LN_PK#',
   (SELECT NVL(MAX(T.ORD_SEQ), 0) + 1
      FROM CRAFT_ORD_FD_PIC T
     WHERE T.ORD_LN_PK = '#ORD_LN_PK#'),
   (SELECT NVL(MAX(T.INDEX_SEQ), 0) + 1
      FROM CRAFT_ORD_FD_PIC T
     WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
       AND T.MSC_PLINE = '#MSC_PLINE#'
       AND T.PROCESS_CODE = '#PROCESS_CODE#'),
   '#PHY_CODE_MAX#',
   '#PHY_NAME_MAX#',
   '#PHY_CODE_MIN#',
   '#PHY_NAME_MIN#',
   '#PHY_CODE#',
   '#PHY_NAME#',
   '#ITEM_CODE_F#',
   '#ITEM_NAME_F#',
   '#ITEM_CODE_W#',
   '#ITEM_NAME_W#',
   '#ITEM_CODE_S#',
   '#ITEM_NAME_S#',
   '#ISCHECK#',
   '#ISQUOTE#',
   '#RESULT_COUNT#',
   '#ISJUDGE#',
   '#PHY_TYPE#',
   '#PHY_FORMULA#',
   '#STDMIN_SIGN#',
   '#STDMIN#',
   '#STDMAX_SIGN#',
   '#STDMAX#',
   '#JUDGE_BASIS#',
   '#STDMEMO#',
   '#ADDCONDITION#',
   '#ADDSTDCON_CODE#',
   '#ADDSTD_MIN_SIGN#',
   '#ADDSTD_MIN#',
   '#ADDSTD_MAX_SIGN#',
   '#ADDSTD_MAX#',
   '#ADDPERCENT#',
   '#STDMIN_SIGN2#',
   '#STDMIN2#',
   '#STDMAX_SIGN2#',
   '#STDMAX2#',
   '#STD_CHOOSE#',
   '#MSC_PLINE#',
   '#PROCESS_CODE#',
   '#BILLET_SAMPLE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#PIC#',
   '#PIC_MEMO#')
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.Update" desc="修改">
        <![CDATA[
UPDATE CRAFT_ORD_FD_PIC T
   SET T.INDEX_SEQ       = '#INDEX_SEQ#',
       T.PHY_CODE_MAX    = '#PHY_CODE_MAX#',
       T.PHY_NAME_MAX    = '#PHY_NAME_MAX#',
       T.PHY_CODE_MIN    = '#PHY_CODE_MIN#',
       T.PHY_NAME_MIN    = '#PHY_NAME_MIN#',
       T.PHY_CODE        = '#PHY_CODE#',
       T.PHY_NAME        = '#PHY_NAME#',
       T.ITEM_CODE_F     = '#ITEM_CODE_F#',
       T.ITEM_NAME_F     = '#ITEM_NAME_F#',
       T.ITEM_CODE_W     = '#ITEM_CODE_W#',
       T.ITEM_NAME_W     = '#ITEM_NAME_W#',
       T.ITEM_CODE_S     = '#ITEM_CODE_S#',
       T.ITEM_NAME_S     = '#ITEM_NAME_S#',
       T.ISCHECK         = '#ISCHECK#',
       T.ISQUOTE         = '#ISQUOTE#',
       T.RESULT_COUNT    = '#RESULT_COUNT#',
       T.ISJUDGE         = '#ISJUDGE#',
       T.PHY_TYPE        = '#PHY_TYPE#',
       T.PHY_FORMULA     = '#PHY_FORMULA#',
       T.STDMIN_SIGN     = '#STDMIN_SIGN#',
       T.STDMIN          = '#STDMIN#',
       T.STDMAX_SIGN     = '#STDMAX_SIGN#',
       T.STDMAX          = '#STDMAX#',
       T.JUDGE_BASIS     = '#JUDGE_BASIS#',
       T.STDMEMO         = '#STDMEMO#',
       T.ADDCONDITION    = '#ADDCONDITION#',
       T.ADDSTDCON_CODE  = '#ADDSTDCON_CODE#',
       T.ADDSTD_MIN_SIGN = '#ADDSTD_MIN_SIGN#',
       T.ADDSTD_MIN      = '#ADDSTD_MIN#',
       T.ADDSTD_MAX_SIGN = '#ADDSTD_MAX_SIGN#',
       T.ADDSTD_MAX      = '#ADDSTD_MAX#',
       T.ADDPERCENT      = '#ADDPERCENT#',
       T.STDMIN_SIGN2    = '#STDMIN_SIGN2#',
       T.STDMIN2         = '#STDMIN2#',
       T.STDMAX_SIGN2    = '#STDMAX_SIGN2#',
       T.STDMAX2         = '#STDMAX2#',
       T.STD_CHOOSE      = '#STD_CHOOSE#',
       T.MSC_PLINE       = '#MSC_PLINE#',
       T.PROCESS_CODE    = '#PROCESS_CODE#',
       T.BILLET_SAMPLE   = '#BILLET_SAMPLE#',
       T.UPDATE_NAME     = '#UPDATE_NAME#',
       T.UPDATE_TIME     = SYSDATE,
       T.PIC = '#PIC#'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_SEQ = '#ORD_SEQ#'
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.deleteFdPic" desc="删除">
        <![CDATA[
DELETE FROM CRAFT_ORD_FD_PIC T WHERE T.ORD_LN_PK = '#ORD_LN_PK#' AND T.ORD_SEQ = '#ORD_SEQ#'
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.deleteFdPicSmp" desc="删除">
        <![CDATA[
DELETE FROM CRAFT_ORD_FD_PIC_SMP T WHERE T.ORD_LN_PK = {0}
AND T.MSC_PLINE = {1} AND T.PROCESS_CODE = {2}
        ]]>
    </query>
    
     <query id="CraftOrdFdPic.deleteNoExistsFdPicSmp" desc="删除">
        <![CDATA[
DELETE FROM CRAFT_ORD_FD_PIC_SMP T
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND NOT EXISTS
 (SELECT 1
          FROM CRAFT_ORD_FD_PIC A
         WHERE A.ORD_LN_PK = T.ORD_LN_PK
           AND A.MSC_PLINE = T.MSC_PLINE
           AND A.PROCESS_CODE = T.PROCESS_CODE
           AND A.PHY_CODE_MIN = T.PHY_CODE_MIN
           AND NVL(A.ITEM_CODE_F, '1') = NVL(T.ITEM_CODE_F, '1')
           AND NVL(A.ITEM_CODE_W, '1') = NVL(T.ITEM_CODE_W, '1')
           AND NVL(A.ITEM_CODE_S, '1') = NVL(T.ITEM_CODE_C, '1'))
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getNoExistsFdPicGroupSample" desc="获取分组数据">
        <![CDATA[
SELECT T.MSC_PLINE,
        T.PROCESS_CODE,
        T.PHY_CODE_MIN,
        T.ITEM_CODE_F,
        T.ITEM_CODE_W,
        T.ITEM_CODE_S ITEM_CODE_C,
        MIN(T.ITEM_NAME_F) ITEM_NAME_F,
        MIN(T.ITEM_NAME_W) ITEM_NAME_W,
        MIN(T.ITEM_NAME_S) ITEM_NAME_S,
        MIN(T.PHY_NAME_MIN) PHY_NAME_MIN,
        MIN(T.ORD_LN_PK) ORD_LN_PK,
        MIN(T.PIC) PIC,
        MIN(A.STD_CODE) STD_CODE,
        MIN(A.STD_NAME) STD_NAME
   FROM CRAFT_ORD_FD_PIC T, SLM_ORDER_LINE A
  WHERE T.ORD_LN_PK = {0}
    AND A.ORD_LN_PK = T.ORD_LN_PK
    AND T.MSC_PLINE = {1}
    AND T.PROCESS_CODE = {2}
    AND NOT EXISTS (SELECT 1
           FROM CRAFT_ORD_FD_PIC_SMP B
          WHERE B.ORD_LN_PK = T.ORD_LN_PK
            AND B.MSC_PLINE = T.MSC_PLINE
            AND B.PROCESS_CODE = T.PROCESS_CODE
            AND B.PHY_CODE_MIN = T.PHY_CODE_MIN
            AND NVL(B.ITEM_CODE_F, '1') = NVL(T.ITEM_CODE_F, '1')
           AND NVL(B.ITEM_CODE_W, '1') = NVL(T.ITEM_CODE_W, '1')
           AND NVL(B.ITEM_CODE_C, '1') = NVL(T.ITEM_CODE_S, '1'))
  GROUP BY T.MSC_PLINE,
           T.PROCESS_CODE,
           T.PHY_CODE_MIN,
           T.ITEM_CODE_F,
           T.ITEM_CODE_W,
           T.ITEM_CODE_S
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.GetMaxOrdSeq" desc="获取最大序号">
        <![CDATA[
SELECT NVL(MAX(ORD_SEQ), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_FD_PIC T
 WHERE T.ORD_LN_PK = {0}
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.GetMaxIndexSeq" desc="获取最大序号">
        <![CDATA[
SELECT NVL(MAX(INDEX_SEQ), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_FD_PIC T
 WHERE T.ORD_LN_PK = {0}
 AND T.MSC_PLINE = {1}
 AND T.PROCESS_CODE = {2}
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.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.PIC
  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T, CRAFT_ORD_DESIGN_STD_PIC 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.PIC
 ORDER BY T.MSC_PLINE, T.PROCESS_CODE, A.PIC
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.Delete" desc="删除">
        <![CDATA[
DELETE FROM (SELECT *
               FROM CRAFT_ORD_FD_PIC T
              WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
                AND T.ORD_SEQ = '#ORD_SEQ#')
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getPhyMinCount" desc="获取首日检理化试样组数目">
        <![CDATA[
SELECT COUNT(1) COUNT
  FROM CRAFT_ORD_FD_PIC T
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {2}
   AND T.PROCESS_CODE = {3}
   AND EXISTS
 (SELECT 1
          FROM CRAFT_ORD_FD_PIC A
         WHERE A.ORD_LN_PK = {0}
           AND A.ORD_SEQ = {1}
           AND A.PHY_CODE_MIN = T.PHY_CODE_MIN
           AND NVL(A.ITEM_CODE_F, '1') = NVL(T.ITEM_CODE_F, '1')
           AND NVL(A.ITEM_CODE_W, '1') = NVL(T.ITEM_CODE_W, '1')
           AND NVL(A.ITEM_CODE_S, '1') = NVL(T.ITEM_CODE_S, '1'))
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getSamplePhyMinCount" desc="获取首日检取样试样组数目">
        <![CDATA[
SELECT COUNT(1) COUNT
  FROM CRAFT_ORD_FD_PIC_SMP T
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND T.PHY_CODE_MIN = {3}
   AND NVL(T.ITEM_CODE_F, '1') = NVL({4}, '1')
   AND NVL(T.ITEM_CODE_C, '1') = NVL({5}, '1')
   AND NVL(T.ITEM_CODE_W, '1') = NVL({6}, '1')
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.DeleteAll" desc="删除">
        <![CDATA[
DELETE FROM (SELECT *
               FROM CRAFT_ORD_FD_PIC T
              WHERE T.ORD_LN_PK = {0}
                AND T.MSC_PLINE = {1}
                AND T.PROCESS_CODE = {2})
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.DeleteFdSample" desc="删除取样">
        <![CDATA[
 DELETE FROM (SELECT *
                FROM CRAFT_ORD_FD_PIC_SMP T
               WHERE T.ORD_LN_PK = {0}
                 AND T.MSC_PLINE = {1}
                 AND T.PROCESS_CODE = {2}
                 AND EXISTS (SELECT 1
                        FROM CRAFT_ORD_FD_PIC A
                       WHERE A.ORD_LN_PK = T.ORD_LN_PK
                         AND A.ORD_SEQ = {3}
                         AND A.PHY_CODE_MIN = T.PHY_CODE_MIN
                         AND NVL(A.ITEM_CODE_F, '1') =
                             NVL(T.ITEM_CODE_F, '1')
                         AND NVL(A.ITEM_CODE_S, '1') =
                             NVL(T.ITEM_CODE_C, '1')
                         AND NVL(A.ITEM_CODE_W, '1') =
                             NVL(T.ITEM_CODE_W, '1')))
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.setOrdSeq" desc="更新SEQ">
        <![CDATA[
UPDATE CRAFT_ORD_FD_PIC 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="CraftOrdFdPic.setIndexSeq" desc="更新SEQ">
        <![CDATA[
UPDATE CRAFT_ORD_FD_PIC 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="CraftOrdFdPic.getCraftPic" desc="获取工艺记录">
        <![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND T.PIC = {3}
   AND T.SPECL_FL = '2'
   AND T.CRAFT_SOURCE = '0'
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getPhyMinSample" desc="获取取样主信息">
        <![CDATA[
SELECT T.PHY_CODE_MIN,
       MIN(T.PHY_NAME_MIN) PHY_NAME_MIN,
       T.ITEM_CODE_F,
       MIN(T.ITEM_NAME_F) ITEM_NAME_F,
       T.ITEM_CODE_S ITEM_CODE_C,
       MIN(T.ITEM_NAME_S) ITEM_NAME_C,
       T.ITEM_CODE_W,
       MIN(T.ITEM_NAME_W) ITEM_NAME_W,
       MIN(B.STD_CODE_TEST) STD_CODE_TEST,
       MIN(B.STD_NAME_TEST) STD_NAME_TEST,
       MIN(A.STD_NAME) STD_NAME,
       MIN(A.STD_CODE) STD_CODE,
       MIN(A.PRODUCCODE) PRODUCCODE,
       MIN(A.PRODUCNAME) PRODUCNAME,
       MIN(A.STEELCODE) STEELCODE,
       MIN(A.STEELNAME) STEELNAME,
       DECODE(MIN(B.COMMON), '1', 'True', 'False') COMMON
  FROM CRAFT_ORD_FD_PIC T
  LEFT JOIN CRAFT_ORD_FD_PIC_SMP B
    ON B.ORD_LN_PK = T.ORD_LN_PK
   AND B.PHY_CODE_MIN = T.PHY_CODE_MIN
   AND NVL(B.ITEM_CODE_F, '1') = NVL(T.ITEM_CODE_F, '1')
   AND NVL(B.ITEM_CODE_C, '1') = NVL(T.ITEM_CODE_S, '1')
   AND NVL(B.ITEM_CODE_W, '1') = NVL(T.ITEM_CODE_W, '1')
  LEFT JOIN SLM_ORDER_LINE A
    ON A.ORD_LN_PK = T.ORD_LN_PK
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
 GROUP BY T.PHY_CODE_MIN, T.ITEM_CODE_F, T.ITEM_CODE_S, T.ITEM_CODE_W
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getPhyMinSpline" desc="获取试样主信息">
        <![CDATA[
SELECT T.PHY_CODE_MIN,
       MIN(T.PHY_NAME_MIN) PHY_NAME_MIN,
       T.ITEM_CODE_F,
       MIN(T.ITEM_NAME_F) ITEM_NAME_F,
       T.ITEM_CODE_S ITEM_CODE_C,
       MIN(T.ITEM_NAME_S) ITEM_NAME_C,
       MIN(B.STD_CODE_TEST) STD_CODE_TEST,
       MIN(B.STD_NAME_TEST) STD_NAME_TEST,
       MIN(A.STD_NAME) STD_NAME,
       MIN(A.STD_CODE) STD_CODE,
       MIN(A.PRODUCCODE) PRODUCCODE,
       MIN(A.PRODUCNAME) PRODUCNAME,
       MIN(A.STEELCODE) STEELCODE,
       MIN(A.STEELNAME) STEELNAME
  FROM CRAFT_ORD_FD_PIC T
  LEFT JOIN CRAFT_ORD_FD_PIC_SMP B
    ON B.ORD_LN_PK = T.ORD_LN_PK
   AND B.PHY_CODE_MIN = T.PHY_CODE_MIN
   AND NVL(B.ITEM_CODE_F, '1') = NVL(T.ITEM_CODE_F, '1')
   AND NVL(B.ITEM_CODE_C, '1') = NVL(T.ITEM_CODE_S, '1')
   AND NVL(B.ITEM_CODE_W, '1') = NVL(T.ITEM_CODE_W, '1')
  LEFT JOIN SLM_ORDER_LINE A
    ON A.ORD_LN_PK = T.ORD_LN_PK
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
 GROUP BY T.PHY_CODE_MIN, T.ITEM_CODE_F, T.ITEM_CODE_S
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getCraftSample" desc="获取工艺评审取样">
        <![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND T.PIC = {3}
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.insertSample" desc="新增取样信息">
        <![CDATA[
INSERT INTO CRAFT_ORD_FD_PIC_SMP
  (ORD_LN_PK,
   PIC,
   SIC,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   STD_CODE,
   STD_NAME,
   LENGTH,
   RATE,
   DESC_RATE,
   DESC_COUNT,
   POSITION,
   DESC_POSITION,
   SAMPLE_COUNT,
   MEMO,
   BATCH_CNT,
   WIDTH,
   BATCH_UNIT,
   EIC,
   PHY_DIR,
   SIZE_DESC,
   ITEM_CODE_F,
   ITEM_CODE_C,
   ITEM_CODE_W,
   SAMPLE_KEY,
   SAMPLE_KEY_DESC,
   STD_CODE_TEST,
   STD_NAME_TEST,
   SPLINE_ITEM_CODE_S,
   SPLINE_ITEM_NAME_S,
   SPLINE_ITEM_CODE_F,
   SPLINE_ITEM_NAME_F,
   PROCESS_CODE,
   PROCESS_DESC,
   MSC_PLINE,
   ATTACH_PERCENT,
   ATTACH_COUNT,
   TOP_STOVE,
   LOOP_VALUE,
   SSC_CONDITION,
   EXCLUDE_PHY_MIN,
   SAMPLE_STYLE,
   ORD_SEQ)
VALUES
  ('#ORD_LN_PK#',
   '#PIC#',
   '#SIC#',
   '#PHY_CODE_MIN#',
   '#PHY_NAME_MIN#',
   '#STD_CODE#',
   '#STD_NAME#',
   '#LENGTH#',
   '#RATE#',
   '#DESC_RATE#',
   '#DESC_COUNT#',
   '#POSITION#',
   '#DESC_POSITION#',
   '#SAMPLE_COUNT#',
   '#MEMO#',
   '#BATCH_CNT#',
   '#WIDTH#',
   '#BATCH_UNIT#',
   '#EIC#',
   '#PHY_DIR#',
   '#SIZE_DESC#',
   '#ITEM_CODE_F#',
   '#ITEM_CODE_C#',
   '#ITEM_CODE_W#',
   '#SAMPLE_KEY#',
   '#SAMPLE_KEY_DESC#',
   '#STD_CODE_TEST#',
   '#STD_NAME_TEST#',
   '#SPLINE_ITEM_CODE_S#',
   '#SPLINE_ITEM_NAME_S#',
   '#SPLINE_ITEM_CODE_F#',
   '#SPLINE_ITEM_NAME_F#',
   '#PROCESS_CODE#',
   (SELECT PROCESS_DESC FROM COM_BASE_PROCESS A WHERE A.PROCESS_CODE = '#PROCESS_CODE#'),
   '#MSC_PLINE#',
   '#ATTACH_PERCENT#',
   '#ATTACH_COUNT#',
   '#TOP_STOVE#',
   '#LOOP_VALUE#',
   '#SSC_CONDITION#',
   '#EXCLUDE_PHY_MIN#',
   '#SAMPLE_STYLE#',
   (SELECT NVL(MAX(A.ORD_SEQ), 0) + 1
      FROM CRAFT_ORD_FD_PIC_SMP A
     WHERE A.ORD_LN_PK = '#ORD_LN_PK#'))
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.setSample" desc="保存取样信息">
        <![CDATA[
UPDATE CRAFT_ORD_FD_PIC_SMP T
   SET SIC             = '#SIC#',
       STD_CODE        = '#STD_CODE#',
       STD_NAME        = '#STD_NAME#',
       RATE            = '#RATE#',
       DESC_RATE       = '#DESC_RATE#',
       DESC_COUNT      = '#DESC_COUNT#',
       POSITION        = '#POSITION#',
       DESC_POSITION   = '#DESC_POSITION#',
       SAMPLE_COUNT    = '#SAMPLE_COUNT#',
       MEMO            = '#MEMO#',
       BATCH_CNT       = '#BATCH_CNT#',
       BATCH_UNIT      = '#BATCH_UNIT#',
       STD_CODE_TEST   = '#STD_CODE_TEST#',
       STD_NAME_TEST   = '#STD_NAME_TEST#',
       ATTACH_PERCENT  = '#ATTACH_PERCENT#',
       ATTACH_COUNT    = '#ATTACH_COUNT#',
       TOP_STOVE       = '#TOP_STOVE#',
       LOOP_VALUE      = '#LOOP_VALUE#',
       SSC_CONDITION   = '#SSC_CONDITION#',
       EXCLUDE_PHY_MIN = '#EXCLUDE_PHY_MIN#',
       COMMON = '#COMMON#'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND NVL(T.ITEM_CODE_F, '1') = NVL('#ITEM_CODE_F#', '1')
   AND NVL(T.ITEM_CODE_C, '1') = NVL('#ITEM_CODE_C#', '1')
   AND NVL(T.ITEM_CODE_W, '1') = NVL('#ITEM_CODE_W#', '1')
   AND T.MSC_PLINE = '#MSC_PLINE#'
   AND T.PROCESS_CODE = '#PROCESS_CODE#'
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.setSpline" desc="保存取样信息">
        <![CDATA[
UPDATE CRAFT_ORD_FD_PIC_SMP T
   SET EIC                = '#EIC#',
       LENGTH             = '#LENGTH#',
       WIDTH              = '#WIDTH#',
       SIZE_DESC          = '#SIZE_DESC#',
       PHY_DIR            = '#PHY_DIR#',
       SAMPLE_STYLE       = '#SAMPLE_STYLE#',
       STD_CODE_TEST      = '#STD_CODE_TEST#',
       STD_NAME_TEST      = '#STD_NAME_TEST#',
       SPLINE_ITEM_CODE_S = '#SPLINE_ITEM_CODE_S#',
       SPLINE_ITEM_NAME_S = '#SPLINE_ITEM_NAME_S#',
       SPLINE_ITEM_CODE_F = '#SPLINE_ITEM_CODE_F#',
       SPLINE_ITEM_NAME_F = '#SPLINE_ITEM_NAME_F#'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND NVL(T.ITEM_CODE_F, '1') = NVL('#ITEM_CODE_F#', '1')
   AND NVL(T.ITEM_CODE_C, '1') = NVL('#ITEM_CODE_C#', '1')
   AND T.MSC_PLINE = '#MSC_PLINE#'
   AND T.PROCESS_CODE = '#PROCESS_CODE#'
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getSampleBySic" desc="获取取样信息">
        <![CDATA[
SELECT * FROM COM_BASE_SAMPLE T WHERE T.SIC = {0}
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getSplineByEic" desc="获取取样信息">
        <![CDATA[
SELECT * FROM COM_BASE_SPLINE T WHERE T.EIC = {0}
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getFdSampleSic" desc="获取取样信息">
        <![CDATA[
SELECT T.SIC
  FROM CRAFT_ORD_FD_PIC_SMP T
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND T.PHY_CODE_MIN = {3}
   AND NVL(T.ITEM_CODE_F, '1') = NVL({4}, '1')
   AND NVL(T.ITEM_CODE_C, '1') = NVL({5}, '1')
   AND NVL(T.ITEM_CODE_W, '1') = NVL({6}, '1')
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.getFdSplineEic" desc="获取试样信息">
        <![CDATA[
SELECT T.EIC
  FROM CRAFT_ORD_FD_PIC_SMP T
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND T.PHY_CODE_MIN = {3}
   AND NVL(T.ITEM_CODE_F, '1') = NVL({4}, '1')
   AND NVL(T.ITEM_CODE_C, '1') = NVL({5}, '1')
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.updateFdPicMemo" desc="修改首日检索引码备注">
        <![CDATA[
UPDATE CRAFT_ORD_FD_PIC T
   SET T.PIC_MEMO = {3}
 WHERE T.ORD_LN_PK = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
        ]]>
    </query>
    
    <query id="CraftOrdFdPic.exist" desc="是否存在">
        <![CDATA[
SELECT T.PIC
  FROM CRAFT_ORD_FD_PIC T
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.PIC <> '#PIC#'
        ]]>
    </query>
</queryMap>