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
ba675772
authored
Dec 15, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:bug修复
parent
ca400239
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
13 deletions
server-common/src/main/java/com/makeit/enums/CodeMessageEnum.java
server-common/src/main/resources/locale/business_messages.properties
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-service/src/main/java/com/makeit/vo/platform/alarm/PlatAlarmRecordVO.java
server-common/src/main/java/com/makeit/enums/CodeMessageEnum.java
View file @
ba675772
...
@@ -106,6 +106,7 @@ public enum CodeMessageEnum {
...
@@ -106,6 +106,7 @@ public enum CodeMessageEnum {
PLATFORM_ERROR_SPACE_NAME_DUPLICATE
(
500
,
"PLATFORM.ERROR.SPACE.NAME.DUPLICATE"
),
PLATFORM_ERROR_SPACE_NAME_DUPLICATE
(
500
,
"PLATFORM.ERROR.SPACE.NAME.DUPLICATE"
),
PLATFORM_ERROR_SPACE_NOT_DEL
(
500
,
"PLATFORM.ERROR.SPACE.NOT.DEL"
),
PLATFORM_ERROR_SPACE_NOT_DEL
(
500
,
"PLATFORM.ERROR.SPACE.NOT.DEL"
),
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT
(
500
,
"PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT"
),
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT
(
500
,
"PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT"
),
PLATFORM_ERROR_SPACE_OVER_LEVEL
(
500
,
"PLATFORM.ERROR.SPACE.OVER.LEVEL"
),
PLATFORM_ERROR_SPACE_USER_NOT_ADD
(
500
,
"PLATFORM.ERROR.SPACE.USER.NOT.ADD"
),
PLATFORM_ERROR_SPACE_USER_NOT_ADD
(
500
,
"PLATFORM.ERROR.SPACE.USER.NOT.ADD"
),
PLATFORM_ERROR_SPACE_ROOM_NOT_ADD
(
500
,
"PLATFORM.ERROR.SPACE.ROOM.NOT.ADD"
),
PLATFORM_ERROR_SPACE_ROOM_NOT_ADD
(
500
,
"PLATFORM.ERROR.SPACE.ROOM.NOT.ADD"
),
PLATFORM_ERROR_ROOM_EXIT_BAD
(
500
,
"PLATFORM.ERROR.ROOM.EXIT.BED"
),
PLATFORM_ERROR_ROOM_EXIT_BAD
(
500
,
"PLATFORM.ERROR.ROOM.EXIT.BED"
),
...
...
server-common/src/main/resources/locale/business_messages.properties
View file @
ba675772
This diff is collapsed.
Click to expand it.
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
View file @
ba675772
package
com
.
makeit
.
module
.
controller
.
wechat
.
alarm
;
package
com
.
makeit
.
module
.
controller
.
wechat
.
alarm
;
import
cn.hutool.core.collection.CollUtil
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageReqDTO
;
...
@@ -8,7 +9,6 @@ import com.makeit.common.page.PageVO;
...
@@ -8,7 +9,6 @@ import com.makeit.common.page.PageVO;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
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.report.PlatformTypeEnum
;
import
com.makeit.enums.report.PlatformTypeEnum
;
import
com.makeit.global.annotation.AuthIgnore
;
import
com.makeit.global.annotation.AuthIgnore
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
...
@@ -16,7 +16,6 @@ import com.makeit.utils.user.common.CommonUserUtil;
...
@@ -16,7 +16,6 @@ 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
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -44,7 +43,8 @@ public class PlatAlarmRecordWechatController {
...
@@ -44,7 +43,8 @@ public class PlatAlarmRecordWechatController {
Map
<
String
,
Object
>
resMap
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
resMap
=
Maps
.
newHashMap
();
PageVO
<
PlatAlarmRecordVO
>
page
=
platAlarmRecordService
.
page
(
dto
);
PageVO
<
PlatAlarmRecordVO
>
page
=
platAlarmRecordService
.
page
(
dto
);
boolean
b
=
page
.
getList
().
stream
().
anyMatch
(
platAlarmRecord
->
StringUtils
.
equals
(
CommonEnum
.
NO
.
getValue
(),
platAlarmRecord
.
getStatus
()));
// boolean b = page.getList().stream().anyMatch(platAlarmRecord -> StringUtils.equals(CommonEnum.NO.getValue(), platAlarmRecord.getStatus()));
boolean
b
=
CollUtil
.
isNotEmpty
(
page
.
getList
())
&&
page
.
getList
().
get
(
0
).
getStatusFlag
();
resMap
.
put
(
"todoFlag"
,
b
);
resMap
.
put
(
"todoFlag"
,
b
);
resMap
.
put
(
"page"
,
page
);
resMap
.
put
(
"page"
,
page
);
return
ApiResponseUtils
.
success
(
resMap
);
return
ApiResponseUtils
.
success
(
resMap
);
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
View file @
ba675772
...
@@ -150,7 +150,12 @@ public class OffBedAlarm implements IAlarm {
...
@@ -150,7 +150,12 @@ public class OffBedAlarm implements IAlarm {
LocalTime
endTime
=
ruleConfig
.
getOffBedEnd
();
LocalTime
endTime
=
ruleConfig
.
getOffBedEnd
();
Long
firstOffBedLong
=
alarmRedisDTO
.
getStartLong
();
Long
firstOffBedLong
=
alarmRedisDTO
.
getStartLong
();
boolean
isOverTime
=
(
System
.
currentTimeMillis
()
-
firstOffBedLong
)
/
1000
>=
duration
*
60
;
long
currentTimeMillis
=
System
.
currentTimeMillis
();
LocalDateTime
nowTest
=
LocalDateTime
.
now
().
plusHours
(
8
)
.
isAfter
(
LocalDateTime
.
of
(
2023
,
12
,
16
,
0
,
0
,
0
))
?
LocalDateTime
.
now
().
plusHours
(
7
)
:
LocalDateTime
.
now
().
plusHours
(
8
);
currentTimeMillis
=
nowTest
.
toInstant
(
ZoneOffset
.
of
(
"+8"
)).
toEpochMilli
();
log
.
info
(
"handleCrossDay,测试当前的时间:{},时间戳:{}"
,
nowTest
,
currentTimeMillis
);
boolean
isOverTime
=
(
currentTimeMillis
-
firstOffBedLong
)
/
1000
>=
duration
*
60
;
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
firstOffBedLong
),
ZoneOffset
.
of
(
"+8"
));
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
firstOffBedLong
),
ZoneOffset
.
of
(
"+8"
));
LocalTime
firstTime
=
firstOffBedTime
.
toLocalTime
();
LocalTime
firstTime
=
firstOffBedTime
.
toLocalTime
();
...
@@ -163,19 +168,21 @@ public class OffBedAlarm implements IAlarm {
...
@@ -163,19 +168,21 @@ public class OffBedAlarm implements IAlarm {
log
.
info
(
"handleCrossDay 第一次离床时间,{}+持续时间:{}将超过范围,{}"
,
firstTime
,
duration
,
endTime
);
log
.
info
(
"handleCrossDay 第一次离床时间,{}+持续时间:{}将超过范围,{}"
,
firstTime
,
duration
,
endTime
);
return
;
return
;
}
}
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
System
.
currentTimeMillis
()
-
firstOffBedLong
));
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
log
.
info
(
"cross离床告警离床时间在范围时间内,配置:{}"
,
config
.
getRuleConfig
());
log
.
info
(
"cross离床告警离床时间在范围时间内,配置:{}"
,
config
.
getRuleConfig
());
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
return
;
return
;
}
}
LocalDateTime
now
=
LocalDateTime
.
now
();
// LocalDateTime now = LocalDateTime.now();
LocalDateTime
now
=
LocalDateTime
.
now
().
plusHours
(
8
)
.
isAfter
(
LocalDateTime
.
of
(
2023
,
12
,
16
,
0
,
0
,
0
))
?
LocalDateTime
.
now
().
plusHours
(
7
)
:
LocalDateTime
.
now
().
plusHours
(
8
);
LocalDateTime
startLocalDteTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
LocalDateTime
startLocalDteTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
if
(!
isInTime
)
{
if
(!
isInTime
)
{
long
mills
=
Duration
.
between
(
startLocalDteTime
,
now
).
toMillis
()
/
1000
;
long
mills
=
Duration
.
between
(
startLocalDteTime
,
now
).
toMillis
()
/
1000
;
boolean
noInOverTime
=
mills
>=
duration
*
60
;
boolean
noInOverTime
=
mills
>=
duration
*
60
;
if
(
noInOverTime
)
{
if
(
noInOverTime
)
{
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
System
.
currentTimeMillis
()
-
firstOffBedLong
));
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
log
.
info
(
"cross离床告警第一次离床时间在范围前,配置:{}"
,
config
.
getRuleConfig
());
log
.
info
(
"cross离床告警第一次离床时间在范围前,配置:{}"
,
config
.
getRuleConfig
());
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
View file @
ba675772
...
@@ -121,7 +121,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
...
@@ -121,7 +121,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
LambdaQueryWrapper
<
PlatAlarmRecord
>
lambdaQueryWrapper
=
getLambdaQueryWrapper
(
param
);
LambdaQueryWrapper
<
PlatAlarmRecord
>
lambdaQueryWrapper
=
getLambdaQueryWrapper
(
param
);
List
<
PlatAlarmRecord
>
list
=
list
(
lambdaQueryWrapper
);
List
<
PlatAlarmRecord
>
list
=
list
(
lambdaQueryWrapper
);
Boolean
isUnWechatRead
=
CollUtil
.
isNotEmpty
(
list
)
&&
list
.
stream
()
Boolean
isUnWechatRead
=
CollUtil
.
isNotEmpty
(
list
)
&&
list
.
stream
()
.
anyMatch
(
a
->
CommonEnum
.
YES
.
getValue
().
equals
(
a
.
getWechatReadFlag
()));
.
anyMatch
(
a
->
CommonEnum
.
NO
.
getValue
().
equals
(
a
.
getWechatReadFlag
()));
Boolean
statusFlag
=
CollUtil
.
isNotEmpty
(
list
)
&&
list
.
stream
()
.
anyMatch
(
a
->
CommonEnum
.
NO
.
getValue
().
equals
(
a
.
getStatus
()));
Page
<
PlatAlarmRecord
>
page
=
page
(
mpPage
,
lambdaQueryWrapper
);
Page
<
PlatAlarmRecord
>
page
=
page
(
mpPage
,
lambdaQueryWrapper
);
List
<
PlatAlarmRecord
>
records
=
page
.
getRecords
();
List
<
PlatAlarmRecord
>
records
=
page
.
getRecords
();
List
<
PlatAlarmRecordVO
>
dtos
=
BeanDtoVoUtils
.
listVo
(
records
,
PlatAlarmRecordVO
.
class
);
List
<
PlatAlarmRecordVO
>
dtos
=
BeanDtoVoUtils
.
listVo
(
records
,
PlatAlarmRecordVO
.
class
);
...
@@ -136,6 +138,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
...
@@ -136,6 +138,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
platAlarmRecordVO
.
setDevice
(
platDevice
);
platAlarmRecordVO
.
setDevice
(
platDevice
);
}
}
platAlarmRecordVO
.
setIsUnWechatRead
(
isUnWechatRead
);
platAlarmRecordVO
.
setIsUnWechatRead
(
isUnWechatRead
);
platAlarmRecordVO
.
setStatusFlag
(
statusFlag
);
}
}
return
PageUtil
.
toPageVO
(
dtos
,
page
);
return
PageUtil
.
toPageVO
(
dtos
,
page
);
}
}
...
...
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
ba675772
...
@@ -35,6 +35,7 @@ import com.makeit.utils.user.plat.PlatUserVO;
...
@@ -35,6 +35,7 @@ import com.makeit.utils.user.plat.PlatUserVO;
import
com.makeit.vo.platform.space.PlatSpaceAndRoomVO
;
import
com.makeit.vo.platform.space.PlatSpaceAndRoomVO
;
import
jodd.util.StringUtil
;
import
jodd.util.StringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -147,6 +148,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -147,6 +148,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if
(
parentSpace
!=
null
&&
parentSpace
.
getParentPath
()!=
null
&&
parentSpace
.
getParentPath
().
contains
(
dto
.
getId
()))
{
if
(
parentSpace
!=
null
&&
parentSpace
.
getParentPath
()!=
null
&&
parentSpace
.
getParentPath
().
contains
(
dto
.
getId
()))
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT
);
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT
);
}
}
// 编辑后层级大于4,不允许编辑
checkMaxLevel
(
space
);
this
.
updateById
(
space
);
this
.
updateById
(
space
);
List
<
String
>
lastSpaceIds
=
recursionLastSpaceIds
(
space
.
getId
(),
new
ArrayList
<>());
List
<
String
>
lastSpaceIds
=
recursionLastSpaceIds
(
space
.
getId
(),
new
ArrayList
<>());
...
@@ -169,11 +172,6 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -169,11 +172,6 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
log
.
info
(
"房间id:{},对应的空间id:{},parentId:{}"
,
platRoom
.
getId
(),
join
,
dto
.
getParentPath
());
log
.
info
(
"房间id:{},对应的空间id:{},parentId:{}"
,
platRoom
.
getId
(),
join
,
dto
.
getParentPath
());
String
roomSpacePath
=
dto
.
getParentPath
()
+
","
+
join
;
String
roomSpacePath
=
dto
.
getParentPath
()
+
","
+
join
;
log
.
info
(
"roomSpacePath"
+
roomSpacePath
);
log
.
info
(
"roomSpacePath"
+
roomSpacePath
);
// if (lastSpaceIds.get(0).equals(space.getId())) {
// roomSpacePath = dto.getParentPath() + "," + String.join(",", lastSpaceIds);
// } else {
// roomSpacePath = dto.getParentPath() + "," + space.getId() + "," + String.join(",", lastSpaceIds);
// }
platRoom
.
setSpacePath
(
roomSpacePath
);
platRoom
.
setSpacePath
(
roomSpacePath
);
platRoomService
.
updateById
(
platRoom
);
platRoomService
.
updateById
(
platRoom
);
}
}
...
@@ -220,6 +218,44 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -220,6 +218,44 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return
result
;
return
result
;
}
}
private
void
checkMaxLevel
(
PlatSpace
space
)
{
int
level
=
StrUtil
.
isBlank
(
space
.
getParentPath
())
?
0
:
space
.
getParentPath
().
split
(
","
).
length
;
if
(
level
>
3
)
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
}
String
spaceId
=
space
.
getId
();
List
<
PlatSpace
>
platSpaceList
=
list
(
Wrappers
.<
PlatSpace
>
lambdaQuery
()
.
apply
(
StringUtils
.
isNotBlank
(
spaceId
),
"find_in_set('"
+
spaceId
+
"',parent_path)"
));
int
sonLevel
=
0
;
if
(
CollUtil
.
isNotEmpty
(
platSpaceList
))
{
final
int
[]
maxLength
=
{
1
};
platSpaceList
.
forEach
(
s
->
{
if
(
StrUtil
.
isBlank
(
s
.
getParentPath
()))
{
return
;
}
String
[]
parentSpaceIds
=
s
.
getParentPath
().
split
(
","
);
if
(
parentSpaceIds
.
length
>
maxLength
[
0
])
{
maxLength
[
0
]
=
parentSpaceIds
.
length
;
}
});
sonLevel
=
maxLength
[
0
];
}
if
(
level
+
sonLevel
>
3
)
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
}
}
private
List
<
String
>
recursionSpaceId
(
List
<
String
>
result
,
String
spaceId
)
{
List
<
PlatSpace
>
platSpaces
=
this
.
list
(
Wrappers
.<
PlatSpace
>
lambdaQuery
().
eq
(
PlatSpace:
:
getParentId
,
spaceId
));
if
(
CollUtil
.
isNotEmpty
(
platSpaces
))
{
platSpaces
.
forEach
(
p
->
recursionLastSpaceIds
(
p
.
getId
(),
result
));
}
else
{
result
.
add
(
spaceId
);
return
result
;
}
return
result
;
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
del
(
String
id
)
{
public
void
del
(
String
id
)
{
...
...
server-service/src/main/java/com/makeit/vo/platform/alarm/PlatAlarmRecordVO.java
View file @
ba675772
...
@@ -74,4 +74,6 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
...
@@ -74,4 +74,6 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"是否存在未读"
)
@ApiModelProperty
(
value
=
"是否存在未读"
)
private
Boolean
isUnWechatRead
;
private
Boolean
isUnWechatRead
;
@ApiModelProperty
(
value
=
"是否存在未处理"
)
private
Boolean
statusFlag
;
}
}
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