附件
build / build-push (push) Failing after 59s

This commit is contained in:
wanghu
2026-09-21 16:52:57 +08:00
parent 69e628fc28
commit 2d186a1ca9
3 changed files with 13 additions and 43 deletions
@@ -1,8 +1,8 @@
package com.yunhai.dormnotice.service;
import com.yunhai.dormnotice.entity.UpFile;
import com.yunhai.dormnotice.model.notice.UpFileVo;
import com.yunhai.dormnotice.model.notice.UpFileResultVo;
import com.yunhai.dormnotice.model.notice.UpFileVo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@@ -82,11 +82,6 @@ public interface IFileService {
*/
void downloadZipByTopic(String topicType, Integer topicId, String zipName, HttpServletResponse response);
/**
* 按附件ID集合打包下载为 ZIP(通知 AllFileDown 用:通知存的是 fileIds 逗号串)。
*/
void downloadZipByIds(List<Integer> fileIds, String zipName, HttpServletResponse response);
/**
* 批量上传图片(循环上传,返回每个文件的视图对象列表)。
*/
@@ -1,8 +1,8 @@
package com.yunhai.dormnotice.service.impl;
import com.yunhai.dormnotice.entity.UpFile;
import com.yunhai.dormnotice.model.notice.UpFileVo;
import com.yunhai.dormnotice.model.notice.UpFileResultVo;
import com.yunhai.dormnotice.model.notice.UpFileVo;
import com.yunhai.dormnotice.repository.UpFileRepository;
import com.yunhai.dormnotice.service.IFileService;
import com.yunhai.platform.apistd.BizException;
@@ -18,7 +18,6 @@ import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.URLConnection;
@@ -26,15 +25,7 @@ import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.ArrayList;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -53,11 +44,9 @@ public class FileService implements IFileService {
@Autowired
private UpFileRepository upFileRepository;
@Value("${file.upload-path}")
@Value("${FILE_PATH}")
private String uploadPath;
private static final String DEFAULT_APP_TYPE = "dormnotice";
// ============================ 上传 ============================
@Override
@@ -77,13 +66,10 @@ public class FileService implements IFileService {
ext = originalName.substring(dotIdx + 1).toLowerCase();
}
// 构造存储子路径:{appType}/{yyyyMMdd}/{uuid}.{ext}
String dateDir = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String savedName = UUID.randomUUID().toString().replace("-", "") + (ext.isEmpty() ? "" : "." + ext);
String relativePath = (appType == null ? DEFAULT_APP_TYPE : appType) + "/" + dateDir + "/" + savedName;
// 物理写入
Path fullPath = Paths.get(uploadPath, relativePath);
Path fullPath = Paths.get(uploadPath, savedName);
try {
Files.createDirectories(fullPath.getParent());
file.transferTo(fullPath.toFile());
@@ -94,10 +80,10 @@ public class FileService implements IFileService {
// 入库
UpFile entity = new UpFile();
entity.setTopicType(appType == null ? DEFAULT_APP_TYPE : appType);
entity.setTopicType(appType);
entity.setTopicId(topicId);
entity.setFileTrueName(originalName);
entity.setFileName(relativePath);
entity.setFileName(savedName);
entity.setFileSize((int) file.getSize());
entity.setFileType(ext);
upFileRepository.save(entity);
@@ -125,8 +111,7 @@ public class FileService implements IFileService {
@Override
public List<UpFileVo> listByTopic(String appType, Integer topicId) {
String type = appType == null ? DEFAULT_APP_TYPE : appType;
return upFileRepository.findByTopicTypeAndTopicId(type, topicId).stream()
return upFileRepository.findByTopicTypeAndTopicId(appType, topicId).stream()
.map(this::toVo)
.collect(Collectors.toList());
}
@@ -279,17 +264,7 @@ public class FileService implements IFileService {
@Override
public void downloadZipByTopic(String topicType, Integer topicId, String zipName,
HttpServletResponse response) {
String type = topicType == null ? DEFAULT_APP_TYPE : topicType;
List<UpFile> files = upFileRepository.findByTopicTypeAndTopicId(type, topicId);
downloadZip(files, zipName, response);
}
@Override
public void downloadZipByIds(List<Integer> fileIds, String zipName, HttpServletResponse response) {
if (fileIds == null || fileIds.isEmpty()) {
throw new BizException(ErrorCode.PARAM_ERROR, "无附件可下载");
}
List<UpFile> files = upFileRepository.findAllById(fileIds);
List<UpFile> files = upFileRepository.findByTopicTypeAndTopicId(topicType, topicId);
downloadZip(files, zipName, response);
}
@@ -302,9 +277,8 @@ public class FileService implements IFileService {
if (files == null || files.length == 0) {
return results;
}
String type = appType != null ? appType : DEFAULT_APP_TYPE;
for (MultipartFile file : files) {
results.add(upload(file, type, null));
results.add(upload(file, appType, null));
}
return results;
}
@@ -911,7 +911,8 @@ public class NoticeService implements INoticeService {
m.put("receiveText", receiveText(n));
m.put("roomCount", targetRooms(n).size());
m.put("bedCount", allowCount(n));
m.put("progress", "draft".equals(n.getNoticeStatus()) ? null : progress(n.getId(), n));
// 仅通知类(none)不产生回执行,progress 置空,前端据此显示「仅通知 · 无需回执」而不是 0/0
m.put("progress", "draft".equals(n.getNoticeStatus()) || "none".equals(n.getReceiptMode()) ? null : progress(n.getId(), n));
m.put("createBy", n.getCreateBy());
m.put("createTime", fmt(n.getCreateTime()));
m.put("updateBy", n.getUpdateBy());
@@ -943,7 +944,7 @@ public class NoticeService implements INoticeService {
m.put("needSupervisor", nz(n.getNeedSupervisor()));
m.put("noticeStatus", n.getNoticeStatus());
m.put("noticeStatusDesc", DormEnums.statusDesc(n.getNoticeStatus()));
m.put("progress", "draft".equals(n.getNoticeStatus()) ? null : progress(n.getId(), n));
m.put("progress", "draft".equals(n.getNoticeStatus()) || "none".equals(n.getReceiptMode()) ? null : progress(n.getId(), n));
m.put("ChaoSend", fileItems(n.getFileIds()));
m.put("tlist", "ALL".equalsIgnoreCase(str(n.getReceiveList()).trim()) ? "all" : new ArrayList<>(targetRoomIds(n)));
m.put("receiveType", "room");