INSERT INTO dispatch.rd_security_station_summary (
    id,
    NAME,
    station_type,
    company_name,
    principal_id,
    principal_name,
    principal_contact,
    service_scope,
    address,
    count_of_security_man,
    organization_id,
    supervise_domain_id,
    supervise_depart_id,
    last_sync_time,
    last_updated_time,
    site_state,
    begin_date,
    end_date,
    supervise_region_code
) SELECT
      u.ID,
      u.ITEM_ATTENDANCESITENAME,
      u.ITEM_ATTENDANCESITETYPE,
      o.NAME,
      u.ITEM_PRINCIPAL,
      u.ITEM_PRINCIPALNAME,
      u.ITEM_PRINCIPALPHONENO,
      u.ITEM_SERVEOBJECTNAME,
      u.ITEM_ATTENDANCESITEFULLADDRESS,
      ( SELECT count( 1 ) FROM baibaodunflow.tlk_attendance_site_person_info x WHERE x.ITEM_ATTENDANCESITEID = u.ID ) AS count_of_security_man,
      o.ID,
      '#supervise_domain_id-20230407',
      ifnull( u.ITEM_OFFICEPOLICEADDRESSID, '#' ) AS supervise_depart_id,
      u.LASTMODIFIED,
      u.LASTMODIFIED,
      u.ITEM_ATTENDANCESITESTATE,
      u.ITEM_ATTENDANCESTARTDATE,
      u.ITEM_ATTENDANCEENDDATE,
      '130000'
FROM
    baibaodunflow.tlk_attendance_site_base_info u
        JOIN obpm2.tenant_organizations o ON o.ID = u.DOMAINID