Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
6be5cfcf
Commit
6be5cfcf
authored
May 12, 2023
by
lisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加单位换算逻辑
parent
2f30e585
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
MqttReceiveServiceImpl.java
...join/equipmanage/service/impl/MqttReceiveServiceImpl.java
+23
-1
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java
View file @
6be5cfcf
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.feign.systemctl.model.MessageModel
;
import
com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentDefectAlarm
;
...
...
@@ -608,6 +609,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
BigDecimal
minValue
=
getBigDecimal
(
map
.
get
(
"minValues"
));
BigDecimal
maxValue
=
getBigDecimal
(
map
.
get
(
"maxValues"
));
BigDecimal
nowValue
=
getBigDecimal
(
iotDataVO
.
getValue
());
BigDecimal
checkValue
=
checkUnit
(
iotDataVO
.
getKey
().
toLowerCase
(),
nowValue
);
if
(!
ObjectUtils
.
isEmpty
(
checkValue
)){
nowValue
=
checkValue
;
}
if
(
nowValue
.
compareTo
(
minValue
)
<
0
||
nowValue
.
compareTo
(
maxValue
)
>
0
)
{
String
body
=
""
;
if
(
nowValue
.
compareTo
(
minValue
)
<
0
)
{
...
...
@@ -660,7 +665,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
MessageModel
model
=
new
MessageModel
();
Map
<
String
,
Object
>
map
=
fireFightingSystemMapper
.
getWaterPoolLevel
(
equipmentSpecificIndex
.
getEquipmentSpecificId
());
if
(!
ObjectUtils
.
isEmpty
(
map
))
{
BigDecimal
minValues
=
new
BigDecimal
(
map
.
get
(
"minValues"
).
toString
());
BigDecimal
minValue
=
getBigDecimal
(
map
.
get
(
"minValues"
));
BigDecimal
maxValue
=
getBigDecimal
(
map
.
get
(
"maxValues"
));
BigDecimal
nowValue
=
getBigDecimal
(
iotDataVO
.
getValue
());
...
...
@@ -678,6 +682,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
}
nowValue
=
add
.
divide
(
new
BigDecimal
(
i
),
2
,
RoundingMode
.
HALF_UP
);
}
BigDecimal
checkValue
=
checkUnit
(
iotDataVO
.
getKey
().
toLowerCase
(),
nowValue
);
if
(!
ObjectUtils
.
isEmpty
(
checkValue
)){
nowValue
=
checkValue
;
}
if
(
nowValue
.
compareTo
(
minValue
)
<
0
||
nowValue
.
compareTo
(
maxValue
)
>
0
)
{
String
body
=
""
;
if
(
nowValue
.
compareTo
(
minValue
)
<
0
)
{
...
...
@@ -716,6 +724,20 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
return
alarmFlag
;
}
private
BigDecimal
checkUnit
(
String
indexKey
,
BigDecimal
nowValue
){
LambdaQueryWrapper
<
EquipmentIndex
>
eq
=
new
QueryWrapper
<
EquipmentIndex
>().
lambda
().
eq
(
EquipmentIndex:
:
getPerfQuotaDefinitionId
,
indexKey
);
EquipmentIndex
one
=
equipmentIndexService
.
getOne
(
eq
);
if
(!
ObjectUtils
.
isEmpty
(
one
)
||
!
ObjectUtils
.
isEmpty
(
one
.
getUnit
())){
if
(
UnitEnum
.
MM
.
getKey
().
equalsIgnoreCase
(
one
.
getUnit
())
||
UnitEnum
.
MM
.
getName
().
equals
(
one
.
getUnit
())){
BigDecimal
divide
=
new
BigDecimal
(
1000
);
nowValue
=
nowValue
.
divide
(
divide
,
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
else
if
(
UnitEnum
.
CM
.
getKey
().
equalsIgnoreCase
(
one
.
getUnit
())
||
UnitEnum
.
CM
.
getName
().
equals
(
one
.
getUnit
())){
BigDecimal
divide
=
new
BigDecimal
(
100
);
nowValue
=
nowValue
.
divide
(
divide
,
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
}
return
nowValue
;
}
private
BigDecimal
getBigDecimal
(
Object
value
)
{
BigDecimal
val
=
null
;
if
(
value
!=
null
)
{
...
...
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