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

     	<query id="IMscWaterDao.getExamineWic" desc="查询审批水压索引号">
         <![CDATA[
   SELECT *
  FROM COM_MSC_STD_WATER W
 WHERE W.WIC IN
       (SELECT P.WIC
          FROM (SELECT WIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                  FROM COM_MSC_STD_WATER 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 WIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                           FROM COM_MSC_STD_WATER T
                          WHERE T.MSC = ?
                            AND T.CODE_JG IS NULL
                            AND T.VALIDFLAG = 3) Q
                  WHERE INSTR(Q.MODEL_CODE, ?) > 0)))
             ]]>
	  </query>
	  
	  	<query id="IMscWaterDao.getValidWic" desc="查询有效水压索引号">
         <![CDATA[
   SELECT *
  FROM COM_MSC_STD_WATER W
 WHERE W.WIC IN
       (SELECT P.WIC
          FROM (SELECT WIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                  FROM COM_MSC_STD_WATER 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 WIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                           FROM COM_MSC_STD_WATER T
                          WHERE T.MSC = ?
                            AND T.CODE_JG IS NULL
                            AND T.VALIDFLAG != 0) Q
                  WHERE INSTR(Q.MODEL_CODE, ?) > 0)))
             ]]>
	  </query>
	  
	  
	  <query id="IMscWaterDao.getWaterByWic" desc="查詢交付水压标准">
         <![CDATA[
      SELECT WIC,
       XH,
       PRESSURE_Y,
       PRESSURE,
       FORMULA,
       SAVE_TIME,
       MEMO,
       GET_MAXVALUE,
       GET_MINVALUE,
       ROUND_RULE
  FROM COM_MSC_STD_WATER_C T
 WHERE T.WIC = ?
   AND T.VALIDFLAG = 1
             ]]>
	</query>
	
	<query id="IMscWaterDao.saveWic" desc="保存质量设计水压标准">
         <![CDATA[
        INSERT INTO SLM_ORD_DESIGN_STD_WIC(
        DESGIN_KEY,
        WIC,
        USE_CODE,
        USE_DESC,
        SPECL_FL,
        INDEX_SEQ,
        PRESSURE_Y,
        PRESSURE,
        FORMULA,
        SAVE_TIME,
        GET_MAXVALUE,
        GET_MINVALUE,
        RATIO_STD,
        RATIO_REPLACE,
        MAX_PRESS,
        ROUND_RULE)
 VALUES( 
        '#DESGIN_KEY#',
        '#WIC#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#SPECL_FL#',
        '#INDEX_SEQ#',
        '#PRESSURE_Y#',
        '#PRESSURE#',
        '#FORMULA#',
        '#SAVE_TIME#',
        '#GET_MAXVALUE#',
        '#GET_MINVALUE#',
        '#RATIO_STD#',
        '#RATIO_REPLACE#',
        '#MAX_PRESS#',
        '#ROUND_RULE#')
             ]]>
	</query>
	
	
	<query id="IMscWaterDao.getWaterRatioId" desc="查询引用水压标准主键">
         <![CDATA[
   SELECT T.STD_CODE, T.STD_STYLE
  FROM COM_BASE_WATER_RATIO_STD T
 WHERE T.STD_CODE_C = ? AND
       DECODE(?, NULL, '1', T.STD_STYLE_C) = decode(?, null, '1', ?)
   AND DECODE(?, NULL, T.STD_STYLE_C, NULL) IS NULL
   AND T.VALIDFLAG = 1
             ]]>
	</query>
	
	<query id="IMscWaterDao.getPressByMajor" desc="通过水压主键找水压系数和压力">
         <![CDATA[
   SELECT RATIO_STD, MAX_PRESS
  FROM COM_BASE_WATER_RATIO T
 WHERE T.RATIO_ID = ? AND T.VALIDFLAG = 1
             ]]>
	</query>
	
	<query id="IMscWaterDao.getWaterPress" desc="查询水压系数">
         <![CDATA[
SELECT A.RATIO_ID,
       STD_CODE,
       STD_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       RATIO_STD,
       RATIO_REPLACE,
       MAX_PRESS,
       STD_STYLE,
       STD_STYLE_DESC,
       B.MODEL_CODE,
       B.MODEL_DESC,
       C.STEELCODE
  FROM COM_BASE_WATER_RATIO A
  JOIN COM_BASE_WATER_RATIO_MODEL B
    ON A.RATIO_ID = B.RATIO_ID
  JOIN COM_BASE_WATER_RATIO_STEEL C
    ON A.RATIO_ID = C.RATIO_ID
 WHERE B.MODEL_CODE = ?
   AND A.STD_CODE = ?
   AND C.STEELCODE = ?
   AND NVL(A.STD_STYLE, '1') = NVL(?, '1')
   AND A.VALIDFLAG = 1
   AND B.VALIDFLAG = 1
   AND C.VALIDFLAG = 1
             ]]>
	</query>
	
	<query id="IMscWaterDao.getWaterPressOther" desc="查询水压系数">
         <![CDATA[
     SELECT A.RATIO_ID,
       STD_CODE,
       STD_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       RATIO_STD,
       RATIO_REPLACE,
       MAX_PRESS,
       STD_STYLE,
       STD_STYLE_DESC,
       B.MODEL_CODE,
       B.MODEL_DESC,
       C.STEELCODE
  FROM COM_BASE_WATER_RATIO A
  JOIN COM_BASE_WATER_RATIO_MODEL B
    ON A.RATIO_ID = B.RATIO_ID
  JOIN COM_BASE_WATER_RATIO_STEEL C
    ON A.RATIO_ID = C.RATIO_ID
 WHERE B.MODEL_CODE = ?
   AND A.STD_CODE = ?
   AND C.STEELCODE = ?
   AND  A.STD_STYLE = '004'
   AND A.VALIDFLAG = 1
   AND B.VALIDFLAG = 1
   AND C.VALIDFLAG = 1
             ]]>
	</query>
	
	<query id="IMscWaterDao.updateDesignStd" desc="修改交付标准索引号">
         <![CDATA[
      UPDATE SLM_ORD_DESIGN_STD SET WIC = ? WHERE DESGIN_KEY = ?
             ]]>
	</query>
	
	<query id="IMscWaterDao.getSetRatioId" desc="获取设定水压系数">
         <![CDATA[
SELECT T.RATIO_ID VALUE FROM CRAFT_ORD_DESIGN_STD_WIC_S T WHERE T.ORD_LN_PK = {0}
             ]]>
	</query>
	
	<query id="IMscWaterDao.getWaterYS" desc="获取水压最小屈服强度">
         <![CDATA[
SELECT MIN(TT.STDMIN) VALUE
  FROM (SELECT T.STDMIN
          FROM SLM_ORD_DESIGN_STD_PIC T
         WHERE T.DESGIN_KEY = {0}
           AND T.PHY_CODE IN ('P0002',
                              'P0003',
                              'P0016',
                              'P0017',
                              'P0018',
                              'P0019',
                              'P0102',
                              'P0151',
                              'P0349',
                              'P0445',
                              'P0446')
           AND T.SPECL_FL = '1'
           AND T.STDMIN IS NOT NULL
        UNION ALL
        SELECT T.STDMIN
          FROM SLM_ORD_DESIGN_STD_PIC T
         WHERE T.DESGIN_KEY = {0}
           AND T.PHY_CODE IN ('P0002',
                              'P0003',
                              'P0016',
                              'P0017',
                              'P0018',
                              'P0019',
                              'P0102',
                              'P0151',
                              'P0349',
                              'P0445',
                              'P0446')
           AND T.SPECL_FL = '0'
           AND T.STDMIN IS NOT NULL
           AND NOT EXISTS (SELECT 1
                  FROM SLM_ORD_DESIGN_STD_PIC A
                 WHERE A.DESGIN_KEY = T.DESGIN_KEY
                   AND A.PHY_CODE = T.PHY_CODE
                   AND A.STDMIN IS NOT NULL
                   AND A.SPECL_FL = '1')) TT
             ]]>
	</query>
	
	<query id="IMscWaterDao.getWaterTS" desc="获取水压最小抗拉强度">
         <![CDATA[
SELECT MIN(TT.STDMIN) VALUE
  FROM (SELECT T.STDMIN
          FROM SLM_ORD_DESIGN_STD_PIC T
         WHERE T.DESGIN_KEY = {0}
           AND T.PHY_CODE = 'P0025'
           AND T.SPECL_FL = '1'
           AND T.STDMIN IS NOT NULL
        UNION ALL
        SELECT T.STDMIN
          FROM SLM_ORD_DESIGN_STD_PIC T
         WHERE T.DESGIN_KEY = {0}
           AND T.PHY_CODE = 'P0025'
           AND T.SPECL_FL = '0'
           AND T.STDMIN IS NOT NULL
           AND NOT EXISTS (SELECT 1
                  FROM SLM_ORD_DESIGN_STD_PIC A
                 WHERE A.DESGIN_KEY = T.DESGIN_KEY
                   AND A.PHY_CODE = T.PHY_CODE
                   AND A.SPECL_FL = '1'
                   AND A.STDMIN IS NOT NULL)) TT
             ]]>
	</query>
</queryMap>