Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
019d0297
提交
019d0297
编写于
12月 13, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
http://demo.ibizlab.cn/ibiz4jteam/ibzdst
上级
491c9e10
5a745200
变更
36
隐藏空白字符变更
内嵌
并排
正在显示
36 个修改的文件
包含
2359 行增加
和
8 行删除
+2359
-8
dametrics.ts
app_web/src/mock/entity/dametrics/dametrics.ts
+65
-0
meta-entitys.ts
app_web/src/mock/entity/meta-entitys/meta-entitys.ts
+57
-0
rule-items.ts
app_web/src/mock/entity/rule-items/rule-items.ts
+38
-0
dametric-service-base.ts
app_web/src/service/dametric/dametric-service-base.ts
+21
-0
meta-entity-service-base.ts
app_web/src/service/meta-entity/meta-entity-service-base.ts
+20
-0
rule-item-service-base.ts
app_web/src/service/rule-item/rule-item-service-base.ts
+14
-0
IDAMetricService.java
...va/cn/ibizlab/core/analysis/service/IDAMetricService.java
+1
-0
DAMetricServiceImpl.java
...izlab/core/analysis/service/impl/DAMetricServiceImpl.java
+7
-0
BaseEntity.java
...in/java/cn/ibizlab/core/extensions/domain/BaseEntity.java
+600
-0
BaseEntityList.java
...ava/cn/ibizlab/core/extensions/domain/BaseEntityList.java
+140
-0
BaseField.java
...ain/java/cn/ibizlab/core/extensions/domain/BaseField.java
+207
-0
BaseFieldList.java
...java/cn/ibizlab/core/extensions/domain/BaseFieldList.java
+245
-0
DSTEntityModel.java
...ava/cn/ibizlab/core/extensions/domain/DSTEntityModel.java
+23
-0
DSTLookupModel.java
...ava/cn/ibizlab/core/extensions/domain/DSTLookupModel.java
+15
-0
IEntity.java
.../main/java/cn/ibizlab/core/extensions/domain/IEntity.java
+42
-0
IField.java
...c/main/java/cn/ibizlab/core/extensions/domain/IField.java
+35
-0
BaseEntityService.java
...cn/ibizlab/core/extensions/service/BaseEntityService.java
+20
-0
DAMetricExService.java
...cn/ibizlab/core/extensions/service/DAMetricExService.java
+69
-0
MetaEntityExService.java
.../ibizlab/core/extensions/service/MetaEntityExService.java
+53
-0
RuleItemExService.java
...cn/ibizlab/core/extensions/service/RuleItemExService.java
+357
-1
FreeMakerHelper.java
...java/cn/ibizlab/core/extensions/util/FreeMakerHelper.java
+47
-0
IEntityActionHelper.java
.../cn/ibizlab/core/extensions/util/IEntityActionHelper.java
+13
-0
EntityObj.java
...ava/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
+5
-0
ModelObj.java
...java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
+107
-0
IMetaEntityService.java
...java/cn/ibizlab/core/lite/service/IMetaEntityService.java
+1
-0
MetaEntityServiceImpl.java
...ibizlab/core/lite/service/impl/MetaEntityServiceImpl.java
+7
-0
IRuleItemService.java
...n/java/cn/ibizlab/core/rule/service/IRuleItemService.java
+1
-0
RuleItemServiceImpl.java
...n/ibizlab/core/rule/service/impl/RuleItemServiceImpl.java
+7
-0
DSTRule.drl.ftl
ibzdst-core/src/main/resources/ftl/DSTRule.drl.ftl
+24
-0
h2_table.xml
ibzdst-core/src/main/resources/liquibase/h2_table.xml
+4
-4
systemResource.json
...st-core/src/main/resources/permission/systemResource.json
+3
-3
pom.xml
ibzdst-dependencies/pom.xml
+4
-0
DAMetricResource.java
...i/src/main/java/cn/ibizlab/api/rest/DAMetricResource.java
+22
-0
MetaEntityResource.java
...src/main/java/cn/ibizlab/api/rest/MetaEntityResource.java
+22
-0
RuleItemResource.java
...i/src/main/java/cn/ibizlab/api/rest/RuleItemResource.java
+11
-0
RuleUtils.java
...-util/src/main/java/cn/ibizlab/util/helper/RuleUtils.java
+52
-0
未找到文件。
app_web/src/mock/entity/dametrics/dametrics.ts
浏览文件 @
019d0297
...
@@ -427,6 +427,71 @@ mock.onPost(new RegExp(/^\/dametrics\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((
...
@@ -427,6 +427,71 @@ mock.onPost(new RegExp(/^\/dametrics\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((
return
[
status
,
data
];
return
[
status
,
data
];
});
});
// SyncRule
mock
.
onPost
(
new
RegExp
(
/^
\/
dabuilds
\/([
a-zA-Z0-9
\-\;]{1,35})\/
dametrics
\/([
a-zA-Z0-9
\-\;]{1,35})\/
syncrule$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:dametric 方法: SyncRule"
);
console
.
table
({
url
:
config
.
url
,
method
:
config
.
method
,
data
:
config
.
data
});
let
status
=
MockAdapter
.
mockStatus
(
config
);
if
(
status
!==
200
)
{
return
[
status
,
null
];
}
const
paramArray
:
Array
<
any
>
=
[
'build_id'
,
'metric_id'
];
const
matchArray
:
any
=
new
RegExp
(
/^
\/
dabuilds
\/([
a-zA-Z0-9
\-\;]{1,35})\/
dametrics
\/([
a-zA-Z0-9
\-\;]{1,35})\/
syncrule$/
).
exec
(
config
.
url
);
let
tempValue
:
any
=
{};
if
(
matchArray
&&
matchArray
.
length
>
1
&&
paramArray
&&
paramArray
.
length
>
0
){
paramArray
.
forEach
((
item
:
any
,
index
:
number
)
=>
{
Object
.
defineProperty
(
tempValue
,
item
,
{
enumerable
:
true
,
value
:
matchArray
[
index
+
1
]
});
});
}
console
.
groupCollapsed
(
"response数据 status: "
+
status
+
" data: "
);
console
.
table
({});
console
.
groupEnd
();
console
.
groupEnd
();
return
[
status
,
{}];
});
// SyncRule
mock
.
onPost
(
new
RegExp
(
/^
\/
dametrics
\/?([
a-zA-Z0-9
\-\;]{0,35})\/
syncrule$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:dametric 方法: SyncRule"
);
console
.
table
({
url
:
config
.
url
,
method
:
config
.
method
,
data
:
config
.
data
});
let
status
=
MockAdapter
.
mockStatus
(
config
);
if
(
status
!==
200
)
{
return
[
status
,
null
];
}
const
paramArray
:
Array
<
any
>
=
[
'metric_id'
];
const
matchArray
:
any
=
new
RegExp
(
/^
\/
dametrics
\/([
a-zA-Z0-9
\-\;]{1,35})\/
syncrule$/
).
exec
(
config
.
url
);
let
tempValue
:
any
=
{};
if
(
matchArray
&&
matchArray
.
length
>
1
&&
paramArray
&&
paramArray
.
length
>
0
){
paramArray
.
forEach
((
item
:
any
,
index
:
number
)
=>
{
Object
.
defineProperty
(
tempValue
,
item
,
{
enumerable
:
true
,
value
:
matchArray
[
index
+
1
]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.metric_id, tempValue.metric_id));
let
data
=
JSON
.
parse
(
config
.
data
);
mockDatas
.
forEach
((
item
)
=>
{
if
(
item
[
'metric_id'
]
==
tempValue
[
'metric_id'
]
){
for
(
let
value
in
data
){
if
(
item
.
hasOwnProperty
(
value
)){
item
[
value
]
=
data
[
value
];
}
}
}
})
console
.
groupCollapsed
(
"response数据 status: "
+
status
+
" data: "
);
console
.
table
(
data
);
console
.
groupEnd
();
console
.
groupEnd
();
return
[
status
,
data
];
});
// FetchDefault
// FetchDefault
mock
.
onGet
(
new
RegExp
(
/^
\/
dabuilds
\/([
a-zA-Z0-9
\-\;]{1,35})\/
dametrics
\/
fetchdefault$/
)).
reply
((
config
:
any
)
=>
{
mock
.
onGet
(
new
RegExp
(
/^
\/
dabuilds
\/([
a-zA-Z0-9
\-\;]{1,35})\/
dametrics
\/
fetchdefault$/
)).
reply
((
config
:
any
)
=>
{
...
...
app_web/src/mock/entity/meta-entitys/meta-entitys.ts
浏览文件 @
019d0297
...
@@ -362,6 +362,7 @@ mock.onPost(new RegExp(/^\/metaentities\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).
...
@@ -362,6 +362,7 @@ mock.onPost(new RegExp(/^\/metaentities\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).
return
[
status
,
data
];
return
[
status
,
data
];
});
});
// Save
// Save
mock
.
onPost
(
new
RegExp
(
/^
\/
dstsystems
\/([
a-zA-Z0-9
\-\;]{1,35})\/
metaentities
\/([
a-zA-Z0-9
\-\;]{1,35})\/
save$/
)).
reply
((
config
:
any
)
=>
{
mock
.
onPost
(
new
RegExp
(
/^
\/
dstsystems
\/([
a-zA-Z0-9
\-\;]{1,35})\/
metaentities
\/([
a-zA-Z0-9
\-\;]{1,35})\/
save$/
)).
reply
((
config
:
any
)
=>
{
...
@@ -649,3 +650,59 @@ mock.onGet(new RegExp(/^\/metaentities\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((confi
...
@@ -649,3 +650,59 @@ mock.onGet(new RegExp(/^\/metaentities\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((confi
console
.
groupEnd
();
console
.
groupEnd
();
return
[
status
,
_items
?
_items
:{}];
return
[
status
,
_items
?
_items
:{}];
});
});
// GetDefaultModel
mock
.
onGet
(
new
RegExp
(
/^
\/
dstsystems
\/([
a-zA-Z0-9
\-\;]{1,35})\/
metaentities
\/([
a-zA-Z0-9
\-\;]{1,35})\/
getdefaultmodel$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:metaentity 方法: GetDefaultModel"
);
console
.
table
({
url
:
config
.
url
,
method
:
config
.
method
,
data
:
config
.
data
});
let
status
=
MockAdapter
.
mockStatus
(
config
);
if
(
status
!==
200
)
{
return
[
status
,
null
];
}
const
paramArray
:
Array
<
any
>
=
[
'pssystemid'
,
'entity_id'
];
const
matchArray
:
any
=
new
RegExp
(
/^
\/
dstsystems
\/([
a-zA-Z0-9
\-\;]{1,35})\/
metaentities
\/([
a-zA-Z0-9
\-\;]{1,35})\/
getdefaultmodel$/
).
exec
(
config
.
url
);
let
tempValue
:
any
=
{};
if
(
matchArray
&&
matchArray
.
length
>
1
&&
paramArray
&&
paramArray
.
length
>
0
){
paramArray
.
forEach
((
item
:
any
,
index
:
number
)
=>
{
Object
.
defineProperty
(
tempValue
,
item
,
{
enumerable
:
true
,
value
:
matchArray
[
index
+
1
]
});
});
}
let
items
=
mockDatas
?
mockDatas
:
[];
let
_items
=
items
.
find
((
item
:
any
)
=>
Object
.
is
(
item
.
entity_id
,
tempValue
.
entity_id
));
console
.
groupCollapsed
(
"response数据 status: "
+
status
+
" data: "
);
console
.
table
(
_items
?
_items
:{});
console
.
groupEnd
();
console
.
groupEnd
();
return
[
status
,
_items
?
_items
:{}];
});
// GetDefaultModel
mock
.
onGet
(
new
RegExp
(
/^
\/
metaentities
\/([
a-zA-Z0-9
\-\;]{1,35})\/
getdefaultmodel$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:metaentity 方法: GetDefaultModel"
);
console
.
table
({
url
:
config
.
url
,
method
:
config
.
method
,
data
:
config
.
data
});
let
status
=
MockAdapter
.
mockStatus
(
config
);
if
(
status
!==
200
)
{
return
[
status
,
null
];
}
const
paramArray
:
Array
<
any
>
=
[
'entity_id'
];
const
matchArray
:
any
=
new
RegExp
(
/^
\/
metaentities
\/([
a-zA-Z0-9
\-\;]{1,35})\/
getdefaultmodel$/
).
exec
(
config
.
url
);
let
tempValue
:
any
=
{};
if
(
matchArray
&&
matchArray
.
length
>
1
&&
paramArray
&&
paramArray
.
length
>
0
){
paramArray
.
forEach
((
item
:
any
,
index
:
number
)
=>
{
Object
.
defineProperty
(
tempValue
,
item
,
{
enumerable
:
true
,
value
:
matchArray
[
index
+
1
]
});
});
}
let
items
=
mockDatas
?
mockDatas
:
[];
let
_items
=
items
.
find
((
item
:
any
)
=>
Object
.
is
(
item
.
entity_id
,
tempValue
.
entity_id
));
console
.
groupCollapsed
(
"response数据 status: "
+
status
+
" data: "
);
console
.
table
(
_items
?
_items
:{});
console
.
groupEnd
();
console
.
groupEnd
();
return
[
status
,
_items
?
_items
:{}];
});
app_web/src/mock/entity/rule-items/rule-items.ts
浏览文件 @
019d0297
...
@@ -195,6 +195,44 @@ mock.onGet(new RegExp(/^\/ruleitems\/getdraft$/)).reply((config: any) => {
...
@@ -195,6 +195,44 @@ mock.onGet(new RegExp(/^\/ruleitems\/getdraft$/)).reply((config: any) => {
return
[
status
,
{}];
return
[
status
,
{}];
});
});
// BuildRuleFile
mock
.
onPost
(
new
RegExp
(
/^
\/
ruleitems
\/?([
a-zA-Z0-9
\-\;]{0,35})\/
buildrulefile$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:ruleitem 方法: BuildRuleFile"
);
console
.
table
({
url
:
config
.
url
,
method
:
config
.
method
,
data
:
config
.
data
});
let
status
=
MockAdapter
.
mockStatus
(
config
);
if
(
status
!==
200
)
{
return
[
status
,
null
];
}
const
paramArray
:
Array
<
any
>
=
[
'rule_id'
];
const
matchArray
:
any
=
new
RegExp
(
/^
\/
ruleitems
\/([
a-zA-Z0-9
\-\;]{1,35})\/
buildrulefile$/
).
exec
(
config
.
url
);
let
tempValue
:
any
=
{};
if
(
matchArray
&&
matchArray
.
length
>
1
&&
paramArray
&&
paramArray
.
length
>
0
){
paramArray
.
forEach
((
item
:
any
,
index
:
number
)
=>
{
Object
.
defineProperty
(
tempValue
,
item
,
{
enumerable
:
true
,
value
:
matchArray
[
index
+
1
]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.rule_id, tempValue.rule_id));
let
data
=
JSON
.
parse
(
config
.
data
);
mockDatas
.
forEach
((
item
)
=>
{
if
(
item
[
'rule_id'
]
==
tempValue
[
'rule_id'
]
){
for
(
let
value
in
data
){
if
(
item
.
hasOwnProperty
(
value
)){
item
[
value
]
=
data
[
value
];
}
}
}
})
console
.
groupCollapsed
(
"response数据 status: "
+
status
+
" data: "
);
console
.
table
(
data
);
console
.
groupEnd
();
console
.
groupEnd
();
return
[
status
,
data
];
});
// CheckKey
// CheckKey
mock
.
onPost
(
new
RegExp
(
/^
\/
ruleitems
\/?([
a-zA-Z0-9
\-\;]{0,35})\/
checkkey$/
)).
reply
((
config
:
any
)
=>
{
mock
.
onPost
(
new
RegExp
(
/^
\/
ruleitems
\/?([
a-zA-Z0-9
\-\;]{0,35})\/
checkkey$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:ruleitem 方法: CheckKey"
);
console
.
groupCollapsed
(
"实体:ruleitem 方法: CheckKey"
);
...
...
app_web/src/service/dametric/dametric-service-base.ts
浏览文件 @
019d0297
...
@@ -225,6 +225,27 @@ export default class DAMetricServiceBase extends EntityService {
...
@@ -225,6 +225,27 @@ export default class DAMetricServiceBase extends EntityService {
return
res
;
return
res
;
}
}
/**
* SyncRule接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DAMetricServiceBase
*/
public
async
SyncRule
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
context
.
dabuild
&&
context
.
dametric
){
let
masterData
:
any
=
{};
Object
.
assign
(
data
,
masterData
);
let
res
:
any
=
await
Http
.
getInstance
().
post
(
`/dabuilds/
${
context
.
dabuild
}
/dametrics/
${
context
.
dametric
}
/syncrule`
,
data
,
isloading
);
return
res
;
}
let
res
:
any
=
Http
.
getInstance
().
post
(
`/dametrics/
${
context
.
dametric
}
/syncrule`
,
data
,
isloading
);
return
res
;
}
/**
/**
* FetchDefault接口方法
* FetchDefault接口方法
*
*
...
...
app_web/src/service/meta-entity/meta-entity-service-base.ts
浏览文件 @
019d0297
...
@@ -207,6 +207,26 @@ export default class MetaEntityServiceBase extends EntityService {
...
@@ -207,6 +207,26 @@ export default class MetaEntityServiceBase extends EntityService {
return
res
;
return
res
;
}
}
/**
* GetDefaultModel接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaEntityServiceBase
*/
public
async
GetDefaultModel
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
context
.
dstsystem
&&
context
.
metaentity
){
let
res
:
any
=
await
Http
.
getInstance
().
get
(
`/dstsystems/
${
context
.
dstsystem
}
/metaentities/
${
context
.
metaentity
}
/getdefaultmodel`
,
isloading
);
return
res
;
}
let
res
:
any
=
await
Http
.
getInstance
().
get
(
`/metaentities/
${
context
.
metaentity
}
/getdefaultmodel`
,
isloading
);
return
res
;
}
/**
/**
* Save接口方法
* Save接口方法
*
*
...
...
app_web/src/service/rule-item/rule-item-service-base.ts
浏览文件 @
019d0297
...
@@ -139,6 +139,20 @@ export default class RuleItemServiceBase extends EntityService {
...
@@ -139,6 +139,20 @@ export default class RuleItemServiceBase extends EntityService {
return
res
;
return
res
;
}
}
/**
* BuildRuleFile接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof RuleItemServiceBase
*/
public
async
BuildRuleFile
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
let
res
:
any
=
Http
.
getInstance
().
post
(
`/ruleitems/
${
context
.
ruleitem
}
/buildrulefile`
,
data
,
isloading
);
return
res
;
}
/**
/**
* CheckKey接口方法
* CheckKey接口方法
*
*
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/analysis/service/IDAMetricService.java
浏览文件 @
019d0297
...
@@ -36,6 +36,7 @@ public interface IDAMetricService extends IService<DAMetric> {
...
@@ -36,6 +36,7 @@ public interface IDAMetricService extends IService<DAMetric> {
boolean
checkKey
(
DAMetric
et
);
boolean
checkKey
(
DAMetric
et
);
boolean
save
(
DAMetric
et
);
boolean
save
(
DAMetric
et
);
void
saveBatch
(
List
<
DAMetric
>
list
);
void
saveBatch
(
List
<
DAMetric
>
list
);
DAMetric
syncRule
(
DAMetric
et
);
Page
<
DAMetric
>
searchDefault
(
DAMetricSearchContext
context
);
Page
<
DAMetric
>
searchDefault
(
DAMetricSearchContext
context
);
List
<
DAMetric
>
selectByBuildId
(
String
build_id
);
List
<
DAMetric
>
selectByBuildId
(
String
build_id
);
void
removeByBuildId
(
String
build_id
);
void
removeByBuildId
(
String
build_id
);
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/analysis/service/impl/DAMetricServiceImpl.java
浏览文件 @
019d0297
...
@@ -160,6 +160,13 @@ public class DAMetricServiceImpl extends ServiceImpl<DAMetricMapper, DAMetric> i
...
@@ -160,6 +160,13 @@ public class DAMetricServiceImpl extends ServiceImpl<DAMetricMapper, DAMetric> i
saveOrUpdateBatch
(
list
,
batchSize
);
saveOrUpdateBatch
(
list
,
batchSize
);
}
}
@Override
@Transactional
public
DAMetric
syncRule
(
DAMetric
et
)
{
//自定义代码
return
et
;
}
@Override
@Override
public
List
<
DAMetric
>
selectByBuildId
(
String
build_id
)
{
public
List
<
DAMetric
>
selectByBuildId
(
String
build_id
)
{
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/BaseEntity.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
cn.ibizlab.core.extensions.util.IEntityActionHelper
;
import
cn.ibizlab.util.helper.RuleUtils
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
public
class
BaseEntity
extends
ConcurrentHashMap
implements
IEntity
{
public
String
KEY
;
public
String
ENTITYNAME
;
public
String
KEYFIELDNAME
;
public
BaseEntity
FACTENTITY
;
public
BaseEntity
getFACTENTITY
()
{
return
FACTENTITY
;
}
public
void
setFACTENTITY
(
BaseEntity
FACTENTITY
)
{
this
.
FACTENTITY
=
FACTENTITY
;
}
@Override
public
String
toString
()
{
return
""
;
}
public
BaseEntity
findRoot
(
String
key
)
{
if
(
key
.
equalsIgnoreCase
(
"root"
)&&
super
.
containsKey
(
"rootentity"
))
{
return
(
BaseEntity
)
super
.
get
(
"rootentity"
);
}
return
null
;
}
public
void
regesitAttr
(
String
key
,
BaseEntity
val
)
{
if
(
key
.
equalsIgnoreCase
(
"root"
)&&
!
super
.
containsKey
(
"rootentity"
))
super
.
put
(
"rootentity"
,
val
);
}
private
IEntityActionHelper
iEntityActionHelper
=
null
;
public
static
BaseEntity
createEntity
(
String
factentity
,
BaseEntity
item
)
{
try
{
BaseEntity
bt
=(
BaseEntity
)
Class
.
forName
(
"net.ibizsys.dst.common.domain."
+
factentity
).
newInstance
();
bt
.
putAll
(
item
);
bt
.
regesitAttr
(
"root"
,
bt
);
return
bt
;
}
catch
(
Exception
ex
)
{
BaseEntity
bt
=
new
BaseEntity
();
bt
.
putAll
(
item
);
bt
.
regesitAttr
(
"root"
,
bt
);
return
bt
;
}
}
private
BaseField
nullFiled
=
new
BaseField
();
@Override
public
IField
$
(
String
key
)
{
if
(
StringUtils
.
isEmpty
(
key
))
return
nullFiled
;
Object
obj
=
this
.
get
(
key
);
if
(
obj
instanceof
IField
)
{
IField
f
=
(
IField
)
obj
;
if
(
f
.
getValue
()!=
null
&&
key
.
indexOf
(
"."
)>
0
)
{
String
[]
arr
=
key
.
split
(
"[.]"
);
if
(
arr
.
length
>=
2
)
{
if
((!
StringUtils
.
isEmpty
(
arr
[
0
]))&&(!
StringUtils
.
isEmpty
(
arr
[
1
])))
{
f
.
setEntity
(
arr
[
0
]);
f
.
setField
(
arr
[
1
]);
}
}
}
return
f
;
}
else
return
nullFiled
;
}
@Override
public
Double
$D
(
String
key
)
{
IField
field
=
this
.
$
(
key
);
Object
val
=
field
.
getValue
();
if
(
val
==
null
)
return
0
d
;
else
if
((
val
instanceof
Integer
)||(
val
instanceof
Double
)||(
val
instanceof
Long
)||(
val
instanceof
BigDecimal
)||(
val
instanceof
BigInteger
)||(
val
instanceof
Float
))
return
(
double
)
val
;
return
1
d
;
}
@Override
public
boolean
IF
(
String
cond
)
{
return
test
(
cond
);
}
public
boolean
isDel
(
String
members
)
{
String
[]
arr
=
members
.
split
(
"[.]"
);
if
(
arr
.
length
>=
2
&&(!
StringUtils
.
isEmpty
(
arr
[
0
])))
{
if
(
this
.
get
(
arr
[
0
]+
".SFSC"
)!=
null
)
{
if
(
this
.
get
(
arr
[
0
]+
".SFSC"
).
toString
().
equals
(
"Y"
)||
this
.
get
(
arr
[
0
]+
".SFSC"
).
toString
().
equals
(
"1"
))
{
return
true
;
}
}
}
return
false
;
}
@Override
public
boolean
test
(
String
cond
)
{
String
[]
arr
=
cond
.
split
(
"\\s+"
);
String
option
=
""
;
String
members
=
""
;
String
exp
=
""
;
if
(
arr
.
length
>=
2
)
{
members
=
arr
[
0
];
option
=
arr
[
1
];
}
String
[]
ms
=
members
.
split
(
"[.]"
);
if
(
ms
.
length
>=
2
&&(!
StringUtils
.
isEmpty
(
ms
[
0
])))
{
Object
sub
=
this
.
get
(
ms
[
0
]);
if
(
sub
!=
null
&&
sub
instanceof
BaseEntityList
)
{
return
((
BaseEntityList
)
sub
).
test
(
cond
);
}
}
if
(
arr
.
length
>=
3
)
{
exp
=
arr
[
2
];
if
(
exp
.
startsWith
(
"%"
))
{
if
(
isDel
(
members
))
{
return
false
;
}
return
test
(
this
,
members
,
option
,
execFunc
(
exp
));
}
}
if
(
isDel
(
members
))
{
return
false
;
}
return
test
(
this
,
members
,
option
,
exp
);
}
private
Object
execFunc
(
String
exp
)
{
Object
rt
=
null
;
exp
=
exp
.
replace
(
"%"
,
""
).
trim
();
if
(
exp
.
startsWith
(
"DAY("
))
{
Calendar
calendar
=
Calendar
.
getInstance
();
String
quStr
=
exp
.
substring
(
exp
.
indexOf
(
"("
)+
1
,
exp
.
indexOf
(
")"
));
quStr
=
quStr
.
replace
(
"+"
,
""
).
trim
();
int
day
=
0
;
if
(!
StringUtils
.
isEmpty
(
quStr
)){
day
=
Integer
.
parseInt
(
quStr
);
}
calendar
.
add
(
Calendar
.
DATE
,
day
);
return
new
Timestamp
(
calendar
.
getTime
().
getTime
());
}
else
if
(
exp
.
endsWith
(
")"
))
{
String
quStr
=
exp
.
substring
(
exp
.
indexOf
(
"("
)+
1
,
exp
.
indexOf
(
")"
));
exp
=
exp
.
substring
(
0
,
exp
.
indexOf
(
"("
)).
trim
();
quStr
=
quStr
.
replace
(
"+"
,
""
).
trim
();
Integer
day
=
0
;
if
(!
StringUtils
.
isEmpty
(
quStr
)){
day
=
Integer
.
parseInt
(
quStr
);
}
Object
val
=
null
;
if
(
this
.
findRoot
(
"root"
)!=
null
)
val
=
this
.
findRoot
(
"root"
).
$
(
exp
).
getValue
();
else
val
=
this
.
$
(
exp
).
getValue
();
if
(
val
!=
null
)
{
if
(
val
instanceof
Timestamp
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
((
Timestamp
)
val
);
calendar
.
add
(
Calendar
.
DATE
,
day
);
return
new
Timestamp
(
calendar
.
getTime
().
getTime
());
}
else
if
(
val
instanceof
Integer
)
{
return
(
int
)
val
+
day
;
}
else
if
(
val
instanceof
BigDecimal
)
{
return
((
BigDecimal
)
val
).
intValue
()+
day
;
}
}
return
val
;
}
if
(
this
.
findRoot
(
"root"
)!=
null
)
return
this
.
findRoot
(
"root"
).
$
(
exp
).
getValue
();
return
this
.
$
(
exp
).
getValue
();
}
public
static
boolean
test
(
BaseEntity
object
,
String
members
,
String
option
,
Object
exp
)
{
Object
obj
=
object
.
getObj
(
members
);
if
(
obj
==
null
)
obj
=
new
BaseField
();
if
(!(
obj
instanceof
IField
))
return
false
;
IField
field
=(
IField
)
obj
;
if
(
option
.
equalsIgnoreCase
(
"eq"
)||
option
.
equalsIgnoreCase
(
"equal"
)||
option
.
equalsIgnoreCase
(
"="
))
return
field
.
EQ
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"noteq"
)||
option
.
equalsIgnoreCase
(
"notequal"
)||
option
.
equalsIgnoreCase
(
"<>"
)||
option
.
equalsIgnoreCase
(
"!="
))
return
field
.
NOTEQ
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"gt"
)||
option
.
equalsIgnoreCase
(
">"
))
return
field
.
GT
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"lt"
)||
option
.
equalsIgnoreCase
(
"<"
))
return
field
.
LT
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"gtandeq"
)||
option
.
equalsIgnoreCase
(
"ge"
)||
option
.
equalsIgnoreCase
(
">="
))
return
field
.
GTANDEQ
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"ltandeq"
)||
option
.
equalsIgnoreCase
(
"le"
)||
option
.
equalsIgnoreCase
(
"<="
))
return
field
.
LTANDEQ
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"null"
)||
option
.
equalsIgnoreCase
(
"isnull"
))
return
field
.
ISNULL
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"notnull"
)||
option
.
equalsIgnoreCase
(
"isnotnull"
))
return
field
.
ISNOTNULL
(
exp
);
else
if
(
option
.
equalsIgnoreCase
(
"like"
)||
option
.
equalsIgnoreCase
(
"matchor"
))
return
field
.
LIKE
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"leftlike"
)||
option
.
equalsIgnoreCase
(
"startswith"
))
return
field
.
LEFTLIKE
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"rightlike"
)||
option
.
equalsIgnoreCase
(
"endswith"
))
return
field
.
RIGHTLIKE
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"match"
)||
option
.
equalsIgnoreCase
(
"matchand"
)||
option
.
equalsIgnoreCase
(
"matches"
))
return
field
.
MATCHES
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"in"
))
return
field
.
IN
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"notin"
))
return
field
.
NOTIN
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"inc2s"
))
return
field
.
INC2S
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"notinc2s"
))
return
field
.
NOTINC2S
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"NOTLIKE"
))
return
field
.
NOTLIKE
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"LEFTNOTLIKE"
))
return
field
.
LEFTNOTLIKE
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"RIGHTNOTLIKE"
))
return
field
.
RIGHTNOTLIKE
(
exp
.
toString
());
else
if
(
option
.
equalsIgnoreCase
(
"NOTMATCHES"
))
return
field
.
NOTMATCHES
(
exp
.
toString
());
else
return
false
;
}
@Override
public
void
setActionHelper
(
IEntityActionHelper
iEntityActionHelper
)
{
this
.
iEntityActionHelper
=
iEntityActionHelper
;
}
@Override
public
IEntityActionHelper
getActionHelper
()
{
if
(
this
.
iEntityActionHelper
==
null
)
{
return
null
;
}
return
this
.
iEntityActionHelper
;
}
@Override
public
List
<
BaseEntity
>
selectRow
(
String
dblink
,
String
sql
)
{
return
this
.
getActionHelper
().
select
(
dblink
,
sql
);
}
public
void
onFillObj
(
Object
key
)
{
if
(
key
.
toString
().
equalsIgnoreCase
(
this
.
ENTITYNAME
))
{
if
(
this
.
getFACTENTITY
()==
null
)
this
.
set
(
key
.
toString
(),
this
);
else
this
.
set
(
key
.
toString
()
,
this
.
getFACTENTITY
());
return
;
}
DSTEntityModel
entityModel
=
this
.
getActionHelper
().
getModel
(
this
.
ENTITYNAME
);
DSTEntityModel
refmodel
=
this
.
getActionHelper
().
getModel
(
key
.
toString
());
if
(
refmodel
!=
null
&&
entityModel
!=
null
&&
entityModel
.
getLookups
().
containsKey
(
key
.
toString
()))
{
this
.
getRow
(
refmodel
.
getDblink
(),
key
.
toString
(),
refmodel
.
getSqltable
(),
entityModel
.
getLookups
().
get
(
key
.
toString
()).
getSelectCondition
(),
entityModel
.
getLookups
().
get
(
key
.
toString
()).
getParamsCondition
());
}
else
{
BaseEntity
ret
=
new
BaseEntity
();
this
.
put
(
key
,
ret
);
}
}
private
Object
objLock
=
new
Object
();
private
Hashtable
<
Object
,
Integer
>
filled
=
new
Hashtable
<
Object
,
Integer
>();
@Override
public
IEntity
$E
(
String
key
)
{
synchronized
(
objLock
)
{
if
(!
filled
.
containsKey
(
key
))
{
// if(!StringUtils.isEmpty(CodeListBase.getCodeListText("DST_CLEntityCodeList",key.toString())))
// this.onFillObj(key);
filled
.
put
(
key
,
1
);
}
}
Object
val
=
super
.
get
(
key
);
if
(
val
instanceof
IEntity
)
return
(
IEntity
)
val
;
else
if
(
val
!=
null
&&
val
.
getClass
().
isArray
()){
BaseEntityList
list
=
new
BaseEntityList
();
List
<
BaseEntity
>
acts
=(
ArrayList
)
val
;
if
(
acts
.
size
()==
1
)
{
this
.
put
(
key
,
acts
.
get
(
0
));
return
acts
.
get
(
0
);
}
for
(
BaseEntity
item
:
acts
)
list
.
add
(
item
);
this
.
put
(
key
,
list
);
}
else
{
val
=
new
BaseEntity
();
this
.
put
(
key
,
val
);
}
return
(
IEntity
)
val
;
}
@Override
public
Object
get
(
Object
key
)
{
if
(
key
.
toString
().
indexOf
(
"."
)>
0
)
return
this
.
getObj
(
key
.
toString
());
synchronized
(
objLock
)
{
if
(!
filled
.
containsKey
(
key
))
{
// if(!StringUtils.isEmpty(CodeListBase.getCodeListText("DST_CLEntityCodeList",key.toString())))
// this.onFillObj(key);
filled
.
put
(
key
,
1
);
}
}
Object
val
=
super
.
get
(
key
);
if
(
val
instanceof
IField
)
return
val
;
else
if
(
val
instanceof
IEntity
)
return
val
;
else
if
(
val
!=
null
&&
val
.
getClass
().
isArray
()){
BaseEntityList
list
=
new
BaseEntityList
();
List
<
BaseEntity
>
acts
=(
ArrayList
)
val
;
if
(
acts
.
size
()==
1
)
{
this
.
put
(
key
,
acts
.
get
(
0
));
return
acts
.
get
(
0
);
}
for
(
BaseEntity
item
:
acts
)
list
.
add
(
item
);
this
.
put
(
key
,
list
);
}
else
{
BaseField
field
=
new
BaseField
();
field
.
setValue
(
val
);
this
.
put
(
key
,
field
);
}
return
val
;
}
@Override
public
Object
put
(
Object
key
,
Object
val
)
{
if
(
val
instanceof
IField
)
return
super
.
put
(
key
,
val
);
else
if
(
val
instanceof
IEntity
)
{
((
IEntity
)
val
).
setENTITYNAME
(
key
.
toString
());
((
IEntity
)
val
).
regesitAttr
(
"root"
,
this
.
findRoot
(
"root"
));
return
super
.
put
(
key
,
val
);
}
else
if
(
val
!=
null
&&
val
.
getClass
().
isArray
()){
BaseEntityList
list
=
new
BaseEntityList
();
List
<
BaseEntity
>
acts
=(
ArrayList
)
val
;
if
(
acts
.
size
()==
1
)
{
acts
.
get
(
0
).
setENTITYNAME
(
key
.
toString
());
acts
.
get
(
0
).
regesitAttr
(
"root"
,
this
.
findRoot
(
"root"
));
return
super
.
put
(
key
,
acts
.
get
(
0
));
}
for
(
BaseEntity
item
:
acts
)
{
item
.
setENTITYNAME
(
key
.
toString
());
item
.
regesitAttr
(
"root"
,
this
.
findRoot
(
"root"
));
list
.
add
(
item
);
}
list
.
setENTITYNAME
(
key
.
toString
());
list
.
regesitAttr
(
"root"
,
this
.
findRoot
(
"root"
));
return
super
.
put
(
key
,
list
);
}
else
{
BaseField
field
=
new
BaseField
();
field
.
setValue
(
val
);
return
super
.
put
(
key
,
field
);
}
}
public
void
putEntity
(
String
key
,
BaseEntity
val
)
{
if
(
val
==
null
)
{
return
;
}
synchronized
(
objLock
)
{
if
(!
filled
.
containsKey
(
key
))
{
this
.
put
(
key
,
val
);
filled
.
put
(
key
,
1
);
return
;
}
}
}
public
void
addEntity
(
String
key
,
BaseEntity
val
)
{
if
(
val
==
null
)
{
return
;
}
val
.
setENTITYNAME
(
key
);
val
.
regesitAttr
(
"root"
,
this
.
findRoot
(
"root"
));
synchronized
(
objLock
)
{
if
(!
filled
.
containsKey
(
key
))
{
this
.
put
(
key
,
val
);
filled
.
put
(
key
,
1
);
return
;
}
}
Object
obj
=
super
.
get
(
key
);
if
(
obj
instanceof
BaseEntity
)
{
BaseEntityList
list
=
new
BaseEntityList
();
list
.
add
((
BaseEntity
)
obj
);
list
.
add
(
val
);
list
.
setENTITYNAME
(
key
);
list
.
regesitAttr
(
"root"
,
this
.
findRoot
(
"root"
));
this
.
put
(
key
,
list
);
}
else
if
(
obj
instanceof
BaseEntityList
)
{
((
BaseEntityList
)
obj
).
add
(
val
);
}
else
{
this
.
put
(
key
,
val
);
}
}
public
Object
set
(
Object
key
,
Object
val
)
{
return
this
.
put
(
key
,
val
);
}
public
Object
getObj
(
String
key
)
{
return
RuleUtils
.
getObj
(
this
,
key
);
}
public
Object
getRow
(
String
dblink
,
String
itemkey
,
String
selectcommand
,
String
lookupcond
,
List
<
String
>
lookupkeys
)
{
if
(
StringUtils
.
isEmpty
(
selectcommand
))
selectcommand
=
"select * from "
+
itemkey
+
" where 1=1 "
;
List
<
String
>
params
=
new
ArrayList
<
String
>();
for
(
String
lookupkey:
lookupkeys
)
{
Object
key
=
this
.
getObj
(
lookupkey
);
if
((
key
instanceof
IField
))
{
params
.
add
(((
IField
)
key
).
getCondValue
());
}
else
params
.
add
(
"null"
);
}
List
<
BaseEntity
>
list
=
this
.
selectRow
(
dblink
,
selectcommand
+
String
.
format
(
lookupcond
,
params
.
toArray
()));
if
(
list
==
null
||
list
.
size
()==
0
)
{
BaseEntity
ret
=
new
BaseEntity
();
this
.
put
(
itemkey
,
ret
);
return
ret
;
}
else
if
(
list
.
size
()==
1
)
{
this
.
put
(
itemkey
,
list
.
get
(
0
));
return
list
.
get
(
0
);
}
else
{
BaseEntityList
rt
=
new
BaseEntityList
();
for
(
BaseEntity
item
:
list
)
{
item
.
setENTITYNAME
(
itemkey
);
item
.
regesitAttr
(
"root"
,
this
.
findRoot
(
"root"
));
rt
.
add
(
item
);
}
this
.
put
(
itemkey
,
rt
);
return
rt
;
}
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/BaseEntityList.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
cn.ibizlab.core.extensions.util.IEntityActionHelper
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Data
;
import
org.springframework.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.List
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
public
class
BaseEntityList
extends
ArrayList
<
BaseEntity
>
implements
IEntity
{
public
String
KEY
;
public
String
ENTITYNAME
;
private
BaseField
nullFiled
=
new
BaseField
();
private
BaseEntity
root
;
public
void
regesitAttr
(
String
key
,
BaseEntity
val
)
{
if
(
key
.
equalsIgnoreCase
(
"root"
)&&
root
==
null
)
root
=
val
;
}
@Override
public
IEntity
$E
(
String
key
)
{
return
new
BaseEntity
();
}
@Override
public
Object
get
(
Object
key
)
{
if
(
key
instanceof
Integer
)
return
super
.
get
((
int
)
key
);
BaseFieldList
list
=
new
BaseFieldList
();
for
(
BaseEntity
item:
this
)
{
Object
val
=
item
.
get
(
key
);
if
(
val
instanceof
BaseField
)
list
.
add
((
BaseField
)
val
);
}
if
(
list
.
size
()==
1
)
return
list
.
get
(
0
);
else
if
(
list
.
size
()==
0
)
return
nullFiled
;
else
return
list
;
}
@Override
public
IField
$
(
String
key
)
{
if
(
StringUtils
.
isEmpty
(
key
))
return
nullFiled
;
Object
obj
=
this
.
get
(
key
);
if
(
obj
instanceof
IField
)
{
IField
f
=
(
IField
)
obj
;
if
(
f
.
getValue
()!=
null
&&
key
.
indexOf
(
"."
)>
0
)
{
String
[]
arr
=
key
.
split
(
"[.]"
);
if
(
arr
.
length
>=
2
)
{
if
((!
StringUtils
.
isEmpty
(
arr
[
0
]))&&(!
StringUtils
.
isEmpty
(
arr
[
1
])))
{
f
.
setEntity
(
arr
[
0
]);
f
.
setField
(
arr
[
1
]);
}
}
}
return
f
;
}
else
return
nullFiled
;
}
@Override
public
Double
$D
(
String
key
)
{
IField
field
=
this
.
$
(
key
);
Object
val
=
field
.
getValue
();
if
(
field
instanceof
BaseFieldList
)
val
=((
BaseFieldList
)
field
).
get
(
0
);
if
(
val
==
null
)
return
0
d
;
else
if
((
val
instanceof
Integer
)||(
val
instanceof
Double
)||(
val
instanceof
Long
)||(
val
instanceof
BigDecimal
)||(
val
instanceof
BigInteger
)||(
val
instanceof
Float
))
return
(
double
)
val
;
return
1
d
;
}
@Override
public
boolean
IF
(
String
cond
)
{
return
test
(
cond
);
}
@Override
public
boolean
test
(
String
cond
)
{
{
for
(
BaseEntity
obj:
this
)
{
obj
.
setENTITYNAME
(
this
.
ENTITYNAME
);
if
(
obj
.
test
(
cond
))
return
true
;
}
return
false
;
}
}
private
IEntityActionHelper
iEntityActionHelper
=
null
;
@Override
public
void
setActionHelper
(
IEntityActionHelper
iEntityActionHelper
)
{
this
.
iEntityActionHelper
=
iEntityActionHelper
;
}
@Override
public
IEntityActionHelper
getActionHelper
()
{
if
(
this
.
iEntityActionHelper
==
null
)
{
return
null
;
}
return
this
.
iEntityActionHelper
;
}
@Override
public
List
<
BaseEntity
>
selectRow
(
String
dblink
,
String
sql
)
{
return
(
BaseEntityList
)
this
.
getActionHelper
().
select
(
dblink
,
sql
);
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/BaseField.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
cn.ibizlab.util.helper.RuleUtils
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Data
;
import
org.springframework.util.ObjectUtils
;
import
java.io.BufferedReader
;
import
java.io.Reader
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
public
class
BaseField
implements
IField
{
private
String
field
;
private
String
entity
;
private
Object
value
=
null
;
public
void
setValue
(
Object
value
)
{
if
(
value
instanceof
java
.
sql
.
Clob
)
{
// Clob类型 转String
BufferedReader
br
=
null
;
Reader
is
=
null
;
try
{
String
reString
=
""
;
is
=
((
java
.
sql
.
Clob
)
value
).
getCharacterStream
();
br
=
new
BufferedReader
(
is
);
String
s
=
br
.
readLine
();
StringBuffer
sb
=
new
StringBuffer
();
while
(
s
!=
null
)
{
sb
.
append
(
s
);
s
=
br
.
readLine
();
}
reString
=
sb
.
toString
();
this
.
value
=
reString
;
}
catch
(
Exception
ex
)
{
}
finally
{
try
{
if
(
br
!=
null
){
br
.
close
();
}
}
catch
(
Exception
ex
)
{}
try
{
if
(
is
!=
null
){
is
.
close
();
}
}
catch
(
Exception
ex
)
{}
}
}
else
this
.
value
=
value
;
}
public
Object
getValue
()
{
return
this
.
value
;
}
@Override
public
String
getCondValue
()
{
Object
val
=
getValue
();
if
(
ObjectUtils
.
isEmpty
(
val
))
return
"null"
;
String
str
=
""
;
if
((
val
instanceof
Integer
)||(
val
instanceof
Double
)||(
val
instanceof
Long
)||(
val
instanceof
BigDecimal
)||(
val
instanceof
BigInteger
)||(
val
instanceof
Float
))
str
=
val
.
toString
();
else
str
=
"'"
+
val
.
toString
()+
"'"
;
return
str
;
}
@Override
public
Object
getFecthValue
()
{
return
getValue
();
}
public
static
BaseField
from
(
Object
value
)
{
BaseField
field
=
new
BaseField
();
field
.
setValue
(
value
);
return
field
;
}
@Override
public
boolean
EQ
(
Object
val
)
{
return
RuleUtils
.
equal
(
val
,
this
.
value
);
}
@Override
public
boolean
NOTEQ
(
Object
val
)
{
return
!
RuleUtils
.
equal
(
val
,
this
.
value
);
}
@Override
public
boolean
GTANDEQ
(
Object
val
)
{
return
RuleUtils
.
ge
(
val
,
this
.
value
);
}
@Override
public
boolean
GT
(
Object
val
)
{
return
RuleUtils
.
gt
(
val
,
this
.
value
);
}
@Override
public
boolean
LTANDEQ
(
Object
val
)
{
return
RuleUtils
.
le
(
val
,
this
.
value
);
}
@Override
public
boolean
LT
(
Object
val
)
{
return
RuleUtils
.
lt
(
val
,
this
.
value
);
}
@Override
public
boolean
ISNULL
(
Object
val
)
{
return
RuleUtils
.
isNull
(
this
.
value
);
}
@Override
public
boolean
ISNOTNULL
(
Object
val
)
{
return
RuleUtils
.
isNotNull
(
this
.
value
);
}
@Override
public
boolean
LIKE
(
String
val
)
{
return
RuleUtils
.
matchor
(
val
,
this
.
value
);
}
@Override
public
boolean
LEFTLIKE
(
String
val
)
{
return
RuleUtils
.
leftmatchor
(
val
,
this
.
value
);
}
@Override
public
boolean
RIGHTLIKE
(
String
val
)
{
return
RuleUtils
.
rightmatchor
(
val
,
this
.
value
);
}
@Override
public
boolean
IN
(
String
val
)
{
return
RuleUtils
.
in
(
val
,
this
.
value
);
}
@Override
public
boolean
NOTIN
(
String
val
)
{
return
RuleUtils
.
notin
(
val
,
this
.
value
);
}
@Override
public
boolean
INC2S
(
String
val
)
{
return
RuleUtils
.
inc2s
(
val
,
this
.
value
);
}
@Override
public
boolean
NOTINC2S
(
String
val
)
{
return
RuleUtils
.
notinc2s
(
val
,
this
.
value
);
}
@Override
public
boolean
MATCHES
(
String
val
)
{
return
RuleUtils
.
matchand
(
val
,
this
.
value
);
}
@Override
public
String
toString
()
{
if
(
ObjectUtils
.
isEmpty
(
this
.
getValue
()))
return
""
;
else
return
this
.
getValue
().
toString
();
}
@Override
public
boolean
NOTLIKE
(
String
val
)
{
return
!
LIKE
(
val
);
}
@Override
public
boolean
LEFTNOTLIKE
(
String
val
)
{
return
!
LEFTLIKE
(
val
);
}
@Override
public
boolean
RIGHTNOTLIKE
(
String
val
)
{
return
!
RIGHTLIKE
(
val
);
}
@Override
public
boolean
NOTMATCHES
(
String
val
)
{
return
!
MATCHES
(
val
);
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/BaseFieldList.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Data
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.Hashtable
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
public
class
BaseFieldList
extends
ArrayList
<
BaseField
>
implements
IField
{
private
String
field
;
private
String
entity
;
public
Object
getValue
()
{
String
rt
=
""
;
Hashtable
<
Object
,
Integer
>
setcheck
=
new
Hashtable
<
Object
,
Integer
>();
if
(
this
.
size
()==
0
)
return
null
;
if
(
this
.
size
()==
1
)
return
this
.
get
(
0
).
getValue
();
Object
sObj
=
null
;
for
(
BaseField
obj:
this
)
{
Object
val
=
obj
.
getValue
();
if
(
ObjectUtils
.
isEmpty
(
val
))
continue
;
if
(
setcheck
.
containsKey
(
val
))
continue
;
else
setcheck
.
put
(
val
,
1
);
String
str
=
val
.
toString
();
sObj
=
val
;
if
(!
StringUtils
.
isEmpty
(
rt
))
rt
=
rt
+
","
;
rt
=
rt
+
str
;
}
if
(
StringUtils
.
isEmpty
(
rt
))
rt
=
null
;
if
(
setcheck
.
size
()==
1
)
return
sObj
;
return
rt
;
}
@Override
public
String
getCondValue
()
{
String
rt
=
""
;
Hashtable
<
Object
,
Integer
>
setcheck
=
new
Hashtable
<
Object
,
Integer
>();
for
(
BaseField
obj:
this
)
{
Object
val
=
obj
.
getValue
();
if
(
ObjectUtils
.
isEmpty
(
val
))
continue
;
if
(
setcheck
.
containsKey
(
val
))
continue
;
else
setcheck
.
put
(
val
,
1
);
String
str
=
""
;
if
((
val
instanceof
Integer
)||(
val
instanceof
Double
)||(
val
instanceof
Long
)||(
val
instanceof
BigDecimal
)||(
val
instanceof
BigInteger
)||(
val
instanceof
Float
))
str
=
val
.
toString
();
else
str
=
"'"
+
val
.
toString
()+
"'"
;
if
(!
StringUtils
.
isEmpty
(
rt
))
rt
=
rt
+
","
;
rt
=
rt
+
str
;
}
if
(
StringUtils
.
isEmpty
(
rt
))
rt
=
"null"
;
return
rt
;
}
@Override
public
Object
getFecthValue
()
{
return
null
;
}
@Override
public
boolean
EQ
(
Object
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
EQ
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
NOTEQ
(
Object
val
)
{
return
!
EQ
(
val
);
}
@Override
public
boolean
GTANDEQ
(
Object
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
GTANDEQ
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
GT
(
Object
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
GT
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
LTANDEQ
(
Object
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
LTANDEQ
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
LT
(
Object
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
LT
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
ISNULL
(
Object
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
ISNULL
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
ISNOTNULL
(
Object
val
)
{
return
!
ISNULL
(
val
);
}
@Override
public
boolean
LIKE
(
String
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
LIKE
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
LEFTLIKE
(
String
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
LEFTLIKE
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
RIGHTLIKE
(
String
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
RIGHTLIKE
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
IN
(
String
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
IN
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
NOTIN
(
String
val
)
{
return
!
IN
(
val
);
}
@Override
public
boolean
INC2S
(
String
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
INC2S
(
val
))
return
true
;
return
false
;
}
@Override
public
boolean
NOTINC2S
(
String
val
)
{
return
!
INC2S
(
val
);
}
@Override
public
boolean
MATCHES
(
String
val
)
{
for
(
BaseField
obj:
this
)
if
(
obj
.
MATCHES
(
val
))
return
true
;
return
false
;
}
@Override
public
String
toString
()
{
if
(
ObjectUtils
.
isEmpty
(
this
.
getValue
()))
return
""
;
else
{
String
rt
=
""
;
for
(
BaseField
obj:
this
)
{
Object
val
=
obj
.
getValue
();
if
(
ObjectUtils
.
isEmpty
(
val
))
continue
;
String
str
=
val
.
toString
();
if
(!
StringUtils
.
isEmpty
(
rt
))
rt
=
rt
+
","
;
rt
=
rt
+
str
;
}
if
(
StringUtils
.
isEmpty
(
rt
))
rt
=
""
;
return
rt
;
}
}
@Override
public
boolean
NOTLIKE
(
String
val
)
{
return
!
LIKE
(
val
);
}
@Override
public
boolean
LEFTNOTLIKE
(
String
val
)
{
return
!
LEFTLIKE
(
val
);
}
@Override
public
boolean
RIGHTNOTLIKE
(
String
val
)
{
return
!
RIGHTLIKE
(
val
);
}
@Override
public
boolean
NOTMATCHES
(
String
val
)
{
return
!
MATCHES
(
val
);
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/DSTEntityModel.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
cn.ibizlab.core.lite.domain.MetaField
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
@Data
public
class
DSTEntityModel
implements
Serializable
{
private
String
dblink
;
private
String
sqltable
;
private
String
sqlKeyField
;
private
String
getCondition
;
private
Map
<
String
,
DSTLookupModel
>
lookups
;
private
List
<
String
>
releations
;
private
List
<
String
>
subentity
;
private
List
<
MetaField
>
keyFields
;
private
List
<
MetaField
>
f1nFields
;
private
List
<
MetaField
>
fn1Fields
;
private
String
lastUpdateField
;
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/DSTLookupModel.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
@Data
public
class
DSTLookupModel
implements
Serializable
{
private
String
refentity
;
private
String
selectCondition
;
private
List
<
String
>
reffieldsCondition
;
private
String
entity
;
private
List
<
String
>
paramsCondition
;
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/IEntity.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
cn.ibizlab.core.extensions.util.IEntityActionHelper
;
import
java.io.Serializable
;
import
java.util.List
;
public
interface
IEntity
extends
Serializable
{
Object
get
(
Object
key
);
String
getENTITYNAME
();
void
setENTITYNAME
(
String
name
);
void
regesitAttr
(
String
key
,
BaseEntity
val
);
String
getKEY
();
void
setKEY
(
String
KEY
);
IField
$
(
String
key
);
Double
$D
(
String
key
);
IEntity
$E
(
String
key
);
boolean
IF
(
String
cond
);
boolean
test
(
String
cond
);
void
setActionHelper
(
IEntityActionHelper
iEntityActionHelper
);
/**
* 获取操作辅助对象
*
* @return
*/
IEntityActionHelper
getActionHelper
();
List
<
BaseEntity
>
selectRow
(
String
dblink
,
String
sql
);
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/IField.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
java.io.Serializable
;
public
interface
IField
extends
Serializable
{
String
getField
();
void
setField
(
String
field
);
String
getEntity
();
void
setEntity
(
String
entity
);
Object
getValue
();
String
getCondValue
();
Object
getFecthValue
();
boolean
EQ
(
Object
val
);
boolean
NOTEQ
(
Object
val
);
boolean
GTANDEQ
(
Object
val
);
boolean
GT
(
Object
val
);
boolean
LTANDEQ
(
Object
val
);
boolean
LT
(
Object
val
);
boolean
ISNULL
(
Object
val
);
boolean
ISNOTNULL
(
Object
val
);
boolean
LIKE
(
String
val
);
boolean
LEFTLIKE
(
String
val
);
boolean
RIGHTLIKE
(
String
val
);
boolean
NOTLIKE
(
String
val
);
boolean
LEFTNOTLIKE
(
String
val
);
boolean
RIGHTNOTLIKE
(
String
val
);
boolean
IN
(
String
val
);
boolean
NOTIN
(
String
val
);
boolean
INC2S
(
String
val
);
boolean
NOTINC2S
(
String
val
);
boolean
MATCHES
(
String
val
);
boolean
NOTMATCHES
(
String
val
);
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BaseEntityService.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.domain.BaseEntity
;
import
cn.ibizlab.core.extensions.domain.IEntity
;
import
cn.ibizlab.core.extensions.domain.IField
;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.List
;
/**
* 实体[DSTEntity] 服务对象接口
*/
public
interface
BaseEntityService
extends
IService
<
BaseEntity
>
{
void
resetKC
(
String
keyC
);
List
<
BaseEntity
>
selectRow
(
String
dblink
,
String
sql
);
ExecLog
processAll
(
BadRequestAlertException
msg
);
void
saveResult
(
IEntity
param
,
String
RULEID
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
String
BUSINESSCAT
,
Integer
RETVALUE
,
Object
KEYVALUEFIELD
,
IField
DOMAINSFIELD
,
IField
METRICFIELD
,
IField
TIMEFIELD
,
IField
EXT1FIELD
,
IField
EXT2FIELD
);
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/DAMetricExService.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.analysis.service.impl.DAMetricServiceImpl
;
import
cn.ibizlab.core.rule.domain.RuleItem
;
import
cn.ibizlab.core.rule.service.IRuleItemService
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.ibizlab.core.analysis.domain.DAMetric
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Primary
;
import
java.util.*
;
/**
* 实体[指标] 自定义服务对象
*/
@Slf4j
@Primary
@Service
(
"DAMetricExService"
)
public
class
DAMetricExService
extends
DAMetricServiceImpl
{
@Autowired
@Lazy
IRuleItemService
ruleService
;
@Override
public
boolean
create
(
DAMetric
et
)
{
super
.
create
(
et
);
syncRule
(
et
);
return
true
;
}
@Override
public
boolean
update
(
DAMetric
et
)
{
super
.
update
(
et
);
syncRule
(
et
);
return
true
;
}
@Override
protected
Class
currentModelClass
()
{
return
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
ReflectionKit
.
getSuperClassGenericType
(
this
.
getClass
().
getSuperclass
(),
1
);
}
/**
* [SyncRule:同步指标到规则] 行为扩展
* @param et
* @return
*/
@Override
@Transactional
public
DAMetric
syncRule
(
DAMetric
et
)
{
RuleItem
rule
=
new
RuleItem
();
rule
.
setRuleCode
(
et
.
getMetricId
());
rule
.
setRuleName
(
et
.
getMetricName
());
rule
.
setModelId
(
et
.
getModelId
());
rule
.
setModelName
(
et
.
getModelName
());
rule
.
setCfg
(
et
.
getCfg
());
rule
.
setFieldSet
(
et
.
getFieldSet
());
rule
.
setGroup
(
"REP"
);
rule
.
setBusinessCat
(
et
.
getMetricType
());
rule
.
setMemo
(
et
.
getModelName
()+
"."
+
et
.
getMetricName
());
ruleService
.
save
(
rule
);
return
super
.
syncRule
(
et
);
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/MetaEntityExService.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.lite.service.impl.MetaEntityServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.extensions.service.LiteModelService
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
java.util.*
;
/**
* 实体[实体] 自定义服务对象
*/
@Slf4j
@Primary
@Service
(
"MetaEntityExService"
)
public
class
MetaEntityExService
extends
MetaEntityServiceImpl
{
@Override
protected
Class
currentModelClass
()
{
return
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
ReflectionKit
.
getSuperClassGenericType
(
this
.
getClass
().
getSuperclass
(),
1
);
}
/**
* [GetDefaultModel:GetDefaultModel] 行为扩展
* @param et
* @return
*/
@Override
@Transactional
public
MetaEntity
getDefaultModel
(
MetaEntity
et
)
{
return
super
.
getDefaultModel
(
et
);
}
@Autowired
@Lazy
private
LiteModelService
liteModelService
;
@Override
public
boolean
update
(
MetaEntity
et
)
{
if
(!
super
.
update
(
et
))
return
false
;
liteModelService
.
resetEntityModel
(
et
.
getSystemId
(),
et
.
getEntityName
());
return
true
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/RuleItemExService.java
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.util.FreeMakerHelper
;
import
cn.ibizlab.core.rule.service.impl.RuleItemServiceImpl
;
import
cn.ibizlab.core.rule.service.impl.RuleItemServiceImpl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.ibizlab.core.rule.domain.RuleItem
;
import
cn.ibizlab.core.rule.domain.RuleItem
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.util.*
;
import
java.util.*
;
/**
/**
...
@@ -18,6 +22,22 @@ import java.util.*;
...
@@ -18,6 +22,22 @@ import java.util.*;
@Service
(
"RuleItemExService"
)
@Service
(
"RuleItemExService"
)
public
class
RuleItemExService
extends
RuleItemServiceImpl
{
public
class
RuleItemExService
extends
RuleItemServiceImpl
{
@Value
(
"${ibiz.rulepath:/app/file/rules/}"
)
String
rulePath
;
private
Object
lockModel
=
new
Object
();
@Override
public
boolean
create
(
RuleItem
et
)
{
buildRuleFile
(
et
);
return
super
.
create
(
et
);
}
@Override
public
boolean
update
(
RuleItem
et
)
{
buildRuleFile
(
et
);
return
super
.
update
(
et
);
}
@Override
@Override
protected
Class
currentModelClass
()
{
protected
Class
currentModelClass
()
{
return
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
ReflectionKit
.
getSuperClassGenericType
(
this
.
getClass
().
getSuperclass
(),
1
);
return
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
ReflectionKit
.
getSuperClassGenericType
(
this
.
getClass
().
getSuperclass
(),
1
);
...
@@ -37,5 +57,341 @@ public class RuleItemExService extends RuleItemServiceImpl {
...
@@ -37,5 +57,341 @@ public class RuleItemExService extends RuleItemServiceImpl {
}
}
return
super
.
modelchange
(
et
);
return
super
.
modelchange
(
et
);
}
}
/**
* 按照规则生成drl文件
* @param et
* @throws Exception
*/
@Override
public
RuleItem
buildRuleFile
(
RuleItem
et
){
try
{
//获取实体配置信息
String
strCfg
=
et
.
getCfg
();
String
strRuleid
=
et
.
getRuleId
();
String
strRulename
=
et
.
getRuleName
();
String
strMemo
=
et
.
getMemo
();
String
strRuleGroup
=
et
.
getGroup
();
String
strFieldset
=
et
.
getFieldSet
();
String
strMetricfield
=
""
,
strTimefield
=
""
,
strExt1field
=
""
,
strKeyvaluefield
=
""
,
strExt2field
=
""
,
strDomainsfield
=
""
,
strDimfield
=
""
,
strBusinesscatfield
=
""
;
if
(
StringUtils
.
isEmpty
(
strRuleGroup
)){
log
.
error
(
String
.
format
(
"由于[%s-%s]规则尚未选择规则分组,将不予生成drl规则文件~!"
,
strRuleid
,
strRulename
));
return
et
;
}
if
(
StringUtils
.
isEmpty
(
strCfg
)){
log
.
error
(
String
.
format
(
"由于[%s-%s]规则尚未配置规则,将不予生成drl规则文件~!"
,
strRuleid
,
strRulename
));
return
et
;
}
//准备模板参数
JSONObject
obj
=
null
;
if
(!
StringUtils
.
isEmpty
(
strFieldset
)){
obj
=
JSONObject
.
parseObject
(
strFieldset
);
strMetricfield
=
obj
.
getString
(
"metricfield"
);
strTimefield
=
obj
.
getString
(
"timefield"
);
strExt1field
=
obj
.
getString
(
"ext1field"
);
strKeyvaluefield
=
obj
.
getString
(
"keyvaluefield"
);
strExt2field
=
obj
.
getString
(
"ext2field"
);
strDimfield
=
obj
.
getString
(
"dimfield"
);
strBusinesscatfield
=
obj
.
getString
(
"businesscatfield"
);
strDomainsfield
=
StringUtils
.
isEmpty
(
strDimfield
)?
obj
.
getString
(
"domainsfield"
):
strDimfield
;
}
if
(
StringUtils
.
isEmpty
(
strDomainsfield
))
strDomainsfield
=
et
.
getModelName
()+
".CBDW_BM"
;
Map
param
=
new
HashMap
();
param
.
put
(
"ruleid"
,
strRuleid
);
param
.
put
(
"rulename"
,
strRulename
);
param
.
put
(
"memo"
,
strMemo
);
synchronized
(
lockModel
)
{
Hashtable
<
String
,
String
>
modelset
=
new
Hashtable
<
String
,
String
>();
param
.
put
(
"rulecond"
,
parseGroup
(
JSONObject
.
parseObject
(
strCfg
),
modelset
));
param
.
put
(
"releationcond"
,
parseRelationArr
(
JSONObject
.
parseObject
(
strCfg
),
modelset
));
String
strCond
=
""
;
for
(
String
key
:
modelset
.
keySet
())
{
if
(!
StringUtils
.
isEmpty
(
strCond
))
{
strCond
+=
","
;
}
strCond
+=
key
;
strCond
+=
"-"
;
}
et
.
setCond
(
strCond
);
param
.
put
(
"metricfield"
,
getFieldset
(
strMetricfield
,
modelset
));
param
.
put
(
"timefield"
,
getFieldset
(
strTimefield
,
modelset
));
param
.
put
(
"ext1field"
,
getFieldset
(
strExt1field
,
modelset
));
param
.
put
(
"keyvaluefield"
,
getFieldkeyset
(
strKeyvaluefield
,
modelset
));
param
.
put
(
"ext2field"
,
getFieldset
(
strExt2field
,
modelset
));
param
.
put
(
"domainsfield"
,
getFieldset
(
strDomainsfield
,
modelset
));
param
.
put
(
"businesscat"
,
StringUtils
.
isEmpty
(
strBusinesscatfield
)?
et
.
getBusinessCat
():
getFieldset
(
strBusinesscatfield
,
modelset
));
}
String
[]
groupArr
=
strRuleGroup
.
split
(
";"
);
//按照规则类别输出drl文件
for
(
String
ruleGroup:
groupArr
){
param
.
put
(
"rulegroup"
,
ruleGroup
);
String
ruleGroupFolderPath
=
String
.
format
(
"%s%s/"
,
rulePath
,
ruleGroup
.
toUpperCase
());
File
outputFileFolder
=
new
File
(
ruleGroupFolderPath
);
if
(!
outputFileFolder
.
exists
())
outputFileFolder
.
mkdirs
();
File
outputFilePath
=
new
File
(
String
.
format
(
"%s/%s.drl"
,
ruleGroupFolderPath
,
strRuleid
));
FreeMakerHelper
.
outputFreeMaker
(
"/ftl/"
,
"DSTRule.drl.ftl"
,
param
,
outputFilePath
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
et
;
}
/**
* 组查询
* @param groupObj
* @return
*/
private
String
parseGroup
(
JSONObject
groupObj
,
Hashtable
<
String
,
String
>
modelset
){
if
(
StringUtils
.
isEmpty
(
groupObj
))
return
""
;
String
conn
=
groupObj
.
getString
(
"groupcond"
).
replaceAll
(
"AND"
,
"&&"
).
replaceAll
(
"OR"
,
"||"
);
//获取组合方式
JSONArray
fieldArr
=
groupObj
.
getJSONArray
(
"field"
);
//获取值项数组
String
strFieldCond
=
parseFieldList
(
fieldArr
,
conn
,
modelset
);
//获取值项表达式
JSONArray
groupArr
=
groupObj
.
getJSONArray
(
"group"
);
//获取组合条件
String
strGroupCond
=
""
;
if
((!
StringUtils
.
isEmpty
(
groupArr
))
&&
groupArr
.
size
()>
0
){
strGroupCond
=
parseGroupList
(
groupArr
,
conn
,
modelset
);
//获取组合条件表达式
}
String
strRuleCond
=
getRuleCond
(
strFieldCond
,
strGroupCond
,
conn
);
//获取总表达式(值项+组合)
return
strRuleCond
;
}
/**
* 获取规则总表达式(值项+组合)
* @param strFieldCond 值项表达式
* @param strGroupCond 组合表达式
* @param conn 组合方式
* @return
*/
private
String
getRuleCond
(
String
strFieldCond
,
String
strGroupCond
,
String
conn
)
{
String
strRuleCond
=
""
;
if
((!
StringUtils
.
isEmpty
(
strFieldCond
)
&&
(!
StringUtils
.
isEmpty
(
strGroupCond
)))){
strRuleCond
=
String
.
format
(
"(%s %s %s)"
,
strFieldCond
,
conn
,
strGroupCond
);
}
else
if
(!
StringUtils
.
isEmpty
(
strFieldCond
)){
strRuleCond
=
String
.
format
(
"%s"
,
strFieldCond
);
}
else
if
(!
StringUtils
.
isEmpty
(
strGroupCond
)){
strRuleCond
=
String
.
format
(
"%s"
,
strGroupCond
);
}
return
strRuleCond
;
}
/**
* 组查询
* @param GroupArr
* @param conn
* @return
*/
private
String
parseGroupList
(
JSONArray
GroupArr
,
String
conn
,
Hashtable
<
String
,
String
>
modelset
){
if
(
StringUtils
.
isEmpty
(
GroupArr
)||
GroupArr
.
size
()==
0
)
return
""
;
StringBuffer
sbf
=
new
StringBuffer
();
for
(
int
a
=
0
;
a
<
GroupArr
.
size
();
a
++){
String
strGroupCond
=
parseGroup
(
GroupArr
.
getJSONObject
(
a
),
modelset
);
sbf
.
append
(
strGroupCond
);
if
(
a
!=
GroupArr
.
size
()-
1
)
//去掉最后的连接符
sbf
.
append
(
conn
+
" "
);
}
return
String
.
format
(
"(%s)"
,
sbf
.
toString
());
}
/**
* @param fieldArr field数组
* @param conn field连接符
* @return
*/
private
String
parseFieldList
(
JSONArray
fieldArr
,
String
conn
,
Hashtable
<
String
,
String
>
modelset
){
if
(
StringUtils
.
isEmpty
(
fieldArr
)||
fieldArr
.
size
()==
0
)
return
""
;
StringBuffer
sbf
=
new
StringBuffer
();
for
(
int
a
=
0
;
a
<
fieldArr
.
size
();
a
++){
JSONObject
fieldObj
=
fieldArr
.
getJSONObject
(
a
);
String
fieldCond
=
parseField
(
fieldObj
,
modelset
);
sbf
.
append
(
fieldCond
);
if
(
a
!=
fieldArr
.
size
()-
1
)
//去掉最后的连接符
sbf
.
append
(
conn
+
" "
);
}
return
String
.
format
(
"(%s)"
,
sbf
.
toString
());
}
/**
* 拼接field表达式
* @param fieldObj
* @return
*/
private
String
parseField
(
JSONObject
fieldObj
,
Hashtable
<
String
,
String
>
modelset
){
String
fieldName
=
fieldObj
.
getString
(
"fieldname"
);
String
fieldCond
=
fieldObj
.
getString
(
"fieldcond"
);
String
condValue
=
fieldObj
.
getString
(
"condvalue"
);
if
(
modelset
!=
null
)
{
String
[]
arr
=
fieldName
.
split
(
"[.]"
);
if
(
arr
.
length
>=
2
)
{
if
(!
modelset
.
containsKey
(
arr
[
0
]))
{
modelset
.
put
(
arr
[
0
],
"item"
);
}
}
}
return
String
.
format
(
"IF(\"%s %s %s\")"
,
fieldName
,
fieldCond
,
condValue
);
}
/**
* 解析子逻辑数组
* @return
*/
private
String
parseRelationArr
(
JSONObject
groupObj
,
Hashtable
<
String
,
String
>
modelset
){
if
(!
groupObj
.
containsKey
(
"releation"
))
return
null
;
JSONArray
RelationArr
=
groupObj
.
getJSONArray
(
"releation"
);
if
(
StringUtils
.
isEmpty
(
RelationArr
)||
RelationArr
.
size
()==
0
)
return
null
;
StringBuffer
sbf
=
new
StringBuffer
();
for
(
int
a
=
0
;
a
<
RelationArr
.
size
();
a
++){
String
strRelationCond
=
parseRelation
(
RelationArr
.
getJSONObject
(
a
),
modelset
);
sbf
.
append
(
strRelationCond
);
}
return
sbf
.
toString
();
}
/**
* 解析子数据逻辑
* @param relationObj
* @param modelset
* @return
*/
private
String
parseRelation
(
JSONObject
relationObj
,
Hashtable
<
String
,
String
>
modelset
){
if
(
StringUtils
.
isEmpty
(
relationObj
))
return
""
;
String
relaConn
=
relationObj
.
getString
(
"releationcond"
);
//操作符
String
relaEntity
=
relationObj
.
getString
(
"releationentity"
);
//实体
JSONArray
relaGroup
=
relationObj
.
getJSONArray
(
"group"
);
//规则数组
if
(
relaConn
.
equals
(
"exists"
))
{
if
(
modelset
!=
null
)
{
if
(!
StringUtils
.
isEmpty
(
relaEntity
))
{
if
(!
modelset
.
containsKey
(
relaEntity
))
{
modelset
.
put
(
relaEntity
,
relaEntity
);
}
else
{
modelset
.
remove
(
relaEntity
);
modelset
.
put
(
relaEntity
,
relaEntity
);
}
}
}
}
String
strGroupCond
=
""
;
if
((!
StringUtils
.
isEmpty
(
relaGroup
))
&&
relaGroup
.
size
()>
0
){
strGroupCond
=
parseGroupList
(
relaGroup
,
"&&"
,
modelset
);
//Relation各组之间用and连接
}
String
strRelationResult
=
""
;
if
(!
StringUtils
.
isEmpty
(
strGroupCond
)){
if
(
relaConn
.
equals
(
"exists"
))
{
strRelationResult
=
String
.
format
(
"%s:BaseEntity %s from item.$E(\"%s\")"
,
relaEntity
,
strGroupCond
,
relaEntity
);
}
else
if
(
relaConn
.
equals
(
"not exists"
)){
strRelationResult
=
String
.
format
(
"not(exists IEntity %s from item.$E(\"%s\"))"
,
strGroupCond
,
relaEntity
);
}
}
if
(!
StringUtils
.
isEmpty
(
strRelationResult
))
strRelationResult
=
String
.
format
(
" %s "
,
strRelationResult
);
return
strRelationResult
;
}
private
String
getFieldkeyset
(
String
fieldName
,
Hashtable
<
String
,
String
>
modelset
)
{
String
str
=
this
.
getFieldset
(
fieldName
,
modelset
);
if
(
str
.
equals
(
"null"
))
return
"item.KEY"
;
return
str
+
".getValue()"
;
}
private
String
getFieldset
(
String
fieldName
,
Hashtable
<
String
,
String
>
modelset
)
{
if
(
StringUtils
.
isEmpty
(
fieldName
))
return
"null"
;
if
(
modelset
!=
null
)
{
String
[]
arr
=
fieldName
.
split
(
"[.]"
);
if
(
arr
.
length
>=
2
)
{
if
(
modelset
.
containsKey
(
"AJXYRHZ"
))
{
String
tmp
=
arr
[
0
];
if
(
tmp
.
equalsIgnoreCase
(
"TYYW_GG_XYRJBXX"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_GS_XYRQK"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_KG_BXFRQK"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_SHB_XYRQK"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_WJ_BYXBLQK"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_WJ_FZXYR"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_WJ_QTXZQK"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_WJ_XYR"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_WJ_XYRQK"
)||
tmp
.
equalsIgnoreCase
(
"TYYW_ZIZ_FZXYR"
)
||
tmp
.
equalsIgnoreCase
(
"TYYW_ZJ_FZXYR"
))
{
return
"AJXYRHZ.$(\""
+
fieldName
+
"\")"
;
}
}
if
(
modelset
.
containsKey
(
"AJWSHZ"
))
{
String
tmp
=
arr
[
0
];
if
(
tmp
.
equalsIgnoreCase
(
"YX_WS_SL"
)||
tmp
.
equalsIgnoreCase
(
"YX_WS_AJJZWJ"
))
{
return
"AJWSHZ.$(\""
+
fieldName
+
"\")"
;
}
}
if
(
modelset
.
containsKey
(
"AJDZJZMLHZ"
))
{
String
tmp
=
arr
[
0
];
if
(
tmp
.
equalsIgnoreCase
(
"YX_DZJZ_JZML"
))
{
return
"AJDZJZMLHZ.$(\""
+
fieldName
+
"\")"
;
}
}
if
(
modelset
.
containsKey
(
"AJGGQZCSQKHZ"
))
{
String
tmp
=
arr
[
0
];
if
(
tmp
.
equalsIgnoreCase
(
"TYYW_GG_QZCSQK"
))
{
return
"AJGGQZCSQKHZ.$(\""
+
fieldName
+
"\")"
;
}
}
if
(
modelset
.
containsKey
(
arr
[
0
]))
{
return
modelset
.
get
(
arr
[
0
])+
".$(\""
+
fieldName
+
"\")"
;
}
}
}
return
"item.$(\""
+
fieldName
+
"\")"
;
}
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/util/FreeMakerHelper.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
util
;
import
freemarker.cache.ClassTemplateLoader
;
import
freemarker.cache.TemplateLoader
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.Writer
;
import
java.util.Map
;
public
class
FreeMakerHelper
{
private
static
Log
log
=
LogFactory
.
getLog
(
FreeMakerHelper
.
class
);
/**
* 根据ftl生成目标文件
* @param basePackagePath ftl文件目录(classpath相对路径)
* @param templateFileName ftl文件名
* @param param ftl文件所需参数
* @param outputFilePath 目标文件输出路径
* @throws Exception
*/
public
static
void
outputFreeMaker
(
String
basePackagePath
,
String
templateFileName
,
Map
param
,
File
outputFilePath
)
throws
Exception
{
log
.
info
(
"------freemaker正在进行文件输出任务------"
);
// 第一步:创建一个Configuration对象,直接new一个对象。构造方法的参数就是freemarker对于的版本号。
Configuration
configuration
=
new
Configuration
(
Configuration
.
getVersion
());
// 第二步:设置模板文件所在的路径
TemplateLoader
templateLoader
=
new
ClassTemplateLoader
(
FreeMakerHelper
.
class
,
basePackagePath
);
configuration
.
setTemplateLoader
(
templateLoader
);
// 第三步:设置模板文件使用的字符集。一般就是utf-8.
configuration
.
setDefaultEncoding
(
"utf-8"
);
// 第四步:加载一个模板,创建一个模板对象。
Template
template
=
configuration
.
getTemplate
(
templateFileName
);
// 第五步:创建一个模板使用的数据集,可以是pojo也可以是map。一般是Map。
// 第六步:创建一个Writer对象,一般创建一FileWriter对象,指定生成的文件名。
Writer
out
=
new
FileWriter
(
outputFilePath
);
// 第七步:调用模板对象的process方法输出文件。
template
.
process
(
param
,
out
);
// 第八步:关闭流。
out
.
close
();
log
.
info
(
"------freemaker已完成文件输出任务------"
);
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/util/IEntityActionHelper.java
0 → 100644
浏览文件 @
019d0297
package
cn
.
ibizlab
.
core
.
extensions
.
util
;
import
cn.ibizlab.core.extensions.domain.BaseEntity
;
import
cn.ibizlab.core.extensions.domain.DSTEntityModel
;
import
java.util.List
;
public
interface
IEntityActionHelper
{
List
<
BaseEntity
>
select
(
String
dblink
,
String
sql
);
DSTEntityModel
getModel
(
String
etname
);
}
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
浏览文件 @
019d0297
...
@@ -166,4 +166,9 @@ public class EntityObj extends DataObj<String,Object> {
...
@@ -166,4 +166,9 @@ public class EntityObj extends DataObj<String,Object> {
});
});
}
}
}
}
public
boolean
isDelete
()
{
return
false
;
}
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
浏览文件 @
019d0297
...
@@ -3,12 +3,15 @@ package cn.ibizlab.core.lite.extensions.domain;
...
@@ -3,12 +3,15 @@ package cn.ibizlab.core.lite.extensions.domain;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.model.Property
;
import
cn.ibizlab.core.lite.extensions.model.Property
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.helper.RuleUtils
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -269,4 +272,108 @@ public class ModelObj extends DataObj<String,Object> {
...
@@ -269,4 +272,108 @@ public class ModelObj extends DataObj<String,Object> {
return
this
;
return
this
;
}
}
public
boolean
IF
(
String
cond
)
{
String
[]
arr
=
cond
.
split
(
"\\s+"
);
String
option
=
""
;
String
members
=
""
;
String
exp
=
""
;
if
(
arr
.
length
>=
2
)
{
members
=
arr
[
0
];
option
=
arr
[
1
];
}
Object
val
=
null
;
String
[]
ms
=
members
.
split
(
"[.]"
);
if
(
ms
.
length
>=
2
&&(!
StringUtils
.
isEmpty
(
ms
[
0
])))
{
EntityObj
sub
=
this
.
getEntity
(
ms
[
0
]);
if
(
sub
.
isDelete
())
return
false
;
if
(
sub
!=
null
)
{
val
=
sub
.
get
(
ms
[
1
]);
}
}
if
(
arr
.
length
>=
3
)
{
exp
=
arr
[
2
];
if
(
exp
.
startsWith
(
"%"
))
{
return
RuleUtils
.
test
(
val
,
option
,
execFunc
(
exp
));
}
}
return
RuleUtils
.
test
(
val
,
option
,
exp
);
}
private
Object
execFunc
(
String
exp
)
{
exp
=
exp
.
replace
(
"%"
,
""
).
trim
();
if
(
exp
.
startsWith
(
"DAY("
))
{
Calendar
calendar
=
Calendar
.
getInstance
();
String
quStr
=
exp
.
substring
(
exp
.
indexOf
(
"("
)+
1
,
exp
.
indexOf
(
")"
));
quStr
=
quStr
.
replace
(
"+"
,
""
).
trim
();
int
day
=
0
;
if
(!
StringUtils
.
isEmpty
(
quStr
)){
day
=
Integer
.
parseInt
(
quStr
);
}
calendar
.
add
(
Calendar
.
DATE
,
day
);
return
new
Timestamp
(
calendar
.
getTime
().
getTime
());
}
else
if
(
exp
.
endsWith
(
")"
))
{
String
quStr
=
exp
.
substring
(
exp
.
indexOf
(
"("
)+
1
,
exp
.
indexOf
(
")"
));
exp
=
exp
.
substring
(
0
,
exp
.
indexOf
(
"("
)).
trim
();
quStr
=
quStr
.
replace
(
"+"
,
""
).
trim
();
Integer
day
=
0
;
if
(!
StringUtils
.
isEmpty
(
quStr
)){
day
=
Integer
.
parseInt
(
quStr
);
}
Object
val
=
this
.
get
(
exp
);
if
(
val
!=
null
)
{
if
(
val
instanceof
Timestamp
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
((
Timestamp
)
val
);
calendar
.
add
(
Calendar
.
DATE
,
day
);
return
new
Timestamp
(
calendar
.
getTime
().
getTime
());
}
else
if
(
val
instanceof
Integer
)
{
return
(
int
)
val
+
day
;
}
else
if
(
val
instanceof
BigDecimal
)
{
return
((
BigDecimal
)
val
).
intValue
()+
day
;
}
}
return
val
;
}
return
null
;
}
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/lite/service/IMetaEntityService.java
浏览文件 @
019d0297
...
@@ -34,6 +34,7 @@ public interface IMetaEntityService extends IService<MetaEntity> {
...
@@ -34,6 +34,7 @@ public interface IMetaEntityService extends IService<MetaEntity> {
MetaEntity
get
(
String
key
);
MetaEntity
get
(
String
key
);
MetaEntity
getDraft
(
MetaEntity
et
);
MetaEntity
getDraft
(
MetaEntity
et
);
boolean
checkKey
(
MetaEntity
et
);
boolean
checkKey
(
MetaEntity
et
);
MetaEntity
getDefaultModel
(
MetaEntity
et
);
boolean
save
(
MetaEntity
et
);
boolean
save
(
MetaEntity
et
);
void
saveBatch
(
List
<
MetaEntity
>
list
);
void
saveBatch
(
List
<
MetaEntity
>
list
);
Page
<
MetaEntity
>
searchDefault
(
MetaEntitySearchContext
context
);
Page
<
MetaEntity
>
searchDefault
(
MetaEntitySearchContext
context
);
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/lite/service/impl/MetaEntityServiceImpl.java
浏览文件 @
019d0297
...
@@ -157,6 +157,13 @@ public class MetaEntityServiceImpl extends ServiceImpl<MetaEntityMapper, MetaEnt
...
@@ -157,6 +157,13 @@ public class MetaEntityServiceImpl extends ServiceImpl<MetaEntityMapper, MetaEnt
public
boolean
checkKey
(
MetaEntity
et
)
{
public
boolean
checkKey
(
MetaEntity
et
)
{
return
(!
ObjectUtils
.
isEmpty
(
et
.
getEntityId
()))
&&
(!
Objects
.
isNull
(
this
.
getById
(
et
.
getEntityId
())));
return
(!
ObjectUtils
.
isEmpty
(
et
.
getEntityId
()))
&&
(!
Objects
.
isNull
(
this
.
getById
(
et
.
getEntityId
())));
}
}
@Override
@Transactional
public
MetaEntity
getDefaultModel
(
MetaEntity
et
)
{
//自定义代码
return
et
;
}
@Override
@Override
@Transactional
@Transactional
public
boolean
save
(
MetaEntity
et
)
{
public
boolean
save
(
MetaEntity
et
)
{
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/rule/service/IRuleItemService.java
浏览文件 @
019d0297
...
@@ -33,6 +33,7 @@ public interface IRuleItemService extends IService<RuleItem> {
...
@@ -33,6 +33,7 @@ public interface IRuleItemService extends IService<RuleItem> {
void
removeBatch
(
Collection
<
String
>
idList
);
void
removeBatch
(
Collection
<
String
>
idList
);
RuleItem
get
(
String
key
);
RuleItem
get
(
String
key
);
RuleItem
getDraft
(
RuleItem
et
);
RuleItem
getDraft
(
RuleItem
et
);
RuleItem
buildRuleFile
(
RuleItem
et
);
boolean
checkKey
(
RuleItem
et
);
boolean
checkKey
(
RuleItem
et
);
RuleItem
modelchange
(
RuleItem
et
);
RuleItem
modelchange
(
RuleItem
et
);
boolean
save
(
RuleItem
et
);
boolean
save
(
RuleItem
et
);
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/rule/service/impl/RuleItemServiceImpl.java
浏览文件 @
019d0297
...
@@ -125,6 +125,13 @@ public class RuleItemServiceImpl extends ServiceImpl<RuleItemMapper, RuleItem> i
...
@@ -125,6 +125,13 @@ public class RuleItemServiceImpl extends ServiceImpl<RuleItemMapper, RuleItem> i
return
et
;
return
et
;
}
}
@Override
@Transactional
public
RuleItem
buildRuleFile
(
RuleItem
et
)
{
//自定义代码
return
et
;
}
@Override
@Override
public
boolean
checkKey
(
RuleItem
et
)
{
public
boolean
checkKey
(
RuleItem
et
)
{
return
(!
ObjectUtils
.
isEmpty
(
et
.
getRuleId
()))
&&
(!
Objects
.
isNull
(
this
.
getById
(
et
.
getRuleId
())));
return
(!
ObjectUtils
.
isEmpty
(
et
.
getRuleId
()))
&&
(!
Objects
.
isNull
(
this
.
getById
(
et
.
getRuleId
())));
...
...
ibzdst-core/src/main/resources/ftl/DSTRule.drl.ftl
0 → 100644
浏览文件 @
019d0297
package
com
.
engineer
;
import
net
.
ibizsys
.
dst
.
common
.
domain
.
BaseEntity
;
import
net
.
ibizsys
.
dst
.
common
.
domain
.
IEntity
;
import
net
.
ibizsys
.
dst
.
common
.
service
.
BaseEntityService
;
global
BaseEntityService
BaseService
;
rule
"<#if ruleid??>${ruleid}_1</#if>"
salience
100
activation
-
group
"<#if ruleid??>${ruleid}</#if>"
when
item
:
BaseEntity
(
<#
if
rulecond
??>${
rulecond
}</#
if
>
)
<#
if
(
releationcond
??)>${
releationcond
}</#
if
>
then
BaseService
.
saveResult
(
item
,
"<#if ruleid??>${ruleid}</#if>"
,
"<#if rulename??>${rulename}</#if>"
,
"<#if memo??>${memo}</#if>"
,
"<#if businesscat??>${businesscat}</#if>"
,
1
,${
keyvaluefield
},${
domainsfield
},${
metricfield
},${
timefield
},${
ext1field
},${
ext2field
});
end
rule
"<#if ruleid??>${ruleid}_d</#if>"
salience
0
activation
-
group
"<#if ruleid??>${ruleid}</#if>"
when
item
:
BaseEntity
(
)
<#
if
(
releationcond
??)>${
releationcond
}</#
if
>
then
BaseService
.
saveResult
(
item
,
"<#if ruleid??>${ruleid}</#if>"
,
"<#if rulename??>${rulename}</#if>"
,
null
,
"<#if businesscat??>${businesscat}</#if>"
,
0
,
item
.
KEY
,${
domainsfield
},${
metricfield
},${
timefield
},
null
,
null
);
end
\ No newline at end of file
ibzdst-core/src/main/resources/liquibase/h2_table.xml
浏览文件 @
019d0297
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
<!--输出实体[DA_METRIC]数据结构 -->
<!--输出实体[DA_METRIC]数据结构 -->
<changeSet
author=
"a_A_5d9d78509"
id=
"tab-da_metric-5
3
-3"
>
<changeSet
author=
"a_A_5d9d78509"
id=
"tab-da_metric-5
9
-3"
>
<createTable
tableName=
"IBZDAMETRIC"
>
<createTable
tableName=
"IBZDAMETRIC"
>
<column
name=
"DA_METRICID"
remarks=
""
type=
"VARCHAR(100)"
>
<column
name=
"DA_METRICID"
remarks=
""
type=
"VARCHAR(100)"
>
<constraints
primaryKey=
"true"
primaryKeyName=
"PK_DA_METRIC_DA_METRICID"
/>
<constraints
primaryKey=
"true"
primaryKeyName=
"PK_DA_METRIC_DA_METRICID"
/>
...
@@ -226,7 +226,7 @@
...
@@ -226,7 +226,7 @@
<!--输出实体[META_ENTITY]数据结构 -->
<!--输出实体[META_ENTITY]数据结构 -->
<changeSet
author=
"a_A_5d9d78509"
id=
"tab-meta_entity-1
2
-10"
>
<changeSet
author=
"a_A_5d9d78509"
id=
"tab-meta_entity-1
3
-10"
>
<createTable
tableName=
"IBZENTITY"
>
<createTable
tableName=
"IBZENTITY"
>
<column
name=
"ENTITYID"
remarks=
""
type=
"VARCHAR(100)"
>
<column
name=
"ENTITYID"
remarks=
""
type=
"VARCHAR(100)"
>
<constraints
primaryKey=
"true"
primaryKeyName=
"PK_META_ENTITY_ENTITYID"
/>
<constraints
primaryKey=
"true"
primaryKeyName=
"PK_META_ENTITY_ENTITYID"
/>
...
@@ -420,7 +420,7 @@
...
@@ -420,7 +420,7 @@
<!--输出实体[RU_ITEM]数据结构 -->
<!--输出实体[RU_ITEM]数据结构 -->
<changeSet
author=
"a_A_5d9d78509"
id=
"tab-ru_item-
59
-16"
>
<changeSet
author=
"a_A_5d9d78509"
id=
"tab-ru_item-
68
-16"
>
<createTable
tableName=
"IBZRULE"
>
<createTable
tableName=
"IBZRULE"
>
<column
name=
"RULEID"
remarks=
""
type=
"VARCHAR(100)"
>
<column
name=
"RULEID"
remarks=
""
type=
"VARCHAR(100)"
>
<constraints
primaryKey=
"true"
primaryKeyName=
"PK_RU_ITEM_RULEID"
/>
<constraints
primaryKey=
"true"
primaryKeyName=
"PK_RU_ITEM_RULEID"
/>
...
@@ -457,7 +457,7 @@
...
@@ -457,7 +457,7 @@
<!--输出实体[DA_BUILD]外键关系 -->
<!--输出实体[DA_BUILD]外键关系 -->
<!--输出实体[DA_CHART]外键关系 -->
<!--输出实体[DA_CHART]外键关系 -->
<!--输出实体[DA_METRIC]外键关系 -->
<!--输出实体[DA_METRIC]外键关系 -->
<changeSet
author=
"a_A_5d9d78509"
id=
"fk-da_metric-5
3
-17"
>
<changeSet
author=
"a_A_5d9d78509"
id=
"fk-da_metric-5
9
-17"
>
<addForeignKeyConstraint
baseColumnNames=
"BUILDID"
baseTableName=
"IBZDAMETRIC"
constraintName=
"DER1N_DA_METRIC_DA_BUILD_BUILD"
deferrable=
"false"
initiallyDeferred=
"false"
onDelete=
"RESTRICT"
onUpdate=
"RESTRICT"
referencedColumnNames=
"BUILDID"
referencedTableName=
"IBZDABUILD"
validate=
"true"
/>
<addForeignKeyConstraint
baseColumnNames=
"BUILDID"
baseTableName=
"IBZDAMETRIC"
constraintName=
"DER1N_DA_METRIC_DA_BUILD_BUILD"
deferrable=
"false"
initiallyDeferred=
"false"
onDelete=
"RESTRICT"
onUpdate=
"RESTRICT"
referencedColumnNames=
"BUILDID"
referencedTableName=
"IBZDABUILD"
validate=
"true"
/>
</changeSet>
</changeSet>
<!--输出实体[DA_REPORT]外键关系 -->
<!--输出实体[DA_REPORT]外键关系 -->
...
...
ibzdst-core/src/main/resources/permission/systemResource.json
浏览文件 @
019d0297
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
"delogicname"
:
"指标"
,
"delogicname"
:
"指标"
,
"sysmoudle"
:{
"id"
:
"ANALYSIS"
,
"name"
:
"analysis"
},
"sysmoudle"
:{
"id"
:
"ANALYSIS"
,
"name"
:
"analysis"
},
"dedataset"
:[{
"id"
:
"Default"
,
"name"
:
"数据集"
}],
"dedataset"
:[{
"id"
:
"Default"
,
"name"
:
"数据集"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}
,{
"id"
:
"SyncRule"
,
"name"
:
"同步指标到规则"
,
"type"
:
"USERCUSTOM"
}
],
"datascope"
:[{
"id"
:
"all"
,
"name"
:
"全部数据"
}]
"datascope"
:[{
"id"
:
"all"
,
"name"
:
"全部数据"
}]
}
}
,
{
,
{
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
"delogicname"
:
"实体"
,
"delogicname"
:
"实体"
,
"sysmoudle"
:{
"id"
:
"LITE"
,
"name"
:
"lite"
},
"sysmoudle"
:{
"id"
:
"LITE"
,
"name"
:
"lite"
},
"dedataset"
:[{
"id"
:
"Default"
,
"name"
:
"数据集"
}],
"dedataset"
:[{
"id"
:
"Default"
,
"name"
:
"数据集"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"
GetDefaultModel"
,
"name"
:
"GetDefaultModel"
,
"type"
:
"USERCUSTOM"
},{
"id"
:
"
Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}],
"datascope"
:[{
"id"
:
"all"
,
"name"
:
"全部数据"
}]
"datascope"
:[{
"id"
:
"all"
,
"name"
:
"全部数据"
}]
}
}
,
{
,
{
...
@@ -152,7 +152,7 @@
...
@@ -152,7 +152,7 @@
"delogicname"
:
"规则"
,
"delogicname"
:
"规则"
,
"sysmoudle"
:{
"id"
:
"RULE"
,
"name"
:
"rule"
},
"sysmoudle"
:{
"id"
:
"RULE"
,
"name"
:
"rule"
},
"dedataset"
:[{
"id"
:
"Default"
,
"name"
:
"数据集"
}],
"dedataset"
:[{
"id"
:
"Default"
,
"name"
:
"数据集"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Modelchange"
,
"name"
:
"modelchange"
,
"type"
:
"USERCUSTOM"
},{
"id"
:
"Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"
BuildRuleFile"
,
"name"
:
"生成规则文件"
,
"type"
:
"USERCUSTOM"
},{
"id"
:
"
CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Modelchange"
,
"name"
:
"modelchange"
,
"type"
:
"USERCUSTOM"
},{
"id"
:
"Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}],
"datascope"
:[{
"id"
:
"all"
,
"name"
:
"全部数据"
}]
"datascope"
:[{
"id"
:
"all"
,
"name"
:
"全部数据"
}]
}
}
],
],
...
...
ibzdst-dependencies/pom.xml
浏览文件 @
019d0297
...
@@ -350,6 +350,10 @@
...
@@ -350,6 +350,10 @@
</dependency>
</dependency>
<dependency>
<groupId>
org.freemarker
</groupId>
<artifactId>
freemarker
</artifactId>
</dependency>
</dependencies>
</dependencies>
...
...
ibzdst-provider/ibzdst-provider-api/src/main/java/cn/ibizlab/api/rest/DAMetricResource.java
浏览文件 @
019d0297
...
@@ -136,6 +136,17 @@ public class DAMetricResource {
...
@@ -136,6 +136,17 @@ public class DAMetricResource {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-SyncRule-all')"
)
@ApiOperation
(
value
=
"同步指标到规则"
,
tags
=
{
"指标"
},
notes
=
"同步指标到规则"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dametrics/{dametric_id}/syncrule"
)
public
ResponseEntity
<
DAMetricDTO
>
syncRule
(
@PathVariable
(
"dametric_id"
)
String
dametric_id
,
@RequestBody
DAMetricDTO
dametricdto
)
{
DAMetric
domain
=
dametricMapping
.
toDomain
(
dametricdto
);
domain
.
setMetricId
(
dametric_id
);
domain
=
dametricService
.
syncRule
(
domain
);
dametricdto
=
dametricMapping
.
toDto
(
domain
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dametricdto
);
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-searchDefault-all')"
)
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-searchDefault-all')"
)
@ApiOperation
(
value
=
"获取数据集"
,
tags
=
{
"指标"
}
,
notes
=
"获取数据集"
)
@ApiOperation
(
value
=
"获取数据集"
,
tags
=
{
"指标"
}
,
notes
=
"获取数据集"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/dametrics/fetchdefault"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/dametrics/fetchdefault"
)
...
@@ -266,6 +277,17 @@ public class DAMetricResource {
...
@@ -266,6 +277,17 @@ public class DAMetricResource {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-SyncRule-all')"
)
@ApiOperation
(
value
=
"根据分析指标"
,
tags
=
{
"指标"
},
notes
=
"根据分析指标"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dabuilds/{dabuild_id}/dametrics/{dametric_id}/syncrule"
)
public
ResponseEntity
<
DAMetricDTO
>
syncRuleByDABuild
(
@PathVariable
(
"dabuild_id"
)
String
dabuild_id
,
@PathVariable
(
"dametric_id"
)
String
dametric_id
,
@RequestBody
DAMetricDTO
dametricdto
)
{
DAMetric
domain
=
dametricMapping
.
toDomain
(
dametricdto
);
domain
.
setBuildId
(
dabuild_id
);
domain
=
dametricService
.
syncRule
(
domain
)
;
dametricdto
=
dametricMapping
.
toDto
(
domain
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dametricdto
);
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-searchDefault-all')"
)
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-searchDefault-all')"
)
@ApiOperation
(
value
=
"根据分析获取数据集"
,
tags
=
{
"指标"
}
,
notes
=
"根据分析获取数据集"
)
@ApiOperation
(
value
=
"根据分析获取数据集"
,
tags
=
{
"指标"
}
,
notes
=
"根据分析获取数据集"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/dabuilds/{dabuild_id}/dametrics/fetchdefault"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/dabuilds/{dabuild_id}/dametrics/fetchdefault"
)
...
...
ibzdst-provider/ibzdst-provider-api/src/main/java/cn/ibizlab/api/rest/MetaEntityResource.java
浏览文件 @
019d0297
...
@@ -121,6 +121,17 @@ public class MetaEntityResource {
...
@@ -121,6 +121,17 @@ public class MetaEntityResource {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
metaentityService
.
checkKey
(
metaentityMapping
.
toDomain
(
metaentitydto
)));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
metaentityService
.
checkKey
(
metaentityMapping
.
toDomain
(
metaentitydto
)));
}
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-GetDefaultModel-all')"
)
@ApiOperation
(
value
=
"GetDefaultModel"
,
tags
=
{
"实体"
},
notes
=
"GetDefaultModel"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/metaentities/{metaentity_id}/getdefaultmodel"
)
public
ResponseEntity
<
MetaEntityDTO
>
getDefaultModel
(
@PathVariable
(
"metaentity_id"
)
String
metaentity_id
,
@RequestBody
MetaEntityDTO
metaentitydto
)
{
MetaEntity
domain
=
metaentityMapping
.
toDomain
(
metaentitydto
);
domain
.
setEntityId
(
metaentity_id
);
domain
=
metaentityService
.
getDefaultModel
(
domain
);
metaentitydto
=
metaentityMapping
.
toDto
(
domain
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
metaentitydto
);
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-Save-all')"
)
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-Save-all')"
)
@ApiOperation
(
value
=
"保存实体"
,
tags
=
{
"实体"
},
notes
=
"保存实体"
)
@ApiOperation
(
value
=
"保存实体"
,
tags
=
{
"实体"
},
notes
=
"保存实体"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/metaentities/save"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/metaentities/save"
)
...
@@ -245,6 +256,17 @@ public class MetaEntityResource {
...
@@ -245,6 +256,17 @@ public class MetaEntityResource {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
metaentityService
.
checkKey
(
metaentityMapping
.
toDomain
(
metaentitydto
)));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
metaentityService
.
checkKey
(
metaentityMapping
.
toDomain
(
metaentitydto
)));
}
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-GetDefaultModel-all')"
)
@ApiOperation
(
value
=
"根据系统实体"
,
tags
=
{
"实体"
},
notes
=
"根据系统实体"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/dstsystems/{dstsystem_id}/metaentities/{metaentity_id}/getdefaultmodel"
)
public
ResponseEntity
<
MetaEntityDTO
>
getDefaultModelByDstSystem
(
@PathVariable
(
"dstsystem_id"
)
String
dstsystem_id
,
@PathVariable
(
"metaentity_id"
)
String
metaentity_id
,
@RequestBody
MetaEntityDTO
metaentitydto
)
{
MetaEntity
domain
=
metaentityMapping
.
toDomain
(
metaentitydto
);
domain
.
setSystemId
(
dstsystem_id
);
domain
=
metaentityService
.
getDefaultModel
(
domain
)
;
metaentitydto
=
metaentityMapping
.
toDto
(
domain
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
metaentitydto
);
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-Save-all')"
)
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-Save-all')"
)
@ApiOperation
(
value
=
"根据系统保存实体"
,
tags
=
{
"实体"
},
notes
=
"根据系统保存实体"
)
@ApiOperation
(
value
=
"根据系统保存实体"
,
tags
=
{
"实体"
},
notes
=
"根据系统保存实体"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dstsystems/{dstsystem_id}/metaentities/save"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dstsystems/{dstsystem_id}/metaentities/save"
)
...
...
ibzdst-provider/ibzdst-provider-api/src/main/java/cn/ibizlab/api/rest/RuleItemResource.java
浏览文件 @
019d0297
...
@@ -115,6 +115,17 @@ public class RuleItemResource {
...
@@ -115,6 +115,17 @@ public class RuleItemResource {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
ruleitemMapping
.
toDto
(
ruleitemService
.
getDraft
(
new
RuleItem
())));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
ruleitemMapping
.
toDto
(
ruleitemService
.
getDraft
(
new
RuleItem
())));
}
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-RuleItem-BuildRuleFile-all')"
)
@ApiOperation
(
value
=
"生成规则文件"
,
tags
=
{
"规则"
},
notes
=
"生成规则文件"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/ruleitems/{ruleitem_id}/buildrulefile"
)
public
ResponseEntity
<
RuleItemDTO
>
buildRuleFile
(
@PathVariable
(
"ruleitem_id"
)
String
ruleitem_id
,
@RequestBody
RuleItemDTO
ruleitemdto
)
{
RuleItem
domain
=
ruleitemMapping
.
toDomain
(
ruleitemdto
);
domain
.
setRuleId
(
ruleitem_id
);
domain
=
ruleitemService
.
buildRuleFile
(
domain
);
ruleitemdto
=
ruleitemMapping
.
toDto
(
domain
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
ruleitemdto
);
}
@ApiOperation
(
value
=
"检查规则"
,
tags
=
{
"规则"
},
notes
=
"检查规则"
)
@ApiOperation
(
value
=
"检查规则"
,
tags
=
{
"规则"
},
notes
=
"检查规则"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/ruleitems/checkkey"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/ruleitems/checkkey"
)
public
ResponseEntity
<
Boolean
>
checkKey
(
@RequestBody
RuleItemDTO
ruleitemdto
)
{
public
ResponseEntity
<
Boolean
>
checkKey
(
@RequestBody
RuleItemDTO
ruleitemdto
)
{
...
...
ibzdst-util/src/main/java/cn/ibizlab/util/helper/RuleUtils.java
浏览文件 @
019d0297
...
@@ -580,4 +580,56 @@ public class RuleUtils
...
@@ -580,4 +580,56 @@ public class RuleUtils
}
}
return
acts
;
return
acts
;
}
}
public
static
boolean
inc2s
(
String
tvs
,
Object
finalObject
)
{
if
(
ObjectUtils
.
isEmpty
(
finalObject
))
return
false
;
if
(
StringUtils
.
isEmpty
(
tvs
))
return
false
;
if
(
finalObject
instanceof
String
)
{
tvs
=
"s:"
+
tvs
;
}
else
return
false
;
List
acts
=
parseTvs
(
tvs
);
for
(
Iterator
localIterator
=
acts
.
iterator
();
localIterator
.
hasNext
();)
{
Object
act
=
localIterator
.
next
();
if
(
equal
(
c2s
(
act
.
toString
()),
c2s
(
finalObject
.
toString
())))
return
true
;
}
return
false
;
}
public
static
String
c2s
(
String
str
)
{
if
(
str
==
null
)
return
null
;
if
(
str
.
length
()<
300
)
{
str
=
str
.
trim
();
//1234567890()【】〔2018〕
str
=
str
.
replace
(
"1"
,
"1"
).
replace
(
"2"
,
"2"
).
replace
(
"3"
,
"3"
).
replace
(
"4"
,
"4"
).
replace
(
"5"
,
"5"
).
replace
(
"6"
,
"6"
).
replace
(
"7"
,
"7"
)
.
replace
(
"8"
,
"8"
).
replace
(
"9"
,
"9"
).
replace
(
"0"
,
"0"
)
.
replace
(
"("
,
"〔"
).
replace
(
")"
,
"〕"
)
.
replace
(
"("
,
"〔"
).
replace
(
")"
,
"〕"
)
.
replace
(
"【"
,
"〔"
).
replace
(
"】"
,
"〕"
)
.
replace
(
"["
,
"〔"
).
replace
(
"]"
,
"〕"
);
}
return
str
;
}
public
static
boolean
notinc2s
(
String
tvs
,
Object
finalObject
)
{
return
(!
inc2s
(
tvs
,
finalObject
));
}
}
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录