Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
5797ff7f
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,发现更多精彩内容 >>
提交
5797ff7f
编写于
6月 03, 2021
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
数据中心导入模块业务开发2
上级
73597c0e
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
1067 addition
and
41 deletion
+1067
-41
o2server/x_base_core_project/src/main/java/com/x/base/core/project/exception/ExceptionEntityExist.java
...m/x/base/core/project/exception/ExceptionEntityExist.java
+36
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_query_assemble_designer.java
...va/com/x/base/core/project/x_query_assemble_designer.java
+1
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_query_assemble_surface.java
...ava/com/x/base/core/project/x_query_assemble_surface.java
+1
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_query_service_processing.java
...a/com/x/base/core/project/x_query_service_processing.java
+1
-0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishContent.java
...e/control/jaxrs/document/ActionPersistPublishContent.java
+12
-1
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/ThisApplication.java
...in/java/com/x/query/assemble/surface/ThisApplication.java
+5
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/ImportModelJaxrsFilter.java
.../query/assemble/surface/jaxrs/ImportModelJaxrsFilter.java
+10
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionExecute.java
...ery/assemble/surface/jaxrs/importmodel/ActionExecute.java
+39
-30
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionGetRecord.java
...y/assemble/surface/jaxrs/importmodel/ActionGetRecord.java
+41
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionGetRecordStatus.java
...mble/surface/jaxrs/importmodel/ActionGetRecordStatus.java
+73
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionRecordItemListPaging.java
...surface/jaxrs/importmodel/ActionRecordItemListPaging.java
+84
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionRecordListPaging.java
...ble/surface/jaxrs/importmodel/ActionRecordListPaging.java
+84
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ImportModelAction.java
...assemble/surface/jaxrs/importmodel/ImportModelAction.java
+76
-2
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/queue/QueueImportData.java
...a/com/x/query/assemble/surface/queue/QueueImportData.java
+260
-0
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/ImportModel.java
...ty/src/main/java/com/x/query/core/entity/ImportModel.java
+6
-6
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/ImportRecord.java
...y/src/main/java/com/x/query/core/entity/ImportRecord.java
+147
-0
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/ImportRecordItem.java
...c/main/java/com/x/query/core/entity/ImportRecordItem.java
+181
-0
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/PersistenceProperties.java
...n/java/com/x/query/core/entity/PersistenceProperties.java
+10
-2
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/exception/ExceptionEntityExist.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.base.core.project.exception
;
import
com.x.base.core.entity.JpaObject
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
public
class
ExceptionEntityExist
extends
LanguagePromptException
{
private
static
final
long
serialVersionUID
=
-
7099690129755484583L
;
public
static
String
defaultMessage
=
"标识为:{} 的 {} 对象已存在."
;
public
ExceptionEntityExist
(
String
flag
,
JpaObject
jpa
)
{
super
(
defaultMessage
,
flag
,
(
null
==
jpa
)
?
null
:
jpa
.
nameOfEntity
());
}
public
<
T
extends
JpaObject
>
ExceptionEntityExist
(
String
flag
,
Class
<
T
>
cls
)
{
super
(
defaultMessage
,
flag
,
(
null
==
cls
)
?
null
:
cls
.
getSimpleName
());
}
public
<
T
extends
JpaObject
>
ExceptionEntityExist
(
List
<
String
>
ids
,
Class
<
T
>
cls
)
{
super
(
defaultMessage
,
(
null
==
ids
)
?
null
:
StringUtils
.
join
(
ids
,
","
),
(
null
==
cls
)
?
null
:
cls
.
getSimpleName
());
}
public
<
T
extends
JpaObject
>
ExceptionEntityExist
(
String
flag
,
String
name
)
{
super
(
defaultMessage
,
flag
,
name
);
}
public
<
T
extends
JpaObject
>
ExceptionEntityExist
(
String
flag
)
{
super
(
"标识为:{} 的对象已存在."
,
flag
);
this
.
setLanguageKey
(
this
.
getClass
().
getName
()+
"_1"
);
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_query_assemble_designer.java
浏览文件 @
5797ff7f
...
...
@@ -12,6 +12,7 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.query.core.entity.neural.OutText"
,
"com.x.query.core.entity.neural.InValue"
,
"com.x.query.core.entity.neural.OutValue"
,
"com.x.query.core.entity.neural.Model"
,
"com.x.query.core.entity.schema.Table"
,
"com.x.query.core.entity.schema.Statement"
,
"com.x.query.core.entity.ImportModel"
,
"com.x.processplatform.core.entity.content.Review"
,
"com.x.processplatform.core.entity.content.Work"
,
"com.x.processplatform.core.entity.content.WorkCompleted"
,
"com.x.processplatform.core.entity.content.Task"
,
"com.x.processplatform.core.entity.content.TaskCompleted"
,
"com.x.processplatform.core.entity.content.Read"
,
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_query_assemble_surface.java
浏览文件 @
5797ff7f
...
...
@@ -13,6 +13,7 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.query.core.entity.neural.OutText"
,
"com.x.query.core.entity.neural.InValue"
,
"com.x.query.core.entity.neural.OutValue"
,
"com.x.query.core.entity.neural.Model"
,
"com.x.query.core.entity.schema.Table"
,
"com.x.query.core.entity.schema.Statement"
,
"com.x.query.core.entity.ImportModel"
,
"com.x.processplatform.core.entity.content.Task"
,
"com.x.processplatform.core.entity.content.TaskCompleted"
,
"com.x.processplatform.core.entity.content.Read"
,
"com.x.processplatform.core.entity.content.ReadCompleted"
,
"com.x.processplatform.core.entity.content.Review"
,
"com.x.processplatform.core.entity.content.Work"
,
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_query_service_processing.java
浏览文件 @
5797ff7f
...
...
@@ -13,6 +13,7 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.query.core.entity.neural.OutText"
,
"com.x.query.core.entity.neural.InValue"
,
"com.x.query.core.entity.neural.OutValue"
,
"com.x.query.core.entity.neural.Model"
,
"com.x.query.core.entity.schema.*"
,
"com.x.processplatform.core.entity.content.Review"
,
"com.x.query.core.entity.ImportModel"
,
"com.x.processplatform.core.entity.content.Work"
,
"com.x.processplatform.core.entity.content.WorkCompleted"
,
"com.x.processplatform.core.entity.content.Attachment"
,
"com.x.cms.core.entity.Document"
,
"com.x.cms.core.entity.FileInfo"
,
"com.x.cms.core.entity.AppInfo"
,
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishContent.java
浏览文件 @
5797ff7f
...
...
@@ -12,6 +12,7 @@ import com.x.base.core.project.config.StorageMapping;
import
com.x.base.core.project.exception.ExceptionWhen
;
import
com.x.processplatform.core.entity.content.Attachment
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
...
...
@@ -438,7 +439,7 @@ public class ActionPersistPublishContent extends BaseAction {
notify
=
true
;
}
}
if
(
notify
){
if
(
notify
&&
!
BooleanUtils
.
isFalse
(
wi
.
getNotice
())
){
logger
.
debug
(
"try to add notify object to queue for document:"
+
document
.
getTitle
()
);
ThisApplication
.
queueSendDocumentNotify
.
send
(
document
.
getId
()
);
}
...
...
@@ -584,6 +585,8 @@ public class ActionPersistPublishContent extends BaseAction {
@FieldDescribe
(
"是否置顶"
)
private
Boolean
isTop
=
false
;
private
Boolean
isNotice
=
true
;
private
Boolean
hasIndexPic
=
false
;
private
Boolean
reviewed
=
false
;
...
...
@@ -1067,6 +1070,14 @@ public class ActionPersistPublishContent extends BaseAction {
public
void
setCms_attachmentIds
(
String
[]
cms_attachmentIds
)
{
this
.
cms_attachmentIds
=
cms_attachmentIds
;
}
public
Boolean
getNotice
()
{
return
isNotice
;
}
public
void
setNotice
(
Boolean
notice
)
{
isNotice
=
notice
;
}
}
public
static
class
Wo
extends
WoId
{
...
...
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/ThisApplication.java
浏览文件 @
5797ff7f
...
...
@@ -4,6 +4,7 @@ import com.x.base.core.project.Context;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.query.assemble.surface.queue.QueueImportData
;
public
class
ThisApplication
{
...
...
@@ -13,6 +14,8 @@ public class ThisApplication {
protected
static
Context
context
;
public
static
QueueImportData
queueImportData
=
new
QueueImportData
();
public
static
Context
context
()
{
return
context
;
}
...
...
@@ -21,6 +24,8 @@ public class ThisApplication {
try
{
CacheManager
.
init
(
context
.
clazz
().
getSimpleName
());
LoggerFactory
.
setLevel
(
Config
.
logLevel
().
x_query_assemble_surface
());
queueImportData
.
initFixedThreadPool
(
2
);
context
().
startQueue
(
queueImportData
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/ImportModelJaxrsFilter.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.assemble.surface.jaxrs
;
import
com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter
;
import
javax.servlet.annotation.WebFilter
;
@WebFilter
(
urlPatterns
=
"/jaxrs/importmodel/*"
,
asyncSupported
=
true
)
public
class
ImportModelJaxrsFilter
extends
CipherManagerUserJaxrsFilter
{
}
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionExecute.java
浏览文件 @
5797ff7f
...
...
@@ -3,9 +3,9 @@ package com.x.query.assemble.surface.jaxrs.importmodel;
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.CheckPersistType
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.exception.*
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
...
...
@@ -13,16 +13,21 @@ 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.query.assemble.surface.Business
;
import
com.x.query.assemble.surface.ThisApplication
;
import
com.x.query.core.entity.ImportModel
;
import
com.x.query.core.entity.ImportRecord
;
import
com.x.query.core.entity.Query
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.openjpa.jdbc.meta.MappingTool
;
class
ActionExecute
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionExecute
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
id
,
JsonElement
jsonElement
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
ImportModel
model
=
business
.
pick
(
id
,
ImportModel
.
class
);
if
(
null
==
model
)
{
...
...
@@ -39,18 +44,33 @@ class ActionExecute extends BaseAction {
throw
new
ExceptionAccessDenied
(
effectivePerson
,
model
);
}
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
/** 有可能前台不传任何参数 */
if
(
null
==
wi
)
{
wi
=
new
Wi
();
if
(
StringUtils
.
isBlank
(
wi
.
getRecordId
())){
throw
new
ExceptionEntityFieldEmpty
(
ImportRecord
.
class
,
"id"
);
}
logger
.
debug
(
"wi:{}"
,
wi
);
Wo
wo
=
new
Wo
();
wo
.
setId
(
""
);
result
.
setData
(
wo
);
return
result
;
ImportRecord
record
=
business
.
pick
(
wi
.
getRecordId
(),
ImportRecord
.
class
);
if
(
record
!=
null
){
throw
new
ExceptionEntityExist
(
wi
.
getRecordId
(),
record
);
}
emc
.
beginTransaction
(
ImportRecord
.
class
);
record
=
new
ImportRecord
();
record
.
setId
(
wi
.
getRecordId
());
record
.
setName
(
model
.
getName
());
record
.
setModelId
(
model
.
getId
());
record
.
setQuery
(
model
.
getQuery
());
record
.
setCount
(
wi
.
getData
().
getAsJsonArray
().
size
());
record
.
setData
(
wi
.
getData
().
toString
());
record
.
setStatus
(
ImportRecord
.
STATUS_WAIT
);
emc
.
persist
(
record
,
CheckPersistType
.
all
);
emc
.
commit
();
wo
.
setId
(
wi
.
getRecordId
());
}
try
{
ThisApplication
.
queueImportData
.
send
(
wo
.
getId
());
}
catch
(
Exception
e
)
{
logger
.
warn
(
"{}-数据导入处理放入队列异常:{}"
,
wo
.
getId
(),
e
.
getMessage
());
}
result
.
setData
(
wo
);
return
result
;
}
public
static
class
Wo
extends
WoId
{
...
...
@@ -59,29 +79,18 @@ class ActionExecute extends BaseAction {
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"标题."
)
private
String
title
;
@FieldDescribe
(
"创建人员身份."
)
private
String
identity
;
@FieldDescribe
(
"导入记录ID."
)
private
String
recordId
;
@FieldDescribe
(
"数据."
)
private
JsonElement
data
;
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getIdentity
()
{
return
identity
;
public
String
getRecordId
()
{
return
recordId
;
}
public
void
set
Identity
(
String
identity
)
{
this
.
identity
=
identity
;
public
void
set
RecordId
(
String
recordId
)
{
this
.
recordId
=
recordId
;
}
public
JsonElement
getData
()
{
...
...
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionGetRecord.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.assemble.surface.jaxrs.importmodel
;
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.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
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.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.query.assemble.surface.Business
;
import
com.x.query.core.entity.ImportRecord
;
class
ActionGetRecord
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionGetRecord
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
recordId
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
ImportRecord
record
=
business
.
pick
(
recordId
,
ImportRecord
.
class
);
if
(
record
!=
null
){
throw
new
ExceptionEntityNotExist
(
recordId
,
ImportRecord
.
class
);
}
Wo
wo
=
Wo
.
copier
.
copy
(
record
);
result
.
setData
(
wo
);
return
result
;
}
}
public
static
class
Wo
extends
ImportRecord
{
/** 不输出data数据,单独处理 */
static
WrapCopier
<
ImportRecord
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
ImportRecord
.
class
,
Wo
.
class
,
null
,
ListTools
.
toList
(
JpaObject
.
FieldsInvisible
));
}
}
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionGetRecordStatus.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.assemble.surface.jaxrs.importmodel
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.query.assemble.surface.Business
;
import
com.x.query.core.entity.ImportRecord
;
import
com.x.query.core.entity.ImportRecordItem
;
class
ActionGetRecordStatus
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionGetRecordStatus
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
recordId
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
ImportRecord
record
=
business
.
pick
(
recordId
,
ImportRecord
.
class
);
if
(
record
!=
null
){
throw
new
ExceptionEntityNotExist
(
recordId
,
ImportRecord
.
class
);
}
Wo
wo
=
new
Wo
();
wo
.
setCount
(
record
.
getCount
());
wo
.
setStatus
(
record
.
getStatus
());
Long
executeCount
=
emc
.
countEqual
(
ImportRecordItem
.
class
,
ImportRecordItem
.
recordId_FIELDNAME
,
record
.
getId
());
wo
.
setExecuteCount
(
executeCount
);
result
.
setData
(
wo
);
return
result
;
}
}
public
static
class
Wo
extends
GsonPropertyObject
{
@FieldDescribe
(
"当前状态."
)
private
String
status
;
@FieldDescribe
(
"总数量."
)
private
Integer
count
;
@FieldDescribe
(
"已导入数量."
)
private
Long
executeCount
;
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
Integer
getCount
()
{
return
count
;
}
public
void
setCount
(
Integer
count
)
{
this
.
count
=
count
;
}
public
Long
getExecuteCount
()
{
return
executeCount
;
}
public
void
setExecuteCount
(
Long
executeCount
)
{
this
.
executeCount
=
executeCount
;
}
}
}
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionRecordItemListPaging.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.assemble.surface.jaxrs.importmodel
;
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.JpaObject
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.query.core.entity.ImportRecordItem
;
import
com.x.query.core.entity.ImportRecordItem_
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Tuple
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.List
;
class
ActionRecordItemListPaging
extends
BaseAction
{
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
,
Integer
page
,
Integer
size
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
EntityManager
em
=
emc
.
get
(
ImportRecordItem
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
Root
<
ImportRecordItem
>
root
=
cq
.
from
(
ImportRecordItem
.
class
);
Predicate
p
=
cb
.
conjunction
();
if
(
StringUtils
.
isNotBlank
(
wi
.
getRecordId
())){
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
ImportRecordItem_
.
recordId
),
wi
.
getRecordId
()));
}
if
(
StringUtils
.
isNotBlank
(
wi
.
getStatus
())){
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
ImportRecordItem_
.
status
),
wi
.
getStatus
()));
}
List
<
Wo
>
wos
=
emc
.
fetchDescPaging
(
ImportRecordItem
.
class
,
Wo
.
copier
,
p
,
page
,
size
,
ImportRecordItem
.
sequence_FIELDNAME
);
result
.
setData
(
wos
);
result
.
setCount
(
emc
.
count
(
ImportRecordItem
.
class
,
p
));
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
private
static
final
long
serialVersionUID
=
-
907555682909071665L
;
@FieldDescribe
(
"导入记录ID."
)
private
String
recordId
;
@FieldDescribe
(
"状态:导入成功|导入失败."
)
private
String
status
;
public
String
getRecordId
()
{
return
recordId
;
}
public
void
setRecordId
(
String
recordId
)
{
this
.
recordId
=
recordId
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
}
public
static
class
Wo
extends
ImportRecordItem
{
private
static
final
long
serialVersionUID
=
-
7382962683340732228L
;
static
WrapCopier
<
ImportRecordItem
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
ImportRecordItem
.
class
,
Wo
.
class
,
null
,
ListTools
.
toList
(
JpaObject
.
FieldsInvisible
,
ImportRecordItem
.
data_FIELDNAME
));
}
}
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ActionRecordListPaging.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.assemble.surface.jaxrs.importmodel
;
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.JpaObject
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.query.core.entity.ImportRecord
;
import
com.x.query.core.entity.ImportRecord_
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Tuple
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.List
;
class
ActionRecordListPaging
extends
BaseAction
{
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
,
Integer
page
,
Integer
size
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
EntityManager
em
=
emc
.
get
(
ImportRecord
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
Root
<
ImportRecord
>
root
=
cq
.
from
(
ImportRecord
.
class
);
Predicate
p
=
cb
.
conjunction
();
if
(
StringUtils
.
isNotBlank
(
wi
.
getModelId
())){
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
ImportRecord_
.
modelId
),
wi
.
getModelId
()));
}
if
(
StringUtils
.
isNotBlank
(
wi
.
getStatus
())){
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
ImportRecord_
.
status
),
wi
.
getStatus
()));
}
List
<
Wo
>
wos
=
emc
.
fetchDescPaging
(
ImportRecord
.
class
,
Wo
.
copier
,
p
,
page
,
size
,
ImportRecord
.
sequence_FIELDNAME
);
result
.
setData
(
wos
);
result
.
setCount
(
emc
.
count
(
ImportRecord
.
class
,
p
));
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
private
static
final
long
serialVersionUID
=
-
5861772273940394221L
;
@FieldDescribe
(
"导入模型ID."
)
private
String
modelId
;
@FieldDescribe
(
"状态:待导入|导入中|导入成功|部分成功|导入失败."
)
private
String
status
;
public
String
getModelId
()
{
return
modelId
;
}
public
void
setModelId
(
String
modelId
)
{
this
.
modelId
=
modelId
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
}
public
static
class
Wo
extends
ImportRecord
{
private
static
final
long
serialVersionUID
=
56729158952414491L
;
static
WrapCopier
<
ImportRecord
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
ImportRecord
.
class
,
Wo
.
class
,
null
,
ListTools
.
toList
(
JpaObject
.
FieldsInvisible
,
ImportRecord
.
data_FIELDNAME
));
}
}
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/importmodel/ImportModelAction.java
浏览文件 @
5797ff7f
...
...
@@ -63,7 +63,7 @@ public class ImportModelAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"获取
统计内容
."
,
action
=
ActionGet
.
class
)
@JaxrsMethodDescribe
(
value
=
"获取
导入模型
."
,
action
=
ActionGet
.
class
)
@GET
@Path
(
"{id}"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
...
...
@@ -81,13 +81,49 @@ public class ImportModelAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"获取导入记录."
,
action
=
ActionGetRecord
.
class
)
@GET
@Path
(
"/record/{recordId}"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
getRecord
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"导入记录标识"
)
@PathParam
(
"recordId"
)
String
recordId
)
{
ActionResult
<
ActionGetRecord
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionGetRecord
().
execute
(
effectivePerson
,
recordId
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"获取导入记录的执行状态."
,
action
=
ActionGetRecordStatus
.
class
)
@GET
@Path
(
"/record/{recordId}/status"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
getRecordStatus
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"导入记录标识"
)
@PathParam
(
"recordId"
)
String
recordId
)
{
ActionResult
<
ActionGetRecordStatus
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionGetRecordStatus
().
execute
(
effectivePerson
,
recordId
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"执行数据导入"
,
action
=
ActionExecute
.
class
)
@POST
@Path
(
"{id}/execute"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
execute
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"
视图
标识"
)
@PathParam
(
"id"
)
String
id
,
JsonElement
jsonElement
)
{
@JaxrsParameterDescribe
(
"
导入模型
标识"
)
@PathParam
(
"id"
)
String
id
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionExecute
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
...
...
@@ -99,4 +135,42 @@ public class ImportModelAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"导入记录分页查询."
,
action
=
ActionRecordListPaging
.
class
)
@POST
@Path
(
"list/record/paging/{page}/size/{size}"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
recordListPaging
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"分页"
)
@PathParam
(
"page"
)
Integer
page
,
@JaxrsParameterDescribe
(
"每页数量"
)
@PathParam
(
"size"
)
Integer
size
,
JsonElement
jsonElement
)
{
ActionResult
<
List
<
ActionRecordListPaging
.
Wo
>>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionRecordListPaging
().
execute
(
effectivePerson
,
page
,
size
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getDefaultActionResultResponse
(
result
));
}
@JaxrsMethodDescribe
(
value
=
"导入记录明细分页查询."
,
action
=
ActionRecordItemListPaging
.
class
)
@POST
@Path
(
"list/record/item/paging/{page}/size/{size}"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
recordItemListPaging
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"分页"
)
@PathParam
(
"page"
)
Integer
page
,
@JaxrsParameterDescribe
(
"每页数量"
)
@PathParam
(
"size"
)
Integer
size
,
JsonElement
jsonElement
)
{
ActionResult
<
List
<
ActionRecordItemListPaging
.
Wo
>>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionRecordItemListPaging
().
execute
(
effectivePerson
,
page
,
size
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getDefaultActionResultResponse
(
result
));
}
}
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/queue/QueueImportData.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.assemble.surface.queue
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
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.CheckPersistType
;
import
com.x.base.core.entity.dynamic.DynamicEntity
;
import
com.x.base.core.project.Applications
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.gson.XGsonBuilder
;
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.queue.AbstractQueue
;
import
com.x.base.core.project.x_cms_assemble_control
;
import
com.x.base.core.project.x_hotpic_assemble_control
;
import
com.x.base.core.project.x_processplatform_assemble_surface
;
import
com.x.cms.core.entity.CategoryInfo
;
import
com.x.processplatform.core.entity.content.WorkLog
;
import
com.x.processplatform.core.entity.element.Process
;
import
com.x.query.assemble.surface.Business
;
import
com.x.query.assemble.surface.ThisApplication
;
import
com.x.query.core.entity.ImportModel
;
import
com.x.query.core.entity.ImportRecord
;
import
com.x.query.core.entity.ImportRecordItem
;
import
com.x.query.core.entity.schema.Table
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 数据模板数据导入
*
*/
public
class
QueueImportData
extends
AbstractQueue
<
String
>
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
QueueImportData
.
class
);
private
static
Gson
gson
=
XGsonBuilder
.
instance
();
public
static
final
String
PROCESS_STATUS_DRAFT
=
"draft"
;
public
void
execute
(
String
recordId
)
{
logger
.
info
(
"开始数据模板数据导入:{}"
,
recordId
);
try
{
ImportRecord
record
=
null
;
ImportModel
model
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
record
=
emc
.
find
(
recordId
,
ImportRecord
.
class
);
if
(
record
==
null
){
logger
.
warn
(
"导入记录不存在:{}"
,
recordId
);
return
;
}
if
(
record
.
getStatus
().
equals
(
ImportRecord
.
STATUS_PROCESSING
)){
logger
.
warn
(
"导入记录正在导入:{}"
,
recordId
);
return
;
}
model
=
emc
.
find
(
record
.
getModelId
(),
ImportModel
.
class
);
if
(
model
==
null
){
logger
.
warn
(
"导入记录对应的导入模型不存在:{}"
,
record
.
getModelId
());
return
;
}
emc
.
beginTransaction
(
ImportRecord
.
class
);
record
.
setStatus
(
ImportRecord
.
STATUS_PROCESSING
);
emc
.
commit
();
}
try
{
switch
(
model
.
getType
())
{
case
ImportModel
.
TYPE_CMS
:
importCms
(
record
,
model
);
break
;
case
ImportModel
.
TYPE_DYNAMIC_TABLE
:
importDynamicTable
(
record
,
model
);
break
;
case
ImportModel
.
TYPE_PROCESSPLATFORM
:
importProcessPlatform
(
record
,
model
);
break
;
}
}
catch
(
Exception
e
)
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
record
=
emc
.
find
(
recordId
,
ImportRecord
.
class
);
emc
.
beginTransaction
(
ImportRecord
.
class
);
record
.
setStatus
(
ImportRecord
.
STATUS_FAILED
);
emc
.
commit
();
}
logger
.
warn
(
"数据模板数据导入异常:{}"
,
recordId
);
logger
.
error
(
e
);
}
}
catch
(
Exception
e
)
{
logger
.
warn
(
"数据模板数据导入异常:{}"
,
recordId
);
logger
.
error
(
e
);
}
logger
.
info
(
"完成数据模板数据导入:{}"
,
recordId
);
}
public
void
importCms
(
final
ImportRecord
record
,
final
ImportModel
model
)
throws
Exception
{
JsonElement
jsonElement
=
gson
.
fromJson
(
record
.
getData
(),
JsonElement
.
class
);
JsonObject
jsonObject
=
gson
.
fromJson
(
model
.
getData
(),
JsonObject
.
class
);
String
categoryId
=
jsonObject
.
getAsJsonObject
(
"category"
).
getAsJsonObject
(
"id"
).
getAsString
();
String
documentType
=
jsonObject
.
getAsJsonObject
(
"documentType"
).
getAsString
();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
CategoryInfo
categoryInfo
=
emc
.
flag
(
categoryId
,
CategoryInfo
.
class
);
if
(
null
==
categoryInfo
)
{
throw
new
ExceptionEntityNotExist
(
categoryId
,
CategoryInfo
.
class
);
}
}
final
List
<
ImportRecordItem
>
itemList
=
new
ArrayList
<>();
jsonElement
.
getAsJsonArray
().
forEach
(
o
->
{
JsonObject
document
=
o
.
getAsJsonObject
();
document
.
addProperty
(
"categoryId"
,
categoryId
);
document
.
addProperty
(
"documentType"
,
documentType
);
document
.
addProperty
(
"docStatus"
,
"published"
);
document
.
addProperty
(
"isNotice"
,
false
);
String
title
=
document
.
getAsJsonObject
(
"title"
).
getAsString
();
ImportRecordItem
item
=
new
ImportRecordItem
();
item
.
setDocTitle
(
title
);
item
.
setDocType
(
model
.
getType
());
item
.
setRecordId
(
record
.
getId
());
item
.
setModelId
(
record
.
getModelId
());
item
.
setQuery
(
record
.
getQuery
());
item
.
setData
(
o
.
toString
());
try
{
WoId
woId
=
ThisApplication
.
context
().
applications
().
putQuery
(
x_cms_assemble_control
.
class
,
Applications
.
joinQueryUri
(
"document"
,
"publish"
,
"content"
),
document
).
getData
(
WoId
.
class
);
item
.
setDocId
(
woId
.
getId
());
item
.
setStatus
(
ImportRecordItem
.
STATUS_SUCCESS
);
}
catch
(
Exception
e
)
{
item
.
setStatus
(
ImportRecordItem
.
STATUS_FAILED
);
item
.
setDistribution
(
e
.
getMessage
());
}
itemList
.
add
(
item
);
});
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ImportRecord
ir
=
emc
.
find
(
record
.
getId
(),
ImportRecord
.
class
);
boolean
hasSuccess
=
false
;
boolean
hasFailed
=
false
;
emc
.
beginTransaction
(
ImportRecord
.
class
);
emc
.
beginTransaction
(
ImportRecordItem
.
class
);
for
(
ImportRecordItem
o
:
itemList
)
{
if
(
ImportRecordItem
.
STATUS_FAILED
.
equals
(
o
.
getStatus
())){
hasFailed
=
true
;
}
else
{
hasSuccess
=
true
;
}
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
String
status
=
ImportRecord
.
STATUS_SUCCESS
;
if
(
hasFailed
){
if
(
hasSuccess
){
status
=
ImportRecord
.
STATUS_PART_SUCCESS
;
}
else
{
status
=
ImportRecord
.
STATUS_FAILED
;
}
}
ir
.
setStatus
(
status
);
emc
.
commit
();
}
}
public
void
importDynamicTable
(
ImportRecord
record
,
ImportModel
model
)
throws
Exception
{
JsonElement
jsonElement
=
gson
.
fromJson
(
record
.
getData
(),
JsonElement
.
class
);
JsonObject
jsonObject
=
gson
.
fromJson
(
model
.
getData
(),
JsonObject
.
class
);
String
tableId
=
jsonObject
.
getAsJsonObject
(
"dynamicTable"
).
getAsJsonObject
(
"id"
).
getAsString
();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ImportRecord
ir
=
emc
.
find
(
record
.
getId
(),
ImportRecord
.
class
);
Table
table
=
emc
.
flag
(
tableId
,
Table
.
class
);
if
(
null
==
table
)
{
throw
new
ExceptionEntityNotExist
(
tableId
,
Table
.
class
);
}
DynamicEntity
dynamicEntity
=
new
DynamicEntity
(
table
.
getName
());
@SuppressWarnings
(
"unchecked"
)
Class
<?
extends
JpaObject
>
cls
=
(
Class
<
JpaObject
>)
Class
.
forName
(
dynamicEntity
.
className
());
List
<
Object
>
os
=
new
ArrayList
<>();
if
(
jsonElement
.
isJsonArray
())
{
jsonElement
.
getAsJsonArray
().
forEach
(
o
->
{
os
.
add
(
gson
.
fromJson
(
o
,
cls
));
});
}
else
if
(
jsonElement
.
isJsonObject
())
{
os
.
add
(
gson
.
fromJson
(
jsonElement
,
cls
));
}
emc
.
beginTransaction
(
ImportRecord
.
class
);
emc
.
beginTransaction
(
cls
);
for
(
Object
o
:
os
)
{
emc
.
persist
((
JpaObject
)
o
,
CheckPersistType
.
all
);
}
ir
.
setStatus
(
ImportRecord
.
STATUS_SUCCESS
);
emc
.
commit
();
}
}
public
void
importProcessPlatform
(
ImportRecord
record
,
ImportModel
model
)
throws
Exception
{
JsonElement
jsonElement
=
gson
.
fromJson
(
record
.
getData
(),
JsonElement
.
class
);
JsonObject
jsonObject
=
gson
.
fromJson
(
model
.
getData
(),
JsonObject
.
class
);
String
processId
=
jsonObject
.
getAsJsonObject
(
"process"
).
getAsJsonObject
(
"id"
).
getAsString
();
String
processStatus
=
jsonObject
.
getAsJsonObject
(
"processStatus"
).
getAsString
();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Process
process
=
emc
.
flag
(
processId
,
Process
.
class
);
if
(
null
==
process
)
{
throw
new
ExceptionEntityNotExist
(
processId
,
Process
.
class
);
}
}
final
List
<
ImportRecordItem
>
itemList
=
new
ArrayList
<>();
jsonElement
.
getAsJsonArray
().
forEach
(
o
->
{
JsonObject
document
=
o
.
getAsJsonObject
();
String
title
=
document
.
getAsJsonObject
(
"title"
).
getAsString
();
ImportRecordItem
item
=
new
ImportRecordItem
();
item
.
setDocTitle
(
title
);
item
.
setDocType
(
model
.
getType
());
item
.
setRecordId
(
record
.
getId
());
item
.
setModelId
(
record
.
getModelId
());
item
.
setQuery
(
record
.
getQuery
());
item
.
setData
(
o
.
toString
());
try
{
if
(
PROCESS_STATUS_DRAFT
.
equals
(
processStatus
))
{
List
<
WorkLog
>
workLogList
=
ThisApplication
.
context
().
applications
().
postQuery
(
x_processplatform_assemble_surface
.
class
,
Applications
.
joinQueryUri
(
"work"
,
"process"
,
processId
),
document
).
getDataAsList
(
WorkLog
.
class
);
item
.
setDocId
(
workLogList
.
get
(
0
).
getWork
());
item
.
setStatus
(
ImportRecordItem
.
STATUS_SUCCESS
);
}
else
{
WoId
woId
=
ThisApplication
.
context
().
applications
().
putQuery
(
x_processplatform_assemble_surface
.
class
,
Applications
.
joinQueryUri
(
"workcompleted"
,
"process"
,
processId
),
document
).
getData
(
WoId
.
class
);
item
.
setDocId
(
woId
.
getId
());
item
.
setStatus
(
ImportRecordItem
.
STATUS_SUCCESS
);
}
}
catch
(
Exception
e
)
{
item
.
setStatus
(
ImportRecordItem
.
STATUS_FAILED
);
item
.
setDistribution
(
e
.
getMessage
());
}
itemList
.
add
(
item
);
});
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ImportRecord
ir
=
emc
.
find
(
record
.
getId
(),
ImportRecord
.
class
);
boolean
hasSuccess
=
false
;
boolean
hasFailed
=
false
;
emc
.
beginTransaction
(
ImportRecord
.
class
);
emc
.
beginTransaction
(
ImportRecordItem
.
class
);
for
(
ImportRecordItem
o
:
itemList
)
{
if
(
ImportRecordItem
.
STATUS_FAILED
.
equals
(
o
.
getStatus
())){
hasFailed
=
true
;
}
else
{
hasSuccess
=
true
;
}
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
String
status
=
ImportRecord
.
STATUS_SUCCESS
;
if
(
hasFailed
){
if
(
hasSuccess
){
status
=
ImportRecord
.
STATUS_PART_SUCCESS
;
}
else
{
status
=
ImportRecord
.
STATUS_FAILED
;
}
}
ir
.
setStatus
(
status
);
emc
.
commit
();
}
}
}
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/ImportModel.java
浏览文件 @
5797ff7f
...
...
@@ -15,16 +15,16 @@ import java.util.List;
@Entity
@ContainerEntity
(
dumpSize
=
10
,
type
=
ContainerEntity
.
Type
.
content
,
reference
=
ContainerEntity
.
Reference
.
strong
)
@Table
(
name
=
PersistenceProperties
.
ImportModel
.
table
,
uniqueConstraints
=
{
@UniqueConstraint
(
name
=
PersistenceProperties
.
ImportModel
.
table
+
JpaObject
.
IndexNameMiddle
@Table
(
name
=
PersistenceProperties
.
Import
.
Import
Model
.
table
,
uniqueConstraints
=
{
@UniqueConstraint
(
name
=
PersistenceProperties
.
Import
.
Import
Model
.
table
+
JpaObject
.
IndexNameMiddle
+
JpaObject
.
DefaultUniqueConstraintSuffix
,
columnNames
=
{
JpaObject
.
IDCOLUMN
,
JpaObject
.
CREATETIMECOLUMN
,
JpaObject
.
UPDATETIMECOLUMN
,
JpaObject
.
SEQUENCECOLUMN
})
})
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
class
ImportModel
extends
SliceJpaObject
{
private
static
final
long
serialVersionUID
=
-
7520516033901189347
L
;
private
static
final
long
serialVersionUID
=
8585967903130343838
L
;
private
static
final
String
TABLE
=
PersistenceProperties
.
ImportModel
.
table
;
private
static
final
String
TABLE
=
PersistenceProperties
.
Import
.
Import
Model
.
table
;
public
static
final
Integer
MAX_COUNT
=
5000
;
...
...
@@ -128,9 +128,9 @@ public class ImportModel extends SliceJpaObject {
@CheckPersist
(
allowEmpty
=
true
)
private
String
code
;
public
static
final
String
enable
Check_FIELDNAME
=
"enableCheck
"
;
public
static
final
String
enable
Valid_FIELDNAME
=
"enableValid
"
;
@FieldDescribe
(
"是否启用校验."
)
@Column
(
name
=
ColumnNamePrefix
+
enable
Check
_FIELDNAME
)
@Column
(
name
=
ColumnNamePrefix
+
enable
Valid
_FIELDNAME
)
private
Boolean
enableValid
;
public
static
final
String
type_FIELDNAME
=
"type"
;
...
...
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/ImportRecord.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.core.entity
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.SliceJpaObject
;
import
com.x.base.core.entity.annotation.*
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
org.apache.openjpa.persistence.PersistentCollection
;
import
org.apache.openjpa.persistence.jdbc.ContainerTable
;
import
org.apache.openjpa.persistence.jdbc.ElementColumn
;
import
org.apache.openjpa.persistence.jdbc.ElementIndex
;
import
org.apache.openjpa.persistence.jdbc.Index
;
import
javax.persistence.*
;
import
java.util.List
;
@Entity
@ContainerEntity
(
dumpSize
=
10
,
type
=
ContainerEntity
.
Type
.
content
,
reference
=
ContainerEntity
.
Reference
.
soft
)
@Table
(
name
=
PersistenceProperties
.
Import
.
ImportRecord
.
table
,
uniqueConstraints
=
{
@UniqueConstraint
(
name
=
PersistenceProperties
.
Import
.
ImportRecord
.
table
+
JpaObject
.
IndexNameMiddle
+
JpaObject
.
DefaultUniqueConstraintSuffix
,
columnNames
=
{
JpaObject
.
IDCOLUMN
,
JpaObject
.
CREATETIMECOLUMN
,
JpaObject
.
UPDATETIMECOLUMN
,
JpaObject
.
SEQUENCECOLUMN
})
})
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
class
ImportRecord
extends
SliceJpaObject
{
private
static
final
long
serialVersionUID
=
3586573657619339181L
;
private
static
final
String
TABLE
=
PersistenceProperties
.
Import
.
ImportRecord
.
table
;
public
static
final
String
STATUS_WAIT
=
"待导入"
;
public
static
final
String
STATUS_PROCESSING
=
"导入中"
;
public
static
final
String
STATUS_SUCCESS
=
"导入成功"
;
public
static
final
String
STATUS_PART_SUCCESS
=
"部分成功"
;
public
static
final
String
STATUS_FAILED
=
"导入失败"
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
@FieldDescribe
(
"数据库主键,自动生成."
)
@Id
@Column
(
length
=
length_id
,
name
=
ColumnNamePrefix
+
id_FIELDNAME
)
@CheckRemove
(
citationNotExists
=
/* 已经没有Stat使用View了 */
@CitationNotExist
(
type
=
Stat
.
class
,
fields
=
Stat
.
view_FIELDNAME
))
private
String
id
=
createId
();
/* 以上为 JpaObject 默认字段 */
public
void
onPersist
()
throws
Exception
{
}
public
static
final
String
name_FIELDNAME
=
"name"
;
@FieldDescribe
(
"导入模型名称."
)
@Column
(
length
=
length_255B
,
name
=
ColumnNamePrefix
+
name_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
,
simplyString
=
false
)
private
String
name
;
public
static
final
String
modelId_FIELDNAME
=
"modelId"
;
@FieldDescribe
(
"所属导入模型."
)
@Column
(
length
=
JpaObject
.
length_id
,
name
=
ColumnNamePrefix
+
modelId_FIELDNAME
)
@Index
(
name
=
TABLE
+
ColumnNamePrefix
+
modelId_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
,
citationExists
=
{
@CitationExist
(
type
=
ImportModel
.
class
)
})
private
String
modelId
;
public
static
final
String
query_FIELDNAME
=
"query"
;
@FieldDescribe
(
"所属查询."
)
@Column
(
length
=
JpaObject
.
length_id
,
name
=
ColumnNamePrefix
+
query_FIELDNAME
)
@Index
(
name
=
TABLE
+
ColumnNamePrefix
+
query_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
,
citationExists
=
{
@CitationExist
(
type
=
Query
.
class
)
})
private
String
query
;
public
static
final
String
status_FIELDNAME
=
"status"
;
@FieldDescribe
(
"状态."
)
@Column
(
length
=
length_255B
,
name
=
ColumnNamePrefix
+
status_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
)
private
String
status
;
public
static
final
String
count_FIELDNAME
=
"count"
;
@FieldDescribe
(
"导入数量."
)
@Column
(
name
=
ColumnNamePrefix
+
count_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
)
private
Integer
count
;
public
static
final
String
data_FIELDNAME
=
"data"
;
@FieldDescribe
(
"导入数据."
)
@Lob
@Basic
(
fetch
=
FetchType
.
EAGER
)
@Column
(
length
=
JpaObject
.
length_10M
,
name
=
ColumnNamePrefix
+
data_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
String
data
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getQuery
()
{
return
query
;
}
public
void
setQuery
(
String
query
)
{
this
.
query
=
query
;
}
public
String
getModelId
()
{
return
modelId
;
}
public
void
setModelId
(
String
modelId
)
{
this
.
modelId
=
modelId
;
}
public
String
getData
()
{
return
data
;
}
public
void
setData
(
String
data
)
{
this
.
data
=
data
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
Integer
getCount
()
{
return
count
;
}
public
void
setCount
(
Integer
count
)
{
this
.
count
=
count
;
}
}
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/ImportRecordItem.java
0 → 100644
浏览文件 @
5797ff7f
package
com.x.query.core.entity
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.SliceJpaObject
;
import
com.x.base.core.entity.annotation.*
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
org.apache.openjpa.persistence.jdbc.Index
;
import
javax.persistence.*
;
@Entity
@ContainerEntity
(
dumpSize
=
10
,
type
=
ContainerEntity
.
Type
.
content
,
reference
=
ContainerEntity
.
Reference
.
soft
)
@Table
(
name
=
PersistenceProperties
.
Import
.
ImportRecordItem
.
table
,
uniqueConstraints
=
{
@UniqueConstraint
(
name
=
PersistenceProperties
.
Import
.
ImportRecordItem
.
table
+
JpaObject
.
IndexNameMiddle
+
JpaObject
.
DefaultUniqueConstraintSuffix
,
columnNames
=
{
JpaObject
.
IDCOLUMN
,
JpaObject
.
CREATETIMECOLUMN
,
JpaObject
.
UPDATETIMECOLUMN
,
JpaObject
.
SEQUENCECOLUMN
})
})
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
class
ImportRecordItem
extends
SliceJpaObject
{
private
static
final
long
serialVersionUID
=
7214636398640246193L
;
private
static
final
String
TABLE
=
PersistenceProperties
.
Import
.
ImportRecordItem
.
table
;
public
static
final
String
STATUS_SUCCESS
=
"导入成功"
;
public
static
final
String
STATUS_FAILED
=
"导入失败"
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
@FieldDescribe
(
"数据库主键,自动生成."
)
@Id
@Column
(
length
=
length_id
,
name
=
ColumnNamePrefix
+
id_FIELDNAME
)
@CheckRemove
(
citationNotExists
=
/* 已经没有Stat使用View了 */
@CitationNotExist
(
type
=
Stat
.
class
,
fields
=
Stat
.
view_FIELDNAME
))
private
String
id
=
createId
();
/* 以上为 JpaObject 默认字段 */
public
void
onPersist
()
throws
Exception
{
}
public
static
final
String
docTitle_FIELDNAME
=
"docTitle"
;
@FieldDescribe
(
"导入文档标题."
)
@Column
(
length
=
length_255B
,
name
=
ColumnNamePrefix
+
docTitle_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
String
docTitle
;
public
static
final
String
docId_FIELDNAME
=
"docId"
;
@FieldDescribe
(
"导入文档ID."
)
@Column
(
length
=
JpaObject
.
length_id
,
name
=
ColumnNamePrefix
+
docId_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
String
docId
;
public
static
final
String
docType_FIELDNAME
=
"docType"
;
@FieldDescribe
(
"导入文档类型."
)
@Column
(
length
=
JpaObject
.
length_255B
,
name
=
ColumnNamePrefix
+
docType_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
String
docType
;
public
static
final
String
modelId_FIELDNAME
=
"modelId"
;
@FieldDescribe
(
"所属导入模型."
)
@Column
(
length
=
JpaObject
.
length_id
,
name
=
ColumnNamePrefix
+
modelId_FIELDNAME
)
@Index
(
name
=
TABLE
+
ColumnNamePrefix
+
modelId_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
)
private
String
modelId
;
public
static
final
String
recordId_FIELDNAME
=
"recordId"
;
@FieldDescribe
(
"所属导入记录."
)
@Column
(
length
=
JpaObject
.
length_id
,
name
=
ColumnNamePrefix
+
recordId_FIELDNAME
)
@Index
(
name
=
TABLE
+
ColumnNamePrefix
+
recordId_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
)
private
String
recordId
;
public
static
final
String
query_FIELDNAME
=
"query"
;
@FieldDescribe
(
"所属查询."
)
@Column
(
length
=
JpaObject
.
length_id
,
name
=
ColumnNamePrefix
+
query_FIELDNAME
)
@Index
(
name
=
TABLE
+
ColumnNamePrefix
+
query_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
)
private
String
query
;
public
static
final
String
status_FIELDNAME
=
"status"
;
@FieldDescribe
(
"状态."
)
@Column
(
length
=
length_255B
,
name
=
ColumnNamePrefix
+
status_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
false
)
private
String
status
;
public
static
final
String
distribution_FIELDNAME
=
"distribution"
;
@FieldDescribe
(
"导入结果描述."
)
@Lob
@Basic
(
fetch
=
FetchType
.
EAGER
)
@Column
(
length
=
JpaObject
.
length_4K
,
name
=
ColumnNamePrefix
+
distribution_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
String
distribution
;
public
static
final
String
data_FIELDNAME
=
"data"
;
@FieldDescribe
(
"导入数据."
)
@Lob
@Basic
(
fetch
=
FetchType
.
EAGER
)
@Column
(
length
=
JpaObject
.
length_10M
,
name
=
ColumnNamePrefix
+
data_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
String
data
;
public
String
getQuery
()
{
return
query
;
}
public
void
setQuery
(
String
query
)
{
this
.
query
=
query
;
}
public
String
getModelId
()
{
return
modelId
;
}
public
void
setModelId
(
String
modelId
)
{
this
.
modelId
=
modelId
;
}
public
String
getData
()
{
return
data
;
}
public
void
setData
(
String
data
)
{
this
.
data
=
data
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getDocTitle
()
{
return
docTitle
;
}
public
void
setDocTitle
(
String
docTitle
)
{
this
.
docTitle
=
docTitle
;
}
public
String
getDocId
()
{
return
docId
;
}
public
void
setDocId
(
String
docId
)
{
this
.
docId
=
docId
;
}
public
String
getDocType
()
{
return
docType
;
}
public
void
setDocType
(
String
docType
)
{
this
.
docType
=
docType
;
}
public
String
getRecordId
()
{
return
recordId
;
}
public
void
setRecordId
(
String
recordId
)
{
this
.
recordId
=
recordId
;
}
public
String
getDistribution
()
{
return
distribution
;
}
public
void
setDistribution
(
String
distribution
)
{
this
.
distribution
=
distribution
;
}
}
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/PersistenceProperties.java
浏览文件 @
5797ff7f
...
...
@@ -12,8 +12,16 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
public
static
final
String
table
=
"QRY_VIEW"
;
}
public
static
class
ImportModel
{
public
static
final
String
table
=
"QRY_IMPORT_MODEL"
;
public
static
class
Import
{
public
static
class
ImportModel
{
public
static
final
String
table
=
"QRY_IMPORT_MODEL"
;
}
public
static
class
ImportRecord
{
public
static
final
String
table
=
"QRY_IMPORT_RECORD"
;
}
public
static
class
ImportRecordItem
{
public
static
final
String
table
=
"QRY_IMPORT_RECORD_ITEM"
;
}
}
public
static
class
Stat
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录