|
@ -17,6 +17,7 @@ import com.qs.serve.modules.sys.service.SysUserService; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -38,14 +39,14 @@ public class BmsRegion2ServiceImpl extends ServiceImpl<BmsRegion2Mapper,BmsRegio |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean saveBmsRegion2(BmsRegion2 param){ |
|
|
public boolean saveBmsRegion2(BmsRegion2 param){ |
|
|
param = this.flushLevel(param); |
|
|
param = this.toSetLevel(param); |
|
|
return this.save(param); |
|
|
return this.save(param); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean updateBmsRegion2ById(BmsRegion2 param){ |
|
|
public boolean updateBmsRegion2ById(BmsRegion2 param){ |
|
|
BmsRegion2 ori = this.getById(param.getId()); |
|
|
BmsRegion2 ori = this.getById(param.getId()); |
|
|
param = this.flushLevel(param); |
|
|
param = this.toSetLevel(param); |
|
|
boolean b = updateById(param); |
|
|
boolean b = updateById(param); |
|
|
if(!ori.getName().equals(param.getName())) { |
|
|
if(!ori.getName().equals(param.getName())) { |
|
|
this.updatePathByPid(param.getId()); |
|
|
this.updatePathByPid(param.getId()); |
|
@ -112,13 +113,12 @@ public class BmsRegion2ServiceImpl extends ServiceImpl<BmsRegion2Mapper,BmsRegio |
|
|
return this.getOne(lqw,false); |
|
|
return this.getOne(lqw,false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// @Override
|
|
|
public BmsRegion2 toSetLevel(BmsRegion2 param) { |
|
|
public BmsRegion2 flushLevel(BmsRegion2 param) { |
|
|
|
|
|
if(StringUtils.hasText(param.getPid()) && !param.getPid().equals("0")){ |
|
|
if(StringUtils.hasText(param.getPid()) && !param.getPid().equals("0")){ |
|
|
BmsRegion2 parent = this.getById(param.getPid()); |
|
|
BmsRegion2 parent = this.getById(param.getPid()); |
|
|
if(parent!=null){ |
|
|
if(parent!=null){ |
|
|
if(parent.getLevel()>2){ |
|
|
if(parent.getLevel()>3){ |
|
|
Assert.throwEx("最高支持3层级"); |
|
|
Assert.throwEx("最高支持4层级"); |
|
|
} |
|
|
} |
|
|
param.setLevel(parent.getLevel()+1); |
|
|
param.setLevel(parent.getLevel()+1); |
|
|
param.setPathIds(parent.getPathIds()+"_"+param.getId()); |
|
|
param.setPathIds(parent.getPathIds()+"_"+param.getId()); |
|
@ -133,17 +133,19 @@ public class BmsRegion2ServiceImpl extends ServiceImpl<BmsRegion2Mapper,BmsRegio |
|
|
param.setPathNames(param.getName()); |
|
|
param.setPathNames(param.getName()); |
|
|
} |
|
|
} |
|
|
return param; |
|
|
return param; |
|
|
// this.updateById(param);
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void flushAllLevel(boolean batchUpdate) { |
|
|
public void flushAllLevel(boolean batchUpdate) { |
|
|
|
|
|
this.baseMapper.updateSetPathNull(); |
|
|
List<BmsRegionTreeVo> treeVoList = this.getTree(false); |
|
|
List<BmsRegionTreeVo> treeVoList = this.getTree(false); |
|
|
for (BmsRegionTreeVo firstTree : treeVoList) { |
|
|
for (BmsRegionTreeVo firstTree : treeVoList) { |
|
|
if(firstTree.getLevel()==null||firstTree.getLevel()!=1||batchUpdate){ |
|
|
if(firstTree.getLevel()==null||firstTree.getLevel()!=1||batchUpdate){ |
|
|
String pathIds = firstTree.getId(); |
|
|
String pathIds = firstTree.getId(); |
|
|
String pathNames = firstTree.getName(); |
|
|
String pathNames = firstTree.getName(); |
|
|
this.updateLevel(firstTree.getId(),1,pathIds,pathNames); |
|
|
BmsRegion2 param = this.getUpdLevelParam(firstTree.getId(),1,pathIds,pathNames); |
|
|
|
|
|
this.updateById(param); |
|
|
} |
|
|
} |
|
|
if(CollectionUtil.isNotEmpty(firstTree.getChildren())){ |
|
|
if(CollectionUtil.isNotEmpty(firstTree.getChildren())){ |
|
|
for (TreeNode secondTreeNode : firstTree.getChildren()) { |
|
|
for (TreeNode secondTreeNode : firstTree.getChildren()) { |
|
@ -151,15 +153,28 @@ public class BmsRegion2ServiceImpl extends ServiceImpl<BmsRegion2Mapper,BmsRegio |
|
|
if(secondTree.getLevel()==null||secondTree.getLevel()!=2||batchUpdate){ |
|
|
if(secondTree.getLevel()==null||secondTree.getLevel()!=2||batchUpdate){ |
|
|
String pathIds = firstTree.getId()+"_"+secondTree.getId(); |
|
|
String pathIds = firstTree.getId()+"_"+secondTree.getId(); |
|
|
String pathNames = firstTree.getName()+"_"+secondTree.getName(); |
|
|
String pathNames = firstTree.getName()+"_"+secondTree.getName(); |
|
|
this.updateLevel(secondTree.getId(),2,pathIds,pathNames); |
|
|
BmsRegion2 param = this.getUpdLevelParam(secondTree.getId(),2,pathIds,pathNames); |
|
|
|
|
|
this.updateById(param); |
|
|
} |
|
|
} |
|
|
if(CollectionUtil.isNotEmpty(secondTree.getChildren())){ |
|
|
if(CollectionUtil.isNotEmpty(secondTree.getChildren())){ |
|
|
for (TreeNode thirdTreeNode : secondTree.getChildren()) { |
|
|
for (TreeNode thirdTreeNode : secondTree.getChildren()) { |
|
|
BmsRegionTreeVo thirdTree = (BmsRegionTreeVo)thirdTreeNode; |
|
|
BmsRegionTreeVo thirdTree = (BmsRegionTreeVo)thirdTreeNode; |
|
|
if(thirdTree.getLevel()==null||thirdTree.getLevel()!=3||batchUpdate){ |
|
|
if(thirdTree.getLevel()==null||thirdTree.getLevel()!=3||batchUpdate){ |
|
|
String pathIds = firstTree.getId()+"_"+secondTree.getName()+"_"+thirdTree.getId(); |
|
|
String pathIds = firstTree.getId()+"_"+secondTree.getId()+"_"+thirdTree.getId(); |
|
|
String pathNames = firstTree.getName()+"_"+secondTree.getName()+"_"+thirdTree.getName(); |
|
|
String pathNames = firstTree.getName()+"_"+secondTree.getName()+"_"+thirdTree.getName(); |
|
|
this.updateLevel(thirdTree.getId(),3,pathIds,pathNames); |
|
|
BmsRegion2 param = this.getUpdLevelParam(thirdTree.getId(),3,pathIds,pathNames); |
|
|
|
|
|
this.updateById(param); |
|
|
|
|
|
} |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(thirdTree.getChildren())){ |
|
|
|
|
|
for (TreeNode fourthlyTreeNode : thirdTree.getChildren()) { |
|
|
|
|
|
BmsRegionTreeVo fourthlyTree = (BmsRegionTreeVo)fourthlyTreeNode; |
|
|
|
|
|
if(fourthlyTree.getLevel()==null||fourthlyTree.getLevel()!=4||batchUpdate){ |
|
|
|
|
|
String pathIds = firstTree.getId()+"_"+secondTree.getId()+"_"+thirdTree.getId()+"_"+fourthlyTree.getId(); |
|
|
|
|
|
String pathNames = firstTree.getName()+"_"+secondTree.getName()+"_"+thirdTree.getName()+"_"+fourthlyTree.getName(); |
|
|
|
|
|
BmsRegion2 param = this.getUpdLevelParam(fourthlyTree.getId(),4,pathIds,pathNames); |
|
|
|
|
|
this.updateById(param); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -169,13 +184,13 @@ public class BmsRegion2ServiceImpl extends ServiceImpl<BmsRegion2Mapper,BmsRegio |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateLevel(String id, Integer level,String pathIds,String pathName) { |
|
|
public BmsRegion2 getUpdLevelParam(String id, Integer level,String pathIds,String pathName) { |
|
|
BmsRegion2 param = new BmsRegion2(); |
|
|
BmsRegion2 param = new BmsRegion2(); |
|
|
param.setId(id); |
|
|
param.setId(id); |
|
|
param.setLevel(level); |
|
|
param.setLevel(level); |
|
|
param.setPathIds(pathIds); |
|
|
param.setPathIds(pathIds); |
|
|
param.setPathNames(pathName); |
|
|
param.setPathNames(pathName); |
|
|
// this.updateById(param);
|
|
|
return param; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void updatePathByPid(String pid){ |
|
|
private void updatePathByPid(String pid){ |
|
|