Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
454ae0ac
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,发现更多精彩内容 >>
提交
454ae0ac
编写于
10月 24, 2022
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加创建WorkCompleted时执行projection
上级
fa72cf8d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
268 addition
and
171 deletion
+268
-171
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionCreate.java
.../service/processing/jaxrs/workcompleted/ActionCreate.java
+268
-171
未找到文件。
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionCreate.java
浏览文件 @
454ae0ac
package
com.x.processplatform.service.processing.jaxrs.workcompleted
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
...
...
@@ -8,6 +9,7 @@ import java.util.concurrent.TimeUnit;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.google.gson.reflect.TypeToken
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
...
...
@@ -17,194 +19,289 @@ import com.x.base.core.project.annotation.FieldDescribe;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.executor.ProcessPlatformExecutorFactory
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.gson.XGsonBuilder
;
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.organization.Unit
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.processplatform.core.entity.content.Data
;
import
com.x.processplatform.core.entity.content.Read
;
import
com.x.processplatform.core.entity.content.ReadCompleted
;
import
com.x.processplatform.core.entity.content.Review
;
import
com.x.processplatform.core.entity.content.Task
;
import
com.x.processplatform.core.entity.content.TaskCompleted
;
import
com.x.processplatform.core.entity.content.Work
;
import
com.x.processplatform.core.entity.content.WorkCompleted
;
import
com.x.processplatform.core.entity.element.Application
;
import
com.x.processplatform.core.entity.element.Process
;
import
com.x.processplatform.core.entity.element.Projection
;
import
com.x.processplatform.core.entity.element.util.ProjectionFactory
;
import
com.x.processplatform.service.processing.Business
;
import
com.x.query.core.entity.Item
;
import
io.swagger.v3.oas.annotations.media.Schema
;
class
ActionCreate
extends
BaseAction
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ActionCreate
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
processId
,
JsonElement
jsonElement
)
throws
Exception
{
LOGGER
.
debug
(
"execute:{}, processId:{}."
,
effectivePerson:
:
getDistinguishedName
,
()
->
processId
);
String
executorSeed
=
processId
;
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Callable
<
ActionResult
<
Wo
>>
callable
=
new
Callable
<
ActionResult
<
Wo
>>()
{
public
ActionResult
<
Wo
>
call
()
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
Process
process
=
business
.
element
().
get
(
processId
,
Process
.
class
);
if
(
null
==
process
)
{
throw
new
ExceptionEntityNotExist
(
processId
,
Process
.
class
);
}
Application
application
=
business
.
element
().
get
(
process
.
getApplication
(),
Application
.
class
);
if
(
null
==
application
)
{
throw
new
ExceptionEntityNotExist
(
process
.
getApplication
(),
Application
.
class
);
}
String
identity
=
business
.
organization
().
identity
().
get
(
wi
.
getIdentity
());
if
(
StringUtils
.
isEmpty
(
identity
))
{
throw
new
ExceptionIdentityNotExist
(
wi
.
getIdentity
());
}
String
person
=
business
.
organization
().
person
().
getWithIdentity
(
identity
);
String
unit
=
business
.
organization
().
unit
().
getWithIdentity
(
identity
);
Unit
unitObject
=
business
.
organization
().
unit
().
getObject
(
unit
);
emc
.
beginTransaction
(
Item
.
class
);
emc
.
beginTransaction
(
WorkCompleted
.
class
);
Date
now
=
new
Date
();
WorkCompleted
workCompleted
=
new
WorkCompleted
();
workCompleted
.
setApplication
(
application
.
getId
());
workCompleted
.
setApplicationAlias
(
application
.
getAlias
());
workCompleted
.
setApplicationName
(
application
.
getName
());
workCompleted
.
setCompletedTime
((
wi
.
getCompletedTime
()
==
null
)
?
now
:
wi
.
getCompletedTime
());
workCompleted
.
setCreatorIdentity
(
identity
);
workCompleted
.
setCreatorPerson
(
person
);
workCompleted
.
setCreatorUnit
(
unit
);
workCompleted
.
setCreatorUnitLevelName
(
unitObject
.
getLevelName
());
workCompleted
.
setDuration
(
0L
);
workCompleted
.
setExpired
(
false
);
workCompleted
.
setExpireTime
(
null
);
workCompleted
.
setForm
(
wi
.
getForm
());
workCompleted
.
setJob
(
StringTools
.
uniqueToken
());
workCompleted
.
setProcess
(
process
.
getId
());
workCompleted
.
setProcessAlias
(
process
.
getAlias
());
workCompleted
.
setProcessName
(
process
.
getName
());
workCompleted
.
setSerial
(
wi
.
getSerial
());
workCompleted
.
setStartTime
((
wi
.
getStartTime
()
==
null
)
?
now
:
wi
.
getStartTime
());
workCompleted
.
setTitle
(
wi
.
getTitle
());
workCompleted
.
setWork
(
null
);
emc
.
persist
(
workCompleted
,
CheckPersistType
.
all
);
Data
data
=
gson
.
fromJson
(
wi
.
getData
(),
Data
.
class
);
data
.
setWork
(
workCompleted
);
DataItemConverter
<
Item
>
converter
=
new
DataItemConverter
<>(
Item
.
class
);
List
<
Item
>
adds
=
converter
.
disassemble
(
gson
.
toJsonTree
(
data
));
for
(
Item
o
:
adds
)
{
fill
(
o
,
workCompleted
);
business
.
entityManagerContainer
().
persist
(
o
);
}
emc
.
commit
();
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
wo
.
setId
(
workCompleted
.
getId
());
result
.
setData
(
wo
);
return
result
;
}
}
};
return
ProcessPlatformExecutorFactory
.
get
(
executorSeed
).
submit
(
callable
).
get
(
300
,
TimeUnit
.
SECONDS
);
}
public
static
class
Wo
extends
WoId
{
private
static
final
long
serialVersionUID
=
-
8304167991098790325L
;
}
public
static
class
Wi
extends
GsonPropertyObject
{
private
static
final
long
serialVersionUID
=
7817819508116690487L
;
@FieldDescribe
(
"标题."
)
private
String
title
;
@FieldDescribe
(
"序号."
)
private
String
serial
;
@FieldDescribe
(
"指定表单."
)
private
String
form
;
@FieldDescribe
(
"启动人员身份."
)
private
String
identity
;
@FieldDescribe
(
"开始日期."
)
private
Date
startTime
;
@FieldDescribe
(
"结束日期."
)
private
Date
completedTime
;
@FieldDescribe
(
"工作数据."
)
private
JsonElement
data
;
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getIdentity
()
{
return
identity
;
}
public
void
setIdentity
(
String
identity
)
{
this
.
identity
=
identity
;
}
public
JsonElement
getData
()
{
return
data
;
}
public
void
setData
(
JsonElement
data
)
{
this
.
data
=
data
;
}
public
Date
getCompletedTime
()
{
return
completedTime
;
}
public
void
setCompletedTime
(
Date
completedTime
)
{
this
.
completedTime
=
completedTime
;
}
public
String
getForm
()
{
return
form
;
}
public
void
setForm
(
String
form
)
{
this
.
form
=
form
;
}
public
String
getSerial
()
{
return
serial
;
}
public
void
setSerial
(
String
serial
)
{
this
.
serial
=
serial
;
}
public
Date
getStartTime
()
{
return
startTime
;
}
public
void
setStartTime
(
Date
startTime
)
{
this
.
startTime
=
startTime
;
}
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ActionCreate
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
processId
,
JsonElement
jsonElement
)
throws
Exception
{
LOGGER
.
debug
(
"execute:{}, processId:{}."
,
effectivePerson:
:
getDistinguishedName
,
()
->
processId
);
String
executorSeed
=
processId
;
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
return
ProcessPlatformExecutorFactory
.
get
(
executorSeed
).
submit
(
new
CallableImpl
(
wi
,
processId
)).
get
(
300
,
TimeUnit
.
SECONDS
);
}
public
class
CallableImpl
implements
Callable
<
ActionResult
<
Wo
>>
{
private
String
processId
;
private
Wi
wi
;
private
CallableImpl
(
Wi
wi
,
String
processId
)
{
this
.
wi
=
wi
;
this
.
processId
=
processId
;
}
public
ActionResult
<
Wo
>
call
()
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Process
process
;
WorkCompleted
workCompleted
;
Data
data
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
process
=
business
.
element
().
get
(
processId
,
Process
.
class
);
if
(
null
==
process
)
{
throw
new
ExceptionEntityNotExist
(
processId
,
Process
.
class
);
}
Application
application
=
business
.
element
().
get
(
process
.
getApplication
(),
Application
.
class
);
if
(
null
==
application
)
{
throw
new
ExceptionEntityNotExist
(
process
.
getApplication
(),
Application
.
class
);
}
String
identity
=
business
.
organization
().
identity
().
get
(
wi
.
getIdentity
());
if
(
StringUtils
.
isEmpty
(
identity
))
{
throw
new
ExceptionIdentityNotExist
(
wi
.
getIdentity
());
}
String
person
=
business
.
organization
().
person
().
getWithIdentity
(
identity
);
String
unit
=
business
.
organization
().
unit
().
getWithIdentity
(
identity
);
Unit
unitObject
=
business
.
organization
().
unit
().
getObject
(
unit
);
emc
.
beginTransaction
(
Item
.
class
);
emc
.
beginTransaction
(
WorkCompleted
.
class
);
Date
now
=
new
Date
();
workCompleted
=
new
WorkCompleted
();
workCompleted
.
setApplication
(
application
.
getId
());
workCompleted
.
setApplicationAlias
(
application
.
getAlias
());
workCompleted
.
setApplicationName
(
application
.
getName
());
workCompleted
.
setCompletedTime
((
wi
.
getCompletedTime
()
==
null
)
?
now
:
wi
.
getCompletedTime
());
workCompleted
.
setCreatorIdentity
(
identity
);
workCompleted
.
setCreatorPerson
(
person
);
workCompleted
.
setCreatorUnit
(
unit
);
workCompleted
.
setCreatorUnitLevelName
(
unitObject
.
getLevelName
());
workCompleted
.
setDuration
(
0L
);
workCompleted
.
setExpired
(
false
);
workCompleted
.
setExpireTime
(
null
);
workCompleted
.
setForm
(
wi
.
getForm
());
workCompleted
.
setJob
(
StringTools
.
uniqueToken
());
workCompleted
.
setProcess
(
process
.
getId
());
workCompleted
.
setProcessAlias
(
process
.
getAlias
());
workCompleted
.
setProcessName
(
process
.
getName
());
workCompleted
.
setSerial
(
wi
.
getSerial
());
workCompleted
.
setStartTime
((
wi
.
getStartTime
()
==
null
)
?
now
:
wi
.
getStartTime
());
workCompleted
.
setTitle
(
wi
.
getTitle
());
workCompleted
.
setWork
(
null
);
emc
.
persist
(
workCompleted
,
CheckPersistType
.
all
);
data
=
gson
.
fromJson
(
wi
.
getData
(),
Data
.
class
);
data
.
setWork
(
workCompleted
);
DataItemConverter
<
Item
>
converter
=
new
DataItemConverter
<>(
Item
.
class
);
List
<
Item
>
adds
=
converter
.
disassemble
(
gson
.
toJsonTree
(
data
));
for
(
Item
o
:
adds
)
{
fill
(
o
,
workCompleted
);
business
.
entityManagerContainer
().
persist
(
o
);
}
emc
.
commit
();
Wo
wo
=
new
Wo
();
wo
.
setId
(
workCompleted
.
getId
());
result
.
setData
(
wo
);
}
// projection
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
this
.
projection
(
business
,
workCompleted
.
getJob
(),
data
,
process
);
}
return
result
;
}
private
void
projection
(
Business
business
,
String
job
,
Data
data
,
Process
process
)
throws
Exception
{
List
<
Projection
>
projections
=
listProjections
(
process
);
if
(
ListTools
.
isNotEmpty
(
projections
))
{
projection
(
business
,
job
,
data
,
projections
);
}
}
private
void
projection
(
Business
business
,
String
job
,
Data
data
,
List
<
Projection
>
projections
)
throws
Exception
{
EntityManagerContainer
emc
=
business
.
entityManagerContainer
();
emc
.
beginTransaction
(
Work
.
class
);
emc
.
beginTransaction
(
Task
.
class
);
emc
.
beginTransaction
(
TaskCompleted
.
class
);
emc
.
beginTransaction
(
Read
.
class
);
emc
.
beginTransaction
(
ReadCompleted
.
class
);
emc
.
beginTransaction
(
Review
.
class
);
for
(
Work
o
:
emc
.
listEqual
(
Work
.
class
,
Work
.
job_FIELDNAME
,
job
))
{
ProjectionFactory
.
projectionWork
(
projections
,
data
,
o
);
}
for
(
Task
o
:
emc
.
listEqual
(
Task
.
class
,
Task
.
job_FIELDNAME
,
job
))
{
ProjectionFactory
.
projectionTask
(
projections
,
data
,
o
);
}
for
(
TaskCompleted
o
:
emc
.
listEqual
(
TaskCompleted
.
class
,
TaskCompleted
.
job_FIELDNAME
,
job
))
{
ProjectionFactory
.
projectionTaskCompleted
(
projections
,
data
,
o
);
}
for
(
Read
o
:
emc
.
listEqual
(
Read
.
class
,
Read
.
job_FIELDNAME
,
job
))
{
ProjectionFactory
.
projectionRead
(
projections
,
data
,
o
);
}
for
(
ReadCompleted
o
:
emc
.
listEqual
(
ReadCompleted
.
class
,
ReadCompleted
.
job_FIELDNAME
,
job
))
{
ProjectionFactory
.
projectionReadCompleted
(
projections
,
data
,
o
);
}
for
(
Review
o
:
emc
.
listEqual
(
Review
.
class
,
Review
.
job_FIELDNAME
,
job
))
{
ProjectionFactory
.
projectionReview
(
projections
,
data
,
o
);
}
emc
.
commit
();
}
private
List
<
Projection
>
listProjections
(
Process
process
)
{
List
<
Projection
>
list
=
new
ArrayList
<>();
String
text
=
process
.
getProjection
();
if
(
XGsonBuilder
.
isJsonArray
(
text
))
{
list
=
XGsonBuilder
.
instance
().
fromJson
(
text
,
new
TypeToken
<
List
<
Projection
>>()
{
}.
getType
());
}
return
list
;
}
private
void
fill
(
Item
o
,
WorkCompleted
workCompleted
)
{
/** 将DateItem与Work放在同一个分区 */
o
.
setDistributeFactor
(
workCompleted
.
getDistributeFactor
());
o
.
setBundle
(
workCompleted
.
getJob
());
o
.
setItemCategory
(
ItemCategory
.
pp
);
}
}
public
static
class
Wo
extends
WoId
{
private
static
final
long
serialVersionUID
=
-
8304167991098790325L
;
}
public
static
class
Wi
extends
GsonPropertyObject
{
private
static
final
long
serialVersionUID
=
7817819508116690487L
;
@FieldDescribe
(
"标题."
)
@Schema
(
description
=
"标题."
)
private
String
title
;
@FieldDescribe
(
"序号."
)
@Schema
(
description
=
"序号."
)
private
String
serial
;
@FieldDescribe
(
"指定表单."
)
@Schema
(
description
=
"指定表单."
)
private
String
form
;
@FieldDescribe
(
"启动人员身份."
)
@Schema
(
description
=
"启动人员身份."
)
private
String
identity
;
@FieldDescribe
(
"开始日期."
)
@Schema
(
description
=
"开始日期."
)
private
Date
startTime
;
@FieldDescribe
(
"结束日期."
)
@Schema
(
description
=
"结束日期."
)
private
Date
completedTime
;
@FieldDescribe
(
"工作数据."
)
@Schema
(
description
=
"工作数据."
)
private
JsonElement
data
;
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getIdentity
()
{
return
identity
;
}
public
void
setIdentity
(
String
identity
)
{
this
.
identity
=
identity
;
}
public
JsonElement
getData
()
{
return
data
;
}
public
void
setData
(
JsonElement
data
)
{
this
.
data
=
data
;
}
public
Date
getCompletedTime
()
{
return
completedTime
;
}
public
void
setCompletedTime
(
Date
completedTime
)
{
this
.
completedTime
=
completedTime
;
}
public
String
getForm
()
{
return
form
;
}
public
void
setForm
(
String
form
)
{
this
.
form
=
form
;
}
public
String
getSerial
()
{
return
serial
;
}
public
void
setSerial
(
String
serial
)
{
this
.
serial
=
serial
;
}
public
Date
getStartTime
()
{
return
startTime
;
}
}
public
void
setStartTime
(
Date
startTime
)
{
this
.
startTime
=
startTime
;
}
private
void
fill
(
Item
o
,
WorkCompleted
workCompleted
)
{
/** 将DateItem与Work放在同一个分区 */
o
.
setDistributeFactor
(
workCompleted
.
getDistributeFactor
());
o
.
setBundle
(
workCompleted
.
getJob
());
o
.
setItemCategory
(
ItemCategory
.
pp
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录