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
1a3bd09d
Commit
1a3bd09d
authored
Jun 16, 2020
by
张祺
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hy-tobacco' of
http://132.232.112.242:7090/zhangkb/indicators
into hy-tobacco
parents
0c5194c7
0a793609
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
301 additions
and
48 deletions
+301
-48
DriveIndCalculateActor.java
...ymobile/indicators/akka/actor/DriveIndCalculateActor.java
+2
-2
IndicatorsDefCtrl.java
...keymobile/indicators/api/hytobacco/IndicatorsDefCtrl.java
+21
-2
ShortboardRuleCtrl.java
...eymobile/indicators/api/hytobacco/ShortboardRuleCtrl.java
+7
-0
ShortboardDriveIndRel.java
...cators/model/entity/shortboard/ShortboardDriveIndRel.java
+2
-2
DriveIndDefService.java
...bile/indicators/service/hytobacco/DriveIndDefService.java
+53
-2
IndScorecardService.java
...ile/indicators/service/hytobacco/IndScorecardService.java
+2
-2
IndicatorsValueService.java
.../indicators/service/hytobacco/IndicatorsValueService.java
+2
-2
ScoreRuleService.java
...mobile/indicators/service/hytobacco/ScoreRuleService.java
+3
-4
ShortboardRuleService.java
...e/indicators/service/hytobacco/ShortboardRuleService.java
+194
-25
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+13
-7
DriveIndCalResultDefMapper.xml
.../resources/mybatis/mapping/DriveIndCalResultDefMapper.xml
+2
-0
No files found.
src/main/java/com/keymobile/indicators/akka/actor/DriveIndCalculateActor.java
View file @
1a3bd09d
...
...
@@ -167,11 +167,11 @@ public class DriveIndCalculateActor extends AbstractActor{
driveIndCalculateRegionActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
}
catch
(
Exception
e
)
{
DriveIndCalResultDef
driveIndCalResult
=
new
DriveIndCalResultDef
(
compareId
,
driveIndId
,
compareObj
,
date
,
"
0(Error)
"
,
unit
,
"1"
,
"0"
,
"admin"
);
driveIndId
,
compareObj
,
date
,
"
NaN
"
,
unit
,
"1"
,
"0"
,
"admin"
);
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
DriveIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
new
DriveIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
compareId
,
driveIndId
,
compareObj
,
date
,
"
0(Error)
"
,
compareId
,
driveIndId
,
compareObj
,
date
,
"
NaN
"
,
unit
,
indType
,
markType
,
averageDriveIndFormula
);
driveIndCalculateRegionActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
logger
.
error
(
"env:"
+
env
+
";formula:"
+
driveIndFormula
);
...
...
src/main/java/com/keymobile/indicators/api/hytobacco/IndicatorsDefCtrl.java
View file @
1a3bd09d
...
...
@@ -43,6 +43,12 @@ public class IndicatorsDefCtrl {
baseIndDefService
.
delete
(
indId
);
}
@ApiOperation
(
value
=
"根据id查询基础指标详情"
,
notes
=
"根据id查询基础指标详情"
)
@PostMapping
(
value
=
"/getBaseIndById"
)
public
BaseIndDef
getBaseIndById
(
@RequestParam
String
indId
)
throws
Exception
{
return
baseIndDefService
.
getById
(
indId
);
}
@ApiOperation
(
value
=
"根据关键字查询基础指标"
,
notes
=
"根据关键字查询基础指标"
)
@PostMapping
(
value
=
"/getByPageAndKeyword"
)
public
Map
<
String
,
Object
>
getByPageAndKeyword
(
@RequestParam
Integer
catalogId
,
...
...
@@ -54,8 +60,9 @@ public class IndicatorsDefCtrl {
@ApiOperation
(
value
=
"新建考核指标"
,
notes
=
"新建考核指标"
)
@PostMapping
(
value
=
"/createDriveInd"
)
public
void
createDriveInd
(
@RequestBody
DriveIndDef
driveIndDef
,
@RequestParam
Integer
catalogId
,
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
)
throws
Exception
{
driveIndDefService
.
saveOrUpdate
(
driveIndDef
,
catalogId
,
catalogIdPath
,
user
);
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
,
@RequestParam
String
shortboardIds
)
throws
Exception
{
driveIndDefService
.
saveOrUpdate
(
driveIndDef
,
catalogId
,
catalogIdPath
,
user
,
shortboardIds
);
}
@ApiOperation
(
value
=
"删除考核指标"
,
notes
=
"删除考核指标"
)
...
...
@@ -64,6 +71,18 @@ public class IndicatorsDefCtrl {
driveIndDefService
.
delete
(
indId
);
}
@ApiOperation
(
value
=
"根据考核指标id获取指标详情"
,
notes
=
"根据考核指标id获取指标详情"
)
@PostMapping
(
value
=
"/getDrivedefById"
)
public
DriveIndDef
getDrivedefById
(
@RequestParam
String
indId
)
throws
Exception
{
return
driveIndDefService
.
getById
(
indId
);
}
@ApiOperation
(
value
=
"根据考核指标id获取指标详情(包含短板筛选规则信息)"
,
notes
=
"根据考核指标id获取指标详情(包含短板筛选规则信息)"
)
@PostMapping
(
value
=
"/getDrivedefDetailById"
)
public
Map
<
String
,
Object
>
getDrivedefDetailById
(
@RequestParam
String
indId
)
throws
Exception
{
return
driveIndDefService
.
getDetailById
(
indId
);
}
@ApiOperation
(
value
=
"根据关键字查询考核指标"
,
notes
=
"根据关键字查询考核指标"
)
@PostMapping
(
value
=
"/getDriveByPageAndKeyword"
)
public
Map
<
String
,
Object
>
getDriveByPageAndKeyword
(
@RequestParam
Integer
catalogId
,
...
...
src/main/java/com/keymobile/indicators/api/hytobacco/ShortboardRuleCtrl.java
View file @
1a3bd09d
...
...
@@ -73,4 +73,11 @@ public class ShortboardRuleCtrl {
public
ShortboardRule
findById
(
@RequestParam
Integer
id
)
{
return
shortboardRuleService
.
getById
(
id
);
}
@ApiOperation
(
value
=
"根据短板规则筛选短板单位"
,
notes
=
"根据短板规则筛选短板单位"
)
@PostMapping
(
value
=
"/getShortboardObj"
)
public
List
<
Map
<
String
,
Object
>>
getObjShortboard
(
@RequestParam
String
compareId
,
@RequestParam
int
date
,
@RequestParam
List
<
String
>
compareObjs
,
@RequestParam
List
<
String
>
driveIds
)
throws
Exception
{
return
shortboardRuleService
.
getObjShortboard
(
compareId
,
date
,
compareObjs
,
driveIds
);
}
}
src/main/java/com/keymobile/indicators/model/entity/shortboard/ShortboardDriveIndRel.java
View file @
1a3bd09d
...
...
@@ -18,9 +18,9 @@ public class ShortboardDriveIndRel{
private
Integer
id
;
private
Integer
shortboardRuleId
;
//短板规则id
private
Integer
driveIndDefId
;
//考核指标id
private
String
driveIndDefId
;
//考核指标id
public
ShortboardDriveIndRel
(
Integer
driveIndDefId
,
Integer
shortboardRuleId
)
{
public
ShortboardDriveIndRel
(
String
driveIndDefId
,
Integer
shortboardRuleId
)
{
this
.
driveIndDefId
=
driveIndDefId
;
this
.
shortboardRuleId
=
shortboardRuleId
;
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndDefService.java
View file @
1a3bd09d
...
...
@@ -16,7 +16,11 @@ import org.springframework.stereotype.Service;
import
com.google.common.collect.Maps
;
import
com.googlecode.aviator.AviatorEvaluator
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardRule
;
import
com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.ShortboardDriveIndRelMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.ShortboardRuleMapper
;
import
com.keymobile.indicators.utils.CalculateUtils
;
@Service
...
...
@@ -27,9 +31,13 @@ public class DriveIndDefService {
private
DriveIndDefVersionService
driveIndDefVersionService
;
@Autowired
private
BaseIndDataService
baseIndDataService
;
@Autowired
private
ShortboardDriveIndRelMapper
shortboardDriveIndRelMapper
;
@Autowired
private
ShortboardRuleMapper
shortboardRuleMapper
;
public
String
saveOrUpdate
(
DriveIndDef
driveIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
)
throws
Exception
{
public
String
saveOrUpdate
(
DriveIndDef
driveIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
,
String
shortboardIds
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIndId
()))
{
return
"indId can not be null"
;
}
...
...
@@ -56,6 +64,27 @@ public class DriveIndDefService {
driveIndDefMapper
.
updateByPrimaryKey
(
driveIndDef
);
}
}
//插入短板筛选规则
if
(
StringUtils
.
isNotBlank
(
shortboardIds
))
{
//查找考核指标之前关联的短板筛选规则
List
<
ShortboardDriveIndRel
>
relations
=
shortboardDriveIndRelMapper
.
findByDriveIndDefId
(
driveIndDef
.
getIndId
());
if
(!
relations
.
isEmpty
())
{
for
(
ShortboardDriveIndRel
relation
:
relations
)
{
shortboardDriveIndRelMapper
.
delete
(
relation
);
}
}
//新建关联关系
String
[]
shortboards
=
shortboardIds
.
split
(
";"
);
for
(
String
shortboardId
:
shortboards
)
{
ShortboardDriveIndRel
relation
=
new
ShortboardDriveIndRel
(
driveIndDef
.
getIndId
(),
Integer
.
parseInt
(
shortboardId
));
ShortboardDriveIndRel
isExistRel
=
shortboardDriveIndRelMapper
.
selectOne
(
relation
);
if
(
isExistRel
==
null
)
{
shortboardDriveIndRelMapper
.
insert
(
relation
);
}
}
}
return
"success;driveIndId:"
+
driveIndDef
.
getIndId
();
}
...
...
@@ -65,6 +94,28 @@ public class DriveIndDefService {
return
driveIndDefMapper
.
selectOne
(
driveIndDef
);
}
public
Map
<
String
,
Object
>
getDetailById
(
String
indId
)
throws
Exception
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
DriveIndDef
driveIndDef
=
new
DriveIndDef
();
driveIndDef
.
setIndId
(
indId
);
driveIndDef
=
driveIndDefMapper
.
selectOne
(
driveIndDef
);
if
(
driveIndDef
!=
null
)
{
result
.
put
(
"driveIndDef"
,
driveIndDef
);
//查找考核指标之前关联的短板筛选规则
List
<
ShortboardDriveIndRel
>
relations
=
shortboardDriveIndRelMapper
.
findByDriveIndDefId
(
driveIndDef
.
getIndId
());
List
<
ShortboardRule
>
rules
=
new
ArrayList
<>();
for
(
ShortboardDriveIndRel
relation
:
relations
)
{
ShortboardRule
rule
=
shortboardRuleMapper
.
selectByPrimaryKey
(
relation
.
getShortboardRuleId
());
if
(
rule
!=
null
)
{
rules
.
add
(
rule
);
}
}
result
.
put
(
"shortboardRules"
,
rules
);
}
return
result
;
}
public
void
delete
(
String
indId
)
throws
Exception
{
driveIndDefMapper
.
deleteByPrimaryKey
(
indId
);
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndScorecardService.java
View file @
1a3bd09d
...
...
@@ -126,7 +126,7 @@ public class IndScorecardService {
Iterator
<
DriveIndCalResultDef
>
it
=
currentDriveResult
.
iterator
();
while
(
it
.
hasNext
()){
DriveIndCalResultDef
driveCalResult
=
it
.
next
();
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"0(Error)"
.
equals
(
driveCalResult
.
getValue
())
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"0.0000"
.
equals
(
driveCalResult
.
getValue
())||
"0"
.
equals
(
driveCalResult
.
getValue
())){
it
.
remove
();
}
...
...
@@ -145,7 +145,7 @@ public class IndScorecardService {
}
}
String
value
=
currentCompareObjResult
.
getValue
();
if
(!
"NaN"
.
equals
(
value
)
&&
!
"0(Error)"
.
equals
(
value
)
if
(!
"NaN"
.
equals
(
value
)
&&
!
"0.0000"
.
equals
(
value
)
&&
!
"0"
.
equals
(
value
))
{
//综合评价
if
(
"0"
.
equals
(
scoreCard
.
getScoreType
()))
{
//定义
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsValueService.java
View file @
1a3bd09d
...
...
@@ -701,7 +701,7 @@ public class IndicatorsValueService {
Iterator
<
DriveIndCalResultDef
>
it
=
currentDriveResult
.
iterator
();
while
(
it
.
hasNext
()){
DriveIndCalResultDef
driveCalResult
=
it
.
next
();
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"0(Error)"
.
equals
(
driveCalResult
.
getValue
())
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"0.0000"
.
equals
(
driveCalResult
.
getValue
())||
"0"
.
equals
(
driveCalResult
.
getValue
())){
it
.
remove
();
}
...
...
@@ -725,7 +725,7 @@ public class IndicatorsValueService {
Iterator
<
DriveIndCalResultDef
>
sit
=
sameDriveResult
.
iterator
();
while
(
sit
.
hasNext
()){
DriveIndCalResultDef
driveCalResult
=
sit
.
next
();
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"0(Error)"
.
equals
(
driveCalResult
.
getValue
())
if
(
"NaN"
.
equals
(
driveCalResult
.
getValue
())
||
"0.0000"
.
equals
(
driveCalResult
.
getValue
())||
"0"
.
equals
(
driveCalResult
.
getValue
())){
sit
.
remove
();
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ScoreRuleService.java
View file @
1a3bd09d
...
...
@@ -110,7 +110,7 @@ public class ScoreRuleService {
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0(Error)"
.
equals
(
calResult
.
getValue
())
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
values
.
add
(
calResult
.
getValue
());
}
...
...
@@ -169,8 +169,7 @@ public class ScoreRuleService {
if
(
calresultOp
!=
null
)
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
if
(!
"NaN"
.
equals
(
calresultOp
.
getValue
())
&&
!
"0(Error)"
.
equals
(
calresultOp
.
getValue
()))
{
if
(!
"NaN"
.
equals
(
calresultOp
.
getValue
()))
{
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
calresultOp
.
getValue
());
}
else
{
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
"0.0"
);
...
...
@@ -270,7 +269,7 @@ public class ScoreRuleService {
if
(
indTypeWeight
.
getCatalogIdPath
().
indexOf
(
catalogIdPath
)>=
0
)
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0(Error)"
.
equals
(
calResult
.
getValue
())
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
values
.
add
(
calResult
.
getValue
());
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ShortboardRuleService.java
View file @
1a3bd09d
...
...
@@ -76,33 +76,65 @@ public class ShortboardRuleService {
}
//根据短板规则筛选短板单位
public
List
<
Map
<
String
,
String
>>
getObjShortboard
(
String
compareId
,
int
date
,
List
<
String
>
compareObjs
,
List
<
String
>
driveIds
){
List
<
Map
<
String
,
String
>>
result
=
new
ArrayList
<>();
public
List
<
Map
<
String
,
Object
>>
getObjShortboard
(
String
compareId
,
int
date
,
List
<
String
>
compareObjs
,
List
<
String
>
driveIds
)
throws
Exception
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
Gson
gson
=
new
Gson
();
int
status
=
0
;
List
<
DriveIndCalResultDef
>
compareCalResults
=
new
ArrayList
<>();
for
(
String
driveId
:
driveIds
)
{
List
<
Integer
>
shortboardRuleId
=
new
ArrayList
<>();
//保存短板筛选规则id
//根据考核指标id获取关联的短板筛选规则id
List
<
ShortboardDriveIndRel
>
relations
=
shortboardDriveIndRelMapper
.
findByDriveIndDefId
(
driveId
);
for
(
ShortboardDriveIndRel
rel
:
relations
)
{
ShortboardRule
shortboardRule
=
this
.
getById
(
rel
.
getShortboardRuleId
());
if
(
shortboardRule
!=
null
)
{
shortboardRuleId
.
add
(
shortboardRule
.
getId
());
if
(
StringUtils
.
isNotBlank
(
shortboardRule
.
getShortboardItemJson
()))
{
List
<
ShortboardItem
>
shortboardItems
=
gson
.
fromJson
(
shortboardRule
.
getShortboardItemJson
(),
new
TypeToken
<
List
<
ShortboardItem
>>(){}.
getType
());
for
(
ShortboardItem
item
:
shortboardItems
)
{
for
(
ShortboardItem
shortboardItem
:
shortboardItems
)
{
List
<
DriveIndCalResultDef
>
driveIndCalResults
=
this
.
selectShortboardObj
(
shortboardItem
,
compareObjs
,
driveId
,
date
);
if
(
status
==
0
)
{
compareCalResults
.
addAll
(
driveIndCalResults
);
status
=
1
;
}
else
{
//求交集
compareCalResults
.
retainAll
(
driveIndCalResults
);
}
}
}
}
}
if
(!
compareCalResults
.
isEmpty
())
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"compareId"
,
compareId
);
map
.
put
(
"driveId"
,
driveId
);
map
.
put
(
"shortboardRuleId"
,
shortboardRuleId
);
map
.
put
(
"compareCalResults"
,
compareCalResults
);
result
.
add
(
map
);
}
}
return
result
;
}
private
void
selectShortboardObj
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
private
List
<
DriveIndCalResultDef
>
selectShortboardObj
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
String
type
=
shortboardItem
.
getType
();
List
<
DriveIndCalResultDef
>
result
=
new
ArrayList
<>();
if
(
"0"
.
equals
(
type
))
{
//均值
result
=
this
.
selectAverageShortboard
(
shortboardItem
,
compareObjs
,
driveId
,
date
);
}
else
if
(
"1"
.
equals
(
type
))
{
//最大值
result
=
this
.
selectMaxShortboard
(
shortboardItem
,
compareObjs
,
driveId
,
date
);
}
else
if
(
"2"
.
equals
(
type
))
{
//最小值
result
=
this
.
selectMinShortboard
(
shortboardItem
,
compareObjs
,
driveId
,
date
);
}
else
if
(
"3"
.
equals
(
type
))
{
//排名
result
=
this
.
selectRankShortboard
(
shortboardItem
,
compareObjs
,
driveId
,
date
);
}
else
{
//历史同期
result
=
this
.
selectSametimeShortboard
(
shortboardItem
,
compareObjs
,
driveId
,
date
);
}
return
result
;
}
//短板筛选规则为均值
...
...
@@ -119,7 +151,7 @@ public class ShortboardRuleService {
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
//判断规则选择是大于还是小于
if
(
"0"
.
equals
(
shortboardItem
.
getCalType
()))
{
//大于
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0(Error)"
.
equals
(
calResult
.
getValue
())
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
...
...
@@ -135,7 +167,7 @@ public class ShortboardRuleService {
}
}
}
else
{
//小于
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0(Error)"
.
equals
(
calResult
.
getValue
())
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
//判断有没有实际的平均值
if
(!
"0.0"
.
equals
(
calResult
.
getActualAverage
()))
{
...
...
@@ -204,18 +236,28 @@ public class ShortboardRuleService {
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//获取排名第一的最大值
String
maxValue
=
null
;
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(
calResult
.
getRank
()==
1
)
{
maxValue
=
calResult
.
getValue
();
}
if
(!
realCalResults
.
isEmpty
())
{
maxValue
=
calResults
.
get
(
0
).
getValue
();
}
if
(
maxValue
!=
null
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
//判断是比较差还是百分比
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
}
else
{
//百分比
if
(!
"NaN"
.
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
);
}
}
}
}
}
}
...
...
@@ -223,20 +265,147 @@ public class ShortboardRuleService {
}
//短板筛选规则为最小值
private
void
selectMinShortboard
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectMinShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
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
())
&&
!
"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
())
&&
!
"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
);
}
}
}
}
}
}
return
realCalResults
;
}
//短板筛选规则为排名
private
void
selectRankShortboard
(
ShortboardItem
shortboardItem
,
//短板筛选规则为排名
(默认是选排名最后第几名的单位为短板)
private
List
<
DriveIndCalResultDef
>
selectRankShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
List
<
DriveIndCalResultDef
>
filterCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
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,日期和对标对象获取对标结果
if
(!
calResults
.
isEmpty
())
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
filterCalResults
.
add
(
calResult
);
}
}
}
if
(!
filterCalResults
.
isEmpty
())
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
Integer
value
=
Integer
.
parseInt
(
shortboardItem
.
getValue
());
if
(
filterCalResults
.
size
()<=
value
)
{
realCalResults
.
addAll
(
filterCalResults
);
}
else
{
Integer
size
=
filterCalResults
.
size
();
for
(
int
i
=
0
;
i
<
value
;
i
++)
{
realCalResults
.
add
(
filterCalResults
.
get
(
size
-(
i
+
1
)));
}
}
}
}
return
realCalResults
;
}
//短板筛选规则为历史同期
private
void
selectSametimeShortboard
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectSametimeShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
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
())
&&
!
"0.0000"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0"
.
equals
(
currentIndCalResult
.
getValue
()))
{
if
(!
"NaN"
.
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
);
}
}
}
}
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
);
}
}
}
}
}
}
}
}
}
return
realCalResults
;
}
}
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
1a3bd09d
...
...
@@ -21,8 +21,7 @@ public class CalculateUtils {
public
static
String
calGowth
(
String
unit
,
String
currentValue
,
String
sameValue
,
String
type
)
{
String
gowthValue
=
""
;
StringBuilder
formula
=
new
StringBuilder
();
if
(!
"NaN"
.
equals
(
currentValue
)&&!
"0(Error)"
.
equals
(
currentValue
)&&
!
"NaN"
.
equals
(
sameValue
)&&!
"0(Error)"
.
equals
(
sameValue
))
{
if
(!
"NaN"
.
equals
(
currentValue
)
&&
!
"NaN"
.
equals
(
sameValue
))
{
Object
value
=
null
;
if
(
"0"
.
equals
(
type
))
{
if
(
"%"
.
equals
(
unit
))
{
...
...
@@ -55,7 +54,7 @@ public class CalculateUtils {
Map
<
String
,
String
>
invalidMap
=
new
HashMap
<>();
//将map中的无效值挑出来
for
(
Entry
<
String
,
String
>
entry
:
valueMap
.
entrySet
())
{
if
(
"NaN"
.
equals
(
entry
.
getValue
())
||
"0(Error)"
.
equals
(
entry
.
getValue
())
if
(
"NaN"
.
equals
(
entry
.
getValue
())
||
"0.0000"
.
equals
(
entry
.
getValue
())
||
"0"
.
equals
(
entry
.
getValue
())
||
""
.
equals
(
entry
.
getValue
()))
{
invalidMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
...
...
@@ -136,14 +135,14 @@ public class CalculateUtils {
formula
.
append
(
"("
);
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
if
(
type
==
0
)
{
if
(
"NaN"
.
equals
(
values
.
get
(
i
))
||
"0(Error)"
.
equals
(
values
.
get
(
i
))
if
(
"NaN"
.
equals
(
values
.
get
(
i
))
||
"0.0000"
.
equals
(
values
.
get
(
i
))
||
"0"
.
equals
(
values
.
get
(
i
))
||
""
.
equals
(
values
.
get
(
i
)))
{
size
-=
1
;
continue
;
}
}
else
{
if
(
"NaN"
.
equals
(
values
.
get
(
i
))
||
"0(Error)"
.
equals
(
values
.
get
(
i
))
if
(
"NaN"
.
equals
(
values
.
get
(
i
))
||
""
.
equals
(
values
.
get
(
i
)))
{
size
-=
1
;
continue
;
...
...
@@ -232,7 +231,14 @@ public class CalculateUtils {
// formula = formula.replace("[1002]", "5");
// String result1 = AviatorEvaluator.execute(formula).toString();
// System.out.println(result1);
Double
b
=
(
double
)
Math
.
abs
(
34
-
50
);
System
.
out
.
println
(
b
);
// 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
);
}
}
src/main/resources/mybatis/mapping/DriveIndCalResultDefMapper.xml
View file @
1a3bd09d
...
...
@@ -127,5 +127,6 @@
<foreach
item=
"id"
collection=
"compareObjs"
open=
"("
close=
")"
separator=
","
>
#{id}
</foreach>
order by rank asc
</select>
</mapper>
\ No newline at end of file
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