Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
2382fceb
提交
2382fceb
编写于
12月 13, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify
上级
4cf81844
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
140 行增加
和
6 行删除
+140
-6
BaseEntityService.java
...cn/ibizlab/core/extensions/service/BaseEntityService.java
+3
-2
BaseEntityServiceImpl.java
...bizlab/core/extensions/service/BaseEntityServiceImpl.java
+73
-4
RuleEngineExService.java
.../ibizlab/core/extensions/service/RuleEngineExService.java
+64
-0
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BaseEntityService.java
浏览文件 @
2382fceb
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.domain.BaseRequest
;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
...
...
@@ -12,6 +13,6 @@ import java.sql.Timestamp;
public
interface
BaseEntityService
{
void
reset
(
String
keyContainer
);
ExecLog
processAll
(
Ba
dRequestAlertException
msg
);
void
saveResult
(
ModelObj
param
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
String
BUSINESSCAT
,
Integer
RETVALUE
,
String
KEYVALUEFIELD
,
String
DOMAINSFIELD
,
Double
METRICFIELD
,
Timestamp
TIMEFIELD
,
String
EXT1FIELD
,
String
EXT2FIELD
);
ExecLog
processAll
(
Ba
seRequest
msg
);
void
saveResult
(
ModelObj
param
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
String
BUSINESSCAT
,
Integer
RETVALUE
,
Object
KEYVALUEFIELD
,
Object
DOMAINSFIELD
,
Object
DIMFIELD
,
Object
METRICFIELD
,
Timestamp
TIMEFIELD
,
Object
EXT1FIELD
,
Object
EXT2FIELD
);
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BaseEntityServiceImpl.java
浏览文件 @
2382fceb
...
...
@@ -3,6 +3,7 @@ package cn.ibizlab.core.extensions.service;
import
cn.ibizlab.core.extensions.domain.BaseRequest
;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.core.rule.domain.ExecResult
;
import
cn.ibizlab.core.rule.service.IExecLogService
;
import
cn.ibizlab.core.rule.service.IExecResultService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
...
...
@@ -24,6 +25,8 @@ import org.springframework.context.annotation.Primary;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
import
java.util.Collection
;
import
java.util.Hashtable
;
...
...
@@ -35,7 +38,7 @@ import java.util.List;
@Service
@Primary
@Slf4j
public
class
BaseEntityServiceImpl
public
class
BaseEntityServiceImpl
implements
BaseEntityService
{
public
BaseEntityServiceImpl
()
...
...
@@ -46,10 +49,76 @@ public class BaseEntityServiceImpl
}
public
void
saveResult
(
ModelObj
param
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
String
BUSINESSCAT
,
Integer
RETVALUE
,
String
KEYVALUEFIELD
,
String
DOMAINSFIELD
,
Double
METRICFIELD
,
Timestamp
TIMEFIELD
,
String
EXT1FIELD
,
String
EXT2FIELD
)
public
void
saveResult
(
ModelObj
param
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
String
BUSINESSCAT
,
Integer
RETVALUE
,
Object
KEYVALUEFIELD
,
Object
DOMAINSFIELD
,
Object
DIMFIELD
,
Object
METRICFIELD
,
Timestamp
TIMEFIELD
,
Object
EXT1FIELD
,
Object
EXT2FIELD
)
{
ExecResult
result
=
new
ExecResult
();
result
.
setRuleId
(
RULECODE
);
result
.
setRuleName
(
RULENAME
);
result
.
setName
(
RU_EXECRESULTNAME
);
result
.
setBusinessCat
(
BUSINESSCAT
);
result
.
setRetValue
(
RETVALUE
);
if
(
KEYVALUEFIELD
==
null
)
{
result
.
setKeyValueField
(
param
.
getRowKey
());
}
else
{
result
.
setKeyValueField
(
KEYVALUEFIELD
.
toString
());
}
if
(
METRICFIELD
!=
null
)
{
Object
val
=
METRICFIELD
;
if
(
(
val
instanceof
BigDecimal
))
result
.
setMetricField
(((
BigDecimal
)
val
));
else
if
(
(
val
instanceof
BigInteger
))
result
.
setMetricField
(
new
BigDecimal
((
BigInteger
)
val
));
else
if
(
(
val
instanceof
Double
))
result
.
setMetricField
(
new
BigDecimal
((
Double
)
val
));
else
if
(
(
val
instanceof
Float
))
result
.
setMetricField
(
new
BigDecimal
(((
Float
)
val
).
doubleValue
()));
else
if
(
(
val
instanceof
Long
))
result
.
setMetricField
(
new
BigDecimal
((
Long
)
val
));
else
if
(
(
val
instanceof
Integer
))
result
.
setMetricField
(
new
BigDecimal
((
int
)
val
));
else
result
.
setMetricField
(
new
BigDecimal
(
1
));
}
else
result
.
setMetricField
(
new
BigDecimal
(
0
));
if
(
DOMAINSFIELD
!=
null
)
{
result
.
setDomainsField
(
DOMAINSFIELD
.
toString
());
}
else
{
result
.
setDomainsField
(
KEYVALUEFIELD
.
toString
());
}
if
(
DIMFIELD
!=
null
)
{
result
.
setDimField
(
DIMFIELD
.
toString
());
}
else
{
result
.
setDimField
(
KEYVALUEFIELD
.
toString
());
}
if
(
TIMEFIELD
!=
null
&&
TIMEFIELD
instanceof
Timestamp
)
result
.
setTimeField
((
Timestamp
)
TIMEFIELD
);
if
(
EXT1FIELD
!=
null
)
result
.
setExt1Field
(
EXT1FIELD
.
toString
());
if
(
EXT2FIELD
!=
null
)
result
.
setExt2Field
(
EXT2FIELD
.
toString
());
result
.
setId
(
result
.
getDefaultKey
(
true
).
toString
());
if
(
result
.
getRetValue
()==
1
)
{
ruExecResultService
.
save
(
result
);
}
else
{
ruExecResultService
.
remove
(
result
.
getId
());
}
}
@Autowired
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/RuleEngineExService.java
浏览文件 @
2382fceb
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.domain.BaseRequest
;
import
cn.ibizlab.core.lite.extensions.service.DbEntityService
;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.core.rule.domain.RuleItem
;
import
cn.ibizlab.core.rule.filter.RuleItemSearchContext
;
import
cn.ibizlab.core.rule.service.IRuleItemService
;
import
cn.ibizlab.core.rule.service.impl.RuleEngineServiceImpl
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.ibizlab.core.rule.domain.RuleEngine
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.util.*
;
/**
...
...
@@ -21,6 +35,17 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
return
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
ReflectionKit
.
getSuperClassGenericType
(
this
.
getClass
().
getSuperclass
(),
1
);
}
@Autowired
private
DbEntityService
dbEntityService
;
@Autowired
private
IRuleItemService
ruleItemService
;
@Autowired
private
BaseEntityService
baseEntityService
;
@Value
(
"${ibiz.rulepath:/app/file/rules/}"
)
private
String
rulePath
;
/**
* [Run:运行] 行为扩展
* @param et
...
...
@@ -29,6 +54,45 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
@Override
@Transactional
public
RuleEngine
run
(
RuleEngine
et
)
{
if
(!
StringUtils
.
isEmpty
(
et
.
getEngineId
()))
{
CachedBeanCopier
.
copy
(
get
(
et
.
getEngineId
()),
et
);
if
(!
StringUtils
.
isEmpty
(
et
.
getModelId
()))
{
BaseRequest
msg
=
new
BaseRequest
();
msg
.
setId
(
IdWorker
.
getIdStr
());
msg
.
setModel
(
et
.
getModelName
());
java
.
sql
.
Timestamp
starttime
=
new
java
.
sql
.
Timestamp
(
System
.
currentTimeMillis
());
msg
.
setDatas
(
dbEntityService
.
getModelObjs
(
et
.
getModelId
(),
et
.
getLastRuntime
()));
List
<
String
>
rules
=
new
ArrayList
<>();
ruleItemService
.
list
(
Wrappers
.<
RuleItem
>
lambdaQuery
()
.
select
(
RuleItem:
:
getRuleId
).
eq
(
RuleItem:
:
getModelId
,
et
.
getModelId
()).
ne
(
RuleItem:
:
getGroup
,
"REP"
).
like
(
RuleItem:
:
getGroup
,
et
.
getGroup
()))
.
forEach
(
ruleItem
->
{
String
path
=
rulePath
+
et
.
getGroup
()
+
File
.
separator
+
ruleItem
.
getRuleId
()
+
".drl"
;
File
file
=
new
File
(
path
);
if
(
file
.
exists
())
{
rules
.
add
(
path
);
}
});
msg
.
setRules
(
rules
);
ExecLog
execlog
=
baseEntityService
.
processAll
(
msg
);
if
(
execlog
.
getRetCode
()
!=
0
)
return
et
;
et
.
setLastRuntime
(
starttime
);
this
.
update
(
et
);
}
}
return
super
.
run
(
et
);
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录