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
084d81a1
Commit
084d81a1
authored
Aug 31, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加对标运算试运算功能代码
parent
b4dcd4d2
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1002 additions
and
21 deletions
+1002
-21
BeforeCompareUnitCalActor.java
...tors/akka/actor/indicators/BeforeCompareUnitCalActor.java
+22
-3
CompareUnitCalActor.java
...indicators/akka/actor/indicators/CompareUnitCalActor.java
+5
-1
DriveIndIdCalActor.java
.../indicators/akka/actor/indicators/DriveIndIdCalActor.java
+68
-4
DriveIndIdObjCalActor.java
...dicators/akka/actor/indicators/DriveIndIdObjCalActor.java
+31
-1
StartCompareUnitCalActor.java
...ators/akka/actor/indicators/StartCompareUnitCalActor.java
+51
-3
CompareUnitCalMsg.java
...indicators/akka/message/indicators/CompareUnitCalMsg.java
+12
-1
DriveIndIdCalMsg.java
.../indicators/akka/message/indicators/DriveIndIdCalMsg.java
+11
-1
DriveIndIdObjCalMsg.java
...dicators/akka/message/indicators/DriveIndIdObjCalMsg.java
+12
-1
StartCompareUnitCalMsg.java
...ators/akka/message/indicators/StartCompareUnitCalMsg.java
+12
-1
DriveIndCalResultCtrl.java
...obile/indicators/api/hytobacco/DriveIndCalResultCtrl.java
+20
-3
TestDriveIndCalResultDef.java
...cators/model/entity/testrun/TestDriveIndCalResultDef.java
+60
-0
TestObjScoreCalResult.java
...ndicators/model/entity/testrun/TestObjScoreCalResult.java
+30
-0
TestDriveIndCalResultDefMapper.java
.../model/mapper/testrun/TestDriveIndCalResultDefMapper.java
+28
-0
TestObjScoreCalResultMapper.java
...ors/model/mapper/testrun/TestObjScoreCalResultMapper.java
+20
-0
DriveIndCalResultService.java
...ndicators/service/hytobacco/DriveIndCalResultService.java
+2
-2
TestDriveIndCalResultService.java
...icators/service/testrun/TestDriveIndCalResultService.java
+64
-0
TestScoreRuleService.java
...bile/indicators/service/testrun/TestScoreRuleService.java
+380
-0
TestDriveIndCalResultDefMapper.xml
...ources/mybatis/mapping/TestDriveIndCalResultDefMapper.xml
+109
-0
TestObjScoreCalResultMapper.xml
...resources/mybatis/mapping/TestObjScoreCalResultMapper.xml
+65
-0
No files found.
src/main/java/com/keymobile/indicators/akka/actor/indicators/BeforeCompareUnitCalActor.java
View file @
084d81a1
...
@@ -39,6 +39,8 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
...
@@ -39,6 +39,8 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
private
String
code
=
null
;
private
String
code
=
null
;
private
String
isTest
=
null
;
//试运行,0:试运行 1:正式运行
@Override
@Override
public
Receive
createReceive
()
{
public
Receive
createReceive
()
{
return
receiveBuilder
()
return
receiveBuilder
()
...
@@ -47,10 +49,17 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
...
@@ -47,10 +49,17 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
sameCompareUnitDef
.
addAll
(
compareUnitDefs
);
sameCompareUnitDef
.
addAll
(
compareUnitDefs
);
sameDate
=
compareUnitDefs
.
get
(
0
).
getDate
();
sameDate
=
compareUnitDefs
.
get
(
0
).
getDate
();
code
=
beforeCompareUnitCalMsg
.
getCode
();
code
=
beforeCompareUnitCalMsg
.
getCode
();
isTest
=
beforeCompareUnitCalMsg
.
getIsTest
();
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"进行date:"
+
sameDate
+
" 的对标单元试运行计算....."
);
}
else
{
logger
.
info
(
"进行date:"
+
sameDate
+
" 的对标单元计算....."
);
logger
.
info
(
"进行date:"
+
sameDate
+
" 的对标单元计算....."
);
}
//计算同期对标单元
//计算同期对标单元
StartCompareUnitCalMsg
startCompareUnitCalMsg
=
new
StartCompareUnitCalMsg
(
StartCompareUnitCalMsg
startCompareUnitCalMsg
=
new
StartCompareUnitCalMsg
(
compareUnitDefs
,
beforeCompareUnitCalMsg
.
getCode
());
compareUnitDefs
,
beforeCompareUnitCalMsg
.
getCode
(),
beforeCompareUnitCalMsg
.
getIsTest
());
ActorRef
startCompareUnitCalActor
=
this
.
getContext
().
actorOf
(
Props
.
create
(
ActorRef
startCompareUnitCalActor
=
this
.
getContext
().
actorOf
(
Props
.
create
(
StartCompareUnitCalActor
.
class
,()->
new
StartCompareUnitCalActor
(
getSelf
())));
StartCompareUnitCalActor
.
class
,()->
new
StartCompareUnitCalActor
(
getSelf
())));
startCompareUnitCalActor
.
tell
(
startCompareUnitCalMsg
,
getSelf
());
startCompareUnitCalActor
.
tell
(
startCompareUnitCalMsg
,
getSelf
());
...
@@ -66,16 +75,22 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
...
@@ -66,16 +75,22 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
}
}
if
(!
currentCompareUnitDef
.
isEmpty
())
{
if
(!
currentCompareUnitDef
.
isEmpty
())
{
currentDate
=
currentCompareUnitDef
.
get
(
0
).
getDate
();
currentDate
=
currentCompareUnitDef
.
get
(
0
).
getDate
();
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"进行date:"
+
currentDate
+
" 的对标单元试运行计算....."
);
}
else
{
logger
.
info
(
"进行date:"
+
currentDate
+
" 的对标单元计算....."
);
logger
.
info
(
"进行date:"
+
currentDate
+
" 的对标单元计算....."
);
}
//计算同期对标单元
//计算同期对标单元
StartCompareUnitCalMsg
startCompareUnitCalMsg
=
new
StartCompareUnitCalMsg
(
StartCompareUnitCalMsg
startCompareUnitCalMsg
=
new
StartCompareUnitCalMsg
(
currentCompareUnitDef
,
code
);
currentCompareUnitDef
,
code
,
isTest
);
ActorRef
startCompareUnitCalActor
=
this
.
getContext
().
actorOf
(
Props
.
create
(
ActorRef
startCompareUnitCalActor
=
this
.
getContext
().
actorOf
(
Props
.
create
(
StartCompareUnitCalActor
.
class
,()->
new
StartCompareUnitCalActor
(
getSelf
())));
StartCompareUnitCalActor
.
class
,()->
new
StartCompareUnitCalActor
(
getSelf
())));
startCompareUnitCalActor
.
tell
(
startCompareUnitCalMsg
,
getSelf
());
startCompareUnitCalActor
.
tell
(
startCompareUnitCalMsg
,
getSelf
());
}
}
}
}
if
(
numberOfConfirm
>
1
)
{
if
(
numberOfConfirm
>
1
)
{
if
(
"1"
.
equals
(
isTest
))
{
//正式对标单元运算才进行报表数据生成
Map
<
String
,
String
>
compareObjMap
=
new
HashMap
<>();
Map
<
String
,
String
>
compareObjMap
=
new
HashMap
<>();
logger
.
info
(
"进行date:"
+
currentDate
+
" 指标本期同期报表数据和考核指标报表数据2数据整合"
);
logger
.
info
(
"进行date:"
+
currentDate
+
" 指标本期同期报表数据和考核指标报表数据2数据整合"
);
...
@@ -119,10 +134,14 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
...
@@ -119,10 +134,14 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
unitDef
.
getCompareId
(),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
unitDef
.
getCompareId
(),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
unitDef
.
getDate
(),
code
);
unitDef
.
getDate
(),
code
);
}
}
}
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"本期同期对标单元试运行计算完成"
);
}
else
{
logger
.
info
(
"本期同期对标单元计算完成"
);
logger
.
info
(
"本期同期对标单元计算完成"
);
}
}
}
}
}
})
})
.
build
();
.
build
();
}
}
...
...
src/main/java/com/keymobile/indicators/akka/actor/indicators/CompareUnitCalActor.java
View file @
084d81a1
...
@@ -50,6 +50,8 @@ public class CompareUnitCalActor extends AbstractActor{
...
@@ -50,6 +50,8 @@ public class CompareUnitCalActor extends AbstractActor{
private
String
code
;
//机构编码
private
String
code
;
//机构编码
private
String
isTest
;
private
final
ActorRef
startCompareUnitCalActor
;
//定义父actor
private
final
ActorRef
startCompareUnitCalActor
;
//定义父actor
static
public
Props
props
(
ActorRef
startCompareUnitCalActor
)
{
static
public
Props
props
(
ActorRef
startCompareUnitCalActor
)
{
...
@@ -71,6 +73,7 @@ public class CompareUnitCalActor extends AbstractActor{
...
@@ -71,6 +73,7 @@ public class CompareUnitCalActor extends AbstractActor{
averageObj
=
compareUnitDef
.
getAverageObj
();
averageObj
=
compareUnitDef
.
getAverageObj
();
objScoreRuleId
=
compareUnitDef
.
getObjScoreRuleId
();
objScoreRuleId
=
compareUnitDef
.
getObjScoreRuleId
();
code
=
compareUnitCalMsg
.
getCode
();
code
=
compareUnitCalMsg
.
getCode
();
isTest
=
compareUnitCalMsg
.
getIsTest
();
//新增运行日志记录
//新增运行日志记录
CompareUnitCalLog
compCalLog
=
new
CompareUnitCalLog
(
compareId
,
date
,
CompareUnitCalLog
compCalLog
=
new
CompareUnitCalLog
(
compareId
,
date
,
...
@@ -92,7 +95,8 @@ public class CompareUnitCalActor extends AbstractActor{
...
@@ -92,7 +95,8 @@ public class CompareUnitCalActor extends AbstractActor{
for
(
String
indId
:
indIdsList
)
{
for
(
String
indId
:
indIdsList
)
{
DriveIndIdCalMsg
driveIndIdCalMsg
=
new
DriveIndIdCalMsg
(
DriveIndIdCalMsg
driveIndIdCalMsg
=
new
DriveIndIdCalMsg
(
compareUnitDef
.
getCompareId
(),
indId
,
compareObjsList
,
compareUnitDef
.
getDate
(),
compareUnitDef
.
getCompareId
(),
indId
,
compareObjsList
,
compareUnitDef
.
getDate
(),
firstExe
,
averageObj
,
compCalLogId
,
compareUnitCalMsg
.
getCode
());
firstExe
,
averageObj
,
compCalLogId
,
compareUnitCalMsg
.
getCode
(),
compareUnitCalMsg
.
getIsTest
());
//start akka
//start akka
ActorRef
driveIndIdCalActor
=
this
.
getContext
()
ActorRef
driveIndIdCalActor
=
this
.
getContext
()
.
actorOf
(
Props
.
create
(
DriveIndIdCalActor
.
class
,
.
actorOf
(
Props
.
create
(
DriveIndIdCalActor
.
class
,
...
...
src/main/java/com/keymobile/indicators/akka/actor/indicators/DriveIndIdCalActor.java
View file @
084d81a1
...
@@ -16,10 +16,12 @@ import com.keymobile.indicators.akka.message.indicators.DriveIndIdObjCalMsg;
...
@@ -16,10 +16,12 @@ import com.keymobile.indicators.akka.message.indicators.DriveIndIdObjCalMsg;
import
com.keymobile.indicators.akka.message.indicators.FirstExeConfirmMsg
;
import
com.keymobile.indicators.akka.message.indicators.FirstExeConfirmMsg
;
import
com.keymobile.indicators.model.entity.DimValue
;
import
com.keymobile.indicators.model.entity.DimValue
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.testrun.TestDriveIndCalResultDef
;
import
com.keymobile.indicators.service.hytobacco.DriveIndCalResultService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndCalResultService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndDefService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndDefService
;
import
com.keymobile.indicators.service.hytobacco.IndScorecardService
;
import
com.keymobile.indicators.service.hytobacco.IndScorecardService
;
import
com.keymobile.indicators.service.report.IndicatorsReportService
;
import
com.keymobile.indicators.service.report.IndicatorsReportService
;
import
com.keymobile.indicators.service.testrun.TestDriveIndCalResultService
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.keymobile.indicators.utils.SpringUtil
;
import
com.keymobile.indicators.utils.SpringUtil
;
...
@@ -32,6 +34,8 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -32,6 +34,8 @@ public class DriveIndIdCalActor extends AbstractActor{
private
DriveIndCalResultService
driveIndCalResultService
=
SpringUtil
.
getBean
(
DriveIndCalResultService
.
class
);
private
DriveIndCalResultService
driveIndCalResultService
=
SpringUtil
.
getBean
(
DriveIndCalResultService
.
class
);
private
TestDriveIndCalResultService
testDriveIndCalResultService
=
SpringUtil
.
getBean
(
TestDriveIndCalResultService
.
class
);
private
IndScorecardService
indScorecardService
=
SpringUtil
.
getBean
(
IndScorecardService
.
class
);
private
IndScorecardService
indScorecardService
=
SpringUtil
.
getBean
(
IndScorecardService
.
class
);
private
DriveIndDefService
driveIndDefService
=
SpringUtil
.
getBean
(
DriveIndDefService
.
class
);
private
DriveIndDefService
driveIndDefService
=
SpringUtil
.
getBean
(
DriveIndDefService
.
class
);
...
@@ -52,6 +56,8 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -52,6 +56,8 @@ public class DriveIndIdCalActor extends AbstractActor{
private
String
code
;
//机构编码
private
String
code
;
//机构编码
private
String
isTest
;
private
final
ActorRef
compareUnitCalActor
;
//定义父actor
private
final
ActorRef
compareUnitCalActor
;
//定义父actor
static
public
Props
props
(
ActorRef
compareUnitCalActor
)
{
static
public
Props
props
(
ActorRef
compareUnitCalActor
)
{
...
@@ -74,6 +80,8 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -74,6 +80,8 @@ public class DriveIndIdCalActor extends AbstractActor{
averageObj
=
driveIndIdCalMsg
.
getAverageObj
();
averageObj
=
driveIndIdCalMsg
.
getAverageObj
();
compareObjSize
=
compareObjs
.
size
();
compareObjSize
=
compareObjs
.
size
();
code
=
driveIndIdCalMsg
.
getCode
();
code
=
driveIndIdCalMsg
.
getCode
();
isTest
=
driveIndIdCalMsg
.
getIsTest
();
//日志记录id
//日志记录id
Integer
compCalLogId
=
driveIndIdCalMsg
.
getCompCalLogId
();
Integer
compCalLogId
=
driveIndIdCalMsg
.
getCompCalLogId
();
...
@@ -85,7 +93,8 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -85,7 +93,8 @@ public class DriveIndIdCalActor extends AbstractActor{
dimValueList
.
add
(
dimDateObj
);
dimValueList
.
add
(
dimDateObj
);
DriveIndIdObjCalMsg
driveIndIdObjCalMsg
=
new
DriveIndIdObjCalMsg
(
compareId
,
DriveIndIdObjCalMsg
driveIndIdObjCalMsg
=
new
DriveIndIdObjCalMsg
(
compareId
,
indId
,
compareObj
,
date
,
dimValueList
,
compCalLogId
,
driveIndIdCalMsg
.
getCode
());
indId
,
compareObj
,
date
,
dimValueList
,
compCalLogId
,
driveIndIdCalMsg
.
getCode
(),
driveIndIdCalMsg
.
getIsTest
());
ActorRef
driveIndIdObjCalActor
=
this
.
getContext
()
ActorRef
driveIndIdObjCalActor
=
this
.
getContext
()
.
actorOf
(
Props
.
create
(
DriveIndIdObjCalActor
.
class
,
.
actorOf
(
Props
.
create
(
DriveIndIdObjCalActor
.
class
,
()->
new
DriveIndIdObjCalActor
(
getSelf
())));
()->
new
DriveIndIdObjCalActor
(
getSelf
())));
...
@@ -110,18 +119,30 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -110,18 +119,30 @@ public class DriveIndIdCalActor extends AbstractActor{
FirstExeConfirmMsg
firstExeConfirmMsg
=
new
FirstExeConfirmMsg
(
1
,
""
,
compCalLogId
);
FirstExeConfirmMsg
firstExeConfirmMsg
=
new
FirstExeConfirmMsg
(
1
,
""
,
compCalLogId
);
compareUnitCalActor
.
tell
(
firstExeConfirmMsg
,
ActorRef
.
noSender
());
compareUnitCalActor
.
tell
(
firstExeConfirmMsg
,
ActorRef
.
noSender
());
}
else
{
}
else
{
DriveIndCalResultDef
provinceDriveIndCalResult
=
null
;
String
actualAverage
=
"0.0"
;
//实际平均分
String
actualAverage
=
"0.0"
;
//实际平均分
if
(
StringUtils
.
isNotBlank
(
averageObj
))
{
if
(
StringUtils
.
isNotBlank
(
averageObj
))
{
provinceDriveIndCalResult
=
driveIndCalResultService
.
findCompareObjInfo
(
if
(
"0"
.
equals
(
isTest
))
{
TestDriveIndCalResultDef
provinceDriveIndCalResult
=
testDriveIndCalResultService
.
findCompareObjInfo
(
calIndAverageAndRankMsg
.
getDriveIndId
(),
calIndAverageAndRankMsg
.
getDriveIndId
(),
calIndAverageAndRankMsg
.
getDate
(),
calIndAverageAndRankMsg
.
getDate
(),
averageObj
,
code
);
averageObj
,
code
);
if
(
provinceDriveIndCalResult
!=
null
)
{
//获取实际平均分
actualAverage
=
provinceDriveIndCalResult
.
getValue
();
}
}
}
else
{
DriveIndCalResultDef
provinceDriveIndCalResult
=
driveIndCalResultService
.
findCompareObjInfo
(
calIndAverageAndRankMsg
.
getDriveIndId
(),
calIndAverageAndRankMsg
.
getDate
(),
averageObj
,
code
);
if
(
provinceDriveIndCalResult
!=
null
)
{
if
(
provinceDriveIndCalResult
!=
null
)
{
//获取实际平均分
//获取实际平均分
actualAverage
=
provinceDriveIndCalResult
.
getValue
();
actualAverage
=
provinceDriveIndCalResult
.
getValue
();
}
}
}
}
//算组内平均数
//算组内平均数
String
average
=
driveIndDefService
.
calGroupAverage
(
String
average
=
driveIndDefService
.
calGroupAverage
(
calIndAverageAndRankMsg
.
getIndFormula
(),
compareObjs
,
calIndAverageAndRankMsg
.
getIndFormula
(),
compareObjs
,
...
@@ -129,8 +150,20 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -129,8 +150,20 @@ public class DriveIndIdCalActor extends AbstractActor{
//算组内排名
//算组内排名
Map
<
String
,
Integer
>
rankValue
=
CalculateUtils
.
rankValue
(
valueMap
,
indType
);
Map
<
String
,
Integer
>
rankValue
=
CalculateUtils
.
rankValue
(
valueMap
,
indType
);
List
<
DriveIndCalResultDef
>
dataList
=
new
ArrayList
<>();
List
<
DriveIndCalResultDef
>
dataList
=
new
ArrayList
<>();
List
<
TestDriveIndCalResultDef
>
testDataList
=
new
ArrayList
<>();
//填充平均数和排名到考核结果中
//填充平均数和排名到考核结果中
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
if
(
"0"
.
equals
(
isTest
))
{
//根据id获取指标值结果
TestDriveIndCalResultDef
driveIndCalResult
=
testDriveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
if
(
driveIndCalResult
!=
null
)
{
driveIndCalResult
.
setAverage
(
average
);
driveIndCalResult
.
setRank
(
entry
.
getValue
());
driveIndCalResult
.
setActualAverage
(
actualAverage
);
testDataList
.
add
(
driveIndCalResult
);
}
}
else
{
//根据id获取指标值结果
//根据id获取指标值结果
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
...
@@ -141,12 +174,35 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -141,12 +174,35 @@ public class DriveIndIdCalActor extends AbstractActor{
dataList
.
add
(
driveIndCalResult
);
dataList
.
add
(
driveIndCalResult
);
}
}
}
}
}
if
(
"0"
.
equals
(
isTest
))
{
//批量保存修改
testDriveIndCalResultService
.
batchSaveOrUpdate
(
testDataList
);
//批量保存修改
testDataList
.
clear
();
}
else
{
//批量保存修改
//批量保存修改
driveIndCalResultService
.
batchSaveOrUpdate
(
dataList
);
driveIndCalResultService
.
batchSaveOrUpdate
(
dataList
);
//清空list
//批量保存修改//批量保存修改
dataList
.
clear
();
dataList
.
clear
();
}
//根据评分卡算指标分数
//根据评分卡算指标分数
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
for
(
Entry
<
String
,
Integer
>
entry
:
rankValue
.
entrySet
())
{
if
(
"0"
.
equals
(
isTest
))
{
//根据id获取指标值结果
TestDriveIndCalResultDef
driveIndCalResult
=
testDriveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
if
(
driveIndCalResult
!=
null
)
{
//计算分数
Map
<
String
,
String
>
scoreMap
=
indScorecardService
.
calculateIndiScore
(
driveIndCalResult
.
getIndId
(),
driveIndCalResult
.
getDate
(),
driveIndCalResult
.
getCompareObj
(),
scoreCardId
,
driveIndCalResult
.
getCompareId
(),
compareObjs
,
code
);
driveIndCalResult
.
setScore
(
scoreMap
.
get
(
"score"
));
driveIndCalResult
.
setImproveScore
(
scoreMap
.
get
(
"improveScore"
));
testDataList
.
add
(
driveIndCalResult
);
}
}
else
{
//根据id获取指标值结果
//根据id获取指标值结果
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
findById
(
Integer
.
parseInt
(
entry
.
getKey
()));
...
@@ -161,12 +217,20 @@ public class DriveIndIdCalActor extends AbstractActor{
...
@@ -161,12 +217,20 @@ public class DriveIndIdCalActor extends AbstractActor{
dataList
.
add
(
driveIndCalResult
);
dataList
.
add
(
driveIndCalResult
);
}
}
}
}
}
if
(
"0"
.
equals
(
isTest
))
{
//批量保存修改
testDriveIndCalResultService
.
batchSaveOrUpdate
(
testDataList
);
//清空list
testDataList
.
clear
();
}
else
{
//批量保存修改
//批量保存修改
driveIndCalResultService
.
batchSaveOrUpdate
(
dataList
);
driveIndCalResultService
.
batchSaveOrUpdate
(
dataList
);
//整合本期同期报表数据
//整合本期同期报表数据
//indiReportService.dealReportOneDatas(dataList);
//indiReportService.dealReportOneDatas(dataList);
//清空list
//清空list
dataList
.
clear
();
dataList
.
clear
();
}
//发送确认信息给父actor
//发送确认信息给父actor
FirstExeConfirmMsg
firstExeConfirmMsg
=
new
FirstExeConfirmMsg
(
1
,
""
,
compCalLogId
);
FirstExeConfirmMsg
firstExeConfirmMsg
=
new
FirstExeConfirmMsg
(
1
,
""
,
compCalLogId
);
...
...
src/main/java/com/keymobile/indicators/akka/actor/indicators/DriveIndIdObjCalActor.java
View file @
084d81a1
...
@@ -22,9 +22,11 @@ import com.keymobile.indicators.akka.message.indicators.GetBaseIndValueMsg;
...
@@ -22,9 +22,11 @@ import com.keymobile.indicators.akka.message.indicators.GetBaseIndValueMsg;
import
com.keymobile.indicators.model.entity.indicators.CompareUnitCalLog
;
import
com.keymobile.indicators.model.entity.indicators.CompareUnitCalLog
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.testrun.TestDriveIndCalResultDef
;
import
com.keymobile.indicators.service.hytobacco.CompareUnitCalLogService
;
import
com.keymobile.indicators.service.hytobacco.CompareUnitCalLogService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndCalResultService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndCalResultService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndDefService
;
import
com.keymobile.indicators.service.hytobacco.DriveIndDefService
;
import
com.keymobile.indicators.service.testrun.TestDriveIndCalResultService
;
import
com.keymobile.indicators.utils.DateUtils
;
import
com.keymobile.indicators.utils.DateUtils
;
import
com.keymobile.indicators.utils.SpringUtil
;
import
com.keymobile.indicators.utils.SpringUtil
;
...
@@ -39,6 +41,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{
...
@@ -39,6 +41,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{
private
DriveIndCalResultService
driveIndCalResultService
=
SpringUtil
.
getBean
(
DriveIndCalResultService
.
class
);
private
DriveIndCalResultService
driveIndCalResultService
=
SpringUtil
.
getBean
(
DriveIndCalResultService
.
class
);
private
TestDriveIndCalResultService
testDriveIndCalResultService
=
SpringUtil
.
getBean
(
TestDriveIndCalResultService
.
class
);
private
CompareUnitCalLogService
compareUnitCalLogService
=
SpringUtil
.
getBean
(
CompareUnitCalLogService
.
class
);
private
CompareUnitCalLogService
compareUnitCalLogService
=
SpringUtil
.
getBean
(
CompareUnitCalLogService
.
class
);
private
String
compareId
;
private
String
compareId
;
...
@@ -65,6 +69,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{
...
@@ -65,6 +69,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{
private
String
code
;
//编码标识
private
String
code
;
//编码标识
private
String
isTest
;
//试运行
private
Map
<
String
,
Object
>
env
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
env
=
Maps
.
newHashMap
();
//定义线程安全的收集反馈确认消息list
//定义线程安全的收集反馈确认消息list
...
@@ -93,6 +99,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{
...
@@ -93,6 +99,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{
//日志记录id
//日志记录id
compCalLogId
=
driveIndIdObjCalMsg
.
getCompCalLogId
();
compCalLogId
=
driveIndIdObjCalMsg
.
getCompCalLogId
();
code
=
driveIndIdObjCalMsg
.
getCode
();
code
=
driveIndIdObjCalMsg
.
getCode
();
isTest
=
driveIndIdObjCalMsg
.
getIsTest
();
List
<
String
>
indIdList
=
new
ArrayList
<>();
//定义存储从考核指标公式解析出来的基础指标id
List
<
String
>
indIdList
=
new
ArrayList
<>();
//定义存储从考核指标公式解析出来的基础指标id
...
@@ -196,6 +203,29 @@ public class DriveIndIdObjCalActor extends AbstractActor{
...
@@ -196,6 +203,29 @@ public class DriveIndIdObjCalActor extends AbstractActor{
driveIndValue
=
String
.
format
(
"%.4f"
,
driveIndValue
=
String
.
format
(
"%.4f"
,
new
BigDecimal
(
Double
.
valueOf
(
driveIndValue
)));
new
BigDecimal
(
Double
.
valueOf
(
driveIndValue
)));
}
}
if
(
"0"
.
equals
(
isTest
))
{
//试运行
//判断结果表中是否已存在该结果数据,存在则覆盖
TestDriveIndCalResultDef
driveIndCalResult
=
testDriveIndCalResultService
.
findCalResultDataIsExist
(
compareId
,
compareObj
,
driveIndId
,
date
,
code
);
if
(
driveIndCalResult
==
null
)
{
driveIndCalResult
=
new
TestDriveIndCalResultDef
(
compareId
,
driveIndId
,
compareObj
,
date
,
driveIndValue
,
unit
,
"1"
,
"1"
,
"admin"
,
code
,
baseIndValueMsg
.
getCompareObjDesc
());
}
else
{
driveIndCalResult
.
setCode
(
code
);
driveIndCalResult
.
setUnit
(
unit
);
driveIndCalResult
.
setValue
(
driveIndValue
);
driveIndCalResult
.
setLastUpdateTime
(
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
}
//保存进考核指标结果表中
testDriveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
//返回指标值回去算平均值和排名
CalIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
new
CalIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
compareId
,
driveIndId
,
compareObj
,
date
,
driveIndValue
,
unit
,
indType
,
scoreCardId
,
averageDriveIndFormula
,
compCalLogId
);
driveIndIdCalActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
}
else
{
//判断结果表中是否已存在该结果数据,存在则覆盖
//判断结果表中是否已存在该结果数据,存在则覆盖
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
DriveIndCalResultDef
driveIndCalResult
=
driveIndCalResultService
.
findCalResultDataIsExist
(
compareId
,
compareObj
,
driveIndId
,
date
,
code
);
findCalResultDataIsExist
(
compareId
,
compareObj
,
driveIndId
,
date
,
code
);
...
@@ -211,13 +241,13 @@ public class DriveIndIdObjCalActor extends AbstractActor{
...
@@ -211,13 +241,13 @@ public class DriveIndIdObjCalActor extends AbstractActor{
}
}
//保存进考核指标结果表中
//保存进考核指标结果表中
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
driveIndCalResultService
.
saveOrUpdate
(
driveIndCalResult
);
//返回指标值回去算平均值和排名
//返回指标值回去算平均值和排名
CalIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
CalIndAverageAndRankMsg
driveIndAverageAndRankMsg
=
new
CalIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
new
CalIndAverageAndRankMsg
(
driveIndCalResult
.
getId
(),
compareId
,
driveIndId
,
compareObj
,
date
,
driveIndValue
,
compareId
,
driveIndId
,
compareObj
,
date
,
driveIndValue
,
unit
,
indType
,
scoreCardId
,
averageDriveIndFormula
,
compCalLogId
);
unit
,
indType
,
scoreCardId
,
averageDriveIndFormula
,
compCalLogId
);
driveIndIdCalActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
driveIndIdCalActor
.
tell
(
driveIndAverageAndRankMsg
,
ActorRef
.
noSender
());
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
//判断结果表中是否已存在该结果数据,存在则覆盖
//判断结果表中是否已存在该结果数据,存在则覆盖
// DriveIndCalResultDef driveIndCalResult = driveIndCalResultService.
// DriveIndCalResultDef driveIndCalResult = driveIndCalResultService.
...
...
src/main/java/com/keymobile/indicators/akka/actor/indicators/StartCompareUnitCalActor.java
View file @
084d81a1
...
@@ -15,6 +15,7 @@ import com.keymobile.indicators.akka.message.indicators.StartCompareUnitCalMsg;
...
@@ -15,6 +15,7 @@ import com.keymobile.indicators.akka.message.indicators.StartCompareUnitCalMsg;
import
com.keymobile.indicators.model.entity.indicators.CompareUnitDef
;
import
com.keymobile.indicators.model.entity.indicators.CompareUnitDef
;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRule
;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRule
;
import
com.keymobile.indicators.service.hytobacco.ScoreRuleService
;
import
com.keymobile.indicators.service.hytobacco.ScoreRuleService
;
import
com.keymobile.indicators.service.testrun.TestScoreRuleService
;
import
com.keymobile.indicators.utils.SpringUtil
;
import
com.keymobile.indicators.utils.SpringUtil
;
import
akka.actor.AbstractActor
;
import
akka.actor.AbstractActor
;
...
@@ -26,6 +27,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
...
@@ -26,6 +27,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
private
ScoreRuleService
scoreRuleServer
=
SpringUtil
.
getBean
(
ScoreRuleService
.
class
);
private
ScoreRuleService
scoreRuleServer
=
SpringUtil
.
getBean
(
ScoreRuleService
.
class
);
private
TestScoreRuleService
testScoreRuleServer
=
SpringUtil
.
getBean
(
TestScoreRuleService
.
class
);
private
List
<
CompareUnitDef
>
firstExeList
=
new
ArrayList
<>();
//先执行对标单元list
private
List
<
CompareUnitDef
>
firstExeList
=
new
ArrayList
<>();
//先执行对标单元list
private
List
<
CompareUnitDef
>
afterExeList
=
new
ArrayList
<>();
//后执行对标单元list
private
List
<
CompareUnitDef
>
afterExeList
=
new
ArrayList
<>();
//后执行对标单元list
...
@@ -42,6 +45,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
...
@@ -42,6 +45,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
private
String
code
=
null
;
//机构编码
private
String
code
=
null
;
//机构编码
private
String
isTest
=
null
;
//试运行,0:试运行 1:正式运行
private
final
ActorRef
beforeCompareUnitActor
;
//定义父actor
private
final
ActorRef
beforeCompareUnitActor
;
//定义父actor
static
public
Props
props
(
ActorRef
beforeCompareUnitActor
)
{
static
public
Props
props
(
ActorRef
beforeCompareUnitActor
)
{
...
@@ -57,6 +62,7 @@ public class StartCompareUnitCalActor extends AbstractActor{
...
@@ -57,6 +62,7 @@ public class StartCompareUnitCalActor extends AbstractActor{
return
receiveBuilder
()
return
receiveBuilder
()
.
match
(
StartCompareUnitCalMsg
.
class
,
startCompareUnitCalMsg
->
{
.
match
(
StartCompareUnitCalMsg
.
class
,
startCompareUnitCalMsg
->
{
code
=
startCompareUnitCalMsg
.
getCode
();
code
=
startCompareUnitCalMsg
.
getCode
();
isTest
=
startCompareUnitCalMsg
.
getIsTest
();
List
<
CompareUnitDef
>
compareUnitDefs
=
startCompareUnitCalMsg
.
getCompareInitDefs
();
List
<
CompareUnitDef
>
compareUnitDefs
=
startCompareUnitCalMsg
.
getCompareInitDefs
();
//将对标单元进行分类,需要先执行的先开始进行对标计算
//将对标单元进行分类,需要先执行的先开始进行对标计算
for
(
CompareUnitDef
unitDef
:
compareUnitDefs
)
{
for
(
CompareUnitDef
unitDef
:
compareUnitDefs
)
{
...
@@ -80,7 +86,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
...
@@ -80,7 +86,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
if
(!
firstExeList
.
isEmpty
())
{
if
(!
firstExeList
.
isEmpty
())
{
for
(
CompareUnitDef
unitDef
:
firstExeList
)
{
for
(
CompareUnitDef
unitDef
:
firstExeList
)
{
CompareUnitCalMsg
compareUnitCalMsg
=
new
CompareUnitCalMsg
(
unitDef
,
CompareUnitCalMsg
compareUnitCalMsg
=
new
CompareUnitCalMsg
(
unitDef
,
startCompareUnitCalMsg
.
getCode
());
startCompareUnitCalMsg
.
getCode
(),
startCompareUnitCalMsg
.
getIsTest
());
ActorRef
compareUnitCalActor
=
this
.
getContext
()
ActorRef
compareUnitCalActor
=
this
.
getContext
()
.
actorOf
(
Props
.
create
(
CompareUnitCalActor
.
class
,
.
actorOf
(
Props
.
create
(
CompareUnitCalActor
.
class
,
()->
new
CompareUnitCalActor
(
getSelf
())));
()->
new
CompareUnitCalActor
(
getSelf
())));
...
@@ -90,7 +97,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
...
@@ -90,7 +97,8 @@ public class StartCompareUnitCalActor extends AbstractActor{
if
(!
afterExeList
.
isEmpty
())
{
if
(!
afterExeList
.
isEmpty
())
{
for
(
CompareUnitDef
unitDef
:
afterExeList
)
{
for
(
CompareUnitDef
unitDef
:
afterExeList
)
{
CompareUnitCalMsg
compareUnitCalMsg
=
new
CompareUnitCalMsg
(
unitDef
,
CompareUnitCalMsg
compareUnitCalMsg
=
new
CompareUnitCalMsg
(
unitDef
,
startCompareUnitCalMsg
.
getCode
());
startCompareUnitCalMsg
.
getCode
(),
startCompareUnitCalMsg
.
getIsTest
());
ActorRef
compareUnitCalActor
=
this
.
getContext
()
ActorRef
compareUnitCalActor
=
this
.
getContext
()
.
actorOf
(
Props
.
create
(
CompareUnitCalActor
.
class
,
.
actorOf
(
Props
.
create
(
CompareUnitCalActor
.
class
,
()->
new
CompareUnitCalActor
(
getSelf
())));
()->
new
CompareUnitCalActor
(
getSelf
())));
...
@@ -100,9 +108,13 @@ public class StartCompareUnitCalActor extends AbstractActor{
...
@@ -100,9 +108,13 @@ public class StartCompareUnitCalActor extends AbstractActor{
//发送确认消息给父actor
//发送确认消息给父actor
CurrentCompUnitExeMsg
currentCompUnitExeMsg
=
new
CurrentCompUnitExeMsg
(
1
,
""
);
CurrentCompUnitExeMsg
currentCompUnitExeMsg
=
new
CurrentCompUnitExeMsg
(
1
,
""
);
beforeCompareUnitActor
.
tell
(
currentCompUnitExeMsg
,
ActorRef
.
noSender
());
beforeCompareUnitActor
.
tell
(
currentCompUnitExeMsg
,
ActorRef
.
noSender
());
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"对标单元试运行计算完成"
);
}
else
{
logger
.
info
(
"对标单元计算完成"
);
logger
.
info
(
"对标单元计算完成"
);
}
}
}
}
}
})
})
.
match
(
FirstExeConfirmMsg
.
class
,
firstExeConfirmMsg
->
{
.
match
(
FirstExeConfirmMsg
.
class
,
firstExeConfirmMsg
->
{
if
(++
numberOfConfirm
>=
firstExeUnitSize
)
{
//全部先执行的子actor全部返回
if
(++
numberOfConfirm
>=
firstExeUnitSize
)
{
//全部先执行的子actor全部返回
...
@@ -110,46 +122,82 @@ public class StartCompareUnitCalActor extends AbstractActor{
...
@@ -110,46 +122,82 @@ public class StartCompareUnitCalActor extends AbstractActor{
if
(!
afterExeList
.
isEmpty
())
{
if
(!
afterExeList
.
isEmpty
())
{
for
(
CompareUnitDef
unitDef
:
afterExeList
)
{
for
(
CompareUnitDef
unitDef
:
afterExeList
)
{
CompareUnitCalMsg
compareUnitCalMsg
=
new
CompareUnitCalMsg
(
unitDef
,
CompareUnitCalMsg
compareUnitCalMsg
=
new
CompareUnitCalMsg
(
unitDef
,
code
);
code
,
isTest
);
ActorRef
compareUnitCalActor
=
this
.
getContext
()
ActorRef
compareUnitCalActor
=
this
.
getContext
()
.
actorOf
(
Props
.
create
(
CompareUnitCalActor
.
class
,
.
actorOf
(
Props
.
create
(
CompareUnitCalActor
.
class
,
()->
new
CompareUnitCalActor
(
getSelf
())));
()->
new
CompareUnitCalActor
(
getSelf
())));
compareUnitCalActor
.
tell
(
compareUnitCalMsg
,
getSelf
());
compareUnitCalActor
.
tell
(
compareUnitCalMsg
,
getSelf
());
}
}
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"进行后执行对标单元试运行计算...."
);
}
else
{
logger
.
info
(
"进行后执行对标单元计算...."
);
logger
.
info
(
"进行后执行对标单元计算...."
);
}
}
else
{
}
else
{
if
(!
calTypeExeList
.
isEmpty
())
{
if
(!
calTypeExeList
.
isEmpty
())
{
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"计算试运行对标单元单位评分......"
);
}
else
{
logger
.
info
(
"计算对标单元单位评分......"
);
logger
.
info
(
"计算对标单元单位评分......"
);
}
for
(
CompareUnitDef
unitDef
:
calTypeExeList
)
{
for
(
CompareUnitDef
unitDef
:
calTypeExeList
)
{
//试运行
if
(
"0"
.
equals
(
isTest
))
{
testScoreRuleServer
.
testCalObjScore
(
unitDef
.
getCompareId
(),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getCompareObjs
().
split
(
","
)),
unitDef
.
getDate
(),
unitDef
.
getObjScoreRuleId
(),
code
);
}
else
{
scoreRuleServer
.
calObjScore
(
unitDef
.
getCompareId
(),
scoreRuleServer
.
calObjScore
(
unitDef
.
getCompareId
(),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getCompareObjs
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getCompareObjs
().
split
(
","
)),
unitDef
.
getDate
(),
unitDef
.
getObjScoreRuleId
(),
code
);
unitDef
.
getDate
(),
unitDef
.
getObjScoreRuleId
(),
code
);
}
}
}
}
}
//发送确认消息给父actor
//发送确认消息给父actor
CurrentCompUnitExeMsg
currentCompUnitExeMsg
=
new
CurrentCompUnitExeMsg
(
1
,
""
);
CurrentCompUnitExeMsg
currentCompUnitExeMsg
=
new
CurrentCompUnitExeMsg
(
1
,
""
);
beforeCompareUnitActor
.
tell
(
currentCompUnitExeMsg
,
ActorRef
.
noSender
());
beforeCompareUnitActor
.
tell
(
currentCompUnitExeMsg
,
ActorRef
.
noSender
());
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"对标单元试运行计算完成"
);
}
else
{
logger
.
info
(
"对标单元计算完成"
);
logger
.
info
(
"对标单元计算完成"
);
}
}
}
}
}
})
})
.
match
(
AfterExeConfirmMsg
.
class
,
afterExeConfirmMsg
->
{
.
match
(
AfterExeConfirmMsg
.
class
,
afterExeConfirmMsg
->
{
if
(++
numberOfAfterConfirm
>=
afterExeUnitSize
)
{
//全部后执行的子actor全部返回
if
(++
numberOfAfterConfirm
>=
afterExeUnitSize
)
{
//全部后执行的子actor全部返回
if
(!
calTypeExeList
.
isEmpty
())
{
if
(!
calTypeExeList
.
isEmpty
())
{
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"计算试运行对标单元单位评分......"
);
}
else
{
logger
.
info
(
"计算对标单元单位评分......"
);
logger
.
info
(
"计算对标单元单位评分......"
);
}
for
(
CompareUnitDef
unitDef
:
calTypeExeList
)
{
for
(
CompareUnitDef
unitDef
:
calTypeExeList
)
{
//试运行
if
(
"0"
.
equals
(
isTest
))
{
testScoreRuleServer
.
testCalObjScore
(
unitDef
.
getCompareId
(),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getCompareObjs
().
split
(
","
)),
unitDef
.
getDate
(),
unitDef
.
getObjScoreRuleId
(),
code
);
}
else
{
scoreRuleServer
.
calObjScore
(
unitDef
.
getCompareId
(),
scoreRuleServer
.
calObjScore
(
unitDef
.
getCompareId
(),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getIndIds
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getCompareObjs
().
split
(
","
)),
Arrays
.
asList
(
unitDef
.
getCompareObjs
().
split
(
","
)),
unitDef
.
getDate
(),
unitDef
.
getObjScoreRuleId
(),
code
);
unitDef
.
getDate
(),
unitDef
.
getObjScoreRuleId
(),
code
);
}
}
}
}
}
//发送确认消息给父actor
//发送确认消息给父actor
CurrentCompUnitExeMsg
currentCompUnitExeMsg
=
new
CurrentCompUnitExeMsg
(
1
,
""
);
CurrentCompUnitExeMsg
currentCompUnitExeMsg
=
new
CurrentCompUnitExeMsg
(
1
,
""
);
beforeCompareUnitActor
.
tell
(
currentCompUnitExeMsg
,
ActorRef
.
noSender
());
beforeCompareUnitActor
.
tell
(
currentCompUnitExeMsg
,
ActorRef
.
noSender
());
if
(
"0"
.
equals
(
isTest
))
{
logger
.
info
(
"对标单元试运行计算完成"
);
}
else
{
logger
.
info
(
"对标单元计算完成"
);
logger
.
info
(
"对标单元计算完成"
);
}
}
}
})
})
.
build
();
.
build
();
}
}
...
...
src/main/java/com/keymobile/indicators/akka/message/indicators/CompareUnitCalMsg.java
View file @
084d81a1
...
@@ -14,9 +14,12 @@ public class CompareUnitCalMsg implements Serializable{
...
@@ -14,9 +14,12 @@ public class CompareUnitCalMsg implements Serializable{
private
String
code
;
private
String
code
;
public
CompareUnitCalMsg
(
CompareUnitDef
compareUnitDef
,
String
code
)
{
private
String
isTest
;
public
CompareUnitCalMsg
(
CompareUnitDef
compareUnitDef
,
String
code
,
String
isTest
)
{
this
.
compareUnitDef
=
compareUnitDef
;
this
.
compareUnitDef
=
compareUnitDef
;
this
.
code
=
code
;
this
.
code
=
code
;
this
.
isTest
=
isTest
;
}
}
public
CompareUnitDef
getCompareUnitDef
()
{
public
CompareUnitDef
getCompareUnitDef
()
{
...
@@ -34,4 +37,12 @@ public class CompareUnitCalMsg implements Serializable{
...
@@ -34,4 +37,12 @@ public class CompareUnitCalMsg implements Serializable{
public
void
setCode
(
String
code
)
{
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
String
getIsTest
()
{
return
isTest
;
}
public
void
setIsTest
(
String
isTest
)
{
this
.
isTest
=
isTest
;
}
}
}
src/main/java/com/keymobile/indicators/akka/message/indicators/DriveIndIdCalMsg.java
View file @
084d81a1
...
@@ -18,9 +18,10 @@ public class DriveIndIdCalMsg implements Serializable{
...
@@ -18,9 +18,10 @@ public class DriveIndIdCalMsg implements Serializable{
private
String
averageObj
;
//平均分参考对象
private
String
averageObj
;
//平均分参考对象
private
Integer
compCalLogId
;
//运行日志记录id
private
Integer
compCalLogId
;
//运行日志记录id
private
String
code
;
//机构编码
private
String
code
;
//机构编码
private
String
isTest
;
//试运行 0:试运行 1:正式运行
public
DriveIndIdCalMsg
(
String
compareId
,
String
indId
,
List
<
String
>
compareObj
,
Integer
date
,
public
DriveIndIdCalMsg
(
String
compareId
,
String
indId
,
List
<
String
>
compareObj
,
Integer
date
,
String
firstExe
,
String
averageObj
,
Integer
compCalLogId
,
String
code
)
{
String
firstExe
,
String
averageObj
,
Integer
compCalLogId
,
String
code
,
String
isTest
)
{
this
.
compareId
=
compareId
;
this
.
compareId
=
compareId
;
this
.
indId
=
indId
;
this
.
indId
=
indId
;
this
.
compareObj
.
addAll
(
compareObj
);
this
.
compareObj
.
addAll
(
compareObj
);
...
@@ -29,6 +30,7 @@ public class DriveIndIdCalMsg implements Serializable{
...
@@ -29,6 +30,7 @@ public class DriveIndIdCalMsg implements Serializable{
this
.
averageObj
=
averageObj
;
this
.
averageObj
=
averageObj
;
this
.
compCalLogId
=
compCalLogId
;
this
.
compCalLogId
=
compCalLogId
;
this
.
code
=
code
;
this
.
code
=
code
;
this
.
isTest
=
isTest
;
}
}
public
String
getCompareId
()
{
public
String
getCompareId
()
{
...
@@ -84,4 +86,12 @@ public class DriveIndIdCalMsg implements Serializable{
...
@@ -84,4 +86,12 @@ public class DriveIndIdCalMsg implements Serializable{
public
void
setCode
(
String
code
)
{
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
String
getIsTest
()
{
return
isTest
;
}
public
void
setIsTest
(
String
isTest
)
{
this
.
isTest
=
isTest
;
}
}
}
src/main/java/com/keymobile/indicators/akka/message/indicators/DriveIndIdObjCalMsg.java
View file @
084d81a1
...
@@ -19,9 +19,11 @@ public class DriveIndIdObjCalMsg implements Serializable{
...
@@ -19,9 +19,11 @@ public class DriveIndIdObjCalMsg implements Serializable{
private
List
<
DimValue
>
dimValues
=
new
ArrayList
<>();
//维度值list
private
List
<
DimValue
>
dimValues
=
new
ArrayList
<>();
//维度值list
private
Integer
compCalLogId
;
//运行日志记录id
private
Integer
compCalLogId
;
//运行日志记录id
private
String
code
;
//机构编码
private
String
code
;
//机构编码
private
String
isTest
;
//试运行
public
DriveIndIdObjCalMsg
(
String
compareId
,
String
indId
,
String
compareObj
,
public
DriveIndIdObjCalMsg
(
String
compareId
,
String
indId
,
String
compareObj
,
Integer
date
,
List
<
DimValue
>
dimValues
,
Integer
compCalLogId
,
String
code
)
{
Integer
date
,
List
<
DimValue
>
dimValues
,
Integer
compCalLogId
,
String
code
,
String
isTest
)
{
this
.
compareId
=
compareId
;
this
.
compareId
=
compareId
;
this
.
indId
=
indId
;
this
.
indId
=
indId
;
this
.
compareObj
=
compareObj
;
this
.
compareObj
=
compareObj
;
...
@@ -29,6 +31,7 @@ public class DriveIndIdObjCalMsg implements Serializable{
...
@@ -29,6 +31,7 @@ public class DriveIndIdObjCalMsg implements Serializable{
this
.
dimValues
.
addAll
(
dimValues
);
this
.
dimValues
.
addAll
(
dimValues
);
this
.
compCalLogId
=
compCalLogId
;
this
.
compCalLogId
=
compCalLogId
;
this
.
code
=
code
;
this
.
code
=
code
;
this
.
isTest
=
isTest
;
}
}
public
String
getCompareId
()
{
public
String
getCompareId
()
{
...
@@ -77,4 +80,12 @@ public class DriveIndIdObjCalMsg implements Serializable{
...
@@ -77,4 +80,12 @@ public class DriveIndIdObjCalMsg implements Serializable{
public
void
setCode
(
String
code
)
{
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
String
getIsTest
()
{
return
isTest
;
}
public
void
setIsTest
(
String
isTest
)
{
this
.
isTest
=
isTest
;
}
}
}
src/main/java/com/keymobile/indicators/akka/message/indicators/StartCompareUnitCalMsg.java
View file @
084d81a1
...
@@ -16,9 +16,12 @@ public class StartCompareUnitCalMsg implements Serializable{
...
@@ -16,9 +16,12 @@ public class StartCompareUnitCalMsg implements Serializable{
private
String
code
;
private
String
code
;
public
StartCompareUnitCalMsg
(
List
<
CompareUnitDef
>
compareInitDefs
,
String
code
)
{
private
String
isTest
;
public
StartCompareUnitCalMsg
(
List
<
CompareUnitDef
>
compareInitDefs
,
String
code
,
String
isTest
)
{
this
.
compareInitDefs
.
addAll
(
compareInitDefs
);
this
.
compareInitDefs
.
addAll
(
compareInitDefs
);
this
.
code
=
code
;
this
.
code
=
code
;
this
.
setIsTest
(
isTest
);
}
}
public
List
<
CompareUnitDef
>
getCompareInitDefs
()
{
public
List
<
CompareUnitDef
>
getCompareInitDefs
()
{
...
@@ -36,4 +39,12 @@ public class StartCompareUnitCalMsg implements Serializable{
...
@@ -36,4 +39,12 @@ public class StartCompareUnitCalMsg implements Serializable{
public
void
setCode
(
String
code
)
{
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
String
getIsTest
()
{
return
isTest
;
}
public
void
setIsTest
(
String
isTest
)
{
this
.
isTest
=
isTest
;
}
}
}
src/main/java/com/keymobile/indicators/api/hytobacco/DriveIndCalResultCtrl.java
View file @
084d81a1
...
@@ -3,6 +3,7 @@ package com.keymobile.indicators.api.hytobacco;
...
@@ -3,6 +3,7 @@ package com.keymobile.indicators.api.hytobacco;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -35,17 +36,33 @@ public class DriveIndCalResultCtrl {
...
@@ -35,17 +36,33 @@ public class DriveIndCalResultCtrl {
driveIndCalResultService
.
batchSaveOrUpdate
(
calResults
);
driveIndCalResultService
.
batchSaveOrUpdate
(
calResults
);
}
}
@ApiOperation
(
value
=
"对标单元综合计算"
,
notes
=
"对标单元综合计算"
)
@ApiOperation
(
value
=
"对标单元综合计算
(isTest: 0试运行 1正式运行)
"
,
notes
=
"对标单元综合计算"
)
@PostMapping
(
value
=
"/compareUnitListCal"
)
@PostMapping
(
value
=
"/compareUnitListCal"
)
public
void
compareUnitListCal
(
@RequestBody
List
<
CompareUnitDef
>
compareUnitList
,
public
void
compareUnitListCal
(
@RequestBody
List
<
CompareUnitDef
>
compareUnitList
,
@RequestParam
(
value
=
"code"
,
required
=
false
)
String
code
)
{
@RequestParam
(
value
=
"code"
,
required
=
false
)
String
code
,
@RequestParam
(
value
=
"isTest"
,
required
=
false
)
String
isTest
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
code
))
{
throw
new
Exception
(
"user org number is null"
);
}
if
(
StringUtils
.
isBlank
(
isTest
))
{
//空值默认为正式运算
isTest
=
"1"
;
}
else
{
if
(!
"0"
.
equals
(
isTest
)
&&
!
"1"
.
equals
(
isTest
))
{
throw
new
Exception
(
"the param isTest's value must be '0' or '1'"
);
}
}
StringBuilder
compUnitDefString
=
new
StringBuilder
(
""
);
StringBuilder
compUnitDefString
=
new
StringBuilder
(
""
);
for
(
CompareUnitDef
compUnitDef
:
compareUnitList
)
{
for
(
CompareUnitDef
compUnitDef
:
compareUnitList
)
{
compUnitDefString
.
append
(
compUnitDef
.
getCompareId
()).
append
(
";"
);
compUnitDefString
.
append
(
compUnitDef
.
getCompareId
()).
append
(
";"
);
}
}
if
(
"0"
.
equals
(
isTest
))
{
LogManager
.
logInfo
(
Constants
.
LOG_INDICATOR_UNIT_CAL_API
,
"执行对标单元id:{},日期:{} 的试运行计算"
,
compUnitDefString
.
toString
(),
compareUnitList
.
get
(
0
).
getDate
());
}
else
{
LogManager
.
logInfo
(
Constants
.
LOG_INDICATOR_UNIT_CAL_API
,
"执行对标单元id:{},日期:{} 的计算"
,
LogManager
.
logInfo
(
Constants
.
LOG_INDICATOR_UNIT_CAL_API
,
"执行对标单元id:{},日期:{} 的计算"
,
compUnitDefString
.
toString
(),
compareUnitList
.
get
(
0
).
getDate
());
compUnitDefString
.
toString
(),
compareUnitList
.
get
(
0
).
getDate
());
driveIndCalResultService
.
compareUnitListCal
(
compareUnitList
,
code
);
}
driveIndCalResultService
.
compareUnitListCal
(
compareUnitList
,
code
,
isTest
);
}
}
@ApiOperation
(
value
=
"根据对标单元id分页获取日志详情"
,
notes
=
"根据对标单元id分页获取日志详情"
)
@ApiOperation
(
value
=
"根据对标单元id分页获取日志详情"
,
notes
=
"根据对标单元id分页获取日志详情"
)
...
...
src/main/java/com/keymobile/indicators/model/entity/testrun/TestDriveIndCalResultDef.java
0 → 100644
View file @
084d81a1
package
com
.
keymobile
.
indicators
.
model
.
entity
.
testrun
;
import
java.util.Date
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
com.keymobile.indicators.utils.DateUtils
;
import
lombok.Data
;
/**
* author:zhangkb time:2020-8-31 desc:试运行考核指标结果表
*/
@Data
@Table
(
name
=
"test_drive_ind_cal_result_def"
)
public
class
TestDriveIndCalResultDef
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
id
;
private
String
compareId
;
private
String
indId
;
private
String
compareObj
;
private
String
compareObjDesc
;
private
Integer
date
;
private
String
value
;
private
String
unit
;
private
String
type
;
//0:季度 1:年度
private
String
isRight
;
//表示考核指标的值是否计算正常得到的 0:计算有误 1:计算正常
private
String
lastUpdateTime
=
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
private
String
lastUpdater
;
private
String
average
;
//组内平均数
private
Integer
rank
;
//同组排名
private
String
score
;
//指标评分分数
private
String
improveScore
;
//改善提升得分
private
String
actualAverage
;
//实际平均数:用于省对市的操作,如果有全省的基础项数据,直接拿全省的基础项数据算考核指标做为其实际平均值
private
String
code
;
//编码标识
public
TestDriveIndCalResultDef
()
{
super
();
}
public
TestDriveIndCalResultDef
(
String
compareId
,
String
indId
,
String
compareObj
,
int
date
,
String
value
,
String
unit
,
String
type
,
String
isRight
,
String
lastUpdater
,
String
code
,
String
compareObjDesc
)
{
this
.
compareId
=
compareId
;
this
.
indId
=
indId
;
this
.
compareObj
=
compareObj
;
this
.
date
=
date
;
this
.
value
=
value
;
this
.
unit
=
unit
;
this
.
type
=
type
;
this
.
isRight
=
isRight
;
this
.
lastUpdater
=
lastUpdater
;
this
.
code
=
code
;
this
.
compareObjDesc
=
compareObjDesc
;
}
}
src/main/java/com/keymobile/indicators/model/entity/testrun/TestObjScoreCalResult.java
0 → 100644
View file @
084d81a1
package
com
.
keymobile
.
indicators
.
model
.
entity
.
testrun
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
lombok.Data
;
/**
*author:zhangkb time:2020-8-31 desc:试运行单位评分结果存放实体
*/
@Data
@Table
(
name
=
"test_obj_score_cal_result"
)
public
class
TestObjScoreCalResult
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
id
;
private
String
compareId
;
//对标单元id
private
String
compareObj
;
//对标对象
private
String
compareObjDesc
;
//对标对象描述
private
String
indIds
;
//对标考核指标id
private
Integer
date
;
//对标日期
private
String
scoreValue
;
//考核对象得分
private
String
improveValue
;
//考核对象改善得分
private
String
scoreSumValue
;
//指标总积分
private
Integer
indCount
;
//指标个数
private
String
code
;
//机构编码
}
src/main/java/com/keymobile/indicators/model/mapper/testrun/TestDriveIndCalResultDefMapper.java
0 → 100644
View file @
084d81a1
package
com
.
keymobile
.
indicators
.
model
.
mapper
.
testrun
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
com.keymobile.indicators.model.entity.testrun.TestDriveIndCalResultDef
;
import
tk.mybatis.mapper.common.BaseMapper
;
@Mapper
public
interface
TestDriveIndCalResultDefMapper
extends
BaseMapper
<
TestDriveIndCalResultDef
>{
public
List
<
TestDriveIndCalResultDef
>
findByCompareObjAndDate
(
@Param
(
"compareObj"
)
String
compareObj
,
@Param
(
"date"
)
int
date
,
@Param
(
"code"
)
String
code
);
public
TestDriveIndCalResultDef
findByIndIdAndDateAndCompareObj
(
@Param
(
"indId"
)
String
indId
,
@Param
(
"date"
)
int
date
,
@Param
(
"compareObj"
)
String
compareObj
,
@Param
(
"code"
)
String
code
);
public
TestDriveIndCalResultDef
findByCompareIdAndCompareObjAndIndIdAndDate
(
@Param
(
"compareId"
)
String
compareId
,
@Param
(
"compareObj"
)
String
compareObj
,
@Param
(
"indId"
)
String
indId
,
@Param
(
"date"
)
Integer
date
,
@Param
(
"code"
)
String
code
);
//批量保存
public
void
batchSave
(
@Param
(
"datas"
)
List
<
TestDriveIndCalResultDef
>
datas
);
//批量修改
public
void
batchUpdate
(
@Param
(
"datas"
)
List
<
TestDriveIndCalResultDef
>
datas
);
}
src/main/java/com/keymobile/indicators/model/mapper/testrun/TestObjScoreCalResultMapper.java
0 → 100644
View file @
084d81a1
package
com
.
keymobile
.
indicators
.
model
.
mapper
.
testrun
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
com.keymobile.indicators.model.entity.testrun.TestObjScoreCalResult
;
import
tk.mybatis.mapper.common.BaseMapper
;
@Mapper
public
interface
TestObjScoreCalResultMapper
extends
BaseMapper
<
TestObjScoreCalResult
>{
public
TestObjScoreCalResult
getTestObjScoreCalResultByParam
(
@Param
(
"compareId"
)
String
compareId
,
@Param
(
"compareObj"
)
String
compareObj
,
@Param
(
"date"
)
Integer
date
,
@Param
(
"code"
)
String
code
);
public
void
batchSave
(
@Param
(
"datas"
)
List
<
TestObjScoreCalResult
>
datas
);
public
void
batchUpdate
(
@Param
(
"datas"
)
List
<
TestObjScoreCalResult
>
datas
);
}
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndCalResultService.java
View file @
084d81a1
...
@@ -73,7 +73,7 @@ public class DriveIndCalResultService {
...
@@ -73,7 +73,7 @@ public class DriveIndCalResultService {
return
driveIndCalResultDefMapper
.
findByCompareIdAndDate
(
compareId
,
date
);
return
driveIndCalResultDefMapper
.
findByCompareIdAndDate
(
compareId
,
date
);
}
}
public
void
compareUnitListCal
(
List
<
CompareUnitDef
>
compareUnitList
,
String
code
)
{
public
void
compareUnitListCal
(
List
<
CompareUnitDef
>
compareUnitList
,
String
code
,
String
isTest
)
{
if
(!
compareUnitList
.
isEmpty
())
{
if
(!
compareUnitList
.
isEmpty
())
{
List
<
CompareUnitDef
>
sameCompareUnitList
=
new
ArrayList
<>();
List
<
CompareUnitDef
>
sameCompareUnitList
=
new
ArrayList
<>();
//将对标单元的日期改成同期
//将对标单元的日期改成同期
...
@@ -85,7 +85,7 @@ public class DriveIndCalResultService {
...
@@ -85,7 +85,7 @@ public class DriveIndCalResultService {
//启动回流actor
//启动回流actor
final
ActorSystem
system
=
ActorSystem
.
create
(
"CompareUnitCalAkka"
);
//创建akka
final
ActorSystem
system
=
ActorSystem
.
create
(
"CompareUnitCalAkka"
);
//创建akka
StartCompareUnitCalMsg
startCompareUnitCalMsg
=
new
StartCompareUnitCalMsg
(
StartCompareUnitCalMsg
startCompareUnitCalMsg
=
new
StartCompareUnitCalMsg
(
sameCompareUnitList
,
code
);
sameCompareUnitList
,
code
,
isTest
);
ActorRef
beforeCompareUnitCalActor
=
system
.
actorOf
(
Props
.
create
(
ActorRef
beforeCompareUnitCalActor
=
system
.
actorOf
(
Props
.
create
(
BeforeCompareUnitCalActor
.
class
,()->
new
BeforeCompareUnitCalActor
()));
BeforeCompareUnitCalActor
.
class
,()->
new
BeforeCompareUnitCalActor
()));
beforeCompareUnitCalActor
.
tell
(
startCompareUnitCalMsg
,
ActorRef
.
noSender
());
beforeCompareUnitCalActor
.
tell
(
startCompareUnitCalMsg
,
ActorRef
.
noSender
());
...
...
src/main/java/com/keymobile/indicators/service/testrun/TestDriveIndCalResultService.java
0 → 100644
View file @
084d81a1
package
com
.
keymobile
.
indicators
.
service
.
testrun
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.model.entity.testrun.TestDriveIndCalResultDef
;
import
com.keymobile.indicators.model.mapper.testrun.TestDriveIndCalResultDefMapper
;
@Service
public
class
TestDriveIndCalResultService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
TestDriveIndCalResultService
.
class
);
@Autowired
private
TestDriveIndCalResultDefMapper
testDriveIndCalResultDefMapper
;
public
TestDriveIndCalResultDef
findById
(
Integer
id
)
{
return
testDriveIndCalResultDefMapper
.
selectByPrimaryKey
(
id
);
}
public
TestDriveIndCalResultDef
findCompareObjInfo
(
String
driveIndId
,
int
date
,
String
compareObj
,
String
code
)
{
return
testDriveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
driveIndId
,
date
,
compareObj
,
code
);
}
public
TestDriveIndCalResultDef
findCalResultDataIsExist
(
String
compareId
,
String
compareObj
,
String
indId
,
int
date
,
String
code
)
{
return
testDriveIndCalResultDefMapper
.
findByCompareIdAndCompareObjAndIndIdAndDate
(
compareId
,
compareObj
,
indId
,
date
,
code
);
}
public
int
saveOrUpdate
(
TestDriveIndCalResultDef
driveIndCalResult
)
{
if
(
driveIndCalResult
.
getId
()==
null
)
{
testDriveIndCalResultDefMapper
.
insert
(
driveIndCalResult
);
}
else
{
testDriveIndCalResultDefMapper
.
updateByPrimaryKey
(
driveIndCalResult
);
}
return
driveIndCalResult
.
getId
();
}
//批量新增或者修改
public
void
batchSaveOrUpdate
(
List
<
TestDriveIndCalResultDef
>
driveIndCalResults
)
{
List
<
TestDriveIndCalResultDef
>
addList
=
new
ArrayList
<>();
List
<
TestDriveIndCalResultDef
>
updateList
=
new
ArrayList
<>();
for
(
TestDriveIndCalResultDef
driveIndCalResult
:
driveIndCalResults
)
{
if
(
driveIndCalResult
.
getId
()==
null
)
{
addList
.
add
(
driveIndCalResult
);
//新增list
}
else
{
updateList
.
add
(
driveIndCalResult
);
//修改list
}
}
if
(!
addList
.
isEmpty
())
{
//批量新增
testDriveIndCalResultDefMapper
.
batchSave
(
addList
);
}
if
(!
updateList
.
isEmpty
())
{
//批量修改
testDriveIndCalResultDefMapper
.
batchUpdate
(
updateList
);
}
}
}
src/main/java/com/keymobile/indicators/service/testrun/TestScoreRuleService.java
0 → 100644
View file @
084d81a1
package
com
.
keymobile
.
indicators
.
service
.
testrun
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.googlecode.aviator.AviatorEvaluator
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.objscorerule.IndTypeWeight
;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRule
;
import
com.keymobile.indicators.model.entity.testrun.TestDriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.testrun.TestObjScoreCalResult
;
import
com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.ScoreRuleMapper
;
import
com.keymobile.indicators.model.mapper.testrun.TestDriveIndCalResultDefMapper
;
import
com.keymobile.indicators.model.mapper.testrun.TestObjScoreCalResultMapper
;
import
com.keymobile.indicators.utils.CalculateUtils
;
@Service
public
class
TestScoreRuleService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
TestScoreRuleService
.
class
);
@Autowired
private
ScoreRuleMapper
scoreRuleMapper
;
@Autowired
private
DriveIndDefMapper
driveIndDefMapper
;
@Autowired
private
TestObjScoreCalResultMapper
testObjScoreCalResultMapper
;
@Autowired
private
TestDriveIndCalResultDefMapper
testDriveIndCalResultDefMapper
;
private
static
final
Pattern
P
=
Pattern
.
compile
(
"(\\[[^\\]]*\\])"
);
//根据单位评分规则计算单位分数
public
void
testCalObjScore
(
String
compareId
,
List
<
String
>
indIds
,
List
<
String
>
compareObjs
,
int
date
,
Integer
scoreRuleId
,
String
code
)
{
//根据单位得分评分卡id获取评分卡详情
ScoreRule
scoreRule
=
this
.
getById
(
scoreRuleId
);
List
<
TestObjScoreCalResult
>
datas
=
new
ArrayList
<>();
if
(
scoreRule
!=
null
)
{
if
(!
indIds
.
isEmpty
()
&&
!
compareObjs
.
isEmpty
())
{
for
(
String
compareObj
:
compareObjs
)
{
//判断库表是否已存在改结果数据
TestObjScoreCalResult
objScoreCalResult
=
testObjScoreCalResultMapper
.
getTestObjScoreCalResultByParam
(
compareId
,
compareObj
,
date
,
code
);
if
(
objScoreCalResult
==
null
)
{
objScoreCalResult
=
new
TestObjScoreCalResult
();
}
//计算类型:0 地区所有纳入评价的考核指标平均数
if
(
"0"
.
equals
(
scoreRule
.
getCalType
()))
{
objScoreCalResult
=
this
.
calGroupIndAverageOrSum
(
objScoreCalResult
,
scoreRule
,
compareObj
,
date
,
scoreRule
.
getCalType
(),
code
);
}
else
if
(
"1"
.
equals
(
scoreRule
.
getCalType
()))
{
//1 根据目录类别分类算平均分后根据权重计算考核指标
objScoreCalResult
=
this
.
calIndCatalogTypeAverage
(
objScoreCalResult
,
scoreRule
,
compareObj
,
date
,
code
);
}
else
if
(
"2"
.
equals
(
scoreRule
.
getCalType
())){
//2单个指标权重计算
objScoreCalResult
=
this
.
calSingleIndWeight
(
objScoreCalResult
,
scoreRule
,
compareObj
,
date
,
code
);
}
else
{
//3:指标总得分
objScoreCalResult
=
this
.
calGroupIndAverageOrSum
(
objScoreCalResult
,
scoreRule
,
compareObj
,
date
,
scoreRule
.
getCalType
(),
code
);
}
objScoreCalResult
.
setCompareId
(
compareId
);
datas
.
add
(
objScoreCalResult
);
}
//批量新增或修改
this
.
batchSaveOrUpdateObjScoreCalResult
(
datas
);
}
}
else
{
logger
.
info
(
"单位评分卡id:"
+
scoreRuleId
+
" 不存在"
);
}
}
//计算组内考核指标平均值或者总和 type:0 计算地区所有纳入考核指标平均数 3指标总得分
private
TestObjScoreCalResult
calGroupIndAverageOrSum
(
TestObjScoreCalResult
objResult
,
ScoreRule
scoreRule
,
String
compareObj
,
int
date
,
String
type
,
String
code
){
objResult
.
setCompareObj
(
compareObj
);
objResult
.
setScoreValue
(
"0.0"
);
objResult
.
setImproveValue
(
"0.0"
);
objResult
.
setDate
(
date
);
//objResult.setIndIds(String.join(",", indIds));
//根据日期,对标对象和考核的指标获取考核指标结果详情
//Map<String,Object> paremMap = new HashMap<>();
//paremMap.put("compareObj", compareObj);
//paremMap.put("date", date);
//paremMap.put("indIds", indIds);
//List<DriveIndCalResultDef> calResults = driveIndCalResultDefMapper.
//findByCompareObjAndDateAndIndIdIn(paremMap);
List
<
TestDriveIndCalResultDef
>
calResults
=
testDriveIndCalResultDefMapper
.
findByCompareObjAndDate
(
compareObj
,
date
,
code
);
int
indCount
=
0
;
//定义用户记录纳入考核指标个数
List
<
String
>
values
=
new
ArrayList
<>();
List
<
String
>
improveValues
=
new
ArrayList
<>();
if
(!
calResults
.
isEmpty
())
{
//auth:zhangkb time:2020-7-15 desc:填充对标对象描述
objResult
.
setCompareObjDesc
(
calResults
.
get
(
0
).
getCompareObjDesc
());
for
(
TestDriveIndCalResultDef
calResult
:
calResults
)
{
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
calResult
.
getIndId
());
if
(
driveIndDef
!=
null
)
{
//如果考核指标是参与单位计分的
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIsUnitCalScore
())
||
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
indCount
+=
1
;
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
&&
!
"0.0000"
.
equals
(
calResult
.
getValue
())
&&
!
"0"
.
equals
(
calResult
.
getValue
()))
{
values
.
add
(
calResult
.
getValue
());
}
}
else
if
(
"1"
.
equals
(
scoreRule
.
getScoreType
()))
{
//1 指标得分分数参与计算(综合评分和改善提升分开算)
values
.
add
(
calResult
.
getScore
());
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
())
&&
StringUtils
.
isNotBlank
(
calResult
.
getImproveScore
()))
{
improveValues
.
add
(
calResult
.
getImproveScore
());
}
}
else
{
//2指标得分分数参与计算(指标分数=综合+改善)
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
())
&&
StringUtils
.
isNotBlank
(
calResult
.
getImproveScore
()))
{
double
indScore
=
Double
.
parseDouble
(
calResult
.
getScore
());
double
improveScore
=
Double
.
parseDouble
(
calResult
.
getImproveScore
());
double
sum
=
indScore
+
improveScore
;
values
.
add
(
String
.
valueOf
(
sum
));
}
else
{
values
.
add
(
calResult
.
getScore
());
}
}
}
}
}
String
averageValue
=
"0.0"
;
String
averageImproveValue
=
"0.0"
;
if
(
"0"
.
equals
(
type
))
{
//计算平均值
averageValue
=
CalculateUtils
.
averageValue
(
values
,
1
);
}
if
(
"3"
.
equals
(
type
)){
//计算总和
averageValue
=
CalculateUtils
.
sumValue
(
values
);
}
if
(!
improveValues
.
isEmpty
())
{
if
(
"0"
.
equals
(
type
))
{
averageImproveValue
=
CalculateUtils
.
averageValue
(
improveValues
,
1
);
}
if
(
"3"
.
equals
(
type
)){
averageImproveValue
=
CalculateUtils
.
sumValue
(
improveValues
);
}
}
//计算总积分
Double
scoreSumValue
=
(
Double
.
parseDouble
(
CalculateUtils
.
sumValue
(
values
))+
Double
.
parseDouble
(
CalculateUtils
.
sumValue
(
improveValues
)));
objResult
.
setScoreSumValue
(
String
.
valueOf
(
scoreSumValue
));
objResult
.
setIndCount
(
indCount
);
objResult
.
setScoreValue
(
averageValue
);
objResult
.
setImproveValue
(
averageImproveValue
);
}
return
objResult
;
}
private
TestObjScoreCalResult
calSingleIndWeight
(
TestObjScoreCalResult
objResult
,
ScoreRule
scoreRule
,
String
compareObj
,
int
date
,
String
code
){
objResult
.
setCompareObj
(
compareObj
);
objResult
.
setScoreValue
(
"0.0"
);
objResult
.
setImproveValue
(
"0.0"
);
objResult
.
setDate
(
date
);
String
calFormula
=
scoreRule
.
getCalFormula
();
//计算综合评分分数
String
improveCalFormula
=
scoreRule
.
getCalFormula
();
//计算改善提升分数
if
(
StringUtils
.
isNotBlank
(
calFormula
))
{
//获取公式中的考核指标编码
List
<
String
>
indIdList
=
new
ArrayList
<>();
Matcher
m
=
P
.
matcher
(
calFormula
);
while
(
m
.
find
()){
indIdList
.
add
(
m
.
group
().
substring
(
1
,
m
.
group
().
length
()-
1
));
}
for
(
String
indId
:
indIdList
)
{
//根据日期,对标对象和考核的指标获取考核指标结果详情
TestDriveIndCalResultDef
calresultOp
=
testDriveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
indId
,
date
,
compareObj
,
code
);
if
(
calresultOp
!=
null
)
{
//auth:zhangkb time:2020-7-15 desc:填充对标对象描述
objResult
.
setCompareObjDesc
(
calresultOp
.
getCompareObjDesc
());
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
if
(!
"NaN"
.
equals
(
calresultOp
.
getValue
())
&&
!
"Infinite"
.
equals
(
calresultOp
.
getValue
()))
{
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
calresultOp
.
getValue
());
}
else
{
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
"0.0"
);
}
}
else
if
(
"1"
.
equals
(
scoreRule
.
getScoreType
()))
{
//1 指标得分分数参与计算(综合评分和改善提升分开算)
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
calresultOp
.
getValue
());
if
(!
"No"
.
equals
(
calresultOp
.
getImproveScore
())
&&
StringUtils
.
isNotBlank
(
calresultOp
.
getImproveScore
()))
{
improveCalFormula
=
improveCalFormula
.
replace
(
"["
+
indId
+
"]"
,
calresultOp
.
getImproveScore
());
}
else
{
improveCalFormula
=
improveCalFormula
.
replace
(
"["
+
indId
+
"]"
,
"0.0"
);
}
}
else
{
//2指标得分分数参与计算(指标分数=综合+改善)
String
score
=
"0.0"
;
if
(!
"No"
.
equals
(
calresultOp
.
getImproveScore
())
&&
StringUtils
.
isNotBlank
(
calresultOp
.
getImproveScore
()))
{
double
indScore
=
Double
.
parseDouble
(
calresultOp
.
getScore
());
double
improveScore
=
Double
.
parseDouble
(
calresultOp
.
getImproveScore
());
double
sum
=
indScore
+
improveScore
;
score
=
String
.
valueOf
(
sum
);
}
else
{
score
=
calresultOp
.
getScore
();
}
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
score
);
}
}
else
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
"0.0"
);
}
else
if
(
"1"
.
equals
(
scoreRule
.
getScoreType
()))
{
//1 指标得分分数参与计算(综合评分和改善提升分开算)
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
"0.0"
);
improveCalFormula
=
improveCalFormula
.
replace
(
"["
+
indId
+
"]"
,
"0.0"
);
}
else
{
//2指标得分分数参与计算(指标分数=综合+改善)
calFormula
=
calFormula
.
replace
(
"["
+
indId
+
"]"
,
"0.0"
);
}
}
}
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
())
||
"2"
.
equals
(
scoreRule
.
getScoreType
()))
{
String
scoreValue
=
String
.
format
(
"%.4f"
,
new
BigDecimal
((
Double
)
AviatorEvaluator
.
execute
(
calFormula
)));
objResult
.
setScoreValue
(
scoreValue
);
objResult
.
setImproveValue
(
"0.0"
);
}
else
if
(
"1"
.
equals
(
scoreRule
.
getScoreType
()))
{
//1 指标得分分数参与计算(综合评分和改善提升分开算)
String
scoreValue
=
String
.
format
(
"%.4f"
,
new
BigDecimal
((
Double
)
AviatorEvaluator
.
execute
(
calFormula
)));
String
improveValue
=
String
.
format
(
"%.4f"
,
new
BigDecimal
((
Double
)
AviatorEvaluator
.
execute
(
improveCalFormula
)));
objResult
.
setScoreValue
(
scoreValue
);
objResult
.
setImproveValue
(
improveValue
);
}
}
return
objResult
;
}
//按照指标类别进行分类分别计算平均分后再跟类别权重相乘后相加得到最终分数
private
TestObjScoreCalResult
calIndCatalogTypeAverage
(
TestObjScoreCalResult
objResult
,
ScoreRule
scoreRule
,
String
compareObj
,
int
date
,
String
code
){
Gson
gson
=
new
Gson
();
objResult
.
setCompareObj
(
compareObj
);
objResult
.
setScoreValue
(
"0.0"
);
objResult
.
setImproveValue
(
"0.0"
);
objResult
.
setDate
(
date
);
//根据对标对象,日期查找该对标对象对标的所有指标结果
List
<
TestDriveIndCalResultDef
>
calResults
=
testDriveIndCalResultDefMapper
.
findByCompareObjAndDate
(
compareObj
,
date
,
code
);
double
scoreValue
=
0.0
;
double
improveValue
=
0.0
;
if
(!
calResults
.
isEmpty
())
{
//auth:zhangkb time:2020-7-15 desc:填充对标对象描述
objResult
.
setCompareObjDesc
(
calResults
.
get
(
0
).
getCompareObjDesc
());
if
(
StringUtils
.
isNotBlank
(
scoreRule
.
getIndTypeWeightsJson
()))
{
List
<
IndTypeWeight
>
indTypeWeights
=
gson
.
fromJson
(
scoreRule
.
getIndTypeWeightsJson
(),
new
TypeToken
<
List
<
IndTypeWeight
>>(){}.
getType
());
for
(
IndTypeWeight
indTypeWeight
:
indTypeWeights
)
{
Map
<
String
,
Double
>
calScores
=
this
.
calIndTypeScore
(
scoreRule
,
indTypeWeight
,
calResults
);
scoreValue
+=
(
calScores
.
get
(
"score"
)*
Double
.
parseDouble
(
indTypeWeight
.
getWeight
())/
100
);
improveValue
+=
(
calScores
.
get
(
"improve"
)*
Double
.
parseDouble
(
indTypeWeight
.
getWeight
())/
100
);
}
}
}
objResult
.
setScoreValue
(
String
.
format
(
"%.4f"
,
new
BigDecimal
(
scoreValue
)));
objResult
.
setImproveValue
(
String
.
format
(
"%.4f"
,
new
BigDecimal
(
improveValue
)));
return
objResult
;
}
//根据指标分类计算指标平均值
private
Map
<
String
,
Double
>
calIndTypeScore
(
ScoreRule
scoreRule
,
IndTypeWeight
indTypeWeight
,
List
<
TestDriveIndCalResultDef
>
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
(
TestDriveIndCalResultDef
calResult
:
calResults
)
{
String
catalogIdPath
=
indTypeWeight
.
getCatalogIdPath
();
//根据考核指标id获取考核指标
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
calResult
.
getIndId
());
if
(
driveIndDef
!=
null
)
{
//如果考核指标是参与单位计分的
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIsUnitCalScore
())
||
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
//如果指标是该指标分类下的
if
(
driveIndDef
.
getCatalogIdPath
().
indexOf
(
catalogIdPath
)>=
0
)
{
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
if
(!
"NaN"
.
equals
(
calResult
.
getValue
())
&&
!
"Infinite"
.
equals
(
calResult
.
getValue
())
/*&& !"0.0000".equals(calResult.getValue()) && !"0".equals(calResult.getValue())*/
)
{
values
.
add
(
calResult
.
getValue
());
}
}
else
if
(
"1"
.
equals
(
scoreRule
.
getScoreType
()))
{
//1 指标得分分数参与计算(综合评分和改善提升分开算)
values
.
add
(
calResult
.
getScore
());
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
())
&&
StringUtils
.
isNotBlank
(
calResult
.
getImproveScore
()))
{
improveValues
.
add
(
calResult
.
getImproveScore
());
}
}
else
{
//2指标得分分数参与计算(指标分数=综合+改善)
if
(!
"No"
.
equals
(
calResult
.
getImproveScore
())
&&
StringUtils
.
isNotBlank
(
calResult
.
getImproveScore
()))
{
double
indScore
=
Double
.
parseDouble
(
calResult
.
getScore
());
double
improveScore
=
Double
.
parseDouble
(
calResult
.
getImproveScore
());
double
sum
=
indScore
+
improveScore
;
values
.
add
(
String
.
valueOf
(
sum
));
}
else
{
values
.
add
(
calResult
.
getScore
());
}
}
}
}
}
}
//计算平均值
String
averageValue
=
CalculateUtils
.
averageValue
(
values
,
1
);
String
averageImproveValue
=
"0.0"
;
if
(!
improveValues
.
isEmpty
())
{
averageImproveValue
=
CalculateUtils
.
averageValue
(
improveValues
,
1
);
}
result
.
put
(
"score"
,
Double
.
parseDouble
(
averageValue
));
result
.
put
(
"improve"
,
Double
.
parseDouble
(
averageImproveValue
));
return
result
;
}
public
void
batchSaveOrUpdateObjScoreCalResult
(
List
<
TestObjScoreCalResult
>
calDatas
)
{
List
<
TestObjScoreCalResult
>
addList
=
new
ArrayList
<>();
//新增list
List
<
TestObjScoreCalResult
>
updateList
=
new
ArrayList
<>();
//修改list
for
(
TestObjScoreCalResult
calData
:
calDatas
)
{
if
(
calData
.
getId
()==
null
)
{
addList
.
add
(
calData
);
}
else
{
updateList
.
add
(
calData
);
}
}
if
(!
addList
.
isEmpty
())
{
testObjScoreCalResultMapper
.
batchSave
(
addList
);
}
if
(!
updateList
.
isEmpty
())
{
testObjScoreCalResultMapper
.
batchUpdate
(
updateList
);
}
}
private
ScoreRule
getById
(
Integer
id
)
{
ScoreRule
scoreRule
=
scoreRuleMapper
.
selectByPrimaryKey
(
id
);
if
(
scoreRule
!=
null
)
{
return
this
.
changeJson
(
scoreRule
);
}
return
null
;
}
private
ScoreRule
changeJson
(
ScoreRule
scoreRule
)
{
Gson
gson
=
new
Gson
();
if
(
StringUtils
.
isNotBlank
(
scoreRule
.
getIndTypeWeightsJson
()))
{
List
<
IndTypeWeight
>
indTypeWeights
=
gson
.
fromJson
(
scoreRule
.
getIndTypeWeightsJson
(),
new
TypeToken
<
List
<
IndTypeWeight
>>(){}.
getType
());
scoreRule
.
setIndTypeWeights
(
indTypeWeights
);
}
return
scoreRule
;
}
}
src/main/resources/mybatis/mapping/TestDriveIndCalResultDefMapper.xml
0 → 100644
View file @
084d81a1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.keymobile.indicators.model.mapper.testrun.TestDriveIndCalResultDefMapper"
>
<select
id=
"findByCompareObjAndDate"
resultType=
"com.keymobile.indicators.model.entity.testrun.TestDriveIndCalResultDef"
>
select *
from test_drive_ind_cal_result_def
where
compare_obj = #{compareObj} and
date = #{date} and
code = #{code}
</select>
<select
id=
"findByIndIdAndDateAndCompareObj"
resultType=
"com.keymobile.indicators.model.entity.testrun.TestDriveIndCalResultDef"
>
select *
from test_drive_ind_cal_result_def
where
ind_id = #{indId} and
compare_obj = #{compareObj} and
date = #{date} and
code = #{code}
</select>
<select
id=
"findByCompareIdAndCompareObjAndIndIdAndDate"
resultType=
"com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef"
>
select *
from test_drive_ind_cal_result_def
where
compare_id = #{compareId} and
compare_obj = #{compareObj} and
ind_id = #{indId} and
date = #{date} and
code = #{code}
</select>
<insert
id=
"batchSave"
parameterType=
"java.util.List"
>
insert into test_drive_ind_cal_result_def(
compare_id, ind_id, compare_obj, compare_obj_desc, date, value, unit, type,
is_right, last_update_time, last_updater, average, rank, score, improve_score,
actual_average, code)
values
<foreach
collection=
"datas"
item=
"val"
separator=
","
>
(
#{val.compareId}, #{val.indId}, #{val.compareObj}, #{val.compareObjDesc}, #{val.date},
#{val.value},#{val.unit},#{val.type},#{val.isRight},#{val.lastUpdateTime},#{val.lastUpdater},
#{val.average},#{val.rank},#{val.score},#{val.improveScore},#{val.actualAverage},#{val.code}
)
</foreach>
</insert>
<update
id=
"batchUpdate"
parameterType=
"java.util.List"
>
<foreach
collection=
"datas"
item=
"val"
index=
"index"
separator=
";"
>
update test_drive_ind_cal_result_def
<set>
<if
test=
"val.compareId != null"
>
compare_id = #{val.compareId},
</if>
<if
test=
"val.indId != null"
>
ind_id = #{val.indId},
</if>
<if
test=
"val.compareObj != null"
>
compare_obj = #{val.compareObj},
</if>
<if
test=
"val.compareObjDesc != null"
>
compare_obj_desc = #{val.compareObjDesc},
</if>
<if
test=
"val.date != null"
>
date = #{val.date},
</if>
<if
test=
"val.value != null"
>
value = #{val.value},
</if>
<if
test=
"val.unit != null"
>
unit = #{val.unit},
</if>
<if
test=
"val.type != null"
>
type = #{val.type},
</if>
<if
test=
"val.isRight != null"
>
is_right = #{val.isRight},
</if>
<if
test=
"val.lastUpdateTime != null"
>
last_update_time = #{val.lastUpdateTime},
</if>
<if
test=
"val.lastUpdater != null"
>
last_updater = #{val.lastUpdater},
</if>
<if
test=
"val.average != null"
>
average = #{val.average},
</if>
<if
test=
"val.rank != null"
>
rank = #{val.rank},
</if>
<if
test=
"val.score != null"
>
score = #{val.score},
</if>
<if
test=
"val.improveScore != null"
>
improve_score = #{val.improveScore},
</if>
<if
test=
"val.actualAverage != null"
>
actual_average = #{val.actualAverage},
</if>
<if
test=
"val.code != null"
>
code = #{val.code},
</if>
</set>
where id = ${val.id}
</foreach>
</update>
</mapper>
\ No newline at end of file
src/main/resources/mybatis/mapping/TestObjScoreCalResultMapper.xml
0 → 100644
View file @
084d81a1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.keymobile.indicators.model.mapper.testrun.TestObjScoreCalResultMapper"
>
<select
id=
"getTestObjScoreCalResultByParam"
resultType=
"com.keymobile.indicators.model.entity.testrun.TestObjScoreCalResult"
>
select *
from test_obj_score_cal_result
where
compare_id=#{compareId} and
compare_obj=#{compareObj} and
date=#{date} and
code=#{code}
</select>
<insert
id=
"batchSave"
parameterType=
"java.util.List"
>
insert into test_obj_score_cal_result(
compare_id, compare_obj, compare_obj_desc, ind_ids, date, score_value, improve_value,
score_sum_value, ind_count, code)
values
<foreach
collection=
"datas"
item=
"val"
separator=
","
>
(
#{val.compareId}, #{val.compareObj}, #{val.compareObjDesc}, #{val.indIds}, #{val.date},
#{val.scoreValue},#{val.improveValue},#{val.scoreSumValue},#{val.indCount},#{val.code})
</foreach>
</insert>
<update
id=
"batchUpdate"
parameterType=
"java.util.List"
>
<foreach
collection=
"datas"
item=
"val"
separator=
";"
>
update test_obj_score_cal_result
<set>
<if
test=
"val.compareId != null"
>
compare_id = #{val.compareId},
</if>
<if
test=
"val.compareObj != null"
>
compare_obj = #{val.compareObj},
</if>
<if
test=
"val.compareObjDesc != null"
>
compare_obj_desc = #{val.compareObjDesc},
</if>
<if
test=
"val.indIds != null"
>
ind_ids = #{val.indIds},
</if>
<if
test=
"val.date != null"
>
date = #{val.date},
</if>
<if
test=
"val.scoreValue != null"
>
score_value = #{val.scoreValue},
</if>
<if
test=
"val.improveValue != null"
>
improve_value = #{val.improveValue},
</if>
<if
test=
"val.scoreSumValue != null"
>
score_sum_value = #{val.scoreSumValue},
</if>
<if
test=
"val.indCount != null"
>
ind_count = #{val.indCount},
</if>
<if
test=
"val.code != null"
>
code = #{val.code},
</if>
</set>
where id = ${val.id}
</foreach>
</update>
</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