Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
a89a65fe
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,发现更多精彩内容 >>
提交
a89a65fe
编写于
7月 07, 2021
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
内容管理管理员文档分页查询优化
上级
e1f5c162
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
121 addition
and
67 deletion
+121
-67
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/DocumentFactory.java
...a/com/x/cms/assemble/control/factory/DocumentFactory.java
+91
-22
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListWithFilterPaging.java
...ntrol/jaxrs/document/ActionQueryListWithFilterPaging.java
+2
-2
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListWithFilterPagingAdmin.java
.../jaxrs/document/ActionQueryListWithFilterPagingAdmin.java
+24
-39
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentQueryService.java
.../x/cms/assemble/control/service/DocumentQueryService.java
+4
-4
未找到文件。
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/DocumentFactory.java
浏览文件 @
a89a65fe
...
...
@@ -15,6 +15,7 @@ import com.x.cms.core.entity.Review_;
import
com.x.cms.core.express.tools.CriteriaBuilderTools
;
import
com.x.cms.core.express.tools.filter.QueryFilter
;
import
org.apache.commons.beanutils.PropertyUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.persistence.EntityManager
;
...
...
@@ -431,7 +432,7 @@ public class DocumentFactory extends AbstractFactory {
* @throws NoSuchFieldException
*/
public
List
<
Document
>
listPagingWithCondition
(
String
personName
,
String
orderField
,
String
orderType
,
QueryFilter
queryFilter
,
Integer
adjustPage
,
Integer
adjustPageSize
)
throws
Exception
{
Integer
adjustPageSize
,
Boolean
isAuthor
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Document
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
EntityManager
em1
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
...
...
@@ -442,16 +443,50 @@ public class DocumentFactory extends AbstractFactory {
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
Document_
.
class
,
cb
,
null
,
root
,
queryFilter
);
if
(
StringUtils
.
isNotBlank
(
personName
)){
if
(!
BooleanUtils
.
isTrue
(
isAuthor
))
{
Subquery
<
Review
>
subquery
=
cq
.
subquery
(
Review
.
class
);
Root
<
Review
>
root2
=
subquery
.
from
(
em1
.
getMetamodel
().
entity
(
Review
.
class
));
subquery
.
select
(
root2
);
Predicate
p_permission
=
cb1
.
conjunction
();
p_permission
=
cb1
.
and
(
p_permission
,
cb1
.
or
(
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
"*"
),
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
personName
)));
cb1
.
or
(
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
"*"
),
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
personName
)));
p_permission
=
cb1
.
and
(
p_permission
,
cb1
.
equal
(
root
.
get
(
Document_
.
id
),
root2
.
get
(
Review_
.
docId
)));
subquery
.
where
(
p_permission
);
p
=
cb
.
and
(
p
,
cb
.
exists
(
subquery
));
}
else
{
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
unitAllList
=
this
.
business
().
organization
().
unit
().
listWithPersonSupNested
(
personName
);
if
(
unitAllList
!=
null
)
{
for
(
String
item
:
unitAllList
)
{
if
(
item
.
indexOf
(
"@"
)
>
-
1
)
{
list
.
add
(
StringUtils
.
substringAfter
(
item
,
"@"
));
}
}
unitAllList
.
addAll
(
list
);
list
.
clear
();
}
List
<
String
>
groupList
=
this
.
business
().
organization
().
group
().
listWithPersonReference
(
ListTools
.
toList
(
personName
),
true
,
true
,
true
);
if
(
groupList
!=
null
)
{
for
(
String
item
:
groupList
)
{
if
(
item
.
indexOf
(
"@"
)
>
-
1
)
{
list
.
add
(
StringUtils
.
substringAfter
(
item
,
"@"
));
}
}
groupList
.
addAll
(
list
);
list
.
clear
();
}
Predicate
ep
=
cb
.
disjunction
();
ep
=
cb
.
or
(
ep
,
cb
.
isMember
(
personName
,
root
.
get
(
Document_
.
authorPersonList
)));
if
(
ListTools
.
isNotEmpty
(
unitAllList
)){
ep
=
cb
.
or
(
ep
,
root
.
get
(
Document_
.
authorUnitList
).
in
(
unitAllList
));
}
if
(
ListTools
.
isNotEmpty
(
groupList
)){
ep
=
cb
.
or
(
ep
,
root
.
get
(
Document_
.
authorGroupList
).
in
(
groupList
));
}
p
=
cb
.
and
(
p
,
ep
);
}
}
List
<
String
>
fields
=
DocumentWo
.
copier
.
getCopyFields
();
List
<
Selection
<?>>
selections
=
new
ArrayList
<>();
...
...
@@ -505,7 +540,7 @@ public class DocumentFactory extends AbstractFactory {
* @return
* @throws Exception
*/
public
Long
countWithCondition
(
String
personName
,
QueryFilter
queryFilter
)
throws
Exception
{
public
Long
countWithCondition
(
String
personName
,
QueryFilter
queryFilter
,
Boolean
isAuthor
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Document
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
EntityManager
em1
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
...
...
@@ -515,16 +550,50 @@ public class DocumentFactory extends AbstractFactory {
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
Document_
.
class
,
cb
,
null
,
root
,
queryFilter
);
if
(
StringUtils
.
isNotBlank
(
personName
)){
if
(!
BooleanUtils
.
isTrue
(
isAuthor
))
{
Subquery
<
Review
>
subquery
=
cq
.
subquery
(
Review
.
class
);
Root
<
Review
>
root2
=
subquery
.
from
(
em1
.
getMetamodel
().
entity
(
Review
.
class
));
subquery
.
select
(
root2
);
Predicate
p_permission
=
cb1
.
conjunction
();
p_permission
=
cb1
.
and
(
p_permission
,
cb1
.
or
(
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
"*"
),
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
personName
)));
cb1
.
or
(
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
"*"
),
cb1
.
equal
(
root2
.
get
(
Review_
.
permissionObj
),
personName
)));
p_permission
=
cb1
.
and
(
p_permission
,
cb1
.
equal
(
root
.
get
(
Document_
.
id
),
root2
.
get
(
Review_
.
docId
)));
subquery
.
where
(
p_permission
);
p
=
cb
.
and
(
p
,
cb
.
exists
(
subquery
));
}
else
{
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
unitAllList
=
this
.
business
().
organization
().
unit
().
listWithPersonSupNested
(
personName
);
if
(
unitAllList
!=
null
)
{
for
(
String
item
:
unitAllList
)
{
if
(
item
.
indexOf
(
"@"
)
>
-
1
)
{
list
.
add
(
StringUtils
.
substringAfter
(
item
,
"@"
));
}
}
unitAllList
.
addAll
(
list
);
list
.
clear
();
}
List
<
String
>
groupList
=
this
.
business
().
organization
().
group
().
listWithPersonReference
(
ListTools
.
toList
(
personName
),
true
,
true
,
true
);
if
(
groupList
!=
null
)
{
for
(
String
item
:
groupList
)
{
if
(
item
.
indexOf
(
"@"
)
>
-
1
)
{
list
.
add
(
StringUtils
.
substringAfter
(
item
,
"@"
));
}
}
groupList
.
addAll
(
list
);
list
.
clear
();
}
Predicate
ep
=
cb
.
disjunction
();
ep
=
cb
.
or
(
ep
,
cb
.
isMember
(
personName
,
root
.
get
(
Document_
.
authorPersonList
)));
if
(
ListTools
.
isNotEmpty
(
unitAllList
)){
ep
=
cb
.
or
(
ep
,
root
.
get
(
Document_
.
authorUnitList
).
in
(
unitAllList
));
}
if
(
ListTools
.
isNotEmpty
(
groupList
)){
ep
=
cb
.
or
(
ep
,
root
.
get
(
Document_
.
authorGroupList
).
in
(
groupList
));
}
p
=
cb
.
and
(
p
,
ep
);
}
}
return
em
.
createQuery
(
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
)).
getSingleResult
();
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListWithFilterPaging.java
浏览文件 @
a89a65fe
...
...
@@ -90,7 +90,7 @@ public class ActionQueryListWithFilterPaging extends BaseAction {
if
(
isManager
)
{
personName
=
null
;
}
total
=
documentQueryService
.
countWithCondition
(
personName
,
queryFilter
);
total
=
documentQueryService
.
countWithCondition
(
personName
,
queryFilter
,
false
);
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ExceptionDocumentInfoProcess
(
e
,
"系统在获取用户可查询到的文档数据条目数量时发生异常。"
);
...
...
@@ -106,7 +106,7 @@ public class ActionQueryListWithFilterPaging extends BaseAction {
if
(
isManager
)
{
personName
=
null
;
}
searchResultList
=
documentQueryService
.
listPagingWithCondition
(
personName
,
wi
.
getOrderField
(),
wi
.
getOrderType
(),
queryFilter
,
page
,
size
);
searchResultList
=
documentQueryService
.
listPagingWithCondition
(
personName
,
wi
.
getOrderField
(),
wi
.
getOrderType
(),
queryFilter
,
page
,
size
,
false
);
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ExceptionDocumentInfoProcess
(
e
,
"系统在根据用户可访问的文档ID列表对文档进行分页查询时发生异常。"
);
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListWithFilterPagingAdmin.java
浏览文件 @
a89a65fe
...
...
@@ -36,7 +36,6 @@ public class ActionQueryListWithFilterPagingAdmin extends BaseAction {
protected
ActionResult
<
List
<
Wo
>>
execute
(
HttpServletRequest
request
,
Integer
page
,
Integer
size
,
JsonElement
jsonElement
,
EffectivePerson
effectivePerson
)
throws
Exception
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Long
total
=
0L
;
List
<
Wo
>
wos
=
new
ArrayList
<>();
Business
business
=
new
Business
(
null
);
if
(!
business
.
isManager
(
effectivePerson
)){
...
...
@@ -66,27 +65,19 @@ public class ActionQueryListWithFilterPagingAdmin extends BaseAction {
}
QueryFilter
queryFilter
=
wi
.
getQueryFilter
();
List
<
DocumentWo
>
docWos
=
new
ArrayList
<>();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
()
)
{
EntityManager
em
=
emc
.
get
(
Document
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Document
>
cq
=
cb
.
createQuery
(
Document
.
class
);
Root
<
Document
>
root
=
cq
.
from
(
Document
.
class
);
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
Document_
.
class
,
cb
,
null
,
root
,
queryFilter
);
if
(
"asc"
.
equalsIgnoreCase
(
wi
.
getOrderType
())){
docWos
=
emc
.
fetchAscPaging
(
Document
.
class
,
DocumentWo
.
copier
,
p
,
page
,
size
,
wi
.
getOrderField
());
}
else
{
docWos
=
emc
.
fetchDescPaging
(
Document
.
class
,
DocumentWo
.
copier
,
p
,
page
,
size
,
wi
.
getOrderField
());
String
personName
=
wi
.
getPerson
();
if
(
StringUtils
.
isNotBlank
(
wi
.
getPerson
()))
{
personName
=
business
.
organization
().
person
().
get
(
wi
.
getPerson
());
if
(
StringUtils
.
isBlank
(
personName
)){
personName
=
wi
.
getPerson
();
}
total
=
emc
.
count
(
Document
.
class
,
p
);
}
Long
total
=
documentQueryService
.
countWithCondition
(
personName
,
queryFilter
,
wi
.
getAuthor
());
List
<
Document
>
searchResultList
=
documentQueryService
.
listPagingWithCondition
(
personName
,
wi
.
getOrderField
(),
wi
.
getOrderType
(),
queryFilter
,
page
,
size
,
wi
.
getAuthor
());
Wo
wo
=
null
;
for
(
Document
Wo
documentWo
:
docWos
)
{
for
(
Document
document
:
searchResultList
)
{
try
{
wo
=
Wo
.
copier
.
copy
(
document
Wo
);
wo
=
Wo
.
copier
.
copy
(
document
);
if
(
wo
.
getCreatorPerson
()
!=
null
&&
!
wo
.
getCreatorPerson
().
isEmpty
()
)
{
wo
.
setCreatorPersonShort
(
wo
.
getCreatorPerson
().
split
(
"@"
)[
0
]);
}
...
...
@@ -98,7 +89,7 @@ public class ActionQueryListWithFilterPagingAdmin extends BaseAction {
}
if
(
wi
.
getNeedData
()
)
{
//需要组装数据
wo
.
setData
(
documentQueryService
.
getDocumentData
(
document
Wo
)
);
wo
.
setData
(
documentQueryService
.
getDocumentData
(
document
)
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
...
...
@@ -111,35 +102,29 @@ public class ActionQueryListWithFilterPagingAdmin extends BaseAction {
return
result
;
}
public
class
DocumentCacheForFilter
{
public
static
class
Wi
extends
WrapInDocumentFilter
{
private
Long
total
=
0L
;
private
List
<
Wo
>
documentList
=
null
;
@FieldDescribe
(
"查询指定用户可阅读的文档"
)
private
String
person
;
public
Long
getTotal
()
{
return
total
;
}
@FieldDescribe
(
"是否查询指定用户可编辑的文档,如果为true则person字段必填,默认为否"
)
private
Boolean
isAuthor
;
public
void
setTotal
(
Long
total
)
{
this
.
total
=
total
;
public
String
getPerson
(
)
{
return
person
;
}
public
List
<
Wo
>
getDocumentList
(
)
{
return
documentList
;
public
void
setPerson
(
String
person
)
{
this
.
person
=
person
;
}
public
void
setDocumentList
(
List
<
Wo
>
documentList
)
{
this
.
documentList
=
documentList
;
public
Boolean
getAuthor
(
)
{
return
isAuthor
;
}
}
public
static
class
Wi
extends
WrapInDocumentFilter
{
public
void
setAuthor
(
Boolean
author
)
{
isAuthor
=
author
;
}
public
static
class
DocumentWo
extends
Document
{
static
WrapCopier
<
Document
,
DocumentWo
>
copier
=
WrapCopierFactory
.
wo
(
Document
.
class
,
DocumentWo
.
class
,
JpaObject
.
singularAttributeField
(
Document
.
class
,
true
,
true
),
null
);
}
public
static
class
Wo
extends
WrapOutDocumentList
{
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentQueryService.java
浏览文件 @
a89a65fe
...
...
@@ -458,12 +458,12 @@ public class DocumentQueryService {
* @throws Exception
*/
public
List
<
Document
>
listPagingWithCondition
(
String
personName
,
String
orderField
,
String
orderType
,
QueryFilter
queryFilter
,
Integer
adjustPage
,
Integer
pageSize
)
throws
Exception
{
Integer
pageSize
,
Boolean
isAuthor
)
throws
Exception
{
if
(
pageSize
==
0
)
{
pageSize
=
20
;
}
//按正常逻辑根据序列进行分页查询
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
()
)
{
Business
business
=
new
Business
(
emc
);
return
business
.
getDocumentFactory
().
listPagingWithCondition
(
personName
,
orderField
,
orderType
,
queryFilter
,
adjustPage
,
pageSize
);
return
business
.
getDocumentFactory
().
listPagingWithCondition
(
personName
,
orderField
,
orderType
,
queryFilter
,
adjustPage
,
pageSize
,
isAuthor
);
}
catch
(
Exception
e
)
{
throw
e
;
}
...
...
@@ -476,11 +476,11 @@ public class DocumentQueryService {
* @return
* @throws Exception
*/
public
Long
countWithCondition
(
String
personName
,
QueryFilter
queryFilter
)
throws
Exception
{
public
Long
countWithCondition
(
String
personName
,
QueryFilter
queryFilter
,
Boolean
isAuthor
)
throws
Exception
{
//按正常逻辑根据序列进行分页查询
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
()
)
{
Business
business
=
new
Business
(
emc
);
return
business
.
getDocumentFactory
().
countWithCondition
(
personName
,
queryFilter
);
return
business
.
getDocumentFactory
().
countWithCondition
(
personName
,
queryFilter
,
isAuthor
);
}
catch
(
Exception
e
)
{
throw
e
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录