| | |
| | | |
| | | 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; |
| | |
| | | private SafeFacilityLedgerService safeFacilityLedgerService; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | @Autowired |
| | | private FileUtil fileUtil; |
| | | |
| | | @Override |
| | | public SafeFacilityInspection getById(Serializable id) { |
| | |
| | | |
| | | 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) { |
| | |
| | | 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() |
| | | ); |
| | | } |
| | | } |