<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zc
    $Date: 2020年11月20日
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="contract_id"/>
        <bm:field name="ele_flow_id"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                 select * from (
                 select c.contract_id, c.ele_flow_id
                  from con_contract_ele_flow c
                 where nvl(c.ele_file_dl_flag,'N') = 'N'
                   and (c.flow_status = 2 or c.flow_status is null)
                   and c.creation_date>=add_months(sysdate,-1)) t1
                 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                  wx_ele_contract_pkg.init_con_atm(p_contract_id => ${@contract_id},
                                                   p_file_path   => ${@file_url},
                                                   p_file_name   => ${@file_name},
                                                   p_file_length => ${@file_size},
                                                   p_user_id     => nvl(${/session/@user_id},1));
                   COMMIT;
                END;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                BEGIN
                      update con_contract_ele_flow cr
                       set cr.ele_file_dl_flag = 'Y',
                           cr.last_update_date = sysdate
                     where cr.ele_flow_id =${@flow_id};
                   COMMIT;
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="contract_id" queryOperator="="/>
        <bm:query-field field="ele_flow_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
