<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
SELECT t.*,(select scv.code_value_name
          from sys_code_values_v scv
         where scv.code = 'RSC_FIVE_CLASS_EXAMINE_STATUS'
           and scv.code_value = t.status_name) status_name_n,
(select scv.code_value_name
          from sys_code_values_v scv
         where scv.code = 'RSC_FIVE_CLASS_CRITERION'
           and scv.code_value = t.before_sort) before_sort_n ,
(SELECT hb.bp_name FROM hls_bp_master hb
      where hb.bp_id=t.bp_id_tenant) bp_id_tenant_n,
 (SELECT cc.contract_number FROM con_contract cc
      where cc.contract_id=t.contract_id) contract_number_n  FROM (SELECT cc.contract_id,
       cc.overdue_max_days,
       cc.bp_id_tenant,
       cc.lease_channel,
       'APPROVING' status_name,
       nvl(cc.five_class, 'NORMAL') before_sort
  FROM con_contract cc
  where cc.data_class='NORMAL'
  and cc.contract_number=${@contract_number}) t
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                begin
                    RSC_FIVE_CLASS_WFL.UPDATE_FINAL_SORT
                    (
                        p_estimate_num=>${@estimate_num},
                        p_user_id=>${/session/@user_id}
                    );
                end;]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
