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
042906a7
Commit
042906a7
authored
Jan 15, 2023
by
KeYong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新后端液位转换
parent
a262e8d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
UnitEnum.java
...n/java/com/yeejoin/equipmanage/common/enums/UnitEnum.java
+2
-1
UnitTransformUtil.java
...m/yeejoin/equipmanage/common/utils/UnitTransformUtil.java
+32
-2
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/UnitEnum.java
View file @
042906a7
...
@@ -17,7 +17,8 @@ public enum UnitEnum {
...
@@ -17,7 +17,8 @@ public enum UnitEnum {
M
(
"m"
,
"米"
,
""
),
M
(
"m"
,
"米"
,
""
),
DM
(
"dm"
,
"分米"
,
""
),
DM
(
"dm"
,
"分米"
,
""
),
CM
(
"cm"
,
"厘米"
,
""
);
CM
(
"cm"
,
"厘米"
,
""
),
MM
(
"mm"
,
"毫米"
,
""
);
private
String
key
;
private
String
key
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/utils/UnitTransformUtil.java
View file @
042906a7
...
@@ -20,7 +20,37 @@ public class UnitTransformUtil {
...
@@ -20,7 +20,37 @@ public class UnitTransformUtil {
public
static
Map
<
String
,
Object
>
transformValues
(
String
currentValue
,
String
currentUnit
,
String
minValue
,
String
maxValue
)
{
public
static
Map
<
String
,
Object
>
transformValues
(
String
currentValue
,
String
currentUnit
,
String
minValue
,
String
maxValue
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
UnitEnum
.
CM
.
getKey
().
equalsIgnoreCase
(
currentUnit
)
||
UnitEnum
.
CM
.
getName
().
equals
(
currentUnit
)){
if
(
UnitEnum
.
MM
.
getKey
().
equalsIgnoreCase
(
currentUnit
)
||
UnitEnum
.
MM
.
getName
().
equals
(
currentUnit
)){
BigDecimal
divide
=
new
BigDecimal
(
1000
);
if
(
StringUtil
.
isNotEmpty
(
currentValue
)
&&
!
"--"
.
equals
(
currentValue
)){
BigDecimal
nowLevel
=
new
BigDecimal
(
currentValue
);
map
.
put
(
"nowValue"
,
nowLevel
.
divide
(
divide
,
2
,
BigDecimal
.
ROUND_HALF_UP
));
BigDecimal
nowVal
=
new
BigDecimal
(
currentValue
).
divide
(
divide
,
2
,
BigDecimal
.
ROUND_HALF_UP
);
// status 中 0 表示过低;1 表示正常;2 表示过高
if
(
StringUtil
.
isNotEmpty
(
minValue
)
&&
!
"--"
.
equals
(
minValue
)
&&
StringUtil
.
isNotEmpty
(
maxValue
)
&&
!
"--"
.
equals
(
maxValue
)
&&
!
"null"
.
equalsIgnoreCase
(
minValue
)&&
!
"--"
.
equals
(
maxValue
)
&&
!
"null"
.
equalsIgnoreCase
(
maxValue
))
{
if
(
nowVal
.
compareTo
(
new
BigDecimal
(
minValue
))
<
0
)
{
map
.
put
(
"status"
,
"0"
);
map
.
put
(
"abs"
,
nowVal
.
divide
(
new
BigDecimal
(
maxValue
),
2
,
BigDecimal
.
ROUND_HALF_UP
).
movePointRight
(
2
));
}
else
if
(
nowVal
.
compareTo
(
new
BigDecimal
(
maxValue
))
==
1
)
{
map
.
put
(
"status"
,
"2"
);
map
.
put
(
"abs"
,
100
);
}
else
{
map
.
put
(
"status"
,
"1"
);
map
.
put
(
"abs"
,
nowVal
.
divide
(
new
BigDecimal
(
maxValue
),
2
,
BigDecimal
.
ROUND_HALF_UP
).
movePointRight
(
2
));
}
}
else
{
map
.
put
(
"status"
,
"--"
);
map
.
put
(
"abs"
,
"--"
);
}
}
else
{
map
.
put
(
"nowValue"
,
"--"
);
map
.
put
(
"status"
,
"--"
);
map
.
put
(
"abs"
,
"--"
);
}
}
else
if
(
UnitEnum
.
CM
.
getKey
().
equalsIgnoreCase
(
currentUnit
)
||
UnitEnum
.
CM
.
getName
().
equals
(
currentUnit
)){
BigDecimal
divide
=
new
BigDecimal
(
100
);
BigDecimal
divide
=
new
BigDecimal
(
100
);
if
(
StringUtil
.
isNotEmpty
(
currentValue
)
&&
!
"--"
.
equals
(
currentValue
)){
if
(
StringUtil
.
isNotEmpty
(
currentValue
)
&&
!
"--"
.
equals
(
currentValue
)){
BigDecimal
nowLevel
=
new
BigDecimal
(
currentValue
);
BigDecimal
nowLevel
=
new
BigDecimal
(
currentValue
);
...
@@ -81,7 +111,7 @@ public class UnitTransformUtil {
...
@@ -81,7 +111,7 @@ public class UnitTransformUtil {
}
}
}
else
{
}
else
{
BigDecimal
nowVal
=
new
BigDecimal
(
0
);
BigDecimal
nowVal
=
new
BigDecimal
(
0
);
if
(
StringUtil
.
isNotEmpty
(
currentValue
))
{
if
(
StringUtil
.
isNotEmpty
(
currentValue
)
&&
!
"--"
.
equals
(
currentValue
)
)
{
nowVal
=
new
BigDecimal
(
currentValue
);
nowVal
=
new
BigDecimal
(
currentValue
);
map
.
put
(
"nowValue"
,
nowVal
);
map
.
put
(
"nowValue"
,
nowVal
);
}
else
{
}
else
{
...
...
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