<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工艺评审-理化标准">

	<query id="MscPhyDao.getExaminePic" desc="查询已审批理化索引号">
         <![CDATA[
      SELECT P.PIC, P.MODEL_CODE
   FROM (SELECT T.PIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
          FROM COM_MSC_STD_PIC T
         WHERE T.MSC = ?
           AND T.CODE_JG IS NULL
           AND T.VALIDFLAG = 3) P
 WHERE INSTR(P.MODEL_CODE, ?) > 0
    OR (P.MODEL_CODE = 'C001' AND NOT EXISTS
        (SELECT 1
           FROM (SELECT T.PIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                   FROM COM_MSC_STD_PIC T
                  WHERE T.MSC = ?
                    AND T.CODE_JG IS NULL
                    AND T.VALIDFLAG = 3) A
          WHERE INSTR(A.MODEL_CODE, ?) > 0))
 ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="MscPhyDao.getEValidPic" desc="查询有效理化索引号">
         <![CDATA[
      SELECT P.PIC, P.MODEL_CODE
   FROM (SELECT T.PIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
          FROM COM_MSC_STD_PIC T
         WHERE T.MSC = ?
           AND T.CODE_JG IS NULL
           AND T.VALIDFLAG != 0) P
 WHERE INSTR(P.MODEL_CODE, ?) > 0
    OR (P.MODEL_CODE = 'C001' AND NOT EXISTS
        (SELECT 1
           FROM (SELECT T.PIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                   FROM COM_MSC_STD_PIC T
                  WHERE T.MSC = ?
                    AND T.CODE_JG IS NULL
                    AND T.VALIDFLAG != 0) A
          WHERE INSTR(A.MODEL_CODE, ?) > 0))
 ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="MscPhyDao.getPhyByPic" desc="查询交付理化标准">
         <![CDATA[
SELECT T.PIC,
       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,
       T.GROUP_SEQ,
       T.RESULT_COUNT,
       T.ISCHECK,
       T.ISJUDGE,
       T.ISQUOTE,
       T.PHY_TYPE,
       T.PHY_FORMULA,
       T.STDMIN_SIGN,
       T.STDMIN,
       T.STDMAX_SIGN,
       T.STDMAX,
       T.JUDGE_BASIS,
       T.DELIVERYSTATE,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STDMEMO,
       T.SIZE_CODE2,
       T.SIZE_NAME2,
       T.SIZE_MIN_SIGN2,
       T.SIZE_MIN2,
       T.SIZE_MAX_SIGN2,
       T.SIZE_MAX2,
       T.SIZE_CODE,
       T.SIZE_NAME,
       T.SIZE_MIN_SIGN,
       T.SIZE_MIN,
       T.SIZE_MAX_SIGN,
       T.SIZE_MAX,
       T.SPEC_JG,
       T.SPEC_JG_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, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.VALIDFLAG,
       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.GUID,
       T.BILLET_SAMPLE,
       A.MEMO PIC_MEMO,
       T.FORMULA,
       T.MIN_F,
       T.MIN_F_SIGN,
       T.MAX_F,
       T.MAX_F_SIGN,
       T.PHY_MIN_SEQ,
       T.IS_PRODUCT_CHECK
  FROM COM_MSC_STD_PHY T, COM_MSC_STD_PIC A
 WHERE T.PIC = ?
   AND T.VALIDFLAG = '1'
   AND A.PIC = T.PIC
 ORDER BY 
          T.PHY_CODE_MAX,
          T.PHY_CODE_MIN,
          T.PHY_CODE,
          T.ITEM_CODE_F,
          T.ITEM_CODE_S,
          T.ITEM_CODE_W
             ]]>
	</query>

	<query id="MscPhyDao.savePhy" desc="保存工艺评审-理化标准">
         <![CDATA[
         INSERT INTO CRAFT_ORD_DESIGN_STD_PIC(
        DESGIN_KEY,
        PIC,
        USE_CODE,
        USE_DESC,
        SPECL_FL,
        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,
        GROUP_SEQ,
        ISCHECK,
        ISQUOTE,
        RESULT_COUNT,
        ISJUDGE,
        PHY_TYPE,
        PHY_FORMULA,
        STDMIN_SIGN,
        STDMIN,
        STDMAX_SIGN,
        STDMAX,
        JUDGE_BASIS,
        DELIVERYSTATE,
        MODEL_CODE,
        MODEL_DESC,
        STDMEMO,
        SIZE_CODE,
        SIZE_NAME,
        SIZE_MIN_SIGN,
        SIZE_MIN,
        SIZE_MAX_SIGN,
        SIZE_MAX,
        SIZE_CODE2,
        SIZE_NAME2,
        SIZE_MIN_SIGN2,
        SIZE_MIN2,
        SIZE_MAX_SIGN2,
        SIZE_MAX2,
        SPEC_JG,
        SPEC_JG_DESC,
        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,
        PIC_MEMO,
        FORMULA,
        MIN_F,
        MIN_F_SIGN,
        MAX_F,
        MAX_F_SIGN,
        PHY_MIN_SEQ,
        IS_PRODUCT_CHECK
        )
 VALUES( 
        '#DESGIN_KEY#',
        '#PIC#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#SPECL_FL#',
        '#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#',
        '#GROUP_SEQ#',
        '#ISCHECK#',
        '#ISQUOTE#',
        '#RESULT_COUNT#',
        '#ISJUDGE#',
        '#PHY_TYPE#',
        '#PHY_FORMULA#',
        '#STDMIN_SIGN#',
        '#STDMIN#',
        '#STDMAX_SIGN#',
        '#STDMAX#',
        '#JUDGE_BASIS#',
        '#DELIVERYSTATE#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#STDMEMO#',
        '#SIZE_CODE#',
        '#SIZE_NAME#',
        '#SIZE_MIN_SIGN#',
        '#SIZE_MIN#',
        '#SIZE_MAX_SIGN#',
        '#SIZE_MAX#',
        '#SIZE_CODE2#',
        '#SIZE_NAME2#',
        '#SIZE_MIN_SIGN2#',
        '#SIZE_MIN2#',
        '#SIZE_MAX_SIGN2#',
        '#SIZE_MAX2#',
        '#SPEC_JG#',
        '#SPEC_JG_DESC#',
        '#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#',
        '#PIC_MEMO#',
        '#FORMULA#',
        '#MIN_F#',
        '#MIN_F_SIGN#',
        '#MAX_F#',
        '#MAX_F_SIGN#',
        '#PHY_MIN_SEQ#',
        '#IS_PRODUCT_CHECK#')
             ]]>
	</query>


	<query id="MscPhyDao.getPicSample" desc="查询质量设计取样要求">
         <![CDATA[
SELECT T1.PIC,
       T1.SIC,
       T1.PHY_CODE_MIN,
       T1.PHY_NAME_MIN,
       T2.STD_CODE,
       T2.STD_NAME,
       T2.RATE,
       T2.DESC_RATE,
       T2.DESC_COUNT,
       T2.POSITION,
       T2.DESC_POSITION,
       T2.MEMO,
       T2.MIN_D,
       T2.MAX_D,
       T2.MIN_H,
       T2.MAX_H,
       T2.MIN_D_SIGN,
       T2.MAX_D_SIGN,
       T2.MIN_H_SIGN,
       T2.MAX_H_SIGN,
       T2.SAMPLE_COUNT,
       T2.BATCH_CNT,
       T2.BATCH_UNIT,
       T2.ATTACH_PERCENT,
       T2.ATTACH_COUNT,
       T2.TOP_STOVE,
       T2.LOOP_VALUE,
       T2.SSC_CONDITION,
       T2.EXCLUDE_PHY_MIN,
       T1.SAMPLE_KEY,
       T1.SAMPLE_KEY_DESC,
       T1.ITEM_CODE_F,
       T1.ITEM_CODE_C,
       T1.ITEM_CODE_W,
       T1.STD_CODE_TEST,
       T1.STD_NAME_TEST
  FROM COM_MSC_PHY_SAMPLE T1, COM_BASE_SAMPLE T2
 WHERE T1.SIC = T2.SIC
   AND T1.PIC = {0}
   AND T1.PHY_CODE_MIN = {1}
   AND DECODE({2}, NULL, '1', T1.ITEM_CODE_F) = DECODE({2}, NULL, '1', {2})
   AND DECODE({2}, NULL, T1.ITEM_CODE_F, NULL) IS NULL
   AND DECODE({3}, NULL, '1', T1.ITEM_CODE_C) = DECODE({3}, NULL, '1', {3})
   AND DECODE({3}, NULL, T1.ITEM_CODE_C, NULL) IS NULL
   AND DECODE({4}, NULL, '1', T1.ITEM_CODE_W) = DECODE({4}, NULL, '1', {4})
   AND DECODE({4}, NULL, T1.ITEM_CODE_W, NULL) IS NULL
   AND T1.VALIDFLAG = 1
   AND T2.VALIDFLAG = 1
   AND (EXISTS (SELECT 1
                  FROM COM_BASE_SAMPLE_R_STD A
                 WHERE A.SIC = T2.SIC
                   AND A.VALIDFLAG = '1'
                   AND A.STD_CODE = {5}) OR NOT EXISTS
        (SELECT 1
           FROM COM_BASE_SAMPLE_R_STD A
          WHERE A.SIC = T2.SIC
            AND A.VALIDFLAG = '1'))
   AND (EXISTS (SELECT 1
                  FROM COM_BASE_SAMPLE_R_STEEL A
                 WHERE A.SIC = T2.SIC
                   AND A.VALIDFLAG = '1'
                   AND A.STEELCODE = {6}) OR NOT EXISTS
        (SELECT 1
           FROM COM_BASE_SAMPLE_R_STEEL A
          WHERE A.SIC = T2.SIC
            AND A.VALIDFLAG = '1'))
   AND (EXISTS (SELECT 1
                  FROM COM_BASE_SAMPLE_R_PRODUCT A
                 WHERE A.SIC = T2.SIC
                   AND A.PRODUCCODE = {7}) OR NOT EXISTS
        (SELECT 1 FROM COM_BASE_SAMPLE_R_PRODUCT A WHERE A.SIC = T2.SIC))
             ]]>
	</query>

	<query id="MscPhyDao.getPicSpline" desc="查询质量设计试样要求">
         <![CDATA[
SELECT B.PHY_DIR,
       B.LENGTH,
       B.WIDTH,
       B.SAMPLE_STYLE,
       B.SIZE_DESC,
       C.MIN_D,
       C.MAX_D,
       C.MIN_H,
       C.MAX_H,
       C.MIN_D_SIGN,
       C.MIN_H_SIGN,
       C.MAX_D_SIGN,
       C.MAX_H_SIGN,
       C.FORMULA,
       C.MIN_F,
       C.MIN_F_SIGN,
       C.MAX_F,
       C.MAX_F_SIGN,
       A.EIC,
       A.SAMPLE_KEY,
       A.SAMPLE_KEY_DESC,
       A.ITEM_CODE_F,
       A.ITEM_CODE_C,
       A.ITEM_CODE_W,
       F.PIC,
       A.PHY_CODE_MIN
  FROM COM_MSC_PHY_SPLINE2 A,
       COM_BASE_SPLINE    B,
       COM_BASE_SPLINE_C  C,
       COM_MSC_PHY_SAMPLE F
 WHERE A.EIC = B.EIC
   AND A.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', A.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, A.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', A.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, A.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', A.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, A.ITEM_CODE_W, NULL) IS NULL
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', F.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, F.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', F.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, F.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', F.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, F.ITEM_CODE_W, NULL) IS NULL
   AND F.PHY_CODE_MIN = A.PHY_CODE_MIN
   AND F.STD_CODE_TEST = A.STD_CODE_TEST
   AND C.EIC = B.EIC
   AND C.STD_CODE = '#STD_CODE#'
   AND C.VALIDFLAG = '1'
   AND EXISTS
 (SELECT 1
          FROM COM_BASE_SPLINE_R_STD E
         WHERE E.EIC = B.EIC
           AND E.STD_CODE = F.STD_CODE_TEST)
   AND (EXISTS (SELECT 1
                  FROM COM_BASE_SPLINE_C_R_PRODUCT D
                 WHERE D.TIC = C.TIC
                   AND D.VALIDFLAG = '1'
                   AND D.PRODUCCODE = '#PRODUCCODE#') OR NOT EXISTS
        (SELECT 1
           FROM COM_BASE_SPLINE_C_R_PRODUCT D
          WHERE D.TIC = C.TIC
            AND D.VALIDFLAG = '1'))
   AND (EXISTS (SELECT 1
                  FROM COM_BASE_SPLINE_C_R_STEEL E
                 WHERE E.TIC = C.TIC
                   AND E.VALIDFLAG = '1'
                   AND E.STEELCODE = '#STEELCODE#') OR NOT EXISTS
        (SELECT 1
           FROM COM_BASE_SPLINE_C_R_STEEL E
          WHERE E.TIC = C.TIC
            AND E.VALIDFLAG = '1'))
UNION ALL
SELECT B.PHY_DIR,
       B.LENGTH,
       B.WIDTH,
       B.SAMPLE_STYLE,
       B.SIZE_DESC,
       NULL              MIN_D,
       NULL              MAX_D,
       NULL              MIN_H,
       NULL              MAX_H,
       NULL              MIN_D_SIGN,
       NULL              MIN_H_SIGN,
       NULL              MAX_D_SIGN,
       NULL              MAX_H_SIGN,
       NULL FORMULA,
       NULL MIN_F,
       NULL MIN_F_SIGN,
       NULL MAX_F_SIGN,
       NULL MAX_F,
       A.EIC,
       A.SAMPLE_KEY,
       A.SAMPLE_KEY_DESC,
       A.ITEM_CODE_F,
       A.ITEM_CODE_C,
       A.ITEM_CODE_W,
       F.PIC,
       A.PHY_CODE_MIN
  FROM COM_MSC_PHY_SPLINE2 A, COM_BASE_SPLINE B, COM_MSC_PHY_SAMPLE F
 WHERE A.EIC = B.EIC
   AND A.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', A.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, A.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', A.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, A.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', A.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, A.ITEM_CODE_W, NULL) IS NULL
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', F.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, F.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', F.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, F.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', F.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, F.ITEM_CODE_W, NULL) IS NULL
   AND F.PHY_CODE_MIN = A.PHY_CODE_MIN
   AND F.STD_CODE_TEST = A.STD_CODE_TEST
   AND NOT EXISTS (SELECT 1
          FROM COM_BASE_SPLINE_C C
         WHERE C.EIC = B.EIC
           AND C.VALIDFLAG = '1')
             ]]>
	</query>
	
	<query id="MscPhyDao.getPicSplineNk" desc="查询质量设计试样要求（内控）">
         <![CDATA[

SELECT B.PHY_DIR,
       B.LENGTH,
       B.WIDTH,
       B.SAMPLE_STYLE,
       B.SIZE_DESC,
       C.MIN_D,
       C.MAX_D,
       C.MIN_H,
       C.MAX_H,
       C.MIN_D_SIGN,
       C.MIN_H_SIGN,
       C.MAX_D_SIGN,
       C.MAX_H_SIGN,
       C.FORMULA,
       C.MIN_F,
       C.MIN_F_SIGN,
       C.MAX_F_SIGN,
       C.MAX_F,
       A.EIC,
       A.SAMPLE_KEY,
       A.SAMPLE_KEY_DESC,
       A.ITEM_CODE_C,
       A.ITEM_CODE_F,
       A.ITEM_CODE_W,
       F.PIC,
       A.PHY_CODE_MIN
  FROM COM_MSC_PHY_SPLINE2 A,
       COM_BASE_SPLINE    B,
       COM_BASE_SPLINE_C  C,
       COM_MSC_PHY_SAMPLE F
 WHERE A.EIC = B.EIC
   AND A.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', A.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, A.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', A.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, A.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', A.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, A.ITEM_CODE_W, NULL) IS NULL
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', F.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, F.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', F.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, F.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', F.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, F.ITEM_CODE_W, NULL) IS NULL
   AND F.PHY_CODE_MIN = A.PHY_CODE_MIN
   AND F.STD_CODE_TEST = A.STD_CODE_TEST
   AND C.EIC = B.EIC
   AND C.STD_CODE = '#STD_CODE#'
   AND C.VALIDFLAG = '1'
   AND EXISTS (SELECT 1
          FROM COM_BASE_SPLINE_R_STD E
         WHERE E.EIC = B.EIC
           AND E.STD_CODE = F.STD_CODE_TEST)
UNION ALL
SELECT B.PHY_DIR,
       B.LENGTH,
       B.WIDTH,
       B.SAMPLE_STYLE,
       B.SIZE_DESC,
       NULL              MIN_D,
       NULL              MAX_D,
       NULL              MIN_H,
       NULL              MAX_H,
       NULL              MIN_D_SIGN,
       NULL              MIN_H_SIGN,
       NULL              MAX_D_SIGN,
       NULL              MAX_H_SIGN,
       NULL FORMULA,
       NULL MIN_F,
       NULL MIN_F_SIGN,
       NULL MAX_F_SIGN,
       NULL MAX_F,
       A.EIC,
       A.SAMPLE_KEY,
       A.SAMPLE_KEY_DESC,
       A.ITEM_CODE_C,
       A.ITEM_CODE_F,
       A.ITEM_CODE_W,
       F.PIC,
       A.PHY_CODE_MIN
  FROM COM_MSC_PHY_SPLINE2 A, COM_BASE_SPLINE B, COM_MSC_PHY_SAMPLE F
 WHERE A.EIC = B.EIC
   AND A.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', A.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, A.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', A.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, A.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', A.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, A.ITEM_CODE_W, NULL) IS NULL
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', F.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, F.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', F.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, F.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', F.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, F.ITEM_CODE_W, NULL) IS NULL
   AND F.PHY_CODE_MIN = A.PHY_CODE_MIN
   AND F.STD_CODE_TEST = A.STD_CODE_TEST
   AND NOT EXISTS (SELECT 1
          FROM COM_BASE_SPLINE_C C
         WHERE C.EIC = B.EIC
           AND C.VALIDFLAG = '1')
             ]]>
	</query>

	<query id="MscPhyDao.savePicSample" desc="保存质量设计取样要求">
         <![CDATA[
INSERT INTO CRAFT_ORD_DESIGN_STD_PIC_SMP
  (DESGIN_KEY,
   PIC,
   SIC,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   STD_CODE,
   STD_NAME,
   LENGTH,
   DESC_LENGTH,
   RATE,
   DESC_RATE,
   DESC_COUNT,
   POSITION,
   DESC_POSITION,
   SAMPLE_COUNT,
   MEMO,
   SAMPLE_STYLE,
   WIDTH,
   BATCH_CNT,
   BATCH_UNIT,
   EIC,
   PHY_DIR,
   SIZE_DESC,
   SAMPLE_KEY,
   SAMPLE_KEY_DESC,
   ITEM_CODE_F,
   ITEM_CODE_C,
   ITEM_CODE_W,
   STD_CODE_TEST,
   STD_NAME_TEST,
   PROCESS_CODE,
   PROCESS_DESC,
   MSC_PLINE,
   ATTACH_PERCENT,
   ATTACH_COUNT,
   TOP_STOVE,
   LOOP_VALUE,
   SSC_CONDITION,
   EXCLUDE_PHY_MIN)
VALUES
  ('#DESGIN_KEY#',
   '#PIC#',
   '#SIC#',
   '#PHY_CODE_MIN#',
   '#PHY_NAME_MIN#',
   '#STD_CODE#',
   '#STD_NAME#',
   '#LENGTH#',
   '#DESC_LENGTH#',
   '#RATE#',
   '#DESC_RATE#',
   '#DESC_COUNT#',
   '#POSITION#',
   '#DESC_POSITION#',
   '#SAMPLE_COUNT#',
   '#MEMO#',
   '#SAMPLE_STYLE#',
   '#WIDTH#',
   '#BATCH_CNT#',
   '#BATCH_UNIT#',
   '#EIC#',
   '#PHY_DIR#',
   '#SIZE_DESC#',
   '#SAMPLE_KEY#',
   '#SAMPLE_KEY_DESC#',
   '#ITEM_CODE_F#',
   '#ITEM_CODE_C#',
   '#ITEM_CODE_W#',
   '#STD_CODE_TEST#',
   '#STD_NAME_TEST#',
   '#PROCESS_CODE#',
   '#PROCESS_DESC#',
   '#MSC_PLINE#',
   '#ATTACH_PERCENT#',
   '#ATTACH_COUNT#',
   '#TOP_STOVE#',
   '#LOOP_VALUE#',
   '#SSC_CONDITION#',
   '#EXCLUDE_PHY_MIN#')
             ]]>
	</query>
	
	<query id="MscPhyDao.savePicSpline" desc="保存质量设计试样要求">
         <![CDATA[
UPDATE CRAFT_ORD_DESIGN_STD_PIC_SMP T
   SET T.LENGTH             = '#LENGTH#',
       T.SAMPLE_STYLE       = '#SAMPLE_STYLE#',
       T.WIDTH              = '#WIDTH#',
       T.EIC                = '#EIC#',
       T.PHY_DIR            = '#PHY_DIR#',
       T.SIZE_DESC          = '#SIZE_DESC#',
       T.SPLINE_ITEM_CODE_F = '#SPLINE_ITEM_CODE_F#',
       T.SPLINE_ITEM_NAME_F = '#SPLINE_ITEM_NAME_F#',
       T.SPLINE_ITEM_CODE_S = '#SPLINE_ITEM_CODE_S#',
       T.SPLINE_ITEM_NAME_S = '#SPLINE_ITEM_NAME_S#'
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.PIC = '#PIC#'
   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.PROCESS_CODE = '#PROCESS_CODE#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
             ]]>
	</query>
	
	<query id="MscPhyDao.getCraftPicSmp" desc="获取工艺评审取样信息">
         <![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T
 WHERE T.DESGIN_KEY = {0}
   AND T.CRAFT_SOURCE = '0'
             ]]>
	</query>

	<query id="MscPhyDao.updateDesignStd" desc="修改交付标准索引号">
         <![CDATA[
      UPDATE CRAFT_ORD_DESIGN_STD SET PIC = ? WHERE DESGIN_KEY = ?
             ]]>
	</query>

	<query id="MscPhyDao.checkSmp" desc="验证取样要求">
         <![CDATA[
      SELECT T.PIC
  FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.PIC = '#PIC#'
   AND T.SIC = '#SIC#'
   AND T.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND DECODE('#ITEM_CODE_F#', NULL, '1', T.ITEM_CODE_F) =
       DECODE('#ITEM_CODE_F#', NULL, '1', '#ITEM_CODE_F#')
   AND DECODE('#ITEM_CODE_F#', NULL, T.ITEM_CODE_F, NULL) IS NULL
   AND DECODE('#ITEM_CODE_C#', NULL, '1', T.ITEM_CODE_C) =
       DECODE('#ITEM_CODE_C#', NULL, '1', '#ITEM_CODE_C#')
   AND DECODE('#ITEM_CODE_C#', NULL, T.ITEM_CODE_C, NULL) IS NULL
   AND DECODE('#ITEM_CODE_W#', NULL, '1', T.ITEM_CODE_W) =
       DECODE('#ITEM_CODE_W#', NULL, '1', '#ITEM_CODE_W#')
   AND DECODE('#ITEM_CODE_W#', NULL, T.ITEM_CODE_W, NULL) IS NULL
             ]]>
	</query>
	
	<query id="MscPhyDao.getStdCodeNkByPic" desc="通过Pic获取内控标准">
         <![CDATA[
SELECT T.STD_CODE_NK VALUE FROM COM_MSC_STD_PIC T WHERE T.PIC = {0}
             ]]>
	</query>

	<query id="MscPhyDao.getMscStdPicByPk" desc="通过Pic获取理化主表">
         <![CDATA[
SELECT * FROM COM_MSC_STD_PIC T WHERE T.PIC = {0}
             ]]>
	</query>
	
	<query id="MscPhyDao.getBaseImpact" desc="通过主键查询冲击主表">
         <![CDATA[
SELECT * FROM COM_BASE_IMPACT T WHERE T.ID = {0}
             ]]>
	</query>
	
	<query id="MscPhyDao.getBaseSplineLength" desc="获取样条长度">
         <![CDATA[
SELECT T.*, C.ITEM_NAME ITEM_NAME_F, D.ITEM_NAME ITEM_NAME_C
  FROM COM_BASE_SPLINE_LENGTH T
  LEFT JOIN COM_BASE_PHY_ITEM C
    ON C.ITEM_CODE = T.ITEM_CODE_F
  LEFT JOIN COM_BASE_PHY_ITEM D
    ON D.ITEM_CODE = T.ITEM_CODE_C, COM_BASE_IMPACT A, COM_BASE_IMPACT_C B
 WHERE T.ITEM_CODE_F = {0}
   AND T.VALIDFLAG = '1'
   AND T.ITEM_CODE_C = B.ITEM_CODE_C
   AND B.ID = A.ID
   AND B.VALIDFLAG = '1'
   AND A.ID = {1}
   AND A.VALIDFLAG = '1'
   AND T.SPLINE_SHAPE IN ('0', A.ALLOW_ARC)
 ORDER BY T.ID
             ]]>
	</query>
	
	<query id="MscPhyDao.getBaseImpactC" desc="查询冲击值从表">
         <![CDATA[
SELECT T.ID,
       T.INDEX_SEQ,
       T.ITEM_CODE_C,
       T.ITEM_SPEC,
       T.ITEM_WIDTH,
       TO_CHAR(T.DECLINE_RATIO, 'FM0.000') DECLINE_RATIO,
       T.CREATE_NAME,
       T.CREATE_TIME,
       T.UPDATE_NAME,
       T.UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME,
       T.VALIDFLAG,
       T.MEMO
  FROM COM_BASE_IMPACT_C T
 WHERE T.ITEM_CODE_C = {0}
   AND T.ID = {1}
   AND T.VALIDFLAG = '1'
             ]]>
	</query>
	
	<query id="MscPhyDao.getSplineMinSize" desc="查询最小冲击尺寸">
         <![CDATA[
SELECT B.ITEM_CODE_S, T2.ITEM_NAME ITEM_NAME_S, NULL RATE
  FROM COM_BASE_SPLINE_STD_SPEC B
  LEFT JOIN COM_BASE_PHY_ITEM T2
    ON T2.ITEM_CODE = B.ITEM_CODE_S, COM_BASE_SPLINE_STD A
 WHERE A.SPLINE_DIRECTION = {0}
   AND INSTR(A.SPLINE_STD_CODE, {1}) > 0
   AND B.ID = A.ID
   AND COMPARE_VALUE({3}, B.MIN_D_SIGN, B.MIN_D) = 1
   AND COMPARE_VALUE({3}, B.MAX_D_SIGN, B.MAX_D) = 1
   AND COMPARE_VALUE({4}, B.MIN_H_SIGN, B.MIN_H) = 1
   AND COMPARE_VALUE({4}, B.MAX_H_SIGN, B.MAX_H) = 1
UNION ALL
SELECT T.ITEM_CODE_S, T2.ITEM_NAME ITEM_NAME_S, T.RATE
  FROM COM_BASE_SPLINE_STD_SIZE T
  LEFT JOIN COM_BASE_PHY_ITEM T2
    ON T2.ITEM_CODE = T.ITEM_CODE_S, COM_BASE_SPLINE_STD A
 WHERE A.SPLINE_DIRECTION = {0}
   AND INSTR(A.SPLINE_STD_CODE, {1}) > 0
   AND T.ID = A.ID
   AND COMPARE_VALUE({2}, T.MIN_SIGN, T.MIN_SIZE) = 1
   AND COMPARE_VALUE({2}, T.MAX_SIGN, T.MAX_SIZE) = 1
         ]]>
	</query>
	
	<query id="MscPhyDao.getSplineMinSizeByName" desc="查询最小冲击尺寸">
         <![CDATA[
SELECT B.ITEM_CODE_S, T2.ITEM_NAME ITEM_NAME_S, NULL RATE
  FROM COM_BASE_SPLINE_STD_SPEC B
  LEFT JOIN COM_BASE_PHY_ITEM T2
    ON T2.ITEM_CODE = B.ITEM_CODE_S, COM_BASE_SPLINE_STD A
 WHERE A.SPLINE_DIRECTION = {0}
   AND UPPER(TO_CHAR((SELECT wm_concat(STD.STD_NAME)
                 FROM COM_BASE_STD STD
                WHERE INSTR(A.SPLINE_STD_CODE, STD.STD_CODE) > 0))) LIKE UPPER('%'||{1}||'%')
   AND B.ID = A.ID
   AND COMPARE_VALUE({3}, B.MIN_D_SIGN, B.MIN_D) = 1
   AND COMPARE_VALUE({3}, B.MAX_D_SIGN, B.MAX_D) = 1
   AND COMPARE_VALUE({4}, B.MIN_H_SIGN, B.MIN_H) = 1
   AND COMPARE_VALUE({4}, B.MAX_H_SIGN, B.MAX_H) = 1
UNION ALL
SELECT T.ITEM_CODE_S, T2.ITEM_NAME ITEM_NAME_S, T.RATE
  FROM COM_BASE_SPLINE_STD_SIZE T
  LEFT JOIN COM_BASE_PHY_ITEM T2
    ON T2.ITEM_CODE = T.ITEM_CODE_S, COM_BASE_SPLINE_STD A
 WHERE A.SPLINE_DIRECTION = {0}
   AND UPPER(TO_CHAR((SELECT wm_concat(STD.STD_NAME)
                 FROM COM_BASE_STD STD
                WHERE INSTR(A.SPLINE_STD_CODE, STD.STD_CODE) > 0))) LIKE UPPER('%'||{1}||'%')
   AND T.ID = A.ID
   AND COMPARE_VALUE({2}, T.MIN_SIGN, T.MIN_SIZE) = 1
   AND COMPARE_VALUE({2}, T.MAX_SIGN, T.MAX_SIZE) = 1
         ]]>
	</query>
	
	<query id="MscPhyDao.checkStdIsExist" desc="查询最小冲击尺寸">
         <![CDATA[
SELECT count(1)
  FROM COM_BASE_SPLINE_STD A
 WHERE  A.SPLINE_DIRECTION = ?
  		AND UPPER(TO_CHAR((SELECT wm_concat(STD.STD_NAME)
                 FROM COM_BASE_STD STD
                WHERE INSTR(A.SPLINE_STD_CODE, STD.STD_CODE) > 0))) LIKE UPPER('%'||?||'%')

         ]]>
	</query>
	
<query id="MscPhyDao.queryMscStdName" desc="查询质量设计MSC">
		<![CDATA[
SELECT T.MSC,
       T.DESGIN_KEY,
       T.STD_NAME
  FROM Craft_ORD_DESIGN_MSC T
 WHERE T.DESGIN_KEY = {0}
 AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="MscPhyDao.getComBaseImpactTempC" desc="查询递减温度">
         <![CDATA[
SELECT T.TEMP_REDUCE
  FROM COM_BASE_IMPACT_TEMP_C T
 WHERE T.ID = {0}
   AND T.VALIDFLAG = '1'
   AND T.ITEM_CODE_C = {1}
   AND COMPARE_VALUE({2}, T.MIN_H_SIGN, T.MIN_H) = 1
   AND COMPARE_VALUE({2}, T.MAX_H_SIGN, T.MAX_H) = 1
         ]]>
	</query>
	
	<query id="MscPhyDao.getPhyItemW" desc="查询递减温度">
         <![CDATA[
 SELECT T.ITEM_NAME, T.ITEM_CODE
     FROM COM_BASE_PHY_ITEM T
    WHERE T.ITEM_NAME = {0}
      AND T.VALIDFLAG = '1'
         ]]>
	</query>

	<query id="MscPhyDao.getLashenCraftPhys" desc="查询拉伸工艺理化">
		<![CDATA[
SELECT T.PIC, T.INDEX_SEQ, T.STDMIN, T.STDMAX, T.STDMIN2, T.STDMAX2, T.PHY_CODE_MIN, T.DESGIN_KEY,T.ITEM_CODE_F
     FROM CRAFT_ORD_DESIGN_STD_PIC T
    WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
      AND T.PHY_CODE_MAX = 'R0001'
      AND (T.STDMIN LIKE '%Axc%' OR T.STDMAX LIKE '%Axc%' OR
          T.STDMIN2 LIKE '%Axc%' OR T.STDMAX2 LIKE '%Axc%')
         ]]>
	</query>

	<query id="MscPhyDao.getLashenSize" desc="查询拉伸工艺理化尺寸">
		<![CDATA[
SELECT T.SIZE_DESC, T.PHY_CODE_MIN,T.ITEM_CODE_F
            FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T, COM_BASE_PHY_C A
           WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
             AND A.PHY_TYPE_M = 'R0001'
             AND A.PHY_CODE = T.PHY_CODE_MIN
         ]]>
	</query>

	<query id="MscPhyDao.setLashenStdValue" desc="修改拉伸标准值">
		<![CDATA[
 UPDATE CRAFT_ORD_DESIGN_STD_PIC T
             SET T.STDMIN  = '#STDMIN#',
                 T.STDMAX  = '#STDMAX#',
                 T.STDMIN2 = '#STDMIN2#',
                 T.STDMAX2 = '#STDMAX2#'
           WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
             AND T.PIC = '#PIC#'
             AND T.INDEX_SEQ = '#INDEX_SEQ#'
         ]]>
	</query>
</queryMap> 