<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zc
    $Date: 2020年11月18日 14点02分
    $Revision: 1.0
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                begin
                    con_contract_workflow_pkg.contract_sign_cancel(
                    p_contract_id =>${@contract_id},
                    p_user_id => ${/session/@user_id}
                    );
                end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                  select *
                    from (select cf.ele_flow_id, cf.contract_id
                            FROM CON_CONTRACT_ELE_FLOW cf
                           where cf.ele_flow_type in ('CE', 'AE')
                             and cf.revoke_flag is null
                          union all
                          select ce.ele_flow_id, ce.contract_id
                            from con_contract_ele_flow ce
                           where ce.ele_flow_type = 'ET'
                             and ce.revoke_flag is null
                             and ce.flow_status is null) t
				  #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                begin
                    update con_contract c
                       set c.ec_sign_type = 'NEW',
                           c.sign_contract_status = 'NEW',
                           c.last_update_date = sysdate,
                           c.last_updated_by = nvl(${/session/@user_id},'1')
                     where c.contract_id = ${@contract_id};

                    delete from con_contract_ele_signer cs where cs.contract_id = ${@contract_id};
                    delete from CON_CONTRACT_ELE_FLOW t where t.ele_flow_type in ('CE','AE','ET') and t.contract_id = ${@contract_id};
                commit;
                end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="ele_flow_id" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ELE_FLOW_ID"/>
        <bm:field name="contract_id"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="t.contract_id = ${@contract_id}"/>
    </bm:query-fields>
</bm:model>
