diff --git a/gather-app/src/main/java/com/ruoyi/common/utils/PageByList.java b/gather-app/src/main/java/com/ruoyi/common/utils/PageByList.java new file mode 100644 index 0000000..8e5d57d --- /dev/null +++ b/gather-app/src/main/java/com/ruoyi/common/utils/PageByList.java @@ -0,0 +1,40 @@ +package com.ruoyi.common.utils; + +import java.util.List; + +public class PageByList { + /** + * 开始分页 + * @param list 传入的list集合 + * @param pageNum 页码 + * @param pageSize 每页多少条数据 + * @return + */ + public static List startPage(List list, Integer pageNum, Integer pageSize) { + if (list == null) { + return null; + } + if (list.size() == 0) { + return null; + } + Integer count = list.size(); // 记录总数 + Integer pageCount = 0; // 页数 + if (count % pageSize == 0) { + pageCount = count / pageSize; + } else { + pageCount = count / pageSize + 1; + } + int fromIndex = 0; // 开始索引 + int toIndex = 0; // 结束索引 + if (pageNum != pageCount) { + fromIndex = (pageNum - 1) * pageSize; + toIndex = fromIndex + pageSize; + } else { + fromIndex = (pageNum - 1) * pageSize; + toIndex = count; + } + List pageList = list.subList(fromIndex, toIndex); + return pageList; + } +} + diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/DisposalInfoController.java b/gather-app/src/main/java/com/ruoyi/database/controller/DisposalInfoController.java index 7dd1359..12b9180 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/DisposalInfoController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/DisposalInfoController.java @@ -3,11 +3,15 @@ package com.ruoyi.database.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.github.pagehelper.PageInfo; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.PageByList; import com.ruoyi.common.utils.PageUtils; import com.ruoyi.database.domain.DevopsVideoStatus; import com.ruoyi.database.domain.DisposalInfo; @@ -38,10 +42,12 @@ public class DisposalInfoController extends BaseController { @GetMapping @ApiOperation("查询预警信息处置表") public TableDataInfo list(TransitHuntersUserModelRecord modelRecord) { - int count = transitHuntersUserModelRecordService.count(); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); +// int count = transitHuntersUserModelRecordService.count(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); - PageUtils.startPage(); QueryWrapper queryWrapper = new QueryWrapper<>(modelRecord); queryWrapper.orderByDesc("warning_time"); List list1 = transitHuntersUserModelRecordService.list(queryWrapper); @@ -78,19 +84,23 @@ public class DisposalInfoController extends BaseController { String warningTime = transitHuntersUserModelRecord.getWarningTime(); LocalDateTime localDateTime = LocalDateTime.parse(warningTime, inputFormatter); transitHuntersUserModelRecord.setWarningTime(localDateTime.format(formatter)); - if (modelRecord.getDisposalResultCn() != null && modelRecord.getDisposalResultCn().equals(transitHuntersUserModelRecord.getDisposalResultCn())) { + if (modelRecord.getSignStatusCn()!=null && modelRecord.getSignStatusCn().equals(transitHuntersUserModelRecord.getSignStatusCn())){ transitHuntersUserModelRecords.add(transitHuntersUserModelRecord); + continue; } - if (modelRecord.getSignStatusCn() != null && modelRecord.getSignStatusCn().equals(transitHuntersUserModelRecord.getSignStatusCn())){ + if (modelRecord.getDisposalResultCn()!=null && modelRecord.getDisposalResultCn().equals(transitHuntersUserModelRecord.getDisposalResultCn())){ transitHuntersUserModelRecords.add(transitHuntersUserModelRecord); + continue; } - if (modelRecord.getSignStatusCn() == null && modelRecord.getDisposalResultCn() == null){ + if ( modelRecord.getDisposalResultCn()==null && modelRecord.getSignStatusCn()==null ){ transitHuntersUserModelRecords.add(transitHuntersUserModelRecord); } } - TableDataInfo dataTable = getDataTable(transitHuntersUserModelRecords); - dataTable.setTotal(count); - return dataTable; + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(200); + rspData.setRows(PageByList.startPage(transitHuntersUserModelRecords, pageNum, pageSize)); + rspData.setTotal(new PageInfo(transitHuntersUserModelRecords).getTotal()); + return rspData; } @PostMapping