Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
rx
Commits
b35c3bac
Commit
b35c3bac
authored
Aug 23, 2024
by
wujipeng
Browse files
优化
parent
8e3facb1
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/rx/controller/EquipmentController.java
View file @
b35c3bac
...
...
@@ -36,4 +36,10 @@ public class EquipmentController {
public
Result
getDeviceInfoList
(
@RequestBody
EquipmentDTO
equipmentDTO
)
{
return
Result
.
success
(
equipmentService
.
getDeviceInfoList
(
equipmentDTO
));
}
// @ApiOperation(value = "获取所有设备的最新一条数据")
// @PostMapping("/report/list")
// public Result getDeviceDataList() {
// return Result.success(equipmentService.getDeviceDataList());
// }
}
src/main/java/com/ruzhoukj/rx/dao/DeviceDao.java
View file @
b35c3bac
...
...
@@ -5,6 +5,8 @@ import com.ruzhoukj.rx.pojo.vo.DeviceVO;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* @author 邬吉朋
*/
...
...
@@ -12,4 +14,6 @@ import org.springframework.stereotype.Component;
public
interface
DeviceDao
extends
MongoRepository
<
DeviceEntity
,
String
>
{
DeviceVO
findTopByDeviceIdOrderByTimestampDesc
(
String
deviceId
);
// List<DeviceVO> findtopOrderByTimestampDescgroupByDeviceId();
}
src/main/java/com/ruzhoukj/rx/pojo/entity/DeviceEntity.java
View file @
b35c3bac
...
...
@@ -28,25 +28,46 @@ public class DeviceEntity {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
timestamp
;
@ApiModelProperty
(
value
=
"道路路面积水"
)
private
double
zu
;
@ApiModelProperty
(
value
=
"窨井水位深度/管网液位"
)
private
double
zb
;
@ApiModelProperty
(
value
=
"瞬时流速"
)
private
double
vj
;
@ApiModelProperty
(
value
=
"瞬时流量"
)
private
double
q
;
@ApiModelProperty
(
value
=
"总流量"
)
private
double
qa
;
@ApiModelProperty
(
value
=
"正流量"
)
private
double
pqa
;
@ApiModelProperty
(
value
=
""
)
private
double
ph
;
@ApiModelProperty
(
value
=
""
)
private
double
cod
;
@ApiModelProperty
(
value
=
""
)
private
double
tn
;
@ApiModelProperty
(
value
=
""
)
private
double
cond
;
@ApiModelProperty
(
value
=
""
)
private
double
tp
;
@ApiModelProperty
(
value
=
"负流量"
)
private
double
nqa
;
@ApiModelProperty
(
value
=
"悬浮物(SS)"
)
private
double
tss
;
@ApiModelProperty
(
value
=
"总雨量(mm)"
)
private
double
pt
;
@ApiModelProperty
(
value
=
"5分钟内雨量(mm)"
)
private
double
pn05
;
@ApiModelProperty
(
value
=
"电源电压"
)
private
double
vt
;
@ApiModelProperty
(
value
=
"内置电池电压"
)
private
double
svt
;
@ApiModelProperty
(
value
=
"遥测站状态及报警信息(见设备状态说明)"
)
private
double
zt
;
@ApiModelProperty
(
value
=
"无线信号强度"
)
private
double
sin
;
@ApiModelProperty
(
value
=
"主板温度"
)
private
double
tem
;
@ApiModelProperty
(
value
=
"主板湿度"
)
private
double
hum
;
}
src/main/java/com/ruzhoukj/rx/service/EquipmentService.java
View file @
b35c3bac
...
...
@@ -31,4 +31,10 @@ public interface EquipmentService extends IService<EquipmentEntity> {
* @return List<EquipmentVO>
*/
List
<
EquipmentVO
>
getDeviceInfoList
(
EquipmentDTO
equipmentDTO
);
// /**
// * 获取所有设备的最新一条数据
// * @return List<DeviceVO>
// */
// List<DeviceVO> getDeviceDataList();
}
src/main/java/com/ruzhoukj/rx/service/impl/EquipmentServiceImpl.java
View file @
b35c3bac
...
...
@@ -45,16 +45,33 @@ public class EquipmentServiceImpl
public
List
<
EquipmentVO
>
getDeviceInfoList
(
EquipmentDTO
equipmentDTO
)
{
List
<
EquipmentVO
>
deviceInfoList
=
baseMapper
.
getDeviceInfoList
(
equipmentDTO
);
for
(
EquipmentVO
equipmentVO
:
deviceInfoList
)
{
//判断设备类型,如果是水位传感器,则获取最新一条水位数据,并判断有没有超过阀值
//判断有没有超过阀值
DeviceVO
deviceVO
=
deviceDao
.
findTopByDeviceIdOrderByTimestampDesc
(
equipmentVO
.
getDeviceId
());
if
(
equipmentVO
.
getType
().
equals
(
NumberConstant
.
ONE
))
{
DeviceVO
deviceVO
=
deviceDao
.
findTopByDeviceIdOrderByTimestampDesc
(
equipmentVO
.
getDeviceId
());
if
(
deviceVO
!=
null
&&
deviceVO
.
getZt
()
>=
equipmentVO
.
getThresholdValue
())
{
equipmentVO
.
setLiquidLevelStatus
(
NumberConstant
.
ONE
);
}
else
if
(
deviceVO
!=
null
&&
deviceVO
.
getZt
()
<
equipmentVO
.
getThresholdValue
())
{
equipmentVO
.
setLiquidLevelStatus
(
NumberConstant
.
ZERO
);
}
}
else
if
(
equipmentVO
.
getType
().
equals
(
NumberConstant
.
TWO
))
{
if
(
deviceVO
!=
null
&&
deviceVO
.
getTss
()
>=
equipmentVO
.
getThresholdValue
())
{
equipmentVO
.
setLiquidLevelStatus
(
NumberConstant
.
ONE
);
}
else
if
(
deviceVO
!=
null
&&
deviceVO
.
getTss
()
<
equipmentVO
.
getThresholdValue
())
{
equipmentVO
.
setLiquidLevelStatus
(
NumberConstant
.
ZERO
);
}
}
else
if
(
equipmentVO
.
getType
().
equals
(
NumberConstant
.
THREE
))
{
if
(
deviceVO
!=
null
&&
deviceVO
.
getVj
()
>=
equipmentVO
.
getThresholdValue
())
{
equipmentVO
.
setLiquidLevelStatus
(
NumberConstant
.
ONE
);
}
else
if
(
deviceVO
!=
null
&&
deviceVO
.
getVj
()
<
equipmentVO
.
getThresholdValue
())
{
equipmentVO
.
setLiquidLevelStatus
(
NumberConstant
.
ZERO
);
}
}
}
return
deviceInfoList
;
}
// @Override
// public List<DeviceVO> getDeviceDataList() {
// return deviceDao.findtopOrderByTimestampDescgroupByDeviceId();
// }
}
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