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
d7046ca6
authored
Oct 10, 2023
by
杨伟程
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
坐标定位和轨迹更新
parent
30bb5321
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
25 deletions
server-common/src/main/java/com/makeit/module/iot/service/IotProductDeviceService.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderDayReportDayServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderRealTimeServiceImpl.java
server-service/src/main/java/com/makeit/vo/platform/elder/realtime/PlatElderCoordinateVO.java
server-common/src/main/java/com/makeit/module/iot/service/IotProductDeviceService.java
View file @
d7046ca6
...
...
@@ -158,6 +158,24 @@ public class IotProductDeviceService extends IotCommonService {
}
public
DeviceInfoContentFall
getLastDeviceLogFall
(
String
deviceId
,
Integer
ignoreDuration
)
{
//秒
DeviceOperationLogEntity
deviceOperationLogEntity
=
getLastDeviceLogByType
(
deviceId
,
REPORT_PROPERTY
);
if
(
deviceOperationLogEntity
==
null
)
{
return
null
;
}
DeviceInfoContentFall
fall
=
JsonUtil
.
toObj
((
String
)
deviceOperationLogEntity
.
getContent
(),
DeviceInfoContentFall
.
class
);
LocalDateTime
time
=
LongTimestampUtil
.
toLocalDateTime
(
fall
.
getTimestamp
());
if
(
ignoreDuration
!=
null
&&
Duration
.
between
(
time
,
LocalDateTime
.
now
()).
getSeconds
()
>
ignoreDuration
)
{
return
null
;
}
return
fall
;
}
public
List
<
String
>
getLastDayHourRange
(
LocalDateTime
startDateTime
)
{
int
count
=
24
;
List
<
String
>
list
=
Lists
.
newArrayList
();
...
...
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderDayReportDayServiceImpl.java
View file @
d7046ca6
...
...
@@ -354,22 +354,25 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override
public
List
<
PlatElderCoordinateVO
>
coordinateList
(
String
elderId
,
String
deviceId
,
LocalDateTime
start
,
LocalDateTime
end
)
{
List
<
PlatDevice
>
platDeviceList
=
platElderRealTimeService
.
getSpaceDevice
(
elderId
,
deviceId
);
List
<
PlatDevice
>
platDeviceList
Space
=
platElderRealTimeService
.
getSpaceDevice
(
elderId
,
deviceId
);
if
(
CollectionUtils
.
isEmpty
(
platDeviceList
))
{
List
<
PlatDevice
>
platDeviceListFall
=
platElderRealTimeService
.
getFallDevice
(
elderId
,
deviceId
);
if
(
CollectionUtils
.
isEmpty
(
platDeviceListSpace
)
&&
CollectionUtils
.
isEmpty
(
platDeviceListFall
))
{
return
new
ArrayList
<>(
10
);
}
List
<
PlatElderCoordinateVO
>
voList
=
new
ArrayList
<>(
10
);
platDeviceList
.
forEach
(
e
->
{
platDeviceList
Space
.
forEach
(
e
->
{
List
<
DeviceInfoContentSpace
>
spaceList
=
iotProductDeviceService
.
getDeviceLogByTimeRangeSpace
(
e
.
getOriDeviceId
(),
2
*
24
*
3600
,
start
,
end
);
voList
.
addAll
(
StreamUtil
.
map
(
spaceList
,
i
->
{
PlatElderCoordinateVO
vo
=
new
PlatElderCoordinateVO
();
vo
.
setX
(
new
BigDecimal
(
i
.
getProperties
().
getDistance
()).
multiply
(
new
BigDecimal
(
Math
.
cos
(
i
.
getProperties
().
getAngle
())
+
""
)).
setScale
(
2
,
RoundingMode
.
HALF_UP
));
vo
.
setY
(
new
BigDecimal
(
i
.
getProperties
().
getDistance
()).
multiply
(
new
BigDecimal
(
Math
.
sin
(
i
.
getProperties
().
getAngle
())
+
""
)).
setScale
(
2
,
RoundingMode
.
HALF_UP
));
// vo.setX(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
// vo.setY(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo
.
setDistance
(
i
.
getProperties
().
getDistance
());
vo
.
setAngle
(
i
.
getProperties
().
getAngle
());
...
...
@@ -384,6 +387,25 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
});
platDeviceListFall
.
forEach
(
e
->
{
List
<
DeviceInfoContentFall
>
fallList
=
iotProductDeviceService
.
getDeviceLogByTimeRangeFall
(
e
.
getOriDeviceId
(),
2
*
24
*
3600
,
start
,
end
);
voList
.
addAll
(
StreamUtil
.
map
(
fallList
,
i
->
{
PlatElderCoordinateVO
vo
=
new
PlatElderCoordinateVO
();
vo
.
setTrack
(
i
.
getProperties
().
getTrack
());
vo
.
setDeviceId
(
e
.
getId
());
vo
.
setOriDeviceId
(
e
.
getOriDeviceId
());
return
vo
;
})
);
});
return
voList
;
}
...
...
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderRealTimeServiceImpl.java
View file @
d7046ca6
...
...
@@ -9,9 +9,11 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import
com.makeit.entity.saas.analysis.SaasSleepEvaluateReport
;
import
com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum
;
import
com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum
;
import
com.makeit.module.iot.enums.DeviceInfoContentFallEnum
;
import
com.makeit.module.iot.enums.DeviceInfoContentSpaceEnum
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe
;
import
com.makeit.module.iot.vo.fall.DeviceInfoContentFall
;
import
com.makeit.module.iot.vo.space.DeviceInfoContentSpace
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.elder.PlatElderDayReportDayService
;
...
...
@@ -40,6 +42,7 @@ import java.util.List;
import
java.util.Objects
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* <p>
...
...
@@ -143,13 +146,46 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
}
private
List
<
DeviceInfoContentFall
>
getNowDataFall
(
String
elderId
,
String
deviceId
)
{
List
<
PlatDevice
>
deviceList
=
getFallDevice
(
elderId
,
deviceId
);
if
(
CollectionUtils
.
isEmpty
(
deviceList
))
{
return
null
;
}
return
deviceList
.
stream
().
map
(
e
->
iotProductDeviceService
.
getLastDeviceLogFall
(
e
.
getOriDeviceId
(),
10
)).
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
}
private
void
nowStatusOut
(
PlatElderRealTimeNowVO
platElderRealTimeNowVO
,
PlatElderIdDTO
platElderIdDTO
)
{
List
<
DeviceInfoContentSpace
>
deviceInfoContentSpaceList
=
getNowDataSpace
(
platElderIdDTO
.
getElderId
(),
platElderIdDTO
.
getDeviceId
());
if
(
CollectionUtils
.
isEmpty
(
deviceInfoContentSpaceList
))
{
List
<
DeviceInfoContentFall
>
deviceInfoContentFallList
=
getNowDataFall
(
platElderIdDTO
.
getElderId
(),
platElderIdDTO
.
getDeviceId
());
if
(
CollectionUtils
.
isEmpty
(
deviceInfoContentSpaceList
)
&&
CollectionUtils
.
isEmpty
(
deviceInfoContentFallList
))
{
return
;
}
if
(
StreamUtil
.
allMatch
(
deviceInfoContentSpaceList
,
e
->
DeviceInfoContentSpaceEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
e
.
getProperties
().
getPersonState
())))
{
// if (StreamUtil.allMatch(deviceInfoContentSpaceList, e -> DeviceInfoContentSpaceEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()))) {
// platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.OUT.getValue());
// }
Boolean
spaceFlag
=
null
;
Boolean
fallFlag
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
deviceInfoContentSpaceList
))
{
spaceFlag
=
StreamUtil
.
allMatch
(
deviceInfoContentSpaceList
,
e
->
DeviceInfoContentSpaceEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
e
.
getProperties
().
getPersonState
()));
}
if
(
CollectionUtils
.
isNotEmpty
(
deviceInfoContentFallList
))
{
fallFlag
=
StreamUtil
.
allMatch
(
deviceInfoContentFallList
,
e
->
DeviceInfoContentFallEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
e
.
getProperties
().
getPersonState
()));
}
List
<
Boolean
>
flagList
=
Stream
.
of
(
spaceFlag
,
fallFlag
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
flagList
)
&&
StreamUtil
.
allMatch
(
flagList
,
Boolean
.
TRUE
::
equals
))
{
platElderRealTimeNowVO
.
setStatus
(
PlatElderRealtimeReportEnum
.
NowStatus
.
OUT
.
getValue
());
}
...
...
@@ -161,7 +197,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
return
;
}
boolean
flag
=
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
nowDataBreathe
.
getProperties
().
getPersonState
()
+
""
);
boolean
flag
=
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
nowDataBreathe
.
getProperties
().
getPersonState
()
+
""
);
if
(!
flag
)
{
return
;
...
...
@@ -182,7 +218,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
return
;
}
boolean
flag
=
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
nowDataBreathe
.
getProperties
().
getPersonState
()
+
""
);
boolean
flag
=
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
nowDataBreathe
.
getProperties
().
getPersonState
()
+
""
);
if
(!
flag
)
{
return
;
...
...
@@ -203,7 +239,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
return
;
}
boolean
flag
=
!
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
nowDataBreathe
.
getProperties
().
getPersonState
()
+
""
);
boolean
flag
=
!
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
getValue
().
equals
(
nowDataBreathe
.
getProperties
().
getPersonState
()
+
""
);
if
(!
flag
)
{
return
;
}
...
...
@@ -241,7 +277,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
public
PlatElderRealTimeNowVO
nowStatus
(
PlatElderIdDTO
platElderIdDTO
)
{
Object
result
=
RedisUtil
.
get
(
ELDER_STATUS
+
platElderIdDTO
.
getElderId
());
if
(
result
!=
null
)
{
return
JSON
.
parseObject
(
result
.
toString
(),
PlatElderRealTimeNowVO
.
class
);
return
JSON
.
parseObject
(
result
.
toString
(),
PlatElderRealTimeNowVO
.
class
);
}
DeviceInfoContentBreathe
deviceInfoContentBreathe
=
getNowDataBreathe
(
platElderIdDTO
.
getElderId
(),
platElderIdDTO
.
getDeviceId
());
...
...
@@ -274,7 +310,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
platElderRealTimeNowVO
.
setRespiratoryRate
(
deviceInfoContentBreathe
.
getProperties
().
getBr
());
platElderRealTimeNowVO
.
setBodyMove
(
deviceInfoContentBreathe
.
getProperties
().
getBodymove
());
RedisUtil
.
set
(
ELDER_STATUS
+
platElderIdDTO
.
getElderId
(),
JSON
.
toJSONString
(
platElderRealTimeNowVO
),
15
,
TimeUnit
.
SECONDS
);
RedisUtil
.
set
(
ELDER_STATUS
+
platElderIdDTO
.
getElderId
(),
JSON
.
toJSONString
(
platElderRealTimeNowVO
),
15
,
TimeUnit
.
SECONDS
);
return
platElderRealTimeNowVO
;
}
...
...
@@ -313,29 +349,90 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
}
// @Override
// public List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO) {
// List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
//
// List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
//
// if (CollectionUtils.isEmpty(deviceInfoContentSpaceList)) {
// return voList;
// }
//
// voList = StreamUtil.map(deviceInfoContentSpaceList, e -> {
// PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
//
//// vo.setDeviceId();
//// vo.setOriDeviceId();
//
// vo.setX(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
// vo.setY(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
//
// vo.setDistance(e.getProperties().getDistance());
// vo.setAngle(e.getProperties().getAngle());
//
// return vo;
// });
//
// return voList;
// }
@Override
public
List
<
PlatElderCoordinateVO
>
coordinate
(
PlatElderIdDTO
platElderIdDTO
)
{
List
<
DeviceInfoContentSpace
>
deviceInfoContentSpaceList
=
getNowDataSpace
(
platElderIdDTO
.
getElderId
(),
platElderIdDTO
.
getDeviceId
());
List
<
PlatElderCoordinateVO
>
voList
=
new
ArrayList
<>(
10
);
if
(
CollectionUtils
.
isEmpty
(
deviceInfoContentSpaceList
))
{
List
<
PlatDevice
>
deviceListSpace
=
getSpaceDevice
(
platElderIdDTO
.
getElderId
(),
platElderIdDTO
.
getDeviceId
());
List
<
PlatDevice
>
deviceListFall
=
getFallDevice
(
platElderIdDTO
.
getElderId
(),
platElderIdDTO
.
getDeviceId
());
if
(
CollectionUtils
.
isEmpty
(
deviceListSpace
)
&&
CollectionUtils
.
isNotEmpty
(
deviceListFall
))
{
return
voList
;
}
voList
=
StreamUtil
.
map
(
deviceInfoContentSpaceList
,
e
->
{
deviceListSpace
.
forEach
(
e
->
{
DeviceInfoContentSpace
i
=
iotProductDeviceService
.
getLastDeviceLogSpace
(
e
.
getOriDeviceId
(),
10
);
if
(
i
==
null
)
{
return
;
}
PlatElderCoordinateVO
vo
=
new
PlatElderCoordinateVO
();
vo
.
set
X
(
new
BigDecimal
(
e
.
getProperties
().
getDistance
()).
multiply
(
new
BigDecimal
(
Math
.
cos
(
e
.
getProperties
().
getAngle
())
+
""
)).
setScale
(
2
,
RoundingMode
.
HALF_UP
));
vo
.
set
Y
(
new
BigDecimal
(
e
.
getProperties
().
getDistance
()).
multiply
(
new
BigDecimal
(
Math
.
sin
(
e
.
getProperties
().
getAngle
())
+
""
)).
setScale
(
2
,
RoundingMode
.
HALF_UP
));
vo
.
set
DeviceId
(
e
.
getId
(
));
vo
.
set
OriDeviceId
(
e
.
getOriDeviceId
(
));
vo
.
setDistance
(
e
.
getProperties
().
getDistance
());
vo
.
setAngle
(
e
.
getProperties
().
getAngle
());
// vo.setX(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
// vo.setY(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo
.
setDistance
(
i
.
getProperties
().
getDistance
());
vo
.
setAngle
(
i
.
getProperties
().
getAngle
());
voList
.
add
(
vo
);
return
vo
;
});
deviceListFall
.
forEach
(
e
->
{
DeviceInfoContentFall
i
=
iotProductDeviceService
.
getLastDeviceLogFall
(
e
.
getOriDeviceId
(),
10
);
if
(
i
==
null
)
{
return
;
}
PlatElderCoordinateVO
vo
=
new
PlatElderCoordinateVO
();
vo
.
setDeviceId
(
e
.
getId
());
vo
.
setOriDeviceId
(
e
.
getOriDeviceId
());
vo
.
setTrack
(
i
.
getProperties
().
getTrack
());
voList
.
add
(
vo
);
});
return
voList
;
}
}
server-service/src/main/java/com/makeit/vo/platform/elder/realtime/PlatElderCoordinateVO.java
View file @
d7046ca6
...
...
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
@Data
public
class
PlatElderCoordinateVO
{
...
...
@@ -14,11 +15,11 @@ public class PlatElderCoordinateVO {
@ApiModelProperty
(
value
=
"原始设备ID"
)
private
String
oriDeviceId
;
@ApiModelProperty
(
"x"
)
private
BigDecimal
x
;
@ApiModelProperty
(
"y"
)
private
BigDecimal
y
;
//
@ApiModelProperty("x")
//
private BigDecimal x;
//
//
@ApiModelProperty("y")
//
private BigDecimal y;
@ApiModelProperty
(
"人体目标距离雷达位置 范围:0-1000,单位cm"
)
private
Integer
distance
;
...
...
@@ -26,5 +27,8 @@ public class PlatElderCoordinateVO {
@ApiModelProperty
(
"人体目标偏离雷达法线角度范围:±60,单位°"
)
private
Integer
angle
;
@ApiModelProperty
(
"跌倒设备轨迹"
)
private
List
<
Integer
>
track
;
}
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