Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
operation-control-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王锦盛
operation-control-platform
Commits
cc5fdf04
Commit
cc5fdf04
authored
Mar 15, 2022
by
王锦盛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加模型分类删除
parent
2b619e75
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
34 deletions
+102
-34
src/main/java/com/pms/ocp/common/constants/ResultCode.java
src/main/java/com/pms/ocp/common/constants/ResultCode.java
+1
-0
src/main/java/com/pms/ocp/controller/ModelClassifyController.java
.../java/com/pms/ocp/controller/ModelClassifyController.java
+22
-5
src/main/java/com/pms/ocp/service/ModelClassifyService.java
src/main/java/com/pms/ocp/service/ModelClassifyService.java
+11
-1
src/main/java/com/pms/ocp/service/impl/ModelClassifyServiceImpl.java
...va/com/pms/ocp/service/impl/ModelClassifyServiceImpl.java
+68
-28
No files found.
src/main/java/com/pms/ocp/common/constants/ResultCode.java
View file @
cc5fdf04
...
...
@@ -87,6 +87,7 @@ public enum ResultCode {
ROLE_EXIST
(
10007
,
"角色定义已存在!"
),
CODE_EXIST
(
10008
,
"编码已存在!"
),
NAME_EXIST
(
10009
,
"名称已存在!"
),
NO_DELETE
(
10010
,
"无法删除,有关联数据!"
),
USER_ORGANIZATION_LEVEL_ERROR
(
10023
,
"用户组织机构关联层级有误!"
),
USER_ORGANIZATION_INFO_ERROR
(
10024
,
"用户组织机构信息有误!"
),
TOKEN_INVALID
(
9997
,
"登录失效,请重新登录!"
),
...
...
src/main/java/com/pms/ocp/controller/ModelClassifyController.java
View file @
cc5fdf04
package
com.pms.ocp.controller
;
import
com.github.pagehelper.PageInfo
;
import
com.pms.ocp.common.constants.ResultCode
;
import
com.pms.ocp.model.entity.ModelClassify
;
import
com.pms.ocp.model.vo.OcpModelGroupVO
;
import
com.pms.ocp.model.vo.ResponseVO
;
import
com.pms.ocp.service.ModelClassifyService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -30,7 +32,6 @@ public class ModelClassifyController {
/**
* 模型分类导航
*
* @param searchCondition 分类名称
* @return pms.ocp.model.vo.ResponseVO
* @author huxiuwu
* @date 2022/3/9
...
...
@@ -52,8 +53,8 @@ public class ModelClassifyController {
@GetMapping
(
"/subclassDetailsList"
)
public
ResponseVO
subclassDetailsList
(
@RequestParam
int
currentPage
,
@RequestParam
int
pageSize
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
parentGroupCode
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
subclassGroupName
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
parentGroupCode
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
subclassGroupName
)
{
return
modelClassifyService
.
subclassDetailsList
(
currentPage
,
pageSize
,
parentGroupCode
,
subclassGroupName
);
}
...
...
@@ -85,4 +86,20 @@ public class ModelClassifyController {
public
ResponseVO
update
(
@RequestBody
List
<
ModelClassify
>
list
)
{
return
modelClassifyService
.
update
(
list
);
}
/**
* 删除模型分类
**/
@ApiOperation
(
"删除模型分类"
)
@PostMapping
(
"/delete"
)
public
ResponseVO
delete
(
@ApiParam
(
value
=
"模型分类编号"
)
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
objId
,
@ApiParam
(
value
=
"模型分类编码"
)
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
modelGroupCode
,
@ApiParam
(
value
=
"模型分类归属公司编码"
)
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
groupCompanyCode
)
{
Integer
integer
=
modelClassifyService
.
deleteModelClassify
(
objId
,
modelGroupCode
,
groupCompanyCode
);
if
(
integer
.
intValue
()
==
-
1
)
{
ResponseVO
.
ok
(
ResultCode
.
NO_DELETE
);
}
return
ResponseVO
.
ok
(
integer
);
}
}
\ No newline at end of file
src/main/java/com/pms/ocp/service/ModelClassifyService.java
View file @
cc5fdf04
...
...
@@ -16,7 +16,17 @@ public interface ModelClassifyService {
ResponseVO
insert
(
List
<
ModelClassify
>
list
);
ResponseVO
subclassDetailsList
(
int
currentPage
,
int
pageSize
,
String
parentGroupCode
,
String
subclassGroupName
);
ResponseVO
subclassDetailsList
(
int
currentPage
,
int
pageSize
,
String
parentGroupCode
,
String
subclassGroupName
);
ResponseVO
update
(
List
<
ModelClassify
>
list
);
/**
* 删除模型分类
*
* @param objId
* @param modelCode
* @param groupCompanyCode
* @return
*/
Integer
deleteModelClassify
(
String
objId
,
String
modelCode
,
String
groupCompanyCode
);
}
src/main/java/com/pms/ocp/service/impl/ModelClassifyServiceImpl.java
View file @
cc5fdf04
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.pms.ocp.common.constants.CodeEnum
;
import
com.pms.ocp.common.utils.PageUtil
;
import
com.pms.ocp.mapper.ModelClassifyMapper
;
import
com.pms.ocp.model.entity.Model
;
import
com.pms.ocp.model.entity.ModelClassify
;
import
com.pms.ocp.model.vo.OcpModelGroupVO
;
import
com.pms.ocp.model.vo.ResponseVO
;
...
...
@@ -57,26 +58,28 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
* 这边是右侧详情页,需求是点击右侧导航树上的分类显示该分类的所有子集,
* 所以第一次查询查询到所有并将其转换为key为其分类编码,value为其本身
* 的map.第二次是根据搜素框的值进行模糊查询
*
* @return pms.ocp.model.vo.ResponseVO
* @author huxiuwu
* @date 2022/3/9 <PageInfo<OcpModelGroupVO>>
**/
@Override
public
ResponseVO
subclassDetailsList
(
int
currentPage
,
int
pageSize
,
String
parentGroupCode
,
String
subclassGroupName
)
{
public
ResponseVO
subclassDetailsList
(
int
currentPage
,
int
pageSize
,
String
parentGroupCode
,
String
subclassGroupName
)
{
//查询所有
List
<
OcpModelGroupVO
>
ocpModelGroupVOList
=
this
.
selectByCondition
(
null
,
null
);
List
<
OcpModelGroupVO
>
ocpModelGroupVOList
=
this
.
selectByCondition
(
null
,
null
);
//将查询到所有数据的list转换为key为分类code,value为本身的map
Map
<
String
,
OcpModelGroupVO
>
groupByCode
=
ocpModelGroupVOList
.
stream
().
collect
(
Collectors
.
toMap
(
OcpModelGroupVO:
:
getModelGroupCode
,
Function
.
identity
(),
(
key1
,
key2
)
->
key2
));
//根据key获取前端传入code的对象
OcpModelGroupVO
ocpModelGroupVO
=
groupByCode
.
get
(
parentGroupCode
);
//模糊查询
List
<
OcpModelGroupVO
>
dimConditionList
=
this
.
selectByCondition
(
null
,
subclassGroupName
);
List
<
OcpModelGroupVO
>
dimConditionList
=
this
.
selectByCondition
(
null
,
subclassGroupName
);
//递归获取模糊查询后属于parentGroupCode子集
List
<
OcpModelGroupVO
>
childrenList
=
findChildren
(
dimConditionList
,
ocpModelGroupVO
,
new
LinkedList
<>());
PageUtil
<
OcpModelGroupVO
>
pageUtil
=
new
PageUtil
<>();
pageUtil
.
pageUtil
(
currentPage
,
pageSize
,
childrenList
);
pageUtil
.
pageUtil
(
currentPage
,
pageSize
,
childrenList
);
return
ResponseVO
.
ok
(
pageUtil
);
}
/**
* 修改
*
...
...
@@ -113,23 +116,24 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
/**
* 获取父节点下的所有子节点放入list中
* @author huxiuwu
* @date 2022/3/9
*
* @param
* @param
* @param
* @return void
* @author huxiuwu
* @date 2022/3/9
**/
private
List
<
OcpModelGroupVO
>
findChildren
(
List
<
OcpModelGroupVO
>
groupList
,
OcpModelGroupVO
parent
,
List
<
OcpModelGroupVO
>
childList
)
{
private
List
<
OcpModelGroupVO
>
findChildren
(
List
<
OcpModelGroupVO
>
groupList
,
OcpModelGroupVO
parent
,
List
<
OcpModelGroupVO
>
childList
)
{
for
(
OcpModelGroupVO
vo
:
groupList
)
{
//遍历出父id等于参数的id,add进子节点集合
if
(
parent
!=
null
if
(
parent
!=
null
&&
parent
.
getModelGroupCode
()
.
equals
(
vo
.
getModelGroupPcode
())
&&
!
""
.
equals
(
parent
.
getModelGroupCode
()))
{
//递归遍历下一级
vo
.
setModelGroupPName
(
parent
.
getModelGroupName
());
if
(!
childList
.
remove
(
vo
))
{
if
(!
childList
.
remove
(
vo
))
{
childList
.
add
(
vo
);
}
findChildren
(
groupList
,
vo
,
childList
);
...
...
@@ -137,12 +141,14 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
}
return
childList
;
}
/**
* 构建树节点
* @author huxiuwu
* @date 2022/3/10
*
* @param treeNodes 需要构建的list
* @return List<com.pms.ocp.model.vo.OcpModelGroupVO>
* @author huxiuwu
* @date 2022/3/10
**/
private
List
<
OcpModelGroupVO
>
build
(
List
<
OcpModelGroupVO
>
treeNodes
)
{
List
<
OcpModelGroupVO
>
result
=
new
ArrayList
<>();
...
...
@@ -155,7 +161,7 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
//得到自己的父类
OcpModelGroupVO
parent
=
nodeMap
.
get
(
node
.
getModelGroupPcode
());
if
(
parent
!=
null
&&
(
node
.
getModelGroupPcode
().
equals
(
parent
.
getModelGroupCode
()))
&&
(!
""
.
equals
(
node
.
getModelGroupPcode
())||
!
""
.
equals
(
parent
.
getModelGroupCode
())))
{
&&
(!
""
.
equals
(
node
.
getModelGroupPcode
())
||
!
""
.
equals
(
parent
.
getModelGroupCode
())))
{
//防止每次都new list或者只是使用该对象就new对象浪费内存或者覆盖上一次记录
if
(
parent
.
getChildrenList
()
==
null
)
{
parent
.
setChildrenList
(
new
LinkedList
<>());
...
...
@@ -172,33 +178,67 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
}
/**
*
* @author huxiuwu
* @date 2022/3/10
* @param parent 父类
* @param treeNodes 需要遍历list
* @author huxiuwu
* @date 2022/3/10
**/
private
void
addLevel
(
OcpModelGroupVO
parent
,
List
<
OcpModelGroupVO
>
treeNodes
)
{
int
level
=
parent
.
getLevel
();
parent
.
setLevel
(
level
++);
for
(
OcpModelGroupVO
treeNode
:
treeNodes
)
{
if
(
treeNode
!=
null
&&
parent
.
getModelGroupCode
().
equals
(
treeNode
.
getModelGroupPcode
())){
addLevel
(
treeNode
,
treeNodes
);
if
(
treeNode
!=
null
&&
parent
.
getModelGroupCode
().
equals
(
treeNode
.
getModelGroupPcode
()))
{
addLevel
(
treeNode
,
treeNodes
);
}
}
}
/**
* 生成构造器
* @author huxiuwu
* @date 2022/3/10
*
* @param searchCondition
* @return List<com.pms.ocp.model.vo.OcpModelGroupVO>
* @author huxiuwu
* @date 2022/3/10
**/
private
List
<
OcpModelGroupVO
>
selectByCondition
(
String
...
searchCondition
)
{
QueryWrapper
<
OcpModelGroupVO
>
queryWrapper
=
new
QueryWrapper
<>();
//根据是否传入搜索条件创建构造器进行查询
queryWrapper
.
eq
(
StringUtils
.
isNotEmpty
(
searchCondition
[
0
]),
"model_group_pcode"
,
searchCondition
[
0
])
.
like
(
StringUtils
.
isNotEmpty
(
searchCondition
[
1
]),
"model_group_name"
,
searchCondition
[
1
]).
orderBy
(
false
,
false
,
"group_ctime"
);
.
like
(
StringUtils
.
isNotEmpty
(
searchCondition
[
1
]),
"model_group_name"
,
searchCondition
[
1
]).
orderBy
(
false
,
false
,
"group_ctime"
);
return
classifyMapper
.
selectList
(
queryWrapper
);
}
/**
* 删除模型分类
*
* @param objId
* @param modelGroupCode
* @param groupCompanyCode
* @return
*/
@Override
public
Integer
deleteModelClassify
(
String
objId
,
String
modelGroupCode
,
String
groupCompanyCode
)
{
QueryWrapper
<
OcpModelGroupVO
>
queryWrapper
=
new
QueryWrapper
();
if
(
StringUtils
.
isNotEmpty
(
modelGroupCode
))
{
queryWrapper
.
lambda
().
eq
(
OcpModelGroupVO:
:
getModelGroupPcode
,
modelGroupCode
);
}
List
<
OcpModelGroupVO
>
opList
=
classifyMapper
.
selectList
(
queryWrapper
);
if
(
opList
.
isEmpty
())
{
if
(
StringUtils
.
isNotEmpty
(
objId
))
{
queryWrapper
.
lambda
().
eq
(
OcpModelGroupVO:
:
getObjId
,
objId
);
}
if
(
StringUtils
.
isNotEmpty
(
groupCompanyCode
))
{
queryWrapper
.
lambda
().
eq
(
OcpModelGroupVO:
:
getGroupCompanyCode
,
groupCompanyCode
);
}
return
classifyMapper
.
delete
(
queryWrapper
);
}
return
-
1
;
}
}
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