diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/controller/TaskTaskController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/controller/TaskTaskController.java index 82a2f6e..d52b703 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/controller/TaskTaskController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/controller/TaskTaskController.java @@ -39,7 +39,6 @@ import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -198,12 +197,12 @@ public class TaskTaskController extends JeecgController> queryByBusinessId(@RequestParam(name = "businessId", required = true) String businessId) throws Exception { - List taskTaskList = taskTaskService.getTaskTaskListByBusinessId(businessId); - if (CollectionUtils.isEmpty(taskTaskList)) { - return Result.error("未找到对应数据"); - } - return Result.OK(taskTaskList); + public Result> queryByBusinessId(@RequestParam(name = "businessId", required = true) String businessId, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) throws Exception { + Page page = new Page<>(pageNo, pageSize); + IPage pageList = taskTaskService.getTaskTaskPageByBusinessId(page, businessId); + return Result.OK(pageList); } /** diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/ITaskTaskService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/ITaskTaskService.java index 29ee58d..ad36ed7 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/ITaskTaskService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/ITaskTaskService.java @@ -2,10 +2,10 @@ package org.jeecg.modules.tasktask.service; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.tasktask.entity.TaskTask; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; -import java.util.List; - /** * @Description: 事项任务计划表(发起流程) * @Author: jeecg-boot @@ -16,7 +16,7 @@ public interface ITaskTaskService extends IService { boolean singleFlowStart(TaskTask taskTask,String userName) throws Exception; boolean multiFlowStart(TaskTask taskTask,String userName,Integer intervalType, Integer startCount) throws Exception; Result handleFlowStart(TaskTask taskTask, String username, Integer intervalType, Integer startCount)throws Exception; - List getTaskTaskListByBusinessId(String businessId) throws Exception; + IPage getTaskTaskPageByBusinessId(Page page, String businessId) throws Exception; boolean updateDeptHandlerName(String processInstanceId, String deptHandlerName); boolean deleteSingleProcess(String processInstId); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/impl/TaskTaskServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/impl/TaskTaskServiceImpl.java index 1178c96..918375c 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/impl/TaskTaskServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/service/impl/TaskTaskServiceImpl.java @@ -2,6 +2,8 @@ package org.jeecg.modules.tasktask.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.shiro.util.Assert; @@ -50,7 +52,8 @@ public class TaskTaskServiceImpl extends ServiceImpl i TaskTask newTask = new TaskTask(); BeanUtils.copyProperties(taskTask, newTask); newTask.setId(null); - newTask.setStartTime(null); + // 立即发起流程以实际发起时刻为准,避免流程记录缺少开始时间。 + newTask.setStartTime(new Date()); this.save(newTask); Result res = bpmBaseExtApiImpl.startMutilProcess(taskTask.getFlowCode(), newTask.getId(), taskTask.getFormUrl(), taskTask.getFormUrl(), userName, jsonString); String procId = res.getResult(); @@ -140,14 +143,17 @@ public class TaskTaskServiceImpl extends ServiceImpl i return Result.ok(); } - public List getTaskTaskListByBusinessId(String businessId) throws Exception{ + @Override + public IPage getTaskTaskPageByBusinessId(Page page, String businessId) throws Exception{ if (StringUtils.isBlank(businessId)) { - return Collections.emptyList(); + return page; } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(TaskTask::getBusinessId, businessId); - // 2. 查询不到数据 → MP 本身会返回空集合,不是 null - return this.list(queryWrapper); + queryWrapper.eq(TaskTask::getBusinessId, businessId) + // Show the latest started or created process first for the current business. + .orderByDesc(TaskTask::getStartTime) + .orderByDesc(TaskTask::getCreateTime); + return this.page(page, queryWrapper); } @Override