Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
3c56a765
提交
3c56a765
编写于
6月 10, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
1e43c56f
变更
4
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
756 行增加
和
1 行删除
+756
-1
BuildResult.java
...n/java/cn/ibizlab/core/extensions/domain/BuildResult.java
+332
-0
AnalyseEntityServiceImpl.java
...lab/core/extensions/service/AnalyseEntityServiceImpl.java
+5
-1
AnalyseSqlServiceImpl.java
...bizlab/core/extensions/service/AnalyseSqlServiceImpl.java
+302
-0
BuildResultService.java
...n/ibizlab/core/extensions/service/BuildResultService.java
+117
-0
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/domain/BuildResult.java
0 → 100644
浏览文件 @
3c56a765
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.sql.Timestamp
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@ApiModel
(
"执行结果"
)
public
class
BuildResult
implements
Serializable
{
/**
* 属性 [RU_EXECRESULTID]
*
*/
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
@ApiModelProperty
(
"规则执行结果标识"
)
private
String
id
;
/**
* 属性 [RU_EXECRESULTNAME]
*
*/
@JSONField
(
name
=
"name"
)
@JsonProperty
(
"name"
)
@ApiModelProperty
(
"规则执行结果描述"
)
private
String
name
;
/**
* 属性 [RULEID]
*
*/
@JSONField
(
name
=
"rule_id"
)
@JsonProperty
(
"rule_id"
)
@ApiModelProperty
(
"规则标识"
)
private
String
ruleId
;
/**
* 属性 [RULENAME]
*
*/
@JSONField
(
name
=
"rule_name"
)
@JsonProperty
(
"rule_name"
)
@ApiModelProperty
(
"规则标识"
)
private
String
ruleName
;
/**
* 属性 [RETVALUE]
*
*/
@JSONField
(
name
=
"ret_value"
)
@JsonProperty
(
"ret_value"
)
@ApiModelProperty
(
"是否匹配"
)
private
Integer
retValue
;
/**
* 属性 [BUSINESSCAT]
*
*/
@JSONField
(
name
=
"business_cat"
)
@JsonProperty
(
"business_cat"
)
@ApiModelProperty
(
"业务类别"
)
private
String
businessCat
;
/**
* 属性 [KEYVALUEFIELD]
*
*/
@JSONField
(
name
=
"key_value_field"
)
@JsonProperty
(
"key_value_field"
)
@ApiModelProperty
(
"标识属性"
)
private
String
keyValueField
;
/**
* 属性 [DOMAINSFIELD]
*
*/
@JSONField
(
name
=
"domains_field"
)
@JsonProperty
(
"domains_field"
)
@ApiModelProperty
(
"分区字段"
)
private
String
domainsField
;
/**
* 属性 [TIMEFIELD]
*
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"time_field"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"time_field"
)
@ApiModelProperty
(
"时间属性"
)
private
Timestamp
timeField
;
/**
* 属性 [DIMFIELD]
*
*/
@JSONField
(
name
=
"dim_field"
)
@JsonProperty
(
"dim_field"
)
@ApiModelProperty
(
"维度属性"
)
private
String
dimField
;
/**
* 属性 [METRICFIELD]
*
*/
@JSONField
(
name
=
"metric_field"
)
@JsonProperty
(
"metric_field"
)
@ApiModelProperty
(
"指标属性"
)
private
BigDecimal
metricField
;
/**
* 属性 [CREATEDATE]
*
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"createdate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"createdate"
)
@ApiModelProperty
(
"建立时间"
)
private
Timestamp
createdate
;
/**
* 属性 [UPDATEDATE]
*
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"updatedate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"updatedate"
)
@ApiModelProperty
(
"更新时间"
)
private
Timestamp
updatedate
;
/**
* 属性 [EXT1FIELD]
*
*/
@JSONField
(
name
=
"ext1_field"
)
@JsonProperty
(
"ext1_field"
)
@ApiModelProperty
(
"扩展属性1"
)
private
String
ext1Field
;
/**
* 属性 [EXT2FIELD]
*
*/
@JSONField
(
name
=
"ext2_field"
)
@JsonProperty
(
"ext2_field"
)
@ApiModelProperty
(
"扩展属性2"
)
private
String
ext2Field
;
/**
* 属性 [SYSTEMID]
*
*/
@JSONField
(
name
=
"system_id"
)
@JsonProperty
(
"system_id"
)
@ApiModelProperty
(
"系统标识"
)
private
String
systemId
;
public
cn
.
ibizlab
.
core
.
extensions
.
cql
.
ExecResult
getCqlResult
()
{
cn
.
ibizlab
.
core
.
extensions
.
cql
.
ExecResult
result
=
new
cn
.
ibizlab
.
core
.
extensions
.
cql
.
ExecResult
();
result
.
setDimfield
(
dimField
);
result
.
setDomainsfield
(
domainsField
);
result
.
setKeyvaluefield
(
keyValueField
);
result
.
setRetvalue
(
retValue
);
result
.
setRuleid
(
ruleId
);
if
(
timeField
!=
null
)
result
.
setTimefieldLV
(
timeField
.
getTime
());
result
.
setBusinesscat
(
businessCat
);
result
.
setExt1field
(
ext1Field
);
result
.
setExt2field
(
ext2Field
);
result
.
setMetricfield
(
metricField
!=
null
?
metricField
.
doubleValue
():
1
d
);
result
.
setRuexecresultname
(
name
);
result
.
setRulename
(
ruleName
);
if
(
updatedate
!=
null
)
result
.
setUpdatedateLV
(
updatedate
.
getTime
());
return
result
;
}
public
BuildResult
setCqlResult
(
cn
.
ibizlab
.
core
.
extensions
.
cql
.
ExecResult
result
)
{
if
(
result
!=
null
)
{
dimField
=
result
.
getDimfield
();
domainsField
=
result
.
getDomainsfield
();
keyValueField
=
result
.
getKeyvaluefield
();
retValue
=
result
.
getRetvalue
();
ruleId
=
result
.
getRuleid
();
if
(
result
.
getTimefield
()!=
null
)
timeField
=
new
Timestamp
(
result
.
getTimefieldLV
());
businessCat
=
result
.
getBusinesscat
();
ext1Field
=
result
.
getExt1field
();
ext2Field
=
result
.
getExt2field
();
result
.
setMetricfield
(
metricField
!=
null
?
metricField
.
doubleValue
():
1
d
);
name
=
result
.
getRuexecresultname
();
ruleName
=
result
.
getRulename
();
if
(
result
.
getUpdatedate
()!=
null
)
updatedate
=
new
Timestamp
(
result
.
getUpdatedateLV
());
}
return
this
;
}
public
cn
.
ibizlab
.
core
.
rule
.
domain
.
ExecResult
getSqlResult
()
{
cn
.
ibizlab
.
core
.
rule
.
domain
.
ExecResult
execResult
=
new
cn
.
ibizlab
.
core
.
rule
.
domain
.
ExecResult
();
if
(
this
.
getName
()
!=
null
)
{
execResult
.
setName
(
this
.
getName
()
);
}
if
(
this
.
getRuleId
()
!=
null
)
{
execResult
.
setRuleId
(
this
.
getRuleId
()
);
}
if
(
this
.
getRuleName
()
!=
null
)
{
execResult
.
setRuleName
(
this
.
getRuleName
()
);
}
if
(
this
.
getRetValue
()
!=
null
)
{
execResult
.
setRetValue
(
this
.
getRetValue
()
);
}
if
(
this
.
getBusinessCat
()
!=
null
)
{
execResult
.
setBusinessCat
(
this
.
getBusinessCat
()
);
}
if
(
this
.
getKeyValueField
()
!=
null
)
{
execResult
.
setKeyValueField
(
this
.
getKeyValueField
()
);
}
if
(
this
.
getDomainsField
()
!=
null
)
{
execResult
.
setDomainsField
(
this
.
getDomainsField
()
);
}
if
(
this
.
getTimeField
()
!=
null
)
{
execResult
.
setTimeField
(
this
.
getTimeField
()
);
}
if
(
this
.
getDimField
()
!=
null
)
{
execResult
.
setDimField
(
this
.
getDimField
()
);
}
if
(
this
.
getMetricField
()
!=
null
)
{
execResult
.
setMetricField
(
this
.
getMetricField
()
);
}
if
(
this
.
getExt1Field
()
!=
null
)
{
execResult
.
setExt1Field
(
this
.
getExt1Field
()
);
}
if
(
this
.
getExt2Field
()
!=
null
)
{
execResult
.
setExt2Field
(
this
.
getExt2Field
()
);
}
if
(
this
.
getSystemId
()
!=
null
)
{
execResult
.
setSystemId
(
this
.
getSystemId
()
);
}
if
(
this
.
getId
()
!=
null
)
{
execResult
.
setId
(
this
.
getId
()
);
}
if
(
this
.
getCreatedate
()
!=
null
)
{
execResult
.
setCreatedate
(
this
.
getCreatedate
()
);
}
if
(
this
.
getUpdatedate
()
!=
null
)
{
execResult
.
setUpdatedate
(
this
.
getUpdatedate
()
);
}
return
execResult
;
}
public
BuildResult
setSqlResult
(
cn
.
ibizlab
.
core
.
rule
.
domain
.
ExecResult
entity
)
{
if
(
entity
!=
null
)
{
if
(
entity
.
getName
()
!=
null
)
{
this
.
setName
(
entity
.
getName
()
);
}
if
(
entity
.
getRuleId
()
!=
null
)
{
this
.
setRuleId
(
entity
.
getRuleId
()
);
}
if
(
entity
.
getRuleName
()
!=
null
)
{
this
.
setRuleName
(
entity
.
getRuleName
()
);
}
if
(
entity
.
getRetValue
()
!=
null
)
{
this
.
setRetValue
(
entity
.
getRetValue
()
);
}
if
(
entity
.
getBusinessCat
()
!=
null
)
{
this
.
setBusinessCat
(
entity
.
getBusinessCat
()
);
}
if
(
entity
.
getKeyValueField
()
!=
null
)
{
this
.
setKeyValueField
(
entity
.
getKeyValueField
()
);
}
if
(
entity
.
getDomainsField
()
!=
null
)
{
this
.
setDomainsField
(
entity
.
getDomainsField
()
);
}
if
(
entity
.
getTimeField
()
!=
null
)
{
this
.
setTimeField
(
entity
.
getTimeField
()
);
}
if
(
entity
.
getDimField
()
!=
null
)
{
this
.
setDimField
(
entity
.
getDimField
()
);
}
if
(
entity
.
getMetricField
()
!=
null
)
{
this
.
setMetricField
(
entity
.
getMetricField
()
);
}
if
(
entity
.
getExt1Field
()
!=
null
)
{
this
.
setExt1Field
(
entity
.
getExt1Field
()
);
}
if
(
entity
.
getExt2Field
()
!=
null
)
{
this
.
setExt2Field
(
entity
.
getExt2Field
()
);
}
if
(
entity
.
getSystemId
()
!=
null
)
{
this
.
setSystemId
(
entity
.
getSystemId
()
);
}
if
(
entity
.
getId
()
!=
null
)
{
this
.
setId
(
entity
.
getId
()
);
}
if
(
entity
.
getCreatedate
()
!=
null
)
{
this
.
setCreatedate
(
entity
.
getCreatedate
()
);
}
if
(
entity
.
getUpdatedate
()
!=
null
)
{
this
.
setUpdatedate
(
entity
.
getUpdatedate
()
);
}
}
return
this
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/AnalyseEntityServiceImpl.java
浏览文件 @
3c56a765
...
@@ -12,10 +12,12 @@ import cn.ibizlab.core.lite.extensions.domain.ModelObj;
...
@@ -12,10 +12,12 @@ import cn.ibizlab.core.lite.extensions.domain.ModelObj;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.core.rule.service.IExecLogService
;
import
cn.ibizlab.core.rule.service.IExecLogService
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.dict.CodeList
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.kie.api.runtime.KieSession
;
import
org.kie.api.runtime.KieSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -27,6 +29,7 @@ import java.util.List;
...
@@ -27,6 +29,7 @@ import java.util.List;
@Slf4j
@Slf4j
@Service
(
"AnalyseEntityServiceImpl"
)
@Service
(
"AnalyseEntityServiceImpl"
)
@ConditionalOnExpression
(
"!''.equals('${cassandra.host:}')"
)
public
class
AnalyseEntityServiceImpl
extends
BaseEntityServiceImpl
{
public
class
AnalyseEntityServiceImpl
extends
BaseEntityServiceImpl
{
public
static
final
String
Tag_SaveResults
=
"SaveResults"
;
public
static
final
String
Tag_SaveResults
=
"SaveResults"
;
...
@@ -118,10 +121,11 @@ public class AnalyseEntityServiceImpl extends BaseEntityServiceImpl {
...
@@ -118,10 +121,11 @@ public class AnalyseEntityServiceImpl extends BaseEntityServiceImpl {
if
(!
StringUtils
.
isEmpty
(
dictname
))
if
(!
StringUtils
.
isEmpty
(
dictname
))
{
{
CodeList
codeList
=
dictDstService
.
getCodeListCatalog
(
dictname
);
//维度指定代码表时,向上同时为每一个父节点添加一条数据
//维度指定代码表时,向上同时为每一个父节点添加一条数据
while
(
true
)
while
(
true
)
{
{
CodeItem
code
=
dictDstService
.
getCodeListCatalog
(
dictname
)
.
findCodeItem
(
val
);
CodeItem
code
=
codeList
.
findCodeItem
(
val
);
if
(
code
!=
null
)
if
(
code
!=
null
)
{
{
ExecResult
result2
=
new
ExecResult
();
ExecResult
result2
=
new
ExecResult
();
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/AnalyseSqlServiceImpl.java
0 → 100644
浏览文件 @
3c56a765
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.analysis.domain.DADimension
;
import
cn.ibizlab.core.dict.extensions.service.DictDstService
;
import
cn.ibizlab.core.rule.domain.ExecResult
;
import
cn.ibizlab.core.extensions.domain.BaseRequest
;
import
cn.ibizlab.core.lite.extensions.domain.FieldObj
;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.core.rule.service.IExecLogService
;
import
cn.ibizlab.core.rule.service.IExecResultService
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.dict.CodeList
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DataObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.kie.api.runtime.KieSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
@Slf4j
@Service
(
"AnalyseEntityServiceImpl"
)
@ConditionalOnExpression
(
"''.equals('${cassandra.host:}')"
)
public
class
AnalyseSqlServiceImpl
extends
BaseEntityServiceImpl
{
@Autowired
@Lazy
private
DABuildExService
daBuildExService
;
@Autowired
@Lazy
private
DictDstService
dictDstService
;
@Autowired
private
IExecResultService
ruExecResultService
;
@Override
public
void
saveResult
(
ModelObj
param
,
String
RULEID
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
FieldObj
BUSINESSCAT
,
Integer
RETVALUE
,
FieldObj
KEYVALUEFIELD
,
FieldObj
DOMAINSFIELD
,
FieldObj
DIMFIELD
,
FieldObj
METRICFIELD
,
FieldObj
TIMEFIELD
,
FieldObj
EXT1FIELD
,
FieldObj
EXT2FIELD
)
{
ExecResult
result
=
new
ExecResult
();
result
.
setRuleId
(
RULEID
);
result
.
setRuleName
(
RULENAME
);
result
.
setName
(
RU_EXECRESULTNAME
);
result
.
setRetValue
(
RETVALUE
);
if
(
DOMAINSFIELD
==
null
)
DOMAINSFIELD
=
param
.
getEmpty
();
if
(
BUSINESSCAT
==
null
)
BUSINESSCAT
=
param
.
getEmpty
();
if
(
METRICFIELD
==
null
)
METRICFIELD
=
param
.
getEmpty
();
if
(
TIMEFIELD
==
null
)
TIMEFIELD
=
param
.
getEmpty
();
if
(
EXT1FIELD
==
null
)
EXT1FIELD
=
param
.
getEmpty
();
if
(
EXT2FIELD
==
null
)
EXT2FIELD
=
param
.
getEmpty
();
result
.
setKeyValueField
(
param
.
getRowKey
());
result
.
setBusinessCat
(
BUSINESSCAT
.
getValue
(
String
.
class
,
null
));
result
.
setMetricField
(
METRICFIELD
.
getDecimal
());
Timestamp
timefield
=
TIMEFIELD
.
getValue
(
Timestamp
.
class
,
null
);
if
(
timefield
!=
null
)
result
.
setTimeField
(
timefield
);
String
ext1
=
EXT1FIELD
.
getValues
();
if
(
ext1
.
length
()>
330
)
ext1
=
ext1
.
substring
(
0
,
330
)+
"..."
;
if
(!
StringUtils
.
isEmpty
(
ext1
))
result
.
setExt1Field
(
ext1
);
String
ext2
=
EXT2FIELD
.
getValues
();
if
(
ext2
.
length
()>
330
)
ext2
=
ext2
.
substring
(
0
,
330
)+
"..."
;
if
(!
StringUtils
.
isEmpty
(
ext2
))
result
.
setExt2Field
(
ext2
);
result
.
setDomainsField
(
DOMAINSFIELD
.
getValue
(
String
.
class
,
""
));
result
.
setSystemId
(
DataObject
.
getStringValue
(
param
.
get
(
"systemid"
),
null
));
Object
resultDataSource
=
ExecResultExService
.
Default_ResultDataSource
;
Object
resultTableName
=
ExecResultExService
.
Default_ResultTableName
;
if
(
param
.
containsKey
(
RuleEngineExService
.
Setting_ResultDataSource
.
toUpperCase
())){
resultDataSource
=
param
.
get
(
RuleEngineExService
.
Setting_ResultDataSource
);
}
if
(
param
.
containsKey
(
RuleEngineExService
.
Setting_ResultTableName
.
toUpperCase
())){
resultTableName
=
param
.
get
(
RuleEngineExService
.
Setting_ResultTableName
);
}
result
.
set
(
Tag_EngineId
,
param
.
get
(
Tag_EngineId
));
result
.
set
(
RuleEngineExService
.
Setting_ResultDataSource
,
resultDataSource
);
result
.
set
(
RuleEngineExService
.
Setting_ResultTableName
,
resultTableName
);
if
((!
StringUtils
.
isEmpty
(
result
.
getRuleId
()))&&(!
StringUtils
.
isEmpty
(
result
.
getKeyValueField
())))
{
List
<
DADimension
>
dims
=
daBuildExService
.
getDims
(
result
.
getBusinessCat
());
if
(
dims
!=
null
)
{
for
(
DADimension
dim
:
dims
)
{
String
codevalue
=
param
.
$
(
dim
.
getField
()).
getValue
(
String
.
class
,
""
);
if
(!
StringUtils
.
isEmpty
(
codevalue
))
{
String
dictname
=
dim
.
getDict
();
Object
val
=
codevalue
;
if
(!
StringUtils
.
isEmpty
(
dictname
))
{
CodeList
codeList
=
dictDstService
.
getCodeListCatalog
(
dictname
);
//维度指定代码表时,向上同时为每一个父节点添加一条数据
while
(
true
)
{
CodeItem
code
=
codeList
.
findCodeItem
(
val
);
if
(
code
!=
null
)
{
ExecResult
result2
=
new
ExecResult
();
CachedBeanCopier
.
copy
(
result
,
result2
);
result2
.
setDimField
(
code
.
getValue
().
toString
());
result2
.
setId
(
result2
.
getDefaultKey
(
true
).
toString
());
if
(
result2
.
getRetValue
()==
1
)
ruExecResultService
.
saveAsync
(
result2
);
else
ruExecResultService
.
deleteAsync
(
result2
);
//非逐层核算或无父代码项退出
if
(
dim
.
getRecursive
()
==
0
||
StringUtils
.
isEmpty
(
code
.
getParent
()))
{
break
;
}
else
{
val
=
code
.
getParent
();
}
}
else
break
;
}
}
else
{
//维度未指定代码表时,只保存一条数据
result
.
setDimField
(
codevalue
);
result
.
setId
(
result
.
getDefaultKey
(
true
).
toString
());
if
(
result
.
getRetValue
()==
1
)
ruExecResultService
.
saveAsync
(
result
);
else
ruExecResultService
.
deleteAsync
(
result
);
}
}
}
}
}
}
@Autowired
protected
IExecLogService
ruExecLogService
;
public
ExecLog
processAll
(
BaseRequest
msg
)
{
ExecLog
execlog
=
new
ExecLog
();
execlog
.
setId
(
msg
.
getId
());
execlog
.
setRunBody
(
msg
.
toString
());
StringBuilder
strErrorInfo
=
new
StringBuilder
();
int
count
=
0
;
int
errorcount
=
0
;
String
strResId
=
initRule
(
msg
.
getRules
(),
msg
.
getBatch
());
if
(
StringUtils
.
isEmpty
(
strResId
))
{
strErrorInfo
.
append
(
"准备rule文件错误"
);
strErrorInfo
.
append
(
"\r\n"
);
execlog
.
setRetCode
(
2
);
execlog
.
setCnt
(
count
);
execlog
.
setSucc
(
errorcount
);
execlog
.
setRunResult
(
strErrorInfo
.
toString
());
ruExecLogService
.
update
(
execlog
);
return
execlog
;
}
try
{
for
(
ModelObj
modelObj
:
msg
.
getDatas
())
{
try
{
count
++;
modelObj
.
set
(
"BATCH"
,
msg
.
getBatch
());
modelObj
.
set
(
Tag_EngineId
,
msg
.
getEngineId
());
modelObj
.
set
(
"systemid"
,
msg
.
getSystemid
());
if
(!
StringUtils
.
isEmpty
(
msg
.
getResultDataSource
())){
modelObj
.
set
(
RuleEngineExService
.
Setting_ResultDataSource
,
msg
.
getResultDataSource
());
}
if
(!
StringUtils
.
isEmpty
(
msg
.
getResultTableName
())){
modelObj
.
set
(
RuleEngineExService
.
Setting_ResultTableName
,
msg
.
getResultTableName
());
}
processRule
(
modelObj
,
modelObj
.
getRowKey
(),
strResId
);
}
catch
(
Exception
e
)
{
errorcount
++;
log
.
error
(
"Service错误,加载数据详细信息:"
+
modelObj
.
getRowKey
()
+
","
+
e
.
getMessage
());
if
(
strErrorInfo
.
toString
().
length
()
<=
5000
)
{
strErrorInfo
.
append
(
"加载数据详细信息:"
+
modelObj
.
getRowKey
()
+
",错误:"
+
e
.
getMessage
());
strErrorInfo
.
append
(
"\r\n"
);
if
(
e
.
getCause
()
!=
null
&&
e
.
getCause
().
getMessage
()
!=
null
)
{
strErrorInfo
.
append
(
e
.
getCause
().
getMessage
());
strErrorInfo
.
append
(
"\r\n"
);
}
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Service读取BaseRequest错误:"
+
e
.
toString
());
strErrorInfo
.
append
(
"读取BaseRequest错误:"
+
e
.
getMessage
());
strErrorInfo
.
append
(
"\r\n"
);
if
(
e
.
getCause
()
!=
null
&&
e
.
getCause
().
getMessage
()
!=
null
)
{
strErrorInfo
.
append
(
e
.
getCause
().
getMessage
());
strErrorInfo
.
append
(
"\r\n"
);
}
execlog
.
setRetCode
(
1
);
execlog
.
setCnt
(
count
);
if
(
errorcount
==
0
)
execlog
.
setSucc
(
0
);
else
execlog
.
setSucc
(
count
-
errorcount
);
execlog
.
setRunResult
(
strErrorInfo
.
toString
());
ruExecLogService
.
update
(
execlog
);
return
execlog
;
}
finally
{
if
(
setkieSession
.
containsKey
(
strResId
))
{
KieSession
kieSession
=
setkieSession
.
get
(
strResId
);
try
{
kieSession
.
dispose
();
}
catch
(
Exception
ex
){}
setkieSession
.
remove
(
strResId
);
setRuleCount
.
remove
(
strResId
);
}
}
log
.
info
(
new
StringBuilder
().
append
(
"Service成功,process successfully:"
).
append
(
msg
.
toString
()).
toString
());
strErrorInfo
.
append
(
"Service成功,process successfully\r\n"
);
execlog
.
setCnt
(
count
);
execlog
.
setSucc
(
count
-
errorcount
);
if
(
execlog
.
getCnt
()==
0
)
execlog
.
setRetCode
(
3
);
else
execlog
.
setRetCode
(
0
);
execlog
.
setRunResult
(
strErrorInfo
.
toString
());
this
.
ruExecLogService
.
update
(
execlog
);
return
execlog
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BuildResultService.java
0 → 100644
浏览文件 @
3c56a765
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.cql.ExecResult
;
import
cn.ibizlab.core.extensions.cql.ExecResultRepository
;
import
cn.ibizlab.core.extensions.domain.BuildResult
;
import
com.datastax.driver.core.LocalDate
;
import
com.datastax.driver.core.PagingState
;
import
com.datastax.driver.core.ResultSet
;
import
com.datastax.driver.core.Statement
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
datastax
.
driver
.
core
.
querybuilder
.
QueryBuilder
.*;
import
static
com
.
datastax
.
driver
.
core
.
querybuilder
.
QueryBuilder
.
lte
;
@Service
@Primary
@Slf4j
public
class
BuildResultService
{
@Value
(
"${cassandra.host:}"
)
private
String
cassandraHost
;
@Autowired
(
required
=
false
)
@Lazy
private
ExecResultRepository
execResultRepository
;
public
List
<
BuildResult
>
sum
(
List
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
)
{
List
<
BuildResult
>
ret
=
new
ArrayList
<>();
if
(!
StringUtils
.
isEmpty
(
cassandraHost
))
{
List
<
ExecResult
>
list
=
execResultRepository
.
sum
(
ruleids
,
retValue
,
dims
,
start
,
end
);
list
.
forEach
(
item
->{
ret
.
add
(
new
BuildResult
().
setCqlResult
(
item
));
});
}
else
{
}
return
ret
;
// LocalDate st = ExecResult.time2LocalDate(start);
// LocalDate ed = ExecResult.time2LocalDate(end);
// final ResultSet result = session.execute(select().column("ruleid").column("retvalue").column("dimfield").sum("metricfield").as("metricfield").
// from(TABLE).
// where(in("ruleid", ruleids)).
// and(eq("retvalue", retValue)).
// and(in("dimfield", dims)).
// and(gte("timefield", st)).and(lte("timefield", ed)).groupBy("ruleid", "retvalue", "dimfield").limit(5000).setReadTimeoutMillis(200000));
// return mapper.map(result).all();
// }
//
// public List<ExecResult> avg(List<String> ruleids, Integer retValue, List<String> dims, Timestamp start, Timestamp end) {
// LocalDate st = ExecResult.time2LocalDate(start);
// LocalDate ed = ExecResult.time2LocalDate(end);
// final ResultSet result = session.execute(select().column("ruleid").column("retvalue").column("dimfield").avg("metricfield").as("metricfield").
// from(TABLE).
// where(in("ruleid", ruleids)).
// and(eq("retvalue", retValue)).
// and(in("dimfield", dims)).
// and(gte("timefield", st)).and(lte("timefield", ed)).groupBy("ruleid", "retvalue", "dimfield").limit(5000).setReadTimeoutMillis(200000));
// return mapper.map(result).all();
// }
//
// public List<ExecResult> group(List<String> ruleids, Integer retValue, List<String> dims, String type, Timestamp start, Timestamp end) {
// if (type.equalsIgnoreCase("avg"))
// return avg(ruleids, retValue, dims, start, end);
// else
// return sum(ruleids, retValue, dims, start, end);
// }
//
// public List<ExecResult> group(List<String> ruleids, Integer retValue, List<String> dims, Timestamp start, Timestamp end) {
//
// return group(ruleids, retValue, dims, "sum", start, end);
// }
//
// /**
// * 根据规则ID、单位和时间查询相应的规则结果数据
// *
// * @param ruleid
// * @param retValue
// * @param dims
// * @param start
// * @param end
// * @return
// */
// public ResultSet getPageData(String ruleid, PagingState pagingState, Integer retValue, String dims, Timestamp start, Timestamp end) {
// final int RESULTS_PER_PAGE = 1000;
// LocalDate st = ExecResult.time2LocalDate(start);
// LocalDate ed = ExecResult.time2LocalDate(end);
// Statement statement = select().column("keyvaluefield").
// from(TABLE).
// where(eq("ruleid", ruleid)).
// and(eq("retvalue", retValue)).
// and(eq("dimfield", dims)).
// and(gte("timefield", st)).and(lte("timefield", ed)).setReadTimeoutMillis(200000);
// statement.setFetchSize(RESULTS_PER_PAGE);
// if (pagingState != null) {
// statement.setPagingState(pagingState);
// }
// final ResultSet result = session.execute(statement);
// return result;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录