1.添加工作流相关依赖
业务的api工程添加工作流相关依赖
package pro.shushi.pamirs.demo.api;
import org.springframework.stereotype.Component;
import pro.shushi.pamirs.core.common.CommonModule;
import pro.shushi.pamirs.file.api.FileModule;
import pro.shushi.pamirs.meta.annotation.Module;
import pro.shushi.pamirs.meta.base.PamirsModule;
import pro.shushi.pamirs.meta.common.constants.ModuleConstants;
import pro.shushi.pamirs.user.api.UserModule;
import pro.shushi.pamirs.workflow.app.api.WorkflowModule;
@Component
@Module(
name = DemoModule.MODULE_NAME,
displayName = "oinoneDemo工程",
version = "1.0.0",
priority = 1,
dependencies = {ModuleConstants.MODULE_BASE,
CommonModule.MODULE_MODULE,
UserModule.MODULE_MODULE,
// 此处新增工作流依赖
WorkflowModule.MODULE_MODULE,
FileModule.MODULE_MODULE
}
)
@Module.module(DemoModule.MODULE_MODULE)
@Module.Advanced(selfBuilt = true, application = true)
public class DemoModule implements PamirsModule {
public static final String MODULE_MODULE = "demo_core";
public static final String MODULE_NAME = "DemoCore";
@Override
public String[] packagePrefix() {
return new String[]{
"pro.shushi.pamirs.demo"
};
}
}
业务的core工程添加工作流相关依赖
<dependency>
<groupId>pro.shushi.pamirs.workflow</groupId>
<artifactId>pamirs-workflow-api</artifactId>
</dependency>
<dependency>
<groupId>pro.shushi.pamirs.workflow</groupId>
<artifactId>pamirs-workflow-core</artifactId>
</dependency>
2.自定义action动作,在一个动作内分别执行工作流应用自带的加签和审核同意动作
package pro.shushi.pamirs.demo.core.action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import pro.shushi.pamirs.meta.annotation.Action;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.enmu.ActionContextTypeEnum;
import pro.shushi.pamirs.meta.enmu.ViewTypeEnum;
import pro.shushi.pamirs.workflow.app.api.model.WorkflowTaskInstance;
import pro.shushi.pamirs.workflow.app.api.model.WorkflowUserTask;
import pro.shushi.pamirs.workflow.app.core.action.WorkflowUserTaskAction;
import pro.shushi.pamirs.framework.common.utils.ObjectUtils;
@Component
@Model.model(WorkflowUserTask.MODEL_MODEL)
public class DemoWorkflowUserTaskAction {
@Autowired
private WorkflowUserTaskAction workflowUserTaskAction;
@Transactional(rollbackFor = {Exception.class})
@Action(displayName = "加签并审核同意", bindingType = ViewTypeEnum.FORM, contextType = ActionContextTypeEnum.SINGLE)
public WorkflowUserTask approveAddsignAgree(WorkflowUserTask workflowUserTask) throws Throwable {
WorkflowUserTask addsignRes = workflowUserTaskAction.approveAddsign(ObjectUtils.clone(workflowUserTask));
WorkflowTaskInstance updateTaskInstance = new WorkflowTaskInstance();
updateTaskInstance.setId(addsignRes.getTaskId());
updateTaskInstance.setLocked(false);
updateTaskInstance.updateById();
WorkflowUserTask res = workflowUserTaskAction.approveAgree(ObjectUtils.clone(workflowUserTask));
return res;
}
}
3.自定义加签的view视图文件workflow_signature_form.xml
,放到src/resources目录下,从数据库复制出工作流加签页面原有的视图,将里面的加签动作替换为上面自定义的新动作approveAddsignAgree
<view widget="form">
<template slot="actions">
<action name="internalGotoListTableRouter" priority="0" label="返回" actionType="CLIENT" fun="$$internal_GotoListTableRouter" type="default"/>
<action name="approveAddsignAgree" widget="FlowTaskCommonAction" priority="15" label="加签" model="workflow.WorkflowUserTask" displayName="加签" goBack="true" validateForm="true"/>
</template>
<template slot="fields">
<field name="id" invisible="true" priority="0" model="workflow.WorkflowUserTask" data="id"/>
<field name="filterAddSign" invisible="true" priority="1" model="workflow.WorkflowUserTask" data="filterAddSign"/>
<field name="userId" invisible="true" priority="2" model="workflow.WorkflowUserTask" data="userId"/>
<field name="addSignUser" widget="Select" invisible="true" priority="3" model="workflow.WorkflowUserTask" data="addSignUser" required="true" domain="${activeRecord.filterAddSign} and bindingUserId!= ${activeRecord.userId}" displayName="选择加签用户" renderOnParent="false"/>
<field name="deadline" invisible="$!{activeRecord.deadline}" priority="4" model="workflow.WorkflowUserTask" data="deadline" label="截止时间" disabled="true"/>
<field name="remark" invisible="true" priority="5" model="workflow.WorkflowUserTask" data="remark" displayName="加签备注"/>
<field name="taskType" invisible="true" priority="6" model="workflow.WorkflowUserTask" data="taskType"/>
<field name="selectType" widget="WorkflowPersonTypeSelect" priority="7" model="workflow.WorkflowUserTask" data="selectType" label="加签人类型" required="true" personField="addSignPerson"/>
<field name="addSignPerson" widget="Select" invisible="true" priority="8" model="workflow.WorkflowUserTask" data="addSignPerson" optionFields="id,name,type"/>
<field name="addSignInfo" widget="WorkflowNodePersonSelect" priority="9" model="workflow.WorkflowUserTask" data="addSignInfo" label="选择加签人" required="true" personField="addSignPerson"/>
<pack widget="group" title="" cols="2">
<field span="2" name="remark" widget="TextArea" priority="0" model="workflow.WorkflowUserTask" data="remark" label="加签意见"/>
<field span="1" name="pics" widget="UploadImg" invisible="activeRecord.attachments && activeRecord.attachments.length" priority="1" model="workflow.WorkflowUserTask" data="pics" label="图片"/>
<field span="1" name="attachments" widget="WorkflowO2MUpload" invisible="activeRecord.pics && activeRecord.pics.length" priority="2" model="workflow.WorkflowUserTask" data="attachments" label="附件"/>
</pack>
<field name="status" invisible="true" priority="11" model="workflow.WorkflowUserTask" data="status"/>
<field name="allowAddSign" invisible="true" priority="12" model="workflow.WorkflowUserTask" data="allowAddSign"/>
<field name="allowTransfer" invisible="true" priority="13" model="workflow.WorkflowUserTask" data="allowTransfer"/>
</template>
</view>
4.在业务工程启动生命周期内更新加签的自定义视图
package pro.shushi.pamirs.demo.core.init;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import pro.shushi.pamirs.boot.common.api.command.AppLifecycleCommand;
import pro.shushi.pamirs.boot.common.extend.MetaDataEditor;
import pro.shushi.pamirs.core.common.InitializationUtil;
import pro.shushi.pamirs.demo.api.DemoModule;
import pro.shushi.pamirs.meta.annotation.fun.extern.Slf4j;
import pro.shushi.pamirs.meta.api.dto.meta.Meta;
import pro.shushi.pamirs.meta.enmu.ViewTypeEnum;
import pro.shushi.pamirs.workflow.app.api.model.WorkflowUserTask;
import java.util.Map;
@Slf4j
@Component
@Order(Ordered.LOWEST_PRECEDENCE)
public class DemoModuleCustomWorkflowInstall implements MetaDataEditor {
@Override
public void edit(AppLifecycleCommand command, Map<String, Meta> metaMap) {
InitializationUtil util = InitializationUtil.get(metaMap, DemoModule.MODULE_MODULE, DemoModule.MODULE_NAME);
if (util != null) {
util.createView(WorkflowUserTask.MODEL_MODEL, "审批加签", "工作流审批加签_workflow", "file:pamirs/workflow_signature_form.xml", ViewTypeEnum.FORM, 10, false);
}
}
}
Oinone社区 作者:nation原创文章,如若转载,请注明出处:https://doc.oinone.top/workflow/13505.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验