Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6fcd2444
authored
Nov 21, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:声网token区分rtm和rtc
parent
d72bd5bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
27 deletions
server-module/src/main/java/com/makeit/module/controller/alarm/PlatAlarmRecordController.java
server-service/src/main/java/com/makeit/service/platform/alarm/PlatAlarmRecordService.java
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderChildrenInfoServiceImpl.java
server-module/src/main/java/com/makeit/module/controller/alarm/PlatAlarmRecordController.java
View file @
6fcd2444
...
...
@@ -68,15 +68,16 @@ public class PlatAlarmRecordController {
@ApiOperation
(
"呼叫设备"
)
@PostMapping
(
"callingDevice"
)
public
ApiResponseEntity
<
PlatAlarmCallDeviceVO
>
callingDevice
()
{
return
ApiResponseUtils
.
success
(
platAlarmRecordService
.
callingDevice
());
public
ApiResponseEntity
<
PlatAlarmCallDeviceVO
>
callingDevice
(
@RequestBody
PlatCallingDeviceDTO
dto
)
{
return
ApiResponseUtils
.
success
(
platAlarmRecordService
.
callingDevice
(
dto
));
}
@ApiOperation
(
"呼叫设备"
)
@PostMapping
(
"callingDeviceAuthIgnore"
)
@AuthIgnore
public
ApiResponseEntity
<
PlatAlarmCallDeviceVO
>
callingDeviceAuthIgnore
()
{
return
ApiResponseUtils
.
success
(
platAlarmRecordService
.
callingDevice
());
@TenantIdIgnore
public
ApiResponseEntity
<
PlatAlarmCallDeviceVO
>
callingDeviceAuthIgnore
(
@RequestBody
PlatCallingDeviceDTO
dto
)
{
return
ApiResponseUtils
.
success
(
platAlarmRecordService
.
callingDevice
(
dto
));
}
@ApiOperation
(
"呼叫设备rtm"
)
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/PlatAlarmRecordService.java
View file @
6fcd2444
...
...
@@ -70,7 +70,7 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
void
misinformation
(
String
id
);
PlatAlarmCallDeviceVO
callingDevice
();
PlatAlarmCallDeviceVO
callingDevice
(
PlatCallingDeviceDTO
dto
);
PlatAlarmCallDeviceVO
callingDeviceAuthIgnoreRtm
(
PlatCallingDeviceDTO
id
);
}
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
View file @
6fcd2444
...
...
@@ -61,7 +61,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -586,44 +585,38 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
}
@Override
public
PlatAlarmCallDeviceVO
callingDevice
()
{
public
PlatAlarmCallDeviceVO
callingDevice
(
PlatCallingDeviceDTO
dto
)
{
PlatAlarmCallDeviceVO
platAlarmCallDeviceVO
=
new
PlatAlarmCallDeviceVO
();
PlatAlarmRecord
platAlarmRecord
=
getById
(
dto
.
getId
());
if
(
platAlarmRecord
==
null
)
{
throw
new
RuntimeException
(
"告警记录为空:"
+
dto
.
getId
());
}
String
deviceId
=
platAlarmRecord
.
getDeviceId
();
PlatDevice
platDevice
=
platDeviceService
.
getById
(
deviceId
);
platAlarmCallDeviceVO
.
setDeviceId
(
platDevice
.
getOriDeviceId
());
platAlarmCallDeviceVO
.
setUserId
(
dto
.
getUserId
());
platAlarmCallDeviceVO
.
setAppId
(
shengwangProperties
.
getAppId
());
LocalDateTime
now
=
LocalDateTime
.
now
();
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
String
format
=
now
.
format
(
dateTimeFormatter
);
String
channelName
=
String
.
format
(
"%s:%s"
,
"RTC"
,
now
.
format
(
dateTimeFormatter
)
);
RtcTokenBuilder2
token
=
new
RtcTokenBuilder2
();
String
result
=
token
.
buildTokenWithUid
(
shengwangProperties
.
getAppId
(),
shengwangProperties
.
getAppCertificate
(),
format
,
0
,
RtcTokenBuilder2
.
Role
.
ROLE_SUBSCRIBER
,
String
result
=
token
.
buildTokenWithUid
(
shengwangProperties
.
getAppId
(),
shengwangProperties
.
getAppCertificate
(),
channelName
,
0
,
RtcTokenBuilder2
.
Role
.
ROLE_SUBSCRIBER
,
shengwangProperties
.
getTokenExpirationInSeconds
(),
shengwangProperties
.
getPrivilegeExpirationInSeconds
());
PlatAlarmCallDeviceVO
platAlarmCallDeviceVO
=
new
PlatAlarmCallDeviceVO
();
platAlarmCallDeviceVO
.
setAccessToken
(
result
);
platAlarmCallDeviceVO
.
setChannelName
(
format
);
platAlarmCallDeviceVO
.
setChannelName
(
channelName
);
return
platAlarmCallDeviceVO
;
}
@Override
public
PlatAlarmCallDeviceVO
callingDeviceAuthIgnoreRtm
(
PlatCallingDeviceDTO
dto
)
{
String
redisResult
=
redisTemplate
.
opsForValue
().
get
(
REDIS_DEVICE_CALL
+
dto
.
getUserId
());
if
(
StringUtils
.
isNotEmpty
(
redisResult
))
{
return
JSON
.
parseObject
(
redisResult
,
PlatAlarmCallDeviceVO
.
class
);
}
PlatAlarmCallDeviceVO
platAlarmCallDeviceVO
=
new
PlatAlarmCallDeviceVO
();
PlatAlarmRecord
platAlarmRecord
=
getById
(
dto
.
getId
());
if
(
platAlarmRecord
==
null
)
{
throw
new
RuntimeException
(
"告警记录为空:"
+
dto
.
getId
());
}
String
deviceId
=
platAlarmRecord
.
getDeviceId
();
PlatDevice
platDevice
=
platDeviceService
.
getById
(
deviceId
);
platAlarmCallDeviceVO
.
setDeviceId
(
platDevice
.
getOriDeviceId
());
platAlarmCallDeviceVO
.
setUserId
(
dto
.
getUserId
());
RtmTokenBuilder2
token
=
new
RtmTokenBuilder2
();
String
result
=
token
.
buildToken
(
shengwangProperties
.
getAppId
(),
shengwangProperties
.
getAppCertificate
(),
dto
.
getUserId
(),
shengwangProperties
.
getTokenExpirationInSeconds
());
LocalDateTime
now
=
LocalDateTime
.
now
();
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
String
format
=
now
.
format
(
dateTimeFormatter
);
String
format
=
String
.
format
(
"%s:%s"
,
"RTM"
,
now
.
format
(
dateTimeFormatter
)
);
platAlarmCallDeviceVO
.
setAccessToken
(
result
);
platAlarmCallDeviceVO
.
setChannelName
(
format
);
platAlarmCallDeviceVO
.
setChannelName
(
shengwangProperties
.
getAppId
());
redisTemplate
.
opsForValue
().
set
(
REDIS_DEVICE_CALL
+
dto
.
getUserId
(),
JSON
.
toJSONString
(
platAlarmCallDeviceVO
),
shengwangProperties
.
getTokenExpirationInSeconds
(),
TimeUnit
.
SECONDS
);
return
platAlarmCallDeviceVO
;
}
}
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderChildrenInfoServiceImpl.java
View file @
6fcd2444
...
...
@@ -72,6 +72,7 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
.
like
(
StringUtils
.
isNotBlank
(
dto
.
getPhone
()),
PlatElderChildrenInfo:
:
getPhone
,
dto
.
getPhone
())
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getElderId
()),
PlatElderChildrenInfo:
:
getElderId
,
dto
.
getElderId
())
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getTenantId
()),
PlatElderChildrenInfo:
:
getTenantId
,
dto
.
getTenantId
())
.
in
(
CollectionUtils
.
isNotEmpty
(
dto
.
getOrgIdList
()),
PlatElderChildrenInfo:
:
getOrgId
,
dto
.
getOrgIdList
())
.
apply
(
StringUtils
.
isNotBlank
(
dto
.
getOrgId
()),
"find_in_set('"
+
dto
.
getOrgId
()
+
"',org_path)"
);
}
...
...
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