<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质量设计理化">
	<query id="CraftOrdDesignStdPicDAL.query" desc="查询质量设计理化">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.PIC,
       T.USE_CODE,
       T.USE_DESC,
       T.SPECL_FL,
       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.ISCHECK,
       T.ISQUOTE,
       T.RESULT_COUNT,
       T.ISJUDGE,
       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_CODE,
       T.SIZE_NAME,
       T.SIZE_MIN_SIGN,
       T.SIZE_MIN,
       T.SIZE_MAX_SIGN,
       T.SIZE_MAX,
       T.SIZE_CODE2,
       T.SIZE_NAME2,
       T.SIZE_MIN_SIGN2,
       T.SIZE_MIN2,
       T.SIZE_MAX_SIGN2,
       T.SIZE_MAX2,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       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
 FROM Craft_ORD_DESIGN_STD_PIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#PIC#', T.PIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPicDAL.queryByDesignKeyPic" desc="查询工艺评审理化">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.PIC,
       T.USE_CODE,
       T.USE_DESC,
       SPECL_FL,
       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,
       DECODE(T.ISCHECK, '0', 'False', '1', 'True','False') ISCHECK,
       DECODE(T.ISQUOTE, '0', 'False', '1', 'True','False') ISQUOTE,
       T.RESULT_COUNT,
       DECODE(T.ISJUDGE, '0', 'False', '1', 'True','False') ISJUDGE,
       DECODE(T.PHY_TYPE, '0', 'False', '1', 'True','False') 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_CODE,
       T.SIZE_NAME,
       T.SIZE_MIN_SIGN,
       T.SIZE_MIN,
       T.SIZE_MAX_SIGN,
       T.SIZE_MAX,
       T.SIZE_CODE2,
       T.SIZE_NAME2,
       T.SIZE_MIN_SIGN2,
       T.SIZE_MIN2,
       T.SIZE_MAX_SIGN2,
       T.SIZE_MAX2,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       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,
       A.PROCESS_DESC_C,
       DECODE(T.BILLET_SAMPLE, '0', 'False', '1', 'True','False') BILLET_SAMPLE,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       CRAFT_SOURCE
  FROM CRAFT_ORD_DESIGN_STD_PIC 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.PIC) = DECODE({3},'','1',{3})
   AND T.PHY_CODE_MIN = {4}
   ORDER BY T.PIC, T.INDEX_SEQ
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPicDAL.queryPicByDesignKey" desc="查询质量设计理化">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.PIC
 FROM Craft_ORD_DESIGN_STD_PIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#PIC#', T.PIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPicDAL.Insert" 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,
   CREATE_NAME,
   CREATE_TIME,
   CRAFT_SOURCE)
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#',
   '#CREATE_NAME#',
   SYSDATE,
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdPicDAL.Update" desc="修改">
        <![CDATA[
UPDATE CRAFT_ORD_DESIGN_STD_PIC T
   SET T.DESGIN_KEY      = '#DESGIN_KEY#',
       T.PIC             = '#PIC#',
       T.USE_CODE        = '#USE_CODE#',
       T.USE_DESC        = '#USE_DESC#',
       T.SPECL_FL        = '#SPECL_FL#',
       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.GROUP_SEQ       = '#GROUP_SEQ#',
       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.DELIVERYSTATE   = '#DELIVERYSTATE#',
       T.MODEL_CODE      = '#MODEL_CODE#',
       T.MODEL_DESC      = '#MODEL_DESC#',
       T.STDMEMO         = '#STDMEMO#',
       T.SIZE_CODE       = '#SIZE_CODE#',
       T.SIZE_NAME       = '#SIZE_NAME#',
       T.SIZE_MIN_SIGN   = '#SIZE_MIN_SIGN#',
       T.SIZE_MIN        = '#SIZE_MIN#',
       T.SIZE_MAX_SIGN   = '#SIZE_MAX_SIGN#',
       T.SIZE_MAX        = '#SIZE_MAX#',
       T.SIZE_CODE2      = '#SIZE_CODE2#',
       T.SIZE_NAME2      = '#SIZE_NAME2#',
       T.SIZE_MIN_SIGN2  = '#SIZE_MIN_SIGN2#',
       T.SIZE_MIN2       = '#SIZE_MIN2#',
       T.SIZE_MAX_SIGN2  = '#SIZE_MAX_SIGN2#',
       T.SIZE_MAX2       = '#SIZE_MAX2#',
       T.SPEC_JG         = '#SPEC_JG#',
       T.SPEC_JG_DESC    = '#SPEC_JG_DESC#',
       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.CRAFT_SOURCE    = '#CRAFT_SOURCE#',
       T.UPDATE_NAME     = '#UPDATE_NAME#',
       T.UPDATE_TIME     = SYSDATE
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.PIC = '#PIC#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdPicDAL.GetMaxIndex" desc="获取最大序号">
        <![CDATA[
SELECT NVL(MAX(INDEX_SEQ), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.PIC = '#PIC#'
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdPicDAL.Delete" desc="获取最大序号">
        <![CDATA[
DELETE FROM (SELECT *
                  FROM CRAFT_ORD_DESIGN_STD_PIC T
                 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
                   AND T.PIC = '#PIC#'
                   AND T.INDEX_SEQ = '#INDEX_SEQ#')
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdPicDAL.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.PIC                PIC,
       A.DESGIN_KEY         DESIGNKEY
  FROM CRAFT_ORD_DESIGN_MSC_PL A,
       CRAFT_ORD_DESIGN_MSC_PL_PRC B,
       (SELECT C.PIC, MSC_PLINE, PROCESS_CODE
          FROM CRAFT_ORD_DESIGN_STD_PIC C
         WHERE C.DESGIN_KEY = {0}
         GROUP BY C.PIC, 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>
    
    <query id="CraftOrdDesignStdPicDAL.getGroupPhyMin" desc="获取评审记录试样组的分组">
        <![CDATA[
SELECT
    TT.PHY_CODE_MIN,
       TT.PHY_NAME_MIN,
       TT.ITEM_CODE_F,
       TT.ITEM_CODE_C   ITEM_CODE_S,
       TT.ITEM_CODE_W,
       TT.POSITION,
       TT.DESC_POSITION,
       TT.DESC_COUNT,
       TT.SAMPLE_COUNT,
       A.ITEM_NAME      ITEM_NAME_F,
       B.ITEM_NAME      ITEM_NAME_S,
       C.ITEM_NAME      ITEM_NAME_W
  FROM (SELECT T.PHY_CODE_MIN,
               T.PHY_NAME_MIN,
               T.ITEM_CODE_F,
               T.ITEM_CODE_C,
               T.ITEM_CODE_W,
               T.POSITION,
               T.DESC_POSITION,
               T.DESC_COUNT,
               T.SAMPLE_COUNT
          FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T
         WHERE T.DESGIN_KEY = {0}
             AND  DECODE({1},'','1',T.PIC) = DECODE({1},'','1',{1})
           AND T.MSC_PLINE = {2}
           AND T.PROCESS_CODE = {3}
         GROUP BY T.PHY_CODE_MIN,
                  T.PHY_NAME_MIN,
                  T.ITEM_CODE_F,
                  T.ITEM_CODE_C,
                  T.ITEM_CODE_W,
                  T.POSITION,
                  T.DESC_POSITION,
                  T.DESC_COUNT,
                  T.SAMPLE_COUNT) TT
  LEFT JOIN COM_BASE_PHY_ITEM A
    ON A.ITEM_CODE = TT.ITEM_CODE_F
  LEFT JOIN COM_BASE_PHY_ITEM B
    ON B.ITEM_CODE = TT.ITEM_CODE_C
  LEFT JOIN COM_BASE_PHY_ITEM C
    ON C.ITEM_CODE = TT.ITEM_CODE_W
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdPicDAL.getPhyNameMin" desc="获取试样组基础数据">
        <![CDATA[
SELECT T.PHY_CODE   PHY_CODE_MIN,
        T.PHY_TYPE   PHY_NAME_MIN,
        T.PHY_TYPE_M PHY_CODE_MAX,
        A.PHY_TYPE   PHY_NAME_MAX
   FROM COM_BASE_PHY_C T, COM_BASE_PHY_B A
  WHERE A.PHY_CODE = T.PHY_TYPE_M
    AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdPicDAL.getPhyMaxByPhyMin" desc="通过试样组获取检验大项">
        <![CDATA[
SELECT B.PHY_CODE PHY_CODE_MAX, B.PHY_TYPE PHY_NAME_MAX, A.PHY_TYPE PHY_NAME_MIN
  FROM COM_BASE_PHY_C A, COM_BASE_PHY_B B
 WHERE A.PHY_CODE = {0}
   AND A.PHY_TYPE_M = B.PHY_CODE
        ]]>
    </query>
</queryMap>