查看权限详情 将部门大类单据整合,将子类单据id去重合并
/** * 查看权限详情 * @param id 部门id * @return */ @GetMapping("getListInfo") public R getDetail(String id){ List<SapFormCategory>sapFormCategoryList=new ArrayList<>(); //1.将部门大类单据整合,将子类单据id去重合并 Map<String,String>keyMap=new HashMap<String,String>(); //过滤后要返回的list String[] deptIds=id.split(","); for(String deptId:deptIds){ //获取权限设置 Map<String,Object>deptMap=new HashMap<String,Object>(); deptMap.put("dept_id",deptId); log.info("获取权限设置deptMap====="+deptMap); List<SapJurisdictionMaintain> maintainList=service.listByMap(deptMap); log.info("获取权限设置maintainList===="+maintainList); for(SapJurisdictionMaintain msg:maintainList){ String typeId=msg.getTypeId(); String orderIds=msg.getOrderId(); if(!keyMap.containsKey(typeId)){ keyMap.put(typeId,orderIds); }else{ String values =keyMap.get(typeId); String[]orders=orderIds.split(","); for(String order:orders){ if(!values.contains(order)){ values.concat(",").concat(order); keyMap.put(typeId,values); } } } } } //2.根据分类好的 map中的key是大类id,vaue是细类id if(Func.isNotEmpty(keyMap)){ Iterator<String> iter = keyMap.keySet().iterator(); while(iter.hasNext()){ String key=iter.next(); String value = keyMap.get(key); log.info(key+" "+value); //获取表单类型 SapFormCategory sapFormCategory=categoryService.getById(Long.valueOf(key)); if(Func.isNotEmpty(sapFormCategory)){ //根据大的单据id获取子单据 Map<String,Object>map=new HashMap<String,Object>(); map.put("form_category_id",Long.valueOf(key)); //根据form_category_id获取单据列表 List<SapFormInfo> list=infoService.listByMap(map); if(Func.isNotEmpty(list)){ Map<String,Object>valueMap=new HashMap<>(); List<SapFormInfo>returnList=new ArrayList<>(); String[]valueIds=value.split(","); //根据设置的权限过滤出自己具有的权限列表 for(String valueId:valueIds){ for(SapFormInfo formInfo:list){ if(valueId.equals(String.valueOf(formInfo.getId()))){ returnList.add(formInfo); } } } sapFormCategory.setSapFormInfoList(returnList); } } //将单据小类放入单据分类 sapFormCategoryList.add(sapFormCategory); } } return R.data(sapFormCategoryList); }