Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
997ac7c1
提交
997ac7c1
编写于
6月 16, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
cb3a98b0
变更
8
展开全部
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
963 行增加
和
110 行删除
+963
-110
ExecResultRepository.java
.../cn/ibizlab/core/extensions/cql/ExecResultRepository.java
+4
-3
FetchItem.java
...c/main/java/cn/ibizlab/core/extensions/dto/FetchItem.java
+85
-0
FetchParam.java
.../main/java/cn/ibizlab/core/extensions/dto/FetchParam.java
+145
-7
FetchResult.java
...main/java/cn/ibizlab/core/extensions/dto/FetchResult.java
+84
-0
VMConfig.java
...rc/main/java/cn/ibizlab/core/extensions/dto/VMConfig.java
+11
-8
BuildResultService.java
...n/ibizlab/core/extensions/service/BuildResultService.java
+621
-88
DABuildExService.java
.../cn/ibizlab/core/extensions/service/DABuildExService.java
+9
-0
DataObject.java
...util/src/main/java/cn/ibizlab/util/helper/DataObject.java
+4
-4
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/cql/ExecResultRepository.java
浏览文件 @
997ac7c1
...
...
@@ -10,6 +10,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import
org.springframework.stereotype.Repository
;
import
java.sql.Timestamp
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -125,7 +126,7 @@ public class ExecResultRepository {
public
List
<
ExecResult
>
sum
(
List
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
)
{
public
List
<
ExecResult
>
sum
(
Collection
<
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"
).
sum
(
"metricfield"
).
as
(
"metricfield"
).
...
...
@@ -137,7 +138,7 @@ public class ExecResultRepository {
return
mapper
.
map
(
result
).
all
();
}
public
List
<
ExecResult
>
avg
(
List
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
)
{
public
List
<
ExecResult
>
avg
(
Collection
<
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"
).
...
...
@@ -149,7 +150,7 @@ public class ExecResultRepository {
return
mapper
.
map
(
result
).
all
();
}
public
List
<
ExecResult
>
group
(
List
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
String
type
,
Timestamp
start
,
Timestamp
end
)
{
public
List
<
ExecResult
>
group
(
Collection
<
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
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/dto/FetchItem.java
0 → 100644
浏览文件 @
997ac7c1
package
cn
.
ibizlab
.
core
.
extensions
.
dto
;
import
cn.ibizlab.core.lite.extensions.domain.DataObj
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.math.BigDecimal
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
FetchItem
extends
DataObj
{
// 表格展示类型:1. default(维度数据以行的形式展示),2. LIST_BOX(维度数据以列的形式展示)
public
String
getDisplayType
()
{
return
this
.
getStringValue
(
"displayType"
,
"default"
);
}
public
FetchItem
setDisplayType
(
String
displayType
)
{
this
.
put
(
"displayType"
,
displayType
);
return
this
;
}
public
int
getNo
()
{
return
this
.
getIntegerValue
(
"no"
,
1
);
}
public
FetchItem
setNo
(
int
no
)
{
this
.
put
(
"no"
,
no
);
return
this
;
}
public
String
getDimId
()
{
return
this
.
getStringValue
(
"dimId"
);
}
public
FetchItem
setDimId
(
String
dimId
)
{
this
.
put
(
"dimId"
,
dimId
);
this
.
put
(
"itemId"
,
dimId
);
return
this
;
}
public
String
getDimName
()
{
return
this
.
getStringValue
(
"dimName"
);
}
public
FetchItem
setDimName
(
String
dimName
)
{
this
.
put
(
"dimName"
,
dimName
);
this
.
put
(
"itemName"
,
dimName
);
return
this
;
}
public
String
getMetricId1
()
{
return
this
.
getStringValue
(
"metricId"
);
}
public
FetchItem
setMetricId
(
String
metricId
)
{
this
.
put
(
"metricId"
,
metricId
);
this
.
put
(
"itemId"
,
metricId
);
return
this
;
}
public
String
getMetricName
()
{
return
this
.
getStringValue
(
"metricName"
);
}
public
FetchItem
setMetricName
(
String
metricName
)
{
this
.
put
(
"metricName"
,
metricName
);
this
.
put
(
"itemName"
,
metricName
);
return
this
;
}
public
BigDecimal
getVal
(
String
colId
)
{
return
this
.
getBigDecimalValue
(
colId
,
BigDecimal
.
ZERO
);
}
public
FetchItem
setVal
(
String
colId
,
BigDecimal
val
)
{
if
(
val
==
null
)
val
=
BigDecimal
.
ZERO
;
this
.
put
(
colId
,
val
);
return
this
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/dto/FetchParam.java
浏览文件 @
997ac7c1
package
cn
.
ibizlab
.
core
.
extensions
.
dto
;
import
cn.ibizlab.core.analysis.domain.DAMetric
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
...
...
@@ -12,10 +15,10 @@ import lombok.experimental.Accessors;
import
org.springframework.util.StringUtils
;
import
java.sql.Timestamp
;
import
java.
util.ArrayLis
t
;
import
java.
util.LinkedHashMap
;
import
java.
util.Lis
t
;
import
java.util.
Map
;
import
java.
text.DateForma
t
;
import
java.
text.ParseException
;
import
java.
text.SimpleDateForma
t
;
import
java.util.
*
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Getter
...
...
@@ -52,6 +55,8 @@ public class FetchParam {
private
int
page
=
0
;
private
int
size
=
100
;
private
boolean
filled
=
false
;
public
List
<
String
>
getDimValues
()
{
if
(
dimValues
==
null
&&(!
includeChild
)&&(!
StringUtils
.
isEmpty
(
dimValue
)))
...
...
@@ -75,10 +80,28 @@ public class FetchParam {
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
List
<
String
>>
dimTables
;
private
CodeItem
dimItem
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
CodeItem
getDimItem
()
{
return
dimItem
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
FetchParam
setDimItem
(
CodeItem
dimItem
)
{
this
.
dimItem
=
dimItem
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
Set
<
String
>>
dimTables
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
Lis
t
<
String
>>
getDimTables
()
public
Map
<
String
,
Se
t
<
String
>>
getDimTables
()
{
if
(
dimTables
==
null
)
dimTables
=
new
LinkedHashMap
<>();
...
...
@@ -86,10 +109,125 @@ public class FetchParam {
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
FetchParam
getDimTables
(
Map
<
String
,
Lis
t
<
String
>>
dimTables
)
public
FetchParam
setDimTables
(
Map
<
String
,
Se
t
<
String
>>
dimTables
)
{
this
.
dimTables
=
dimTables
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
DAMetric
>
metrics
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
DAMetric
>
getMetrics
()
{
if
(
metrics
==
null
)
metrics
=
new
LinkedHashMap
<>();
return
metrics
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
FetchParam
setMetrics
(
Map
<
String
,
DAMetric
>
metrics
)
{
this
.
metrics
=
metrics
;
return
this
;
}
public
Timestamp
getStartTime
()
{
if
(
startTime
!=
null
)
{
try
{
return
new
Timestamp
(
DataObject
.
dayFormat
.
parse
(
DataObject
.
dayFormat
.
format
(
startTime
)).
getTime
());
}
catch
(
Exception
exception
)
{
}
}
return
getDefaultStartTimestamp
();
}
public
Timestamp
getEndTime
()
{
if
(
endTime
!=
null
)
{
try
{
return
new
Timestamp
(
DataObject
.
dayFormat
.
parse
(
DataObject
.
dayFormat
.
format
(
endTime
)+
" 23:59:59"
).
getTime
());
}
catch
(
Exception
exception
)
{
}
}
return
getDefaultEndTimestamp
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
List
<
VMConfig
>
vmConfigs
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
String
group
;
public
static
Timestamp
getDefaultStartTimestamp
()
{
Calendar
c
=
Calendar
.
getInstance
();
Date
d
=
new
Date
();
try
{
d
=
DataObject
.
dayFormat
.
parse
(
DataObject
.
dayFormat
.
format
(
d
));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
c
.
setTime
(
d
);
c
.
add
(
Calendar
.
MONTH
,
-
1
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
return
new
Timestamp
(
c
.
getTime
().
getTime
());
}
public
static
Timestamp
getDefaultEndTimestamp
()
{
Calendar
c
=
Calendar
.
getInstance
();
Date
d
=
new
Date
();
try
{
d
=
DataObject
.
dayFormat
.
parse
(
DataObject
.
dayFormat
.
format
(
d
)+
" 23:59:59"
);
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
c
.
setTime
(
d
);
int
month
=
c
.
get
(
Calendar
.
MONTH
);
c
.
set
(
Calendar
.
MONTH
,
month
-
1
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
c
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
return
new
Timestamp
(
c
.
getTime
().
getTime
());
}
public
static
Timestamp
getLastYear
(
Timestamp
time
)
{
Date
date
=
new
Date
(
time
.
getTime
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
// 设置为当前时间
calendar
.
set
(
Calendar
.
YEAR
,
calendar
.
get
(
Calendar
.
YEAR
)
-
1
);
// 设置为上一年
date
=
calendar
.
getTime
();
Timestamp
rt
=
new
Timestamp
(
date
.
getTime
());
return
rt
;
}
public
static
Timestamp
getLastMonth
(
Timestamp
time
)
{
Date
date
=
new
Date
(
time
.
getTime
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
// 设置为当前时间
calendar
.
set
(
Calendar
.
MONTH
,
calendar
.
get
(
Calendar
.
MONTH
)
-
1
);
// 设置为上一个月
date
=
calendar
.
getTime
();
Timestamp
rt
=
new
Timestamp
(
date
.
getTime
());
return
rt
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/dto/FetchResult.java
0 → 100644
浏览文件 @
997ac7c1
package
cn
.
ibizlab
.
core
.
extensions
.
dto
;
import
cn.ibizlab.core.analysis.domain.DAMetric
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.sql.Timestamp
;
import
java.text.ParseException
;
import
java.util.*
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
FetchResult
{
// 表格展示类型:1. default(维度数据以行的形式展示),2. LIST_BOX(维度数据以列的形式展示)
private
String
displayType
=
"default"
;
private
List
<
FetchItem
>
rows
;
private
List
<
VMConfig
>
headers
;
public
List
<
VMConfig
>
getHeaders
()
{
if
(
headers
==
null
)
{
headers
=
new
ArrayList
<>();
headers
.
add
(
new
VMConfig
().
setHeaderName
(
"序号"
).
setEntity
(
"item"
).
setField
(
"no"
).
setPinned
(
"left"
));
headers
.
add
(
new
VMConfig
().
setHeaderName
(
getGroup
()).
setEntity
(
"item"
).
setField
(
"itemName"
).
setPinned
(
"left"
));
if
(
vmConfigs
!=
null
)
headers
.
addAll
(
vmConfigs
);
}
return
headers
;
}
public
FetchResult
trans2ListBox
()
{
FetchResult
listBox
=
new
FetchResult
();
List
<
VMConfig
>
vms
=
new
ArrayList
<>();
rows
.
forEach
(
row
->{
VMConfig
config
=
new
VMConfig
();
config
.
setHeaderName
(
row
.
getDimName
()).
setEntity
(
"item"
).
setField
(
row
.
getDimId
()).
setWidth
(
80
);
vms
.
add
(
config
);
});
this
.
setVmConfigs
(
vms
);
return
listBox
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
List
<
VMConfig
>
vmConfigs
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
String
group
;
public
static
FetchResult
from
(
FetchParam
fetchParam
)
{
FetchResult
fetchResult
=
new
FetchResult
();
fetchResult
.
setDisplayType
(
fetchParam
.
getDisplayType
());
if
(
fetchParam
.
getVmConfigs
()!=
null
)
{
fetchResult
.
setVmConfigs
(
fetchParam
.
getVmConfigs
());
}
fetchResult
.
setGroup
(
StringUtils
.
isEmpty
(
fetchParam
.
getGroup
())?
"分项"
:
fetchParam
.
getGroup
());
return
fetchResult
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/dto/VMConfig.java
浏览文件 @
997ac7c1
...
...
@@ -3,6 +3,7 @@ package cn.ibizlab.core.extensions.dto;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -13,19 +14,21 @@ import org.springframework.util.StringUtils;
import
java.util.*
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
VMConfig
{
private
String
headerName
;
private
String
width
;
private
Integer
width
;
@JSONField
(
name
=
"entity"
)
@JsonProperty
(
"entity"
)
private
String
buildId
;
private
String
entity
;
@JSONField
(
name
=
"field"
)
@JsonProperty
(
"field"
)
private
String
metricId
;
private
String
field
;
private
String
pinned
;
private
List
<
VMConfig
>
children
;
public
Map
<
String
,
Set
<
String
>>
getBuilds
(
Map
<
String
,
Set
<
String
>>
builds
)
...
...
@@ -34,17 +37,17 @@ public class VMConfig {
{
builds
=
new
LinkedHashMap
<>();
}
if
((!
StringUtils
.
isEmpty
(
buildId
))
&&
(!
StringUtils
.
isEmpty
(
metricI
d
)))
if
((!
StringUtils
.
isEmpty
(
entity
))
&&
(!
StringUtils
.
isEmpty
(
fiel
d
)))
{
if
(
builds
.
containsKey
(
buildId
))
if
(
builds
.
containsKey
(
entity
))
{
builds
.
get
(
buildId
).
add
(
metricI
d
);
builds
.
get
(
entity
).
add
(
fiel
d
);
}
else
{
Set
<
String
>
metricIds
=
new
LinkedHashSet
<>();
metricIds
.
add
(
metricI
d
);
builds
.
put
(
buildId
,
metricIds
);
metricIds
.
add
(
fiel
d
);
builds
.
put
(
entity
,
metricIds
);
}
}
if
(!
ObjectUtils
.
isEmpty
(
children
))
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BuildResultService.java
浏览文件 @
997ac7c1
此差异已折叠。
点击以展开。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/DABuildExService.java
浏览文件 @
997ac7c1
...
...
@@ -20,6 +20,7 @@ import cn.ibizlab.core.rule.service.IExecLogService;
import
cn.ibizlab.core.rule.service.IRuleItemService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.Setting
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
...
@@ -174,6 +175,14 @@ public class DABuildExService extends DABuildServiceImpl {
msg
.
setBatch
(
engineMQMsg
.
getBatch
());
msg
.
setSystemid
(
et
.
getSystemId
());
msg
.
setEngineId
(
engineMQMsg
.
getEngineId
());
String
resultDataSource
=
Setting
.
getValue
(
et
.
getExtParams
(),
"resultDataSource"
);
String
resultTableName
=
Setting
.
getValue
(
et
.
getExtParams
(),
"resultTableName"
);
if
(!
StringUtils
.
isEmpty
(
resultDataSource
)){
msg
.
setResultDataSource
(
resultDataSource
);
}
if
(!
StringUtils
.
isEmpty
(
resultTableName
)){
msg
.
setResultTableName
(
resultTableName
);
}
ExecLog
execlog
=
new
ExecLog
();
execlog
.
setId
(
msg
.
getId
());
...
...
ibzdst-util/src/main/java/cn/ibizlab/util/helper/DataObject.java
浏览文件 @
997ac7c1
...
...
@@ -238,20 +238,20 @@ public class DataObject {
}
try
{
if
(
objValue
instanceof
BigDecimal
){
return
(
BigDecimal
)(
objValue
);
return
(
(
BigDecimal
)(
objValue
)).
stripTrailingZeros
(
);
}
if
(
objValue
instanceof
Double
){
return
BigDecimal
.
valueOf
((
Double
)
objValue
);
return
BigDecimal
.
valueOf
((
Double
)
objValue
)
.
stripTrailingZeros
()
;
}
if
(
objValue
instanceof
Long
){
return
BigDecimal
.
valueOf
((
Long
)
objValue
);
return
BigDecimal
.
valueOf
((
Long
)
objValue
)
.
stripTrailingZeros
()
;
}
String
strValue
=
objValue
.
toString
();
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
fDefault
;
}
strValue
=
strValue
.
replace
(
","
,
""
);
return
BigDecimal
.
valueOf
(
Double
.
parseDouble
(
strValue
));
return
BigDecimal
.
valueOf
(
Double
.
parseDouble
(
strValue
))
.
stripTrailingZeros
()
;
}
catch
(
Exception
ex
)
{
return
fDefault
;
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录