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
dc60ded3
Commit
dc60ded3
authored
Jun 22, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改计算考核指标增幅逻辑代码
parent
7bfa8031
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
32 deletions
+60
-32
DriveIndDef.java
...obile/indicators/model/entity/indicators/DriveIndDef.java
+1
-0
IndScorecardService.java
...ile/indicators/service/hytobacco/IndScorecardService.java
+6
-3
IndicatorsValueService.java
.../indicators/service/hytobacco/IndicatorsValueService.java
+10
-4
ShortboardRuleService.java
...e/indicators/service/hytobacco/ShortboardRuleService.java
+41
-18
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+2
-7
No files found.
src/main/java/com/keymobile/indicators/model/entity/indicators/DriveIndDef.java
View file @
dc60ded3
...
@@ -29,6 +29,7 @@ public class DriveIndDef {
...
@@ -29,6 +29,7 @@ public class DriveIndDef {
private
String
indCalScoreRuleDesc
;
//计分规则描述
private
String
indCalScoreRuleDesc
;
//计分规则描述
private
String
isUnitCalScore
;
//是否参与单位得分计算 是:1 否:0
private
String
isUnitCalScore
;
//是否参与单位得分计算 是:1 否:0
private
String
indFrequency
;
//指标频度 0:月度给数 1:季度给数 2:年度给数
private
String
indFrequency
;
//指标频度 0:月度给数 1:季度给数 2:年度给数
private
String
growCalType
;
//增幅计算类型 0:本期-同期 1:(本期-同期)/同期*100
private
String
version
;
//版本号
private
String
version
;
//版本号
private
Integer
catalogId
;
//挂靠目录id
private
Integer
catalogId
;
//挂靠目录id
private
String
catalogIdPath
;
//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
private
String
catalogIdPath
;
//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndScorecardService.java
View file @
dc60ded3
...
@@ -119,6 +119,7 @@ public class IndScorecardService {
...
@@ -119,6 +119,7 @@ public class IndScorecardService {
double
baseScoreValue
=
0
;
double
baseScoreValue
=
0
;
if
(
scoreCard
!=
null
)
{
if
(
scoreCard
!=
null
)
{
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
indId
);
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
indId
);
if
(
driveIndDef
!=
null
)
{
//获取指标是正向还是反向类型
//获取指标是正向还是反向类型
String
acsType
=
driveIndDef
.
getIndType
();
String
acsType
=
driveIndDef
.
getIndType
();
String
unit
=
driveIndDef
.
getIndUnit
();
String
unit
=
driveIndDef
.
getIndUnit
();
...
@@ -224,7 +225,7 @@ public class IndScorecardService {
...
@@ -224,7 +225,7 @@ public class IndScorecardService {
}
}
double
improveScore
=
this
.
calImproveValue
(
acsType
,
unit
,
double
improveScore
=
this
.
calImproveValue
(
acsType
,
unit
,
importScoreDefList
,
currentCompareObjResult
,
importScoreDefList
,
currentCompareObjResult
,
sameCompareObjResult
,
compareObjs
);
sameCompareObjResult
,
compareObjs
,
driveIndDef
.
getGrowCalType
()
);
if
(
scoreCard
.
getLimitScore
()!=
0
)
{
if
(
scoreCard
.
getLimitScore
()!=
0
)
{
if
(
improveScore
>
scoreCard
.
getLimitScore
())
{
if
(
improveScore
>
scoreCard
.
getLimitScore
())
{
improveScore
=
scoreCard
.
getLimitScore
();
improveScore
=
scoreCard
.
getLimitScore
();
...
@@ -237,6 +238,7 @@ public class IndScorecardService {
...
@@ -237,6 +238,7 @@ public class IndScorecardService {
result
.
put
(
"improveScore"
,
"No"
);
//表示不纳入单位得分计算标识
result
.
put
(
"improveScore"
,
"No"
);
//表示不纳入单位得分计算标识
}
}
}
}
}
}
else
{
}
else
{
logger
.
error
(
"id:"
+
indScorecardId
+
" 的评分卡不存在"
);
logger
.
error
(
"id:"
+
indScorecardId
+
" 的评分卡不存在"
);
}
}
...
@@ -249,7 +251,8 @@ public class IndScorecardService {
...
@@ -249,7 +251,8 @@ public class IndScorecardService {
}
}
private
double
calImproveValue
(
String
acsType
,
String
unit
,
List
<
ImproveScoreDef
>
importScoreDefList
,
private
double
calImproveValue
(
String
acsType
,
String
unit
,
List
<
ImproveScoreDef
>
importScoreDefList
,
DriveIndCalResultDef
current
,
DriveIndCalResultDef
same
,
List
<
String
>
compareObjs
)
{
DriveIndCalResultDef
current
,
DriveIndCalResultDef
same
,
List
<
String
>
compareObjs
,
String
growCalType
)
{
double
sumValue
=
0
;
double
sumValue
=
0
;
for
(
ImproveScoreDef
scoreDef
:
importScoreDefList
)
{
for
(
ImproveScoreDef
scoreDef
:
importScoreDefList
)
{
// 0:同期排位比 1:单位同期比
// 0:同期排位比 1:单位同期比
...
@@ -296,7 +299,7 @@ public class IndScorecardService {
...
@@ -296,7 +299,7 @@ public class IndScorecardService {
}
}
}
else
{
}
else
{
//获取单位同期比率
//获取单位同期比率
String
rate
=
CalculateUtils
.
calGowth
(
unit
,
current
.
getValue
(),
same
.
getValue
(),
null
);
String
rate
=
CalculateUtils
.
calGowth
(
current
.
getValue
(),
same
.
getValue
(),
growCalType
);
if
(
StringUtils
.
isNotBlank
(
rate
))
{
if
(
StringUtils
.
isNotBlank
(
rate
))
{
if
(
"0"
.
equals
(
acsType
))
{
if
(
"0"
.
equals
(
acsType
))
{
if
(
Double
.
valueOf
(
rate
)>
0
)
{
//同比趋好
if
(
Double
.
valueOf
(
rate
)>
0
)
{
//同比趋好
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsValueService.java
View file @
dc60ded3
...
@@ -194,8 +194,9 @@ public class IndicatorsValueService {
...
@@ -194,8 +194,9 @@ public class IndicatorsValueService {
dataMap
.
put
(
"currentValue"
,
driveIndCalResult
.
getValue
());
dataMap
.
put
(
"currentValue"
,
driveIndCalResult
.
getValue
());
dataMap
.
put
(
"currentRank"
,
String
.
valueOf
(
driveIndCalResult
.
getRank
()));
dataMap
.
put
(
"currentRank"
,
String
.
valueOf
(
driveIndCalResult
.
getRank
()));
dataMap
.
put
(
"sameValue"
,
sameDriveIndCalResult
.
getValue
());
dataMap
.
put
(
"sameValue"
,
sameDriveIndCalResult
.
getValue
());
String
calGowth
=
CalculateUtils
.
calGowth
(
deiveIndDef
.
getIndUnit
(),
String
calGowth
=
CalculateUtils
.
calGowth
(
driveIndCalResult
.
getValue
(),
sameDriveIndCalResult
.
getValue
(),
"1"
);
driveIndCalResult
.
getValue
(),
sameDriveIndCalResult
.
getValue
(),
deiveIndDef
.
getGrowCalType
());
dataMap
.
put
(
"calGowth"
,
calGowth
);
dataMap
.
put
(
"calGowth"
,
calGowth
);
gowthMap
.
put
(
compareObj
,
calGowth
);
gowthMap
.
put
(
compareObj
,
calGowth
);
...
@@ -412,7 +413,8 @@ public class IndicatorsValueService {
...
@@ -412,7 +413,8 @@ public class IndicatorsValueService {
}
}
//根据指标id获取指标信息
//根据指标id获取指标信息
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
indId
);
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
indId
);
rate
=
CalculateUtils
.
calGowth
(
driveIndDef
.
getIndUnit
(),
currentValue
,
sameValue
,
"0"
);
rate
=
CalculateUtils
.
calGowth
(
currentValue
,
sameValue
,
driveIndDef
.
getGrowCalType
());
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
indId
));
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
indId
));
row
.
getCell
(
3
).
setCellValue
(
currentValue
);
row
.
getCell
(
3
).
setCellValue
(
currentValue
);
...
@@ -523,6 +525,8 @@ public class IndicatorsValueService {
...
@@ -523,6 +525,8 @@ public class IndicatorsValueService {
}
}
//根据考核指标id获取本期和同期的指标值
//根据考核指标id获取本期和同期的指标值
for
(
String
indId
:
indIds
)
{
for
(
String
indId
:
indIds
)
{
DriveIndDef
deiveIndDef
=
driveIndDefService
.
getById
(
indId
);
if
(
deiveIndDef
!=
null
)
{
List
<
DriveIndCalResultDef
>
driveResult
=
driveIndCalResultDefMapper
.
findByIndId
(
indId
);
List
<
DriveIndCalResultDef
>
driveResult
=
driveIndCalResultDefMapper
.
findByIndId
(
indId
);
for
(
DriveIndCalResultDef
result
:
driveResult
)
{
for
(
DriveIndCalResultDef
result
:
driveResult
)
{
String
region
=
result
.
getCompareObj
();
String
region
=
result
.
getCompareObj
();
...
@@ -553,7 +557,9 @@ public class IndicatorsValueService {
...
@@ -553,7 +557,9 @@ public class IndicatorsValueService {
}
}
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
region
));
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
region
));
row
.
getCell
((
cellMap
.
get
(
indId
)+
2
)).
setCellValue
(
row
.
getCell
((
cellMap
.
get
(
indId
)+
2
)).
setCellValue
(
CalculateUtils
.
calGowth
(
gowthValues
.
get
(
0
).
getUnit
(),
currentValue
,
sameValue
,
null
));
CalculateUtils
.
calGowth
(
currentValue
,
sameValue
,
deiveIndDef
.
getGrowCalType
()));
}
}
}
}
}
}
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ShortboardRuleService.java
View file @
dc60ded3
...
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
...
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardItem
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardItem
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardRule
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardRule
;
...
@@ -32,6 +33,8 @@ public class ShortboardRuleService {
...
@@ -32,6 +33,8 @@ public class ShortboardRuleService {
private
ShortboardDriveIndRelMapper
shortboardDriveIndRelMapper
;
private
ShortboardDriveIndRelMapper
shortboardDriveIndRelMapper
;
@Autowired
@Autowired
private
DriveIndCalResultDefMapper
driveIndCalResultDefMapper
;
private
DriveIndCalResultDefMapper
driveIndCalResultDefMapper
;
@Autowired
private
DriveIndDefService
driveIndDefService
;
public
Integer
saveOrUpdate
(
ShortboardRule
shortboardRule
,
Integer
catalogId
,
public
Integer
saveOrUpdate
(
ShortboardRule
shortboardRule
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
)
{
String
catalogIdPath
,
String
user
)
{
...
@@ -179,15 +182,18 @@ public class ShortboardRuleService {
...
@@ -179,15 +182,18 @@ public class ShortboardRuleService {
//短板筛选规则为均值
//短板筛选规则为均值
private
List
<
DriveIndCalResultDef
>
selectAverageShortboard
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectAverageShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
List
<
DriveIndCalResultDef
>
filterCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
List
<
DriveIndCalResultDef
>
filterCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
//判断规则选择是大于还是小于
//判断规则选择是大于还是小于
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
...
@@ -247,33 +253,39 @@ public class ShortboardRuleService {
...
@@ -247,33 +253,39 @@ public class ShortboardRuleService {
}
else
{
//百分比
}
else
{
//百分比
//判断有没有实际的平均值
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
filterCalResult
.
getValue
(),
filterCalResult
.
getActualAverage
(),
"1"
)));
filterCalResult
.
getValue
(),
filterCalResult
.
getActualAverage
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
realCalResults
.
add
(
filterCalResult
);
}
}
}
else
{
}
else
{
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
filterCalResult
.
getValue
(),
filterCalResult
.
getAverage
(),
"1"
)));
filterCalResult
.
getValue
(),
filterCalResult
.
getAverage
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
realCalResults
.
add
(
filterCalResult
);
}
}
}
}
}
}
}
}
}
return
realCalResults
;
return
realCalResults
;
}
}
//短板筛选规则为最大值
//短板筛选规则为最大值
private
List
<
DriveIndCalResultDef
>
selectMaxShortboard
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectMaxShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//获取排名第一的最大值
//获取排名第一的最大值
String
maxValue
=
null
;
String
maxValue
=
null
;
if
(!
calResults
.
isEmpty
())
{
if
(!
calResults
.
isEmpty
())
{
...
@@ -291,8 +303,8 @@ public class ShortboardRuleService {
...
@@ -291,8 +303,8 @@ public class ShortboardRuleService {
realCalResults
.
add
(
calResult
);
realCalResults
.
add
(
calResult
);
}
}
}
else
{
//百分比
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
maxValue
,
calResult
.
getValue
(),
"1"
)));
maxValue
,
calResult
.
getValue
(),
driveIndDef
.
getGrowCalType
()
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
realCalResults
.
add
(
calResult
);
}
}
...
@@ -301,13 +313,17 @@ public class ShortboardRuleService {
...
@@ -301,13 +313,17 @@ public class ShortboardRuleService {
}
}
}
}
}
}
}
return
realCalResults
;
return
realCalResults
;
}
}
//短板筛选规则为最小值
//短板筛选规则为最小值
private
List
<
DriveIndCalResultDef
>
selectMinShortboard
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectMinShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"date"
,
date
);
...
@@ -336,8 +352,8 @@ public class ShortboardRuleService {
...
@@ -336,8 +352,8 @@ public class ShortboardRuleService {
realCalResults
.
add
(
calResult
);
realCalResults
.
add
(
calResult
);
}
}
}
else
{
//百分比
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
calResult
.
getValue
(),
minValue
,
"1"
)));
calResult
.
getValue
(),
minValue
,
driveIndDef
.
getGrowCalType
()
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
realCalResults
.
add
(
calResult
);
}
}
...
@@ -346,6 +362,7 @@ public class ShortboardRuleService {
...
@@ -346,6 +362,7 @@ public class ShortboardRuleService {
}
}
}
}
}
}
}
return
realCalResults
;
return
realCalResults
;
}
}
...
@@ -386,8 +403,11 @@ public class ShortboardRuleService {
...
@@ -386,8 +403,11 @@ public class ShortboardRuleService {
//短板筛选规则为历史同期
//短板筛选规则为历史同期
private
List
<
DriveIndCalResultDef
>
selectSametimeShortboard
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectSametimeShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
for
(
String
compareObj
:
compareObjs
)
{
for
(
String
compareObj
:
compareObjs
)
{
//获取本期
//获取本期
DriveIndCalResultDef
currentIndCalResult
=
driveIndCalResultDefMapper
.
DriveIndCalResultDef
currentIndCalResult
=
driveIndCalResultDefMapper
.
...
@@ -417,8 +437,9 @@ public class ShortboardRuleService {
...
@@ -417,8 +437,9 @@ public class ShortboardRuleService {
realCalResults
.
add
(
currentIndCalResult
);
realCalResults
.
add
(
currentIndCalResult
);
}
}
}
else
{
//百分比
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
currentIndCalResult
.
getValue
(),
sameIndCalResult
.
getValue
(),
"1"
)));
currentIndCalResult
.
getValue
(),
sameIndCalResult
.
getValue
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
realCalResults
.
add
(
currentIndCalResult
);
}
}
...
@@ -435,8 +456,9 @@ public class ShortboardRuleService {
...
@@ -435,8 +456,9 @@ public class ShortboardRuleService {
realCalResults
.
add
(
currentIndCalResult
);
realCalResults
.
add
(
currentIndCalResult
);
}
}
}
else
{
//百分比
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
sameIndCalResult
.
getValue
(),
currentIndCalResult
.
getValue
(),
"1"
)));
sameIndCalResult
.
getValue
(),
currentIndCalResult
.
getValue
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
realCalResults
.
add
(
currentIndCalResult
);
}
}
...
@@ -448,6 +470,7 @@ public class ShortboardRuleService {
...
@@ -448,6 +470,7 @@ public class ShortboardRuleService {
}
}
}
}
}
}
}
return
realCalResults
;
return
realCalResults
;
}
}
}
}
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
dc60ded3
package
com
.
keymobile
.
indicators
.
utils
;
package
com
.
keymobile
.
indicators
.
utils
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
...
@@ -18,23 +17,19 @@ import com.googlecode.aviator.AviatorEvaluator;
...
@@ -18,23 +17,19 @@ 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
calGowth
(
String
unit
,
String
currentValue
,
String
sameValue
,
String
type
)
{
//type:0 : 本期-同期 1:(本期-同期)/同期
public
static
String
calGowth
(
String
currentValue
,
String
sameValue
,
String
type
)
{
String
gowthValue
=
""
;
String
gowthValue
=
""
;
StringBuilder
formula
=
new
StringBuilder
();
StringBuilder
formula
=
new
StringBuilder
();
if
(!
"NaN"
.
equals
(
currentValue
)
&&
!
"Infinite"
.
equals
(
currentValue
)
if
(!
"NaN"
.
equals
(
currentValue
)
&&
!
"Infinite"
.
equals
(
currentValue
)
&&
!
"NaN"
.
equals
(
sameValue
)
&&
!
"Infinite"
.
equals
(
sameValue
))
{
&&
!
"NaN"
.
equals
(
sameValue
)
&&
!
"Infinite"
.
equals
(
sameValue
))
{
Object
value
=
null
;
Object
value
=
null
;
if
(
"0"
.
equals
(
type
))
{
if
(
"0"
.
equals
(
type
))
{
if
(
"%"
.
equals
(
unit
))
{
formula
.
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
);
formula
.
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
);
}
else
{
}
else
{
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
}
}
}
else
{
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
}
value
=
AviatorEvaluator
.
execute
(
formula
.
toString
());
value
=
AviatorEvaluator
.
execute
(
formula
.
toString
());
if
(
value
!=
null
&&
!
"NaN"
.
equals
(
value
.
toString
())
&&
!
"Infinite"
.
equals
(
value
.
toString
()))
{
if
(
value
!=
null
&&
!
"NaN"
.
equals
(
value
.
toString
())
&&
!
"Infinite"
.
equals
(
value
.
toString
()))
{
try
{
try
{
...
...
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