|
@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.nio.file.Files;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.Month;
|
|
@@ -133,11 +134,20 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
return specimenInfoMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// public PageResult<SpecimenInfoDO> getSpecimenInfoExcel(SpecimenInfoExportReqVO pageReqVO) {
|
|
|
+// return specimenInfoMapper.selectPage(pageReqVO);
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
- public PageResult<SpecimenInfoDO> getSpecimenInfoExcel(SpecimenInfoExportReqVO pageReqVO) {
|
|
|
- return specimenInfoMapper.selectPage(pageReqVO);
|
|
|
+ public List<SpecimenInfoDO> getSpecimenInfoExcel(SpecimenInfoExportReqVO pageReqVO, List<Long> ids) {
|
|
|
+ if (!ids.isEmpty()) {
|
|
|
+ return specimenInfoMapper.selectByIds(ids); // 使用自定义的 Mapper 方法来根据 IDs 查询
|
|
|
+ }
|
|
|
+ return specimenInfoMapper.selectPage(pageReqVO).getList(); // 如果没有传递 ID 数组,执行原来的分页查询逻辑
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 标本Excel的批量导入
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
|
@@ -325,15 +335,16 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
if (!file.getOriginalFilename().endsWith(".zip")) {
|
|
|
throw exception(PHOTO_GROUP_MUST_BE_COMPRESSED_PACKAGE);
|
|
|
}
|
|
|
- try (ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream())) {
|
|
|
- ZipEntry entry;
|
|
|
+ try (ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream(file.getInputStream())) {
|
|
|
+ ZipArchiveEntry entry;
|
|
|
while ((entry = zipInputStream.getNextEntry()) != null) {
|
|
|
if (!entry.isDirectory()) {
|
|
|
- String fileName = entry.getName().toLowerCase();
|
|
|
+ String fileName = entry.getName();
|
|
|
if (isSupportedImage(fileName)) {
|
|
|
File newFile = new File(tempDir, fileName);
|
|
|
try (FileOutputStream fos = new FileOutputStream(newFile);
|
|
|
BufferedOutputStream bos = new BufferedOutputStream(fos)) {
|
|
|
+
|
|
|
byte[] buffer = new byte[4096];
|
|
|
int length;
|
|
|
while ((length = zipInputStream.read(buffer)) != -1) {
|
|
@@ -472,7 +483,6 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
return fileName.endsWith(".jpg") || fileName.endsWith(".png") || fileName.endsWith(".gif") ||
|
|
|
fileName.endsWith(".bmp") || fileName.endsWith(".tiff") || fileName.endsWith(".jpeg") ||
|
|
|
fileName.endsWith(".psd") || fileName.endsWith(".raw") || fileName.endsWith(".svg");
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private File findImageInTempDir(File tempDir, String imageName) {
|
|
@@ -488,7 +498,7 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
"yyyy-MM-dd'T'HH:mm:ss", // ISO_LOCAL_DATE_TIME 格式
|
|
|
"yyyy/MM/dd'T'HH:mm:ss",
|
|
|
"yyyy-MM-dd",
|
|
|
- "yyyy/MM/dd",
|
|
|
+ "yyyyMM/dd",
|
|
|
"dd-MM-yyyy HH:mm:ss",
|
|
|
"dd/MM/yyyy HH:mm:ss",
|
|
|
"dd-MM-yyyy",
|