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
a44beb64
Commit
a44beb64
authored
Jun 16, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
指标短板筛选规则接口代码提交
parent
60785873
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
244 additions
and
31 deletions
+244
-31
IndicatorsDefCtrl.java
...keymobile/indicators/api/hytobacco/IndicatorsDefCtrl.java
+3
-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
+27
-2
ShortboardRuleService.java
...e/indicators/service/hytobacco/ShortboardRuleService.java
+194
-23
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+9
-2
DriveIndCalResultDefMapper.xml
.../resources/mybatis/mapping/DriveIndCalResultDefMapper.xml
+2
-0
No files found.
src/main/java/com/keymobile/indicators/api/hytobacco/IndicatorsDefCtrl.java
View file @
a44beb64
...
@@ -54,8 +54,9 @@ public class IndicatorsDefCtrl {
...
@@ -54,8 +54,9 @@ public class IndicatorsDefCtrl {
@ApiOperation
(
value
=
"新建考核指标"
,
notes
=
"新建考核指标"
)
@ApiOperation
(
value
=
"新建考核指标"
,
notes
=
"新建考核指标"
)
@PostMapping
(
value
=
"/createDriveInd"
)
@PostMapping
(
value
=
"/createDriveInd"
)
public
void
createDriveInd
(
@RequestBody
DriveIndDef
driveIndDef
,
@RequestParam
Integer
catalogId
,
public
void
createDriveInd
(
@RequestBody
DriveIndDef
driveIndDef
,
@RequestParam
Integer
catalogId
,
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
)
throws
Exception
{
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
,
driveIndDefService
.
saveOrUpdate
(
driveIndDef
,
catalogId
,
catalogIdPath
,
user
);
@RequestParam
String
shortboardIds
)
throws
Exception
{
driveIndDefService
.
saveOrUpdate
(
driveIndDef
,
catalogId
,
catalogIdPath
,
user
,
shortboardIds
);
}
}
@ApiOperation
(
value
=
"删除考核指标"
,
notes
=
"删除考核指标"
)
@ApiOperation
(
value
=
"删除考核指标"
,
notes
=
"删除考核指标"
)
...
...
src/main/java/com/keymobile/indicators/api/hytobacco/ShortboardRuleCtrl.java
View file @
a44beb64
...
@@ -73,4 +73,11 @@ public class ShortboardRuleCtrl {
...
@@ -73,4 +73,11 @@ public class ShortboardRuleCtrl {
public
ShortboardRule
findById
(
@RequestParam
Integer
id
)
{
public
ShortboardRule
findById
(
@RequestParam
Integer
id
)
{
return
shortboardRuleService
.
getById
(
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 @
a44beb64
...
@@ -18,9 +18,9 @@ public class ShortboardDriveIndRel{
...
@@ -18,9 +18,9 @@ public class ShortboardDriveIndRel{
private
Integer
id
;
private
Integer
id
;
private
Integer
shortboardRuleId
;
//短板规则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
.
driveIndDefId
=
driveIndDefId
;
this
.
shortboardRuleId
=
shortboardRuleId
;
this
.
shortboardRuleId
=
shortboardRuleId
;
}
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndDefService.java
View file @
a44beb64
...
@@ -16,7 +16,9 @@ import org.springframework.stereotype.Service;
...
@@ -16,7 +16,9 @@ import org.springframework.stereotype.Service;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.googlecode.aviator.AviatorEvaluator
;
import
com.googlecode.aviator.AviatorEvaluator
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel
;
import
com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper
;
import
com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.ShortboardDriveIndRelMapper
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.keymobile.indicators.utils.CalculateUtils
;
@Service
@Service
...
@@ -27,9 +29,11 @@ public class DriveIndDefService {
...
@@ -27,9 +29,11 @@ public class DriveIndDefService {
private
DriveIndDefVersionService
driveIndDefVersionService
;
private
DriveIndDefVersionService
driveIndDefVersionService
;
@Autowired
@Autowired
private
BaseIndDataService
baseIndDataService
;
private
BaseIndDataService
baseIndDataService
;
@Autowired
private
ShortboardDriveIndRelMapper
shortboardDriveIndRelMapper
;
public
String
saveOrUpdate
(
DriveIndDef
driveIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
)
public
String
saveOrUpdate
(
DriveIndDef
driveIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
throws
Exception
{
String
user
,
String
shortboardIds
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIndId
()))
{
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIndId
()))
{
return
"indId can not be null"
;
return
"indId can not be null"
;
}
}
...
@@ -56,6 +60,27 @@ public class DriveIndDefService {
...
@@ -56,6 +60,27 @@ public class DriveIndDefService {
driveIndDefMapper
.
updateByPrimaryKey
(
driveIndDef
);
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
();
return
"success;driveIndId:"
+
driveIndDef
.
getIndId
();
}
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ShortboardRuleService.java
View file @
a44beb64
...
@@ -76,33 +76,65 @@ public class ShortboardRuleService {
...
@@ -76,33 +76,65 @@ public class ShortboardRuleService {
}
}
//根据短板规则筛选短板单位
//根据短板规则筛选短板单位
public
List
<
Map
<
String
,
String
>>
getObjShortboard
(
String
compareId
,
int
date
,
public
List
<
Map
<
String
,
Object
>>
getObjShortboard
(
String
compareId
,
int
date
,
List
<
String
>
compareObjs
,
List
<
String
>
driveIds
){
List
<
String
>
compareObjs
,
List
<
String
>
driveIds
)
throws
Exception
{
List
<
Map
<
String
,
String
>>
result
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
Gson
gson
=
new
Gson
();
Gson
gson
=
new
Gson
();
int
status
=
0
;
List
<
DriveIndCalResultDef
>
compareCalResults
=
new
ArrayList
<>();
for
(
String
driveId
:
driveIds
)
{
for
(
String
driveId
:
driveIds
)
{
List
<
Integer
>
shortboardRuleId
=
new
ArrayList
<>();
//保存短板筛选规则id
//根据考核指标id获取关联的短板筛选规则id
//根据考核指标id获取关联的短板筛选规则id
List
<
ShortboardDriveIndRel
>
relations
=
shortboardDriveIndRelMapper
.
List
<
ShortboardDriveIndRel
>
relations
=
shortboardDriveIndRelMapper
.
findByDriveIndDefId
(
driveId
);
findByDriveIndDefId
(
driveId
);
for
(
ShortboardDriveIndRel
rel
:
relations
)
{
for
(
ShortboardDriveIndRel
rel
:
relations
)
{
ShortboardRule
shortboardRule
=
this
.
getById
(
rel
.
getShortboardRuleId
());
ShortboardRule
shortboardRule
=
this
.
getById
(
rel
.
getShortboardRuleId
());
if
(
shortboardRule
!=
null
)
{
if
(
shortboardRule
!=
null
)
{
shortboardRuleId
.
add
(
shortboardRule
.
getId
());
if
(
StringUtils
.
isNotBlank
(
shortboardRule
.
getShortboardItemJson
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardRule
.
getShortboardItemJson
()))
{
List
<
ShortboardItem
>
shortboardItems
=
gson
.
List
<
ShortboardItem
>
shortboardItems
=
gson
.
fromJson
(
shortboardRule
.
getShortboardItemJson
(),
new
TypeToken
<
List
<
ShortboardItem
>>(){}.
getType
());
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
;
return
result
;
}
}
private
void
selectShortboardObj
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectShortboardObj
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
throws
Exception
{
String
type
=
shortboardItem
.
getType
();
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
;
}
}
//短板筛选规则为均值
//短板筛选规则为均值
...
@@ -204,18 +236,28 @@ public class ShortboardRuleService {
...
@@ -204,18 +236,28 @@ public class ShortboardRuleService {
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
List
<
DriveIndCalResultDef
>
realCalResults
=
new
ArrayList
<>();
//用于保存符合过滤条件的指标结果
//获取排名第一的最大值
//获取排名第一的最大值
String
maxValue
=
null
;
String
maxValue
=
null
;
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
if
(!
realCalResults
.
isEmpty
())
{
if
(
calResult
.
getRank
()==
1
)
{
maxValue
=
calResults
.
get
(
0
).
getValue
();
maxValue
=
calResult
.
getValue
();
}
}
}
if
(
maxValue
!=
null
)
{
if
(
maxValue
!=
null
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
for
(
DriveIndCalResultDef
calResult
:
calResults
)
{
//判断是比较差还是百分比
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"0(Error)"
.
equals
(
calResult
.
getValue
())
if
(
"0"
.
equals
(
shortboardItem
.
getAnalysisType
()))
{
//绝对值
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
shortboardItem
.
getValue
()))
{
}
else
{
//百分比
//判断是比较差还是百分比
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,149 @@ public class ShortboardRuleService {
...
@@ -223,20 +265,149 @@ public class ShortboardRuleService {
}
}
//短板筛选规则为最小值
//短板筛选规则为最小值
private
void
selectMinShortboard
(
ShortboardItem
shortboardItem
,
private
List
<
DriveIndCalResultDef
>
selectMinShortboard
(
ShortboardItem
shortboardItem
,
List
<
String
>
compareObjs
,
String
driveId
,
int
date
)
{
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(Error)"
.
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(Error)"
.
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
<
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(Error)"
.
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
<
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(Error)"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
currentIndCalResult
.
getValue
())
&&
!
"0"
.
equals
(
currentIndCalResult
.
getValue
()))
{
if
(!
"NaN"
.
equals
(
sameIndCalResult
.
getValue
())
&&
!
"0(Error)"
.
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 @
a44beb64
...
@@ -232,7 +232,14 @@ public class CalculateUtils {
...
@@ -232,7 +232,14 @@ public class CalculateUtils {
// formula = formula.replace("[1002]", "5");
// formula = formula.replace("[1002]", "5");
// String result1 = AviatorEvaluator.execute(formula).toString();
// String result1 = AviatorEvaluator.execute(formula).toString();
// System.out.println(result1);
// System.out.println(result1);
Double
b
=
(
double
)
Math
.
abs
(
34
-
50
);
// Double b = (double) Math.abs(34-50);
System
.
out
.
println
(
b
);
// 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 @
a44beb64
...
@@ -127,5 +127,6 @@
...
@@ -127,5 +127,6 @@
<foreach
item=
"id"
collection=
"compareObjs"
open=
"("
close=
")"
separator=
","
>
<foreach
item=
"id"
collection=
"compareObjs"
open=
"("
close=
")"
separator=
","
>
#{id}
#{id}
</foreach>
</foreach>
order by rank asc
</select>
</select>
</mapper>
</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