<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
      <bm:fields>
            <bm:field name="bp_id"/>
            <bm:field name="auth_id"/>
        </bm:fields>
    <bm:operations>
      <bm:operation name="query">
        <bm:query-sql><![CDATA[
            select *
              from (select c.bp_id, c.auth_id
                      from bp_auth_ele_flow c
                     where c.flow_status is null
                       and c.bp_class = 'ORG'
                       and c.auth_id is not 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_auth_sign_online_pkg.ele_bp_auth_flow(p_bp_id =>${@bp_id},
                                                    p_auth_id =>${@auth_id},
                                                    p_user_id     =>nvl(${/session/@user_id},1));
      END;
    ]]></bm:update-sql>
</bm:operation>
<bm:operation name="execute">
        <bm:update-sql><![CDATA[
          BEGIN
             update bp_auth_ele_flow cf
               set cf.flow_status      = ${@flow_status},
                   cf.end_time         = to_date(${@end_time},'yyyy/mm/dd'),
                   cf.effective_start_time = to_date(${@effective_start_time},'yyyy/mm/dd'),
                   cf.effective_end_time = to_date(${@effective_end_time},'yyyy/mm/dd'),
                   cf.last_update_date = sysdate
             where cf.auth_id = ${@auth_id};

             update bp_agent_ele_signer cs
                set cs.effective_start_time = to_date(${@effective_start_time},'yyyy/mm/dd'),
                    cs.effective_end_time= to_date(${@effective_end_time},'yyyy/mm/dd'),
                    cs.sign_status=${@flow_status},
                    cs.last_update_date = sysdate
              where cs.bp_id = ${@bp_id};

             update hls_bp_master cc
                set cc.sign_auth_status     = {@flow_status},
                    cc.effective_start_time = to_date(${@effective_start_time},'yyyy/mm/dd'),
                    cc.effective_end_time = to_date(${@effective_end_time},'yyyy/mm/dd'),
                    cc.last_update_date = sysdate
              where cc.bp_id = ${@bp_id};
                COMMIT;
              end;
            ]]></bm:update-sql>
    </bm:operation>
</bm:operations>
  <bm:query-fields>
        <bm:query-field field="bp_id" queryOperator="="/>
        <bm:query-field field="auth_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
