<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工艺评审-制程">

	<query id="ProDucDao.getProDuc" desc="查询有效制程">
         <![CDATA[
      SELECT MSC,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       PROCESS_NO,
       VALIDFLAG_NK,
       PROCESS_NAME,
       AUTO_CRAFT
  FROM COM_MSC_BACKLOG T
 WHERE T.MSC = ?
   AND T.VALIDFLAG != '0'
         ]]>
	</query>
	
		<query id="ProDucDao.getTecPline" desc="查询有效制程">
         <![CDATA[
      SELECT 	distinct T2.MSC_PLINE
 	 FROM SLM_ORD_DESIGN_MSC T1,
  		SLM_ORD_DESIGN_MSC_PL T2
 	WHERE T1.ORD_LN_PK = (SELECT T3.ORD_LN_PK FROM CRAFT_ORD_DESIGN T3 WHERE T3.DESGIN_KEY=?)
 		AND T1.DESGIN_KEY=T2.DESGIN_KEY
    	AND T1.VALIDFLAG='1'
         ]]>
	</query>
	
	<query id="ProDucDao.getCraftPline" desc="查询有效制程">
         <![CDATA[
      SELECT 	distinct T2.MSC_PLINE,T1.ORD_LN_PK,T1.PRODUCER_FL
 	 FROM CRAFT_ORD_DESIGN_MSC T1,
  		CRAFT_ORD_DESIGN_MSC_PL T2
 	WHERE T1.DESGIN_KEY = ?
 		AND T1.DESGIN_KEY=T2.DESGIN_KEY
    	AND T1.VALIDFLAG='1'
         ]]>
	</query>

	<query id="ProDucDao.updateProDuc" desc="修改制程">
         <![CDATA[
 UPDATE CRAFT_ORD_DESIGN_MSC_PL T
   SET 
        T.DESGIN_KEY = '#DESGIN_KEY#',
        T.MSC_PLINE = '#MSC_PLINE#',
        T.WHOLE_BACKLOG = '#WHOLE_BACKLOG#',
        T.WHOLE_BACKLOG_DESC = '#WHOLE_BACKLOG_DESC#',
        T.SET_FL = '#SET_FL#',
        T.WARN_DESC = '#WARN_DESC#',
        T.ORD_LN_PK = '#ORD_LN_PK#',
        T.PROCESS_NO = '#PROCESS_NO#',
        T.PROCESS_NAME = '#PROCESS_NAME#'
 WHERE
T.DESGIN_KEY = '#DESGIN_KEY#'
AND T.MSC_PLINE = '#MSC_PLINE#'
         ]]>
	</query>

	<query id="ProDucDao.saveProDuc" desc="保存制程">
         <![CDATA[
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL
               (DESGIN_KEY,
                MSC_PLINE,
                WHOLE_BACKLOG,
                WHOLE_BACKLOG_DESC,
                SET_FL,
                WARN_DESC,
                ORD_LN_PK,
                PROCESS_NO,
                PROCESS_NAME,
                AUTO_CRAFT)
         VALUES
               (?, ?, ?, ?, ?, ?,?,?,?, ?)
         ]]>
	</query>

	<query id="ProDucDao.getDesignChem" desc="查询质量设计成分标准条数">
         <![CDATA[
    SELECT COUNT(*) AS COUNT
      FROM CRAFT_ORD_DESIGN_STD_CIC T
     WHERE T.DESGIN_KEY = ?
       AND T.VALIDFLAG = 1
         ]]>
	</query>

	<query id="ProDucDao.getDesignPhy" desc="查询质量设计理化标准条数">
         <![CDATA[
    SELECT COUNT(*) AS COUNT
      FROM CRAFT_ORD_DESIGN_STD_PIC T
     WHERE T.DESGIN_KEY = ?
         ]]>
	</query>


	<query id="ProDucDao.getDesignSpec" desc="查询质量设计公差标准条数">
         <![CDATA[
    SELECT COUNT(*) AS COUNT
      FROM CRAFT_ORD_DESIGN_STD_SIC T
     WHERE T.DESGIN_KEY = ?
         ]]>
	</query>

	<query id="ProDucDao.getDesignDete" desc="查询质量设计探伤标准条数">
         <![CDATA[
    SELECT COUNT(*) AS COUNT
      FROM CRAFT_ORD_DESIGN_STD_DIC T
     WHERE T.DESGIN_KEY = ?
         ]]>
	</query>

	<query id="ProDucDao.getDesignWater" desc="查询质量设计水压标准条数">
         <![CDATA[
    SELECT COUNT(*) AS COUNT
      FROM CRAFT_ORD_DESIGN_STD_WIC T
     WHERE T.DESGIN_KEY = ?
         ]]>
	</query>

	<query id="ProDucDao.getDesignGic" desc="查询质量设计加工标准条数">
         <![CDATA[
    SELECT COUNT(*) AS COUNT
      FROM CRAFT_ORD_DESIGN_STD_GIC T
     WHERE T.DESGIN_KEY = ?
         ]]>
	</query>

	<query id="ProDucDao.getAddAskNoStation" desc="查询附加要求工艺点类型">
         <![CDATA[
     SELECT D.STATION_CODE,D.STATION_DESC,B.ASK_SUB_ITME_DESC
  FROM (SELECT DISTINCT A.ASK_SUB_ITME,A.ASK_SUB_ITME_DESC
          FROM SLM_ORDER_ADD_ASK A
         WHERE A.ADD_ASK_NO =?
           AND A.VALIDFLAG = 1) B,
       COM_BASE_ASK_R_STATION C,
       COM_BASE_STATION D
 WHERE C.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
   AND B.ASK_SUB_ITME = C.ASK_ITEM_NO
   AND C.STATION_CODE = D.STATION_CODE
         ]]>
	</query>

	<query id="ProDucDao.getMscPlSetFl" desc="查询设定制程 ">
         <![CDATA[
SELECT T.DESGIN_KEY,
       T.MSC_PLINE,
       A.WHOLE_BACKLOG,
       A.WHOLE_BACKLOG_DESC,
       T.SET_FL,
       T.WARN_DESC,
       T.ORD_LN_PK,
       T.PROCESS_NO,
       T.PROCESS_NAME
  FROM CRAFT_ORD_DESIGN_MSC_PL T, COM_MSC_BACKLOG A, CRAFT_ORD_DESIGN_MSC B
 WHERE T.DESGIN_KEY = ?
   AND T.SET_FL = '1'
   AND A.MSC = B.MSC
   AND A.MSC_PLINE = T.MSC_PLINE
   AND B.DESGIN_KEY = T.DESGIN_KEY
         ]]>
	</query>

	<query id="ProDucDao.checkProDucIsExist" desc="查询制程 是否存在">
         <![CDATA[
SELECT COUNT(1) COUNT
  FROM CRAFT_ORD_DESIGN_MSC_PL T
 WHERE T.DESGIN_KEY = ?
   AND T.MSC_PLINE = ?
         ]]>
	</query>

	<query id="ProDucDao.getCft" desc="查询工艺参数">
         <![CDATA[
SELECT *
  FROM COM_MSC_STD_CRAFT T
 WHERE T.MSC = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.STATION_CODE = {3}
   AND T.CRAFTITEM_CDOE = {4}
         ]]>
	</query>
	
	<query id="ProDucDao.getCft2" desc="查询工艺参数">
         <![CDATA[
SELECT *
  FROM COM_MSC_STD_CRAFT T
 WHERE T.MSC = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.STATION_CODE = {3}
   AND T.CRAFTITEM_CDOE = {4}
   AND NVL(T.SPEC_JG, '1') = DECODE(T.SPEC_JG, NULL, '1', {5})
         ]]>
	</query>
	
	<query id="ProDucDao.getCft3" desc="查询工艺参数">
         <![CDATA[
SELECT *
  FROM COM_MSC_STD_CRAFT T
 WHERE T.MSC = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.STATION_CODE = {3}
   AND T.CRAFTITEM_CDOE = {4}
   AND DECODE(T.MIN_D, NULL, 1, TO_NUMBER({5})) >= NVL(T.MIN_D, 1)
   AND DECODE(T.MAX_D, NULL, 1, TO_NUMBER({5})) <= NVL(T.MAX_D, 1)
   AND DECODE(T.MIN_D, NULL, 1, TO_NUMBER({6})) <= NVL(T.MIN_H, 1)
   AND DECODE(T.MAX_H, NULL, 1, TO_NUMBER({6})) >= NVL(T.MAX_H, 1)
         ]]>
	</query>
	
	<query id="ProDucDao.getCft4" desc="查询工艺参数">
         <![CDATA[
SELECT *
  FROM COM_MSC_STD_CRAFT T
 WHERE T.MSC = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.STATION_CODE = {3}
   AND T.CRAFTITEM_CDOE = {4}
   AND NVL(T.SPEC_JG, '1') = DECODE(T.SPEC_JG, NULL, '1', {5})
   AND (INSTR(T.MODEL_CODE, {5}) > 0 OR T.MODEL_CODE IS NULL)
         ]]>
	</query>
	
	<query id="ProDucDao.getCft5" desc="查询工艺参数">
         <![CDATA[
SELECT *
  FROM COM_MSC_STD_CRAFT T
 WHERE T.MSC = {0}
   AND T.MSC_PLINE = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.STATION_CODE = {3}
   AND T.CRAFTITEM_CDOE = {4}
   AND DECODE(T.MIN_D, NULL, 1, TO_NUMBER({5})) >= NVL(T.MIN_D, 1)
   AND DECODE(T.MAX_D, NULL, 1, TO_NUMBER({5})) <= NVL(T.MAX_D, 1)
   AND DECODE(T.MIN_D, NULL, 1, TO_NUMBER({6})) <= NVL(T.MIN_H, 1)
   AND DECODE(T.MAX_H, NULL, 1, TO_NUMBER({6})) >= NVL(T.MAX_H, 1)
   AND (INSTR(T.MODEL_CODE, {7}) > 0 OR T.MODEL_CODE IS NULL)
         ]]>
	</query>
	
	<query id="ProDucDao.getProcessSpec" desc="查询工序规格">
         <![CDATA[
SELECT T.SPEC_CODE,
       A.DIMATER,
       A.HEIGHT,
       T.B_SPEC_CODE,
       B.SPEC_NAME B_SPEC_NAME,
       T.C_SPEC_CODE,
       T.C_SPEC_NAME
  FROM CRAFT_ORD_DESIGN_MSC_BILT_C T
  LEFT JOIN COM_BASE_SPEC A
    ON A.SPEC_CODE = T.SPEC_CODE
  LEFT JOIN COM_BASE_SPEC B
    ON B.SPEC_CODE = T.B_SPEC_CODE
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
         ]]>
	</query>

	<query id="ProDucDao.saveCft" desc="保存工艺参数">
         <![CDATA[
 INSERT INTO CRAFT_ORD_DESIGN_MSC_CFT(
        DESGIN_KEY,
        MSC,
        MSC_PLINE,
        BACKLOG_SEQ,
        PROCESS_CDOE,
        PROCESS_DESC,
        PROCESS_CDOE_C,
        PROCESS_DESC_C,
        STATION_CODE,
        STATION_DESC,
        MIN_D,
        MAX_D,
        MIN_H,
        MAX_H,
        MODEL_CODE,
        MODEL_DESC,
        SPEC_JG,
        SPEC_JG_DESC,
        GRADE_SEQ,
        CRAFTITEM_CDOE,
        CRAFTITEM_DESC,
        ALLOW_COUNT,
        MIN_VALUE,
        MAX_VALUE,
        CRAFTITEM_CDOE1,
        CRAFTITEM_DESC1,
        MIN_VALUE1,
        MAX_VALUE1,
        CRAFTITEM_CDOE2,
        CRAFTITEM_DESC2,
        MIN_VALUE2,
        MAX_VALUE2,
        CRAFTITEM_CDOE3,
        CRAFTITEM_DESC3,
        MIN_VALUE3,
        MAX_VALUE3,
        CRAFTITEM_CDOE4,
        CRAFTITEM_DESC4,
        MIN_VALUE4,
        MAX_VALUE4,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        DELETE_NAME,
        DELETE_TIME,
        VALIDFLAG,
        MEMO)
 VALUES( 
        '#DESGIN_KEY#',
        '#MSC#',
        '#MSC_PLINE#',
        '#BACKLOG_SEQ#',
        '#PROCESS_CDOE#',
        '#PROCESS_DESC#',
        '#PROCESS_CDOE_C#',
        '#PROCESS_DESC_C#',
        '#STATION_CODE#',
        '#STATION_DESC#',
        '#MIN_D#',
        '#MAX_D#',
        '#MIN_H#',
        '#MAX_H#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#SPEC_JG#',
        '#SPEC_JG_DESC#',
        '#GRADE_SEQ#',
        '#CRAFTITEM_CDOE#',
        '#CRAFTITEM_DESC#',
        '#ALLOW_COUNT#',
        '#MIN_VALUE#',
        '#MAX_VALUE#',
        '#CRAFTITEM_CDOE1#',
        '#CRAFTITEM_DESC1#',
        '#MIN_VALUE1#',
        '#MAX_VALUE1#',
        '#CRAFTITEM_CDOE2#',
        '#CRAFTITEM_DESC2#',
        '#MIN_VALUE2#',
        '#MAX_VALUE2#',
        '#CRAFTITEM_CDOE3#',
        '#CRAFTITEM_DESC3#',
        '#MIN_VALUE3#',
        '#MAX_VALUE3#',
        '#CRAFTITEM_CDOE4#',
        '#CRAFTITEM_DESC4#',
        '#MIN_VALUE4#',
        '#MAX_VALUE4#',
        '#CREATE_NAME#',
        SYSDATE,
        '',
        null,
        '',
        NULL,
        '#VALIDFLAG#',
        '#MEMO#')
         ]]>
	</query>

	<query id="ProDucDao.getDeteInfo" desc="查询探伤检验项 ">
         <![CDATA[
       SELECT DESGIN_KEY,
       DIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       XH,
       PHY_CODE,
       PHY_NAME,
       POSITION_CODE,
       POSITION_DESC,
       STD_DESC,
       LV_CODE,
       LV_DESC,
       GROOVE_POS,
       GROOVE_DIR,
       COVERAGE,
       RATE,
       DESC_RATE,
       DESC_VAL,
       GROUP_SEQ,
       MEMO,
       MIN_D,
       MAX_D,
       MIN_H,
       MAX_H
  FROM CRAFT_ORD_DESIGN_STD_DIC T
 WHERE T.DESGIN_KEY = ?
         ]]>
	</query>

	<query id="ProDucDao.getModelStyle" desc="查询探伤检验项 ">
         <![CDATA[
SELECT T.MODEL_STYLE, T.MODEL_STYLE_DESC
  FROM COM_BASE_MODEL T
 WHERE T.MODEL_CODE = ?
   AND T.VALIDFLAG = '1'
         ]]>
	</query>
	
	<query id="ProDucDao.getCraftStation" desc="获取工序中涉及到工艺参数的工序点">
            <![CDATA[ 
SELECT B.STATION_CODE, B.STATION_DESC, C.CRAFTITEM_CODE, C.CRAFTITEM_DESC
  FROM COM_MSC_STATION B, COM_BASE_STATION_R_CRAFT C
 WHERE B.MSC = {0}
   AND B.MSC_PLINE = {1}
   AND B.PROCESS_CODE = {2}
   AND B.STATION_CODE = C.STATION_CODE
                ]]>
	</query>
	
	<query id="ProDucDao.getCraftDesignGrade" desc="获取质量设计钢种">
            <![CDATA[ 
SELECT *
     FROM CRAFT_ORD_DESIGN_MSC_PL_GZ T
    WHERE T.DESGIN_KEY = {0}
      AND T.MSC_PLINE = {1}
                ]]>
	</query>
	
	<query id="ProDucDao.getSLmDesignGrade" desc="获取质量设计钢种">  
            <![CDATA[ 
SELECT *
     FROM SLM_ORD_DESIGN_MSC_PL_GZ T
    WHERE T.DESGIN_KEY = {0}
      AND T.MSC_PLINE = {1}
                ]]>
	</query>
	
	<query id="ProDucDao.getProcessDescC" desc="获取二级工序描述">  
            <![CDATA[ 
SELECT * FROM COM_BASE_PROCESS_C T WHERE T.PROCESS_CDOE_C = {0}
                ]]>
	</query>
</queryMap>