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 {
...
@@ -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,122 +119,124 @@ public class IndScorecardService {
...
@@ -119,122 +119,124 @@ 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
unit
=
driveIndDef
.
getIndUnit
();
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
(
currentCompareObjResult
!=
null
)
{
List
<
DriveIndCalResultDef
>
currentDriveResult
=
driveIndCalResultDefMapper
String
average
=
currentCompareObjResult
.
getAverage
();
.
findByIndIdAndDateAndCompareIdAndSort
(
indId
,
date
,
compareId
);
//如果实际平均值存在
if
(!
currentDriveResult
.
isEmpty
())
{
if
(
currentCompareObjResult
.
getActualAverage
()!=
null
)
{
//过滤考核指标结果集无效值
if
(!
"0.0"
.
equals
(
currentCompareObjResult
.
getActualAverage
()))
{
Iterator
<
DriveIndCalResultDef
>
it
=
currentDriveResult
.
iterator
();
average
=
currentCompareObjResult
.
getActualAverage
();
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
();
int
currentDriveResultSize
=
currentDriveResult
.
size
();
if
(!
"NaN"
.
equals
(
value
)
&&
!
"Infinite"
.
equals
(
value
)
//根据indId,date,compareObj获取考核结果
&&
!
"0.0000"
.
equals
(
value
)
&&
!
"0"
.
equals
(
value
))
{
DriveIndCalResultDef
currentCompareObjResult
=
driveIndCalResultDefMapper
//综合评价
.
findByIndIdAndDateAndCompareObj
(
indId
,
date
,
compareObj
);
if
(
"0"
.
equals
(
scoreCard
.
getScoreType
()))
{
//定义
baseScoreValue
=
scoreCard
.
getIndBaseScore
();
//基础分
if
(
currentCompareObjResult
!=
null
)
{
String
average
=
currentCompareObjResult
.
getAverage
();
//如果是反向指标(越小越好)
//如果实际平均值存在
if
(
"1"
.
equals
(
acsType
))
{
if
(
currentCompareObjResult
.
getActualAverage
()!=
null
)
{
if
(
Double
.
valueOf
(
value
)<
Double
.
valueOf
(
average
))
{
//大于组内平均分
if
(!
"0.0"
.
equals
(
currentCompareObjResult
.
getActualAverage
()))
{
baseScoreValue
+=
scoreCard
.
getMoreAverage
();
average
=
currentCompareObjResult
.
getActualAverage
();
}
else
{
baseScoreValue
-=
scoreCard
.
getLessAverage
();
}
}
else
{
//正向指标,越大越好
if
(
Double
.
valueOf
(
value
)>
Double
.
valueOf
(
average
))
{
//大于组内平均分
baseScoreValue
+=
scoreCard
.
getMoreAverage
();
}
else
{
baseScoreValue
-=
scoreCard
.
getLessAverage
();
}
}
}
}
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
String
value
=
currentCompareObjResult
.
getValue
();
//加分项
if
(!
"NaN"
.
equals
(
value
)
&&
!
"Infinite"
.
equals
(
value
)
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getAddScoreItemJson
()))
{
&&
!
"0.0000"
.
equals
(
value
)
&&
!
"0"
.
equals
(
value
))
{
List
<
RankScoreDef
>
addScoreItem
=
gson
.
//综合评价
fromJson
(
scoreCard
.
getAddScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
if
(
"0"
.
equals
(
scoreCard
.
getScoreType
()))
{
//定义
for
(
RankScoreDef
scoreDef
:
addScoreItem
)
{
baseScoreValue
=
scoreCard
.
getIndBaseScore
();
//基础分
if
(
scoreDef
.
getRank
()==
rank
)
{
baseScoreValue
+=
scoreDef
.
getScore
();
//如果是反向指标(越小越好)
break
;
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
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getMinusScoreItemJson
()))
{
//加分项
List
<
RankScoreDef
>
minusScoreItem
=
gson
.
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getAddScoreItemJson
()))
{
fromJson
(
scoreCard
.
getMinusScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
List
<
RankScoreDef
>
addScoreItem
=
gson
.
rank
=
currentDriveResultSize
-
rank
+
1
;
fromJson
(
scoreCard
.
getAddScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
for
(
RankScoreDef
scoreDef
:
minusScoreItem
)
{
for
(
RankScoreDef
scoreDef
:
addScoreItem
)
{
if
(
scoreDef
.
getRank
()==
rank
)
{
if
(
scoreDef
.
getRank
()==
rank
)
{
baseScoreValue
-=
scoreDef
.
getScore
();
baseScoreValue
+=
scoreDef
.
getScore
();
break
;
break
;
}
}
}
}
}
}
//减分项
}
else
{
//公式
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getMinusScoreItemJson
()))
{
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
List
<
RankScoreDef
>
minusScoreItem
=
gson
.
if
(
rank
==
1
)
{
//最佳指标
fromJson
(
scoreCard
.
getMinusScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
baseScoreValue
=
scoreCard
.
getBestIndScore
();
rank
=
currentDriveResultSize
-
rank
+
1
;
}
else
if
(
rank
==
currentDriveResultSize
)
{
//最差指标
for
(
RankScoreDef
scoreDef
:
minusScoreItem
)
{
baseScoreValue
=
scoreCard
.
getWorstIndScore
();
if
(
scoreDef
.
getRank
()==
rank
)
{
}
else
{
//其他
baseScoreValue
-=
scoreDef
.
getScore
();
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getOtherCalFormula
()))
{
break
;
baseScoreValue
=
this
.
getValueFromFormula
(
}
scoreCard
.
getOtherCalFormula
(),
currentCompareObjResult
,
}
currentDriveResult
,
acsType
);
}
}
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
()))
{
//纳入单位得分计算
if
(
"1"
.
equals
(
scoreCard
.
getIsIncluScore
()))
{
//纳入单位得分计算
//同期
//同期
DriveIndCalResultDef
sameCompareObjResult
=
driveIndCalResultDefMapper
DriveIndCalResultDef
sameCompareObjResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
indId
,
(
date
-
100
),
compareObj
);
.
findByIndIdAndDateAndCompareObj
(
indId
,
(
date
-
100
),
compareObj
);
if
(
sameCompareObjResult
!=
null
)
{
if
(
sameCompareObjResult
!=
null
)
{
List
<
ImproveScoreDef
>
importScoreDefList
=
new
ArrayList
<>();
List
<
ImproveScoreDef
>
importScoreDefList
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getImproveScoreItemJson
()))
{
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getImproveScoreItemJson
()))
{
importScoreDefList
=
gson
.
importScoreDefList
=
gson
.
fromJson
(
scoreCard
.
getImproveScoreItemJson
(),
fromJson
(
scoreCard
.
getImproveScoreItemJson
(),
new
TypeToken
<
List
<
ImproveScoreDef
>>(){}.
getType
());
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
();
}
}
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
));
}
else
{
result
.
put
(
"improveScore"
,
indImproveScoreValue
);
result
.
put
(
"improveScore"
,
"No"
);
//表示不纳入单位得分计算标识
}
}
}
else
{
result
.
put
(
"improveScore"
,
"No"
);
//表示不纳入单位得分计算标识
}
}
}
}
}
else
{
}
else
{
...
@@ -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,37 +525,41 @@ public class IndicatorsValueService {
...
@@ -523,37 +525,41 @@ public class IndicatorsValueService {
}
}
//根据考核指标id获取本期和同期的指标值
//根据考核指标id获取本期和同期的指标值
for
(
String
indId
:
indIds
)
{
for
(
String
indId
:
indIds
)
{
List
<
DriveIndCalResultDef
>
driveResult
=
driveIndCalResultDefMapper
.
findByIndId
(
indId
);
DriveIndDef
deiveIndDef
=
driveIndDefService
.
getById
(
indId
);
for
(
DriveIndCalResultDef
result
:
driveResult
)
{
if
(
deiveIndDef
!=
null
)
{
String
region
=
result
.
getCompareObj
();
List
<
DriveIndCalResultDef
>
driveResult
=
driveIndCalResultDefMapper
.
findByIndId
(
indId
);
if
(
rowMap
.
get
(
region
)!=
null
)
{
for
(
DriveIndCalResultDef
result
:
driveResult
)
{
XSSFRow
row
=
excelSheet
.
getRow
(
rowMap
.
get
(
region
));
String
region
=
result
.
getCompareObj
();
if
(
result
.
getDate
()==
201912
)
{
if
(
rowMap
.
get
(
region
)!=
null
)
{
row
.
getCell
(
cellMap
.
get
(
indId
)).
setCellValue
(
result
.
getValue
());
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
{
}
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
=
""
;
if
(
result
.
getDate
()==
201912
)
{
//算增幅
String
currentValue
=
""
;
List
<
DriveIndCalResultDef
>
gowthValues
=
driveIndCalResultDefMapper
String
sameValue
=
""
;
.
findByIndIdAndCompareObj
(
indId
,
region
);
//算增幅
for
(
DriveIndCalResultDef
gowth
:
gowthValues
)
{
List
<
DriveIndCalResultDef
>
gowthValues
=
driveIndCalResultDefMapper
if
(
gowth
.
getDate
()==
201912
)
{
.
findByIndIdAndCompareObj
(
indId
,
region
);
currentValue
=
gowth
.
getValue
();
for
(
DriveIndCalResultDef
gowth
:
gowthValues
)
{
}
else
{
if
(
gowth
.
getDate
()==
201912
)
{
sameValue
=
gowth
.
getValue
();
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;
...
@@ -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,84 +182,90 @@ public class ShortboardRuleService {
...
@@ -179,84 +182,90 @@ 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
{
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
>
filterCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
filterCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
//根据考核指标id获取考核指标
//判断规则选择是大于还是小于
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(
driveIndDef
!=
null
)
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
paramMap
.
put
(
"indId"
,
driveId
);
//判断有没有实际的平均值
paramMap
.
put
(
"date"
,
date
);
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
>
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
Double
.
parseDouble
(
calResult
.
getActualAverage
()))
{
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
filterCalResults
.
add
(
calResult
);
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
())
>
}
else
{
//小于
Double
.
parseDouble
(
calResult
.
getAverage
()))
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
filterCalResults
.
add
(
calResult
);
&&
!
"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
())
//分析filterCalResults
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
for
(
DriveIndCalResultDef
filterCalResult
:
filterCalResults
)
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
//判断有没有实际的平均值
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
<
//获取差值绝对值
Double
.
parseDouble
(
calResult
.
getActualAverage
()))
{
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
filterCalResult
.
getActualAverage
())
filterCalResults
.
add
(
calResult
);
-
Double
.
parseDouble
(
filterCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
}
else
{
//没有比较组内平均值
}
else
{
if
(
Double
.
parseDouble
(
calResult
.
getValue
())
<
//获取差值绝对值
Double
.
parseDouble
(
calResult
.
getAverage
()))
{
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
filterCalResult
.
getAverage
())
filterCalResults
.
add
(
calResult
);
-
Double
.
parseDouble
(
filterCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
filterCalResult
);
}
}
}
}
}
}
else
{
//百分比
}
//判断有没有实际的平均值
}
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
//分析filterCalResults
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
for
(
DriveIndCalResultDef
filterCalResult
:
filterCalResults
)
{
filterCalResult
.
getValue
(),
filterCalResult
.
getActualAverage
(),
//判断是比较差还是百分比
driveIndDef
.
getGrowCalType
())));
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
//判断有没有实际的平均值
realCalResults
.
add
(
filterCalResult
);
if
(!
"0.0"
.
equals
(
filterCalResult
.
getActualAverage
()))
{
}
//获取差值绝对值
}
else
{
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
filterCalResult
.
getActualAverage
())
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
-
Double
.
parseDouble
(
filterCalResult
.
getValue
()));
filterCalResult
.
getValue
(),
filterCalResult
.
getAverage
(),
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
driveIndDef
.
getGrowCalType
())));
realCalResults
.
add
(
filterCalResult
);
if
(
percentage
>
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
);
}
}
}
}
}
}
...
@@ -267,34 +276,38 @@ public class ShortboardRuleService {
...
@@ -267,34 +276,38 @@ public class ShortboardRuleService {
//短板筛选规则为最大值
//短板筛选规则为最大值
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
{
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
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//获取排名第一的最大值
//根据考核指标id获取考核指标
String
maxValue
=
null
;
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
if
(!
calResults
.
isEmpty
())
{
if
(
driveIndDef
!=
null
)
{
maxValue
=
calResults
.
get
(
0
).
getValue
();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
}
paramMap
.
put
(
"indId"
,
driveId
);
if
(
maxValue
!=
null
)
{
paramMap
.
put
(
"date"
,
date
);
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//获取排名第一的最大值
//判断是比较差还是百分比
String
maxValue
=
null
;
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
if
(!
calResults
.
isEmpty
())
{
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
maxValue
)-
Double
.
parseDouble
(
calResult
.
getValue
()));
maxValue
=
calResults
.
get
(
0
).
getValue
();
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
}
realCalResults
.
add
(
calResult
);
if
(
maxValue
!=
null
)
{
}
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
}
else
{
//百分比
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
maxValue
,
calResult
.
getValue
(),
"1"
)));
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
//判断是比较差还是百分比
realCalResults
.
add
(
calResult
);
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 {
...
@@ -306,40 +319,44 @@ public class ShortboardRuleService {
//短板筛选规则为最小值
//短板筛选规则为最小值
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
<>();
//用于保存符合过滤条件的指标结果
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
//根据考核指标id获取考核指标
paramMap
.
put
(
"indId"
,
driveId
);
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
paramMap
.
put
(
"date"
,
date
);
if
(
driveIndDef
!=
null
)
{
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
paramMap
.
put
(
"indId"
,
driveId
);
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
//根据考核指标id,日期和对标对象获取对标结果
paramMap
.
put
(
"date"
,
date
);
//获取最小值
paramMap
.
put
(
"compareObjs"
,
compareObjs
);
String
minValue
=
null
;
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
if
(!
calResults
.
isEmpty
())
{
findByIndIdAndDateAndCompareObjIn
(
paramMap
);
//根据考核指标id,日期和对标对象获取对标结果
for
(
int
i
=(
calResults
.
size
()-
1
);
i
>=
0
;
i
--)
{
//获取最小值
if
(!
"NaN"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"Infinite"
.
equals
(
calResults
.
get
(
i
).
getValue
())
String
minValue
=
null
;
&&
!
"0.0000"
.
equals
(
calResults
.
get
(
i
).
getValue
())
&&
!
"0"
.
equals
(
calResults
.
get
(
i
).
getValue
()))
{
if
(!
calResults
.
isEmpty
())
{
minValue
=
calResults
.
get
(
i
).
getValue
();
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
)
{
if
(
minValue
!=
null
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
//判断是比较差还是百分比
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
calResult
.
getValue
())-
Double
.
parseDouble
(
minValue
));
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
calResult
.
getValue
())-
Double
.
parseDouble
(
minValue
));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
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
,
driveIndDef
.
getGrowCalType
())));
calResult
.
getValue
(),
minValue
,
"1"
)));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
calResult
);
realCalResults
.
add
(
calResult
);
}
}
}
}
}
}
}
...
@@ -386,59 +403,65 @@ public class ShortboardRuleService {
...
@@ -386,59 +403,65 @@ 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
<>();
for
(
String
compareObj
:
compareObjs
)
{
//根据考核指标id获取考核指标
//获取本期
DriveIndDef
driveIndDef
=
driveIndDefService
.
getById
(
driveId
);
DriveIndCalResultDef
currentIndCalResult
=
driveIndCalResultDefMapper
.
if
(
driveIndDef
!=
null
)
{
findByIndIdAndDateAndCompareObj
(
driveId
,
date
,
compareObj
);
for
(
String
compareObj
:
compareObjs
)
{
//获取同期
//获取本期
DriveIndCalResultDef
sameIndCalResult
=
driveIndCalResultDefMapper
.
DriveIndCalResultDef
currentIndCalResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
driveId
,(
date
-
100
),
compareObj
);
findByIndIdAndDateAndCompareObj
(
driveId
,
date
,
compareObj
);
if
(
currentIndCalResult
!=
null
&&
sameIndCalResult
!=
null
)
{
//获取同期
if
(!
"NaN"
.
equals
(
currentIndCalResult
.
getValue
())
&&
DriveIndCalResultDef
sameIndCalResult
=
driveIndCalResultDefMapper
.
!
"Infinite"
.
equals
(
currentIndCalResult
.
getValue
())
&&
findByIndIdAndDateAndCompareObj
(
driveId
,(
date
-
100
),
compareObj
);
!
"0.0000"
.
equals
(
currentIndCalResult
.
getValue
())
&&
if
(
currentIndCalResult
!=
null
&&
sameIndCalResult
!=
null
)
{
!
"0"
.
equals
(
currentIndCalResult
.
getValue
()))
{
if
(!
"NaN"
.
equals
(
currentIndCalResult
.
getValue
())
&&
if
(!
"NaN"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"0"
.
equals
(
currentIndCalResult
.
getValue
()))
{
!
"0"
.
equals
(
sameIndCalResult
.
getValue
()))
{
if
(!
"NaN"
.
equals
(
sameIndCalResult
.
getValue
())
&&
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
!
"Infinite"
.
equals
(
sameIndCalResult
.
getValue
())
&&
//判断规则选择是大于还是小于
!
"0.0000"
.
equals
(
sameIndCalResult
.
getValue
())
&&
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
!
"0"
.
equals
(
sameIndCalResult
.
getValue
()))
{
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())>
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//大于历史同期
//判断规则选择是大于还是小于
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())>
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())-
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//大于历史同期
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()));
//判断是比较差还是百分比
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
realCalResults
.
add
(
currentIndCalResult
);
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())-
}
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()));
}
else
{
//百分比
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
"%"
,
realCalResults
.
add
(
currentIndCalResult
);
currentIndCalResult
.
getValue
(),
sameIndCalResult
.
getValue
(),
"1"
)));
}
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
}
else
{
//百分比
realCalResults
.
add
(
currentIndCalResult
);
Double
percentage
=
Math
.
abs
(
Double
.
parseDouble
(
CalculateUtils
.
calGowth
(
currentIndCalResult
.
getValue
(),
sameIndCalResult
.
getValue
(),
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
}
}
}
}
}
}
}
else
{
//小于
}
else
{
//小于
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())<
if
(
Double
.
parseDouble
(
currentIndCalResult
.
getValue
())<
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//小于历史同期
Double
.
parseDouble
(
sameIndCalResult
.
getValue
()))
{
//小于历史同期
//判断是比较差还是百分比
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
sameIndCalResult
.
getValue
())-
Double
differ
=
Math
.
abs
(
Double
.
parseDouble
(
sameIndCalResult
.
getValue
())-
Double
.
parseDouble
(
currentIndCalResult
.
getValue
()));
Double
.
parseDouble
(
currentIndCalResult
.
getValue
()));
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
differ
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
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
(),
sameIndCalResult
.
getValue
(),
currentIndCalResult
.
getValue
(),
"1"
)));
driveIndDef
.
getGrowCalType
())));
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
if
(
percentage
>
Double
.
parseDouble
(
shortboardItem
.
getValue
()))
{
realCalResults
.
add
(
currentIndCalResult
);
realCalResults
.
add
(
currentIndCalResult
);
}
}
}
}
}
}
}
...
...
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,19 +17,15 @@ import com.googlecode.aviator.AviatorEvaluator;
...
@@ -18,19 +17,15 @@ 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
{
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
}
}
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"
);
...
...
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