| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | private LambdaQueryWrapper<ArchiveRecords> buildCondition(ArchiveRecords archiveRecords, Long userId){ |
| | | LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>(); |
| | | |
| | | // 根据开始和结束的categoryNumber生成连续的recordId |
| | | String categoryNumberStart = archiveRecords.getCategoryNumberStart(); |
| | | String categoryNumberEnd = archiveRecords.getCategoryNumberEnd(); |
| | | |
| | | if (!StringUtils.isEmpty(categoryNumberStart) && !StringUtils.isEmpty(categoryNumberEnd)) { |
| | | try { |
| | | // 解析开始和结束的编号,提取前缀和数字部分 |
| | | // 例如:B1.3-999-2024-1 -> 前缀: B1.3-999-2024-, 数字: 1 |
| | | int lastDashIndexStart = categoryNumberStart.lastIndexOf('-'); |
| | | int lastDashIndexEnd = categoryNumberEnd.lastIndexOf('-'); |
| | | |
| | | if (lastDashIndexStart > 0 && lastDashIndexEnd > 0) { |
| | | String prefixStart = categoryNumberStart.substring(0, lastDashIndexStart + 1); |
| | | String prefixEnd = categoryNumberEnd.substring(0, lastDashIndexEnd + 1); |
| | | |
| | | // 确保前缀相同,才生成连续编号 |
| | | if (prefixStart.equals(prefixEnd)) { |
| | | int startNum = Integer.parseInt(categoryNumberStart.substring(lastDashIndexStart + 1)); |
| | | int endNum = Integer.parseInt(categoryNumberEnd.substring(lastDashIndexEnd + 1)); |
| | | |
| | | // 生成连续的recordId列表,将数字格式化为5位(如00001, 00101) |
| | | List<String> recordIds = new ArrayList<>(); |
| | | for (int i = startNum; i <= endNum; i++) { |
| | | // 使用String.format将数字格式化为5位,不足前面补0 |
| | | String formattedNumber = String.format("%05d", i); |
| | | recordIds.add(prefixStart + formattedNumber); |
| | | } |
| | | |
| | | // 添加到查询条件中 |
| | | lqw.in(ArchiveRecords::getRecordId, recordIds); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | // 如果解析失败,忽略此条件 |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | System.out.println(archiveRecords.getIds()); |
| | | |
| | | lqw.like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getInquiryNumber()), ArchiveRecords::getInquiryNumber, archiveRecords.getInquiryNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getCaseTitle()), ArchiveRecords::getCaseTitle, archiveRecords.getCaseTitle()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getPreparationUnit()), ArchiveRecords::getPreparationUnit, archiveRecords.getPreparationUnit()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getRetentionPeriod()), ArchiveRecords::getRetentionPeriod, archiveRecords.getRetentionPeriod()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getSecurityClassification()), ArchiveRecords::getSecurityClassification, archiveRecords.getSecurityClassification()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getConstructionUnit()), ArchiveRecords::getConstructionUnit, archiveRecords.getConstructionUnit()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getConstructionAddress()), ArchiveRecords::getConstructionAddress, archiveRecords.getConstructionAddress()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getProjectName()), ArchiveRecords::getProjectName, archiveRecords.getProjectName()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getProjectNumber()), ArchiveRecords::getProjectNumber, archiveRecords.getProjectNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getScanningCompany()), ArchiveRecords::getScanningCompany, archiveRecords.getScanningCompany()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getArchiveRoomNumber()), ArchiveRecords::getArchiveRoomNumber, archiveRecords.getArchiveRoomNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getMicrofilmNumber()), ArchiveRecords::getMicrofilmNumber, archiveRecords.getMicrofilmNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getHistoricalReferenceNumber()), ArchiveRecords::getHistoricalReferenceNumber, archiveRecords.getHistoricalReferenceNumber()) |
| | | .eq(!StringUtils.isEmpty(archiveRecords.getRecordStatus()), ArchiveRecords::getRecordStatus, archiveRecords.getRecordStatus()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getEveryProjectName()), ArchiveRecords::getEveryProjectName, archiveRecords.getEveryProjectName()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getRemarks()), ArchiveRecords::getRemarks, archiveRecords.getRemarks()); |
| | | // 如果没有使用连续编号条件,才使用普通的like条件 |
| | | if (StringUtils.isEmpty(categoryNumberStart) || StringUtils.isEmpty(categoryNumberEnd)) { |
| | | lqw.like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId()); |
| | | } |
| | | else { |
| | | lqw. |
| | | like(!StringUtils.isEmpty(archiveRecords.getInquiryNumber()), ArchiveRecords::getInquiryNumber, archiveRecords.getInquiryNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getCaseTitle()), ArchiveRecords::getCaseTitle, archiveRecords.getCaseTitle()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getPreparationUnit()), ArchiveRecords::getPreparationUnit, archiveRecords.getPreparationUnit()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getRetentionPeriod()), ArchiveRecords::getRetentionPeriod, archiveRecords.getRetentionPeriod()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getSecurityClassification()), ArchiveRecords::getSecurityClassification, archiveRecords.getSecurityClassification()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getConstructionUnit()), ArchiveRecords::getConstructionUnit, archiveRecords.getConstructionUnit()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getConstructionAddress()), ArchiveRecords::getConstructionAddress, archiveRecords.getConstructionAddress()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getProjectName()), ArchiveRecords::getProjectName, archiveRecords.getProjectName()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getProjectNumber()), ArchiveRecords::getProjectNumber, archiveRecords.getProjectNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getScanningCompany()), ArchiveRecords::getScanningCompany, archiveRecords.getScanningCompany()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getArchiveRoomNumber()), ArchiveRecords::getArchiveRoomNumber, archiveRecords.getArchiveRoomNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getMicrofilmNumber()), ArchiveRecords::getMicrofilmNumber, archiveRecords.getMicrofilmNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getHistoricalReferenceNumber()), ArchiveRecords::getHistoricalReferenceNumber, archiveRecords.getHistoricalReferenceNumber()) |
| | | .eq(!StringUtils.isEmpty(archiveRecords.getRecordStatus()), ArchiveRecords::getRecordStatus, archiveRecords.getRecordStatus()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getEveryProjectName()), ArchiveRecords::getEveryProjectName, archiveRecords.getEveryProjectName()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getRemarks()), ArchiveRecords::getRemarks, archiveRecords.getRemarks()); |
| | | |
| | | |
| | | } |
| | | |
| | | if(archiveRecords.getIds()!=null) |
| | | lqw.in(ArchiveRecords::getId,new ArrayList<>(Arrays.asList(archiveRecords.getIds()))); |