get_prj_cdd.lwm 6.41 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Hongquan.Dai  
    $Date: 2018-2-26 下午4:29:06  
    $Revision: 1.0  
    $Purpose: 打包下载项目附件
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                            SELECT
                    pci.cdd_item,
                    pci.description,
                    pci.order_seq,
                    pci.show_seq,
                    pp.send_flag,
                    pp.paper_required,
                    pp.attachment_required,
                    pp.not_applicable,
                    pp.check_id,
                    (SELECT
                        COUNT(1)
                    FROM
                        fnd_atm_attachment_multi m
                    WHERE
                        m.table_name     = 'PRJ_CDD_ITEM_CHECK' AND
                        m.table_pk_value = TO_CHAR(pp.check_id)
                    )attach_count,
                    pci.sys_flag,
                    pci.note,
                    pci.cdd_list_id,
                    pci.cdd_item_id,
                    pci.line_type,
                    pci.chance_required_flag,
                    pci.chance_display_flag,
                    pci.project_required_flag,
                    pci.project_display_flag,
                    pci.contract_required_flag,
                    pci.contract_display_flag,
                    pci.sign_required_flag,
                    pci.sign_display_flag,
                    pci.incept_required_flag,
                    pci.incept_display_flag,
                    pci.lender_required_flag,
                    pci.lender_display_flag,
                    pci.chance_tab_group,
                    pci.project_tab_group,
                    pci.contract_tab_group,
                    pci.sign_tab_group,
                    pci.incept_tab_group,
                    pci.lender_tab_group,
                    tg.tab_group_id,
                    tg.tab_group attachment_tab_group,
                    lgt.important_flag,
                    lgt.seq_num,
                    DECODE(NVL(lgt.important_flag,'N'),'Y',1,'N',0,0) order_field,
                    NVL(pp.document_id,${@document_id}) document_id,
                    NVL(pp.document_table, ${@document_table}) document_table,
                    NVL(
                    (SELECT
                        'Y'
                    FROM
                        dual
                    WHERE
                        EXISTS
                        (SELECT
                            1
                        FROM
                            con_contract_payment_terms t,
                            con_contract_cashflow cf
                        WHERE
                            t.cashflow_id     =cf.cashflow_id AND
                            cf.contract_id    =${@document_id} AND
                            t.cdd_item_id     =pci.cdd_item_id AND
                            ${@document_table}='CON_CONTRACT'
                        )
                    ),'N') payment_terms_flag,
                    (SELECT
                        ptc.confirm_flag
                    FROM
                        con_contract_payment_t_check ptc
                    WHERE
                        ptc.cdd_item_id    = pci.cdd_item_id AND
                        ptc.contract_id    = ${@document_id} AND
                        ${@document_table} = 'CON_CONTRACT'
                    ) check_confirm_flag,
                    (SELECT
                        ptc.confirm_note
                    FROM
                        con_contract_payment_t_check ptc
                    WHERE
                        ptc.cdd_item_id    = pci.cdd_item_id AND
                        ptc.contract_id    = ${@document_id} AND
                        ${@document_table} = 'CON_CONTRACT'
                    ) check_confirm_note,
                    f.file_path,
                    pci.description
                    || '-' || f.file_name as file_name,
                    f.attachment_id,
                    (Select tab_group From prj_cdd_item_tab_group Where tab_group_id = tg.tab_group_id) AS attach_file_type,  -- add by zhuxianfei
                    (Select tab_group_name From prj_cdd_item_tab_group  Where tab_group_id = tg.tab_group_id) AS attach_file_type_n  
                FROM
                    (SELECT
                        pcf.check_id,
                        pcf.document_id,
                        pcf.document_table,
                        pck.cdd_item_id,
                        pck.send_flag,
                        pck.paper_required,
                        pck.attachment_required,
                        pck.not_applicable
                    FROM
                        prj_cdd_item_doc_ref pcf,
                        prj_cdd_item_check pck
                    WHERE
                        pcf.document_table = ${@document_table} AND
                        pcf.document_id    = ${@document_id} AND
                        pck.check_id       = pcf.check_id
                    ) pp,
                    prj_cdd_item pci,
                    prj_cdd_item_list_grp_tab lgt,
                    prj_cdd_item_tab_group tg,
                    fnd_atm_attachment_multi fm, 
                    fnd_atm_attachment f
                WHERE
                    pci.cdd_item_id  = lgt.cdd_item_id AND
                    lgt.TAB_GROUP_ID =tg.TAB_GROUP_ID AND
                    lgt.enabled_flag = 'Y' AND
                    tg.enabled_flag  = 'Y' AND
                    pci.cdd_item_id  = pp.cdd_item_id(+) AND
                    pci.cdd_list_id  = ${@cdd_list_id} AND
                    lgt.cdd_list_id  = pci.cdd_list_id AND
                    pci.enabled_flag = 'Y' AND
                    fm.attachment_id = f.attachment_id AND
                    fm.table_name = 'PRJ_CDD_ITEM_CHECK' AND
                    fm.table_pk_value = pp.check_id 
                ORDER BY
                lgt.seq_num ASC
            
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_NAME"/>
        <bm:field name="file_path" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PATH"/>
        <bm:field name="attachment_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ATTACHMENT_ID"/>
    </bm:fields>
</bm:model>