Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
e94fd7f2
提交
e94fd7f2
编写于
8月 18, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
39476b17
变更
15
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
638 行增加
和
92 行删除
+638
-92
pom.xml
ibzdata-core/pom.xml
+1
-1
DstSystemModel.java
...c/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
+30
-0
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+265
-0
EntityModel.java
.../src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
+25
-1
FieldModel.java
...e/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
+3
-1
LiteModelFallback.java
...ain/java/cn/ibizlab/core/data/lite/LiteModelFallback.java
+10
-0
LiteModelFeignClient.java
.../java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
+11
-0
LiteStorage.java
.../src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
+36
-84
MetaFieldModel.java
...c/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
+2
-0
MetaLookupModel.java
.../main/java/cn/ibizlab/core/data/lite/MetaLookupModel.java
+60
-0
MetaRelationshipModel.java
...java/cn/ibizlab/core/data/lite/MetaRelationshipModel.java
+137
-0
RelationshipModel.java
...ain/java/cn/ibizlab/core/data/lite/RelationshipModel.java
+3
-1
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+53
-2
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+1
-1
DTOModelServiceImpl.java
...n/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
+1
-1
未找到文件。
ibzdata-core/pom.xml
浏览文件 @
e94fd7f2
...
...
@@ -100,7 +100,7 @@
<dependency>
<groupId>
net.ibizsys.model
</groupId>
<artifactId>
ibizlab-model
</artifactId>
<version>
1.
1.60
</version>
<version>
1.
2.2
</version>
</dependency>
</dependencies>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
0 → 100644
浏览文件 @
e94fd7f2
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
DstSystemModel
{
/**
* 系统标识
*/
@JSONField
(
name
=
"pssystemid"
)
@JsonProperty
(
"pssystemid"
)
private
String
pssystemid
;
/**
* 系统名称
*/
@JSONField
(
name
=
"pssystemname"
)
@JsonProperty
(
"pssystemname"
)
private
String
pssystemname
;
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
0 → 100644
浏览文件 @
e94fd7f2
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.core.data.model.PojoModel
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
com.alibaba.fastjson.JSON
;
import
net.ibizsys.model.IPSSystem
;
import
net.ibizsys.model.PSModelServiceImpl
;
import
net.ibizsys.model.dataentity.IPSDataEntity
;
import
net.ibizsys.model.dataentity.defield.IPSDEField
;
import
net.ibizsys.model.dataentity.defield.IPSLinkDEField
;
import
net.ibizsys.model.dataentity.der.IPSDER1N
;
import
net.ibizsys.model.dataentity.der.IPSDERBase
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.util.*
;
@Service
public
class
DynamicModelService
{
@Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
@Autowired
@Lazy
private
DynamicModelService
proxy
;
private
Map
<
String
,
IPSSystem
>
dynamicSystems
;
public
synchronized
IPSSystem
getDynamicSystem
(
String
system
)
{
if
(
dynamicSystems
==
null
)
dynamicSystems
=
new
HashMap
<>();
if
(
dynamicSystems
.
containsKey
(
system
))
return
dynamicSystems
.
get
(
system
);
return
initDynamicSystem
(
system
);
}
public
IPSSystem
initDynamicSystem
(
String
system
)
{
if
(
dynamicSystems
==
null
)
dynamicSystems
=
new
HashMap
<>();
PSModelServiceImpl
psModelService
=
new
PSModelServiceImpl
();
psModelService
.
setPSModelFolderPath
(
modelPath
+
File
.
separator
+
system
+
File
.
separator
+
"model"
);
IPSSystem
iPSSystem
=
null
;
try
{
iPSSystem
=
psModelService
.
getPSSystem
();
if
(
iPSSystem
==
null
)
throw
new
BadRequestAlertException
(
String
.
format
(
"加载系统模型错误"
),
"DynamicSystem"
,
system
);
dynamicSystems
.
put
(
system
,
iPSSystem
);
if
(!
system
.
equals
(
iPSSystem
.
getCodeName
()))
dynamicSystems
.
put
(
iPSSystem
.
getCodeName
(),
iPSSystem
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
String
.
format
(
"加载系统模型错误:%s"
,
e
.
getMessage
()),
"DynamicSystem"
,
system
);
}
return
iPSSystem
;
}
@Cacheable
(
value
=
"metaentitys"
,
key
=
"'system:'+#p0"
)
public
Map
<
String
,
MetaEntityModel
>
getEntitys
(
String
system
)
throws
Exception
{
Map
<
String
,
MetaEntityModel
>
entitys
=
new
HashMap
<>();
IPSSystem
iPSSystem
=
proxy
.
getDynamicSystem
(
system
);
int
i
=
1
;
for
(
IPSDataEntity
dataEntity:
iPSSystem
.
getAllPSDataEntities
()){
MetaEntityModel
metaEntityModel
=
new
MetaEntityModel
();
metaEntityModel
.
setEntityId
(
dataEntity
.
getId
()).
setEntityName
(
dataEntity
.
getName
())
.
setLogicName
(
dataEntity
.
getLogicName
()).
setCodeName
(
dataEntity
.
getCodeName
()).
setTableName
(
dataEntity
.
getTableName
())
.
setDsId
(
iPSSystem
.
getCodeName
()+
"-"
+((
StringUtils
.
isEmpty
(
dataEntity
.
getDSLink
())||
dataEntity
.
getDSLink
().
equalsIgnoreCase
(
"DEFAULT"
))?
"master"
:
dataEntity
.
getDSLink
()))
.
setDsName
(
metaEntityModel
.
getDsId
())
.
setSystemId
(
iPSSystem
.
getCodeName
()).
setSystemName
(
iPSSystem
.
getLogicName
()).
setShowOrder
(
i
);
i
++;
entitys
.
put
(
metaEntityModel
.
getCodeName
(),
metaEntityModel
);
if
(!
metaEntityModel
.
getEntityName
().
equals
(
metaEntityModel
.
getCodeName
()))
entitys
.
put
(
metaEntityModel
.
getEntityName
(),
metaEntityModel
);
}
return
entitys
;
}
public
EntityModel
getDynamicEntity
(
String
system
,
String
entity
)
throws
Exception
{
MetaEntityModel
metaEntityModel
=
proxy
.
getEntitys
(
system
).
get
(
entity
);
if
(
metaEntityModel
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的实体模型"
,
"DynamicEntity"
,
entity
);
IPSSystem
iPSSystem
=
proxy
.
getDynamicSystem
(
system
);
IPSDataEntity
dataEntity
=
iPSSystem
.
getPSDataEntity
(
metaEntityModel
.
getEntityId
(),
true
);
if
(
dataEntity
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的实体模型"
,
"DynamicEntity"
,
entity
);
EntityModel
entityModel
=
new
EntityModel
();
if
(
dataEntity
.
isLogicValid
())
{
List
<
Setting
>
settingList
=
new
ArrayList
<>();
String
val
=
dataEntity
.
getValidLogicValue
();
if
(
StringUtils
.
isEmpty
(
val
))
val
=
"1"
;
String
deVal
=
dataEntity
.
getInvalidLogicValue
();
if
(
StringUtils
.
isEmpty
(
deVal
))
deVal
=
"0"
;
settingList
.
add
(
new
Setting
().
setProperty
(
"logicval"
).
setValue
(
val
));
settingList
.
add
(
new
Setting
().
setProperty
(
"logicdelval"
).
setValue
(
deVal
));
metaEntityModel
.
setExtParams
(
JSON
.
toJSONString
(
settingList
));
}
entityModel
.
setEntity
(
metaEntityModel
);
Map
<
String
,
FieldModel
>
fieldMaps
=
new
LinkedHashMap
<>();
for
(
IPSDEField
defield:
dataEntity
.
getAllPSDEFields
())
{
FieldModel
fieldModel
=
new
FieldModel
();
MetaFieldModel
metaFieldModel
=
new
MetaFieldModel
();
metaFieldModel
.
setFieldId
(
defield
.
getId
()).
setFieldName
(
defield
.
getName
()).
setCodeName
(
defield
.
getCodeName
()).
setFieldLogicName
(
defield
.
getLogicName
())
.
setEntityId
(
dataEntity
.
getId
()).
setEntityCodeName
(
dataEntity
.
getCodeName
()).
setEntityName
(
dataEntity
.
getName
()).
setSystemId
(
system
)
.
setFieldUniName
(
dataEntity
.
getName
()+
"."
+
defield
.
getName
()).
setFieldShowName
(
String
.
format
(
"%1$s-%2$s[%3$s]"
,
defield
.
getName
(),
defield
.
getLogicName
(),
dataEntity
.
getName
()))
.
setKeyField
(
defield
.
isKeyDEField
()?
1
:
null
).
setMajorField
(
defield
.
isMajorDEField
()?
1
:
null
).
setUnionKey
(
defield
.
getUnionKeyValue
()).
setFieldType
(
defield
.
getDataType
())
.
setPredefined
(
defield
.
getPredefinedType
()).
setDict
(
defield
.
getPSCodeList
()!=
null
?
defield
.
getPSCodeList
().
getCodeName
():
null
).
setNullable
(
defield
.
isAllowEmpty
()?
1
:
0
)
.
setPhysicalField
(
defield
.
isPhisicalDEField
()?
1
:
0
).
setDataType
(
DataType
.
findTypeName
(
defield
.
getStdDataType
())).
setDataLength
(
defield
.
getLength
()).
setDataPreci
(
defield
.
getPrecision
())
.
setIsEnableAudit
(
defield
.
isEnableAudit
()?
1
:
null
).
setShowOrder
(
defield
.
getImportOrder
());
if
(
defield
.
isLinkDEField
()
&&
defield
instanceof
IPSLinkDEField
)
{
IPSLinkDEField
linkDEField
=
(
IPSLinkDEField
)
defield
;
metaFieldModel
.
setRefFieldId
(
linkDEField
.
getRelatedPSDEField
().
getId
())
.
setRefFieldName
(
linkDEField
.
getRelatedPSDEField
().
getName
()).
setRelationId
(
linkDEField
.
getPSDER
().
getId
())
.
setRelationName
(
linkDEField
.
getPSDER
().
getName
()).
setRelationCodeName
(
linkDEField
.
getPSDER
().
getCodeName
()).
setRefEntityName
(
linkDEField
.
getPSDER
().
getMajorPSDataEntity
().
getName
());
}
fieldModel
.
setCodeName
(
metaFieldModel
.
getCodeName
()).
setColumnName
(
metaFieldModel
.
getFieldName
()).
setUnionName
(
metaFieldModel
.
getFieldUniName
()).
setShowName
(
metaFieldModel
.
getFieldShowName
())
.
setComment
(
metaFieldModel
.
getFieldLogicName
()).
setField
(
metaFieldModel
);
fieldMaps
.
put
(
fieldModel
.
getColumnName
(),
fieldModel
);
entityModel
.
addField
(
fieldModel
);
}
if
(
dataEntity
.
getMinorPSDERs
()!=
null
)
{
for
(
IPSDERBase
der
:
dataEntity
.
getMinorPSDERs
())
{
RelationshipModel
rel
=
new
RelationshipModel
();
rel
.
setCodeName
(
der
.
getCodeName
()).
setEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
.
setEntityCodeName
(
der
.
getMajorPSDataEntity
().
getCodeName
()).
setEntityName
(
der
.
getMajorPSDataEntity
().
getName
())
.
setEntityLogicName
(
der
.
getMajorPSDataEntity
().
getLogicName
()).
setSystemId
(
iPSSystem
.
getCodeName
()).
setTableName
(
der
.
getMajorPSDataEntity
().
getTableName
());
MetaRelationshipModel
metaRel
=
new
MetaRelationshipModel
();
metaRel
.
setId
(
der
.
getId
()).
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getCodeName
()).
setRefEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setEntityId
(
dataEntity
.
getId
()).
setName
(
dataEntity
.
getName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setSystemId
(
iPSSystem
.
getCodeName
());
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
MetaLookupModel
lookupModel
=
new
MetaLookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
der1n
.
getPSPickupDEField
().
getRelatedPSDEField
().
getName
());
metaRel
.
addLookup
(
lookupModel
);
}
rel
.
setRelation
(
metaRel
);
entityModel
.
addReference
(
rel
);
}
}
if
(
dataEntity
.
getMajorPSDERs
()!=
null
)
{
for
(
IPSDERBase
der
:
dataEntity
.
getMajorPSDERs
())
{
if
(
StringUtils
.
isEmpty
(
der
.
getMinorCodeName
()))
continue
;
RelationshipModel
rel
=
new
RelationshipModel
();
rel
.
setCodeName
(
der
.
getMinorCodeName
()).
setEntityId
(
der
.
getMinorPSDataEntity
().
getId
())
.
setEntityCodeName
(
der
.
getMinorPSDataEntity
().
getCodeName
()).
setEntityName
(
der
.
getMinorPSDataEntity
().
getName
())
.
setEntityLogicName
(
der
.
getMinorPSDataEntity
().
getLogicName
()).
setSystemId
(
iPSSystem
.
getCodeName
()).
setTableName
(
der
.
getMinorPSDataEntity
().
getTableName
());
MetaRelationshipModel
metaRel
=
new
MetaRelationshipModel
();
metaRel
.
setId
(
der
.
getId
()).
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getCodeName
()).
setRefEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setEntityId
(
dataEntity
.
getId
()).
setName
(
dataEntity
.
getName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setSystemId
(
iPSSystem
.
getCodeName
());
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
MetaLookupModel
lookupModel
=
new
MetaLookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
der1n
.
getPSPickupDEField
().
getRelatedPSDEField
().
getName
());
metaRel
.
addLookup
(
lookupModel
);
}
rel
.
setRelation
(
metaRel
);
entityModel
.
addNested
(
rel
);
}
}
return
entityModel
;
}
public
static
enum
DataType
{
UNKNOWN
(
0
,
"UNKNOWN"
),
BIGINT
(
1
,
"BIGINT"
),
BINARY
(
2
,
"BINARY"
),
BIT
(
3
,
"BIT"
),
CHAR
(
4
,
"CHAR"
),
DATETIME
(
5
,
"DATETIME"
),
DECIMAL
(
6
,
"DECIMAL"
),
FLOAT
(
7
,
"FLOAT"
),
IMAGE
(
8
,
"IMAGE"
),
INT
(
9
,
"INT"
),
MONEY
(
10
,
"MONEY"
),
NCHAR
(
11
,
"NCHAR"
),
NTEXT
(
12
,
"NTEXT"
),
NVARCHAR
(
13
,
"NVARCHAR"
),
NUMERIC
(
14
,
"NUMERIC"
),
REAL
(
15
,
"REAL"
),
SMALLDATETIME
(
16
,
"SMALLDATETIME"
),
SMALLINT
(
17
,
"SMALLINT"
),
SMALLMONEY
(
18
,
"SMALLMONEY"
),
SQL_VARIANT
(
19
,
"SQL_VARIANT"
),
SYSNAME
(
20
,
"SYSNAME"
),
TEXT
(
21
,
"TEXT"
),
TIMESTAMP
(
22
,
"TIMESTAMP"
),
TINYINT
(
23
,
"TINYINT"
),
VARBINARY
(
24
,
"VARBINARY"
),
VARCHAR
(
25
,
"VARCHAR"
),
UNIQUEIDENTIFIER
(
26
,
"UNIQUEIDENTIFIER"
),
DATE
(
27
,
"DATE"
),
TIME
(
28
,
"TIME"
);
public
final
int
code
;
public
final
String
name
;
private
DataType
(
int
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
int
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
public
static
String
findTypeName
(
Integer
type
)
{
for
(
DataType
userTypeEnum
:
DataType
.
values
())
{
if
(
userTypeEnum
.
getCode
()==
type
)
{
return
userTypeEnum
.
getName
();
}
}
return
VARCHAR
.
getName
();
}
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
浏览文件 @
e94fd7f2
...
...
@@ -62,8 +62,24 @@ public class EntityModel {
private
List
<
FieldModel
>
fields
;
public
EntityModel
addField
(
FieldModel
fieldModel
)
{
if
(
fields
==
null
)
fields
=
new
ArrayList
<>();
fields
.
add
(
fieldModel
);
return
this
;
}
private
List
<
RelationshipModel
>
references
;
public
EntityModel
addReference
(
RelationshipModel
relationshipModel
)
{
if
(
references
==
null
)
references
=
new
ArrayList
<>();
references
.
add
(
relationshipModel
);
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
RelationshipModel
>
refMaps
;
...
...
@@ -79,7 +95,7 @@ public class EntityModel {
if
(!
StringUtils
.
isEmpty
(
ship
.
getCodeName
()))
refMaps
.
put
(
ship
.
getCodeName
(),
ship
);
if
(!
StringUtils
.
isEmpty
(
ship
.
getRelation
()))
{
String
fkname
=
DataObject
.
getStringValue
(
ship
.
getRelation
().
get
(
"name"
),
""
);
String
fkname
=
DataObject
.
getStringValue
(
ship
.
getRelation
().
get
Name
(
),
""
);
if
(!
StringUtils
.
isEmpty
(
fkname
))
refMaps
.
put
(
fkname
,
ship
);
}
...
...
@@ -90,6 +106,14 @@ public class EntityModel {
private
List
<
RelationshipModel
>
nesteds
;
public
EntityModel
addNested
(
RelationshipModel
relationshipModel
)
{
if
(
nesteds
==
null
)
nesteds
=
new
ArrayList
<>();
nesteds
.
add
(
relationshipModel
);
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
FieldModel
>
fieldMap
=
null
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
浏览文件 @
e94fd7f2
...
...
@@ -6,11 +6,13 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
FieldModel
{
...
...
@@ -91,7 +93,7 @@ public class FieldModel {
if
(
dataType
.
indexOf
(
"TEXT"
)>=
0
||
dataType
.
indexOf
(
"CHAR"
)>=
0
||
dataType
.
indexOf
(
"LOB"
)>=
0
)
return
"string"
;
else
if
(
dataType
.
indexOf
(
"TIME"
)>=
0
)
return
"dat
a
-time"
;
return
"dat
e
-time"
;
else
if
(
dataType
.
indexOf
(
"DATE"
)>=
0
)
return
"date"
;
else
if
(
dataType
.
indexOf
(
"NUM"
)>=
0
||
dataType
.
indexOf
(
"FLOAT"
)>=
0
||
dataType
.
indexOf
(
"DOUBLE"
)>=
0
||
dataType
.
indexOf
(
"DECIMAL"
)>=
0
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFallback.java
浏览文件 @
e94fd7f2
...
...
@@ -18,5 +18,15 @@ public class LiteModelFallback implements LiteModelFeignClient {
return
null
;
}
@Override
public
List
<
EntityModel
>
getEntityModel
(
String
system
)
{
return
null
;
}
@Override
public
List
<
DstSystemModel
>
getSysApps
()
{
return
null
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
浏览文件 @
e94fd7f2
...
...
@@ -2,8 +2,12 @@ package cn.ibizlab.core.data.lite;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 实体[MetaModel] 服务对象接口
...
...
@@ -19,5 +23,12 @@ public interface LiteModelFeignClient {
@Cacheable
(
value
=
"entitymodel"
,
key
=
"'row:'+#p0+'.'+#p1"
)
EntityModel
getProxyEntityModel
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
);
@GetMapping
(
"/lite/{system}/entitys"
)
List
<
EntityModel
>
getEntityModel
(
@PathVariable
(
"system"
)
String
system
);
@GetMapping
(
"/lite/sysapps"
)
@Cacheable
(
value
=
"syspssystem"
,
key
=
"'row:sys-dst-sys-apps'"
)
List
<
DstSystemModel
>
getSysApps
();
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
浏览文件 @
e94fd7f2
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.JSON
;
import
net.ibizsys.model.IPSSystem
;
import
net.ibizsys.model.PSModelServiceImpl
;
import
net.ibizsys.model.dataentity.IPSDataEntity
;
import
net.ibizsys.model.dataentity.defield.IPSDEField
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.
beans.factory.annotation.Value
;
import
org.springframework.
context.annotation.Lazy
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.PostConstruct
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
LiteStorage
{
private
static
LiteModelFeignClient
service
;
private
static
LiteModelFeignClient
liteModelFeignClient
;
private
static
DynamicModelService
dynamicModelService
;
public
static
void
setDynamicModelService
(
DynamicModelService
service
)
{
if
(
LiteStorage
.
dynamicModelService
==
null
)
LiteStorage
.
dynamicModelService
=
service
;
}
public
static
void
setLiteModelService
(
LiteModelFeignClient
service
)
{
if
(
LiteStorage
.
service
==
null
)
LiteStorage
.
service
=
service
;
if
(
LiteStorage
.
liteModelFeignClient
==
null
)
LiteStorage
.
liteModelFeignClient
=
service
;
}
public
static
LiteModelFeignClient
getLiteModelService
()
{
return
service
;
return
liteModelFeignClient
;
}
public
static
EntityModel
getEntityModel
(
String
system
,
String
entity
)
public
static
DynamicModelService
getDynamicModelService
(
)
{
return
service
.
getProxyEntityModel
(
system
,
entity
);
return
dynamicModelService
;
}
public
static
EntityModel
getEntityModel
(
String
system
,
String
entity
)
{
@Autowired
private
LiteModelFeignClient
client
;
@PostConstruct
public
void
init
(){
LiteStorage
.
setLiteModelService
(
client
);
}
EntityModel
entityModel
=
null
;
try
{
entityModel
=
getDynamicModelService
().
getDynamicEntity
(
system
,
entity
);
}
catch
(
Exception
exception
)
{
}
if
(
entityModel
==
null
)
entityModel
=
getLiteModelService
().
getProxyEntityModel
(
system
,
entity
);
@Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
return
entityModel
;
}
private
Map
<
String
,
IPSSystem
>
dynamicSystems
;
public
synchronized
IPSSystem
getDynamicSystem
(
String
system
)
{
if
(
dynamicSystems
==
null
)
dynamicSystems
=
new
HashMap
<>();
if
(
dynamicSystems
.
containsKey
(
system
))
return
dynamicSystems
.
get
(
system
);
return
initDynamicSystem
(
system
);
}
@Autowired
private
LiteModelFeignClient
liteService
;
public
synchronized
IPSSystem
initDynamicSystem
(
String
system
)
{
if
(
dynamicSystems
==
null
)
dynamicSystems
=
new
HashMap
<>();
@Autowired
@Lazy
private
DynamicModelService
dynamicService
;
PSModelServiceImpl
psModelService
=
new
PSModelServiceImpl
();
psModelService
.
setPSModelFolderPath
(
modelPath
+
File
.
separator
+
system
+
File
.
separator
+
"model"
);
IPSSystem
iPSSystem
=
null
;
try
{
iPSSystem
=
psModelService
.
getPSSystem
();
dynamicSystems
.
put
(
system
,
iPSSystem
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
String
.
format
(
"加载系统模型错误:%s"
,
e
.
getMessage
()));
}
return
iPSSystem
;
@PostConstruct
public
void
init
(){
LiteStorage
.
setLiteModelService
(
liteService
);
LiteStorage
.
setDynamicModelService
(
dynamicService
)
;
}
public
synchronized
EntityModel
getDynamicEntity
(
String
system
,
String
entity
)
throws
Exception
{
IPSSystem
iPSSystem
=
getDynamicSystem
(
system
);
if
(
iPSSystem
==
null
)
return
null
;
IPSDataEntity
dataEntity
=
iPSSystem
.
getPSDataEntity
(
entity
,
true
);
if
(
dataEntity
==
null
)
return
null
;
EntityModel
entityModel
=
new
EntityModel
();
MetaEntityModel
metaEntityModel
=
new
MetaEntityModel
();
metaEntityModel
.
setEntityId
(
dataEntity
.
getId
()).
setEntityName
(
dataEntity
.
getName
())
.
setLogicName
(
dataEntity
.
getLogicName
()).
setCodeName
(
dataEntity
.
getCodeName
()).
setTableName
(
dataEntity
.
getTableName
())
.
setSystemId
(
system
).
setSystemName
(
iPSSystem
.
getLogicName
()).
setShowOrder
(
0
);
if
(
dataEntity
.
isLogicValid
())
{
List
<
Setting
>
settingList
=
new
ArrayList
<>();
String
val
=
dataEntity
.
getValidLogicValue
();
if
(
StringUtils
.
isEmpty
(
val
))
val
=
"1"
;
String
deVal
=
dataEntity
.
getInvalidLogicValue
();
if
(
StringUtils
.
isEmpty
(
deVal
))
deVal
=
"0"
;
settingList
.
add
(
new
Setting
().
setProperty
(
"logicval"
).
setValue
(
val
));
settingList
.
add
(
new
Setting
().
setProperty
(
"logicdelval"
).
setValue
(
deVal
));
metaEntityModel
.
setExtParams
(
JSON
.
toJSONString
(
settingList
));
}
entityModel
.
setEntity
(
metaEntityModel
);
for
(
IPSDEField
defield:
dataEntity
.
getAllPSDEFields
())
{
}
return
entityModel
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
浏览文件 @
e94fd7f2
...
...
@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
java.sql.Timestamp
;
...
...
@@ -18,6 +19,7 @@ import java.sql.Timestamp;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
@ApiModel
(
"属性"
)
public
class
MetaFieldModel
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaLookupModel.java
0 → 100644
浏览文件 @
e94fd7f2
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.*
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* [lookup] 对象
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@ApiModel
(
"lookup"
)
public
class
MetaLookupModel
implements
Serializable
{
/**
* 标识
*/
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
@ApiModelProperty
(
"标识"
)
private
String
id
;
/**
* 关系标识
*/
@JSONField
(
name
=
"relationId"
)
@JsonProperty
(
"relationId"
)
@ApiModelProperty
(
"关系标识"
)
private
String
relationid
;
/**
* 属性名称
*/
@JSONField
(
name
=
"fieldName"
)
@JsonProperty
(
"fieldName"
)
@ApiModelProperty
(
"属性名称"
)
private
String
fieldname
;
/**
* 引用属性名称
*/
@JSONField
(
name
=
"refFieldName"
)
@JsonProperty
(
"refFieldName"
)
@ApiModelProperty
(
"引用属性名称"
)
private
String
reffieldname
;
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaRelationshipModel.java
0 → 100644
浏览文件 @
e94fd7f2
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 实体[实体关系]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
@ApiModel
(
"实体关系"
)
public
class
MetaRelationshipModel
implements
Serializable
{
/**
* 关系标识
*/
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
@ApiModelProperty
(
"关系标识"
)
private
String
id
;
/**
* 关系名称
*/
@JSONField
(
name
=
"name"
)
@JsonProperty
(
"name"
)
@ApiModelProperty
(
"关系名称"
)
private
String
name
;
/**
* 类型
*/
@JSONField
(
name
=
"relation_type"
)
@JsonProperty
(
"relation_type"
)
@ApiModelProperty
(
"类型"
)
private
String
relationType
;
/**
* 代码名称
*/
@JSONField
(
name
=
"code_name"
)
@JsonProperty
(
"code_name"
)
@ApiModelProperty
(
"代码名称"
)
private
String
codeName
;
/**
* 实体标识
*/
@JSONField
(
name
=
"entity_id"
)
@JsonProperty
(
"entity_id"
)
@ApiModelProperty
(
"实体标识"
)
private
String
entityId
;
/**
* 实体名称
*/
@JSONField
(
name
=
"entity_name"
)
@JsonProperty
(
"entity_name"
)
@ApiModelProperty
(
"实体名称"
)
private
String
entityName
;
/**
* 引用实体标识
*/
@JSONField
(
name
=
"ref_entity_id"
)
@JsonProperty
(
"ref_entity_id"
)
@ApiModelProperty
(
"引用实体标识"
)
private
String
refEntityId
;
/**
* 引用实体名称
*/
@JSONField
(
name
=
"ref_entity_name"
)
@JsonProperty
(
"ref_entity_name"
)
@ApiModelProperty
(
"引用实体名称"
)
private
String
refEntityName
;
/**
* 嵌套代码名称
*/
@JSONField
(
name
=
"nested_name"
)
@JsonProperty
(
"nested_name"
)
@ApiModelProperty
(
"嵌套代码名称"
)
private
String
nestedName
;
/**
* 系统
*/
@JSONField
(
name
=
"system_id"
)
@JsonProperty
(
"system_id"
)
@ApiModelProperty
(
"系统"
)
private
String
systemId
;
/**
* 创建时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"createdate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"createdate"
)
@ApiModelProperty
(
"创建时间"
)
private
Timestamp
createdate
;
/**
* 最后修改时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"updatedate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"updatedate"
)
@ApiModelProperty
(
"最后修改时间"
)
private
Timestamp
updatedate
;
/**
* lookup
*/
@JSONField
(
name
=
"lookups"
)
@JsonProperty
(
"lookups"
)
private
List
<
MetaLookupModel
>
lookup
;
public
MetaRelationshipModel
addLookup
(
MetaLookupModel
obj
)
{
if
(
lookup
==
null
)
lookup
=
new
ArrayList
<>();
lookup
.
add
(
obj
);
return
this
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/RelationshipModel.java
浏览文件 @
e94fd7f2
...
...
@@ -4,12 +4,14 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
java.util.Map
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
RelationshipModel
{
...
...
@@ -29,6 +31,6 @@ public class RelationshipModel {
private
String
entityId
;
private
M
ap
relation
;
private
M
etaRelationshipModel
relation
;
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
e94fd7f2
...
...
@@ -2,6 +2,7 @@ package cn.ibizlab.core.data.model;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.FieldModel
;
import
cn.ibizlab.core.data.lite.MetaRelationshipModel
;
import
cn.ibizlab.core.data.lite.RelationshipModel
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -122,11 +123,11 @@ public class TransUtils {
pojoSchema
.
getOptions
().
setAll
(
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
entityModel
.
getEntity
())));
int
order
=
1
;
PojoSchema
sub
=
null
;
for
(
FieldModel
fieldModel:
entityModel
.
getFields
())
{
String
propType
=
fieldModel
.
getPropType
();
PojoSchema
sub
=
null
;
if
(
"date"
.
equals
(
propType
))
sub
=
new
PojoSchema
().
setType
(
PojoSchema
.
Type
.
string
.
getCode
()).
setFormat
(
"date"
);
else
if
(
"date-time"
.
equals
(
propType
))
...
...
@@ -145,9 +146,59 @@ public class TransUtils {
}
pojoSchema
.
addProperty
(
sub
.
getName
(),
sub
);
order
++;
}
if
(
entityModel
.
getReferences
()!=
null
)
{
for
(
RelationshipModel
rel:
entityModel
.
getReferences
())
{
PojoSchema
sub
=
new
PojoSchema
().
setType
(
PojoSchema
.
Type
.
object
.
getCode
()).
setName
(
rel
.
getCodeName
()).
setTitle
(
rel
.
getCodeName
()+
rel
.
getEntityLogicName
())
.
setPropertyOrder
(
order
).
setOptions
(
new
PojoOption
()
.
set
(
"logic_name"
,
rel
.
getEntityLogicName
())
.
set
(
"entity_name"
,
rel
.
getEntityName
())
.
set
(
"system_id"
,(
StringUtils
.
isEmpty
(
rel
.
getSystemId
())?
entityModel
.
getSystemId
():
rel
.
getSystemId
()))
.
set
(
"entity_id"
,
rel
.
getEntityId
()).
set
(
"code_name"
,
rel
.
getEntityCodeName
())
.
set
(
"table_name"
,
rel
.
getTableName
()).
set
(
"ds_name"
,
rel
.
getDataSourceName
()).
set
(
"relation"
,
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
rel
.
getRelation
()),
MetaRelationshipModel
.
class
))
)
.
setRef
((
StringUtils
.
isEmpty
(
rel
.
getSystemId
())?
entityModel
.
getSystemId
():
rel
.
getSystemId
())+
".domain."
+
rel
.
getEntityName
());
pojoSchema
.
addProperty
(
sub
.
getName
(),
sub
);
order
++;
}
}
if
(
entityModel
.
getNesteds
()!=
null
)
{
for
(
RelationshipModel
nest:
entityModel
.
getNesteds
())
{
PojoSchema
sub
=
new
PojoSchema
().
setType
(
PojoSchema
.
Type
.
array
.
getCode
()).
setName
(
nest
.
getCodeName
()).
setTitle
(
nest
.
getCodeName
()+
nest
.
getEntityLogicName
())
.
setPropertyOrder
(
order
).
setOptions
(
new
PojoOption
()
.
set
(
"logic_name"
,
nest
.
getEntityLogicName
())
.
set
(
"entity_name"
,
nest
.
getEntityName
())
.
set
(
"system_id"
,(
StringUtils
.
isEmpty
(
nest
.
getSystemId
())?
entityModel
.
getSystemId
():
nest
.
getSystemId
()))
.
set
(
"entity_id"
,
nest
.
getEntityId
()).
set
(
"code_name"
,
nest
.
getEntityCodeName
())
.
set
(
"table_name"
,
nest
.
getTableName
()).
set
(
"ds_name"
,
nest
.
getDataSourceName
()).
set
(
"relation"
,
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
nest
.
getRelation
()),
MetaRelationshipModel
.
class
))
)
.
setItems
(
new
PojoSchema
().
setType
(
PojoSchema
.
Type
.
object
.
getCode
()).
setName
(
nest
.
getEntityName
()).
setTitle
(
nest
.
getEntityLogicName
())
.
setRef
((
StringUtils
.
isEmpty
(
nest
.
getSystemId
())?
entityModel
.
getSystemId
():
nest
.
getSystemId
())+
".domain."
+
nest
.
getEntityName
())
.
setOptions
(
new
PojoOption
()
.
set
(
"logic_name"
,
nest
.
getEntityLogicName
())
.
set
(
"entity_name"
,
nest
.
getEntityName
())
.
set
(
"system_id"
,(
StringUtils
.
isEmpty
(
nest
.
getSystemId
())?
entityModel
.
getSystemId
():
nest
.
getSystemId
()))
.
set
(
"entity_id"
,
nest
.
getEntityId
()).
set
(
"code_name"
,
nest
.
getEntityCodeName
())
.
set
(
"table_name"
,
nest
.
getTableName
()).
set
(
"ds_name"
,
nest
.
getDataSourceName
())
)
);
pojoSchema
.
addProperty
(
sub
.
getName
(),
sub
);
order
++;
}
}
return
pojoSchema
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
e94fd7f2
...
...
@@ -94,7 +94,7 @@ public class DOModelServiceImpl implements IDOModelService {
File
schemaJson
=
new
File
(
domainDir
,
entity
+
".json"
);
if
(!
schemaJson
.
exists
())
{
EntityModel
entityModel
=
LiteStorage
.
get
LiteModelService
().
getProxy
EntityModel
(
system
,
entity
);
EntityModel
entityModel
=
LiteStorage
.
getEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
TransUtils
.
LiteEntityModelModel2Schema
(
entityModel
);
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
浏览文件 @
e94fd7f2
...
...
@@ -99,7 +99,7 @@ public class DTOModelServiceImpl implements IDTOModelService {
String
entity
=
dto
;
if
(
entity
.
endsWith
(
"DTO"
))
entity
=
entity
.
substring
(
0
,
entity
.
length
()-
3
);
EntityModel
entityModel
=
LiteStorage
.
get
LiteModelService
().
getProxy
EntityModel
(
system
,
entity
);
EntityModel
entityModel
=
LiteStorage
.
getEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
TransUtils
.
LiteEntityModelModel2Schema
(
entityModel
)),
PojoSchema
.
class
);
schema
.
setName
(
dto
);
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录