Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
af1fadde
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,发现更多精彩内容 >>
提交
af1fadde
编写于
12月 08, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、增加删除人员接口,删除个人关联信息(身份、角色等),但保留人员(企业离退休人员需要能登录平台但不能做业务处理).
2、删除人员的时候同时删除个人custom信息
上级
9ee0e9a2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
289 addition
and
25 deletion
+289
-25
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/person/ActionDelete.java
...anization/assemble/control/jaxrs/person/ActionDelete.java
+27
-24
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/person/ActionDeleteV2.java
...ization/assemble/control/jaxrs/person/ActionDeleteV2.java
+243
-0
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/person/PersonAction.java
...anization/assemble/control/jaxrs/person/PersonAction.java
+19
-1
未找到文件。
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/person/ActionDelete.java
浏览文件 @
af1fadde
...
...
@@ -33,20 +33,7 @@ import com.x.organization.assemble.control.ThisApplication;
import
com.x.organization.assemble.control.message.OrgBodyMessage
;
import
com.x.organization.assemble.control.message.OrgMessage
;
import
com.x.organization.assemble.control.message.OrgMessageFactory
;
import
com.x.organization.core.entity.Group
;
import
com.x.organization.core.entity.Group_
;
import
com.x.organization.core.entity.Identity
;
import
com.x.organization.core.entity.Identity_
;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.PersonAttribute
;
import
com.x.organization.core.entity.PersonAttribute_
;
import
com.x.organization.core.entity.Person_
;
import
com.x.organization.core.entity.Role
;
import
com.x.organization.core.entity.Role_
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.UnitDuty
;
import
com.x.organization.core.entity.UnitDuty_
;
import
com.x.organization.core.entity.Unit_
;
import
com.x.organization.core.entity.*
;
class
ActionDelete
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionDelete
.
class
);
...
...
@@ -80,6 +67,9 @@ class ActionDelete extends BaseAction {
/** 删除个人属性 */
emc
.
beginTransaction
(
PersonAttribute
.
class
);
this
.
removePersonAttribute
(
business
,
person
);
/** 删除个人自定义信息 */
emc
.
beginTransaction
(
Custom
.
class
);
this
.
removePersonCustom
(
business
,
person
);
/** 删除群组成员 */
emc
.
beginTransaction
(
Group
.
class
);
this
.
removeMemberOfGroup
(
business
,
person
);
...
...
@@ -102,12 +92,12 @@ class ActionDelete extends BaseAction {
CacheManager
.
notify
(
Person
.
class
);
/** 通知x_collect_service_transmit同步数据到collect */
business
.
instrument
().
collect
().
person
();
/**创建 组织变更org消息通信 */
//createMessageCommunicate(person, effectivePerson);
OrgMessageFactory
orgMessageFactory
=
new
OrgMessageFactory
();
orgMessageFactory
.
createMessageCommunicate
(
"delete"
,
"person"
,
person
,
effectivePerson
);
Wo
wo
=
new
Wo
();
wo
.
setId
(
person
.
getId
());
result
.
setData
(
wo
);
...
...
@@ -193,6 +183,19 @@ class ActionDelete extends BaseAction {
}
}
private
void
removePersonCustom
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Custom
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Custom
>
cq
=
cb
.
createQuery
(
Custom
.
class
);
Root
<
Custom
>
root
=
cq
.
from
(
Custom
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Custom_
.
person
),
person
.
getId
());
p
=
cb
.
or
(
p
,
cb
.
equal
(
root
.
get
(
Custom_
.
person
),
person
.
getDistinguishedName
()));
List
<
Custom
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
for
(
Custom
o
:
os
)
{
business
.
entityManagerContainer
().
remove
(
o
,
CheckRemoveType
.
all
);
}
}
private
void
removeMemberOfGroup
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Group
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
...
...
@@ -216,14 +219,14 @@ class ActionDelete extends BaseAction {
o
.
getPersonList
().
remove
(
person
.
getId
());
}
}
/**创建 组织变更org消息通信 */
private
boolean
createMessageCommunicate
(
Person
person
,
EffectivePerson
effectivePerson
)
{
try
{
Gson
gson
=
new
Gson
();
String
strPerson
=
gson
.
toJson
(
person
);
OrgMessage
orgMessage
=
new
OrgMessage
();
orgMessage
.
setOperType
(
"delete"
);
orgMessage
.
setOrgType
(
"person"
);
orgMessage
.
setOperUerId
(
effectivePerson
.
getDistinguishedName
());
...
...
@@ -231,26 +234,26 @@ class ActionDelete extends BaseAction {
orgMessage
.
setReceiveSystem
(
""
);
orgMessage
.
setConsumed
(
false
);
orgMessage
.
setConsumedModule
(
""
);
OrgBodyMessage
orgBodyMessage
=
new
OrgBodyMessage
();
orgBodyMessage
.
setOriginalData
(
strPerson
);
orgMessage
.
setBody
(
gson
.
toJson
(
orgBodyMessage
));
Applications
applications
=
new
Applications
();
String
path
=
"org/create"
;
//String address = "http://127.0.0.1:20020/x_message_assemble_communicate/jaxrs/org/create";
//ActionResponse resp = CipherConnectionAction.post(false, address, body);
ActionResponse
resp
=
ThisApplication
.
context
().
applications
()
.
postQuery
(
x_message_assemble_communicate
.
class
,
path
,
orgMessage
);
String
mess
=
resp
.
getMessage
();
String
data
=
resp
.
getData
().
toString
();
return
true
;
}
catch
(
Exception
e
)
{
logger
.
print
(
e
.
toString
());
return
false
;
}
}
}
}
\ No newline at end of file
}
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/person/ActionDeleteV2.java
0 → 100644
浏览文件 @
af1fadde
package
com.x.organization.assemble.control.jaxrs.person
;
import
com.google.gson.Gson
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.annotation.CheckRemoveType
;
import
com.x.base.core.project.Applications
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.connection.ActionResponse
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoId
;
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.x_message_assemble_communicate
;
import
com.x.organization.assemble.control.Business
;
import
com.x.organization.assemble.control.ThisApplication
;
import
com.x.organization.assemble.control.message.OrgBodyMessage
;
import
com.x.organization.assemble.control.message.OrgMessage
;
import
com.x.organization.core.entity.*
;
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.List
;
import
java.util.stream.Collectors
;
class
ActionDeleteV2
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionDeleteV2
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
flag
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
if
(
Config
.
token
().
isInitialManager
(
flag
))
{
throw
new
ExceptionDenyDeleteInitialManager
();
}
else
{
Business
business
=
new
Business
(
emc
);
Person
person
=
business
.
person
().
pick
(
flag
);
if
(
null
==
person
)
{
throw
new
ExceptionEntityNotExist
(
flag
,
Person
.
class
);
}
/** 从内存中取到人 */
person
=
emc
.
find
(
person
.
getId
(),
Person
.
class
);
if
(!
this
.
editable
(
business
,
effectivePerson
,
person
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
List
<
Identity
>
identities
=
this
.
listIdentity
(
business
,
person
);
/** 删除身份组织职务成员,提交后才可以删除身份 */
emc
.
beginTransaction
(
UnitDuty
.
class
);
this
.
removeMemberOfUnitDuty
(
business
,
identities
);
emc
.
commit
();
/** 删除身份 */
emc
.
beginTransaction
(
Identity
.
class
);
for
(
Identity
o
:
identities
)
{
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
emc
.
commit
();
/** 删除个人自定义信息 */
emc
.
beginTransaction
(
Custom
.
class
);
this
.
removePersonCustom
(
business
,
person
);
/** 删除群组成员 */
emc
.
beginTransaction
(
Group
.
class
);
this
.
removeMemberOfGroup
(
business
,
person
);
/** 删除角色成员 */
emc
.
beginTransaction
(
Role
.
class
);
this
.
removeMemberOfRole
(
business
,
person
);
/** 删除组织的管理个人以及继承的管理个人 */
emc
.
beginTransaction
(
Unit
.
class
);
this
.
removeMemberOfUnitController
(
business
,
person
);
/** 删除个人管理者成员 */
this
.
removeMemberOfPersonController
(
business
,
person
);
/** 删除汇报人员为将要删除的人 */
this
.
removeMemberOfPersonSuperior
(
business
,
person
);
emc
.
beginTransaction
(
Person
.
class
);
/** 先进行一次提交,通过check */
emc
.
commit
();
CacheManager
.
notify
(
Person
.
class
);
Wo
wo
=
new
Wo
();
wo
.
setId
(
person
.
getId
());
result
.
setData
(
wo
);
}
return
result
;
}
}
public
static
class
Wo
extends
WoId
{
}
private
List
<
Identity
>
listIdentity
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Identity
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Identity
>
cq
=
cb
.
createQuery
(
Identity
.
class
);
Root
<
Identity
>
root
=
cq
.
from
(
Identity
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Identity_
.
person
),
person
.
getId
());
List
<
Identity
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
return
os
;
}
private
void
removeMemberOfUnitDuty
(
Business
business
,
List
<
Identity
>
identities
)
throws
Exception
{
List
<
String
>
ids
=
ListTools
.
extractProperty
(
identities
,
JpaObject
.
id_FIELDNAME
,
String
.
class
,
true
,
true
);
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_
.
identityList
).
in
(
ids
);
List
<
UnitDuty
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
().
stream
().
distinct
().
collect
(
Collectors
.
toList
());
for
(
UnitDuty
o
:
os
)
{
o
.
getIdentityList
().
removeAll
(
ids
);
}
}
private
void
removeMemberOfUnitController
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Unit
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Unit
>
cq
=
cb
.
createQuery
(
Unit
.
class
);
Root
<
Unit
>
root
=
cq
.
from
(
Unit
.
class
);
Predicate
p
=
cb
.
isMember
(
person
.
getId
(),
root
.
get
(
Unit_
.
controllerList
));
//p = cb.or(cb.isMember(person.getId(), root.get(Unit_.inheritedControllerList)));
List
<
Unit
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
().
stream
().
distinct
().
collect
(
Collectors
.
toList
());
for
(
Unit
o
:
os
)
{
o
.
getControllerList
().
remove
(
person
.
getId
());
//o.getInheritedControllerList().remove(person.getId());
}
}
private
void
removeMemberOfPersonController
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Person
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Person
>
cq
=
cb
.
createQuery
(
Person
.
class
);
Root
<
Person
>
root
=
cq
.
from
(
Person
.
class
);
Predicate
p
=
cb
.
isMember
(
person
.
getId
(),
root
.
get
(
Person_
.
controllerList
));
List
<
Person
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
().
stream
().
distinct
().
collect
(
Collectors
.
toList
());
for
(
Person
o
:
os
)
{
o
.
getControllerList
().
remove
(
person
.
getId
());
}
}
private
void
removeMemberOfPersonSuperior
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Person
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Person
>
cq
=
cb
.
createQuery
(
Person
.
class
);
Root
<
Person
>
root
=
cq
.
from
(
Person
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Person_
.
superior
),
person
.
getId
());
List
<
Person
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
for
(
Person
o
:
os
)
{
o
.
setSuperior
(
""
);
}
}
private
void
removePersonAttribute
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
PersonAttribute
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
PersonAttribute
>
cq
=
cb
.
createQuery
(
PersonAttribute
.
class
);
Root
<
PersonAttribute
>
root
=
cq
.
from
(
PersonAttribute
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
PersonAttribute_
.
person
),
person
.
getId
());
List
<
PersonAttribute
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
for
(
PersonAttribute
o
:
os
)
{
business
.
entityManagerContainer
().
remove
(
o
,
CheckRemoveType
.
all
);
}
}
private
void
removePersonCustom
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Custom
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Custom
>
cq
=
cb
.
createQuery
(
Custom
.
class
);
Root
<
Custom
>
root
=
cq
.
from
(
Custom
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Custom_
.
person
),
person
.
getId
());
p
=
cb
.
or
(
p
,
cb
.
equal
(
root
.
get
(
Custom_
.
person
),
person
.
getDistinguishedName
()));
List
<
Custom
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
for
(
Custom
o
:
os
)
{
business
.
entityManagerContainer
().
remove
(
o
,
CheckRemoveType
.
all
);
}
}
private
void
removeMemberOfGroup
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Group
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Group
>
cq
=
cb
.
createQuery
(
Group
.
class
);
Root
<
Group
>
root
=
cq
.
from
(
Group
.
class
);
Predicate
p
=
cb
.
isMember
(
person
.
getId
(),
root
.
get
(
Group_
.
personList
));
List
<
Group
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
for
(
Group
o
:
os
)
{
o
.
getPersonList
().
remove
(
person
.
getId
());
}
}
private
void
removeMemberOfRole
(
Business
business
,
Person
person
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Role
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Role
>
cq
=
cb
.
createQuery
(
Role
.
class
);
Root
<
Role
>
root
=
cq
.
from
(
Role
.
class
);
Predicate
p
=
cb
.
isMember
(
person
.
getId
(),
root
.
get
(
Role_
.
personList
));
List
<
Role
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
for
(
Role
o
:
os
)
{
o
.
getPersonList
().
remove
(
person
.
getId
());
}
}
/**创建 组织变更org消息通信 */
private
boolean
createMessageCommunicate
(
Person
person
,
EffectivePerson
effectivePerson
)
{
try
{
Gson
gson
=
new
Gson
();
String
strPerson
=
gson
.
toJson
(
person
);
OrgMessage
orgMessage
=
new
OrgMessage
();
orgMessage
.
setOperType
(
"delete"
);
orgMessage
.
setOrgType
(
"person"
);
orgMessage
.
setOperUerId
(
effectivePerson
.
getDistinguishedName
());
orgMessage
.
setOperDataId
(
person
.
getId
());
orgMessage
.
setReceiveSystem
(
""
);
orgMessage
.
setConsumed
(
false
);
orgMessage
.
setConsumedModule
(
""
);
OrgBodyMessage
orgBodyMessage
=
new
OrgBodyMessage
();
orgBodyMessage
.
setOriginalData
(
strPerson
);
orgMessage
.
setBody
(
gson
.
toJson
(
orgBodyMessage
));
Applications
applications
=
new
Applications
();
String
path
=
"org/create"
;
//String address = "http://127.0.0.1:20020/x_message_assemble_communicate/jaxrs/org/create";
//ActionResponse resp = CipherConnectionAction.post(false, address, body);
ActionResponse
resp
=
ThisApplication
.
context
().
applications
()
.
postQuery
(
x_message_assemble_communicate
.
class
,
path
,
orgMessage
);
String
mess
=
resp
.
getMessage
();
String
data
=
resp
.
getData
().
toString
();
return
true
;
}
catch
(
Exception
e
)
{
logger
.
print
(
e
.
toString
());
return
false
;
}
}
}
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/person/PersonAction.java
浏览文件 @
af1fadde
...
...
@@ -108,6 +108,24 @@ public class PersonAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"删除个人关联信息(身份、角色等),但保留人员(企业离退休人员需要能登录平台但不能做业务处理)."
,
action
=
ActionDeleteV2
.
class
)
@DELETE
@Path
(
"{flag}/v2"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
deleteV2
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"人员标识"
)
@PathParam
(
"flag"
)
String
flag
)
{
ActionResult
<
ActionDeleteV2
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionDeleteV2
().
execute
(
effectivePerson
,
flag
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"列示个人,下一页."
,
action
=
ActionListNext
.
class
)
@GET
@Path
(
"list/{flag}/next/{count}"
)
...
...
@@ -346,4 +364,4 @@ public class PersonAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录