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
84eb110e
Commit
84eb110e
authored
Mar 18, 2021
by
hzc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加积分规则区间公式:测试001
parent
befb1735
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
124 additions
and
3 deletions
+124
-3
DriveIndIdCalActor.java
.../indicators/akka/actor/indicators/DriveIndIdCalActor.java
+3
-0
IndScorecard.java
...obile/indicators/model/entity/scorecard/IndScorecard.java
+0
-1
TaskServiceImpl.java
...le/indicators/service/dataenter/impl/TaskServiceImpl.java
+2
-0
IndScorecardService.java
...ile/indicators/service/hytobacco/IndScorecardService.java
+119
-2
No files found.
src/main/java/com/keymobile/indicators/akka/actor/indicators/DriveIndIdCalActor.java
View file @
84eb110e
...
@@ -201,6 +201,9 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -201,6 +201,9 @@ public class DriveIndIdCalActor extends AbstractActor{
driveIndCalResultService
.
batchSaveOrUpdate
(
dataList
);
driveIndCalResultService
.
batchSaveOrUpdate
(
dataList
);
dataList
.
clear
();
dataList
.
clear
();
}
}
//根据评分卡算指标分数
//根据评分卡算指标分数
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
if
(
"0"
.
equals
(
isTest
))
{
if
(
"0"
.
equals
(
isTest
))
{
...
...
src/main/java/com/keymobile/indicators/model/entity/scorecard/IndScorecard.java
View file @
84eb110e
...
@@ -61,7 +61,6 @@ public class IndScorecard {
...
@@ -61,7 +61,6 @@ public class IndScorecard {
private
Double
improveBaseScore
;
//改善提升基础分,新增改善提升基础分-hzc 2020 12 29
private
Double
improveBaseScore
;
//改善提升基础分,新增改善提升基础分-hzc 2020 12 29
private
Double
sectionBaseScore
;
//区间基础得分
private
String
sectionFormula
;
//区间公式表达式
private
String
sectionFormula
;
//区间公式表达式
...
...
src/main/java/com/keymobile/indicators/service/dataenter/impl/TaskServiceImpl.java
View file @
84eb110e
...
@@ -213,7 +213,9 @@ public class TaskServiceImpl implements TaskService {
...
@@ -213,7 +213,9 @@ public class TaskServiceImpl implements TaskService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveTaskValues
(
List
<
TaskIndValue
>
values
,
String
taskId
,
Integer
indSource
)
{
public
void
saveTaskValues
(
List
<
TaskIndValue
>
values
,
String
taskId
,
Integer
indSource
)
{
// taskIndValueMapper.deleteByTaskAndSource(taskId, indSource);
// taskIndValueMapper.deleteByTaskAndSource(taskId, indSource);
log
.
info
(
"正在批量清楚历史数据。。。"
);
taskIndValueMapper
.
batchDelete
(
values
);
taskIndValueMapper
.
batchDelete
(
values
);
log
.
info
(
"保存excel数据。。。"
);
taskIndValueMapper
.
batchInsert
(
values
);
taskIndValueMapper
.
batchInsert
(
values
);
}
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndScorecardService.java
View file @
84eb110e
...
@@ -7,6 +7,7 @@ import java.util.Iterator;
...
@@ -7,6 +7,7 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -25,7 +26,7 @@ import com.keymobile.indicators.model.entity.scorecard.RankScoreDef;
...
@@ -25,7 +26,7 @@ import com.keymobile.indicators.model.entity.scorecard.RankScoreDef;
import
com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.IndScorecardMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.IndScorecardMapper
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.keymobile.indicators.utils.CalculateUtils
;
@Slf4j
@Service
@Service
public
class
IndScorecardService
{
public
class
IndScorecardService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
IndScorecardService
.
class
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
IndScorecardService
.
class
);
...
@@ -236,7 +237,9 @@ public class IndScorecardService {
...
@@ -236,7 +237,9 @@ public class IndScorecardService {
}
}
}
}
}
}
}
else
{
//公式
}
else
if
(
"1"
.
equals
(
scoreCard
.
getScoreType
())
//&& !"0.0000".equals(value)
&&
!
"1"
.
equals
(
value
)){
//公式
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
int
rank
=
currentCompareObjResult
.
getRank
();
//获取排位
if
(
rank
==
1
&&
scoreCard
.
getBestIndScore
()!=
null
)
{
//最佳指标
if
(
rank
==
1
&&
scoreCard
.
getBestIndScore
()!=
null
)
{
//最佳指标
if
(
checkMaxEqMin
(
currentDriveResult
,
acsType
)){
if
(
checkMaxEqMin
(
currentDriveResult
,
acsType
)){
...
@@ -261,6 +264,25 @@ public class IndScorecardService {
...
@@ -261,6 +264,25 @@ public class IndScorecardService {
currentDriveResult
,
acsType
);
currentDriveResult
,
acsType
);
}
}
}
}
}
else
if
(
"2"
.
equals
(
scoreCard
.
getScoreType
())
&&
!
"2"
.
equals
(
value
)){
//公式
List
<
DriveIndCalResultDef
>
sectionScores
=
this
.
getSectionFonmulaValues
(
currentDriveResult
,
scoreCard
);
DriveIndCalResultDef
currentValue
=
new
DriveIndCalResultDef
();
for
(
DriveIndCalResultDef
sectionScore
:
sectionScores
)
{
if
(
sectionScore
.
getId
().
equals
(
currentCompareObjResult
.
getId
())){
currentValue
.
setId
(
sectionScore
.
getId
());
currentValue
.
setValue
(
sectionScore
.
getValue
());
currentValue
.
setRank
(
sectionScore
.
getRank
());
currentValue
.
setAverage
(
sectionScore
.
getAverage
());
break
;
}
}
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getOtherCalFormula
()))
{
baseScoreValue
=
this
.
getValueFromFormula
(
scoreCard
.
getOtherCalFormula
(),
currentValue
,
sectionScores
,
acsType
);
}
}
}
//判断是否有设置综合评分分数上限,有的话判断上限分和实际分
//判断是否有设置综合评分分数上限,有的话判断上限分和实际分
if
(
scoreCard
.
getCompLimitScore
()!=
null
)
{
if
(
scoreCard
.
getCompLimitScore
()!=
null
)
{
...
@@ -326,6 +348,101 @@ public class IndScorecardService {
...
@@ -326,6 +348,101 @@ public class IndScorecardService {
return
result
;
return
result
;
}
}
private
List
<
DriveIndCalResultDef
>
getSectionFonmulaValues
(
List
<
DriveIndCalResultDef
>
currentDriveResult
,
IndScorecard
scoreCard
)
{
List
<
DriveIndCalResultDef
>
values
=
new
ArrayList
<>();
Map
<
String
,
String
>
rankMapTmp
=
new
HashMap
<>();
double
sum
=
0
;
for
(
DriveIndCalResultDef
driveIndCalResultDef
:
currentDriveResult
)
{
String
sectionFonmulaValue
=
this
.
getSectionFonmulaValue
(
driveIndCalResultDef
,
scoreCard
);
rankMapTmp
.
put
(
driveIndCalResultDef
.
getId
().
toString
(),
sectionFonmulaValue
);
sum
+=
Double
.
parseDouble
(
sectionFonmulaValue
);
}
double
avg
=
(
sum
*
1.0
)/(
currentDriveResult
.
size
()*
1.0
);
Map
<
String
,
Integer
>
stringIntegerMap
=
CalculateUtils
.
rankValue
(
rankMapTmp
,
"0"
);
for
(
String
s
:
stringIntegerMap
.
keySet
())
{
DriveIndCalResultDef
driveIndCalResultDef
=
new
DriveIndCalResultDef
();
driveIndCalResultDef
.
setAverage
(
String
.
format
(
"%.8f"
,
new
BigDecimal
(
avg
)));
driveIndCalResultDef
.
setId
(
Integer
.
parseInt
(
s
));
driveIndCalResultDef
.
setRank
(
stringIntegerMap
.
get
(
s
));
driveIndCalResultDef
.
setValue
(
rankMapTmp
.
get
(
s
));
values
.
add
(
driveIndCalResultDef
);
}
return
values
;
}
private
String
getSectionFonmulaValue
(
DriveIndCalResultDef
driveIndCalResultDef
,
IndScorecard
scoreCard
)
{
String
sectionFormulas
=
scoreCard
.
getSectionFormula
();
String
[]
sections
=
sectionFormulas
.
split
(
","
);
String
valueTmp
=
driveIndCalResultDef
.
getValue
();
String
[]
section
;
double
start
=
0
;
boolean
startEq
=
false
;
double
end
=
0
;
boolean
endEq
=
false
;
double
value
=
Double
.
parseDouble
(
valueTmp
);
double
returnValue
=
0
;
for
(
String
sectionTmp
:
sections
)
{
section
=
sectionTmp
.
split
(
","
);
start
=
Double
.
parseDouble
(
section
[
0
]);
startEq
=
"1"
.
equals
(
section
[
1
])?
true
:
false
;
end
=
Double
.
parseDouble
(
section
[
3
]);
endEq
=
"1"
.
equals
(
section
[
2
])?
true
:
false
;
//先假设全是闭区间
if
(
value
>=
start
&&
value
<=
end
){
if
(!
startEq
&&
value
==
start
){
//是开区间,而且值就等于边界值跳过
continue
;
}
if
(!
endEq
&&
value
==
end
){
//是开区间,而且值就等于边界值跳过
continue
;
}
//符合区间范围
double
baseScore
=
Double
.
parseDouble
(
section
[
4
]);
//区间内取那边值来比较,每高选start ,每低选end
double
scopeOne
=
end
*
1.0
;
if
(
"1"
.
equals
(
section
[
5
])){
//每高
scopeOne
=
start
*
1.0
;
}
//差值(value和区间边界的差值
double
scope
=
Math
.
abs
(
value
-
scopeOne
)*
1.0
;
//比值(每高低多少
double
than
=
Double
.
parseDouble
(
section
[
6
])*
1.0
;
double
scopeValue
=
scope
/
than
;
if
(
"2"
.
equals
(
section
[
7
])){
//不按比例。满才加分 去掉小数点取整
scopeValue
=
Math
.
floor
(
scopeValue
);
}
//判断是加还是减
boolean
isAdd
=
"1"
.
equals
(
section
[
8
])?
true
:
false
;
//每个比值加多少分。如:每高than加thanValue分
double
thanValue
=
Double
.
parseDouble
(
section
[
9
]);
double
changeValue
=
scopeValue
*
thanValue
;
double
limit
=
Double
.
parseDouble
(
section
[
10
]);
if
(
changeValue
>
limit
){
changeValue
=
limit
;
}
if
(
isAdd
){
returnValue
=
baseScore
+
changeValue
;
}
else
{
returnValue
=
baseScore
-
changeValue
;
}
log
.
info
(
"value:{},公式:{},积分值:{}"
,
driveIndCalResultDef
.
getValue
(),
sectionTmp
,
returnValue
);
break
;
}
}
return
String
.
valueOf
(
returnValue
);
}
private
boolean
checkMaxEqMin
(
List
<
DriveIndCalResultDef
>
currentDriveResult
,
String
acsType
){
private
boolean
checkMaxEqMin
(
List
<
DriveIndCalResultDef
>
currentDriveResult
,
String
acsType
){
double
min
=
0
;
double
min
=
0
;
if
(
"1"
.
equals
(
acsType
))
{
if
(
"1"
.
equals
(
acsType
))
{
...
...
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