| | |
| | | import com.ruoyi.device.dto.DeviceMaintenanceDto; |
| | | import com.ruoyi.device.execl.DeviceMaintenanceExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceMaintenanceMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private DeviceMaintenanceMapper deviceMaintenanceMapper; |
| | | |
| | | @Autowired |
| | | private IDeviceLedgerService deviceLedgerService; |
| | | |
| | | @Override |
| | | public IPage<DeviceMaintenanceDto> queryPage(Page page, DeviceMaintenanceDto deviceMaintenanceDto) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult batchSaveDeviceRepair(DeviceMaintenance deviceMaintenance) { |
| | | List<Long> deviceIds = deviceMaintenance.getDeviceIds(); |
| | | List<DeviceMaintenance> list = new ArrayList<>(); |
| | | for (Long deviceId : deviceIds) { |
| | | DeviceLedger ledger = deviceLedgerService.getById(deviceId); |
| | | if (ledger == null) { |
| | | continue; |
| | | } |
| | | DeviceMaintenance m = new DeviceMaintenance(); |
| | | m.setDeviceLedgerId(deviceId); |
| | | m.setDeviceName(ledger.getDeviceName()); |
| | | m.setDeviceModel(ledger.getDeviceModel()); |
| | | m.setMaintenancePlanTime(deviceMaintenance.getMaintenancePlanTime()); |
| | | m.setMaintenanceItem(deviceMaintenance.getMaintenanceItem()); |
| | | m.setCreateUser(deviceMaintenance.getCreateUser()); |
| | | m.setStatus(0); |
| | | list.add(m); |
| | | } |
| | | if (list.isEmpty()) { |
| | | return AjaxResult.error("未找到有效设备"); |
| | | } |
| | | return this.saveBatch(list) ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenance deviceMaintenance) { |
| | | 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); |