Sfoglia il codice sorgente

工作台突然坏了

hyy 4 mesi fa
parent
commit
1b8ec5706e

+ 1 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java

@@ -43,6 +43,7 @@ public class FileController {
     public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
         MultipartFile file = uploadReqVO.getFile();
         String path = uploadReqVO.getPath();
+        String type = uploadReqVO.getType();
         return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
     }
 

+ 3 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileUploadReqVO.java

@@ -20,4 +20,7 @@ public class FileUploadReqVO {
     @Schema(description = "文件附件", example = "yudaoyuanma.png")
     private Boolean another;
 
+    @Schema(description = "文件 MIME 类型", example = "application/octet-stream")
+    private String type;
+
 }

+ 0 - 2
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java

@@ -51,7 +51,6 @@ public interface FileService {
      */
     String createFile(String name, String path, byte[] content, Boolean another);
 
-
     /**
      * 创建文件
      *
@@ -83,5 +82,4 @@ public interface FileService {
      * @return 预签名地址信息
      */
     FilePresignedUrlRespVO getFilePresignedUrl(String path) throws Exception;
-
 }

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

@@ -186,7 +186,6 @@ public class SpecimenInfoController {
         // 处理标本图片的导入(如果存在)
         if (imageFile != null && !imageFile.isEmpty()) {
             String imageResult = specimenInfoService.importSpecimenImages(imageFile);
-//             确保返回的数据不为 null
             if (imageResult == null) {
                 throw exception(INVALID_IMAGE_FORMAT);
             }

+ 3 - 3
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/controller/admin/specimenoutbound/vo/SpecimenOutboundSaveReqVO.java

@@ -15,9 +15,9 @@ public class SpecimenOutboundSaveReqVO {
     @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
     private Long id;
 
-//    @Schema(description = "关联到总表中的标本ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
-//    @DiffLogField(name = "关联到总表中的标本ID")
-//    private String infoId;
+    @Schema(description = "关联到总表中的标本ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @DiffLogField(name = "关联到总表中的标本ID")
+    private List<String> infoId;
 
     @Schema(description = "申请出库的标本编号", requiredMode = Schema.RequiredMode.REQUIRED)
     @NotEmpty(message = "申请出库的标本编号不能为空")

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

@@ -134,12 +134,12 @@ public interface SpecimenInfoMapper extends BaseMapperX<SpecimenInfoDO> {
     @Select("SELECT * FROM museums_specimen_info WHERE deleted = 0")
     List<SpecimenInfoDO> getInStockRecords();
 
-    @Select("SELECT YEAR(create_time) AS year, source, COUNT(*) AS count " +
-            "FROM museums_specimen_info " +
+    //acquisition_time
+    @Select("SELECT YEAR(acquisition_time) AS year, source, COUNT(*) AS count " +
+            "FROM museums_specimen_info WHERE acquisition_time != '' AND acquisition_time IS NOT NULL " +
             "GROUP BY YEAR(acquisition_time), source")
     List<Map<String, Object>> getYearlySourceStatistics();
 
-
     @Select("SELECT YEAR(create_time) AS year, COUNT(*) AS in_stock_count " +
             "FROM museums_specimen_info " +
             "WHERE deleted = 0 " +

+ 1 - 14
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/dal/mysql/specimenoutbound/SpecimenOutboundMapper.java

@@ -55,22 +55,9 @@ public interface SpecimenOutboundMapper extends BaseMapperX<SpecimenOutboundDO>
       List<Map<String, Object>> getMonthlyReturnStatistics(int year);
 
 
-
-    /**
-     * 根据年份统计已出库和已回库的标本信息
-     *
-     * @param year 年份
-     * @return 标本回库信息列表
-     */
-    @Select("SELECT * FROM museums_specimen_outbound " +
-            "WHERE (status = 4) " +
-            "AND YEAR(application_date) = #{year} " +
-            "AND deleted = 0")
-    List<SpecimenOutboundReturnReqVO> selectReturnStatisticsByYear(int year);
-
     //根据出、回、入库登记统计标本历年增减情况
     @Select("SELECT YEAR(outgoing_time) AS year, COUNT(*) AS out_stock_count " +
-            "FROM museums_specimen_outbound " +
+            "FROM museums_specimen_outbound WHERE outgoing_time != '' AND outgoing_time IS NOT NULL " +
             "GROUP BY YEAR(outgoing_time)")
     List<Map<String, Object>> getYearlyOutboundRecords();
 

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

@@ -1,16 +1,8 @@
 package cn.iocoder.yudao.module.museums.service.specimeninfo;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
 import cn.iocoder.yudao.module.infra.api.file.FileApi;
-import cn.iocoder.yudao.module.museums.dal.dataobject.specimenoutbound.SpecimenOutboundDO;
 import cn.iocoder.yudao.module.museums.dal.mysql.specimenoutbound.SpecimenOutboundMapper;
-import cn.iocoder.yudao.module.museums.enums.social.LogRecordConstants;
-import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
-import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.mzt.logapi.context.LogRecordContext;
 import com.mzt.logapi.service.impl.DiffParseFunction;
 import com.mzt.logapi.starter.annotation.LogRecord;
@@ -27,8 +19,6 @@ import java.io.*;
 import java.nio.file.Files;
 import java.util.*;
 import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
 
 import cn.iocoder.yudao.module.museums.controller.admin.specimeninfo.vo.*;
 import cn.iocoder.yudao.module.museums.dal.dataobject.specimeninfo.SpecimenInfoDO;
@@ -67,7 +57,7 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
     @LogRecord(type = MUSEUMS_SPECIMEN_TYPE, subType = MUSEUMS_SPECIMEN_CREATE_SUB_TYPE,
             bizNo = "{{#specimenInfo.id}}",
             success = MUSEUMS_SPECIMEN_CREATE_SUCCESS,
-            extra = "{{#specimenInfo.id}}")
+            extra = "[{{#specimenInfo.id}}]")
     public String createSpecimenInfo(SpecimenInfoSaveReqVO createReqVO) {
         // 校验标本编号是否已存在
         if (specimenInfoMapper.existsByNumber(createReqVO.getSpecimenNumber())) {
@@ -85,21 +75,9 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
         return "标本创建成功,标本ID:" + specimenInfo.getId();
     }
 
-//    @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);
-//    }
     @Override
     @LogRecord(type = MUSEUMS_SPECIMEN_TYPE, subType = MUSEUMS_SPECIMEN_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
-            success = MUSEUMS_SPECIMEN_UPDATE_SUCCESS , extra = "{{#updateReqVO.id}}")
+            success = MUSEUMS_SPECIMEN_UPDATE_SUCCESS , extra = "[{{#updateReqVO.id}}]")
     public void updateSpecimenInfo(SpecimenInfoSaveReqVO updateReqVO) {
         // 校验存在
         SpecimenInfoDO specimenInfo = specimenInfoMapper.selectById(updateReqVO.getId());
@@ -216,11 +194,8 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
         successfulSpecimenIds.addAll(updatedSpecimenIds);
 
         // 记录成功导入和更新的标本ID到日志上下文
-        LogRecordContext.putVariable("extra", successfulSpecimenIds.stream()
-                .map(String::valueOf)
-                .collect(Collectors.joining(", "))); // 转换为逗号分隔的字符串
+        LogRecordContext.putVariable("extra", successfulSpecimenIds);
 
-        System.out.println(successfulSpecimenIds);
         return respVO;
     }
 
@@ -248,16 +223,13 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
         // 创建临时目录存放解压后的文件
         File tempDir = Files.createTempDirectory("specimen_images").toFile();
 
-        // 使用 ZipArchiveInputStream 代替 ZipInputStream,并设置字符编码为 UTF-8
         try (ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream(file.getInputStream())) {
             ZipArchiveEntry entry;
             Set<String> imagePathsSet = new HashSet<>();  // 使用 Set 来去重
 
             while ((entry = zipInputStream.getNextEntry()) != null) {
                 if (!entry.isDirectory()) {
-                    // 处理中文文件名问题,使用 entry.getName() 获取文件名,默认是 UTF-8 编码
                     File newFile = new File(tempDir, entry.getName());
-                    // 进行解压
                     try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(newFile))) {
                         byte[] buffer = new byte[1024];
                         int len;
@@ -317,8 +289,6 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
         return "标本图片导入成功";
     }
 
-
-
     //工作台
     //根据入库的登记情况统计本年标本入库信息
     @Override
@@ -416,7 +386,7 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
         }
         // 构建最终的返回结果
         Map<String, Object> resultMap = new HashMap<>();
-        resultMap.put("code", 200);
+        resultMap.put("code", 0);
         resultMap.put("data", yearlyStatisticsList);
         resultMap.put("msg", "各年入库出库回库标本数");
 

+ 10 - 13
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/service/specimenoutbound/SpecimenOutboundServiceImpl.java

@@ -3,9 +3,11 @@ package cn.iocoder.yudao.module.museums.service.specimenoutbound;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.module.museums.controller.admin.specimeninfo.vo.SpecimenInfoPageReqVO;
 import cn.iocoder.yudao.module.museums.controller.admin.specimeninfo.vo.SpecimenInfoRespVO;
+import cn.iocoder.yudao.module.museums.controller.admin.specimeninfo.vo.SpecimenInfoSaveReqVO;
 import cn.iocoder.yudao.module.museums.dal.dataobject.specimeninfo.SpecimenInfoDO;
 import cn.iocoder.yudao.module.museums.dal.mysql.specimeninfo.SpecimenInfoMapper;
 import com.mzt.logapi.context.LogRecordContext;
+import com.mzt.logapi.service.impl.DiffParseFunction;
 import com.mzt.logapi.starter.annotation.LogRecord;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
@@ -52,7 +54,7 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
     @Transactional(rollbackFor = Exception.class)
     @LogRecord(type = MUSEUMS_SPECIMEN_TYPE, subType = MUSEUMS_SPECIMEN_OUTBOUND_SUB_TYPE,
             bizNo = "{{#specimenOutbound.id}}",
-            success = MUSEUMS_SPECIMEN_CREATE_OUTBOUND_SUCCESS, extra = "{{#createReqVO.infoId}}")
+            success = MUSEUMS_SPECIMEN_CREATE_OUTBOUND_SUCCESS, extra = "{{#validInfoIds}}")
     public Long createSpecimenOutbound(SpecimenOutboundSaveReqVO createReqVO) {
         // 校验标本状态,收集有效的ID
         List<String> validInfoIds = new ArrayList<>();
@@ -76,7 +78,7 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
 
         // 记录日志上下文
         LogRecordContext.putVariable("specimenOutbound", specimenOutbound);
-        LogRecordContext.putVariable("createReqVO", createReqVO);
+        LogRecordContext.putVariable("validInfoIds", validInfoIds);
 
         // 返回出库记录ID
         return specimenOutbound.getId();
@@ -119,6 +121,7 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
             specimenOutbound.setProcessInstanceId(req.getProcessInstanceId());
             specimenOutbound.setApprovalTime(req.getApprovalTime()); // 设置当前审批时间
             specimenOutbound.setApproveUsers(getLoginUserNickname()); // 设置一审操作员
+
         }
 
         // 二审逻辑
@@ -172,14 +175,14 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
                 throw exception(EXISTS_SPECIMEN_IS_LENDING_OUT);
             }
         }
+        SpecimenOutboundDO specimenInfo = specimenOutboundMapper.selectById(updateReqVO.getId());
         // 更新
         SpecimenOutboundDO updateObj = BeanUtils.toBean(updateReqVO, SpecimenOutboundDO.class);
         updateObj.setInfoId(validInfoIds.toString());
         specimenOutboundMapper.updateById(updateObj);
 
         // 记录日志上下文
-        LogRecordContext.putVariable("specimenOutbound", updateObj); // 添加更新后的出库单对象
-        LogRecordContext.putVariable("updateReqVO", updateReqVO); // 添加请求对象
+        LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(specimenInfo, SpecimenOutboundSaveReqVO.class));
     }
 
     //确认出库,已经简化
@@ -238,16 +241,11 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
         }
 
         // 使用链式调用合并设置
-        existingSpecimen.setStatus(4) // 修改状态为已回库
-                .setReturnDate(LocalDateTime.now()) // 设置回库时间为当前时间
-                .setSpecimenCondition(updateReqVO.getSpecimenCondition()) // 设置标本状态
-                .setReturner(updateReqVO.getReturner()) // 设置归还人
-                .setReceiver(updateReqVO.getReceiver()) // 设置接收人
-                .setRemarks(updateReqVO.getRemarks()) // 设置备注
-                .setSampleStatus(updateReqVO.getSampleStatus());//回库附件上传
+        SpecimenOutboundDO updateObj = BeanUtils.toBean(updateReqVO, SpecimenOutboundDO.class);
+        updateObj.setStatus(4).setReturnDate(LocalDateTime.now()); // 设置回库时间为当前时间
 
         // 更新数据库
-        specimenOutboundMapper.updateById(existingSpecimen);
+        specimenOutboundMapper.updateById(updateObj);
 
         String infoIdString = existingSpecimen.getInfoId();
         infoIdString = infoIdString.replaceAll("[\\[\\] ]", ""); // 移除方括号和空格
@@ -332,7 +330,6 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
         // 这里修改为分页查询标本信息
         PageResult<SpecimenInfoDO> pageResult = specimenInfoMapper.selectPage(pageReqVO, new LambdaQueryWrapperX<SpecimenInfoDO>()
                 .inIfPresent(SpecimenInfoDO::getId, idList));  // 根据 infoIds 查询标本信息
-        // 将 DO 转换为 VO
         PageResult<SpecimenInfoRespVO> pageResultVO = BeanUtils.toBean(pageResult, SpecimenInfoRespVO.class);
         // 创建返回对象
         SpecimenOutboundWithInfoRespVO response = BeanUtils.toBean(specimenOutbound, SpecimenOutboundWithInfoRespVO.class);