From 16d50e1fd871b2306e7beb650463bc76263e5e98 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 28 七月 2026 10:03:30 +0800
Subject: [PATCH] fix: 异常图片上传、bug修改
---
src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRectificationServiceImpl.java | 51 +++++++++
src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRecord.java | 9 +
src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRecordServiceImpl.java | 41 ++++++++
src/main/resources/mapper/safe/specialequipment/SpecialEquipmentRectificationMapper.xml | 2
src/main/java/com/ruoyi/safe/pojo/SafeFacilityInspection.java | 11 ++
src/main/java/com/ruoyi/safe/controller/SafeLineInspectionController.java | 3
src/main/java/com/ruoyi/safe/pojo/SafeLineInspectionRecord.java | 11 ++
src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionHazardServiceImpl.java | 41 +++++++
src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRectification.java | 9 +
src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java | 61 +++++++++++
src/main/java/com/ruoyi/safe/specialequipment/controller/SpecialEquipmentRectificationController.java | 7 +
src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java | 39 +++++++
src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java | 4
13 files changed, 276 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java b/src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java
index 6fa2822..8325355 100644
--- a/src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java
+++ b/src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java
@@ -67,6 +67,10 @@
SAFE_TRAINING_DETAILS("safe_training_details"),
SAFE_TRAINING("safe_training"),
SAFE_HIDDEN_FILE("safe_hidden_file"),
+ SAFE_LINE_INSPECTION_RECORD("safe_line_inspection_record"),
+ SAFE_FACILITY_INSPECTION("safe_facility_inspection"),
+ SPECIAL_EQUIPMENT_RECORD("special_equipment_record"),
+ SPECIAL_EQUIPMENT_RECTIFICATION("special_equipment_rectification"),
SAFE_HAZARD_RECORD("safe_hazard_record"),
SAFE_HIDDEN("safe_hidden"),
SAFE_HAZARD("safe_hazard"),
diff --git a/src/main/java/com/ruoyi/safe/controller/SafeLineInspectionController.java b/src/main/java/com/ruoyi/safe/controller/SafeLineInspectionController.java
index b5a9f5d..685aa0f 100644
--- a/src/main/java/com/ruoyi/safe/controller/SafeLineInspectionController.java
+++ b/src/main/java/com/ruoyi/safe/controller/SafeLineInspectionController.java
@@ -94,6 +94,9 @@
if (inspection == null) {
return R.fail("宸℃浠诲姟涓嶅瓨鍦�");
}
+ if ("宸插畬鎴�".equals(inspection.getStatus())) {
+ return R.fail("宸℃浠诲姟宸插畬鎴愶紝璇峰嬁閲嶅鎿嶄綔");
+ }
// 鏍¢獙鏄惁鏈夋湭鏁存敼鐨勯殣鎮�
List<SafeLineInspectionHazard> hazards = safeLineInspectionHazardService.listByInspectionId(id);
diff --git a/src/main/java/com/ruoyi/safe/pojo/SafeFacilityInspection.java b/src/main/java/com/ruoyi/safe/pojo/SafeFacilityInspection.java
index aca617a..577163e 100644
--- a/src/main/java/com/ruoyi/safe/pojo/SafeFacilityInspection.java
+++ b/src/main/java/com/ruoyi/safe/pojo/SafeFacilityInspection.java
@@ -5,8 +5,11 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.basic.dto.StorageBlobDTO;
+import com.ruoyi.basic.dto.StorageBlobVO;
import java.io.Serializable;
import java.time.LocalDateTime;
+import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -98,4 +101,12 @@
@TableField(exist = false)
private String inspectorName;
+
+ @Schema(description = "闄勪欢涓婁紶")
+ @TableField(exist = false)
+ private List<StorageBlobDTO> storageBlobDTOs;
+
+ @Schema(description = "闄勪欢鍥炴樉")
+ @TableField(exist = false)
+ private List<StorageBlobVO> storageBlobVOs;
}
diff --git a/src/main/java/com/ruoyi/safe/pojo/SafeLineInspectionRecord.java b/src/main/java/com/ruoyi/safe/pojo/SafeLineInspectionRecord.java
index 6fa53bc..302ca4b 100644
--- a/src/main/java/com/ruoyi/safe/pojo/SafeLineInspectionRecord.java
+++ b/src/main/java/com/ruoyi/safe/pojo/SafeLineInspectionRecord.java
@@ -5,8 +5,11 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.basic.dto.StorageBlobDTO;
+import com.ruoyi.basic.dto.StorageBlobVO;
import java.io.Serializable;
import java.time.LocalDateTime;
+import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -68,4 +71,12 @@
@TableField(fill = FieldFill.INSERT)
private Long deptId;
+
+ @Schema(description = "闄勪欢涓婁紶")
+ @TableField(exist = false)
+ private List<StorageBlobDTO> storageBlobDTOs;
+
+ @Schema(description = "闄勪欢鍥炴樉")
+ @TableField(exist = false)
+ private List<StorageBlobVO> storageBlobVOs;
}
diff --git a/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java b/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java
index a8e2b85..b5301d6 100644
--- a/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java
+++ b/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java
@@ -2,6 +2,10 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.StorageBlobVO;
+import com.ruoyi.basic.enums.ApplicationTypeEnum;
+import com.ruoyi.basic.enums.RecordTypeEnum;
+import com.ruoyi.basic.utils.FileUtil;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.safe.pojo.SafeFacilityInspection;
@@ -35,6 +39,8 @@
private SafeFacilityLedgerService safeFacilityLedgerService;
@Autowired
private SysUserMapper sysUserMapper;
+ @Autowired
+ private FileUtil fileUtil;
@Override
public SafeFacilityInspection getById(Serializable id) {
@@ -56,6 +62,20 @@
fillExtraInfo(result.getRecords());
return result;
+ }
+
+ @Override
+ public boolean save(SafeFacilityInspection entity) {
+ boolean saved = super.save(entity);
+ syncAttachments(saved, entity);
+ return saved;
+ }
+
+ @Override
+ public boolean updateById(SafeFacilityInspection entity) {
+ boolean updated = super.updateById(entity);
+ syncAttachments(updated, entity);
+ return updated;
}
private void fillExtraInfo(List<SafeFacilityInspection> records) {
@@ -105,6 +125,25 @@
if (record.getInspectorId() != null) {
record.setInspectorName(userMap.getOrDefault(record.getInspectorId().longValue(), "鏈煡鐢ㄦ埛"));
}
+ if (record.getId() != null) {
+ List<StorageBlobVO> attachments = fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(
+ RecordTypeEnum.SAFE_FACILITY_INSPECTION,
+ record.getId().longValue()
+ );
+ record.setStorageBlobVOs(attachments == null ? Collections.emptyList() : attachments);
+ }
}
}
+
+ private void syncAttachments(boolean success, SafeFacilityInspection entity) {
+ if (!success || entity == null || entity.getId() == null || entity.getStorageBlobDTOs() == null) {
+ return;
+ }
+ fileUtil.saveStorageAttachment(
+ ApplicationTypeEnum.IMAGE,
+ RecordTypeEnum.SAFE_FACILITY_INSPECTION,
+ entity.getId().longValue(),
+ entity.getStorageBlobDTOs()
+ );
+ }
}
diff --git a/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionHazardServiceImpl.java b/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionHazardServiceImpl.java
index 3f2e43b..4b53b5c 100644
--- a/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionHazardServiceImpl.java
+++ b/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionHazardServiceImpl.java
@@ -3,14 +3,18 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.safe.pojo.SafeLineInspectionHazard;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.safe.mapper.SafeLineInspectionHazardMapper;
+import com.ruoyi.safe.pojo.SafeLineInspectionHazard;
import com.ruoyi.safe.service.SafeLineInspectionHazardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* <p>
@@ -23,22 +27,29 @@
@Service
public class SafeLineInspectionHazardServiceImpl extends ServiceImpl<SafeLineInspectionHazardMapper, SafeLineInspectionHazard> implements SafeLineInspectionHazardService {
+ @Autowired
+ private SysUserMapper sysUserMapper;
+
@Override
public IPage<SafeLineInspectionHazard> pageSafeLineInspectionHazard(Page page, SafeLineInspectionHazard safeLineInspectionHazard) {
- return this.lambdaQuery()
+ IPage<SafeLineInspectionHazard> result = this.lambdaQuery()
.eq(safeLineInspectionHazard.getInspectionId() != null, SafeLineInspectionHazard::getInspectionId, safeLineInspectionHazard.getInspectionId())
.like(safeLineInspectionHazard.getHazardCode() != null, SafeLineInspectionHazard::getHazardCode, safeLineInspectionHazard.getHazardCode())
.eq(safeLineInspectionHazard.getStatus() != null, SafeLineInspectionHazard::getStatus, safeLineInspectionHazard.getStatus())
.orderByDesc(SafeLineInspectionHazard::getCreateTime)
.page(page);
+ fillRectifyUserName(result.getRecords());
+ return result;
}
@Override
public List<SafeLineInspectionHazard> listByInspectionId(Integer inspectionId) {
- return this.lambdaQuery()
+ List<SafeLineInspectionHazard> records = this.lambdaQuery()
.eq(SafeLineInspectionHazard::getInspectionId, inspectionId)
.orderByDesc(SafeLineInspectionHazard::getCreateTime)
.list();
+ fillRectifyUserName(records);
+ return records;
}
@Override
@@ -63,4 +74,26 @@
long count = this.count() + 1;
return "YH" + String.format("%05d", count);
}
+
+ private void fillRectifyUserName(List<SafeLineInspectionHazard> records) {
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ List<Long> userIds = records.stream()
+ .map(SafeLineInspectionHazard::getRectifyUserId)
+ .filter(Objects::nonNull)
+ .map(Integer::longValue)
+ .distinct()
+ .collect(Collectors.toList());
+ if (userIds.isEmpty()) {
+ return;
+ }
+ Map<Long, String> userMap = sysUserMapper.selectUserByIds(userIds).stream()
+ .collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName, (v1, v2) -> v1));
+ records.forEach(record -> {
+ if (record.getRectifyUserId() != null) {
+ record.setRectifyUserName(userMap.getOrDefault(record.getRectifyUserId().longValue(), "鏈煡鐢ㄦ埛"));
+ }
+ });
+ }
}
diff --git a/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java b/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java
index 89da3f0..bca99c5 100644
--- a/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java
@@ -1,11 +1,17 @@
package com.ruoyi.safe.service.impl;
-import com.ruoyi.safe.pojo.SafeLineInspectionRecord;
-import com.ruoyi.safe.mapper.SafeLineInspectionRecordMapper;
-import com.ruoyi.safe.service.SafeLineInspectionRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.StorageBlobVO;
+import com.ruoyi.basic.enums.ApplicationTypeEnum;
+import com.ruoyi.basic.enums.RecordTypeEnum;
+import com.ruoyi.basic.utils.FileUtil;
+import com.ruoyi.safe.mapper.SafeLineInspectionRecordMapper;
+import com.ruoyi.safe.pojo.SafeLineInspectionRecord;
+import com.ruoyi.safe.service.SafeLineInspectionRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.Collections;
import java.util.List;
/**
@@ -19,11 +25,58 @@
@Service
public class SafeLineInspectionRecordServiceImpl extends ServiceImpl<SafeLineInspectionRecordMapper, SafeLineInspectionRecord> implements SafeLineInspectionRecordService {
+ @Autowired
+ private FileUtil fileUtil;
+
@Override
public List<SafeLineInspectionRecord> listByInspectionId(Integer inspectionId) {
- return this.lambdaQuery()
+ List<SafeLineInspectionRecord> records = this.lambdaQuery()
.eq(SafeLineInspectionRecord::getInspectionId, inspectionId)
.orderByDesc(SafeLineInspectionRecord::getCheckTime)
.list();
+ fillAttachments(records);
+ return records;
+ }
+
+ @Override
+ public boolean save(SafeLineInspectionRecord entity) {
+ boolean saved = super.save(entity);
+ syncAttachments(saved, entity);
+ return saved;
+ }
+
+ @Override
+ public boolean updateById(SafeLineInspectionRecord entity) {
+ boolean updated = super.updateById(entity);
+ syncAttachments(updated, entity);
+ return updated;
+ }
+
+ private void syncAttachments(boolean success, SafeLineInspectionRecord entity) {
+ if (!success || entity == null || entity.getId() == null || entity.getStorageBlobDTOs() == null) {
+ return;
+ }
+ fileUtil.saveStorageAttachment(
+ ApplicationTypeEnum.IMAGE,
+ RecordTypeEnum.SAFE_LINE_INSPECTION_RECORD,
+ entity.getId().longValue(),
+ entity.getStorageBlobDTOs()
+ );
+ }
+
+ private void fillAttachments(List<SafeLineInspectionRecord> records) {
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ records.forEach(record -> {
+ if (record.getId() == null) {
+ return;
+ }
+ List<StorageBlobVO> attachments = fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(
+ RecordTypeEnum.SAFE_LINE_INSPECTION_RECORD,
+ record.getId().longValue()
+ );
+ record.setStorageBlobVOs(attachments == null ? Collections.emptyList() : attachments);
+ });
}
}
diff --git a/src/main/java/com/ruoyi/safe/specialequipment/controller/SpecialEquipmentRectificationController.java b/src/main/java/com/ruoyi/safe/specialequipment/controller/SpecialEquipmentRectificationController.java
index 567dbfa..f5dc8cb 100644
--- a/src/main/java/com/ruoyi/safe/specialequipment/controller/SpecialEquipmentRectificationController.java
+++ b/src/main/java/com/ruoyi/safe/specialequipment/controller/SpecialEquipmentRectificationController.java
@@ -35,6 +35,13 @@
return service.save(req) ? success() : error();
}
+ @PostMapping("/update")
+ @Log(title = "闅愭偅鏁存敼-淇敼", businessType = BusinessType.UPDATE)
+ @Operation(summary = "闅愭偅鏁存敼-淇敼")
+ public AjaxResult update(@RequestBody SpecialEquipmentRectification req) {
+ return service.updateById(req) ? success() : error();
+ }
+
@PostMapping("/close")
@Log(title = "闅愭偅鏁存敼-闂幆", businessType = BusinessType.UPDATE)
@Operation(summary = "闅愭偅鏁存敼-闂幆")
diff --git a/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRecord.java b/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRecord.java
index c11ab1a..49fbffe 100644
--- a/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRecord.java
+++ b/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRecord.java
@@ -2,6 +2,8 @@
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.basic.dto.StorageBlobDTO;
+import com.ruoyi.basic.dto.StorageBlobVO;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -10,6 +12,7 @@
import java.io.Serial;
import java.io.Serializable;
import java.time.*;
+import java.util.List;
@Data
@Schema(description = "鐗圭璁惧妫�楠岀淮淇濊褰�")
@@ -56,6 +59,12 @@
@Excel(name = "闄勪欢璇存槑")
private String attachmentRemark;
+ @TableField(exist = false)
+ private List<StorageBlobDTO> storageBlobDTOs;
+
+ @TableField(exist = false)
+ private List<StorageBlobVO> storageBlobVOs;
+
@TableField(fill = FieldFill.INSERT)
private Long createUser;
diff --git a/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRectification.java b/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRectification.java
index f11cb90..8f40f02 100644
--- a/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRectification.java
+++ b/src/main/java/com/ruoyi/safe/specialequipment/pojo/SpecialEquipmentRectification.java
@@ -2,6 +2,8 @@
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.basic.dto.StorageBlobDTO;
+import com.ruoyi.basic.dto.StorageBlobVO;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -10,6 +12,7 @@
import java.io.Serial;
import java.io.Serializable;
import java.time.*;
+import java.util.List;
@Data
@Schema(description = "鐗圭璁惧闅愭偅鏁存敼")
@@ -61,6 +64,12 @@
@Excel(name = "澶囨敞")
private String remarks;
+ @TableField(exist = false)
+ private List<StorageBlobDTO> storageBlobDTOs;
+
+ @TableField(exist = false)
+ private List<StorageBlobVO> storageBlobVOs;
+
@TableField(fill = FieldFill.INSERT)
private Long createUser;
diff --git a/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRecordServiceImpl.java b/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRecordServiceImpl.java
index 56de862..2665625 100644
--- a/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRecordServiceImpl.java
@@ -3,6 +3,10 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.StorageBlobVO;
+import com.ruoyi.basic.enums.ApplicationTypeEnum;
+import com.ruoyi.basic.enums.RecordTypeEnum;
+import com.ruoyi.basic.utils.FileUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.safe.specialequipment.mapper.SpecialEquipmentLedgerMapper;
import com.ruoyi.safe.specialequipment.mapper.SpecialEquipmentRecordMapper;
@@ -13,15 +17,20 @@
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
+import java.util.Collections;
+import java.util.List;
@Service
@RequiredArgsConstructor
public class SpecialEquipmentRecordServiceImpl extends ServiceImpl<SpecialEquipmentRecordMapper, SpecialEquipmentRecord> implements SpecialEquipmentRecordService {
private final SpecialEquipmentRecordMapper mapper;
private final SpecialEquipmentLedgerMapper ledgerMapper;
+ private final FileUtil fileUtil;
public IPage<SpecialEquipmentRecord> listPage(Page page, SpecialEquipmentRecord req) {
- return mapper.listPage(page, req);
+ IPage<SpecialEquipmentRecord> result = mapper.listPage(page, req);
+ fillAttachments(result.getRecords());
+ return result;
}
public boolean save(SpecialEquipmentRecord entity) {
@@ -29,6 +38,7 @@
entity.setCreateUser(SecurityUtils.getLoginUser().getUserId());
entity.setCreateTime(LocalDateTime.now());
boolean saved = super.save(entity);
+ syncAttachments(saved, entity);
syncLedgerDate(entity);
return saved;
}
@@ -36,6 +46,7 @@
@Override
public boolean updateById(SpecialEquipmentRecord entity) {
boolean updated = super.updateById(entity);
+ syncAttachments(updated, entity);
syncLedgerDate(entity);
return updated;
}
@@ -57,4 +68,32 @@
}
ledgerMapper.updateById(ledger);
}
+
+ private void syncAttachments(boolean success, SpecialEquipmentRecord entity) {
+ if (!success || entity == null || entity.getId() == null || entity.getStorageBlobDTOs() == null) {
+ return;
+ }
+ fileUtil.saveStorageAttachment(
+ ApplicationTypeEnum.FILE,
+ RecordTypeEnum.SPECIAL_EQUIPMENT_RECORD,
+ entity.getId(),
+ entity.getStorageBlobDTOs()
+ );
+ }
+
+ private void fillAttachments(List<SpecialEquipmentRecord> records) {
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ records.forEach(record -> {
+ if (record.getId() == null) {
+ return;
+ }
+ List<StorageBlobVO> attachments = fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(
+ RecordTypeEnum.SPECIAL_EQUIPMENT_RECORD,
+ record.getId()
+ );
+ record.setStorageBlobVOs(attachments == null ? Collections.emptyList() : attachments);
+ });
+ }
}
diff --git a/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRectificationServiceImpl.java b/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRectificationServiceImpl.java
index ae4dc00..eae9cf2 100644
--- a/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRectificationServiceImpl.java
+++ b/src/main/java/com/ruoyi/safe/specialequipment/service/impl/SpecialEquipmentRectificationServiceImpl.java
@@ -3,6 +3,10 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.StorageBlobVO;
+import com.ruoyi.basic.enums.ApplicationTypeEnum;
+import com.ruoyi.basic.enums.RecordTypeEnum;
+import com.ruoyi.basic.utils.FileUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.safe.specialequipment.mapper.SpecialEquipmentRectificationMapper;
import com.ruoyi.safe.specialequipment.pojo.SpecialEquipmentRectification;
@@ -11,14 +15,20 @@
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
+import java.time.LocalDate;
+import java.util.Collections;
+import java.util.List;
@Service
@RequiredArgsConstructor
public class SpecialEquipmentRectificationServiceImpl extends ServiceImpl<SpecialEquipmentRectificationMapper, SpecialEquipmentRectification> implements SpecialEquipmentRectificationService {
private final SpecialEquipmentRectificationMapper mapper;
+ private final FileUtil fileUtil;
public IPage<SpecialEquipmentRectification> listPage(Page page, SpecialEquipmentRectification req) {
- return mapper.listPage(page, req);
+ IPage<SpecialEquipmentRectification> result = mapper.listPage(page, req);
+ fillAttachments(result.getRecords());
+ return result;
}
public boolean save(SpecialEquipmentRectification entity) {
@@ -26,11 +36,46 @@
entity.setCreateUser(SecurityUtils.getLoginUser().getUserId());
entity.setCreateTime(LocalDateTime.now());
entity.setRectificationStatus(entity.getRectificationStatus() == null ? 1 : entity.getRectificationStatus());
- return super.save(entity);
+ boolean saved = super.save(entity);
+ syncAttachments(saved, entity);
+ return saved;
}
@Override
public boolean updateById(SpecialEquipmentRectification entity) {
- return super.updateById(entity);
+ if (entity.getRectificationStatus() != null && entity.getRectificationStatus() == 4 && entity.getClosedDate() == null) {
+ entity.setClosedDate(LocalDate.now());
+ }
+ boolean updated = super.updateById(entity);
+ syncAttachments(updated, entity);
+ return updated;
+ }
+
+ private void syncAttachments(boolean success, SpecialEquipmentRectification entity) {
+ if (!success || entity == null || entity.getId() == null || entity.getStorageBlobDTOs() == null) {
+ return;
+ }
+ fileUtil.saveStorageAttachment(
+ ApplicationTypeEnum.FILE,
+ RecordTypeEnum.SPECIAL_EQUIPMENT_RECTIFICATION,
+ entity.getId(),
+ entity.getStorageBlobDTOs()
+ );
+ }
+
+ private void fillAttachments(List<SpecialEquipmentRectification> records) {
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ records.forEach(record -> {
+ if (record.getId() == null) {
+ return;
+ }
+ List<StorageBlobVO> attachments = fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(
+ RecordTypeEnum.SPECIAL_EQUIPMENT_RECTIFICATION,
+ record.getId()
+ );
+ record.setStorageBlobVOs(attachments == null ? Collections.emptyList() : attachments);
+ });
}
}
diff --git a/src/main/resources/mapper/safe/specialequipment/SpecialEquipmentRectificationMapper.xml b/src/main/resources/mapper/safe/specialequipment/SpecialEquipmentRectificationMapper.xml
index d9a6db1..c166da4 100644
--- a/src/main/resources/mapper/safe/specialequipment/SpecialEquipmentRectificationMapper.xml
+++ b/src/main/resources/mapper/safe/specialequipment/SpecialEquipmentRectificationMapper.xml
@@ -37,7 +37,7 @@
<if test="req.equipmentId != null">
and equipment_id = #{req.equipmentId}
</if>
- order by id
+ order by id desc
</select>
</mapper>
--
Gitblit v1.9.3