同步组织架构人员到数据字典

一、场景:分配权限的时候选不到某些组织部门
 
二、解决方案
1、新系统,在组织管理点击同步AgencyID字典,在人员管理点击同步人员字典,执行完成后清空系统缓存
2、1不生效的话执行下面语句
在框架数据库执行,替换CRM为实际CRM的数据库名称
delete FROM [Dictionary] where type='AgencyID' and value not in(select AgencyID from CRM.dbo.AgencyTable);
delete FROM [Dictionary] where type='DepartmentID' and value not in(select DepartmentID from CRM.dbo.DepartmentTable);

insert into Dictionary([type],[value],text,orderNo,DependValue) select 'AgencyID',AgencyID,AgencyName,OrderID,'1' from  CRM.dbo.AgencyTable where AgencyID not in(select value FROM [Dictionary] where [type]='AgencyID');
insert into Dictionary([type],[value],text,orderNo,DependValue) select 'DepartmentID',DepartmentID,DepartmentName,OrderID,'1' from  CRM.dbo.DepartmentTable where DepartmentID not in(select value FROM [Dictionary] where [type]='DepartmentID');
insert into Dictionary([type],[value],text,orderNo,DependValue) select 'UserGuid',UserGuid,Realname,OrderID,'1' from  CRM.dbo.EmployeeTable where UserGuid not in(select value FROM [Dictionary] where [type]='UserGuid');