add 添加审批附件上传

This commit is contained in:
gssong 2024-02-25 22:07:01 +08:00
parent 714c87c259
commit 2551d16d08
3 changed files with 76 additions and 0 deletions

View File

@ -28,6 +28,11 @@ public class CompleteTaskBo implements Serializable {
@NotBlank(message = "任务id不能为空", groups = {AddGroup.class}) @NotBlank(message = "任务id不能为空", groups = {AddGroup.class})
private String taskId; private String taskId;
/**
* 附件id
*/
private String fileId;
/** /**
* 消息类型 * 消息类型
*/ */

View File

@ -0,0 +1,68 @@
package org.dromara.workflow.flowable.cmd;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.service.ISysOssService;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.persistence.entity.AttachmentEntity;
import org.flowable.engine.impl.persistence.entity.AttachmentEntityManager;
import org.flowable.engine.impl.util.CommandContextUtil;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* 串行加签
*
* @author 附件上传
*/
public class AttachmentCmd implements Command<Boolean> {
private final String fileId;
private final String taskId;
private final String processInstanceId;
public AttachmentCmd(String fileId, String taskId, String processInstanceId) {
this.fileId = fileId;
this.taskId = taskId;
this.processInstanceId = processInstanceId;
}
@Override
public Boolean execute(CommandContext commandContext) {
try {
if (StringUtils.isNotBlank(fileId)) {
List<Long> fileIds = StreamUtils.toList(Arrays.asList(fileId.split(StrUtil.COMMA)), Long::valueOf);
List<SysOssVo> sysOssVos = SpringUtils.getBean(ISysOssService.class).listByIds(fileIds);
if (CollUtil.isNotEmpty(sysOssVos)) {
for (SysOssVo sysOssVo : sysOssVos) {
AttachmentEntityManager attachmentEntityManager = CommandContextUtil.getAttachmentEntityManager();
AttachmentEntity attachmentEntity = attachmentEntityManager.create();
attachmentEntity.setRevision(1);
attachmentEntity.setUserId(LoginHelper.getUserId().toString());
attachmentEntity.setName(sysOssVo.getFileName());
attachmentEntity.setDescription(sysOssVo.getOriginalName());
attachmentEntity.setType(sysOssVo.getFileSuffix());
attachmentEntity.setTaskId(taskId);
attachmentEntity.setProcessInstanceId(processInstanceId);
attachmentEntity.setContentId(sysOssVo.getOssId().toString());
attachmentEntity.setTime(new Date());
attachmentEntityManager.insert(attachmentEntity);
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return true;
}
}

View File

@ -156,6 +156,9 @@ public class ActTaskServiceImpl implements IActTaskService {
taskService.complete(newTask.getId()); taskService.complete(newTask.getId());
return true; return true;
} }
//附件上传
AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId());
managementService.executeCommand(attachmentCmd);
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey()); FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey());
String businessStatus = WorkflowUtils.getBusinessStatus(task.getProcessInstanceId()); String businessStatus = WorkflowUtils.getBusinessStatus(task.getProcessInstanceId());
if (BusinessStatusEnum.DRAFT.getStatus().equals(businessStatus) || BusinessStatusEnum.BACK.getStatus().equals(businessStatus) || BusinessStatusEnum.CANCEL.getStatus().equals(businessStatus)) { if (BusinessStatusEnum.DRAFT.getStatus().equals(businessStatus) || BusinessStatusEnum.BACK.getStatus().equals(businessStatus) || BusinessStatusEnum.CANCEL.getStatus().equals(businessStatus)) {