hyy 1 ヶ月 前
コミット
22ae350ae3

+ 25 - 5
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/controller/admin/specimeninfo/SpecimenInfoController.java

@@ -93,19 +93,39 @@ public class SpecimenInfoController {
         return success(BeanUtils.toBean(pageResult, SpecimenInfoRespVO.class));
     }
 
+//    @GetMapping("/export-excel")
+//    @Operation(summary = "导出标本管理 Excel")
+//    @PreAuthorize("@ss.hasPermission('museums:specimen-info:export')")
+//    @ApiAccessLog(operateType = EXPORT)
+//    public void exportSpecimenInfoExcel(@Valid SpecimenInfoExportReqVO pageReqVO,
+//              HttpServletResponse response) throws IOException {
+//        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+//        List<SpecimenInfoDO> list = specimenInfoService.getSpecimenInfoExcel(pageReqVO).getList();
+//        // 导出 Excel
+//        ExcelUtils.write(response, "标本总表.xls", "数据", SpecimenInfoExportRespVO.class,
+//                        BeanUtils.toBean(list, SpecimenInfoExportRespVO.class));
+//    }
+
     @GetMapping("/export-excel")
     @Operation(summary = "导出标本管理 Excel")
     @PreAuthorize("@ss.hasPermission('museums:specimen-info:export')")
     @ApiAccessLog(operateType = EXPORT)
     public void exportSpecimenInfoExcel(@Valid SpecimenInfoExportReqVO pageReqVO,
-              HttpServletResponse response) throws IOException {
-        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
-        List<SpecimenInfoDO> list = specimenInfoService.getSpecimenInfoExcel(pageReqVO).getList();
+                                        @RequestParam List<Long> ids,  // 接收前端传递的 ID 数组
+                                        HttpServletResponse response) throws IOException {
+        // 如果有 ID 数组,设置查询条件,过滤查询
+        if (!ids.isEmpty()) {
+            pageReqVO.setIds(ids);  // 设置过滤条件
+        }
+
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);  // 设置不分页
+        List<SpecimenInfoDO> list = specimenInfoService.getSpecimenInfoExcel(pageReqVO, ids);  // 根据 ID 查询数据
+
         // 导出 Excel
         ExcelUtils.write(response, "标本总表.xls", "数据", SpecimenInfoExportRespVO.class,
-                        BeanUtils.toBean(list, SpecimenInfoExportRespVO.class));
-    }
+                BeanUtils.toBean(list, SpecimenInfoExportRespVO.class));
 
+    }
     @GetMapping("/get-specimen-import-template")
     @Operation(summary = "获得导入标本信息模板")
     public void getSpecimenImportTemplate(@RequestParam("specimenType") Integer specimenType, HttpServletResponse response) throws IOException {

+ 4 - 0
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/controller/admin/specimeninfo/vo/SpecimenInfoExportReqVO.java

@@ -8,6 +8,7 @@ import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 
@@ -127,4 +128,7 @@ public class SpecimenInfoExportReqVO extends PageParam {
 
     @Schema(description = "注销原因", example = "不香")
     private String deletedReason;
+
+    @Schema(description = "注销原因", example = "不香")
+    private List<Long> ids;
 }

+ 3 - 0
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/controller/admin/specimeninfo/vo/SpecimenInfoPageReqVO.java

@@ -127,4 +127,7 @@ public class SpecimenInfoPageReqVO extends PageParam {
 
     @Schema(description = "国家")
     private String country;
+
+    @Schema(description = "有无入资产")
+    private Boolean assetNumberIsNull;
 }

+ 21 - 3
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/dal/mysql/specimeninfo/SpecimenInfoMapper.java

@@ -21,7 +21,7 @@ import org.apache.ibatis.annotations.Update;
 public interface SpecimenInfoMapper extends BaseMapperX<SpecimenInfoDO> {
 
     default PageResult<SpecimenInfoDO> selectPage(SpecimenInfoPageReqVO reqVO) {
-        return selectPage(reqVO, new LambdaQueryWrapperX<SpecimenInfoDO>()
+        LambdaQueryWrapperX<SpecimenInfoDO> queryWrapper = new LambdaQueryWrapperX<SpecimenInfoDO>()
                 .eqIfPresent(SpecimenInfoDO::getSpecimenType, reqVO.getSpecimenType())
                 .likeIfPresent(SpecimenInfoDO::getSpecimenNumber, reqVO.getSpecimenNumber())
                 .likeIfPresent(SpecimenInfoDO::getAssetNumber, reqVO.getAssetNumber())
@@ -55,10 +55,21 @@ public interface SpecimenInfoMapper extends BaseMapperX<SpecimenInfoDO> {
                 .eqIfPresent(SpecimenInfoDO::getSaveStatus, reqVO.getSaveStatus())
                 .eqIfPresent(SpecimenInfoDO::getEconomize, reqVO.getEconomize())
                 .eqIfPresent(SpecimenInfoDO::getCountry, reqVO.getCountry())
-                .eqIfPresent(SpecimenInfoDO::getMainPurpose, reqVO.getMainPurpose())
-                .orderByDesc(SpecimenInfoDO::getId));
+                .eqIfPresent(SpecimenInfoDO::getMainPurpose, reqVO.getMainPurpose());
+
+        // 新增的查询条件:根据 assetNumberIsNull 来判断是否查询为空或不为空
+        if (reqVO.getAssetNumberIsNull() != null) {
+            if (reqVO.getAssetNumberIsNull()) {
+                queryWrapper.isNull(SpecimenInfoDO::getAssetNumber);  // 查询 assetNumber 为空的记录
+            } else {
+                queryWrapper.isNotNull(SpecimenInfoDO::getAssetNumber);  // 查询 assetNumber 不为空的记录
+            }
+        }
+        // 继续其他的排序条件
+        return selectPage(reqVO, queryWrapper.orderByDesc(SpecimenInfoDO::getId));
     }
 
+
     default PageResult<SpecimenInfoDO> selectPage(SpecimenInfoExportReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<SpecimenInfoDO>()
                 .eqIfPresent(SpecimenInfoDO::getSpecimenType, reqVO.getSpecimenType())
@@ -97,6 +108,13 @@ public interface SpecimenInfoMapper extends BaseMapperX<SpecimenInfoDO> {
                 .orderByDesc(SpecimenInfoDO::getId));
     }
 
+    // 根据 ID 数组查询
+    default List<SpecimenInfoDO> selectByIds(List<Long> ids) {
+        return selectList(new LambdaQueryWrapperX<SpecimenInfoDO>()
+                .in(SpecimenInfoDO::getId, ids)  // 根据 ID 数组过滤
+                .orderByDesc(SpecimenInfoDO::getId));  // 排序可以根据需求调整
+    }
+
     /**
      * 更新标本信息中的馆藏状态
      *

+ 2 - 1
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/service/specimeninfo/SpecimenInfoService.java

@@ -58,7 +58,8 @@ public interface SpecimenInfoService {
      * @param pageReqVO 分页查询
      * @return 标本管理分页
      */
-    PageResult<SpecimenInfoDO> getSpecimenInfoExcel(SpecimenInfoExportReqVO pageReqVO);
+//    PageResult<SpecimenInfoDO> getSpecimenInfoExcel(SpecimenInfoExportReqVO pageReqVO);
+    List<SpecimenInfoDO> getSpecimenInfoExcel(SpecimenInfoExportReqVO pageReqVO, List<Long> ids);
 
     /**
      * 批量导入标本

+ 17 - 7
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/service/specimeninfo/SpecimenInfoServiceImpl.java

@@ -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",

+ 2 - 2
yudao-server/src/main/resources/application.yaml

@@ -13,8 +13,8 @@ spring:
   servlet:
     # 文件上传相关配置项
     multipart:
-      max-file-size: 100MB # 单个文件大小
-      max-request-size: 200MB # 设置总上传的文件大小
+      max-file-size: 500MB # 单个文件大小
+      max-request-size: 500MB # 设置总上传的文件大小
 
   # Jackson 配置项
   jackson: