<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工艺评审取样表">
	<query id="JdgCraftOrdDesignStdPicSmp.getSscConditonCnt" desc="查询硬度最高的数">
		<![CDATA[
SELECT COUNT(1) COUNT
  FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T,
       CRAFT_ORD_DESIGN B
 WHERE B.ORD_LN_PK = {0}
   AND B.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = B.DESGIN_KEY
   AND ({2} = '1' AND T.CRAFT_SOURCE = '2' OR
       {2} <> '1' AND T.MSC_PLINE = {3} AND T.PROCESS_CODE = {4} AND
       T.PIC = {5})
   AND T.SSC_CONDITION = '409902'
		]]>
	</query>
	
	<query id="JdgCraftOrdDesignStdPicSmp.queryGroupCountByOrdLnPk" desc="通过交货行PK获取工艺评审理化">
		<![CDATA[
SELECT CASE
         WHEN MIN(T.RATE) = '408603' AND MIN(T.ATTACH_PERCENT) IS NOT NULL THEN
          nvl(MIN(T.ATTACH_COUNT),0)
         ELSE
          nvl(SUM(T.DESC_COUNT * T.SAMPLE_COUNT),0)
       END COUNT,
       MIN(T.PHY_NAME_MIN) VALUE
  FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T,
       CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND ({6} = '1' AND T.CRAFT_SOURCE = '2' OR
       {6} = '0' AND T.MSC_PLINE = {2} AND T.PROCESS_CODE = {3} AND
       T.PIC = {4})
   AND T.PHY_CODE_MIN = {5}
 GROUP BY T.PHY_CODE_MIN
		]]>
	</query>
	
	<query id="JdgCraftOrdDesignStdPicSmp.getRate" desc="获取取样频率">
		<![CDATA[
SELECT C.PHY_CODE_MIN,
       MIN(C.DESC_RATE) DESC_RATE,
       MIN(C.RATE) RATE,
       MIN(C.ATTACH_PERCENT) ATTACH_PERCENT,
       MIN(C.ATTACH_COUNT) ATTACH_COUNT,
       MIN(C.PIC) PIC,
       NVL(MIN(C.DESC_COUNT), 0) DESC_COUNT,
       NVL(MIN(C.SAMPLE_COUNT), 0) SAMPLE_COUNT,
       MIN(C.PHY_NAME_MIN) PHY_NAME_MIN,
       MIN(C.PHY_CODE_MIN) PHY_CODE_MAX,
       MIN(C.PHY_NAME_MIN) PHY_NAME_MAX,
       MIN(C.LOOP_VALUE) LOOP_VALUE
  FROM CRAFT_ORD_DESIGN B, CRAFT_ORD_DESIGN_STD_PIC_SMP C
  LEFT JOIN COM_BASE_PHY_C D
    ON D.PHY_CODE = C.PHY_CODE_MIN
 WHERE B.CRAFT_SEQ = {1}
   AND B.ORD_LN_PK = {0}
   AND C.DESGIN_KEY = B.DESGIN_KEY
   AND C.MSC_PLINE = {2}
   AND C.PROCESS_CODE = {3}
   AND C.PIC = {4}
 GROUP BY C.PHY_CODE_MIN
		]]>
	</query>
	
	<query id="JdgCraftOrdDesignStdPicSmp.getFdRate" desc="获取取样频率">
		<![CDATA[
SELECT C.PHY_CODE_MIN,
       MIN(C.DESC_RATE) DESC_RATE,
       MIN(C.RATE) RATE,
       MIN(C.ATTACH_PERCENT) ATTACH_PERCENT,
       MIN(C.ATTACH_COUNT) ATTACH_COUNT,
       MIN(C.PIC) PIC,
       NVL(MIN(C.DESC_COUNT), 0) DESC_COUNT,
       NVL(MIN(C.SAMPLE_COUNT), 0) SAMPLE_COUNT,
       MIN(C.PHY_NAME_MIN) PHY_NAME_MIN,
       MIN(C.PHY_CODE_MIN) PHY_CODE_MAX,
       MIN(C.PHY_NAME_MIN) PHY_NAME_MAX,
	   MIN(E.ISCHECK) IS_CHECK,
	   MIN(E.ISQUOTE) IS_QUOTE,
	   MIN(E.ISJUDGE) IS_JUDGE,
       MIN(C.PROCESS_CODE) PROCESS_CODE,
       MIN(C.LOOP_VALUE) LOOP_VALUE
  FROM CRAFT_ORD_DESIGN B, CRAFT_ORD_DESIGN_STD_PIC_SMP C
  LEFT JOIN COM_BASE_PHY_C D
    ON D.PHY_CODE = C.PHY_CODE_MIN,
CRAFT_ORD_DESIGN_STD_PIC E
 WHERE B.CRAFT_SEQ = {1}
   AND B.ORD_LN_PK = {0}
   AND C.DESGIN_KEY = B.DESGIN_KEY
   	 AND B.DESGIN_KEY = E.DESGIN_KEY
	 AND C.PHY_CODE_MIN = E.PHY_CODE_MIN
   AND C.CRAFT_SOURCE = '2'
 GROUP BY C.PHY_CODE_MIN
		]]>
	</query>
</queryMap>