|
@@ -71,12 +71,6 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
List<String> imagePath = createReqVO.getImagePath();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
SpecimenInfoDO specimenInfo = BeanUtils.toBean(createReqVO, SpecimenInfoDO.class);
|
|
|
- try {
|
|
|
- String jsonString = objectMapper.writeValueAsString(imagePath);
|
|
|
- specimenInfo.setImagePath(jsonString);
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
- throw new RuntimeException("图像路径转换为 JSON 失败", e);
|
|
|
- }
|
|
|
|
|
|
specimenInfoMapper.insert(specimenInfo);
|
|
|
// 返回新创建的标本ID
|
|
@@ -186,11 +180,11 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 2.2.2 如果存在,判断是否允许更新
|
|
|
-// if (!isUpdateSupport) {
|
|
|
-// respVO.getFailureSpecimenNumbers().put(importSpecimen.getSpecimenNumber(), "标本编号已存在,且不支持更新");
|
|
|
-// return;
|
|
|
-// }
|
|
|
+// 2.2.2 如果存在,判断是否允许更新
|
|
|
+ if (!isUpdateSupport) {
|
|
|
+ respVO.getFailureSpecimenNumbers().put(importSpecimen.getSpecimenNumber(), "标本编号已存在,且不支持更新");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
// 更新逻辑
|
|
|
SpecimenInfoDO updateSpecimen = BeanUtils.toBean(importSpecimen, SpecimenInfoDO.class);
|
|
@@ -211,73 +205,6 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
- //图片导入
|
|
|
-// @Override
|
|
|
-// @Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
|
|
-// public String importSpecimenImages(MultipartFile file) throws Exception {
|
|
|
-// // 校验文件类型
|
|
|
-// if (!file.getOriginalFilename().endsWith(".zip")) {
|
|
|
-// throw exception(UPLOADED_FOLDER_CANNOT_EMPTY);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 创建临时目录存放解压后的文件
|
|
|
-// File tempDir = Files.createTempDirectory("specimen_images").toFile();
|
|
|
-// try (ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream())) {
|
|
|
-// ZipEntry entry;
|
|
|
-// while ((entry = zipInputStream.getNextEntry()) != null) {
|
|
|
-// if (!entry.isDirectory()) {
|
|
|
-// File newFile = new File(tempDir, entry.getName());
|
|
|
-// // 进行解压
|
|
|
-// try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(newFile))) {
|
|
|
-// byte[] buffer = new byte[1024];
|
|
|
-// int len;
|
|
|
-// while ((len = zipInputStream.read(buffer)) > 0) {
|
|
|
-// bos.write(buffer, 0, len);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 处理每个图片文件
|
|
|
-// File[] imageFiles = tempDir.listFiles();
|
|
|
-// if (imageFiles != null) {
|
|
|
-// for (File imageFile : imageFiles) {
|
|
|
-// String imageName = imageFile.getName();
|
|
|
-// if (!isValidImageName(imageName)) {
|
|
|
-// System.err.println("无效的图片格式: " + imageName);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// // 根据图片名称查找对应的标本
|
|
|
-// SpecimenInfoDO specimenInfo = specimenInfoMapper.selectByImageNames(imageName);
|
|
|
-// if (specimenInfo != null) {
|
|
|
-// // 上传图片并获取URL
|
|
|
-// String imagePath = fileApi.createFile(Files.readAllBytes(imageFile.toPath()));
|
|
|
-// // 获取当前的图片路径
|
|
|
-// Set<String> imagePathsSet = new HashSet<>();
|
|
|
-// String existingImagePaths = specimenInfo.getImagePath();
|
|
|
-//
|
|
|
-// // 如果 existingImagePaths 为空或仅包含空白字符,则不添加
|
|
|
-// if (existingImagePaths != null && !existingImagePaths.trim().isEmpty()) {
|
|
|
-// Collections.addAll(imagePathsSet, existingImagePaths.split(","));
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 检查 imagePath 是否有效
|
|
|
-// if (imagePath != null && !imagePath.trim().isEmpty()) {
|
|
|
-// imagePathsSet.add(imagePath);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 转换回字符串,避免前面出现多余的逗号
|
|
|
-// String newImagePaths = String.join(",", imagePathsSet);
|
|
|
-// specimenInfo.setImagePath(newImagePaths);
|
|
|
-//
|
|
|
-// updateSpecimenInfo(BeanUtils.toBean(specimenInfo, SpecimenInfoSaveReqVO.class));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 清理临时文件
|
|
|
-// FileUtils.deleteDirectory(tempDir);
|
|
|
-// return "标本图片导入成功";
|
|
|
-// }
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -369,9 +296,6 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//工作台
|
|
|
//根据入库的登记情况统计本年标本入库信息
|
|
|
@Override
|