Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzlite
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzlite
提交
a0387894
提交
a0387894
编写于
11月 22, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
自动填充完成
上级
da055f93
变更
6
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
163 行增加
和
60 行删除
+163
-60
DataObj.java
.../java/cn/ibizlab/core/lite/extensions/domain/DataObj.java
+16
-0
EntityObj.java
...ava/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
+37
-17
ModelObj.java
...java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
+35
-15
NestedArray.java
...a/cn/ibizlab/core/lite/extensions/domain/NestedArray.java
+6
-10
Property.java
.../java/cn/ibizlab/core/lite/extensions/model/Property.java
+44
-0
DbEntityService.java
...ibizlab/core/lite/extensions/service/DbEntityService.java
+25
-18
未找到文件。
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/DataObj.java
浏览文件 @
a0387894
...
...
@@ -178,6 +178,22 @@ public class DataObj<K,V> extends ConcurrentHashMap<K,V> {
}
}
}
else
if
(
targetEntity
instanceof
EntityObj
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
EntityObj
)
targetEntity
).
set
((
String
)
field
,
value
);
}
}
}
else
if
(
targetEntity
instanceof
ModelObj
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
ModelObj
)
targetEntity
).
set
((
String
)
field
,
value
);
}
}
}
else
if
(
targetEntity
instanceof
DataObj
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
浏览文件 @
a0387894
...
...
@@ -8,6 +8,9 @@ import com.alibaba.fastjson.annotation.JSONField;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.List
;
public
class
EntityObj
extends
DataObj
<
String
,
Object
>
{
...
...
@@ -22,12 +25,6 @@ public class EntityObj extends DataObj<String,Object> {
return
entityModel
;
}
public
EntityObj
setEntityModel
(
EntityModel
entityModel
)
{
this
.
entityModel
=
entityModel
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
DataModel
dataModel
;
...
...
@@ -35,18 +32,9 @@ public class EntityObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
DataModel
getDataModel
()
{
if
(
this
.
dataModel
==
null
&&
this
.
getProperty
()!=
null
)
this
.
dataModel
=
this
.
getProperty
().
getOwnerDataModel
();
return
dataModel
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityObj
setDataModel
(
DataModel
dataModel
)
{
this
.
dataModel
=
dataModel
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Property
property
;
...
...
@@ -65,7 +53,8 @@ public class EntityObj extends DataObj<String,Object> {
this
.
setDstSystemId
(
property
.
getSystem
());
if
(!
StringUtils
.
isEmpty
(
property
.
getPropertyEntity
()))
this
.
setMetaEntityName
(
property
.
getPropertyEntity
());
this
.
setEntityModel
(
property
.
getEntityModel
());
this
.
entityModel
=
property
.
getEntityModel
();
this
.
dataModel
=
property
.
getOwnerDataModel
();
}
this
.
property
=
property
;
return
this
;
...
...
@@ -117,5 +106,36 @@ public class EntityObj extends DataObj<String,Object> {
return
this
;
}
@Override
public
String
getRowKey
()
{
String
rowKey
=
super
.
getRowKey
();
if
(
StringUtils
.
isEmpty
(
rowKey
))
{
rowKey
=
this
.
getStringValue
(
this
.
getEntityModel
().
getKeyField
().
getColumnName
());
this
.
setRowKey
(
rowKey
);
}
return
rowKey
;
}
public
void
findModel
(
List
<
ModelObj
>
modelObjs
)
{
HashMap
<
String
,
ModelObj
>
tmps
=
new
HashMap
<
String
,
ModelObj
>();
modelObjs
.
forEach
(
obj
->
tmps
.
put
(
obj
.
getRowKey
(),
obj
));
this
.
getProperty
().
getPropertyMappings
().
forEach
(
mapping
->{
String
selfVal
=
this
.
getStringValue
(
mapping
.
getSelfPropertyColumn
());
modelObjs
.
forEach
(
modelObj
->{
String
parentVal
=
modelObj
.
getEntity
(
mapping
.
getJoinPropertyEntity
()).
getStringValue
(
mapping
.
getJoinPropertyColumn
());
if
((
StringUtils
.
isEmpty
(
parentVal
))||(!
parentVal
.
equals
(
selfVal
)))
tmps
.
remove
(
modelObj
.
getRowKey
());
});
});
if
(
tmps
.
size
()>
0
)
{
tmps
.
values
().
forEach
(
obj
->{
EntityObj
copy
=
this
.
copyTo
(
new
EntityObj
(),
true
).
setProperty
(
this
.
getProperty
());
obj
.
setEntity
(
this
.
getProperty
().
getPropertyName
(),
copy
);
});
}
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
浏览文件 @
a0387894
...
...
@@ -47,6 +47,8 @@ public class ModelObj extends DataObj<String,Object> {
@JSONField
(
serialize
=
false
)
public
ModelObj
setParent
(
ModelObj
parent
)
{
this
.
parent
=
parent
;
if
(
parent
!=
null
)
parent
.
getNested
(
this
.
getDataModel
().
getDataModelName
(),
false
).
add
(
this
);
return
this
;
}
...
...
@@ -63,7 +65,7 @@ public class ModelObj extends DataObj<String,Object> {
Property
property
=
this
.
getDataModel
().
getObjectProperty
(
name
);
if
(
property
!=
null
)
{
return
new
EntityObj
().
set
DataModel
(
this
.
getDataModel
()).
set
Property
(
property
).
setRowKey
(
this
.
getRowKey
());
return
new
EntityObj
().
setProperty
(
property
).
setRowKey
(
this
.
getRowKey
());
}
if
(
recursion
)
...
...
@@ -78,18 +80,23 @@ public class ModelObj extends DataObj<String,Object> {
}
}
return
new
EntityObj
().
setD
ataModel
(
this
.
getDataModel
()).
setD
stSystemId
(
this
.
getDataModel
().
getFactPorperty
().
getSystem
()).
setMetaEntityName
(
name
).
setRowKey
(
this
.
getRowKey
());
return
new
EntityObj
().
setDstSystemId
(
this
.
getDataModel
().
getFactPorperty
().
getSystem
()).
setMetaEntityName
(
name
).
setRowKey
(
this
.
getRowKey
());
}
public
ModelObj
setEntity
(
String
name
,
EntityObj
entityObj
)
{
if
(
entityObj
!=
null
)
{
if
(
entityObj
.
getModelObj
()==
null
)
entityObj
.
setModelObj
(
this
);
this
.
set
(
name
,
entityObj
);
}
return
this
;
}
public
ModelObj
setFactEntity
(
EntityObj
entityObj
)
{
this
.
set
(
this
.
getDataModel
().
getFactPorperty
().
getPropertyName
(),
entityObj
);
this
.
set
Entity
(
this
.
getDataModel
().
getFactPorperty
().
getPropertyName
(),
entityObj
);
return
this
;
}
...
...
@@ -109,11 +116,16 @@ public class ModelObj extends DataObj<String,Object> {
{
Object
list
=
this
.
get
(
name
);
if
(
list
!=
null
&&
list
instanceof
NestedArray
)
return
(
NestedArray
)
list
;
{
NestedArray
nestedArray
=(
NestedArray
)
list
;
if
(
nestedArray
.
getParent
()==
null
)
nestedArray
.
setParent
(
this
);
return
nestedArray
;
}
DataModel
model
=
this
.
getDataModel
().
getNestedDataModel
(
name
);
if
(
model
!=
null
)
return
new
NestedArray
().
set
DataModel
(
this
.
getDataModel
()).
set
Parent
(
this
);
return
new
NestedArray
().
setParent
(
this
);
if
(
recursion
)
{
...
...
@@ -137,7 +149,7 @@ public class ModelObj extends DataObj<String,Object> {
{
subarry
=
subarry
.
getSubNested
(
steps
.
get
(
i
));
if
(
subarry
.
size
()==
0
)
return
new
NestedArray
().
set
DataModel
(
this
.
getDataModel
()).
set
Parent
(
this
);
return
new
NestedArray
().
setParent
(
this
);
}
return
subarry
;
}
...
...
@@ -145,7 +157,7 @@ public class ModelObj extends DataObj<String,Object> {
}
}
return
new
NestedArray
().
set
DataModel
(
this
.
getDataModel
()).
set
Parent
(
this
);
return
new
NestedArray
().
setParent
(
this
);
}
...
...
@@ -167,13 +179,23 @@ public class ModelObj extends DataObj<String,Object> {
return
super
.
get
(
key
);
}
public
ModelObj
findParent
(
Collection
<
ModelObj
>
uplayerObjs
)
@Override
public
String
getRowKey
()
{
String
rowKey
=
super
.
getRowKey
();
if
(
StringUtils
.
isEmpty
(
rowKey
))
{
rowKey
=
this
.
getFactEntity
().
getRowKey
();
this
.
setRowKey
(
rowKey
);
}
return
rowKey
;
}
public
ModelObj
findParent
(
List
<
ModelObj
>
uplayerObjs
)
{
if
(
uplayerObjs
.
size
()==
1
)
{
ModelObj
parent
=
uplayerObjs
.
iterator
().
next
();
this
.
setParent
(
parent
);
parent
.
getNested
(
this
.
getDataModel
().
getDataModelName
(),
false
).
add
(
this
);
this
.
setParent
(
uplayerObjs
.
iterator
().
next
());
return
this
;
}
HashMap
<
String
,
ModelObj
>
tmps
=
new
HashMap
<
String
,
ModelObj
>();
...
...
@@ -188,9 +210,7 @@ public class ModelObj extends DataObj<String,Object> {
});
if
(
tmps
.
size
()==
1
)
{
ModelObj
parent
=
tmps
.
values
().
iterator
().
next
();
this
.
setParent
(
parent
);
parent
.
getNested
(
this
.
getDataModel
().
getDataModelName
(),
false
).
add
(
this
);
this
.
setParent
(
tmps
.
values
().
iterator
().
next
());
}
return
this
;
}
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/NestedArray.java
浏览文件 @
a0387894
...
...
@@ -18,13 +18,6 @@ public class NestedArray extends ArrayList<ModelObj> {
return
dataModel
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
NestedArray
setDataModel
(
DataModel
dataModel
)
{
this
.
dataModel
=
dataModel
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
ModelObj
parent
;
...
...
@@ -39,6 +32,8 @@ public class NestedArray extends ArrayList<ModelObj> {
@JSONField
(
serialize
=
false
)
public
NestedArray
setParent
(
ModelObj
parent
)
{
this
.
parent
=
parent
;
if
(
parent
!=
null
&&
this
.
getDataModel
()==
null
)
this
.
dataModel
=(
parent
.
getDataModel
());
return
this
;
}
...
...
@@ -48,11 +43,12 @@ public class NestedArray extends ArrayList<ModelObj> {
for
(
ModelObj
modelObj:
this
)
{
Object
list
=
modelObj
.
get
(
nam
e
);
if
(
list
!=
null
&&
list
instanceof
NestedArray
)
rt
.
addAll
(
(
NestedArray
)
list
);
NestedArray
list
=
modelObj
.
getNested
(
name
,
fals
e
);
if
(
list
!=
null
)
rt
.
addAll
(
list
);
}
return
rt
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/model/Property.java
浏览文件 @
a0387894
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
model
;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -13,7 +15,10 @@ import lombok.experimental.Accessors;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Set
;
@Getter
@Setter
...
...
@@ -100,4 +105,43 @@ public class Property {
return
entityModel
;
}
public
String
lookup
(
List
<
ModelObj
>
modelObjList
)
{
String
sql
=
""
;
Set
<
String
>
conds
=
new
LinkedHashSet
<>();
if
(
propertyMappings
.
size
()>
0
)
{
for
(
PropertyMapping
mapping:
propertyMappings
){
if
(!
StringUtils
.
isEmpty
(
sql
))
sql
+=
","
;
sql
+=
mapping
.
getSelfPropertyColumn
();
}
for
(
ModelObj
modelObj:
modelObjList
)
{
String
condItem
=
""
;
for
(
PropertyMapping
mapping:
propertyMappings
)
{
Object
val
=
modelObj
.
getEntity
(
mapping
.
getJoinPropertyEntity
()).
get
(
mapping
.
getJoinPropertyColumn
());
if
(
val
instanceof
String
)
val
=
"'"
+
val
.
toString
()+
"'"
;
if
(!
StringUtils
.
isEmpty
(
condItem
))
condItem
+=
","
;
condItem
+=
val
;
}
conds
.
add
(
"("
+
condItem
+
")"
);
}
}
String
cond
=
""
;
for
(
String
val:
conds
)
{
if
(!
StringUtils
.
isEmpty
(
cond
))
cond
+=
","
;
else
cond
+=
val
;
}
return
"("
+
sql
+
") in ("
+
cond
+
")"
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/DbEntityService.java
浏览文件 @
a0387894
...
...
@@ -6,6 +6,7 @@ import cn.ibizlab.core.lite.extensions.domain.FieldModel;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
import
cn.ibizlab.core.lite.extensions.filter.DbEntitySearchContext
;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.model.Property
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
cn.ibizlab.core.extensions.mapper.DbEntityMapper
;
import
cn.ibizlab.util.filter.QueryFilter
;
...
...
@@ -20,6 +21,7 @@ import org.springframework.util.StringUtils;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
...
...
@@ -91,27 +93,32 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
public
List
<
ModelObj
>
getModelObjs
(
DataModel
dataModel
,
List
<
EntityObj
>
kEntityObjs
)
{
EntityModel
entityModel
=
dataModel
.
getFactEntityModel
();
LinkedHashMap
<
String
,
ModelObj
>
rt
=
new
LinkedHashMap
<>();
List
<
ModelObj
>
rt
=
new
ArrayList
<>();
List
<
EntityObj
>
factEntityList
=
this
.
selectBase
(
entityModel
,
QueryFilter
.
createQuery
().
cust
(
dataModel
.
lookup
(
kEntityObjs
)));
factEntityList
.
forEach
(
entityObj
->{
String
rowKey
=
entityObj
.
getStringValue
(
entityModel
.
getKeyField
().
getColumnName
());
ModelObj
modelObj
=
new
ModelObj
().
setDataModel
(
dataModel
).
setFactEntity
(
entityObj
).
setRowKey
(
rowKey
);
entityObj
.
setProperty
(
dataModel
.
getFactPorperty
()).
setDataModel
(
dataModel
).
setModelObj
(
modelObj
);
rt
.
put
(
rowKey
,
modelObj
);
});
factEntityList
.
forEach
(
entityObj
->
rt
.
add
(
new
ModelObj
().
setDataModel
(
dataModel
).
setFactEntity
(
entityObj
.
setProperty
(
dataModel
.
getFactPorperty
()))));
fillEntityObj
(
dataModel
,
rt
);
dataModel
.
getNestedDataModels
().
forEach
(
subModel
->
this
.
getModelObjs
(
subModel
,
factEntityList
).
forEach
(
subObj
->
subObj
.
findParent
(
rt
)));
return
rt
;
}
for
(
DataModel
subModel:
dataModel
.
getNestedDataModels
())
public
void
fillEntityObj
(
DataModel
dataModel
,
List
<
ModelObj
>
modelObjs
)
{
if
(
dataModel
.
getObjectProperties
().
size
()>
1
)
{
for
(
Property
property:
dataModel
.
getObjectProperties
())
{
List
<
ModelObj
>
subObjs
=
this
.
getModelObjs
(
subModel
,
factEntityList
);
subObjs
.
forEach
(
subObj
->{
subObj
.
findParent
(
rt
.
values
());
if
(
property
.
getPropertyName
().
equals
(
dataModel
.
getFactPorperty
().
getPropertyName
()))
continue
;
EntityModel
entityModel
=
property
.
getEntityModel
();
List
<
EntityObj
>
entityObjs
=
this
.
selectBase
(
entityModel
,
QueryFilter
.
createQuery
().
cust
(
property
.
lookup
(
modelObjs
)));
entityObjs
.
forEach
(
entityObj
->
{
entityObj
.
setProperty
(
property
);
entityObj
.
findModel
(
modelObjs
);
});
}
return
null
;
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录