<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zc
    $Date: 2020年11月9日 10点35分
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="con_ele_signer_id"/>
        <bm:field name="contract_id"/>
        <bm:field name="contract_number"/>
        <bm:field name="bp_id"/>
        <bm:field name="bp_name"/>
        <bm:field name="id_type"/>
        <bm:field name="id_no"/>
        <bm:field name="templet_signer_id"/>
        <bm:field name="ec_sign_status"/>
        <bm:field name="templet_id"/>
        <bm:field name="indentity_type"/>
        <bm:field name="key_word"/>
        <bm:field name="auto_sign"/>
        <bm:field name="sign_order"/>
        <bm:field name="sign_type"/>
        <bm:field name="signer_category"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
select *
  from (select cs.con_ele_signer_id,
               (select cc.contract_number
                  from con_contract cc
                 where cc.contract_id = cs.contract_id
                   and cc.data_class = 'NORMAL') contract_number,
               cs.contract_id,
               cs.bp_id,
               cs.bp_name,
               cs.id_type,
               cs.id_no,
               cs.templet_signer_id,
               cs.ec_sign_status,
               hs.templet_id,
               hs.indentity_type,
               hs.key_word,
               nvl(hs.auto_sign, 'N') auto_sign,
               hs.sign_order,
               hs.sign_type,
               hs.signer_category
          from con_contract_ele_signer cs, hls_doc_file_templet_signer hs
         where cs.templet_signer_id = hs.templet_signer_id
           and cs.esign_type = 'CE'
          and not exists (select 1
          from con_contract_bp cb
         where cb.contract_id = cs.contract_id
           and cb.sp_sign_flag = 'N'
           and hs.signer_category = (cb.bp_category || '_SP')
           and cb.id_no_sp = cs.id_no)) t
                #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            	begin
            		wx_ele_contract_pkg.ele_contract_signer_save(
            			p_contract_id =>${@contract_id},
            			p_user_id     =>nvl(${/session/@user_id},1)
            		);
            	end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="t.contract_id= ${@contract_id}"/>
        <bm:query-field name="signer_category" queryExpression="t.signer_category= ${@signer_category}"/>
    </bm:query-fields>
</bm:model>
