新增指标字典功能和组件功能调整

This commit is contained in:
2023-05-30 13:43:06 +08:00
parent a549c461f9
commit 8d4228d0eb
19 changed files with 874 additions and 22 deletions

View File

@@ -9,6 +9,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.user.pojo.param.ComponentParam;
import com.njcn.user.pojo.po.Component;
import com.njcn.user.pojo.vo.ComponentVO;
import com.njcn.user.service.IComponentService;
import com.njcn.web.controller.BaseController;
@@ -115,5 +116,14 @@ public class ComponentController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
}
@OperateInfo
@GetMapping("/getFatherComponent")
@ApiOperation("获取父组件节点")
public HttpResult<List<Component>> getFatherComponent(@RequestParam @Validated String systemType){
String methodDescribe = getMethodDescribe("getFatherComponent");
List<Component> list = componentService.getFatherComponent(systemType);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
}
}

View File

@@ -66,4 +66,6 @@ public interface IComponentService extends IService<Component> {
* @date 2022/1/24 12:33
*/
List<ComponentVO> getUserComponentTree();
List<Component> getFatherComponent(String systemType);
}

View File

@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.enums.UserResponseEnum;
import com.njcn.user.mapper.ComponentMapper;
import com.njcn.user.pojo.constant.ComponentState;
@@ -21,6 +23,7 @@ import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
@@ -46,6 +49,8 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
private final IRoleComponentService roleComponentService;
private final DicDataFeignClient dicDataFeignClient;
@Override
public boolean addComponent(ComponentParam componentParam) {
checkComponentParam(componentParam, false);
@@ -58,12 +63,8 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
component.setPids(FunctionState.FATHER_PID);
} else {
Component fatherComponent = this.lambdaQuery().eq(Component::getId, componentParam.getPid()).one();
if (Objects.equals(fatherComponent.getPid(), FunctionState.FATHER_PID)) {
component.setPids(componentParam.getPid());
} else {
String pidS = fatherComponent.getPids();
component.setPids(pidS + "," + componentParam.getPid());
}
String pidS = fatherComponent.getPids();
component.setPids(pidS + "," + componentParam.getPid());
}
return this.save(component);
}
@@ -89,17 +90,30 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
@Override
public List<ComponentVO> getComponentTree() {
List<ComponentVO> list = new ArrayList<>();
List<ComponentVO> result = new ArrayList<>();
List<ComponentDTO> componentList = componentMapper.getAllComponent();
componentList.forEach(item -> {
ComponentVO componentVO = new ComponentVO();
BeanUtil.copyProperties(item, componentVO);
componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()));
list.add(componentVO);
});
return list.stream()
.filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
.peek(funS -> funS.setChildren(getChildCategoryList(funS, list)))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(componentList)){
componentList.forEach(item -> {
ComponentVO componentVO = new ComponentVO();
BeanUtil.copyProperties(item, componentVO);
componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()));
list.add(componentVO);
});
Map<String,List<ComponentVO>> map = list.stream().collect(Collectors.groupingBy(ComponentVO::getSystemType));
map.forEach((k,v)->{
DictData dictData = dicDataFeignClient.getDicDataById(k).getData();
ComponentVO componentVO = new ComponentVO();
componentVO.setId(dictData.getId());
componentVO.setName(dictData.getName());
componentVO.setChildren(
v.stream()
.filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
.peek(funS -> funS.setChildren(getChildCategoryList(funS, v)))
.collect(Collectors.toList()));
result.add(componentVO);
});
}
return result;
}
@Override
@@ -115,21 +129,39 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
List<String> componentList = roleComponentService.selectRoleComponent(roleList.stream().map(Role::getId).collect(Collectors.toList()));
list = componentMapper.getComponentByList(componentList);
}
list.forEach(item -> {
ComponentVO componentVO = new ComponentVO();
BeanUtil.copyProperties(item, componentVO);
componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()));
componentVOList.add(componentVO);
});
result = componentVOList.stream()
.filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
.peek(funS -> funS.setChildren(getChildCategoryList(funS, componentVOList)))
.collect(Collectors.toList());
Map<String,List<ComponentVO>> map = componentVOList.stream().collect(Collectors.groupingBy(ComponentVO::getSystemType));
map.forEach((k, v)->{
DictData dictData = dicDataFeignClient.getDicDataById(k).getData();
ComponentVO componentVO = new ComponentVO();
componentVO.setName(dictData.getName());
componentVO.setChildren(
v.stream()
.filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
.peek(funS -> funS.setChildren(getChildCategoryList(funS, v)))
.collect(Collectors.toList()));
result.add(componentVO);
});
}
return result;
}
@Override
public List<Component> getFatherComponent(String systemType) {
List<Component> list = new ArrayList<>();
Component component = new Component();
component.setId("0");
component.setName("");
list.add(component);
list.addAll(this.lambdaQuery().eq(Component::getSystemType, systemType).eq(Component::getPid,ComponentState.FATHER_PID).eq(Component::getState, ComponentState.ENABLE).list());
return list;
}
/**
* 递归组装组件表
*/
@@ -147,6 +179,7 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
LambdaQueryWrapper<Component> componentLambdaQueryWrapper = new LambdaQueryWrapper<>();
componentLambdaQueryWrapper
.eq(Component::getName, componentParam.getName())
.eq(Component::getSystemType, componentParam.getSystemType())
.eq(Component::getState, ComponentState.ENABLE);
//更新的时候,需排除当前记录
if (isExcludeSelf) {