Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart-office-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart-office-platform
Commits
cc5de5f6
Commit
cc5de5f6
authored
Dec 28, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改通知去重复
parent
13ae8fc7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
18 deletions
+44
-18
smart-office-manager/src/main/java/com/mortals/xhx/common/key/RedisKey.java
...er/src/main/java/com/mortals/xhx/common/key/RedisKey.java
+4
-0
smart-office-manager/src/main/java/com/mortals/xhx/daemon/task/MeetSwitchTaskImpl.java
.../java/com/mortals/xhx/daemon/task/MeetSwitchTaskImpl.java
+26
-14
smart-office-manager/src/main/java/com/mortals/xhx/daemon/task/SyncMeetStatusTaskImpl.java
...a/com/mortals/xhx/daemon/task/SyncMeetStatusTaskImpl.java
+14
-4
No files found.
smart-office-manager/src/main/java/com/mortals/xhx/common/key/RedisKey.java
View file @
cc5de5f6
...
...
@@ -25,4 +25,8 @@ public class RedisKey {
public
static
final
String
KEY_TOKEN_API_CACHE
=
"token:api:"
;
public
static
final
String
KEY_USER_MENU_CACHE
=
"user:menu"
;
public
static
final
String
KEY_METTING_START_CACHE
=
"metting:start"
;
public
static
final
String
KEY_METTING_END_CACHE
=
"metting:end"
;
}
smart-office-manager/src/main/java/com/mortals/xhx/daemon/task/MeetSwitchTaskImpl.java
View file @
cc5de5f6
...
...
@@ -4,10 +4,13 @@ import cn.hutool.core.date.DateUnit;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.xhx.common.code.FinishMethodEnum
;
import
com.mortals.xhx.common.code.MeetStatusEnum
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.keys.RedisCacheKeys
;
import
com.mortals.xhx.common.pdu.UploadDeviceReq
;
import
com.mortals.xhx.feign.device.IDeviceMessageFeign
;
import
com.mortals.xhx.module.basic.model.BasicSetEntity
;
...
...
@@ -19,6 +22,7 @@ import com.mortals.xhx.module.room.model.RoomDeviceQuery;
import
com.mortals.xhx.module.room.model.RoomEntity
;
import
com.sun.org.apache.xerces.internal.dom.PSVIAttrNSImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -41,10 +45,10 @@ public class MeetSwitchTaskImpl implements ITaskExcuteService {
@Autowired
private
BasicSetService
basicSetService
;
@Autowired
private
IDeviceMessageFeign
messageFeign
;
@Autowired
private
ICacheService
cacheService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
...
...
@@ -72,12 +76,15 @@ public class MeetSwitchTaskImpl implements ITaskExcuteService {
for
(
MettingRecordEntity
recordEntity
:
recordEntities
)
{
long
between
=
DateUtil
.
between
(
new
Date
(),
recordEntity
.
getMeetTimeStart
(),
DateUnit
.
MINUTE
);
if
(
between
<=
basicSetEntity
.
getPreMeetStart
())
{
//通知设备进行数据更新 todo
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
uploadDeviceReq
.
setDeviceCodeList
(
Arrays
.
asList
(
recordEntity
.
getDeviceCode
()));
uploadDeviceReq
.
setAction
(
"preMeetStart"
);
uploadDeviceReq
.
setContent
(
JSON
.
toJSONString
(
recordEntity
));
messageFeign
.
downMsg
(
uploadDeviceReq
);
//通知设备进行数据更新
boolean
setnx
=
cacheService
.
setnx
(
RedisKey
.
KEY_METTING_START_CACHE
,
recordEntity
.
getId
(),
between
*
60
);
if
(
setnx
)
{
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
uploadDeviceReq
.
setDeviceCodeList
(
Arrays
.
asList
(
recordEntity
.
getDeviceCode
()));
uploadDeviceReq
.
setAction
(
"preMeetStart"
);
uploadDeviceReq
.
setContent
(
JSON
.
toJSONString
(
recordEntity
));
messageFeign
.
downMsg
(
uploadDeviceReq
);
}
}
}
...
...
@@ -87,12 +94,17 @@ public class MeetSwitchTaskImpl implements ITaskExcuteService {
mettingRecordQuery
.
setMeetStatus
(
MeetStatusEnum
.
进行中
.
getValue
());
List
<
MettingRecordEntity
>
pendRecordEntities
=
mettingRecordService
.
find
(
mettingRecordQuery
);
for
(
MettingRecordEntity
pendRecordEntity
:
pendRecordEntities
)
{
long
between
=
DateUtil
.
between
(
pendRecordEntity
.
getMeetTimeStart
(),
new
Date
(),
DateUnit
.
MINUTE
);
if
(
between
<=
basicSetEntity
.
getPostMeetStart
())
{
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
uploadDeviceReq
.
setDeviceCodeList
(
Arrays
.
asList
(
pendRecordEntity
.
getDeviceCode
()));
uploadDeviceReq
.
setAction
(
"postMeet"
);
messageFeign
.
downMsg
(
uploadDeviceReq
);
long
between
=
DateUtil
.
between
(
pendRecordEntity
.
getMeetTimeStart
(),
new
Date
(),
DateUnit
.
MINUTE
);
if
(
between
>=
basicSetEntity
.
getPostMeetStart
())
{
//结束通知 通过redis 去重复
long
sub
=
DateUtil
.
between
(
pendRecordEntity
.
getMeetTimeStart
(),
pendRecordEntity
.
getMeetTimeEnd
(),
DateUnit
.
SECOND
,
true
);
boolean
setnx
=
cacheService
.
setnx
(
RedisKey
.
KEY_METTING_END_CACHE
,
pendRecordEntity
.
getId
(),
sub
);
if
(
setnx
)
{
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
uploadDeviceReq
.
setDeviceCodeList
(
Arrays
.
asList
(
pendRecordEntity
.
getDeviceCode
()));
uploadDeviceReq
.
setAction
(
"postMeet"
);
messageFeign
.
downMsg
(
uploadDeviceReq
);
}
}
}
...
...
smart-office-manager/src/main/java/com/mortals/xhx/daemon/task/SyncMeetStatusTaskImpl.java
View file @
cc5de5f6
package
com.mortals.xhx.daemon.task
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.xhx.common.code.FinishMethodEnum
;
import
com.mortals.xhx.common.code.MeetStatusEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.pdu.UploadDeviceReq
;
import
com.mortals.xhx.feign.device.IDeviceMessageFeign
;
import
com.mortals.xhx.module.basic.model.BasicSetEntity
;
...
...
@@ -38,6 +41,8 @@ public class SyncMeetStatusTaskImpl implements ITaskExcuteService {
@Autowired
private
BasicSetService
basicSetService
;
@Autowired
private
ICacheService
cacheService
;
@Override
...
...
@@ -82,10 +87,15 @@ public class SyncMeetStatusTaskImpl implements ITaskExcuteService {
mettingRecordService
.
update
(
pendRecordEntity
);
//判断基础是否设置关闭切换通知,有则推送
if
(!
ObjectUtils
.
isEmpty
(
basicSetEntity
.
getMeetEnd
())
&&
basicSetEntity
.
getMeetEnd
()
==
YesNoEnum
.
YES
.
getValue
())
{
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
uploadDeviceReq
.
setDeviceCodeList
(
Arrays
.
asList
(
pendRecordEntity
.
getDeviceCode
()));
uploadDeviceReq
.
setAction
(
"postMeet"
);
messageFeign
.
downMsg
(
uploadDeviceReq
);
//结束通知 通过redis 去重复
long
sub
=
DateUtil
.
between
(
pendRecordEntity
.
getMeetTimeStart
(),
pendRecordEntity
.
getMeetTimeEnd
(),
DateUnit
.
SECOND
,
true
);
boolean
setnx
=
cacheService
.
setnx
(
RedisKey
.
KEY_METTING_END_CACHE
,
pendRecordEntity
.
getId
(),
sub
);
if
(
setnx
)
{
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
uploadDeviceReq
.
setDeviceCodeList
(
Arrays
.
asList
(
pendRecordEntity
.
getDeviceCode
()));
uploadDeviceReq
.
setAction
(
"postMeet"
);
messageFeign
.
downMsg
(
uploadDeviceReq
);
}
}
}
...
...
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