<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质量设计公差">
	<query id="CraftOrdDesignStdSicDAL.query" desc="查询质量设计公差">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.SIC,
       T.USE_CODE,
       T.USE_DESC,
       T.SPECL_FL,
       T.INDEX_SEQ,
       T.BIAS_CODE,
       T.BIAS_NAME,
       T.LV,
       T.BIAS_CODE_Z,
       T.BIAS_NAME_Z,
       T.ZMIN_SIGN,
       T.ZMIN,
       T.ZMAX_SIGN,
       T.ZMAX,
       T.BIAS_CODE_C,
       T.BIAS_NAME_C,
       T.CMIN_SIGN,
       T.CMIN,
       T.CMAX_SIGN,
       T.CMAX,
       T.BIAS_CODE_S,
       T.BIAS_NAME_S,
       T.SMIN_SIGN,
       T.SMIN,
       T.SMAX_SIGN,
       T.SMAX,
       T.ISCHECK,
       T.STD_MIN_VAL,
       T.STD_MAX_VAL,
       T.STD_MIN_IN,
       T.STD_MAX_IN,
       T.STD_MIN_PERCENT,
       T.STD_MAX_PERCENT,
       T.STD_MIN_FORMULA,
       T.STD_MAX_FORMULA,
       T.STD_MIN_FORMULA_V,
       T.STD_MAX_FORMULA_V,
       T.STDMEMO
 FROM Craft_ORD_DESIGN_STD_SIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#SIC#', T.SIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdSicDAL.queryByDesignKeySic" desc="查询质量设计公差">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.SIC,
       T.USE_CODE,
       T.USE_DESC,
       SPECL_FL,
       T.INDEX_SEQ,
       T.BIAS_CODE,
       T.BIAS_NAME,
       T.LV,
       T.BIAS_CODE_Z,
       T.BIAS_NAME_Z,
       T.ZMIN_SIGN,
       T.ZMIN,
       T.ZMAX_SIGN,
       T.ZMAX,
       T.BIAS_CODE_C,
       T.BIAS_NAME_C,
       T.CMIN_SIGN,
       T.CMIN,
       T.CMAX_SIGN,
       T.CMAX,
       T.BIAS_CODE_S,
       T.BIAS_NAME_S,
       T.SMIN_SIGN,
       T.SMIN,
       T.SMAX_SIGN,
       T.SMAX,
       DECODE(T.ISCHECK, '0', 'False', '1', 'True') ISCHECK,
       T.STD_MIN_VAL,
       T.STD_MAX_VAL,
       T.STD_MIN_IN,
       T.STD_MAX_IN,
       T.STD_MIN_PERCENT,
       T.STD_MAX_PERCENT,
       T.STD_MIN_FORMULA,
       T.STD_MAX_FORMULA,
       DECODE(T.STD_MIN_FORMULA_V, '0', 'False', '1', 'True') STD_MIN_FORMULA_V,
       DECODE(T.STD_MAX_FORMULA_V, '0', 'False', '1', 'True') STD_MAX_FORMULA_V,
       T.STDMEMO,
       T.GROUP_SEQ,
       T.MSC_PLINE,
       T.PROCESS_CODE,
       A.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_SIC 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.SIC) = DECODE({3},'','1',{3})
   ORDER BY T.SIC, T.INDEX_SEQ
		]]>
	</query>
	
	<query id="CraftOrdDesignStdSicDAL.querySicByDesignKey" desc="查询质量设计公差">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.SIC
 FROM Craft_ORD_DESIGN_STD_SIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#SIC#', T.SIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdSicDAL.Insert" desc="新增">
        <![CDATA[
INSERT INTO CRAFT_ORD_DESIGN_STD_SIC
  (DESGIN_KEY,
   SIC,
   USE_CODE,
   USE_DESC,
   SPECL_FL,
   INDEX_SEQ,
   BIAS_CODE,
   BIAS_NAME,
   LV,
   BIAS_CODE_Z,
   BIAS_NAME_Z,
   ZMIN_SIGN,
   ZMIN,
   ZMAX_SIGN,
   ZMAX,
   BIAS_CODE_C,
   BIAS_NAME_C,
   CMIN_SIGN,
   CMIN,
   CMAX_SIGN,
   CMAX,
   BIAS_CODE_S,
   BIAS_NAME_S,
   SMIN_SIGN,
   SMIN,
   SMAX_SIGN,
   SMAX,
   ISCHECK,
   STD_MIN_VAL,
   STD_MAX_VAL,
   STD_MIN_IN,
   STD_MAX_IN,
   STD_MIN_PERCENT,
   STD_MAX_PERCENT,
   STD_MIN_FORMULA,
   STD_MAX_FORMULA,
   STD_MIN_FORMULA_V,
   STD_MAX_FORMULA_V,
   STDMEMO,
   GROUP_SEQ,
   MSC_PLINE,
   PROCESS_CODE,
   CREATE_NAME,
   CREATE_TIME,
   CRAFT_SOURCE)
VALUES
  ('#DESGIN_KEY#',
   '#SIC#',
   '#USE_CODE#',
   '#USE_DESC#',
   '#SPECL_FL#',
   '#INDEX_SEQ#',
   '#BIAS_CODE#',
   '#BIAS_NAME#',
   '#LV#',
   '#BIAS_CODE_Z#',
   '#BIAS_NAME_Z#',
   '#ZMIN_SIGN#',
   '#ZMIN#',
   '#ZMAX_SIGN#',
   '#ZMAX#',
   '#BIAS_CODE_C#',
   '#BIAS_NAME_C#',
   '#CMIN_SIGN#',
   '#CMIN#',
   '#CMAX_SIGN#',
   '#CMAX#',
   '#BIAS_CODE_S#',
   '#BIAS_NAME_S#',
   '#SMIN_SIGN#',
   '#SMIN#',
   '#SMAX_SIGN#',
   '#SMAX#',
   '#ISCHECK#',
   '#STD_MIN_VAL#',
   '#STD_MAX_VAL#',
   '#STD_MIN_IN#',
   '#STD_MAX_IN#',
   '#STD_MIN_PERCENT#',
   '#STD_MAX_PERCENT#',
   '#STD_MIN_FORMULA#',
   '#STD_MAX_FORMULA#',
   '#STD_MIN_FORMULA_V#',
   '#STD_MAX_FORMULA_V#',
   '#STDMEMO#',
   '#GROUP_SEQ#',
   '#MSC_PLINE#',
   '#PROCESS_CODE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdSicDAL.Update" desc="修改">
        <![CDATA[
UPDATE CRAFT_ORD_DESIGN_STD_SIC T
   SET T.DESGIN_KEY        = '#DESGIN_KEY#',
       T.SIC               = '#SIC#',
       T.USE_CODE          = '#USE_CODE#',
       T.USE_DESC          = '#USE_DESC#',
       T.SPECL_FL          = '#SPECL_FL#',
       T.INDEX_SEQ         = '#INDEX_SEQ#',
       T.BIAS_CODE         = '#BIAS_CODE#',
       T.BIAS_NAME         = '#BIAS_NAME#',
       T.LV                = '#LV#',
       T.BIAS_CODE_Z       = '#BIAS_CODE_Z#',
       T.BIAS_NAME_Z       = '#BIAS_NAME_Z#',
       T.ZMIN_SIGN         = '#ZMIN_SIGN#',
       T.ZMIN              = '#ZMIN#',
       T.ZMAX_SIGN         = '#ZMAX_SIGN#',
       T.ZMAX              = '#ZMAX#',
       T.BIAS_CODE_C       = '#BIAS_CODE_C#',
       T.BIAS_NAME_C       = '#BIAS_NAME_C#',
       T.CMIN_SIGN         = '#CMIN_SIGN#',
       T.CMIN              = '#CMIN#',
       T.CMAX_SIGN         = '#CMAX_SIGN#',
       T.CMAX              = '#CMAX#',
       T.BIAS_CODE_S       = '#BIAS_CODE_S#',
       T.BIAS_NAME_S       = '#BIAS_NAME_S#',
       T.SMIN_SIGN         = '#SMIN_SIGN#',
       T.SMIN              = '#SMIN#',
       T.SMAX_SIGN         = '#SMAX_SIGN#',
       T.SMAX              = '#SMAX#',
       T.ISCHECK           = '#ISCHECK#',
       T.STD_MIN_VAL       = '#STD_MIN_VAL#',
       T.STD_MAX_VAL       = '#STD_MAX_VAL#',
       T.STD_MIN_IN        = '#STD_MIN_IN#',
       T.STD_MAX_IN        = '#STD_MAX_IN#',
       T.STD_MIN_PERCENT   = '#STD_MIN_PERCENT#',
       T.STD_MAX_PERCENT   = '#STD_MAX_PERCENT#',
       T.STD_MIN_FORMULA   = '#STD_MIN_FORMULA#',
       T.STD_MAX_FORMULA   = '#STD_MAX_FORMULA#',
       T.STD_MIN_FORMULA_V = '#STD_MIN_FORMULA_V#',
       T.STD_MAX_FORMULA_V = '#STD_MAX_FORMULA_V#',
       T.STDMEMO           = '#STDMEMO#',
       T.GROUP_SEQ         = '#GROUP_SEQ#',
       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.SIC = '#SIC#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdSicDAL.GetMaxIndex" desc="获取最大序号">
        <![CDATA[
SELECT NVL(MAX(INDEX_SEQ), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_DESIGN_STD_SIC T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.SIC = '#SIC#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdSicDAL.Delete" desc="删除">
        <![CDATA[
DELETE FROM (SELECT *
                  FROM CRAFT_ORD_DESIGN_STD_SIC T
                 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
                   AND T.SIC = '#SIC#'
                   AND T.INDEX_SEQ = '#INDEX_SEQ#')
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdSicDAL.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.SIC                SIC,
       A.DESGIN_KEY         DESIGNKEY
  FROM CRAFT_ORD_DESIGN_MSC_PL A,
       CRAFT_ORD_DESIGN_MSC_PL_PRC B,
       (SELECT C.SIC, MSC_PLINE, PROCESS_CODE
          FROM CRAFT_ORD_DESIGN_STD_SIC C
         WHERE C.DESGIN_KEY = {0}
         GROUP BY C.SIC, 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>