From fc712449840c929022e5ad61102a0709c353dd63 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 09 三月 2026 17:46:21 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New' into dev_New
---
src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpServiceImpl.java | 63 +++++++++++++++++++++++++++----
1 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpServiceImpl.java
index 9f452ac..5637307 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpServiceImpl.java
@@ -8,10 +8,12 @@
import com.ruoyi.basic.pojo.CustomerFollowUpFile;
import com.ruoyi.basic.service.CustomerFollowUpFileService;
import com.ruoyi.basic.service.CustomerFollowUpService;
-import com.ruoyi.basic.service.ICustomerService;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.basic.dto.CustomerFollowUpFileDto;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.service.ISysUserService;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.BeanUtils;
@@ -28,7 +30,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.UUID;
@@ -49,6 +51,9 @@
@Value("${file.upload-dir}")
private String uploadDir;
+
+ @Autowired
+ private ISysUserService sysUserService;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -78,8 +83,8 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public void addFollowUpFiles(List<MultipartFile> files, Integer followUpId) {
- handleFollowUpFiles(files, followUpId);
+ public List<CustomerFollowUpFileDto> addFollowUpFiles(List<MultipartFile> files, Integer followUpId) {
+ return handleFollowUpFiles(files, followUpId);
}
@Override
@@ -136,14 +141,27 @@
}
}
- private void handleFollowUpFiles(List<MultipartFile> multipartFiles, Integer followUpId) {
+ @Override
+ public 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 customerFollowUpFileService.list(queryWrapper);
+ }
+
+ private List<CustomerFollowUpFileDto> handleFollowUpFiles(List<MultipartFile> multipartFiles, Integer followUpId) {
+ List<CustomerFollowUpFile> fileList = new ArrayList<>();
+ List<CustomerFollowUpFileDto> dtoList = new ArrayList<>();
if (multipartFiles == null || multipartFiles.isEmpty()) {
- return;
+ return dtoList;
}
Long currentUserId = SecurityUtils.getUserId();
Long currentTenantId = SecurityUtils.getLoginUser().getTenantId();
- List<CustomerFollowUpFile> fileList = new ArrayList<>();
for (MultipartFile file : multipartFiles) {
if (file == null || file.isEmpty()) {
@@ -159,7 +177,8 @@
String originalFilename = file.getOriginalFilename();
String fileExtension = FilenameUtils.getExtension(originalFilename);
- String formalFilename = followUpId + "_" +
+ String prefix = (followUpId != null) ? followUpId.toString() : "temp";
+ String formalFilename = prefix + "_" +
System.currentTimeMillis() + "_" +
UUID.randomUUID().toString().substring(0, 8) +
(StringUtils.hasText(fileExtension) ? "." + fileExtension : "");
@@ -184,7 +203,35 @@
}
if (!fileList.isEmpty()) {
customerFollowUpFileService.saveBatch(fileList);
+ return convertToDtoList(fileList);
}
+ return dtoList;
+ }
+
+ private List<CustomerFollowUpFileDto> convertToDtoList(List<CustomerFollowUpFile> fileList) {
+ List<CustomerFollowUpFileDto> dtoList = new ArrayList<>();
+ if (fileList == null || fileList.isEmpty()) {
+ return dtoList;
+ }
+ for (CustomerFollowUpFile entity : fileList) {
+ CustomerFollowUpFileDto dto = new CustomerFollowUpFileDto();
+ BeanUtils.copyProperties(entity, dto);
+
+ if (entity.getCreateUser() != null) {
+ SysUser createUser = sysUserService.selectUserById(entity.getCreateUser());
+ if (createUser != null) {
+ dto.setCreateUserName(createUser.getNickName());
+ }
+ }
+ if (entity.getUpdateUser() != null) {
+ SysUser updateUser = sysUserService.selectUserById(entity.getUpdateUser());
+ if (updateUser != null) {
+ dto.setUpdateUserName(updateUser.getNickName());
+ }
+ }
+ dtoList.add(dto);
+ }
+ return dtoList;
}
private void validateFollowUp(CustomerFollowUp followUp) {
--
Gitblit v1.9.3