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
ed83a504
Commit
ed83a504
authored
Apr 30, 2021
by
linruibiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口编写
parent
e7d79f55
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
3 deletions
+112
-3
BaseRestController.java
...java/com/syc/slm/slmbi/controller/BaseRestController.java
+4
-0
VariableController.java
...java/com/syc/slm/slmbi/controller/VariableController.java
+37
-3
VariableService.java
src/main/java/com/syc/slm/slmbi/service/VariableService.java
+21
-0
VariableServiceImpl.java
...a/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
+50
-0
No files found.
src/main/java/com/syc/slm/slmbi/controller/BaseRestController.java
View file @
ed83a504
...
@@ -61,7 +61,11 @@ public class BaseRestController {
...
@@ -61,7 +61,11 @@ public class BaseRestController {
protected
String
filedValue
;
protected
String
filedValue
;
@Value
(
"${dc_client.interfaces.send}"
)
@Value
(
"${dc_client.interfaces.send}"
)
protected
String
send
;
protected
String
send
;
@Value
(
"${dc_client.interfaces.variableStatus}"
)
protected
String
variableStatus
;
@Value
(
"${dc_client.interfaces.variableHistoryStatus}"
)
protected
String
variableHistoryStatus
;
...
...
src/main/java/com/syc/slm/slmbi/controller/VariableController.java
View file @
ed83a504
...
@@ -3,16 +3,18 @@ package com.syc.slm.slmbi.controller;
...
@@ -3,16 +3,18 @@ package com.syc.slm.slmbi.controller;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.syc.slm.common.core.util.R
;
import
com.syc.slm.common.core.util.R
;
import
com.syc.slm.common.core.util.RestTemplateUtils
;
import
com.syc.slm.slmbi.dto.*
;
import
com.syc.slm.slmbi.dto.*
;
import
com.syc.slm.slmbi.entity.CurrentUser
;
import
com.syc.slm.slmbi.entity.CurrentUser
;
import
com.syc.slm.slmbi.service.VariableService
;
import
com.syc.slm.slmbi.service.VariableService
;
import
com.syc.slm.slmbi.vo.*
;
import
com.syc.slm.slmbi.vo.PanelTreeNodeVo
;
import
com.syc.slm.slmbi.vo.VariableDeviceVo
;
import
com.syc.slm.slmbi.vo.VariableSourceVo
;
import
com.syc.slm.slmbi.vo.VariableVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -136,4 +138,36 @@ public class VariableController extends BaseRestController{
...
@@ -136,4 +138,36 @@ public class VariableController extends BaseRestController{
variableService
.
send
(
sendDTO
,
currentUser
,
dcClientHost
+
send
);
variableService
.
send
(
sendDTO
,
currentUser
,
dcClientHost
+
send
);
});
});
}
}
@GetMapping
(
"/{deviceId}/{variableCode}/status"
)
@ApiOperation
(
"状态点实时数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"appId"
,
value
=
"租户id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@ApiImplicitParam
(
name
=
"deviceId"
,
value
=
"设备id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@ApiImplicitParam
(
name
=
"variableCode"
,
value
=
"变量点code"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
})
public
R
<
Map
<
String
,
Object
>>
status
(
HttpServletRequest
request
,
@PathVariable
String
appId
,
@PathVariable
String
deviceId
,
@PathVariable
String
variableCode
)
{
return
call
(()
->
{
CurrentUser
currentUser
=
getCurrentUser
(
request
);
return
variableService
.
status
(
dcClientHost
+
variableStatus
,
deviceId
,
variableCode
,
currentUser
);
});
}
@GetMapping
(
"/{deviceId}/{variableCode}/history-status"
)
@ApiOperation
(
"状态点历史数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"appId"
,
value
=
"租户id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@ApiImplicitParam
(
name
=
"deviceId"
,
value
=
"设备id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@ApiImplicitParam
(
name
=
"variableCode"
,
value
=
"变量点code"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间(时间戳)"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间(时间戳,开是否要加一天加一月加一年)"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
})
public
R
<
Map
<
String
,
Object
>>
historyStatus
(
HttpServletRequest
request
,
@PathVariable
String
appId
,
@PathVariable
String
deviceId
,
@PathVariable
String
variableCode
,
@RequestParam
String
startTime
,
@RequestParam
String
endTime
)
{
return
call
(()
->
{
CurrentUser
currentUser
=
getCurrentUser
(
request
);
return
variableService
.
historyStatus
(
dcClientHost
+
variableHistoryStatus
,
deviceId
,
variableCode
,
startTime
,
endTime
,
currentUser
);
});
}
}
}
src/main/java/com/syc/slm/slmbi/service/VariableService.java
View file @
ed83a504
...
@@ -66,4 +66,25 @@ public interface VariableService {
...
@@ -66,4 +66,25 @@ public interface VariableService {
* @param uri
* @param uri
*/
*/
void
send
(
VariableSendDTO
sendDTO
,
CurrentUser
currentUser
,
String
uri
);
void
send
(
VariableSendDTO
sendDTO
,
CurrentUser
currentUser
,
String
uri
);
/**
* 状态点实时数据
* @param uri
* @param deviceId
* @param variableCode
* @return
*/
Map
<
String
,
Object
>
status
(
String
uri
,
String
deviceId
,
String
variableCode
,
CurrentUser
user
);
/**
* 状态点历史数据
* @param uri
* @param deviceId
* @param variableCode
* @param startTime
* @param endTime
* @param currentUser
* @return
*/
Map
<
String
,
Object
>
historyStatus
(
String
uri
,
String
deviceId
,
String
variableCode
,
String
startTime
,
String
endTime
,
CurrentUser
currentUser
);
}
}
src/main/java/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
View file @
ed83a504
...
@@ -270,6 +270,56 @@ public class VariableServiceImpl implements VariableService {
...
@@ -270,6 +270,56 @@ public class VariableServiceImpl implements VariableService {
}
}
@Override
public
Map
<
String
,
Object
>
status
(
String
uri
,
String
deviceId
,
String
variableCode
,
CurrentUser
user
)
{
if
(
StringUtils
.
isBlank
(
variableCode
)){
throw
new
SysException
(
"变量code不能为空"
);
}
if
(
StringUtils
.
isBlank
(
deviceId
)){
throw
new
SysException
(
"设备id不能为空"
);
}
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"appId"
,
user
.
getAppId
());
uriVariables
.
put
(
"deviceId"
,
deviceId
);
uriVariables
.
put
(
"variableCode"
,
variableCode
);
R
<
Map
<
String
,
Object
>>
result
=
RestTemplateUtils
.
get
(
uri
,
new
TypeToken
<
R
<
Map
<
String
,
Object
>>>()
{}.
getType
(),
uriVariables
);
return
result
.
detach
();
}
@Override
public
Map
<
String
,
Object
>
historyStatus
(
String
uri
,
String
deviceId
,
String
variableCode
,
String
startTime
,
String
endTime
,
CurrentUser
currentUser
)
{
if
(
StringUtils
.
isBlank
(
variableCode
)){
throw
new
SysException
(
"变量code不能为空"
);
}
if
(
StringUtils
.
isBlank
(
deviceId
)){
throw
new
SysException
(
"设备id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
startTime
)){
throw
new
SysException
(
"开始时间不能为空"
);
}
if
(
StringUtils
.
isBlank
(
endTime
)){
throw
new
SysException
(
"结束时间不能为空"
);
}
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"appId"
,
currentUser
.
getAppId
());
uriVariables
.
put
(
"deviceId"
,
deviceId
);
uriVariables
.
put
(
"variableCode"
,
variableCode
);
uriVariables
.
put
(
"startTime"
,
startTime
);
uriVariables
.
put
(
"endTime"
,
endTime
);
R
<
Map
<
String
,
Object
>>
result
=
RestTemplateUtils
.
get
(
uri
,
new
TypeToken
<
R
<
Map
<
String
,
Object
>>>()
{}.
getType
(),
uriVariables
);
return
result
.
detach
();
}
private
R
<
Map
<
String
,
String
>>
setDeptAndRole
(
CurrentUser
user
,
String
uri
){
private
R
<
Map
<
String
,
String
>>
setDeptAndRole
(
CurrentUser
user
,
String
uri
){
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"appId"
,
user
.
getAppId
());
uriVariables
.
put
(
"appId"
,
user
.
getAppId
());
...
...
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