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
8f2f3cee
Commit
8f2f3cee
authored
Jun 05, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化单位评分功能代码
parent
3a704693
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
77 deletions
+135
-77
ScoreRule.java
...obile/indicators/model/entity/objscorerule/ScoreRule.java
+2
-2
DriveIndCalResultRepository.java
...persistence/hyindicators/DriveIndCalResultRepository.java
+2
-0
ScoreRuleService.java
...mobile/indicators/service/hytobacco/ScoreRuleService.java
+131
-75
No files found.
src/main/java/com/keymobile/indicators/model/entity/objscorerule/ScoreRule.java
View file @
8f2f3cee
...
@@ -23,8 +23,8 @@ public class ScoreRule implements Serializable{
...
@@ -23,8 +23,8 @@ public class ScoreRule implements Serializable{
@Id
@Id
private
String
id
;
private
String
id
;
private
String
ruleName
;
//规则名称
private
String
ruleName
;
//规则名称
private
String
scoreType
;
//得分类型:0 指标值直接参与计算 1 指标得分分数参与计算(
包括综合评分和改善提升
)
private
String
scoreType
;
//得分类型:0 指标值直接参与计算 1 指标得分分数参与计算(
综合评分和改善提升分开算) 2指标得分分数参与计算(指标分数=综合+改善
)
private
String
calType
;
//计算类型:0 计算所有考核指标平均数 1 根据目录类别分类算平均分后根据权重计算考核指标
private
String
calType
;
//计算类型:0 计算
组内
所有考核指标平均数 1 根据目录类别分类算平均分后根据权重计算考核指标
private
List
<
IndTypeWeight
>
indTypeWeights
=
new
ArrayList
<>();
//目录类别权重数据
private
List
<
IndTypeWeight
>
indTypeWeights
=
new
ArrayList
<>();
//目录类别权重数据
private
String
code
;
//标识编码
private
String
code
;
//标识编码
...
...
src/main/java/com/keymobile/indicators/persistence/hyindicators/DriveIndCalResultRepository.java
View file @
8f2f3cee
...
@@ -31,4 +31,6 @@ public interface DriveIndCalResultRepository extends MongoRepository<DriveIndCal
...
@@ -31,4 +31,6 @@ public interface DriveIndCalResultRepository extends MongoRepository<DriveIndCal
public
List
<
DriveIndCalResult
>
findByIndIdAndDateAndCompareId
(
String
indId
,
int
date
,
String
compareId
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDateAndCompareId
(
String
indId
,
int
date
,
String
compareId
);
public
List
<
DriveIndCalResult
>
findByCompareObjAndDate
(
String
compareObj
,
int
date
);
public
List
<
DriveIndCalResult
>
findByCompareObjAndDate
(
String
compareObj
,
int
date
);
public
List
<
DriveIndCalResult
>
findByCompareObjAndDateAndIndIdIn
(
String
compareObj
,
int
date
,
List
<
String
>
indIds
);
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/ScoreRuleService.java
View file @
8f2f3cee
...
@@ -52,7 +52,130 @@ public class ScoreRuleService {
...
@@ -52,7 +52,130 @@ public class ScoreRuleService {
return
null
;
return
null
;
}
}
public
void
calObjScore
(
String
reportId
,
List
<
String
>
compareObjs
,
int
date
,
String
scoreRuleId
)
{
//计算组内考核指标平均值
private
Map
<
String
,
String
>
calGroupIndAverage
(
ScoreRule
scoreRule
,
List
<
String
>
indIds
,
String
compareObj
,
int
date
){
Map
<
String
,
String
>
result
=
new
HashMap
<>();
result
.
put
(
"compareObj"
,
compareObj
);
result
.
put
(
"scoreValue"
,
"0.0"
);
result
.
put
(
"improveValue"
,
"0.0"
);
result
.
put
(
"date"
,
String
.
valueOf
(
date
));
//根据日期,对标对象和考核的指标获取考核指标结果详情
List
<
DriveIndCalResult
>
calResults
=
driveIndCalResultRepo
.
findByCompareObjAndDateAndIndIdIn
(
compareObj
,
date
,
indIds
);
List
<
String
>
values
=
new
ArrayList
<>();
List
<
String
>
improveValues
=
new
ArrayList
<>();
if
(!
calResults
.
isEmpty
())
{
for
(
DriveIndCalResult
calResult
:
calResults
)
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
values
.
add
(
calResult
.
getValue
());
}
else
if
(
"1"
.
equals
(
scoreRule
.
getScoreType
()))
{
//1 指标得分分数参与计算(综合评分和改善提升分开算)
values
.
add
(
calResult
.
getScore
());
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
()))
{
improveValues
.
add
(
calResult
.
getImproveScore
());
}
}
else
{
//2指标得分分数参与计算(指标分数=综合+改善)
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
()))
{
double
indScore
=
Double
.
valueOf
(
calResult
.
getScore
());
double
improveScore
=
Double
.
valueOf
(
calResult
.
getImproveScore
());
double
sum
=
indScore
+
improveScore
;
values
.
add
(
String
.
valueOf
(
sum
));
}
else
{
values
.
add
(
calResult
.
getScore
());
}
}
}
//计算平均值
String
averageValue
=
CalculateUtils
.
averageValue
(
values
,
0
);
String
averageImproveValue
=
"0.0"
;
if
(!
improveValues
.
isEmpty
())
{
averageImproveValue
=
CalculateUtils
.
averageValue
(
improveValues
,
0
);
}
result
.
put
(
"scoreValue"
,
averageValue
);
result
.
put
(
"improveValue"
,
averageImproveValue
);
}
return
result
;
}
//按照指标类别进行分类分别计算平均分后再跟类别权重相乘后相加得到最终分数
private
Map
<
String
,
String
>
calIndCatalogTypeAverage
(
ScoreRule
scoreRule
,
String
compareObj
,
int
date
){
Map
<
String
,
String
>
result
=
new
HashMap
<>();
result
.
put
(
"compareObj"
,
compareObj
);
result
.
put
(
"scoreValue"
,
"0.0"
);
result
.
put
(
"improveValue"
,
"0.0"
);
result
.
put
(
"date"
,
String
.
valueOf
(
date
));
//根据对标对象,日期查找该对标对象对标的所有指标结果
List
<
DriveIndCalResult
>
calResults
=
driveIndCalResultRepo
.
findByCompareObjAndDate
(
compareObj
,
date
);
double
scoreValue
=
0.0
;
double
improveValue
=
0.0
;
if
(!
scoreRule
.
getIndTypeWeights
().
isEmpty
())
{
for
(
IndTypeWeight
indTypeWeight
:
scoreRule
.
getIndTypeWeights
())
{
Map
<
String
,
Double
>
calScores
=
this
.
calIndTypeScore
(
scoreRule
,
indTypeWeight
,
calResults
);
scoreValue
+=
(
calScores
.
get
(
"score"
)*
Double
.
valueOf
(
indTypeWeight
.
getWeight
()));
improveValue
+=
(
calScores
.
get
(
"improve"
)*
Double
.
valueOf
(
indTypeWeight
.
getWeight
()));
}
}
result
.
put
(
"scoreValue"
,
String
.
valueOf
(
scoreValue
));
result
.
put
(
"improveValue"
,
String
.
valueOf
(
improveValue
));
return
result
;
}
//根据指标分类计算指标平均值
private
Map
<
String
,
Double
>
calIndTypeScore
(
ScoreRule
scoreRule
,
IndTypeWeight
indTypeWeight
,
List
<
DriveIndCalResult
>
calResults
)
{
Map
<
String
,
Double
>
result
=
new
HashMap
<>();
result
.
put
(
"score"
,
0.0
);
result
.
put
(
"improve"
,
0.0
);
List
<
String
>
values
=
new
ArrayList
<>();
List
<
String
>
improveValues
=
new
ArrayList
<>();
for
(
DriveIndCalResult
calResult
:
calResults
)
{
String
catalogIdPath
=
indTypeWeight
.
getCatalogIdPath
();
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
calResult
.
getIndId
());
if
(
driveIndDef
!=
null
)
{
//如果考核指标是参与单位计分的
if
(
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
//如果指标是该指标分类下的
if
(
indTypeWeight
.
getCatalogIdPath
().
indexOf
(
catalogIdPath
)>=
0
)
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
values
.
add
(
calResult
.
getValue
());
}
else
if
(
"1"
.
equals
(
scoreRule
.
getScoreType
()))
{
//1 指标得分分数参与计算(综合评分和改善提升分开算)
values
.
add
(
calResult
.
getScore
());
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
()))
{
improveValues
.
add
(
calResult
.
getImproveScore
());
}
}
else
{
//2指标得分分数参与计算(指标分数=综合+改善)
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
()))
{
double
indScore
=
Double
.
valueOf
(
calResult
.
getScore
());
double
improveScore
=
Double
.
valueOf
(
calResult
.
getImproveScore
());
double
sum
=
indScore
+
improveScore
;
values
.
add
(
String
.
valueOf
(
sum
));
}
else
{
values
.
add
(
calResult
.
getScore
());
}
}
}
}
}
}
//计算平均值
String
averageValue
=
CalculateUtils
.
averageValue
(
values
,
0
);
String
averageImproveValue
=
"0.0"
;
if
(!
improveValues
.
isEmpty
())
{
averageImproveValue
=
CalculateUtils
.
averageValue
(
improveValues
,
0
);
}
result
.
put
(
"score"
,
Double
.
valueOf
(
averageValue
));
result
.
put
(
"improve"
,
Double
.
valueOf
(
averageImproveValue
));
return
result
;
}
//根据单位评分规则计算单位分数
public
void
calObjScore
(
String
reportId
,
String
compareId
,
List
<
String
>
indIds
,
List
<
String
>
compareObjs
,
int
date
,
String
scoreRuleId
)
{
List
<
Map
<
String
,
String
>>
results
=
new
ArrayList
<>();
List
<
Map
<
String
,
String
>>
results
=
new
ArrayList
<>();
//根据单位得分评分卡id获取评分卡详情
//根据单位得分评分卡id获取评分卡详情
ScoreRule
scoreRule
=
this
.
getById
(
scoreRuleId
);
ScoreRule
scoreRule
=
this
.
getById
(
scoreRuleId
);
...
@@ -62,83 +185,16 @@ public class ScoreRuleService {
...
@@ -62,83 +185,16 @@ public class ScoreRuleService {
List
<
DriveIndCalResult
>
calResults
=
driveIndCalResultRepo
.
List
<
DriveIndCalResult
>
calResults
=
driveIndCalResultRepo
.
findByCompareObjAndDate
(
compareObj
,
date
);
findByCompareObjAndDate
(
compareObj
,
date
);
if
(!
calResults
.
isEmpty
())
{
if
(!
calResults
.
isEmpty
())
{
//计算类型:0 计算所有考核指标平均数
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
//计算类型:0 计算组内所有考核指标平均数
if
(
"0"
.
equals
(
scoreRule
.
getCalType
()))
{
if
(
"0"
.
equals
(
scoreRule
.
getCalType
()))
{
List
<
String
>
values
=
new
ArrayList
<>();
resultMap
=
this
.
calGroupIndAverage
(
scoreRule
,
indIds
,
compareObj
,
date
);
List
<
String
>
improveValues
=
new
ArrayList
<>();
for
(
DriveIndCalResult
calResult
:
calResults
)
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
values
.
add
(
calResult
.
getValue
());
}
else
{
values
.
add
(
calResult
.
getScore
());
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
()))
{
improveValues
.
add
(
calResult
.
getImproveScore
());
}
}
}
//计算平均值
String
averageValue
=
CalculateUtils
.
averageValue
(
values
,
0
);
String
averageImproveValue
=
"0.0"
;
if
(!
improveValues
.
isEmpty
())
{
averageImproveValue
=
CalculateUtils
.
averageValue
(
improveValues
,
0
);
}
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"reportId"
,
reportId
);
resultMap
.
put
(
"compareObj"
,
compareObj
);
resultMap
.
put
(
"scoreValue"
,
averageValue
);
resultMap
.
put
(
"improveValue"
,
averageImproveValue
);
resultMap
.
put
(
"date"
,
String
.
valueOf
(
date
));
results
.
add
(
resultMap
);
}
else
{
//1 根据目录类别分类算平均分后根据权重计算考核指标
}
else
{
//1 根据目录类别分类算平均分后根据权重计算考核指标
if
(!
scoreRule
.
getIndTypeWeights
().
isEmpty
())
{
resultMap
=
this
.
calIndCatalogTypeAverage
(
scoreRule
,
compareObj
,
date
);
double
scoreValue
=
0.0
;
double
improveValue
=
0.0
;
for
(
IndTypeWeight
indTypeWeight
:
scoreRule
.
getIndTypeWeights
())
{
List
<
String
>
values
=
new
ArrayList
<>();
List
<
String
>
improveValues
=
new
ArrayList
<>();
for
(
DriveIndCalResult
calResult
:
calResults
)
{
String
catalogIdPath
=
indTypeWeight
.
getCatalogIdPath
();
String
driveIndId
=
calResult
.
getIndId
();
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
driveIndId
);
if
(
driveIndDef
!=
null
)
{
//如果考核指标是参与单位计分的
if
(
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
if
(
indTypeWeight
.
getCatalogIdPath
().
indexOf
(
catalogIdPath
)>=
0
)
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
values
.
add
(
calResult
.
getValue
());
}
else
{
values
.
add
(
calResult
.
getScore
());
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
()))
{
improveValues
.
add
(
calResult
.
getImproveScore
());
}
}
}
}
}
}
//计算平均值
String
averageValue
=
CalculateUtils
.
averageValue
(
values
,
0
);
String
averageImproveValue
=
"0.0"
;
if
(!
improveValues
.
isEmpty
())
{
averageImproveValue
=
CalculateUtils
.
averageValue
(
improveValues
,
0
);
}
scoreValue
=
scoreValue
+
Double
.
valueOf
(
averageValue
)*
(
Double
.
valueOf
(
indTypeWeight
.
getWeight
())/
100
);
improveValue
=
improveValue
+
Double
.
valueOf
(
averageImproveValue
)*
(
Double
.
valueOf
(
indTypeWeight
.
getWeight
())/
100
);
}
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"reportId"
,
reportId
);
resultMap
.
put
(
"compareObj"
,
compareObj
);
resultMap
.
put
(
"scoreValue"
,
String
.
valueOf
(
scoreValue
));
resultMap
.
put
(
"improveValue"
,
String
.
valueOf
(
improveValue
));
resultMap
.
put
(
"date"
,
String
.
valueOf
(
date
));
results
.
add
(
resultMap
);
}
}
}
resultMap
.
put
(
"reportId"
,
reportId
);
resultMap
.
put
(
"compareId"
,
compareId
);
results
.
add
(
resultMap
);
}
}
}
}
}
else
{
}
else
{
...
...
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