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
e625748c
Commit
e625748c
authored
May 24, 2021
by
linruibiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口编写
parent
06a1abf5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
48 deletions
+51
-48
VariableController.java
...java/com/syc/slm/slmbi/controller/VariableController.java
+0
-1
VariableSendDTO.java
src/main/java/com/syc/slm/slmbi/dto/VariableSendDTO.java
+2
-0
VariableServiceImpl.java
...a/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
+49
-47
No files found.
src/main/java/com/syc/slm/slmbi/controller/VariableController.java
View file @
e625748c
...
@@ -151,7 +151,6 @@ public class VariableController extends BaseRestController{
...
@@ -151,7 +151,6 @@ public class VariableController extends BaseRestController{
});
});
}
}
@GetMapping
(
"/{deviceId}/{variableId}/{variableCode}/status"
)
@GetMapping
(
"/{deviceId}/{variableId}/{variableCode}/status"
)
@ApiOperation
(
"状态点实时数据"
)
@ApiOperation
(
"状态点实时数据"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
...
...
src/main/java/com/syc/slm/slmbi/dto/VariableSendDTO.java
View file @
e625748c
...
@@ -26,4 +26,6 @@ public class VariableSendDTO {
...
@@ -26,4 +26,6 @@ public class VariableSendDTO {
@ApiModelProperty
(
value
=
"key 是变量得id , value 是下发得值"
,
required
=
true
)
@ApiModelProperty
(
value
=
"key 是变量得id , value 是下发得值"
,
required
=
true
)
private
Map
<
String
,
Object
>
commandMap
;
private
Map
<
String
,
Object
>
commandMap
;
@ApiModelProperty
(
value
=
"控制按钮给1 读写框给2"
,
required
=
true
)
private
Integer
control
;
}
}
src/main/java/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
View file @
e625748c
...
@@ -17,7 +17,9 @@ import com.syc.slm.slmbi.enums.AccessType;
...
@@ -17,7 +17,9 @@ import com.syc.slm.slmbi.enums.AccessType;
import
com.syc.slm.slmbi.enums.StatisticsType
;
import
com.syc.slm.slmbi.enums.StatisticsType
;
import
com.syc.slm.slmbi.exception.SysException
;
import
com.syc.slm.slmbi.exception.SysException
;
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.VariableDeviceVo
;
import
com.syc.slm.slmbi.vo.VariableSourceVo
;
import
com.syc.slm.slmbi.vo.VariableVo
;
import
lombok.NonNull
;
import
lombok.NonNull
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -201,71 +203,71 @@ public class VariableServiceImpl implements VariableService {
...
@@ -201,71 +203,71 @@ public class VariableServiceImpl implements VariableService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
send
(
VariableSendDTO
sendDTO
,
CurrentUser
currentUser
,
String
uri
)
{
public
void
send
(
VariableSendDTO
sendDTO
,
CurrentUser
currentUser
,
String
uri
)
{
if
(
StringUtils
.
isBlank
(
sendDTO
.
getAccessType
()))
{
if
(
sendDTO
.
getControl
()
==
null
)
{
throw
new
SysException
(
"
请传入访问类型
"
);
throw
new
SysException
(
"
控件类型必填,控制按钮传1 读写框填2
"
);
}
}
if
(
sendDTO
.
getControl
().
equals
(
1
))
{
if
(
AccessType
.
PRIVATE
.
value
.
equals
(
sendDTO
.
getAccessType
())){
if
(
StringUtils
.
isBlank
(
sendDTO
.
getAccessType
()))
{
if
(
StringUtils
.
isBlank
(
sendDTO
.
getUserId
()))
{
throw
new
SysException
(
"请传入访问类型"
);
throw
new
SysException
(
"访问类型为私有,请传入创建人"
);
}
if
(
currentUser
.
getUid
().
equals
(
sendDTO
.
getUserId
())){
throw
new
SysException
(
"没有访问权限"
);
}
}
}
else
if
(
AccessType
.
CUSTOM
.
value
.
equals
(
sendDTO
.
getAccessType
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
sendDTO
.
getPermissions
())){
if
(
AccessType
.
PRIVATE
.
value
.
equals
(
sendDTO
.
getAccessType
()))
{
Map
<
String
,
List
<
CustomPermissionDTO
>>
maps
=
if
(
StringUtils
.
isBlank
(
sendDTO
.
getUserId
()))
{
sendDTO
.
getPermissions
().
stream
().
collect
(
Collectors
.
groupingBy
(
CustomPermissionDTO:
:
getBizType
));
throw
new
SysException
(
"访问类型为私有,请传入创建人"
);
List
<
CustomPermissionDTO
>
departments
=
maps
.
get
(
"department"
);
List
<
CustomPermissionDTO
>
positions
=
maps
.
get
(
"position"
);
List
<
CustomPermissionDTO
>
users
=
maps
.
get
(
"user"
);
boolean
flag
=
true
;
if
(
CollectionUtils
.
isNotEmpty
(
users
)){
if
(
users
.
stream
().
noneMatch
(
x
->
currentUser
.
getUid
().
equals
(
x
.
getBizId
()))){
flag
=
false
;
}
}
}
if
(
CollectionUtils
.
isNotEmpty
(
departments
)
||
CollectionUtils
.
isNotEmpty
(
positions
))
{
if
(
currentUser
.
getUid
().
equals
(
sendDTO
.
getUserId
()))
{
R
<
Map
<
String
,
String
>>
result
=
setDeptAndRole
(
currentUser
,
uri
);
throw
new
SysException
(
"没有访问权限"
);
Map
<
String
,
String
>
detach
=
result
.
detach
();
}
String
officeIds
=
detach
.
get
(
"deptIds"
);
}
else
if
(
AccessType
.
CUSTOM
.
value
.
equals
(
sendDTO
.
getAccessType
()))
{
String
roleIds
=
detach
.
get
(
"roleIds"
);
if
(
CollectionUtils
.
isNotEmpty
(
sendDTO
.
getPermissions
()))
{
if
(
flag
)
{
Map
<
String
,
List
<
CustomPermissionDTO
>>
maps
=
sendDTO
.
getPermissions
().
stream
().
collect
(
Collectors
.
groupingBy
(
CustomPermissionDTO:
:
getBizType
));
if
(
CollectionUtils
.
isNotEmpty
(
departments
))
{
List
<
CustomPermissionDTO
>
departments
=
maps
.
get
(
"department"
);
if
(
departments
.
stream
()
List
<
CustomPermissionDTO
>
positions
=
maps
.
get
(
"position"
);
.
map
(
CustomPermissionDTO:
:
getBizId
)
List
<
CustomPermissionDTO
>
users
=
maps
.
get
(
"user"
);
.
anyMatch
(
officeIds:
:
contains
))
{
boolean
flag
=
true
;
flag
=
false
;
if
(
CollectionUtils
.
isNotEmpty
(
users
))
{
}
if
(
users
.
stream
().
noneMatch
(
x
->
currentUser
.
getUid
().
equals
(
x
.
getBizId
())))
{
flag
=
false
;
}
}
}
}
if
(
flag
)
{
if
(
CollectionUtils
.
isNotEmpty
(
departments
)
||
CollectionUtils
.
isNotEmpty
(
positions
))
{
if
(
CollectionUtils
.
isNotEmpty
(
positions
))
{
R
<
Map
<
String
,
String
>>
result
=
setDeptAndRole
(
currentUser
,
uri
);
if
(
positions
.
stream
().
map
(
CustomPermissionDTO:
:
getBizId
).
anyMatch
(
roleIds:
:
contains
))
{
Map
<
String
,
String
>
detach
=
result
.
detach
();
flag
=
false
;
String
officeIds
=
detach
.
get
(
"deptIds"
);
String
roleIds
=
detach
.
get
(
"roleIds"
);
if
(
flag
)
{
if
(
CollectionUtils
.
isNotEmpty
(
departments
))
{
if
(
departments
.
stream
().
map
(
CustomPermissionDTO:
:
getBizId
).
anyMatch
(
officeIds:
:
contains
))
{
flag
=
false
;
}
}
}
}
}
}
if
(
flag
)
{
if
(
flag
){
if
(
CollectionUtils
.
isNotEmpty
(
positions
))
{
throw
new
SysException
(
"没有访问权限"
);
if
(
positions
.
stream
().
map
(
CustomPermissionDTO:
:
getBizId
).
anyMatch
(
roleIds:
:
contains
))
{
flag
=
false
;
}
}
}
if
(
flag
)
{
throw
new
SysException
(
"没有访问权限"
);
}
}
}
}
}
}
}
}
}
Map
<
String
,
Object
>
commandMap
=
sendDTO
.
getCommandMap
();
Map
<
String
,
Object
>
commandMap
=
sendDTO
.
getCommandMap
();
if
(
CollectionUtils
.
isEmpty
(
commandMap
))
{
if
(
CollectionUtils
.
isEmpty
(
commandMap
))
{
throw
new
SysException
(
"变量值必传"
);
throw
new
SysException
(
"变量值必传"
);
}
}
if
(
commandMap
.
keySet
().
stream
().
anyMatch
(
StringUtils:
:
isBlank
))
{
if
(
commandMap
.
keySet
().
stream
().
anyMatch
(
StringUtils:
:
isBlank
))
{
throw
new
SysException
(
"变量id 不能为空"
);
throw
new
SysException
(
"变量id 不能为空"
);
}
}
if
(
commandMap
.
values
().
stream
().
anyMatch
(
ObjectUtils:
:
isEmpty
))
{
if
(
commandMap
.
values
().
stream
().
anyMatch
(
ObjectUtils:
:
isEmpty
))
{
throw
new
SysException
(
"变量对应得value 值不能为空"
);
throw
new
SysException
(
"变量对应得value 值不能为空"
);
}
}
SendDeviceCommandsDTO
dto
=
new
SendDeviceCommandsDTO
();
SendDeviceCommandsDTO
dto
=
new
SendDeviceCommandsDTO
();
dto
.
setCommandMap
(
commandMap
);
dto
.
setCommandMap
(
commandMap
);
dto
.
setToken
(
currentUser
.
getToken
());
dto
.
setToken
(
currentUser
.
getToken
());
...
...
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