Commit 6d6dc83f authored by 田涛's avatar 田涛

Bug-443修复 删除预案分组报错

parent 5c934314
......@@ -3,12 +3,14 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.repository.IPlanClassifyTreeDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao;
import com.yeejoin.amos.fas.business.service.intfc.IPlanClassifyTreeService;
import com.yeejoin.amos.fas.business.util.TreeUtil;
import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo;
import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree;
import com.yeejoin.amos.fas.exception.YeeException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.TreeBuilder;
......@@ -37,14 +39,13 @@ public class PlanClassifyTreeServiceImpl implements IPlanClassifyTreeService {
}
@Override
@Transactional(rollbackFor = {YeeException.class, Exception.class})
public Boolean delete(String ids) {
List<Long> seqs = StringUtil.String2LongList(ids);
Set<Long> allIds = new HashSet<>(seqs);
Set allIds = new HashSet<>(seqs);
for (Long seq : seqs) {
PlanClassifyTree planClassifyTree = planClassifyTreeDao.findById(seq).orElse(null);
//所有子分类
List<PlanClassifyTree> childGroupSequenceList = getChildSequenceList(planClassifyTree);
allIds.addAll(new HashSet(Bean.listToMap(childGroupSequenceList, "id", "id", PlanClassifyTree.class).keySet()));
List<PlanClassifyTreeVo> allChildIncludeMe = getAllChildIncludeMe(seq);
allIds.addAll(Bean.listToMap(TreeUtil.getAllChildren(allChildIncludeMe), "id", "id", PlanClassifyTreeVo.class).keySet());
}
// 查询分类下是否有预案
if (planDetailDao.existsByClassifyIdInAndIsDelete(allIds, false)) {
......@@ -95,39 +96,8 @@ public class PlanClassifyTreeServiceImpl implements IPlanClassifyTreeService {
return completeList;
}
/**
* 预案分类的子id
*
* @param planClassifyTree
* @return
*/
public List<PlanClassifyTree> getChildSequenceList(PlanClassifyTree planClassifyTree) {
List<Long> sequenceList = new ArrayList<>();
List<PlanClassifyTree> childList = new ArrayList<>();
this.getAllChildList(planClassifyTree, childList);
// for (KnowledgeDocCategoryModel tagGroupModel : childList) {
// sequenceList.add(tagGroupModel.getSequenceNbr());
// }
return childList;
}
private void getAllChildList(PlanClassifyTree currentPlanClassifyTree, List<PlanClassifyTree> resList) {
if (null == currentPlanClassifyTree) {
return;
}
Long parentId = currentPlanClassifyTree.getId();
List<PlanClassifyTree> childList = planClassifyTreeDao.findByParentId(parentId);
if (!childList.isEmpty()) {
for (PlanClassifyTree tagPlanClassifyTree : childList) {
this.getAllChildList(tagPlanClassifyTree, resList);
}
}
resList.add(currentPlanClassifyTree);
}
@Override
public Collection<PlanClassifyTreeVo> getAllChildIncludeMe(Long root) {
public List<PlanClassifyTreeVo> getAllChildIncludeMe(Long root) {
List<PlanClassifyTreeVo> treeDaoAll = Bean.toModels(planClassifyTreeDao.getAll(), PlanClassifyTreeVo.class);
Collection<PlanClassifyTreeVo> treeList = TreeBuilder.bulid(treeDaoAll, root);
if (!ROOT.equals(root)) {
......@@ -138,7 +108,7 @@ public class PlanClassifyTreeServiceImpl implements IPlanClassifyTreeService {
return Arrays.asList(classifyTreeVo);
}
}
return treeList;
return new ArrayList<>(treeList);
}
@Override
......
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