一、关于gitee更新代码
在没有提交自己的代码的时候,不要点击update的代码。更新的操作在自己提交的时候,由系统进行update的操作,进行合并,否则自己主动update会造成不必要的麻烦。
二、关于查询文件的业务类型的整体流程思路
首先按照时间区间范围来统计userId 进行group by分类 能算出文件的数量。其次再进行一个sql 对上面的sql进行查询
获取文件和资料堆的关联 这样就可以关联到哪个文件夹下面的有多少数量的文件。因为我们根据创建者分过组了
然后开始对结果集进行过滤 首先是注意批量查询 先统计所有有关的业务ID 通过批量进行查询出来相关的信息。
stream流过滤结果集的时候 是filter !不等于 代表的是排除包含在哪些元素里的信息
结果集过滤的代码示例如下:
Date strDate = DateUtil.beginOfMonth(DateUtils.getNowDate()); Date endDate = DateUtil.endOfMonth(DateUtils.getNowDate()); // 查询近一个月的文件信息 List<FileAndTypeVo> fileArchiveVoList = baseMapper.ListByMonth(strDate, endDate); if (fileArchiveVoList == null || fileArchiveVoList.isEmpty()) { return Collections.emptyMap(); } // 收集私有文件和资料堆信息 FileArchivePrivateVo privateFiles = getPrivateFiles(); List<Long> privateFilesFileArchiveIds = privateFiles.getFileArchiveIds(); List<Long> privateFilesFileStackIds = privateFiles.getFileStackIds(); // 获取本部门及以下部门的数据 Long deptId = getDeptId(); List<Long> deptIds = sysDeptService.selectChildrenDeptIdById(deptId); deptIds.add(deptId); // 获取所有资料堆ID Set<Long> allFileStackIds = fileArchiveVoList.stream() .map(FileAndTypeVo::getFileStackId) .collect(Collectors.toSet()); //查询所有有效的资料堆 List<FileStack> allFileStacks = fileStackService.list(new QueryWrapper<FileStack>().in("id", allFileStackIds).eq("del_flag", BizConstant.DeleteFlag.UN_DEL)); //获取所有业务字典类型ID Map<Long, Long> fileStackToBizTypeId = allFileStacks.stream() .filter(fs -> fs.getBizTypeId() != null) .collect(Collectors.toMap(FileStack::getId, FileStack::getBizTypeId)); // 批量获取所有业务字典类型 List<BizDictType> allBizDictTypes = bizDictTypeService.list(new QueryWrapper<BizDictType>().in("id", new ArrayList<>(fileStackToBizTypeId.values()))); //获取子业务类型 List<BizDictType> nodeBizTypes = bizDictTypeService.list(new QueryWrapper<BizDictType>().in("pid", new ArrayList<>(fileStackToBizTypeId.values())).eq("status", BizConstant.DeleteFlag.UN_DEL)); Map<Long, BizDictType> bizDictTypeCache = allBizDictTypes.stream() .filter(bizType -> bizType != null) .collect(Collectors.toMap(BizDictType::getId, bizType -> bizType)); //子业务类型名称集合 List<String> bizTypeNames = nodeBizTypes.stream() .map(BizDictType::getDictName) .collect(Collectors.toList()); // 创建一个映射,用于存储每个用户名下的业务类型(包括子类型)的累计计数 Map<String, Map<String, Integer>> userCombinedCounts = new HashMap<>(); // 使用 stream 进行过滤和分组操作 fileArchiveVoList.stream() .filter(fa -> !privateFilesFileArchiveIds.contains(fa.getFileId())) .filter(fa -> !privateFilesFileStackIds.contains(fa.getFileStackId())) .filter(fa -> !deptIds.contains(fa.getDeptId())) .forEach(fa -> { Long fileStackId = fa.getFileStackId(); Long businessDictionaryId = fileStackToBizTypeId.getOrDefault(fileStackId, null); BizDictType dictType = bizDictTypeCache.get(businessDictionaryId); String dictName = dictType != null ? dictType.getDictName() : "其他"; String userName = fa.getUserName(); // 如果是子业务类型,找到其父业务类型 if (bizTypeNames.contains(dictName)) { //获取父业务类型名称 String parentDictName = findParentDictName(dictName); userCombinedCounts.computeIfAbsent(userName, k -> new HashMap<>()) .merge(parentDictName, 1, Integer::sum); } else { userCombinedCounts.computeIfAbsent(userName, k -> new HashMap<>()) .merge(dictName, 1, Integer::sum); } }); // 转换为最终输出格式 Map<String, List<DictTypeCountVo>> resultMap = userCombinedCounts.entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, entry -> entry.getValue().entrySet().stream() .map(innerEntry -> { DictTypeCountVo vo = new DictTypeCountVo(); vo.setDictName(innerEntry.getKey()); vo.setCount(innerEntry.getValue()); return vo; }) .collect(Collectors.toList()) )); return resultMap; }
三、关于解决问题的思路
首先不要全信chat的 这种判别不准,要靠自己的思想先去想了之后再和chat结合 然后对于chat给出的结果要自己去理解,不能复制,不然很费时间,在代码上来回的改不准确。chat的准确率并不是很能理解业务需求。所有的业务都是增删改查,要不就是递归查询,没有很难。
四、踩坑记录
Could not autowire. There is more than one bean of 'ISwtSendCommentLogService' type.Beans:ISwtSendCommentLogService (ISwtSendCommentLogService.java)swtSendCommentLogServiceImpl (SwtSendCommentLogServiceImpl.java)
这是因为接口也打了service注解 接口不应该打这个注解
找不到问题的原因就看相同的类之间的差别