| | |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MasterAuthorMapper; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.pojo.Page; |
| | | import com.highdatas.mdm.pojo.kettle.UnBigDataDataSourceInfo; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.ContentBuilder; |
| | |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | UnBigDataDataSourceInfo unBigDataDataSourceInfo; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | IMaintainDetailService maintainDetailService; |
| | | @Autowired |
| | | MasterDataService masterDataService; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | |
| | | @Override |
| | | public Page getInitPageInfo(MasterAuthor masterAuthor, Maintain maintain, TUser user, boolean getIncrement) { |
| | | Page page = new Page(0); |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(masterAuthor.getTableName()); |
| | | |
| | | List<SysField> fieldByMaintain = fieldService.getFieldByMaintain(maintain.getId()); |
| | | List<String> authorFieldList = fieldByMaintain.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | int totalLength = 0; |
| | | for (TableSchemaResult tableSchemaResult : tableField) { |
| | | String fieldName = tableSchemaResult.getFieldName(); |
| | | if (!authorFieldList.contains(fieldName)) { |
| | | continue; |
| | | } |
| | | int length = tableSchemaResult.getLength(); |
| | | totalLength += length; |
| | | } |
| | | |
| | | int pageSize = Constant.MaxDispenseSize / totalLength; |
| | | page.setPageSize(pageSize); |
| | | long totalCnt; |
| | | if (getIncrement) { |
| | | totalCnt = maintainDetailService.selectCount(new EntityWrapper<MaintainDetail>().eq(Constant.PARENT_ID, maintain.getId())); |
| | | }else { |
| | | String filter = getFilter(user, maintain.getId()); |
| | | totalCnt = masterDataService.getCountByVersion(user, maintain.getTableName(), filter, maintain.getVersion(), false); |
| | | } |
| | | page.setRecordCount(Long.valueOf(totalCnt).intValue()); |
| | | if (totalCnt == 0) { |
| | | return null; |
| | | } |
| | | int pages; |
| | | if (totalCnt % pageSize == 0) { |
| | | pages = Long.valueOf(totalCnt/pageSize).intValue(); |
| | | }else { |
| | | pages = (Long.valueOf(totalCnt/pageSize).intValue()) + 1; |
| | | } |
| | | page.setPages(pages); |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public HashMap<String, MasterAuthor> merageRoleAuthor(Set<String> roleIds) { |
| | |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenu(Character character) { |
| | | return getMenu(character, false); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuUnParent(Character character) { |
| | | return getMenuUnParent(character, false); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuUnParent(Character character, boolean isTableMenu) { |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | switch (type){ |
| | |
| | | return null; |
| | | } |
| | | List<String> menuIds = masterAuthors.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toList()); |
| | | LinkedHashSet<String> strings = new LinkedHashSet<>(menuIds); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(strings); |
| | | if (byParentId == null) { |
| | | return null; |
| | | |
| | | if (isTableMenu) { |
| | | List<String> tempList = new ArrayList<>(); |
| | | for (String menuId : menuIds) { |
| | | String tableNameByMenu = menuMappingService.getTableNameByMenu(menuId); |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(tableNameByMenu); |
| | | if (exists) { |
| | | tempList.add(menuId); |
| | | } |
| | | } |
| | | menuIds = tempList; |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(menuIds); |
| | | return sysMenus; |
| | | } |
| | | |
| | | private List<MasterAuthor> getUserAuthor(String characterId, MaintainField maintainField) { |
| | | @Override |
| | | public List<SysMenu> getMenu(Character character, boolean isTableMenu) { |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | switch (type){ |
| | | case role: |
| | | masterAuthors = getRoleAuthors(character.getId(), null); |
| | | break; |
| | | case groupInfo: |
| | | masterAuthors = getOneGroupAuthors(character.getId(), null); |
| | | break; |
| | | case user: |
| | | masterAuthors = getUserAuthor(character.getId(), null); |
| | | } |
| | | if (masterAuthors == null || masterAuthors.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> menuIds = masterAuthors.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toList()); |
| | | |
| | | if (isTableMenu) { |
| | | List<String> tempList = new ArrayList<>(); |
| | | for (String menuId : menuIds) { |
| | | String tableNameByMenu = menuMappingService.getTableNameByMenu(menuId); |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(tableNameByMenu); |
| | | if (exists) { |
| | | tempList.add(menuId); |
| | | } |
| | | } |
| | | menuIds = tempList; |
| | | } |
| | | |
| | | LinkedHashSet<String> strings = new LinkedHashSet<>(menuIds); |
| | | List<SysMenu> sysMenus = menuService.getMenuByParentId(strings); |
| | | if (sysMenus == null) { |
| | | return null; |
| | | } |
| | | return sysMenus; |
| | | } |
| | | |
| | | @Override |
| | | public List<MasterAuthor> getUserAuthor(String characterId, MaintainField maintainField) { |
| | | Wrapper<MasterAuthor> userWrapper = new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.user).eq(MasterAuthorController.character_id, characterId); |
| | | |
| | | if (maintainField != null) { |
| | |
| | | builder.append(format); |
| | | } |
| | | String filter = builder.toString(); |
| | | if (StringUtils.isEmpty(filter)) { |
| | | return Constant.WHERE_DEFAULT; |
| | | } |
| | | return filter; |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public LinkedHashSet<Maintain> getMaintainSet(String tableName, TUser user) { |
| | | List<MasterAuthor> userAuthor = this.getUserAuthor(user.getUserId(), null); |
| | | LinkedHashSet<Maintain> maintainSet = new LinkedHashSet<>(); |
| | | Collections.reverse(userAuthor); |
| | | |
| | | for (MasterAuthor masterAuthor : userAuthor) { |
| | | String tabName = masterAuthor.getTableName(); |
| | | String maintainFieldId = masterAuthor.getMaintainFieldId(); |
| | | if (StringUtils.isEmpty(tabName) || !tableName.equalsIgnoreCase(tableName) || StringUtils.isEmpty(maintainFieldId)) { |
| | | continue; |
| | | } |
| | | List<Maintain> maintainByMaintainField = maintainFieldService.getMaintainByMaintainField(maintainFieldId, tableName); |
| | | maintainSet.addAll(maintainByMaintainField); |
| | | } |
| | | return maintainSet; |
| | | } |
| | | |
| | | public void dealFlow(String maintainId, ActivitiStatus status) { |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | MaintainField maintainFieldByMaintain = fieldService.getMaintainFieldByMaintain(maintainId); |
| | | SysMenu menuByTableName = menuMappingService.getMenuByTableName(maintain.getTableName()); |
| | | |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>() |
| | | .eq("maintain_field_id", maintainFieldByMaintain.getId()) |
| | | .eq("table_name", maintain.getTableName()) |
| | | .eq("menu_id", menuByTableName.getId()) |
| | | .eq("maintain_auto", true)); |
| | | for (MasterAuthor masterAuthor : masterAuthors) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | private MasterAuthor merage(MasterAuthor preMerageMasterAuthor, MasterAuthor masterAuthor) { |
| | | // table name masterField 一样 只有字段不同了 |
| | | List<MasterAuthorDetail> preFields = preMerageMasterAuthor.getFields(); |