<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="公差标准">

	<query id="IMscSpecDao.getExamineSic" desc="查询已审批公差索引号">
         <![CDATA[
    SELECT P.SIC
     FROM (SELECT T.SIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
             FROM COM_MSC_STD_SPEC 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.SIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                   FROM COM_MSC_STD_SPEC T
                  WHERE T.MSC = ?
                    AND T.CODE_JG IS NULL
                    AND T.VALIDFLAG = 3) Q
          WHERE INSTR(Q.MODEL_CODE, ?) > 0))
 ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="IMscSpecDao.getvalidSic" desc="查询有效公差索引号">
         <![CDATA[
    SELECT P.SIC
     FROM (SELECT T.SIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
             FROM COM_MSC_STD_SPEC 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.SIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                   FROM COM_MSC_STD_SPEC T
                  WHERE T.MSC = ?
                    AND T.CODE_JG IS NULL
                    AND T.VALIDFLAG != 0) Q
          WHERE INSTR(Q.MODEL_CODE, ?) > 0))
 ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="IMscSpecDao.getSpecBySic" desc="查詢交付公差标准">
         <![CDATA[
      SELECT SIC,
       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
  FROM COM_MSC_STD_SPEC_C T
 WHERE T.SIC = ?
   AND T.VALIDFLAG = 1
             ]]>
	</query>

	<query id="IMscSpecDao.saveSic" desc="保存质量设计公差标准">
         <![CDATA[
       INSERT INTO SLM_ORD_DESIGN_STD_SIC(
        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,
        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)
 VALUES( 
        '#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#',
        '#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#')
             ]]>
	</query>

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

	<query id="IMscSpecDao.getSicFlag" desc="查询公差标准差值是否小于15确认标识">
         <![CDATA[
     SELECT T.SIC_FLAG FROM slm_ord_design_sic_control T WHERE T.ORD_LN_PK = ?
             ]]>
	</query>
</queryMap>