INSERT INTO jdbc_insert_rd_employee_summary (
    id,
    supervise_region_code,
    name,
    head_photo,
    contact,
    company_name,
    status,
    checked_status,
    authenticated_status,
    military_status,
    security_certificate_no,
    occupation_type,
    hired_date,
    leave_time,
    insure,
    organization_id,
    tenant_user_id,
    tenant_employee_id,
    last_sync_time,
    last_updated_time,
    device_number,
    tenant_im_user_id,
    idCard_no,
    cid
) SELECT
      ee.id,
      '#fk-t399',
      u.`name`,
      c.head_photo,
      u.telephone,
      o.`name` AS orgName,
      ee.`status`,
      u.checked_status,
      u.authenticated_status,
      u.military_status,(
          d.number
    ) AS securityCredentialNo,
	ee.occupation_type,
	IFNULL( TO_TIMESTAMP ( FROM_UNIXTIME( ee.hired_date / 1000, 'yyyy-MM-dd HH:mm:ss' )), CURRENT_TIMESTAMP ) AS hired_date,
	TO_TIMESTAMP (
	FROM_UNIXTIME( ee.leave_time / 1000, 'yyyy-MM-dd HH:mm:ss' )) AS leave_time,
	ifnull( ee.insure, 0 ),
	ee.organization_id,
	ee.tenant_user_id,
	ee.id,
	TO_TIMESTAMP (
	FROM_UNIXTIME( ee.last_sync_time / 1000, 'yyyy-MM-dd HH:mm:ss' )) AS last_sync_time,
	TO_TIMESTAMP (
	FROM_UNIXTIME( ee.last_updated_time / 1000, 'yyyy-MM-dd HH:mm:ss' )) AS last_updated_time,
	'',
	ifnull( u.im_identity, '#' ),
	c.number,
	u.cid
FROM
    kafka_tenant_users u
    JOIN kafka_tenant_user_credentials c ON c.id = u.selected_credential_id
    JOIN kafka_tenant_employees ee ON ee.tenant_user_id = u.id
    JOIN kafka_tenant_organizations o ON o.id = ee.organization_id
    LEFT JOIN kafka_tenant_user_credentials d on d.tenant_user_id=u.id and d.credential_type = 7
WHERE
    ee.`status` =0 and o.approved_information_status=1