<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="CraftOrdDesignStdPic.existPicLgColligate" desc="查询">
        <![CDATA[
SELECT COUNT(1)
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE IN ('A', 'B', 'C')
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdPic.getPicCount" desc="查询PIC数">
        <![CDATA[
SELECT COUNT(1)
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE IN ('A', 'B', 'C')
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdPic.queryCraftPhy" desc="查询工艺评审理化记录">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PIC = {2}
   AND T.PROCESS_CODE = {3}
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPic.queryCraftJfPhy" desc="查询工艺评审交付理化记录">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '0'
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_PIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND A.PHY_CODE = T.PHY_CODE
           AND A.ITEM_CODE_F = T.ITEM_CODE_F
           AND A.ITEM_CODE_W = T.ITEM_CODE_W
           AND A.ITEM_CODE_S = T.ITEM_CODE_S)
UNION ALL
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '1'
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPic.queryCraftPhyByOrdLnPk" desc="通过交货行PK获取工艺评审理化">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.PIC,
       T.USE_CODE,
       T.USE_DESC,
       DECODE(T.SPECL_FL, '0', '1', T.SPECL_FL) 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,
       CASE
         WHEN T.PHY_NAME LIKE '冲击功%' OR T.PHY_NAME LIKE '冲击值%' THEN
          'D'
         ELSE
          T.JUDGE_BASIS
       END JUDGE_BASIS,
       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,
       T.IS_PRODUCT_CHECK
  FROM CRAFT_ORD_DESIGN_STD_PIC 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} <> '1' AND T.MSC_PLINE = {2} AND T.PROCESS_CODE = {3} AND
       T.PIC = {4})
   AND ({5} IS NULL OR T.PHY_CODE_MIN = {5})
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPic.getCraftJfPhyByOrdLnPk" desc="获取工艺评审成分">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.PIC,
       T.USE_CODE,
       T.USE_DESC,
       '1' 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 ITEM_CODE_F,
       D2.ITEM_NAME ITEM_NAME_F,
       T.ITEM_CODE_W,
       T.ITEM_NAME_W,
       T.ITEM_CODE_s ITEM_CODE_S,
       D3.ITEM_NAME 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,
       CASE
         WHEN T.PHY_NAME LIKE '冲击功%' OR T.PHY_NAME LIKE '冲击值%' THEN
          'D'
         ELSE
          T.JUDGE_BASIS
       END JUDGE_BASIS,
       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
  FROM CRAFT_ORD_DESIGN_STD_PIC T
  LEFT JOIN COM_BASE_PHY_ITEM D2
    ON D2.ITEM_CODE = T.ITEM_CODE_F
  LEFT JOIN COM_BASE_PHY_ITEM D3
    ON D3.ITEM_CODE = T.ITEM_CODE_s, CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND C.DESGIN_KEY = T.DESGIN_KEY
   AND T.SPECL_FL = '0'
   AND NOT EXISTS
 (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_PIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.PHY_CODE_MAX = A.PHY_CODE_MAX
           AND T.PHY_CODE_MIN = A.PHY_CODE_MIN
           AND T.PHY_CODE = A.PHY_CODE
           AND NVL(T.ITEM_CODE_F, '1') = NVL(A.ITEM_CODE_F, '1')
           AND NVL(T.ITEM_CODE_W, '1') = NVL(A.ITEM_CODE_W, '1')
           AND NVL(T.ITEM_CODE_S, '1') = NVL(A.ITEM_CODE_S, '1'))
   AND ({2} IS NULL OR T.PHY_CODE_MIN = {2})
UNION ALL
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 ITEM_CODE_F,
       D2.ITEM_NAME ITEM_NAME_F,
       T.ITEM_CODE_W,
       T.ITEM_NAME_W,
       T.ITEM_CODE_s ITEM_CODE_S,
       D3.ITEM_NAME 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,
       CASE
         WHEN T.PHY_NAME LIKE '冲击功%' OR T.PHY_NAME LIKE '冲击值%' THEN
          'D'
         ELSE
          T.JUDGE_BASIS
       END JUDGE_BASIS,
       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
  FROM CRAFT_ORD_DESIGN_STD_PIC T
  LEFT JOIN COM_BASE_PHY_ITEM D2
    ON D2.ITEM_CODE = T.ITEM_CODE_F
  LEFT JOIN COM_BASE_PHY_ITEM D3
    ON D3.ITEM_CODE = T.ITEM_CODE_s, CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND T.SPECL_FL = '1'
   AND ({2} IS NULL OR T.PHY_CODE_MIN = {2})
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPic.getPhyCnt" desc="获取理化数">
		<![CDATA[
SELECT COUNT(1) COUNT
  FROM CRAFT_ORD_DESIGN_STD_PIC T,
       CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND T.PROCESS_CODE = {2}
   and t.ischeck = '1'
   AND (({3} IS NULL OR {3} = '1') AND T.CRAFT_SOURCE = '2' OR
       ({3} IS NULL OR {3} <> '1') AND T.CRAFT_SOURCE = '0' AND
       T.PROCESS_CODE = {2} AND T.MSC_PLINE = {4})
		]]>
	</query>

	<query id="CraftOrdDesignStdPic.getPhyCntJudge" desc="获取理化数">
		<![CDATA[
SELECT T.ISCHECK,
       T.ISQUOTE,
       T.ISJUDGE,T.PHY_CODE_MAX,T.PHY_NAME_MAX
  FROM CRAFT_ORD_DESIGN_STD_PIC T,
       CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND T.PROCESS_CODE = {2}
   and t.isjudge = '1'
   AND (({3} IS NULL OR {3} = '1') AND T.CRAFT_SOURCE = '2' OR
       ({3} IS NULL OR {3} <> '1') AND T.CRAFT_SOURCE = '0' AND
       T.PROCESS_CODE = {2} AND T.MSC_PLINE = {4})
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPic.getBilletSampleCnt" desc="获取小样热处理数">
		<![CDATA[
SELECT COUNT(1) COUNT
  FROM CRAFT_ORD_DESIGN_STD_PIC T,
       CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND ({3} = '1' AND T.CRAFT_SOURCE = '2' OR
       {3} <> '1' AND T.CRAFT_SOURCE = '0' AND T.PROCESS_CODE = {2})
   AND T.BILLET_SAMPLE = '1'
		]]>
	</query>
	
	<query id="CraftOrdDesignStdPic.getNkMinPic" desc="获取某制程、工序下最小的内控PIC">
		<![CDATA[
SELECT MIN(A.PIC) PIC
  FROM CRAFT_ORD_DESIGN_STD_PIC A,
       CRAFT_ORD_DESIGN B
 WHERE B.DESGIN_KEY = A.DESGIN_KEY
   AND B.ORD_LN_PK = {0}
   AND B.CRAFT_SEQ = {1}
   AND A.MSC_PLINE = {2}
   AND A.PROCESS_CODE = {3}
   AND A.CRAFT_SOURCE = '0'
		]]>
	</query>

	<query id="CraftOrdDesignStdPic.getCraftPhyMemo" desc="备注">
		<![CDATA[
SELECT MIN(A.STDMEMO) STDMEMO
  FROM CRAFT_ORD_DESIGN_STD_PIC A, CRAFT_ORD_DESIGN B
 WHERE B.DESGIN_KEY = A.DESGIN_KEY
   AND B.ORD_LN_PK = {0}
   AND B.CRAFT_SEQ = {1}
   AND A.MSC_PLINE = {2}
   AND A.PROCESS_CODE = {3}
   AND A.CRAFT_SOURCE = '0'
   AND A.PIC = {4}
   AND A.PHY_CODE_MIN = {5}
		]]>
	</query>
</queryMap>