| | |
| | | import com.ruoyi.device.execl.DeviceMaintenanceExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceMaintenanceMapper; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.service.DeviceMaintenanceFileService; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | @Autowired |
| | | private DeviceMaintenanceMapper deviceMaintenanceMapper; |
| | | |
| | | @Autowired |
| | | private DeviceMaintenanceFileService deviceMaintenanceFileService; |
| | | |
| | | @Override |
| | | public IPage<DeviceMaintenanceDto> queryPage(Page page, DeviceMaintenanceDto deviceMaintenanceDto) { |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult saveDeviceRepair(DeviceMaintenance deviceMaintenance) { |
| | | // 先保存设备保养记录 |
| | | boolean save = this.save(deviceMaintenance); |
| | | if (save){ |
| | | return AjaxResult.success(); |
| | | if (!save) { |
| | | return AjaxResult.error("保存失败"); |
| | | } |
| | | return AjaxResult.error(); |
| | | |
| | | // 处理临时文件关联 |
| | | if (deviceMaintenance.getTempFileIds() != null && !deviceMaintenance.getTempFileIds().isEmpty()) { |
| | | for (String tempId : deviceMaintenance.getTempFileIds()) { |
| | | try { |
| | | deviceMaintenanceFileService.bindFromTemp(tempId, deviceMaintenance.getId().intValue(), null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("关联临时文件失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return AjaxResult.success(deviceMaintenance); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenance deviceMaintenance) { |
| | | // 处理临时文件关联 |
| | | if (deviceMaintenance.getTempFileIds() != null && !deviceMaintenance.getTempFileIds().isEmpty()) { |
| | | for (String tempId : deviceMaintenance.getTempFileIds()) { |
| | | try { |
| | | deviceMaintenanceFileService.bindFromTemp(tempId, deviceMaintenance.getId().intValue(), null); |
| | | } catch (Exception e) { |
| | | return AjaxResult.error("关联临时文件失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (this.updateById(deviceMaintenance)) { |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response, Long[] ids) { |
| | | ArrayList<Long> arrayList = new ArrayList<>(); |
| | | Arrays.stream(ids).map(id -> { |
| | | return arrayList.add( id); |
| | | }); |
| | | List<DeviceMaintenance> supplierManageList = deviceMaintenanceMapper.selectBatchIds(arrayList); |
| | | List<DeviceMaintenance> supplierManageList = deviceMaintenanceMapper.selectList(null); |
| | | ArrayList<DeviceMaintenanceExeclDto> deviceLedgerExeclDtos = new ArrayList<>(); |
| | | supplierManageList.stream().forEach(deviceMaintenance -> { |
| | | supplierManageList.forEach(deviceMaintenance -> { |
| | | DeviceMaintenanceExeclDto deviceRepairExeclDto = new DeviceMaintenanceExeclDto(); |
| | | BeanUtils.copyProperties(deviceMaintenance,deviceRepairExeclDto); |
| | | deviceRepairExeclDto.setStatus(deviceMaintenance.getStatus() == 0 ? "待维修" : "完结"); |
| | | deviceRepairExeclDto.setMaintenanceResult(deviceMaintenance.getMaintenanceResult() == 0 ? "维修" : "完好"); |
| | | |
| | | deviceRepairExeclDto.setStatus(deviceMaintenance.getStatus() == 0 ? "待维修" : deviceMaintenance.getStatus() == 1 ? "完结" : "失败"); |
| | | // deviceRepairExeclDto.setMaintenanceResult(deviceMaintenance.getMaintenanceResult() != null && deviceMaintenance.getMaintenanceResult() == 0 ? "维修" : "完好"); |
| | | deviceLedgerExeclDtos.add(deviceRepairExeclDto); |
| | | }); |
| | | ExcelUtil<DeviceMaintenanceExeclDto> util = new ExcelUtil<DeviceMaintenanceExeclDto>(DeviceMaintenanceExeclDto.class); |