| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.device.mapper.DeviceAreaMapper; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceArea; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.inspectiontask.dto.InspectionTaskDto; |
| | | import com.ruoyi.inspectiontask.mapper.InspectionTaskMapper; |
| | | import com.ruoyi.inspectiontask.pojo.InspectionTask; |
| | |
| | | @Autowired |
| | | private CommonFileServiceImpl commonFileService; |
| | | |
| | | @Autowired |
| | | private DeviceLedgerMapper deviceLedgerMapper; |
| | | |
| | | @Autowired |
| | | private DeviceAreaMapper deviceAreaMapper; |
| | | |
| | | @Override |
| | | public IPage<InspectionTaskDto> selectInspectionTaskList(Page<InspectionTask> page, InspectionTaskDto inspectionTaskDto) { |
| | | LambdaQueryWrapper<InspectionTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(InspectionTask::getCreateTime); |
| | | if (StringUtils.isNotBlank(inspectionTaskDto.getTaskName())) { |
| | | queryWrapper.like(InspectionTask::getTaskName, inspectionTaskDto.getTaskName()); |
| | | } |
| | | if (inspectionTaskDto.getAreaId() != null) { |
| | | queryWrapper.eq(InspectionTask::getAreaId, inspectionTaskDto.getAreaId()); |
| | | } |
| | | IPage<InspectionTask> entityPage = inspectionTaskMapper.selectPage(page, queryWrapper); |
| | | |
| | |
| | | } |
| | | // 获取id集合 |
| | | List<Long> ids = entityPage.getRecords().stream().map(InspectionTask::getId).collect(Collectors.toList()); |
| | | Map<Long, String> areaNameMap = buildAreaNameMap(entityPage.getRecords().stream() |
| | | .map(InspectionTask::getAreaId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet())); |
| | | //登记人ids |
| | | List<Long> registrantIds = entityPage.getRecords().stream().map(InspectionTask::getRegistrantId).collect(Collectors.toList()); |
| | | // 批量查询登记人 |
| | |
| | | if (sysUser != null) { |
| | | dto.setRegistrant(sysUser.getNickName()); |
| | | } |
| | | dto.setAreaName(areaNameMap.get(inspectionTask.getAreaId())); |
| | | // 处理巡检人名称 |
| | | if (StringUtils.isNotBlank(inspectionTask.getInspectorId())) { |
| | | String inspectorNames = Arrays.stream(inspectionTask.getInspectorId().split(",")) |
| | |
| | | return resultPage; |
| | | } |
| | | |
| | | private Map<Long, String> buildAreaNameMap(Set<Long> areaIds) { |
| | | if (areaIds == null || areaIds.isEmpty()) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | return deviceAreaMapper.selectBatchIds(new ArrayList<>(areaIds)).stream() |
| | | .collect(Collectors.toMap(DeviceArea::getId, DeviceArea::getAreaName, (left, right) -> left)); |
| | | } |
| | | |
| | | // 提取创建BlobDTO的公共方法 |
| | | private StorageBlobDTO createBlobDto(StorageBlob blob) { |
| | | StorageBlobDTO dto = new StorageBlobDTO(); |
| | |
| | | public int addOrEditInspectionTask(InspectionTaskDto inspectionTaskDto) throws IOException { |
| | | InspectionTask inspectionTask = new InspectionTask(); |
| | | BeanUtils.copyProperties(inspectionTaskDto, inspectionTask); |
| | | if (inspectionTask.getAreaId() == null && inspectionTask.getTaskId() != null) { |
| | | DeviceLedger deviceLedger = deviceLedgerMapper.selectById(Long.valueOf(inspectionTask.getTaskId())); |
| | | if (deviceLedger != null) { |
| | | inspectionTask.setAreaId(deviceLedger.getAreaId()); |
| | | } |
| | | } |
| | | inspectionTask.setRegistrantId(SecurityUtils.getLoginUser().getUserId()); |
| | | inspectionTask.setRegistrant(SecurityUtils.getLoginUser().getUsername()); |
| | | int i; |