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
ef0e6c27
Commit
ef0e6c27
authored
Jun 16, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化考核指标计算逻辑
parent
7587d22b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
92 deletions
+111
-92
DriveIndCalculateActor.java
...ymobile/indicators/akka/actor/DriveIndCalculateActor.java
+9
-2
DriveIndCalculateRegionActor.java
...ors/akka/actor/specific/DriveIndCalculateRegionActor.java
+46
-44
IndicatorsValueService.java
.../indicators/service/hytobacco/IndicatorsValueService.java
+22
-18
ScoreRuleService.java
...mobile/indicators/service/hytobacco/ScoreRuleService.java
+9
-7
ShortboardRuleService.java
...e/indicators/service/hytobacco/ShortboardRuleService.java
+1
-1
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+24
-20
No files found.
src/main/java/com/keymobile/indicators/akka/actor/DriveIndCalculateActor.java
View file @
ef0e6c27
...
...
@@ -166,8 +166,15 @@ public class DriveIndCalculateActor extends AbstractActor{
unit
,
indType
,
markType
,
averageDriveIndFormula
);
driveIndCalculateRegionActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
}
catch
(
Exception
e
)
{
DriveIndCalResultDef
driveIndCalResult
=
new
DriveIndCalResultDef
(
compareId
,
driveIndId
,
compareObj
,
date
,
"NaN"
,
unit
,
"1"
,
"0"
,
"admin"
);
//判断结果表中是否已存在该结果数据,存在则覆盖
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findCalResultDataIsExist
(
compareId
,
compareObj
,
driveIndId
,
date
);
if
(
driveIndCalResult
==
null
)
{
driveIndCalResult
=
new
DriveIndCalResultDef
(
compareId
,
driveIndId
,
compareObj
,
date
,
"NaN"
,
unit
,
"1"
,
"0"
,
"admin"
);
}
else
{
driveIndCalResult
.
setValue
(
"NaN"
);
}
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
DriveIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
new
DriveIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
...
...
src/main/java/com/keymobile/indicators/akka/actor/specific/DriveIndCalculateRegionActor.java
View file @
ef0e6c27
...
...
@@ -76,51 +76,53 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
compareObjs
.
add
(
driveIndAverageAndRankMsg
.
getCompareObj
());
}
if
(++
numberOfConfirm
>=
compareObjSize
)
{
//子actor全部返回
//考核地区只有一个“全省”的情况下
if
(!
"全省"
.
equals
(
driveIndAverageAndRankMsg
.
getCompareObj
()))
{
//查询有没有全省的考核指标数据
DriveIndCalResultDef
provinceDriveIndCalResult
=
driveIndCalResultService
.
findCompareObjInfo
(
driveIndAverageAndRankMsg
.
getDriveIndId
(),
driveIndAverageAndRankMsg
.
getDate
(),
"全省"
);
String
actualAverage
=
"0.0"
;
if
(
provinceDriveIndCalResult
!=
null
)
{
//获取实际平均分
actualAverage
=
provinceDriveIndCalResult
.
getValue
();
}
//算组内平均数
//String average = CalculateUtils.averageValue(values);
String
average
=
driveIndDefService
.
calGroupAverage
(
driveIndAverageAndRankMsg
.
getIndFormula
(),
compareObjs
,
driveIndAverageAndRankMsg
.
getDate
());
//算组内排名
Map
<
String
,
Integer
>
rankValue
=
CalculateUtils
.
rankValue
(
valueMap
,
indType
);
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
//根据id获取指标值结果
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
if
(
driveIndCalResult
!=
null
)
{
driveIndCalResult
.
setAverage
(
average
);
driveIndCalResult
.
setRank
(
entry
.
getValue
());
driveIndCalResult
.
setActualAverage
(
actualAverage
);
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
if
(!
valueMap
.
isEmpty
()
&&
!
compareObjs
.
isEmpty
())
{
//考核地区只有一个“全省”的情况下
if
(!
"全省"
.
equals
(
driveIndAverageAndRankMsg
.
getCompareObj
()))
{
//查询有没有全省的考核指标数据
DriveIndCalResultDef
provinceDriveIndCalResult
=
driveIndCalResultService
.
findCompareObjInfo
(
driveIndAverageAndRankMsg
.
getDriveIndId
(),
driveIndAverageAndRankMsg
.
getDate
(),
"全省"
);
String
actualAverage
=
"0.0"
;
if
(
provinceDriveIndCalResult
!=
null
)
{
//获取实际平均分
actualAverage
=
provinceDriveIndCalResult
.
getValue
();
}
//算组内平均数
//String average = CalculateUtils.averageValue(values);
String
average
=
driveIndDefService
.
calGroupAverage
(
driveIndAverageAndRankMsg
.
getIndFormula
(),
compareObjs
,
driveIndAverageAndRankMsg
.
getDate
());
//算组内排名
Map
<
String
,
Integer
>
rankValue
=
CalculateUtils
.
rankValue
(
valueMap
,
indType
);
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
//根据id获取指标值结果
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
if
(
driveIndCalResult
!=
null
)
{
driveIndCalResult
.
setAverage
(
average
);
driveIndCalResult
.
setRank
(
entry
.
getValue
());
driveIndCalResult
.
setActualAverage
(
actualAverage
);
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
}
}
//根据评分卡算指标分数
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
//根据id获取指标值结果
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
if
(
driveIndCalResult
!=
null
)
{
//计算分数
Map
<
String
,
String
>
scoreMap
=
indScorecardService
.
calculateIndiScore
(
driveIndCalResult
.
getIndId
(),
driveIndCalResult
.
getDate
(),
driveIndCalResult
.
getCompareObj
(),
markType
,
driveIndCalResult
.
getCompareId
(),
compareObjs
);
driveIndCalResult
.
setScore
(
scoreMap
.
get
(
"score"
));
driveIndCalResult
.
setImproveScore
(
scoreMap
.
get
(
"improveScore"
));
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
}
}
}
//根据评分卡算指标分数
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
//根据id获取指标值结果
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
if
(
driveIndCalResult
!=
null
)
{
//计算分数
Map
<
String
,
String
>
scoreMap
=
indScorecardService
.
calculateIndiScore
(
driveIndCalResult
.
getIndId
(),
driveIndCalResult
.
getDate
(),
driveIndCalResult
.
getCompareObj
(),
markType
,
driveIndCalResult
.
getCompareId
(),
compareObjs
);
driveIndCalResult
.
setScore
(
scoreMap
.
get
(
"score"
));
driveIndCalResult
.
setImproveScore
(
scoreMap
.
get
(
"improveScore"
));
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
}
}
}
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsValueService.java
View file @
ef0e6c27
...
...
@@ -697,15 +697,17 @@ public class IndicatorsValueService {
currentDriveResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndSortAndActualAverageIsNotNull
(
indId
,
date
);
}
//去除无效值
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
();
}
}
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
();
}
}
}
//同期考核结果
List
<
DriveIndCalResultDef
>
sameDriveResult
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
compareId
))
{
...
...
@@ -721,15 +723,17 @@ public class IndicatorsValueService {
sameDriveResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndSortAndActualAverageIsNotNull
(
indId
,
date
);
}
//去除无效值
Iterator
<
DriveIndCalResultDef
>
sit
=
sameDriveResult
.
iterator
();
while
(
sit
.
hasNext
()){
DriveIndCalResultDef
driveCalResult
=
sit
.
next
();
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"Infinite"
.
equals
(
driveCalResult
.
getValue
())
||
"0.0000"
.
equals
(
driveCalResult
.
getValue
())||
"0"
.
equals
(
driveCalResult
.
getValue
())){
sit
.
remove
();
}
}
if
(!
sameDriveResult
.
isEmpty
())
{
//去除无效值
Iterator
<
DriveIndCalResultDef
>
sit
=
sameDriveResult
.
iterator
();
while
(
sit
.
hasNext
()){
DriveIndCalResultDef
driveCalResult
=
sit
.
next
();
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"Infinite"
.
equals
(
driveCalResult
.
getValue
())
||
"0.0000"
.
equals
(
driveCalResult
.
getValue
())||
"0"
.
equals
(
driveCalResult
.
getValue
())){
sit
.
remove
();
}
}
}
if
(!
currentDriveResult
.
isEmpty
())
{
result
.
put
(
"average"
,
currentDriveResult
.
get
(
0
).
getAverage
());
if
(!
"0.0"
.
equals
(
currentDriveResult
.
get
(
0
).
getActualAverage
()))
{
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ScoreRuleService.java
View file @
ef0e6c27
...
...
@@ -236,13 +236,15 @@ public class ScoreRuleService {
findByCompareObjAndDate
(
compareObj
,
date
);
double
scoreValue
=
0.0
;
double
improveValue
=
0.0
;
if
(
StringUtils
.
isNotBlank
(
scoreRule
.
getIndTypeWeightsJson
()))
{
List
<
IndTypeWeight
>
indTypeWeights
=
gson
.
fromJson
(
scoreRule
.
getIndTypeWeightsJson
(),
new
TypeToken
<
List
<
IndTypeWeight
>>(){}.
getType
());
for
(
IndTypeWeight
indTypeWeight
:
indTypeWeights
)
{
Map
<
String
,
Double
>
calScores
=
this
.
calIndTypeScore
(
scoreRule
,
indTypeWeight
,
calResults
);
scoreValue
+=
(
calScores
.
get
(
"score"
)*
Double
.
parseDouble
(
indTypeWeight
.
getWeight
()));
improveValue
+=
(
calScores
.
get
(
"improve"
)*
Double
.
parseDouble
(
indTypeWeight
.
getWeight
()));
if
(!
calResults
.
isEmpty
())
{
if
(
StringUtils
.
isNotBlank
(
scoreRule
.
getIndTypeWeightsJson
()))
{
List
<
IndTypeWeight
>
indTypeWeights
=
gson
.
fromJson
(
scoreRule
.
getIndTypeWeightsJson
(),
new
TypeToken
<
List
<
IndTypeWeight
>>(){}.
getType
());
for
(
IndTypeWeight
indTypeWeight
:
indTypeWeights
)
{
Map
<
String
,
Double
>
calScores
=
this
.
calIndTypeScore
(
scoreRule
,
indTypeWeight
,
calResults
);
scoreValue
+=
(
calScores
.
get
(
"score"
)*
Double
.
parseDouble
(
indTypeWeight
.
getWeight
()));
improveValue
+=
(
calScores
.
get
(
"improve"
)*
Double
.
parseDouble
(
indTypeWeight
.
getWeight
()));
}
}
}
result
.
put
(
"scoreValue"
,
String
.
valueOf
(
scoreValue
));
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ShortboardRuleService.java
View file @
ef0e6c27
...
...
@@ -236,7 +236,7 @@ public class ShortboardRuleService {
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//获取排名第一的最大值
String
maxValue
=
null
;
if
(!
realC
alResults
.
isEmpty
())
{
if
(!
c
alResults
.
isEmpty
())
{
maxValue
=
calResults
.
get
(
0
).
getValue
();
}
if
(
maxValue
!=
null
)
{
...
...
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
ef0e6c27
...
...
@@ -98,10 +98,14 @@ public class CalculateUtils {
headIndValue
=
entry
.
getValue
();
}
order
+=
1
;
if
(!
invalidMap
.
isEmpty
())
{
if
(!
invalidMap
.
isEmpty
()
&&
!
compareMap
.
isEmpty
()
)
{
for
(
Entry
<
String
,
String
>
entry
:
invalidMap
.
entrySet
())
{
result
.
put
(
entry
.
getKey
(),
order
);
}
}
else
{
for
(
Entry
<
String
,
String
>
entry
:
invalidMap
.
entrySet
())
{
result
.
put
(
entry
.
getKey
(),
0
);
}
}
return
result
;
}
...
...
@@ -214,18 +218,18 @@ public class CalculateUtils {
}
public
static
void
main
(
String
[]
args
)
{
//
Map<String,String> map = new HashMap<>();
// map.put("1001", "1
");
// map.put("1002", "3
");
// map.put("1003", "2
");
// map.put("1004", "4
");
// map.put("1005", "8
");
// map.put("1006", "6
");
// map.put("1007", "7
");
// map.put("1008", "5
");
//
CalculateUtils cal = new CalculateUtils();
//
Map<String,Integer> result = cal.rankValue(map, "1");
//
System.out.println(result);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"1001"
,
"NaN
"
);
map
.
put
(
"1002"
,
"NaN
"
);
map
.
put
(
"1003"
,
"NaN
"
);
map
.
put
(
"1004"
,
"NaN
"
);
map
.
put
(
"1005"
,
"NaN
"
);
map
.
put
(
"1006"
,
"NaN
"
);
map
.
put
(
"1007"
,
"NaN
"
);
map
.
put
(
"1008"
,
"NaN
"
);
CalculateUtils
cal
=
new
CalculateUtils
();
Map
<
String
,
Integer
>
result
=
cal
.
rankValue
(
map
,
"1"
);
System
.
out
.
println
(
result
);
//
// String formula = "([1001]+[1002])/2";
// formula = formula.replace("[1001]", "3");
...
...
@@ -234,12 +238,12 @@ public class CalculateUtils {
// System.out.println(result1);
// Double b = (double) Math.abs(34-50);
// System.out.println(b);
List
<
String
>
listA
=
new
ArrayList
<>();
listA
.
add
(
"a"
);
listA
.
add
(
"b"
);
listA
.
add
(
"c"
);
List
<
String
>
listB
=
new
ArrayList
<>();
listA
.
retainAll
(
listB
);
System
.
out
.
println
(
listA
);
//
List<String> listA = new ArrayList<>();
//
listA.add("a");
//
listA.add("b");
//
listA.add("c");
//
List<String> listB = new ArrayList<>();
//
listA.retainAll(listB);
//
System.out.println(listA);
}
}
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