Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzou
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzou
提交
d86e600a
提交
d86e600a
编写于
5月 10, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
直接内存代替缓存
上级
8a95b275
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
130 行增加
和
106 行删除
+130
-106
OUModelService.java
...va/cn/ibizlab/core/extensions/service/OUModelService.java
+130
-106
未找到文件。
ibzou-core/src/main/java/cn/ibizlab/core/extensions/service/OUModelService.java
浏览文件 @
d86e600a
...
...
@@ -18,51 +18,59 @@ import java.util.*;
public
class
OUModelService
{
@Autowired
private
IIBZOrganizationService
iibzOrganizationService
;
@Autowired
private
IIBZDepartmentService
iibzDepartmentService
;
@Cacheable
(
value
=
"ibzou-model"
,
key
=
"'orgmap'"
)
public
synchronized
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
getOrgModel
()
private
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
orgmap
=
null
;
private
Object
lockOrg
=
new
Object
();
//@Cacheable( value="ibzou-model",key = "'orgmap'")
public
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
getOrgModel
()
{
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
store
=
new
LinkedHashMap
<>();
Map
<
String
,
IBZOrganization
>
orgset
=
new
LinkedHashMap
<>();
List
<
IBZOrganization
>
listOrg
=
iibzOrganizationService
.
list
();
for
(
IBZOrganization
org:
listOrg
)
if
(
orgmap
!=
null
)
return
orgmap
;
synchronized
(
lockOrg
)
{
Map
<
String
,
Set
<
String
>>
map
=
new
HashMap
<>();
Set
<
String
>
parent
=
new
LinkedHashSet
<
String
>();
if
(!
StringUtils
.
isEmpty
(
org
.
getParentorgid
()))
parent
.
add
(
org
.
getParentorgid
());
map
.
put
(
"parent"
,
parent
);
Set
<
String
>
sub
=
new
LinkedHashSet
<
String
>();
sub
.
add
(
org
.
getOrgid
());
map
.
put
(
"sub"
,
sub
);
store
.
put
(
org
.
getOrgid
(),
map
);
orgset
.
put
(
org
.
getOrgid
(),
org
);
}
if
(
orgmap
!=
null
)
return
orgmap
;
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
store
=
new
LinkedHashMap
<>();
Map
<
String
,
IBZOrganization
>
orgset
=
new
LinkedHashMap
<>();
List
<
IBZOrganization
>
listOrg
=
iibzOrganizationService
.
list
();
for
(
IBZOrganization
org:
listOrg
)
{
Map
<
String
,
Set
<
String
>>
map
=
new
HashMap
<>();
Set
<
String
>
parent
=
new
LinkedHashSet
<
String
>();
if
(!
StringUtils
.
isEmpty
(
org
.
getParentorgid
()))
parent
.
add
(
org
.
getParentorgid
());
map
.
put
(
"parent"
,
parent
);
Set
<
String
>
sub
=
new
LinkedHashSet
<
String
>();
sub
.
add
(
org
.
getOrgid
());
map
.
put
(
"sub"
,
sub
);
store
.
put
(
org
.
getOrgid
(),
map
);
orgset
.
put
(
org
.
getOrgid
(),
org
);
}
for
(
IBZOrganization
org:
listOrg
)
{
loopOrg
(
org
,
orgset
,
store
);
}
for
(
IBZOrganization
org:
listOrg
)
{
loopOrg
(
org
,
orgset
,
store
);
}
for
(
IBZOrganization
org:
listOrg
)
{
for
(
String
sub:
store
.
get
(
org
.
getOrgid
()).
get
(
"sub"
))
for
(
IBZOrganization
org:
listOrg
)
{
if
(!
org
.
getOrgid
().
equals
(
sub
))
store
.
get
(
sub
).
get
(
"parent"
).
add
(
org
.
getOrgid
());
for
(
String
sub:
store
.
get
(
org
.
getOrgid
()).
get
(
"sub"
))
{
if
(!
org
.
getOrgid
().
equals
(
sub
))
store
.
get
(
sub
).
get
(
"parent"
).
add
(
org
.
getOrgid
());
}
}
orgmap
=
store
;
}
return
store
;
return
orgmap
;
}
public
void
loopOrg
(
IBZOrganization
org
,
Map
<
String
,
IBZOrganization
>
orgset
,
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
store
)
...
...
@@ -79,102 +87,114 @@ public class OUModelService
}
@Cacheable
(
value
=
"ibzou-model"
,
key
=
"'deptmap'"
)
public
synchronized
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
getDeptModel
(
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
orgstore
)
{
if
(
orgstore
==
null
)
orgstore
=
this
.
getOrgModel
();
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
store
=
new
LinkedHashMap
<>();
Map
<
String
,
IBZDepartment
>
deptset
=
new
LinkedHashMap
<>();
Map
<
String
,
Set
<
String
>>
bcmap
=
new
HashMap
<>();
private
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
deptmap
=
null
;
private
Object
lockDept
=
new
Object
();
List
<
IBZDepartment
>
listDept
=
iibzDepartmentService
.
list
();
for
(
IBZDepartment
dept:
listDept
)
//@Cacheable( value="ibzou-model",key = "'deptmap'")
public
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
getDeptModel
(
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
orgstore
)
{
if
(
deptmap
!=
null
)
return
deptmap
;
synchronized
(
lockDept
)
{
Map
<
String
,
Set
<
String
>>
map
=
new
HashMap
<>();
Set
<
String
>
parent
=
new
LinkedHashSet
<
String
>();
if
(!
StringUtils
.
isEmpty
(
dept
.
getParentdeptid
()))
parent
.
add
(
dept
.
getParentdeptid
());
map
.
put
(
"parent"
,
parent
);
Set
<
String
>
sub
=
new
LinkedHashSet
<
String
>();
sub
.
add
(
dept
.
getDeptid
());
map
.
put
(
"sub"
,
sub
);
store
.
put
(
dept
.
getDeptid
(),
map
);
deptset
.
put
(
dept
.
getDeptid
(),
dept
);
String
bc
=
dept
.
getBcode
();
if
(!
StringUtils
.
isEmpty
(
bc
))
if
(
deptmap
!=
null
)
return
deptmap
;
if
(
orgstore
==
null
)
orgstore
=
this
.
getOrgModel
();
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
store
=
new
LinkedHashMap
<>();
Map
<
String
,
IBZDepartment
>
deptset
=
new
LinkedHashMap
<>();
Map
<
String
,
Set
<
String
>>
bcmap
=
new
HashMap
<>();
List
<
IBZDepartment
>
listDept
=
iibzDepartmentService
.
list
();
for
(
IBZDepartment
dept:
listDept
)
{
bc
=
bc
.
replace
(
";"
,
","
).
replace
(
";"
,
","
).
replace
(
","
,
","
);
String
[]
bcs
=
bc
.
split
(
","
);
for
(
String
strbc:
bcs
)
Map
<
String
,
Set
<
String
>>
map
=
new
HashMap
<>();
Set
<
String
>
parent
=
new
LinkedHashSet
<
String
>();
if
(!
StringUtils
.
isEmpty
(
dept
.
getParentdeptid
()))
parent
.
add
(
dept
.
getParentdeptid
());
map
.
put
(
"parent"
,
parent
);
Set
<
String
>
sub
=
new
LinkedHashSet
<
String
>();
sub
.
add
(
dept
.
getDeptid
());
map
.
put
(
"sub"
,
sub
);
store
.
put
(
dept
.
getDeptid
(),
map
);
deptset
.
put
(
dept
.
getDeptid
(),
dept
);
String
bc
=
dept
.
getBcode
();
if
(!
StringUtils
.
isEmpty
(
bc
))
{
strbc
=
strbc
.
trim
();
if
(!
StringUtils
.
isEmpty
(
strbc
))
bc
=
bc
.
replace
(
";"
,
","
).
replace
(
";"
,
","
).
replace
(
","
,
","
);
String
[]
bcs
=
bc
.
split
(
","
);
for
(
String
strbc:
bcs
)
{
if
(!
bcmap
.
containsKey
(
strbc
))
strbc
=
strbc
.
trim
();
if
(!
StringUtils
.
isEmpty
(
strbc
))
{
Set
<
String
>
bcset
=
new
HashSet
<>();
bcmap
.
put
(
strbc
,
bcset
);
if
(!
bcmap
.
containsKey
(
strbc
))
{
Set
<
String
>
bcset
=
new
HashSet
<>();
bcmap
.
put
(
strbc
,
bcset
);
}
bcmap
.
get
(
strbc
).
add
(
dept
.
getDeptid
()+
":"
+
dept
.
getOrgid
());
}
bcmap
.
get
(
strbc
).
add
(
dept
.
getDeptid
()+
":"
+
dept
.
getOrgid
());
}
}
}
}
for
(
IBZDepartment
dept:
listDept
)
{
loopDept
(
dept
,
deptset
,
store
);
}
for
(
IBZDepartment
dept:
listDept
)
{
for
(
String
sub:
store
.
get
(
dept
.
getDeptid
()).
get
(
"sub"
))
for
(
IBZDepartment
dept:
listDept
)
{
if
(!
dept
.
getDeptid
().
equals
(
sub
))
store
.
get
(
sub
).
get
(
"parent"
).
add
(
dept
.
getDeptid
());
loopDept
(
dept
,
deptset
,
store
);
}
}
for
(
IBZDepartment
dept:
listDept
)
{
String
orgid
=
dept
.
getOrgid
();
if
(
StringUtils
.
isEmpty
(
orgid
)||(!
orgstore
.
containsKey
(
orgid
)))
continue
;
for
(
IBZDepartment
dept:
listDept
)
{
for
(
String
sub:
store
.
get
(
dept
.
getDeptid
()).
get
(
"sub"
))
{
if
(!
dept
.
getDeptid
().
equals
(
sub
))
store
.
get
(
sub
).
get
(
"parent"
).
add
(
dept
.
getDeptid
());
}
}
String
bc
=
dept
.
getBcode
();
if
(!
StringUtils
.
isEmpty
(
bc
))
for
(
IBZDepartment
dept:
listDept
)
{
bc
=
bc
.
replace
(
";"
,
","
).
replace
(
";"
,
","
).
replace
(
","
,
","
);
String
[]
bcs
=
bc
.
split
(
","
);
for
(
String
strbc
:
bcs
)
String
orgid
=
dept
.
getOrgid
();
if
(
StringUtils
.
isEmpty
(
orgid
)||(!
orgstore
.
containsKey
(
orgid
)))
continue
;
String
bc
=
dept
.
getBcode
();
if
(!
StringUtils
.
isEmpty
(
bc
))
{
strbc
=
strbc
.
trim
();
if
(!
StringUtils
.
isEmpty
(
strbc
))
bc
=
bc
.
replace
(
";"
,
","
).
replace
(
";"
,
","
).
replace
(
","
,
","
);
String
[]
bcs
=
bc
.
split
(
","
);
for
(
String
strbc
:
bcs
)
{
if
(
bcmap
.
containsKey
(
strbc
))
strbc
=
strbc
.
trim
();
if
(!
StringUtils
.
isEmpty
(
strbc
))
{
Set
<
String
>
bcset
=
bcmap
.
get
(
strbc
);
for
(
String
bcstring:
bcset
)
if
(
bcmap
.
containsKey
(
strbc
))
{
S
tring
[]
bcstringarr
=
bcstring
.
split
(
":"
);
if
(
bcstringarr
.
length
==
2
)
S
et
<
String
>
bcset
=
bcmap
.
get
(
strbc
);
for
(
String
bcstring:
bcset
)
{
String
bcdept
=
bcstringarr
[
0
];
String
bcorg
=
bcstringarr
[
1
];
for
(
String
porg:
orgstore
.
get
(
orgid
).
get
(
"parent"
))
String
[]
bcstringarr
=
bcstring
.
split
(
":"
);
if
(
bcstringarr
.
length
==
2
)
{
if
(
bcorg
.
equals
(
porg
))
store
.
get
(
dept
.
getDeptid
()).
get
(
"parent"
).
add
(
bcdept
);
}
for
(
String
sorg:
orgstore
.
get
(
orgid
).
get
(
"sub"
))
{
if
(
bcorg
.
equals
(
sorg
))
store
.
get
(
dept
.
getDeptid
()).
get
(
"sub"
).
add
(
bcdept
);
String
bcdept
=
bcstringarr
[
0
];
String
bcorg
=
bcstringarr
[
1
];
for
(
String
porg:
orgstore
.
get
(
orgid
).
get
(
"parent"
))
{
if
(
bcorg
.
equals
(
porg
))
store
.
get
(
dept
.
getDeptid
()).
get
(
"parent"
).
add
(
bcdept
);
}
for
(
String
sorg:
orgstore
.
get
(
orgid
).
get
(
"sub"
))
{
if
(
bcorg
.
equals
(
sorg
))
store
.
get
(
dept
.
getDeptid
()).
get
(
"sub"
).
add
(
bcdept
);
}
}
}
}
...
...
@@ -182,9 +202,11 @@ public class OUModelService
}
}
}
deptmap
=
store
;
}
return
store
;
return
deptmap
;
}
public
void
loopDept
(
IBZDepartment
dept
,
Map
<
String
,
IBZDepartment
>
deptset
,
Map
<
String
,
Map
<
String
,
Set
<
String
>>>
store
)
...
...
@@ -201,10 +223,12 @@ public class OUModelService
}
@CacheEvict
(
value
=
"ibzou-model"
,
allEntries
=
true
)
public
void
refreshModel
()
//
@CacheEvict( value="ibzou-model",allEntries = true)
public
synchronized
void
refreshModel
()
{
this
.
deptmap
=
null
;
this
.
orgmap
=
null
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录