REPLACE INTO dispatch.rd_security_station_summary (
	id,
	NAME,
	station_type,
	company_name,
	principal_id,
	principal_name,
	principal_contact,
	service_scope,
	address,
	lon_lat,
	organization_id,
	supervise_domain_id,
	supervise_depart_id,
	last_sync_time,
	last_updated_time,
	site_state,
	begin_date,
	end_date,
	supervise_region_code
) SELECT DISTINCT
              bi.ID,
              bi.ITEM_attendanceSiteName,
              bi.ITEM_attendanceSiteType,
              o.NAME,
              bi.ITEM_principal,
              bi.ITEM_principalName,
              bi.ITEM_principalPhoneNo,
              bi.ITEM_serveObjectName,
              bi.ITEM_attendanceSiteFullAddress,
              #CONCAT("{""lat"":""",ITEM_attendanceSiteLatitude,""",""lon"":""",ITEM_attendanceSiteLongitude,"""}")AS lonlat,
              CONCAT("{""lat"":",ITEM_attendanceSiteLatitude,",""lon"":",ITEM_attendanceSiteLongitude,"}")AS lonlat,
              o.id,
              '#',
              ifnull( bi.ITEM_officePoliceAddressID, '#' ) AS supervise_depart_id,
              bi.LASTMODIFIED,
              bi.LASTMODIFIED,
              bi.ITEM_attendanceSiteState,
              bi.ITEM_attendanceStartDate,
              bi.ITEM_attendanceEndDate,
              '11000'
  FROM
              baibaodunflow.tlk_attendance_site_base_info bi JOIN obpm2.tenant_organizations o ON o.id = bi.DOMAINID
  WHERE ITEM_attendanceSiteState IN ( '生效','待完善');