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
710abc78
Commit
710abc78
authored
Jun 21, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增基础和考核指标自增指标编号接口以及修改基础和考核指标新增逻辑。
parent
4c2dbb08
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
130 additions
and
42 deletions
+130
-42
IndicatorsDefCtrl.java
...keymobile/indicators/api/hytobacco/IndicatorsDefCtrl.java
+21
-6
BaseIndDefMapper.java
.../indicators/model/mapper/indicators/BaseIndDefMapper.java
+3
-0
DriveIndDefMapper.java
...indicators/model/mapper/indicators/DriveIndDefMapper.java
+3
-0
BaseIndDefService.java
...obile/indicators/service/hytobacco/BaseIndDefService.java
+44
-18
DriveIndDefService.java
...bile/indicators/service/hytobacco/DriveIndDefService.java
+45
-18
BaseIndDefMapper.xml
src/main/resources/mybatis/mapping/BaseIndDefMapper.xml
+7
-0
DriveIndDefMapper.xml
src/main/resources/mybatis/mapping/DriveIndDefMapper.xml
+7
-0
No files found.
src/main/java/com/keymobile/indicators/api/hytobacco/IndicatorsDefCtrl.java
View file @
710abc78
...
@@ -30,11 +30,19 @@ public class IndicatorsDefCtrl {
...
@@ -30,11 +30,19 @@ public class IndicatorsDefCtrl {
@Autowired
@Autowired
private
DriveIndCalResultService
driveIndCalResultService
;
private
DriveIndCalResultService
driveIndCalResultService
;
@ApiOperation
(
value
=
"新建基础指标"
,
notes
=
"新建基础指标"
)
@ApiOperation
(
value
=
"获取基础指标最大id"
,
notes
=
"获取基础指标最大id"
)
@PostMapping
(
value
=
"/getBaseIndMaxId"
)
public
String
getBaseIndMaxId
(
@RequestParam
String
code
,
@RequestParam
Integer
length
)
throws
Exception
{
return
baseIndDefService
.
getBaseIndMaxIndId
(
code
,
length
);
}
@ApiOperation
(
value
=
"新建基础指标(isUpdate:0 新增 1修改)"
,
notes
=
"新建基础指标(isUpdate:0 新增 1修改)"
)
@PostMapping
(
value
=
"/createBaseInd"
)
@PostMapping
(
value
=
"/createBaseInd"
)
public
void
createBaseInd
(
@RequestBody
BaseIndDef
baseIndDef
,
@RequestParam
Integer
catalogId
,
public
void
createBaseInd
(
@RequestBody
BaseIndDef
baseIndDef
,
@RequestParam
Integer
catalogId
,
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
)
throws
Exception
{
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
,
baseIndDefService
.
saveOrUpdate
(
baseIndDef
,
catalogId
,
catalogIdPath
,
user
);
@RequestParam
String
isUpdate
)
throws
Exception
{
baseIndDefService
.
saveOrUpdate
(
baseIndDef
,
catalogId
,
catalogIdPath
,
user
,
isUpdate
);
}
}
@ApiOperation
(
value
=
"删除基础指标"
,
notes
=
"删除基础指标"
)
@ApiOperation
(
value
=
"删除基础指标"
,
notes
=
"删除基础指标"
)
...
@@ -57,12 +65,19 @@ public class IndicatorsDefCtrl {
...
@@ -57,12 +65,19 @@ public class IndicatorsDefCtrl {
return
baseIndDefService
.
getByPageAndKeyword
(
catalogId
,
keyword
,
page
,
rows
);
return
baseIndDefService
.
getByPageAndKeyword
(
catalogId
,
keyword
,
page
,
rows
);
}
}
@ApiOperation
(
value
=
"新建考核指标"
,
notes
=
"新建考核指标"
)
@ApiOperation
(
value
=
"获取考核指标最大id"
,
notes
=
"获取考核指标最大id"
)
@PostMapping
(
value
=
"/getDriveIndMaxId"
)
public
String
getDriveIndMaxId
(
@RequestParam
String
code
,
@RequestParam
Integer
length
)
throws
Exception
{
return
driveIndDefService
.
getDriveIndMaxIndId
(
code
,
length
);
}
@ApiOperation
(
value
=
"新建考核指标(isUpdate:0 新增 1修改)"
,
notes
=
"新建考核指标(isUpdate:0 新增 1修改)"
)
@PostMapping
(
value
=
"/createDriveInd"
)
@PostMapping
(
value
=
"/createDriveInd"
)
public
void
createDriveInd
(
@RequestBody
DriveIndDef
driveIndDef
,
@RequestParam
Integer
catalogId
,
public
void
createDriveInd
(
@RequestBody
DriveIndDef
driveIndDef
,
@RequestParam
Integer
catalogId
,
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
,
@RequestParam
String
catalogIdPath
,
@RequestParam
String
user
,
@RequestParam
String
isUpdate
,
@RequestParam
String
shortboardIds
)
throws
Exception
{
@RequestParam
String
shortboardIds
)
throws
Exception
{
driveIndDefService
.
saveOrUpdate
(
driveIndDef
,
catalogId
,
catalogIdPath
,
user
,
shortboardIds
);
driveIndDefService
.
saveOrUpdate
(
driveIndDef
,
catalogId
,
catalogIdPath
,
user
,
isUpdate
,
shortboardIds
);
}
}
@ApiOperation
(
value
=
"删除考核指标"
,
notes
=
"删除考核指标"
)
@ApiOperation
(
value
=
"删除考核指标"
,
notes
=
"删除考核指标"
)
...
...
src/main/java/com/keymobile/indicators/model/mapper/indicators/BaseIndDefMapper.java
View file @
710abc78
...
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
import
com.keymobile.indicators.model.entity.indicators.BaseIndDef
;
import
com.keymobile.indicators.model.entity.indicators.BaseIndDef
;
import
feign.Param
;
import
tk.mybatis.mapper.common.BaseMapper
;
import
tk.mybatis.mapper.common.BaseMapper
;
@Mapper
@Mapper
...
@@ -16,4 +17,6 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{
...
@@ -16,4 +17,6 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{
public
int
getByKeywordCount
(
Map
<
String
,
Object
>
param
);
public
int
getByKeywordCount
(
Map
<
String
,
Object
>
param
);
public
void
deleteByCatalogIdIn
(
List
<
Integer
>
catalogIds
);
public
void
deleteByCatalogIdIn
(
List
<
Integer
>
catalogIds
);
public
String
getMaxIndId
(
@Param
(
"code"
)
String
code
,
@Param
(
"length"
)
int
length
);
}
}
src/main/java/com/keymobile/indicators/model/mapper/indicators/DriveIndDefMapper.java
View file @
710abc78
...
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
feign.Param
;
import
tk.mybatis.mapper.common.BaseMapper
;
import
tk.mybatis.mapper.common.BaseMapper
;
@Mapper
@Mapper
...
@@ -16,4 +17,6 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{
...
@@ -16,4 +17,6 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{
public
int
getByKeywordCount
(
Map
<
String
,
Object
>
param
);
public
int
getByKeywordCount
(
Map
<
String
,
Object
>
param
);
public
void
deleteByCatalogIdIn
(
List
<
Integer
>
catalogIds
);
public
void
deleteByCatalogIdIn
(
List
<
Integer
>
catalogIds
);
public
String
getMaxIndId
(
@Param
(
"code"
)
String
code
,
@Param
(
"length"
)
int
length
);
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/BaseIndDefService.java
View file @
710abc78
...
@@ -19,32 +19,43 @@ public class BaseIndDefService {
...
@@ -19,32 +19,43 @@ public class BaseIndDefService {
@Autowired
@Autowired
private
BaseIndDefVersionService
baseIndDefVersionService
;
private
BaseIndDefVersionService
baseIndDefVersionService
;
public
String
saveOrUpdate
(
BaseIndDef
baseIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
)
public
String
saveOrUpdate
(
BaseIndDef
baseIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
,
String
isUpdate
)
throws
Exception
{
throws
Exception
{
if
(
StringUtils
.
isBlank
(
baseIndDef
.
getIndId
()))
{
if
(
StringUtils
.
isBlank
(
baseIndDef
.
getIndId
()))
{
return
"indId can not be null"
;
return
"indId can not be null"
;
}
}
BaseIndDef
dbBaseIndDef
=
this
.
getById
(
baseIndDef
.
getIndId
());
//如果是新增,需要判断库中是否已存在指标编号
if
(
dbBaseIndDef
==
null
)
{
if
(
"0"
.
equals
(
isUpdate
))
{
//新增
baseIndDef
.
setCreater
(
user
);
BaseIndDef
dbBaseIndDef
=
this
.
getById
(
baseIndDef
.
getIndId
());
baseIndDef
.
setCreateTime
(
new
Date
());
if
(
dbBaseIndDef
!=
null
)
{
baseIndDef
.
setUpdater
(
user
);
return
"indId is exist,create base indicators fail"
;
baseIndDef
.
setUpdateTime
(
new
Date
());
}
else
{
baseIndDef
.
setVersion
(
"1.0"
);
baseIndDef
.
setCreater
(
user
);
baseIndDef
.
setCatalogId
(
catalogId
);
baseIndDef
.
setCreateTime
(
new
Date
());
baseIndDef
.
setCatalogIdPath
(
catalogIdPath
);
baseIndDefMapper
.
insert
(
baseIndDef
);
}
else
{
//生成版本
if
(
baseIndDefVersionService
.
save
(
dbBaseIndDef
))
{
String
oldVersion
=
dbBaseIndDef
.
getVersion
();
String
newVersion
=
String
.
valueOf
(
Double
.
valueOf
(
oldVersion
)+
1
);
//旧版本+1
baseIndDef
.
setUpdater
(
user
);
baseIndDef
.
setUpdater
(
user
);
baseIndDef
.
setUpdateTime
(
new
Date
());
baseIndDef
.
setUpdateTime
(
new
Date
());
baseIndDef
.
setVersion
(
newVersion
);
baseIndDef
.
setVersion
(
"1.0"
);
baseIndDef
.
setCatalogId
(
catalogId
);
baseIndDef
.
setCatalogId
(
catalogId
);
baseIndDef
.
setCatalogIdPath
(
catalogIdPath
);
baseIndDef
.
setCatalogIdPath
(
catalogIdPath
);
baseIndDefMapper
.
updateByPrimaryKey
(
baseIndDef
);
baseIndDefMapper
.
insert
(
baseIndDef
);
}
}
else
{
//修改
BaseIndDef
dbBaseIndDef
=
this
.
getById
(
baseIndDef
.
getIndId
());
if
(
dbBaseIndDef
!=
null
)
{
//生成版本
if
(
baseIndDefVersionService
.
save
(
dbBaseIndDef
))
{
String
oldVersion
=
dbBaseIndDef
.
getVersion
();
String
newVersion
=
String
.
valueOf
(
Double
.
valueOf
(
oldVersion
)+
1
);
//旧版本+1
baseIndDef
.
setUpdater
(
user
);
baseIndDef
.
setUpdateTime
(
new
Date
());
baseIndDef
.
setVersion
(
newVersion
);
baseIndDef
.
setCatalogId
(
catalogId
);
baseIndDef
.
setCatalogIdPath
(
catalogIdPath
);
baseIndDefMapper
.
updateByPrimaryKey
(
baseIndDef
);
}
}
else
{
return
"base ind is not exist,update ind fail"
;
}
}
}
}
return
"success;indId:"
+
baseIndDef
.
getIndId
();
return
"success;indId:"
+
baseIndDef
.
getIndId
();
...
@@ -83,4 +94,19 @@ public class BaseIndDefService {
...
@@ -83,4 +94,19 @@ public class BaseIndDefService {
return
resultMap
;
return
resultMap
;
}
}
public
String
getBaseIndMaxIndId
(
String
code
,
int
length
)
{
if
(
code
.
length
()>=
length
)
{
return
"id的编码不能大于等于id的长度"
;
}
String
maxId
=
baseIndDefMapper
.
getMaxIndId
(
code
+
"%"
,
length
);
if
(
StringUtils
.
isBlank
(
maxId
))
{
String
addZero
=
""
;
for
(
int
i
=
0
;
i
<(
length
-
code
.
length
()-
1
);
i
++)
{
addZero
+=
"0"
;
}
maxId
=
code
+
addZero
+
"1"
;
}
return
maxId
;
}
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndDefService.java
View file @
710abc78
...
@@ -37,31 +37,40 @@ public class DriveIndDefService {
...
@@ -37,31 +37,40 @@ public class DriveIndDefService {
private
ShortboardRuleMapper
shortboardRuleMapper
;
private
ShortboardRuleMapper
shortboardRuleMapper
;
public
String
saveOrUpdate
(
DriveIndDef
driveIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
public
String
saveOrUpdate
(
DriveIndDef
driveIndDef
,
Integer
catalogId
,
String
catalogIdPath
,
String
user
,
String
shortboardIds
)
throws
Exception
{
String
user
,
String
isUpdate
,
String
shortboardIds
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIndId
()))
{
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIndId
()))
{
return
"indId can not be null"
;
return
"indId can not be null"
;
}
}
DriveIndDef
dbBaseIndDef
=
this
.
getById
(
driveIndDef
.
getIndId
());
if
(
"0"
.
equals
(
isUpdate
))
{
//新建
if
(
dbBaseIndDef
==
null
)
{
DriveIndDef
dbDriveIndDef
=
this
.
getById
(
driveIndDef
.
getIndId
());
driveIndDef
.
setCreater
(
user
);
if
(
dbDriveIndDef
==
null
)
{
driveIndDef
.
setCreateTime
(
new
Date
());
return
"indId is exist,create drive indicators fail"
;
driveIndDef
.
setUpdater
(
user
);
}
else
{
driveIndDef
.
setUpdateTime
(
new
Date
());
driveIndDef
.
setCreater
(
user
);
driveIndDef
.
setVersion
(
"1.0"
);
driveIndDef
.
setCreateTime
(
new
Date
());
driveIndDef
.
setCatalogId
(
catalogId
);
driveIndDef
.
setCatalogIdPath
(
catalogIdPath
);
driveIndDefMapper
.
insert
(
driveIndDef
);
}
else
{
//生成版本
if
(
driveIndDefVersionService
.
save
(
dbBaseIndDef
))
{
String
oldVersion
=
dbBaseIndDef
.
getVersion
();
String
newVersion
=
String
.
valueOf
(
Double
.
valueOf
(
oldVersion
)+
1
);
//旧版本+1
driveIndDef
.
setUpdater
(
user
);
driveIndDef
.
setUpdater
(
user
);
driveIndDef
.
setUpdateTime
(
new
Date
());
driveIndDef
.
setUpdateTime
(
new
Date
());
driveIndDef
.
setVersion
(
newVersion
);
driveIndDef
.
setVersion
(
"1.0"
);
driveIndDef
.
setCatalogId
(
catalogId
);
driveIndDef
.
setCatalogId
(
catalogId
);
driveIndDef
.
setCatalogIdPath
(
catalogIdPath
);
driveIndDef
.
setCatalogIdPath
(
catalogIdPath
);
driveIndDefMapper
.
updateByPrimaryKey
(
driveIndDef
);
driveIndDefMapper
.
insert
(
driveIndDef
);
}
}
else
{
DriveIndDef
dbDriveIndDef
=
this
.
getById
(
driveIndDef
.
getIndId
());
if
(
dbDriveIndDef
!=
null
)
{
//生成版本
if
(
driveIndDefVersionService
.
save
(
dbDriveIndDef
))
{
String
oldVersion
=
dbDriveIndDef
.
getVersion
();
String
newVersion
=
String
.
valueOf
(
Double
.
valueOf
(
oldVersion
)+
1
);
//旧版本+1
driveIndDef
.
setUpdater
(
user
);
driveIndDef
.
setUpdateTime
(
new
Date
());
driveIndDef
.
setVersion
(
newVersion
);
driveIndDef
.
setCatalogId
(
catalogId
);
driveIndDef
.
setCatalogIdPath
(
catalogIdPath
);
driveIndDefMapper
.
updateByPrimaryKey
(
driveIndDef
);
}
}
else
{
return
"drive ind is not exist,update ind fail"
;
}
}
}
}
//插入短板筛选规则
//插入短板筛选规则
...
@@ -178,4 +187,22 @@ public class DriveIndDefService {
...
@@ -178,4 +187,22 @@ public class DriveIndDefService {
}
}
return
result
;
return
result
;
}
}
public
String
getDriveIndMaxIndId
(
String
code
,
int
length
)
{
code
=
"A"
+
code
;
if
(
code
.
length
()>=
length
)
{
return
"id的编码不能大于等于id的长度"
;
}
String
maxId
=
driveIndDefMapper
.
getMaxIndId
(
code
+
"%"
,
length
);
if
(
StringUtils
.
isBlank
(
maxId
))
{
String
addZero
=
""
;
for
(
int
i
=
0
;
i
<(
length
-
code
.
length
()-
1
);
i
++)
{
addZero
+=
"0"
;
}
maxId
=
code
+
addZero
+
"1"
;
}
else
{
maxId
=
"A"
+
maxId
;
}
return
maxId
;
}
}
}
src/main/resources/mybatis/mapping/BaseIndDefMapper.xml
View file @
710abc78
...
@@ -34,4 +34,10 @@
...
@@ -34,4 +34,10 @@
#{id}
#{id}
</foreach>
</foreach>
</delete>
</delete>
<select
id=
"getMaxIndId"
resultType=
"java.lang.String"
>
select (max(CAST(ind_id as SIGNED INTEGER))+1) as maxId
from base_ind_def
where ind_id like #{code} and LENGTH(ind_id)=#{length}
</select>
</mapper>
</mapper>
\ No newline at end of file
src/main/resources/mybatis/mapping/DriveIndDefMapper.xml
View file @
710abc78
...
@@ -34,4 +34,10 @@
...
@@ -34,4 +34,10 @@
#{id}
#{id}
</foreach>
</foreach>
</delete>
</delete>
<select
id=
"getMaxIndId"
resultType=
"java.lang.String"
>
select (max(CAST(SUBSTRING(ind_id,2) as SIGNED INTEGER))+1) as maxId
from drive_ind_def
where ind_id like #{code} and LENGTH(ind_id)=#{length};
</select>
</mapper>
</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