| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.highdatas.mdm.mapper.SysMenuMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.IMenuMappingService; |
| | | import com.highdatas.mdm.service.ISysMenuService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.util.NoticeClient; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService { |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | NoticeClient noticeClient; |
| | | @Override |
| | | public LinkedHashSet<String> getByParentId(LinkedHashSet<String> parentIdSet) { |
| | | if (parentIdSet.size() == 0) { |
| | |
| | | LinkedHashSet<String> subSet = new LinkedHashSet<>(); |
| | | for (String s : parentIdSet) { |
| | | SysMenu sysMenu = menuService.selectById(s); |
| | | if (sysMenu == null) { |
| | | continue; |
| | | } |
| | | String parentId = sysMenu.getParentId(); |
| | | if (StringUtils.isEmpty(parentId)) { |
| | | continue; |
| | |
| | | |
| | | return parentIdSet; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuByParentId(LinkedHashSet<String> parentIdSet) { |
| | | LinkedHashSet<String> byParentId = getByParentId(parentIdSet); |
| | | if (byParentId == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<SysMenu> sysMenus = selectBatchIds(byParentId); |
| | | List<SysMenu> result = new ArrayList<SysMenu>(); |
| | | for (String s : byParentId) { |
| | | List<SysMenu> collect = sysMenus.stream().filter(sysMenu -> sysMenu.getId().equalsIgnoreCase(s)).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()) { |
| | | result.add(collect.get(0)); |
| | | } |
| | | |
| | | } |
| | | Collections.reverse(result); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void dealFlow(String maintainId, ActivitiStatus status, String userId) { |
| | | if (!status.equals(ActivitiStatus.open)) { |
| | | return; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | SysMenu menuByTableName = menuMappingService.getMenuByTableName(maintain.getTableName()); |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(); |
| | | parentIdSet.add(menuByTableName.getId()); |
| | | LinkedHashSet<String> byParentId = getByParentId(parentIdSet); |
| | | if (byParentId == null) { |
| | | noticeClient.openByAddMenu(menuByTableName, null, userId); |
| | | } else { |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | SysMenu menu = sysMenus.get(0); |
| | | noticeClient.openByAddMenu(menuByTableName, menu, userId); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |