Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-bi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林锐标
slm-bi
Commits
0cf33171
Commit
0cf33171
authored
May 14, 2021
by
梁光意
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改业务字段统计类型
parent
1444bbdf
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
101 additions
and
12 deletions
+101
-12
RestTemplateUtils.java
.../java/com/syc/slm/common/core/util/RestTemplateUtils.java
+1
-1
BaseRestController.java
...java/com/syc/slm/slmbi/controller/BaseRestController.java
+3
-0
VariableController.java
...java/com/syc/slm/slmbi/controller/VariableController.java
+10
-0
BusinessConditionDTO.java
...main/java/com/syc/slm/slmbi/dto/BusinessConditionDTO.java
+1
-1
BusinessDTO.java
src/main/java/com/syc/slm/slmbi/dto/BusinessDTO.java
+6
-6
BusinessFieldStatisticsDTO.java
...ava/com/syc/slm/slmbi/dto/BusinessFieldStatisticsDTO.java
+20
-0
VariableStatusRealTimeDataDTO.java
.../com/syc/slm/slmbi/dto/VariableStatusRealTimeDataDTO.java
+20
-0
VariableService.java
src/main/java/com/syc/slm/slmbi/service/VariableService.java
+10
-0
BusinessConfigServiceImpl.java
...syc/slm/slmbi/service/impl/BusinessConfigServiceImpl.java
+10
-4
VariableServiceImpl.java
...a/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
+18
-0
application.yml
src/main/resources/application.yml
+2
-0
No files found.
src/main/java/com/syc/slm/common/core/util/RestTemplateUtils.java
View file @
0cf33171
...
@@ -48,7 +48,7 @@ public final class RestTemplateUtils {
...
@@ -48,7 +48,7 @@ public final class RestTemplateUtils {
log
.
info
(
"GET请求,开始请求DC,uri是{},参数是{}"
,
url
,
SlmConstants
.
gson
.
toJson
(
uriVariables
));
log
.
info
(
"GET请求,开始请求DC,uri是{},参数是{}"
,
url
,
SlmConstants
.
gson
.
toJson
(
uriVariables
));
HttpEntity
<?>
requestEntity
=
new
HttpEntity
<>(
httpHeaders
);
HttpEntity
<?>
requestEntity
=
new
HttpEntity
<>(
httpHeaders
);
ResponseEntity
<
String
>
response
=
REST_TEMPLATE
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
,
uriVariables
);
ResponseEntity
<
String
>
response
=
REST_TEMPLATE
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
,
uriVariables
);
log
.
info
(
"请求结果是=============:{}"
,
response
.
getBody
());
log
.
info
(
"
GET
请求结果是=============:{}"
,
response
.
getBody
());
if
(
HttpStatus
.
OK
.
value
()
==
response
.
getStatusCodeValue
())
{
if
(
HttpStatus
.
OK
.
value
()
==
response
.
getStatusCodeValue
())
{
if
(
resultType
.
equals
(
String
.
class
))
{
if
(
resultType
.
equals
(
String
.
class
))
{
return
(
TResult
)
response
.
getBody
();
return
(
TResult
)
response
.
getBody
();
...
...
src/main/java/com/syc/slm/slmbi/controller/BaseRestController.java
View file @
0cf33171
...
@@ -73,6 +73,9 @@ public class BaseRestController {
...
@@ -73,6 +73,9 @@ public class BaseRestController {
// @Value("${dc_client.interfaces.historyCurve}")
// @Value("${dc_client.interfaces.historyCurve}")
// protected String historyCurve;
// protected String historyCurve;
@Value
(
"${dc_client.interfaces.variableStatusRealTimeDataList}"
)
protected
String
variableStatusRealTimeDataList
;
...
...
src/main/java/com/syc/slm/slmbi/controller/VariableController.java
View file @
0cf33171
...
@@ -193,4 +193,14 @@ public class VariableController extends BaseRestController{
...
@@ -193,4 +193,14 @@ public class VariableController extends BaseRestController{
return
variableService
.
listRealTimeVariableData
(
dcClientHost
+
realTimeVariableDataList
,
variableDTO
,
currentUser
);
return
variableService
.
listRealTimeVariableData
(
dcClientHost
+
realTimeVariableDataList
,
variableDTO
,
currentUser
);
});
});
}
}
@PostMapping
(
"/status/real-time/data"
)
@ApiOperation
(
"变量状态点实时数据(仪表盘和饼图专用)"
)
public
R
<
Map
<
String
,
Map
<
String
,
Object
>>>
listVariableStatusRealTimeData
(
HttpServletRequest
request
,
@PathVariable
String
appId
,
@RequestBody
List
<
VariableStatusRealTimeDataDTO
>
statusRealTimeDataList
)
{
return
call
(()
->
{
CurrentUser
currentUser
=
getCurrentUser
(
request
);
return
variableService
.
listVariableStatusRealTimeData
(
dcClientHost
+
variableStatusRealTimeDataList
,
statusRealTimeDataList
,
currentUser
);
});
}
}
}
src/main/java/com/syc/slm/slmbi/dto/BusinessConditionDTO.java
View file @
0cf33171
...
@@ -10,7 +10,7 @@ import lombok.Data;
...
@@ -10,7 +10,7 @@ import lombok.Data;
* @author : lin
* @author : lin
* @date : 2021-04-19 19:36
* @date : 2021-04-19 19:36
**/
**/
@ApiModel
(
value
=
"业务查询条件DTO"
)
@ApiModel
(
value
=
"业务查询条件
以及key的
DTO"
)
@Data
@Data
public
class
BusinessConditionDTO
{
public
class
BusinessConditionDTO
{
@ApiModelProperty
(
value
=
"区间配置字段"
,
required
=
true
)
@ApiModelProperty
(
value
=
"区间配置字段"
,
required
=
true
)
...
...
src/main/java/com/syc/slm/slmbi/dto/BusinessDTO.java
View file @
0cf33171
...
@@ -18,15 +18,15 @@ import java.util.Map;
...
@@ -18,15 +18,15 @@ import java.util.Map;
public
class
BusinessDTO
{
public
class
BusinessDTO
{
@ApiModelProperty
(
value
=
"查询表名"
,
required
=
true
)
@ApiModelProperty
(
value
=
"查询表名"
,
required
=
true
)
private
String
table
;
private
String
table
;
@ApiModelProperty
(
value
=
"纵轴变量"
,
required
=
true
)
private
String
y
;
@ApiModelProperty
(
value
=
"横轴变量"
,
required
=
true
)
@ApiModelProperty
(
value
=
"横轴纬度"
,
required
=
true
)
private
String
x
;
private
String
x
;
@ApiModelProperty
(
value
=
"横轴格式"
)
@ApiModelProperty
(
value
=
"横轴格式"
)
private
String
format
;
private
String
format
;
@ApiModelProperty
(
value
=
"查询配置(如果为空不要调用后台)"
,
required
=
true
)
@ApiModelProperty
(
value
=
"查询配置(如果为空不要调用后台)"
,
required
=
true
)
List
<
Map
<
String
,
List
<
BusinessConditionDTO
>>>
where
;
List
<
Map
<
String
,
List
<
BusinessConditionDTO
>>>
where
;
@ApiModelProperty
(
value
=
"统计类型(平均值 avg ,合计值 sum, 最大值 max ,最小值 min,中位数 middle ,原值 original)"
,
required
=
true
)
private
String
statisticsType
;
@ApiModelProperty
(
value
=
"统计参数"
,
required
=
true
)
List
<
BusinessFieldStatisticsDTO
>
statisticsList
;
}
}
src/main/java/com/syc/slm/slmbi/dto/BusinessFieldStatisticsDTO.java
0 → 100644
View file @
0cf33171
package
com
.
syc
.
slm
.
slmbi
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author: guangyi-liang
* @date: 2021/5/14
*/
@Data
@ApiModel
(
value
=
"字段统计DTO"
)
public
class
BusinessFieldStatisticsDTO
{
@ApiModelProperty
(
value
=
"统计类型(平均值 avg ,合计值 sum, 最大值 max ,最小值 min,中位数 middle)"
,
required
=
true
)
private
String
statisticsType
;
@ApiModelProperty
(
value
=
"纵轴变量"
,
required
=
true
)
private
String
field
;
}
src/main/java/com/syc/slm/slmbi/dto/VariableStatusRealTimeDataDTO.java
0 → 100644
View file @
0cf33171
package
com
.
syc
.
slm
.
slmbi
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author: guangyi-liang
* @date: 2021/5/14
*/
@Data
@ApiModel
(
value
=
"变量实时状态数据DTO(仪表盘和饼图专用)"
)
public
class
VariableStatusRealTimeDataDTO
{
@ApiModelProperty
(
value
=
"所属设备"
)
private
String
deviceId
;
@ApiModelProperty
(
value
=
"变量code,也就是变量name"
)
private
String
variableCode
;
}
src/main/java/com/syc/slm/slmbi/service/VariableService.java
View file @
0cf33171
...
@@ -104,4 +104,14 @@ public interface VariableService {
...
@@ -104,4 +104,14 @@ public interface VariableService {
* @return 返回值
* @return 返回值
*/
*/
Map
<
String
,
List
<
Object
>>
listRealTimeVariableData
(
@NonNull
String
uri
,
RealTimeVariableDataDTO
variableDTO
,
CurrentUser
user
);
Map
<
String
,
List
<
Object
>>
listRealTimeVariableData
(
@NonNull
String
uri
,
RealTimeVariableDataDTO
variableDTO
,
CurrentUser
user
);
/**
* 批量查询实时状态数据
* @param uri 请求uri
* @param statusRealTimeDataList 请求条件
* @param user 当前用户
* @return key为设备ID,value中key为变量名称,vlaue是数据
*/
Map
<
String
,
Map
<
String
,
Object
>>
listVariableStatusRealTimeData
(
@NonNull
String
uri
,
List
<
VariableStatusRealTimeDataDTO
>
statusRealTimeDataList
,
CurrentUser
user
);
}
}
src/main/java/com/syc/slm/slmbi/service/impl/BusinessConfigServiceImpl.java
View file @
0cf33171
...
@@ -82,15 +82,21 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
...
@@ -82,15 +82,21 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
if
(
StringUtils
.
isBlank
(
dto
.
getTable
())){
if
(
StringUtils
.
isBlank
(
dto
.
getTable
())){
throw
new
SysException
(
"请传入对应的表名"
);
throw
new
SysException
(
"请传入对应的表名"
);
}
}
if
(
StringUtils
.
isBlank
(
dto
.
getStatisticsType
())){
if
(
CollectionUtils
.
isEmpty
(
dto
.
getStatisticsList
())){
throw
new
SysException
(
"请传入字段统计参数"
);
}
else
{
if
(
dto
.
getStatisticsList
().
stream
().
anyMatch
(
x
->
StringUtils
.
isBlank
(
x
.
getField
()))){
throw
new
SysException
(
"y轴配置字段不能为空"
);
}
if
(
dto
.
getStatisticsList
().
stream
().
anyMatch
(
x
->
StringUtils
.
isBlank
(
x
.
getStatisticsType
()))){
throw
new
SysException
(
"统计类型不能为空"
);
throw
new
SysException
(
"统计类型不能为空"
);
}
}
}
if
(
StringUtils
.
isBlank
(
dto
.
getX
())){
if
(
StringUtils
.
isBlank
(
dto
.
getX
())){
throw
new
SysException
(
"x轴维度不能为空"
);
throw
new
SysException
(
"x轴维度不能为空"
);
}
}
if
(
StringUtils
.
isBlank
(
dto
.
getY
())){
throw
new
SysException
(
"y轴配置字段不能为空"
);
}
if
(
CollectionUtils
.
isEmpty
(
dto
.
getWhere
())){
if
(
CollectionUtils
.
isEmpty
(
dto
.
getWhere
())){
throw
new
SysException
(
"where 条件不能为空"
);
throw
new
SysException
(
"where 条件不能为空"
);
}
}
...
...
src/main/java/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
View file @
0cf33171
...
@@ -336,6 +336,24 @@ public class VariableServiceImpl implements VariableService {
...
@@ -336,6 +336,24 @@ public class VariableServiceImpl implements VariableService {
return
result
.
detach
();
return
result
.
detach
();
}
}
@Override
public
Map
<
String
,
Map
<
String
,
Object
>>
listVariableStatusRealTimeData
(
@NonNull
String
uri
,
List
<
VariableStatusRealTimeDataDTO
>
statusRealTimeDataList
,
CurrentUser
user
)
{
if
(
CollectionUtils
.
isEmpty
(
statusRealTimeDataList
)){
throw
new
SysException
(
"请传入变量"
);
}
else
{
if
(
statusRealTimeDataList
.
stream
().
anyMatch
(
x
->
StringUtils
.
isBlank
(
x
.
getDeviceId
()))){
throw
new
SysException
(
"设备ID不能为空"
);
}
if
(
statusRealTimeDataList
.
stream
().
anyMatch
(
x
->
StringUtils
.
isBlank
(
x
.
getVariableCode
()))){
throw
new
SysException
(
"变量Code不能为空"
);
}
}
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"appId"
,
user
.
getAppId
());
R
<
Map
<
String
,
Map
<
String
,
Object
>>>
result
=
RestTemplateUtils
.
post
(
uri
,
statusRealTimeDataList
,
new
TypeToken
<
R
<
Map
<
String
,
Map
<
String
,
Object
>>>>()
{}.
getType
(),
uriVariables
);
return
result
.
detach
();
}
private
void
judgeSearchList
(
List
<
VariableSearchDTO
>
variableSearchList
){
private
void
judgeSearchList
(
List
<
VariableSearchDTO
>
variableSearchList
){
if
(
CollectionUtils
.
isEmpty
(
variableSearchList
)){
if
(
CollectionUtils
.
isEmpty
(
variableSearchList
)){
throw
new
SysException
(
"请传入变量"
);
throw
new
SysException
(
"请传入变量"
);
...
...
src/main/resources/application.yml
View file @
0cf33171
...
@@ -70,3 +70,4 @@ dc_client:
...
@@ -70,3 +70,4 @@ dc_client:
# historyCurve : /{appId}/variables/history-curve?deviceId={deviceId}&endTime={endTime}&startTime={startTime}&variableCode={variableCode}&variableId={variableId}&format={format}
# historyCurve : /{appId}/variables/history-curve?deviceId={deviceId}&endTime={endTime}&startTime={startTime}&variableCode={variableCode}&variableId={variableId}&format={format}
# historyCurve : /{appId}/variables/history-curve
# historyCurve : /{appId}/variables/history-curve
permissionCodeUrl
:
/{appId}/bi/permission/code
permissionCodeUrl
:
/{appId}/bi/permission/code
variableStatusRealTimeDataList
:
/{appId}/variables/status/real-time/data
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment