<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="质量设计加工">
	<query id="CraftOrdDesignStdGicDAL.query" desc="查询质量设计加工">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.GIC,
       T.USE_CODE,
       T.USE_DESC,
       T.SPECL_FL,
       T.XH,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.PROCESS_CDOE_C,
       T.PROCESS_DESC_C,
       T.STATION_CODE,
       T.STATION_DESC,
       T.VALUE_TEXT,
       T.VALUE_NUM,
       T.VALUE_MEMO,
       T.GROUP_SEQ,
       T.MEMO
 FROM Craft_ORD_DESIGN_STD_GIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#GIC#', T.GIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdGicDAL.queryDesignKeyByGic" desc="查询质量设计加工">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.GIC,
       T.USE_CODE,
       T.USE_DESC,
       SPECL_FL,
       T.XH,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.PROCESS_CDOE_C,
       T.PROCESS_DESC_C,
       T.STATION_CODE,
       T.STATION_DESC,
       T.VALUE_TEXT,
       T.VALUE_NUM,
       T.VALUE_MEMO,
       T.GROUP_SEQ,
       T.MEMO,
       T.MSC_PLINE,
       T.PROCESS_CODE,
       A.PROCESS_DESC_C PROCESS_DESC_C2,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       CRAFT_SOURCE,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
  FROM CRAFT_ORD_DESIGN_STD_GIC 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.GIC) = DECODE({3},'','1',{3})
   ORDER BY T.GIC, T.XH
		]]>
	</query>
	
	<query id="CraftOrdDesignStdGicDAL.queryGicByDesignKey" desc="查询质量设计加工">
		<![CDATA[
 SELECT 
       T.DESGIN_KEY,
       T.GIC
 FROM Craft_ORD_DESIGN_STD_GIC T
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND INSTR('#GIC#', T.GIC) > 0
		]]>
	</query>
	
	<query id="CraftOrdDesignStdGicDAL.Insert" desc="新增">
        <![CDATA[
INSERT INTO CRAFT_ORD_DESIGN_STD_GIC
  (DESGIN_KEY,
   GIC,
   USE_CODE,
   USE_DESC,
   SPECL_FL,
   XH,
   PROCESS_CDOE,
   PROCESS_DESC,
   PROCESS_CDOE_C,
   PROCESS_DESC_C,
   STATION_CODE,
   STATION_DESC,
   VALUE_TEXT,
   VALUE_NUM,
   VALUE_MEMO,
   GROUP_SEQ,
   MEMO,
   MSC_PLINE,
   PROCESS_CODE,
   CREATE_NAME,
   CREATE_TIME,
   CRAFT_SOURCE)
VALUES
  ('#DESGIN_KEY#',
   '#GIC#',
   '#USE_CODE#',
   '#USE_DESC#',
   '#SPECL_FL#',
   '#XH#',
   '#PROCESS_CDOE#',
   '#PROCESS_DESC#',
   '#PROCESS_CDOE_C#',
   '#PROCESS_DESC_C#',
   '#STATION_CODE#',
   '#STATION_DESC#',
   '#VALUE_TEXT#',
   '#VALUE_NUM#',
   '#VALUE_MEMO#',
   '#GROUP_SEQ#',
   '#MEMO#',
   '#MSC_PLINE#',
   '#PROCESS_CODE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdGicDAL.Update" desc="修改">
        <![CDATA[
UPDATE CRAFT_ORD_DESIGN_STD_GIC T
   SET T.DESGIN_KEY     = '#DESGIN_KEY#',
       T.GIC            = '#GIC#',
       T.USE_CODE       = '#USE_CODE#',
       T.USE_DESC       = '#USE_DESC#',
       T.SPECL_FL       = '#SPECL_FL#',
       T.XH             = '#XH#',
       T.PROCESS_CDOE   = '#PROCESS_CDOE#',
       T.PROCESS_DESC   = '#PROCESS_DESC#',
       T.PROCESS_CDOE_C = '#PROCESS_CDOE_C#',
       T.PROCESS_DESC_C = '#PROCESS_DESC_C#',
       T.STATION_CODE   = '#STATION_CODE#',
       T.STATION_DESC   = '#STATION_DESC#',
       T.VALUE_TEXT     = '#VALUE_TEXT#',
       T.VALUE_NUM      = '#VALUE_NUM#',
       T.VALUE_MEMO     = '#VALUE_MEMO#',
       T.GROUP_SEQ      = '#GROUP_SEQ#',
       T.MEMO           = '#MEMO#',
       T.MSC_PLINE      = '#MSC_PLINE#',
       T.PROCESS_CODE   = '#PROCESS_CODE#',
       T.CRAFT_SOURCE   = '#CRAFT_SOURCE#',
       T.UPDATE_NAME    = '#UPDATE_NAME#',
       T.UPDATE_TIME    = SYSDATE
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.GIC = '#GIC#'
   AND T.XH = '#XH#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdGicDAL.GetMaxIndex" desc="获取最大主键">
        <![CDATA[
SELECT NVL(MAX(XH), 0) + 1 MAX_VALUE
  FROM CRAFT_ORD_DESIGN_STD_GIC T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.GIC = '#GIC#'
        ]]>
    </query>
    <query id="CraftOrdDesignStdGicDAL.Delete" desc="删除">
        <![CDATA[
select * from CRAFT_ORD_DESIGN_STD_GIC t;
DELETE FROM (SELECT *
               FROM CRAFT_ORD_DESIGN_STD_GIC T
              WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
                AND T.GIC = '#GIC#'
                AND T.XH = '#XH#')
        ]]>
    </query>
    <query id="CraftOrdDesignStdGicDAL.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.GIC                GIC,
       A.DESGIN_KEY         DESIGNKEY
  FROM CRAFT_ORD_DESIGN_MSC_PL A,
       CRAFT_ORD_DESIGN_MSC_PL_PRC B,
       (SELECT C.GIC, MSC_PLINE, PROCESS_CODE
          FROM CRAFT_ORD_DESIGN_STD_GIC C
         WHERE C.DESGIN_KEY = {0}
         GROUP BY C.GIC, 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
        ]]>
    </query>
</queryMap>