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
4f9135f8
authored
Dec 14, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:离床预警时间修改
parent
ed634944
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
60 deletions
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmConfigOffBedDTOVO.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
View file @
4f9135f8
...
@@ -10,8 +10,8 @@ import com.makeit.common.response.ApiResponseUtils;
...
@@ -10,8 +10,8 @@ import com.makeit.common.response.ApiResponseUtils;
import
com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO
;
import
com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.report.PlatformTypeEnum
;
import
com.makeit.enums.report.PlatformTypeEnum
;
import
com.makeit.global.annotation.AuthIgnore
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.utils.user.common.CommonUserUtil
;
import
com.makeit.vo.platform.alarm.PlatAlarmRecordVO
;
import
com.makeit.vo.platform.alarm.PlatAlarmRecordVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -34,9 +34,10 @@ public class PlatAlarmRecordWechatController {
...
@@ -34,9 +34,10 @@ public class PlatAlarmRecordWechatController {
@ApiOperation
(
"列表"
)
@ApiOperation
(
"列表"
)
@PostMapping
(
"page"
)
@PostMapping
(
"page"
)
@AuthIgnore
public
ApiResponseEntity
<
Map
<
String
,
Object
>>
page
(
@RequestBody
PageReqDTO
<
PlatAlarmRecordQueryDTO
>
dto
)
{
public
ApiResponseEntity
<
Map
<
String
,
Object
>>
page
(
@RequestBody
PageReqDTO
<
PlatAlarmRecordQueryDTO
>
dto
)
{
//小程序告警记录只看到发给自己的告警
//小程序告警记录只看到发给自己的告警
String
userId
=
CommonUserUtil
.
getUserId
()
;
String
userId
=
"1700085146788667394"
;
PlatAlarmRecordQueryDTO
data
=
dto
.
getData
();
PlatAlarmRecordQueryDTO
data
=
dto
.
getData
();
data
.
setNotifyUser
(
userId
);
data
.
setNotifyUser
(
userId
);
...
...
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmConfigOffBedDTOVO.java
View file @
4f9135f8
...
@@ -27,16 +27,16 @@ public class PlatAlarmConfigOffBedDTOVO {
...
@@ -27,16 +27,16 @@ public class PlatAlarmConfigOffBedDTOVO {
@JsonFormat
(
pattern
=
"HH:mm:ss"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalTime
offBedStart
;
private
LocalTime
offBedStart
;
@ApiModelProperty
(
"离床时间类型 :1-当日,2-次日"
)
//
@ApiModelProperty("离床时间类型 :1-当日,2-次日")
private
String
startTimeType
;
//
private String startTimeType;
@ApiModelProperty
(
"离床结束时间"
)
@ApiModelProperty
(
"离床结束时间"
)
@DateTimeFormat
(
pattern
=
"HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"HH:mm:ss"
)
@JsonFormat
(
pattern
=
"HH:mm:ss"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalTime
offBedEnd
;
private
LocalTime
offBedEnd
;
@ApiModelProperty
(
"离床时间类型 :1-当日,2-次日"
)
//
@ApiModelProperty("离床时间类型 :1-当日,2-次日")
private
String
endTimeType
;
//
private String endTimeType;
@ApiModelProperty
(
"离床持续时间"
)
@ApiModelProperty
(
"离床持续时间"
)
private
Integer
duration
;
private
Integer
duration
;
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
View file @
4f9135f8
...
@@ -79,7 +79,8 @@ public class OffBedAlarm implements IAlarm {
...
@@ -79,7 +79,8 @@ public class OffBedAlarm implements IAlarm {
log
.
error
(
"离床告警配置解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
log
.
error
(
"离床告警配置解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
return
;
return
;
}
}
if
(!
CURRENT_DAY
.
equals
(
ruleConfig
.
getStartTimeType
()))
{
if
(
ruleConfig
.
getOffBedStart
()
==
null
||
ruleConfig
.
getOffBedEnd
()
==
null
)
{
log
.
error
(
"离床告警配置时间不能为空,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
return
;
return
;
}
}
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
...
@@ -94,11 +95,8 @@ public class OffBedAlarm implements IAlarm {
...
@@ -94,11 +95,8 @@ public class OffBedAlarm implements IAlarm {
return
;
return
;
}
}
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
LocalDateTime
endTime
=
CURRENT_DAY
.
equals
(
ruleConfig
.
getEndTimeType
())
?
timeRange
.
get
(
1
)
:
timeRange
.
get
(
1
).
plusDays
(
1
);
LocalDateTime
endTime
=
timeRange
.
get
(
1
);
if
(
startTime
.
isAfter
(
endTime
))
{
log
.
info
(
"离床预警时间范围,begin:{},end:{}"
,
startTime
,
endTime
);
log
.
error
(
"离床告警配置开始时间大于结束时间,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
return
;
}
Integer
duration
=
ruleConfig
.
getDuration
();
Integer
duration
=
ruleConfig
.
getDuration
();
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
boolean
isOffBed
=
"0"
.
equals
(
personState
);
boolean
isOffBed
=
"0"
.
equals
(
personState
);
...
@@ -157,46 +155,6 @@ public class OffBedAlarm implements IAlarm {
...
@@ -157,46 +155,6 @@ public class OffBedAlarm implements IAlarm {
}
}
// if (isOffBed && isInRange) {
//
// // AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
// if (alarmRedisDTO == null) {
// Date now = new Date();
// long endLong = now.getTime();
// alarmRedisDTO = new AlarmRedisDTO();
// alarmRedisDTO.setAlarm(CommonEnum.NO.getValue());
// alarmRedisDTO.setStart(now);
// alarmRedisDTO.setStartLong(endLong);
// RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
// log.warn("离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}",
// getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
// return;
// }
// Date now = new Date();
// long endLong = now.getTime();
// Long startLong = alarmRedisDTO.getStartLong();
// long count = endLong - startLong;
// // 持续时间满足、且未预警过
// if (count / 1000 >= duration * 60 && StringUtils.equals(alarmRedisDTO.getAlarm(), CommonEnum.NO.getValue())) {
// log.warn("离床持续时间:{} 秒,当前时间:{},duration:{}", count / 1000, now, duration);
// // alarmRedisDTO.setStartLong(endLong);
// alarmRedisDTO.setStart(now);
// alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
// platAlarmCheckDTO.setAbnormalValue(String.valueOf(count));
// RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
// log.warn("推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{}",
// getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
// notice(platAlarmCheckDTO);
// }
// }
}
public
static
void
main
(
String
[]
args
)
{
LocalDateTime
startTime
=
LocalDateTime
.
of
(
2023
,
12
,
12
,
23
,
59
);
long
second
=
startTime
.
toInstant
(
ZoneOffset
.
of
(
"+8"
)).
toEpochMilli
();
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
second
),
ZoneOffset
.
of
(
"+8"
));
System
.
out
.
println
(
second
);
System
.
out
.
println
(
firstOffBedTime
);
}
}
private
void
sendToRedis
(
AlarmRedisDTO
alarmRedisDTO
,
String
deviceId
)
{
private
void
sendToRedis
(
AlarmRedisDTO
alarmRedisDTO
,
String
deviceId
)
{
...
@@ -232,17 +190,13 @@ public class OffBedAlarm implements IAlarm {
...
@@ -232,17 +190,13 @@ public class OffBedAlarm implements IAlarm {
private
List
<
LocalDateTime
>
getOffTimeRange
(
PlatAlarmConfigOffBedDTOVO
ruleConfig
)
{
private
List
<
LocalDateTime
>
getOffTimeRange
(
PlatAlarmConfigOffBedDTOVO
ruleConfig
)
{
List
<
LocalDateTime
>
result
=
new
ArrayList
<>();
List
<
LocalDateTime
>
result
=
new
ArrayList
<>();
LocalDate
localDate
=
LocalDate
.
now
();
LocalDate
localDate
=
LocalDate
.
now
();
LocalDateTime
startTime
;
LocalDateTime
startTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedStart
())
;
LocalDateTime
endTime
;
LocalDateTime
endTime
;
if
(
CURRENT_DAY
.
equals
(
ruleConfig
.
getStartTimeType
()))
{
boolean
isNextDay
=
ruleConfig
.
getOffBedStart
().
isAfter
(
ruleConfig
.
getOffBedEnd
());
startTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedStart
());
if
(
isNextDay
)
{
endTime
=
LocalDateTime
.
of
(
localDate
.
plusDays
(
1
),
ruleConfig
.
getOffBedEnd
());
}
else
{
}
else
{
startTime
=
LocalDateTime
.
of
(
localDate
.
plusDays
(
1
),
ruleConfig
.
getOffBedStart
());
}
if
(
CURRENT_DAY
.
equals
(
ruleConfig
.
getEndTimeType
()))
{
endTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedEnd
());
endTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedEnd
());
}
else
{
endTime
=
LocalDateTime
.
of
(
localDate
.
plusDays
(
1
),
ruleConfig
.
getOffBedEnd
());
}
}
result
.
add
(
startTime
);
result
.
add
(
startTime
);
result
.
add
(
endTime
);
result
.
add
(
endTime
);
...
...
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