Commit 385d8f2f authored by huxiuwu's avatar huxiuwu

胡秀武:模型分类接口修改bug

parent e4dc740a
...@@ -88,12 +88,15 @@ public class OcpModelGroupVO implements Serializable { ...@@ -88,12 +88,15 @@ public class OcpModelGroupVO implements Serializable {
@ApiModelProperty(value = "是否已删除0未删除 1未删除") @ApiModelProperty(value = "是否已删除0未删除 1未删除")
private Integer isDelete; private Integer isDelete;
@TableField(exist = false)
@ApiModelProperty(value = "层级")
private int level;
/** /**
* 子类集合 * 子类集合
*/ */
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "子类集合") @ApiModelProperty(value = "子类集合")
List<OcpModelGroupVO> childrenList; private List<OcpModelGroupVO> childrenList;
public String getModelGroupCode() { public String getModelGroupCode() {
return modelGroupCode == null ? "" : modelGroupCode; return modelGroupCode == null ? "" : modelGroupCode;
...@@ -102,6 +105,7 @@ public class OcpModelGroupVO implements Serializable { ...@@ -102,6 +105,7 @@ public class OcpModelGroupVO implements Serializable {
public String getModelGroupPcode() { public String getModelGroupPcode() {
return modelGroupPcode == null ? "" : modelGroupPcode; return modelGroupPcode == null ? "" : modelGroupPcode;
} }
} }
......
...@@ -64,7 +64,6 @@ public class ModelClassifyServiceImpl implements ModelClassifyService { ...@@ -64,7 +64,6 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
**/ **/
@Override @Override
public ResponseVO<PageInfo<OcpModelGroupVO>> subclassDetailsList(int currentPage,int pageSize,String parentGroupCode,String subclassGroupName) { public ResponseVO<PageInfo<OcpModelGroupVO>> 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 //将查询到所有数据的list转换为key为分类code,value为本身的map
...@@ -140,7 +139,11 @@ public class ModelClassifyServiceImpl implements ModelClassifyService { ...@@ -140,7 +139,11 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
/** /**
* 构建树节点 * 构建树节点
*/ * @author huxiuwu
* @date 2022/3/10
* @param treeNodes 需要构建的list
* @return List<com.pms.ocp.model.vo.OcpModelGroupVO>
**/
private List<OcpModelGroupVO> build(List<OcpModelGroupVO> treeNodes) { private List<OcpModelGroupVO> build(List<OcpModelGroupVO> treeNodes) {
List<OcpModelGroupVO> result = new ArrayList<>(); List<OcpModelGroupVO> result = new ArrayList<>();
//list转map =>将每个对象的id作为key,自己作为value. //list转map =>将每个对象的id作为key,自己作为value.
...@@ -152,9 +155,12 @@ public class ModelClassifyServiceImpl implements ModelClassifyService { ...@@ -152,9 +155,12 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
//得到自己的父类 //得到自己的父类
OcpModelGroupVO parent = nodeMap.get(node.getModelGroupPcode()); OcpModelGroupVO parent = nodeMap.get(node.getModelGroupPcode());
if (parent != null && !(node.getModelGroupCode().equals(parent.getModelGroupCode()))) { if (parent != null && !(node.getModelGroupCode().equals(parent.getModelGroupCode()))) {
//防止每次都new list或者只是使用该对象就new对象浪费内存或者覆盖上一次记录
if (parent.getChildrenList() == null) { if (parent.getChildrenList() == null) {
parent.setChildrenList(new LinkedList<>()); parent.setChildrenList(new LinkedList<>());
} }
//说明他有父类其下子类都需要加一级
addLevel(node,treeNodes);
parent.getChildrenList().add(node); parent.getChildrenList().add(node);
continue; continue;
} }
...@@ -162,6 +168,21 @@ public class ModelClassifyServiceImpl implements ModelClassifyService { ...@@ -162,6 +168,21 @@ public class ModelClassifyServiceImpl implements ModelClassifyService {
} }
return result; return result;
} }
/**
*
* @author huxiuwu
* @date 2022/3/10
* @param parent 父类
* @param treeNodes 需要遍历list
**/
private void addLevel(OcpModelGroupVO parent, List<OcpModelGroupVO> treeNodes) {
parent.setLevel(parent.getLevel()+1);
for (OcpModelGroupVO treeNode : treeNodes) {
if (treeNode != null && parent.getModelGroupCode().equals(treeNode.getModelGroupPcode())){
addLevel(treeNode,treeNodes);
}
}
}
private List<OcpModelGroupVO> selectByCondition(String... searchCondition) { private List<OcpModelGroupVO> selectByCondition(String... searchCondition) {
QueryWrapper<OcpModelGroupVO> queryWrapper = new QueryWrapper<>(); QueryWrapper<OcpModelGroupVO> queryWrapper = new QueryWrapper<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment