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
e609702d
Commit
e609702d
authored
Jun 28, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
指标关系接口优化
parent
e0f65606
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
IndicatorsRel.java
...ile/indicators/model/entity/indicators/IndicatorsRel.java
+1
-0
IndicatorsRelService.java
...le/indicators/service/hytobacco/IndicatorsRelService.java
+43
-3
No files found.
src/main/java/com/keymobile/indicators/model/entity/indicators/IndicatorsRel.java
View file @
e609702d
...
...
@@ -18,6 +18,7 @@ public class IndicatorsRel {
private
Integer
id
;
private
String
indId
;
private
String
relIndId
;
private
String
indType
;
//类型 0:基础指标 1:考核指标
private
String
indFormat
;
//指标公式
private
String
indFormatDesc
;
//指标公式描述
}
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsRelService.java
View file @
e609702d
...
...
@@ -35,6 +35,7 @@ public class IndicatorsRelService {
//incluSelf:表示是否包含自己 0:否 1:是
//type:0 基础指标 1:考核指标
@SuppressWarnings
(
"unchecked"
)
public
Map
<
String
,
Object
>
getRelByIndId
(
String
indId
,
String
type
,
String
incluSelf
){
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
//先从库里找,找不到再分析公式然后保存进库里
...
...
@@ -59,19 +60,45 @@ public class IndicatorsRelService {
formulaDesc
=
driveIndDef
.
getIndFormatDesc
();
}
}
resultMap
.
put
(
"formula"
,
formula
);
resultMap
.
put
(
"formulaDesc"
,
formulaDesc
);
for
(
IndicatorsRel
indRel
:
indRels
)
{
resultIndIdList
.
add
(
indRel
.
getRelIndId
());
}
//循环找出基础指标包含的指标
Map
<
String
,
Object
>
resultBaseRelMap
=
this
.
getBaseIndRel
(
resultIndIdList
,
formula
);
resultIndIdList
.
addAll
((
List
<
String
>)
resultBaseRelMap
.
get
(
"resultIndIdList"
));
if
(
resultBaseRelMap
.
get
(
"formula"
)!=
null
&&
!
""
.
equals
(
resultBaseRelMap
.
get
(
"formula"
)))
{
formula
=
resultBaseRelMap
.
get
(
"formula"
).
toString
();
}
if
(
"1"
.
equals
(
incluSelf
))
{
resultIndIdList
.
add
(
indId
);
}
resultMap
.
put
(
"ind_type"
,
type
);
resultMap
.
put
(
"formula"
,
formula
);
resultMap
.
put
(
"formulaDesc"
,
formulaDesc
);
resultMap
.
put
(
"indIdList"
,
resultIndIdList
);
}
return
resultMap
;
}
@SuppressWarnings
(
"unchecked"
)
public
Map
<
String
,
Object
>
getBaseIndRel
(
List
<
String
>
resultIndIdList
,
String
formula
){
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
String
>
resultRelIndList
=
new
ArrayList
<>();
for
(
String
indId
:
resultIndIdList
)
{
Map
<
String
,
Object
>
relIndIdMap
=
this
.
getRelFromFormula
(
indId
,
"0"
,
"0"
);
if
(
relIndIdMap
.
get
(
"formula"
)!=
null
&&
!
""
.
equals
(
relIndIdMap
.
get
(
"formula"
)))
{
String
relIndFormula
=
relIndIdMap
.
get
(
"formula"
).
toString
();
List
<
String
>
relIndList
=
(
List
<
String
>)
relIndIdMap
.
get
(
"indIdList"
);
resultRelIndList
.
addAll
(
relIndList
);
formula
=
formula
.
replace
(
"["
+
indId
+
"]"
,
"("
+
relIndFormula
+
")"
);
}
}
result
.
put
(
"resultIndIdList"
,
resultRelIndList
);
result
.
put
(
"formula"
,
formula
);
return
result
;
}
public
Map
<
String
,
Object
>
getRelFromFormula
(
String
indId
,
String
type
,
String
incluSelf
){
String
formula
=
null
;
String
formulaDesc
=
null
;
...
...
@@ -80,6 +107,8 @@ public class IndicatorsRelService {
resultMap
.
put
(
"indIdList"
,
new
ArrayList
<>());
resultMap
.
put
(
"formula"
,
formula
);
resultMap
.
put
(
"formulaDesc"
,
formulaDesc
);
//判断该指标有没有保存了关联指标
List
<
IndicatorsRel
>
indRels
=
indicatorsRelMapper
.
findByIndId
(
indId
);
//根据类型查找指标
if
(
"0"
.
equals
(
type
))
{
//基础指标
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indId
);
...
...
@@ -94,6 +123,14 @@ public class IndicatorsRelService {
formulaDesc
=
driveIndDef
.
getIndFormatDesc
();
}
}
if
(!
indRels
.
isEmpty
())
{
for
(
IndicatorsRel
rel
:
indRels
)
{
resultIndIdList
.
add
(
rel
.
getRelIndId
());
}
if
(
"1"
.
equals
(
incluSelf
))
{
resultIndIdList
.
add
(
indId
);
}
}
else
{
//解析公式关系
if
(
StringUtils
.
isNotBlank
(
formula
))
{
List
<
String
>
indIdList
=
new
ArrayList
<>();
...
...
@@ -107,16 +144,18 @@ public class IndicatorsRelService {
indRel
.
setRelIndId
(
relIndId
);
indRel
.
setIndFormat
(
formula
);
indRel
.
setIndFormatDesc
(
formulaDesc
);
indRel
.
setIndType
(
type
);
indicatorsRelMapper
.
insert
(
indRel
);
resultIndIdList
.
add
(
relIndId
);
}
if
(
"1"
.
equals
(
incluSelf
))
{
resultIndIdList
.
add
(
indId
);
}
}
}
resultMap
.
put
(
"indIdList"
,
resultIndIdList
);
resultMap
.
put
(
"formula"
,
formula
);
resultMap
.
put
(
"formulaDesc"
,
formulaDesc
);
}
return
resultMap
;
}
...
...
@@ -157,6 +196,7 @@ public class IndicatorsRelService {
indRel
.
setRelIndId
(
relIndId
);
indRel
.
setIndFormat
(
formula
);
indRel
.
setIndFormatDesc
(
formulaDesc
);
indRel
.
setIndType
(
type
);
indicatorsRelMapper
.
insert
(
indRel
);
}
}
...
...
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