| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.StorageBlobVO; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.safe.pojo.SafeFacilityInspection; |
| | | import com.ruoyi.safe.pojo.SafeFacilityLedger; |
| | | import com.ruoyi.safe.pojo.SafeFacilityRectification; |
| | | import com.ruoyi.safe.mapper.SafeFacilityRectificationMapper; |
| | | import com.ruoyi.safe.service.SafeFacilityInspectionService; |
| | | import com.ruoyi.safe.service.SafeFacilityLedgerService; |
| | | import com.ruoyi.safe.service.SafeFacilityRectificationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | @Autowired |
| | | private SafeFacilityLedgerService safeFacilityLedgerService; |
| | | @Autowired |
| | | private SafeFacilityInspectionService safeFacilityInspectionService; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | @Autowired |
| | | private FileUtil fileUtil; |
| | | |
| | | @Override |
| | | public SafeFacilityRectification getById(Serializable id) { |
| | |
| | | return; |
| | | } |
| | | |
| | | // 收集设施ID |
| | | List<Integer> facilityIds = records.stream() |
| | | .map(SafeFacilityRectification::getFacilityId) |
| | | List<Integer> inspectionIds = records.stream() |
| | | .map(SafeFacilityRectification::getInspectionId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | Map<Integer, SafeFacilityInspection> inspectionMap = inspectionIds.isEmpty() ? Collections.emptyMap() |
| | | : safeFacilityInspectionService.listByIds(inspectionIds).stream() |
| | | .collect(Collectors.toMap(SafeFacilityInspection::getId, inspection -> inspection, (v1, v2) -> v1)); |
| | | |
| | | // 收集设施ID |
| | | Set<Integer> facilityIdSet = records.stream() |
| | | .map(SafeFacilityRectification::getFacilityId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | inspectionMap.values().stream() |
| | | .map(SafeFacilityInspection::getFacilityId) |
| | | .filter(Objects::nonNull) |
| | | .forEach(facilityIdSet::add); |
| | | List<Integer> facilityIds = new ArrayList<>(facilityIdSet); |
| | | |
| | | // 收集所有用户ID(整改责任人 + 验收人) |
| | | Set<Long> userIds = new HashSet<>(); |
| | |
| | | .collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName, (v1, v2) -> v1)); |
| | | |
| | | for (SafeFacilityRectification record : records) { |
| | | SafeFacilityInspection inspection = record.getInspectionId() == null ? null : inspectionMap.get(record.getInspectionId()); |
| | | if (inspection != null) { |
| | | record.setInspectionCode(inspection.getInspectionCode()); |
| | | if (record.getFacilityId() == null) { |
| | | record.setFacilityId(inspection.getFacilityId()); |
| | | } |
| | | List<StorageBlobVO> attachments = fileUtil.getStorageBlobVOsByRecordTypeAndRecordId( |
| | | RecordTypeEnum.SAFE_FACILITY_INSPECTION, |
| | | inspection.getId().longValue() |
| | | ); |
| | | record.setStorageBlobVOs(attachments == null ? Collections.emptyList() : attachments); |
| | | } |
| | | if (record.getFacilityId() != null) { |
| | | SafeFacilityLedger facility = facilityMap.get(record.getFacilityId()); |
| | | if (facility != null) { |
| | | record.setFacilityName(facility.getFacilityName()); |
| | | record.setFacilityCode(facility.getFacilityCode()); |
| | | } |
| | | } |
| | | if (record.getRectifyUserId() != null) { |
| | |
| | | entity.setActualTime(LocalDateTime.now()); |
| | | } |
| | | if ("已验收".equals(entity.getStatus())) { |
| | | if (entity.getVerifyUserId() == null) { |
| | | entity.setVerifyUserId(currentUserId.intValue()); |
| | | } |
| | | entity.setVerifyTime(LocalDateTime.now()); |
| | | } |
| | | return super.updateById(entity); |