1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| CREATE OR REPLACE FUNCTION sync_flowable_identify() RETURNS NUMERIC AS $$ BEGIN
raise notice '业务用户数与Flowable用户数同步'; INSERT INTO act_id_user(id_,rev_,first_,last_,display_name_,email_,tenant_id_) SELECT username,'2',fullname,'[同步]',fullname,email,null from t_member where username not in (SELECT id_ from act_id_user); update act_id_user set pwd_ = '123123' where id_ = 'admin';
raise notice '业务角色数与Flowable组同步'; INSERT INTO act_id_group(id_,rev_,name_,type_) SELECT distinct name,1,name,'assignment' from t_role where name <> '' and name not in (SELECT id_ from act_id_group);
raise notice '业务关系记录与Flowable关系记录同步'; INSERT INTO act_id_membership(user_id_,group_id_) select distinct m.username,r.name from t_member_role mr left join t_member m on mr.member_id=m.id left join t_role r on mr.role_id = r.id where m.username is not null and m.username not in (select user_id_ from act_id_membership);
RETURN 1; END; $$ LANGUAGE PLPGSQL;
SELECT sync_flowable_identify();
|