REPLACE INTO dispatch.rd_employee_summary (
	id,
	`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 DISTINCT
    ee.id,
    u.`name`,
    c.head_photo,
    u.telephone,
    o.`name` AS orgName,
    ee.`status`,
    u.checked_status,
    u.authenticated_status,
    u.military_status,(
        SELECT
            c2.number
        FROM
            obpm2.tenant_user_credentials c2
        WHERE
                c2.tenant_user_id = u.id
          AND c2.credential_type = 7
                LIMIT 1
    ) AS securityCredentialNo,
	ee.occupation_type,
	IFNULL( ee.hired_date, CURRENT_TIMESTAMP ) AS hired_date,
	ee.leave_time AS leave_time,
	ifnull( ee.insure, 0 ),
	ee.organization_id,
	ee.tenant_user_id,
	ee.id,
	ee.last_sync_time AS last_sync_time,
	ee.last_updated_time AS last_updated_time,
	'',
	ifnull( u.im_identity, '#' ),
	c.number,
	u.cid
FROM obpm2.tenant_users u
    LEFT JOIN obpm2.tenant_user_credentials c ON u.id = c.tenant_user_id
    AND c.credential_type = 0
    JOIN obpm2.tenant_employees ee ON ee.tenant_user_id = u.id
    JOIN obpm2.tenant_organizations o ON o.id = ee.organization_id
where ee.id in ("327600--__qFCcCnozYNwzoG3O6Ms",
    "327581--__qFCcCnozYNwzoG3O6Ms",
    "327628--__qFCcCnozYNwzoG3O6Ms",
    "327596--__qFCcCnozYNwzoG3O6Ms",
    "327406--__qFCcCnozYNwzoG3O6Ms",
    "327564--__qFCcCnozYNwzoG3O6Ms",
    "z9CbkaGn",
    "z0o5IAvv1AVlqh7BmK9");



select CONCAT("""",id,""",") as eid,idCard_no,`name` from dispatch.rd_employee_summary
where idCard_no is null limit 300000;