gongchunyi
6 天以前 ad45ebdf25cae54a3950bba33aa767fc7a8a43d8
feat: 设备台账新增附件图片上传
已修改4个文件
90 ■■■■ 文件已修改
src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/service/IDeviceLedgerService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
@@ -35,7 +35,6 @@
    private DeviceMaintenanceMapper deviceMaintenanceMapper;
    @Operation(summary = "设备台账列表")
    @GetMapping("/page")
    public AjaxResult page(Page page , DeviceLedgerDto deviceLedger) {
@@ -44,21 +43,21 @@
    @PostMapping()
    @Operation(summary = "添加设备台账")
    public AjaxResult add(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.saveDeviceLedger(deviceLedger);
    public AjaxResult add(@RequestBody DeviceLedgerDto deviceLedgerDto) {
        return deviceLedgerService.saveDeviceLedger(deviceLedgerDto);
    }
    @Operation(summary = "根据id查询设备台账")
    @GetMapping("/{id}")
    public AjaxResult detail(@PathVariable Long id) {
        return AjaxResult.success(deviceLedgerService.getById(id));
        DeviceLedgerDto deviceLedgerDto = deviceLedgerService.getDeviceLedgerDetail(id);
        return AjaxResult.success(deviceLedgerDto);
    }
    @PutMapping ()
    @Operation(summary = "修改设备台账")
    public AjaxResult update(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.updateDeviceLedger(deviceLedger);
    public AjaxResult update(@RequestBody DeviceLedgerDto deviceLedgerDto) {
        return deviceLedgerService.updateDeviceLedger(deviceLedgerDto);
    }
    @DeleteMapping("/{ids}")
@@ -108,8 +107,8 @@
    public AjaxResult scanDevice(Long id) {
        List<DeviceMaintenance> list = deviceMaintenanceMapper.list1(id);
        DeviceLedger deviceLedger = deviceLedgerMapper.selectById1(id);
        if (list.size()>0){
            deviceLedger.setUpdateTime(list.get(0).getMaintenanceActuallyTime());//最后维护时间
        if (!list.isEmpty()) {
            deviceLedger.setUpdateTime(list.getFirst().getMaintenanceActuallyTime());//最后维护时间
        }
        deviceLedger.setCreateTime(deviceLedger.getUpdateTime().plusMonths(1));//下次维护时间
        return AjaxResult.success(deviceLedger);
src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java
@@ -12,6 +12,9 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import com.ruoyi.basic.dto.StorageBlobDTO;
import com.ruoyi.basic.dto.StorageBlobVO;
/**
 * 设备台账实体类
@@ -55,6 +58,20 @@
    private String supplierName;
    /**
     * 设备附件(用于接收)
     */
    @TableField(exist = false)
    @Schema(description = "设备附件接收列表")
    private List<StorageBlobDTO> storageBlobDTOs;
    /**
     * 设备附件(用于返回)
     */
    @TableField(exist = false)
    @Schema(description = "设备附件展示列表")
    private List<StorageBlobVO> storageBlobVOs;
    /**
     * 单位
     */
    private String unit;
src/main/java/com/ruoyi/device/service/IDeviceLedgerService.java
@@ -14,9 +14,11 @@
public interface IDeviceLedgerService  extends IService<DeviceLedger> {
    IPage<DeviceLedgerDto> queryPage(Page page, DeviceLedgerDto deviceLedger);
    AjaxResult saveDeviceLedger(DeviceLedger deviceLedger);
    AjaxResult saveDeviceLedger(DeviceLedgerDto deviceLedgerDto);
    AjaxResult updateDeviceLedger(DeviceLedger deviceLedger);
    AjaxResult updateDeviceLedger(DeviceLedgerDto deviceLedgerDto);
    DeviceLedgerDto getDeviceLedgerDetail(Long id);
    void export(HttpServletResponse response, Long[] ids);
src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
@@ -12,6 +12,9 @@
import com.ruoyi.device.execl.DeviceLedgerExeclDto;
import com.ruoyi.device.mapper.DeviceLedgerMapper;
import com.ruoyi.device.pojo.DeviceLedger;
import com.ruoyi.basic.dto.StorageAttachmentDTO;
import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.service.StorageAttachmentService;
import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.SysUser;
@@ -36,6 +39,7 @@
    private final DeviceLedgerMapper deviceLedgerMapper;
    private final SysUserMapper sysUserMapper;
    private final StorageAttachmentService storageAttachmentService;
    @Override
    public IPage<DeviceLedgerDto> queryPage(Page page, DeviceLedgerDto deviceLedger) {
@@ -44,25 +48,61 @@
    }
    @Override
    public AjaxResult saveDeviceLedger(DeviceLedger deviceLedger) {
    public AjaxResult saveDeviceLedger(DeviceLedgerDto deviceLedgerDto) {
        LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
        deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedger.getDeviceName());
        deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedgerDto.getDeviceName());
        if (this.count(deviceLedgerLambdaQueryWrapper) > 0) {
            return AjaxResult.error("设备名称已存在");
        }
        DeviceLedger deviceLedger = new DeviceLedger();
        BeanUtils.copyProperties(deviceLedgerDto, deviceLedger);
        boolean save = this.save(deviceLedger);
        if (save){
            if (deviceLedgerDto.getStorageBlobDTOs() != null) {
                StorageAttachmentDTO attachmentDTO = new StorageAttachmentDTO();
                attachmentDTO.setApplication("image");
                attachmentDTO.setRecordType(RecordTypeEnum.DEVICE_LEDGER.getType());
                attachmentDTO.setRecordId(deviceLedger.getId());
                attachmentDTO.setStorageBlobDTOs(deviceLedgerDto.getStorageBlobDTOs());
                storageAttachmentService.saveStorageAttachment(attachmentDTO);
            }
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
    @Override
    public AjaxResult updateDeviceLedger(DeviceLedger deviceLedger) {
    public AjaxResult updateDeviceLedger(DeviceLedgerDto deviceLedgerDto) {
        DeviceLedger deviceLedger = new DeviceLedger();
        BeanUtils.copyProperties(deviceLedgerDto, deviceLedger);
        if (this.updateById(deviceLedger)) {
            if (deviceLedgerDto.getStorageBlobDTOs() != null) {
                StorageAttachmentDTO attachmentDTO = new StorageAttachmentDTO();
                attachmentDTO.setApplication("image");
                attachmentDTO.setRecordType(RecordTypeEnum.DEVICE_LEDGER.getType());
                attachmentDTO.setRecordId(deviceLedger.getId());
                attachmentDTO.setStorageBlobDTOs(deviceLedgerDto.getStorageBlobDTOs());
                storageAttachmentService.saveStorageAttachment(attachmentDTO);
            }
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
    @Override
    public DeviceLedgerDto getDeviceLedgerDetail(Long id) {
        DeviceLedger deviceLedger = this.getById(id);
        if (deviceLedger != null) {
            DeviceLedgerDto deviceLedgerDto = new DeviceLedgerDto();
            BeanUtils.copyProperties(deviceLedger, deviceLedgerDto);
            StorageAttachmentDTO dto = new StorageAttachmentDTO();
            dto.setRecordType(RecordTypeEnum.DEVICE_LEDGER.getType());
            dto.setRecordId(id);
            dto.setApplication("image");
            deviceLedgerDto.setStorageBlobVOs(storageAttachmentService.list(dto));
            return deviceLedgerDto;
        }
        return null;
    }
    @Override
@@ -82,9 +122,7 @@
            util.exportExcel(response, deviceLedgerExeclDtos, "设备台账导出");
        }else  {
            ArrayList<Long> arrayList = new ArrayList<>();
            Arrays.stream(ids).map(id -> {
                return arrayList.add( id);
            });
            Arrays.stream(ids).map(arrayList::add);
            List<DeviceLedger> supplierManageList = deviceLedgerMapper.selectBatchIds(arrayList);
            ArrayList<DeviceLedgerExeclDto> deviceLedgerExeclDtos = new ArrayList<>();
            supplierManageList.stream().forEach(deviceLedger -> {