Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
4be78d7f
提交
4be78d7f
编写于
8月 20, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
b457b716
变更
13
显示空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
450 行增加
和
101 行删除
+450
-101
pom.xml
ibzdata-core/pom.xml
+1
-1
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+7
-3
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+47
-8
EntityModel.java
.../src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
+75
-1
FieldModel.java
...e/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
+5
-0
MetaEntityModel.java
.../main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
+4
-2
MetaFieldModel.java
...c/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
+4
-2
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+118
-25
PojoOption.java
.../src/main/java/cn/ibizlab/core/data/model/PojoOption.java
+21
-2
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+5
-0
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+110
-47
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+47
-6
DTOModelServiceImpl.java
...n/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
+6
-4
未找到文件。
ibzdata-core/pom.xml
浏览文件 @
4be78d7f
...
...
@@ -100,7 +100,7 @@
<dependency>
<groupId>
net.ibizsys.model
</groupId>
<artifactId>
ibizlab-model
</artifactId>
<version>
1.2.
4
</version>
<version>
1.2.
5
</version>
</dependency>
</dependencies>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
4be78d7f
...
...
@@ -280,10 +280,14 @@ public class DOModel extends EntityBase implements Serializable {
return
getPOSchema
(
"default"
);
}
public
DOModel
addPOSchema
(
String
name
,
POSchema
poSchema
)
{
if
(
poSchema
!=
null
)
{
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
poSchemas
.
put
(
name
,
poSchema
);
poSchemas
.
put
(
name
,
poSchema
.
build
());
}
return
this
;
}
public
POSchema
getPOSchema
(
String
name
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
4be78d7f
...
...
@@ -4,6 +4,7 @@ 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.database.IPSDEFDTColumn
;
import
net.ibizsys.model.database.IPSSysDBTable
;
import
net.ibizsys.model.dataentity.IPSDataEntity
;
import
net.ibizsys.model.dataentity.defield.IPSDEField
;
...
...
@@ -58,7 +59,7 @@ public class DynamicModelService {
IPSSystem
iPSSystem
=
null
;
String
strPSModelFolderPath
=
null
;
if
(
Files
.
exists
(
Paths
.
get
(
getModelPath
(),
system
,
"model"
,
"PSSYSTEM.json"
)))
{
strPSModelFolderPath
=
Paths
.
get
(
getModelPath
(),
system
,
"model"
,
"PSSYSTEM.json"
).
toString
();
strPSModelFolderPath
=
Paths
.
get
(
getModelPath
(),
system
,
"model"
).
toString
();
}
else
{
...
...
@@ -183,10 +184,24 @@ public class DynamicModelService {
}
entityModel
.
setEntity
(
metaEntityModel
);
List
<
String
>
dsTypes
=
new
ArrayList
<>();
if
(
dataEntity
.
getAllPSDEDBConfigs
()!=
null
)
{
dataEntity
.
getAllPSDEDBConfigs
().
forEach
(
item
->{
dsTypes
.
add
(
item
.
getDBType
().
toLowerCase
());
if
(!
entityModel
.
getTableName
().
equalsIgnoreCase
(
item
.
getTableName
()))
entityModel
.
getEntity
().
set
(
"table-"
+
item
.
getDBType
().
toLowerCase
(),
item
.
getTableName
());
});
}
if
(
dsTypes
.
size
()>
0
)
entityModel
.
getEntity
().
set
(
"ds_types"
,
String
.
join
(
","
,
dsTypes
));
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
())
...
...
@@ -203,7 +218,7 @@ public class DynamicModelService {
if
(!
metaFieldModel
.
getFieldName
().
equalsIgnoreCase
(
col
.
getColumnName
()))
metaFieldModel
.
set
(
"column-"
+
col
.
getDBType
().
toLowerCase
(),
col
.
getColumnName
());
if
(
StringUtils
.
isEmpty
(
metaFieldModel
)&&
defield
.
isFormulaDEField
()&&(!
StringUtils
.
isEmpty
(
col
.
getQueryCodeExp
())))
metaFieldModel
.
setExpression
(
col
.
getQueryCodeExp
().
replace
(
"`"
,
""
));
metaFieldModel
.
setExpression
(
col
.
getQueryCodeExp
().
replace
(
"`"
,
""
)
.
replace
(
"["
,
""
).
replace
(
"]"
,
""
)
);
});
}
...
...
@@ -233,7 +248,7 @@ public class DynamicModelService {
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
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setEntityId
(
dataEntity
.
getId
()).
set
Entity
Name
(
dataEntity
.
getName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setSystemId
(
iPSSystem
.
getCodeName
());
if
(
der
instanceof
IPSDER1N
)
...
...
@@ -263,7 +278,7 @@ public class DynamicModelService {
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
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setEntityId
(
dataEntity
.
getId
()).
set
Entity
Name
(
dataEntity
.
getName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setSystemId
(
iPSSystem
.
getCodeName
());
if
(
der
instanceof
IPSDER1N
)
...
...
@@ -287,7 +302,7 @@ public class DynamicModelService {
if
(
dataQuery
.
getAllPSDEDataQueryCodes
()!=
null
)
{
dataQuery
.
getAllPSDEDataQueryCodes
().
forEach
(
dq
->{
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
"
dq-"
+
dataQuery
.
getCodeName
()+
"-"
+
dq
.
getDBType
().
toLowerCase
())
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-
dq-"
+
dataQuery
.
getCodeName
()+
"-"
+
dq
.
getDBType
().
toLowerCase
())
.
setDatasetName
(
dataQuery
.
getLogicName
()).
setCodeName
(
dataQuery
.
getCodeName
())
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
dq
.
getQueryCode
());
entityModel
.
addDataSet
(
dsModel
);
...
...
@@ -306,8 +321,12 @@ public class DynamicModelService {
try
{
if
(
dataSet
.
getPSDEDataQueries
()!=
null
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
dataSet
.
getPSDEDataQueries
().
forEach
(
dataQuery
->{
...
...
@@ -324,7 +343,7 @@ public class DynamicModelService {
code
=
map
.
get
(
dq
.
getDBType
());
code
=
code
+
"\r\n union all \r\n"
;
}
code
=
code
+
dq
.
getQueryCode
()
;
code
=
code
+
"<include refid=\""
+
entityModel
.
getEntityName
().
toLowerCase
()+
"_dq_"
+
dataQuery
.
getCodeName
()+
"_"
+
dq
.
getDBType
().
toLowerCase
()+
"\"/>"
;
map
.
put
(
dq
.
getDBType
(),
code
);
});
}
...
...
@@ -336,9 +355,27 @@ public class DynamicModelService {
for
(
Map
.
Entry
<
String
,
String
>
entry:
map
.
entrySet
())
{
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
"ds-"
+
dataSet
.
getCodeName
()+
"-"
+
entry
.
getKey
().
toLowerCase
())
String
sql
=
"select t1.* from (\r\n"
.
concat
(
entry
.
getValue
()).
concat
(
"\r\n) t1"
);
if
(
dataSet
.
getMajorSortPSDEField
()!=
null
)
{
IPSDEFDTColumn
column
=
dataSet
.
getMajorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
(),
false
);
sql
=
sql
.
concat
(
" order by "
).
concat
(
column
==
null
?
dataSet
.
getMajorSortPSDEField
().
getName
():
column
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMajorSortDir
()))
sql
=
sql
.
concat
(
" "
).
concat
(
dataSet
.
getMajorSortDir
());
if
(
dataSet
.
getMinorSortPSDEField
()!=
null
)
{
IPSDEFDTColumn
subCol
=
dataSet
.
getMinorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
(),
false
);
sql
=
sql
.
concat
(
","
).
concat
(
subCol
==
null
?
dataSet
.
getMinorSortPSDEField
().
getName
():
subCol
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMinorSortDir
()))
sql
=
sql
.
concat
(
" "
).
concat
(
dataSet
.
getMinorSortDir
());
}
}
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-ds-"
+
dataSet
.
getCodeName
()+
"-"
+
entry
.
getKey
().
toLowerCase
())
.
setDatasetName
(
dataSet
.
getLogicName
()).
setCodeName
(
dataSet
.
getCodeName
())
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
entry
.
getValue
()
);
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
sql
);
entityModel
.
addDataSet
(
dsModel
);
}
...
...
@@ -348,6 +385,8 @@ public class DynamicModelService {
}
});
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
浏览文件 @
4be78d7f
...
...
@@ -277,6 +277,35 @@ public class EntityModel {
return
null
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getDefaultQueryScript
()
{
if
(
this
.
getDataSets
()!=
null
)
{
for
(
MetaDataSetModel
set:
this
.
getDataSets
()){
if
(
StringUtils
.
isEmpty
(
set
.
getDsCode
()))
continue
;
if
(
"view"
.
equalsIgnoreCase
(
set
.
getDatasetId
())||
set
.
getDatasetId
().
startsWith
(
"dq-view-"
)||
set
.
getDatasetId
().
startsWith
(
getEntityName
().
toLowerCase
()+
"-dq-view-"
))
{
return
set
.
getDsCode
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
}
}
for
(
MetaDataSetModel
set:
this
.
getDataSets
()){
if
(
StringUtils
.
isEmpty
(
set
.
getDsCode
()))
continue
;
if
(
"default"
.
equalsIgnoreCase
(
set
.
getDatasetId
())||
set
.
getDatasetId
().
startsWith
(
"dq-default-"
)||
set
.
getDatasetId
().
startsWith
(
getEntityName
().
toLowerCase
()+
"-dq-default-"
))
{
return
set
.
getDsCode
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
}
}
}
return
""
;
}
public
String
getSqlSegment
(
String
dataSet
)
{
...
...
@@ -298,6 +327,35 @@ public class EntityModel {
{
return
"select count(1) from "
+
this
.
getTableName
()+
" "
;
}
else
if
(
this
.
getDataSets
()!=
null
)
{
for
(
MetaDataSetModel
set:
this
.
getDataSets
()){
if
(
StringUtils
.
isEmpty
(
set
.
getDsCode
()))
continue
;
if
(
dataSet
.
equalsIgnoreCase
(
set
.
getDatasetId
())||
set
.
getDatasetId
().
indexOf
(
"ds-"
+
dataSet
.
toLowerCase
()+
"-"
)>=
0
||
set
.
getDatasetId
().
startsWith
(
getEntityName
().
toLowerCase
()+
"-ds-"
+
dataSet
.
toLowerCase
()+
"-"
))
{
return
set
.
getDsCode
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
}
}
for
(
MetaDataSetModel
set:
this
.
getDataSets
()){
if
(
StringUtils
.
isEmpty
(
set
.
getDsCode
()))
continue
;
if
(
dataSet
.
equalsIgnoreCase
(
set
.
getDatasetId
())||
set
.
getDatasetId
().
indexOf
(
"dq-"
+
dataSet
.
toLowerCase
()+
"-"
)>=
0
||
set
.
getDatasetId
().
startsWith
(
getEntityName
().
toLowerCase
()+
"-dq-"
+
dataSet
.
toLowerCase
()+
"-"
))
{
return
set
.
getDsCode
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
}
}
}
if
(
dataSet
.
equalsIgnoreCase
(
"VIEW"
)||
dataSet
.
equalsIgnoreCase
(
"DEFAULT"
))
{
return
""
;
}
else
{
String
columnSet
=
""
;
...
...
@@ -417,7 +475,23 @@ public class EntityModel {
public
String
getExtParams
(
String
key
)
{
return
Setting
.
getValue
(
this
.
getEntity
().
getExtParams
(),
key
);
return
DataObject
.
getStringValue
(
entity
.
get
(
key
),
""
);
}
public
String
getTableName
(
String
dsType
)
{
return
DataObject
.
getStringValue
(
entity
.
get
(
"table-"
+
dsType
.
toLowerCase
()),
getTableName
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
List
<
String
>
getDsTypes
()
{
List
<
String
>
dsTypes
=
new
ArrayList
<>();
String
strDsTypes
=
DataObject
.
getStringValue
(
entity
.
get
(
"ds_types"
),
""
);
for
(
String
dsType:
strDsTypes
.
split
(
","
))
dsTypes
.
add
(
dsType
);
return
dsTypes
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
浏览文件 @
4be78d7f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
...
...
@@ -103,5 +104,9 @@ public class FieldModel {
return
"string"
;
}
public
String
getColumnName
(
String
dsType
)
{
return
DataObject
.
getStringValue
(
field
.
get
(
"column-"
+
dsType
.
toLowerCase
()),
getColumnName
());
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
浏览文件 @
4be78d7f
...
...
@@ -142,8 +142,10 @@ public class MetaEntityModel{
extensionparams
.
put
(
key
,
value
);
List
<
Setting
>
settingList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry:
extensionparams
.
entrySet
())
settingList
.
add
(
new
Setting
().
setProperty
(
key
).
setValue
(
DataObject
.
getStringValue
(
value
,
""
)));
for
(
Map
.
Entry
<
String
,
Object
>
entry:
extensionparams
.
entrySet
())
{
if
(!
entry
.
getKey
().
equalsIgnoreCase
(
"param"
))
settingList
.
add
(
new
Setting
().
setProperty
(
entry
.
getKey
()).
setValue
(
DataObject
.
getStringValue
(
entry
.
getValue
(),
""
)));
}
return
setExtParams
(
JSON
.
toJSONString
(
settingList
));
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
浏览文件 @
4be78d7f
...
...
@@ -293,8 +293,10 @@ public class MetaFieldModel {
extensionparams
.
put
(
key
,
value
);
List
<
Setting
>
settingList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry:
extensionparams
.
entrySet
())
settingList
.
add
(
new
Setting
().
setProperty
(
key
).
setValue
(
DataObject
.
getStringValue
(
value
,
""
)));
for
(
Map
.
Entry
<
String
,
Object
>
entry:
extensionparams
.
entrySet
())
{
if
(!
entry
.
getKey
().
equalsIgnoreCase
(
"param"
))
settingList
.
add
(
new
Setting
().
setProperty
(
entry
.
getKey
()).
setValue
(
DataObject
.
getStringValue
(
entry
.
getValue
(),
""
)));
}
return
setExtParams
(
JSON
.
toJSONString
(
settingList
));
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
4be78d7f
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.core.data.dto.BaseData
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
...
...
@@ -12,6 +15,10 @@ import lombok.experimental.Accessors;
import
org.apache.ibatis.mapping.VendorDatabaseIdProvider
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.StandardOpenOption
;
import
java.util.*
;
@Getter
...
...
@@ -22,15 +29,21 @@ import java.util.*;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
POSchema
{
@JSONField
(
ordinal
=
1
)
private
String
name
;
@JSONField
(
ordinal
=
2
)
private
String
remarks
;
@JSONField
(
ordinal
=
3
)
private
String
dsType
;
@JSONField
(
ordinal
=
4
)
private
String
defaultDataSource
;
@JSONField
(
ordinal
=
5
)
private
String
logicVal
;
@JSONField
(
ordinal
=
6
)
private
String
logicDelVal
;
public
String
getLogicVal
()
{
...
...
@@ -45,8 +58,10 @@ public class POSchema {
return
logicDelVal
;
}
@JSONField
(
ordinal
=
7
)
private
List
<
Column
>
columns
;
@JSONField
(
ordinal
=
8
)
private
List
<
Column
>
transients
;
public
POSchema
setColumns
(
List
<
Column
>
columns
)
...
...
@@ -81,6 +96,7 @@ public class POSchema {
return
this
;
}
@JSONField
(
ordinal
=
9
)
private
List
<
ForeignKeyConstraint
>
foreignKeyConstraints
;
public
POSchema
addForeignKeyConstraint
(
ForeignKeyConstraint
foreignKeyConstraint
)
...
...
@@ -120,6 +136,7 @@ public class POSchema {
return
columnMaps
;
}
@JSONField
(
ordinal
=
10
)
public
boolean
needTrans
=
false
;
public
void
refreshColumnMaps
()
...
...
@@ -174,7 +191,7 @@ public class POSchema {
if
(
column
.
isLastModify
())
this
.
setLastModifyColumn
(
column
);
}
if
((!
StringUtils
.
isEmpty
(
column
.
getAlias
()))&&
column
.
getAlias
().
equalsIgnoreCase
(
column
.
getName
(
)))
if
((!
StringUtils
.
isEmpty
(
column
.
getAlias
()))&&
(!
column
.
getAlias
().
equalsIgnoreCase
(
column
.
getName
()
)))
{
needTrans
=
true
;
columnMaps
.
put
(
column
.
getAlias
().
toLowerCase
(),
column
);
...
...
@@ -300,6 +317,12 @@ public class POSchema {
private
String
alias
;
private
String
predefined
;
public
Column
setAlias
(
String
alias
)
{
if
((!
StringUtils
.
isEmpty
(
name
))&&(!
name
.
equalsIgnoreCase
(
alias
)))
this
.
alias
=
alias
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
...
...
@@ -447,21 +470,38 @@ public class POSchema {
@Accessors
(
chain
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
static
class
S
crip
t
{
public
static
class
S
egmen
t
{
private
String
name
;
private
String
vendorProvider
;
private
String
declare
;
private
String
body
;
private
Map
params
;
public
Segment
setVendorProvider
(
String
vendorProvider
)
{
if
(!
StringUtils
.
isEmpty
(
vendorProvider
))
this
.
vendorProvider
=
provider
.
get
(
vendorProvider
.
toLowerCase
());
return
this
;
}
}
public
List
<
Script
>
scripts
;
@JSONField
(
ordinal
=
11
)
public
List
<
Segment
>
segments
;
public
POSchema
addSegment
(
Segment
segment
)
{
if
(
segments
==
null
)
segments
=
new
ArrayList
<>();
segments
.
add
(
segment
);
return
this
;
}
private
static
Map
<
String
,
String
>
provider
=
new
HashMap
<
String
,
String
>(){{
put
(
"oracle"
,
"oracle"
);
put
(
"mysql"
,
"mysql"
);
put
(
"mysql5"
,
"mysql"
);
put
(
"postgresql"
,
"postgresql"
);
put
(
"mppdb"
,
"postgresql"
);
put
(
"dm"
,
"oracle"
);
...
...
@@ -472,39 +512,60 @@ public class POSchema {
public
S
cript
getScrip
t
(
String
name
,
String
type
)
public
S
egment
getSegmen
t
(
String
name
,
String
type
)
{
if
(
s
crip
ts
!=
null
)
if
(
s
egmen
ts
!=
null
)
{
String
vendorProvider
=
"mysql"
;
if
((!
StringUtils
.
isEmpty
(
type
))&&
provider
.
containsKey
(
type
.
toLowerCase
()))
vendorProvider
=
provider
.
get
(
type
.
toLowerCase
());
for
(
Script
script:
scripts
)
String
vendorProvider
=
StringUtils
.
isEmpty
(
type
)?
""
:
provider
.
get
(
type
.
toLowerCase
());
for
(
Segment
script:
segments
)
{
if
(
name
.
equalsIgnoreCase
(
script
.
getName
())&&((
script
.
getVendorProvider
().
indexOf
(
vendorProvider
)>=
0
)
||
StringUtils
.
isEmpty
(
script
.
getVendorProvider
())))
if
(
script
.
getName
().
toLowerCase
().
indexOf
(
name
.
toLowerCase
())>=
0
&&(
StringUtils
.
isEmpty
(
vendorProvider
)||
script
.
getVendorProvider
().
indexOf
(
vendorProvider
)>=
0
||
StringUtils
.
isEmpty
(
script
.
getVendorProvider
())))
return
script
;
}
}
else
{
scrip
ts
=
new
ArrayList
<>();
segmen
ts
=
new
ArrayList
<>();
}
return
getDefaultQueryScript
()
;
return
null
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Script
defaultQueryScript
;
@JSONField
(
ordinal
=
12
)
public
Segment
defaultQueryScript
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Script
getDefaultQueryScript
()
public
POSchema
setDefaultQueryScript
(
String
sql
)
{
defaultQueryScript
=
new
Segment
().
setName
(
"default_query_script"
).
setVendorProvider
(
""
).
setBody
(
sql
);
return
this
;
}
public
Segment
getDefaultQueryScript
()
{
if
(
defaultQueryScript
==
null
)
{
defaultQueryScript
=
new
Script
();
defaultQueryScript
.
setName
(
"default"
);
defaultQueryScript
.
setVendorProvider
(
"mysql,oracle,postgresql"
);
Segment
segment
=
this
.
getSegment
(
"dq-view-"
,
this
.
getDsType
());
if
(
segment
==
null
)
segment
=
this
.
getSegment
(
"dq-default-"
,
this
.
getDsType
());
if
(
segment
!=
null
)
{
setDefaultQueryScript
(
segment
.
getBody
());
return
defaultQueryScript
;
}
else
if
(!
StringUtils
.
isEmpty
(
this
.
getDsType
()))
{
segment
=
this
.
getSegment
(
"dq-view-"
,
""
);
if
(
segment
==
null
)
segment
=
this
.
getSegment
(
"dq-default-"
,
""
);
if
(
segment
!=
null
)
{
setDefaultQueryScript
(
segment
.
getBody
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
));
return
defaultQueryScript
;
}
}
defaultQueryScript
=
new
Segment
();
defaultQueryScript
.
setName
(
"default_query_script"
);
defaultQueryScript
.
setVendorProvider
(
""
);
String
sql
=
"select "
;
String
cols
=
""
;
...
...
@@ -514,18 +575,18 @@ public class POSchema {
{
if
(!
StringUtils
.
isEmpty
(
cols
))
cols
+=
","
;
cols
+=(
"t."
+
key
+
" as "
+
baseColumnMap
.
get
(
key
));
cols
+=(
"t
1
."
+
key
+
" as "
+
baseColumnMap
.
get
(
key
));
}
}
else
cols
=
"*"
;
cols
=
"
t1.
*"
;
sql
+=
(
cols
+
" from "
+
name
+
" t "
);
sql
+=
(
cols
+
" from "
+
name
+
" t
1
"
);
if
(
isLogicValid
())
{
sql
+=
" where t."
+
this
.
getLogicValidCond
();
sql
+=
" where t
1
."
+
this
.
getLogicValidCond
();
}
defaultQueryScript
.
setBody
(
sql
);
...
...
@@ -574,4 +635,36 @@ public class POSchema {
}
}
public
POSchema
writeTo
(
Path
path
)
{
return
writeTo
(
this
,
path
);
}
public
static
POSchema
fromPath
(
Path
path
)
{
try
{
if
(!
Files
.
exists
(
path
))
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"POSchema"
,
path
.
toString
());
return
JSON
.
parseObject
(
Files
.
readAllBytes
(
path
),
POSchema
.
class
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"解析文件失败"
,
"POSchema"
,
path
.
toString
());
}
}
public
static
POSchema
writeTo
(
POSchema
poSchema
,
Path
path
)
{
try
{
File
dir
=
path
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
poSchema
),
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchema"
,
path
.
toString
());
}
return
poSchema
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoOption.java
浏览文件 @
4be78d7f
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.core.data.dto.DataObj
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
...
...
@@ -55,12 +58,28 @@ public class PojoOption extends DataObj
return
this
.
getStringValue
(
"ds_name"
,
this
.
getSystem
()+
"-master"
);
}
public
List
<
String
>
getDsTypes
(){
List
<
String
>
dsTypes
=
new
ArrayList
<>();
String
strDsTypes
=
this
.
getStringValue
(
"ds_types"
);
for
(
String
dsType:
strDsTypes
.
split
(
","
))
dsTypes
.
add
(
dsType
);
return
dsTypes
;
}
public
PojoOption
setDsTypes
(
String
dsTypes
){
return
this
.
set
(
"ds_types"
,
dsTypes
);
}
public
String
getDefaultQueryScript
()
{
return
this
.
getStringValue
(
"default_query_script"
);
}
public
Boolean
isLogicValid
()
{
return
this
.
getBooleanValue
(
"logic
V
alid"
);
return
this
.
getBooleanValue
(
"logic
_v
alid"
);
}
public
PojoOption
setLogicValid
(
Boolean
logicValid
)
{
return
this
.
set
(
"logic
V
alid"
,
logicValid
);
return
this
.
set
(
"logic
_v
alid"
,
logicValid
);
}
public
String
getLogicVal
()
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
4be78d7f
...
...
@@ -13,6 +13,7 @@ import lombok.Setter;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.nio.file.Files
;
...
...
@@ -326,6 +327,10 @@ public class PojoSchema {
public
static
PojoSchema
writeTo
(
PojoSchema
pojoSchema
,
Path
path
)
{
try
{
File
dir
=
path
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
),
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"PojoSchema"
,
path
.
toString
());
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
4be78d7f
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
cn.ibizlab.core.data.domain.POModel
;
import
cn.ibizlab.core.data.lite.*
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.util.StringUtils
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
class
TransUtils
{
...
...
@@ -119,8 +120,9 @@ public class TransUtils {
public
static
PojoSchema
EntityModelModel2Schema
(
EntityModel
entityModel
)
{
PojoSchema
pojoSchema
=
new
PojoSchema
().
setName
(
entityModel
.
getEntityName
()).
setType
(
"object"
).
setTitle
(
entityModel
.
getLogicName
()).
setId
(
entityModel
.
getEntityId
())
.
setOptions
(
new
PojoOption
().
setLogicValid
(
entityModel
.
isLogicValid
()).
setLogicVal
(
entityModel
.
getLogicVal
()).
setLogicDelVal
(
entityModel
.
getLogicDelVal
()));
pojoSchema
.
getOptions
().
setAll
(
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
entityModel
.
getEntity
())));
.
setOptions
(
new
PojoOption
().
setDsTypes
(
String
.
join
(
","
,
entityModel
.
getDsTypes
())).
setLogicValid
(
entityModel
.
isLogicValid
()).
setLogicVal
(
entityModel
.
getLogicVal
()).
setLogicDelVal
(
entityModel
.
getLogicDelVal
()));
pojoSchema
.
getOptions
().
setAll
(
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
entityModel
.
getEntity
()))).
remove
(
"ext_params"
);
int
order
=
1
;
...
...
@@ -134,7 +136,9 @@ public class TransUtils {
sub
=
new
PojoSchema
().
setType
(
PojoSchema
.
Type
.
string
.
getCode
()).
setFormat
(
"date-time"
);
else
sub
=
new
PojoSchema
().
setType
(
propType
);
sub
.
setName
(
fieldModel
.
getCodeName
()).
setTitle
(
fieldModel
.
getField
().
getFieldLogicName
()).
setPropertyOrder
(
order
).
setOptions
(
new
PojoOption
().
setAll
(
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
fieldModel
.
getField
()))));
sub
.
setName
(
fieldModel
.
getCodeName
()).
setTitle
(
fieldModel
.
getField
().
getFieldLogicName
()).
setPropertyOrder
(
order
)
.
setOptions
(
new
PojoOption
().
setAll
(
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
fieldModel
.
getField
()))));
sub
.
getOptions
().
remove
(
"ext_params"
);
if
(
"PICKUP"
.
equals
(
fieldModel
.
getField
().
getFieldType
())&&
fieldModel
.
isPhysicalField
())
{
if
(!
StringUtils
.
isEmpty
(
sub
.
getOptions
().
getRelationCodeName
()))
...
...
@@ -162,7 +166,7 @@ public class TransUtils {
.
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
());
.
setRef
(
"
domain."
+
rel
.
getEntityName
());
pojoSchema
.
addProperty
(
sub
.
getName
(),
sub
);
order
++;
}
...
...
@@ -182,7 +186,7 @@ public class TransUtils {
.
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
())
.
setRef
(
"
domain."
+
nest
.
getEntityName
())
.
setOptions
(
new
PojoOption
()
.
set
(
"logic_name"
,
nest
.
getEntityLogicName
())
.
set
(
"entity_name"
,
nest
.
getEntityName
())
...
...
@@ -204,7 +208,8 @@ public class TransUtils {
public
static
POSchema
PojoSchema2PO
(
PojoSchema
pojoSchema
)
{
POSchema
poSchema
=
new
POSchema
().
setName
(
pojoSchema
.
getDefaultTableName
()).
setDefaultDataSource
(
pojoSchema
.
getDefaultDataSoruce
()).
setRemarks
(
pojoSchema
.
getTitle
()).
setLogicVal
(
pojoSchema
.
getOptions
().
getLogicVal
()).
setLogicDelVal
(
pojoSchema
.
getOptions
().
getLogicDelVal
());
POSchema
poSchema
=
new
POSchema
().
setName
(
pojoSchema
.
getDefaultTableName
()).
setDefaultDataSource
(
pojoSchema
.
getDefaultDataSoruce
())
.
setRemarks
(
pojoSchema
.
getTitle
()).
setLogicVal
(
pojoSchema
.
getOptions
().
getLogicVal
()).
setLogicDelVal
(
pojoSchema
.
getOptions
().
getLogicDelVal
());
...
...
@@ -217,7 +222,7 @@ public class TransUtils {
Integer
length
=
sub
.
getOptions
().
getDataLength
();
Integer
precision
=
sub
.
getOptions
().
getDataPreci
();
POSchema
.
Column
column
=
new
POSchema
.
Column
().
set
Alias
(
name
).
setName
(
sub
.
getOptions
().
getFieldName
()
).
setRemarks
(
sub
.
getTitle
()).
setDefaultValue
(
sub
.
getOptions
().
getDefaultValue
()).
setPredefined
(
sub
.
getOptions
().
getPredefined
()).
setLength
(
length
);
POSchema
.
Column
column
=
new
POSchema
.
Column
().
set
Name
(
sub
.
getOptions
().
getFieldName
()).
setAlias
(
name
).
setRemarks
(
sub
.
getTitle
()).
setDefaultValue
(
sub
.
getOptions
().
getDefaultValue
()).
setPredefined
(
sub
.
getOptions
().
getPredefined
()).
setLength
(
length
);
if
(
PojoSchema
.
Type
.
object
.
getCode
().
equals
(
sub
.
getType
())||
PojoSchema
.
Type
.
array
.
getCode
().
equals
(
sub
.
getType
()))
{
...
...
@@ -289,46 +294,104 @@ public class TransUtils {
poSchema
.
addColumn
(
column
);
}
String
defaultQueryScript
=
pojoSchema
.
getOptions
().
getDefaultQueryScript
();
if
(!
StringUtils
.
isEmpty
(
defaultQueryScript
))
poSchema
.
setDefaultQueryScript
(
defaultQueryScript
);
return
poSchema
;
}
//
// public static PojoSchema EntityModelModel2PO(EntityModel entityModel,String dbType) {
//
// POSchema poSchema=new POSchema().setName(pojoSchema.getDefaultTableName()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce()).setRemarks(pojoSchema.getTitle()).setLogicVal(pojoSchema.getOptions().getLogicVal()).setLogicDelVal(pojoSchema.getOptions().getLogicDelVal());
//
//
// PojoSchema pojoSchema = new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId())
// .setOptions(new PojoOption().setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()));
// pojoSchema.getOptions().setAll(JSONObject.parseObject(JSON.toJSONString(entityModel.getEntity())));
//
// int order = 1;
//
// 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))
// sub = new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date-time");
// else
// sub = new PojoSchema().setType(propType);
// sub.setName(fieldModel.getCodeName()).setTitle(fieldModel.getField().getFieldLogicName()).setPropertyOrder(order).setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField()))));
// if ("PICKUP".equals(fieldModel.getField().getFieldType()) && fieldModel.isPhysicalField()) {
// if (!StringUtils.isEmpty(sub.getOptions().getRelationCodeName())) {
// RelationshipModel relationshipModel = entityModel.getRefMaps().get(sub.getOptions().getRelationCodeName());
// if (relationshipModel != null && (!StringUtils.isEmpty(relationshipModel.getTableName())))
// sub.getOptions().setRefTableName(relationshipModel.getTableName());
// }
//
// }
// pojoSchema.addProperty(sub.getName(), sub);
// order++;
// }
//
// }
public
static
POSchema
EntityModelModel2PO
(
EntityModel
entityModel
,
String
dsType
)
{
final
String
dataSourceType
=
dsType
.
toLowerCase
();
POSchema
poSchema
=
new
POSchema
().
setDsType
(
dsType
).
setName
(
entityModel
.
getTableName
(
dsType
)).
setDefaultDataSource
(
entityModel
.
getDsName
())
.
setRemarks
(
entityModel
.
getLogicName
()).
setLogicVal
(
entityModel
.
getLogicVal
()).
setLogicDelVal
(
entityModel
.
getLogicDelVal
());
Map
<
String
,
FieldModel
>
keyMap
=
new
LinkedHashMap
<>();
Map
<
String
,
RelationshipModel
>
relationshipModelMap
=
new
LinkedHashMap
<>();
if
(
entityModel
.
getKeyFields
()!=
null
)
entityModel
.
getKeyFields
().
forEach
(
model
->
keyMap
.
put
(
model
.
getColumnName
(),
model
));
if
(
entityModel
.
getReferences
()!=
null
)
entityModel
.
getReferences
().
forEach
(
model
->
relationshipModelMap
.
put
(
model
.
getRelation
().
getName
(),
model
));
int
order
=
1
;
for
(
FieldModel
fieldModel
:
entityModel
.
getFields
())
{
MetaFieldModel
sub
=
fieldModel
.
getField
();
String
colName
=
fieldModel
.
getColumnName
(
dataSourceType
);
String
dataType
=
sub
.
getDataType
();
Integer
length
=
sub
.
getDataLength
();
Integer
precision
=
sub
.
getDataPreci
();
POSchema
.
Column
column
=
new
POSchema
.
Column
().
setName
(
colName
).
setAlias
(
sub
.
getCodeName
()).
setRemarks
(
sub
.
getFieldLogicName
()).
setPredefined
(
sub
.
getPredefined
()).
setLength
(
length
).
setType
(
sub
.
getDataType
());
if
(
column
.
isNumber
())
column
.
setPrecision
(
precision
);
if
(
sub
.
getNullable
()!=
null
&&
sub
.
getNullable
()==
0
)
column
.
getConstraints
(
true
).
setNullable
(
false
);
if
(
keyMap
.
containsKey
(
column
.
getName
()))
{
String
primaryKeyName
=
"PK_"
+
poSchema
.
getName
().
toUpperCase
()+
"_"
+
column
.
getName
().
toUpperCase
();
if
(
primaryKeyName
.
length
()>
30
)
primaryKeyName
=
primaryKeyName
.
substring
(
0
,
30
);
column
.
getConstraints
(
true
).
setPrimaryKey
(
true
).
setPrimaryKeyName
(
primaryKeyName
);
}
if
(
fieldModel
.
isLogicValidField
())
{
if
(!
StringUtils
.
isEmpty
(
entityModel
.
getLogicVal
()))
column
.
setDefaultValue
(
entityModel
.
getLogicVal
());
else
column
.
setDefaultValue
(
"1"
);
}
if
(
"PICKUP"
.
equals
(
sub
.
getFieldType
())&&
fieldModel
.
isPhysicalField
())
{
RelationshipModel
relationshipModel
=
relationshipModelMap
.
get
(
sub
.
getRelationName
());
String
fkName
=
sub
.
getRelationName
().
toUpperCase
();
if
(
relationshipModel
!=
null
&&(!
StringUtils
.
isEmpty
(
relationshipModel
.
getTableName
()))&&(!
StringUtils
.
isEmpty
(
fkName
)))
{
if
(
fkName
.
length
()>
30
)
fkName
=
fkName
.
substring
(
0
,
30
);
column
.
getConstraints
(
true
).
setReferencedTableName
(
relationshipModel
.
getTableName
())
.
setReferencedColumnNames
(
sub
.
getRefFieldName
()).
setForeignKeyName
(
fkName
);
poSchema
.
addForeignKeyConstraint
(
new
POSchema
.
ForeignKeyConstraint
().
setConstraintName
(
fkName
)
.
setBaseTableName
(
poSchema
.
getName
()).
setBaseColumnNames
(
column
.
getName
())
.
setReferencedTableName
(
relationshipModel
.
getTableName
()).
setReferencedColumnNames
(
sub
.
getRefFieldName
()));
}
}
if
(!
fieldModel
.
isPhysicalField
())
poSchema
.
addTransient
(
column
.
setComputed
(
true
));
else
poSchema
.
addColumn
(
column
);
order
++;
}
if
(
entityModel
.
getDataSets
()!=
null
)
{
entityModel
.
getDataSets
().
forEach
(
dataSet
->{
if
(
dataSet
.
getDatasetId
().
startsWith
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-"
)&&
dataSet
.
getDatasetId
().
endsWith
(
dataSourceType
))
{
POSchema
.
Segment
segment
=
new
POSchema
.
Segment
().
setName
(
dataSet
.
getDatasetId
()).
setVendorProvider
(
dataSourceType
).
setBody
(
dataSet
.
getDsCode
());
poSchema
.
addSegment
(
segment
);
}
else
if
(!
dataSet
.
getDatasetId
().
startsWith
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-"
))
{
POSchema
.
Segment
segment
=
new
POSchema
.
Segment
().
setName
(
dataSet
.
getCodeName
()).
setVendorProvider
(
dataSourceType
).
setBody
(
dataSet
.
getDsCode
());
poSchema
.
addSegment
(
segment
);
}
});
}
return
poSchema
;
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
"{\"code\":\"CaseInfo\",\"name\":\"案件基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_id\",\"name\":\"请求ID标识\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"req_type\",\"name\":\"业务请求类型\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajbh\",\"name\":\"公共案件编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajmc\",\"name\":\"公共案件名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ab\",\"name\":\"案由代码\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"案由\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"gajgysrdh\",\"name\":\"移送人电话\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"case_status\",\"name\":\"案件状态\",\"required\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"CaseSuspect_List\",\"name\":\"嫌疑人自然人信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSuspect\",\"name\":\"嫌疑人自然人信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"rybh\",\"name\":\"人员编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"rybs\",\"name\":\"公安人员标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"xm\",\"name\":\"姓名\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"SuspectCoercive_List\",\"name\":\"嫌疑人强制措施信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCoercive\",\"name\":\"嫌疑人强制措施信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"cslb\",\"name\":\"强制措施种类代码\",\"required\":false,\"uniqueKeys\":true,\"dict\":\"强制措施种类\",\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}],\"extensions\":{}}},{\"code\":\"SuspectCompany_List\",\"name\":\"涉案单位信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCompany\",\"name\":\"涉案人单位信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"dwmc\",\"name\":\"单位名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSHR_List\",\"name\":\"受害人列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSHR\",\"name\":\"受害人基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"xm\",\"name\":\"姓名\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSAWP_List\",\"name\":\"涉案物品列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSAWP\",\"name\":\"涉案物品信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"sawpmc\",\"name\":\"名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseStatus_List\",\"name\":\"案件移送记录列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"object\",\"model\":{\"code\":\"CaseStatus\",\"name\":\"提请逮捕移送记录\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_dept\",\"name\":\"发送部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_deptname\",\"name\":\"发送部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_dept\",\"name\":\"接收部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_deptname\",\"name\":\"接收部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_time\",\"name\":\"发送时间\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"date\"},{\"code\":\"send_type\",\"name\":\"移送状态\",\"required\":true,\"uniqueKeys\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_type_zh\",\"name\":\"移送状态名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh_zh\",\"name\":\"文书名称\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh\",\"name\":\"移送文书文号\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}]}"
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
4be78d7f
package
cn
.
ibizlab
.
core
.
data
.
service
.
impl
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Collection
;
import
java.nio.file.StandardOpenOption
;
import
java.util.*
;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
...
...
@@ -71,18 +74,56 @@ public class DOModelServiceImpl implements IDOModelService {
String
entity
=
args
[
2
];
Path
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
"domain"
,
entity
+
".json"
);
Path
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
EntityModel
entityModel
=
LiteStorage
.
getEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
TransUtils
.
EntityModelModel2Schema
(
entityModel
);
if
(
schema
!=
null
)
{
for
(
String
dsType:
entityModel
.
getDsTypes
())
{
POSchema
poSchema
=
TransUtils
.
EntityModelModel2PO
(
entityModel
,
dsType
);
if
(
poSchema
!=
null
)
{
doModel
.
addPOSchema
(
dsType
,
poSchema
);
}
}
if
(
doModel
.
getPoSchemas
()!=
null
)
{
Path
poPath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"repository"
,
entity
+
".json"
);
try
{
File
dir
=
poPath
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()),
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
}
}
schema
.
writeTo
(
storePath
);
}
}
}
else
{
schema
=
PojoSchema
.
fromPath
(
storePath
);
Path
poPath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"repository"
,
entity
+
".json"
);
if
(
Files
.
exists
(
poPath
))
{
try
{
LinkedHashMap
map
=
JSON
.
parseObject
(
Files
.
readAllBytes
(
poPath
),
LinkedHashMap
.
class
);
map
.
keySet
().
forEach
(
dsType
->{
doModel
.
addPOSchema
(
dsType
.
toString
(),
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
.
get
(
dsType
)),
POSchema
.
class
));
});
}
catch
(
IOException
e
)
{
}
}
}
else
schema
=
PojoSchema
.
fromPath
(
storePath
);
if
(
schema
!=
null
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
浏览文件 @
4be78d7f
...
...
@@ -68,12 +68,14 @@ public class DTOModelServiceImpl implements IDTOModelService {
String
system
=
args
[
0
];
String
dto
=
args
[
2
];
Path
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
"dto"
,
dto
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
String
entity
=
dto
;
if
(
entity
.
endsWith
(
"DTO"
))
entity
=
entity
.
substring
(
0
,
entity
.
length
()-
3
);
Path
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"dto"
,
dto
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
EntityModel
entityModel
=
LiteStorage
.
getEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
TransUtils
.
EntityModelModel2Schema
(
entityModel
);
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录