| | |
| | | package com.ruoyi.basic.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.common.constant.StorageAttachmentConstants; |
| | | import com.ruoyi.common.enums.StorageAttachmentRecordType; |
| | |
| | | * @param fileType 文件类型 |
| | | * @return 文件信息列表 |
| | | */ |
| | | List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType); |
| | | List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, String fileType); |
| | | |
| | | /** |
| | | * 保存通用文件上传的附件信息 |
| | |
| | | */ |
| | | public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType); |
| | | |
| | | public void saveStorageAttachmentByStorageBlob(List<StorageBlobDTO> storageBlobs, Long recordId, StorageAttachmentRecordType recordType, String fileType); |
| | | |
| | | public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, String fileType); |
| | | |
| | | |
| | |
| | | * @return 删除结果 |
| | | */ |
| | | public int deleteStorageAttachment(StorageAttachment storageAttachment); |
| | | |
| | | public int deleteStorageAttachmentAndBlob(StorageAttachment storageAttachment); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.mapper.StorageAttachmentMapper; |
| | | import com.ruoyi.basic.mapper.StorageBlobMapper; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.pojo.StorageBlob; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.basic.service.StorageBlobService; |
| | |
| | | private MinioUtils minioUtils; |
| | | |
| | | @Override |
| | | public List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType) { |
| | | public List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, String fileType) { |
| | | List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>() |
| | | .eq(StorageAttachment::getRecordId, recordId) |
| | | .eq(StorageAttachment::getRecordType, recordType.ordinal()) |
| | | .eq(StorageAttachment::getName, fileType.toString())); |
| | | .eq(StorageAttachment::getName, fileType)); |
| | | if (storageAttachments != null) { |
| | | for (StorageAttachment storageAttachment : storageAttachments) { |
| | | StorageBlob storageBlob = storageBlobMapper.selectById(storageAttachment.getStorageBlobId()); |
| | | StorageBlobDTO storageBlobDTO = new StorageBlobDTO(); |
| | | BeanUtils.copyProperties(storageBlob, storageBlobDTO); |
| | | storageBlobDTO.setUrl(minioUtils.getPreviewUrl(storageBlob.getBucketName(), storageBlob.getBucketName(), true)); |
| | | storageBlobDTO.setUrl(minioUtils.getPreviewUrl(storageBlob.getBucketFilename(), storageBlob.getBucketName(), true)); |
| | | storageAttachment.setStorageBlobDTO(storageBlobDTO); |
| | | } |
| | | } |
| | |
| | | attachment.setStorageBlobId(storageBlob.getId()); |
| | | storageAttachmentMapper.insert(attachment); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void saveStorageAttachmentByStorageBlob(List<StorageBlobDTO> storageBlobs, Long recordId, StorageAttachmentRecordType recordType, String fileType) { |
| | | // 删除旧图 |
| | | deleteStorageAttachment(new StorageAttachment(fileType, (long) recordType.ordinal(), recordId)); |
| | | for (StorageBlobDTO storageBlobDTO : storageBlobs) { |
| | | StorageAttachment attachment = new StorageAttachment( |
| | | fileType, |
| | | (long) recordType.ordinal(), |
| | | recordId |
| | | ); |
| | | attachment.setStorageBlobDTO(storageBlobDTO); |
| | | // 绑定关联记录 |
| | | attachment.setName(fileType); |
| | | attachment.setRecordType((long) recordType.ordinal()); |
| | | attachment.setRecordId(recordId); |
| | | attachment.setStorageBlobId(storageBlobDTO.getId()); |
| | | storageAttachmentMapper.insert(attachment); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public int deleteStorageAttachment(StorageAttachment storageAttachment) { |
| | | // 先删除明细表 |
| | | storageBlobService.deleteStorageBlobs(storageAttachment); |
| | | return storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>() |
| | | .eq(StorageAttachment::getRecordId, storageAttachment.getRecordId()) |
| | | .eq(StorageAttachment::getRecordType, storageAttachment.getRecordType()) |
| | | .eq(StorageAttachment::getName, storageAttachment.getName())); |
| | | } |
| | | |
| | | @Override |
| | | public int deleteStorageAttachmentAndBlob(StorageAttachment storageAttachment) { |
| | | // 先删除明细表 |
| | | storageBlobService.deleteStorageBlobs(storageAttachment); |
| | | |
| | | return storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>() |
| | | .eq(StorageAttachment::getRecordId, storageAttachment.getRecordId()) |
| | |
| | | Template("Template","范例"), |
| | | Archives("Archives","文档管理"), |
| | | InspectionTasks("InspectionTasks","生产巡检"), |
| | | QrCodeScanRecords("QrCodeScanRecords","二维码扫码记录文件"); |
| | | QrCodeScanRecords("QrCodeScanRecords","二维码扫码记录文件"), |
| | | DeviceRepairImage("DeviceRepairImage","设备报修图片"), |
| | | DeviceMaintenanceImage("DeviceMaintenanceImage","设备保养图片"); |
| | | |
| | | |
| | | private final String code; |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceMaintenanceDto; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.device.service.IDeviceRepairService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | |
| | | @Api(tags = "设备保养") |
| | |
| | | |
| | | @PostMapping() |
| | | @ApiModelProperty("添加设备保养") |
| | | public AjaxResult add(@RequestBody DeviceMaintenance deviceMaintenance) { |
| | | public AjaxResult add(@RequestBody DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceMaintenance.getDeviceLedgerId()); |
| | | deviceMaintenance.setDeviceName(byId.getDeviceName()); |
| | | deviceMaintenance.setDeviceModel(byId.getDeviceModel()); |
| | |
| | | |
| | | @PutMapping () |
| | | @ApiModelProperty("修改设备保养") |
| | | public AjaxResult update(@RequestBody DeviceMaintenance deviceMaintenance) { |
| | | public AjaxResult update(@RequestBody DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceMaintenance.getDeviceLedgerId()); |
| | | deviceMaintenance.setDeviceName(byId.getDeviceName()); |
| | | deviceMaintenance.setDeviceModel(byId.getDeviceModel()); |
| | |
| | | |
| | | @PostMapping ("maintenance") |
| | | @ApiModelProperty("修改设备保养") |
| | | public AjaxResult maintenance(@RequestBody DeviceMaintenance deviceMaintenance) { |
| | | public AjaxResult maintenance(@RequestBody DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceMaintenanceDto byId = deviceMaintenanceService.detailById(deviceMaintenance.getId()); |
| | | deviceMaintenance.setStatus(1); |
| | | deviceMaintenance.setFiles(byId.getFiles()); |
| | | return deviceMaintenanceService.updateDeviceDeviceMaintenance(deviceMaintenance); |
| | | } |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceRepairService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | |
| | | @Api(tags = "设备报修管理") |
| | |
| | | |
| | | @PostMapping() |
| | | @ApiModelProperty("添加设备报修") |
| | | public AjaxResult add( @RequestBody DeviceRepair deviceRepair) { |
| | | public AjaxResult add( @RequestBody DeviceRepairDto deviceRepair) { |
| | | return deviceRepairService.saveDeviceRepair(deviceRepair); |
| | | } |
| | | |
| | |
| | | |
| | | @PutMapping () |
| | | @ApiModelProperty("修改设备报修") |
| | | public AjaxResult update( @RequestBody DeviceRepair deviceRepair) { |
| | | public AjaxResult update( @RequestBody DeviceRepairDto deviceRepair) { |
| | | return deviceRepairService.updateDeviceRepair(deviceRepair); |
| | | } |
| | | |
| | | @PostMapping ("repair") |
| | | @ApiModelProperty("设备维修") |
| | | public AjaxResult repair( @RequestBody DeviceRepair deviceRepair) { |
| | | public AjaxResult repair( @RequestBody DeviceRepairDto deviceRepair) { |
| | | DeviceRepairDto deviceRepairDto = deviceRepairService.detailById(deviceRepair.getId()); |
| | | deviceRepair.setStatus(1); |
| | | deviceRepair.setFiles(deviceRepairDto.getFiles()); |
| | | return deviceRepairService.updateDeviceRepair(deviceRepair); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.device.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class DeviceMaintenanceDto { |
| | | |
| | | |
| | | @ApiModelProperty("设备保养id") |
| | | |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("设备台账id") |
| | | private Long deviceLedgerId; |
| | | |
| | | @ApiModelProperty("设备名称") |
| | | private String deviceName; |
| | | |
| | | @ApiModelProperty("规格型号") |
| | | private String deviceModel; |
| | | public class DeviceMaintenanceDto extends DeviceMaintenance { |
| | | |
| | | @ApiModelProperty("计划保养日期") |
| | | private String maintenancePlanTimeReq; |
| | | |
| | | @ApiModelProperty("计划保养日期") |
| | | private LocalDateTime maintenancePlanTime; |
| | | |
| | | @ApiModelProperty("实际保养人") |
| | | private String maintenanceActuallyName; |
| | | |
| | | @ApiModelProperty("实际保养日期") |
| | | private LocalDateTime maintenanceActuallyTime; |
| | | |
| | | @ApiModelProperty("实际保养日期") |
| | | private String maintenanceActuallyTimeReq; |
| | | |
| | | @ApiModelProperty("保养结果 0 维修 1 完好") |
| | | private Integer maintenanceResult; |
| | | |
| | | @ApiModelProperty("状态 0 待保养 1 完结") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty("创建时间") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("更新时间") |
| | | @TableField(fill = FieldFill.UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("创建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createUser; |
| | | |
| | | @ApiModelProperty("更新人") |
| | | @TableField(fill = FieldFill.UPDATE) |
| | | private String updateUser; |
| | | |
| | | @ApiModelProperty("租户id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @ApiModelProperty("创建人名称") |
| | | private String createUserName; |
| | | |
| | | @ApiModelProperty("保养进度描述") |
| | | private String maintenanceProcessDesc; |
| | | |
| | | @ApiModelProperty("设备图片") |
| | | private List<StorageBlobDTO> files; |
| | | } |
| | |
| | | package com.ruoyi.device.dto; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class DeviceRepairDto { |
| | | public class DeviceRepairDto extends DeviceRepair { |
| | | |
| | | @ApiModelProperty("设备报修id") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("设备台账id") |
| | | private Long deviceLedgerId; |
| | | |
| | | @ApiModelProperty("设备名称") |
| | | private String deviceName; |
| | | |
| | | @ApiModelProperty("设备型号") |
| | | private String deviceModel; |
| | | |
| | | @ApiModelProperty("报修时间") |
| | | private Date repairTime; |
| | | @ApiModelProperty("设备图片") |
| | | private List<StorageBlobDTO> files; |
| | | |
| | | private String repairTimeStr; |
| | | |
| | | @ApiModelProperty("报修人") |
| | | private String repairName; |
| | | |
| | | @ApiModelProperty("报修内容") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("维修人") |
| | | private String maintenanceName; |
| | | |
| | | @ApiModelProperty("维修时间") |
| | | private Date maintenanceTime; |
| | | |
| | | private String maintenanceTimeStr; |
| | | |
| | | @ApiModelProperty("维修结果") |
| | | private String maintenanceResult; |
| | | |
| | | @ApiModelProperty("状态") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty("创建时间") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("更新时间") |
| | | @TableField(fill = FieldFill.UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("创建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createUser; |
| | | |
| | | @ApiModelProperty("更新人") |
| | | @TableField(fill = FieldFill.UPDATE) |
| | | private String updateUser; |
| | | |
| | | @ApiModelProperty("租户id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @ApiModelProperty("保养进度描述") |
| | | private String maintenanceProcessDesc; |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | IPage<DeviceMaintenanceDto> queryPage(Page page, DeviceMaintenanceDto deviceMaintenanceDto); |
| | | |
| | | AjaxResult saveDeviceRepair(DeviceMaintenance deviceMaintenance); |
| | | AjaxResult saveDeviceRepair(DeviceMaintenanceDto deviceMaintenance); |
| | | |
| | | AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenance deviceMaintenance); |
| | | AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenanceDto deviceMaintenance); |
| | | |
| | | void export(HttpServletResponse response, Long[] ids); |
| | | |
| | |
| | | |
| | | IPage<DeviceRepairDto> queryPage(Page page, DeviceRepairDto deviceRepairDto); |
| | | |
| | | AjaxResult saveDeviceRepair(DeviceRepair deviceRepair); |
| | | AjaxResult saveDeviceRepair(DeviceRepairDto deviceRepair); |
| | | |
| | | AjaxResult updateDeviceRepair(DeviceRepair deviceRepair); |
| | | AjaxResult updateDeviceRepair(DeviceRepairDto deviceRepair); |
| | | |
| | | void export(HttpServletResponse response, Long[] ids); |
| | | |
| | |
| | | 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.DeviceMaintenanceDto; |
| | |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private DeviceMaintenanceMapper deviceMaintenanceMapper; |
| | | @Autowired |
| | | private StorageAttachmentService storageAttachmentService; |
| | | |
| | | @Override |
| | | public IPage<DeviceMaintenanceDto> queryPage(Page page, DeviceMaintenanceDto deviceMaintenanceDto) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult saveDeviceRepair(DeviceMaintenance deviceMaintenance) { |
| | | public AjaxResult saveDeviceRepair(DeviceMaintenanceDto deviceMaintenance) { |
| | | boolean save = this.save(deviceMaintenance); |
| | | storageAttachmentService.saveStorageAttachmentByStorageBlob(deviceMaintenance.getFiles(), |
| | | deviceMaintenance.getId(), StorageAttachmentRecordType.DeviceMaintenanceImage, |
| | | StorageAttachmentConstants.StorageAttachmentImage); |
| | | if (save){ |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenance deviceMaintenance) { |
| | | public AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenanceDto deviceMaintenance) { |
| | | if (this.updateById(deviceMaintenance)) { |
| | | storageAttachmentService.saveStorageAttachmentByStorageBlob(deviceMaintenance.getFiles(), |
| | | deviceMaintenance.getId(), StorageAttachmentRecordType.DeviceMaintenanceImage, |
| | | StorageAttachmentConstants.StorageAttachmentImage); |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | |
| | | |
| | | @Override |
| | | public DeviceMaintenanceDto detailById(Long id) { |
| | | |
| | | return deviceMaintenanceMapper.detailById(id); |
| | | DeviceMaintenanceDto deviceMaintenanceDto = deviceMaintenanceMapper.detailById(id); |
| | | List<StorageAttachment> storageAttachments = storageAttachmentService.selectStorageAttachments(id, StorageAttachmentRecordType.DeviceMaintenanceImage, |
| | | StorageAttachmentConstants.StorageAttachmentImage); |
| | | if (CollectionUtils.isNotEmpty(storageAttachments)) { |
| | | List<StorageBlobDTO> storageBlobs = storageAttachments.stream().map(StorageAttachment::getStorageBlobDTO).collect(Collectors.toList()); |
| | | deviceMaintenanceDto.setFiles(storageBlobs); |
| | | } |
| | | return deviceMaintenanceDto; |
| | | } |
| | | } |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.project.common;
|
| | |
|
| | | import java.io.File;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.ruoyi.basic.service.StorageBlobService;
|
| | | import com.ruoyi.framework.web.domain.R;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.http.MediaType;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.file.FileUploadUtils;
|
| | |
| | | import com.ruoyi.framework.config.RuoYiConfig;
|
| | | import com.ruoyi.framework.config.ServerConfig;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.http.MediaType;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * 通用请求处理
|
| | |
| | | */
|
| | | @PostMapping("/minioUploads")
|
| | | @ApiOperation(value = "minio通用上传请求")
|
| | | public AjaxResult minioUploadFiles(List<MultipartFile> files, String bucketName, Long type) throws Exception
|
| | | public AjaxResult minioUploadFiles(@RequestParam("file") MultipartFile file, @RequestParam("bucketName") String bucketName, @RequestParam("type") Long type) throws Exception
|
| | | {
|
| | | return AjaxResult.success(storageBlobService.updateStorageBlobs(files, bucketName,type));
|
| | | return AjaxResult.success(storageBlobService.updateStorageBlobs(new ArrayList<>(Arrays.asList(file)), bucketName,type));
|
| | | }
|
| | |
|
| | | /**
|