Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
31b07d2d
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
31b07d2d
编写于
6月 30, 2021
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
UnitListObject改为多线程执行
上级
f2b4583c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
105 addition
and
62 deletion
+105
-62
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListObject.java
...ization/assemble/express/jaxrs/unit/ActionListObject.java
+77
-43
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/ActionListIdentityWithUnitWithNameObject.java
...rs/unitduty/ActionListIdentityWithUnitWithNameObject.java
+28
-19
未找到文件。
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListObject.java
浏览文件 @
31b07d2d
...
...
@@ -3,6 +3,16 @@ package com.x.organization.assemble.express.jaxrs.unit;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutionException
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
...
...
@@ -24,39 +34,29 @@ import com.x.organization.core.entity.Identity;
import
com.x.organization.core.entity.Identity_
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.Unit_
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
class
ActionListObject
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionListObject
.
class
);
@SuppressWarnings
(
"unchecked"
)
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
wi
.
getUnitList
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
List
<
Wo
>)
optional
.
get
());
}
else
{
List
<
Wo
>
wos
=
this
.
list
(
business
,
wi
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wos
);
result
.
setData
(
wos
);
}
return
result
;
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
wi
.
getUnitList
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
List
<
Wo
>)
optional
.
get
());
}
else
{
List
<
Wo
>
wos
=
this
.
list
(
wi
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wos
);
result
.
setData
(
wos
);
}
return
result
;
}
public
static
class
Wi
extends
GsonPropertyObject
{
private
static
final
long
serialVersionUID
=
9140053706113645992L
;
@FieldDescribe
(
"组织"
)
private
List
<
String
>
unitList
=
new
ArrayList
<>();
...
...
@@ -71,6 +71,7 @@ class ActionListObject extends BaseAction {
}
public
static
class
Wo
extends
Unit
{
private
static
final
long
serialVersionUID
=
-
7913547275132005308L
;
@FieldDescribe
(
"匹配字段"
)
...
...
@@ -82,9 +83,6 @@ class ActionListObject extends BaseAction {
@FieldDescribe
(
"直接下级身份数量"
)
private
Long
subDirectIdentityCount
=
0L
;
// static WrapCopier<Unit, Wo> copier = WrapCopierFactory.wo(Unit.class, Wo.class, null,
// ListTools.toList(JpaObject.FieldsInvisible,Unit.controllerList_FIELDNAME,Unit.inheritedControllerList_FIELDNAME));
static
WrapCopier
<
Unit
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
Unit
.
class
,
Wo
.
class
,
null
,
ListTools
.
toList
(
JpaObject
.
FieldsInvisible
,
Unit
.
controllerList_FIELDNAME
));
...
...
@@ -114,25 +112,63 @@ class ActionListObject extends BaseAction {
}
private
List
<
Wo
>
list
(
Business
business
,
Wi
wi
)
throws
Exception
{
// private List<Wo> list(Business business, Wi wi) throws Exception {
// List<Wo> wos = new ArrayList<>();
// for (String str : wi.getUnitList()) {
// Unit o = business.unit().pick(str);
// if (o != null) {
// Wo wo = Wo.copier.copy(o);
// wo.setMatchKey(str);
// if (StringUtils.isNotEmpty(wo.getSuperior())) {
// Unit superior = business.unit().pick(wo.getSuperior());
// if (null != superior) {
// wo.setSuperior(superior.getDistinguishedName());
// }
// }
// wo.setSubDirectIdentityCount(this.countSubDirectIdentity(business, wo));
// wo.setSubDirectUnitCount(this.countSubDirectUnit(business, wo));
// wos.add(wo);
// }
// }
// return wos;
//}
private
List
<
Wo
>
list
(
Wi
wi
)
throws
InterruptedException
,
ExecutionException
{
List
<
Wo
>
wos
=
new
ArrayList
<>();
List
<
CompletableFuture
<
Wo
>>
futures
=
new
ArrayList
<>();
for
(
String
str
:
wi
.
getUnitList
())
{
Unit
o
=
business
.
unit
().
pick
(
str
);
if
(
o
!=
null
)
{
Wo
wo
=
Wo
.
copier
.
copy
(
o
);
wo
.
setMatchKey
(
str
);
if
(
StringUtils
.
isNotEmpty
(
wo
.
getSuperior
()))
{
Unit
superior
=
business
.
unit
().
pick
(
wo
.
getSuperior
());
if
(
null
!=
superior
)
{
wo
.
setSuperior
(
superior
.
getDistinguishedName
());
futures
.
add
(
future
(
str
));
}
for
(
CompletableFuture
<
Wo
>
future
:
futures
)
{
wos
.
add
(
future
.
get
());
}
return
wos
;
}
private
CompletableFuture
<
Wo
>
future
(
String
name
)
{
return
CompletableFuture
.
supplyAsync
(()
->
{
Wo
wo
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
Unit
o
=
business
.
unit
().
pick
(
name
);
if
(
o
!=
null
)
{
wo
=
Wo
.
copier
.
copy
(
o
);
wo
.
setMatchKey
(
name
);
if
(
StringUtils
.
isNotEmpty
(
wo
.
getSuperior
()))
{
Unit
superior
=
business
.
unit
().
pick
(
wo
.
getSuperior
());
if
(
null
!=
superior
)
{
wo
.
setSuperior
(
superior
.
getDistinguishedName
());
}
}
wo
.
setSubDirectIdentityCount
(
this
.
countSubDirectIdentity
(
business
,
wo
));
wo
.
setSubDirectUnitCount
(
this
.
countSubDirectUnit
(
business
,
wo
));
}
wo
.
setSubDirectIdentityCount
(
this
.
countSubDirectIdentity
(
business
,
wo
));
wo
.
setSubDirectUnitCount
(
this
.
countSubDirectUnit
(
business
,
wo
));
wos
.
add
(
wo
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
}
return
wos
;
return
wo
;
})
;
}
private
Long
countSubDirectUnit
(
Business
business
,
Wo
wo
)
throws
Exception
{
...
...
@@ -141,8 +177,7 @@ class ActionListObject extends BaseAction {
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
Unit
>
root
=
cq
.
from
(
Unit
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Unit_
.
superior
),
wo
.
getId
());
Long
count
=
em
.
createQuery
(
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
)).
getSingleResult
();
return
count
;
return
em
.
createQuery
(
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
)).
getSingleResult
();
}
private
Long
countSubDirectIdentity
(
Business
business
,
Wo
wo
)
throws
Exception
{
...
...
@@ -151,8 +186,7 @@ class ActionListObject extends BaseAction {
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
Identity
>
root
=
cq
.
from
(
Identity
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Identity_
.
unit
),
wo
.
getId
());
Long
count
=
em
.
createQuery
(
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
)).
getSingleResult
();
return
count
;
return
em
.
createQuery
(
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
)).
getSingleResult
();
}
}
\ No newline at end of file
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/ActionListIdentityWithUnitWithNameObject.java
浏览文件 @
31b07d2d
package
com.x.organization.assemble.express.jaxrs.unitduty
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
com.x.organization.core.entity.*
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -17,12 +26,11 @@ import com.x.base.core.project.http.ActionResult;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.organization.assemble.express.Business
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
com.x.organization.core.entity.Identity
;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.UnitDuty
;
import
com.x.organization.core.entity.UnitDuty_
;
class
ActionListIdentityWithUnitWithNameObject
extends
BaseAction
{
...
...
@@ -196,27 +204,28 @@ class ActionListIdentityWithUnitWithNameObject extends BaseAction {
}
}
private
List
<
Wo
>
list
(
Business
business
,
List
<
String
>
names
,
List
<
String
>
units
,
Boolean
recursiveUnit
)
throws
Exception
{
private
List
<
Wo
>
list
(
Business
business
,
List
<
String
>
names
,
List
<
String
>
units
,
Boolean
recursiveUnit
)
throws
Exception
{
List
<
Wo
>
wos
=
new
ArrayList
<>();
List
<
UnitDuty
>
os
=
new
ArrayList
<>();
Map
<
String
,
Unit
>
unitMap
=
new
HashMap
<>();
if
(
units
.
isEmpty
())
{
if
(
units
.
isEmpty
())
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
UnitDuty
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
UnitDuty
>
cq
=
cb
.
createQuery
(
UnitDuty
.
class
);
Root
<
UnitDuty
>
root
=
cq
.
from
(
UnitDuty
.
class
);
Predicate
p
=
root
.
get
(
UnitDuty_
.
name
).
in
(
names
);
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
}
else
{
}
else
{
List
<
Unit
>
unitList
=
business
.
unit
().
pick
(
units
);
if
(!
unitList
.
isEmpty
())
{
if
(!
unitList
.
isEmpty
())
{
units
.
clear
();
for
(
Unit
unit
:
unitList
)
{
for
(
Unit
unit
:
unitList
)
{
units
.
add
(
unit
.
getId
());
unitMap
.
put
(
unit
.
getId
(),
unit
);
if
(
BooleanUtils
.
isTrue
(
recursiveUnit
))
{
if
(
BooleanUtils
.
isTrue
(
recursiveUnit
))
{
List
<
Unit
>
subUnitList
=
business
.
unit
().
listSubNestedObject
(
unit
);
for
(
Unit
subunit
:
subUnitList
)
{
for
(
Unit
subunit
:
subUnitList
)
{
unitMap
.
put
(
subunit
.
getId
(),
subunit
);
units
.
add
(
subunit
.
getId
());
}
...
...
@@ -237,12 +246,12 @@ class ActionListIdentityWithUnitWithNameObject extends BaseAction {
int
i
=
0
;
for
(
Identity
identity
:
business
.
identity
().
pick
(
o
.
getIdentityList
()))
{
Unit
matchUnit
=
unitMap
.
get
(
o
.
getUnit
());
if
(
matchUnit
==
null
)
{
if
(
matchUnit
==
null
)
{
matchUnit
=
business
.
unit
().
pick
(
o
.
getUnit
());
unitMap
.
put
(
matchUnit
.
getId
(),
matchUnit
);
}
Unit
unit
=
unitMap
.
get
(
identity
.
getUnit
());
if
(
unit
==
null
)
{
if
(
unit
==
null
)
{
unit
=
business
.
unit
().
pick
(
identity
.
getUnit
());
unitMap
.
put
(
unit
.
getId
(),
unit
);
}
...
...
@@ -269,12 +278,12 @@ class ActionListIdentityWithUnitWithNameObject extends BaseAction {
if
(
null
!=
unit
)
{
wo
.
setUnit
(
unit
.
getDistinguishedName
());
wo
.
setUnitOrder
(
unit
.
getOrderNumber
());
}
else
{
}
else
{
wo
.
setUnit
(
identity
.
getUnit
());
}
if
(
null
!=
person
)
{
wo
.
setPerson
(
person
.
getDistinguishedName
());
}
else
{
}
else
{
wo
.
setPerson
(
identity
.
getPerson
());
}
if
(
null
!=
identity
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录