3 天以前 1a89a2eca92540f2a6e9ed5c140b00610f2f4bfc
src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
@@ -16,6 +16,10 @@
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;
@@ -72,12 +76,21 @@
    @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);
@@ -87,6 +100,10 @@
        }
        // 获取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());
        // 批量查询登记人
@@ -143,6 +160,7 @@
            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(","))
@@ -177,6 +195,14 @@
        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();
@@ -204,6 +230,12 @@
    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;