


insert into identity_principals(id,created_time,`status`,identity_user_id,last_updated_time)
select
    a.id,'2021-01-01',
    (case when IFNULL(b.LOCKFLAG,1)=0 or IFNULL(b.`STATUS`,1)=0 or IFNULL(b.DIMISSION,1)=0 then 2 else 0 end),
    a.id,
    a.created_time
from identity_user a join t_user b on a.id = b.ID and a.id not in (select id from identity_principals);



