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
56e74d5f
Commit
56e74d5f
authored
Jul 10, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加公式计算接口
parent
a6bc68e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
BaseIndDataService.java
...bile/indicators/service/hytobacco/BaseIndDataService.java
+0
-8
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+23
-6
No files found.
src/main/java/com/keymobile/indicators/service/hytobacco/BaseIndDataService.java
View file @
56e74d5f
...
@@ -8,18 +8,10 @@ import java.util.Map;
...
@@ -8,18 +8,10 @@ import java.util.Map;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.conf.MongoDBConfig
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
com.keymobile.indicators.model.mapper.indmapper.IndicatorsDataMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.IndicatorsDataMapper
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DB
;
import
com.mongodb.DBCollection
;
import
com.mongodb.DBCursor
;
import
com.mongodb.DBObject
;
import
com.mongodb.MongoClient
;
@Service
@Service
public
class
BaseIndDataService
{
public
class
BaseIndDataService
{
...
...
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
56e74d5f
...
@@ -18,6 +18,18 @@ import com.googlecode.aviator.AviatorEvaluator;
...
@@ -18,6 +18,18 @@ import com.googlecode.aviator.AviatorEvaluator;
public
class
CalculateUtils
{
public
class
CalculateUtils
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
CalculateUtils
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
CalculateUtils
.
class
);
//根据公式和值计算数值
public
static
String
calculateFormula
(
String
formula
,
Map
<
String
,
String
>
dataMap
)
{
String
result
=
"NaN"
;
if
(
StringUtils
.
isNotBlank
(
formula
)
&&
!
dataMap
.
isEmpty
())
{
for
(
Entry
<
String
,
String
>
entry
:
dataMap
.
entrySet
())
{
formula
=
formula
.
replace
(
"["
+
entry
.
getKey
()+
"]"
,
entry
.
getValue
());
}
result
=
AviatorEvaluator
.
execute
(
formula
).
toString
();
}
return
result
;
}
//type:0 : 本期-同期 1:(本期-同期)/同期
//type:0 : 本期-同期 1:(本期-同期)/同期
public
static
String
calGowth
(
String
currentValue
,
String
sameValue
,
String
type
)
{
public
static
String
calGowth
(
String
currentValue
,
String
sameValue
,
String
type
)
{
String
gowthValue
=
""
;
String
gowthValue
=
""
;
...
@@ -226,15 +238,20 @@ public class CalculateUtils {
...
@@ -226,15 +238,20 @@ public class CalculateUtils {
// map.put("1006", "NaN");
// map.put("1006", "NaN");
// map.put("1007", "NaN");
// map.put("1007", "NaN");
// map.put("1008", "NaN");
// map.put("1008", "NaN");
//
CalculateUtils cal = new CalculateUtils();
CalculateUtils
cal
=
new
CalculateUtils
();
// Map<String,Integer> result = cal.rankValue(map, "1");
// Map<String,Integer> result = cal.rankValue(map, "1");
// System.out.println(result);
// System.out.println(result);
//
//
// String formula = "([1001]+[1002])/2";
String
formula
=
"([1001]+[1002])/2"
;
// formula = formula.replace("[1001]", "3");
Map
<
String
,
String
>
map
=
new
HashMap
<>();
// formula = formula.replace("[1002]", "5");
map
.
put
(
"1001"
,
"3"
);
// String result1 = AviatorEvaluator.execute(formula).toString();
map
.
put
(
"1002"
,
"5"
);
// System.out.println(result1);
formula
=
formula
.
replace
(
"[1001]"
,
"3"
);
formula
=
formula
.
replace
(
"[1002]"
,
"5"
);
String
result1
=
AviatorEvaluator
.
execute
(
formula
).
toString
();
String
result2
=
cal
.
calculateFormula
(
formula
,
map
);
System
.
out
.
println
(
result1
);
System
.
out
.
println
(
result2
);
// Double b = (double) Math.abs(34-50);
// Double b = (double) Math.abs(34-50);
// System.out.println(b);
// System.out.println(b);
// List<String> listA = new ArrayList<>();
// List<String> listA = new ArrayList<>();
...
...
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