| | |
| | | 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.StorageBlobDTO; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.common.constant.StorageAttachmentConstants; |
| | | import com.ruoyi.common.enums.StorageAttachmentRecordType; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.device.dto.DeviceDefectRecordDto; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.execl.DeviceRepairExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceDefectRecordMapper; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceDefectRecord; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.DeviceDefectRecordService; |
| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | |
| | | private DeviceRepairMapper deviceRepairMapper; |
| | | @Autowired |
| | | private IDeviceLedgerService deviceLedgerService; |
| | | @Autowired |
| | | private StorageAttachmentService storageAttachmentService; |
| | | @Override |
| | | public IPage<DeviceRepairDto> queryPage(Page page, DeviceRepairDto deviceRepairDto) { |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult saveDeviceRepair(DeviceRepair deviceRepair) { |
| | | public AjaxResult saveDeviceRepair(DeviceRepairDto deviceRepair) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceRepair.getDeviceLedgerId()); |
| | | deviceRepair.setDeviceName(byId.getDeviceName()); |
| | | deviceRepair.setDeviceModel(byId.getDeviceModel()); |
| | | boolean save = this.save(deviceRepair); |
| | | if (save){ |
| | | int save = deviceRepairMapper.insert(deviceRepair); |
| | | storageAttachmentService.saveStorageAttachmentByStorageBlob(deviceRepair.getFiles(), |
| | | deviceRepair.getId(), StorageAttachmentRecordType.DeviceRepairImage, |
| | | StorageAttachmentConstants.StorageAttachmentImage); |
| | | if (save == 1){ |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateDeviceRepair(DeviceRepair deviceRepair) { |
| | | public AjaxResult updateDeviceRepair(DeviceRepairDto deviceRepair) { |
| | | if (this.updateById(deviceRepair)) { |
| | | Long id = deviceRepair.getId(); |
| | | // |
| | |
| | | deviceDefectRecordService.updateByDDR(deviceDefectRecord); |
| | | }); |
| | | } |
| | | storageAttachmentService.saveStorageAttachmentByStorageBlob(deviceRepair.getFiles(), |
| | | deviceRepair.getId(), StorageAttachmentRecordType.DeviceRepairImage, |
| | | StorageAttachmentConstants.StorageAttachmentImage); |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | |
| | | |
| | | @Override |
| | | public DeviceRepairDto detailById(Long id) { |
| | | |
| | | return deviceRepairMapper.detailById(id); |
| | | DeviceRepairDto deviceRepairDto = deviceRepairMapper.detailById(id); |
| | | List<StorageAttachment> storageAttachments = storageAttachmentService.selectStorageAttachments(id, StorageAttachmentRecordType.DeviceRepairImage, |
| | | StorageAttachmentConstants.StorageAttachmentImage); |
| | | if (CollectionUtils.isNotEmpty(storageAttachments)) { |
| | | List<StorageBlobDTO> storageBlobs = storageAttachments.stream().map(StorageAttachment::getStorageBlobDTO).collect(Collectors.toList()); |
| | | deviceRepairDto.setFiles(storageBlobs); |
| | | } |
| | | return deviceRepairDto; |
| | | } |
| | | |
| | | } |