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
84833a54
Commit
84833a54
authored
Jul 02, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改标签关系接口和配置文件添加接口调用超时配置
parent
a7423b56
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
94 deletions
+102
-94
IndicatorsRelCtrl.java
...keymobile/indicators/api/hytobacco/IndicatorsRelCtrl.java
+2
-3
BaseIndDef.java
...mobile/indicators/model/entity/indicators/BaseIndDef.java
+4
-0
IndicatorsRelService.java
...le/indicators/service/hytobacco/IndicatorsRelService.java
+82
-90
application-test.yml
src/main/resources/application-test.yml
+14
-1
No files found.
src/main/java/com/keymobile/indicators/api/hytobacco/IndicatorsRelCtrl.java
View file @
84833a54
...
@@ -22,8 +22,7 @@ public class IndicatorsRelCtrl {
...
@@ -22,8 +22,7 @@ public class IndicatorsRelCtrl {
@ApiOperation
(
value
=
"根据指标id获取指标关系,type:0 基础指标 1考核指标"
,
notes
=
"根据指标id获取指标关系,type:0 基础指标 1考核指标"
)
@ApiOperation
(
value
=
"根据指标id获取指标关系,type:0 基础指标 1考核指标"
,
notes
=
"根据指标id获取指标关系,type:0 基础指标 1考核指标"
)
@PostMapping
(
value
=
"/getRelByIndId"
)
@PostMapping
(
value
=
"/getRelByIndId"
)
public
Map
<
String
,
Object
>
getRelByIndId
(
@RequestParam
String
indId
,
@RequestParam
String
type
,
public
Map
<
String
,
Object
>
getRelByIndId
(
@RequestParam
String
indId
,
@RequestParam
String
type
){
@RequestParam
String
incluSelf
){
return
indRelService
.
getRelByIndId
(
indId
,
type
);
return
indRelService
.
getRelByIndId
(
indId
,
type
,
incluSelf
);
}
}
}
}
src/main/java/com/keymobile/indicators/model/entity/indicators/BaseIndDef.java
View file @
84833a54
package
com
.
keymobile
.
indicators
.
model
.
entity
.
indicators
;
package
com
.
keymobile
.
indicators
.
model
.
entity
.
indicators
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
...
@@ -34,4 +36,6 @@ public class BaseIndDef {
...
@@ -34,4 +36,6 @@ public class BaseIndDef {
private
String
version
;
//版本号
private
String
version
;
//版本号
private
Integer
catalogId
;
//挂靠目录id
private
Integer
catalogId
;
//挂靠目录id
private
String
catalogIdPath
;
//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
private
String
catalogIdPath
;
//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
private
List
<
BaseIndDef
>
children
=
new
ArrayList
<>();
//子基础项
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsRelService.java
View file @
84833a54
...
@@ -33,82 +33,45 @@ public class IndicatorsRelService {
...
@@ -33,82 +33,45 @@ public class IndicatorsRelService {
@Autowired
@Autowired
private
IndicatorsRelMapper
indicatorsRelMapper
;
private
IndicatorsRelMapper
indicatorsRelMapper
;
//incluSelf:表示是否包含自己 0:否 1:是
//type:0 基础指标 1:考核指标
//type:0 基础指标 1:考核指标
@SuppressWarnings
(
"unchecked"
)
public
Map
<
String
,
Object
>
getRelByIndId
(
String
indId
,
String
type
){
public
Map
<
String
,
Object
>
getRelByIndId
(
String
indId
,
String
type
,
String
incluSelf
){
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
List
<
BaseIndDef
>
resultList
=
new
ArrayList
<>();
//先从库里找,找不到再分析公式然后保存进库里
//先从库里找,找不到再分析公式然后保存进库里
List
<
IndicatorsRel
>
indRels
=
indicatorsRelMapper
.
findByIndId
(
indId
);
List
<
IndicatorsRel
>
indRels
=
indicatorsRelMapper
.
findByIndId
(
indId
);
if
(
indRels
.
isEmpty
())
{
if
(
indRels
.
isEmpty
())
{
result
Map
=
this
.
getRelFromFormula
(
indId
,
type
,
incluSelf
);
result
List
=
this
.
getRelFromFormula
(
indId
,
type
);
}
else
{
}
else
{
String
formula
=
null
;
for
(
IndicatorsRel
indRel
:
indRels
)
{
//基础指标
String
formulaDesc
=
null
;
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indRel
.
getRelIndId
());
List
<
String
>
resultIndIdList
=
new
ArrayList
<>();
//根据类型查找指标
if
(
"0"
.
equals
(
type
))
{
//基础指标
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indId
);
if
(
baseIndDef
!=
null
)
{
if
(
baseIndDef
!=
null
)
{
formula
=
baseIndDef
.
getIndFormat
();
//判断数据项是否包含子数据项
formulaDesc
=
baseIndDef
.
getIndFormatDesc
();
List
<
IndicatorsRel
>
childIndRels
=
indicatorsRelMapper
.
findByIndId
(
baseIndDef
.
getIndId
());
}
if
(!
childIndRels
.
isEmpty
())
{
}
else
{
//考核指标
List
<
BaseIndDef
>
childIndList
=
new
ArrayList
<>();
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
indId
);
for
(
IndicatorsRel
childIndRel
:
childIndRels
)
{
if
(
driveIndDef
!=
null
)
{
BaseIndDef
childBaseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
formula
=
driveIndDef
.
getIndFormat
();
childIndRel
.
getRelIndId
());
formulaDesc
=
driveIndDef
.
getIndFormatDesc
();
if
(
childBaseIndDef
!=
null
)
{
childIndList
.
add
(
childBaseIndDef
);
}
}
baseIndDef
.
setChildren
(
childIndList
);
resultList
.
add
(
baseIndDef
);
}
else
{
resultList
.
addAll
(
this
.
getRelFromFormula
(
baseIndDef
.
getIndId
(),
"0"
));
}
}
}
}
}
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
);
}
}
resultMap
.
put
(
"indList"
,
resultList
);
return
resultMap
;
return
resultMap
;
}
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
BaseIndDef
>
getRelFromFormula
(
String
indId
,
String
type
){
public
Map
<
String
,
Object
>
getBaseIndRel
(
List
<
String
>
resultIndIdList
,
String
formula
){
List
<
BaseIndDef
>
resultList
=
new
ArrayList
<>();
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
formula
=
null
;
String
formulaDesc
=
null
;
String
formulaDesc
=
null
;
List
<
String
>
resultIndIdList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"indIdList"
,
new
ArrayList
<>());
resultMap
.
put
(
"formula"
,
formula
);
resultMap
.
put
(
"formulaDesc"
,
formulaDesc
);
//判断该指标有没有保存了关联指标
List
<
IndicatorsRel
>
indRels
=
indicatorsRelMapper
.
findByIndId
(
indId
);
//根据类型查找指标
//根据类型查找指标
if
(
"0"
.
equals
(
type
))
{
//基础指标
if
(
"0"
.
equals
(
type
))
{
//基础指标
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indId
);
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indId
);
...
@@ -123,40 +86,69 @@ public class IndicatorsRelService {
...
@@ -123,40 +86,69 @@ public class IndicatorsRelService {
formulaDesc
=
driveIndDef
.
getIndFormatDesc
();
formulaDesc
=
driveIndDef
.
getIndFormatDesc
();
}
}
}
}
if
(!
indRels
.
isEmpty
())
{
//解析公式关系
for
(
IndicatorsRel
rel
:
indRels
)
{
if
(
StringUtils
.
isNotBlank
(
formula
))
{
resultIndIdList
.
add
(
rel
.
getRelIndId
());
List
<
String
>
indIdList
=
new
ArrayList
<>();
Matcher
m
=
P
.
matcher
(
formula
);
while
(
m
.
find
()){
indIdList
.
add
(
m
.
group
().
substring
(
1
,
m
.
group
().
length
()-
1
));
}
}
if
(
"1"
.
equals
(
incluSelf
))
{
for
(
String
relIndId
:
indIdList
)
{
resultIndIdList
.
add
(
indId
);
IndicatorsRel
indRel
=
new
IndicatorsRel
();
indRel
.
setIndId
(
indId
);
indRel
.
setRelIndId
(
relIndId
);
indRel
.
setIndFormat
(
formula
);
indRel
.
setIndFormatDesc
(
formulaDesc
);
indRel
.
setIndType
(
type
);
indicatorsRelMapper
.
insert
(
indRel
);
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
relIndId
);
if
(
baseIndDef
!=
null
)
{
//解析基础项关联的子基础项
//判断该指标有没有保存了关联指标
List
<
IndicatorsRel
>
indRels
=
indicatorsRelMapper
.
findByIndId
(
baseIndDef
.
getIndId
());
List
<
BaseIndDef
>
childList
=
new
ArrayList
<>();
if
(!
indRels
.
isEmpty
())
{
for
(
IndicatorsRel
indR
:
indRels
)
{
BaseIndDef
childBaseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indR
.
getRelIndId
());
if
(
childBaseIndDef
!=
null
)
{
childList
.
add
(
childBaseIndDef
);
}
}
}
else
{
if
(
StringUtils
.
isNotBlank
(
baseIndDef
.
getIndFormat
()))
{
//解析基础指标公式
List
<
String
>
indIdList1
=
new
ArrayList
<>();
Matcher
m1
=
P
.
matcher
(
baseIndDef
.
getIndFormat
());
while
(
m1
.
find
()){
indIdList1
.
add
(
m1
.
group
().
substring
(
1
,
m1
.
group
().
length
()-
1
));
}
for
(
String
relIndId1
:
indIdList1
)
{
IndicatorsRel
indRel1
=
new
IndicatorsRel
();
indRel1
.
setIndId
(
baseIndDef
.
getIndId
());
indRel1
.
setRelIndId
(
relIndId1
);
indRel1
.
setIndFormat
(
baseIndDef
.
getIndFormat
());
indRel1
.
setIndFormatDesc
(
baseIndDef
.
getIndFormatDesc
());
indRel1
.
setIndType
(
"0"
);
indicatorsRelMapper
.
insert
(
indRel1
);
BaseIndDef
childBaseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
relIndId1
);
if
(
childBaseIndDef
!=
null
)
{
childList
.
add
(
childBaseIndDef
);
}
}
}
}
baseIndDef
.
setChildren
(
childList
);
resultList
.
add
(
baseIndDef
);
}
}
}
}
else
{
}
else
{
//解析公式关系
if
(
"0"
.
equals
(
type
))
{
//基础指标
if
(
StringUtils
.
isNotBlank
(
formula
))
{
resultList
.
add
(
baseIndDefMapper
.
selectByPrimaryKey
(
indId
));
List
<
String
>
indIdList
=
new
ArrayList
<>();
Matcher
m
=
P
.
matcher
(
formula
);
while
(
m
.
find
()){
indIdList
.
add
(
m
.
group
().
substring
(
1
,
m
.
group
().
length
()-
1
));
}
for
(
String
relIndId
:
indIdList
)
{
IndicatorsRel
indRel
=
new
IndicatorsRel
();
indRel
.
setIndId
(
indId
);
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
);
return
resultList
;
resultMap
.
put
(
"formula"
,
formula
);
resultMap
.
put
(
"formulaDesc"
,
formulaDesc
);
return
resultMap
;
}
}
//type:0 基础指标 1:考核指标
//type:0 基础指标 1:考核指标
...
...
src/main/resources/application-test.yml
View file @
84833a54
...
@@ -44,6 +44,18 @@ eureka:
...
@@ -44,6 +44,18 @@ eureka:
instance
:
instance
:
prefer-ip-address
:
true
prefer-ip-address
:
true
hostname
:
192.168.0.230
hostname
:
192.168.0.230
ribbon
:
ReadTimeout
:
180000
ConnectTimeout
:
180000
OkToRetryOnAllOperations
:
true
MaxAutoRetries
:
3
feign
:
client
:
config
:
default
:
connectTimeout
:
180000
ReadTimeout
:
180000
security
:
security
:
permit
:
true
permit
:
true
...
@@ -57,5 +69,5 @@ mybatis:
...
@@ -57,5 +69,5 @@ mybatis:
logging
:
logging
:
level
:
level
:
com.keymobile.indicators
:
debug
com.keymobile.indicators
:
info
config
:
classpath:logback-custom.xml
config
:
classpath:logback-custom.xml
\ 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