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
1b3a72c7
Commit
1b3a72c7
authored
May 09, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传对标评分卡功能代码
parent
21b63d21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
329 additions
and
24 deletions
+329
-24
DriveIndCalculateActor.java
...ymobile/indicators/akka/actor/DriveIndCalculateActor.java
+7
-2
DriveIndCalculateRegionActor.java
...ors/akka/actor/specific/DriveIndCalculateRegionActor.java
+43
-11
DriveIndAverageAndRankMsg.java
...tors/akka/message/specific/DriveIndAverageAndRankMsg.java
+12
-2
IndScorecardCtrl.java
.../keymobile/indicators/api/hytobacco/IndScorecardCtrl.java
+57
-0
IndicatorsValueCtrl.java
...ymobile/indicators/api/hytobacco/IndicatorsValueCtrl.java
+36
-0
DriveIndCalResult.java
.../keymobile/indicators/model/entity/DriveIndCalResult.java
+4
-1
ImproveScoreDef.java
...le/indicators/model/entity/scorecard/ImproveScoreDef.java
+18
-0
IndScorecard.java
...obile/indicators/model/entity/scorecard/IndScorecard.java
+59
-0
RankScoreDef.java
...obile/indicators/model/entity/scorecard/RankScoreDef.java
+16
-0
DriveIndCalResultRepository.java
...persistence/hyindicators/DriveIndCalResultRepository.java
+16
-0
IndScorecardRepository.java
...tors/persistence/hyindicators/IndScorecardRepository.java
+9
-0
DriveIndCalResultService.java
...ndicators/service/hytobacco/DriveIndCalResultService.java
+9
-0
IndScorecardService.java
...ile/indicators/service/hytobacco/IndScorecardService.java
+0
-0
IndicatorsValueService.java
.../indicators/service/hytobacco/IndicatorsValueService.java
+0
-0
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+43
-8
No files found.
src/main/java/com/keymobile/indicators/akka/actor/DriveIndCalculateActor.java
View file @
1b3a72c7
...
@@ -59,6 +59,8 @@ public class DriveIndCalculateActor extends AbstractActor{
...
@@ -59,6 +59,8 @@ public class DriveIndCalculateActor extends AbstractActor{
private
String
unit
;
private
String
unit
;
private
String
markType
;
private
String
driveIndId
;
private
String
driveIndId
;
private
Map
<
String
,
Object
>
env
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
env
=
Maps
.
newHashMap
();
...
@@ -89,6 +91,7 @@ public class DriveIndCalculateActor extends AbstractActor{
...
@@ -89,6 +91,7 @@ public class DriveIndCalculateActor extends AbstractActor{
IndAcsDef
indAcsDef
=
indAcsDefService
.
getById
(
driveIndId
);
IndAcsDef
indAcsDef
=
indAcsDefService
.
getById
(
driveIndId
);
unit
=
indAcsDef
.
getUnt
();
unit
=
indAcsDef
.
getUnt
();
indType
=
indAcsDef
.
getIndType
();
indType
=
indAcsDef
.
getIndType
();
markType
=
indAcsDef
.
getMarkType
();
List
<
IndAcsScoreInfo
>
acsSoreInfoList
=
indAcsScoreInfoService
.
getListByIndId
(
List
<
IndAcsScoreInfo
>
acsSoreInfoList
=
indAcsScoreInfoService
.
getListByIndId
(
driveIndId
);
driveIndId
);
...
@@ -155,7 +158,8 @@ public class DriveIndCalculateActor extends AbstractActor{
...
@@ -155,7 +158,8 @@ public class DriveIndCalculateActor extends AbstractActor{
//返回指标值回去算平均值和排名
//返回指标值回去算平均值和排名
DriveIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
DriveIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
new
DriveIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
new
DriveIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
compareId
,
driveIndId
,
compareObj
,
date
,
driveIndValue
,
unit
,
indType
);
compareId
,
driveIndId
,
compareObj
,
date
,
driveIndValue
,
unit
,
indType
,
markType
);
driveIndCalculateRegionActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
driveIndCalculateRegionActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
DriveIndCalResult
driveIndCalResult
=
new
DriveIndCalResult
(
compareId
,
DriveIndCalResult
driveIndCalResult
=
new
DriveIndCalResult
(
compareId
,
...
@@ -163,7 +167,8 @@ public class DriveIndCalculateActor extends AbstractActor{
...
@@ -163,7 +167,8 @@ public class DriveIndCalculateActor extends AbstractActor{
driveIndCalResult
=
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
driveIndCalResult
=
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
DriveIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
DriveIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
new
DriveIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
new
DriveIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
compareId
,
driveIndId
,
compareObj
,
date
,
"0(Error)"
,
unit
,
indType
);
compareId
,
driveIndId
,
compareObj
,
date
,
"0(Error)"
,
unit
,
indType
,
markType
);
driveIndCalculateRegionActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
driveIndCalculateRegionActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
logger
.
error
(
"env:"
+
env
+
";formula:"
+
driveIndFormula
);
logger
.
error
(
"env:"
+
env
+
";formula:"
+
driveIndFormula
);
}
}
...
...
src/main/java/com/keymobile/indicators/akka/actor/specific/DriveIndCalculateRegionActor.java
View file @
1b3a72c7
...
@@ -13,6 +13,7 @@ import com.keymobile.indicators.akka.message.specific.DriveIndCalculateRegionMsg
...
@@ -13,6 +13,7 @@ import com.keymobile.indicators.akka.message.specific.DriveIndCalculateRegionMsg
import
com.keymobile.indicators.model.entity.DimValue
;
import
com.keymobile.indicators.model.entity.DimValue
;
import
com.keymobile.indicators.model.entity.DriveIndCalResult
;
import
com.keymobile.indicators.model.entity.DriveIndCalResult
;
import
com.keymobile.indicators.service.hytobacco.DriveIndCalResultService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndCalResultService
;
import
com.keymobile.indicators.service.hytobacco.IndScorecardService
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.keymobile.indicators.utils.SpringUtil
;
import
com.keymobile.indicators.utils.SpringUtil
;
...
@@ -24,6 +25,8 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
...
@@ -24,6 +25,8 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
private
DriveIndCalResultService
driveIndCalResultService
=
SpringUtil
.
getBean
(
DriveIndCalResultService
.
class
);
private
DriveIndCalResultService
driveIndCalResultService
=
SpringUtil
.
getBean
(
DriveIndCalResultService
.
class
);
private
IndScorecardService
indScorecardService
=
SpringUtil
.
getBean
(
IndScorecardService
.
class
);
private
int
numberOfConfirm
=
0
;
//定义返回确认消息的子actor
private
int
numberOfConfirm
=
0
;
//定义返回确认消息的子actor
private
int
compareObjSize
=
0
;
//对标对象个数
private
int
compareObjSize
=
0
;
//对标对象个数
...
@@ -61,20 +64,49 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
...
@@ -61,20 +64,49 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
String
value
=
driveIndAverageAndRankMsg
.
getDriveIndValue
();
String
value
=
driveIndAverageAndRankMsg
.
getDriveIndValue
();
String
id
=
driveIndAverageAndRankMsg
.
getId
();
String
id
=
driveIndAverageAndRankMsg
.
getId
();
String
indType
=
driveIndAverageAndRankMsg
.
getIndType
();
String
indType
=
driveIndAverageAndRankMsg
.
getIndType
();
String
markType
=
driveIndAverageAndRankMsg
.
getMarkType
();
//评分卡id
valueMap
.
put
(
id
,
value
);
valueMap
.
put
(
id
,
value
);
values
.
add
(
value
);
values
.
add
(
value
);
if
(++
numberOfConfirm
>=
compareObjSize
)
{
//子actor全部返回
if
(++
numberOfConfirm
>=
compareObjSize
)
{
//子actor全部返回
//算平均数
//考核地区只有一个“全省”的情况下
String
average
=
CalculateUtils
.
averageValue
(
values
);
if
(!
"全省"
.
equals
(
driveIndAverageAndRankMsg
.
getCompareObj
()))
{
//算组内排名
//查询有没有全省的考核指标数据
Map
<
String
,
Integer
>
rankValue
=
CalculateUtils
.
rankValue
(
valueMap
,
indType
);
DriveIndCalResult
provinceDriveIndCalResult
=
driveIndCalResultService
.
findCompareObjInfo
(
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
driveIndAverageAndRankMsg
.
getDriveIndId
(),
driveIndAverageAndRankMsg
.
getDate
(),
//根据id获取指标值结果
"全省"
);
DriveIndCalResult
driveIndCalResult
=
driveIndCalResultService
.
findById
(
entry
.
getKey
());
String
actualAverage
=
"0.0"
;
if
(
driveIndCalResult
!=
null
)
{
if
(
provinceDriveIndCalResult
!=
null
)
{
driveIndCalResult
.
setAverage
(
average
);
//获取实际平均分
driveIndCalResult
.
setRank
(
entry
.
getValue
());
actualAverage
=
provinceDriveIndCalResult
.
getValue
();
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
}
//算组内平均数
String
average
=
CalculateUtils
.
averageValue
(
values
);
//算组内排名
Map
<
String
,
Integer
>
rankValue
=
CalculateUtils
.
rankValue
(
valueMap
,
indType
);
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
//根据id获取指标值结果
DriveIndCalResult
driveIndCalResult
=
driveIndCalResultService
.
findById
(
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获取指标值结果
DriveIndCalResult
driveIndCalResult
=
driveIndCalResultService
.
findById
(
entry
.
getKey
());
if
(
driveIndCalResult
!=
null
)
{
//计算分数
Map
<
String
,
String
>
scoreMap
=
indScorecardService
.
calculateIndiScore
(
driveIndCalResult
.
getIndId
(),
driveIndCalResult
.
getDate
(),
driveIndCalResult
.
getCompareObj
(),
markType
,
driveIndCalResult
.
getCompareId
());
driveIndCalResult
.
setScore
(
scoreMap
.
get
(
"score"
));
driveIndCalResult
.
setImproveScore
(
scoreMap
.
get
(
"improveScore"
));
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
}
}
}
}
}
}
}
...
...
src/main/java/com/keymobile/indicators/akka/message/specific/DriveIndAverageAndRankMsg.java
View file @
1b3a72c7
...
@@ -16,9 +16,10 @@ public class DriveIndAverageAndRankMsg implements Serializable{
...
@@ -16,9 +16,10 @@ public class DriveIndAverageAndRankMsg implements Serializable{
private
String
driveIndValue
;
private
String
driveIndValue
;
private
String
unit
;
private
String
unit
;
private
String
indType
;
private
String
indType
;
private
String
markType
;
public
DriveIndAverageAndRankMsg
(
String
id
,
String
compareId
,
String
driveIndId
,
String
compareObj
,
public
DriveIndAverageAndRankMsg
(
String
id
,
String
compareId
,
String
driveIndId
,
String
compareObj
,
int
date
,
String
driveIndValue
,
String
unit
,
String
indType
)
{
int
date
,
String
driveIndValue
,
String
unit
,
String
indType
,
String
markType
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
compareId
=
compareId
;
this
.
compareId
=
compareId
;
this
.
driveIndId
=
driveIndId
;
this
.
driveIndId
=
driveIndId
;
...
@@ -26,7 +27,8 @@ public class DriveIndAverageAndRankMsg implements Serializable{
...
@@ -26,7 +27,8 @@ public class DriveIndAverageAndRankMsg implements Serializable{
this
.
date
=
date
;
this
.
date
=
date
;
this
.
driveIndValue
=
driveIndValue
;
this
.
driveIndValue
=
driveIndValue
;
this
.
unit
=
unit
;
this
.
unit
=
unit
;
this
.
setIndType
(
indType
);
this
.
indType
=
indType
;
this
.
markType
=
markType
;
}
}
public
String
getCompareId
()
{
public
String
getCompareId
()
{
...
@@ -92,4 +94,12 @@ public class DriveIndAverageAndRankMsg implements Serializable{
...
@@ -92,4 +94,12 @@ public class DriveIndAverageAndRankMsg implements Serializable{
public
void
setIndType
(
String
indType
)
{
public
void
setIndType
(
String
indType
)
{
this
.
indType
=
indType
;
this
.
indType
=
indType
;
}
}
public
String
getMarkType
()
{
return
markType
;
}
public
void
setMarkType
(
String
markType
)
{
this
.
markType
=
markType
;
}
}
}
src/main/java/com/keymobile/indicators/api/hytobacco/IndScorecardCtrl.java
0 → 100644
View file @
1b3a72c7
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.keymobile.indicators.model.entity.scorecard.IndScorecard
;
import
com.keymobile.indicators.service.hytobacco.IndScorecardService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
tags
={
"评分卡CRUD"
})
@RestController
@RequestMapping
(
value
=
"/indScorecard"
)
public
class
IndScorecardCtrl
{
@Autowired
private
IndScorecardService
indScorecardService
;
@ApiOperation
(
value
=
"新增/修改"
,
notes
=
"新增/修改"
)
@PostMapping
(
value
=
"/saveOrUpdate"
)
public
String
saveOrUpdate
(
@RequestBody
IndScorecard
indScorecard
)
{
return
indScorecardService
.
saveOrUpdate
(
indScorecard
);
}
@ApiOperation
(
value
=
"删除"
,
notes
=
"删除"
)
@PostMapping
(
value
=
"/delete"
)
public
void
delete
(
@RequestBody
List
<
String
>
ids
)
{
indScorecardService
.
delete
(
ids
);
}
@ApiOperation
(
value
=
"获取所有评分卡"
,
notes
=
"获取所有评分卡"
)
@PostMapping
(
value
=
"/getAll"
)
public
List
<
IndScorecard
>
getAll
(){
return
indScorecardService
.
getAll
();
}
@ApiOperation
(
value
=
"根据id获取评分卡"
,
notes
=
"根据id获取评分卡"
)
@PostMapping
(
value
=
"/findById"
)
public
IndScorecard
findById
(
@RequestParam
String
id
)
{
return
indScorecardService
.
findById
(
id
);
}
@ApiOperation
(
value
=
"根据评分卡计算指标分数"
,
notes
=
"根据评分卡计算指标分数"
)
@PostMapping
(
value
=
"/calculateIndiScore"
)
public
Map
<
String
,
String
>
calculateIndiScore
(
@RequestParam
String
indId
,
@RequestParam
int
date
,
@RequestParam
String
compareObj
,
@RequestParam
String
indScorecardId
,
@RequestParam
String
compareId
)
{
return
indScorecardService
.
calculateIndiScore
(
indId
,
date
,
compareObj
,
indScorecardId
,
compareId
);
}
}
src/main/java/com/keymobile/indicators/api/hytobacco/IndicatorsValueCtrl.java
View file @
1b3a72c7
...
@@ -33,6 +33,15 @@ public class IndicatorsValueCtrl {
...
@@ -33,6 +33,15 @@ public class IndicatorsValueCtrl {
}
}
}
}
@ApiOperation
(
value
=
"上传解析县2020第一季度基础指标数据"
,
notes
=
"上传解析县2020第一季度基础指标数据"
)
@PostMapping
(
value
=
"/importXianOneIndiValue"
)
public
void
importXianOneIndiValue
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
try
(
InputStream
is
=
file
.
getInputStream
()){
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
is
);
indicatorsValueService
.
importXianOneIndicatorsData
(
xssfWorkbook
);
}
}
@ApiOperation
(
value
=
"上传解析市基础指标数据"
,
notes
=
"上传解析市基础指标数据"
)
@ApiOperation
(
value
=
"上传解析市基础指标数据"
,
notes
=
"上传解析市基础指标数据"
)
@PostMapping
(
value
=
"/importShiIndiValue"
)
@PostMapping
(
value
=
"/importShiIndiValue"
)
public
void
importShiIndicatorsData
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
public
void
importShiIndicatorsData
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
...
@@ -48,4 +57,31 @@ public class IndicatorsValueCtrl {
...
@@ -48,4 +57,31 @@ public class IndicatorsValueCtrl {
@RequestParam
String
type
,
@RequestParam
(
required
=
false
)
String
compareId
)
throws
Exception
{
@RequestParam
String
type
,
@RequestParam
(
required
=
false
)
String
compareId
)
throws
Exception
{
indicatorsValueService
.
fillExcelFileOne
(
indIds
,
date
,
type
,
compareId
);
indicatorsValueService
.
fillExcelFileOne
(
indIds
,
date
,
type
,
compareId
);
}
}
@ApiOperation
(
value
=
"填充excel file2数据"
,
notes
=
"填充excel file2数据"
)
@PostMapping
(
value
=
"/fillExcelFileTwo"
)
public
void
fillExcelFileTwo
(
@RequestBody
List
<
String
>
indIds
)
throws
Exception
{
indicatorsValueService
.
fillExcelFileTwo
(
indIds
);
}
@ApiOperation
(
value
=
"填充excel file3数据"
,
notes
=
"填充excel file3数据"
)
@PostMapping
(
value
=
"/fillExcelFileThree"
)
public
void
fillExcelFileThree
(
@RequestBody
List
<
String
>
indIds
,
@RequestParam
String
type
)
throws
Exception
{
indicatorsValueService
.
fillExcelFileThree
(
indIds
,
type
);
}
@ApiOperation
(
value
=
"填充excel file4数据"
,
notes
=
"填充excel file4数据"
)
@PostMapping
(
value
=
"/fillExcelFileFour"
)
public
void
fillExcelFileFour
(
@RequestBody
List
<
String
>
indIds
,
@RequestParam
int
date
,
@RequestParam
String
type
)
throws
Exception
{
indicatorsValueService
.
fillExcelFileFour
(
indIds
,
date
,
type
);
}
@ApiOperation
(
value
=
"填充excel file5数据"
,
notes
=
"填充excel file5数据"
)
@PostMapping
(
value
=
"/fillExcelFileFive"
)
public
void
fillExcelFileFive
(
@RequestBody
List
<
String
>
indIds
,
@RequestParam
int
date
,
@RequestParam
String
type
,
@RequestParam
(
required
=
false
)
String
compareIds
)
throws
Exception
{
indicatorsValueService
.
fillExcelFileFive
(
indIds
,
date
,
type
,
compareIds
);
}
}
}
src/main/java/com/keymobile/indicators/model/entity/DriveIndCalResult.java
View file @
1b3a72c7
...
@@ -34,8 +34,11 @@ public class DriveIndCalResult implements Serializable{
...
@@ -34,8 +34,11 @@ public class DriveIndCalResult implements Serializable{
private
String
isRight
;
//表示考核指标的值是否计算正常得到的 0:计算有误 1:计算正常
private
String
isRight
;
//表示考核指标的值是否计算正常得到的 0:计算有误 1:计算正常
private
String
lastUpdateTime
=
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
private
String
lastUpdateTime
=
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
private
String
lastUpdater
;
private
String
lastUpdater
;
private
String
average
;
//平均数
private
String
average
;
//
组内
平均数
private
int
rank
;
//同组排名
private
int
rank
;
//同组排名
private
String
score
;
//指标评分分数
private
String
improveScore
;
//改善提升得分
private
String
actualAverage
;
//实际平均数:用于省对市的操作,如果有全省的基础项数据,直接拿全省的基础项数据算考核指标做为其实际平均值
public
DriveIndCalResult
(
String
compareId
,
String
indId
,
String
compareObj
,
int
date
,
String
value
,
public
DriveIndCalResult
(
String
compareId
,
String
indId
,
String
compareObj
,
int
date
,
String
value
,
String
unit
,
String
type
,
String
isRight
,
String
lastUpdater
)
{
String
unit
,
String
type
,
String
isRight
,
String
lastUpdater
)
{
...
...
src/main/java/com/keymobile/indicators/model/entity/scorecard/ImproveScoreDef.java
0 → 100644
View file @
1b3a72c7
package
com
.
keymobile
.
indicators
.
model
.
entity
.
scorecard
;
import
java.io.Serializable
;
import
lombok.Data
;
@Data
public
class
ImproveScoreDef
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
String
gradeType
;
//改善提升类型 0:同期排位比 1:单位同期比
private
String
opType
;
//加减分类型 0:累计加减 1:一次加减 (通常同期排位比配合累计加减使用)
private
String
gradeOp
;
//加减分操作 0:加分 1:减分
private
double
score
;
//分值
}
src/main/java/com/keymobile/indicators/model/entity/scorecard/IndScorecard.java
0 → 100644
View file @
1b3a72c7
package
com
.
keymobile
.
indicators
.
model
.
entity
.
scorecard
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.keymobile.indicators.utils.DateUtils
;
import
lombok.Data
;
/**
*author:zhangkb time:2020-5-6 desc:考核指标评分卡
*/
@Data
@Document
(
collection
=
"drive_ind_score_card"
)
public
class
IndScorecard
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
String
id
;
private
String
cardName
;
private
String
desc
;
private
String
scoreType
;
//综合评分类型 0:定义 1:公式
//定义综合评价
private
double
indBaseScore
;
//基础分
private
double
moreAverage
;
//大于组内平均分加分
private
double
lessAverage
;
//小于组内平均分减分
private
List
<
RankScoreDef
>
addScoreItem
=
new
ArrayList
<>();
//加分项
private
List
<
RankScoreDef
>
minusScoreItem
=
new
ArrayList
<>();
//减分项
//公式综合评价
private
double
bestIndScore
;
//最佳指标分
private
double
worstIndScore
;
//最差指标分
private
String
otherCalFormula
;
//其他计算公式
//改善提升
private
double
limitScore
;
//上限分数
private
List
<
ImproveScoreDef
>
improveScoreItem
=
new
ArrayList
<>();
//改善提升分数
private
String
lastUpdateTime
=
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
private
String
lastUpdater
;
public
void
setAddScoreItem
(
List
<
RankScoreDef
>
addScoreItem
)
{
this
.
addScoreItem
.
addAll
(
addScoreItem
);
}
public
void
setMinusScoreItem
(
List
<
RankScoreDef
>
minusScoreItem
)
{
this
.
minusScoreItem
.
addAll
(
minusScoreItem
);
}
public
void
setImproveScoreItem
(
List
<
ImproveScoreDef
>
improveScoreItem
)
{
this
.
improveScoreItem
.
addAll
(
improveScoreItem
);
}
}
src/main/java/com/keymobile/indicators/model/entity/scorecard/RankScoreDef.java
0 → 100644
View file @
1b3a72c7
package
com
.
keymobile
.
indicators
.
model
.
entity
.
scorecard
;
import
java.io.Serializable
;
import
lombok.Data
;
@Data
public
class
RankScoreDef
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
int
rank
;
private
double
score
;
}
src/main/java/com/keymobile/indicators/persistence/hyindicators/DriveIndCalResultRepository.java
View file @
1b3a72c7
package
com
.
keymobile
.
indicators
.
persistence
.
hyindicators
;
package
com
.
keymobile
.
indicators
.
persistence
.
hyindicators
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.keymobile.indicators.model.entity.DriveIndCalResult
;
import
com.keymobile.indicators.model.entity.DriveIndCalResult
;
public
interface
DriveIndCalResultRepository
extends
MongoRepository
<
DriveIndCalResult
,
String
>{
public
interface
DriveIndCalResultRepository
extends
MongoRepository
<
DriveIndCalResult
,
String
>{
public
List
<
DriveIndCalResult
>
findByIndId
(
String
indId
);
public
List
<
DriveIndCalResult
>
findByIndIdAndCompareObj
(
String
indId
,
String
compareObj
);
public
Optional
<
DriveIndCalResult
>
findByIndIdAndDateAndCompareObj
(
String
indId
,
int
date
,
String
compareObj
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDate
(
String
indId
,
int
date
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDate
(
String
indId
,
int
date
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDateAndActualAverageIsNotNull
(
String
indId
,
int
date
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDate
(
String
indId
,
int
date
,
Sort
sort
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDateAndActualAverageIsNotNull
(
String
indId
,
int
date
,
Sort
sort
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDateAndCompareId
(
String
indId
,
int
date
,
String
compareId
,
Sort
sort
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDateAndCompareId
(
String
indId
,
int
date
,
String
compareId
);
public
List
<
DriveIndCalResult
>
findByIndIdAndDateAndCompareId
(
String
indId
,
int
date
,
String
compareId
);
}
}
src/main/java/com/keymobile/indicators/persistence/hyindicators/IndScorecardRepository.java
0 → 100644
View file @
1b3a72c7
package
com
.
keymobile
.
indicators
.
persistence
.
hyindicators
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.keymobile.indicators.model.entity.scorecard.IndScorecard
;
public
interface
IndScorecardRepository
extends
MongoRepository
<
IndScorecard
,
String
>{
}
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndCalResultService.java
View file @
1b3a72c7
...
@@ -36,6 +36,15 @@ public class DriveIndCalResultService {
...
@@ -36,6 +36,15 @@ public class DriveIndCalResultService {
return
null
;
return
null
;
}
}
public
DriveIndCalResult
findCompareObjInfo
(
String
driveIndId
,
int
date
,
String
compareObj
)
{
Optional
<
DriveIndCalResult
>
resultOp
=
driveIndCalResultRepo
.
findByIndIdAndDateAndCompareObj
(
driveIndId
,
date
,
compareObj
);
if
(
resultOp
.
isPresent
())
{
return
resultOp
.
get
();
}
return
null
;
}
public
void
calculateComp
(
String
compareId
,
String
compareObjsString
,
String
driveIndIdsString
,
public
void
calculateComp
(
String
compareId
,
String
compareObjsString
,
String
driveIndIdsString
,
int
date
)
{
int
date
)
{
String
[]
compareObjs
=
compareObjsString
.
split
(
";"
);
String
[]
compareObjs
=
compareObjsString
.
split
(
";"
);
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndScorecardService.java
0 → 100644
View file @
1b3a72c7
This diff is collapsed.
Click to expand it.
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsValueService.java
View file @
1b3a72c7
This diff is collapsed.
Click to expand it.
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
1b3a72c7
...
@@ -10,9 +10,43 @@ import java.util.Map;
...
@@ -10,9 +10,43 @@ import java.util.Map;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.googlecode.aviator.AviatorEvaluator
;
import
com.googlecode.aviator.AviatorEvaluator
;
public
class
CalculateUtils
{
public
class
CalculateUtils
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
CalculateUtils
.
class
);
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
))
{
Object
value
=
null
;
if
(
"0"
.
equals
(
type
))
{
if
(
"%"
.
equals
(
unit
))
{
formula
.
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
);
}
else
{
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
}
}
else
{
formula
.
append
(
"("
).
append
(
currentValue
).
append
(
"-"
).
append
(
sameValue
).
append
(
")"
)
.
append
(
"/"
).
append
(
sameValue
).
append
(
"*100"
);
}
value
=
AviatorEvaluator
.
execute
(
formula
.
toString
());
if
(
value
!=
null
&&
!
"NaN"
.
equals
(
value
.
toString
())
&&
!
"Infinite"
.
equals
(
value
.
toString
()))
{
try
{
gowthValue
=
String
.
format
(
"%.4f"
,
new
BigDecimal
((
Double
)
value
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"计算异常:"
+
formula
.
toString
());
}
}
}
return
gowthValue
;
}
//考虑同分并列的情况,type:0 正向排序:从大到小 1:反向排序:从小到大
//考虑同分并列的情况,type:0 正向排序:从大到小 1:反向排序:从小到大
public
static
Map
<
String
,
Integer
>
rankValue
(
Map
<
String
,
String
>
valueMap
,
String
type
){
public
static
Map
<
String
,
Integer
>
rankValue
(
Map
<
String
,
String
>
valueMap
,
String
type
){
...
@@ -61,6 +95,7 @@ public class CalculateUtils {
...
@@ -61,6 +95,7 @@ public class CalculateUtils {
return
result
;
return
result
;
}
}
//计算平均值
public
static
String
averageValue
(
List
<
String
>
values
)
{
public
static
String
averageValue
(
List
<
String
>
values
)
{
String
calValue
=
"0.0"
;
String
calValue
=
"0.0"
;
StringBuilder
formula
=
new
StringBuilder
();
StringBuilder
formula
=
new
StringBuilder
();
...
@@ -138,7 +173,7 @@ public class CalculateUtils {
...
@@ -138,7 +173,7 @@ public class CalculateUtils {
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// System.out.println(AviatorEvaluator.execute("0/1.
0"));
System
.
out
.
println
(
AviatorEvaluator
.
execute
(
"(35.9756-84.4884)/(35.9756-2556.3310)*1
0"
));
// Map<String, Object> env = Maps.newHashMap();
// Map<String, Object> env = Maps.newHashMap();
// env.put("F004", 18471.8080);
// env.put("F004", 18471.8080);
...
@@ -146,13 +181,13 @@ public class CalculateUtils {
...
@@ -146,13 +181,13 @@ public class CalculateUtils {
// // 输出的是6.333333333333333
// // 输出的是6.333333333333333
// System.out.println(AviatorEvaluator.execute("F004/F002*100", env));
// System.out.println(AviatorEvaluator.execute("F004/F002*100", env));
List
<
String
>
values
=
new
ArrayList
<>();
//
List<String> values = new ArrayList<>();
values
.
add
(
"0"
);
//
values.add("0");
values
.
add
(
"18"
);
//
values.add("18");
values
.
add
(
"18"
);
//
values.add("18");
CalculateUtils
cal
=
new
CalculateUtils
();
//
CalculateUtils cal = new CalculateUtils();
String
average
=
cal
.
averageValue
(
values
);
//
String average = cal.averageValue(values);
System
.
out
.
println
(
average
);
//
System.out.println(average);
// Map<String,String> map = new HashMap<>();
// Map<String,String> map = new HashMap<>();
// map.put("1", "NaN");
// map.put("1", "NaN");
...
...
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