<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lpc
    $Date: 2018-11-5 上午11:12:08
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:fields>
        <bm:field name="source_id"/>
        <bm:field name="company_name"/>
        <bm:field name="business_type"/>
        <bm:field name="address"/>
        <bm:field name="id_number"/>
        <bm:field name="opt_type"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT *
                FROM (SELECT bp.bp_code source_id,
                bp.bp_name company_name,
                decode(bp.bp_type,
                'AGENT',
                '0',
                'TRAILER_COMPANY',
                '1') business_type,
                nvl((SELECT ba.address
                FROM hls_bp_master_address ba
                WHERE ba.bp_id = bp.bp_id
                AND ba.address_type = 'REGISTERED_ADDRESS'
                AND rownum = 1),
                '没有地址') address,
                ' ' id_number,
                compare_update_flag_pkg.get_company_modify_flag(p_bp_id           => bp.bp_id,
                p_comparison_date => SYSDATE - 0.5 / 24,
                p_sys_user        => 'N', --检查sys_user
                p_bp_adress       => 'Y', --检查hls_bp_master_adress
                p_company         => 'Y',
                p_trailer         => 'N') opt_type
                FROM hls_bp_master bp
                WHERE bp.bp_type IN ('AGENT',
                'TRAILER_COMPANY')) t1
                WHERE t1.opt_type <> 'N'
                ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                declare
                v_job_id number;
                begin
                SELECT MAX(job_id) into v_job_id FROM sch_concurrent_job WHERE task_code = 'WX_UPDATE_COMPANY_INFO';
                SCH_CREATE_LOG(p_job_id        => v_job_id,
                p_log_desc      => '接口调用结果('||${@code}||')',
                p_error_message => ${@message});
                end;
                ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
