Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
9c354f21
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,发现更多精彩内容 >>
提交
9c354f21
编写于
6月 17, 2021
作者:
O
o2null
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix/copier' into 'wrdp'
修正copier错误 See merge request o2oa/o2oa!4068
上级
234fa7a5
d3b25998
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
46 deletion
+38
-46
o2server/x_base_core_project/src/main/java/com/x/base/core/project/bean/WrapCopierFactory.java
.../java/com/x/base/core/project/bean/WrapCopierFactory.java
+5
-17
o2server/x_program_center/src/main/java/com/x/program/center/schedule/CollectMarket.java
...ain/java/com/x/program/center/schedule/CollectMarket.java
+33
-29
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/bean/WrapCopierFactory.java
浏览文件 @
9c354f21
...
...
@@ -58,13 +58,13 @@ public class WrapCopierFactory {
List
<
String
>
copyFieldNames
=
new
ArrayList
<>();
ListTools
.
includesExcludes
(
ListUtils
.
intersection
(
origFieldNames
,
destFieldNames
),
includes
,
excludes
)
.
stream
().
forEach
(
name
->
{
if
(
copya
ble
(
origClass
,
destClass
,
name
))
{
if
(
accessi
ble
(
origClass
,
destClass
,
name
))
{
copyFieldNames
.
add
(
name
);
}
});
List
<
String
>
eraseFieldNames
=
new
ArrayList
<>();
ListUtils
.
subtract
(
destFieldNames
,
copyFieldNames
).
stream
().
forEach
(
name
->
{
if
(
erasable
(
destClass
,
name
))
{
if
(
accessible
(
origClass
,
destClass
,
name
))
{
eraseFieldNames
.
add
(
name
);
}
});
...
...
@@ -76,7 +76,8 @@ public class WrapCopierFactory {
}
}
private
static
<
T
,
W
>
boolean
copyable
(
Class
<
T
>
origClass
,
Class
<
W
>
destClass
,
String
name
)
{
// 需要erase的属性也必须在orig中有,否则新增加的属性将直接被擦除
private
static
<
T
,
W
>
boolean
accessible
(
Class
<
T
>
origClass
,
Class
<
W
>
destClass
,
String
name
)
{
try
{
Field
origField
=
FieldUtils
.
getField
(
origClass
,
name
,
true
);
Field
destField
=
FieldUtils
.
getField
(
destClass
,
name
,
true
);
...
...
@@ -92,19 +93,6 @@ public class WrapCopierFactory {
return
false
;
}
private
static
<
W
>
boolean
erasable
(
Class
<
W
>
destClass
,
String
name
)
{
try
{
Field
destField
=
FieldUtils
.
getField
(
destClass
,
name
,
true
);
if
((
null
!=
destField
)
&&
(
null
!=
MethodUtils
.
getAccessibleMethod
(
destClass
,
getSetterName
(
destField
),
destField
.
getType
())))
{
return
true
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
public
static
<
T
,
W
>
WrapCopier
<
T
,
W
>
wi
(
Class
<
T
>
origClass
,
Class
<
W
>
destClass
,
List
<
String
>
includes
,
List
<
String
>
excludes
)
{
return
wi
(
origClass
,
destClass
,
includes
,
excludes
,
true
);
...
...
@@ -118,7 +106,7 @@ public class WrapCopierFactory {
List
<
String
>
copyFieldNames
=
new
ArrayList
<>();
ListTools
.
includesExcludes
(
ListUtils
.
intersection
(
origFieldNames
,
destFieldNames
),
includes
,
excludes
)
.
stream
().
forEach
(
name
->
{
if
(
copya
ble
(
origClass
,
destClass
,
name
))
{
if
(
accessi
ble
(
origClass
,
destClass
,
name
))
{
copyFieldNames
.
add
(
name
);
}
});
...
...
o2server/x_program_center/src/main/java/com/x/program/center/schedule/CollectMarket.java
浏览文件 @
9c354f21
...
...
@@ -44,63 +44,67 @@ public class CollectMarket extends BaseAction {
Business
business
=
new
Business
(
emc
);
String
token
=
business
.
loginCollect
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
logger
.
info
(
"start sync market data====="
);
logger
.
debug
(
"start sync market data====="
);
List
<
Wi
>
wiList
=
null
;
try
{
ActionResponse
response
=
ConnectionAction
.
get
(
Config
.
collect
().
url
(
Collect
.
ADDRESS_COLLECT_APPLICATION_LIST
),
ListTools
.
toList
(
new
NameValuePair
(
Collect
.
COLLECT_TOKEN
,
token
)));
ActionResponse
response
=
ConnectionAction
.
get
(
Config
.
collect
().
url
(
Collect
.
ADDRESS_COLLECT_APPLICATION_LIST
),
ListTools
.
toList
(
new
NameValuePair
(
Collect
.
COLLECT_TOKEN
,
token
)));
wiList
=
response
.
getDataAsList
(
Wi
.
class
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"connect o2cloud error:{}."
+
e
.
getMessage
());
}
if
(
wiList
!=
null
&&
!
wiList
.
isEmpty
())
{
logger
.
info
(
"wait sync market app size:{}"
,
wiList
.
size
());
if
(
wiList
!=
null
&&
!
wiList
.
isEmpty
())
{
logger
.
info
(
"wait sync market app size:{}"
,
wiList
.
size
());
emc
.
beginTransaction
(
Application
.
class
);
emc
.
beginTransaction
(
Attachment
.
class
);
List
<
Application
>
appList
=
emc
.
listAll
(
Application
.
class
);
Map
<
String
,
Application
>
appMap
=
new
HashMap
<>();
List
<
String
>
appIds
=
ListTools
.
extractField
(
wiList
,
JpaObject
.
id_FIELDNAME
,
String
.
class
,
true
,
true
);
for
(
Application
app
:
appList
){
if
(
appIds
.
contains
(
app
.
getId
())){
List
<
String
>
appIds
=
ListTools
.
extractField
(
wiList
,
JpaObject
.
id_FIELDNAME
,
String
.
class
,
true
,
true
);
for
(
Application
app
:
appList
)
{
if
(
appIds
.
contains
(
app
.
getId
()))
{
appMap
.
put
(
app
.
getId
(),
app
);
}
else
{
List
<
Attachment
>
attachments
=
emc
.
listEqual
(
Attachment
.
class
,
Attachment
.
application_FIELDNAME
,
app
.
getId
());
for
(
Attachment
att
:
attachments
){
}
else
{
List
<
Attachment
>
attachments
=
emc
.
listEqual
(
Attachment
.
class
,
Attachment
.
application_FIELDNAME
,
app
.
getId
());
for
(
Attachment
att
:
attachments
)
{
emc
.
remove
(
att
);
}
emc
.
remove
(
app
);
}
}
for
(
Wi
wi
:
wiList
)
{
for
(
Wi
wi
:
wiList
)
{
Application
app
=
appMap
.
get
(
wi
.
getId
());
if
(
app
!=
null
)
{
if
(
wi
.
getLastUpdateTime
().
compareTo
(
app
.
getLastUpdateTime
())
==
1
)
{
if
(
app
!=
null
)
{
if
(
wi
.
getLastUpdateTime
().
compareTo
(
app
.
getLastUpdateTime
())
==
1
)
{
Wi
.
copier
.
copy
(
wi
,
app
);
emc
.
persist
(
app
,
CheckPersistType
.
all
);
List
<
Attachment
>
attachments
=
emc
.
listEqual
(
Attachment
.
class
,
Attachment
.
application_FIELDNAME
,
app
.
getId
());
List
<
String
>
attIds
=
ListTools
.
extractField
(
wi
.
getAttList
(),
JpaObject
.
id_FIELDNAME
,
String
.
class
,
true
,
true
);
List
<
Attachment
>
attachments
=
emc
.
listEqual
(
Attachment
.
class
,
Attachment
.
application_FIELDNAME
,
app
.
getId
());
List
<
String
>
attIds
=
ListTools
.
extractField
(
wi
.
getAttList
(),
JpaObject
.
id_FIELDNAME
,
String
.
class
,
true
,
true
);
List
<
String
>
attIds2
=
new
ArrayList
<>();
for
(
Attachment
att
:
attachments
)
{
if
(
attIds
.
contains
(
att
.
getId
()))
{
for
(
Attachment
att
:
attachments
)
{
if
(
attIds
.
contains
(
att
.
getId
()))
{
attIds2
.
add
(
att
.
getId
());
}
else
{
}
else
{
emc
.
remove
(
att
);
}
}
if
(
wi
.
getAttList
()
!=
null
)
{
for
(
Attachment
att
:
wi
.
getAttList
()){
if
(!
attIds2
.
contains
(
att
.
getId
()))
{
if
(
wi
.
getAttList
()
!=
null
)
{
for
(
Attachment
att
:
wi
.
getAttList
())
{
if
(!
attIds2
.
contains
(
att
.
getId
()))
{
emc
.
persist
(
att
,
CheckPersistType
.
all
);
}
}
}
}
}
else
{
}
else
{
app
=
Wi
.
copier
.
copy
(
wi
);
emc
.
persist
(
app
,
CheckPersistType
.
all
);
if
(
wi
.
attList
!=
null
)
{
for
(
Attachment
att:
wi
.
attList
)
{
if
(
wi
.
attList
!=
null
)
{
for
(
Attachment
att
:
wi
.
attList
)
{
emc
.
persist
(
att
,
CheckPersistType
.
all
);
}
}
...
...
@@ -108,7 +112,7 @@ public class CollectMarket extends BaseAction {
}
emc
.
commit
();
}
logger
.
info
(
"end sync market data====="
);
logger
.
debug
(
"end sync market data====="
);
}
}
}
...
...
@@ -122,7 +126,8 @@ public class CollectMarket extends BaseAction {
public
static
class
Wi
extends
Application
{
static
WrapCopier
<
Wi
,
Application
>
copier
=
WrapCopierFactory
.
wo
(
Wi
.
class
,
Application
.
class
,
null
,
ListTools
.
toList
(
"attList"
));
static
WrapCopier
<
Wi
,
Application
>
copier
=
WrapCopierFactory
.
wo
(
Wi
.
class
,
Application
.
class
,
null
,
ListTools
.
toList
(
"attList"
));
private
List
<
Attachment
>
attList
=
new
ArrayList
<>();
...
...
@@ -135,5 +140,4 @@ public class CollectMarket extends BaseAction {
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录