<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="CraftOrdDesignStdCic.existCicLgColligate" desc="查询">
        <![CDATA[
SELECT COUNT(1)
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE IN ('A', 'B', 'C')
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdCic.queryCraftChem" desc="查询工艺评审成分记录">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.CIC = {2}
   AND T.PROCESS_CODE = {3}
		]]>
	</query>
	
	<query id="CraftOrdDesignStdCic.getCraftJfChem" desc="获取工艺评审成分">
		<![CDATA[
SELECT T.*, A.CHEM_SEQ
  FROM (SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ 
               FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '0'
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_CIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.CHEM_CODE = A.CHEM_CODE)
   AND T.CHEM_CODE NOT IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065')
UNION ALL
SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '1'
   AND T.CHEM_CODE NOT IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065')
UNION ALL
SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T,
  CRAFT_ORD_DESIGN_MSC MSC
 WHERE T.DESGIN_KEY = {0}
   AND T.CIC = {1}
   AND T.DESGIN_KEY=MSC.DESGIN_KEY
   AND T.SPECL_FL = '2'
   AND T.PROCESS_CODE='A'
   AND MSC.JUDGEFLAG IN ('1','3')
   AND T.CHEM_CODE IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065')
                                   )T
   LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
 ORDER BY CHEM_SEQ
 
		]]>
	</query>
	
	<query id="CraftOrdDesignStdCic.queryCraftChemByOrdLnPk" desc="通过交货行PK获取工艺评审成分">
		<![CDATA[
SELECT TT.*, A.CHEM_SEQ
  FROM (SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ
          FROM CRAFT_ORD_DESIGN_STD_CIC T,
               CRAFT_ORD_DESIGN C
         WHERE C.ORD_LN_PK = {0}
           AND C.CRAFT_SEQ = {1}
           AND T.DESGIN_KEY = C.DESGIN_KEY
           AND ({5} = '1' AND T.CRAFT_SOURCE = '2' OR
               {5} <> '1' AND T.MSC_PLINE = {2} AND T.PROCESS_CODE = {3} AND
               T.CIC = {4})
           AND  T.CHEM_CODE NOT IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065','C085')
        UNION ALL
        SELECT E.DESGIN_KEY,
               {4} CIC,
               E.USE_CODE,
               E.USE_DESC,
               '2' SPECL_FL,
               E.INDEX_SEQ,
               E.CHEM_CODE,
               E.CHEM_NAME,
               E.CHEM_TYPE,
               E.CHEM_FORMULA,
               E.ISCHECK,
               E.ISJUDGE,
               E.ISQUOTE,
               E.COMPLEX_TYPE,
               E.STDMIN_SIGN,
               E.STDMIN,
               E.STDMAX_SIGN,
               E.STDMAX,
               E.STDTARGET,
               E.MODEL_CODE,
               E.MODEL_DESC,
               E.STDMEMO,
               E.ELE_CODE,
               E.ELE_NAME,
               E.ELE_MIN_SIGN,
               E.ELE_MIN,
               E.ELE_MAX_SIGN,
               E.ELE_MAX,
               E.REP_CODE,
               E.REP_NAME,
               E.REP_MIN_SIGN,
               E.REP_MIN,
               E.REP_MAX_SIGN,
               E.REP_MAX,
               E.REP_VAL,
               E.MSC_PLINE,
               E.PROCESS_CODE,
               E.CRAFT_SOURCE,
               E.CIC_MEMO,
               E.GROUP_SEQ
          FROM CRAFT_ORD_DESIGN_STD_CIC E,
               CRAFT_ORD_DESIGN G
         WHERE G.ORD_LN_PK = {0}
           AND G.CRAFT_SEQ = {1}
           AND E.DESGIN_KEY = G.DESGIN_KEY
           AND E.SPECL_FL = '1'
           AND E.CHEM_CODE IN ('C012',
                               'C013',
                               'C014',
                               'C032',
                               'C043',
                               'C051',
                               'C064',
                               'C065','C085')
        UNION ALL
        SELECT E.DESGIN_KEY,
               {4} CIC,
               E.USE_CODE,
               E.USE_DESC,
               '2' SPECL_FL,
               E.INDEX_SEQ,
               E.CHEM_CODE,
               E.CHEM_NAME,
               E.CHEM_TYPE,
               E.CHEM_FORMULA,
               E.ISCHECK,
               E.ISJUDGE,
               E.ISQUOTE,
               E.COMPLEX_TYPE,
               E.STDMIN_SIGN,
               E.STDMIN,
               E.STDMAX_SIGN,
               E.STDMAX,
               E.STDTARGET,
               E.MODEL_CODE,
               E.MODEL_DESC,
               E.STDMEMO,
               E.ELE_CODE,
               E.ELE_NAME,
               E.ELE_MIN_SIGN,
               E.ELE_MIN,
               E.ELE_MAX_SIGN,
               E.ELE_MAX,
               E.REP_CODE,
               E.REP_NAME,
               E.REP_MIN_SIGN,
               E.REP_MIN,
               E.REP_MAX_SIGN,
               E.REP_MAX,
               E.REP_VAL,
               E.MSC_PLINE,
               E.PROCESS_CODE,
               E.CRAFT_SOURCE,
               E.CIC_MEMO,
               E.GROUP_SEQ
          FROM CRAFT_ORD_DESIGN_STD_CIC E,
               CRAFT_ORD_DESIGN G,
               craft_ord_design_msc MSC
         WHERE G.ORD_LN_PK = {0}
           AND G.CRAFT_SEQ = {1}
           AND E.DESGIN_KEY = G.DESGIN_KEY
           AND E.DESGIN_KEY = MSC.DESGIN_KEY
           AND MSC.JUDGEFLAG IN ('2','3')
           AND E.SPECL_FL = '0'
           AND E.CHEM_CODE IN ('C012',
                               'C013',
                               'C014',
                               'C032',
                               'C043',
                               'C051',
                               'C064',
                               'C065','C085')
           AND NOT EXISTS (SELECT 1
                  FROM CRAFT_ORD_DESIGN_STD_CIC E2
                 WHERE E2.CHEM_CODE = E.CHEM_CODE
                   AND E2.DESGIN_KEY = E.DESGIN_KEY
                   AND E2.SPECL_FL = '1')) TT
  LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = TT.CHEM_CODE
   AND A.VALIDFLAG = '1'
 ORDER BY A.CHEM_SEQ
		]]>
	</query>
	
	<query id="CraftOrdDesignStdCic.queryMeltingCraftChemByOrdLnPk" desc="通过交货行PK获取工艺评审成分">
		<![CDATA[
SELECT T.*, A.CHEM_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T
  LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
   AND A.VALIDFLAG = '1', CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND MSC_PLINE = {2}
   AND PROCESS_CODE = {3}
   AND CIC = {4}
   AND T.VALIDFLAG = '1'
   AND A.CHEM_CODE NOT IN ('C012',
                               'C013',
                               'C014',
                               'C032',
                               'C043',
                               'C051',
                               'C064',
                               'C065')
                                 UNION ALL
 SELECT T.*, A.CHEM_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T
  LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
   AND A.VALIDFLAG = '1'
   LEFT JOIN craft_ord_design_msc MSC
    ON MSC.DESGIN_KEY = T.DESGIN_KEY, CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND MSC.JUDGEFLAG IN ('1','3')
   AND MSC_PLINE = {2}
   AND PROCESS_CODE = {3}
   AND T.VALIDFLAG = '1'
   AND CIC = {4}
   AND A.CHEM_CODE IN (--'C032',
   								'C012',
                               'C013',
                               'C014',
                               'C043',
                               'C051',
                               'C064',
                               'C065')
		]]>
	</query>
	
	<query id = "CraftOrdDesignStdCic.getCraftJfChemByOrdLnPk1" desc="获取工艺评审成分">
	<![CDATA[
	SELECT B.*, D.CHEM_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC B
   LEFT JOIN COM_BASE_CHEM D
    ON D.CHEM_CODE = B.CHEM_CODE
   AND D.VALIDFLAG = '1'
 WHERE B.DESGIN_KEY IN (SELECT A.DESGIN_KEY
                          FROM CRAFT_ORD_DESIGN A
                         WHERE A.VALIDFLAG = '1'
                           AND A.ORD_LN_PK = {0})
   AND B.SPECL_FL = '0'
	]]>
	</query>
	
	<query id="CraftOrdDesignStdCic.getCraftJfChemByOrdLnPk" desc="获取工艺评审成分">
		<![CDATA[
SELECT T.*, A.CHEM_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T
  LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
   AND A.VALIDFLAG = '1', 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 A.CHEM_CODE NOT IN ('C012',
                               'C013',
                               'C014',
                               'C032',
                               'C043',
                               'C051',
                               'C064',
                               'C065')
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_CIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.CHEM_CODE = A.CHEM_CODE)
UNION ALL
SELECT T.*, A.CHEM_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T
  LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
   AND A.VALIDFLAG = '1'
  LEFT JOIN craft_ord_design_msc MSC
    ON MSC.DESGIN_KEY = T.DESGIN_KEY, 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 MSC.JUDGEFLAG IN ('2','3')
   AND A.CHEM_CODE IN ('C012',
                               'C013',
                               'C014',
                               'C032',
                               'C043',
                               'C051',
                               'C064',
                               'C065')
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_CIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.CHEM_CODE = A.CHEM_CODE)
UNION ALL
SELECT T.*, A.CHEM_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T
  LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
   AND A.VALIDFLAG = '1', 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'
 ORDER BY CHEM_SEQ
		]]>
	</query>
	
		<query id="CraftOrdDesignStdCic.getCraftJfChemByOrdLnPkMaking" desc="获取工艺评审成分">
		<![CDATA[		
SELECT TT.*,A.CHEM_SEQ FROM( SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T, 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 T.VALIDFLAG = '1'
   AND T.CHEM_CODE NOT IN ('C012',
                               'C013',
                               'C014',
                               'C032',
                               'C043',
                               'C051',
                               'C064',
                               'C065')
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_CIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.CHEM_CODE = A.CHEM_CODE)
UNION ALL
SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               '0' SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T, CRAFT_ORD_DESIGN C,craft_ord_design_msc msc
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.CIC = {2}
   AND C.DESGIN_KEY = T.DESGIN_KEY
   AND MSC.DESGIN_KEY = T.DESGIN_KEY
   AND MSC.JUDGEFLAG IN ('1','3')
   AND T.SPECL_FL = '2'
   AND PROCESS_CODE = 'A'
   AND T.VALIDFLAG = '1'
   AND T.CHEM_CODE IN ('C012',
                               'C013',
                               'C014',
                               'C032',
                               'C043',
                               'C051',
                               'C064',
                               'C065')
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_CIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.CHEM_CODE = A.CHEM_CODE)
   	 AND EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_CIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '0'
           AND T.CHEM_CODE = A.CHEM_CODE)
UNION ALL
SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ 
  FROM CRAFT_ORD_DESIGN_STD_CIC T, CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.VALIDFLAG = '1'
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND T.SPECL_FL = '1')TT
   LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = TT.CHEM_CODE
   AND A.VALIDFLAG = '1'
 ORDER BY CHEM_SEQ
		]]>
	</query>
	
	<query id="CraftOrdDesignStdCic.getBiasChem" desc="获取工艺评审偏差成分">
		<![CDATA[
SELECT T.*, A.STD_NAME
  FROM CRAFT_ORD_DESIGN_STD_BIAS_C T, COM_MSC_STD_CHEM_BIAS A
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL IN ('0', '1')
   AND A.CIC = T.CIC
		]]>
	</query>
	
	<query id="CraftOrdDesignStdCic.getChemCnt" desc="获取成分数">
		<![CDATA[
SELECT SUM(CNT) COUNT
  FROM (SELECT COUNT(1) CNT
          FROM CRAFT_ORD_DESIGN_STD_CIC T,
               CRAFT_ORD_DESIGN C,
               (SELECT MAX(D.PROCESS_CODE) PROCESS_CODE
                  FROM CRAFT_ORD_DESIGN            C2,
                       CRAFT_ORD_DESIGN_MSC_PL_STI D
                 WHERE C2.ORD_LN_PK = {0}
                   AND C2.CRAFT_SEQ = {1}
                   AND D.DESGIN_KEY = C2.DESGIN_KEY
                   AND D.STATION_TYPE = '403202'
                   AND D.MSC_PLINE = {3}) D2
         WHERE C.ORD_LN_PK = {0}
           AND C.CRAFT_SEQ = {1}
           AND T.DESGIN_KEY = C.DESGIN_KEY
           AND ({2} IS NULL OR {2} = '1')
           AND T.CRAFT_SOURCE = '2'
           AND D2.PROCESS_CODE = {4}
        UNION ALL
        SELECT COUNT(1)
          FROM CRAFT_ORD_DESIGN_MSC_PL_STI T,
               CRAFT_ORD_DESIGN C
         WHERE C.ORD_LN_PK = {0}
           AND C.CRAFT_SEQ = {1}
           AND T.DESGIN_KEY = C.DESGIN_KEY
           AND ({2} IS NULL OR {2} <> '1')
           AND T.MSC_PLINE = {3}
           AND T.PROCESS_CODE = {4}
           AND T.STATION_TYPE = '403201')
		]]>
	</query>
	
	 <query id="CraftOrdDesignStdCic.getNewCicsByOrdLnDlyPk" desc="获取最新工艺CIC">
		<![CDATA[
SELECT C.CIC, MIN(B.ORD_LN_PK) ORD_LN_PK
  FROM CRAFT_ORD_DESIGN B,
       CRAFT_ORD_DESIGN_STD_CIC C,
       COM_MSC_STD_CIC D
 WHERE B.ORD_LN_PK = {0}
   AND B.VALIDFLAG = '1'
   AND C.DESGIN_KEY = B.DESGIN_KEY
   AND C.MSC_PLINE = {1}
   AND C.PROCESS_CODE = 'A'
   AND D.CIC = C.CIC
 GROUP BY C.CIC
		]]>
	</query>

	<query id="CraftOrdDesignStdCic.getCraftChemMemo" desc="备注">
		<![CDATA[
SELECT MIN(A.STDMEMO) STDMEMO
  FROM CRAFT_ORD_DESIGN_STD_CIC 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.CIC = {4}
		]]>
	</query>
</queryMap>