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
e0f65606
Commit
e0f65606
authored
Jun 27, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加指标保存时保存指标关系和根据指标id查找关系接口
parent
deb27883
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
0 deletions
+126
-0
IndicatorsRelCtrl.java
...keymobile/indicators/api/hytobacco/IndicatorsRelCtrl.java
+29
-0
BaseIndDefService.java
...obile/indicators/service/hytobacco/BaseIndDefService.java
+4
-0
DriveIndDefService.java
...bile/indicators/service/hytobacco/DriveIndDefService.java
+4
-0
IndicatorsRelService.java
...le/indicators/service/hytobacco/IndicatorsRelService.java
+89
-0
No files found.
src/main/java/com/keymobile/indicators/api/hytobacco/IndicatorsRelCtrl.java
0 → 100644
View file @
e0f65606
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.keymobile.indicators.service.hytobacco.IndicatorsRelService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
tags
={
"指标关系接口"
})
@RestController
@RequestMapping
(
value
=
"/indRel"
)
public
class
IndicatorsRelCtrl
{
@Autowired
private
IndicatorsRelService
indRelService
;
@ApiOperation
(
value
=
"根据指标id获取指标关系,type:0 基础指标 1考核指标"
,
notes
=
"根据指标id获取指标关系,type:0 基础指标 1考核指标"
)
@PostMapping
(
value
=
"/getRelByIndId"
)
public
Map
<
String
,
Object
>
getRelByIndId
(
@RequestParam
String
indId
,
@RequestParam
String
type
,
@RequestParam
String
incluSelf
){
return
indRelService
.
getRelByIndId
(
indId
,
type
,
incluSelf
);
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/BaseIndDefService.java
View file @
e0f65606
...
...
@@ -18,6 +18,8 @@ public class BaseIndDefService {
private
BaseIndDefMapper
baseIndDefMapper
;
@Autowired
private
BaseIndDefVersionService
baseIndDefVersionService
;
@Autowired
private
IndicatorsRelService
indRelService
;
public
String
saveOrUpdate
(
BaseIndDef
baseIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
,
String
isUpdate
)
...
...
@@ -58,6 +60,8 @@ public class BaseIndDefService {
return
"base ind is not exist,update ind fail"
;
}
}
//保存或修改指标关系
indRelService
.
saveOrUpdate
(
baseIndDef
.
getIndId
(),
"0"
);
return
"success;indId:"
+
baseIndDef
.
getIndId
();
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndDefService.java
View file @
e0f65606
...
...
@@ -35,6 +35,8 @@ public class DriveIndDefService {
private
ShortboardDriveIndRelMapper
shortboardDriveIndRelMapper
;
@Autowired
private
ShortboardRuleMapper
shortboardRuleMapper
;
@Autowired
private
IndicatorsRelService
indRelService
;
public
String
saveOrUpdate
(
DriveIndDef
driveIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
,
String
isUpdate
,
String
shortboardIds
)
throws
Exception
{
...
...
@@ -94,6 +96,8 @@ public class DriveIndDefService {
}
}
}
//保存或修改指标关系
indRelService
.
saveOrUpdate
(
driveIndDef
.
getIndId
(),
"1"
);
return
"success;driveIndId:"
+
driveIndDef
.
getIndId
();
}
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsRelService.java
View file @
e0f65606
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
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
;
...
...
@@ -31,6 +33,93 @@ public class IndicatorsRelService {
@Autowired
private
IndicatorsRelMapper
indicatorsRelMapper
;
//incluSelf:表示是否包含自己 0:否 1:是
//type:0 基础指标 1:考核指标
public
Map
<
String
,
Object
>
getRelByIndId
(
String
indId
,
String
type
,
String
incluSelf
){
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
//先从库里找,找不到再分析公式然后保存进库里
List
<
IndicatorsRel
>
indRels
=
indicatorsRelMapper
.
findByIndId
(
indId
);
if
(
indRels
.
isEmpty
())
{
resultMap
=
this
.
getRelFromFormula
(
indId
,
type
,
incluSelf
);
}
else
{
String
formula
=
null
;
String
formulaDesc
=
null
;
List
<
String
>
resultIndIdList
=
new
ArrayList
<>();
//根据类型查找指标
if
(
"0"
.
equals
(
type
))
{
//基础指标
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indId
);
if
(
baseIndDef
!=
null
)
{
formula
=
baseIndDef
.
getIndFormat
();
formulaDesc
=
baseIndDef
.
getIndFormatDesc
();
}
}
else
{
//考核指标
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
indId
);
if
(
driveIndDef
!=
null
)
{
formula
=
driveIndDef
.
getIndFormat
();
formulaDesc
=
driveIndDef
.
getIndFormatDesc
();
}
}
resultMap
.
put
(
"formula"
,
formula
);
resultMap
.
put
(
"formulaDesc"
,
formulaDesc
);
for
(
IndicatorsRel
indRel
:
indRels
)
{
resultIndIdList
.
add
(
indRel
.
getRelIndId
());
}
if
(
"1"
.
equals
(
incluSelf
))
{
resultIndIdList
.
add
(
indId
);
}
resultMap
.
put
(
"indIdList"
,
resultIndIdList
);
}
return
resultMap
;
}
public
Map
<
String
,
Object
>
getRelFromFormula
(
String
indId
,
String
type
,
String
incluSelf
){
String
formula
=
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
);
//根据类型查找指标
if
(
"0"
.
equals
(
type
))
{
//基础指标
BaseIndDef
baseIndDef
=
baseIndDefMapper
.
selectByPrimaryKey
(
indId
);
if
(
baseIndDef
!=
null
)
{
formula
=
baseIndDef
.
getIndFormat
();
formulaDesc
=
baseIndDef
.
getIndFormatDesc
();
}
}
else
{
//考核指标
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
indId
);
if
(
driveIndDef
!=
null
)
{
formula
=
driveIndDef
.
getIndFormat
();
formulaDesc
=
driveIndDef
.
getIndFormatDesc
();
}
}
//解析公式关系
if
(
StringUtils
.
isNotBlank
(
formula
))
{
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
);
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
;
}
//type:0 基础指标 1:考核指标
public
void
saveOrUpdate
(
String
indId
,
String
type
)
{
String
formula
=
null
;
...
...
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