<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质量设计成分">
	<query id="CraftOrdDesignStdCicDAL.query" desc="查询质量设计成分">
		<![CDATA[
 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,
       DECODE(T.ISCHECK, '1', '是', '否') ISCHECK_DESC,
       T.ISJUDGE,
       DECODE(T.ISJUDGE, '1', '是', '否') ISJUDGE_DESC,
       T.ISQUOTE,
       DECODE(T.ISQUOTE, '1', '是', '否') ISQUOTE_DESC,
       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.SIZE_CODE2,
       T.SIZE_NAME2,
       T.SIZE_MIN_SIGN2,
       T.SIZE_MIN2,
       T.SIZE_MAX_SIGN2,
       T.SIZE_MAX2,
       T.SIZE_CODE,
       T.SIZE_NAME,
       T.SIZE_MIN_SIGN,
       T.SIZE_MIN,
       T.SIZE_MAX_SIGN,
       T.SIZE_MAX,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.REP_CODE,
       T.REP_NAME,
       T.REP_MIN_SIGN,
       T.REP_MIN,
       T.REP_MAX_SIGN,
       T.REP_MAX,
       T.REP_VAL
 FROM Craft_ORD_DESIGN_STD_CIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#CIC#', T.CIC) > 0
AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CraftOrdDesignStdCicDAL.queryByDesignKeyCic" desc="通过DesignKey和Cic查询成分结果">
        <![CDATA[
SELECT T.DESGIN_KEY,
       T.CIC,
       T.USE_CODE,
       T.USE_DESC,
       SPECL_FL,
       T.INDEX_SEQ,
       T.CHEM_CODE,
       T.CHEM_NAME,
       T.CHEM_TYPE,
       T.CHEM_FORMULA,
       DECODE(T.ISCHECK, '0', 'False', '1', 'True') ISCHECK,
       DECODE(T.ISJUDGE, '0', 'False', '1', 'True') ISJUDGE,
       DECODE(T.ISQUOTE, '0', 'False', '1', 'True') ISQUOTE,
       DECODE(T.COMPLEX_TYPE, '0', 'False', '1', 'True') 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.SIZE_CODE2,
       T.SIZE_NAME2,
       T.SIZE_MIN_SIGN2,
       T.SIZE_MIN2,
       T.SIZE_MAX_SIGN2,
       T.SIZE_MAX2,
       T.SIZE_CODE,
       T.SIZE_NAME,
       T.SIZE_MIN_SIGN,
       T.SIZE_MIN,
       T.SIZE_MAX_SIGN,
       T.SIZE_MAX,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       DECODE(T.VALIDFLAG, '0', '无效', '1', '有效') VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       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,
       A.PROCESS_DESC_C,
       T.CRAFT_SOURCE
  FROM CRAFT_ORD_DESIGN_STD_CIC T
  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC A
    ON A.DESGIN_KEY = T.DESGIN_KEY
   AND A.MSC_PLINE = T.MSC_PLINE
   AND A.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CODE = {2}
   AND  DECODE({3},'','1',T.CIC) = DECODE({3},'','1',{3})
 ORDER BY T.CIC, T.INDEX_SEQ
        ]]>
    </query>
	
	<query id="CraftOrdDesignStdCicDAL.queryCicByDesignKey" desc="查询质量设计成分">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.CIC
 FROM Craft_ORD_DESIGN_STD_CIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#CIC#', T.CIC) > 0
AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CraftOrdDesignStdCicDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO CRAFT_ORD_DESIGN_STD_CIC
  (DESGIN_KEY,
   CIC,
   USE_CODE,
   USE_DESC,
   SPECL_FL,
   INDEX_SEQ,
   CHEM_CODE,
   CHEM_NAME,
   CHEM_TYPE,
   CHEM_FORMULA,
   ISCHECK,
   ISJUDGE,
   ISQUOTE,
   COMPLEX_TYPE,
   STDMIN_SIGN,
   STDMIN,
   STDMAX_SIGN,
   STDMAX,
   STDTARGET,
   MODEL_CODE,
   MODEL_DESC,
   STDMEMO,
   ELE_CODE,
   ELE_NAME,
   ELE_MIN_SIGN,
   ELE_MIN,
   ELE_MAX_SIGN,
   ELE_MAX,
   SIZE_CODE2,
   SIZE_NAME2,
   SIZE_MIN_SIGN2,
   SIZE_MIN2,
   SIZE_MAX_SIGN2,
   SIZE_MAX2,
   SIZE_CODE,
   SIZE_NAME,
   SIZE_MIN_SIGN,
   SIZE_MIN,
   SIZE_MAX_SIGN,
   SIZE_MAX,
   SPEC_JG,
   SPEC_JG_DESC,
   CREATE_NAME,
   CREATE_TIME,
   REP_CODE,
   REP_NAME,
   REP_MIN_SIGN,
   REP_MIN,
   REP_MAX_SIGN,
   REP_MAX,
   REP_VAL,
   MSC_PLINE,
   PROCESS_CODE,
   CRAFT_SOURCE)
VALUES
  ('#DESGIN_KEY#',
   '#CIC#',
   '#USE_CODE#',
   '#USE_DESC#',
   '#SPECL_FL#',
   '#INDEX_SEQ#',
   '#CHEM_CODE#',
   '#CHEM_NAME#',
   '#CHEM_TYPE#',
   '#CHEM_FORMULA#',
   '#ISCHECK#',
   '#ISJUDGE#',
   '#ISQUOTE#',
   '#COMPLEX_TYPE#',
   '#STDMIN_SIGN#',
   '#STDMIN#',
   '#STDMAX_SIGN#',
   '#STDMAX#',
   '#STDTARGET#',
   '#MODEL_CODE#',
   '#MODEL_DESC#',
   '#STDMEMO#',
   '#ELE_CODE#',
   '#ELE_NAME#',
   '#ELE_MIN_SIGN#',
   '#ELE_MIN#',
   '#ELE_MAX_SIGN#',
   '#ELE_MAX#',
   '#SIZE_CODE2#',
   '#SIZE_NAME2#',
   '#SIZE_MIN_SIGN2#',
   '#SIZE_MIN2#',
   '#SIZE_MAX_SIGN2#',
   '#SIZE_MAX2#',
   '#SIZE_CODE#',
   '#SIZE_NAME#',
   '#SIZE_MIN_SIGN#',
   '#SIZE_MIN#',
   '#SIZE_MAX_SIGN#',
   '#SIZE_MAX#',
   '#SPEC_JG#',
   '#SPEC_JG_DESC#',
   '#CREATE_NAME#',
   SYSDATE,
   '#REP_CODE#',
   '#REP_NAME#',
   '#REP_MIN_SIGN#',
   '#REP_MIN#',
   '#REP_MAX_SIGN#',
   '#REP_MAX#',
   '#REP_VAL#',
   '#MSC_PLINE#',
   '#PROCESS_CODE#',
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdCicDAL.Update" desc="修改">
        <![CDATA[
UPDATE CRAFT_ORD_DESIGN_STD_CIC T
   SET T.DESGIN_KEY     = '#DESGIN_KEY#',
       T.CIC            = '#CIC#',
       T.USE_CODE       = '#USE_CODE#',
       T.USE_DESC       = '#USE_DESC#',
       T.SPECL_FL       = '#SPECL_FL#',
       T.INDEX_SEQ      = '#INDEX_SEQ#',
       T.CHEM_CODE      = '#CHEM_CODE#',
       T.CHEM_NAME      = '#CHEM_NAME#',
       T.CHEM_TYPE      = '#CHEM_TYPE#',
       T.CHEM_FORMULA   = '#CHEM_FORMULA#',
       T.ISCHECK        = '#ISCHECK#',
       T.ISJUDGE        = '#ISJUDGE#',
       T.ISQUOTE        = '#ISQUOTE#',
       T.COMPLEX_TYPE   = '#COMPLEX_TYPE#',
       T.STDMIN_SIGN    = '#STDMIN_SIGN#',
       T.STDMIN         = '#STDMIN#',
       T.STDMAX_SIGN    = '#STDMAX_SIGN#',
       T.STDMAX         = '#STDMAX#',
       T.STDTARGET      = '#STDTARGET#',
       T.MODEL_CODE     = '#MODEL_CODE#',
       T.MODEL_DESC     = '#MODEL_DESC#',
       T.STDMEMO        = '#STDMEMO#',
       T.ELE_CODE       = '#ELE_CODE#',
       T.ELE_NAME       = '#ELE_NAME#',
       T.ELE_MIN_SIGN   = '#ELE_MIN_SIGN#',
       T.ELE_MIN        = '#ELE_MIN#',
       T.ELE_MAX_SIGN   = '#ELE_MAX_SIGN#',
       T.ELE_MAX        = '#ELE_MAX#',
       T.SIZE_CODE2     = '#SIZE_CODE2#',
       T.SIZE_NAME2     = '#SIZE_NAME2#',
       T.SIZE_MIN_SIGN2 = '#SIZE_MIN_SIGN2#',
       T.SIZE_MIN2      = '#SIZE_MIN2#',
       T.SIZE_MAX_SIGN2 = '#SIZE_MAX_SIGN2#',
       T.SIZE_MAX2      = '#SIZE_MAX2#',
       T.SIZE_CODE      = '#SIZE_CODE#',
       T.SIZE_NAME      = '#SIZE_NAME#',
       T.SIZE_MIN_SIGN  = '#SIZE_MIN_SIGN#',
       T.SIZE_MIN       = '#SIZE_MIN#',
       T.SIZE_MAX_SIGN  = '#SIZE_MAX_SIGN#',
       T.SIZE_MAX       = '#SIZE_MAX#',
       T.SPEC_JG        = '#SPEC_JG#',
       T.SPEC_JG_DESC   = '#SPEC_JG_DESC#',
       T.UPDATE_NAME    = '#UPDATE_NAME#',
       T.UPDATE_TIME    = SYSDATE,
       T.REP_CODE       = '#REP_CODE#',
       T.REP_NAME       = '#REP_NAME#',
       T.REP_MIN_SIGN   = '#REP_MIN_SIGN#',
       T.REP_MIN        = '#REP_MIN#',
       T.REP_MAX_SIGN   = '#REP_MAX_SIGN#',
       T.REP_MAX        = '#REP_MAX#',
       T.REP_VAL        = '#REP_VAL#',
       T.MSC_PLINE      = '#MSC_PLINE#',
       T.PROCESS_CODE   = '#PROCESS_CODE#',
       T.CRAFT_SOURCE   = '#CRAFT_SOURCE#'
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.CIC = '#CIC#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdCicDAL.GetMaxIndex" desc="获取最大序号">
        <![CDATA[
SELECT NVL(MAX(INDEX_SEQ), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.CIC = '#CIC#'
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdCicDAL.Delete" desc="删除">
        <![CDATA[
DELETE FROM (SELECT *
                  FROM CRAFT_ORD_DESIGN_STD_CIC T
                 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
                   AND T.CIC = '#CIC#'
                   AND T.INDEX_SEQ = '#INDEX_SEQ#')
        ]]>
    </query>
    
    <query id="CraftOrdDesignStdCicDAL.getCraftMscPline" desc="获取工艺评审制程">
        <![CDATA[
SELECT A.MSC_PLINE          MSCPLINE,
       A.WHOLE_BACKLOG      WHOLEBACKLOG,
       A.WHOLE_BACKLOG_DESC WHOLEBACKLOGDESC,
       B.PROCESS_CODE       PROCESSCODE,
       B.PROCESS_DESC       PROCESSDESC,
       B.PROCESS_CODE_C     PROCESSCODEC,
       B.PROCESS_DESC_C     PROCESSDESCC,
       C.CIC                CIC,
       A.DESGIN_KEY         DESIGNKEY
  FROM CRAFT_ORD_DESIGN_MSC_PL A,
       CRAFT_ORD_DESIGN_MSC_PL_PRC B,
       (SELECT C.CIC, MSC_PLINE, PROCESS_CODE
          FROM CRAFT_ORD_DESIGN_STD_CIC C
         WHERE C.DESGIN_KEY = {0}
         GROUP BY C.CIC, C.MSC_PLINE, C.PROCESS_CODE) C
 WHERE A.DESGIN_KEY = {0}
   AND B.PROCESS_CODE = {1}
   AND B.DESGIN_KEY = A.DESGIN_KEY
   AND B.MSC_PLINE = A.MSC_PLINE
   AND C.MSC_PLINE = A.MSC_PLINE
   AND C.PROCESS_CODE = B.PROCESS_CODE
   AND EXISTS
 (SELECT 1
          FROM CRAFT_ORD_DESIGN D, PLN_SALEORD E, PLN_SALEORD_PROC F
         WHERE D.DESGIN_KEY = A.DESGIN_KEY
           AND D.ORD_LN_PK = E.ORD_LN_PK
           AND E.ORD_LN_DLY_PK = F.ORD_LN_DLY_PK
           AND F.INDEX_SEQ = A.MSC_PLINE
           AND F.PLN_DIVIDE_ID =
               (SELECT MAX(F.PLN_DIVIDE_ID)
                  FROM PLN_SALEORD_PROC G
                 WHERE G.ORD_LN_DLY_PK = F.ORD_LN_DLY_PK))
        ]]>
    </query>
</queryMap>