|
@@ -90,19 +90,30 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@LogRecord(type = MUSEUMS_SPECIMEN_TYPE, subType = MUSEUMS_SPECIMEN_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
|
|
success = MUSEUMS_SPECIMEN_UPDATE_SUCCESS , extra = "{{#updateReqVO.id}}")
|
|
|
public void updateSpecimenInfo(SpecimenInfoSaveReqVO updateReqVO) {
|
|
|
|
|
|
- validateSpecimenInfoExists(updateReqVO.getId());
|
|
|
-
|
|
|
- SpecimenInfoDO updateObj = BeanUtils.toBean(updateReqVO, SpecimenInfoDO.class);
|
|
|
- specimenInfoMapper.updateById(updateObj);
|
|
|
-
|
|
|
- LogRecordContext.putVariable("update-specimen", updateObj);
|
|
|
+ SpecimenInfoDO specimenInfo = specimenInfoMapper.selectById(updateReqVO.getId());
|
|
|
+ if(specimenInfo != null){
|
|
|
+ SpecimenInfoDO updateObj = BeanUtils.toBean(updateReqVO, SpecimenInfoDO.class);
|
|
|
+ specimenInfoMapper.updateById(updateObj);
|
|
|
+ LogRecordContext.putVariable("update-specimen", updateObj);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@LogRecord(type = MUSEUMS_SPECIMEN_TYPE, subType = MUSEUMS_SPECIMEN_DELETE_SUB_TYPE, bizNo = "{{#id}}",
|
|
@@ -233,20 +244,24 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String importSpecimenImages(MultipartFile file) throws Exception {
|
|
|
|
|
|
- if (!file.getOriginalFilename().toLowerCase().endsWith(".zip")) {
|
|
|
+ if (!file.getOriginalFilename().endsWith(".zip")) {
|
|
|
throw exception(UPLOADED_FOLDER_CANNOT_EMPTY);
|
|
|
}
|
|
|
-
|
|
|
|
|
|
File tempDir = Files.createTempDirectory("specimen_images").toFile();
|
|
|
- ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream());
|
|
|
- try {
|
|
|
+
|
|
|
+ File tempZipFile = File.createTempFile("uploaded_", ".zip");
|
|
|
+
|
|
|
+ file.transferTo(tempZipFile);
|
|
|
+ try (ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(tempZipFile.toPath()))) {
|
|
|
ZipEntry entry;
|
|
|
while ((entry = zipInputStream.getNextEntry()) != null) {
|
|
|
if (!entry.isDirectory()) {
|
|
|
File newFile = new File(tempDir, entry.getName());
|
|
|
+
|
|
|
+ newFile.getParentFile().mkdirs();
|
|
|
|
|
|
- try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(newFile))) {
|
|
|
+ try (BufferedOutputStream bos = new BufferedOutputStream(Files.newOutputStream(newFile.toPath()))) {
|
|
|
byte[] buffer = new byte[1024];
|
|
|
int len;
|
|
|
while ((len = zipInputStream.read(buffer)) > 0) {
|
|
@@ -256,7 +271,6 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
}
|
|
|
zipInputStream.closeEntry();
|
|
|
}
|
|
|
-
|
|
|
|
|
|
File[] imageFiles = tempDir.listFiles();
|
|
|
if (imageFiles != null) {
|
|
@@ -279,16 +293,16 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
|
|
|
imagePathsSet.add(imagePath.trim());
|
|
|
|
|
|
-
|
|
|
+
|
|
|
String existingImagePaths = specimenInfo.getImagePath();
|
|
|
- if (existingImagePaths != null && !existingImagePaths.trim().isEmpty() && !existingImagePaths.equals("[]")) {
|
|
|
-
|
|
|
+ if (existingImagePaths != null && !existingImagePaths.trim().isEmpty()) {
|
|
|
String[] existingPaths = existingImagePaths.split(",\\s*");
|
|
|
Collections.addAll(imagePathsSet, existingPaths);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
String newImagePaths = String.join(", ", imagePathsSet);
|
|
|
|
|
@@ -301,16 +315,15 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } finally {
|
|
|
zipInputStream.close();
|
|
|
-
|
|
|
+ System.gc();
|
|
|
+ } finally {
|
|
|
|
|
|
FileUtils.deleteDirectory(tempDir);
|
|
|
}
|
|
|
return "标本图片导入成功";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
@Override
|