package jnpf.dmsController; import cn.dev33.satoken.annotation.SaCheckLogin; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import jnpf.base.ActionResult; import jnpf.dmsEntity.wenjianbianhao.form.DmsFlowEventForm; import jnpf.dmsService.DmsWenjianBanbenService; import jnpf.exception.DataException; import jnpf.flowable.WorkFlowApi; import jnpf.flowable.entity.TaskEntity; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @Tag(name = "DMS文件版本控制接口") @RestController @SaCheckLogin @RequiredArgsConstructor @RequestMapping("/biz/wenjian/banben") public class DmsWenjianBanbenController { private final DmsWenjianBanbenService service; private final WorkFlowApi workFlowApi; @Operation(summary = "同步文件新增审核流程事件") @PostMapping("/xinzeng-shenhe/flow-event") public ActionResult syncNewAuditFlowEvent( @Valid @RequestBody DmsFlowEventForm form) throws DataException { service.syncNewAuditFlow(form.getFlowId(), form.getTaskId(), requireWorkflowState(form.getTaskId()), form.getEventType()); return ActionResult.success("文件新增审核版本同步成功", "文件新增审核版本同步成功"); } @Operation(summary = "同步文件修订审核流程事件") @PostMapping("/xiuding-shenhe/flow-event") public ActionResult syncRevisionAuditFlowEvent( @Valid @RequestBody DmsFlowEventForm form) throws DataException { service.syncRevisionAuditFlow(form.getFlowId(), form.getTaskId(), requireWorkflowState(form.getTaskId()), form.getEventType()); return ActionResult.success("文件修订审核版本同步成功", "文件修订审核版本同步成功"); } private Integer requireWorkflowState(String taskId) throws DataException { TaskEntity task = workFlowApi.getInfoSubmit(taskId.trim()); if (task == null || task.getId() == null) { throw new DataException("未找到流程任务:" + taskId); } if (!taskId.trim().equals(task.getId())) { throw new DataException("流程任务与传入任务ID不匹配"); } if (task.getStatus() == null) { throw new DataException("流程任务状态为空:" + taskId); } return task.getStatus(); } }