Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
indicators
Overview
Overview
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
zhangkb
indicators
Commits
f87d6dea
Commit
f87d6dea
authored
Sep 02, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改aviator表达式计算引擎计算整数取整问题
parent
ecb3b9f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
7 deletions
+33
-7
DriveIndIdObjCalActor.java
...dicators/akka/actor/indicators/DriveIndIdObjCalActor.java
+4
-1
DriveIndDefService.java
...bile/indicators/service/hytobacco/DriveIndDefService.java
+3
-0
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+26
-6
No files found.
src/main/java/com/keymobile/indicators/akka/actor/indicators/DriveIndIdObjCalActor.java
View file @
f87d6dea
...
...
@@ -163,9 +163,12 @@ public class DriveIndIdObjCalActor extends AbstractActor{
String
indValue
=
baseIndValueMsg
.
getValue
();
//如果指标值返回空值
if
(
StringUtils
.
isBlank
(
indValue
))
{
indValue
=
"0.0"
;
indValue
=
"0.0
0
"
;
}
try
{
if
(
indValue
.
indexOf
(
"."
)<
0
)
{
indValue
+=
".00"
;
}
driveIndFormula
=
driveIndFormula
.
replace
(
"["
+
baseIndValueMsg
.
getIndId
()+
"]"
,
indValue
);
//替换公式中的基础指标id为确定指标值
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndDefService.java
View file @
f87d6dea
...
...
@@ -192,6 +192,9 @@ public class DriveIndDefService {
List
<
String
>
indDateList
=
baseIndDataService
.
getIndData
(
indId
,
date
,
compareObjs
,
code
);
String
sumValue
=
CalculateUtils
.
sumValue
(
indDateList
);
if
(
sumValue
.
indexOf
(
"."
)<
0
)
{
sumValue
+=
".00"
;
}
env
.
put
(
indId
,
Double
.
valueOf
(
sumValue
));
driveIndFormula
=
driveIndFormula
.
replace
(
"["
+
indId
+
"]"
,
sumValue
);
}
...
...
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
f87d6dea
...
...
@@ -42,6 +42,12 @@ public class CalculateUtils {
if
(!
"NaN"
.
equals
(
currentValue
)
&&
!
"Infinite"
.
equals
(
currentValue
)
&&
StringUtils
.
isNotBlank
(
currentValue
)
&&
!
"NaN"
.
equals
(
sameValue
)
&&
!
"Infinite"
.
equals
(
sameValue
)
&&
StringUtils
.
isNotBlank
(
sameValue
))
{
Object
value
=
null
;
if
(
currentValue
.
indexOf
(
"."
)<
0
)
{
currentValue
+=
".00"
;
}
if
(
sameValue
.
indexOf
(
"."
)<
0
)
{
sameValue
+=
".00"
;
}
if
(
"0"
.
equals
(
type
))
{
formula
.
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
);
}
else
{
...
...
@@ -133,10 +139,14 @@ public class CalculateUtils {
if
(
StringUtils
.
isBlank
(
values
.
get
(
i
)))
{
continue
;
}
String
value
=
values
.
get
(
i
);
if
(
value
.
indexOf
(
"."
)<
0
)
{
value
+=
".00"
;
}
if
(
i
==
values
.
size
()-
1
)
{
//最后一个不加+号
formula
.
append
(
"("
).
append
(
value
s
.
get
(
i
)
).
append
(
")"
);
formula
.
append
(
"("
).
append
(
value
).
append
(
")"
);
}
else
{
formula
.
append
(
"("
).
append
(
value
s
.
get
(
i
)
).
append
(
")"
).
append
(
"+"
);
formula
.
append
(
"("
).
append
(
value
).
append
(
")"
).
append
(
"+"
);
}
}
if
(
formula
.
toString
().
endsWith
(
"+"
))
{
...
...
@@ -172,10 +182,14 @@ public class CalculateUtils {
continue
;
}
}
String
value
=
values
.
get
(
i
);
if
(
value
.
indexOf
(
"."
)<
0
)
{
value
+=
".00"
;
}
if
(
i
==
values
.
size
()-
1
)
{
//最后一个不加+号
formula
.
append
(
"("
).
append
(
value
s
.
get
(
i
)
).
append
(
")"
);
formula
.
append
(
"("
).
append
(
value
).
append
(
")"
);
}
else
{
formula
.
append
(
"("
).
append
(
value
s
.
get
(
i
)
).
append
(
")"
).
append
(
"+"
);
formula
.
append
(
"("
).
append
(
value
).
append
(
")"
).
append
(
"+"
);
}
}
if
(
formula
.
toString
().
endsWith
(
"+"
))
{
...
...
@@ -379,9 +393,15 @@ public class CalculateUtils {
// map.put("1002", "5");
// formula = formula.replace("[1001]", "3");
// formula = formula.replace("[1002]", "5");
// String result1 = AviatorEvaluator.execute(formula).toString();
String
ss
=
"1755"
;
String
formula
=
"(ss/2299-1)*100"
;
if
(
ss
.
indexOf
(
"."
)<
0
)
{
ss
+=
".00"
;
}
formula
=
formula
.
replace
(
"ss"
,
ss
);
String
result1
=
AviatorEvaluator
.
execute
(
formula
).
toString
();
// String result2 = cal.calculateFormula(formula, map);
//
System.out.println(result1);
System
.
out
.
println
(
result1
);
// System.out.println(result2);
// Double b = (double) Math.abs(34-50);
// System.out.println(b);
...
...
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