|
@@ -53,7 +53,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<CostResponsibilityVO> getList( ) {
|
|
|
|
|
|
|
+ public List<CostResponsibilityVO> getList() {
|
|
|
// 1. 获取所有的列表然后组装
|
|
// 1. 获取所有的列表然后组装
|
|
|
List<CostResponsibilityVO> costResponsibilityVOS = this.getCostResponsibilityVO();
|
|
List<CostResponsibilityVO> costResponsibilityVOS = this.getCostResponsibilityVO();
|
|
|
// 拷贝组合
|
|
// 拷贝组合
|
|
@@ -89,6 +89,76 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
// }
|
|
// }
|
|
|
// return all;
|
|
// return all;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<CostResponsibilityVO> getSharelevelRespList(Integer shareId, String filter) {
|
|
|
|
|
+ // 1. 获取指定层级和过滤条件的责任中心
|
|
|
|
|
+ List<CostResponsibilityVO> shareLevelResponsibilityVOS = this.getShareLevelResponsibilityVO(shareId, filter);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(shareLevelResponsibilityVOS)) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 获取所有的责任中心用于构建完整树结构
|
|
|
|
|
+ List<CostResponsibilityVO> allResponsibilityVOS = this.getCostResponsibilityVO();
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 构建ID映射,用于快速查找
|
|
|
|
|
+ Map<Long, CostResponsibilityVO> idMap = allResponsibilityVOS.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(CostResponsibilityVO::getId, i -> i, (existing, replacement) -> existing));
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 收集需要返回的所有责任中心ID(包括父级)
|
|
|
|
|
+ Set<Long> needReturnIds = new HashSet<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 将满足条件的责任中心及其所有父级加入集合
|
|
|
|
|
+ for (CostResponsibilityVO vo : shareLevelResponsibilityVOS) {
|
|
|
|
|
+ // 添加自身
|
|
|
|
|
+ needReturnIds.add(vo.getId());
|
|
|
|
|
+ // 添加所有父级
|
|
|
|
|
+ Long parentId = vo.getParentId();
|
|
|
|
|
+ while (parentId != null && parentId != 0) {
|
|
|
|
|
+ needReturnIds.add(parentId);
|
|
|
|
|
+ CostResponsibilityVO parent = idMap.get(parentId);
|
|
|
|
|
+ if (parent != null) {
|
|
|
|
|
+ parentId = parent.getParentId();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 筛选出需要返回的责任中心
|
|
|
|
|
+ List<CostResponsibilityVO> needReturnList = allResponsibilityVOS.stream()
|
|
|
|
|
+ .filter(vo -> needReturnIds.contains(vo.getId()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 添加字典数据
|
|
|
|
|
+ List<DictDataVo> responsibilityType = getResponsibilityType();
|
|
|
|
|
+ Map<String, String> dictMap = responsibilityType.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(DictDataVo::getCode, DictDataVo::getName, (a, b) -> b));
|
|
|
|
|
+
|
|
|
|
|
+ List<DictDataVo> standardShareLevel = getStandardShareLevel();
|
|
|
|
|
+ Map<String, String> standardDictMap = standardShareLevel.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(DictDataVo::getCode, DictDataVo::getName, (a, b) -> b));
|
|
|
|
|
+
|
|
|
|
|
+ for (CostResponsibilityVO responsibility : needReturnList) {
|
|
|
|
|
+ if (!StringUtils.isEmpty(responsibility.getType())) {
|
|
|
|
|
+ responsibility.setTypeName(dictMap.get(responsibility.getType()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!StringUtils.isEmpty(responsibility.getStandardShareLevel())) {
|
|
|
|
|
+ responsibility.setStandardShareLevelName(standardDictMap.get(responsibility.getStandardShareLevel()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 7. 构建多层级树结构
|
|
|
|
|
+ List<CostResponsibilityVO> result = needReturnList.stream()
|
|
|
|
|
+ .filter(i -> i.getParentId() == 0) // 只取顶级节点
|
|
|
|
|
+ .peek(i -> i.setChild(this.getResponsibilityChildren(i, needReturnList)))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 8. 排序
|
|
|
|
|
+ responsibilitySort(result);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void responsibilitySort(List<CostResponsibilityVO> responsibilityList){
|
|
private void responsibilitySort(List<CostResponsibilityVO> responsibilityList){
|
|
|
for (CostResponsibilityVO responsibility :responsibilityList){
|
|
for (CostResponsibilityVO responsibility :responsibilityList){
|
|
|
if(!CollectionUtils.isEmpty(responsibility.getChild())){
|
|
if(!CollectionUtils.isEmpty(responsibility.getChild())){
|
|
@@ -111,6 +181,23 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
return BeanUtil.convertList(list, CostResponsibilityVO.class);
|
|
return BeanUtil.convertList(list, CostResponsibilityVO.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private List<CostResponsibilityVO> getShareLevelResponsibilityVO(Integer shareId, String filter ) {
|
|
|
|
|
+ LambdaQueryWrapper<Responsibility> queryWrapper = new LambdaQueryWrapper<Responsibility>()
|
|
|
|
|
+ .eq(Responsibility::getHospId, UserContext.getHospId())
|
|
|
|
|
+ .orderByDesc(Responsibility::getCreateTime);
|
|
|
|
|
+ if(shareId != null){
|
|
|
|
|
+ queryWrapper.eq(Responsibility::getShareId,shareId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!StringUtils.isEmpty(filter)){
|
|
|
|
|
+ queryWrapper.like(Responsibility::getResponsibilityName,filter);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Responsibility> list = this.list(queryWrapper);
|
|
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return BeanUtil.convertList(list, CostResponsibilityVO.class);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取子层级
|
|
* 获取子层级
|
|
|
*
|
|
*
|