<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
         
          select 
 pci.description cdd_item_desc,
                    pp.check_id,

       hls_sys_upload_pkg.get_atm_file_href_json(p_table_pk_value => pp.check_id, p_source_type =>'PRJ_CDD_ITEM_CHECK', p_user_id => ${@user_id}) attach                                      
   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 = 'PRJ_PROJECT'
           AND pcf.document_id = ${@project_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,
       (SELECT sg.tab_group_id
          FROM prj_cdd_item_tab_sub_group sg
         START WITH sg.parent_tab_group_id = 83
        CONNECT BY PRIOR sg.tab_group_id = sg.parent_tab_group_id
        UNION
        SELECT to_number(83)--附件分组号:PROJECT
          FROM dual) sg
 WHERE pci.cdd_item_id = lgt.cdd_item_id
   AND lgt.tab_group_id = tg.tab_group_id
   AND lgt.tab_group_id = sg.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 =(select w.cdd_list_id from prj_project w where w.project_id = ${@project_id})
   AND lgt.cdd_list_id = pci.cdd_list_id
   AND pci.enabled_flag = 'Y'
 ORDER BY lgt.seq_num ASC

            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="cdd_item_desc"/>
        <bm:field name="attach"/>
        <bm:field name="check_id"/>
    </bm:fields>
</bm:model>
