diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/turnover/TurnOverController.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/turnover/TurnOverController.java index 9e239976..c22e83b3 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/turnover/TurnOverController.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/turnover/TurnOverController.java @@ -4,7 +4,9 @@ import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO; import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; import org.springframework.web.bind.annotation.*; + import javax.annotation.Resource; + import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; import io.swagger.v3.oas.annotations.tags.Tag; @@ -19,11 +21,13 @@ import java.io.IOException; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; + import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; import cn.iocoder.yudao.module.archives.controller.admin.turnover.vo.*; @@ -93,23 +97,23 @@ public class TurnOverController { List list = pageResult.getList(); if (CollUtil.isNotEmpty(list)) { for (TurnOverDO t : list) { - List taskListByProcessInstanceId = taskService.getTaskListByProcessInstanceId(t.getProcessInstanceId()); - Optional latestTask = taskListByProcessInstanceId.stream() - .filter(task -> task.getEndTime() != null) - .sorted(Comparator.comparing(BpmTaskRespVO::getEndTime).reversed()) - .findFirst(); - - if (latestTask.isPresent()) { - BpmTaskRespVO latest = latestTask.get(); - // 找到了endTime最新的任务 - TurnOverUpdateReqVO updateReqVO = new TurnOverUpdateReqVO(); - updateReqVO.setId(t.getId()); - if (!latest.getResult().toString().equals(t.getStatus())) { - updateReqVO.setStatus(latest.getResult().toString()); - turnOverService.updateTurnOver(updateReqVO); + if (t.getProcessInstanceId() != null) { + List taskListByProcessInstanceId = taskService.getTaskListByProcessInstanceId(t.getProcessInstanceId()); + Optional latestTask = taskListByProcessInstanceId.stream() + .filter(task -> task.getEndTime() != null) + .sorted(Comparator.comparing(BpmTaskRespVO::getEndTime).reversed()) + .findFirst(); + + if (latestTask.isPresent()) { + BpmTaskRespVO latest = latestTask.get(); + // 找到了endTime最新的任务 + TurnOverUpdateReqVO updateReqVO = new TurnOverUpdateReqVO(); + updateReqVO.setId(t.getId()); + if (!latest.getResult().toString().equals(t.getStatus())) { + updateReqVO.setStatus(latest.getResult().toString()); + turnOverService.updateTurnOver(updateReqVO); + } } - } else { - // 没有找到有endTime的任务 } } PageResult pageResult2 = turnOverService.getTurnOverPage(pageVO); @@ -123,7 +127,7 @@ public class TurnOverController { @PreAuthorize("@ss.hasPermission('archives:turn-over:export')") @OperateLog(type = EXPORT) public void exportTurnOverExcel(@Valid TurnOverExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException { List list = turnOverService.getTurnOverList(exportReqVO); // 导出 Excel List datas = TurnOverConvert.INSTANCE.convertList02(list);