<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="CRAFT_FILE_LV2 （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="CraftFileLv2DAL.Query" desc="查询">
        <![CDATA[
 SELECT 
       T.PK,
       T.CRAFT_NO_LV2,
       T.PROCESS_CODE,
       T.PROCESS_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       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,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       CRAFT_PATH,
       MSC,
       MEMO
 FROM CRAFT_FILE_LV2 T
 WHERE 1 = 1
        ]]>
    </query>
    <query id="CraftFileLv2DAL.QueryAll" desc="查询">
        <![CDATA[
SELECT * FROM CRAFT_FILE_LV2 T
        ]]>
    </query>
    <query id="CraftFileLv2DAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.PK,
       T.CRAFT_NO_LV2,
       T.PROCESS_CODE,
       T.PROCESS_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       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.VALIDFLAG
 FROM CRAFT_FILE_LV2 T
 WHERE
       T.PK = '#PK#'
        ]]>
    </query>
    <query id="CraftFileLv2DAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO CRAFT_FILE_LV2(
        PK,
        CRAFT_NO_LV2,
        PROCESS_CODE,
        PROCESS_DESC,
        PLINE_CODE,
        PLINE_NAME,
        CREATE_NAME,
        CREATE_TIME,
        CRAFT_PATH,
        MSC,
        MEMO)
 VALUES( 
        '#PK#',
        '#CRAFT_NO_LV2#',
        '#PROCESS_CODE#',
        '#PROCESS_DESC#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#CREATE_NAME#',
        SYSDATE,
        '#CRAFT_PATH#',
        '#MSC#',
        '#MEMO#')
        ]]>
    </query>
    <query id="CraftFileLv2DAL.Update" desc="修改">
        <![CDATA[
 UPDATE CRAFT_FILE_LV2 T
   SET
        T.CRAFT_NO_LV2 = DECODE(T.CRAFT_NO_LV2, NULL, '#CRAFT_NO_LV2#', T.CRAFT_NO_LV2),
        T.PROCESS_CODE = '#PROCESS_CODE#',
        T.PROCESS_DESC = '#PROCESS_DESC#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PLINE_NAME = '#PLINE_NAME#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.CRAFT_PATH = '#CRAFT_PATH#',
        T.MSC = '#MSC#',
        T.MEMO = '#MEMO#'
 WHERE
       T.PK = '#PK#'
        ]]>
    </query>
    <query id="CraftFileLv2DAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT LPAD(NVL(MAX(PK), 0) + 1, 5, '0') MAX_VALUE FROM CRAFT_FILE_LV2 T
        ]]>
    </query>
    <query id="CraftFileLv2DAL.Delete" desc="作废">
        <![CDATA[
UPDATE CRAFT_FILE_LV2 T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.PK = '#PK#'
        ]]>
    </query>
    <query id="CraftFileLv2DAL.Resume" desc="恢复">
        <![CDATA[
UPDATE CRAFT_FILE_LV2 T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.PK = '#PK#'
        ]]>
    </query>
    <query id="CraftFileLv2DAL.FilterCraftFileLv2" desc="通过工艺评审结果过滤可用的二级工艺文件">
        <![CDATA[
SELECT A.PK,
       A.CRAFT_NO_LV2,
       A.PROCESS_CODE,
       A.PROCESS_DESC,
       A.PLINE_CODE,
       A.PLINE_NAME,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(A.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       A.CRAFT_PATH,
       A.MSC,
       A.MEMO
  FROM CRAFT_FILE_LV2 A
 WHERE (EXISTS
        (SELECT 1
           FROM CRAFT_FILE_LV2_C B, CRAFT_ORD_DESIGN_MSC C
          WHERE C.DESGIN_KEY = '#DESGIN_KEY#'
            AND B.FILE_LV2_PK = A.PK
            AND B.VALIDFLAG = '1'
            AND (INSTR(B.PRODUCCODE, C.PRODUCCODE) > 0 OR
                B.PRODUCCODE IS NULL)
            AND (INSTR(B.STEELCODE, C.STEELCODE) > 0 OR B.STEELCODE IS NULL)
            AND (INSTR(B.STD_CODE, C.STD_CODE) > 0 OR B.STD_CODE IS NULL)
            AND (INSTR(B.MODEL_CODE, C.MODEL_CODE) > 0 OR
                B.MODEL_CODE IS NULL)
            AND (INSTR(B.CRAFT_NO, '#CRAFT_NO#') > 0 OR B.CRAFT_NO IS NULL)
          #GRADECODE#
            AND COMPARE_VALUE(C.DIMATER, B.MIN_D_SIGN, B.MIN_D) = 1
            AND COMPARE_VALUE(C.DIMATER, B.MAX_D_SIGN, B.MAX_D) = 1
            AND COMPARE_VALUE(C.HEIGHT, B.MIN_H_SIGN, B.MIN_H) = 1
            AND COMPARE_VALUE(C.HEIGHT, B.MAX_H_SIGN, B.MAX_H) = 1) OR
        NOT EXISTS (SELECT 1
                      FROM CRAFT_FILE_LV2_C B
                     WHERE B.FILE_LV2_PK = A.PK
                       AND B.VALIDFLAG = '1'))
   AND A.CRAFT_NO_LV2 IS NOT NULL
   AND A.PROCESS_CODE = '#PROCESS_CODE#'
   AND A.MSC = '#MSC#'
   AND A.VALIDFLAG IN ('1', '#VALIDFALG#')
   AND DECODE('#CRAFT_NO_LV2#', NULL, '1', LOWER(A.CRAFT_NO_LV2)) LIKE
       DECODE('#CRAFT_NO_LV2#', NULL, '1', LOWER('%#CRAFT_NO_LV2#%'))
        ]]>
    </query>
    <query id="CraftFileLv2DAL.QueryCraftGz" desc="查询工艺评审钢种">
        <![CDATA[
SELECT * FROM CRAFT_ORD_DESIGN_MSC_PL_GZ T WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
        ]]>
    </query>
    <query id="CraftFileLv2DAL.IsExistCraftLv2" desc="是否存在二级工艺文件">
        <![CDATA[
SELECT 1
  FROM CRAFT_FILE_LV2 T
 WHERE T.CRAFT_NO_LV2 = '#CRAFT_NO_LV2#'
   AND T.PK <> '#PKC#'
        ]]>
    </query>
</queryMap>