Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
c70a67e7
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
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,发现更多精彩内容 >>
提交
c70a67e7
编写于
7月 21, 2021
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加根据分类刷新文档权限接口
上级
b4ec8d9b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
215 addition
and
32 deletion
+215
-32
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/permission/ActionRefreshCategoryDocPermission.java
.../jaxrs/permission/ActionRefreshCategoryDocPermission.java
+46
-0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/permission/PermissionManagerAction.java
...ble/control/jaxrs/permission/PermissionManagerAction.java
+24
-0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentPersistService.java
.../cms/assemble/control/service/DocumentPersistService.java
+125
-23
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/ReviewService.java
...ava/com/x/cms/assemble/control/service/ReviewService.java
+20
-9
未找到文件。
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/permission/ActionRefreshCategoryDocPermission.java
0 → 100644
浏览文件 @
c70a67e7
package
com.x.cms.assemble.control.jaxrs.permission
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WrapString
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.cms.assemble.control.service.DocumentPersistService
;
import
com.x.cms.core.entity.Document
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.concurrent.locks.ReentrantLock
;
public
class
ActionRefreshCategoryDocPermission
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionRefreshCategoryDocPermission
.
class
);
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
categoryId
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Boolean
check
=
true
;
Wo
wo
=
new
Wo
();
DocumentPersistService
documentPersistService
=
new
DocumentPersistService
();
if
(
check
)
{
try
{
boolean
flag
=
documentPersistService
.
refreshDocumentPermissionByCategory
(
categoryId
);
if
(
flag
)
{
wo
.
setValue
(
"权限处理完成!"
);
}
else
{
wo
.
setValue
(
"权限刷新失败,可能有其他分类正在刷新权限!"
);
}
result
.
setData
(
wo
);
}
catch
(
Exception
e
)
{
Exception
exception
=
new
ExceptionDocumentPermissionProcess
();
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
CacheManager
.
notify
(
Document
.
class
);
return
result
;
}
public
static
class
Wo
extends
WrapString
{
}
}
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/permission/PermissionManagerAction.java
浏览文件 @
c70a67e7
...
@@ -2,6 +2,7 @@ package com.x.cms.assemble.control.jaxrs.permission;
...
@@ -2,6 +2,7 @@ package com.x.cms.assemble.control.jaxrs.permission;
import
com.x.base.core.project.annotation.JaxrsDescribe
;
import
com.x.base.core.project.annotation.JaxrsDescribe
;
import
com.x.base.core.project.annotation.JaxrsMethodDescribe
;
import
com.x.base.core.project.annotation.JaxrsMethodDescribe
;
import
com.x.base.core.project.annotation.JaxrsParameterDescribe
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.http.HttpMediaType
;
import
com.x.base.core.project.http.HttpMediaType
;
...
@@ -45,4 +46,27 @@ public class PermissionManagerAction extends StandardJaxrsAction {
...
@@ -45,4 +46,27 @@ public class PermissionManagerAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
@JaxrsMethodDescribe
(
value
=
"重新计算指定分类文档的权限信息."
,
action
=
ActionRefreshCategoryDocPermission
.
class
)
@GET
@Path
(
"refresh/category/{categoryId}"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
refreshCategoryDocument
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"分类ID"
)
@PathParam
(
"categoryId"
)
String
categoryId
)
{
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
ActionResult
<
ActionRefreshCategoryDocPermission
.
Wo
>
result
=
new
ActionResult
<>();
Boolean
check
=
true
;
if
(
check
){
try
{
result
=
new
ActionRefreshCategoryDocPermission
().
execute
(
request
,
effectivePerson
,
categoryId
);
}
catch
(
Exception
e
)
{
result
=
new
ActionResult
<>();
Exception
exception
=
new
ExceptionAppCategoryAdminProcess
(
e
,
"查询登录用户是否指定栏目的管理员时发生异常。"
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
}
\ No newline at end of file
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentPersistService.java
浏览文件 @
c70a67e7
...
@@ -5,8 +5,9 @@ import com.x.base.core.container.EntityManagerContainer;
...
@@ -5,8 +5,9 @@ import com.x.base.core.container.EntityManagerContainer;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
import
com.x.base.core.entity.dataitem.ItemCategory
;
import
com.x.base.core.entity.dataitem.ItemCategory
;
import
com.x.base.core.project.cache.ApplicationCache
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.cms.assemble.control.DocumentDataHelper
;
import
com.x.cms.assemble.control.DocumentDataHelper
;
import
com.x.cms.assemble.control.jaxrs.document.ActionPersistBatchModifyData.WiDataChange
;
import
com.x.cms.assemble.control.jaxrs.document.ActionPersistBatchModifyData.WiDataChange
;
...
@@ -14,17 +15,29 @@ import com.x.cms.assemble.control.jaxrs.document.ActionPersistBatchModifyData.Wo
...
@@ -14,17 +15,29 @@ import com.x.cms.assemble.control.jaxrs.document.ActionPersistBatchModifyData.Wo
import
com.x.cms.assemble.control.jaxrs.permission.element.PermissionInfo
;
import
com.x.cms.assemble.control.jaxrs.permission.element.PermissionInfo
;
import
com.x.cms.core.entity.CategoryInfo
;
import
com.x.cms.core.entity.CategoryInfo
;
import
com.x.cms.core.entity.Document
;
import
com.x.cms.core.entity.Document
;
import
com.x.cms.core.entity.Document_
;
import
com.x.cms.core.entity.content.Data
;
import
com.x.cms.core.entity.content.Data
;
import
com.x.query.core.entity.Item
;
import
com.x.query.core.entity.Item
;
import
org.apache.commons.collections4.list.TreeList
;
import
org.apache.commons.lang3.StringUtils
;
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
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.locks.ReentrantLock
;
/**
/**
* 对文档信息进行持久化服务类
* 对文档信息进行持久化服务类
*/
*/
public
class
DocumentPersistService
{
public
class
DocumentPersistService
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DocumentPersistService
.
class
);
private
static
ReentrantLock
lock
=
new
ReentrantLock
();
private
DocumentInfoService
documentInfoService
=
new
DocumentInfoService
();
private
DocumentInfoService
documentInfoService
=
new
DocumentInfoService
();
private
PermissionOperateService
permissionService
=
new
PermissionOperateService
();
private
PermissionOperateService
permissionService
=
new
PermissionOperateService
();
...
@@ -329,31 +342,120 @@ public class DocumentPersistService {
...
@@ -329,31 +342,120 @@ public class DocumentPersistService {
* 重新计算所有的文档的权限和review信息
* 重新计算所有的文档的权限和review信息
*/
*/
public
void
refreshAllDocumentPermission
()
throws
Exception
{
public
void
refreshAllDocumentPermission
()
throws
Exception
{
//根据栏目一个一个来查询
try
{
AppInfoServiceAdv
appInfoService
=
new
AppInfoServiceAdv
();
if
(
lock
.
tryLock
())
{
DocumentQueryService
documentQueryService
=
new
DocumentQueryService
();
AppInfoServiceAdv
appInfoService
=
new
AppInfoServiceAdv
();
List
<
String
>
appIds
=
appInfoService
.
listAllIds
(
"信息"
);
DocumentQueryService
documentQueryService
=
new
DocumentQueryService
();
List
<
String
>
documentIds
=
null
;
List
<
String
>
appIds
=
appInfoService
.
listAllIds
(
"信息"
);
ReviewService
reviewService
=
new
ReviewService
();
if
(
ListTools
.
isNotEmpty
(
appIds
))
{
if
(
ListTools
.
isNotEmpty
(
appIds
)){
for
(
String
appId
:
appIds
)
{
for
(
String
appId
:
appIds
){
//查询指定App中所有的文档Id
//查询指定App中所有的文档Id
List
<
String
>
documentIds
=
documentQueryService
.
listIdsByAppId
(
appId
,
"信息"
,
50000
);
documentIds
=
documentQueryService
.
listIdsByAppId
(
appId
,
"信息"
,
50000
);
logger
.
info
(
"刷新应用{}的数据共{}条"
,
appId
,
documentIds
.
size
());
if
(
ListTools
.
isNotEmpty
(
documentIds
)){
if
(
ListTools
.
isNotEmpty
(
documentIds
))
{
for
(
String
documentId
:
documentIds
){
int
count
=
0
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
()
)
{
for
(
List
<
String
>
partDocIds
:
ListTools
.
batch
(
documentIds
,
10
)){
boolean
fullRead
=
reviewService
.
refreshDocumentReview
(
emc
,
documentId
);
count
=
count
+
10
;
Document
document
=
emc
.
find
(
documentId
,
Document
.
class
);
List
<
CompletableFuture
<
Void
>>
futures
=
new
TreeList
<>();
emc
.
beginTransaction
(
Document
.
class
);
for
(
String
documentId
:
partDocIds
)
{
document
.
setIsAllRead
(
fullRead
);
CompletableFuture
<
Void
>
future
=
CompletableFuture
.
runAsync
(()
->
{
emc
.
commit
();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
}
catch
(
Exception
e
)
{
ReviewService
reviewService
=
new
ReviewService
();
throw
e
;
boolean
fullRead
=
reviewService
.
refreshDocumentReview
(
emc
,
documentId
);
Document
document
=
emc
.
find
(
documentId
,
Document
.
class
);
emc
.
beginTransaction
(
Document
.
class
);
document
.
setIsAllRead
(
fullRead
);
emc
.
commit
();
}
catch
(
Exception
e
)
{
logger
.
warn
(
"刷新文档权限异常1:{}"
,
e
.
getMessage
());
}
});
futures
.
add
(
future
);
}
for
(
CompletableFuture
<
Void
>
future
:
futures
)
{
try
{
future
.
get
(
200
,
TimeUnit
.
SECONDS
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"刷新文档权限异常2:{}"
,
e
.
getMessage
());
}
}
futures
.
clear
();
if
(
count
>
99
&&
count
%
100
==
0
){
logger
.
info
(
"应用文档权限已刷新{}个"
,
count
);
}
}
}
}
}
}
CacheManager
.
notify
(
Document
.
class
);
}
}
lock
.
unlock
();
}
}
CacheManager
.
notify
(
Document
.
class
);
}
catch
(
Exception
e
)
{
lock
.
unlock
();
logger
.
error
(
e
);
}
}
}
}
public
boolean
refreshDocumentPermissionByCategory
(
String
categoryId
)
{
boolean
flag
=
false
;
try
{
if
(
lock
.
tryLock
())
{
List
<
String
>
documentIds
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
EntityManager
em
=
emc
.
get
(
Document
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
Document
>
root
=
cq
.
from
(
Document
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Document_
.
categoryId
),
categoryId
);
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
Document_
.
documentType
),
"信息"
));
cq
.
select
(
root
.
get
(
Document_
.
id
)
).
where
(
p
);
documentIds
=
em
.
createQuery
(
cq
).
getResultList
();
}
if
(
ListTools
.
isNotEmpty
(
documentIds
))
{
logger
.
info
(
"刷新分类{}的数据共{}条"
,
categoryId
,
documentIds
.
size
());
int
count
=
0
;
for
(
List
<
String
>
partDocIds
:
ListTools
.
batch
(
documentIds
,
10
)){
count
=
count
+
10
;
List
<
CompletableFuture
<
Void
>>
futures
=
new
TreeList
<>();
for
(
String
documentId
:
partDocIds
)
{
CompletableFuture
<
Void
>
future
=
CompletableFuture
.
runAsync
(()
->
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ReviewService
reviewService
=
new
ReviewService
();
boolean
fullRead
=
reviewService
.
refreshDocumentReview
(
emc
,
documentId
);
Document
document
=
emc
.
find
(
documentId
,
Document
.
class
);
emc
.
beginTransaction
(
Document
.
class
);
document
.
setIsAllRead
(
fullRead
);
emc
.
commit
();
}
catch
(
Exception
e
)
{
logger
.
warn
(
"刷新文档权限异常1:{}"
,
e
.
getMessage
());
}
});
futures
.
add
(
future
);
}
for
(
CompletableFuture
<
Void
>
future
:
futures
)
{
try
{
future
.
get
(
200
,
TimeUnit
.
SECONDS
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"刷新文档权限异常2:{}"
,
e
.
getMessage
());
}
}
futures
.
clear
();
if
(
count
>
99
&&
count
%
100
==
0
){
logger
.
info
(
"分类文档权限已刷新{}个"
,
count
);
}
}
}
CacheManager
.
notify
(
Document
.
class
);
lock
.
unlock
();
flag
=
true
;
logger
.
info
(
"完成分类{}的权限刷新"
,
categoryId
);
}
else
{
logger
.
info
(
"有分类正在刷新权限中,请稍后...."
);
}
}
catch
(
Exception
e
)
{
lock
.
unlock
();
logger
.
error
(
e
);
}
return
flag
;
}
}
}
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/ReviewService.java
浏览文件 @
c70a67e7
...
@@ -15,6 +15,8 @@ import com.x.cms.core.entity.Review;
...
@@ -15,6 +15,8 @@ import com.x.cms.core.entity.Review;
import
com.x.cms.core.express.tools.filter.QueryFilter
;
import
com.x.cms.core.express.tools.filter.QueryFilter
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Query
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -567,20 +569,23 @@ public class ReviewService {
...
@@ -567,20 +569,23 @@ public class ReviewService {
*/
*/
private
void
refreshDocumentReview
(
EntityManagerContainer
emc
,
AppInfo
appInfo
,
CategoryInfo
categoryInfo
,
Document
document
,
List
<
String
>
permissionPersons
)
throws
Exception
{
private
void
refreshDocumentReview
(
EntityManagerContainer
emc
,
AppInfo
appInfo
,
CategoryInfo
categoryInfo
,
Document
document
,
List
<
String
>
permissionPersons
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
Business
business
=
new
Business
(
emc
);
Review
review
=
null
;
List
<
Review
>
reviews
=
null
;
//先检查该文档是否存在Review信息
//先检查该文档是否存在Review信息
List
<
String
>
oldReviewIds
=
business
.
reviewFactory
().
listByDocument
(
document
.
getId
(),
9999
);
List
<
String
>
oldReviewIds
=
business
.
reviewFactory
().
listByDocument
(
document
.
getId
(),
9999
);
//先删除原来所有的Review信息
//先删除原来所有的Review信息
if
(
ListTools
.
isNotEmpty
(
oldReviewIds
))
{
if
(
ListTools
.
isNotEmpty
(
oldReviewIds
))
{
Review
oldReview
=
null
;
emc
.
beginTransaction
(
Review
.
class
);
emc
.
beginTransaction
(
Review
.
class
);
int
i
=
0
;
for
(
String
reviewId
:
oldReviewIds
){
for
(
String
reviewId
:
oldReviewIds
){
oldReview
=
emc
.
find
(
reviewId
,
Review
.
class
);
Review
oldReview
=
emc
.
find
(
reviewId
,
Review
.
class
);
if
(
oldReview
!=
null
){
if
(
oldReview
!=
null
){
emc
.
remove
(
oldReview
,
CheckRemoveType
.
all
);
emc
.
remove
(
oldReview
,
CheckRemoveType
.
all
);
i
++;
if
(
i
>
99
&&
i
%
100
==
0
){
emc
.
commit
();
emc
.
beginTransaction
(
Review
.
class
);
}
}
}
}
}
emc
.
commit
();
emc
.
commit
();
...
@@ -592,6 +597,7 @@ public class ReviewService {
...
@@ -592,6 +597,7 @@ public class ReviewService {
emc
.
beginTransaction
(
Review
.
class
);
emc
.
beginTransaction
(
Review
.
class
);
Person
personObj
=
null
;
Person
personObj
=
null
;
String
personName
=
null
;
String
personName
=
null
;
int
i
=
0
;
for
(
String
person
:
permissionPersons
)
{
for
(
String
person
:
permissionPersons
)
{
if
(
!
person
.
equalsIgnoreCase
(
"*"
))
{
if
(
!
person
.
equalsIgnoreCase
(
"*"
))
{
//检查一下个人是否存在,防止姓名或者唯一标识变更过了导致文档权限不正确
//检查一下个人是否存在,防止姓名或者唯一标识变更过了导致文档权限不正确
...
@@ -604,11 +610,16 @@ public class ReviewService {
...
@@ -604,11 +610,16 @@ public class ReviewService {
}
}
if
(
StringUtils
.
isNotEmpty
(
personName
))
{
if
(
StringUtils
.
isNotEmpty
(
personName
))
{
//查询一下,数据库里, 是否有相同的数据,如果有,就不再添加了
//查询一下,数据库里, 是否有相同的数据,如果有,就不再添加了
oldReviewIds
=
business
.
reviewFactory
().
listByDocumentAndPerson
(
document
.
getId
(),
personName
);
oldReviewIds
=
business
.
reviewFactory
().
listByDocumentAndPerson
(
document
.
getId
(),
personName
);
if
(
ListTools
.
isEmpty
(
oldReviewIds
))
{
if
(
ListTools
.
isEmpty
(
oldReviewIds
))
{
review
=
createReviewWithDocument
(
appInfo
,
categoryInfo
,
document
,
personName
);
Review
review
=
createReviewWithDocument
(
appInfo
,
categoryInfo
,
document
,
personName
);
emc
.
persist
(
review
,
CheckPersistType
.
all
);
emc
.
persist
(
review
,
CheckPersistType
.
all
);
}
i
++;
if
(
i
>
99
&&
i
%
100
==
0
){
emc
.
commit
();
emc
.
beginTransaction
(
Review
.
class
);
}
}
}
}
}
}
emc
.
commit
();
emc
.
commit
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录