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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
346 additions
and
318 deletions
+346
-318
DriveIndDef.java
...obile/indicators/model/entity/indicators/DriveIndDef.java
+1
-0
IndScorecardService.java
...ile/indicators/service/hytobacco/IndScorecardService.java
+107
-104
IndicatorsValueService.java
.../indicators/service/hytobacco/IndicatorsValueService.java
+36
-30
ShortboardRuleService.java
...e/indicators/service/hytobacco/ShortboardRuleService.java
+199
-176
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+3
-8
No files found.
src/main/java/com/keymobile/indicators/model/entity/indicators/DriveIndDef.java
View file @
dc60ded3
...
...
@@ -29,6 +29,7 @@ public class DriveIndDef {
private
String
indCalScoreRuleDesc
;
//计分规则描述
private
String
isUnitCalScore
;
//是否参与单位得分计算 是:1 否:0
private
String
indFrequency
;
//指标频度 0:月度给数 1:季度给数 2:年度给数
private
String
growCalType
;
//增幅计算类型 0:本期-同期 1:(本期-同期)/同期*100
private
String
version
;
//版本号
private
Integer
catalogId
;
//挂靠目录id
private
String
catalogIdPath
;
//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndScorecardService.java
View file @
dc60ded3
...
...
@@ -119,122 +119,124 @@ public class IndScorecardService {
double
baseScoreValue
=
0
;
if
(
scoreCard
!=
null
)
{
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
indId
);
//获取指标是正向还是反向类型
String
acsType
=
driveIndDef
.
getIndType
();
String
unit
=
driveIndDef
.
getIndUnit
();
List
<
DriveIndCalResultDef
>
currentDriveResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareIdAndSort
(
indId
,
date
,
compareId
);
if
(!
currentDriveResult
.
isEmpty
())
{
//过滤考核指标结果集无效值
Iterator
<
DriveIndCalResultDef
>
it
=
currentDriveResult
.
iterator
();
while
(
it
.
hasNext
()){
DriveIndCalResultDef
driveCalResult
=
it
.
next
();
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"Infinite"
.
equals
(
driveCalResult
.
getValue
())
||
"0.0000"
.
equals
(
driveCalResult
.
getValue
())||
"0"
.
equals
(
driveCalResult
.
getValue
())){
it
.
remove
();
}
}
int
currentDriveResultSize
=
currentDriveResult
.
size
();
//根据indId,date,compareObj获取考核结果
DriveIndCalResultDef
currentCompareObjResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
indId
,
date
,
compareObj
);
if
(
driveIndDef
!=
null
)
{
//获取指标是正向还是反向类型
String
acsType
=
driveIndDef
.
getIndType
();
String
unit
=
driveIndDef
.
getIndUnit
();
if
(
currentCompareObjResult
!=
null
)
{
String
average
=
currentCompareObjResult
.
getAverage
();
//如果实际平均值存在
if
(
currentCompareObjResult
.
getActualAverage
()!=
null
)
{
if
(!
"0.0"
.
equals
(
currentCompareObjResult
.
getActualAverage
()))
{
average
=
currentCompareObjResult
.
getActualAverage
();
List
<
DriveIndCalResultDef
>
currentDriveResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareIdAndSort
(
indId
,
date
,
compareId
);
if
(!
currentDriveResult
.
isEmpty
())
{
//过滤考核指标结果集无效值
Iterator
<
DriveIndCalResultDef
>
it
=
currentDriveResult
.
iterator
();
while
(
it
.
hasNext
()){
DriveIndCalResultDef
driveCalResult
=
it
.
next
();
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"Infinite"
.
equals
(
driveCalResult
.
getValue
())
||
"0.0000"
.
equals
(
driveCalResult
.
getValue
())||
"0"
.
equals
(
driveCalResult
.
getValue
())){
it
.
remove
();
}
}
String
value
=
currentCompareObjResult
.
getValue
();
if
(!
"NaN"
.
equals
(
value
)
&&
!
"Infinite"
.
equals
(
value
)
&&
!
"0.0000"
.
equals
(
value
)
&&
!
"0"
.
equals
(
value
))
{
//综合评价
if
(
"0"
.
equals
(
scoreCard
.
getScoreType
()))
{
//定义
baseScoreValue
=
scoreCard
.
getIndBaseScore
();
//基础分
//如果是反向指标(越小越好)
if
(
"1"
.
equals
(
acsType
))
{
if
(
Double
.
valueOf
(
value
)<
Double
.
valueOf
(
average
))
{
//大于组内平均分
baseScoreValue
+=
scoreCard
.
getMoreAverage
();
}
else
{
baseScoreValue
-=
scoreCard
.
getLessAverage
();
}
}
else
{
//正向指标,越大越好
if
(
Double
.
valueOf
(
value
)>
Double
.
valueOf
(
average
))
{
//大于组内平均分
baseScoreValue
+=
scoreCard
.
getMoreAverage
();
}
else
{
baseScoreValue
-=
scoreCard
.
getLessAverage
();
}
}
int
currentDriveResultSize
=
currentDriveResult
.
size
();
//根据indId,date,compareObj获取考核结果
DriveIndCalResultDef
currentCompareObjResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
indId
,
date
,
compareObj
);
if
(
currentCompareObjResult
!=
null
)
{
String
average
=
currentCompareObjResult
.
getAverage
();
//如果实际平均值存在
if
(
currentCompareObjResult
.
getActualAverage
()!=
null
)
{
if
(!
"0.0"
.
equals
(
currentCompareObjResult
.
getActualAverage
()))
{
average
=
currentCompareObjResult
.
getActualAverage
();
}
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
//加分项
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getAddScoreItemJson
()))
{
List
<
RankScoreDef
>
addScoreItem
=
gson
.
fromJson
(
scoreCard
.
getAddScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
for
(
RankScoreDef
scoreDef
:
addScoreItem
)
{
if
(
scoreDef
.
getRank
()==
rank
)
{
baseScoreValue
+=
scoreDef
.
getScore
();
break
;
}
String
value
=
currentCompareObjResult
.
getValue
();
if
(!
"NaN"
.
equals
(
value
)
&&
!
"Infinite"
.
equals
(
value
)
&&
!
"0.0000"
.
equals
(
value
)
&&
!
"0"
.
equals
(
value
))
{
//综合评价
if
(
"0"
.
equals
(
scoreCard
.
getScoreType
()))
{
//定义
baseScoreValue
=
scoreCard
.
getIndBaseScore
();
//基础分
//如果是反向指标(越小越好)
if
(
"1"
.
equals
(
acsType
))
{
if
(
Double
.
valueOf
(
value
)<
Double
.
valueOf
(
average
))
{
//大于组内平均分
baseScoreValue
+=
scoreCard
.
getMoreAverage
();
}
else
{
baseScoreValue
-=
scoreCard
.
getLessAverage
();
}
}
else
{
//正向指标,越大越好
if
(
Double
.
valueOf
(
value
)>
Double
.
valueOf
(
average
))
{
//大于组内平均分
baseScoreValue
+=
scoreCard
.
getMoreAverage
();
}
else
{
baseScoreValue
-=
scoreCard
.
getLessAverage
();
}
}
}
//减分项
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getMinusScoreItemJson
()))
{
List
<
RankScoreDef
>
minusScoreItem
=
gson
.
fromJson
(
scoreCard
.
getMinusScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
rank
=
currentDriveResultSize
-
rank
+
1
;
for
(
RankScoreDef
scoreDef
:
minusScoreItem
)
{
if
(
scoreDef
.
getRank
()==
rank
)
{
baseScoreValue
-=
scoreDef
.
getScore
();
break
;
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
//加分项
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getAddScoreItemJson
()))
{
List
<
RankScoreDef
>
addScoreItem
=
gson
.
fromJson
(
scoreCard
.
getAddScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
for
(
RankScoreDef
scoreDef
:
addScoreItem
)
{
if
(
scoreDef
.
getRank
()==
rank
)
{
baseScoreValue
+=
scoreDef
.
getScore
();
break
;
}
}
}
}
}
else
{
//公式
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
if
(
rank
==
1
)
{
//最佳指标
baseScoreValue
=
scoreCard
.
getBestIndScore
();
}
else
if
(
rank
==
currentDriveResultSize
)
{
//最差指标
baseScoreValue
=
scoreCard
.
getWorstIndScore
();
}
else
{
//其他
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getOtherCalFormula
()))
{
baseScoreValue
=
this
.
getValueFromFormula
(
scoreCard
.
getOtherCalFormula
(),
currentCompareObjResult
,
currentDriveResult
,
acsType
);
//减分项
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getMinusScoreItemJson
()))
{
List
<
RankScoreDef
>
minusScoreItem
=
gson
.
fromJson
(
scoreCard
.
getMinusScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
rank
=
currentDriveResultSize
-
rank
+
1
;
for
(
RankScoreDef
scoreDef
:
minusScoreItem
)
{
if
(
scoreDef
.
getRank
()==
rank
)
{
baseScoreValue
-=
scoreDef
.
getScore
();
break
;
}
}
}
}
else
{
//公式
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
if
(
rank
==
1
)
{
//最佳指标
baseScoreValue
=
scoreCard
.
getBestIndScore
();
}
else
if
(
rank
==
currentDriveResultSize
)
{
//最差指标
baseScoreValue
=
scoreCard
.
getWorstIndScore
();
}
else
{
//其他
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getOtherCalFormula
()))
{
baseScoreValue
=
this
.
getValueFromFormula
(
scoreCard
.
getOtherCalFormula
(),
currentCompareObjResult
,
currentDriveResult
,
acsType
);
}
}
}
}
}
}
//改善提升
if
(
"1"
.
equals
(
scoreCard
.
getIsIncluScore
()))
{
//纳入单位得分计算
//同期
DriveIndCalResultDef
sameCompareObjResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
indId
,
(
date
-
100
),
compareObj
);
if
(
sameCompareObjResult
!=
null
)
{
List
<
ImproveScoreDef
>
importScoreDefList
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getImproveScoreItemJson
()))
{
importScoreDefList
=
gson
.
fromJson
(
scoreCard
.
getImproveScoreItemJson
(),
new
TypeToken
<
List
<
ImproveScoreDef
>>(){}.
getType
());
}
double
improveScore
=
this
.
calImproveValue
(
acsType
,
unit
,
importScoreDefList
,
currentCompareObjResult
,
sameCompareObjResult
,
compareObjs
);
if
(
scoreCard
.
getLimitScore
()!=
0
)
{
if
(
improveScore
>
scoreCard
.
getLimitScore
())
{
improveScore
=
scoreCard
.
getLimitScore
();
//改善提升
if
(
"1"
.
equals
(
scoreCard
.
getIsIncluScore
()))
{
//纳入单位得分计算
//同期
DriveIndCalResultDef
sameCompareObjResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
indId
,
(
date
-
100
),
compareObj
);
if
(
sameCompareObjResult
!=
null
)
{
List
<
ImproveScoreDef
>
importScoreDefList
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getImproveScoreItemJson
()))
{
importScoreDefList
=
gson
.
fromJson
(
scoreCard
.
getImproveScoreItemJson
(),
new
TypeToken
<
List
<
ImproveScoreDef
>>(){}.
getType
());
}
double
improveScore
=
this
.
calImproveValue
(
acsType
,
unit
,
importScoreDefList
,
currentCompareObjResult
,
sameCompareObjResult
,
compareObjs
,
driveIndDef
.
getGrowCalType
());
if
(
scoreCard
.
getLimitScore
()!=
0
)
{
if
(
improveScore
>
scoreCard
.
getLimitScore
())
{
improveScore
=
scoreCard
.
getLimitScore
();
}
}
indImproveScoreValue
=
String
.
format
(
"%.4f"
,
new
BigDecimal
(
improveScore
));
result
.
put
(
"improveScore"
,
indImproveScoreValue
);
}
indImproveScoreValue
=
String
.
format
(
"%.4f"
,
new
BigDecimal
(
improveScore
));
result
.
put
(
"improveScore"
,
indImproveScoreValue
);
}
else
{
result
.
put
(
"improveScore"
,
"No"
);
//表示不纳入单位得分计算标识
}
}
else
{
result
.
put
(
"improveScore"
,
"No"
);
//表示不纳入单位得分计算标识
}
}
}
else
{
...
...
@@ -249,7 +251,8 @@ public class IndScorecardService {
}
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
;
for
(
ImproveScoreDef
scoreDef
:
importScoreDefList
)
{
// 0:同期排位比 1:单位同期比
...
...
@@ -296,7 +299,7 @@ public class IndScorecardService {
}
}
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
(
"0"
.
equals
(
acsType
))
{
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 {
dataMap
.
put
(
"currentValue"
,
driveIndCalResult
.
getValue
());
dataMap
.
put
(
"currentRank"
,
String
.
valueOf
(
driveIndCalResult
.
getRank
()));
dataMap
.
put
(
"sameValue"
,
sameDriveIndCalResult
.
getValue
());
String
calGowth
=
CalculateUtils
.
calGowth
(
deiveIndDef
.
getIndUnit
(),
driveIndCalResult
.
getValue
(),
sameDriveIndCalResult
.
getValue
(),
"1"
);
String
calGowth
=
CalculateUtils
.
calGowth
(
driveIndCalResult
.
getValue
(),
sameDriveIndCalResult
.
getValue
(),
deiveIndDef
.
getGrowCalType
());
dataMap
.
put
(
"calGowth"
,
calGowth
);
gowthMap
.
put
(
compareObj
,
calGowth
);
...
...
@@ -412,7 +413,8 @@ public class IndicatorsValueService {
}
//根据指标id获取指标信息
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
));
row
.
getCell
(
3
).
setCellValue
(
currentValue
);
...
...
@@ -523,37 +525,41 @@ public class IndicatorsValueService {
}
//根据考核指标id获取本期和同期的指标值
for
(
String
indId
:
indIds
)
{
List
<
DriveIndCalResultDef
>
driveResult
=
driveIndCalResultDefMapper
.
findByIndId
(
indId
);
for
(
DriveIndCalResultDef
result
:
driveResult
)
{
String
region
=
result
.
getCompareObj
();
if
(
rowMap
.
get
(
region
)!=
null
)
{
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
region
));
if
(
result
.
getDate
()==
201912
)
{
row
.
getCell
(
cellMap
.
get
(
indId
)).
setCellValue
(
result
.
getValue
());
DriveIndDef
deiveIndDef
=
driveIndDefService
.
getById
(
indId
);
if
(
deiveIndDef
!=
null
)
{
List
<
DriveIndCalResultDef
>
driveResult
=
driveIndCalResultDefMapper
.
findByIndId
(
indId
);
for
(
DriveIndCalResultDef
result
:
driveResult
)
{
String
region
=
result
.
getCompareObj
();
if
(
rowMap
.
get
(
region
)!=
null
)
{
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
region
));
if
(
result
.
getDate
()==
201912
)
{
row
.
getCell
(
cellMap
.
get
(
indId
)).
setCellValue
(
result
.
getValue
());
}
else
{
row
.
getCell
((
cellMap
.
get
(
indId
)+
1
)).
setCellValue
(
result
.
getValue
());
}
}
else
{
row
.
getCell
((
cellMap
.
get
(
indId
)+
1
)).
setCellValue
(
result
.
getValue
()
);
logger
.
info
(
"找不到 "
+
region
+
" 对应的列"
);
}
}
else
{
logger
.
info
(
"找不到 "
+
region
+
" 对应的列"
);
}
//算一次
if
(
result
.
getDate
()==
201912
)
{
String
currentValue
=
""
;
String
sameValue
=
""
;
//算增幅
List
<
DriveIndCalResultDef
>
gowthValues
=
driveIndCalResultDefMapper
.
findByIndIdAndCompareObj
(
indId
,
region
);
for
(
DriveIndCalResultDef
gowth
:
gowthValues
)
{
if
(
gowth
.
getDate
()==
201912
)
{
currentValue
=
gowth
.
getValue
();
}
else
{
sameValue
=
gowth
.
getValue
();
//算一次
if
(
result
.
getDate
()==
201912
)
{
String
currentValue
=
""
;
String
sameValue
=
""
;
//算增幅
List
<
DriveIndCalResultDef
>
gowthValues
=
driveIndCalResultDefMapper
.
findByIndIdAndCompareObj
(
indId
,
region
);
for
(
DriveIndCalResultDef
gowth
:
gowthValues
)
{
if
(
gowth
.
getDate
()==
201912
)
{
currentValue
=
gowth
.
getValue
();
}
else
{
sameValue
=
gowth
.
getValue
();
}
}
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
region
));
row
.
getCell
((
cellMap
.
get
(
indId
)+
2
)).
setCellValue
(
CalculateUtils
.
calGowth
(
currentValue
,
sameValue
,
deiveIndDef
.
getGrowCalType
()));
}
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
region
));
row
.
getCell
((
cellMap
.
get
(
indId
)+
2
)).
setCellValue
(
CalculateUtils
.
calGowth
(
gowthValues
.
get
(
0
).
getUnit
(),
currentValue
,
sameValue
,
null
));
}
}
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ShortboardRuleService.java
View file @
dc60ded3
...
...
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
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.ShortboardItem
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardRule
;
...
...
@@ -32,6 +33,8 @@ public class ShortboardRuleService {
private
ShortboardDriveIndRelMapper
shortboardDriveIndRelMapper
;
@Autowired
private
DriveIndCalResultDefMapper
driveIndCalResultDefMapper
;
@Autowired
private
DriveIndDefService
driveIndDefService
;
public
Integer
saveOrUpdate
(
ShortboardRule
shortboardRule
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
)
{
...
...
@@ -179,84 +182,90 @@ public class ShortboardRuleService {
//短板筛选规则为均值
private
List
<
DriveIndCalResultDef
>
selectAverageShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
List
<
DriveIndCalResultDef
>
filterCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
//判断规则选择是大于还是小于
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
>
Double
.
parseDouble
(
calResult
.
getActualAverage
()))
{
filterCalResults
.
add
(
calResult
);
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
//判断规则选择是大于还是小于
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
>
Double
.
parseDouble
(
calResult
.
getActualAverage
()))
{
filterCalResults
.
add
(
calResult
);
}
}
else
{
//没有比较组内平均值
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
>
Double
.
parseDouble
(
calResult
.
getAverage
()))
{
filterCalResults
.
add
(
calResult
);
}
}
}
else
{
//没有比较组内平均值
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
>
Double
.
parseDouble
(
calResult
.
getAverage
()))
{
filterCalResults
.
add
(
calResult
);
}
}
else
{
//小于
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
<
Double
.
parseDouble
(
calResult
.
getActualAverage
()))
{
filterCalResults
.
add
(
calResult
);
}
}
else
{
//没有比较组内平均值
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
<
Double
.
parseDouble
(
calResult
.
getAverage
()))
{
filterCalResults
.
add
(
calResult
);
}
}
}
}
}
else
{
//小于
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
}
//分析filterCalResults
for
(
DriveIndCalResultDef
filterCalResult
:
filterCalResults
)
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
<
Double
.
parseDouble
(
calResult
.
getActualAverage
()))
{
filterCalResults
.
add
(
calResult
);
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
//获取差值绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
filterCalResult
.
getActualAverage
())
-
Double
.
parseDouble
(
filterCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
else
{
//没有比较组内平均值
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
<
Double
.
parseDouble
(
calResult
.
getAverage
()))
{
filterCalResults
.
add
(
calResult
);
}
else
{
//获取差值绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
filterCalResult
.
getAverage
())
-
Double
.
parseDouble
(
filterCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
}
}
}
//分析filterCalResults
for
(
DriveIndCalResultDef
filterCalResult
:
filterCalResults
)
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
//获取差值绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
filterCalResult
.
getActualAverage
())
-
Double
.
parseDouble
(
filterCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
else
{
//获取差值绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
filterCalResult
.
getAverage
())
-
Double
.
parseDouble
(
filterCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
}
else
{
//百分比
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
filterCalResult
.
getValue
(),
filterCalResult
.
getActualAverage
(),
"1"
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
else
{
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
filterCalResult
.
getValue
(),
filterCalResult
.
getAverage
(),
"1"
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
else
{
//百分比
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
filterCalResult
.
getValue
(),
filterCalResult
.
getActualAverage
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
else
{
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
filterCalResult
.
getValue
(),
filterCalResult
.
getAverage
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
}
}
...
...
@@ -267,34 +276,38 @@ public class ShortboardRuleService {
//短板筛选规则为最大值
private
List
<
DriveIndCalResultDef
>
selectMaxShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//获取排名第一的最大值
String
maxValue
=
null
;
if
(!
calResults
.
isEmpty
())
{
maxValue
=
calResults
.
get
(
0
).
getValue
();
}
if
(
maxValue
!=
null
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
maxValue
)-
Double
.
parseDouble
(
calResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
maxValue
,
calResult
.
getValue
(),
"1"
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
//获取排名第一的最大值
String
maxValue
=
null
;
if
(!
calResults
.
isEmpty
())
{
maxValue
=
calResults
.
get
(
0
).
getValue
();
}
if
(
maxValue
!=
null
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
maxValue
)-
Double
.
parseDouble
(
calResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
maxValue
,
calResult
.
getValue
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
}
}
}
}
...
...
@@ -306,40 +319,44 @@ public class ShortboardRuleService {
//短板筛选规则为最小值
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
<>();
//用于保存符合过滤条件的指标结果
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
//根据考核指标id,日期和对标对象获取对标结果
//获取最小值
String
minValue
=
null
;
if
(!
calResults
.
isEmpty
())
{
for
(
int
i
=(
calResults
.
size
()-
1
);
i
>=
0
;
i
--)
{
if
(!
"NaN"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"Infinite"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"0.0000"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"0"
.
equals
(
calResults
.
get
(
i
).
getValue
()))
{
minValue
=
calResults
.
get
(
i
).
getValue
();
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"indId"
,
driveId
);
paramMap
.
put
(
"date"
,
date
);
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
//根据考核指标id,日期和对标对象获取对标结果
//获取最小值
String
minValue
=
null
;
if
(!
calResults
.
isEmpty
())
{
for
(
int
i
=(
calResults
.
size
()-
1
);
i
>=
0
;
i
--)
{
if
(!
"NaN"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"Infinite"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"0.0000"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"0"
.
equals
(
calResults
.
get
(
i
).
getValue
()))
{
minValue
=
calResults
.
get
(
i
).
getValue
();
}
}
}
}
if
(
minValue
!=
null
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
calResult
.
getValue
())-
Double
.
parseDouble
(
minValue
));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
calResult
.
getValue
(),
minValue
,
"1"
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
if
(
minValue
!=
null
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
calResult
.
getValue
())-
Double
.
parseDouble
(
minValue
));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
calResult
.
getValue
(),
minValue
,
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
}
}
}
}
...
...
@@ -386,59 +403,65 @@ public class ShortboardRuleService {
//短板筛选规则为历史同期
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
<>();
for
(
String
compareObj
:
compareObjs
)
{
//获取本期
DriveIndCalResultDef
currentIndCalResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
driveId
,
date
,
compareObj
);
//获取同期
DriveIndCalResultDef
sameIndCalResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
driveId
,(
date
-
100
),
compareObj
);
if
(
currentIndCalResult
!=
null
&&
sameIndCalResult
!=
null
)
{
if
(!
"NaN"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0"
.
equals
(
currentIndCalResult
.
getValue
()))
{
if
(!
"NaN"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"0"
.
equals
(
sameIndCalResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//判断规则选择是大于还是小于
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())>
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//大于历史同期
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())-
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
currentIndCalResult
.
getValue
(),
sameIndCalResult
.
getValue
(),
"1"
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
driveIndDef
!=
null
)
{
for
(
String
compareObj
:
compareObjs
)
{
//获取本期
DriveIndCalResultDef
currentIndCalResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
driveId
,
date
,
compareObj
);
//获取同期
DriveIndCalResultDef
sameIndCalResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
driveId
,(
date
-
100
),
compareObj
);
if
(
currentIndCalResult
!=
null
&&
sameIndCalResult
!=
null
)
{
if
(!
"NaN"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0"
.
equals
(
currentIndCalResult
.
getValue
()))
{
if
(!
"NaN"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"0"
.
equals
(
sameIndCalResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//判断规则选择是大于还是小于
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())>
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//大于历史同期
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())-
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
currentIndCalResult
.
getValue
(),
sameIndCalResult
.
getValue
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
}
}
}
}
else
{
//小于
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())<
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//小于历史同期
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
sameIndCalResult
.
getValue
())-
Double
.
parseDouble
(
currentIndCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
sameIndCalResult
.
getValue
(),
currentIndCalResult
.
getValue
(),
"1"
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
else
{
//小于
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())<
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//小于历史同期
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
sameIndCalResult
.
getValue
())-
Double
.
parseDouble
(
currentIndCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
}
else
{
//百分比
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
sameIndCalResult
.
getValue
(),
currentIndCalResult
.
getValue
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
}
}
}
...
...
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
dc60ded3
package
com
.
keymobile
.
indicators
.
utils
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
...
...
@@ -18,19 +17,15 @@ import com.googlecode.aviator.AviatorEvaluator;
public
class
CalculateUtils
{
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
=
""
;
StringBuilder
formula
=
new
StringBuilder
();
if
(!
"NaN"
.
equals
(
currentValue
)
&&
!
"Infinite"
.
equals
(
currentValue
)
&&
!
"NaN"
.
equals
(
sameValue
)
&&
!
"Infinite"
.
equals
(
sameValue
))
{
Object
value
=
null
;
if
(
"0"
.
equals
(
type
))
{
if
(
"%"
.
equals
(
unit
))
{
formula
.
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
);
}
else
{
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
}
formula
.
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
);
}
else
{
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
...
...
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