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
2b585dc7
Commit
2b585dc7
authored
Feb 21, 2023
by
dengwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.原烟纯度公式计算 2.权重配置
parent
fe345cd8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
181 additions
and
20 deletions
+181
-20
ObjScoreIndWeightCfgCtrl.java
...le/indicators/api/hytobacco/ObjScoreIndWeightCfgCtrl.java
+7
-0
Function_YYCD.java
...java/com/keymobile/indicators/function/Function_YYCD.java
+40
-0
ObjScoreIndWeightCfg.java
...ymobile/indicators/model/entity/ObjScoreIndWeightCfg.java
+18
-5
ObjScoreIndWeightCfgMapper.java
...s/model/mapper/indicators/ObjScoreIndWeightCfgMapper.java
+1
-1
IndScorecardService.java
...ile/indicators/service/hytobacco/IndScorecardService.java
+48
-9
ObjScoreIndWeightCfgServiceImpl.java
...icators/service/impl/ObjScoreIndWeightCfgServiceImpl.java
+50
-3
IndicatorsReportService.java
...le/indicators/service/report/IndicatorsReportService.java
+3
-1
CalculateUtils.java
...n/java/com/keymobile/indicators/utils/CalculateUtils.java
+13
-0
ObjScoreIndWeightCfgMapper.xml
.../resources/mybatis/mapping/ObjScoreIndWeightCfgMapper.xml
+1
-1
No files found.
src/main/java/com/keymobile/indicators/api/hytobacco/ObjScoreIndWeightCfgCtrl.java
View file @
2b585dc7
...
@@ -84,4 +84,11 @@ public class ObjScoreIndWeightCfgCtrl {
...
@@ -84,4 +84,11 @@ public class ObjScoreIndWeightCfgCtrl {
return
Result
.
genOkResult
();
return
Result
.
genOkResult
();
}
}
@ApiOperation
(
"根据id获取权重配置信息"
)
@GetMapping
(
"/getWeightCfgById"
)
public
ObjScoreIndWeightCfg
getWeightCfgById
(
@ApiParam
(
"id"
)
@RequestParam
(
"id"
)
Integer
id
)
{
LogManager
.
logInfo
(
Constants
.
LOG_INDICATOR_WEIGHTCFG_API
,
"查询权重配置信息,id:{}"
,
id
);
return
weightCfgService
.
getById
(
id
);
}
}
}
src/main/java/com/keymobile/indicators/function/Function_YYCD.java
0 → 100644
View file @
2b585dc7
package
com
.
keymobile
.
indicators
.
function
;
import
com.googlecode.aviator.runtime.function.AbstractFunction
;
import
com.googlecode.aviator.runtime.function.FunctionUtils
;
import
com.googlecode.aviator.runtime.type.AviatorDouble
;
import
com.googlecode.aviator.runtime.type.AviatorObject
;
import
java.util.Map
;
/**
* @author DW
* @date 2023-02-17-0017 16:17
* @description 原烟纯度函数计算公式
*/
public
class
Function_YYCD
extends
AbstractFunction
{
@Override
public
AviatorObject
call
(
Map
<
String
,
Object
>
env
,
AviatorObject
ind1
,
AviatorObject
ind2
,
AviatorObject
num1
,
AviatorObject
num2
)
{
Number
ind1Result
=
FunctionUtils
.
getNumberValue
(
ind1
,
env
);
Number
ind2Result
=
FunctionUtils
.
getNumberValue
(
ind2
,
env
);
Number
ind1Kpi
=
FunctionUtils
.
getNumberValue
(
num1
,
env
);
Number
ind2Kpi
=
FunctionUtils
.
getNumberValue
(
num2
,
env
);
if
(
ind1Result
.
doubleValue
()
>=
ind1Kpi
.
doubleValue
()
&&
ind2Result
.
doubleValue
()
>=
ind2Kpi
.
doubleValue
()){
return
new
AviatorDouble
(
100
);
}
else
{
return
new
AviatorDouble
(
0
);
}
}
/**
* 返回方法名
*/
@Override
public
String
getName
()
{
return
"YYCD"
;
}
}
src/main/java/com/keymobile/indicators/model/entity/ObjScoreIndWeightCfg.java
View file @
2b585dc7
package
com
.
keymobile
.
indicators
.
model
.
entity
;
package
com
.
keymobile
.
indicators
.
model
.
entity
;
import
com.keymobile.indicators.model.entity.dataenter.TaskRuleIndicator
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -8,7 +9,9 @@ import javax.persistence.GeneratedValue;
...
@@ -8,7 +9,9 @@ import javax.persistence.GeneratedValue;
import
javax.persistence.GenerationType
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
/**
* @author DW
* @author DW
...
@@ -28,7 +31,7 @@ public class ObjScoreIndWeightCfg extends BaseModel {
...
@@ -28,7 +31,7 @@ public class ObjScoreIndWeightCfg extends BaseModel {
private
String
name
;
// 配置名称
private
String
name
;
// 配置名称
@ApiModelProperty
(
value
=
"配置级别"
)
@ApiModelProperty
(
value
=
"配置级别"
)
private
String
levelName
;
// 配置级别
private
String
levelName
;
// 配置级别
/getWeightCfgById
@ApiModelProperty
(
value
=
"配置周期"
)
@ApiModelProperty
(
value
=
"配置周期"
)
private
String
dateValue
;
// 配置周期
private
String
dateValue
;
// 配置周期
...
@@ -48,14 +51,20 @@ public class ObjScoreIndWeightCfg extends BaseModel {
...
@@ -48,14 +51,20 @@ public class ObjScoreIndWeightCfg extends BaseModel {
@ApiModelProperty
(
value
=
"两烟区大类权重"
)
@ApiModelProperty
(
value
=
"两烟区大类权重"
)
private
BigDecimal
weightTwo
;
// 两烟区大类权重
private
BigDecimal
weightTwo
;
// 两烟区大类权重
@ApiModelProperty
(
value
=
"两烟区单位"
)
@ApiModelProperty
(
value
=
"两烟区单位ID"
)
private
String
weightTwoUnit
;
// 两烟区单位
private
Integer
weightTwoUnit
;
// 两烟区单位ID
@ApiModelProperty
(
value
=
"两烟区单位名称"
)
private
String
weightTwoUnitName
;
@ApiModelProperty
(
value
=
"纯销区大类权重"
)
@ApiModelProperty
(
value
=
"纯销区大类权重"
)
private
BigDecimal
weightOne
;
// 纯销区大类权重
private
BigDecimal
weightOne
;
// 纯销区大类权重
@ApiModelProperty
(
value
=
"纯销区单位"
)
@ApiModelProperty
(
value
=
"纯销区单位ID"
)
private
String
weightOneUnit
;
// 纯销区单位
private
Integer
weightOneUnit
;
// 纯销区单位ID
@ApiModelProperty
(
value
=
"纯销区单位名称"
)
private
String
weightOneUnitName
;
// 纯销区单位名称
@ApiModelProperty
(
value
=
"租户组织CODE,区分不同单位"
)
@ApiModelProperty
(
value
=
"租户组织CODE,区分不同单位"
)
private
String
code
;
// 租户组织CODE,区分不同单位
private
String
code
;
// 租户组织CODE,区分不同单位
...
@@ -66,4 +75,8 @@ public class ObjScoreIndWeightCfg extends BaseModel {
...
@@ -66,4 +75,8 @@ public class ObjScoreIndWeightCfg extends BaseModel {
@ApiModelProperty
(
value
=
"备注"
)
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
// 备注
private
String
remark
;
// 备注
@ApiModelProperty
(
value
=
"组内指标"
)
@Transient
private
List
<
TaskRuleIndicator
>
indicators
;
// 2023年2月19日15:13:53 组内指标 邓威
}
}
src/main/java/com/keymobile/indicators/model/mapper/indicators/ObjScoreIndWeightCfgMapper.java
View file @
2b585dc7
...
@@ -56,5 +56,5 @@ public interface ObjScoreIndWeightCfgMapper extends BaseMapper<ObjScoreIndWeight
...
@@ -56,5 +56,5 @@ public interface ObjScoreIndWeightCfgMapper extends BaseMapper<ObjScoreIndWeight
* @param ids
* @param ids
* @return
* @return
*/
*/
List
<
ObjScoreIndWeightCfg
>
findByIdList
(
List
<
Integer
>
ids
);
List
<
ObjScoreIndWeightCfg
>
findByIdList
(
@Param
(
"ids"
)
List
<
Integer
>
ids
);
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/IndScorecardService.java
View file @
2b585dc7
...
@@ -3,6 +3,8 @@ package com.keymobile.indicators.service.hytobacco;
...
@@ -3,6 +3,8 @@ package com.keymobile.indicators.service.hytobacco;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.*
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
com.keymobile.indicators.model.mapper.indmapper.IndicatorsDataMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -33,6 +35,8 @@ public class IndScorecardService {
...
@@ -33,6 +35,8 @@ public class IndScorecardService {
private
DriveIndDefService
driveIndDefService
;
private
DriveIndDefService
driveIndDefService
;
@Autowired
@Autowired
private
DriveIndCalResultDefMapper
driveIndCalResultDefMapper
;
private
DriveIndCalResultDefMapper
driveIndCalResultDefMapper
;
@Autowired
private
IndicatorsDataMapper
indicatorsDataMapper
;
//id不为空为修改,为空为新增
//id不为空为修改,为空为新增
public
Integer
saveOrUpdate
(
IndScorecard
indScorecard
,
String
code
,
Integer
catalogId
,
public
Integer
saveOrUpdate
(
IndScorecard
indScorecard
,
String
code
,
Integer
catalogId
,
...
@@ -138,6 +142,7 @@ public class IndScorecardService {
...
@@ -138,6 +142,7 @@ public class IndScorecardService {
public
Map
<
String
,
String
>
calculateIndiScore
(
String
compareCatalog
,
String
compareId
,
String
indId
,
int
date
,
String
compareObj
,
public
Map
<
String
,
String
>
calculateIndiScore
(
String
compareCatalog
,
String
compareId
,
String
indId
,
int
date
,
String
compareObj
,
Integer
indScorecardId
,
List
<
String
>
compareObjs
,
String
code
,
int
dateMark
)
throws
Exception
{
Integer
indScorecardId
,
List
<
String
>
compareObjs
,
String
code
,
int
dateMark
)
throws
Exception
{
logger
.
info
(
"计算方法参数为:"
+
compareCatalog
+
"|"
+
compareId
+
"|"
+
indId
+
"|"
+
date
+
"|"
+
compareObj
+
"|"
+
indScorecardId
+
"|"
+
compareObjs
+
"|"
+
code
+
"|"
+
dateMark
);
Map
<
String
,
String
>
result
=
new
HashMap
<>();
Map
<
String
,
String
>
result
=
new
HashMap
<>();
Gson
gson
=
new
Gson
();
Gson
gson
=
new
Gson
();
String
indScoreValue
=
"0.0"
;
String
indScoreValue
=
"0.0"
;
...
@@ -256,7 +261,7 @@ public class IndScorecardService {
...
@@ -256,7 +261,7 @@ public class IndScorecardService {
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getOtherCalFormula
()))
{
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getOtherCalFormula
()))
{
baseScoreValue
=
this
.
getValueFromFormula
(
baseScoreValue
=
this
.
getValueFromFormula
(
scoreCard
.
getOtherCalFormula
(),
currentCompareObjResult
,
scoreCard
.
getOtherCalFormula
(),
currentCompareObjResult
,
currentDriveResult
,
acsType
);
currentDriveResult
,
acsType
,
compareObj
,
dateMark
,
code
);
}
}
}
}
}
else
if
(
"2"
.
equals
(
scoreCard
.
getScoreType
())
}
else
if
(
"2"
.
equals
(
scoreCard
.
getScoreType
())
...
@@ -282,7 +287,7 @@ public class IndScorecardService {
...
@@ -282,7 +287,7 @@ public class IndScorecardService {
scoreCard
.
setOtherCalFormula
(
otherCalFormula
);
scoreCard
.
setOtherCalFormula
(
otherCalFormula
);
baseScoreValue
=
this
.
getValueFromFormula
(
baseScoreValue
=
this
.
getValueFromFormula
(
scoreCard
.
getOtherCalFormula
(),
currentValue
,
scoreCard
.
getOtherCalFormula
(),
currentValue
,
sectionScores
,
acsType
);
sectionScores
,
acsType
,
compareObj
,
dateMark
,
code
);
}
}
}
else
if
(
"3"
.
equals
(
scoreCard
.
getScoreType
())){
// 排名强制区间表达式计算
}
else
if
(
"3"
.
equals
(
scoreCard
.
getScoreType
())){
// 排名强制区间表达式计算
...
@@ -371,7 +376,7 @@ public class IndScorecardService {
...
@@ -371,7 +376,7 @@ public class IndScorecardService {
// 增幅计算类型 0:本期-同期 1:(本期-同期)/同期*100
// 增幅计算类型 0:本期-同期 1:(本期-同期)/同期*100
String
growCalType
=
driveIndDef
.
getGrowCalType
();
String
growCalType
=
driveIndDef
.
getGrowCalType
();
// 获取改善提升积分
// 获取改善提升积分
double
improveScore
=
this
.
getImproveScore
(
currentDriveResult
,
sameDriveResult
,
currentCompareObjResult
,
scoreCard
,
growCalType
,
acsType
);
double
improveScore
=
this
.
getImproveScore
(
currentDriveResult
,
sameDriveResult
,
currentCompareObjResult
,
scoreCard
,
growCalType
,
acsType
,
dateMark
,
code
);
// 改善提升积分上限
// 改善提升积分上限
if
(
scoreCard
.
getImproveLimitScore
()
!=
null
&&
scoreCard
.
getImproveLimitScore
()
!=
0
){
if
(
scoreCard
.
getImproveLimitScore
()
!=
null
&&
scoreCard
.
getImproveLimitScore
()
!=
0
){
if
(
improveScore
>
scoreCard
.
getImproveLimitScore
()){
if
(
improveScore
>
scoreCard
.
getImproveLimitScore
()){
...
@@ -422,7 +427,7 @@ public class IndScorecardService {
...
@@ -422,7 +427,7 @@ public class IndScorecardService {
* @param growCalType
* @param growCalType
* @return
* @return
*/
*/
private
double
getImproveScore
(
List
<
DriveIndCalResultDef
>
currentDriveResult
,
List
<
DriveIndCalResultDef
>
sameDriveResult
,
DriveIndCalResultDef
currentCompareObjResult
,
IndScorecard
scoreCard
,
String
growCalType
,
String
acsType
)
{
private
double
getImproveScore
(
List
<
DriveIndCalResultDef
>
currentDriveResult
,
List
<
DriveIndCalResultDef
>
sameDriveResult
,
DriveIndCalResultDef
currentCompareObjResult
,
IndScorecard
scoreCard
,
String
growCalType
,
String
acsType
,
int
dateMark
,
String
code
)
{
double
improveScore
=
0.0
;
double
improveScore
=
0.0
;
Map
<
String
,
String
>
current
=
new
HashMap
<>();
Map
<
String
,
String
>
current
=
new
HashMap
<>();
Map
<
String
,
String
>
same
=
new
HashMap
<>();
Map
<
String
,
String
>
same
=
new
HashMap
<>();
...
@@ -490,7 +495,7 @@ public class IndScorecardService {
...
@@ -490,7 +495,7 @@ public class IndScorecardService {
}
}
}
else
{
// 公式
}
else
{
// 公式
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getImproveOtherCalFormula
()))
{
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getImproveOtherCalFormula
()))
{
improveScore
=
this
.
getValueFromFormula
(
scoreCard
.
getImproveOtherCalFormula
(),
currentCompareObjResult
,
list
,
acsType
);
improveScore
=
this
.
getValueFromFormula
(
scoreCard
.
getImproveOtherCalFormula
(),
currentCompareObjResult
,
list
,
acsType
,
compareObj
,
dateMark
,
code
);
}
}
}
}
return
improveScore
;
return
improveScore
;
...
@@ -522,7 +527,7 @@ public class IndScorecardService {
...
@@ -522,7 +527,7 @@ public class IndScorecardService {
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getMinusScoreItemJson
()))
{
if
(
StringUtils
.
isNotBlank
(
scoreCard
.
getMinusScoreItemJson
()))
{
List
<
RankScoreDef
>
minusScoreItem
=
gson
.
List
<
RankScoreDef
>
minusScoreItem
=
gson
.
fromJson
(
scoreCard
.
getMinusScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
fromJson
(
scoreCard
.
getMinusScoreItemJson
(),
new
TypeToken
<
List
<
RankScoreDef
>>(){}.
getType
());
rank
=
currentDriveResult
.
size
()-
rank
+
1
;
int
maxRank
=
0
;
int
maxRank
=
0
;
for
(
DriveIndCalResultDef
tempDriveIndCalResultDef
:
currentDriveResult
)
{
for
(
DriveIndCalResultDef
tempDriveIndCalResultDef
:
currentDriveResult
)
{
if
(
tempDriveIndCalResultDef
.
getRank
()>
maxRank
){
if
(
tempDriveIndCalResultDef
.
getRank
()>
maxRank
){
...
@@ -681,7 +686,7 @@ public class IndScorecardService {
...
@@ -681,7 +686,7 @@ public class IndScorecardService {
if
(
"2"
.
equals
(
section
[
7
])){
if
(
"2"
.
equals
(
section
[
7
])){
//不按比例。满才加分 去掉小数点取整
//不按比例。满才加分 去掉小数点取整
// TODO: 2023-02-09-0009 目前为小数向下取整,可能需要改成向上取整 -- 向上取整方法Math.ceil
// TODO: 2023-02-09-0009 目前为小数向下取整,可能需要改成向上取整 -- 向上取整方法Math.ceil
scopeValue
=
Math
.
floor
(
scopeValue
);
scopeValue
=
Math
.
ceil
(
scopeValue
);
}
}
//判断是加还是减
//判断是加还是减
boolean
isAdd
=
"1"
.
equals
(
section
[
8
])?
true
:
false
;
boolean
isAdd
=
"1"
.
equals
(
section
[
8
])?
true
:
false
;
...
@@ -812,7 +817,7 @@ public class IndScorecardService {
...
@@ -812,7 +817,7 @@ public class IndScorecardService {
}
}
private
double
getValueFromFormula
(
String
formula
,
DriveIndCalResultDef
resultObject
,
private
double
getValueFromFormula
(
String
formula
,
DriveIndCalResultDef
resultObject
,
List
<
DriveIndCalResultDef
>
currentDriveResult
,
String
acsType
)
{
List
<
DriveIndCalResultDef
>
currentDriveResult
,
String
acsType
,
String
compareObj
,
int
dateMark
,
String
code
)
{
double
value
=
0
;
double
value
=
0
;
Map
<
String
,
Object
>
env
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
env
=
Maps
.
newHashMap
();
String
formulaTmp
=
""
;
String
formulaTmp
=
""
;
...
@@ -878,7 +883,10 @@ public class IndScorecardService {
...
@@ -878,7 +883,10 @@ public class IndScorecardService {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"计算指标积分综合评价的公式积分错误:formula:"
+
formula
+
";env:"
+
env
);
logger
.
error
(
"计算指标积分综合评价的公式积分错误:formula:"
+
formula
+
";env:"
+
env
);
}
}
}
else
{
}
else
if
(
StringUtils
.
contains
(
formula
,
"YYCD"
))
{
// 1.校验原烟纯度公式是否合法,2.根据指标ID查询指标值(公式中的包含的ind_id, , compareObj, dateMark),3.参与计算
value
=
this
.
getValueByYYCD
(
formula
,
compareObj
,
dateMark
,
code
);
}
else
{
try
{
try
{
value
=
(
Double
)
AviatorEvaluator
.
execute
(
formula
);
value
=
(
Double
)
AviatorEvaluator
.
execute
(
formula
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -889,6 +897,37 @@ public class IndScorecardService {
...
@@ -889,6 +897,37 @@ public class IndScorecardService {
}
}
/**
/**
* 计算原烟纯度函数的值
* @param formula 原烟纯度公式
* @param compareObj 查询基础指标数据的维度1
* @param dateMark 查询基础指标数据的维度2
* @param code 地区编码
* @return 公式计算结果
*/
private
double
getValueByYYCD
(
String
formula
,
String
compareObj
,
int
dateMark
,
String
code
)
{
String
[]
strings
=
formula
.
split
(
"\\|"
);
double
value
=
0
;
// 1.校验原烟纯度公式是否合法
if
(
strings
.
length
==
4
&
StringUtils
.
contains
(
formula
,
"("
)
&&
StringUtils
.
contains
(
formula
,
")"
))
{
// YYCD([]|[]|90|85)
// 获取原烟纯度函数中的指标ID
String
allIndId1
=
strings
[
0
].
split
(
"\\("
)[
1
];
String
allIndId2
=
strings
[
1
];
String
indId1
=
allIndId1
.
substring
(
1
,
allIndId1
.
length
()
-
1
);
String
indId2
=
allIndId2
.
substring
(
1
,
allIndId2
.
length
()
-
1
);
// 2.根据指标ID查询指标值(公式中的包含的ind_id, compareObj, code, dateMark)
IndicatorsData
indicatorsData1
=
indicatorsDataMapper
.
getIndData
(
indId1
,
dateMark
,
compareObj
,
code
,
dateMark
);
IndicatorsData
indicatorsData2
=
indicatorsDataMapper
.
getIndData
(
indId2
,
dateMark
,
compareObj
,
code
,
dateMark
);
// 组装原烟纯度计算公式
String
finalFormula
=
"YYCD("
+
indicatorsData1
.
getValue
()
+
", "
+
indicatorsData2
.
getValue
()
+
", "
+
strings
[
2
]
+
", "
+
strings
[
3
];
value
=
CalculateUtils
.
calculateYYCD
(
finalFormula
);
}
else
{
logger
.
error
(
"原烟纯度公式配置错误,请重新配置!"
);
}
return
value
;
}
/**
* 求公式结果的最大值最小值
* 求公式结果的最大值最小值
* @Param [formula, currentDriveResult, isMax]
* @Param [formula, currentDriveResult, isMax]
* @Date 2021/1/26 9:28
* @Date 2021/1/26 9:28
...
...
src/main/java/com/keymobile/indicators/service/impl/ObjScoreIndWeightCfgServiceImpl.java
View file @
2b585dc7
...
@@ -2,8 +2,13 @@ package com.keymobile.indicators.service.impl;
...
@@ -2,8 +2,13 @@ package com.keymobile.indicators.service.impl;
import
com.keymobile.indicators.constant.Constants
;
import
com.keymobile.indicators.constant.Constants
;
import
com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg
;
import
com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg
;
import
com.keymobile.indicators.model.entity.dataenter.TaskRuleIndicator
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper
;
import
com.keymobile.indicators.model.mapper.indicators.ObjScoreIndWeightCfgMapper
;
import
com.keymobile.indicators.model.mapper.indicators.ObjScoreIndWeightCfgMapper
;
import
com.keymobile.indicators.service.ObjScoreIndWeightCfgService
;
import
com.keymobile.indicators.service.ObjScoreIndWeightCfgService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageImpl
;
...
@@ -12,6 +17,7 @@ import org.springframework.stereotype.Service;
...
@@ -12,6 +17,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -21,10 +27,13 @@ import java.util.List;
...
@@ -21,10 +27,13 @@ import java.util.List;
* @description
* @description
*/
*/
@Service
@Service
@Slf4j
public
class
ObjScoreIndWeightCfgServiceImpl
implements
ObjScoreIndWeightCfgService
{
public
class
ObjScoreIndWeightCfgServiceImpl
implements
ObjScoreIndWeightCfgService
{
@Autowired
@Autowired
private
ObjScoreIndWeightCfgMapper
weightCfgMapper
;
private
ObjScoreIndWeightCfgMapper
weightCfgMapper
;
@Autowired
private
DriveIndDefMapper
driveIndDefMapper
;
@Override
@Override
public
void
deleteById
(
Integer
id
)
{
public
void
deleteById
(
Integer
id
)
{
...
@@ -33,7 +42,21 @@ public class ObjScoreIndWeightCfgServiceImpl implements ObjScoreIndWeightCfgServ
...
@@ -33,7 +42,21 @@ public class ObjScoreIndWeightCfgServiceImpl implements ObjScoreIndWeightCfgServ
@Override
@Override
public
ObjScoreIndWeightCfg
getById
(
Integer
id
)
{
public
ObjScoreIndWeightCfg
getById
(
Integer
id
)
{
return
weightCfgMapper
.
getById
(
id
);
ObjScoreIndWeightCfg
weightCfg
=
weightCfgMapper
.
getById
(
id
);
if
(
StringUtils
.
isNotBlank
(
weightCfg
.
getIndIds
()))
{
List
<
String
>
indIds
=
Arrays
.
asList
(
weightCfg
.
getIndIds
().
split
(
","
));
List
<
DriveIndDef
>
indDefs
=
driveIndDefMapper
.
getByIdList
(
indIds
);
List
<
TaskRuleIndicator
>
indicators
=
new
ArrayList
<>();
for
(
DriveIndDef
indDef
:
indDefs
)
{
TaskRuleIndicator
indicator
=
new
TaskRuleIndicator
();
indicator
.
setIndId
(
indDef
.
getIndId
());
indicator
.
setIndName
(
indDef
.
getIndName
());
indicator
.
setIndUnit
(
indDef
.
getIndUnit
());
indicators
.
add
(
indicator
);
}
weightCfg
.
setIndicators
(
indicators
);
}
return
weightCfg
;
}
}
@Override
@Override
...
@@ -51,14 +74,38 @@ public class ObjScoreIndWeightCfgServiceImpl implements ObjScoreIndWeightCfgServ
...
@@ -51,14 +74,38 @@ public class ObjScoreIndWeightCfgServiceImpl implements ObjScoreIndWeightCfgServ
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
createWeight
(
ObjScoreIndWeightCfg
weightCfg
)
{
public
void
createWeight
(
ObjScoreIndWeightCfg
weightCfg
)
{
weightCfg
.
setState
(
Constants
.
DATA_STATE_A
);
weightCfg
.
setState
(
Constants
.
DATA_STATE_A
);
weightCfgMapper
.
insert
(
weightCfg
);
weightCfgMapper
.
insert
(
setIndMsg
(
weightCfg
)
);
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateWeight
(
ObjScoreIndWeightCfg
weightCfg
)
{
public
void
updateWeight
(
ObjScoreIndWeightCfg
weightCfg
)
{
weightCfg
.
setState
(
Constants
.
DATA_STATE_A
);
weightCfg
.
setState
(
Constants
.
DATA_STATE_A
);
weightCfgMapper
.
updateByPrimaryKey
(
weightCfg
);
weightCfgMapper
.
updateByPrimaryKey
(
setIndMsg
(
weightCfg
));
}
/**
* 通过indicators设置权重指标相关内容
* @param weightCfg
* @return
*/
private
static
ObjScoreIndWeightCfg
setIndMsg
(
ObjScoreIndWeightCfg
weightCfg
)
{
List
<
TaskRuleIndicator
>
indicators
=
weightCfg
.
getIndicators
();
if
(
indicators
!=
null
&&
indicators
.
size
()
>
0
)
{
StringBuilder
indIds
=
new
StringBuilder
();
StringBuilder
indNames
=
new
StringBuilder
();
indIds
.
append
(
indicators
.
get
(
0
).
getIndId
());
indNames
.
append
(
indicators
.
get
(
0
).
getIndName
());
for
(
int
i
=
1
;
i
<
indicators
.
size
();
i
++)
{
String
indId
=
indicators
.
get
(
i
).
getIndId
();
String
indName
=
indicators
.
get
(
i
).
getIndName
();
indIds
.
append
(
","
).
append
(
indId
);
indNames
.
append
(
","
).
append
(
indName
);
}
weightCfg
.
setIndIds
(
indIds
.
toString
());
weightCfg
.
setIndNames
(
indNames
.
toString
());
}
return
weightCfg
;
}
}
@Override
@Override
...
...
src/main/java/com/keymobile/indicators/service/report/IndicatorsReportService.java
View file @
2b585dc7
...
@@ -930,7 +930,9 @@ public class IndicatorsReportService {
...
@@ -930,7 +930,9 @@ public class IndicatorsReportService {
int
start
=
0
;
int
start
=
0
;
int
end
=
3
;
int
end
=
3
;
Map
<
String
,
Integer
>
resultRank
=
(
Map
<
String
,
Integer
>)
sameImproveResult
.
get
(
"resultRank"
);
Map
<
String
,
Integer
>
resultRank
=
(
Map
<
String
,
Integer
>)
sameImproveResult
.
get
(
"resultRank"
);
if
(!
resultRank
.
isEmpty
())
{
logger
.
info
(
"空指针日志resultRank:"
+
resultRank
);
// TODO: 2023-02-16-0016 判空有未考虑到情况,需要添加其他判空情况
if
(
resultRank
!=
null
&&
!
resultRank
.
isEmpty
())
{
//根据省对市地区顺序排列排名并列的情况
//根据省对市地区顺序排列排名并列的情况
Map
<
String
,
Object
>
objSortRank
=
CalculateUtils
.
rankByObjSort
(
resultRank
,
objSort
);
Map
<
String
,
Object
>
objSortRank
=
CalculateUtils
.
rankByObjSort
(
resultRank
,
objSort
);
resultRank
=
(
Map
<
String
,
Integer
>)
objSortRank
.
get
(
"rankMap"
);
resultRank
=
(
Map
<
String
,
Integer
>)
objSortRank
.
get
(
"rankMap"
);
...
...
src/main/java/com/keymobile/indicators/utils/CalculateUtils.java
View file @
2b585dc7
...
@@ -7,6 +7,7 @@ import java.util.regex.Matcher;
...
@@ -7,6 +7,7 @@ import java.util.regex.Matcher;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
com.keymobile.indicators.function.Function_YYCD
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -396,6 +397,18 @@ public class CalculateUtils {
...
@@ -396,6 +397,18 @@ public class CalculateUtils {
}
}
}
}
/**
* 计算原烟纯度公式的值
* @param finalFormula 原烟纯度公式
* @return 公式计算结果
*/
public
static
Double
calculateYYCD
(
String
finalFormula
)
{
AviatorEvaluator
.
addFunction
(
new
Function_YYCD
());
Object
execute1
=
AviatorEvaluator
.
execute
(
finalFormula
);
return
(
Double
)
execute1
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// Map<String,Integer> objSort = new HashMap<>();
// Map<String,Integer> objSort = new HashMap<>();
// objSort.put("4301",1);objSort.put("4302",2);objSort.put("4303",3);
// objSort.put("4301",1);objSort.put("4302",2);objSort.put("4303",3);
...
...
src/main/resources/mybatis/mapping/ObjScoreIndWeightCfgMapper.xml
View file @
2b585dc7
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
<include
refid=
"findWhereSql"
/>
<include
refid=
"findWhereSql"
/>
</select>
</select>
<select
id=
"findByIdList"
resultType=
"com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg"
>
<select
id=
"findByIdList"
parameterType=
"java.util.List"
resultType=
"com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg"
>
select *
select *
from obj_score_ind_weight_cfg as weight
from obj_score_ind_weight_cfg as weight
where id in
where id in
...
...
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