Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
015602d5
o2oa
项目概览
fuyue82
/
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,发现更多精彩内容 >>
提交
015602d5
编写于
9月 27, 2020
作者:
O
o2null
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix/context' into 'release'
fix merge See merge request o2oa/o2oa!1724
上级
432c6e57
b03bd0f9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
390 addition
and
230 deletion
+390
-230
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ProcessPlatform.java
.../java/com/x/base/core/project/config/ProcessPlatform.java
+13
-1
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionAppend.java
...splatform/service/processing/jaxrs/task/ActionAppend.java
+11
-13
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionCombine.java
...service/processing/jaxrs/workcompleted/ActionCombine.java
+0
-193
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionMerge.java
...m/service/processing/jaxrs/workcompleted/ActionMerge.java
+344
-0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/WorkCompletedAction.java
...e/processing/jaxrs/workcompleted/WorkCompletedAction.java
+5
-5
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/ExceptionMerge.java
...splatform/service/processing/schedule/ExceptionMerge.java
+2
-2
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/Merge.java
.../x/processplatform/service/processing/schedule/Merge.java
+15
-16
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ProcessPlatform.java
浏览文件 @
015602d5
...
...
@@ -14,6 +14,7 @@ import com.x.base.core.project.annotation.FieldDescribe;
import
com.x.base.core.project.gson.XGsonBuilder
;
import
com.x.base.core.project.tools.DefaultCharset
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.NumberTools
;
/**
* @author Zhou Rui
...
...
@@ -330,6 +331,8 @@ public class ProcessPlatform extends ConfigObject {
public
static
class
Merge
extends
ConfigObject
{
private
static
final
long
serialVersionUID
=
-
5858277850858377338L
;
public
static
Merge
defaultInstance
()
{
Merge
o
=
new
Merge
();
return
o
;
...
...
@@ -341,15 +344,24 @@ public class ProcessPlatform extends ConfigObject {
public
static
final
Integer
DEFAULT_THRESHOLDDAYS
=
365
*
2
;
public
static
final
Integer
DEFAULT_BATCHSIZE
=
100
;
@FieldDescribe
(
"是否启用"
)
private
Boolean
enable
=
DEFAULT_ENABLE
;
@FieldDescribe
(
"定时cron表达式"
)
private
String
cron
=
DEFAULT_CRON
;
@FieldDescribe
(
"期限,已完成工作结束间隔指定时间进行
combine,默认两年后进行combin
e"
)
@FieldDescribe
(
"期限,已完成工作结束间隔指定时间进行
merge,默认两年后进行merg
e"
)
private
Integer
thresholdDays
=
DEFAULT_THRESHOLDDAYS
;
@FieldDescribe
(
"批量大小."
)
private
Integer
batchSize
=
DEFAULT_BATCHSIZE
;
public
Integer
getBatchSize
()
{
return
NumberTools
.
nullOrLessThan
(
this
.
batchSize
,
1
)
?
DEFAULT_BATCHSIZE
:
this
.
batchSize
;
}
public
String
getCron
()
{
if
(
StringUtils
.
isNotEmpty
(
this
.
cron
)
&&
CronExpression
.
isValidExpression
(
this
.
cron
))
{
return
this
.
cron
;
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionAppend.java
浏览文件 @
015602d5
...
...
@@ -80,7 +80,7 @@ class ActionAppend extends BaseAction {
if
(
ListTools
.
isNotEmpty
(
wi
.
getIdentityList
()))
{
identities
.
addAll
(
wi
.
getIdentityList
());
}
if
(
(
null
!=
manual
)
&&
(
route
!=
null
)
)
{
if
(
route
!=
null
)
{
if
(
StringUtils
.
equals
(
route
.
getType
(),
Route
.
TYPE_APPENDTASK
)
&&
StringUtils
.
equals
(
manual
.
getId
(),
route
.
getActivity
()))
{
if
(
StringUtils
.
equals
(
route
.
getAppendTaskIdentityType
(),
...
...
@@ -107,7 +107,7 @@ class ActionAppend extends BaseAction {
}
Process
process
=
business
.
element
().
get
(
task
.
getProcess
(),
Process
.
class
);
identities
=
business
.
organization
().
identity
().
list
(
ListTools
.
trim
(
identities
,
true
,
true
));
TaskIdentities
taskIdentities
=
empower
(
business
,
process
,
task
,
identities
);
TaskIdentities
taskIdentities
=
empower
(
business
,
process
,
task
,
identities
);
identities
=
taskIdentities
.
identities
();
if
(
ListTools
.
isNotEmpty
(
identities
))
{
List
<
TaskCompleted
>
os
=
emc
.
listEqualAndInAndNotEqual
(
TaskCompleted
.
class
,
...
...
@@ -118,23 +118,20 @@ class ActionAppend extends BaseAction {
emc
.
beginTransaction
(
TaskCompleted
.
class
);
for
(
TaskCompleted
o
:
os
)
{
o
.
setJoinInquire
(
false
);
// o.setProcessingType(ProcessingType.beAppendedTask);
o
.
setProcessingType
(
TaskCompleted
.
PROCESSINGTYPE_BEAPPENDEDTASK
);
}
}
/
* 后面还要合并,clone一个新实例 */
/
/ 后面还要合并,clone一个新实例
wo
.
getValueList
().
addAll
(
new
ArrayList
<>(
identities
));
identities
=
ListUtils
.
sum
(
ListUtils
.
subtract
(
work
.
getManualTaskIdentityList
(),
ListTools
.
toList
(
task
.
getIdentity
())),
identities
);
identities
=
business
.
organization
().
identity
().
list
(
ListTools
.
trim
(
identities
,
true
,
true
));
emc
.
beginTransaction
(
Work
.
class
);
for
(
TaskIdentity
o
:
taskIdentities
)
{
if
(
StringUtils
.
isNotEmpty
(
o
.
getFromIdentity
()))
{
// work.properties().getManualEmpowerMap().put(o.getIdentity(),
// o.getFromIdentity());
}
}
work
.
setManualTaskIdentityList
(
identities
);
emc
.
beginTransaction
(
Task
.
class
);
// 转派后设置过期为空
task
.
setExpired
(
false
);
task
.
setExpireTime
(
null
);
emc
.
commit
();
}
result
.
setData
(
wo
);
...
...
@@ -162,11 +159,12 @@ class ActionAppend extends BaseAction {
return
scriptContext
;
}
private
TaskIdentities
empower
(
Business
business
,
Process
process
,
Task
task
,
List
<
String
>
identities
)
throws
Exception
{
private
TaskIdentities
empower
(
Business
business
,
Process
process
,
Task
task
,
List
<
String
>
identities
)
throws
Exception
{
TaskIdentities
taskIdentities
=
new
TaskIdentities
();
taskIdentities
.
addIdentities
(
identities
);
taskIdentities
.
empower
(
business
.
organization
().
empower
().
listWithIdentityObject
(
task
.
getApplication
(),
process
.
getEdition
(),
task
.
getProcess
(),
task
.
getWork
(),
identities
));
taskIdentities
.
empower
(
business
.
organization
().
empower
().
listWithIdentityObject
(
task
.
getApplication
(),
process
.
getEdition
(),
task
.
getProcess
(),
task
.
getWork
(),
identities
));
return
taskIdentities
;
}
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionCombine.java
已删除
100644 → 0
浏览文件 @
432c6e57
package
com.x.processplatform.service.processing.jaxrs.workcompleted
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
java.util.stream.Collectors
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.annotation.CheckRemoveType
;
import
com.x.base.core.entity.dataitem.DataItemConverter
;
import
com.x.base.core.entity.dataitem.ItemCategory
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.executor.ProcessPlatformExecutorFactory
;
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.processplatform.core.entity.content.Data
;
import
com.x.processplatform.core.entity.content.DocumentVersion
;
import
com.x.processplatform.core.entity.content.ReadCompleted
;
import
com.x.processplatform.core.entity.content.Record
;
import
com.x.processplatform.core.entity.content.Review
;
import
com.x.processplatform.core.entity.content.TaskCompleted
;
import
com.x.processplatform.core.entity.content.WorkCompleted
;
import
com.x.processplatform.core.entity.content.WorkLog
;
import
com.x.processplatform.service.processing.Business
;
import
com.x.query.core.entity.Item
;
class
ActionCombine
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionCombine
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
id
)
throws
Exception
{
String
executorSeed
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
WorkCompleted
workCompleted
=
emc
.
fetch
(
id
,
WorkCompleted
.
class
,
ListTools
.
toList
(
WorkCompleted
.
job_FIELDNAME
));
if
(
null
==
workCompleted
)
{
throw
new
ExceptionEntityNotExist
(
id
,
WorkCompleted
.
class
);
}
executorSeed
=
workCompleted
.
getJob
();
}
return
ProcessPlatformExecutorFactory
.
get
(
executorSeed
).
submit
(
new
CallableAction
(
id
)).
get
();
}
public
static
class
Wo
extends
WoId
{
}
public
class
CallableAction
implements
Callable
<
ActionResult
<
Wo
>>
{
private
String
id
;
CallableAction
(
String
id
)
{
this
.
id
=
id
;
}
@Override
public
ActionResult
<
Wo
>
call
()
throws
Exception
{
WorkCompleted
workCompleted
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
workCompleted
=
emc
.
find
(
id
,
WorkCompleted
.
class
);
Business
business
=
new
Business
(
emc
);
if
(
null
!=
workCompleted
)
{
List
<
DocumentVersion
>
documentVersions
=
listDocumentVersion
(
business
,
workCompleted
);
List
<
Item
>
items
=
combineItem
(
business
,
workCompleted
);
List
<
TaskCompleted
>
taskCompleteds
=
combineTaskCompleted
(
business
,
workCompleted
);
List
<
ReadCompleted
>
readCompleteds
=
combineReadCompleted
(
business
,
workCompleted
);
List
<
Review
>
reviews
=
combineReview
(
business
,
workCompleted
);
List
<
WorkLog
>
workLogs
=
combineWorkLog
(
business
,
workCompleted
);
List
<
Record
>
records
=
combineRecord
(
business
,
workCompleted
);
emc
.
beginTransaction
(
WorkCompleted
.
class
);
workCompleted
.
setMerged
(
true
);
emc
.
commit
();
this
.
remove
(
business
,
items
,
workLogs
,
records
,
documentVersions
);
logger
.
print
(
"已完成工作合并, id: {}, title:{}, sequence:{}."
,
workCompleted
.
getId
(),
workCompleted
.
getTitle
(),
workCompleted
.
getSequence
());
}
}
catch
(
Exception
e
)
{
throw
new
ExceptionCombine
(
e
,
id
);
}
Wo
wo
=
new
Wo
();
wo
.
setId
(
id
);
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
result
.
setData
(
wo
);
return
result
;
}
private
void
remove
(
Business
business
,
List
<
Item
>
items
,
List
<
WorkLog
>
workLogs
,
List
<
Record
>
records
,
List
<
DocumentVersion
>
documentVersions
)
throws
Exception
{
EntityManagerContainer
emc
=
business
.
entityManagerContainer
();
if
(!
items
.
isEmpty
())
{
emc
.
beginTransaction
(
Item
.
class
);
for
(
Item
o
:
items
)
{
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
}
if
(!
workLogs
.
isEmpty
())
{
emc
.
beginTransaction
(
WorkLog
.
class
);
for
(
WorkLog
o
:
workLogs
)
{
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
}
if
(!
records
.
isEmpty
())
{
emc
.
beginTransaction
(
Record
.
class
);
for
(
Record
o
:
records
)
{
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
}
if
(!
documentVersions
.
isEmpty
())
{
emc
.
beginTransaction
(
DocumentVersion
.
class
);
for
(
DocumentVersion
o
:
documentVersions
)
{
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
}
emc
.
commit
();
}
private
List
<
TaskCompleted
>
combineTaskCompleted
(
Business
business
,
WorkCompleted
workCompleted
)
throws
Exception
{
List
<
TaskCompleted
>
list
=
business
.
entityManagerContainer
().
listEqual
(
TaskCompleted
.
class
,
TaskCompleted
.
job_FIELDNAME
,
workCompleted
.
getJob
());
list
=
list
.
stream
()
.
sorted
(
Comparator
.
comparing
(
TaskCompleted:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setTaskCompletedList
(
list
);
return
list
;
}
private
List
<
ReadCompleted
>
combineReadCompleted
(
Business
business
,
WorkCompleted
workCompleted
)
throws
Exception
{
List
<
ReadCompleted
>
list
=
business
.
entityManagerContainer
().
listEqual
(
ReadCompleted
.
class
,
ReadCompleted
.
job_FIELDNAME
,
workCompleted
.
getJob
());
list
=
list
.
stream
()
.
sorted
(
Comparator
.
comparing
(
ReadCompleted:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setReadCompletedList
(
list
);
return
list
;
}
private
List
<
Review
>
combineReview
(
Business
business
,
WorkCompleted
workCompleted
)
throws
Exception
{
List
<
Review
>
list
=
business
.
entityManagerContainer
().
listEqual
(
Review
.
class
,
Review
.
job_FIELDNAME
,
workCompleted
.
getJob
());
list
=
list
.
stream
()
.
sorted
(
Comparator
.
comparing
(
Review:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setReviewList
(
list
);
return
list
;
}
private
List
<
DocumentVersion
>
listDocumentVersion
(
Business
business
,
WorkCompleted
workCompleted
)
throws
Exception
{
return
business
.
entityManagerContainer
().
listEqual
(
DocumentVersion
.
class
,
DocumentVersion
.
job_FIELDNAME
,
workCompleted
.
getJob
());
}
private
List
<
Item
>
combineItem
(
Business
business
,
WorkCompleted
workCompleted
)
throws
Exception
{
List
<
Item
>
list
=
business
.
entityManagerContainer
().
listEqualAndEqual
(
Item
.
class
,
Item
.
bundle_FIELDNAME
,
workCompleted
.
getJob
(),
Item
.
itemCategory_FIELDNAME
,
ItemCategory
.
pp
);
DataItemConverter
<
Item
>
converter
=
new
DataItemConverter
<
Item
>(
Item
.
class
);
JsonElement
jsonElement
=
converter
.
assemble
(
list
);
workCompleted
.
getProperties
().
setData
(
gson
.
fromJson
(
jsonElement
,
Data
.
class
));
return
list
;
}
private
List
<
Record
>
combineRecord
(
Business
business
,
WorkCompleted
workCompleted
)
throws
Exception
{
List
<
Record
>
list
=
business
.
entityManagerContainer
().
listEqual
(
Record
.
class
,
Record
.
job_FIELDNAME
,
workCompleted
.
getJob
());
Collections
.
sort
(
list
,
Comparator
.
comparing
(
Record:
:
getOrder
,
Comparator
.
nullsLast
(
Long:
:
compareTo
)));
workCompleted
.
getProperties
().
setRecordList
(
list
);
return
list
;
}
private
List
<
WorkLog
>
combineWorkLog
(
Business
business
,
WorkCompleted
workCompleted
)
throws
Exception
{
List
<
WorkLog
>
list
=
business
.
entityManagerContainer
().
listEqual
(
WorkLog
.
class
,
WorkCompleted
.
job_FIELDNAME
,
workCompleted
.
getJob
());
Collections
.
sort
(
list
,
Comparator
.
comparing
(
WorkLog:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)));
workCompleted
.
getProperties
().
setWorkLogList
(
list
);
return
list
;
}
}
}
\ No newline at end of file
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionMerge.java
0 → 100644
浏览文件 @
015602d5
package
com.x.processplatform.service.processing.jaxrs.workcompleted
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.stream.Collectors
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.dataitem.DataItem
;
import
com.x.base.core.entity.dataitem.DataItemConverter
;
import
com.x.base.core.entity.dataitem.ItemCategory
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.executor.ProcessPlatformExecutorFactory
;
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.processplatform.core.entity.content.Data
;
import
com.x.processplatform.core.entity.content.DocumentVersion
;
import
com.x.processplatform.core.entity.content.Read
;
import
com.x.processplatform.core.entity.content.ReadCompleted
;
import
com.x.processplatform.core.entity.content.Record
;
import
com.x.processplatform.core.entity.content.Review
;
import
com.x.processplatform.core.entity.content.TaskCompleted
;
import
com.x.processplatform.core.entity.content.WorkCompleted
;
import
com.x.processplatform.core.entity.content.WorkLog
;
import
com.x.processplatform.service.processing.Business
;
import
com.x.query.core.entity.Item
;
class
ActionMerge
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionMerge
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
id
)
throws
Exception
{
String
executorSeed
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
WorkCompleted
workCompleted
=
emc
.
fetch
(
id
,
WorkCompleted
.
class
,
ListTools
.
toList
(
WorkCompleted
.
job_FIELDNAME
));
if
(
null
==
workCompleted
)
{
throw
new
ExceptionEntityNotExist
(
id
,
WorkCompleted
.
class
);
}
executorSeed
=
workCompleted
.
getJob
();
}
return
ProcessPlatformExecutorFactory
.
get
(
executorSeed
).
submit
(
new
CallableAction
(
id
)).
get
();
}
public
static
class
Wo
extends
WoId
{
}
public
class
CallableAction
implements
Callable
<
ActionResult
<
Wo
>>
{
private
String
id
;
CallableAction
(
String
id
)
{
this
.
id
=
id
;
}
@Override
public
ActionResult
<
Wo
>
call
()
throws
Exception
{
WorkCompleted
workCompleted
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
workCompleted
=
emc
.
find
(
id
,
WorkCompleted
.
class
);
Business
business
=
new
Business
(
emc
);
List
<
Item
>
items
=
new
ArrayList
<>();
List
<
TaskCompleted
>
taskCompleteds
=
new
ArrayList
<>();
List
<
ReadCompleted
>
readCompleteds
=
new
ArrayList
<>();
List
<
Review
>
reviews
=
new
ArrayList
<>();
List
<
WorkLog
>
workLogs
=
new
ArrayList
<>();
List
<
Record
>
records
=
new
ArrayList
<>();
List
<
Read
>
reads
=
new
ArrayList
<>();
List
<
DocumentVersion
>
documentVersions
=
new
ArrayList
<>();
if
(
null
!=
workCompleted
)
{
CompletableFuture
.
allOf
(
mergeItem
(
business
,
workCompleted
,
items
),
mergeTaskCompleted
(
business
,
workCompleted
,
taskCompleteds
),
mergeReadCompleted
(
business
,
workCompleted
,
readCompleteds
),
mergeReview
(
business
,
workCompleted
,
reviews
),
mergeWorkLog
(
business
,
workCompleted
,
workLogs
),
mergeRecord
(
business
,
workCompleted
,
records
),
listRead
(
business
,
workCompleted
,
reads
),
listDocumentVersion
(
business
,
workCompleted
,
documentVersions
)).
get
();
emc
.
beginTransaction
(
WorkCompleted
.
class
);
workCompleted
.
setMerged
(
true
);
emc
.
commit
();
CompletableFuture
.
allOf
(
deleteItem
(
business
,
items
),
deleteTaskCompleted
(
business
,
taskCompleteds
),
deleteReadCompleted
(
business
,
readCompleteds
),
deleteReview
(
business
,
reviews
),
deleteWorkLog
(
business
,
workLogs
),
deleteRecord
(
business
,
records
),
deleteRead
(
business
,
reads
),
deleteDocumentVersion
(
business
,
documentVersions
))
.
get
();
emc
.
commit
();
logger
.
print
(
"已完成工作合并, id: {}, title:{}, sequence:{}."
,
workCompleted
.
getId
(),
workCompleted
.
getTitle
(),
workCompleted
.
getSequence
());
}
}
catch
(
Exception
e
)
{
throw
new
ExceptionCombine
(
e
,
id
);
}
Wo
wo
=
new
Wo
();
wo
.
setId
(
id
);
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
result
.
setData
(
wo
);
return
result
;
}
private
CompletableFuture
<
Void
>
mergeItem
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
Item
>
items
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
Item
>
os
=
business
.
entityManagerContainer
().
listEqualAndEqual
(
Item
.
class
,
DataItem
.
bundle_FIELDNAME
,
workCompleted
.
getJob
(),
DataItem
.
itemCategory_FIELDNAME
,
ItemCategory
.
pp
);
DataItemConverter
<
Item
>
converter
=
new
DataItemConverter
<>(
Item
.
class
);
JsonElement
jsonElement
=
converter
.
assemble
(
os
);
workCompleted
.
getProperties
().
setData
(
gson
.
fromJson
(
jsonElement
,
Data
.
class
));
items
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
mergeTaskCompleted
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
TaskCompleted
>
taskCompleteds
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
TaskCompleted
>
os
=
business
.
entityManagerContainer
()
.
listEqual
(
TaskCompleted
.
class
,
TaskCompleted
.
job_FIELDNAME
,
workCompleted
.
getJob
())
.
stream
().
sorted
(
Comparator
.
comparing
(
TaskCompleted:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setTaskCompletedList
(
os
);
taskCompleteds
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
mergeReadCompleted
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
ReadCompleted
>
readCompleteds
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
ReadCompleted
>
os
=
business
.
entityManagerContainer
()
.
listEqual
(
ReadCompleted
.
class
,
ReadCompleted
.
job_FIELDNAME
,
workCompleted
.
getJob
())
.
stream
().
sorted
(
Comparator
.
comparing
(
ReadCompleted:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setReadCompletedList
(
os
);
readCompleteds
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
mergeReview
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
Review
>
reviews
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
Review
>
os
=
business
.
entityManagerContainer
()
.
listEqual
(
Review
.
class
,
Review
.
job_FIELDNAME
,
workCompleted
.
getJob
()).
stream
()
.
sorted
(
Comparator
.
comparing
(
Review:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setReviewList
(
os
);
reviews
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
mergeWorkLog
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
WorkLog
>
workLogs
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
WorkLog
>
os
=
business
.
entityManagerContainer
()
.
listEqual
(
WorkLog
.
class
,
WorkLog
.
job_FIELDNAME
,
workCompleted
.
getJob
()).
stream
()
.
sorted
(
Comparator
.
comparing
(
WorkLog:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setWorkLogList
(
os
);
workLogs
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
mergeRecord
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
Record
>
records
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
Record
>
os
=
business
.
entityManagerContainer
()
.
listEqual
(
Record
.
class
,
Record
.
job_FIELDNAME
,
workCompleted
.
getJob
()).
stream
()
.
sorted
(
Comparator
.
comparing
(
Record:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
workCompleted
.
getProperties
().
setRecordList
(
os
);
records
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
listDocumentVersion
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
DocumentVersion
>
documentVersions
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
DocumentVersion
>
os
=
business
.
entityManagerContainer
().
listEqual
(
DocumentVersion
.
class
,
DocumentVersion
.
job_FIELDNAME
,
workCompleted
.
getJob
());
documentVersions
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
listRead
(
Business
business
,
WorkCompleted
workCompleted
,
List
<
Read
>
reads
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
List
<
Read
>
os
=
business
.
entityManagerContainer
()
.
listEqual
(
Read
.
class
,
Read
.
job_FIELDNAME
,
workCompleted
.
getJob
()).
stream
()
.
sorted
(
Comparator
.
comparing
(
Read:
:
getCreateTime
,
Comparator
.
nullsLast
(
Date:
:
compareTo
)))
.
collect
(
Collectors
.
toList
());
reads
.
addAll
(
os
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteItem
(
Business
business
,
List
<
Item
>
items
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
Item
.
class
);
for
(
Item
o
:
items
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteTaskCompleted
(
Business
business
,
List
<
TaskCompleted
>
taskCompleteds
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
TaskCompleted
.
class
);
for
(
TaskCompleted
o
:
taskCompleteds
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteReadCompleted
(
Business
business
,
List
<
ReadCompleted
>
readCompleteds
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
ReadCompleted
.
class
);
for
(
ReadCompleted
o
:
readCompleteds
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteReview
(
Business
business
,
List
<
Review
>
reviews
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
Review
.
class
);
for
(
Review
o
:
reviews
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteWorkLog
(
Business
business
,
List
<
WorkLog
>
workLogs
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
WorkLog
.
class
);
for
(
WorkLog
o
:
workLogs
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteRecord
(
Business
business
,
List
<
Record
>
records
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
Record
.
class
);
for
(
Record
o
:
records
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteDocumentVersion
(
Business
business
,
List
<
DocumentVersion
>
documentVersions
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
DocumentVersion
.
class
);
for
(
DocumentVersion
o
:
documentVersions
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
CompletableFuture
<
Void
>
deleteRead
(
Business
business
,
List
<
Read
>
reads
)
{
return
CompletableFuture
.
runAsync
(()
->
{
try
{
business
.
entityManagerContainer
().
beginTransaction
(
Read
.
class
);
for
(
Read
o
:
reads
)
{
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
}
}
\ No newline at end of file
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/WorkCompletedAction.java
浏览文件 @
015602d5
...
...
@@ -49,17 +49,17 @@ public class WorkCompletedAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"指定的已完成工作进行合并."
,
action
=
Action
Combin
e
.
class
)
@JaxrsMethodDescribe
(
value
=
"指定的已完成工作进行合并."
,
action
=
Action
Merg
e
.
class
)
@GET
@Path
(
"{flag}/
combin
e"
)
@Path
(
"{flag}/
merg
e"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
combin
e
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
public
void
merg
e
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"完成工作"
)
@PathParam
(
"flag"
)
String
flag
)
{
ActionResult
<
Action
Combin
e
.
Wo
>
result
=
new
ActionResult
<>();
ActionResult
<
Action
Merg
e
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
Action
Combin
e
().
execute
(
effectivePerson
,
flag
);
result
=
new
Action
Merg
e
().
execute
(
effectivePerson
,
flag
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/Exception
Combin
e.java
→
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/Exception
Merg
e.java
浏览文件 @
015602d5
...
...
@@ -2,11 +2,11 @@ package com.x.processplatform.service.processing.schedule;
import
com.x.base.core.project.exception.PromptException
;
class
Exception
Combin
e
extends
PromptException
{
class
Exception
Merg
e
extends
PromptException
{
private
static
final
long
serialVersionUID
=
-
7038279889683420366L
;
Exception
Combin
e
(
Exception
e
,
String
id
,
String
title
,
String
sequence
)
{
Exception
Merg
e
(
Exception
e
,
String
id
,
String
title
,
String
sequence
)
{
super
(
e
,
"已完成工作合并失败, id:{}, title:{}, sequence:{}."
);
}
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/Merge.java
浏览文件 @
015602d5
...
...
@@ -52,21 +52,7 @@ public class Merge extends AbstractJob {
if
(!
targets
.
isEmpty
())
{
sequence
=
targets
.
get
(
targets
.
size
()
-
1
).
getSequence
();
for
(
WorkCompleted
workCompleted
:
targets
)
{
try
{
try
{
ThisApplication
.
context
().
applications
()
.
getQuery
(
x_processplatform_service_processing
.
class
,
Applications
.
joinQueryUri
(
"workcompleted"
,
workCompleted
.
getId
(),
"combine"
),
workCompleted
.
getJob
())
.
getData
(
WoId
.
class
);
count
.
incrementAndGet
();
}
catch
(
Exception
e
)
{
throw
new
ExceptionCombine
(
e
,
workCompleted
.
getId
(),
workCompleted
.
getTitle
(),
workCompleted
.
getSequence
());
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
call
(
workCompleted
,
count
);
}
}
}
while
(!
targets
.
isEmpty
());
...
...
@@ -76,6 +62,18 @@ public class Merge extends AbstractJob {
}
}
private
void
call
(
WorkCompleted
workCompleted
,
AtomicInteger
count
)
{
try
{
ThisApplication
.
context
().
applications
().
getQuery
(
x_processplatform_service_processing
.
class
,
Applications
.
joinQueryUri
(
"workcompleted"
,
workCompleted
.
getId
(),
"merge"
),
workCompleted
.
getJob
())
.
getData
(
WoId
.
class
);
count
.
incrementAndGet
();
}
catch
(
Exception
e
)
{
logger
.
error
(
new
ExceptionMerge
(
e
,
workCompleted
.
getId
(),
workCompleted
.
getTitle
(),
workCompleted
.
getSequence
()));
}
}
private
List
<
WorkCompleted
>
list
(
EntityManagerContainer
emc
,
String
sequence
)
throws
Exception
{
Date
date
=
new
Date
();
date
=
DateUtils
.
addDays
(
date
,
0
-
Config
.
processPlatform
().
getMerge
().
getThresholdDays
());
...
...
@@ -93,7 +91,8 @@ public class Merge extends AbstractJob {
p
=
cb
.
and
(
p
,
cb
.
greaterThan
(
sequencePath
,
sequence
));
}
cq
.
multiselect
(
idPath
,
jobPath
,
sequencePath
).
where
(
p
).
orderBy
(
cb
.
asc
(
sequencePath
));
List
<
Tuple
>
os
=
em
.
createQuery
(
cq
).
setMaxResults
(
100
).
getResultList
();
List
<
Tuple
>
os
=
em
.
createQuery
(
cq
).
setMaxResults
(
Config
.
processPlatform
().
getMerge
().
getBatchSize
())
.
getResultList
();
List
<
WorkCompleted
>
list
=
new
ArrayList
<>();
for
(
Tuple
o
:
os
)
{
WorkCompleted
workCompleted
=
new
WorkCompleted
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录