| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.stream.CollectorUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.basic.mapper.CustomerFollowUpFileMapper; |
| | | import com.ruoyi.basic.pojo.CustomerFollowUpFile; |
| | | import com.ruoyi.basic.service.CustomerFollowUpFileService; |
| | | import com.ruoyi.basic.service.CustomerFollowUpService; |
| | | import com.ruoyi.common.vo.SimpleFileVo; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @RequiredArgsConstructor |
| | | public class CustomerFollowUpFileServiceImpl extends ServiceImpl<CustomerFollowUpFileMapper, CustomerFollowUpFile> implements CustomerFollowUpFileService { |
| | | |
| | | private final CustomerFollowUpService customerFollowUpService; |
| | | |
| | | private final CustomerFollowUpFileMapper customerFollowUpFileMapper; |
| | | |
| | | @Override |
| | | public <T> void fillAttachment(List<T> list, Function<T, String> getAttachmentIds, BiConsumer<T, List<SimpleFileVo>> setAttachmentList) { |
| | |
| | | List<CustomerFollowUpFile> followUpFilesByIds = new ArrayList<>(); |
| | | Lists.partition(Lists.newArrayList(ids), 999).forEach(it -> { |
| | | followUpFilesByIds.addAll( |
| | | customerFollowUpService.getFollowUpFilesByIds(it) |
| | | getFollowUpFilesByIds(it) |
| | | ); |
| | | }); |
| | | if (CollUtil.isEmpty(followUpFilesByIds)) { |
| | |
| | | if (StrUtil.isNotBlank(attachmentIds)) { |
| | | List<SimpleFileVo> fileVos = Arrays.stream(attachmentIds.split(",")) |
| | | .map(Long::valueOf) |
| | | .map(it->collectMap.getOrDefault(it, (SimpleFileVo) Collections.emptyList())) |
| | | .map(it->collectMap.getOrDefault(it, null)) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | setAttachmentList.accept(t, fileVos); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private List<CustomerFollowUpFile> getFollowUpFilesByIds(Collection<Long> fileIds) { |
| | | if (fileIds == null || fileIds.isEmpty()) { |
| | | return new ArrayList<>(0); |
| | | } |
| | | |
| | | LambdaQueryWrapper<CustomerFollowUpFile> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(CustomerFollowUpFile::getId, fileIds) |
| | | .select(CustomerFollowUpFile::getId, CustomerFollowUpFile::getFileUrl, CustomerFollowUpFile::getFileName); |
| | | return customerFollowUpFileMapper.selectList(queryWrapper); |
| | | } |
| | | } |