update
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package com.blueland.bpm.engine.config.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.blueland.bpm.common.base.BaseIbatis3Dao;
|
||||
import com.blueland.bpm.engine.config.model.ActivityInfoConfig;
|
||||
|
||||
|
||||
@Repository
|
||||
public class ActivityInfoConfigDao extends BaseIbatis3Dao<ActivityInfoConfig,String>{
|
||||
|
||||
@Override
|
||||
public String getIbatisMapperNamesapce() {
|
||||
return "ActivityInfoConfig";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.blueland.bpm.engine.config.dao;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.blueland.bpm.common.base.BaseIbatis3Dao;
|
||||
import com.blueland.bpm.common.page.Page;
|
||||
import com.blueland.bpm.engine.config.model.ProcessInfoConfig;
|
||||
|
||||
|
||||
@Repository
|
||||
public class ProcessInfoConfigDao extends BaseIbatis3Dao<ProcessInfoConfig,String>{
|
||||
|
||||
@Override
|
||||
public String getIbatisMapperNamesapce() {
|
||||
return "ProcessInfoConfig";
|
||||
}
|
||||
public Page<List<ProcessInfoConfig>> findConfigPage(ProcessInfoConfig params){
|
||||
return pageQuery(getIbatisMapperNamesapce()+".findConfigPage",params);
|
||||
}
|
||||
/**
|
||||
* 获取所有满足要求的procDefId以供导出zip
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public List<String> getAllProcessIdForExport(ProcessInfoConfig params){
|
||||
return this.getSqlSessionTemplate().selectList(getIbatisMapperNamesapce()+".getAllProcessIdForExport",params);
|
||||
}
|
||||
public ProcessInfoConfig getLinkId(String processDefId){
|
||||
Map params=new HashMap();
|
||||
params.put("processDefId", processDefId);
|
||||
return this.getSqlSessionTemplate().selectOne(getIbatisMapperNamesapce()+".getLinkId", params);
|
||||
}
|
||||
|
||||
public Page<List<ProcessInfoConfig>> findConfigAndModelPage(ProcessInfoConfig params){
|
||||
return pageQuery(getIbatisMapperNamesapce()+".findConfigAndModelPage",params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
package com.blueland.bpm.engine.config.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.bpmn.model.CallActivity;
|
||||
import org.activiti.bpmn.model.ExclusiveGateway;
|
||||
import org.activiti.bpmn.model.FlowElement;
|
||||
import org.activiti.bpmn.model.ScriptTask;
|
||||
import org.activiti.bpmn.model.ServiceTask;
|
||||
import org.activiti.bpmn.model.UserTask;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import com.blueland.bpm.common.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @since
|
||||
*/
|
||||
|
||||
public class ActivityInfoConfig extends BaseEntity implements
|
||||
java.io.Serializable {
|
||||
private static final long serialVersionUID = 5454155825314635342L;
|
||||
|
||||
// date formats
|
||||
|
||||
// 可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
|
||||
// columns START
|
||||
/**
|
||||
* 流程环节定义ID db_column: ACTIVITY_DEF_ID
|
||||
*/
|
||||
@Length(max = 100)
|
||||
private String activityDefId;
|
||||
/**
|
||||
* 流程环节定义名称 db_column: ACTIVITY_DEF_NAME
|
||||
*/
|
||||
@Length(max = 100)
|
||||
private String activityDefName;
|
||||
/**
|
||||
* 流程环节状态名称(默认与环节名称一致) db_column: ACTIVITY_STATUS_NAME
|
||||
*/
|
||||
@Length(max = 100)
|
||||
private String activityStatusName;
|
||||
/**
|
||||
* 流程定义ID db_column: PROCESS_DEF_ID
|
||||
*/
|
||||
@Length(max = 100)
|
||||
private String processDefId;
|
||||
/**
|
||||
* 流程定义名称 db_column: PROCESS_DEF_NAME
|
||||
*/
|
||||
@Length(max = 100)
|
||||
private String processDefName;
|
||||
/**
|
||||
* 流程环节表单URL db_column: ACTIVITY_PAGE_URL
|
||||
*/
|
||||
@Length(max = 500)
|
||||
private String activityPageUrl;
|
||||
/**
|
||||
* 流程环节表单数据 db_column: ACTIVITY_PAGE_INFO
|
||||
*/
|
||||
@Length(max = 4000)
|
||||
private String activityPageInfo;
|
||||
/**
|
||||
* 流程环节绑定操作权限ID,多个权限ID以#号分隔 db_column: ACTIVITY_OPERATION_ROLEID
|
||||
*/
|
||||
@Length(max = 4000)
|
||||
private String activityOperationRoleid;
|
||||
/**
|
||||
* remark db_column: REMARK
|
||||
*/
|
||||
private List<ActivityOperatePower> activityOperatePowers;
|
||||
@Length(max = 500)
|
||||
private String remark;
|
||||
/**
|
||||
* 环节跳转类型,AUTO:自动路径跳转;MANUAL:人工选择跳转、FREE:自由选择跳转
|
||||
*/
|
||||
private String jumpType;
|
||||
/**
|
||||
* 环节跳转类型,AUTO:自动路径跳转;MANUAL:人工选择跳转、FREE:自由选择跳转
|
||||
*/
|
||||
private static final String JUMP_TYPE_AUTO = "AUTO";
|
||||
private static final String JUMP_TYPE_FREE = "FREE";
|
||||
private static final String JUMP_TYPE_MANUAL = "MANUAL";
|
||||
|
||||
private boolean autoJumpType;
|
||||
private boolean freeJumpType;
|
||||
/**
|
||||
* 环节排序
|
||||
*/
|
||||
private Integer activityOrder;
|
||||
/**
|
||||
* 环节时限
|
||||
*/
|
||||
private Integer activityLimitTime;
|
||||
/**
|
||||
* 是否显示意见输入区域,默认启用ENABLED,否则禁用DISABLE
|
||||
*/
|
||||
private String isShowIdea;
|
||||
/**
|
||||
* 意见分栏
|
||||
*/
|
||||
private String ideaDisplayArea;
|
||||
/**
|
||||
* 环节类型
|
||||
*/
|
||||
private String activityDefType;
|
||||
/**
|
||||
*环节处理类型,单人\多人
|
||||
*/
|
||||
private String activityDefDealType;
|
||||
/**
|
||||
* 环节子类型,through:流程贯穿,inside:内部流程
|
||||
*/
|
||||
private String activityDefChildType;
|
||||
/**
|
||||
* 其它系统处理状态 0 不可处理;1 仅阅读;2可处理
|
||||
*/
|
||||
private String otherSysDealStatus;
|
||||
/**
|
||||
* 是否是开始节点 是为Y 否为N
|
||||
*/
|
||||
private String isStartUserTask;
|
||||
|
||||
|
||||
public static String ACTIVITY_DEF_CHILD_TYPE_THROUGH="through";
|
||||
public static String ACTIVITY_DEF_CHILD_TYPE_INSIDE="inside";
|
||||
private String cprotocol;
|
||||
private String murl;
|
||||
private String mprotocol;
|
||||
private static Map activityDefTypeMap = new HashMap();
|
||||
static {
|
||||
activityDefTypeMap.put(BpmnXMLConstants.ELEMENT_TASK, "用户任务");
|
||||
activityDefTypeMap.put(BpmnXMLConstants.ELEMENT_TASK_SCRIPT, "脚本任务");
|
||||
activityDefTypeMap.put(BpmnXMLConstants.ELEMENT_TASK_SERVICE, "服务任务");
|
||||
activityDefTypeMap.put(BpmnXMLConstants.ELEMENT_CALL_ACTIVITY, "调用子流");
|
||||
}
|
||||
|
||||
private List<DataObject> dataObjects;
|
||||
|
||||
// columns END
|
||||
|
||||
public static ActivityInfoConfig build(FlowElement fowElement, String procDefId,
|
||||
String procDefName) {
|
||||
ActivityInfoConfig actInfoConfig = new ActivityInfoConfig();
|
||||
actInfoConfig.setProcessDefId(procDefId);
|
||||
actInfoConfig.setProcessDefName(procDefName);
|
||||
actInfoConfig.setActivityDefId(fowElement.getId());
|
||||
actInfoConfig.setActivityDefName(fowElement.getName());
|
||||
if (UserTask.class.isInstance(fowElement)) {
|
||||
actInfoConfig.setJumpType("MANUAL");
|
||||
actInfoConfig.setActivityDefType(BpmnXMLConstants.ELEMENT_TASK_USER);
|
||||
} else if (ScriptTask.class.isInstance(fowElement)) {
|
||||
actInfoConfig.setJumpType("AUTO");
|
||||
actInfoConfig
|
||||
.setActivityDefType(BpmnXMLConstants.ELEMENT_TASK_SCRIPT);
|
||||
} else if (ServiceTask.class.isInstance(fowElement)) {
|
||||
actInfoConfig.setJumpType("AUTO");
|
||||
actInfoConfig
|
||||
.setActivityDefType(BpmnXMLConstants.ELEMENT_TASK_SERVICE);
|
||||
} else if (ExclusiveGateway.class.isInstance(fowElement)) {
|
||||
actInfoConfig.setJumpType("AUTO");
|
||||
actInfoConfig.setActivityDefType(BpmnXMLConstants.ELEMENT_GATEWAY_EXCLUSIVE);
|
||||
}else if (CallActivity.class.isInstance(fowElement)) {
|
||||
actInfoConfig.setJumpType("AUTO");
|
||||
actInfoConfig.setActivityDefType(BpmnXMLConstants.ELEMENT_CALL_ACTIVITY);
|
||||
}
|
||||
actInfoConfig.setActivityDefDealType("single");
|
||||
actInfoConfig.setIsShowIdea("ENABLED");
|
||||
actInfoConfig.setOtherSysDealStatus("yes");
|
||||
actInfoConfig.setCprotocol("hnzy:workitem");
|
||||
actInfoConfig.setMprotocol("none");
|
||||
|
||||
return actInfoConfig;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public List<String> convertActivityOperationRoleid() {
|
||||
if (StringUtils.isEmpty(activityOperationRoleid)) {
|
||||
return null;
|
||||
}
|
||||
String[] activityOperationRoleids = null;
|
||||
if (activityOperationRoleid.indexOf(";") != -1) {
|
||||
activityOperationRoleids = activityOperationRoleid.split(";");
|
||||
} else {
|
||||
activityOperationRoleids = new String[] { activityOperationRoleid };
|
||||
}
|
||||
return Arrays.asList(activityOperationRoleids);
|
||||
}
|
||||
|
||||
public boolean isAutoJumpType() {
|
||||
this.autoJumpType = "AUTO".equals(jumpType);
|
||||
return autoJumpType;
|
||||
}
|
||||
|
||||
public boolean isFreeJumpType() {
|
||||
this.freeJumpType = "FREE".equals(jumpType);
|
||||
return freeJumpType;
|
||||
}
|
||||
|
||||
public boolean isMulti() {
|
||||
return StringUtils.isEmpty(activityDefDealType) ? false : "multi"
|
||||
.equals(activityDefDealType);
|
||||
}
|
||||
|
||||
public ActivityInfoConfig() {
|
||||
}
|
||||
|
||||
public ActivityInfoConfig(String activityDefId, String processDefId) {
|
||||
this.activityDefId = activityDefId;
|
||||
this.processDefId = processDefId;
|
||||
}
|
||||
|
||||
public void setActivityDefId(String value) {
|
||||
this.activityDefId = value;
|
||||
}
|
||||
|
||||
public String getActivityDefId() {
|
||||
return this.activityDefId;
|
||||
}
|
||||
|
||||
public void setActivityDefName(String value) {
|
||||
this.activityDefName = value;
|
||||
}
|
||||
|
||||
public String getActivityDefName() {
|
||||
return this.activityDefName;
|
||||
}
|
||||
|
||||
public void setProcessDefId(String value) {
|
||||
this.processDefId = value;
|
||||
}
|
||||
|
||||
public String getProcessDefId() {
|
||||
return this.processDefId;
|
||||
}
|
||||
|
||||
public void setProcessDefName(String value) {
|
||||
this.processDefName = value;
|
||||
}
|
||||
|
||||
public String getProcessDefName() {
|
||||
return this.processDefName;
|
||||
}
|
||||
|
||||
public void setActivityPageUrl(String value) {
|
||||
this.activityPageUrl = value;
|
||||
}
|
||||
|
||||
public String getActivityPageUrl() {
|
||||
return this.activityPageUrl;
|
||||
}
|
||||
|
||||
public void setActivityPageInfo(String value) {
|
||||
this.activityPageInfo = value;
|
||||
}
|
||||
|
||||
public String getActivityPageInfo() {
|
||||
return this.activityPageInfo;
|
||||
}
|
||||
|
||||
public void setActivityOperationRoleid(String value) {
|
||||
this.activityOperationRoleid = value;
|
||||
}
|
||||
|
||||
public String getActivityOperationRoleid() {
|
||||
return this.activityOperationRoleid;
|
||||
}
|
||||
|
||||
public Integer getActivityOrder() {
|
||||
return activityOrder;
|
||||
}
|
||||
|
||||
public void setActivityOrder(Integer activityOrder) {
|
||||
this.activityOrder = activityOrder;
|
||||
}
|
||||
|
||||
public void setRemark(String value) {
|
||||
this.remark = value;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return this.remark;
|
||||
}
|
||||
|
||||
public Integer getActivityLimitTime() {
|
||||
return activityLimitTime;
|
||||
}
|
||||
|
||||
public void setActivityLimitTime(Integer activityLimitTime) {
|
||||
this.activityLimitTime = activityLimitTime;
|
||||
}
|
||||
|
||||
public String getActivityStatusName() {
|
||||
return activityStatusName;
|
||||
}
|
||||
|
||||
public void setActivityStatusName(String activityStatusName) {
|
||||
this.activityStatusName = activityStatusName;
|
||||
}
|
||||
|
||||
public List<ActivityOperatePower> getActivityOperatePowers() {
|
||||
return activityOperatePowers;
|
||||
}
|
||||
|
||||
public void setActivityOperatePowers(
|
||||
List<ActivityOperatePower> activityOperatePowers) {
|
||||
this.activityOperatePowers = activityOperatePowers;
|
||||
}
|
||||
|
||||
public void setJumpType(String jumpType) {
|
||||
this.jumpType = jumpType;
|
||||
}
|
||||
|
||||
public String getIsShowIdea() {
|
||||
return isShowIdea;
|
||||
}
|
||||
|
||||
public void setIsShowIdea(String isShowIdea) {
|
||||
this.isShowIdea = isShowIdea;
|
||||
}
|
||||
|
||||
public String getJumpType() {
|
||||
return jumpType;
|
||||
}
|
||||
|
||||
public String getIdeaDisplayArea() {
|
||||
return ideaDisplayArea;
|
||||
}
|
||||
|
||||
public void setIdeaDisplayArea(String ideaDisplayArea) {
|
||||
this.ideaDisplayArea = ideaDisplayArea;
|
||||
}
|
||||
|
||||
public String getActivityDefType() {
|
||||
return activityDefType;
|
||||
}
|
||||
|
||||
public void setActivityDefType(String activityDefType) {
|
||||
this.activityDefType = activityDefType;
|
||||
}
|
||||
|
||||
public List<DataObject> getDataObjects() {
|
||||
return dataObjects;
|
||||
}
|
||||
|
||||
public void setDataObjects(List<DataObject> dataObjects) {
|
||||
this.dataObjects = dataObjects;
|
||||
}
|
||||
|
||||
public String getActivityDefChildType() {
|
||||
return activityDefChildType;
|
||||
}
|
||||
|
||||
public void setActivityDefChildType(String activityDefChildType) {
|
||||
this.activityDefChildType = activityDefChildType;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this,
|
||||
ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
|
||||
public String getActivityDefDealType() {
|
||||
return activityDefDealType;
|
||||
}
|
||||
|
||||
public void setActivityDefDealType(String activityDefDealType) {
|
||||
this.activityDefDealType = activityDefDealType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCprotocol() {
|
||||
return cprotocol;
|
||||
}
|
||||
|
||||
|
||||
public void setCprotocol(String cprotocol) {
|
||||
this.cprotocol = cprotocol;
|
||||
}
|
||||
|
||||
|
||||
public String getMurl() {
|
||||
return murl;
|
||||
}
|
||||
|
||||
|
||||
public void setMurl(String murl) {
|
||||
this.murl = murl;
|
||||
}
|
||||
|
||||
|
||||
public String getMprotocol() {
|
||||
return mprotocol;
|
||||
}
|
||||
|
||||
|
||||
public void setMprotocol(String mprotocol) {
|
||||
this.mprotocol = mprotocol;
|
||||
}
|
||||
|
||||
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(getActivityDefId())
|
||||
.append(getProcessDefId()).toHashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof ActivityInfoConfig == false)
|
||||
return false;
|
||||
if (this == obj)
|
||||
return true;
|
||||
ActivityInfoConfig other = (ActivityInfoConfig) obj;
|
||||
return new EqualsBuilder()
|
||||
.append(getActivityDefId(), other.getActivityDefId())
|
||||
.append(getProcessDefId(), other.getProcessDefId()).isEquals();
|
||||
}
|
||||
|
||||
|
||||
public String getOtherSysDealStatus() {
|
||||
return otherSysDealStatus;
|
||||
}
|
||||
|
||||
|
||||
public void setOtherSysDealStatus(String otherSysDealStatus) {
|
||||
this.otherSysDealStatus = otherSysDealStatus;
|
||||
}
|
||||
|
||||
|
||||
public String getIsStartUserTask() {
|
||||
return isStartUserTask;
|
||||
}
|
||||
|
||||
public void setIsStartUserTask(String isStartUserTask) {
|
||||
this.isStartUserTask = isStartUserTask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,494 @@
|
||||
package com.blueland.bpm.engine.config.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import com.blueland.bpm.common.base.BaseEntity;
|
||||
import com.blueland.bpm.common.util.DateConvertUtils;
|
||||
import com.blueland.bpm.engine.core.model.ProcessDefinitionModel;
|
||||
|
||||
/**
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @since
|
||||
*/
|
||||
|
||||
|
||||
public class ProcessInfoConfig extends BaseEntity implements java.io.Serializable{
|
||||
private static final long serialVersionUID = 5454155825314635342L;
|
||||
|
||||
|
||||
//date formats
|
||||
|
||||
//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
|
||||
//columns START
|
||||
/**
|
||||
* 流程定义ID db_column: PROCESS_DEF_ID
|
||||
*/
|
||||
@Length(max=100)
|
||||
private String processDefId;
|
||||
/**
|
||||
* 流程定义名称 db_column: PROCESS_DEF_NAME
|
||||
*/
|
||||
@Length(max=100)
|
||||
private String processDefName;
|
||||
/**
|
||||
* 流程类型 db_column: PROCESS_TYPE_ID
|
||||
*/
|
||||
@Length(max=50)
|
||||
private String processTypeId;
|
||||
private String processTypeName;
|
||||
/**
|
||||
* 流程表单URL db_column: PROCESS_PAGE_URL
|
||||
*/
|
||||
@Length(max=1000)
|
||||
private String processPageUrl;
|
||||
/**
|
||||
* 流程表单数据 db_column: PROCESS_PAGE_INFO
|
||||
*/
|
||||
@Length(max=4000)
|
||||
private String processPageInfo;
|
||||
/**
|
||||
* 流程表单起草权限 db_column: PROCESS_START_AUTH
|
||||
*/
|
||||
@Length(max=500)
|
||||
private String processStartAuth;
|
||||
/**
|
||||
* 新建流程是否可见 db_column: PROCESS_START_ISSHOW
|
||||
*/
|
||||
@Length(max=10)
|
||||
private String processStartIsshow;
|
||||
|
||||
private int processVersion;
|
||||
private String processDefKey;
|
||||
/**
|
||||
* 备注 db_column: REMARK
|
||||
*/
|
||||
@Length(max=500)
|
||||
private String remark;
|
||||
|
||||
private String pageIshowSelectUserTree;
|
||||
|
||||
private String processHandlerClassPath;
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer processStartOrder;
|
||||
|
||||
private String deploymentId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最好更新时间
|
||||
*/
|
||||
|
||||
private Date lastUpdateTime;
|
||||
/**
|
||||
* 扩展属性
|
||||
*/
|
||||
private List<DataObject> dataObjects;
|
||||
//columns END
|
||||
private static Map processStartIsshowMap=new LinkedHashMap();
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
/**
|
||||
* 手机端处理状态
|
||||
*/
|
||||
private String otherSysDealStatus;
|
||||
/**
|
||||
* arisr流程编码
|
||||
*/
|
||||
private String arisCode;
|
||||
|
||||
private String cprotocol;
|
||||
private String murl;
|
||||
private String mprotocol;
|
||||
/**
|
||||
* 流程定义管理状态
|
||||
*/
|
||||
private String processMgrState;
|
||||
private static Map processMgrStateMap=new LinkedHashMap();
|
||||
public static String PROCESS_START_ISSHOW_YES="Y";
|
||||
public static String PROCESS_START_ISSHOW_NO="Y";
|
||||
public static String PROCESS_MGR_STATE_UNRELEASE="UNRELEASE";
|
||||
public static String PROCESS_MGR_STATE_UPDATE="UPDATE";
|
||||
public static String PROCESS_MGR_STATE_RELEASE="RELEASE";
|
||||
|
||||
static{
|
||||
processStartIsshowMap.put("Y","可见");
|
||||
processStartIsshowMap.put("N","不可见");
|
||||
processMgrStateMap.put("UNRELEASE","未发布");
|
||||
processMgrStateMap.put("UPDATE","修订中");
|
||||
processMgrStateMap.put("RELEASE","已发布");
|
||||
}
|
||||
private List<ActivityInfoConfig> activityInfoConfigs;
|
||||
private List<ActivityRule> activityRules;
|
||||
/**
|
||||
* 扩展属性
|
||||
*/
|
||||
private List<DataObjectRelation> dataObjectRelations;
|
||||
/**
|
||||
* 流程定义与模型同步状态,Y:已同步,N:未同步
|
||||
*/
|
||||
private String processModelSyncState;
|
||||
public static String PROCESS_MODEL_SYNC_STATE_Y="Y";
|
||||
public static String PROCESS_MODEL_SYNC_STATE_N="N";
|
||||
/**
|
||||
* 流程定义管理状态:Y:可见,N:不可见'
|
||||
*/
|
||||
private String processMgrIsshow;
|
||||
|
||||
public static String PROCESS_MGR_ISSHOW_Y="Y";
|
||||
public static String PROCESS_MGR_ISSHOW_N="N";
|
||||
public static ProcessInfoConfig build(ProcessDefinitionModel processDefinition){
|
||||
ProcessInfoConfig processInfoConfig=new ProcessInfoConfig();
|
||||
processInfoConfig.processDefId=processDefinition.getProcDefId();
|
||||
processInfoConfig.processDefKey=processDefinition.getProcDefKey();
|
||||
processInfoConfig.processDefName=processDefinition.getProcDefName();
|
||||
processInfoConfig.deploymentId=processDefinition.getDeploymentId();
|
||||
processInfoConfig.processVersion=processDefinition.getVersion();
|
||||
processInfoConfig.tenantId=processDefinition.getTenantId();
|
||||
Date nowDate=new Date();
|
||||
processInfoConfig.createTime=nowDate;
|
||||
processInfoConfig.lastUpdateTime=nowDate;
|
||||
processInfoConfig.processStartIsshow="Y";
|
||||
processInfoConfig.processMgrState="UNRELEASE";
|
||||
processInfoConfig.setOtherSysDealStatus("yes");
|
||||
processInfoConfig.setCprotocol("hnzy:workitem");
|
||||
processInfoConfig.setMprotocol("none");
|
||||
return processInfoConfig;
|
||||
}
|
||||
|
||||
|
||||
public ProcessInfoConfig(){
|
||||
}
|
||||
|
||||
public ProcessInfoConfig(
|
||||
String processDefId
|
||||
){
|
||||
this.processDefId = processDefId;
|
||||
}
|
||||
|
||||
public void setProcessDefId(String value) {
|
||||
this.processDefId = value;
|
||||
}
|
||||
|
||||
public String getProcessDefId() {
|
||||
return this.processDefId;
|
||||
}
|
||||
public void setProcessDefName(String value) {
|
||||
this.processDefName = value;
|
||||
}
|
||||
|
||||
public String getProcessDefName() {
|
||||
return this.processDefName;
|
||||
}
|
||||
public void setProcessTypeId(String value) {
|
||||
this.processTypeId = value;
|
||||
}
|
||||
|
||||
public String getProcessTypeId() {
|
||||
return this.processTypeId;
|
||||
}
|
||||
public void setProcessPageUrl(String value) {
|
||||
this.processPageUrl = value;
|
||||
}
|
||||
|
||||
public String getProcessPageUrl() {
|
||||
return this.processPageUrl;
|
||||
}
|
||||
public void setProcessPageInfo(String value) {
|
||||
this.processPageInfo = value;
|
||||
}
|
||||
|
||||
public String getProcessPageInfo() {
|
||||
return this.processPageInfo;
|
||||
}
|
||||
public void setProcessStartAuth(String value) {
|
||||
this.processStartAuth = value;
|
||||
}
|
||||
|
||||
public String getProcessStartAuth() {
|
||||
return this.processStartAuth;
|
||||
}
|
||||
public void setProcessStartIsshow(String value) {
|
||||
this.processStartIsshow = value;
|
||||
}
|
||||
|
||||
public String getProcessStartIsshow() {
|
||||
return this.processStartIsshow;
|
||||
}
|
||||
public void setRemark(String value) {
|
||||
this.remark = value;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return this.remark;
|
||||
}
|
||||
|
||||
public int getProcessVersion() {
|
||||
return processVersion;
|
||||
}
|
||||
|
||||
public void setProcessVersion(int processVersion) {
|
||||
this.processVersion = processVersion;
|
||||
}
|
||||
|
||||
public String getProcessDefKey() {
|
||||
return processDefKey;
|
||||
}
|
||||
|
||||
public void setProcessDefKey(String processDefKey) {
|
||||
this.processDefKey = processDefKey;
|
||||
}
|
||||
|
||||
public String getPageIshowSelectUserTree() {
|
||||
return pageIshowSelectUserTree;
|
||||
}
|
||||
|
||||
public void setPageIshowSelectUserTree(String pageIshowSelectUserTree) {
|
||||
this.pageIshowSelectUserTree = pageIshowSelectUserTree;
|
||||
}
|
||||
|
||||
public String getProcessHandlerClassPath() {
|
||||
return processHandlerClassPath;
|
||||
}
|
||||
|
||||
public void setProcessHandlerClassPath(String processHandlerClassPath) {
|
||||
this.processHandlerClassPath = processHandlerClassPath;
|
||||
}
|
||||
|
||||
public Integer getProcessStartOrder() {
|
||||
return processStartOrder;
|
||||
}
|
||||
|
||||
public void setProcessStartOrder(Integer processStartOrder) {
|
||||
this.processStartOrder = processStartOrder;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getLastUpdateTime() {
|
||||
return lastUpdateTime;
|
||||
}
|
||||
|
||||
public void setLastUpdateTime(Date lastUpdateTime) {
|
||||
this.lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
|
||||
public String getProcessTypeName() {
|
||||
return processTypeName;
|
||||
}
|
||||
|
||||
public void setProcessTypeName(String processTypeName) {
|
||||
this.processTypeName = processTypeName;
|
||||
}
|
||||
|
||||
public boolean isProcessRelease(){
|
||||
return "1".equals(this.processStartIsshow);
|
||||
}
|
||||
|
||||
public String getDeploymentId() {
|
||||
return deploymentId;
|
||||
}
|
||||
|
||||
public void setDeploymentId(String deploymentId) {
|
||||
this.deploymentId = deploymentId;
|
||||
}
|
||||
|
||||
public String getProcessStartIsshowVal(){
|
||||
return (String) (processStartIsshowMap.get(processStartIsshow)!=null?processStartIsshowMap.get(processStartIsshow):"");
|
||||
}
|
||||
|
||||
public String getProcessMgrStateVal(){
|
||||
return (String) (processMgrStateMap.get(processMgrState)!=null?processMgrStateMap.get(processMgrState):"");
|
||||
}
|
||||
|
||||
public List<ActivityRule> getActivityRules() {
|
||||
return activityRules;
|
||||
}
|
||||
|
||||
public void setActivityRules(List<ActivityRule> activityRules) {
|
||||
this.activityRules = activityRules;
|
||||
}
|
||||
|
||||
public Map getProcessStartIsshowMap() {
|
||||
return processStartIsshowMap;
|
||||
}
|
||||
public String getCreateTimeString() {
|
||||
return DateConvertUtils.format(getCreateTime(), DATE_FORMAT);
|
||||
}
|
||||
public String getLastUpdateTimeString() {
|
||||
return DateConvertUtils.format(getLastUpdateTime(), DATE_TIME_FORMAT);
|
||||
}
|
||||
public boolean isRelease(){
|
||||
return "RELEASE".equals(this.processMgrState);
|
||||
}
|
||||
|
||||
public boolean isUpdate(){
|
||||
return "UPDATE".equals(this.processMgrState);
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public List<ActivityInfoConfig> getActivityInfoConfigs() {
|
||||
return activityInfoConfigs;
|
||||
}
|
||||
|
||||
public void setActivityInfoConfigs(List<ActivityInfoConfig> activityInfoConfigs) {
|
||||
this.activityInfoConfigs = activityInfoConfigs;
|
||||
}
|
||||
|
||||
public List<DataObject> getDataObjects() {
|
||||
return dataObjects;
|
||||
}
|
||||
|
||||
public void setDataObjects(List<DataObject> dataObjects) {
|
||||
this.dataObjects = dataObjects;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getProcessMgrIsshow() {
|
||||
return processMgrIsshow;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessMgrIsshow(String processMgrIsshow) {
|
||||
this.processMgrIsshow = processMgrIsshow;
|
||||
}
|
||||
|
||||
|
||||
public String getProcessMgrState() {
|
||||
return processMgrState;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessMgrState(String processMgrState) {
|
||||
this.processMgrState = processMgrState;
|
||||
}
|
||||
|
||||
|
||||
public static Map getProcessMgrStateMap() {
|
||||
return processMgrStateMap;
|
||||
}
|
||||
|
||||
|
||||
public String getProcessModelSyncState() {
|
||||
return processModelSyncState;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessModelSyncState(String processModelSyncState) {
|
||||
this.processModelSyncState = processModelSyncState;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCprotocol() {
|
||||
return cprotocol;
|
||||
}
|
||||
|
||||
|
||||
public void setCprotocol(String cprotocol) {
|
||||
this.cprotocol = cprotocol;
|
||||
}
|
||||
|
||||
|
||||
public String getMurl() {
|
||||
return murl;
|
||||
}
|
||||
|
||||
|
||||
public void setMurl(String murl) {
|
||||
this.murl = murl;
|
||||
}
|
||||
|
||||
|
||||
public String getMprotocol() {
|
||||
return mprotocol;
|
||||
}
|
||||
|
||||
|
||||
public void setMprotocol(String mprotocol) {
|
||||
this.mprotocol = mprotocol;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
|
||||
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder()
|
||||
.append(getProcessDefId())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof ProcessInfoConfig == false) return false;
|
||||
if(this == obj) return true;
|
||||
ProcessInfoConfig other = (ProcessInfoConfig)obj;
|
||||
return new EqualsBuilder()
|
||||
.append(getProcessDefId(),other.getProcessDefId())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
|
||||
public String getOtherSysDealStatus() {
|
||||
return otherSysDealStatus;
|
||||
}
|
||||
|
||||
|
||||
public void setOtherSysDealStatus(String otherSysDealStatus) {
|
||||
this.otherSysDealStatus = otherSysDealStatus;
|
||||
}
|
||||
|
||||
|
||||
public String getArisCode() {
|
||||
return arisCode;
|
||||
}
|
||||
|
||||
|
||||
public void setArisCode(String arisCode) {
|
||||
this.arisCode = arisCode;
|
||||
}
|
||||
|
||||
|
||||
public List<DataObjectRelation> getDataObjectRelations() {
|
||||
return dataObjectRelations;
|
||||
}
|
||||
|
||||
|
||||
public void setDataObjectRelations(List<DataObjectRelation> dataObjectRelations) {
|
||||
this.dataObjectRelations = dataObjectRelations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
|
||||
|
||||
<!-- 不使用namespace的话sql搜索定位会比较方便 -->
|
||||
<mapper namespace="ActivityInfoConfig">
|
||||
|
||||
<resultMap id="RM_ActivityInfoConfig" type="com.blueland.bpm.engine.config.model.ActivityInfoConfig">
|
||||
<result property="activityDefId" column="ACTIVITY_DEF_ID"/>
|
||||
<result property="activityDefName" column="ACTIVITY_DEF_NAME"/>
|
||||
<result property="activityStatusName" column="ACTIVITY_STATUS_NAME"/>
|
||||
<result property="processDefId" column="PROCESS_DEF_ID"/>
|
||||
<result property="processDefName" column="PROCESS_DEF_NAME"/>
|
||||
<result property="activityPageUrl" column="ACTIVITY_PAGE_URL"/>
|
||||
<result property="activityPageInfo" column="ACTIVITY_PAGE_INFO"/>
|
||||
<result property="activityOperationRoleid" column="ACTIVITY_OPERATION_ROLEID"/>
|
||||
<result property="jumpType" column="JUMP_TYPE"/>
|
||||
<result property="activityOrder" column="ACTIVITY_ORDER"/>
|
||||
<result property="activityLimitTime" column="ACTIVITY_LIMIT_TIME"/>
|
||||
<result property="ideaDisplayArea" column="IDEA_DISPLAY_AREA"/>
|
||||
<result property="isShowIdea" column="IS_SHOW_IDEA"/>
|
||||
<result property="activityDefType" column="ACTIVITY_DEF_TYPE"/>
|
||||
<result property="activityDefChildType" column="ACTIVITY_DEF_CHILD_TYPE"/>
|
||||
<result property="activityDefDealType" column="ACTIVITY_DEF_DEAL_TYPE"/>
|
||||
<result property="remark" column="REMARK"/>
|
||||
<result property="otherSysDealStatus" column="OTHER_SYS_DEAL_STATUS"/>
|
||||
<result property="isStartUserTask" column="IS_START_USERTASK"/>
|
||||
<result property="cprotocol" column="C_PROTOCL"/>
|
||||
<result property="murl" column="M_URL"/>
|
||||
<result property="mprotocol" column="M_PROTOCL"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 用于select查询公用抽取的列 -->
|
||||
<sql id="ActivityInfoConfig.columns">
|
||||
<![CDATA[
|
||||
ACTIVITY_DEF_DEAL_TYPE,ACTIVITY_DEF_CHILD_TYPE,ACTIVITY_DEF_TYPE,ACTIVITY_ORDER,ACTIVITY_DEF_ID,JUMP_TYPE,ACTIVITY_DEF_NAME,ACTIVITY_STATUS_NAME,PROCESS_DEF_ID,PROCESS_DEF_NAME,ACTIVITY_PAGE_URL,ACTIVITY_PAGE_INFO,ACTIVITY_OPERATION_ROLEID,ACTIVITY_LIMIT_TIME,IDEA_DISPLAY_AREA,IS_SHOW_IDEA,REMARK,
|
||||
OTHER_SYS_DEAL_STATUS,IS_START_USERTASK,C_PROTOCL,M_URL,M_PROTOCL
|
||||
]]>
|
||||
</sql>
|
||||
|
||||
<!-- useGeneratedKeys="true" keyProperty="xxx" for sqlserver and mysql -->
|
||||
<insert id="ActivityInfoConfig.insert" useGeneratedKeys="false" keyProperty="activityDefId">
|
||||
<![CDATA[
|
||||
INSERT INTO T_WF_ACTIVITY_INFO_CONFIG (
|
||||
ACTIVITY_DEF_ID ,
|
||||
ACTIVITY_DEF_NAME ,
|
||||
ACTIVITY_STATUS_NAME,
|
||||
PROCESS_DEF_ID ,
|
||||
PROCESS_DEF_NAME ,
|
||||
ACTIVITY_PAGE_URL ,
|
||||
ACTIVITY_PAGE_INFO ,
|
||||
ACTIVITY_OPERATION_ROLEID ,
|
||||
JUMP_TYPE,
|
||||
ACTIVITY_ORDER,
|
||||
ACTIVITY_LIMIT_TIME,
|
||||
IDEA_DISPLAY_AREA,
|
||||
IS_SHOW_IDEA,
|
||||
ACTIVITY_DEF_TYPE,
|
||||
ACTIVITY_DEF_CHILD_TYPE,
|
||||
ACTIVITY_DEF_DEAL_TYPE,
|
||||
REMARK,
|
||||
OTHER_SYS_DEAL_STATUS ,
|
||||
C_PROTOCL,M_URL,M_PROTOCL
|
||||
|
||||
) VALUES (
|
||||
#{activityDefId,jdbcType=VARCHAR} ,
|
||||
#{activityDefName,jdbcType=VARCHAR} ,
|
||||
#{activityStatusName,jdbcType=VARCHAR} ,
|
||||
#{processDefId,jdbcType=VARCHAR} ,
|
||||
#{processDefName,jdbcType=VARCHAR} ,
|
||||
#{activityPageUrl,jdbcType=VARCHAR} ,
|
||||
#{activityPageInfo,jdbcType=CLOB} ,
|
||||
#{activityOperationRoleid,jdbcType=VARCHAR} ,
|
||||
#{jumpType,jdbcType=VARCHAR} ,
|
||||
#{activityOrder,jdbcType=INTEGER} ,
|
||||
#{activityLimitTime,jdbcType=INTEGER} ,
|
||||
#{ideaDisplayArea,jdbcType=VARCHAR} ,
|
||||
#{isShowIdea,jdbcType=VARCHAR} ,
|
||||
#{activityDefType,jdbcType=VARCHAR} ,
|
||||
#{activityDefChildType,jdbcType=VARCHAR} ,
|
||||
#{activityDefDealType,jdbcType=VARCHAR} ,
|
||||
#{remark,jdbcType=VARCHAR},
|
||||
#{otherSysDealStatus,jdbcType=VARCHAR} ,
|
||||
#{cprotocol,jdbcType=VARCHAR} ,
|
||||
#{murl,jdbcType=VARCHAR} ,
|
||||
#{mprotocol,jdbcType=VARCHAR}
|
||||
)
|
||||
]]>
|
||||
<!--
|
||||
oracle: order="BEFORE" SELECT sequenceName.nextval AS ID FROM DUAL
|
||||
DB2: order="BEFORE"" values nextval for sequenceName
|
||||
<selectKey resultType="java.lang.Long" order="BEFORE" keyProperty="userId">
|
||||
SELECT sequenceName.nextval AS ID FROM DUAL
|
||||
</selectKey>
|
||||
-->
|
||||
</insert>
|
||||
|
||||
<update id="ActivityInfoConfig.update" >
|
||||
<![CDATA[
|
||||
UPDATE T_WF_ACTIVITY_INFO_CONFIG SET
|
||||
ACTIVITY_DEF_NAME = #{activityDefName,jdbcType=VARCHAR} ,
|
||||
ACTIVITY_STATUS_NAME = #{activityStatusName,jdbcType=VARCHAR} ,
|
||||
PROCESS_DEF_NAME = #{processDefName,jdbcType=VARCHAR} ,
|
||||
ACTIVITY_PAGE_URL = #{activityPageUrl,jdbcType=VARCHAR} ,
|
||||
ACTIVITY_PAGE_INFO = #{activityPageInfo,jdbcType=CLOB} ,
|
||||
ACTIVITY_OPERATION_ROLEID = #{activityOperationRoleid,jdbcType=VARCHAR} ,
|
||||
JUMP_TYPE = #{jumpType,jdbcType=VARCHAR} ,
|
||||
ACTIVITY_ORDER=#{activityOrder,jdbcType=INTEGER} ,
|
||||
ACTIVITY_LIMIT_TIME=#{activityLimitTime,jdbcType=INTEGER} ,
|
||||
IDEA_DISPLAY_AREA=#{ideaDisplayArea,jdbcType=VARCHAR} ,
|
||||
IS_SHOW_IDEA=#{isShowIdea,jdbcType=VARCHAR} ,
|
||||
ACTIVITY_DEF_DEAL_TYPE=#{activityDefDealType,jdbcType=VARCHAR} ,
|
||||
ACTIVITY_DEF_CHILD_TYPE=#{activityDefChildType,jdbcType=VARCHAR} ,
|
||||
ACTIVITY_DEF_TYPE=#{activityDefType,jdbcType=VARCHAR} ,
|
||||
REMARK = #{remark,jdbcType=VARCHAR},
|
||||
OTHER_SYS_DEAL_STATUS=#{otherSysDealStatus,jdbcType=VARCHAR} ,
|
||||
C_PROTOCL=#{cprotocol,jdbcType=VARCHAR} ,
|
||||
M_URL=#{murl,jdbcType=VARCHAR} ,
|
||||
M_PROTOCL=#{mprotocol,jdbcType=VARCHAR}
|
||||
WHERE
|
||||
ACTIVITY_DEF_ID = #{activityDefId} AND
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<update id="ActivityInfoConfig.updateByProcessDefName" >
|
||||
<![CDATA[
|
||||
UPDATE T_WF_ACTIVITY_INFO_CONFIG SET
|
||||
PROCESS_DEF_NAME = #{processDefName,jdbcType=VARCHAR}
|
||||
WHERE
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
<delete id="ActivityInfoConfig.delete">
|
||||
<![CDATA[
|
||||
DELETE FROM T_WF_ACTIVITY_INFO_CONFIG WHERE
|
||||
ACTIVITY_DEF_ID = #{activityDefId} AND
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<delete id="ActivityInfoConfig.deleteActivityInfoConfigs">
|
||||
<![CDATA[
|
||||
DELETE FROM T_WF_ACTIVITY_INFO_CONFIG WHERE
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="ActivityInfoConfig.getById" resultMap="RM_ActivityInfoConfig">
|
||||
SELECT <include refid="ActivityInfoConfig.columns" />
|
||||
<![CDATA[
|
||||
FROM T_WF_ACTIVITY_INFO_CONFIG
|
||||
WHERE
|
||||
ACTIVITY_DEF_ID = #{activityDefId} AND
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<sql id="ActivityInfoConfig.findPage.where">
|
||||
<!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用rapid中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类 -->
|
||||
<where>
|
||||
<if test="@Ognl@isNotEmpty(activityDefId)">
|
||||
AND ACTIVITY_DEF_ID = #{activityDefId}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(activityDefName)">
|
||||
AND ACTIVITY_DEF_NAME = #{activityDefName}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processDefId)">
|
||||
AND PROCESS_DEF_ID = #{processDefId}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processDefName)">
|
||||
AND PROCESS_DEF_NAME = #{processDefName}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(activityOperationRoleid)">
|
||||
AND ACTIVITY_OPERATION_ROLEID = #{activityOperationRoleid}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="ActivityInfoConfig.findPage.count" resultType="long">
|
||||
SELECT count(*) FROM T_WF_ACTIVITY_INFO_CONFIG
|
||||
<include refid="ActivityInfoConfig.findPage.where"/>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
分页查询已经使用Dialect进行分页,也可以不使用Dialect直接编写分页
|
||||
因为分页查询将传 offset,pageSize,lastRows 三个参数,不同的数据库可以根于此三个参数属性应用不同的分页实现
|
||||
-->
|
||||
<select id="ActivityInfoConfig.findPage" resultMap="RM_ActivityInfoConfig">
|
||||
SELECT <include refid="ActivityInfoConfig.columns" />
|
||||
FROM T_WF_ACTIVITY_INFO_CONFIG
|
||||
<include refid="ActivityInfoConfig.findPage.where"/>
|
||||
ORDER BY ACTIVITY_ORDER
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,335 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
|
||||
|
||||
<!-- 不使用namespace的话sql搜索定位会比较方便 -->
|
||||
<mapper namespace="ProcessInfoConfig">
|
||||
|
||||
<resultMap id="RM_ProcessInfoConfig" type="com.blueland.bpm.engine.config.model.ProcessInfoConfig">
|
||||
<result property="processDefId" column="PROCESS_DEF_ID"/>
|
||||
<result property="processDefName" column="PROCESS_DEF_NAME"/>
|
||||
<result property="processTypeId" column="PROCESS_TYPE_ID"/>
|
||||
<result property="processTypeName" column="PROCESS_TYPE_NAME"/>
|
||||
<result property="processPageUrl" column="PROCESS_PAGE_URL"/>
|
||||
<result property="processPageInfo" column="PROCESS_PAGE_INFO"/>
|
||||
<result property="processStartAuth" column="PROCESS_START_AUTH"/>
|
||||
<result property="processStartIsshow" column="PROCESS_START_ISSHOW"/>
|
||||
<result property="processStartOrder" column="PROCESS_START_ORDER"/>
|
||||
<result property="deploymentId" column="DEPLOYMENT_ID"/>
|
||||
<result property="pageIshowSelectUserTree" column="PAGE_ISSHOW_SELECT_USERTREE"/>
|
||||
<result property="processHandlerClassPath" column="PROCESS_HANDLER_CLASS_PATH"/>
|
||||
<result property="createTime" column="CREATE_TIME"/>
|
||||
<result property="lastUpdateTime" column="LAST_UPDATE_TIME"/>
|
||||
<result property="remark" column="REMARK"/>
|
||||
<result property="tenantId" column="TENANT_ID"/>
|
||||
<result property="processMgrState" column="PROCESS_MGR_STATE"/>
|
||||
<result property="processModelSyncState" column="PROCESS_MODEL_SYNC_STATE"/>
|
||||
<result property="processMgrIsshow" column="PROCESS_MGR_ISSHOW"/>
|
||||
<result property="otherSysDealStatus" column="OTHER_SYS_DEAL_STATUS"/>
|
||||
<result property="arisCode" column="ARIS_CODE"/>
|
||||
<result property="cprotocol" column="C_PROTOCL"/>
|
||||
<result property="murl" column="M_URL"/>
|
||||
<result property="mprotocol" column="M_PROTOCL"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 用于select查询公用抽取的列 -->
|
||||
<sql id="ProcessInfoConfig.columns">
|
||||
<![CDATA[
|
||||
PROCESS_MODEL_SYNC_STATE,PROCESS_MGR_STATE,DEPLOYMENT_ID,PROCESS_DEF_ID,PROCESS_HANDLER_CLASS_PATH,PAGE_ISSHOW_SELECT_USERTREE,PROCESS_DEF_NAME,PROCESS_TYPE_ID,PROCESS_PAGE_URL,PROCESS_PAGE_INFO,PROCESS_START_AUTH,PROCESS_START_ISSHOW,PROCESS_START_ORDER,CREATE_TIME,
|
||||
LAST_UPDATE_TIME,REMARK,TENANT_ID,PROCESS_MGR_ISSHOW,OTHER_SYS_DEAL_STATUS,ARIS_CODE,C_PROTOCL,M_URL,M_PROTOCL
|
||||
]]>
|
||||
</sql>
|
||||
|
||||
<!-- useGeneratedKeys="true" keyProperty="xxx" for sqlserver and mysql -->
|
||||
<insert id="ProcessInfoConfig.insert" useGeneratedKeys="false" keyProperty="processDefId">
|
||||
<![CDATA[
|
||||
INSERT INTO T_WF_PROCESS_INFO_CONFIG (
|
||||
PROCESS_DEF_ID ,
|
||||
PROCESS_DEF_NAME ,
|
||||
PROCESS_TYPE_ID ,
|
||||
PROCESS_PAGE_URL ,
|
||||
PROCESS_PAGE_INFO ,
|
||||
PROCESS_START_AUTH ,
|
||||
PROCESS_START_ISSHOW ,
|
||||
REMARK ,
|
||||
PROCESS_HANDLER_CLASS_PATH,
|
||||
PROCESS_START_ORDER,
|
||||
DEPLOYMENT_ID,
|
||||
CREATE_TIME,
|
||||
TENANT_ID,
|
||||
PROCESS_MGR_STATE,
|
||||
PROCESS_MODEL_SYNC_STATE,
|
||||
PROCESS_MGR_ISSHOW,
|
||||
OTHER_SYS_DEAL_STATUS,
|
||||
ARIS_CODE,
|
||||
C_PROTOCL,M_URL,M_PROTOCL
|
||||
) VALUES (
|
||||
#{processDefId,jdbcType=VARCHAR} ,
|
||||
#{processDefName,jdbcType=VARCHAR} ,
|
||||
#{processTypeId,jdbcType=VARCHAR} ,
|
||||
#{processPageUrl,jdbcType=VARCHAR} ,
|
||||
#{processPageInfo,jdbcType=VARCHAR} ,
|
||||
#{processStartAuth,jdbcType=VARCHAR} ,
|
||||
'Y',
|
||||
#{remark,jdbcType=VARCHAR} ,
|
||||
#{processHandlerClassPath,jdbcType=VARCHAR} ,
|
||||
#{processStartOrder,jdbcType=INTEGER},
|
||||
#{deploymentId,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{tenantId,jdbcType=VARCHAR},
|
||||
'UNRELEASE',
|
||||
'Y',
|
||||
'Y',
|
||||
#{otherSysDealStatus,jdbcType=VARCHAR},
|
||||
#{arisCode,jdbcType=VARCHAR} ,
|
||||
#{cprotocol,jdbcType=VARCHAR} ,
|
||||
#{murl,jdbcType=VARCHAR} ,
|
||||
#{mprotocol,jdbcType=VARCHAR}
|
||||
)
|
||||
]]>
|
||||
<!--
|
||||
oracle: order="BEFORE" SELECT sequenceName.nextval AS ID FROM DUAL
|
||||
DB2: order="BEFORE"" values nextval for sequenceName
|
||||
<selectKey resultType="java.lang.Long" order="BEFORE" keyProperty="userId">
|
||||
SELECT sequenceName.nextval AS ID FROM DUAL
|
||||
</selectKey>
|
||||
-->
|
||||
</insert>
|
||||
|
||||
<update id="ProcessInfoConfig.update" >
|
||||
<![CDATA[
|
||||
UPDATE T_WF_PROCESS_INFO_CONFIG SET
|
||||
PROCESS_DEF_NAME = #{processDefName,jdbcType=VARCHAR} ,
|
||||
PROCESS_TYPE_ID = #{processTypeId,jdbcType=VARCHAR} ,
|
||||
PROCESS_PAGE_URL = #{processPageUrl,jdbcType=VARCHAR} ,
|
||||
PROCESS_PAGE_INFO = #{processPageInfo,jdbcType=VARCHAR} ,
|
||||
PROCESS_START_AUTH = #{processStartAuth,jdbcType=VARCHAR} ,
|
||||
PROCESS_START_ISSHOW = #{processStartIsshow,jdbcType=VARCHAR} ,
|
||||
REMARK = #{remark,jdbcType=VARCHAR} ,
|
||||
PROCESS_HANDLER_CLASS_PATH = #{processHandlerClassPath,jdbcType=VARCHAR} ,
|
||||
PROCESS_START_ORDER=#{processStartOrder,jdbcType=INTEGER} ,
|
||||
LAST_UPDATE_TIME=#{lastUpdateTime,jdbcType=TIMESTAMP},
|
||||
PROCESS_MGR_STATE=#{processMgrState,jdbcType=VARCHAR} ,
|
||||
PROCESS_MODEL_SYNC_STATE=#{processModelSyncState,jdbcType=VARCHAR},
|
||||
PROCESS_MGR_ISSHOW=#{processMgrIsshow,jdbcType=VARCHAR},
|
||||
OTHER_SYS_DEAL_STATUS=#{otherSysDealStatus,jdbcType=VARCHAR},
|
||||
ARIS_CODE=#{arisCode,jdbcType=VARCHAR},
|
||||
C_PROTOCL=#{cprotocol,jdbcType=VARCHAR} ,
|
||||
M_URL=#{murl,jdbcType=VARCHAR} ,
|
||||
M_PROTOCL=#{mprotocol,jdbcType=VARCHAR}
|
||||
WHERE
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
<delete id="ProcessInfoConfig.delete">
|
||||
<![CDATA[
|
||||
DELETE FROM T_WF_PROCESS_INFO_CONFIG WHERE
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<select id="ProcessInfoConfig.getById" resultMap="RM_ProcessInfoConfig">
|
||||
SELECT <include refid="ProcessInfoConfig.columns" />,g.type_name as PROCESS_TYPE_NAME
|
||||
<![CDATA[
|
||||
FROM T_WF_PROCESS_INFO_CONFIG t left join T_SYS_GL_TYPE g on t.PROCESS_TYPE_ID=g.type_id
|
||||
WHERE
|
||||
PROCESS_DEF_ID = #{processDefId}
|
||||
]]>
|
||||
</select>
|
||||
<select id="ProcessInfoConfig.getLinkId" resultMap="RM_ProcessInfoConfig">
|
||||
SELECT <include refid="ProcessInfoConfig.columns" />,g.type_name as PROCESS_TYPE_NAME
|
||||
<![CDATA[
|
||||
FROM T_WF_PROCESS_INFO_CONFIG t left join T_SYS_GL_TYPE g on t.PROCESS_TYPE_ID=g.type_id
|
||||
WHERE
|
||||
PROCESS_DEF_ID like CONCAT(#{processDefId},'%')
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<sql id="ProcessInfoConfig.findConfigPage.where">
|
||||
<!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用rapid中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类 -->
|
||||
<where>
|
||||
|
||||
<if test="@Ognl@isNotEmpty(processDefId)">
|
||||
AND PROCESS_DEF_ID like CONCAT('%',#{processDefId},'%')
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processDefKey)">
|
||||
AND PROCESS_DEF_ID like CONCAT(#{processDefKey},'%')
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processDefName)">
|
||||
AND PROCESS_DEF_NAME like CONCAT('%',#{processDefName},'%')
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processTypeId)">
|
||||
AND PROCESS_TYPE_ID = #{processTypeId}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processPageUrl)">
|
||||
AND PROCESS_PAGE_URL = #{processPageUrl}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processPageInfo)">
|
||||
AND PROCESS_PAGE_INFO = #{processPageInfo}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processStartAuth)">
|
||||
AND PROCESS_START_AUTH = #{processStartAuth}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processStartIsshow)">
|
||||
AND PROCESS_START_ISSHOW = #{processStartIsshow}
|
||||
</if>
|
||||
|
||||
<if test="@Ognl@isNotEmpty(tenantId)">
|
||||
AND TENANT_ID = #{tenantId}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processMgrState)">
|
||||
AND PROCESS_MGR_STATE = #{processMgrState}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processMgrIsshow)">
|
||||
AND PROCESS_MGR_ISSHOW = #{processMgrIsshow}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<sql id="ProcessInfoConfig.findPage.where">
|
||||
<!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用rapid中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类 -->
|
||||
<where>
|
||||
T.PROCESS_DEF_ID = C.PROCESS_DEF_ID_
|
||||
<if test="@Ognl@isNotEmpty(processDefId)">
|
||||
AND PROCESS_DEF_ID = #{processDefId}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processDefName)">
|
||||
AND PROCESS_DEF_NAME = #{processDefName}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processTypeId)">
|
||||
AND PROCESS_TYPE_ID = #{processTypeId}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processPageUrl)">
|
||||
AND PROCESS_PAGE_URL = #{processPageUrl}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processPageInfo)">
|
||||
AND PROCESS_PAGE_INFO = #{processPageInfo}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processStartAuth)">
|
||||
AND PROCESS_START_AUTH = #{processStartAuth}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processStartIsshow)">
|
||||
AND PROCESS_START_ISSHOW = #{processStartIsshow}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processMgrState)">
|
||||
AND PROCESS_MGR_STATE = #{processMgrState}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(processMgrIsshow)">
|
||||
AND PROCESS_MGR_ISSHOW = #{processMgrIsshow}
|
||||
</if>
|
||||
<if test="@Ognl@isNotEmpty(tenantId)">
|
||||
AND TENANT_ID = #{tenantId}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="ProcessInfoConfig.findConfigPage.count" resultType="long">
|
||||
SELECT count(*) FROM T_WF_PROCESS_INFO_CONFIG t left join T_SYS_GL_TYPE g on t.PROCESS_TYPE_ID=g.type_id
|
||||
<include refid="ProcessInfoConfig.findConfigPage.where"/>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="ProcessInfoConfig.findPage.count" resultType="long">
|
||||
SELECT count(*) FROM T_WF_PROCESS_INFO_CONFIG
|
||||
<include refid="ProcessInfoConfig.findPage.where"/>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
分页查询已经使用Dialect进行分页,也可以不使用Dialect直接编写分页
|
||||
因为分页查询将传 offset,pageSize,lastRows 三个参数,不同的数据库可以根于此三个参数属性应用不同的分页实现
|
||||
-->
|
||||
<select id="ProcessInfoConfig.findConfigPage" resultMap="RM_ProcessInfoConfig">
|
||||
SELECT <include refid="ProcessInfoConfig.columns" />,g.type_name as PROCESS_TYPE_NAME
|
||||
FROM T_WF_PROCESS_INFO_CONFIG t left join T_SYS_GL_TYPE g on t.PROCESS_TYPE_ID=g.type_id
|
||||
<include refid="ProcessInfoConfig.findConfigPage.where"/>
|
||||
<if test="@Ognl@isNotEmpty(sortColumns)">
|
||||
ORDER BY ${sortColumns}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="ProcessInfoConfig.getAllProcessIdForExport" resultType="String">
|
||||
SELECT PROCESS_DEF_ID
|
||||
FROM T_WF_PROCESS_INFO_CONFIG t
|
||||
left join T_SYS_GL_TYPE g on t.PROCESS_TYPE_ID=g.type_id
|
||||
<include refid="ProcessInfoConfig.findConfigPage.where"/>
|
||||
<if test="@Ognl@isNotEmpty(sortColumns)">
|
||||
ORDER BY ${sortColumns}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
分页查询已经使用Dialect进行分页,也可以不使用Dialect直接编写分页
|
||||
因为分页查询将传 offset,pageSize,lastRows 三个参数,不同的数据库可以根于此三个参数属性应用不同的分页实现
|
||||
-->
|
||||
<select id="ProcessInfoConfig.findPage" resultMap="RM_ProcessInfoConfig">
|
||||
SELECT <include refid="ProcessInfoConfig.columns" />
|
||||
FROM T_WF_PROCESS_INFO_CONFIG T,
|
||||
(SELECT T.PROCESS_DEF_ID AS PROCESS_DEF_ID_, T.PROCESS_TYPE_ID AS PROCESS_TYPE_ID_, PROCESS_START_ORDER AS PROCESS_START_ORDER_
|
||||
FROM T_WF_PROCESS_INFO_CONFIG T
|
||||
GROUP BY T.PROCESS_DEF_ID, PROCESS_START_ORDER, PROCESS_TYPE_ID
|
||||
ORDER BY T.PROCESS_TYPE_ID, T.PROCESS_START_ORDER) C
|
||||
|
||||
<include refid="ProcessInfoConfig.findPage.where"/>
|
||||
|
||||
<if test="@Ognl@isNotEmpty(sortColumns)">
|
||||
ORDER BY ${sortColumns}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="ProcessInfoConfig.findConfigAndModelPage.count" resultType="long">
|
||||
SELECT count(*) FROM T_WF_PROCESS_INFO_CONFIG t left join T_SYS_GL_TYPE g on t.PROCESS_TYPE_ID=g.type_id
|
||||
left join act_re_model m on t.deployment_id =m.deployment_id_
|
||||
<include refid="ProcessInfoConfig.findConfigPage.where"/>
|
||||
</select>
|
||||
|
||||
<!-- 流程配置和建模 -->
|
||||
<select id="ProcessInfoConfig.findConfigAndModelPage" resultMap="RM_ProcessInfoConfig">
|
||||
SELECT <include refid="ProcessInfoConfig.columns" />,g.type_name as PROCESS_TYPE_NAME,m.id_ as MODEL_ID
|
||||
FROM T_WF_PROCESS_INFO_CONFIG t left join T_SYS_GL_TYPE g on t.PROCESS_TYPE_ID=g.type_id
|
||||
left join act_re_model m on t.deployment_id =m.deployment_id_
|
||||
<include refid="ProcessInfoConfig.findConfigPage.where"/>
|
||||
<if test="@Ognl@isNotEmpty(sortColumns)">
|
||||
ORDER BY ${sortColumns}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getPreTaskInstance" resultType="string">
|
||||
select assignee_ from t_wf_hi_taskinst t where t.proc_inst_id_=#{processInstanceId} and pre_task_id=#{taskId} and end_time_ is not null
|
||||
</select>
|
||||
|
||||
<!-- 流程引擎扩展SQL
|
||||
<select id="getSubProcessInstance" resultType="string">
|
||||
select * from ACT_HI_PROCINST p where FIND_IN_SET(proc_inst_id_, getprocchildlst(#{processInstanceId}))
|
||||
</select>
|
||||
<select id="getAllProcessInstance" resultType="string">
|
||||
select id_, proc_inst_id_, business_key_, proc_def_id_, start_time_, end_time_, duration_, start_user_id_, start_act_id_, end_act_id_, super_process_instance_id_, delete_reason_, tenant_id_, name_, proc_title, proc_state, proc_def_name, starter_org_name, starter_org_id, starter, top_process_instance_id_,
|
||||
(select assignee_user_name from( select tk.assignee_user_name,proc_inst_id_ from ACT_HI_TASKINST tk order by tk.start_time_) tk
|
||||
where tk.proc_inst_id_=p.id_ limit 1) as START_USER_NAME from ACT_HI_PROCINST p where FIND_IN_SET(
|
||||
proc_inst_id_, getprocchildlst((select t.top_process_instance_id_ from ACT_HI_PROCINST t
|
||||
where t.proc_inst_id_=#{processInstanceId} limit 1)))
|
||||
</select>
|
||||
|
||||
<select id="getTopProcessInstance" resultType="string">
|
||||
select * from ACT_HI_PROCINST p where p.PROC_INST_ID_ in(
|
||||
select t.top_process_instance_id_ from ACT_HI_PROCINST t
|
||||
where t.proc_inst_id_=#{processInstanceId}) limit 1
|
||||
</select>
|
||||
<select id="getSubProcessInstanceIds" resultType="string">
|
||||
select * from ACT_HI_PROCINST t where t.super_process_instance_id_=#{processInstanceId}
|
||||
</select>
|
||||
|
||||
<select id="getTopProcessAllTasks" resultType="string">
|
||||
select *from ACT_RU_TASK t where t.proc_inst_id_ in(select p.proc_inst_id_ from ACT_HI_PROCINST p where p.top_process_instance_id_=#{processInstanceId})
|
||||
</select>
|
||||
|
||||
<select id="findBackAvtivity" resultType="string">
|
||||
select t.* from act_hi_taskinst t,(select t.task_def_key_,max(t.end_time_) as end_time from act_hi_taskinst t
|
||||
WHERE t.proc_inst_id_=#{processInstanceId}
|
||||
and task_def_key_!= #{actDefId}
|
||||
and end_time_ is not null and t.delete_reason_!='custom-completed' group by task_def_key_) a where t.task_def_key_=a.task_def_key_ and t.end_time_=a.end_time
|
||||
and t.proc_inst_id_=#{processInstanceId} order by start_time_
|
||||
</select> -->
|
||||
</mapper>
|
||||
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* 该类主要负责系统主要业务逻辑的实现,如多表处理的事务操作、权限控制等
|
||||
* 该类根据具体的业务逻辑来调用该实体对应的Dao或者多个Dao来实现数据库操作
|
||||
* 实际的数据库操作在对应的Dao或其他Dao中实现
|
||||
*/
|
||||
|
||||
package com.blueland.bpm.engine.config.service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.bpmn.model.FlowElement;
|
||||
import org.activiti.bpmn.model.Process;
|
||||
import org.activiti.bpmn.model.UserTask;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.base.BaseManager;
|
||||
import com.blueland.bpm.common.base.EntityDao;
|
||||
import com.blueland.bpm.common.page.Page;
|
||||
import com.blueland.bpm.engine.config.dao.ActivityInfoConfigDao;
|
||||
import com.blueland.bpm.engine.config.model.ActivityInfoConfig;
|
||||
import com.blueland.bpm.engine.config.model.ActivityOperatePower;
|
||||
import com.blueland.bpm.engine.core.model.ProcessDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessDefinitionService;
|
||||
import com.blueland.bpm.engine.core.service.ProcessModelService;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
|
||||
/**
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @since
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class ActivityInfoConfigManager extends BaseManager<ActivityInfoConfig,String>{
|
||||
@Autowired
|
||||
//ActivityInfoConfig对应的DAO类,主要用于数据库的增删改查等操作
|
||||
private ActivityInfoConfigDao activityInfoConfigDao;
|
||||
@Autowired
|
||||
private ActivityOperatePowerManager activityOperatePowerManager;
|
||||
@Autowired
|
||||
private ProcessDefinitionService processDefinitionService;
|
||||
@Autowired
|
||||
private ProcessModelService processModelService;
|
||||
|
||||
public EntityDao getEntityDao() {
|
||||
return this.activityInfoConfigDao;
|
||||
}
|
||||
//分页查询
|
||||
public Page findPage(ActivityInfoConfig query) {
|
||||
return activityInfoConfigDao.pageQuery(query);
|
||||
}
|
||||
/*public void updateAndFlush(ActivityInfoConfig entity){
|
||||
if(StringUtils.isEmpty(entity.getActivityStatusName())){
|
||||
entity.setActivityStatusName(entity.getActivityDefName());
|
||||
}
|
||||
activityInfoConfigDao.update(entity);
|
||||
if(comparisonActvity(entity)){
|
||||
//获取最新版本的流程定义
|
||||
BpmnModel bpmnModel=processModelService.getBpmnModelByProcDefId(entity.getProcessDefId());
|
||||
UserTask userTask=findAct(bpmnModel,entity.getActivityDefId());
|
||||
userTask.setName(entity.getActivityDefName());
|
||||
//获取最新版本的流程定义
|
||||
ProcessDefinitionModel proceDefModel=processDefinitionService.getProcessDef(entity.getProcessDefId());
|
||||
//更新bpmn.xml
|
||||
processDefinitionService.updateDeploymentResource(proceDefModel.getDeploymentId(),proceDefModel.getProcessDefinitionId(),processModelService.convertBpmnModelToByte(bpmnModel,proceDefModel.getProcessDefinitionId()),true);
|
||||
//更新流程定义缓存
|
||||
processDefinitionService.refreshProcessDefineCache(proceDefModel.getProcessDefinitionId());
|
||||
}
|
||||
|
||||
}*/
|
||||
public void update(ActivityInfoConfig entity){
|
||||
if(StringUtils.isEmpty(entity.getActivityStatusName())){
|
||||
entity.setActivityStatusName(entity.getActivityDefName());
|
||||
}if(StringUtils.isEmpty(entity.getActivityDefType())){
|
||||
entity.setActivityDefType(BpmnXMLConstants.ELEMENT_TASK_USER);
|
||||
}
|
||||
activityInfoConfigDao.update(entity);
|
||||
}
|
||||
private UserTask findAct(BpmnModel bpmnModel,String actId){
|
||||
//List userList=new ArrayList();
|
||||
UserTask userTask = null;
|
||||
if (bpmnModel == null) {
|
||||
return userTask;
|
||||
}
|
||||
FlowElement flowElement=bpmnModel.getFlowElement(actId);
|
||||
if(flowElement==null){
|
||||
return userTask;
|
||||
}
|
||||
if (!UserTask.class.isInstance(flowElement)) {
|
||||
return userTask;
|
||||
}
|
||||
userTask = (UserTask) flowElement;
|
||||
return userTask;
|
||||
}
|
||||
private boolean comparisonActvity(ActivityInfoConfig params){
|
||||
ActivityInfoConfig entity=this.getActivityInfoConfig(params.getProcessDefId(),params.getActivityDefId());
|
||||
if(!params.getActivityDefName().equals(entity.getActivityDefName())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void save(ActivityInfoConfig entity){
|
||||
if(StringUtils.isEmpty(entity.getActivityStatusName())){
|
||||
entity.setActivityStatusName(entity.getActivityDefName());
|
||||
}
|
||||
if(StringUtils.isEmpty(entity.getActivityDefChildType())){
|
||||
entity.setActivityDefChildType(ActivityInfoConfig.ACTIVITY_DEF_CHILD_TYPE_INSIDE);
|
||||
}if(StringUtils.isEmpty(entity.getIdeaDisplayArea())){
|
||||
entity.setActivityDefChildType(ActivityInfoConfig.ACTIVITY_DEF_CHILD_TYPE_INSIDE);
|
||||
}
|
||||
activityInfoConfigDao.save(entity);
|
||||
}
|
||||
public ActivityInfoConfig getActivityInfoConfig(String procDefId,
|
||||
String activityDefId) throws WorkFlowException {
|
||||
ActivityInfoConfig param=new ActivityInfoConfig();
|
||||
param.setActivityDefId(activityDefId);
|
||||
param.setProcessDefId(procDefId);
|
||||
return activityInfoConfigDao.getByEntity(param);
|
||||
}
|
||||
|
||||
public List<ActivityInfoConfig> findActivityInfoConfigs(String procDefId) throws WorkFlowException {
|
||||
ActivityInfoConfig param=new ActivityInfoConfig();
|
||||
param.setProcessDefId(procDefId);
|
||||
return activityInfoConfigDao.findByExample(param);
|
||||
}
|
||||
|
||||
public boolean deleteActivityInfoConfigs(String procDefId) throws WorkFlowException {
|
||||
ActivityInfoConfig param=new ActivityInfoConfig();
|
||||
param.setProcessDefId(procDefId);
|
||||
return this.activityInfoConfigDao.getSqlSessionTemplate().delete(this.activityInfoConfigDao.getIbatisMapperNamesapce()+".deleteActivityInfoConfigs", param)>0;
|
||||
}
|
||||
|
||||
|
||||
public List<ActivityOperatePower> findActivityOperatePower(String procDefId,
|
||||
String activityDefId) throws WorkFlowException {
|
||||
List<ActivityOperatePower> activityOperatePowers=null;
|
||||
ActivityInfoConfig param=getActivityInfoConfig(procDefId,activityDefId);
|
||||
String operationRoleId=param.getActivityOperationRoleid();
|
||||
if(operationRoleId==null){
|
||||
return activityOperatePowers;
|
||||
}
|
||||
String[] operationRoleIds=null;
|
||||
if(operationRoleId.indexOf(";")!=-1){
|
||||
operationRoleIds=operationRoleId.split(";");
|
||||
}else{
|
||||
operationRoleIds=new String[]{operationRoleId};
|
||||
}
|
||||
activityOperatePowers=activityOperatePowerManager.findActivityOperatePowerByIds(Arrays.asList(operationRoleIds), "", "");
|
||||
return activityOperatePowers;
|
||||
}
|
||||
|
||||
public boolean addActivityOperatePower(List<String> opIds,String processDefId,
|
||||
String activityDefId) {
|
||||
if(opIds==null||opIds.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
ActivityInfoConfig activityInfoConfig=getActivityInfoConfig(processDefId,activityDefId);
|
||||
String activityOperationRoleid=activityInfoConfig.getActivityOperationRoleid();
|
||||
String[] existOpIds=null;
|
||||
if(StringUtils.isNotEmpty(activityOperationRoleid)){
|
||||
if(activityOperationRoleid.indexOf(";")!=-1){
|
||||
existOpIds=activityOperationRoleid.split(";");
|
||||
}else{
|
||||
existOpIds=new String[]{activityOperationRoleid};
|
||||
}
|
||||
|
||||
for (int i=0;i<opIds.size();i++) {
|
||||
for (String existOpId : existOpIds) {
|
||||
if(existOpId.equals(opIds.get(i))){
|
||||
opIds.remove(i);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(opIds.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
if(existOpIds!=null){
|
||||
opIds.addAll(Arrays.asList(existOpIds));
|
||||
}
|
||||
String allOpId=convertAllOpIds(opIds);
|
||||
activityInfoConfig.setActivityOperationRoleid(allOpId);
|
||||
activityInfoConfigDao.update(activityInfoConfig);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeActivityOperatePower(List<String> opIds,String processDefId,
|
||||
String activityDefId) {
|
||||
if(opIds==null||opIds.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
ActivityInfoConfig activityInfoConfig=getActivityInfoConfig(processDefId,activityDefId);
|
||||
String[] existOpIds=null;
|
||||
if(activityInfoConfig.getActivityOperationRoleid().indexOf(";")!=-1){
|
||||
existOpIds=activityInfoConfig.getActivityOperationRoleid().split(";");
|
||||
}else{
|
||||
existOpIds=new String[]{activityInfoConfig.getActivityOperationRoleid()};
|
||||
}
|
||||
List<String> existOpIdList=new ArrayList<String>();
|
||||
existOpIdList.addAll(Arrays.asList(existOpIds));
|
||||
for (int i=0;i<existOpIdList.size();i++) {
|
||||
for (String opId : opIds) {
|
||||
if(existOpIdList.get(i).equals(opId)){
|
||||
existOpIdList.remove(i);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String allOpId=convertAllOpIds(existOpIdList);
|
||||
activityInfoConfig.setActivityOperationRoleid(allOpId);
|
||||
activityInfoConfigDao.update(activityInfoConfig);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void remove(String processDefId,String activityDefId) {
|
||||
Map params=new HashMap();
|
||||
params.put("processDefId", processDefId);
|
||||
params.put("activityDefId", activityDefId);
|
||||
this.activityInfoConfigDao.getSqlSessionTemplate().delete(this.activityInfoConfigDao.getIbatisMapperNamesapce()+".delete", params);
|
||||
}
|
||||
|
||||
|
||||
private String convertAllOpIds(List<String> list){
|
||||
String allOpId="";
|
||||
for (String opId : list) {
|
||||
allOpId+=opId+";";
|
||||
}
|
||||
if(!allOpId.equals("")){
|
||||
allOpId=allOpId.substring(0,allOpId.lastIndexOf(";"));
|
||||
}
|
||||
return allOpId;
|
||||
}
|
||||
public void updateByProcessDefName(String processDefId,String processDefName){
|
||||
Map params=new HashMap();
|
||||
params.put("processDefId", processDefId);
|
||||
params.put("processDefName", processDefName);
|
||||
this.activityInfoConfigDao.getSqlSessionTemplate().delete(this.activityInfoConfigDao.getIbatisMapperNamesapce()+".updateByProcessDefName", params);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 该类主要负责系统主要业务逻辑的实现,如多表处理的事务操作、权限控制等
|
||||
* 该类根据具体的业务逻辑来调用该实体对应的Dao或者多个Dao来实现数据库操作
|
||||
* 实际的数据库操作在对应的Dao或其他Dao中实现
|
||||
*/
|
||||
|
||||
package com.blueland.bpm.engine.config.service;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.base.BaseManager;
|
||||
import com.blueland.bpm.common.base.EntityDao;
|
||||
import com.blueland.bpm.common.page.Page;
|
||||
import com.blueland.bpm.engine.config.dao.ProcessInfoConfigDao;
|
||||
import com.blueland.bpm.engine.config.model.ProcessInfoConfig;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessDefinitionService;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
|
||||
/**
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @since
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class ProcessInfoConfigManager extends BaseManager<ProcessInfoConfig,String>{
|
||||
|
||||
@Autowired
|
||||
//ProcessInfoConfig对应的DAO类,主要用于数据库的增删改查等操作
|
||||
private ProcessInfoConfigDao processInfoConfigDao;
|
||||
@Autowired
|
||||
ProcessDefinitionService processDefinitionService;
|
||||
public EntityDao getEntityDao() {
|
||||
return this.processInfoConfigDao;
|
||||
}
|
||||
//分页查询
|
||||
public Page findPage(ProcessInfoConfig query) {
|
||||
return processInfoConfigDao.pageQuery(query);
|
||||
}
|
||||
|
||||
public Page<List<ProcessInfoConfig>> findConfigPage(ProcessInfoConfig query){
|
||||
return processInfoConfigDao.findConfigPage(query);
|
||||
}
|
||||
/**
|
||||
* 获取所有满足要求的procDefId以供导出zip
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public List<String> getAllProcessIdForExport(ProcessInfoConfig params){
|
||||
return processInfoConfigDao.getAllProcessIdForExport(params);
|
||||
}
|
||||
|
||||
public ProcessInfoConfig getById(String processDefId){
|
||||
if(StringUtils.isEmpty(processDefId)){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"processDefId is nulll");
|
||||
}
|
||||
ProcessInfoConfig processInfoConfig=processInfoConfigDao.getById(processDefId);
|
||||
if(processInfoConfig!=null){
|
||||
ProcessDefinitionModel processDefinition=processDefinitionService.getProcessDef(processDefId);
|
||||
processInfoConfig.setProcessDefName(processDefinition.getProcDefName());
|
||||
processInfoConfig.setProcessVersion(processDefinition.getVersion());
|
||||
processInfoConfig.setProcessDefKey(processDefinition.getProcDefKey());
|
||||
}
|
||||
return processInfoConfig;
|
||||
}
|
||||
|
||||
|
||||
public ProcessInfoConfig getLinkId(String processDefId){
|
||||
if(StringUtils.isEmpty(processDefId)){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"processDefId is nulll");
|
||||
}
|
||||
ProcessInfoConfig processInfoConfig=processInfoConfigDao.getLinkId(processDefId);
|
||||
if(processInfoConfig!=null){
|
||||
ProcessDefinitionModel processDefinition=processDefinitionService.getProcessDef(processInfoConfig.getProcessDefId());
|
||||
processInfoConfig.setProcessDefName(processDefinition.getProcDefName());
|
||||
processInfoConfig.setProcessVersion(processDefinition.getVersion());
|
||||
processInfoConfig.setProcessDefKey(processDefinition.getProcDefKey());
|
||||
}
|
||||
return processInfoConfig;
|
||||
}
|
||||
|
||||
public boolean saveOrUpdate(ProcessInfoConfig paramsConfig){
|
||||
boolean resultFlag=false;
|
||||
ProcessInfoConfig processInfoConfig=processInfoConfigDao.getById(paramsConfig.getProcessDefId());
|
||||
if(processInfoConfig==null){
|
||||
paramsConfig.setProcessModelSyncState(ProcessInfoConfig.PROCESS_MODEL_SYNC_STATE_Y);
|
||||
resultFlag=processInfoConfigDao.save(paramsConfig);
|
||||
}else{
|
||||
paramsConfig.setLastUpdateTime(new Date());
|
||||
if(StringUtils.isEmpty(paramsConfig.getProcessModelSyncState())){
|
||||
paramsConfig.setProcessModelSyncState(ProcessInfoConfig.PROCESS_MODEL_SYNC_STATE_Y);
|
||||
}if(StringUtils.isEmpty(paramsConfig.getProcessMgrIsshow())){
|
||||
paramsConfig.setProcessMgrIsshow(ProcessInfoConfig.PROCESS_MGR_ISSHOW_Y);
|
||||
}
|
||||
resultFlag=processInfoConfigDao.update(paramsConfig);
|
||||
}
|
||||
return resultFlag;
|
||||
}
|
||||
|
||||
|
||||
public void save(ProcessInfoConfig paramsConfig){
|
||||
if(paramsConfig==null)
|
||||
return;
|
||||
if(paramsConfig.getOtherSysDealStatus()==null){
|
||||
paramsConfig.setOtherSysDealStatus("yes");
|
||||
}
|
||||
processInfoConfigDao.save(paramsConfig);
|
||||
}
|
||||
|
||||
|
||||
public void recoverProcessInfoConfig(String procDefId){
|
||||
ProcessInfoConfig prevProcessInfoConfig=getPrevVersionProcessConfig(procDefId);
|
||||
if(prevProcessInfoConfig!=null){
|
||||
prevProcessInfoConfig.setProcessMgrIsshow(ProcessInfoConfig.PROCESS_MODEL_SYNC_STATE_Y);
|
||||
update(prevProcessInfoConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public ProcessInfoConfig getPrevVersionProcessConfig(String procDefId){
|
||||
ProcessInfoConfig processInfoConfig=null;
|
||||
String[] processDefinitionIdArray=procDefId.split(":");
|
||||
if(Integer.parseInt(processDefinitionIdArray[1])>1){
|
||||
processInfoConfig = getLinkId(processDefinitionIdArray[0]+":"+(Integer.parseInt(processDefinitionIdArray[1])-1));
|
||||
}
|
||||
return processInfoConfig;
|
||||
}
|
||||
|
||||
public void update(ProcessInfoConfig paramsConfig){
|
||||
paramsConfig.setLastUpdateTime(new Date());
|
||||
processInfoConfigDao.update(paramsConfig);
|
||||
}
|
||||
|
||||
public void updateProcessMgrIsshowN(String processDefKey){
|
||||
Map<String,Object> params=new HashMap<String,Object>();
|
||||
params.put("processDefKey", processDefKey);
|
||||
params.put("processMgrIsshow", "N");
|
||||
processInfoConfigDao.getSqlSessionTemplate().update(processInfoConfigDao.getIbatisMapperNamesapce()+".updateProcessMgrIsshow", params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setProcessInfoUpdateState(String processDefId){
|
||||
ProcessInfoConfig paramsConfig=this.getById(processDefId);
|
||||
paramsConfig.setLastUpdateTime(new Date());
|
||||
paramsConfig.setProcessMgrState("UPDATE");
|
||||
paramsConfig.setProcessModelSyncState(ProcessInfoConfig.PROCESS_MODEL_SYNC_STATE_N);
|
||||
processInfoConfigDao.update(paramsConfig);
|
||||
}
|
||||
|
||||
public void releaseProcessInfo(ProcessInfoConfig paramsConfig){
|
||||
paramsConfig.setLastUpdateTime(new Date());
|
||||
paramsConfig.setProcessMgrState("RELEASE");
|
||||
paramsConfig.setProcessModelSyncState(ProcessInfoConfig.PROCESS_MODEL_SYNC_STATE_Y);
|
||||
processInfoConfigDao.update(paramsConfig);
|
||||
}
|
||||
|
||||
public void unReleaseProcessInfo(ProcessInfoConfig paramsConfig){
|
||||
paramsConfig.setLastUpdateTime(new Date());
|
||||
paramsConfig.setProcessMgrState("UNRELEASE");
|
||||
processInfoConfigDao.update(paramsConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取经办任务接收人
|
||||
* @author hanj
|
||||
* @version 1.0
|
||||
*/
|
||||
public List<String> getPreTaskInstance(String processInstanceId,String taskId) {
|
||||
Map params=new HashMap();
|
||||
params.put("processInstanceId", processInstanceId);
|
||||
params.put("taskId", taskId);
|
||||
return processInfoConfigDao.getSqlSessionTemplate().selectList(processInfoConfigDao.getIbatisMapperNamesapce()+".getPreTaskInstance", params);
|
||||
}
|
||||
|
||||
public Page<List<ProcessInfoConfig>> findConfigAndModelPage(ProcessInfoConfig query){
|
||||
return processInfoConfigDao.findConfigAndModelPage(query);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricVariableInstance;
|
||||
import org.activiti.engine.impl.ProcessInstanceQueryImpl;
|
||||
import org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.impl.pvm.runtime.InterpretableExecution;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 补发多实例命令类,暂时只支持补发单环节多人任务实例
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @created 07-四月-2013 15:39:01
|
||||
*/
|
||||
public class AddCallActivityCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Variable names for outer instance(as described in spec)
|
||||
//环节接收变量
|
||||
protected final String ASSIGNEE = "assignee";
|
||||
//实例数
|
||||
protected final String NUMBER_OF_INSTANCES = "nrOfInstances";
|
||||
//存活实例数
|
||||
protected final String NUMBER_OF_ACTIVE_INSTANCES = "nrOfActiveInstances";
|
||||
//已完成的实例数
|
||||
protected final String NUMBER_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
|
||||
//当前循环实例下标
|
||||
// Variable names for inner instances (as described in the spec)
|
||||
protected final String LOOP_COUNTER = "loopCounter";
|
||||
//实例总数
|
||||
protected Integer nrOfInstances = 0;
|
||||
//当前活动的,比如,还没完成的,实例数量。 对于顺序执行的多实例,值一直为1。
|
||||
protected Integer nrOfActiveInstances = 0;
|
||||
//表示特定实例的在循环的索引值。可以使用activiti的elementIndexVariable属性修改loopCounter的变量名。
|
||||
protected Integer loopCounter = 0;
|
||||
//当前任务实例ID
|
||||
protected String taskId;
|
||||
//补发接收人列表
|
||||
protected List<String> receivers;
|
||||
protected Map<String, Object> variables;
|
||||
|
||||
public AddCallActivityCmd(String taskId, List<String> receivers,
|
||||
Map<String, Object> variables) {
|
||||
this.taskId = taskId;
|
||||
this.receivers = receivers;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
//获取当前任务实例
|
||||
Task task = commandContext.getTaskEntityManager().findTaskById(taskId);
|
||||
String processInstanceId = task.getProcessInstanceId();
|
||||
//获取发起多实例的任务实例
|
||||
ProcessInstanceQueryImpl query = new ProcessInstanceQueryImpl();
|
||||
query.processInstanceId(processInstanceId);
|
||||
ExecutionEntity executionEntityOfMany = commandContext.getExecutionEntityManager().getParentExecution(query);
|
||||
if(executionEntityOfMany==null){
|
||||
executionEntityOfMany = commandContext.getExecutionEntityManager().getTopExecution(query);
|
||||
}
|
||||
try {
|
||||
//根据补发接收列表创建多实例任务
|
||||
createInstances(task,executionEntityOfMany, commandContext);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the parallel case of spawning the instances. Will create child
|
||||
* executions accordingly for every instance needed.
|
||||
*/
|
||||
protected void createInstances(Task task,ActivityExecution execution,
|
||||
CommandContext commandContext)
|
||||
throws Exception {
|
||||
//初始化已有的多实例循环变量--子流程只能用ID(因为前面已经找了父execution
|
||||
initMultiVariable(commandContext, execution.getId());
|
||||
|
||||
//创建执行实例
|
||||
List<ExecutionEntity> concurrentExecutions = new ArrayList<ExecutionEntity>();
|
||||
//内嵌子流程结构 topExecution->多个内嵌子流节点Execution->每个执行路径的Execution
|
||||
for (String receiver: receivers) {
|
||||
//创建与execution平级的内嵌子流节点Execution
|
||||
ExecutionEntity concurrentExecution = (ExecutionEntity) execution.createExecution();
|
||||
concurrentExecution.setActive(true);
|
||||
concurrentExecution.setConcurrent(true);
|
||||
concurrentExecution.setScope(false);
|
||||
concurrentExecution.setParentId(execution.getId());
|
||||
concurrentExecution.setParent((InterpretableExecution) execution);
|
||||
/*if (BpmnXMLConstants.ELEMENT_SUBPROCESS.equals(concurrentExecution.getActivity().getProperty("type"))||BpmnXMLConstants.ELEMENT_CALL_ACTIVITY.equals(concurrentExecution.getActivity().getProperty("type"))) {
|
||||
//创建每个执行路径的Execution
|
||||
ExecutionEntity extraScopedExecution = concurrentExecution.createExecution();
|
||||
//concurrentExecution.setParentId(extraScopedExecution.getId());
|
||||
extraScopedExecution.setActive(true);
|
||||
extraScopedExecution.setConcurrent(true);
|
||||
extraScopedExecution.setScope(false);
|
||||
//extraScopedExecution.setParentId(execution.getParentId());
|
||||
concurrentExecution = extraScopedExecution;
|
||||
|
||||
}*/
|
||||
concurrentExecutions.add(concurrentExecution);
|
||||
}
|
||||
String callActivityProcDefKey=ProcessDefinitionUtils.getCallActivityKey((ActivityImpl) execution.getActivity());
|
||||
//执行活动
|
||||
for (int i = 0; i < receivers.size(); i++) {
|
||||
ExecutionEntity concurrentExecution = (ExecutionEntity) concurrentExecutions.get(i);
|
||||
//递增循环变量
|
||||
concurrentExecution.setVariableLocal("assignee", receivers.get(i));
|
||||
concurrentExecution.setVariableLocal(LOOP_COUNTER, loopCounter++);
|
||||
execution.setVariable(NUMBER_OF_INSTANCES,
|
||||
++nrOfInstances);
|
||||
execution.setVariable(NUMBER_OF_ACTIVE_INSTANCES,
|
||||
++nrOfActiveInstances);
|
||||
concurrentExecution.setSenderOrgId(task.getSenderOrgId());
|
||||
concurrentExecution.setSendUserName(task.getSendUserName());
|
||||
concurrentExecution.setSenderOrgName(task.getSenderOrgName());
|
||||
concurrentExecution.setSendUserId(task.getSendUserId());
|
||||
concurrentExecution.setSender(task.getSender());
|
||||
variables.put("wf_preTaskDefKey", task.getPreTaskDefKey());
|
||||
variables.put("wf_preTaskDefName", task.getPreTaskDefName());
|
||||
variables.put("wf_preTaskId", task.getPreTaskId());
|
||||
concurrentExecution.setVariablesLocal(variables);
|
||||
CallActivityBehavior call=new CallActivityBehavior(callActivityProcDefKey);
|
||||
|
||||
call.execute(concurrentExecution);
|
||||
}
|
||||
|
||||
// See ACT-1586: ExecutionQuery returns wrong results when using multi
|
||||
// instance on a receive task
|
||||
// The parent execution must be set to false, so it wouldn't show up in
|
||||
// the execution query
|
||||
// when using .activityId(something). Do not we cannot nullify the
|
||||
// activityId (that would
|
||||
// have been a better solution), as it would break boundary event
|
||||
// behavior.
|
||||
if (!concurrentExecutions.isEmpty()) {
|
||||
// ExecutionEntity executionEntity = (ExecutionEntity) execution;
|
||||
//executionEntity.setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void initMultiVariable(CommandContext commandContext,
|
||||
String executionId) {
|
||||
/*
|
||||
* 更新多实例相关变量
|
||||
*/
|
||||
List<HistoricVariableInstance> list = commandContext.getProcessEngineConfiguration().getHistoryService().createHistoricVariableInstanceQuery().executionId(executionId).list();
|
||||
for (HistoricVariableInstance var : list) {
|
||||
if (var.getVariableName().equals("nrOfInstances")) {
|
||||
this.nrOfInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("nrOfActiveInstances")) {
|
||||
this.nrOfActiveInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("loopCounter")) {
|
||||
Integer tempLoopCounter = (Integer) var.getValue();
|
||||
if (tempLoopCounter!= null&&tempLoopCounter > loopCounter) {
|
||||
this.loopCounter = tempLoopCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.history.HistoricVariableInstance;
|
||||
import org.activiti.engine.impl.NativeExecutionQueryImpl;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntityManager;
|
||||
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
|
||||
/**
|
||||
* 补发多实例命令类,暂时只支持补发单环节多人任务实例
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @created 07-四月-2013 15:39:01
|
||||
*/
|
||||
public class AddMultiInstanceCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Variable names for outer instance(as described in spec)
|
||||
//环节接收变量
|
||||
protected final String ASSIGNEE = "assignee";
|
||||
//实例数
|
||||
protected final String NUMBER_OF_INSTANCES = "nrOfInstances";
|
||||
//存活实例数
|
||||
protected final String NUMBER_OF_ACTIVE_INSTANCES = "nrOfActiveInstances";
|
||||
//已完成的实例数
|
||||
protected final String NUMBER_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
|
||||
//当前循环实例下标
|
||||
// Variable names for inner instances (as described in the spec)
|
||||
protected final String LOOP_COUNTER = "loopCounter";
|
||||
|
||||
protected Integer nrOfInstances = 0;
|
||||
protected Integer nrOfActiveInstances = 0;
|
||||
protected Integer loopCounter = 0;
|
||||
//当前任务实例ID
|
||||
protected String taskId;
|
||||
//补发接收人列表
|
||||
protected List<String> receivers;
|
||||
protected Map<String, Object> variables;
|
||||
|
||||
public AddMultiInstanceCmd(String taskId, List<String> receivers,
|
||||
Map<String, Object> variables) {
|
||||
this.taskId = taskId;
|
||||
this.receivers = receivers;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
//获取当前任务实例
|
||||
Task task = commandContext.getTaskEntityManager().findTaskById(taskId);
|
||||
String processInstanceId = task.getProcessInstanceId();
|
||||
// 获取发起多实例的任务实例
|
||||
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
|
||||
List<ExecutionEntity> parentExecutions = executionEntityManager
|
||||
.findChildExecutionsByParentExecutionId(processInstanceId);
|
||||
List<ExecutionEntity> childExecutions = executionEntityManager
|
||||
.findChildExecutionsByParentExecutionId(parentExecutions.get(0).getId());
|
||||
ExecutionEntity executionEntityOfMany = childExecutions.get(0);
|
||||
try {
|
||||
//根据补发接收列表创建多实例任务
|
||||
createInstances(task,executionEntityOfMany, commandContext);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the parallel case of spawning the instances. Will create child
|
||||
* executions accordingly for every instance needed.
|
||||
*/
|
||||
protected void createInstances(Task task,ActivityExecution execution,
|
||||
CommandContext commandContext)
|
||||
throws Exception {
|
||||
//初始化已有的多实例循环变量
|
||||
initMultiVariable(commandContext, execution.getParentId());
|
||||
|
||||
//创建执行实例
|
||||
List<ExecutionEntity> concurrentExecutions = new ArrayList<ExecutionEntity>();
|
||||
//内嵌子流程结构 topExecution->多个内嵌子流节点Execution->每个执行路径的Execution
|
||||
for (String receiver: receivers) {
|
||||
//创建与execution平级的内嵌子流节点Execution
|
||||
ExecutionEntity concurrentExecution = (ExecutionEntity) execution.createExecution();
|
||||
concurrentExecution.setActive(true);
|
||||
concurrentExecution.setConcurrent(true);
|
||||
concurrentExecution.setScope(false);
|
||||
concurrentExecution.setParentId(execution.getParentId());
|
||||
if (BpmnXMLConstants.ELEMENT_SUBPROCESS.equals(concurrentExecution.getActivity().getProperty("type"))) {
|
||||
//创建每个执行路径的Execution
|
||||
ExecutionEntity extraScopedExecution = concurrentExecution.createExecution();
|
||||
//concurrentExecution.setParentId(extraScopedExecution.getId());
|
||||
extraScopedExecution.setActive(true);
|
||||
extraScopedExecution.setConcurrent(false);
|
||||
extraScopedExecution.setScope(true);
|
||||
//extraScopedExecution.setParentId(execution.getParentId());
|
||||
concurrentExecution = extraScopedExecution;
|
||||
|
||||
}
|
||||
concurrentExecutions.add(concurrentExecution);
|
||||
}
|
||||
//执行活动
|
||||
for (int i = 0; i < receivers.size(); i++) {
|
||||
ExecutionEntity concurrentExecution = (ExecutionEntity) concurrentExecutions.get(i);
|
||||
//递增循环变量
|
||||
concurrentExecution.setVariableLocal("assignee", receivers.get(i));
|
||||
concurrentExecution.setVariableLocal(LOOP_COUNTER, ++loopCounter);
|
||||
concurrentExecution.setVariable(NUMBER_OF_INSTANCES,
|
||||
++nrOfInstances);
|
||||
concurrentExecution.setVariable(NUMBER_OF_ACTIVE_INSTANCES,
|
||||
++nrOfActiveInstances);
|
||||
concurrentExecution.setSenderOrgId(task.getSenderOrgId());
|
||||
concurrentExecution.setSendUserName(task.getSendUserName());
|
||||
concurrentExecution.setSenderOrgName(task.getSenderOrgName());
|
||||
concurrentExecution.setSendUserId(task.getSendUserId());
|
||||
concurrentExecution.setSender(task.getSender());
|
||||
variables.put("wf_preTaskDefKey", task.getPreTaskDefKey());
|
||||
variables.put("wf_preTaskDefName", task.getPreTaskDefName());
|
||||
variables.put("wf_preTaskId", task.getPreTaskId());
|
||||
concurrentExecution.setVariablesLocal(variables);
|
||||
concurrentExecution.executeActivity(concurrentExecution.getActivity());
|
||||
}
|
||||
|
||||
// See ACT-1586: ExecutionQuery returns wrong results when using multi
|
||||
// instance on a receive task
|
||||
// The parent execution must be set to false, so it wouldn't show up in
|
||||
// the execution query
|
||||
// when using .activityId(something). Do not we cannot nullify the
|
||||
// activityId (that would
|
||||
// have been a better solution), as it would break boundary event
|
||||
// behavior.
|
||||
if (!concurrentExecutions.isEmpty()) {
|
||||
// ExecutionEntity executionEntity = (ExecutionEntity) execution;
|
||||
//executionEntity.setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void initMultiVariable(CommandContext commandContext,
|
||||
String executionId) {
|
||||
/*
|
||||
* 更新多实例相关变量
|
||||
*/
|
||||
List<HistoricVariableInstance> list = commandContext.getProcessEngineConfiguration().getHistoryService().createHistoricVariableInstanceQuery().executionId(executionId).list();
|
||||
for (HistoricVariableInstance var : list) {
|
||||
if (var.getVariableName().equals("nrOfInstances")) {
|
||||
this.nrOfInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("nrOfActiveInstances")) {
|
||||
this.nrOfActiveInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("loopCounter")) {
|
||||
Integer tempLoopCounter = (Integer) var.getValue();
|
||||
if (tempLoopCounter!= null&&tempLoopCounter > loopCounter) {
|
||||
this.loopCounter = tempLoopCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricVariableInstance;
|
||||
import org.activiti.engine.impl.ProcessInstanceQueryImpl;
|
||||
import org.activiti.engine.impl.bpmn.behavior.InclusiveGatewayActivityBehavior2;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.pvm.PvmActivity;
|
||||
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
|
||||
/**
|
||||
* 补发多实例命令类,暂时只支持补发单环节多人任务实例
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @created 07-四月-2013 15:39:01
|
||||
*/
|
||||
public class AddParallerMultiInstanceCmd extends InclusiveGatewayActivityBehavior2 implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Variable names for outer instance(as described in spec)
|
||||
//环节接收变量
|
||||
protected final String ASSIGNEE = "assignee";
|
||||
//实例数
|
||||
protected final String NUMBER_OF_INSTANCES = "nrOfInstances";
|
||||
//存活实例数
|
||||
protected final String NUMBER_OF_ACTIVE_INSTANCES = "nrOfActiveInstances";
|
||||
//已完成的实例数
|
||||
protected final String NUMBER_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
|
||||
//当前循环实例下标
|
||||
// Variable names for inner instances (as described in the spec)
|
||||
protected final String LOOP_COUNTER = "loopCounter";
|
||||
|
||||
protected Integer nrOfInstances = 0;
|
||||
protected Integer nrOfActiveInstances = 0;
|
||||
protected Integer loopCounter = 0;
|
||||
//当前任务实例ID
|
||||
protected String taskId;
|
||||
//补发接收人列表
|
||||
protected List<String> receivers;
|
||||
protected Map<String, Object> variables;
|
||||
|
||||
public AddParallerMultiInstanceCmd(String taskId, List<String> receivers,
|
||||
Map<String, Object> variables) {
|
||||
this.taskId = taskId;
|
||||
this.receivers = receivers;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
//获取当前任务实例
|
||||
Task task = commandContext.getTaskEntityManager().findTaskById(taskId);
|
||||
String processInstanceId = task.getProcessInstanceId();
|
||||
String taskDefinitionKey = task.getTaskDefinitionKey();
|
||||
// 获取发起多实例的任务实例
|
||||
ExecutionEntity executionEntityOfMany = getParentExecution(processInstanceId,commandContext);
|
||||
try {
|
||||
//executionEntityOfMany.inactivate();
|
||||
//lockConcurrentRoot(executionEntityOfMany);
|
||||
PvmActivity activity = executionEntityOfMany.getActivity();
|
||||
if (!activeConcurrentExecutionsExist(executionEntityOfMany)) {
|
||||
//根据补发接收列表创建多实例任务
|
||||
createInstances(executionEntityOfMany, commandContext,
|
||||
processInstanceId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the parallel case of spawning the instances. Will create child
|
||||
* executions accordingly for every instance needed.
|
||||
*/
|
||||
protected void createInstances(ActivityExecution execution,
|
||||
CommandContext commandContext, String processIntsanceId)
|
||||
throws Exception {
|
||||
//初始化已有的多实例循环变量
|
||||
initMultiVariable(commandContext, processIntsanceId);
|
||||
//创建执行实例
|
||||
List<ActivityExecution> concurrentExecutions = new ArrayList<ActivityExecution>();
|
||||
for (String receiver: receivers) {
|
||||
ExecutionEntity concurrentExecution = (ExecutionEntity) execution.createExecution();
|
||||
concurrentExecution.setActive(true);
|
||||
concurrentExecution.setConcurrent(false);
|
||||
concurrentExecution.setScope(true);
|
||||
concurrentExecution.setParentId(execution.getProcessInstanceId());
|
||||
//if (BpmnXMLConstants.ELEMENT_SUBPROCESS.equals(concurrentExecution.getActivity().getProperty("type"))) {
|
||||
ExecutionEntity extraScopedExecution = concurrentExecution.createExecution();
|
||||
extraScopedExecution.setActive(true);
|
||||
extraScopedExecution.setConcurrent(true);
|
||||
extraScopedExecution.setScope(false);
|
||||
concurrentExecution = extraScopedExecution;
|
||||
//}
|
||||
concurrentExecutions.add(concurrentExecution);
|
||||
}
|
||||
//执行活动
|
||||
for (int i = 0; i < receivers.size(); i++) {
|
||||
ActivityExecution concurrentExecution = concurrentExecutions.get(i);
|
||||
if (concurrentExecution.isActive()
|
||||
&& !concurrentExecution.isEnded()
|
||||
//&& concurrentExecution.getParent().isActive()
|
||||
&& !concurrentExecution.getParent().isEnded()) {
|
||||
//递增循环变量
|
||||
concurrentExecution.setVariableLocal("assignee", receivers.get(i));
|
||||
concurrentExecution.setVariableLocal(LOOP_COUNTER, ++loopCounter);
|
||||
concurrentExecution.setVariable(NUMBER_OF_INSTANCES,
|
||||
++nrOfInstances);
|
||||
concurrentExecution.setVariable(NUMBER_OF_ACTIVE_INSTANCES,
|
||||
++nrOfActiveInstances);
|
||||
concurrentExecution.setVariablesLocal(variables);
|
||||
concurrentExecution.executeActivity(concurrentExecution.getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
// See ACT-1586: ExecutionQuery returns wrong results when using multi
|
||||
// instance on a receive task
|
||||
// The parent execution must be set to false, so it wouldn't show up in
|
||||
// the execution query
|
||||
// when using .activityId(something). Do not we cannot nullify the
|
||||
// activityId (that would
|
||||
// have been a better solution), as it would break boundary event
|
||||
// behavior.
|
||||
if (!concurrentExecutions.isEmpty()) {
|
||||
ExecutionEntity executionEntity = (ExecutionEntity) execution;
|
||||
//executionEntity.setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void initMultiVariable(CommandContext commandContext,
|
||||
String processInstanceId) {
|
||||
/*
|
||||
* 更新多实例相关变量
|
||||
*/
|
||||
List<HistoricVariableInstance> list = commandContext.getProcessEngineConfiguration().getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list();
|
||||
for (HistoricVariableInstance var : list) {
|
||||
if (var.getVariableName().equals("nrOfInstances")) {
|
||||
this.nrOfInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("nrOfActiveInstances")) {
|
||||
this.nrOfActiveInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("loopCounter")) {
|
||||
Integer tempLoopCounter = (Integer) var.getValue();
|
||||
if (tempLoopCounter > loopCounter) {
|
||||
this.loopCounter = tempLoopCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程执行父路径
|
||||
*
|
||||
* @param topExecutionId
|
||||
* @param commandContext
|
||||
* @return
|
||||
*/
|
||||
public ExecutionEntity getParentExecution(String executionId,CommandContext commandContext) {
|
||||
ProcessInstanceQueryImpl query = new ProcessInstanceQueryImpl();
|
||||
query.processInstanceId(executionId);
|
||||
return commandContext.getExecutionEntityManager().getParentExecution(query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.service.ProcessTransitionFreeService;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
|
||||
/**
|
||||
* 退回上一步命令类
|
||||
* @author lw
|
||||
*/
|
||||
public class CallBackPrevTaskCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected String taskId;
|
||||
protected String backActivityId;
|
||||
protected Map<String,Object> variables;
|
||||
|
||||
public CallBackPrevTaskCmd(String taskId,String backActivityId,Map<String,Object> variables) {
|
||||
this.taskId = taskId;
|
||||
this.backActivityId=backActivityId;
|
||||
this.variables=variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
if (StringUtils.isEmpty(taskId)) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"taskId is empty");
|
||||
}
|
||||
if (StringUtils.isEmpty(backActivityId)) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"backActivityId is empty");
|
||||
}
|
||||
ProcessTransitionFreeService baseWfService = new ProcessTransitionFreeService(
|
||||
commandContext.getProcessEngineConfiguration());
|
||||
baseWfService.commitProcess(taskId,backActivityId, variables);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
import com.blueland.bpm.engine.core.service.ProcessTransitionFreeService;
|
||||
|
||||
/**
|
||||
* 撤回上一步命令类
|
||||
* @author lw
|
||||
*/
|
||||
public class CallBackTaskCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected String taskId;
|
||||
protected String backActivityId;
|
||||
protected Map<String,Object> variables;
|
||||
|
||||
public CallBackTaskCmd(String taskId,String backActivityId,Map<String,Object> variables) {
|
||||
this.taskId = taskId;
|
||||
this.backActivityId=backActivityId;
|
||||
this.variables=variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
ProcessTransitionFreeService baseWfService = new ProcessTransitionFreeService(
|
||||
commandContext.getProcessEngineConfiguration());
|
||||
baseWfService.commitProcess(taskId,backActivityId, variables);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessTransitionFreeService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
|
||||
/**
|
||||
* 退回起草命令类
|
||||
* @author lw
|
||||
*/
|
||||
public class CallBackToStartActivityCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected String taskId;
|
||||
protected String userId;
|
||||
protected Map<String,Object> variables;
|
||||
|
||||
public CallBackToStartActivityCmd(String taskId,String userId,Map<String,Object> variables) {
|
||||
this.taskId = taskId;
|
||||
this.userId=userId;
|
||||
this.variables=variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
if (StringUtils.isEmpty(taskId)) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"taskId is empty");
|
||||
}
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"userId is empty");
|
||||
}
|
||||
TaskEntity taskEntity = commandContext.getTaskEntityManager()
|
||||
.findTaskById(taskId);
|
||||
HistoricProcessInstanceEntity historicProcessInstanceEntity = commandContext
|
||||
.getHistoricProcessInstanceEntityManager()
|
||||
.findHistoricProcessInstance(taskEntity.getProcessInstanceId());
|
||||
ProcessInputModel processInputModel = ProcessDefinitionUtils
|
||||
.getWfprocessInputModel(variables);
|
||||
processInputModel.setWf_nextActDefId(historicProcessInstanceEntity
|
||||
.getStartActivityId());
|
||||
processInputModel.setWf_receiver(historicProcessInstanceEntity
|
||||
.getStartUserId());
|
||||
processInputModel.setWf_sender(userId);
|
||||
processInputModel.setWf_procInstId(historicProcessInstanceEntity
|
||||
.getProcessInstanceId());
|
||||
processInputModel.setWf_curActDefId(taskEntity.getTaskDefinitionKey());
|
||||
processInputModel.setWf_curActDefName(taskEntity.getName());
|
||||
processInputModel.setWf_curActInstId(taskEntity.getId());
|
||||
if(StringUtils.isEmpty(processInputModel.getWf_procTitle())){
|
||||
processInputModel.setWf_procTitle(taskEntity.getProcTitle());
|
||||
}
|
||||
variables.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
taskEntity.setActionType(processInputModel.getWf_actionType());
|
||||
ProcessTransitionFreeService baseWfService = new ProcessTransitionFreeService(
|
||||
commandContext.getProcessEngineConfiguration());
|
||||
baseWfService.commitProcess(taskEntity.getId(),
|
||||
historicProcessInstanceEntity.getStartActivityId(), variables);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.delegate.event.ActivitiEventType;
|
||||
import org.activiti.engine.delegate.event.impl.ActivitiEventBuilder;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.HistoricProcessInstanceQueryImpl;
|
||||
import org.activiti.engine.impl.ProcessInstanceQueryImpl;
|
||||
import org.activiti.engine.impl.context.Context;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.runtime.Execution;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
|
||||
/**
|
||||
* 流程作废命令类
|
||||
* @author lw
|
||||
*/
|
||||
public class CancelProcessInstanceCmd implements Command<Void>{
|
||||
protected final String executionId;
|
||||
protected final String taskId;
|
||||
protected final String reason;
|
||||
|
||||
public CancelProcessInstanceCmd(String executionId, String taskId,String reason) {
|
||||
this.executionId = executionId;
|
||||
this.taskId = taskId;
|
||||
this.reason=reason;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
TaskEntity task = null;
|
||||
if(taskId!=null){
|
||||
task = commandContext.getTaskEntityManager().findTaskById(taskId);
|
||||
}else{
|
||||
task=new TaskEntity();
|
||||
}
|
||||
ExecutionEntity curExecutionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
|
||||
ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findProcessDefinitionById(curExecutionEntity.getProcessDefinitionId());
|
||||
commandContext.getHistoryManager().recordProcessInstanceCancel(executionId, reason, task.getTaskDefinitionKey());
|
||||
// All child executions are suspended
|
||||
List<ExecutionEntity> childExecutions=new ArrayList<ExecutionEntity>();
|
||||
String topExecutionId="";
|
||||
if(StringUtils.isNotEmpty(curExecutionEntity.getSuperExecutionId())){
|
||||
topExecutionId=curExecutionEntity.getTopProcessInstanceId();
|
||||
List<ExecutionEntity> executions=getAllExecutionEntity(topExecutionId,commandContext);
|
||||
childExecutions.addAll(executions);
|
||||
}else{
|
||||
childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByProcessInstanceId(executionId);
|
||||
topExecutionId=curExecutionEntity.getProcessInstanceId();
|
||||
}
|
||||
|
||||
for (ExecutionEntity childExecution : childExecutions) {
|
||||
if (!childExecution.getId().equals(executionId)) {
|
||||
commandContext.getHistoryManager().recordProcessInstanceCancel(childExecution.getId(), reason, task.getTaskDefinitionKey());
|
||||
}
|
||||
}
|
||||
// All tasks are suspended
|
||||
List<HistoricProcessInstance> procInsts=getAllProcessInstance(topExecutionId,commandContext);
|
||||
for (HistoricProcessInstance historicProcessInstance : procInsts) {
|
||||
List<TaskEntity> tasks = commandContext.getTaskEntityManager()
|
||||
.findTasksByProcessInstanceId(historicProcessInstance.getId());
|
||||
for (TaskEntity taskEntity : tasks) {
|
||||
if(taskId!=null&&taskId.equals(taskEntity.getId())){
|
||||
taskEntity.setActionType(WorkFlowContants.ACTION_TYPE_CANCEL_PROCESS);
|
||||
commandContext.getHistoryManager().recordTaskUpdate(taskEntity);
|
||||
}
|
||||
taskEntity.setDescription(WorkFlowContants.ACTION_TYPE_CANCEL_PROCESS);
|
||||
commandContext.getTaskEntityManager().deleteTaskForce(taskEntity.getId(), reason, false);
|
||||
}
|
||||
}
|
||||
curExecutionEntity.setProcessDefinition(processDefinition);
|
||||
task.setProcessInstance(curExecutionEntity);
|
||||
Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
|
||||
ActivitiEventBuilder.createEntityEvent(ActivitiEventType.PROCESS_CANCEL, curExecutionEntity));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 找到所有流程列表(找子)
|
||||
* @param topExecutionId
|
||||
* @param commandContext
|
||||
* @return
|
||||
*/
|
||||
public List<HistoricProcessInstance> getAllProcessInstance(
|
||||
String topExecutionId, CommandContext commandContext) {
|
||||
HistoricProcessInstanceQueryImpl query = new HistoricProcessInstanceQueryImpl();
|
||||
query.processInstanceId(topExecutionId);
|
||||
List<HistoricProcessInstance> historicProcessInstances =commandContext.getHistoricProcessInstanceEntityManager().getAllProcessInstance(query);
|
||||
return historicProcessInstances;
|
||||
}
|
||||
|
||||
|
||||
public List<ExecutionEntity> getAllExecutionEntity(String topExecutionId,CommandContext commandContext){
|
||||
ProcessInstanceQueryImpl query = new ProcessInstanceQueryImpl();
|
||||
query.processInstanceId(topExecutionId);
|
||||
List<ExecutionEntity> executions = commandContext.getExecutionEntityManager().findAllExecution(query);
|
||||
List<ExecutionEntity> executionEntitys=new ArrayList<ExecutionEntity>();
|
||||
for (Execution execution : executions) {
|
||||
executionEntitys.add((ExecutionEntity) execution);
|
||||
}
|
||||
return executionEntitys;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.ActivitiException;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* 该类暂时无用
|
||||
* @author lw
|
||||
*/
|
||||
public class CounterSignCmd implements Command<Object> {
|
||||
private static Logger log = LoggerFactory.getLogger(CounterSignCmd.class);
|
||||
private String operateType;
|
||||
private String activityId;
|
||||
private List<String> assignees;
|
||||
private String processInstanceId;
|
||||
private String collectionVariableName;
|
||||
private String collectionElementVariableName;
|
||||
private CommandContext commandContext;
|
||||
private String taskId;
|
||||
|
||||
public CounterSignCmd(String operateType, List<String> assignees, String taskId) {
|
||||
this.operateType = operateType;
|
||||
this.assignees = assignees;
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operateType
|
||||
* 操作类型 add or remove
|
||||
* @param activityId
|
||||
* 节点ID
|
||||
* @param assignee
|
||||
* 人员代码
|
||||
* @param processInstanceId
|
||||
* 流程实例ID
|
||||
* @param collectionVariableName
|
||||
* collection 设置的变量名
|
||||
* @param collectionElementVariableName
|
||||
* collection 的每个元素变量名
|
||||
*/
|
||||
public CounterSignCmd(final String operateType, final String activityId,
|
||||
final List<String> assignees, final String processInstanceId,
|
||||
final String collectionVariableName,
|
||||
final String collectionElementVariableName) {
|
||||
this.operateType = operateType;
|
||||
this.activityId = activityId;
|
||||
this.assignees = assignees;
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.collectionVariableName = collectionVariableName;
|
||||
this.collectionElementVariableName = collectionElementVariableName;
|
||||
}
|
||||
|
||||
public Object execute(CommandContext commandContext) {
|
||||
this.commandContext = commandContext;
|
||||
|
||||
if (this.taskId != null) {
|
||||
TaskEntity taskEntity = commandContext.getTaskEntityManager()
|
||||
.findTaskById(taskId);
|
||||
activityId = taskEntity.getExecution().getActivityId();
|
||||
processInstanceId = taskEntity.getProcessInstanceId();
|
||||
this.collectionVariableName = "assigneeList";
|
||||
this.collectionElementVariableName = "assignee";
|
||||
}
|
||||
|
||||
if (operateType.equalsIgnoreCase("add")) {
|
||||
addInstance();
|
||||
} else if (operateType.equalsIgnoreCase("remove")) {
|
||||
removeInstance();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>加签
|
||||
*/
|
||||
public void addInstance() {
|
||||
if (isParallel()) {
|
||||
addParallelInstance();
|
||||
} else {
|
||||
addSequentialInstance();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>减签
|
||||
*/
|
||||
public void removeInstance() {
|
||||
for (String assignee : assignees) {
|
||||
if (isParallel()) {
|
||||
removeParallelInstance(assignee);
|
||||
} else {
|
||||
removeSequentialInstance(assignee);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>添加一条并行实例
|
||||
*/
|
||||
private void addParallelInstance() {
|
||||
ExecutionEntity parentExecutionEntity = commandContext
|
||||
.getExecutionEntityManager()
|
||||
.findExecutionById(processInstanceId).findExecution(activityId);
|
||||
ActivityImpl activity = getActivity();
|
||||
ExecutionEntity execution = parentExecutionEntity.createExecution();
|
||||
execution.setActive(true);
|
||||
execution.setConcurrent(true);
|
||||
execution.setScope(false);
|
||||
|
||||
if (getActivity().getProperty("type").equals("subProcess")) {
|
||||
ExecutionEntity extraScopedExecution = execution.createExecution();
|
||||
extraScopedExecution.setActive(true);
|
||||
extraScopedExecution.setConcurrent(false);
|
||||
extraScopedExecution.setScope(true);
|
||||
execution = extraScopedExecution;
|
||||
}
|
||||
|
||||
setLoopVariable(parentExecutionEntity, "nrOfInstances",
|
||||
(Integer) parentExecutionEntity
|
||||
.getVariableLocal("nrOfInstances") + 1);
|
||||
setLoopVariable(parentExecutionEntity, "nrOfActiveInstances",
|
||||
(Integer) parentExecutionEntity
|
||||
.getVariableLocal("nrOfActiveInstances") + 1);
|
||||
setLoopVariable(execution, "loopCounter", parentExecutionEntity
|
||||
.getExecutions().size() + 1);
|
||||
// setLoopVariable(execution, collectionElementVariableName, assignee);
|
||||
execution.executeActivity(activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>给串行实例集合中添加一个审批人
|
||||
*/
|
||||
private void addSequentialInstance() {
|
||||
ExecutionEntity execution = getActivieExecutions().get(0);
|
||||
|
||||
if (getActivity().getProperty("type").equals("subProcess")) {
|
||||
if (!execution.isActive()
|
||||
&& execution.isEnded()
|
||||
&& ((execution.getExecutions() == null) || (execution
|
||||
.getExecutions().size() == 0))) {
|
||||
execution.setActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
Collection<String> col = (Collection<String>) execution
|
||||
.getVariable(collectionVariableName);
|
||||
// col.add(assignee);
|
||||
execution.setVariable(collectionVariableName, col);
|
||||
setLoopVariable(execution, "nrOfInstances",
|
||||
(Integer) execution.getVariableLocal("nrOfInstances") + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>移除一条并行实例
|
||||
*/
|
||||
private void removeParallelInstance(String assignee) {
|
||||
List<ExecutionEntity> executions = getActivieExecutions();
|
||||
|
||||
for (ExecutionEntity executionEntity : executions) {
|
||||
String executionVariableAssignee = (String) executionEntity
|
||||
.getVariableLocal(collectionElementVariableName);
|
||||
|
||||
if ((executionVariableAssignee != null)
|
||||
&& executionVariableAssignee.equals(assignee)) {
|
||||
executionEntity.remove();
|
||||
|
||||
ExecutionEntity parentConcurrentExecution = executionEntity
|
||||
.getParent();
|
||||
|
||||
if (getActivity().getProperty("type").equals("subProcess")) {
|
||||
parentConcurrentExecution = parentConcurrentExecution
|
||||
.getParent();
|
||||
}
|
||||
|
||||
setLoopVariable(parentConcurrentExecution, "nrOfInstances",
|
||||
(Integer) parentConcurrentExecution
|
||||
.getVariableLocal("nrOfInstances") - 1);
|
||||
setLoopVariable(parentConcurrentExecution,
|
||||
"nrOfActiveInstances",
|
||||
(Integer) parentConcurrentExecution
|
||||
.getVariableLocal("nrOfActiveInstances") - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>冲串行列表中移除未完成的用户(当前执行的用户无法移除)
|
||||
*/
|
||||
private void removeSequentialInstance(String assignee) {
|
||||
ExecutionEntity executionEntity = getActivieExecutions().get(0);
|
||||
Collection<String> col = (Collection<String>) executionEntity
|
||||
.getVariable(collectionVariableName);
|
||||
log.info("移除前审批列表 : {}", col.toString());
|
||||
col.remove(assignee);
|
||||
executionEntity.setVariable(collectionVariableName, col);
|
||||
setLoopVariable(executionEntity, "nrOfInstances",
|
||||
(Integer) executionEntity.getVariableLocal("nrOfInstances") - 1);
|
||||
|
||||
// 如果串行要删除的人是当前active执行,
|
||||
if (executionEntity.getVariableLocal(collectionElementVariableName)
|
||||
.equals(assignee)) {
|
||||
throw new ActivitiException("当前正在执行的实例,无法移除!");
|
||||
}
|
||||
|
||||
log.info("移除后审批列表 : {}", col.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>获取活动的执行 , 子流程的活动执行是其孩子执行(并行多实例情况下) <li>串行情况下获取的结果数量为1
|
||||
*/
|
||||
protected List<ExecutionEntity> getActivieExecutions() {
|
||||
List<ExecutionEntity> activeExecutions = new ArrayList<ExecutionEntity>();
|
||||
ActivityImpl activity = getActivity();
|
||||
List<ExecutionEntity> executions = getChildExecutionByProcessInstanceId();
|
||||
|
||||
for (ExecutionEntity execution : executions) {
|
||||
if (execution.isActive()
|
||||
&& (execution.getActivityId().equals(activityId) || activity
|
||||
.contains(execution.getActivity()))) {
|
||||
activeExecutions.add(execution);
|
||||
}
|
||||
}
|
||||
|
||||
return activeExecutions;
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>获取流程实例根的所有子执行
|
||||
*/
|
||||
protected List<ExecutionEntity> getChildExecutionByProcessInstanceId() {
|
||||
return commandContext.getExecutionEntityManager()
|
||||
.findChildExecutionsByProcessInstanceId(processInstanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>返回当前节点对象
|
||||
*/
|
||||
protected ActivityImpl getActivity() {
|
||||
return this.getProcessDefinition().findActivity(activityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>判断节点多实例类型是否是并发
|
||||
*/
|
||||
protected boolean isParallel() {
|
||||
return getActivity().getProperty("multiInstance").equals("parallel");
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>返回流程定义对象
|
||||
*/
|
||||
protected ProcessDefinitionImpl getProcessDefinition() {
|
||||
return this.getProcessInstanceEntity().getProcessDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>返回流程实例的根执行对象
|
||||
*/
|
||||
protected ExecutionEntity getProcessInstanceEntity() {
|
||||
return commandContext.getExecutionEntityManager().findExecutionById(
|
||||
processInstanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>添加本地变量
|
||||
*/
|
||||
protected void setLoopVariable(ActivityExecution execution,
|
||||
String variableName, Object value) {
|
||||
execution.setVariableLocal(variableName, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.activiti.engine.ActivitiException;
|
||||
import org.activiti.engine.ActivitiObjectNotFoundException;
|
||||
import org.activiti.engine.delegate.event.ActivitiEventType;
|
||||
import org.activiti.engine.delegate.event.impl.ActivitiEventBuilder;
|
||||
import org.activiti.engine.impl.db.DbSqlSession;
|
||||
import org.activiti.engine.impl.identity.Authentication;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.AttachmentEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.util.IoUtil;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Attachment;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
|
||||
/**
|
||||
* 添加附件命令类
|
||||
* @author lw
|
||||
*/
|
||||
// Not Serializable
|
||||
public class CreateAttachmentCmd implements Command<Attachment> {
|
||||
|
||||
protected String attachmentType;
|
||||
protected String taskId;
|
||||
protected String processInstanceId;
|
||||
protected String attachmentName;
|
||||
protected String attachmentDescription;
|
||||
protected InputStream content;
|
||||
protected String url;
|
||||
|
||||
public CreateAttachmentCmd(String attachmentType, String taskId, String processInstanceId, String attachmentName, String attachmentDescription, InputStream content, String url) {
|
||||
this.attachmentType = attachmentType;
|
||||
this.taskId = taskId;
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.attachmentName = attachmentName;
|
||||
this.attachmentDescription = attachmentDescription;
|
||||
this.content = content;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Attachment execute(CommandContext commandContext) {
|
||||
|
||||
verifyParameters(commandContext);
|
||||
|
||||
AttachmentEntity attachment = new AttachmentEntity();
|
||||
attachment.setName(attachmentName);
|
||||
attachment.setDescription(attachmentDescription);
|
||||
attachment.setType(attachmentType);
|
||||
attachment.setTaskId(taskId);
|
||||
attachment.setProcessInstanceId(processInstanceId);
|
||||
attachment.setUrl(url);
|
||||
attachment.setUserId(Authentication.getAuthenticatedUserId());
|
||||
|
||||
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
|
||||
dbSqlSession.insert(attachment);
|
||||
|
||||
if (content != null) {
|
||||
byte[] bytes = IoUtil.readInputStream(content, attachmentName);
|
||||
ByteArrayEntity byteArray = ByteArrayEntity.createAndInsert(bytes);
|
||||
attachment.setContentId(byteArray.getId());
|
||||
}
|
||||
|
||||
commandContext.getHistoryManager()
|
||||
.createAttachmentComment(taskId, processInstanceId, attachmentName, true);
|
||||
|
||||
if(commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
|
||||
// Forced to fetch the process-instance to associate the right process definition
|
||||
String processDefinitionId = null;
|
||||
if(attachment.getProcessInstanceId() != null) {
|
||||
ExecutionEntity process = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
|
||||
if(process != null) {
|
||||
processDefinitionId = process.getProcessDefinitionId();
|
||||
}
|
||||
}
|
||||
|
||||
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
|
||||
ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, attachment, processInstanceId, processInstanceId, processDefinitionId));
|
||||
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
|
||||
ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, attachment, processInstanceId, processInstanceId, processDefinitionId));
|
||||
}
|
||||
|
||||
return attachment;
|
||||
}
|
||||
|
||||
private void verifyParameters(CommandContext commandContext) {
|
||||
if (taskId != null) {
|
||||
TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
|
||||
|
||||
if (task == null) {
|
||||
throw new ActivitiObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
|
||||
}
|
||||
|
||||
if (task.isSuspended()) {
|
||||
throw new ActivitiException("It is not allowed to add an attachment to a suspended task");
|
||||
}
|
||||
}
|
||||
|
||||
if (processInstanceId != null) {
|
||||
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
|
||||
|
||||
if (execution == null) {
|
||||
throw new ActivitiObjectNotFoundException("Process instance " + processInstanceId + " doesn't exist", ProcessInstance.class);
|
||||
}
|
||||
|
||||
if (execution.isSuspended()) {
|
||||
throw new ActivitiException("It is not allowed to add an attachment to a suspended process instance");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricVariableInstance;
|
||||
import org.activiti.engine.impl.TaskQueryImpl;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
|
||||
/**
|
||||
* 撤销多实例命令类,暂时只支持撤销单环节多人任务实例
|
||||
*
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @created 07-四月-2013 15:39:01
|
||||
*/
|
||||
public class DeleteCallActivityCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Variable names for outer instance(as described in spec)
|
||||
// 环节接收变量
|
||||
protected final String ASSIGNEE = "assignee";
|
||||
// 实例数
|
||||
protected final String NUMBER_OF_INSTANCES = "nrOfInstances";
|
||||
// 存活实例数
|
||||
protected final String NUMBER_OF_ACTIVE_INSTANCES = "nrOfActiveInstances";
|
||||
// 已完成的实例数
|
||||
protected final String NUMBER_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
|
||||
// 当前循环实例下标
|
||||
// Variable names for inner instances (as described in the spec)
|
||||
protected final String LOOP_COUNTER = "loopCounter";
|
||||
|
||||
protected Integer nrOfInstances = 0;
|
||||
protected Integer nrOfActiveInstances = 0;
|
||||
protected Integer loopCounter = 0;
|
||||
// 当前任务实例ID
|
||||
protected String processInstanceId;
|
||||
// 当前任务实例ID
|
||||
protected String actInstId;
|
||||
// 当前任务实例ID
|
||||
protected String actDefId;;
|
||||
// 补发接收人列表
|
||||
protected List<String> receivers;
|
||||
protected Map<String, Object> variables;
|
||||
|
||||
public DeleteCallActivityCmd(String processInstanceId,String actDefId,String actInstId, List<String> receivers,
|
||||
Map<String, Object> variables) {
|
||||
this.processInstanceId=processInstanceId;
|
||||
this.actDefId = actDefId;
|
||||
this.actInstId = actInstId;
|
||||
this.receivers = receivers;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
if(StringUtils.isNotEmpty(actInstId)){
|
||||
TaskEntity task = (TaskEntity) new TaskQueryImpl(commandContext).taskId(actInstId).singleResult();
|
||||
delete(task,commandContext);
|
||||
return null;
|
||||
}
|
||||
// 获取当前任务实例
|
||||
for (String receiver : receivers) {
|
||||
List<Task> tasks = new TaskQueryImpl(commandContext).processInstanceId(processInstanceId).taskAssignee(receiver).list();
|
||||
if(tasks==null||tasks.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
delete((TaskEntity) tasks.get(0),commandContext);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void delete(TaskEntity task,CommandContext commandContext){
|
||||
task.setActionType(WorkFlowContants.ACTION_TYPE_DELETE_MULTIINSTANCE_ACTIVITY);
|
||||
String processInstanceId = task.getProcessInstanceId();
|
||||
// 获取发起多实例的任务实例
|
||||
ExecutionEntity executionEntityOfMany =commandContext.getExecutionEntityManager().findExecutionById(task.getExecutionId());
|
||||
if(executionEntityOfMany.getSuperExecutionId()!=null){
|
||||
executionEntityOfMany =commandContext.getExecutionEntityManager().findExecutionById(executionEntityOfMany.getSuperExecutionId());
|
||||
if(executionEntityOfMany.getParentId()!=null){
|
||||
executionEntityOfMany =commandContext.getExecutionEntityManager().findExecutionById(executionEntityOfMany.getParentId());
|
||||
}
|
||||
}
|
||||
try {
|
||||
commandContext.getHistoryManager().recordTaskUpdate(task);
|
||||
// 根据补发接收列表创建多实例任务
|
||||
deleteInstances(task, executionEntityOfMany, commandContext);
|
||||
}catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the parallel case of spawning the instances. Will create child
|
||||
* executions accordingly for every instance needed.
|
||||
*/
|
||||
protected void deleteInstances(TaskEntity task, ExecutionEntity execution,
|
||||
CommandContext commandContext)
|
||||
throws Exception {
|
||||
//初始化已有的多实例循环变量--子流程只能用ID(因为前面已经找了父execution
|
||||
initMultiVariable(commandContext, execution.getId());
|
||||
if (this.nrOfActiveInstances == 0) {
|
||||
return;
|
||||
}
|
||||
// 更新已有的多实例循环变量
|
||||
updateMultiVariable(execution);
|
||||
execution.deleteCascade("");
|
||||
/*
|
||||
* commandContext.getTaskEntityManager().deleteTaskForce(task.getId(),
|
||||
* "", true);
|
||||
*/
|
||||
}
|
||||
|
||||
public void updateMultiVariable(ExecutionEntity execution) {
|
||||
execution.removeVariableLocal(ASSIGNEE);
|
||||
execution.removeVariableLocal(LOOP_COUNTER);
|
||||
execution.setVariable(NUMBER_OF_INSTANCES, --nrOfInstances);
|
||||
execution.setVariable(NUMBER_OF_ACTIVE_INSTANCES, --nrOfActiveInstances);
|
||||
}
|
||||
|
||||
public void initMultiVariable(CommandContext commandContext,
|
||||
String executionId) {
|
||||
/*
|
||||
* 更新多实例相关变量
|
||||
*/
|
||||
List<HistoricVariableInstance> list = commandContext.getProcessEngineConfiguration().getHistoryService().createHistoricVariableInstanceQuery().executionId(executionId).list();
|
||||
for (HistoricVariableInstance var : list) {
|
||||
if (var.getVariableName().equals("nrOfInstances")) {
|
||||
this.nrOfInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("nrOfActiveInstances")) {
|
||||
this.nrOfActiveInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("loopCounter")) {
|
||||
Integer tempLoopCounter = (Integer) var.getValue();
|
||||
if (tempLoopCounter!=null&&tempLoopCounter > loopCounter) {
|
||||
this.loopCounter = tempLoopCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricVariableInstance;
|
||||
import org.activiti.engine.impl.TaskQueryImpl;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
|
||||
/**
|
||||
* 撤销多实例命令类,暂时只支持撤销单环节多人任务实例
|
||||
*
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @created 07-四月-2013 15:39:01
|
||||
*/
|
||||
public class DeleteMultiInstanceCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Variable names for outer instance(as described in spec)
|
||||
// 环节接收变量
|
||||
protected final String ASSIGNEE = "assignee";
|
||||
// 实例数
|
||||
protected final String NUMBER_OF_INSTANCES = "nrOfInstances";
|
||||
// 存活实例数
|
||||
protected final String NUMBER_OF_ACTIVE_INSTANCES = "nrOfActiveInstances";
|
||||
// 已完成的实例数
|
||||
protected final String NUMBER_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
|
||||
// 当前循环实例下标
|
||||
// Variable names for inner instances (as described in the spec)
|
||||
protected final String LOOP_COUNTER = "loopCounter";
|
||||
|
||||
protected Integer nrOfInstances = 0;
|
||||
protected Integer nrOfActiveInstances = 0;
|
||||
protected Integer loopCounter = 0;
|
||||
// 当前任务实例ID
|
||||
protected String processInstanceId;
|
||||
// 当前任务实例ID
|
||||
protected String actInstId;
|
||||
// 当前任务实例ID
|
||||
protected String actDefId;;
|
||||
// 补发接收人列表
|
||||
protected List<String> receivers;
|
||||
protected Map<String, Object> variables;
|
||||
|
||||
public DeleteMultiInstanceCmd(String processInstanceId,String actDefId,String actInstId, List<String> receivers,
|
||||
Map<String, Object> variables) {
|
||||
this.processInstanceId=processInstanceId;
|
||||
this.actDefId = actDefId;
|
||||
this.actInstId = actInstId;
|
||||
this.receivers = receivers;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
if(StringUtils.isNotEmpty(actInstId)){
|
||||
TaskEntity task = (TaskEntity) new TaskQueryImpl(commandContext).taskId(actInstId).singleResult();
|
||||
delete(task,commandContext);
|
||||
return null;
|
||||
}
|
||||
// 获取当前任务实例
|
||||
for (String receiver : receivers) {
|
||||
List<Task> tasks = new TaskQueryImpl(commandContext).processInstanceId(processInstanceId).taskAssignee(receiver).list();
|
||||
if(tasks==null||tasks.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
delete((TaskEntity) tasks.get(0),commandContext);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void delete(TaskEntity task,CommandContext commandContext){
|
||||
task.setActionType(WorkFlowContants.ACTION_TYPE_DELETE_MULTIINSTANCE_ACTIVITY);
|
||||
String processInstanceId = task.getProcessInstanceId();
|
||||
// 获取发起多实例的任务实例
|
||||
ExecutionEntity executionEntityOfMany =commandContext.getExecutionEntityManager().findExecutionById(task.getExecutionId());
|
||||
try {
|
||||
commandContext.getHistoryManager().recordTaskUpdate(task);
|
||||
// 根据补发接收列表创建多实例任务
|
||||
deleteInstances(task, executionEntityOfMany, commandContext,
|
||||
executionEntityOfMany.getParentId());
|
||||
}catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the parallel case of spawning the instances. Will create child
|
||||
* executions accordingly for every instance needed.
|
||||
*/
|
||||
protected void deleteInstances(TaskEntity task, ExecutionEntity execution,
|
||||
CommandContext commandContext, String executionId)
|
||||
throws Exception {
|
||||
initMultiVariable(commandContext, executionId);
|
||||
if (this.nrOfActiveInstances == 0) {
|
||||
return;
|
||||
}
|
||||
// 更新已有的多实例循环变量
|
||||
updateMultiVariable(execution);
|
||||
execution.deleteCascade("");
|
||||
/*
|
||||
* commandContext.getTaskEntityManager().deleteTaskForce(task.getId(),
|
||||
* "", true);
|
||||
*/
|
||||
}
|
||||
|
||||
public void updateMultiVariable(ExecutionEntity execution) {
|
||||
execution.removeVariableLocal(ASSIGNEE);
|
||||
execution.removeVariableLocal(LOOP_COUNTER);
|
||||
execution.setVariable(NUMBER_OF_INSTANCES, --nrOfInstances);
|
||||
execution.setVariable(NUMBER_OF_ACTIVE_INSTANCES, --nrOfActiveInstances);
|
||||
}
|
||||
|
||||
public void initMultiVariable(CommandContext commandContext,
|
||||
String executionId) {
|
||||
/*
|
||||
* 更新多实例相关变量
|
||||
*/
|
||||
List<HistoricVariableInstance> list = commandContext.getProcessEngineConfiguration().getHistoryService().createHistoricVariableInstanceQuery().executionId(executionId).list();
|
||||
for (HistoricVariableInstance var : list) {
|
||||
if (var.getVariableName().equals("nrOfInstances")) {
|
||||
this.nrOfInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("nrOfActiveInstances")) {
|
||||
this.nrOfActiveInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("loopCounter")) {
|
||||
Integer tempLoopCounter = (Integer) var.getValue();
|
||||
if (tempLoopCounter!=null&&tempLoopCounter > loopCounter) {
|
||||
this.loopCounter = tempLoopCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
import com.blueland.bpm.engine.util.CustomProcessDiagramGenerator;
|
||||
/**
|
||||
* 获取流程历史div图形
|
||||
* @author lw
|
||||
*/
|
||||
public class GetHistoryProcessDivCmd implements Command<String> {
|
||||
protected String historyProcessInstanceId;
|
||||
|
||||
public GetHistoryProcessDivCmd(String historyProcessInstanceId) {
|
||||
this.historyProcessInstanceId = historyProcessInstanceId;
|
||||
}
|
||||
|
||||
public String execute(CommandContext commandContext) {
|
||||
try {
|
||||
CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();
|
||||
return customProcessDiagramGenerator
|
||||
.getHistoryProcessDiv(historyProcessInstanceId);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
import com.blueland.bpm.engine.util.CustomProcessDiagramGenerator;
|
||||
/**
|
||||
* 获取流程定义div图形
|
||||
* @author lw
|
||||
*/
|
||||
public class GetProcessDefinitionDivCmd implements Command<String> {
|
||||
protected String processDefinitionId;
|
||||
|
||||
public GetProcessDefinitionDivCmd(String processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
public String execute(CommandContext commandContext) {
|
||||
try {
|
||||
CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();
|
||||
return customProcessDiagramGenerator
|
||||
.getProcessDefinitionDiv(processDefinitionId);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
import com.blueland.bpm.engine.util.CustomProcessDiagramGenerator;
|
||||
/**
|
||||
* 获取流程定义图形大小
|
||||
* @author lw
|
||||
*/
|
||||
public class GetProcessDiagramSize implements Command<String[]> {
|
||||
protected String processDefinitionId;
|
||||
|
||||
public GetProcessDiagramSize(String processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
public String[] execute(CommandContext commandContext) {
|
||||
try {
|
||||
CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();
|
||||
return customProcessDiagramGenerator
|
||||
.getDiagramSize(processDefinitionId);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
import com.blueland.bpm.engine.util.CustomProcessDiagramGenerator;
|
||||
/**
|
||||
* 获取流程处理记录div图形
|
||||
* @author dsl
|
||||
*/
|
||||
public class GetProcessHistoryDivCmd implements Command<Map<String,Object>> {
|
||||
protected String processInstanceId;
|
||||
|
||||
public GetProcessHistoryDivCmd(String processInstanceId) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
}
|
||||
|
||||
public Map<String,Object> execute(CommandContext commandContext) {
|
||||
try {
|
||||
CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();
|
||||
//return customProcessDiagramGenerator.getProcessHistoryDiv(processInstanceId);
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
import com.blueland.bpm.engine.util.CustomProcessTrace;
|
||||
/**
|
||||
* 获取流程轨迹,用于监控展现
|
||||
* @author lw
|
||||
*/
|
||||
public class GetProcessTraceCmd implements Command<List<Map<String, Object>>> {
|
||||
protected String processDefinitionId;
|
||||
|
||||
public GetProcessTraceCmd(String processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> execute(CommandContext commandContext) {
|
||||
try {
|
||||
CustomProcessTrace customProcessTrace = new CustomProcessTrace();
|
||||
return customProcessTrace.getProcessTrace(processDefinitionId);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
import com.blueland.bpm.engine.util.CustomProcessDiagramGenerator;
|
||||
/**
|
||||
* 获取流程实例图形大小
|
||||
* @author lw
|
||||
*/
|
||||
public class HistoryProcessInstanceDiagramCmd implements Command<InputStream> {
|
||||
protected String historyProcessInstanceId;
|
||||
|
||||
public HistoryProcessInstanceDiagramCmd(String historyProcessInstanceId) {
|
||||
this.historyProcessInstanceId = historyProcessInstanceId;
|
||||
}
|
||||
|
||||
public InputStream execute(CommandContext commandContext) {
|
||||
try {
|
||||
CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();
|
||||
return customProcessDiagramGenerator
|
||||
.generateDiagram(historyProcessInstanceId);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.history.HistoricVariableInstance;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否最后一条多实例执行
|
||||
* @author lw
|
||||
* @version 1.0
|
||||
* @created 07-四月-2013 15:39:01
|
||||
*/
|
||||
public class IsEndMultiInstanceCmd implements Command<Boolean>, Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected String executionId;
|
||||
protected String processInstanceId;
|
||||
|
||||
|
||||
public IsEndMultiInstanceCmd(String processInstanceId, String executionId) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.executionId = executionId;
|
||||
}
|
||||
|
||||
public Boolean execute(CommandContext commandContext) {
|
||||
Integer nrOfInstances=null;
|
||||
Integer nrOfActiveInstances=null;
|
||||
Integer nrOfCompletedInstances=null;
|
||||
List<HistoricVariableInstance> list = commandContext.getProcessEngineConfiguration().getHistoryService().createHistoricVariableInstanceQuery().excludeTaskVariables().processInstanceId(processInstanceId).list();
|
||||
for (HistoricVariableInstance var : list) {
|
||||
if (var.getVariableName().equals("nrOfInstances")) {
|
||||
nrOfInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("nrOfActiveInstances")) {
|
||||
nrOfActiveInstances = (Integer) var.getValue();
|
||||
} else if (var.getVariableName().equals("nrOfCompletedInstances")) {
|
||||
nrOfCompletedInstances = (Integer) var.getValue();
|
||||
}
|
||||
}
|
||||
if(nrOfInstances==null||nrOfActiveInstances==null&&nrOfCompletedInstances==null){
|
||||
return false;
|
||||
}
|
||||
if(nrOfInstances==nrOfCompletedInstances&&nrOfActiveInstances==0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.ActivitiException;
|
||||
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
|
||||
import org.activiti.engine.impl.cmd.GetDeploymentProcessDefinitionCmd;
|
||||
import org.activiti.engine.impl.identity.Authentication;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.impl.pvm.runtime.InterpretableExecution;
|
||||
|
||||
public class ReOpenProcessCmd implements Command<Void> {
|
||||
private String historicProcessInstanceId;
|
||||
|
||||
public ReOpenProcessCmd(String historicProcessInstanceId) {
|
||||
this.historicProcessInstanceId = historicProcessInstanceId;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
HistoricProcessInstanceEntity historicProcessInstanceEntity = commandContext
|
||||
.getHistoricProcessInstanceEntityManager()
|
||||
.findHistoricProcessInstance(historicProcessInstanceId);
|
||||
historicProcessInstanceEntity.setEndActivityId(null);
|
||||
historicProcessInstanceEntity.setEndTime(null);
|
||||
|
||||
String processDefinitionId = historicProcessInstanceEntity
|
||||
.getProcessDefinitionId();
|
||||
String initiator = historicProcessInstanceEntity.getStartUserId();
|
||||
String businessKey = historicProcessInstanceEntity.getBusinessKey();
|
||||
|
||||
ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd(
|
||||
processDefinitionId).execute(commandContext);
|
||||
|
||||
// ExecutionEntity processInstance = processDefinition
|
||||
// .createProcessInstance(businessKey);
|
||||
ExecutionEntity processInstance = this.createProcessInstance(
|
||||
historicProcessInstanceEntity.getId(), businessKey, initiator,
|
||||
processDefinition);
|
||||
|
||||
try {
|
||||
Authentication.setAuthenticatedUserId(initiator);
|
||||
// start
|
||||
processInstance.start();
|
||||
} finally {
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ExecutionEntity createProcessInstance(String processInstanceId,
|
||||
String businessKey, String authenticatedUserId,
|
||||
ProcessDefinitionEntity processDefinition) {
|
||||
// ExecutionEntity processInstance = (ExecutionEntity) this
|
||||
// .createProcessInstance(processDefinition);
|
||||
// ExecutionEntity processInstance = (ExecutionEntity) processDefinition
|
||||
// .createProcessInstanceForInitial(processDefinition.getInitial());
|
||||
// processInstance.setId(processInstanceId);
|
||||
ExecutionEntity processInstance = (ExecutionEntity) this
|
||||
.createProcessInstance(processDefinition, processInstanceId);
|
||||
processInstance.setExecutions(new ArrayList<ExecutionEntity>());
|
||||
processInstance.setProcessDefinition(processDefinition);
|
||||
|
||||
// Do not initialize variable map (let it happen lazily)
|
||||
if (businessKey != null) {
|
||||
processInstance.setBusinessKey(businessKey);
|
||||
}
|
||||
|
||||
// Reset the process instance in order to have the db-generated process instance id available
|
||||
processInstance.setProcessInstance(processInstance);
|
||||
|
||||
String initiatorVariableName = (String) processDefinition
|
||||
.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
|
||||
|
||||
if (initiatorVariableName != null) {
|
||||
processInstance.setVariable(initiatorVariableName,
|
||||
authenticatedUserId);
|
||||
}
|
||||
|
||||
// if (authenticatedUserId != null) {
|
||||
// processInstance.addIdentityLink(authenticatedUserId,
|
||||
// IdentityLinkType.STARTER);
|
||||
// }
|
||||
|
||||
// Context.getCommandContext().getHistoryManager()
|
||||
// .recordProcessInstanceStart(processInstance);
|
||||
return processInstance;
|
||||
}
|
||||
|
||||
public ExecutionEntity createProcessInstance(
|
||||
ProcessDefinitionEntity processDefinition, String id) {
|
||||
ActivityImpl initial = processDefinition.getInitial();
|
||||
|
||||
if (initial == null) {
|
||||
throw new ActivitiException(
|
||||
"Cannot start process instance, initial activity where the process instance should start is null.");
|
||||
}
|
||||
|
||||
ExecutionEntity processInstance = new ExecutionEntity(initial);
|
||||
processInstance.setId(id);
|
||||
processInstance.insert();
|
||||
processInstance.setProcessDefinition(processDefinition);
|
||||
processInstance.setTenantId(processDefinition.getTenantId());
|
||||
processInstance.setProcessInstance(processInstance);
|
||||
processInstance.initialize();
|
||||
|
||||
InterpretableExecution scopeInstance = processInstance;
|
||||
|
||||
List<ActivityImpl> initialActivityStack = processDefinition
|
||||
.getInitialActivityStack(initial);
|
||||
|
||||
for (ActivityImpl initialActivity : initialActivityStack) {
|
||||
if (initialActivity.isScope()) {
|
||||
scopeInstance = (InterpretableExecution) scopeInstance
|
||||
.createExecution();
|
||||
scopeInstance.setActivity(initialActivity);
|
||||
|
||||
if (initialActivity.isScope()) {
|
||||
scopeInstance.initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scopeInstance.setActivity(initial);
|
||||
|
||||
return processInstance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.deploy.DeploymentCache;
|
||||
import org.activiti.engine.impl.persistence.deploy.DeploymentManager;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
|
||||
/**
|
||||
* 刷新流程定义缓存
|
||||
* @author lw
|
||||
*/
|
||||
public class RefreshProcessDefineCacheCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected String processDefinitionId;
|
||||
|
||||
|
||||
public RefreshProcessDefineCacheCmd(String processDefinitionId) {
|
||||
this.processDefinitionId=processDefinitionId;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
if (processDefinitionId==null)
|
||||
return null;
|
||||
DeploymentManager deploymentManager=((ProcessEngineConfigurationImpl)commandContext.getProcessEngineConfiguration()).getDeploymentManager();
|
||||
DeploymentCache<ProcessDefinitionEntity> pdfCache=deploymentManager.getProcessDefinitionCache();
|
||||
//将processDefinitionId的实例从流程定义缓存中删除
|
||||
pdfCache.remove(processDefinitionId);
|
||||
//重新新增processDefinitionId的实例到流程定义缓存中
|
||||
deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import org.activiti.engine.ActivitiIllegalArgumentException;
|
||||
import org.activiti.engine.ActivitiObjectNotFoundException;
|
||||
import org.activiti.engine.delegate.event.ActivitiEventType;
|
||||
import org.activiti.engine.delegate.event.impl.ActivitiEventBuilder;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
|
||||
/**
|
||||
* 变更流程名称
|
||||
* @author lw
|
||||
*/
|
||||
public class SetProcessDefinitionNameCmd implements Command<Void> {
|
||||
|
||||
protected String processDefinitionId;
|
||||
protected String name;
|
||||
|
||||
public SetProcessDefinitionNameCmd(String processDefinitionId, String name) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
|
||||
if (processDefinitionId == null) {
|
||||
throw new ActivitiIllegalArgumentException(
|
||||
"Process definition id is null");
|
||||
}
|
||||
|
||||
ProcessDefinitionEntity processDefinition = commandContext
|
||||
.getProcessDefinitionEntityManager().findProcessDefinitionById(
|
||||
processDefinitionId);
|
||||
|
||||
if (processDefinition == null) {
|
||||
throw new ActivitiObjectNotFoundException(
|
||||
"No process definition found for id = '"
|
||||
+ processDefinitionId + "'",
|
||||
ProcessDefinition.class);
|
||||
}
|
||||
|
||||
// Update name
|
||||
processDefinition.setName(name);
|
||||
|
||||
/*
|
||||
* // Remove process definition from cache, it will be refetched later
|
||||
* DeploymentCache<ProcessDefinitionEntity> processDefinitionCache =
|
||||
* commandContext
|
||||
* .getProcessEngineConfiguration().getProcessDefinitionCache(); if
|
||||
* (processDefinitionCache != null) {
|
||||
* processDefinitionCache.remove(processDefinitionId); }
|
||||
*/
|
||||
commandContext.getDbSqlSession().update(processDefinition);
|
||||
|
||||
if (commandContext.getEventDispatcher().isEnabled()) {
|
||||
commandContext.getEventDispatcher().dispatchEvent(
|
||||
ActivitiEventBuilder
|
||||
.createEntityEvent(
|
||||
ActivitiEventType.ENTITY_UPDATED,
|
||||
processDefinition));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getProcessDefinitionId() {
|
||||
return processDefinitionId;
|
||||
}
|
||||
|
||||
public void setProcessDefinitionId(String processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.ActivitiIllegalArgumentException;
|
||||
import org.activiti.engine.ActivitiObjectNotFoundException;
|
||||
import org.activiti.engine.impl.context.Context;
|
||||
import org.activiti.engine.impl.identity.Authentication;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.CommentEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntity;
|
||||
import org.activiti.engine.runtime.Execution;
|
||||
import org.activiti.engine.task.Comment;
|
||||
import org.activiti.engine.task.Event;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
|
||||
/**
|
||||
* 暂存待办任务
|
||||
* @author lw
|
||||
*/
|
||||
public class TempSaveTaskCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected String taskId;
|
||||
protected Map<String, Object> variables;
|
||||
|
||||
public TempSaveTaskCmd(String taskId, Map<String, Object> variables) {
|
||||
this.taskId = taskId;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
if (taskId == null) {
|
||||
throw new ActivitiIllegalArgumentException("taskId is null");
|
||||
}
|
||||
TaskEntity taskEntity = commandContext.getTaskEntityManager()
|
||||
.findTaskById(taskId);
|
||||
if (taskEntity == null) {
|
||||
throw new ActivitiObjectNotFoundException(
|
||||
"Cannot find taskEntity for id '" + taskId + "'.",
|
||||
Execution.class);
|
||||
}
|
||||
//更新页面元素
|
||||
updateField(commandContext, taskEntity);
|
||||
//更新意见字段
|
||||
updateComment(commandContext, taskEntity);
|
||||
taskEntity.setActionType(WorkFlowContants.ACTION_TYPE_SAVE_ACTIVITY);
|
||||
//更新当前任务及对应的历史任务
|
||||
taskEntity.updateCascade();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void updateField(CommandContext commandContext,
|
||||
TaskEntity taskEntity) {
|
||||
List<VariableInstanceEntity> variableInstanceEntitys = commandContext
|
||||
.getVariableInstanceEntityManager()
|
||||
.findVariableInstancesByTaskId(taskId);
|
||||
if (variableInstanceEntitys == null)
|
||||
return;
|
||||
for (VariableInstanceEntity variableInstanceEntity : variableInstanceEntitys) {
|
||||
if (!(variableInstanceEntity.getName().equals(
|
||||
WorkFlowContants.WF_FIELDS_KEY)||variableInstanceEntity.getName().equals(
|
||||
WorkFlowContants.WF_BUSINESS_DATA_OBJECT_KEY))) {
|
||||
continue;
|
||||
}
|
||||
if (variables.get(variableInstanceEntity.getName())!=null)
|
||||
taskEntity.setVariableLocal(variableInstanceEntity.getName(),
|
||||
variables.get(variableInstanceEntity.getName()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void updateComment(CommandContext commandContext,
|
||||
TaskEntity taskEntity) {
|
||||
String message = (String) variables.get(WorkFlowContants.WF_CUR_COMMENT_KEY);
|
||||
if (StringUtils.isBlank(message)) {
|
||||
return;
|
||||
}
|
||||
List<Comment> comments = commandContext.getCommentEntityManager()
|
||||
.findCommentsByTaskId(taskId);
|
||||
if (comments != null && !comments.isEmpty()) {
|
||||
CommentEntity commentEntity = (CommentEntity) comments.get(0);
|
||||
commandContext.getCommentEntityManager().delete(commentEntity);
|
||||
}
|
||||
addComment(commandContext, taskEntity, message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void addComment(CommandContext commandContext,
|
||||
TaskEntity taskEntity, String message) {
|
||||
String userId = Authentication.getAuthenticatedUserId();
|
||||
CommentEntity comment = new CommentEntity();
|
||||
comment.setUserId(userId);
|
||||
comment.setType(CommentEntity.TYPE_COMMENT);
|
||||
comment.setTime(Context.getProcessEngineConfiguration().getClock()
|
||||
.getCurrentTime());
|
||||
comment.setTaskId(taskId);
|
||||
comment.setProcessInstanceId(taskEntity.getProcessInstanceId());
|
||||
comment.setAction(Event.ACTION_ADD_COMMENT);
|
||||
setMessage(comment,message);
|
||||
commandContext.getCommentEntityManager().insert(comment);
|
||||
}
|
||||
private void setMessage(CommentEntity comment,String message){
|
||||
String eventMessage = message.replaceAll("\\s+", " ");
|
||||
if (eventMessage.length() > 163) {
|
||||
eventMessage = eventMessage.substring(0, 160) + "...";
|
||||
}
|
||||
comment.setMessage(eventMessage);
|
||||
comment.setFullMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.blueland.bpm.engine.core.cmd;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.activiti.bpmn.converter.BpmnXMLConverter;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.engine.ProcessEngineConfiguration;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.DeploymentEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ResourceEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ResourceEntityManager;
|
||||
import org.activiti.engine.impl.util.IoUtil;
|
||||
import org.activiti.engine.impl.util.io.InputStreamSource;
|
||||
import org.activiti.image.ProcessDiagramGenerator;
|
||||
import org.activiti.image.impl.DefaultProcessDiagramGenerator;
|
||||
|
||||
/**
|
||||
* 更新流程模型
|
||||
* @author lw
|
||||
*/
|
||||
public class UpdateDeploymentResourceCmd implements Command<Void>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected String processDefinitionId;
|
||||
protected String deploymentId;
|
||||
protected byte[] resource;
|
||||
protected boolean isUpdateImage;
|
||||
|
||||
public UpdateDeploymentResourceCmd(String deploymentId,String processDefinitionId, byte[] resource,boolean isUpdateImage) {
|
||||
this.deploymentId = deploymentId;
|
||||
this.processDefinitionId=processDefinitionId;
|
||||
this.resource=resource;
|
||||
this.isUpdateImage=isUpdateImage;
|
||||
}
|
||||
|
||||
public Void execute(CommandContext commandContext) {
|
||||
if (deploymentId == null || processDefinitionId == null
|
||||
|| resource == null)
|
||||
return null;
|
||||
DeploymentEntity deployment = commandContext
|
||||
.getDeploymentEntityManager().findDeploymentById(deploymentId);
|
||||
ProcessDefinitionEntity processDefinitionEntity = commandContext
|
||||
.getProcessDefinitionEntityManager().findProcessDefinitionById(
|
||||
processDefinitionId);
|
||||
// 更新流程模型
|
||||
deleteAndInsertResource(commandContext, deployment,
|
||||
processDefinitionEntity.getResourceName(), this.resource);
|
||||
ProcessEngineConfiguration processEngineConfiguration=commandContext.getProcessEngineConfiguration();
|
||||
if (isUpdateImage) {
|
||||
try {
|
||||
// 更新流程图片
|
||||
BpmnXMLConverter converter = new BpmnXMLConverter();
|
||||
BpmnModel bpmnModel = converter.convertToBpmnModel(
|
||||
new InputStreamSource(
|
||||
new ByteArrayInputStream(resource)), true,
|
||||
false);
|
||||
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
|
||||
byte[] diagramBytes = IoUtil.readInputStream(
|
||||
processDiagramGenerator.generateDiagram(bpmnModel, "png", processEngineConfiguration.getActivityFontName(),
|
||||
processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader()), null);
|
||||
deleteAndInsertResource(commandContext, deployment,
|
||||
processDefinitionEntity.getDiagramResourceName(),
|
||||
diagramBytes);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void deleteAndInsertResource(CommandContext commandContext,DeploymentEntity deployment,String resourceName,byte[] bytes){
|
||||
ResourceEntityManager resourceEntityManager=commandContext.getResourceEntityManager();
|
||||
//删除老的bpmnResourceEntity
|
||||
ResourceEntity bpmnResourceEntity=resourceEntityManager.findResourceByDeploymentIdAndResourceName(deployment.getId(), resourceName);
|
||||
commandContext.getByteArrayEntityManager().deleteByteArrayById(bpmnResourceEntity.getId());
|
||||
//新增新的bpmnResourceEntity
|
||||
bpmnResourceEntity.setId(null);
|
||||
bpmnResourceEntity.setBytes(bytes);
|
||||
bpmnResourceEntity.setDeploymentId(deployment.getId());
|
||||
resourceEntityManager.insertResource(bpmnResourceEntity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ActivityDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModellBuilder;
|
||||
import com.blueland.bpm.engine.core.service.AbstractServiceHelper;
|
||||
import com.blueland.bpm.engine.core.service.ProcessConfigService;
|
||||
import com.blueland.bpm.engine.core.service.ProcessDefinitionService;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
import com.blueland.bpm.identity.OrgService;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
import com.blueland.bpm.identity.model.Org;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
|
||||
/**
|
||||
* 流程执行基类类
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public abstract class AbstractProcessExecutor extends AbstractServiceHelper {
|
||||
@Resource(name = "processConfigServiceImpl")
|
||||
ProcessConfigService processConfigService;
|
||||
@Resource(name = "processDefinitionServiceImpl")
|
||||
ProcessDefinitionService processDefinitionService;
|
||||
@Resource(name = "processInstanceServiceImpl")
|
||||
ProcessInstanceService processInstanceService;
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
OrgService orgService;
|
||||
@Resource(name = "processInstanceModellBuilder")
|
||||
ProcessInstanceModellBuilder processInstanceModellBuilder;
|
||||
|
||||
protected void validateProcessInputModel(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
if (processInputModel == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"流程输入参数对象{processInputModel}不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_sendUserId())) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,String.format(
|
||||
"流程输入参数{发送人:wf_sendUserId}不能为空,processInputModel[%s]",
|
||||
processInputModel));
|
||||
} /*else if (StringUtils.isEmpty(processInputModel.getWf_sendUserOrgId())) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,String.format(
|
||||
"流程输入参数{发送人组织ID:wf_sendUserOrgId}不能为空,processInputModel[%s]",
|
||||
processInputModel));
|
||||
}*/ else if (StringUtils.isEmpty(processInputModel.getWf_procTitle())) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,String.format(
|
||||
"流程输入参数{流程标题:wf_procTitle}不能为空,processInputModel[%s]",
|
||||
processInputModel));
|
||||
} else if (StringUtils.isEmpty(processInputModel.getWf_procDefId())) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,String.format(
|
||||
"流程输入参数{流程定义ID:wf_procDefId}不能为空,processInputModel[%s]",
|
||||
processInputModel));
|
||||
}
|
||||
}
|
||||
|
||||
protected void additionalProcessInputModel(
|
||||
ProcessInputModel processInputModel,
|
||||
ProcessDefinition processDefinition) throws WorkFlowException {
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_procDefName())) {
|
||||
processInputModel
|
||||
.setWf_procDefName(processDefinition.getName());
|
||||
}
|
||||
/*
|
||||
* User user =null; if
|
||||
* (StringUtils.isEmpty(processInputModel.getWf_sendUserOrgId()))
|
||||
* {//喏维赞允许部分流程(与组织无关流程)组织ID可为空,用用户最新组织走流程 user =
|
||||
* userService.getUserById(processInputModel.getWf_sendUserId());
|
||||
* processInputModel.setWf_sendUserOrgId(user.getOrgId());
|
||||
* processInputModel.setWf_sendUserOrgName(user.getOrgName()); }else{ user =
|
||||
* userService.getUserByCode(processInputModel.getWf_sendUserId(),
|
||||
* processInputModel.getWf_sendUserOrgId()); }
|
||||
*/
|
||||
/*
|
||||
* if (user == null) { throw new WorkFlowException( ExceptionErrorCode.B2058,
|
||||
* String.format( "通过发送人和发送人组织无法获取到用户对象,流程执行失败,processInputModel[%s]",
|
||||
* processInputModel)); }
|
||||
*/
|
||||
if (StringUtils.isNotEmpty(processInputModel.getWf_sendUserId())) {
|
||||
processInputModel.setWf_sender(processInputModel.getWf_sendUserId());
|
||||
}
|
||||
/*
|
||||
* processInputModel.setWf_sender(user.getUserId());
|
||||
* processInputModel.setWf_sendUserName(user.getUserName()); if
|
||||
* (StringUtils.isEmpty(processInputModel.getWf_sendUserOrgName())) { Org org =
|
||||
* orgService.getOrgById(processInputModel .getWf_sendUserOrgId());
|
||||
* processInputModel.setWf_sendUserOrgName(org != null ? org .getOrgName() :
|
||||
* ""); }
|
||||
*/
|
||||
if (processInputModel.getWf_businessDataObject() != null) {
|
||||
processInputModel.getWf_variables().put(WorkFlowContants.WF_BUSINESS_DATA_OBJECT_KEY,
|
||||
processInputModel.getWf_businessDataObject());
|
||||
}
|
||||
if (processInputModel.getWf_throughBizDataObject() != null) {
|
||||
processInputModel.getWf_variables().put(WorkFlowContants.WF_THROUGH_BUSINESS_DATA_OBJECT_KEY,
|
||||
processInputModel.getWf_throughBizDataObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void autoSetNextActDefId(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
// 必须没有选择下一步环节
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_nextActDefId())) {
|
||||
return;
|
||||
}
|
||||
// 自动查询下一环节
|
||||
List<ActivityDefinitionModel> activityDefinitionModels = processDefinitionService
|
||||
.getNextActivity(processInputModel.getWf_procInstId(),
|
||||
processInputModel.getWf_procDefId(),
|
||||
processInputModel.getWf_curActDefId(),
|
||||
processInputModel.getFields());
|
||||
if (activityDefinitionModels == null
|
||||
|| activityDefinitionModels.isEmpty()) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2005,String.format(
|
||||
"无法找到当前环节输出环节,流程流转失败,processInputModel[%s]",
|
||||
processInputModel));
|
||||
}
|
||||
ActivityDefinitionModel activityDefinitionModel = activityDefinitionModels
|
||||
.get(0);
|
||||
processInputModel.setWf_nextActDefId(activityDefinitionModel
|
||||
.getActDefId());
|
||||
processInputModel.setWf_nextActDefType(activityDefinitionModel
|
||||
.getActType());
|
||||
processInputModel.setWf_nextActDefName(activityDefinitionModel
|
||||
.getActDefName());
|
||||
}
|
||||
|
||||
protected List<String> convertReceivers(String receiver) {
|
||||
String[] receiverArray = null;
|
||||
if (receiver.indexOf(",") != -1) {
|
||||
receiverArray = receiver.split(",");
|
||||
} else {
|
||||
receiverArray = new String[] { receiver };
|
||||
}
|
||||
List<String> receiverList = new ArrayList<String>(receiverArray.length);
|
||||
CollectionUtils.addAll(receiverList, receiverArray);
|
||||
return receiverList;
|
||||
}
|
||||
|
||||
protected String getTreeNodeOneUser(List<ActivityResourceModel> users) {
|
||||
for (ActivityResourceModel treeNode : users) {
|
||||
if ("USER".equals(treeNode.getType())) {
|
||||
return treeNode.getRealId();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.AddCallActivityCmd;
|
||||
import com.blueland.bpm.engine.core.cmd.AddMultiInstanceCmd;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 多实例(内嵌子例程)补发执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_ADD_MULTIINSTANCE_ACTIVITY)
|
||||
public class AddMultiInstanceActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置页面fields
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
processInputModel.getWf_fields());
|
||||
// ----------------------------------
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
List<Task> tasks=processInstanceService.getProcessTasks(processInstance.getProcessInstanceId(), processInputModel.getWf_sender(), processInputModel.getWf_curActInstId());
|
||||
Task task=tasks.get(0);
|
||||
if (task == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2060,String.format(
|
||||
"未找到流程实例ID[%S]、任务实例ID[%S]、发送人[%S]对应的待办任务!",
|
||||
processInputModel.getWf_procInstId(),
|
||||
processInputModel.getWf_curActInstId(),processInputModel.getWf_sender()));
|
||||
}
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
Command<Void> addMultiInstanceCmd =null;
|
||||
boolean multiInstance=ProcessDefinitionUtils.isMultiInstance(processInputModel,repositoryService);
|
||||
if(multiInstance||processInstance.getId().equals(processInstance.getTopProcessInstanceId())){//多实例
|
||||
addMultiInstanceCmd = new AddMultiInstanceCmd(
|
||||
task.getId(),
|
||||
convertReceivers(processInputModel.getWf_receiver()),
|
||||
workflowMap);
|
||||
}else{
|
||||
addMultiInstanceCmd = new AddCallActivityCmd(//子流程
|
||||
task.getId(),
|
||||
convertReceivers(processInputModel.getWf_receiver()),
|
||||
workflowMap);
|
||||
}
|
||||
this.managementService.executeCommand(addMultiInstanceCmd);
|
||||
ProcessInstanceModel processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel,processDefinition, processInstance, task);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.AddParallerMultiInstanceCmd;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 该类暂时无用
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_ADD_PARALLER_MULTIINSTANCE_ACTIVITY)
|
||||
public class AddParallerMultiInstanceActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessDefinition processDefinition =getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置页面fields
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}
|
||||
// ----------------------------------
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
Task task =this.findTaskById(processInputModel.getWf_curActInstId());
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
Command<Void> addMultiInstanceCmd = new AddParallerMultiInstanceCmd(
|
||||
processInputModel.getWf_curActInstId(),
|
||||
convertReceivers(processInputModel.getWf_receiver()),
|
||||
workflowMap);
|
||||
this.managementService.executeCommand(addMultiInstanceCmd);
|
||||
ProcessInstanceModel processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel,processDefinition, processInstance, task);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.core.cmd.CallBackTaskCmd;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 在办撤回活动(默认退回至上一步活动)执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_CALLBACK_ACTIVITY)
|
||||
public class CallbackActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
@Autowired
|
||||
ProcessInstanceService processInstanceService;
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessDefinition processDefinition =getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
|
||||
List<Task> tasks = processInstanceService.getProcessTasks(
|
||||
processInputModel.getWf_procInstId(),
|
||||
processInputModel.getWf_sendUserId(),
|
||||
processInputModel.getWf_curActInstId());
|
||||
if (tasks == null || tasks.isEmpty() ||tasks.size() > 1) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2060,String.format(
|
||||
"未找到任务实例ID[%S],发送人[%S]对应的待办任务!",
|
||||
processInputModel.getWf_curActInstId(),
|
||||
processInputModel.getWf_sendUserId()));
|
||||
}
|
||||
Task task = tasks.get(0);
|
||||
if (task == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2060,String.format(
|
||||
"未找到任务实例ID[%S],发送人[%S]对应的待办任务!",
|
||||
processInputModel.getWf_curActInstId(),
|
||||
processInputModel.getWf_sendUserId()));
|
||||
}
|
||||
ProcessInputModel preProcessInputModel = (ProcessInputModel) processInstanceService
|
||||
.getHistoryTaskVariables(task.getId()).get(
|
||||
WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY);
|
||||
processInputModel.setWf_receiver(task.getSender());
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
// 设置页面fields
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
preProcessInputModel.getWf_fields());
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
Command<Void> callBackTaskCmd = new CallBackTaskCmd(task.getId(),
|
||||
task.getPreTaskDefKey(), workflowMap);
|
||||
this.managementService.executeCommand(callBackTaskCmd);
|
||||
ProcessInstanceModel processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel, processDefinition,
|
||||
processInstance, task);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.CallBackPrevTaskCmd;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.impl.ProcessDefinitionResource;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
/**
|
||||
* 退回上一步活动处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_CALLBACK_PREV_ACTIVITY)
|
||||
public class CallbackToPrevActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
@Autowired
|
||||
ProcessDefinitionResource processDefinitionResource;
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessDefinition processDefinition=getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel( processInputModel, processDefinition);
|
||||
ProcessInstance processInstance =getProcessInstance(processInputModel.getWf_procInstId());
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
Task task =this.findTaskById(processInputModel.getWf_curActInstId());
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置页面fields
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}
|
||||
if(processInputModel.getWf_sender()!=null){
|
||||
identityService.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
}
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
processInputModel.getWf_fields());
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
autoSetPrevActInfo(workflowMap,processInputModel,task);
|
||||
Command<Void> callBackPrevTaskCmd = new CallBackPrevTaskCmd(
|
||||
processInputModel.getWf_curActInstId(),
|
||||
processInputModel.getWf_nextActDefId(), workflowMap);
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_curComment())) {
|
||||
taskService.addComment(task.getId(), task.getProcessInstanceId(),
|
||||
processInputModel.getWf_curComment(),processInputModel.getWf_commentDisplayArea());
|
||||
}
|
||||
this.managementService.executeCommand(callBackPrevTaskCmd);
|
||||
ProcessInstanceModel processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel,processDefinition, processInstance, task);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
protected void autoSetPrevActInfo(Map workflowMap,
|
||||
ProcessInputModel processInputModel, Task task)
|
||||
throws WorkFlowException {
|
||||
processInputModel.setWf_nextActDefId(task.getPreTaskDefKey());
|
||||
processInputModel.setWf_nextActDefName(task.getName());
|
||||
if (ProcessDefinitionUtils.isMultiInstance(processInputModel,
|
||||
repositoryService)) {
|
||||
/*List<String> userIds = processDefinitionResource
|
||||
.findActivityReturnFormer(task.getProcessDefinitionId(),
|
||||
task.getProcessInstanceId(), task.getId(),
|
||||
task.getPreTaskId());
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2007,
|
||||
"findActivityReturnFormer is empty");
|
||||
}
|
||||
workflowMap.put(WorkFlowContants.ELEMENT_ASSIGNEE_LIST, userIds);*/
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2007,
|
||||
"prevActInfo is MultiInstance");
|
||||
|
||||
} else {
|
||||
//by lw 20220119 User userReiver =userService.getUserByCode(task.getSendUserId(),task.getSenderOrgId());
|
||||
User userReiver =userService.getUserById(task.getSendUserId());
|
||||
if (userReiver==null) {//喏维赞允许部分流程(与组织无关流程)组织ID可为空,用用户最新组织走流程
|
||||
userReiver = userService.getUserById(task.getSendUserId());
|
||||
}
|
||||
processInputModel.setWf_receiver(userReiver.getUserId());
|
||||
ProcessDefinitionUtils.convertWf_receiver(processInputModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.CallBackToStartActivityCmd;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 退回至起草环节处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_CALLBACK_START_ACTIVITY)
|
||||
public class CallbackToStartActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessDefinition processDefinition=getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel( processInputModel, processDefinition);
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
Task task =this.findTaskById(processInputModel.getWf_curActInstId());
|
||||
if(processInputModel.getWf_sender()!=null){
|
||||
identityService.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
}
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置页面fields
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
processInputModel.getWf_fields());
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
Command<Void> callBackToStartActivityCmd=new CallBackToStartActivityCmd(processInputModel.getWf_curActInstId(),
|
||||
processInputModel.getWf_sender(), workflowMap);
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_curComment())) {
|
||||
taskService.addComment(task.getId(), task.getProcessInstanceId(),
|
||||
processInputModel.getWf_curComment(),processInputModel.getWf_commentDisplayArea());
|
||||
}
|
||||
this.managementService.executeCommand(callBackToStartActivityCmd);
|
||||
ProcessInstanceModel processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel,processDefinition, processInstance, task);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.CancelProcessInstanceCmd;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 作废流程执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_CANCEL_PROCESS)
|
||||
public class CancelProcessExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
ProcessDefinition processDefinition=getProcessDefinition(processInstance.getProcessDefinitionId());
|
||||
|
||||
// 根据wfCurActInstId获取当前任务实例,可以没有待办也能够作废
|
||||
Task task = null;
|
||||
if(!StringUtils.isEmpty(processInputModel.getWf_curActInstId())){
|
||||
task = taskService.createTaskQuery()
|
||||
.processInstanceId(processInputModel.getWf_procInstId())
|
||||
.taskId(processInputModel.getWf_curActInstId()).singleResult();
|
||||
}else{
|
||||
task=new TaskEntity();
|
||||
}
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置页面fields
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}
|
||||
if(processInputModel.getWf_sender()!=null){
|
||||
identityService.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
}
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_curComment())) {
|
||||
taskService.addComment(task.getId(),
|
||||
task.getProcessInstanceId(),
|
||||
processInputModel.getWf_curComment(),
|
||||
processInputModel.getWf_commentDisplayArea());
|
||||
}
|
||||
Command<Void> cancelProcessInstanceCmd = new CancelProcessInstanceCmd(
|
||||
processInputModel.getWf_procInstId(),
|
||||
processInputModel.getWf_curActInstId(), processInputModel.getWf_curComment());
|
||||
this.managementService.executeCommand(cancelProcessInstanceCmd);
|
||||
ProcessInstanceModel processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel,processDefinition, processInstance, task);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.NativeHistoricTaskInstanceQuery;
|
||||
import org.activiti.engine.impl.NativeExecutionQueryImpl;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.DeleteCallActivityCmd;
|
||||
import com.blueland.bpm.engine.core.cmd.DeleteMultiInstanceCmd;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 多实例(内嵌子例程)撤销执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_DELETE_MULTIINSTANCE_ACTIVITY)
|
||||
public class DeleteMultiInstanceActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessDefinition processDefinition=getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel( processInputModel, processDefinition);
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
Long taskSize = 0l;
|
||||
/*
|
||||
* WorkFlowException(ExceptionErrorCode.B2050,
|
||||
* "该流程只有当前一条任务实例,不允许删除(可转派给他人或自由跳转)!"); }
|
||||
*/
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置页面fields
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
processInputModel.getWf_fields());
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
//CounterSignCmd counterSignCmd=new CounterSignCmd("remove",convertReceivers(processInputModel.getWf_receiver()),curTask.getId());
|
||||
Command<Void> deleteMultiInstanceCmd =null;
|
||||
if(processInstance.getId().equals(processInstance.getTopProcessInstanceId())){//多实例
|
||||
deleteMultiInstanceCmd = new DeleteMultiInstanceCmd(processInstance.getId(),processInputModel.getWf_nextActDefId(),processInputModel.getWf_curActInstId(),
|
||||
convertReceivers(processInputModel.getWf_receiver()), workflowMap);
|
||||
}else{//子流程
|
||||
deleteMultiInstanceCmd = new DeleteCallActivityCmd(processInstance.getId(),processInputModel.getWf_nextActDefId(),processInputModel.getWf_curActInstId(),
|
||||
convertReceivers(processInputModel.getWf_receiver()), workflowMap);
|
||||
}
|
||||
this.managementService.executeCommand(deleteMultiInstanceCmd);
|
||||
ProcessInstanceModel processInstanceModel =null;
|
||||
try{
|
||||
processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel,processDefinition, processInstance, null);
|
||||
}catch(Exception e){}
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessTransitionFreeService;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
|
||||
/**
|
||||
* 流程流转(执行下一步活动)执行类
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_EXECUTE_ACTIVITY)
|
||||
public class ExecuteActivityExecutor extends AbstractProcessExecutor implements
|
||||
ProcessExecutor {
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processInputModel
|
||||
.getWf_procDefId());
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel);
|
||||
validateProcessInputModel(processInputModel);
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
|
||||
// 设置页面fields
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
processInputModel.getWf_fields());
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
|
||||
identityService
|
||||
.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
// ----------------------------------
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
Task task = findTaskById(processInputModel.getWf_curActInstId());
|
||||
// 下一步环节为空时,根据规则自动查询出下一步环节
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_nextActDefId())) {
|
||||
autoSetNextActDefId(processInputModel);
|
||||
processInputModel.setWf_webAutoQueryNextActFlag(true);
|
||||
}
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_receiver())) {
|
||||
// 处理下一环节为多实例
|
||||
if (ProcessDefinitionUtils.isMultiInstance(processInputModel,
|
||||
repositoryService)) {
|
||||
List<String> receiverList = convertReceivers(processInputModel
|
||||
.getWf_receiver());
|
||||
workflowMap.put(WorkFlowContants.ELEMENT_ASSIGNEE_LIST,
|
||||
receiverList);
|
||||
}
|
||||
} else if ((ProcessDefinitionUtils.isUserTask(processInputModel)&&!ProcessDefinitionUtils.isMultiInstance(processInputModel,
|
||||
repositoryService))
|
||||
|| BpmnXMLConstants.ELEMENT_TASK_SERVICE
|
||||
.equals(processInputModel.getWf_nextActDefType())) {
|
||||
// 下一步人员为空,自动路由到环节绑定的资源中的最前一个人
|
||||
List<ActivityResourceModel> users = processDefinitionService
|
||||
.getActivityUserTree(processInputModel.getWf_procInstId(),
|
||||
processInputModel.getWf_procDefId(), task.getId(),
|
||||
processInputModel.getWf_curActDefId(),
|
||||
processInputModel.getWf_nextActDefId(),
|
||||
processInputModel.getWf_sendUserId(),
|
||||
processInputModel.getWf_sendUserOrgId(), null,
|
||||
workflowMap);
|
||||
processInputModel.setWf_receiver(getTreeNodeOneUser(users));
|
||||
processInputModel.setWf_webAutoQueryNextUserFlag(true);
|
||||
}
|
||||
// }
|
||||
// 完成当前任务并触发下一步任务
|
||||
ProcessTransitionFreeService baseWfService = new ProcessTransitionFreeService(
|
||||
processEngineConfiguration);
|
||||
ProcessInstanceModel processInstanceModel = null;
|
||||
try {
|
||||
// 完成任务后做一些业务逻辑
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_curComment())) {
|
||||
taskService.addComment(task.getId(),
|
||||
task.getProcessInstanceId(),
|
||||
processInputModel.getWf_curComment(),
|
||||
processInputModel.getWf_commentDisplayArea());
|
||||
}
|
||||
baseWfService.commitProcess(task.getId(),
|
||||
processInputModel.getWf_nextActDefId(), workflowMap);
|
||||
processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcess(processInputModel, processDefinition,
|
||||
processInstance, task);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2050,
|
||||
String.format("流程执行失败,task[%s],processInputModel[%s]",
|
||||
task, processInputModel), e);
|
||||
}
|
||||
// 设置返回参数
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessTransitionFreeService;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 新建流程执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_LAUCH_PROCESS)
|
||||
public class LauchProcessExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
|
||||
validateProcessInputModel(processInputModel);
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置页面fields
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,processInputModel.getWf_fields());
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
String receiver = processInputModel.getWf_receiver();
|
||||
String sender = processInputModel.getWf_sender();
|
||||
|
||||
// 设置流程发起人
|
||||
identityService
|
||||
.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
// 起草流程特殊处理
|
||||
processInputModel.setWf_receiver(sender);
|
||||
|
||||
// 启动流程
|
||||
ProcessInstance processInstance = runtimeService
|
||||
.startProcessInstanceById(processInputModel.getWf_procDefId(),
|
||||
processInputModel.getWf_businessKey(), workflowMap);
|
||||
// 根据sender获取起草环节的任务
|
||||
Task task = this.findTaskByAssignee(processInstance.getId(), sender);
|
||||
// 起草有点特殊,有2条数据
|
||||
processInputModel.setWf_receiver(receiver);
|
||||
processInputModel.setWf_actionType(WorkFlowContants.ACTION_TYPE_EXECUTE_ACTIVITY);
|
||||
|
||||
// 下一步环节为空时,根据规则自动查询出下一步环节
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_nextActDefId())) {
|
||||
autoSetNextActDefId(processInputModel);
|
||||
processInputModel.setWf_webAutoQueryNextActFlag(true);
|
||||
}
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_receiver())) {
|
||||
// 处理下一环节为多实例
|
||||
if (ProcessDefinitionUtils.isMultiInstance(processInputModel,
|
||||
repositoryService)) {
|
||||
List<String> receiverList = convertReceivers(processInputModel
|
||||
.getWf_receiver());
|
||||
workflowMap.put(WorkFlowContants.ELEMENT_ASSIGNEE_LIST,
|
||||
receiverList);
|
||||
}
|
||||
} else if (ProcessDefinitionUtils.isUserTask(processInputModel)
|
||||
|| BpmnXMLConstants.ELEMENT_TASK_SERVICE
|
||||
.equals(processInputModel.getWf_nextActDefType())) {
|
||||
// 下一步人员为空,自动路由到环节绑定的资源中的最前一个人
|
||||
List<ActivityResourceModel> users = processDefinitionService
|
||||
.getActivityUserTree("",
|
||||
processInputModel.getWf_procDefId(), null,
|
||||
processInputModel.getWf_curActDefId(),
|
||||
processInputModel.getWf_nextActDefId(),
|
||||
processInputModel.getWf_sendUserId(),
|
||||
processInputModel.getWf_sendUserOrgId(), null,
|
||||
workflowMap);
|
||||
processInputModel.setWf_receiver(getTreeNodeOneUser(users));
|
||||
processInputModel.setWf_webAutoQueryNextUserFlag(true);
|
||||
}
|
||||
|
||||
// 完成当前任务并触发下一步任务
|
||||
ProcessTransitionFreeService baseWfService = new ProcessTransitionFreeService(
|
||||
processEngineConfiguration);
|
||||
|
||||
ProcessInstanceModel processInstanceModel = null;
|
||||
|
||||
try {
|
||||
// 完成任务后做一些业务逻辑
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_curComment())) {
|
||||
taskService.addComment(task.getId(),
|
||||
task.getProcessInstanceId(),
|
||||
processInputModel.getWf_curComment(),
|
||||
processInputModel.getWf_commentDisplayArea());
|
||||
}
|
||||
baseWfService.commitProcess(task.getId(),
|
||||
processInputModel.getWf_nextActDefId(), workflowMap);
|
||||
processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel, processDefinition,
|
||||
processInstance, task);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2050,String.format(
|
||||
"流程发起失败,task[%s],processInputModel[%s]", task,
|
||||
processInputModel), e);
|
||||
}
|
||||
// 设置返回参数
|
||||
return processInstanceModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 流程执行接口
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public interface ProcessExecutor {
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel) throws WorkFlowException;
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.config.model.Depute;
|
||||
import com.blueland.bpm.engine.config.service.DeputeManager;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
/**
|
||||
* 转办处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_RECEIVER_TRANSFER)
|
||||
public class ReceiverTransferExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
validateProcessInputModel(processInputModel);
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processInputModel
|
||||
.getWf_procDefId());
|
||||
ProcessInstance processInstance = getProcessInstance(processInputModel
|
||||
.getWf_procInstId());
|
||||
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
// ----------------------------------
|
||||
// 根据wfCurActInstId获取当前任务实例
|
||||
Task task = this.findTaskById(processInputModel.getWf_curActInstId());
|
||||
if (processInputModel.getWf_receiver().indexOf(",") != -1) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2056,
|
||||
String.format("转办任务不允许有多个接收人!任务实例ID[%s],接收人[%s]",
|
||||
processInputModel.getWf_curActInstId(),
|
||||
processInputModel.getWf_receiver()));
|
||||
}
|
||||
if(processInputModel.getWf_sender()!=null){
|
||||
identityService.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
}
|
||||
ProcessInstanceModel processInstanceModel = null;
|
||||
try {
|
||||
String receiver = existDeputeReplaceReceiver(task.getId(),processInputModel.getWf_procDefKey(), processInputModel.getWf_receiver(),
|
||||
task.getTenantId());
|
||||
// 将当前待办的接收人修改最新的receiver
|
||||
this.taskService.setAssignee(task.getId(),receiver);
|
||||
processInstanceModel = processInstanceModellBuilder
|
||||
.builderProcessInfo(processInputModel, processDefinition,
|
||||
processInstance, task);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2050,
|
||||
String.format("流程执行失败,task[%s],processInputModel[%s]",
|
||||
task, processInputModel), e);
|
||||
}
|
||||
if (StringUtils.isNotBlank(processInputModel.getWf_curComment())) {
|
||||
taskService.addComment(task.getId(), task.getProcessInstanceId(),"transfer_comment",
|
||||
processInputModel.getWf_curComment(),
|
||||
processInputModel.getWf_commentDisplayArea());
|
||||
}
|
||||
try {
|
||||
ProcessInputModel tempProcessInputModel = (ProcessInputModel) processInstanceService
|
||||
.getTaskVariables(task.getId()).get(
|
||||
WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY);
|
||||
tempProcessInputModel.setWf_receiver(processInputModel
|
||||
.getWf_receiver());
|
||||
ProcessDefinitionUtils.convertWf_receiver(processInputModel);
|
||||
tempProcessInputModel.setWf_receivers(processInputModel
|
||||
.getWf_receivers());
|
||||
this.taskService.setVariableLocal(task.getId(),
|
||||
WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
tempProcessInputModel);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2050,String.format(
|
||||
"流程转办失败,task[%s],processInputModel[%s]", task,
|
||||
processInputModel), e);
|
||||
}
|
||||
// 设置返回参数
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据委托待办来转换receiver字段
|
||||
*
|
||||
* @param processDefKey
|
||||
* @param receiver
|
||||
* @param appId
|
||||
* @param delegateTask
|
||||
* @param processInputModel
|
||||
* @return
|
||||
*/
|
||||
public String existDeputeReplaceReceiver(String taskId,String processDefKey,String receiver, String appId) {
|
||||
try {
|
||||
UserService userService = (UserService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("userServiceImpl");
|
||||
com.blueland.bpm.identity.model.User userReiver = userService
|
||||
.getUserById(receiver);
|
||||
DeputeManager deputeManager = (DeputeManager) ApplicationContextHolder
|
||||
.getBean("deputeManager");
|
||||
|
||||
Depute depute = deputeManager.getUserProcessDepute(
|
||||
userReiver.getUserCode(), processDefKey, appId);
|
||||
//判断是否存在委托关系
|
||||
if (depute == null
|
||||
|| StringUtils.isEmpty(depute.getMandataryUserId())) {//不存在直接返回原始接受人
|
||||
return receiver;
|
||||
}
|
||||
if (userService.getUserById(depute.getMandataryUserId()) != null) {//委托人是否有效
|
||||
logger.info("执行委托代办逻辑, receiver={}, mandataryUserId={},curtActInstId={}", new Object[] {
|
||||
receiver,depute.getMandataryUserId(), taskId});
|
||||
this.taskService.setOwner(taskId,receiver);//备份原始接受人
|
||||
return depute.getMandataryUserId();//返回委托人
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.logger.error("existDeputeReplaceReceiver error,taskId:"+taskId+",receiver:"+receiver, e);
|
||||
}
|
||||
return receiver;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
/**
|
||||
* 驳回处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_REJECT_ACTIVITY)
|
||||
public class RejectActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
@Autowired
|
||||
ExecuteActivityExecutor executeActivityExecutor;
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
//additionalReceiver(processInputModel);
|
||||
// 设置返回参数
|
||||
return executeActivityExecutor.execute(processInputModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回没有传递接受人时,自动找对应环节的人员
|
||||
* @param processInputModel
|
||||
*/
|
||||
private void additionalReceiver(ProcessInputModel processInputModel){
|
||||
try{
|
||||
if(processInputModel.getWf_receiver()!=null){
|
||||
List<ActivityInstanceModel> result = processInstanceService.findBackAvtivity(processInputModel.getWf_curActInstId());
|
||||
if(!result.isEmpty()){
|
||||
for (ActivityInstanceModel actInst : result) {
|
||||
if(actInst.getActDefId().equals(processInputModel.getWf_nextActDefId())){
|
||||
//by lw 20220119 User user=this.userService.getUserByCode(actInst.getReceiverUserId(),actInst.getReceiverOrgId());
|
||||
User user=this.userService.getUserById(actInst.getReceiverUserId());
|
||||
processInputModel.setWf_receiver(user.getUserId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.TempSaveTaskCmd;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 暂存活动(包含新建暂存、待办暂存逻辑)执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_SAVE_ACTIVITY)
|
||||
public class SaveActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
|
||||
// 设置页面fields
|
||||
//if (StringUtils.isEmpty(processInputModel.getWf_fields())) {
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
// }
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
PageFieldsUtil.fieldsToXml(processInputModel.getFields()));
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
String sender = processInputModel.getWf_sender();
|
||||
// 设置流程发起人
|
||||
identityService
|
||||
.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
// ----------------------------------
|
||||
ProcessInstanceModel processInstanceModel = null;
|
||||
ProcessInstance processInstance = null;
|
||||
//新建暂存
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_curActInstId())
|
||||
|| StringUtils.isEmpty(processInputModel.getWf_procInstId())) {
|
||||
processInputModel
|
||||
.setWf_actionType(WorkFlowContants.ACTION_TYPE_LAUCH_SAVE_PROCESS);
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_receiver())) {
|
||||
// 下一步人员为空,自动路由到环节绑定的资源中的最前一个人
|
||||
//setCurActDefIdAndNextActDefIdByStart(processInputModel);
|
||||
sender = processInputModel.getWf_sender();
|
||||
}
|
||||
// 设置流程发起人
|
||||
identityService.setAuthenticatedUserId(processInputModel
|
||||
.getWf_sender());
|
||||
// 起草流程特殊处理
|
||||
processInputModel.setWf_receiver(sender);
|
||||
// 启动流程
|
||||
processInstance = this.runtimeService.startProcessInstanceById(
|
||||
processInputModel.getWf_procDefId(),
|
||||
processInputModel.getWf_businessKey(), workflowMap);
|
||||
} else {//待办暂存
|
||||
// 查询流程
|
||||
processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
}
|
||||
if(processInputModel.getWf_receivers()!=null) {
|
||||
sender=processInputModel.getWf_receivers().get(0).getReceiveUserId();
|
||||
}
|
||||
// 根据sender获取起草环节的任务
|
||||
Task task = this.findTaskByAssignee(processInstance.getId(), sender);
|
||||
processInputModel.setWf_curActInstId(task.getId());
|
||||
// this.taskService.claim(task.getId(), sender);
|
||||
|
||||
processInstanceModel = processInstanceModellBuilder.builderProcessInfo(processInputModel,
|
||||
processDefinition, processInstance, task);
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,
|
||||
PageFieldsUtil.fieldsToXml(processInputModel.getFields()));
|
||||
workflowMap.put(WorkFlowContants.WF_CUR_COMMENT_KEY, processInputModel.getWf_curComment());
|
||||
|
||||
Command<Void> tempSaveTaskCmd=new TempSaveTaskCmd(processInputModel.getWf_curActInstId(),
|
||||
workflowMap);
|
||||
this.managementService.executeCommand(tempSaveTaskCmd);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 该类暂时无用
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class SendReaderExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)throws WorkFlowException {
|
||||
// TODO Auto-generated method stub
|
||||
return new ProcessInstanceModel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 流程流转(发送信号给等待任务并继续执行流程)执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_SIGNAL_RECEIVE_ACTIVITY)
|
||||
public class SignalReceiveActivityExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
if (processInputModel == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"流程输入参数对象{processInputModel}不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_procInstId())) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,String.format(
|
||||
"流程输入参数{流程实例ID:wf_procInstId}不能为空,processInputModel[%s]",
|
||||
processInputModel));
|
||||
} else if (StringUtils.isEmpty(processInputModel.getWf_curActDefId())) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,String.format(
|
||||
"流程输入参数{信号环节ID:wf_curActDefId()}不能为空,processInputModel[%s]",
|
||||
processInputModel));
|
||||
} else if (StringUtils.isEmpty(processInputModel.getWf_procTitle())) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,String.format(
|
||||
"流程输入参数{流程标题:wf_procTitle}不能为空,processInputModel[%s]",
|
||||
processInputModel));
|
||||
}
|
||||
|
||||
ProcessInstance processInstance =getProcessInstance(processInputModel.getWf_procInstId());
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processInstance.getProcessDefinitionId());
|
||||
//validateProcessInputModel(processInputModel);
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
identityService
|
||||
.setAuthenticatedUserId(processInputModel.getWf_sender());
|
||||
// ----------------------------------
|
||||
ProcessInstanceModel processInstanceModel = null;
|
||||
try {
|
||||
ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery()
|
||||
.processInstanceId(processInstance.getId())
|
||||
.activityId(processInputModel.getWf_curActDefId())
|
||||
.singleResult();
|
||||
List<HistoricTaskInstanceEntity> historicTaskInstances = (List)historyService.createHistoricTaskInstanceQuery().includeProcessVariables()
|
||||
.executionId(execution.getId()).taskDefinitionKey(processInputModel.getWf_curActDefId()).orderByHistoricTaskInstanceEndTime().desc().list();
|
||||
if(historicTaskInstances==null||historicTaskInstances.isEmpty()){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2057,"wf_curActDefId对应节点无法在历史任务表中找到");
|
||||
}
|
||||
HistoricTaskInstanceEntity historicTaskInstance=historicTaskInstances.get(0);
|
||||
ProcessInputModel oldprocessInputModel =(ProcessInputModel) historicTaskInstance.getProcessVariables().get(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY);
|
||||
if(oldprocessInputModel.getFields().isEmpty()){
|
||||
// 设置页面fields
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
}else{
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(oldprocessInputModel.getFields()));
|
||||
}
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,processInputModel.getWf_fields());
|
||||
if (processInputModel.getWf_businessDataObject() != null) {
|
||||
processInputModel.getWf_variables().put(WorkFlowContants.WF_BUSINESS_DATA_OBJECT_KEY,
|
||||
processInputModel.getWf_businessDataObject());
|
||||
}else{
|
||||
processInputModel.getWf_variables().put(WorkFlowContants.WF_BUSINESS_DATA_OBJECT_KEY,
|
||||
oldprocessInputModel.getWf_businessDataObject());
|
||||
}
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
if(oldprocessInputModel.getWf_receivers()!=null){
|
||||
processInputModel.setWf_receiver(oldprocessInputModel.getWf_receiver());
|
||||
}
|
||||
processInputModel.setWf_procDefName(processInstance.getProcessDefinitionName());
|
||||
processInputModel.setWf_procDefId(processInstance.getProcessDefinitionId());
|
||||
processInputModel.setWf_sendUserId(historicTaskInstance.getSendUserId());
|
||||
processInputModel.setWf_sendUserOrgId(historicTaskInstance.getSenderOrgId());
|
||||
processInputModel.setWf_sender(historicTaskInstance.getSender());
|
||||
runtimeService.signal(execution.getId(),workflowMap);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2050,String.format(
|
||||
"流程调度失败,processInstance[%s],processInputModel[%s]",
|
||||
processInstance, processInputModel), e);
|
||||
}
|
||||
// 设置返回参数
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.blueland.bpm.engine.core.executor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.cmd.TempSaveTaskCmd;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.PageFieldsUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 流程贯穿-服务任务异步执行类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service(WorkFlowContants.ACTION_TYPE_THROUGH_PROCESS)
|
||||
public class ThroughProcessExecutor extends AbstractProcessExecutor implements ProcessExecutor{
|
||||
|
||||
@Override
|
||||
public ProcessInstanceModel execute(ProcessInputModel processInputModel)
|
||||
throws WorkFlowException {
|
||||
Map<String, Object> workflowMap = new HashMap<String, Object>();
|
||||
|
||||
ProcessDefinition processDefinition = this.repositoryService
|
||||
.getProcessDefinition(processInputModel.getWf_procDefId());
|
||||
additionalProcessInputModel(processInputModel, processDefinition);
|
||||
|
||||
// 设置参数到引擎变量中
|
||||
workflowMap.put(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY,
|
||||
processInputModel);
|
||||
workflowMap.putAll(processInputModel.getWf_variables());
|
||||
String receiver = processInputModel.getWf_receiver();
|
||||
// 设置流程发起人
|
||||
identityService
|
||||
.setAuthenticatedUserId(receiver);
|
||||
// ----------------------------------
|
||||
ProcessInstanceModel processInstanceModel = new ProcessInstanceModel();
|
||||
ProcessInstance processInstance = null;
|
||||
// 新建暂存
|
||||
if (StringUtils.isEmpty(processInputModel.getWf_curActInstId())
|
||||
|| StringUtils.isEmpty(processInputModel.getWf_procInstId())) {
|
||||
processInputModel
|
||||
.setWf_actionType(WorkFlowContants.ACTION_TYPE_LAUCH_SAVE_PROCESS);
|
||||
identityService.setAuthenticatedUserId(receiver);
|
||||
// 启动流程
|
||||
processInstance = this.runtimeService.startProcessInstanceById(
|
||||
processInputModel.getWf_procDefId(),
|
||||
processInputModel.getWf_businessKey(), workflowMap);
|
||||
|
||||
} else {// 待办暂存
|
||||
// 查询流程
|
||||
processInstance = getProcessInstance(processInputModel.getWf_procInstId());
|
||||
}
|
||||
// 在服务任务中调用流程贯穿功能时,流程都在同一个事物中,无法立即启动流程并返回
|
||||
// 根据sender获取起草环节的任务
|
||||
Task task = this.taskService.createTaskQuery()
|
||||
.processInstanceId(processInstance.getId())
|
||||
.taskAssignee(receiver).singleResult();
|
||||
if(task==null){
|
||||
ExecutionEntity executionEntity=(ExecutionEntity)processInstance;
|
||||
task=executionEntity.getTasks().get(0);
|
||||
}
|
||||
processInputModel.setWf_curActInstId(task.getId());
|
||||
// 下一步环节为空时,根据规则自动查询出下一步环节
|
||||
|
||||
|
||||
processInstanceModel = processInstanceModellBuilder.builderProcessInfo(
|
||||
processInputModel, processDefinition, processInstance, task);
|
||||
processInputModel.setWf_fields(PageFieldsUtil
|
||||
.fieldsToXml(processInputModel.getFields()));
|
||||
workflowMap.put(WorkFlowContants.WF_FIELDS_KEY,processInputModel.getWf_fields());
|
||||
workflowMap.put(WorkFlowContants.WF_CUR_COMMENT_KEY,
|
||||
processInputModel.getWf_curComment());
|
||||
|
||||
Command<Void> tempSaveTaskCmd = new TempSaveTaskCmd(
|
||||
processInputModel.getWf_curActInstId(), workflowMap);
|
||||
this.managementService.executeCommand(tempSaveTaskCmd);
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.blueland.bpm.engine.core.handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ActivityDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
|
||||
/**
|
||||
* 业务应用回调处理接口
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public interface BizProcessHandler {
|
||||
/**
|
||||
* 流程提交之后的业务回调方法
|
||||
* @param processInputModel 流程输入模型
|
||||
*/
|
||||
void submitProcessAfter(ProcessInstanceModel processInstanceModel);
|
||||
/**
|
||||
* 流程提交之前的业务回调方法
|
||||
* @param processInputModel 流程输出模型
|
||||
*/
|
||||
void submitProcessBefore(ProcessInputModel processInputModel);
|
||||
|
||||
/**
|
||||
* 选择下一步环节时在此方法中可过滤掉下一环节人员
|
||||
* @param activityResources 流程平台传入下一环节待选人员
|
||||
* @param processInstanceModel 流程实例模型
|
||||
* @param userId 当前登录用户ID
|
||||
* @param conditionMap 界面传入的fields
|
||||
*/
|
||||
void filterNextStepUserTree(List<ActivityResourceModel> activityResources,ProcessInstanceModel processInstanceModel,String userId,Map<String,Object> fieldsMap);
|
||||
/**
|
||||
* 选择下一步环节时在此方法中可过滤掉下一环节
|
||||
* @param activityDefinitionModel 流程平台传入下一环节
|
||||
* @param processInstanceModel 流程实例模型
|
||||
* @param conditionMap 界面传入的fields
|
||||
*/
|
||||
void filterNextStep(List<ActivityDefinitionModel> activityDefinitionModel,ProcessInstanceModel processInstanceModel,Map<String,Object> fieldsMap);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.blueland.bpm.engine.core.handler;
|
||||
|
||||
import java.util.Map;
|
||||
/**
|
||||
* 引擎业务应用全局回调处理接口
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public interface GlobalBizHandler {
|
||||
String AGENT_TYPE_AFTER = "AFTER";
|
||||
String AGENT_TYPE_BEFORE = "BEFORE";
|
||||
|
||||
String TASKS_KEY="tasks";
|
||||
String HIS_TASKS_KEY="hisTasks";
|
||||
public void execute(Map<String,Object> processMap);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.blueland.bpm.engine.core.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.common.util.ClassUtils;
|
||||
import com.blueland.bpm.engine.config.model.GloblBizProcessHandler;
|
||||
import com.blueland.bpm.engine.config.service.GloblBizProcessHandlerManager;
|
||||
/**
|
||||
* 引擎业务应用全局回调处理工厂
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class GlobalBizHandlerFactory {
|
||||
protected static Logger logger = LoggerFactory.getLogger(GlobalBizHandlerFactory.class);
|
||||
private static GlobalBizHandlerFactory globalProcessHandlerFactory=new GlobalBizHandlerFactory();
|
||||
static GloblBizProcessHandlerManager globlBizProcessHandlerManager=(GloblBizProcessHandlerManager) ApplicationContextHolder.getBean("globlBizProcessHandlerManager");
|
||||
private GlobalBizHandlerFactory(){
|
||||
|
||||
}
|
||||
|
||||
// WfBusinessAgent services
|
||||
protected static Map<String, List<GlobalBizHandler>> globalProcessHandlerServiceMap = null;
|
||||
|
||||
static{
|
||||
globalProcessHandlerServiceMap = new HashMap<String, List<GlobalBizHandler>>();
|
||||
}
|
||||
protected static void initGloblBizProcessHandler(){
|
||||
List<GloblBizProcessHandler> globlBizProcessHandlers=globlBizProcessHandlerManager.findByExample(null);
|
||||
for(GloblBizProcessHandler globlBizProcessHandler:globlBizProcessHandlers){
|
||||
if("1".equals(globlBizProcessHandler.getGbphStatus())) {
|
||||
addGlobalProcessHandlerService(globlBizProcessHandler.getGbphType(),globlBizProcessHandler.getGbphClassName());
|
||||
}
|
||||
}
|
||||
}
|
||||
public static GlobalBizHandlerFactory getInstance(){
|
||||
if(globalProcessHandlerServiceMap.isEmpty()){
|
||||
initGloblBizProcessHandler();
|
||||
}
|
||||
return globalProcessHandlerFactory;
|
||||
}
|
||||
public GlobalBizHandlerFactory getWfBusinessAgentFactory(){
|
||||
|
||||
return globalProcessHandlerFactory;
|
||||
}
|
||||
|
||||
public Map<String, List<GlobalBizHandler>> getGlobalProcessHandlerServiceMap() {
|
||||
return globalProcessHandlerServiceMap;
|
||||
}
|
||||
|
||||
public List<GlobalBizHandler> getGlobalProcessHandlerService(String agentType) {
|
||||
return globalProcessHandlerServiceMap.get(agentType);
|
||||
}
|
||||
|
||||
public static void addGlobalProcessHandlerService(String agentType,
|
||||
String wfBusinessAgentServiceClass) {
|
||||
if (StringUtils.isEmpty(agentType)) {
|
||||
return;
|
||||
}
|
||||
List<GlobalBizHandler> agentServices = globalProcessHandlerServiceMap
|
||||
.get(agentType);
|
||||
if (agentServices == null) {
|
||||
agentServices = new ArrayList<GlobalBizHandler>();
|
||||
globalProcessHandlerServiceMap.put(agentType, agentServices);
|
||||
}
|
||||
Object obj = null;
|
||||
try {
|
||||
obj =ClassUtils.getInstance(wfBusinessAgentServiceClass);
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
if (obj != null)
|
||||
agentServices.add((GlobalBizHandler) obj);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.blueland.bpm.engine.core.handler;
|
||||
|
||||
/**
|
||||
* 引擎业务应用全局回调处理拦截器
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class GlobalBizHandlerInterceptor {
|
||||
|
||||
public void handleInvocation(GlobalBizHandlerInvocation invocation)
|
||||
throws Exception {
|
||||
invocation.proceed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.blueland.bpm.engine.core.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.impl.delegate.DelegateInvocation;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
|
||||
/**
|
||||
* 引擎业务应用全局回调处理拦截器
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class GlobalBizHandlerInvocation extends DelegateInvocation {
|
||||
|
||||
protected final GlobalBizHandler wfBusinessAgentService;
|
||||
protected final Map<String,Object> processInstanceModel;
|
||||
|
||||
public GlobalBizHandlerInvocation(
|
||||
GlobalBizHandler wfBusinessAgentService,
|
||||
Map<String,Object> processInstanceModel) {
|
||||
this.wfBusinessAgentService = wfBusinessAgentService;
|
||||
this.processInstanceModel = processInstanceModel;
|
||||
}
|
||||
|
||||
protected void invoke() throws Exception {
|
||||
//TaskEntity task=(TaskEntity) delegateTask;
|
||||
wfBusinessAgentService.execute(processInstanceModel);
|
||||
}
|
||||
|
||||
public Object getTarget() {
|
||||
return wfBusinessAgentService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.blueland.bpm.engine.core.identity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.identity.Group;
|
||||
import org.activiti.engine.impl.GroupQueryImpl;
|
||||
import org.activiti.engine.impl.Page;
|
||||
import org.activiti.engine.impl.persistence.entity.GroupEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.identity.OrgService;
|
||||
import com.blueland.bpm.identity.RoleService;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
import com.blueland.bpm.identity.model.Org;
|
||||
import com.blueland.bpm.identity.model.Role;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
/**
|
||||
* 扩展activiti资源组的管理类(替换掉activiti中的group接口)
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class CustomGroupManager extends GroupEntityManager {
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(CustomGroupManager.class);
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private OrgService orgService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/* @Override
|
||||
public GroupEntity findGroupById(final String groupCode) {
|
||||
GroupEntity groupEntity = null;
|
||||
if (groupCode == null)
|
||||
return groupEntity;
|
||||
try {
|
||||
Role bRole = roleService.getRoleById(groupCode);
|
||||
groupEntity = new GroupEntity();
|
||||
groupEntity.setRevision(1);
|
||||
// activiti有3种预定义的组类型:security-role、assignment、user
|
||||
// 如果使用Activiti
|
||||
// Explorer,需要security-role才能看到manage页签,需要assignment才能claim任务
|
||||
groupEntity.setType("assignment");
|
||||
groupEntity.setId(bRole.getRoleId());
|
||||
groupEntity.setName(bRole.getRoleName());
|
||||
return groupEntity;
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
return groupEntity;
|
||||
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public List<Group> findGroupsByUser(String userCode,String appId) {
|
||||
List<Group> groups = new ArrayList<Group>();
|
||||
if (userCode == null)
|
||||
return groups;
|
||||
try {
|
||||
List<Role> bRoleList = roleService.findRoleByUserId(userCode);
|
||||
|
||||
if (bRoleList == null || bRoleList.isEmpty())
|
||||
return groups;
|
||||
|
||||
GroupEntity GroupEntity;
|
||||
for (Role bRole : bRoleList) {
|
||||
if(StringUtils.isEmpty(appId)||!appId.equals(bRole.getRoleAppId())) {
|
||||
continue;
|
||||
}
|
||||
GroupEntity = new GroupEntity();
|
||||
GroupEntity.setRevision(1);
|
||||
GroupEntity.setType("assignment");
|
||||
GroupEntity.setId(bRole.getRoleId());
|
||||
GroupEntity.setName(bRole.getRoleName());
|
||||
groups.add(GroupEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Group> findGroupByQueryCriteria(GroupQueryImpl query, Page page) {
|
||||
List<Group> bGroups = null;
|
||||
if (query == null)
|
||||
return bGroups;
|
||||
try {
|
||||
Role paramsRole = MyUserToActivitiUserUtils.toMyRole(query);
|
||||
List<Role> roles = roleService
|
||||
.findRoleByEntityCriteria(paramsRole);
|
||||
if (roles == null || roles.isEmpty())
|
||||
return new ArrayList<org.activiti.engine.identity.Group>();
|
||||
bGroups = MyUserToActivitiUserUtils.toActivitiGroups(roles);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
return bGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long findGroupCountByQueryCriteria(GroupQueryImpl query) {
|
||||
// MyUserToActivitiUserUtils
|
||||
throw new RuntimeException("not implement method.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Group> findOrgsByUser(String userId) {
|
||||
User user=userService.getUserById(userId);
|
||||
if(user==null){
|
||||
return null;
|
||||
}
|
||||
List<Org> orgList=orgService.findParentOrgTree(user.getOrgId());
|
||||
return MyUserToActivitiUserUtils.toActivitiGroupsByOrg(orgList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.blueland.bpm.engine.core.identity;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Session;
|
||||
import org.activiti.engine.impl.interceptor.SessionFactory;
|
||||
import org.activiti.engine.impl.persistence.entity.GroupIdentityManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
/**
|
||||
* 扩展activiti资源组的管理类工厂
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class CustomGroupManagerFactory implements SessionFactory {
|
||||
@Autowired
|
||||
private CustomGroupManager customGroupManager;
|
||||
|
||||
|
||||
public Class<?> getSessionType() {
|
||||
// 返回原始的GroupIdentityManager类型
|
||||
return GroupIdentityManager.class;
|
||||
}
|
||||
|
||||
public Session openSession() {
|
||||
// 返回自定义的GroupEntityManager实例
|
||||
return customGroupManager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.blueland.bpm.engine.core.identity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.identity.Group;
|
||||
import org.activiti.engine.identity.User;
|
||||
import org.activiti.engine.impl.Page;
|
||||
import org.activiti.engine.impl.UserQueryImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.UserEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.identity.RoleService;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
import com.blueland.bpm.identity.model.Role;
|
||||
/**
|
||||
* 扩展activiti人员的管理类(替换掉activiti中的user接口)
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class CustomUserManager extends UserEntityManager {
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(CustomUserManager.class);
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Override
|
||||
public UserEntity findUserById(final String userCode) {
|
||||
UserEntity userEntity = null;
|
||||
if (userCode == null)
|
||||
return userEntity;
|
||||
try {
|
||||
com.blueland.bpm.identity.model.User bUser = userService
|
||||
.getUserById(userCode);
|
||||
userEntity = MyUserToActivitiUserUtils.toActivitiUser(bUser);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Group> findGroupsByUser(final String userCode) {
|
||||
List<Group> groups = null;
|
||||
if (userCode == null)
|
||||
return groups;
|
||||
try {
|
||||
List<Role> bRoles = roleService.findRoleByUserId(userCode);
|
||||
groups = MyUserToActivitiUserUtils.toActivitiGroups(bRoles);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
return groups;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findUserByQueryCriteria(UserQueryImpl query, Page page) {
|
||||
throw new RuntimeException("not implement method.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentityInfoEntity findUserInfoByUserIdAndKey(String userId,
|
||||
String key) {
|
||||
throw new RuntimeException("not implement method.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findUserInfoKeysByUserIdAndType(String userId,
|
||||
String type) {
|
||||
throw new RuntimeException("not implement method.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long findUserCountByQueryCriteria(UserQueryImpl query) {
|
||||
throw new RuntimeException("not implement method.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.blueland.bpm.engine.core.identity;
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Session;
|
||||
import org.activiti.engine.impl.interceptor.SessionFactory;
|
||||
import org.activiti.engine.impl.persistence.entity.UserIdentityManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
/**
|
||||
* 扩展activiti人员的管理类工厂
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class CustomUserManagerFactory implements SessionFactory {
|
||||
@Autowired
|
||||
private CustomUserManager customUserManager;
|
||||
|
||||
|
||||
public Class<?> getSessionType() {
|
||||
// 返回原始的UserIdentityManager类型
|
||||
return UserIdentityManager.class;
|
||||
}
|
||||
|
||||
public Session openSession() {
|
||||
// 返回自定义的UserManager实例
|
||||
return customUserManager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.blueland.bpm.engine.core.identity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.impl.GroupQueryImpl;
|
||||
import org.activiti.engine.impl.UserQueryImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.GroupEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.UserEntity;
|
||||
|
||||
import com.blueland.bpm.identity.model.Org;
|
||||
import com.blueland.bpm.identity.model.Role;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
|
||||
/**
|
||||
* activiti中的user、group与自定义的user、group属性转换类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class MyUserToActivitiUserUtils {
|
||||
public static UserEntity toActivitiUser(User bUser){
|
||||
UserEntity userEntity = new UserEntity();
|
||||
if(bUser==null)
|
||||
return userEntity;
|
||||
userEntity.setId(bUser.getUserId());
|
||||
userEntity.setFirstName(bUser.getUserName());
|
||||
userEntity.setLastName(bUser.getUserName());
|
||||
userEntity.setPassword(bUser.getUserPwd());
|
||||
//userEntity.setEmail(bUser.getuser);
|
||||
userEntity.setRevision(1);
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
public static User toMyUser(UserQueryImpl userQueryImpl){
|
||||
User user = new User();
|
||||
user.setUserId(userQueryImpl.getId());
|
||||
user.setUserName(userQueryImpl.getFirstName());
|
||||
return user;
|
||||
}
|
||||
|
||||
public static Role toMyRole(GroupQueryImpl groupQueryImpl){
|
||||
Role role = new Role();
|
||||
role.setRoleId(groupQueryImpl.getId());
|
||||
role.setRoleName(groupQueryImpl.getName());
|
||||
return role;
|
||||
}
|
||||
|
||||
|
||||
public static GroupEntity toActivitiGroup(Role role){
|
||||
GroupEntity groupEntity = new GroupEntity();
|
||||
if(role==null)
|
||||
return groupEntity;
|
||||
groupEntity.setRevision(1);
|
||||
groupEntity.setType("assignment");
|
||||
groupEntity.setId(role.getRoleId());
|
||||
groupEntity.setName(role.getRoleName());
|
||||
return groupEntity;
|
||||
}
|
||||
|
||||
|
||||
public static List<org.activiti.engine.identity.Group> toActivitiGroups(List<Role> bGroups){
|
||||
List<org.activiti.engine.identity.Group> groupEntitys = new ArrayList<org.activiti.engine.identity.Group>();
|
||||
for (Role bGroup : bGroups) {
|
||||
GroupEntity groupEntity = toActivitiGroup(bGroup);
|
||||
groupEntitys.add(groupEntity);
|
||||
}
|
||||
return groupEntitys;
|
||||
}
|
||||
|
||||
public static List<org.activiti.engine.identity.Group> toActivitiGroupsByOrg(List<Org> orgList){
|
||||
List<org.activiti.engine.identity.Group> groupEntitys = new ArrayList<org.activiti.engine.identity.Group>();
|
||||
for (Org org : orgList) {
|
||||
GroupEntity groupEntity = new GroupEntity();
|
||||
if(org==null)
|
||||
return groupEntitys;
|
||||
groupEntity.setRevision(1);
|
||||
groupEntity.setType("assignment");
|
||||
groupEntity.setId(org.getOrgId());
|
||||
groupEntity.setName(org.getOrgName());
|
||||
groupEntitys.add(groupEntity);
|
||||
}
|
||||
return groupEntitys;
|
||||
}
|
||||
|
||||
public static List<org.activiti.engine.identity.User> toActivitiUsers(List<User> bUsers){
|
||||
List<org.activiti.engine.identity.User> userEntitys = new ArrayList<org.activiti.engine.identity.User>();
|
||||
for (User bUser : bUsers) {
|
||||
UserEntity userEntity = toActivitiUser(bUser);
|
||||
userEntitys.add(userEntity);
|
||||
}
|
||||
return userEntitys;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
package com.blueland.bpm.engine.core.listener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.activiti.engine.impl.context.Context;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntity;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.config.model.Depute;
|
||||
import com.blueland.bpm.engine.config.service.DeputeManager;
|
||||
import com.blueland.bpm.engine.core.model.ActivityReceiverModel;
|
||||
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessDefinitionService;
|
||||
import com.blueland.bpm.engine.core.service.ProcessModelService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.ProcessModelUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
|
||||
/**
|
||||
* 全局设置任务接收人监听器
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class GlobalTaskAssigneeListener implements TaskListener {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private int MULTI_INSTANCE_USER_TASK = 2;
|
||||
private int MULTI_INSTANCE_CALL_ACTIVITY = 0;
|
||||
private int MULTI_INSTANCE_NOMAL = 1;
|
||||
|
||||
@Override
|
||||
public void notify(DelegateTask delegate) {
|
||||
if (!delegate.getEventName().equals(TaskListener.EVENTNAME_CREATE))
|
||||
return;
|
||||
TaskEntity delegateTask = (TaskEntity) delegate;
|
||||
logger.debug("触发了全局监听器, pid={}, tid={}, event={}", new Object[] {
|
||||
delegateTask.getProcessInstanceId(), delegateTask.getId(),
|
||||
delegateTask.getEventName() });
|
||||
try {
|
||||
ProcessDefinitionEntity processDefinitionEntity = Context
|
||||
.getCommandContext()
|
||||
.getProcessDefinitionEntityManager()
|
||||
.findProcessDefinitionById(
|
||||
delegateTask.getProcessDefinitionId());
|
||||
// 获取客户端输入对象
|
||||
ProcessInputModel processInputModel = ProcessDefinitionUtils
|
||||
.getWfprocessInputModel(delegateTask);// 同步子流会返回数据
|
||||
logger.info("分配人员processInputModel对象,processInputModel={}", new Object[] {processInputModel});
|
||||
// 获取客户端接受人员列表
|
||||
String receiver = processInputModel.getWf_receiver();
|
||||
receiver = (receiver == null ? "" : receiver);
|
||||
int isMultiFlag = isMultiFlag(delegateTask, receiver);
|
||||
ActivityImpl prevTask = delegateTask.getExecution()
|
||||
.getProcessDefinition()
|
||||
.findActivity(delegateTask.getPreTaskDefKey());
|
||||
boolean isPrevTaskService=prevTask!=null&&BpmnXMLConstants.ELEMENT_TASK_SERVICE
|
||||
.equals(prevTask.getProperty("type"));
|
||||
/* if(prevTask!=null&&BpmnXMLConstants.ELEMENT_TASK_SERVICE
|
||||
.equals(prevTask.getProperty("type"))){
|
||||
// 系统自动查找接受人
|
||||
receiver = getGroupFirstReceiver(
|
||||
delegateTask.getProcessInstanceId(),
|
||||
delegateTask.getProcessDefinitionId(),
|
||||
delegateTask.getId(), delegateTask.getPreTaskDefKey(),
|
||||
delegateTask.getTaskDefinitionKey(),
|
||||
delegateTask.getSender(), delegate.getVariables());
|
||||
if (StringUtils.isEmpty(receiver)) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2064,"自动查询环节人员失败,delegate:"
|
||||
+ delegate);
|
||||
}
|
||||
}*/
|
||||
if ((StringUtils.isEmpty(receiver)
|
||||
&& isMultiFlag == MULTI_INSTANCE_NOMAL)||isPrevTaskService) {// 当客户端没有提交接受人且当前环节不是多实例任务时,自己找到环节绑定的资源
|
||||
// 系统自动查找接受人
|
||||
receiver = getGroupFirstReceiver(
|
||||
delegateTask.getProcessInstanceId(),
|
||||
delegateTask.getProcessDefinitionId(),
|
||||
delegateTask.getId(), delegateTask.getPreTaskDefKey(),
|
||||
delegateTask.getTaskDefinitionKey(),
|
||||
delegateTask.getSender(), delegate.getVariables());
|
||||
if (StringUtils.isEmpty(receiver)) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2064,"自动查询环节人员失败,delegate:"
|
||||
+ delegate);
|
||||
}
|
||||
}
|
||||
// 规则1:普通用户任务设置人员逻辑
|
||||
if (isMultiFlag == MULTI_INSTANCE_NOMAL) {
|
||||
if(receiver.indexOf(',')!=-1)
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2063,"error receiver["+receiver+"] count.");
|
||||
setAssignee(delegateTask, processInputModel,
|
||||
processDefinitionEntity.getKey(), receiver, MULTI_INSTANCE_NOMAL);
|
||||
} else if (isMultiFlag == MULTI_INSTANCE_CALL_ACTIVITY) {// 规则2:调用外部子流程-多实例任务设置人员逻辑
|
||||
ExecutionEntity executionEntity = delegateTask.getExecution()
|
||||
.getSuperExecution() != null ? delegateTask
|
||||
.getExecution().getSuperExecution() : delegateTask
|
||||
.getExecution();
|
||||
VariableInstanceEntity assigneeVar = (VariableInstanceEntity) executionEntity
|
||||
.getVariableInstances().get(
|
||||
WorkFlowContants.ELEMENT_ASSIGNEE);
|
||||
setSubBusinessKey(delegateTask.getExecution(),processInputModel,assigneeVar.getTextValue());
|
||||
setAssignee(delegateTask, processInputModel,
|
||||
processDefinitionEntity.getKey(),
|
||||
assigneeVar.getTextValue(), MULTI_INSTANCE_CALL_ACTIVITY);
|
||||
} else if (isMultiFlag == MULTI_INSTANCE_USER_TASK) {// 单环节多实例和内嵌子流程设置人员逻辑
|
||||
setAssignee(delegateTask, processInputModel,
|
||||
processDefinitionEntity.getKey(),
|
||||
delegateTask.getAssignee(), MULTI_INSTANCE_USER_TASK);
|
||||
}
|
||||
// 设置上下文
|
||||
setTaskVariables(delegateTask);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2061,"setAssignee error,delegate:"
|
||||
+ delegate, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配接受人
|
||||
*
|
||||
* @param delegateTask
|
||||
* @param processInputModel
|
||||
* @param procDefKey
|
||||
* @param tempReceiver
|
||||
* @param type
|
||||
*/
|
||||
private void setAssignee(TaskEntity delegateTask,
|
||||
ProcessInputModel processInputModel, String procDefKey,
|
||||
String tempReceiver, int type) {
|
||||
validateReceiver(tempReceiver);
|
||||
String receiver = existDeputeReplaceReceiver(procDefKey, tempReceiver,
|
||||
delegateTask.getTenantId(), delegateTask, processInputModel);
|
||||
if (type == MULTI_INSTANCE_CALL_ACTIVITY) {
|
||||
delegateTask.setAssignee(receiver, true, false);
|
||||
logger.info("执行子流程分配人员策略, receiver={}, curtActInstId={},curtActDefId={}, preActDefId={}", new Object[] {
|
||||
receiver, delegateTask.getId(),delegateTask.getTaskDefinitionKey(),delegateTask.getPreTaskDefKey()});
|
||||
} else if (type == MULTI_INSTANCE_NOMAL) {
|
||||
// 不记录IdentityLink的设置接受人
|
||||
delegateTask.setAssigneeNotRecordIdentityLink(receiver);
|
||||
logger.info("执行单环节分配人员策略, receiver={}, curtActInstId={},curtActDefId={}, preActDefId={}", new Object[] {
|
||||
receiver, delegateTask.getId(),delegateTask.getTaskDefinitionKey(),delegateTask.getPreTaskDefKey()});
|
||||
} else if (type == MULTI_INSTANCE_USER_TASK && !receiver.equals(tempReceiver)) {// 处理单环节多实例逻辑,有委托才会需要重新设置一次接受人
|
||||
delegateTask.setAssigneeNotRecordIdentityLink(receiver);
|
||||
logger.info("执行单环节多实例和内嵌子流程分配人员策略, receiver={}, curtActInstId={},curtActDefId={}, preActDefId={}", new Object[] {
|
||||
receiver, delegateTask.getId(),delegateTask.getTaskDefinitionKey(),delegateTask.getPreTaskDefKey()});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取环节绑定资源的第一个资源值
|
||||
*
|
||||
* @param procInstId
|
||||
* @param proceDefId
|
||||
* @param curtTaskId
|
||||
* @param curtActDefId
|
||||
* @param nextActDefId
|
||||
* @param userId
|
||||
* @param conditionMap
|
||||
* @return
|
||||
*/
|
||||
public String getGroupFirstReceiver(String procInstId, String proceDefId,
|
||||
String curtTaskId, String curtActDefId, String nextActDefId,
|
||||
String userId, Map conditionMap) {
|
||||
ProcessDefinitionService processDefinitionService = (ProcessDefinitionService) ApplicationContextHolder
|
||||
.getBean("processDefinitionServiceImpl");
|
||||
UserService userService = (UserService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("userServiceImpl");
|
||||
com.blueland.bpm.identity.model.User user =null;
|
||||
if(userId!=null){
|
||||
user = userService
|
||||
.getUserById(userId);
|
||||
}else{
|
||||
user= new com.blueland.bpm.identity.model.User();
|
||||
}
|
||||
List<ActivityResourceModel> users = null;
|
||||
if (StringUtils.isEmpty(curtActDefId)) {
|
||||
users = processDefinitionService.getResource(proceDefId,
|
||||
nextActDefId);
|
||||
} else {
|
||||
users = processDefinitionService.getActivityUserTree(procInstId,
|
||||
proceDefId, curtTaskId, curtActDefId, nextActDefId,
|
||||
user.getUserCode(), user.getOrgId(), null, conditionMap);
|
||||
}
|
||||
String reicever="";
|
||||
for (ActivityResourceModel treeNode : users) {
|
||||
if ("USER".equals(treeNode.getType())) {
|
||||
reicever= treeNode.getRealId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
logger.info("执行自动查询人员策略, reicever={}, curtActDefId={}, nextActDefId={},curUserId={}", new Object[] {
|
||||
reicever, curtActDefId,nextActDefId,userId});
|
||||
return reicever;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据委托待办来转换receiver字段
|
||||
*
|
||||
* @param processDefKey
|
||||
* @param receiver
|
||||
* @param appId
|
||||
* @param delegateTask
|
||||
* @param processInputModel
|
||||
* @return
|
||||
*/
|
||||
public String existDeputeReplaceReceiver(String processDefKey,
|
||||
String receiver, String appId, TaskEntity delegateTask,
|
||||
ProcessInputModel processInputModel) {
|
||||
try {
|
||||
if (WorkFlowContants.ACTION_TYPE_LAUCH_PROCESS
|
||||
.equals(processInputModel.getWf_actionType())
|
||||
|| WorkFlowContants.ACTION_TYPE_LAUCH_SAVE_PROCESS
|
||||
.equals(processInputModel.getWf_actionType())) {
|
||||
// 如果接受人存在委托待办,就将被委托人替换成receiver,起草节点不进行委托处理
|
||||
boolean isStartUserTask = ProcessDefinitionUtils
|
||||
.isStartUserTask(delegateTask);
|
||||
if (isStartUserTask) {
|
||||
return receiver;
|
||||
}
|
||||
} else if (!(WorkFlowContants.ACTION_TYPE_EXECUTE_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType()) ||WorkFlowContants.ACTION_TYPE_CALLBACK_PREV_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType()) ||WorkFlowContants.ACTION_TYPE_CALLBACK_START_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType()) || WorkFlowContants.ACTION_TYPE_THROUGH_PROCESS
|
||||
.equals(processInputModel.getWf_actionType())|| WorkFlowContants.ACTION_TYPE_REJECT_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType())|| WorkFlowContants.ACTION_TYPE_ADD_MULTIINSTANCE_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType()))) {
|
||||
return receiver;
|
||||
}
|
||||
UserService userService = (UserService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("userServiceImpl");
|
||||
com.blueland.bpm.identity.model.User userReiver = userService
|
||||
.getUserById(receiver);
|
||||
DeputeManager deputeManager = (DeputeManager) ApplicationContextHolder
|
||||
.getBean("deputeManager");
|
||||
|
||||
Depute depute = deputeManager.getUserProcessDepute(
|
||||
userReiver.getUserCode(), processDefKey, appId);
|
||||
//判断是否存在委托关系
|
||||
if (depute == null
|
||||
|| StringUtils.isEmpty(depute.getMandataryUserId())) {//不存在直接返回原始接受人
|
||||
return receiver;
|
||||
}
|
||||
if (userService.getUserById(depute.getMandataryUserId()) != null) {//委托人是否有效
|
||||
logger.info("执行委托代办逻辑, receiver={}, mandataryUserId={},curtActInstId={},curtActDefId={}, preActDefId={}", new Object[] {
|
||||
receiver,depute.getMandataryUserId(), delegateTask.getId(),delegateTask.getTaskDefinitionKey(),delegateTask.getPreTaskDefKey()});
|
||||
delegateTask.setOwner(receiver);//备份原始接受人
|
||||
return depute.getMandataryUserId();//返回委托人
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.logger.error("existDeputeReplaceReceiver error,processInputModel:"+processInputModel, e);
|
||||
}
|
||||
return receiver;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务上下文变量
|
||||
*
|
||||
* @param delegateTask
|
||||
*/
|
||||
private void setTaskVariables(TaskEntity delegateTask) {
|
||||
Map<String, Object> taskVariables = delegateTask.getVariables() != null ? delegateTask
|
||||
.getVariables() : delegateTask.getExecution().getVariables();
|
||||
for (Map.Entry<String, Object> variable : taskVariables.entrySet()) {
|
||||
if (StringUtils.isEmpty(variable.getKey())
|
||||
|| variable.getValue() == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(variable.getKey().equals(WorkFlowContants.WF_FIELDS_KEY)
|
||||
|| (variable.getKey()
|
||||
.equals(WorkFlowContants.WF_BUSINESS_DATA_OBJECT_KEY)) || (variable
|
||||
.getKey()
|
||||
.equals(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY)))) {
|
||||
continue;
|
||||
}
|
||||
delegateTask.setVariableLocal(variable.getKey(),
|
||||
variable.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void validateReceiver(String receiver) {
|
||||
if (StringUtils.isEmpty(receiver) || "null".equals(receiver)
|
||||
|| "undefined".equals(receiver)) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2062,"receiver的值为空或非法,receiver:" + receiver);
|
||||
}
|
||||
}
|
||||
|
||||
private int isMultiFlag(TaskEntity delegateTask, String receiver) {
|
||||
boolean isCallActivityMultiInstance = false;
|
||||
boolean isSubProcessMultiInstance = false;
|
||||
//当通过流程管理重新分配人员,再执行下一步,再进行退回上一步时人员出错的逻辑判断
|
||||
if(WorkFlowContants.ACTION_TYPE_CALLBACK_PREV_ACTIVITY.equals(delegateTask.getActionType())&&StringUtils.isNotEmpty(receiver)){
|
||||
return MULTI_INSTANCE_NOMAL;
|
||||
}
|
||||
ActivityImpl curActivity = delegateTask.getExecution()
|
||||
.getProcessDefinition()
|
||||
.findActivity(delegateTask.getTaskDefinitionKey());
|
||||
// 获取是否单环节多人处理标记
|
||||
String multiInstance = (String) curActivity
|
||||
.getProperty(WorkFlowContants.ELEMENT_MULTIINSTANCE);
|
||||
if (StringUtils.isNotEmpty(multiInstance)) {
|
||||
return MULTI_INSTANCE_USER_TASK;
|
||||
}
|
||||
|
||||
boolean isParallelGeteway = isGateway(delegateTask);
|
||||
// 调用外部子流程-多实例任务触发时,此时已是子流程的Execution,需要向上查找SuperExecution
|
||||
if (!isParallelGeteway
|
||||
&& delegateTask.getExecution().getSuperExecution() != null) {
|
||||
ExecutionEntity supperExecutionEntity = ((ExecutionEntity) delegateTask
|
||||
.getExecution().getSuperExecution());
|
||||
if (supperExecutionEntity != null) {
|
||||
isCallActivityMultiInstance = StringUtils
|
||||
.isNotEmpty((String) supperExecutionEntity
|
||||
.getActivity().getProperty(
|
||||
WorkFlowContants.ELEMENT_MULTIINSTANCE));
|
||||
}
|
||||
if (isCallActivityMultiInstance) {
|
||||
boolean isStartUserTask = ProcessDefinitionUtils
|
||||
.isStartUserTask(delegateTask);
|
||||
isCallActivityMultiInstance = isStartUserTask ? true : false;
|
||||
}
|
||||
} else if (delegateTask.getExecution().getParent() != null) {// 内部嵌套子流程多人处理
|
||||
ProcessModelService processModelService = (ProcessModelService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("processModelServiceImpl");
|
||||
ActivityImpl subActivity = delegateTask.getExecution().getParent()
|
||||
.getActivity();
|
||||
subActivity = subActivity == null ? delegateTask.getExecution()
|
||||
.getActivity().getParentActivity() : subActivity;
|
||||
if(subActivity!=null){
|
||||
boolean isSubProcess = BpmnXMLConstants.ELEMENT_SUBPROCESS
|
||||
.equals(subActivity.getProperty("type"));
|
||||
if (isSubProcess) {
|
||||
isSubProcessMultiInstance = StringUtils
|
||||
.isNotEmpty((String) subActivity
|
||||
.getProperty(WorkFlowContants.ELEMENT_MULTIINSTANCE))
|
||||
&& ProcessModelUtils.isSubProcessStartAct(
|
||||
processModelService
|
||||
.getBpmnModelByProcDefId(delegateTask
|
||||
.getProcessDefinitionId()),
|
||||
delegateTask.getTaskDefinitionKey()) != null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (isCallActivityMultiInstance) {
|
||||
return MULTI_INSTANCE_CALL_ACTIVITY;
|
||||
} else if (isSubProcessMultiInstance) {
|
||||
return MULTI_INSTANCE_USER_TASK;
|
||||
} else {
|
||||
return MULTI_INSTANCE_NOMAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isGateway(TaskEntity delegateTask) {
|
||||
boolean isParallelGeteway = false;
|
||||
if (StringUtils.isNotEmpty(delegateTask.getPreTaskDefKey())) {
|
||||
ActivityImpl activityImpl = delegateTask.getExecution()
|
||||
.getProcessDefinition()
|
||||
.findActivity(delegateTask.getPreTaskDefKey());
|
||||
if (activityImpl != null) {
|
||||
isParallelGeteway = BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(activityImpl.getProperty("type"))
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(activityImpl.getProperty("type"));
|
||||
}
|
||||
}
|
||||
return isParallelGeteway;
|
||||
}
|
||||
|
||||
private void setSubBusinessKey(ExecutionEntity executionEntity,
|
||||
ProcessInputModel processInputModel, String assignee) {
|
||||
try {
|
||||
List<ActivityReceiverModel> activityReceiverModels = processInputModel
|
||||
.getWf_receivers();
|
||||
if(activityReceiverModels==null||activityReceiverModels.isEmpty()){
|
||||
return;
|
||||
}
|
||||
UserService userService = (UserService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("userServiceImpl");
|
||||
User user=userService.getUserById(assignee);
|
||||
|
||||
for (ActivityReceiverModel act : activityReceiverModels) {
|
||||
if (StringUtils.isNotEmpty(act.getSubBusinessKey())
|
||||
&& act.getReceiveUserId()
|
||||
.equals(user.getUserCode())
|
||||
&& act.getReceiveUserOrgId()
|
||||
.equals(user.getOrgId())) {
|
||||
executionEntity.setBusinessKey(act.getSubBusinessKey());
|
||||
Context.getCommandContext().getHistoryManager().updateProcessBusinessKeyInHistory(executionEntity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.logger.error("为子流程设置subBusinessKey失败,executionEntity:"
|
||||
+ executionEntity + ",processInputModel:"
|
||||
+ processInputModel + ",assignee:" + assignee, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.blueland.bpm.engine.core.listener;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.config.model.ActivityInfoConfig;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessConfigService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
|
||||
/**
|
||||
* 全局的任务过期时间处理监听器
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class GlobalTaskDutDateListener implements TaskListener {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void notify(DelegateTask delegate) {
|
||||
if (!delegate.getEventName().equals(TaskListener.EVENTNAME_CREATE))
|
||||
return;
|
||||
TaskEntity delegateTask = (TaskEntity) delegate;
|
||||
logger.debug("触发了全局监听器, pid={}, tid={}, event={}", new Object[] {
|
||||
delegateTask.getProcessInstanceId(), delegateTask.getId(),
|
||||
delegateTask.getEventName() });
|
||||
|
||||
Date limitTime = null;
|
||||
try {
|
||||
ProcessInputModel processInputModel = ProcessDefinitionUtils
|
||||
.getWfprocessInputModel(delegateTask);
|
||||
int limit = processInputModel.getWf_actLimitTime();
|
||||
if(limit >0 ) {
|
||||
limitTime = DateUtils.addDays(new Date(), limit);
|
||||
delegateTask.setLimitTime(limit);
|
||||
}else {
|
||||
ProcessConfigService processConfigService = (ProcessConfigService) ApplicationContextHolder
|
||||
.getBean("processConfigServiceImpl");
|
||||
ActivityInfoConfig activityInfoConfig = processConfigService
|
||||
.getActivityInfoConfig(delegate.getProcessDefinitionId(),
|
||||
delegate.getTaskDefinitionKey());
|
||||
if (activityInfoConfig != null
|
||||
&& activityInfoConfig.getActivityLimitTime() != null
|
||||
&& activityInfoConfig.getActivityLimitTime() > 0) {
|
||||
delegateTask.setDueDate(DateUtils.addDays(new Date(),
|
||||
activityInfoConfig.getActivityLimitTime()));
|
||||
delegateTask.setLimitTime(activityInfoConfig.getActivityLimitTime());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2050,"setDueDate error,delegate:"
|
||||
+ delegate, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.blueland.bpm.engine.core.listener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.blueland.bpm.engine.core.handler.GlobalBizHandler;
|
||||
import com.blueland.bpm.engine.util.SmsUtil;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
import com.blueland.unitework.model.UniteworkTask;
|
||||
import com.blueland.unitework.service.MsgService;
|
||||
import com.blueland.unitework.service.UniteworkService;
|
||||
|
||||
public class GlobalTaskMsgMotice implements GlobalBizHandler{
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
UniteworkService uniteworkService = (UniteworkService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("uniteworkService");
|
||||
MsgService imService = (MsgService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("imService");
|
||||
UserService userService = (UserService) com.blueland.bpm.common.util.ApplicationContextHolder
|
||||
.getBean("userServiceImpl");
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Map<String,Object> processMap) {
|
||||
// TODO Auto-generated method stub
|
||||
exeTasks(processMap);
|
||||
exeHisTasks(processMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 待办通知
|
||||
* @param processMap
|
||||
*/
|
||||
private void exeTasks(Map<String,Object> processMap){
|
||||
List<UniteworkTask> tasks=(List<UniteworkTask>) processMap.get(GlobalTaskMsgMotice.TASKS_KEY);
|
||||
if(tasks==null||tasks.isEmpty()){
|
||||
return;
|
||||
}
|
||||
for (UniteworkTask task : tasks) {
|
||||
try{
|
||||
noticeTask(task);
|
||||
}catch(Exception e){
|
||||
logger.error(String.format("待办提醒消息发送失败,task[%s],processMap[%s]",task,processMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 已办通知
|
||||
* @param processMap
|
||||
*/
|
||||
private void exeHisTasks(Map<String,Object> processMap){
|
||||
List<UniteworkTask> hisTasks=(List<UniteworkTask>) processMap.get(GlobalTaskMsgMotice.HIS_TASKS_KEY);
|
||||
if(hisTasks==null||hisTasks.isEmpty()){
|
||||
return;
|
||||
}
|
||||
for (UniteworkTask hisTask : hisTasks) {
|
||||
try{
|
||||
noticeHisTask(hisTask);
|
||||
}catch(Exception e){
|
||||
logger.error(String.format("已办提醒消息发送失败,task[%s],processMap[%s]",hisTask,processMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void noticeTask(UniteworkTask task){
|
||||
String msgId = imService.sendTodoMsg(task);
|
||||
if(!StringUtils.isEmpty(msgId)){
|
||||
task.setMessageId(msgId);
|
||||
}
|
||||
uniteworkService.updateMsgId(task);
|
||||
try {
|
||||
User user=userService.getUserById(task.getRecUserId());
|
||||
String context="湖南中烟信息集成平台提醒您,您有一条待办消息.\\n消息标题:"+task.getTitle();
|
||||
String resultSms=SmsUtil.sendSms(context,user.getUserMobile(), task.getSendUserId(), "ebpm");
|
||||
logger.info("待办短信提醒结果:"+resultSms);
|
||||
}catch(Exception e) {
|
||||
logger.error("待办短信提醒出现异常,UniteworkTask:"+task,e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void noticeHisTask(UniteworkTask task) {
|
||||
imService.sendUptMsg(task, "已处理待办:"+ task.getTitle());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.blueland.bpm.engine.core.listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.blueland.bpm.common.util.SysConfig;
|
||||
import org.activiti.engine.delegate.DelegateExecution;
|
||||
import org.activiti.engine.delegate.Expression;
|
||||
import org.activiti.engine.delegate.JavaDelegate;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.config.model.DataObjectRelation;
|
||||
import com.blueland.bpm.engine.config.service.DataObjectRelationManager;
|
||||
import com.blueland.bpm.engine.core.model.ActivityReceiverModel;
|
||||
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
|
||||
import com.blueland.bpm.engine.core.model.BusinessDataObject;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessDefinitionService;
|
||||
import com.blueland.bpm.engine.core.service.ProcessExecuteService;
|
||||
import com.blueland.bpm.engine.core.service.ProcessExecuteServiceFacde;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
/**
|
||||
* 流程贯穿-服务任务引擎代理
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ThroughBizAppProcess implements JavaDelegate {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private Expression procDefIdText;
|
||||
public void execute(DelegateExecution execution) throws Exception {
|
||||
ProcessExecuteServiceFacde processExecuteService = (ProcessExecuteServiceFacde) ApplicationContextHolder
|
||||
.getBean("processExecuteServiceFacde");
|
||||
ProcessInputModel oldProcessInputModel = (ProcessInputModel) execution
|
||||
.getVariables().get(WorkFlowContants.WF_PROCESS_INPUT_VARIABLE_KEY);
|
||||
if(oldProcessInputModel.getWf_receivers()==null){
|
||||
List<ActivityReceiverModel> activityReceiverModels=getGroupFirstReceiver(oldProcessInputModel.getWf_procInstId(),oldProcessInputModel.getWf_procDefId(),oldProcessInputModel.getWf_curActInstId(),oldProcessInputModel.getWf_curActDefId(),oldProcessInputModel.getWf_nextActDefId(),oldProcessInputModel.getWf_sendUserId(),oldProcessInputModel.getFields());
|
||||
oldProcessInputModel.setWf_receivers(activityReceiverModels);
|
||||
}
|
||||
List<ActivityReceiverModel> receivers= oldProcessInputModel.getWf_receivers();
|
||||
for (ActivityReceiverModel receiver : receivers) {
|
||||
ProcessInputModel newProcessInputModel = buildNewProcessInputModel(
|
||||
oldProcessInputModel, execution);
|
||||
newProcessInputModel.setWf_sendUserId(receiver.getReceiveUserId());
|
||||
newProcessInputModel.setWf_sendUserOrgId(receiver.getReceiveUserOrgId());
|
||||
List<ActivityReceiverModel> tempReceivers=new ArrayList<ActivityReceiverModel>(1);
|
||||
tempReceivers.add(receiver);
|
||||
newProcessInputModel.setWf_receivers(tempReceivers);
|
||||
ProcessDefinitionUtils.convertWf_receivers(newProcessInputModel);
|
||||
//获取流程贯穿的业务数据对象
|
||||
BusinessDataObject businessDataObject = oldProcessInputModel
|
||||
.getWf_throughBizDataObject();
|
||||
if (businessDataObject == null
|
||||
|| businessDataObject.getBizData() == null) {
|
||||
businessDataObject = oldProcessInputModel.getWf_businessDataObject();
|
||||
}
|
||||
//将流程贯穿的业务数据对象赋予wf_businessDataObject
|
||||
newProcessInputModel.getWf_variables().put("wf_businessDataObject",businessDataObject);
|
||||
newProcessInputModel.setWf_businessDataObject(businessDataObject);
|
||||
|
||||
// 下面代码只是为了测试使用,上线后会删除掉
|
||||
try {
|
||||
Map newProcessVar = newProcessInputModel.getWf_variables();
|
||||
Map fields = oldProcessInputModel.getFields();
|
||||
DataObjectRelationManager dataObjectRelationManager = (DataObjectRelationManager) ApplicationContextHolder
|
||||
.getBean("dataObjectRelationManager");
|
||||
List<DataObjectRelation> dataObjectRelations = dataObjectRelationManager
|
||||
.findDataObjectRelationsByThroughProc(
|
||||
execution.getProcessDefinitionId(),
|
||||
execution.getCurrentActivityId());
|
||||
for (DataObjectRelation dataObjectRelation : dataObjectRelations) {
|
||||
Object sourceProcessVar = oldProcessInputModel.getFields().get(
|
||||
dataObjectRelation.getDataObject().getObjKey());
|
||||
newProcessVar.put(dataObjectRelation.getDataObject()
|
||||
.getObjValue(), sourceProcessVar);
|
||||
fields.put(dataObjectRelation.getDataObject().getObjValue(),
|
||||
sourceProcessVar);
|
||||
}
|
||||
//业务流程贯穿标记
|
||||
newProcessVar.put(WorkFlowContants.IS_THROUGH_BIZ_PROCESS_KEY, WorkFlowContants.IS_THROUGH_BIZ_PROCESS_YES);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
processExecuteService.nextExecute(newProcessInputModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ProcessInputModel buildNewProcessInputModel(ProcessInputModel oldProcessInputModel,DelegateExecution execution) {
|
||||
if (oldProcessInputModel == null) {
|
||||
oldProcessInputModel = new ProcessInputModel();
|
||||
oldProcessInputModel.setWf_sender("SYS");
|
||||
}
|
||||
ProcessInputModel newProcessInputModel = new ProcessInputModel();
|
||||
if(procDefIdText==null){
|
||||
String errorMsg="业务流程贯穿服务-贯穿流程ID为null,ProcessInputModel:"+oldProcessInputModel;
|
||||
this.logger.error(errorMsg);
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2006,errorMsg);
|
||||
}
|
||||
newProcessInputModel.setWf_procDefId(procDefIdText.getValue(execution)
|
||||
.toString());
|
||||
newProcessInputModel
|
||||
.setWf_actionType(WorkFlowContants.ACTION_TYPE_THROUGH_PROCESS);
|
||||
newProcessInputModel.setWf_businessKey(java.util.UUID.randomUUID()
|
||||
.toString());
|
||||
//绑定流程父子关系
|
||||
newProcessInputModel.setWf_appId(oldProcessInputModel.getWf_appId());
|
||||
newProcessInputModel.setWf_uniteworkUrl(oldProcessInputModel.getWf_uniteworkUrl());
|
||||
newProcessInputModel.setWf_parentProcInstId(execution.getProcessInstanceId());
|
||||
newProcessInputModel.setWf_procTitle(oldProcessInputModel.getWf_procTitle());
|
||||
newProcessInputModel.setWf_curActDefId(oldProcessInputModel.getWf_curActDefId());
|
||||
newProcessInputModel.setWf_curActDefName(oldProcessInputModel.getWf_curActDefName());
|
||||
newProcessInputModel.setWf_curActDefType(oldProcessInputModel.getWf_curActDefType());
|
||||
return newProcessInputModel;
|
||||
}
|
||||
/**
|
||||
* 获取环节绑定资源的第一个资源值
|
||||
* @param procInstId
|
||||
* @param proceDefId
|
||||
* @param curtTaskId
|
||||
* @param curtActDefId
|
||||
* @param nextActDefId
|
||||
* @param userId
|
||||
* @param conditionMap
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityReceiverModel> getGroupFirstReceiver(String procInstId,String proceDefId,String curtTaskId,String curtActDefId,String nextActDefId,String userId,Map conditionMap){
|
||||
List<ActivityReceiverModel> activityReceiverModels=new ArrayList<ActivityReceiverModel>();
|
||||
ProcessDefinitionService processDefinitionService=null;
|
||||
try{
|
||||
processDefinitionService=(ProcessDefinitionService) ApplicationContextHolder.getBean("processDefinitionServiceImpl");
|
||||
}catch(Exception e){
|
||||
try {
|
||||
Thread.sleep(9000);
|
||||
} catch (InterruptedException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
processDefinitionService=(ProcessDefinitionService) ApplicationContextHolder.getBean("processDefinitionServiceImpl");
|
||||
}
|
||||
UserService userService=(UserService) com.blueland.bpm.common.util.ApplicationContextHolder.getBean("userServiceImpl");
|
||||
com.blueland.bpm.identity.model.User user=userService.getUserById(userId);
|
||||
List<ActivityResourceModel> users=null;
|
||||
if(StringUtils.isEmpty(curtActDefId)){
|
||||
users=processDefinitionService.getResource(proceDefId, nextActDefId);
|
||||
}else{
|
||||
users = processDefinitionService
|
||||
.getActivityUserTree(procInstId,proceDefId,curtTaskId,curtActDefId,nextActDefId,user.getUserCode(),user.getOrgId(),null,conditionMap);
|
||||
}
|
||||
for (ActivityResourceModel treeNode : users) {
|
||||
if("USER".equals(treeNode.getType())){
|
||||
ActivityReceiverModel activityReceiverModel=new ActivityReceiverModel();
|
||||
activityReceiverModel.setReceiveUserId(treeNode.getId());
|
||||
activityReceiverModel.setReceiveUserOrgId(treeNode.getParentId());
|
||||
activityReceiverModels.add(activityReceiverModel);
|
||||
|
||||
}
|
||||
}
|
||||
return activityReceiverModels;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.pvm.PvmActivity;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.impl.pvm.process.TransitionImpl;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.blueland.bpm.engine.config.model.ActivityInfoConfig;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 流程环节定义模型
|
||||
* @author lw
|
||||
*
|
||||
*/
|
||||
public class ActivityDefinitionModel implements
|
||||
Serializable {
|
||||
static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 流程定义ID
|
||||
*/
|
||||
String procDefId;
|
||||
/**
|
||||
* 流程定义名称
|
||||
*/
|
||||
String procDefName;
|
||||
/**
|
||||
* 环节定义ID
|
||||
*/
|
||||
String actDefId;
|
||||
/**
|
||||
* 环节定义名称
|
||||
*/
|
||||
String actDefName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
String description;
|
||||
/**
|
||||
* 优先级
|
||||
*/
|
||||
int priority;
|
||||
/**
|
||||
* 环节类型
|
||||
*/
|
||||
String actType;
|
||||
/**
|
||||
* 是否多人处理
|
||||
*/
|
||||
boolean isMulti;
|
||||
/**
|
||||
* 是否同步模型--待定
|
||||
*/
|
||||
boolean isAsync;
|
||||
/**
|
||||
* 客户端是否可以不传递人员来执行流程
|
||||
*/
|
||||
boolean isNotSelectReceiver;
|
||||
/**
|
||||
* 环节配置对象
|
||||
*/
|
||||
private ActivityInfoConfig activityInfoConfig;
|
||||
|
||||
private List<ActivityResourceModel> activityResources;
|
||||
/**
|
||||
* 环节定义变量--待定
|
||||
*/
|
||||
protected Map<String, Object> variables;
|
||||
|
||||
|
||||
public static ActivityDefinitionModel build(PvmActivity pvmActivity) {
|
||||
ActivityDefinitionModel activityDefinition=new ActivityDefinitionModel();
|
||||
if (pvmActivity == null){
|
||||
/**
|
||||
* 当流程管理中删除流程定义时,如果该流程的环节ID有变更,那么pvmActivity对象可能为Null
|
||||
* 为了不影响删除逻辑此处不抛出异常(通过前端在ProcessMgrDataShare中设置PROCESS_DEF_DEL_MANAGE_OPT标识来判断)
|
||||
* ProcessMgrDataShare.setProcessMgrData(PROCESS_DEF_DEL_MANAGE_OPT)在ProcessDefinitionController.delete()方法中
|
||||
*/
|
||||
Object obj=ProcessMgrDataShare.getProcessMgrData();
|
||||
if(obj!=null&&WorkFlowContants.PROCESS_DEF_DEL_MANAGE_OPT.equals(obj)){
|
||||
return null;
|
||||
}
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2003,"activity is not found");
|
||||
}
|
||||
ActivityImpl activityImpl = (ActivityImpl) pvmActivity;
|
||||
activityDefinition.actDefId = activityImpl.getId();
|
||||
String actDefName = (String) activityImpl.getProperty("name");
|
||||
if (StringUtils.isEmpty(actDefName)) {
|
||||
actDefName = "结束";
|
||||
}
|
||||
activityDefinition.actDefName=actDefName;
|
||||
String destActivityType = (String) activityImpl
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
|
||||
if (ProcessDefinitionUtils.isMultiInstance(activityImpl)) {// 是否多实例类型
|
||||
destActivityType = ProcessDefinitionUtils.WF_ACTIVITY_TYPE_MULTI_INSTANCE;
|
||||
}
|
||||
activityDefinition.isMulti = ProcessDefinitionUtils.isMultiInstance(activityImpl);
|
||||
activityDefinition.isNotSelectReceiver=ProcessDefinitionUtils.isNotSelectReceiver(activityImpl);
|
||||
activityDefinition.isAsync=pvmActivity.isAsync();
|
||||
activityDefinition.actType = destActivityType;
|
||||
activityDefinition.procDefId= activityImpl.getProcessDefinition().getId();
|
||||
activityDefinition.procDefName = activityImpl.getProcessDefinition().getName();
|
||||
//super.build((ProcessDefinition) activityImpl.getProcessDefinition());
|
||||
return activityDefinition;
|
||||
}
|
||||
|
||||
|
||||
public static ActivityDefinitionModel build(PvmActivity pvmActivity,
|
||||
TransitionImpl transitionImpl) {
|
||||
ActivityDefinitionModel activityDefinition=new ActivityDefinitionModel();
|
||||
if (pvmActivity == null)
|
||||
return activityDefinition;
|
||||
ActivityImpl activityImpl = (ActivityImpl) pvmActivity;
|
||||
activityDefinition.actDefId = activityImpl.getId();
|
||||
// 环节名称:当转移线上的名称不为空时,使用它作为环节名称,否则使用任务定义名称
|
||||
String activityName = (String) activityImpl.getProperty("name");
|
||||
String transitionName = (String) transitionImpl.getProperty("name");
|
||||
String name = StringUtils.isNotEmpty(transitionName) ? transitionName
|
||||
: (StringUtils.isNotEmpty(activityName) ? activityName : "送结束");
|
||||
activityDefinition.actDefName = name;
|
||||
activityDefinition.actType =(String) activityImpl
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
activityDefinition.isAsync=pvmActivity.isAsync();
|
||||
activityDefinition.isMulti = ProcessDefinitionUtils.isMultiInstance(activityImpl);;
|
||||
activityDefinition.isNotSelectReceiver=ProcessDefinitionUtils.isNotSelectReceiver(activityImpl);
|
||||
//super.build((ProcessDefinition) activityImpl.getProcessDefinition());
|
||||
return activityDefinition;
|
||||
}
|
||||
|
||||
|
||||
public static ActivityDefinitionModel build(Task tempTask) {
|
||||
ActivityDefinitionModel activityDefinition=new ActivityDefinitionModel();
|
||||
TaskEntity task=null;
|
||||
if (tempTask == null)
|
||||
return activityDefinition;
|
||||
task=(TaskEntity) tempTask;
|
||||
activityDefinition.actDefId=task.getTaskDefinitionKey();
|
||||
String actDefName=task.getName();
|
||||
if (StringUtils.isEmpty(actDefName)) {
|
||||
actDefName = "结束";
|
||||
}
|
||||
activityDefinition.actDefName=actDefName;
|
||||
/* String destActivityType = (String) task.get
|
||||
.getProperty(WorkFlowContants.WF_ACTIVITY_TYPE_KEY);
|
||||
|
||||
if (ProcessDefinitionUtils.isMultiInstance(activityImpl)) {// 是否多实例类型
|
||||
destActivityType = WorkFlowContants.WF_ACTIVITY_TYPE_MULTI_INSTANCE;
|
||||
}
|
||||
this.isMulti = ProcessDefinitionUtils.isMultiInstance(activityImpl);
|
||||
this.isAsync=pvmActivity.isAsync();
|
||||
this.activityType = destActivityType;*/
|
||||
activityDefinition.procDefName=task.getProcessDefinitionName();
|
||||
activityDefinition.procDefId=task.getProcessDefinitionId();
|
||||
return activityDefinition;
|
||||
}
|
||||
|
||||
public ActivityDefinitionModel build(HistoricTaskInstance tempTask) {
|
||||
ActivityDefinitionModel activityDefinition=new ActivityDefinitionModel();
|
||||
HistoricTaskInstance task=null;
|
||||
if (tempTask == null)
|
||||
return activityDefinition;
|
||||
task=(HistoricTaskInstance) tempTask;
|
||||
activityDefinition.actDefId=task.getTaskDefinitionKey();
|
||||
String actDefName=task.getName();
|
||||
if (StringUtils.isEmpty(actDefName)) {
|
||||
actDefName = "结束";
|
||||
}
|
||||
activityDefinition.actDefName=actDefName;
|
||||
/* String destActivityType = (String) task.get
|
||||
.getProperty(WorkFlowContants.WF_ACTIVITY_TYPE_KEY);
|
||||
|
||||
if (ProcessDefinitionUtils.isMultiInstance(activityImpl)) {// 是否多实例类型
|
||||
destActivityType = WorkFlowContants.WF_ACTIVITY_TYPE_MULTI_INSTANCE;
|
||||
}
|
||||
this.isMulti = ProcessDefinitionUtils.isMultiInstance(activityImpl);
|
||||
this.isAsync=pvmActivity.isAsync();
|
||||
this.activityType = destActivityType;*/
|
||||
activityDefinition.procDefId=task.getProcessDefinitionId();
|
||||
activityDefinition.procDefName=task.getProcessDefinitionName();
|
||||
return activityDefinition;
|
||||
}
|
||||
|
||||
|
||||
public String getProcDefId() {
|
||||
return procDefId;
|
||||
}
|
||||
|
||||
|
||||
public void setProcDefId(String procDefId) {
|
||||
this.procDefId = procDefId;
|
||||
}
|
||||
|
||||
|
||||
public String getProcDefName() {
|
||||
return procDefName;
|
||||
}
|
||||
|
||||
|
||||
public void setProcDefName(String procDefName) {
|
||||
this.procDefName = procDefName;
|
||||
}
|
||||
|
||||
|
||||
public String getActDefId() {
|
||||
return actDefId;
|
||||
}
|
||||
|
||||
|
||||
public void setActDefId(String actDefId) {
|
||||
this.actDefId = actDefId;
|
||||
}
|
||||
|
||||
|
||||
public String getActDefName() {
|
||||
return actDefName;
|
||||
}
|
||||
|
||||
|
||||
public void setActDefName(String actDefName) {
|
||||
this.actDefName = actDefName;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
|
||||
public String getActType() {
|
||||
return actType;
|
||||
}
|
||||
|
||||
|
||||
public void setActType(String actType) {
|
||||
this.actType = actType;
|
||||
}
|
||||
|
||||
|
||||
public boolean isMulti() {
|
||||
return isMulti;
|
||||
}
|
||||
|
||||
|
||||
public void setMulti(boolean isMulti) {
|
||||
this.isMulti = isMulti;
|
||||
}
|
||||
|
||||
|
||||
public boolean isAsync() {
|
||||
return isAsync;
|
||||
}
|
||||
|
||||
|
||||
public void setAsync(boolean isAsync) {
|
||||
this.isAsync = isAsync;
|
||||
}
|
||||
|
||||
|
||||
public ActivityInfoConfig getActivityInfoConfig() {
|
||||
return activityInfoConfig;
|
||||
}
|
||||
|
||||
|
||||
public void setActivityInfoConfig(ActivityInfoConfig activityInfoConfig) {
|
||||
this.activityInfoConfig = activityInfoConfig;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
return variables;
|
||||
}
|
||||
|
||||
|
||||
public void setVariables(Map<String, Object> variables) {
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
|
||||
public boolean isNotSelectReceiver() {
|
||||
return isNotSelectReceiver;
|
||||
}
|
||||
|
||||
|
||||
public void setNotSelectReceiver(boolean isNotSelectReceiver) {
|
||||
this.isNotSelectReceiver = isNotSelectReceiver;
|
||||
}
|
||||
|
||||
|
||||
public List<ActivityResourceModel> getActivityResources() {
|
||||
return activityResources;
|
||||
}
|
||||
|
||||
|
||||
public void setActivityResources(List<ActivityResourceModel> activityResources) {
|
||||
this.activityResources = activityResources;
|
||||
}
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 环节实例对象
|
||||
* @author lw
|
||||
*
|
||||
*/
|
||||
public class ActivityInstanceModel implements Serializable {
|
||||
|
||||
static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 流程定义ID
|
||||
*/
|
||||
String procDefId;
|
||||
/**
|
||||
* 流程定义名称
|
||||
*/
|
||||
String procDefName;
|
||||
/**
|
||||
* 父流程实例ID
|
||||
*/
|
||||
String parentProcInstId;
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
String procInstId;
|
||||
/**
|
||||
* 流程名称
|
||||
*/
|
||||
String procTitle;
|
||||
/**
|
||||
* 执行ID
|
||||
*/
|
||||
String executionId;
|
||||
/**
|
||||
* 环节定义ID
|
||||
*/
|
||||
String actDefName;
|
||||
|
||||
/**
|
||||
* 环节定义名称
|
||||
*/
|
||||
String actDefId;
|
||||
/**
|
||||
* 环节实例ID-任务节点对应任务ID
|
||||
*/
|
||||
String actInstId;
|
||||
/**
|
||||
* 父环节实例ID
|
||||
*/
|
||||
String parentActInstId;
|
||||
/**
|
||||
* 上一步环节实例ID
|
||||
*/
|
||||
String prevActInstId;
|
||||
/**
|
||||
* 上一步环节定义ID
|
||||
*/
|
||||
String prevActDefId;
|
||||
/**
|
||||
* 上一步环节定义名称
|
||||
*/
|
||||
String prevActDefName;
|
||||
/**
|
||||
* 当前环节发送人帐号
|
||||
*/
|
||||
String sender;
|
||||
/**
|
||||
* 发送人ID
|
||||
*/
|
||||
String sendUserId;
|
||||
/**
|
||||
* 当前环节发送人姓名
|
||||
*/
|
||||
String sendUserName;
|
||||
|
||||
/**
|
||||
* 当前环节发送人组织机构ID
|
||||
*/
|
||||
String senderOrgId;
|
||||
|
||||
/**
|
||||
* 当前环节发送人组织机构名称
|
||||
*/
|
||||
String senderOrgName;
|
||||
/**
|
||||
* 当前环节的接收人,待办任务可能没有数据
|
||||
*/
|
||||
String receiver;
|
||||
/**
|
||||
* 环节所有者
|
||||
*/
|
||||
String owner;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
String actState;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
Date createTime;
|
||||
/**
|
||||
* 完成时间
|
||||
*/
|
||||
Date finishTime;
|
||||
/**
|
||||
* 持续时间-耗时
|
||||
*/
|
||||
Date dueDate;
|
||||
/**
|
||||
* 环节实例变量--待定
|
||||
*/
|
||||
Map localVariables = new HashMap();
|
||||
/**
|
||||
* 租户ID--待定
|
||||
*/
|
||||
String tenantId;
|
||||
|
||||
/**
|
||||
* 接收人信息,receiver为接收人帐号
|
||||
*/
|
||||
String receiverUserId;
|
||||
String receiverUserName;
|
||||
String receiverOrgId;
|
||||
String receiverOrgName;
|
||||
|
||||
|
||||
private ActivityDefinitionModel activityDefinition;
|
||||
|
||||
public static ActivityInstanceModel buildAndActDef(HistoricTaskInstance task,ActivityDefinitionModel activityDefinitionModel){
|
||||
ActivityInstanceModel activityInstance=new ActivityInstanceModel();
|
||||
if(task==null)
|
||||
return activityInstance;
|
||||
activityInstance.procDefId=task.getProcessDefinitionId();
|
||||
activityInstance.procDefName=task.getProcessDefinitionName();
|
||||
activityInstance.procTitle=task.getProcTitle();
|
||||
activityInstance.procInstId=task.getProcessInstanceId();
|
||||
activityInstance.actInstId=task.getId();
|
||||
activityInstance.owner=task.getOwner();
|
||||
activityInstance.receiver=task.getAssignee();
|
||||
activityInstance.receiverUserId=task.getAssigneeUserId();
|
||||
activityInstance.receiverOrgId=task.getAssigneeOrgId();
|
||||
activityInstance.receiverOrgName=task.getAssigneeOrgName();
|
||||
activityInstance.receiverUserName=task.getAssigneeUserName();
|
||||
activityInstance.sender=task.getSender();
|
||||
activityInstance.sendUserName=task.getSendUserName();
|
||||
activityInstance.sendUserId=task.getSendUserId();
|
||||
activityInstance.senderOrgId=task.getSenderOrgId();
|
||||
activityInstance.senderOrgName=task.getSenderOrgName();
|
||||
activityInstance.procDefName=task.getProcessDefinitionName();
|
||||
activityInstance.createTime=task.getStartTime();
|
||||
activityInstance.finishTime=task.getEndTime();
|
||||
activityInstance.executionId=task.getExecutionId();
|
||||
activityInstance.prevActInstId=task.getPreTaskId();
|
||||
activityInstance.prevActDefId=task.getPreTaskDefKey();
|
||||
activityInstance.prevActDefName=task.getPreTaskDefName();
|
||||
activityInstance.actState="1";
|
||||
activityInstance.dueDate=task.getDueDate();
|
||||
activityInstance.tenantId=task.getTenantId();
|
||||
activityInstance.localVariables=task.getTaskLocalVariables();
|
||||
activityInstance.actDefId=task.getTaskDefinitionKey();
|
||||
activityInstance.actDefName=task.getName();
|
||||
activityInstance.activityDefinition=activityDefinitionModel;
|
||||
return activityInstance;
|
||||
}
|
||||
/**
|
||||
* 构建环节实例
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
public static ActivityInstanceModel buildAndActDef(TaskEntity task,ActivityDefinitionModel activityDefinitionModel){
|
||||
ActivityInstanceModel activityInstance=new ActivityInstanceModel();
|
||||
if(task==null)
|
||||
return activityInstance;
|
||||
activityInstance.procDefId=task.getProcessDefinitionId();
|
||||
activityInstance.procDefName=task.getProcessDefinitionName();
|
||||
activityInstance.procTitle=task.getProcTitle();
|
||||
activityInstance.procInstId=task.getProcessInstanceId();
|
||||
activityInstance.actInstId=task.getId();
|
||||
activityInstance.owner=task.getOwner();
|
||||
activityInstance.receiver=task.getAssignee();
|
||||
activityInstance.receiverUserId=task.getAssigneeUserId();
|
||||
activityInstance.receiverOrgId=task.getAssigneeOrgId();
|
||||
activityInstance.receiverOrgName=task.getAssigneeOrgName();
|
||||
activityInstance.receiverUserName=task.getAssigneeUserName();
|
||||
activityInstance.sender=task.getSender();
|
||||
activityInstance.sendUserId=task.getSendUserId();
|
||||
activityInstance.sendUserName=task.getSendUserName();
|
||||
activityInstance.senderOrgId=task.getSenderOrgId();
|
||||
activityInstance.senderOrgName=task.getSenderOrgName();
|
||||
activityInstance.procDefName=task.getProcessDefinitionName();
|
||||
activityInstance.createTime=task.getCreateTime();
|
||||
activityInstance.executionId=task.getExecutionId();
|
||||
activityInstance.prevActInstId=task.getPreTaskId();
|
||||
activityInstance.prevActDefId=task.getPreTaskDefKey();
|
||||
activityInstance.prevActDefName=task.getPreTaskDefName();
|
||||
activityInstance.actState="0";
|
||||
activityInstance.tenantId=task.getTenantId();
|
||||
activityInstance.localVariables=task.getTaskLocalVariables();
|
||||
activityInstance.dueDate=task.getDueDate();
|
||||
activityInstance.actDefId=task.getTaskDefinitionKey();
|
||||
activityInstance.actDefName=task.getName();
|
||||
activityInstance.activityDefinition=activityDefinitionModel;
|
||||
return activityInstance;
|
||||
}
|
||||
|
||||
|
||||
public String getProcInstId() {
|
||||
return procInstId;
|
||||
}
|
||||
public void setProcInstId(String procInstId) {
|
||||
this.procInstId = procInstId;
|
||||
}
|
||||
public String getProcTitle() {
|
||||
return procTitle;
|
||||
}
|
||||
public void setProcTitle(String procTitle) {
|
||||
this.procTitle = procTitle;
|
||||
}
|
||||
public String getExecutionId() {
|
||||
return executionId;
|
||||
}
|
||||
public void setExecutionId(String executionId) {
|
||||
this.executionId = executionId;
|
||||
}
|
||||
public String getActInstId() {
|
||||
return actInstId;
|
||||
}
|
||||
public void setActInstId(String actInstId) {
|
||||
this.actInstId = actInstId;
|
||||
}
|
||||
public String getParentActInstId() {
|
||||
return parentActInstId;
|
||||
}
|
||||
public void setParentActInstId(String parentActInstId) {
|
||||
this.parentActInstId = parentActInstId;
|
||||
}
|
||||
public String getPrevActInstId() {
|
||||
return prevActInstId;
|
||||
}
|
||||
public void setPrevActInstId(String prevActInstId) {
|
||||
this.prevActInstId = prevActInstId;
|
||||
}
|
||||
public String getPrevActDefId() {
|
||||
return prevActDefId;
|
||||
}
|
||||
public void setPrevActDefId(String prevActDefId) {
|
||||
this.prevActDefId = prevActDefId;
|
||||
}
|
||||
public String getPrevActDefName() {
|
||||
return prevActDefName;
|
||||
}
|
||||
public void setPrevActDefName(String prevActDefName) {
|
||||
this.prevActDefName = prevActDefName;
|
||||
}
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
public String getSendUserName() {
|
||||
return sendUserName;
|
||||
}
|
||||
public void setSendUserName(String sendUserName) {
|
||||
this.sendUserName = sendUserName;
|
||||
}
|
||||
public String getReceiver() {
|
||||
return receiver;
|
||||
}
|
||||
public void setReceiver(String receiver) {
|
||||
this.receiver = receiver;
|
||||
}
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
public String getActState() {
|
||||
return actState;
|
||||
}
|
||||
public void setActState(String actState) {
|
||||
this.actState = actState;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Date getFinishTime() {
|
||||
return finishTime;
|
||||
}
|
||||
public void setFinishTime(Date finishTime) {
|
||||
this.finishTime = finishTime;
|
||||
}
|
||||
public Date getDueDate() {
|
||||
return dueDate;
|
||||
}
|
||||
public void setDueDate(Date dueDate) {
|
||||
this.dueDate = dueDate;
|
||||
}
|
||||
public Map getLocalVariables() {
|
||||
return localVariables;
|
||||
}
|
||||
public void setLocalVariables(Map localVariables) {
|
||||
this.localVariables = localVariables;
|
||||
}
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
public ActivityDefinitionModel getActivityDefinition() {
|
||||
return activityDefinition;
|
||||
}
|
||||
public void setActivityDefinition(ActivityDefinitionModel activityDefinition) {
|
||||
this.activityDefinition = activityDefinition;
|
||||
}
|
||||
public String getProcDefId() {
|
||||
return procDefId;
|
||||
}
|
||||
public void setProcDefId(String procDefId) {
|
||||
this.procDefId = procDefId;
|
||||
}
|
||||
public String getProcDefName() {
|
||||
return procDefName;
|
||||
}
|
||||
public void setProcDefName(String procDefName) {
|
||||
this.procDefName = procDefName;
|
||||
}
|
||||
public String getActDefName() {
|
||||
return actDefName;
|
||||
}
|
||||
public void setActDefName(String actDefName) {
|
||||
this.actDefName = actDefName;
|
||||
}
|
||||
public String getActDefId() {
|
||||
return actDefId;
|
||||
}
|
||||
public void setActDefId(String actDefId) {
|
||||
this.actDefId = actDefId;
|
||||
}
|
||||
public String getSenderOrgId() {
|
||||
return senderOrgId;
|
||||
}
|
||||
public void setSenderOrgId(String senderOrgId) {
|
||||
this.senderOrgId = senderOrgId;
|
||||
}
|
||||
public String getSenderOrgName() {
|
||||
return senderOrgName;
|
||||
}
|
||||
public void setSenderOrgName(String senderOrgName) {
|
||||
this.senderOrgName = senderOrgName;
|
||||
}
|
||||
|
||||
public void setSendUserId(String sendUserId) {
|
||||
this.sendUserId = sendUserId;
|
||||
}
|
||||
public String getSendUserId() {
|
||||
return this.sendUserId;
|
||||
}
|
||||
public void setReceiverUserId(String receiverUserName) {
|
||||
this.receiverUserId = receiverUserName;
|
||||
}
|
||||
public String getReceiverUserId() {
|
||||
return this.receiverUserId;
|
||||
}
|
||||
public void setReceiverUserName(String receiverUserName) {
|
||||
this.receiverUserName = receiverUserName;
|
||||
}
|
||||
public String getReceiverUserName() {
|
||||
return this.receiverUserName;
|
||||
}
|
||||
public void setReceiverOrgId(String receiverUserName) {
|
||||
this.receiverOrgId = receiverUserName;
|
||||
}
|
||||
public String getReceiverOrgId() {
|
||||
return this.receiverOrgId;
|
||||
}
|
||||
public void setReceiverOrgName(String receiverOrgName) {
|
||||
this.receiverOrgName = receiverOrgName;
|
||||
}
|
||||
public String getReceiverOrgName() {
|
||||
return this.receiverOrgName;
|
||||
}
|
||||
public String getParentProcInstId() {
|
||||
return parentProcInstId;
|
||||
}
|
||||
public void setParentProcInstId(String parentProcInstId) {
|
||||
this.parentProcInstId = parentProcInstId;
|
||||
}
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* 下一步接受人对象
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ActivityReceiverModel implements java.io.Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String receiveUserId;
|
||||
private String receiveUserName;
|
||||
private String receiveUserOrgId;
|
||||
private String receiveUserOrgName;
|
||||
private String subBusinessKey;
|
||||
private Map<String,Object> extendAttribute=new HashMap<String,Object>();
|
||||
|
||||
public String getReceiveUserId() {
|
||||
return receiveUserId;
|
||||
}
|
||||
public void setReceiveUserId(String receiveUserId) {
|
||||
this.receiveUserId = receiveUserId;
|
||||
}
|
||||
public String getReceiveUserName() {
|
||||
return receiveUserName;
|
||||
}
|
||||
public void setReceiveUserName(String receiveUserName) {
|
||||
this.receiveUserName = receiveUserName;
|
||||
}
|
||||
public String getReceiveUserOrgId() {
|
||||
return receiveUserOrgId;
|
||||
}
|
||||
public void setReceiveUserOrgId(String receiveUserOrgId) {
|
||||
this.receiveUserOrgId = receiveUserOrgId;
|
||||
}
|
||||
public String getReceiveUserOrgName() {
|
||||
return receiveUserOrgName;
|
||||
}
|
||||
public void setReceiveUserOrgName(String receiveUserOrgName) {
|
||||
this.receiveUserOrgName = receiveUserOrgName;
|
||||
}
|
||||
public Map<String, Object> getExtendAttribute() {
|
||||
return extendAttribute;
|
||||
}
|
||||
public void setExtendAttribute(Map<String, Object> extendAttribute) {
|
||||
this.extendAttribute = extendAttribute;
|
||||
}
|
||||
|
||||
public String getSubBusinessKey() {
|
||||
return subBusinessKey;
|
||||
}
|
||||
public void setSubBusinessKey(String subBusinessKey) {
|
||||
this.subBusinessKey = subBusinessKey;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + receiveUserId
|
||||
+ "," + receiveUserOrgId + ")";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* 下一环节资源对象
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ActivityResourceModel implements java.io.Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 唯一标识
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 父唯一标识
|
||||
*/
|
||||
private String parentId;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 类型,ORG:组织,USER:人员
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 级别
|
||||
*/
|
||||
private Integer level;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
// @JsonIgnore
|
||||
private String realId;
|
||||
|
||||
public ActivityResourceModel(String realId,String id, String pId, String name, Integer level, String type,Integer sort) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.parentId = pId;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.level = level;
|
||||
this.sort = sort;
|
||||
this.realId=realId;
|
||||
|
||||
}
|
||||
|
||||
public ActivityResourceModel(String id, String pId, String name, Integer level, String type,Integer sort) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.parentId = pId;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.level = level;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result
|
||||
+ ((parentId == null) ? 0 : parentId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getRealId() {
|
||||
return realId!=null?realId:id;
|
||||
}
|
||||
|
||||
public void setRealId(String realId) {
|
||||
this.realId = realId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ActivityResourceModel other = (ActivityResourceModel) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (parentId == null) {
|
||||
if (other.parentId != null)
|
||||
return false;
|
||||
} else if (!parentId.equals(other.parentId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
/**
|
||||
* 业务数据对象
|
||||
* @author lw
|
||||
*
|
||||
*/
|
||||
public class BusinessDataObject implements java.io.Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 业务类型,如合同,方便根据对象查询分析
|
||||
*/
|
||||
private String objectType;
|
||||
/**
|
||||
* 序列化之后的业务对象
|
||||
*/
|
||||
private String bizData;
|
||||
public String getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
public void setObjectType(String objectType) {
|
||||
this.objectType = objectType;
|
||||
}
|
||||
public String getBizData() {
|
||||
return bizData;
|
||||
}
|
||||
public void setBizData(String bizData) {
|
||||
this.bizData = bizData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.blueland.bpm.common.base.BaseEntity;
|
||||
import com.blueland.bpm.engine.config.model.ProcessInfoConfig;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 流程定义模型
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessDefinitionModel extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 流程定义ID-随机生成
|
||||
*/
|
||||
String procDefId;
|
||||
/**
|
||||
* 流程定义KEY(建模模型填写的KEY)
|
||||
*/
|
||||
String procDefKey;
|
||||
/**
|
||||
* 流程名称
|
||||
*/
|
||||
String procDefName;
|
||||
/**
|
||||
* 流程分组ID--待定
|
||||
*/
|
||||
String category;
|
||||
/**
|
||||
* 流程描述--待定
|
||||
*/
|
||||
String description;
|
||||
/**
|
||||
* 流程版本
|
||||
*/
|
||||
int version;
|
||||
/**
|
||||
* 流程资源名称--待定
|
||||
*//*
|
||||
String resourceName;
|
||||
*//**
|
||||
* 流程图形资源名称--待定
|
||||
*//*
|
||||
String diagramResourceName;
|
||||
*//**
|
||||
* 是否被挂起
|
||||
*//*
|
||||
boolean isSuspended;*/
|
||||
|
||||
/**
|
||||
* 流程定义创建时间
|
||||
*/
|
||||
Date pdCreateTime;
|
||||
/**
|
||||
* 流程部署ID
|
||||
*/
|
||||
String deploymentId;
|
||||
/**
|
||||
* 部署名称
|
||||
*//*
|
||||
String deploymentName;
|
||||
*//**
|
||||
* 部署分类--待定
|
||||
*//*
|
||||
String deploymentCategory;*/
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
String tenantId;
|
||||
/**
|
||||
* 流程配置对象
|
||||
*/
|
||||
private ProcessInfoConfig processInfoConfig;
|
||||
|
||||
public ProcessDefinitionModel build(ProcessDefinitionModel processDefinitionModel) {
|
||||
if (processDefinitionModel == null)
|
||||
return this;
|
||||
return processDefinitionModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建ProcessDefinitionModel对象属性
|
||||
* @param processDefinition
|
||||
* @return
|
||||
*/
|
||||
public static ProcessDefinitionModel build(ProcessDefinition processDefinition){
|
||||
ProcessDefinitionModel processDefinitionModel=new ProcessDefinitionModel();
|
||||
if(processDefinition==null){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2002,"processDefinition is null");
|
||||
}if(StringUtils.isEmpty(processDefinition.getId())){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2002,"processDefinition id is null");
|
||||
}
|
||||
processDefinitionModel.procDefId=processDefinition.getId();
|
||||
processDefinitionModel.procDefKey=processDefinition.getKey();
|
||||
processDefinitionModel.procDefName=processDefinition.getName();
|
||||
processDefinitionModel.version=processDefinition.getVersion();
|
||||
processDefinitionModel.tenantId=processDefinition.getTenantId();
|
||||
processDefinitionModel.description=processDefinition.getDescription();
|
||||
processDefinitionModel.deploymentId=processDefinition.getDeploymentId();
|
||||
//this.category=processDefinition.getCategory();
|
||||
/* this.isSuspended=processDefinition.isSuspended();
|
||||
this.diagramResourceName=processDefinition.getDiagramResourceName();
|
||||
this.resourceName=processDefinition.getResourceName();
|
||||
this.deploymentId=processDefinition.getDeploymentId();*/
|
||||
return processDefinitionModel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 构建ProcessDefinitionModel对象属性
|
||||
* @param processDefinition
|
||||
* @return
|
||||
*/
|
||||
public static ProcessDefinitionModel build(HistoricProcessInstance processInstance){
|
||||
ProcessDefinitionModel processDefinitionModel=new ProcessDefinitionModel();
|
||||
if(processInstance==null){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2002,"processInstance is null");
|
||||
}if(StringUtils.isEmpty(processInstance.getProcessDefinitionId())){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2002,"processDefinition id is null");
|
||||
}
|
||||
processDefinitionModel.procDefId=processInstance.getProcessDefinitionId();
|
||||
processDefinitionModel.procDefKey=processInstance.getProcessDefinitionName();
|
||||
|
||||
/*this.processDefinitionKey=processDefinition.getKey();
|
||||
this.processDefinitionName=processDefinition.getName();
|
||||
this.hasStartFormKey=processDefinition.hasStartFormKey();
|
||||
this.isSuspended=processDefinition.isSuspended();
|
||||
this.version=processDefinition.getVersion();
|
||||
this.tenantId=processDefinition.getTenantId();
|
||||
this.diagramResourceName=processDefinition.getDiagramResourceName();
|
||||
this.resourceName=processDefinition.getResourceName();
|
||||
this.description=processDefinition.getDescription();
|
||||
this.category=processDefinition.getCategory();
|
||||
this.deploymentId=processDefinition.getDeploymentId();*/
|
||||
return processDefinitionModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建ProcessDefinitionModel对象属性
|
||||
* @param processDefinition
|
||||
* @return
|
||||
*/
|
||||
public static ProcessDefinitionModel build(ProcessDefinition processDefinition,Deployment deployment ){
|
||||
ProcessDefinitionModel processDefinitionModel=new ProcessDefinitionModel();
|
||||
if(processDefinition==null||deployment==null)
|
||||
return processDefinitionModel;
|
||||
processDefinitionModel.procDefId=processDefinition.getId();
|
||||
processDefinitionModel.procDefKey=processDefinition.getKey();
|
||||
processDefinitionModel.procDefName=processDefinition.getName();
|
||||
processDefinitionModel.version=processDefinition.getVersion();
|
||||
processDefinitionModel.tenantId=processDefinition.getTenantId();
|
||||
processDefinitionModel.description=processDefinition.getDescription();
|
||||
processDefinitionModel.deploymentId=processDefinition.getDeploymentId();
|
||||
processDefinitionModel.pdCreateTime=deployment.getDeploymentTime();
|
||||
|
||||
//this.category=processDefinition.getCategory();
|
||||
/* this.isSuspended=processDefinition.isSuspended();
|
||||
this.diagramResourceName=processDefinition.getDiagramResourceName();
|
||||
this.resourceName=processDefinition.getResourceName();
|
||||
this.deploymentId=processDefinition.getDeploymentId();
|
||||
//deployment property
|
||||
this.deploymentName=deployment.getName();
|
||||
this.deploymentCategory=deployment.getCategory();*/
|
||||
return processDefinitionModel;
|
||||
}
|
||||
|
||||
|
||||
public String getProcDefId() {
|
||||
return procDefId;
|
||||
}
|
||||
|
||||
public void setProcDefId(String procDefId) {
|
||||
this.procDefId = procDefId;
|
||||
}
|
||||
|
||||
public String getProcDefKey() {
|
||||
return procDefKey;
|
||||
}
|
||||
|
||||
public void setProcDefKey(String procDefKey) {
|
||||
this.procDefKey = procDefKey;
|
||||
}
|
||||
|
||||
public String getProcDefName() {
|
||||
return procDefName;
|
||||
}
|
||||
|
||||
public void setProcDefName(String procDefName) {
|
||||
this.procDefName = procDefName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Date getPdCreateTime() {
|
||||
return pdCreateTime;
|
||||
}
|
||||
|
||||
public void setPdCreateTime(Date pdCreateTime) {
|
||||
this.pdCreateTime = pdCreateTime;
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public ProcessInfoConfig getProcessInfoConfig() {
|
||||
return processInfoConfig;
|
||||
}
|
||||
|
||||
public void setProcessInfoConfig(ProcessInfoConfig processInfoConfig) {
|
||||
this.processInfoConfig = processInfoConfig;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getDeploymentId() {
|
||||
return deploymentId;
|
||||
}
|
||||
|
||||
public void setDeploymentId(String deploymentId) {
|
||||
this.deploymentId = deploymentId;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.task.Comment;
|
||||
|
||||
import com.blueland.bpm.identity.model.Org;
|
||||
/**
|
||||
* 流程详细日志模型
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessDetailLog {
|
||||
private Comment comment;
|
||||
private HistoricTaskInstance historicTaskInstance;
|
||||
private String sendUserName;
|
||||
private String reiceiveUserName;
|
||||
private Org sendOrg;
|
||||
private Org receiveOrg;
|
||||
private String finishState;
|
||||
private String wirteConmentUserName;
|
||||
public Comment getComment() {
|
||||
return comment;
|
||||
}
|
||||
public void setComment(Comment comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
public HistoricTaskInstance getHistoricTaskInstance() {
|
||||
return historicTaskInstance;
|
||||
}
|
||||
public void setHistoricTaskInstance(HistoricTaskInstance historicTaskInstance) {
|
||||
this.historicTaskInstance = historicTaskInstance;
|
||||
}
|
||||
public String getSendUserName() {
|
||||
return sendUserName;
|
||||
}
|
||||
public void setSendUserName(String sendUserName) {
|
||||
this.sendUserName = sendUserName;
|
||||
}
|
||||
public String getReiceiveUserName() {
|
||||
return reiceiveUserName;
|
||||
}
|
||||
public void setReiceiveUserName(String reiceiveUserName) {
|
||||
this.reiceiveUserName = reiceiveUserName;
|
||||
}
|
||||
public Org getSendOrg() {
|
||||
return sendOrg;
|
||||
}
|
||||
public void setSendOrg(Org sendOrg) {
|
||||
this.sendOrg = sendOrg;
|
||||
}
|
||||
public Org getReceiveOrg() {
|
||||
return receiveOrg;
|
||||
}
|
||||
public void setReceiveOrg(Org receiveOrg) {
|
||||
this.receiveOrg = receiveOrg;
|
||||
}
|
||||
public String getFinishState() {
|
||||
return finishState;
|
||||
}
|
||||
public void setFinishState(String finishState) {
|
||||
this.finishState = finishState;
|
||||
}
|
||||
public String getWirteConmentUserName() {
|
||||
return wirteConmentUserName;
|
||||
}
|
||||
public void setWirteConmentUserName(String wirteConmentUserName) {
|
||||
this.wirteConmentUserName = wirteConmentUserName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程执行数据全局共享
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessExeDataShare {
|
||||
|
||||
static ThreadLocal<Map<String,Object>> processExeDataShareThreadLocal = new ThreadLocal<Map<String,Object>>();
|
||||
|
||||
public static void setProcessExeData1(Map<String,Object> processExeData) {
|
||||
clear();
|
||||
processExeDataShareThreadLocal.set(processExeData);
|
||||
}
|
||||
|
||||
public static Map<String,Object> getProcessExeData1() {
|
||||
return processExeDataShareThreadLocal.get();
|
||||
}
|
||||
public static void clear() {
|
||||
processExeDataShareThreadLocal.set(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程执行错误消息全局共享
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessExeErrorShare {
|
||||
|
||||
static ThreadLocal<Map<String,Object>> processExeErrorShareThreadLocal = new ThreadLocal<Map<String,Object>>();
|
||||
|
||||
public static void setProcessExeErrorData(Map<String,Object> processExeErrorData) {
|
||||
processExeErrorShareThreadLocal.set(null);
|
||||
processExeErrorShareThreadLocal.set(processExeErrorData);
|
||||
}
|
||||
|
||||
public static Map<String,Object> getProcessExeErrorData() {
|
||||
return processExeErrorShareThreadLocal.get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,514 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程客户端输入对象
|
||||
* @author lw
|
||||
*
|
||||
*/
|
||||
public class ProcessInputModel implements java.io.Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 流程应用系统
|
||||
*/
|
||||
private String wf_appId;
|
||||
/**
|
||||
* 流程标题
|
||||
*/
|
||||
private String wf_procTitle;
|
||||
/**
|
||||
* 动作处理标识
|
||||
*/
|
||||
private String wf_actionType;
|
||||
/**
|
||||
* 流程定义ID,对应引擎自动生成的ID,规则为(流程定义KEY:版本号:部署ID)
|
||||
*/
|
||||
private String wf_procDefId;
|
||||
/**
|
||||
* 流程定义KEY,对应建模的时候流程定义ID
|
||||
*/
|
||||
private String wf_procDefKey;
|
||||
/**
|
||||
* 动作处理标识
|
||||
*/
|
||||
private String wf_procDefName;
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
private String wf_procInstId;
|
||||
|
||||
/**
|
||||
* 父流程实例ID
|
||||
*/
|
||||
private String wf_parentProcInstId;
|
||||
/**
|
||||
* 当前环节定义Id
|
||||
*/
|
||||
private String wf_curActDefId;
|
||||
|
||||
/**
|
||||
* 当前环节定义类型
|
||||
*/
|
||||
private String wf_curActDefType;
|
||||
|
||||
/**
|
||||
* 当前环节定义Name
|
||||
*/
|
||||
private String wf_curActDefName;
|
||||
/**
|
||||
* 当前环节实例Id
|
||||
*/
|
||||
private String wf_curActInstId;
|
||||
/**
|
||||
* 当前环节实例Name
|
||||
*/
|
||||
private String wf_curActInstName;
|
||||
/**
|
||||
* 下一个环节定义ID
|
||||
*/
|
||||
private String wf_nextActDefId;
|
||||
/**
|
||||
* 下一个环节定义Name
|
||||
*/
|
||||
private String wf_nextActDefName;
|
||||
/**
|
||||
* 下一个环节定义类型
|
||||
*/
|
||||
private String wf_nextActDefType;
|
||||
private String wf_preActSender;
|
||||
/**
|
||||
* 发送人ID
|
||||
*/
|
||||
private String wf_sendUserId;
|
||||
/**
|
||||
* 发送人ID
|
||||
*/
|
||||
private String wf_sender;
|
||||
/**
|
||||
* 发送人姓名
|
||||
*/
|
||||
private String wf_sendUserName;
|
||||
|
||||
/**
|
||||
* 发送人组织ID
|
||||
*/
|
||||
private String wf_sendUserOrgId;
|
||||
/**
|
||||
* 发送人组织ID
|
||||
*/
|
||||
private String wf_sendUserOrgName;
|
||||
/**
|
||||
* 发送人公司ID
|
||||
*/
|
||||
private String wf_sendUserCompanyId;
|
||||
/**
|
||||
* 接收者列表(user1;user2;user3)
|
||||
*/
|
||||
private List<ActivityReceiverModel> wf_receivers;
|
||||
/**
|
||||
* 接收者列表(user1;user2;user3)
|
||||
*/
|
||||
private String wf_receiver;
|
||||
|
||||
/**
|
||||
* 页面处理时间 格式:年月日时分秒 必须
|
||||
*/
|
||||
private String wf_pageDealTime;
|
||||
|
||||
private String wf_fields;
|
||||
|
||||
/**
|
||||
* 流程变量,存在于当前流程实例生命周期中
|
||||
*/
|
||||
private Map<String,Object> wf_variables=new HashMap<String,Object>();
|
||||
|
||||
/**
|
||||
* 页面中需要存储的表单元素,表示为:key:字段ID,value:字段值
|
||||
*/
|
||||
private Map<String,Object> fields=new HashMap<String,Object>();
|
||||
/**
|
||||
* <附件路径+附件名> 页面传的该字段只在新增和修改附件的情况下填写,并且是该环节上的所有附件组合串 (没有附件时候,和没有对附件进行过修改时,该字段不需要)
|
||||
*/
|
||||
private String wf_attachments;
|
||||
/**
|
||||
* 当前环节意见
|
||||
*/
|
||||
private String wf_curComment;
|
||||
/**
|
||||
* 批量处理标识
|
||||
*/
|
||||
private String wf_batchId;
|
||||
|
||||
|
||||
/**
|
||||
* 意见展示区域
|
||||
*/
|
||||
private String wf_commentDisplayArea;
|
||||
|
||||
private String wf_businessKey;
|
||||
|
||||
/**
|
||||
* 业务数据对象
|
||||
*/
|
||||
private BusinessDataObject wf_businessDataObject;
|
||||
|
||||
/**
|
||||
* 扩业务的流程数据对象
|
||||
*/
|
||||
private BusinessDataObject wf_throughBizDataObject;
|
||||
|
||||
/**
|
||||
* 流程待办URL
|
||||
*/
|
||||
private String wf_uniteworkUrl;
|
||||
|
||||
/**
|
||||
* 桌面端、网页端访问待办详情的方式,指访问该待办采⽤的协议,具体参考统一待办规范
|
||||
*/
|
||||
private String wf_cportalProtocol ;
|
||||
/**
|
||||
* 手机端统一待办处理URL,如果不传,取流程配置的手机端统一待办路径。流程平台在产生待办的时候会在这个URL之后附加流程实例的相关参数
|
||||
*/
|
||||
private String wf_mportalUrl;
|
||||
/**
|
||||
* 手机端访问待办详情的方式,指访问该待办采⽤的协议,具体参考统一待办规范
|
||||
*/
|
||||
private String wf_mportalProtocol;
|
||||
/**
|
||||
* 该属性仅在手机端使用,readonly指该待办在移动端是否只读。具体参考统一待办规范
|
||||
*/
|
||||
private String wf_otherSysDealStatus;
|
||||
|
||||
/**
|
||||
* 流程下一环节处理时限
|
||||
*/
|
||||
private int wf_actLimitTime;
|
||||
|
||||
/**
|
||||
* 是否前端自动查询出下一步人员,用于ParallelMultiInstanceBehavior初始化人员的判断
|
||||
*/
|
||||
private boolean wf_webAutoQueryNextUserFlag;
|
||||
|
||||
/**
|
||||
* 是否前端自动查询出下一步人员,用于ParallelMultiInstanceBehavior初始化人员的判断
|
||||
*/
|
||||
private boolean wf_webAutoQueryNextActFlag;
|
||||
|
||||
|
||||
private String wf_uniteCategory;
|
||||
|
||||
public String getWf_procTitle() {
|
||||
return wf_procTitle;
|
||||
}
|
||||
public void setWf_procTitle(String wf_procTitle) {
|
||||
this.wf_procTitle = wf_procTitle;
|
||||
}
|
||||
|
||||
public String getWf_actionType() {
|
||||
return wf_actionType;
|
||||
}
|
||||
public void setWf_actionType(String wf_actionType) {
|
||||
this.wf_actionType = wf_actionType;
|
||||
}
|
||||
|
||||
public String getWf_procDefId() {
|
||||
return wf_procDefId;
|
||||
}
|
||||
public void setWf_procDefId(String wf_procDefId) {
|
||||
this.wf_procDefId = wf_procDefId;
|
||||
}
|
||||
public String getWf_procDefKey() {
|
||||
return wf_procDefKey;
|
||||
}
|
||||
public void setWf_procDefKey(String wf_procDefKey) {
|
||||
this.wf_procDefKey = wf_procDefKey;
|
||||
}
|
||||
public String getWf_procDefName() {
|
||||
return wf_procDefName;
|
||||
}
|
||||
public void setWf_procDefName(String wf_procDefName) {
|
||||
this.wf_procDefName = wf_procDefName;
|
||||
}
|
||||
public String getWf_procInstId() {
|
||||
return wf_procInstId;
|
||||
}
|
||||
public void setWf_procInstId(String wf_procInstId) {
|
||||
this.wf_procInstId = wf_procInstId;
|
||||
}
|
||||
public String getWf_curActDefId() {
|
||||
return wf_curActDefId;
|
||||
}
|
||||
public void setWf_curActDefId(String wf_curActDefId) {
|
||||
this.wf_curActDefId = wf_curActDefId;
|
||||
}
|
||||
public String getWf_curActDefName() {
|
||||
return wf_curActDefName;
|
||||
}
|
||||
public void setWf_curActDefName(String wf_curActDefName) {
|
||||
this.wf_curActDefName = wf_curActDefName;
|
||||
}
|
||||
public String getWf_curActInstId() {
|
||||
return wf_curActInstId;
|
||||
}
|
||||
public void setWf_curActInstId(String wf_curActInstId) {
|
||||
this.wf_curActInstId = wf_curActInstId;
|
||||
}
|
||||
public String getWf_curActInstName() {
|
||||
return wf_curActInstName;
|
||||
}
|
||||
public void setWf_curActInstName(String wf_curActInstName) {
|
||||
this.wf_curActInstName = wf_curActInstName;
|
||||
}
|
||||
public String getWf_nextActDefId() {
|
||||
return wf_nextActDefId;
|
||||
}
|
||||
public void setWf_nextActDefId(String wf_nextActDefId) {
|
||||
this.wf_nextActDefId = wf_nextActDefId;
|
||||
}
|
||||
public String getWf_nextActDefName() {
|
||||
return wf_nextActDefName;
|
||||
}
|
||||
public void setWf_nextActDefName(String wf_nextActDefName) {
|
||||
this.wf_nextActDefName = wf_nextActDefName;
|
||||
}
|
||||
public String getWf_sender() {
|
||||
return wf_sender;
|
||||
}
|
||||
public void setWf_sender(String wf_sender) {
|
||||
this.wf_sender = wf_sender;
|
||||
}
|
||||
|
||||
public String getWf_preActSender() {
|
||||
return wf_preActSender;
|
||||
}
|
||||
public void setWf_preActSender(String wf_preActSender) {
|
||||
this.wf_preActSender = wf_preActSender;
|
||||
}
|
||||
public String getWf_pageDealTime() {
|
||||
return wf_pageDealTime;
|
||||
}
|
||||
public void setWf_pageDealTime(String wf_pageDealTime) {
|
||||
this.wf_pageDealTime = wf_pageDealTime;
|
||||
}
|
||||
public String getWf_attachments() {
|
||||
return wf_attachments;
|
||||
}
|
||||
public void setWf_attachments(String wf_attachments) {
|
||||
this.wf_attachments = wf_attachments;
|
||||
}
|
||||
public String getWf_curComment() {
|
||||
return wf_curComment;
|
||||
}
|
||||
public void setWf_curComment(String wf_curComment) {
|
||||
this.wf_curComment = wf_curComment;
|
||||
}
|
||||
public String getWf_businessKey() {
|
||||
return wf_businessKey;
|
||||
}
|
||||
public void setWf_businessKey(String wf_businessKey) {
|
||||
this.wf_businessKey = wf_businessKey;
|
||||
}
|
||||
public void addField(String key,String value) {
|
||||
fields.put(key, value);
|
||||
}
|
||||
public Map<String, Object> getFields() {
|
||||
return this.fields;
|
||||
}
|
||||
public void setFields(Map<String, Object> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
public String getWf_fields() {
|
||||
return wf_fields;
|
||||
}
|
||||
public void setWf_fields(String wf_fields) {
|
||||
this.wf_fields = wf_fields;
|
||||
}
|
||||
public String getWf_curActDefType() {
|
||||
return wf_curActDefType;
|
||||
}
|
||||
public void setWf_curActDefType(String wf_curActDefType) {
|
||||
this.wf_curActDefType = wf_curActDefType;
|
||||
}
|
||||
public String getWf_nextActDefType() {
|
||||
return wf_nextActDefType;
|
||||
}
|
||||
public void setWf_nextActDefType(String wf_nextActDefType) {
|
||||
this.wf_nextActDefType = wf_nextActDefType;
|
||||
}
|
||||
public Map<String,Object> getWf_variables() {
|
||||
return wf_variables;
|
||||
}
|
||||
public void setWf_variables(Map<String,Object> wf_variables) {
|
||||
this.wf_variables = wf_variables;
|
||||
}
|
||||
|
||||
public String getWf_commentDisplayArea() {
|
||||
return wf_commentDisplayArea;
|
||||
}
|
||||
public void setWf_commentDisplayArea(String wf_commentDisplayArea) {
|
||||
this.wf_commentDisplayArea = wf_commentDisplayArea;
|
||||
}
|
||||
|
||||
|
||||
public String getWf_appId() {
|
||||
return wf_appId;
|
||||
}
|
||||
|
||||
public void setWf_appId(String wf_appId) {
|
||||
this.wf_appId = wf_appId;
|
||||
}
|
||||
public String getWf_sendUserName() {
|
||||
return wf_sendUserName;
|
||||
}
|
||||
public void setWf_sendUserName(String wf_sendUserName) {
|
||||
this.wf_sendUserName = wf_sendUserName;
|
||||
}
|
||||
public void addWf_variable(String key,Object value) {
|
||||
if(wf_variables==null)
|
||||
this.wf_variables=new HashMap();
|
||||
wf_variables.put(key, value);
|
||||
}
|
||||
|
||||
|
||||
public String getWf_sendUserOrgId() {
|
||||
return wf_sendUserOrgId;
|
||||
}
|
||||
public void setWf_sendUserOrgId(String wf_sendUserOrgId) {
|
||||
this.wf_sendUserOrgId = wf_sendUserOrgId;
|
||||
}
|
||||
public String getWf_sendUserOrgName() {
|
||||
return wf_sendUserOrgName;
|
||||
}
|
||||
public void setWf_sendUserOrgName(String wf_sendUserOrgName) {
|
||||
this.wf_sendUserOrgName = wf_sendUserOrgName;
|
||||
}
|
||||
public String getWf_sendUserCompanyId() {
|
||||
return wf_sendUserCompanyId;
|
||||
}
|
||||
public void setWf_sendUserCompanyId(String wf_sendUserCompanyId) {
|
||||
this.wf_sendUserCompanyId = wf_sendUserCompanyId;
|
||||
}
|
||||
public BusinessDataObject getWf_businessDataObject() {
|
||||
return wf_businessDataObject;
|
||||
}
|
||||
public void setWf_businessDataObject(BusinessDataObject wf_businessDataObject) {
|
||||
this.wf_businessDataObject = wf_businessDataObject;
|
||||
}
|
||||
public BusinessDataObject getWf_throughBizDataObject() {
|
||||
return wf_throughBizDataObject;
|
||||
}
|
||||
public void setWf_throughBizDataObject(
|
||||
BusinessDataObject wf_throughBizDataObject) {
|
||||
this.wf_throughBizDataObject = wf_throughBizDataObject;
|
||||
}
|
||||
public String getWf_parentProcInstId() {
|
||||
return wf_parentProcInstId;
|
||||
}
|
||||
public void setWf_parentProcInstId(String wf_parentProcInstId) {
|
||||
this.wf_parentProcInstId = wf_parentProcInstId;
|
||||
}
|
||||
|
||||
public String getWf_receiver() {
|
||||
return wf_receiver;
|
||||
}
|
||||
public void setWf_receiver(String wf_receiver) {
|
||||
this.wf_receiver = wf_receiver;
|
||||
}
|
||||
|
||||
public String getWf_sendUserId() {
|
||||
return wf_sendUserId;
|
||||
}
|
||||
public void setWf_sendUserId(String wf_sendUserId) {
|
||||
this.wf_sendUserId = wf_sendUserId;
|
||||
}
|
||||
public List<ActivityReceiverModel> getWf_receivers() {
|
||||
return wf_receivers;
|
||||
}
|
||||
public void setWf_receivers(List<ActivityReceiverModel> wf_receivers) {
|
||||
this.wf_receivers = wf_receivers;
|
||||
}
|
||||
|
||||
public String getWf_uniteworkUrl() {
|
||||
return wf_uniteworkUrl;
|
||||
}
|
||||
public void setWf_uniteworkUrl(String wf_uniteworkUrl) {
|
||||
this.wf_uniteworkUrl = wf_uniteworkUrl;
|
||||
}
|
||||
|
||||
public String getWf_batchId() {
|
||||
return wf_batchId;
|
||||
}
|
||||
public void setWf_batchId(String wf_batchId) {
|
||||
this.wf_batchId = wf_batchId;
|
||||
}
|
||||
|
||||
public int getWf_actLimitTime() {
|
||||
return this.wf_actLimitTime;
|
||||
}
|
||||
|
||||
public void setWf_actLimitTime(int actLimitTime) {
|
||||
this.wf_actLimitTime = actLimitTime;
|
||||
}
|
||||
|
||||
|
||||
public boolean getWf_webAutoQueryNextUserFlag() {
|
||||
return wf_webAutoQueryNextUserFlag;
|
||||
}
|
||||
public void setWf_webAutoQueryNextUserFlag(boolean wf_webAutoQueryNextUserFlag) {
|
||||
this.wf_webAutoQueryNextUserFlag = wf_webAutoQueryNextUserFlag;
|
||||
}
|
||||
public boolean getWf_webAutoQueryNextActFlag() {
|
||||
return wf_webAutoQueryNextActFlag;
|
||||
}
|
||||
public void setWf_webAutoQueryNextActFlag(boolean wf_webAutoQueryNextActFlag) {
|
||||
this.wf_webAutoQueryNextActFlag = wf_webAutoQueryNextActFlag;
|
||||
}
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
|
||||
public String getWf_uniteCategory() {
|
||||
return wf_uniteCategory;
|
||||
}
|
||||
public void setWf_uniteCategory(String wf_uniteCategory) {
|
||||
this.wf_uniteCategory = wf_uniteCategory;
|
||||
}
|
||||
|
||||
|
||||
public String getWf_cportalProtocol() {
|
||||
return wf_cportalProtocol;
|
||||
}
|
||||
public void setWf_cportalProtocol(String wf_cportalProtocol) {
|
||||
this.wf_cportalProtocol = wf_cportalProtocol;
|
||||
}
|
||||
public String getWf_mportalUrl() {
|
||||
return wf_mportalUrl;
|
||||
}
|
||||
public void setWf_mportalUrl(String wf_mportalUrl) {
|
||||
this.wf_mportalUrl = wf_mportalUrl;
|
||||
}
|
||||
public String getWf_mportalProtocol() {
|
||||
return wf_mportalProtocol;
|
||||
}
|
||||
public void setWf_mportalProtocol(String wf_mportalProtocol) {
|
||||
this.wf_mportalProtocol = wf_mportalProtocol;
|
||||
}
|
||||
|
||||
|
||||
public String getWf_otherSysDealStatus() {
|
||||
return wf_otherSysDealStatus;
|
||||
}
|
||||
public void setWf_otherSysDealStatus(String wf_otherSysDealStatus) {
|
||||
this.wf_otherSysDealStatus = wf_otherSysDealStatus;
|
||||
}
|
||||
public String toString(){
|
||||
return org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,435 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.SuspensionState;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
/**
|
||||
* 流程实例对象
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessInstanceModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 流程定义ID
|
||||
*/
|
||||
String procDefId;
|
||||
/**
|
||||
* 流程定义名称
|
||||
*/
|
||||
String procDefName;
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
String procInstId;
|
||||
|
||||
/**
|
||||
* 顶层流程实例父ID
|
||||
*/
|
||||
String topProcInstId;
|
||||
/**
|
||||
* 流程实例父ID
|
||||
*/
|
||||
String parentProcInstId;
|
||||
/**
|
||||
* 流程标题
|
||||
*/
|
||||
String procTitle;
|
||||
/**
|
||||
* 流程起草人
|
||||
*/
|
||||
String startUserId;
|
||||
/**
|
||||
* 流程起草人
|
||||
*/
|
||||
String startUserName;
|
||||
/**
|
||||
* 流程起草组织
|
||||
*/
|
||||
String starterOrgId;
|
||||
/**
|
||||
* 流程起草组织
|
||||
*/
|
||||
String starterOrgName;
|
||||
/**
|
||||
* 流程创建时间
|
||||
*/
|
||||
Date createTime;
|
||||
/**
|
||||
* 流程完成时间
|
||||
*/
|
||||
Date finishTime;
|
||||
/**
|
||||
* 流程开始环节ID
|
||||
*/
|
||||
String startActivityId;
|
||||
/**
|
||||
* 流程结束环节ID
|
||||
*/
|
||||
String endActivityId;
|
||||
|
||||
/**
|
||||
* 业务主键
|
||||
*/
|
||||
String businessKey;
|
||||
/**
|
||||
* 流程状态
|
||||
*/
|
||||
String procState;
|
||||
/**
|
||||
* 是否包含子流
|
||||
*/
|
||||
boolean hasSubProcess;
|
||||
/**
|
||||
* 动作类型
|
||||
*/
|
||||
String actionType;
|
||||
|
||||
/**
|
||||
* 流程定义
|
||||
*/
|
||||
ProcessDefinitionModel processDefinition;
|
||||
|
||||
/**
|
||||
* 当前环节实例ID--待定
|
||||
*/
|
||||
ActivityInstanceModel currentActivity;
|
||||
/**
|
||||
* 下一步环节实例对象--待定
|
||||
*/
|
||||
List<ActivityInstanceModel> nextActivity;
|
||||
|
||||
|
||||
/**
|
||||
* 子流程-流程实例ID列表
|
||||
*/
|
||||
List<String> subProcInstIds;
|
||||
|
||||
/**
|
||||
* 流程全局变量--待定
|
||||
*/
|
||||
Map processVariables = new HashMap();
|
||||
/**
|
||||
* 输入对象--待定
|
||||
*/
|
||||
ProcessInputModel processInputModel;
|
||||
/**
|
||||
* 租衣Id
|
||||
*/
|
||||
String tenantId;
|
||||
|
||||
|
||||
public static ProcessInstanceModel buildAndProcDef(HistoricProcessInstance processInstance,ProcessDefinitionModel processDefinition){
|
||||
ProcessInstanceModel processInstanceModel=new ProcessInstanceModel();
|
||||
if(processInstance==null)
|
||||
return processInstanceModel;
|
||||
processInstanceModel.procTitle=processInstance.getProcTitle();
|
||||
processInstanceModel.businessKey=processInstance.getBusinessKey();
|
||||
processInstanceModel.procInstId=processInstance.getId();
|
||||
processInstanceModel.createTime=processInstance.getStartTime();
|
||||
processInstanceModel.finishTime=processInstance.getEndTime();
|
||||
processInstanceModel.startActivityId=processInstance.getStartActivityId();
|
||||
processInstanceModel.endActivityId=processInstance.getEndActivityId();
|
||||
processInstanceModel.startUserId=processInstance.getStartUserId();
|
||||
processInstanceModel.startUserName=processInstance.getStartUserName();
|
||||
processInstanceModel.parentProcInstId=processInstance.getSuperProcessInstanceId();
|
||||
processInstanceModel.topProcInstId=processInstance.getTopProcessInstanceId();
|
||||
processInstanceModel.procDefId=processInstance.getProcessDefinitionId();
|
||||
processInstanceModel.procDefName=processInstance.getProcessDefinitionName();
|
||||
processInstanceModel.starterOrgId=processInstance.getStarterOrgId();
|
||||
processInstanceModel.starterOrgName=processInstance.getStarterOrgName();
|
||||
processInstanceModel.processDefinition=processDefinition;
|
||||
processInstanceModel.procState = String.valueOf(processInstance.getProcState());
|
||||
processInstanceModel.tenantId=processInstance.getTenantId();
|
||||
processInstanceModel.processDefinition=processDefinition;
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
public static ProcessInstanceModel buildAndProcDef(ExecutionEntity processInstance,ProcessDefinitionModel processDefinition){
|
||||
ProcessInstanceModel processInstanceModel=new ProcessInstanceModel();
|
||||
if(processInstance==null)
|
||||
return processInstanceModel;
|
||||
processInstanceModel.procTitle=processInstance.getProcTitle();
|
||||
processInstanceModel.businessKey=processInstance.getBusinessKey();
|
||||
processInstanceModel.procInstId=processInstance.getId();
|
||||
processInstanceModel.createTime=new Date();
|
||||
processInstanceModel.startActivityId=processInstance.getCurrentActivityId();
|
||||
processInstanceModel.startUserId=processInstance.getSendUserId();
|
||||
processInstanceModel.startUserName=processInstance.getSendUserName();
|
||||
processInstanceModel.parentProcInstId=processInstance.getSuperExecution()!=null?processInstance.getSuperExecution().getProcessInstanceId():processInstance.getParentId();
|
||||
processInstanceModel.topProcInstId=processInstance.getTopProcessInstanceId();
|
||||
processInstanceModel.procDefId=processInstance.getProcessDefinitionId();
|
||||
processInstanceModel.procDefName=processInstance.getProcessDefinitionName();
|
||||
processInstanceModel.starterOrgId=processInstance.getSenderOrgId();
|
||||
processInstanceModel.starterOrgName=processInstance.getSenderOrgName();
|
||||
processInstanceModel.processDefinition=processDefinition;
|
||||
processInstanceModel.procState = String.valueOf(SuspensionState.ACTIVE);
|
||||
processInstanceModel.tenantId=processInstance.getTenantId();
|
||||
processInstanceModel.processDefinition=processDefinition;
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
public static ProcessInstanceModel build(HistoricProcessInstance processInstance){
|
||||
return buildAndProcDef(processInstance,null);
|
||||
}
|
||||
|
||||
|
||||
public String getProcInstId() {
|
||||
return procInstId;
|
||||
}
|
||||
|
||||
|
||||
public void setProcInstId(String procInstId) {
|
||||
this.procInstId = procInstId;
|
||||
}
|
||||
|
||||
|
||||
public String getParentProcInstId() {
|
||||
return parentProcInstId;
|
||||
}
|
||||
|
||||
|
||||
public void setParentProcInstId(String parentProcInstId) {
|
||||
this.parentProcInstId = parentProcInstId;
|
||||
}
|
||||
|
||||
|
||||
public String getProcTitle() {
|
||||
return procTitle;
|
||||
}
|
||||
|
||||
|
||||
public void setProcTitle(String procTitle) {
|
||||
this.procTitle = procTitle;
|
||||
}
|
||||
|
||||
|
||||
public String getStartUserId() {
|
||||
return startUserId;
|
||||
}
|
||||
|
||||
|
||||
public void setStartUserId(String startUserId) {
|
||||
this.startUserId = startUserId;
|
||||
}
|
||||
|
||||
|
||||
public String getStartUserName() {
|
||||
return startUserName;
|
||||
}
|
||||
|
||||
|
||||
public void setStartUserName(String startUserName) {
|
||||
this.startUserName = startUserName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getStarterOrgId() {
|
||||
return starterOrgId;
|
||||
}
|
||||
|
||||
public void setStarterOrgId(String starterOrgId) {
|
||||
this.starterOrgId = starterOrgId;
|
||||
}
|
||||
|
||||
public String getStarterOrgName() {
|
||||
return starterOrgName;
|
||||
}
|
||||
|
||||
public void setStarterOrgName(String starterOrgName) {
|
||||
this.starterOrgName = starterOrgName;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
||||
public Date getFinishTime() {
|
||||
return finishTime;
|
||||
}
|
||||
|
||||
|
||||
public void setFinishTime(Date finishTime) {
|
||||
this.finishTime = finishTime;
|
||||
}
|
||||
|
||||
|
||||
public String getStartActivityId() {
|
||||
return startActivityId;
|
||||
}
|
||||
|
||||
|
||||
public void setStartActivityId(String startActivityId) {
|
||||
this.startActivityId = startActivityId;
|
||||
}
|
||||
|
||||
|
||||
public String getEndActivityId() {
|
||||
return endActivityId;
|
||||
}
|
||||
|
||||
|
||||
public void setEndActivityId(String endActivityId) {
|
||||
this.endActivityId = endActivityId;
|
||||
}
|
||||
|
||||
|
||||
public String getBusinessKey() {
|
||||
return businessKey;
|
||||
}
|
||||
|
||||
|
||||
public void setBusinessKey(String businessKey) {
|
||||
this.businessKey = businessKey;
|
||||
}
|
||||
|
||||
|
||||
public String getProcState() {
|
||||
return procState;
|
||||
}
|
||||
|
||||
|
||||
public void setProcState(String procState) {
|
||||
this.procState = procState;
|
||||
}
|
||||
|
||||
|
||||
public boolean isHasSubProcess() {
|
||||
return hasSubProcess;
|
||||
}
|
||||
|
||||
|
||||
public void setHasSubProcess(boolean hasSubProcess) {
|
||||
this.hasSubProcess = hasSubProcess;
|
||||
}
|
||||
|
||||
|
||||
public String getActionType() {
|
||||
return actionType;
|
||||
}
|
||||
|
||||
|
||||
public void setActionType(String actionType) {
|
||||
this.actionType = actionType;
|
||||
}
|
||||
|
||||
|
||||
public Map getProcessVariables() {
|
||||
return processVariables;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessVariables(Map processVariables) {
|
||||
this.processVariables = processVariables;
|
||||
}
|
||||
|
||||
|
||||
public ProcessInputModel getProcessInputModel() {
|
||||
return processInputModel;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessInputModel(ProcessInputModel processInputModel) {
|
||||
this.processInputModel = processInputModel;
|
||||
}
|
||||
|
||||
|
||||
public ActivityInstanceModel getCurrentActivity() {
|
||||
return currentActivity;
|
||||
}
|
||||
|
||||
|
||||
public void setCurrentActivity(ActivityInstanceModel currentActivity) {
|
||||
this.currentActivity = currentActivity;
|
||||
}
|
||||
|
||||
|
||||
public List<ActivityInstanceModel> getNextActivity() {
|
||||
return nextActivity;
|
||||
}
|
||||
|
||||
|
||||
public void setNextActivity(List<ActivityInstanceModel> nextActivity) {
|
||||
this.nextActivity = nextActivity;
|
||||
}
|
||||
|
||||
public ProcessDefinitionModel getProcessDefinition() {
|
||||
return processDefinition;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessDefinition(ProcessDefinitionModel processDefinition) {
|
||||
this.processDefinition = processDefinition;
|
||||
}
|
||||
|
||||
|
||||
public String getProcDefId() {
|
||||
return procDefId;
|
||||
}
|
||||
|
||||
public void setProcDefId(String procDefId) {
|
||||
this.procDefId = procDefId;
|
||||
}
|
||||
|
||||
public String getProcDefName() {
|
||||
return procDefName;
|
||||
}
|
||||
|
||||
public void setProcDefName(String procDefName) {
|
||||
this.procDefName = procDefName;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
public String getTopProcInstId() {
|
||||
return topProcInstId;
|
||||
}
|
||||
|
||||
public void setTopProcInstId(String topProcInstId) {
|
||||
this.topProcInstId = topProcInstId;
|
||||
}
|
||||
|
||||
public List<String> getSubProcInstIds() {
|
||||
/*if(subProcInstIds==null){
|
||||
this.subProcInstIds=new ArrayList<String>();
|
||||
}*/
|
||||
return subProcInstIds;
|
||||
}
|
||||
|
||||
public void setSubProcInstIds(List<String> subProcInstIds) {
|
||||
this.subProcInstIds = subProcInstIds;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isFinishProcess(){
|
||||
return this.finishTime!=null&&this.procState.equals(String.valueOf(SuspensionState.FINISH.getStateCode()));
|
||||
}
|
||||
public String toString(){
|
||||
return org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.core.service.AbstractServiceHelper;
|
||||
import com.blueland.bpm.engine.core.service.ProcessDefinitionService;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
/**
|
||||
* 流程实例构造类
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class ProcessInstanceModellBuilder extends AbstractServiceHelper {
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Resource(name="processInstanceServiceImpl")
|
||||
ProcessInstanceService processInstanceService;
|
||||
@Resource(name="processDefinitionServiceImpl")
|
||||
ProcessDefinitionService processDefinitionService;
|
||||
|
||||
public ProcessInstanceModel builderProcessInfoNoNextTask(
|
||||
ProcessInputModel processInputModel,
|
||||
ProcessDefinition processDefinition,
|
||||
ProcessInstance processInstance, Task tempCurrentTask) {
|
||||
ProcessInstanceModel processInfo = null;
|
||||
ExecutionEntity executionEntity = (org.activiti.engine.impl.persistence.entity.ExecutionEntity) processInstance;
|
||||
if (WorkFlowContants.ACTION_TYPE_LAUCH_PROCESS.equals(processInputModel
|
||||
.getWf_actionType())
|
||||
|| WorkFlowContants.ACTION_TYPE_LAUCH_SAVE_PROCESS
|
||||
.equals(processInputModel.getWf_actionType())) {
|
||||
processInfo = ProcessInstanceModel.buildAndProcDef(executionEntity,
|
||||
ProcessDefinitionModel.build(processDefinition));
|
||||
} else {
|
||||
HistoricProcessInstance historicProcessInstance = this.historyService
|
||||
.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(processInstance.getId()).singleResult();
|
||||
if(historicProcessInstance==null){
|
||||
processInfo = ProcessInstanceModel.buildAndProcDef(executionEntity,
|
||||
ProcessDefinitionModel.build(processDefinition));
|
||||
}else{
|
||||
processInfo = ProcessInstanceModel.buildAndProcDef(
|
||||
historicProcessInstance,
|
||||
ProcessDefinitionModel.build(processDefinition));
|
||||
}
|
||||
}
|
||||
processInfo.processVariables = processInstance.getProcessVariables();
|
||||
processInfo.processInputModel=processInputModel;
|
||||
TaskEntity currentTask = (TaskEntity) tempCurrentTask;
|
||||
if(currentTask==null||currentTask.getId()==null){
|
||||
processInfo.actionType = processInputModel.getWf_actionType();
|
||||
return processInfo;
|
||||
}
|
||||
processInfo.actionType = currentTask.getActionType();
|
||||
ActivityInstanceModel curtActivityInfo = builderCurrentActivityInfo(
|
||||
executionEntity, currentTask);
|
||||
processInfo.currentActivity = curtActivityInfo;
|
||||
return processInfo;
|
||||
}
|
||||
|
||||
|
||||
public ProcessInstanceModel builderProcessInfo(
|
||||
ProcessInputModel processInputModel,
|
||||
ProcessDefinition processDefinition,
|
||||
ProcessInstance processInstance, Task tempCurrentTask) {
|
||||
ProcessInstanceModel processInfo = builderProcessInfoNoNextTask(
|
||||
processInputModel, processDefinition, processInstance,
|
||||
tempCurrentTask);
|
||||
if (!(WorkFlowContants.ACTION_TYPE_CANCEL_PROCESS
|
||||
.equals(processInputModel.getWf_actionType())
|
||||
|| WorkFlowContants.ACTION_TYPE_SAVE_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType()))) {
|
||||
if(processInfo.getCurrentActivity()!=null) {
|
||||
List<ActivityInstanceModel> nextActivityInfo = builderNextActivityInfo(
|
||||
processInfo.getProcInstId(), processInfo
|
||||
.getCurrentActivity().getReceiver());
|
||||
processInfo.nextActivity = nextActivityInfo;
|
||||
}
|
||||
}
|
||||
if (WorkFlowContants.ACTION_TYPE_LAUCH_PROCESS.equals(processInputModel
|
||||
.getWf_actionType())
|
||||
|| WorkFlowContants.ACTION_TYPE_EXECUTE_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType())) {
|
||||
try {
|
||||
processInfo.subProcInstIds = processInstanceService
|
||||
.getSubProcessInstanceIds(processInfo.getProcInstId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return processInfo;
|
||||
}
|
||||
|
||||
public ProcessInstanceModel builderProcess(
|
||||
ProcessInputModel processInputModel,
|
||||
ProcessDefinition processDefinition,
|
||||
ProcessInstance processInstance, Task tempCurrentTask) {
|
||||
ProcessInstanceModel processInfo = builderProcessInfoNoNextTask(
|
||||
processInputModel, processDefinition, processInstance,
|
||||
tempCurrentTask);
|
||||
if (!(WorkFlowContants.ACTION_TYPE_CANCEL_PROCESS
|
||||
.equals(processInputModel.getWf_actionType())
|
||||
|| WorkFlowContants.ACTION_TYPE_SAVE_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType()))) {
|
||||
List<ActivityInstanceModel> nextActivityInfo = builderNextActivityInfo(
|
||||
processInfo.getProcInstId(), processInfo
|
||||
.getCurrentActivity().getReceiver());
|
||||
processInfo.nextActivity = nextActivityInfo;
|
||||
}
|
||||
if (WorkFlowContants.ACTION_TYPE_LAUCH_PROCESS.equals(processInputModel
|
||||
.getWf_actionType())
|
||||
|| WorkFlowContants.ACTION_TYPE_EXECUTE_ACTIVITY
|
||||
.equals(processInputModel.getWf_actionType())) {
|
||||
try {
|
||||
processInfo.subProcInstIds = processInstanceService
|
||||
.getSubProcessInstanceIds(processInfo.getProcInstId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return processInfo;
|
||||
}
|
||||
|
||||
|
||||
public ActivityInstanceModel builderCurrentActivityInfo(ProcessInstance processInstance,Task task){
|
||||
TaskEntity currentTask=(TaskEntity) task;
|
||||
ActivityDefinitionModel defModel=null;
|
||||
try{
|
||||
defModel=processDefinitionService.getActivity(currentTask.getProcessDefinitionId(), currentTask.getTaskDefinitionKey());
|
||||
}catch(Exception e){
|
||||
//e.printStackTrace();
|
||||
defModel=new ActivityDefinitionModel();
|
||||
}
|
||||
ActivityInstanceModel activityInfo=ActivityInstanceModel.buildAndActDef(currentTask, defModel);
|
||||
return activityInfo;
|
||||
}
|
||||
|
||||
public List<ActivityInstanceModel> builderNextActivityInfo(String topProcessInstanceId,String assignee) {
|
||||
List<ActivityInstanceModel> activityInfos = new ArrayList<ActivityInstanceModel>();
|
||||
List<Task> nextTasks = null;
|
||||
try{nextTasks=processInstanceService.getProcessTasks(topProcessInstanceId, assignee,"");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (nextTasks == null||nextTasks.isEmpty())
|
||||
return activityInfos;
|
||||
for (Task tempNextTask : nextTasks) {
|
||||
TaskEntity nextTask = (TaskEntity) tempNextTask;
|
||||
ActivityInstanceModel activityInfo=ActivityInstanceModel.buildAndActDef(nextTask, processDefinitionService.getActivity(nextTask.getProcessDefinitionId(), nextTask.getTaskDefinitionKey()));
|
||||
activityInfos.add(activityInfo);
|
||||
}
|
||||
return activityInfos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.task.Comment;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
/**
|
||||
* 流程详细日志模型
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessLogModel {
|
||||
private String multiCommentMsg;
|
||||
private Comment comment;
|
||||
private HistoricTaskInstance historicTaskInstance;
|
||||
private String sendUserId;
|
||||
private String reiceiveUserId;
|
||||
private String sendUserName;
|
||||
private String reiceiveUserName;
|
||||
private String sendOrgId;
|
||||
private String receiveOrgId;
|
||||
private String sendOrgName;
|
||||
private String sendCompanyName;
|
||||
private String sendCompanyId;
|
||||
private String receiveOrgName;
|
||||
private String ownerName;
|
||||
private String finishState;
|
||||
|
||||
//用于组装给前端页面显示公司名称、部门、组织
|
||||
private String sendInfo;
|
||||
private String assigneeInfo;
|
||||
|
||||
|
||||
public String getSendCompanyId() {
|
||||
return sendCompanyId;
|
||||
}
|
||||
public void setSendCompanyId(String sendCompanyId) {
|
||||
this.sendCompanyId = sendCompanyId;
|
||||
}
|
||||
public Comment getComment() {
|
||||
return comment;
|
||||
}
|
||||
public void setComment(Comment comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
public HistoricTaskInstance getHistoricTaskInstance() {
|
||||
return historicTaskInstance;
|
||||
}
|
||||
public void setHistoricTaskInstance(HistoricTaskInstance historicTaskInstance) {
|
||||
this.historicTaskInstance = historicTaskInstance;
|
||||
}
|
||||
public String getSendUserName() {
|
||||
return sendUserName;
|
||||
}
|
||||
public void setSendUserName(String sendUserName) {
|
||||
this.sendUserName = sendUserName;
|
||||
}
|
||||
public String getReiceiveUserName() {
|
||||
return reiceiveUserName;
|
||||
}
|
||||
public void setReiceiveUserName(String reiceiveUserName) {
|
||||
this.reiceiveUserName = reiceiveUserName;
|
||||
}
|
||||
public String getSendUserId() {
|
||||
return sendUserId;
|
||||
}
|
||||
public void setSendUserId(String sendUserId) {
|
||||
this.sendUserId = sendUserId;
|
||||
}
|
||||
public String getReiceiveUserId() {
|
||||
return reiceiveUserId;
|
||||
}
|
||||
public void setReiceiveUserId(String reiceiveUserId) {
|
||||
this.reiceiveUserId = reiceiveUserId;
|
||||
}
|
||||
public String getSendOrgId() {
|
||||
return sendOrgId;
|
||||
}
|
||||
public void setSendOrgId(String sendOrgId) {
|
||||
this.sendOrgId = sendOrgId;
|
||||
}
|
||||
public String getReceiveOrgId() {
|
||||
return receiveOrgId;
|
||||
}
|
||||
public void setReceiveOrgId(String receiveOrgId) {
|
||||
this.receiveOrgId = receiveOrgId;
|
||||
}
|
||||
public String getSendOrgName() {
|
||||
return sendOrgName;
|
||||
}
|
||||
public void setSendOrgName(String sendOrgName) {
|
||||
this.sendOrgName = sendOrgName;
|
||||
}
|
||||
public String getReceiveOrgName() {
|
||||
return receiveOrgName;
|
||||
}
|
||||
public void setReceiveOrgName(String receiveOrgName) {
|
||||
this.receiveOrgName = receiveOrgName;
|
||||
}
|
||||
public String getFinishState() {
|
||||
return finishState;
|
||||
}
|
||||
public void setFinishState(String finishState) {
|
||||
this.finishState = finishState;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getOwnerName() {
|
||||
return ownerName;
|
||||
}
|
||||
public void setOwnerName(String ownerName) {
|
||||
this.ownerName = ownerName;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getMultiCommentMsg() {
|
||||
return multiCommentMsg;
|
||||
}
|
||||
public void setMultiCommentMsg(String multiCommentMsg) {
|
||||
this.multiCommentMsg = multiCommentMsg;
|
||||
}
|
||||
public String getSendCompanyName() {
|
||||
return sendCompanyName;
|
||||
}
|
||||
public void setSendCompanyName(String sendCompanyName) {
|
||||
this.sendCompanyName = sendCompanyName;
|
||||
}
|
||||
public String getSendInfo() {
|
||||
return sendInfo;
|
||||
}
|
||||
public void setSendInfo(String sendInfo) {
|
||||
this.sendInfo = sendInfo;
|
||||
}
|
||||
public String getAssigneeInfo() {
|
||||
return assigneeInfo;
|
||||
}
|
||||
public void setAssigneeInfo(String assigneeInfo) {
|
||||
this.assigneeInfo = assigneeInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
|
||||
/**
|
||||
* 流程管理数据全局共享
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessMgrDataShare {
|
||||
|
||||
static ThreadLocal<Object> processMgrDataThreadLocal = new ThreadLocal<Object>();
|
||||
|
||||
public static void setProcessMgrData(Object processMgrData) {
|
||||
clear();
|
||||
processMgrDataThreadLocal.set(processMgrData);
|
||||
}
|
||||
|
||||
public static Object getProcessMgrData() {
|
||||
return processMgrDataThreadLocal.get();
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
processMgrDataThreadLocal.set(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 流程上下文
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class ProcessPageContext {
|
||||
private String openPageType;
|
||||
private String actionType;
|
||||
private String workflowPage;
|
||||
private String userId;
|
||||
private String userOrgId;
|
||||
|
||||
|
||||
public ProcessPageContext(String openPageType, String actionType,
|
||||
String workflowPage, String userId, String userOrgId) {
|
||||
super();
|
||||
this.openPageType = openPageType;
|
||||
this.actionType = actionType;
|
||||
this.workflowPage = workflowPage;
|
||||
if(StringUtils.isEmpty(userId)){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"打开流程界面的userId不允许为空");
|
||||
}
|
||||
if(StringUtils.isEmpty(userOrgId)){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"打开流程界面的userOrgId不允许为空");
|
||||
}
|
||||
this.userId = userId;
|
||||
this.userOrgId = userOrgId;
|
||||
}
|
||||
public String getOpenPageType() {
|
||||
return openPageType;
|
||||
}
|
||||
public void setOpenPageType(String openPageType) {
|
||||
this.openPageType = openPageType;
|
||||
}
|
||||
public String getActionType() {
|
||||
return actionType;
|
||||
}
|
||||
public void setActionType(String actionType) {
|
||||
this.actionType = actionType;
|
||||
}
|
||||
public String getWorkflowPage() {
|
||||
return workflowPage;
|
||||
}
|
||||
public void setWorkflowPage(String workflowPage) {
|
||||
this.workflowPage = workflowPage;
|
||||
}
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public String getUserOrgId() {
|
||||
return userOrgId;
|
||||
}
|
||||
public void setUserOrgId(String userOrgId) {
|
||||
this.userOrgId = userOrgId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.blueland.bpm.common.page.PageRequest;
|
||||
import com.blueland.bpm.common.util.DateConvertUtils;
|
||||
/**
|
||||
* 流程查询对象
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class SearchProcessListDTO extends PageRequest{
|
||||
public static final String FORMAT_CREATE_TIME = "yyyy-MM-dd HH:mm:ss";
|
||||
private String title;
|
||||
private String processInstanceId;
|
||||
private String processDefId;
|
||||
private String processDefKey;
|
||||
private Integer procState;
|
||||
private String processDefName;
|
||||
private String flowType;
|
||||
private Date startTime;
|
||||
private Date endTime;
|
||||
private String tenantId;
|
||||
private String userId;
|
||||
private Map otherSearchMap=new HashMap();
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
public String getStartTimeString() {
|
||||
return DateConvertUtils.format(getStartTime(), FORMAT_CREATE_TIME);
|
||||
}
|
||||
public String getEndTimeString() {
|
||||
return DateConvertUtils.format(getEndTime(), FORMAT_CREATE_TIME);
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
public String getFlowType() {
|
||||
return flowType;
|
||||
}
|
||||
public void setFlowType(String flowType) {
|
||||
this.flowType = flowType;
|
||||
}
|
||||
public Map getOtherSearchMap() {
|
||||
return otherSearchMap;
|
||||
}
|
||||
public void setOtherSearchMap(Map otherSearchMap) {
|
||||
this.otherSearchMap = otherSearchMap;
|
||||
}
|
||||
public String getProcessInstanceId() {
|
||||
return processInstanceId;
|
||||
}
|
||||
public void setProcessInstanceId(String processInstanceId) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
}
|
||||
public String getProcessDefId() {
|
||||
return processDefId;
|
||||
}
|
||||
public void setProcessDefId(String processDefId) {
|
||||
this.processDefId = processDefId;
|
||||
}
|
||||
public String getProcessDefName() {
|
||||
return processDefName;
|
||||
}
|
||||
public void setProcessDefName(String processDefName) {
|
||||
this.processDefName = processDefName;
|
||||
}
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public String getProcessDefKey() {
|
||||
return processDefKey;
|
||||
}
|
||||
public void setProcessDefKey(String processDefKey) {
|
||||
this.processDefKey = processDefKey;
|
||||
}
|
||||
public Integer getProcState() {
|
||||
return procState;
|
||||
}
|
||||
public void setProcState(Integer procState) {
|
||||
this.procState = procState;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.blueland.bpm.engine.core.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.blueland.unitework.model.UniteworkTask;
|
||||
|
||||
/**
|
||||
* 流程待办任务数据全局共享
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class TaskEntityDataShare {
|
||||
protected static Logger logger = LoggerFactory.getLogger(TaskEntityDataShare.class);
|
||||
//当前线程流程待办共享池
|
||||
static final ThreadLocal<List<UniteworkTask>> taskEntityShareThreadLocal = new ThreadLocal<List<UniteworkTask>>();
|
||||
//当前线程流程待办共享池
|
||||
static final ThreadLocal<List<UniteworkTask>> hisTaskEntityShareThreadLocal = new ThreadLocal<List<UniteworkTask>>();
|
||||
|
||||
|
||||
/**
|
||||
* 返回当前线程中流程待办列表
|
||||
* @return
|
||||
*/
|
||||
public static List<UniteworkTask> getTask() {
|
||||
List<UniteworkTask> taskEntitys=getTaskEntitys();
|
||||
return taskEntitys;
|
||||
}
|
||||
/**
|
||||
* 返回当前线程中流程已办列表
|
||||
* @return
|
||||
*/
|
||||
public static List<UniteworkTask> getHisTask() {
|
||||
List<UniteworkTask> hisTaskEntitys=getHisTaskEntitys();
|
||||
return hisTaskEntitys;
|
||||
}
|
||||
public static void setTask(UniteworkTask taskEntity) {
|
||||
logger.info("set待办数据:"+taskEntity);
|
||||
getTaskEntitys().add(taskEntity);
|
||||
}
|
||||
|
||||
public static void setHisTask(UniteworkTask taskEntity) {
|
||||
logger.info("set已办数据:"+taskEntity);
|
||||
getHisTaskEntitys().add(taskEntity);
|
||||
}
|
||||
|
||||
|
||||
public static void clear() {
|
||||
if(getTaskEntitys()!=null){
|
||||
getTaskEntitys().clear();
|
||||
taskEntityShareThreadLocal.set(null);
|
||||
}
|
||||
if(getHisTaskEntitys()!=null){
|
||||
getHisTaskEntitys().clear();
|
||||
hisTaskEntityShareThreadLocal.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<UniteworkTask> getTaskEntitys() {
|
||||
List<UniteworkTask> taskEntitys=taskEntityShareThreadLocal.get();
|
||||
if(taskEntitys==null){
|
||||
taskEntitys=new CopyOnWriteArrayList<UniteworkTask>();
|
||||
taskEntityShareThreadLocal.set(taskEntitys);
|
||||
}
|
||||
return taskEntitys;
|
||||
}
|
||||
|
||||
private static List<UniteworkTask> getHisTaskEntitys() {
|
||||
List<UniteworkTask> hisTaskEntitys = hisTaskEntityShareThreadLocal
|
||||
.get();
|
||||
if (hisTaskEntitys == null) {
|
||||
hisTaskEntitys = new CopyOnWriteArrayList<UniteworkTask>();
|
||||
hisTaskEntityShareThreadLocal.set(hisTaskEntitys);
|
||||
}
|
||||
return hisTaskEntitys;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
public abstract class AbstractActivityOperatePower implements ActivityOperatePowerHandler {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import java.util.Map;
|
||||
/**
|
||||
* 流程操作权限处理接口
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public interface ActivityOperatePowerHandler {
|
||||
public boolean isActivityOperatePower(Map<String, Object> pageDetailVaribale);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessPageContext;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
/**
|
||||
* 补发多实例操作权限处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class AddMulltiActivityOperatePower extends AbstractActivityOperatePower {
|
||||
ProcessInstanceService processInstanceService = (ProcessInstanceService) ApplicationContextHolder
|
||||
.getBean("processInstanceServiceImpl");
|
||||
RepositoryServiceImpl repositoryService = (RepositoryServiceImpl) ApplicationContextHolder
|
||||
.getBean("repositoryService");
|
||||
|
||||
@Override
|
||||
public boolean isActivityOperatePower(Map<String, Object> pageDetailVaribale) {
|
||||
boolean isPower = false;
|
||||
ProcessPageContext context = (ProcessPageContext) pageDetailVaribale
|
||||
.get("processPageContext");
|
||||
ActivityInstanceModel curActivityInstance = (ActivityInstanceModel) pageDetailVaribale
|
||||
.get("task");
|
||||
HistoricProcessInstance processInstance = (HistoricProcessInstance) pageDetailVaribale
|
||||
.get("processInstance");
|
||||
if (context == null || curActivityInstance == null
|
||||
|| processInstance == null) {
|
||||
return isPower;
|
||||
}
|
||||
/*List<Task> tasks=processInstanceService.getProcessTasks(prevActivityInstance.getProcInstId(), prevActivityInstance.getReceiver(), prevActivityInstance.getActInstId());
|
||||
if(tasks==null||tasks.isEmpty()){
|
||||
return isPower;
|
||||
}*/
|
||||
//ActivityInstanceModel curActivityInstance=ActivityInstanceModel.buildAndActDef((TaskEntity)tasks.get(0),null);
|
||||
RepositoryServiceImpl repositoryServiceImpl = (org.activiti.engine.impl.RepositoryServiceImpl) repositoryService;
|
||||
ReadOnlyProcessDefinition rpd = repositoryServiceImpl
|
||||
.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
|
||||
ActivityImpl activity = (ActivityImpl) rpd
|
||||
.findActivity(curActivityInstance.getActDefId());
|
||||
System.out.println(activity.getParentActivity());
|
||||
boolean isDestActivityPower = ProcessDefinitionUtils
|
||||
.isSubProcessStartTask(activity)
|
||||
|| ProcessDefinitionUtils.isMultiInstance(activity)||ProcessDefinitionUtils.isSubProcessMultiInstance(activity);
|
||||
return (isDestActivityPower)||!curActivityInstance.getProcInstId().equals(curActivityInstance.getExecutionId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessPageContext;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
/**
|
||||
* 撤回操作权限处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class CallBackButActivityOperatePower extends AbstractActivityOperatePower {
|
||||
ProcessInstanceService processInstanceService = (ProcessInstanceService) ApplicationContextHolder
|
||||
.getBean("processInstanceServiceImpl");
|
||||
RepositoryServiceImpl repositoryService = (RepositoryServiceImpl) ApplicationContextHolder
|
||||
.getBean("repositoryService");
|
||||
|
||||
@Override
|
||||
public boolean isActivityOperatePower(Map<String, Object> pageDetailVaribale) {
|
||||
boolean isPower = false;
|
||||
ProcessPageContext context = (ProcessPageContext) pageDetailVaribale
|
||||
.get("processPageContext");
|
||||
ActivityInstanceModel prevActivityInstance = (ActivityInstanceModel) pageDetailVaribale
|
||||
.get("task");
|
||||
HistoricProcessInstance processInstance = (HistoricProcessInstance) pageDetailVaribale
|
||||
.get("processInstance");
|
||||
|
||||
if (context == null || prevActivityInstance == null
|
||||
|| processInstance == null) {
|
||||
return isPower;
|
||||
}
|
||||
List<Task> tasks=processInstanceService.getProcessTasks(prevActivityInstance.getProcInstId(), prevActivityInstance.getReceiver(), prevActivityInstance.getActInstId());
|
||||
if(tasks!=null&&tasks.size()!=1){
|
||||
return isPower;
|
||||
}
|
||||
ActivityInstanceModel curActivityInstance=ActivityInstanceModel.buildAndActDef((TaskEntity)tasks.get(0),null);
|
||||
boolean isClaimTask = processInstanceService
|
||||
.isClaimTask(curActivityInstance.getActInstId());
|
||||
if (isClaimTask
|
||||
|| !curActivityInstance.getSender().equals(context.getUserId())) {
|
||||
return isPower;
|
||||
}
|
||||
RepositoryServiceImpl repositoryServiceImpl = (org.activiti.engine.impl.RepositoryServiceImpl) repositoryService;
|
||||
ReadOnlyProcessDefinition rpd = repositoryServiceImpl
|
||||
.getDeployedProcessDefinition(curActivityInstance.getProcDefId());
|
||||
ActivityImpl activity = (ActivityImpl) rpd
|
||||
.findActivity(curActivityInstance.getActDefId());
|
||||
String destActivityType = (String) activity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
ActivityImpl prevActivity = (ActivityImpl) rpd
|
||||
.findActivity(curActivityInstance.getPrevActDefId());
|
||||
String prevActivityType = (String) prevActivity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
|
||||
boolean isDestActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartEvent(activity)
|
||||
|| ProcessDefinitionUtils.isSubProcessEndEvent(activity)
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, activity)
|
||||
|| ProcessDefinitionUtils.isMultiInstance(activity)
|
||||
|| ProcessDefinitionUtils.isEndEvent(activity)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(destActivityType) || BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(destActivityType));
|
||||
boolean isPrevActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartEvent(prevActivity)
|
||||
|| ProcessDefinitionUtils.isSubProcessEndEvent(prevActivity)
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, prevActivity)
|
||||
|| ProcessDefinitionUtils.isMultiInstance(prevActivity)
|
||||
|| ProcessDefinitionUtils.isEndEvent(prevActivity)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(prevActivityType)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(prevActivityType)
|
||||
|| BpmnXMLConstants.ELEMENT_TASK_SERVICE
|
||||
.equals(prevActivityType) || BpmnXMLConstants.ELEMENT_TASK_SCRIPT
|
||||
.equals(prevActivityType));
|
||||
if (prevActivityInstance != null
|
||||
&& !(prevActivityInstance.getExecutionId()
|
||||
.equals(curActivityInstance.getExecutionId()))) {
|
||||
isPrevActivityPower = false;
|
||||
}
|
||||
|
||||
return (isDestActivityPower && isPrevActivityPower);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
/**
|
||||
* 退回上一步操作权限处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class CallPrevButActivityOperatePower extends AbstractActivityOperatePower{
|
||||
ProcessInstanceService processInstanceService=(ProcessInstanceService) ApplicationContextHolder.getBean("processInstanceServiceImpl");
|
||||
RepositoryServiceImpl repositoryService=(RepositoryServiceImpl) ApplicationContextHolder.getBean("repositoryService");
|
||||
|
||||
@Override
|
||||
public boolean isActivityOperatePower(Map<String, Object> pageDetailVaribale) {
|
||||
ActivityInstanceModel activityInstance = (ActivityInstanceModel) pageDetailVaribale
|
||||
.get("task");
|
||||
HistoricProcessInstance processInstance = (HistoricProcessInstance) pageDetailVaribale
|
||||
.get("processInstance");
|
||||
boolean isDestActivityPower = false;
|
||||
if((activityInstance==null||processInstance==null)||StringUtils.isEmpty(activityInstance.getPrevActDefId())){
|
||||
return isDestActivityPower;
|
||||
}
|
||||
RepositoryServiceImpl repositoryServiceImpl = (org.activiti.engine.impl.RepositoryServiceImpl) repositoryService;
|
||||
ReadOnlyProcessDefinition rpd = repositoryServiceImpl
|
||||
.getDeployedProcessDefinition(activityInstance.getProcDefId());
|
||||
ActivityImpl activity = (ActivityImpl) rpd
|
||||
.findActivity(activityInstance.getActivityDefinition()
|
||||
.getActDefId());
|
||||
String destActivityType = (String) activity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
isDestActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartEvent(activity)
|
||||
|| ProcessDefinitionUtils.isSubProcessEndEvent(activity)
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, activity)
|
||||
|| ProcessDefinitionUtils.isMultiInstance(activity)
|
||||
|| ProcessDefinitionUtils.isEndEvent(activity)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(destActivityType) || BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(destActivityType));
|
||||
boolean isPrevActivityPower = false;
|
||||
if (isDestActivityPower) {
|
||||
ActivityImpl prevActivity = (ActivityImpl) rpd
|
||||
.findActivity(activityInstance.getPrevActDefId());
|
||||
if(prevActivity==null){
|
||||
return isPrevActivityPower;
|
||||
}
|
||||
String prevActivityType = (String) prevActivity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
|
||||
isPrevActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartEvent(prevActivity)
|
||||
|| ProcessDefinitionUtils
|
||||
.isSubProcessEndEvent(prevActivity)
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, prevActivity)
|
||||
|| ProcessDefinitionUtils.isMultiInstance(prevActivity)
|
||||
|| ProcessDefinitionUtils.isEndEvent(prevActivity)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(prevActivityType)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(prevActivityType)
|
||||
|| BpmnXMLConstants.ELEMENT_TASK_SERVICE
|
||||
.equals(prevActivityType) || BpmnXMLConstants.ELEMENT_TASK_SCRIPT
|
||||
.equals(prevActivityType));
|
||||
if (isPrevActivityPower) {
|
||||
ActivityInstanceModel prevActivityInstance = null;
|
||||
try {
|
||||
prevActivityInstance = processInstanceService
|
||||
.getHistoryTask(activityInstance.getPrevActInstId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
if(prevActivityInstance==null){
|
||||
return false;
|
||||
}else if(!prevActivityInstance.getExecutionId()
|
||||
.equals(activityInstance.getExecutionId())) {
|
||||
isPrevActivityPower = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isPrevActivityPower;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.pvm.PvmActivity;
|
||||
import org.activiti.engine.impl.pvm.PvmTransition;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
/**
|
||||
* 退回拟稿环节操作权限处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class CallStartButActivityOperatePower extends AbstractActivityOperatePower{
|
||||
ProcessInstanceService processInstanceService=(ProcessInstanceService) ApplicationContextHolder.getBean("processInstanceServiceImpl");
|
||||
RepositoryServiceImpl repositoryService=(RepositoryServiceImpl) ApplicationContextHolder.getBean("repositoryService");
|
||||
|
||||
@Override
|
||||
public boolean isActivityOperatePower(Map<String, Object> pageDetailVaribale) {
|
||||
boolean isDestActivityPower = false;
|
||||
ActivityInstanceModel activityInstance = (ActivityInstanceModel) pageDetailVaribale
|
||||
.get("task");
|
||||
HistoricProcessInstance processInstance = (HistoricProcessInstance) pageDetailVaribale
|
||||
.get("processInstance");
|
||||
if(activityInstance==null||processInstance==null){
|
||||
return isDestActivityPower;
|
||||
}
|
||||
RepositoryServiceImpl repositoryServiceImpl = (org.activiti.engine.impl.RepositoryServiceImpl) repositoryService;
|
||||
ReadOnlyProcessDefinition rpd = repositoryServiceImpl
|
||||
.getDeployedProcessDefinition(activityInstance.getProcDefId());
|
||||
PvmActivity pvmActivity = rpd.getInitial();
|
||||
PvmTransition pvmTransition = pvmActivity.getOutgoingTransitions().get(
|
||||
0);
|
||||
PvmActivity pvmStartActivity = pvmTransition.getDestination();
|
||||
if(activityInstance.getActDefId().equals(pvmStartActivity.getId())){
|
||||
return isDestActivityPower;
|
||||
}
|
||||
ActivityImpl activity = (ActivityImpl) rpd
|
||||
.findActivity(activityInstance.getActivityDefinition()
|
||||
.getActDefId());
|
||||
if(activity==null){
|
||||
return isDestActivityPower;
|
||||
}
|
||||
String destActivityType = (String) activity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
|
||||
if(!activityInstance.getExecutionId().equals(processInstance.getId())){
|
||||
isDestActivityPower=false;
|
||||
}else{
|
||||
isDestActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartTask(activity)
|
||||
|| ProcessDefinitionUtils.isSubProcessEndEvent(activity)
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, activity)
|
||||
|| ProcessDefinitionUtils.isMultiInstance(activity)
|
||||
|| ProcessDefinitionUtils.isEndEvent(activity)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(destActivityType) || BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(destActivityType));
|
||||
}
|
||||
return (isDestActivityPower);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
/**
|
||||
* 作废流程操作权限处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class CancelButActivityOperatePower extends AbstractActivityOperatePower{
|
||||
ProcessInstanceService processInstanceService=(ProcessInstanceService) ApplicationContextHolder.getBean("processInstanceServiceImpl");
|
||||
RepositoryServiceImpl repositoryService=(RepositoryServiceImpl) ApplicationContextHolder.getBean("repositoryService");
|
||||
|
||||
@Override
|
||||
public boolean isActivityOperatePower(Map<String, Object> pageDetailVaribale) {
|
||||
ActivityInstanceModel activityInstance = (ActivityInstanceModel) pageDetailVaribale
|
||||
.get("task");
|
||||
HistoricProcessInstance processInstance = (HistoricProcessInstance) pageDetailVaribale
|
||||
.get("processInstance");
|
||||
RepositoryServiceImpl repositoryServiceImpl = (org.activiti.engine.impl.RepositoryServiceImpl) repositoryService;
|
||||
ReadOnlyProcessDefinition rpd = repositoryServiceImpl
|
||||
.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
|
||||
ActivityImpl activity = (ActivityImpl) rpd
|
||||
.findActivity(activityInstance.getActDefId()!=null?activityInstance.getActDefId():activityInstance.getActivityDefinition()
|
||||
.getActDefId());
|
||||
String destActivityType = (String) activity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
boolean isDestActivityPower = false;
|
||||
if(activityInstance.getExecutionId().equals(processInstance.getTopProcessInstanceId())&&!ProcessDefinitionUtils.isMultiInstance(activity)&&!ProcessDefinitionUtils.isExclusiveGateway(activity)){
|
||||
isDestActivityPower=true;
|
||||
}/*else{
|
||||
isDestActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartEvent(activity)
|
||||
|| ProcessDefinitionUtils.isSubProcessEndEvent(activity)
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, activity)
|
||||
|| ProcessDefinitionUtils.isEndEvent(activity)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(destActivityType));
|
||||
}*/
|
||||
return (isDestActivityPower);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
import com.blueland.bpm.common.util.ApplicationContextHolder;
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessPageContext;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
/**
|
||||
* 撤销多实例操作权限处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class DeleteMulltiActivityOperatePower extends AbstractActivityOperatePower {
|
||||
ProcessInstanceService processInstanceService = (ProcessInstanceService) ApplicationContextHolder
|
||||
.getBean("processInstanceServiceImpl");
|
||||
RepositoryServiceImpl repositoryService = (RepositoryServiceImpl) ApplicationContextHolder
|
||||
.getBean("repositoryService");
|
||||
|
||||
@Override
|
||||
public boolean isActivityOperatePower(Map<String, Object> pageDetailVaribale) {
|
||||
boolean isPower = false;
|
||||
ProcessPageContext context = (ProcessPageContext) pageDetailVaribale
|
||||
.get("processPageContext");
|
||||
ActivityInstanceModel curActivityInstance = (ActivityInstanceModel) pageDetailVaribale
|
||||
.get("task");
|
||||
HistoricProcessInstance processInstance = (HistoricProcessInstance) pageDetailVaribale
|
||||
.get("processInstance");
|
||||
if (context == null || curActivityInstance == null
|
||||
|| processInstance == null) {
|
||||
return isPower;
|
||||
}
|
||||
/*List<Task> tasks=processInstanceService.getProcessTasks(prevActivityInstance.getProcInstId(), prevActivityInstance.getReceiver(), prevActivityInstance.getActInstId());
|
||||
if(tasks==null||tasks.isEmpty()){
|
||||
return isPower;
|
||||
}*/
|
||||
RepositoryServiceImpl repositoryServiceImpl = (org.activiti.engine.impl.RepositoryServiceImpl) repositoryService;
|
||||
ReadOnlyProcessDefinition rpd = repositoryServiceImpl
|
||||
.getDeployedProcessDefinition(curActivityInstance.getProcDefId());
|
||||
ActivityImpl activity = (ActivityImpl) rpd
|
||||
.findActivity(curActivityInstance.getActDefId());
|
||||
|
||||
boolean isDestActivityPower = ProcessDefinitionUtils
|
||||
.isSubProcessStartTask(activity)
|
||||
|| ProcessDefinitionUtils.isMultiInstance(activity)||ProcessDefinitionUtils.isSubProcessMultiInstance(activity);
|
||||
return (isDestActivityPower)||!curActivityInstance.getProcInstId().equals(curActivityInstance.getExecutionId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.blueland.bpm.engine.core.power;
|
||||
|
||||
import org.activiti.bpmn.constants.BpmnXMLConstants;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.core.service.ProcessInstanceService;
|
||||
import com.blueland.bpm.engine.util.ProcessDefinitionUtils;
|
||||
/**
|
||||
* 驳回至历史环节操作权限处理类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class RejectButActivityOperatePower{
|
||||
@Autowired
|
||||
ProcessInstanceService processInstanceService;
|
||||
@Autowired
|
||||
RepositoryServiceImpl repositoryService;
|
||||
|
||||
/**
|
||||
* 判断curActivityInstance当前节点是否允许驳回
|
||||
* @param processInstance
|
||||
* @param curActivityInstance
|
||||
* @param rpd
|
||||
* @return
|
||||
*/
|
||||
public boolean isCurActivityInstanceRejectPower(ProcessInstanceModel processInstance,ActivityInstanceModel curActivityInstance,ReadOnlyProcessDefinition rpd ) {
|
||||
boolean isDestActivityPower = false;
|
||||
if (curActivityInstance == null) {
|
||||
return isDestActivityPower;
|
||||
}
|
||||
ActivityImpl activity = (ActivityImpl) rpd
|
||||
.findActivity(curActivityInstance.getActDefId());
|
||||
String destActivityType = (String) activity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
isDestActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartEvent(activity)//是否内嵌子流开始节点
|
||||
|| ProcessDefinitionUtils.isSubProcessEndEvent(activity)//是否内嵌子流结束节点
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, activity)//是否外部子流结束节点
|
||||
|| ProcessDefinitionUtils.isMultiInstance(activity)//是否多实例节点
|
||||
|| ProcessDefinitionUtils.isEndEvent(activity)//是否流程结束节点点
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(destActivityType) || BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(destActivityType));//是否并行网关、包容网关
|
||||
return isDestActivityPower;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断historicTaskInstance历史节点是否允许驳回
|
||||
* @param processInstance
|
||||
* @param curActivityInstance
|
||||
* @param historicTaskInstance
|
||||
* @param rpd
|
||||
* @return
|
||||
*/
|
||||
public boolean isHisActivityInstanceRejectPower(ProcessInstanceModel processInstance,
|
||||
ActivityInstanceModel curActivityInstance,
|
||||
HistoricTaskInstance historicTaskInstance,ReadOnlyProcessDefinition rpd) {
|
||||
boolean isHisActivityPower = false;
|
||||
if (historicTaskInstance == null) {
|
||||
return isHisActivityPower;
|
||||
}
|
||||
ActivityImpl hisActivity = (ActivityImpl) rpd
|
||||
.findActivity(historicTaskInstance.getTaskDefinitionKey());
|
||||
if (hisActivity == null) {
|
||||
return isHisActivityPower;
|
||||
}
|
||||
String hisActivityType = (String) hisActivity
|
||||
.getProperty(BpmnXMLConstants.ATTRIBUTE_TYPE);
|
||||
isHisActivityPower = !(ProcessDefinitionUtils
|
||||
.isSubProcessStartEvent(hisActivity)//是否内嵌子流开始节点
|
||||
|| ProcessDefinitionUtils.isSubProcessEndEvent(hisActivity)//是否内嵌子流结束节点
|
||||
|| ProcessDefinitionUtils.isCallSubProcessEndEvent(
|
||||
processInstance, hisActivity)//是否外部子流结束节点
|
||||
|| ProcessDefinitionUtils.isMultiInstance(hisActivity)//是否多实例节点
|
||||
|| ProcessDefinitionUtils.isEndEvent(hisActivity)//是否流程结束节点点
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL
|
||||
.equals(hisActivityType)
|
||||
|| BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE
|
||||
.equals(hisActivityType)
|
||||
|| BpmnXMLConstants.ELEMENT_TASK_SERVICE
|
||||
.equals(hisActivityType) || BpmnXMLConstants.ELEMENT_TASK_SCRIPT
|
||||
.equals(hisActivityType));//是否并行网关、包容网关、服务任务、脚本任务
|
||||
if (isHisActivityPower) {
|
||||
//判断当前任务与待驳回的任务执行路径是否一致
|
||||
if (!(historicTaskInstance.getExecutionId()
|
||||
.equals(curActivityInstance.getExecutionId()))) {
|
||||
isHisActivityPower = false;
|
||||
}
|
||||
}
|
||||
|
||||
return isHisActivityPower;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.blueland.bpm.engine.core.script;
|
||||
|
||||
import groovy.lang.Binding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* groovy绑定类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public class GroovyBinding extends Binding
|
||||
{
|
||||
private Map variables;
|
||||
private static ThreadLocal localVars = new ThreadLocal();
|
||||
private static Map propertyMap = new HashMap();
|
||||
public GroovyBinding()
|
||||
{
|
||||
}
|
||||
|
||||
public GroovyBinding(Map variables)
|
||||
{
|
||||
localVars.set(variables);
|
||||
}
|
||||
|
||||
public GroovyBinding(String args[])
|
||||
{
|
||||
this();
|
||||
setVariable("args", args);
|
||||
}
|
||||
|
||||
public Object getVariable(String name)
|
||||
{
|
||||
Map map = (Map)localVars.get();
|
||||
Object result = null;
|
||||
if(map != null && map.containsKey(name))
|
||||
result = map.get(name);
|
||||
else
|
||||
result = propertyMap.get(name);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setVariable(String name, Object value)
|
||||
{
|
||||
if(localVars.get() == null)
|
||||
{
|
||||
Map vars = new LinkedHashMap();
|
||||
vars.put(name, value);
|
||||
localVars.set(vars);
|
||||
} else
|
||||
{
|
||||
((Map)localVars.get()).put(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Map getVariables()
|
||||
{
|
||||
if(localVars.get() == null)
|
||||
return new LinkedHashMap();
|
||||
else
|
||||
return (Map)localVars.get();
|
||||
}
|
||||
|
||||
public void clearVariables()
|
||||
{
|
||||
localVars.remove();
|
||||
}
|
||||
|
||||
public Object getProperty(String property)
|
||||
{
|
||||
return propertyMap.get(property);
|
||||
}
|
||||
|
||||
public void setProperty(String property, Object newValue)
|
||||
{
|
||||
propertyMap.put(property, newValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.FormService;
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.IdentityService;
|
||||
import org.activiti.engine.ManagementService;
|
||||
import org.activiti.engine.ProcessEngineConfiguration;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.StringUtils;
|
||||
import com.blueland.bpm.engine.core.handler.BizProcessHandler;
|
||||
import com.blueland.bpm.engine.core.model.ExceptionErrorCode;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
import com.blueland.bpm.log.model.ProcessErrorLog;
|
||||
|
||||
/**
|
||||
* 获取Activiti5相关Service的辅助类
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class AbstractServiceHelper implements ActivitiService{
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Autowired
|
||||
protected RepositoryService repositoryService;
|
||||
@Autowired
|
||||
protected RuntimeService runtimeService;
|
||||
@Autowired
|
||||
protected HistoryService historyService;
|
||||
@Autowired
|
||||
protected IdentityService identityService;
|
||||
@Autowired
|
||||
protected TaskService taskService;
|
||||
@Autowired
|
||||
protected FormService formService;
|
||||
@Autowired
|
||||
protected ManagementService managementService;
|
||||
@Autowired
|
||||
protected ProcessEngineConfiguration processEngineConfiguration;
|
||||
@Autowired
|
||||
protected BizProcessHandlerFactory bussinessProcessHandlerFactory;
|
||||
public RepositoryService getRepositoryService() {
|
||||
return repositoryService;
|
||||
}
|
||||
|
||||
public void setRepositoryService(RepositoryService repositoryService) {
|
||||
this.repositoryService = repositoryService;
|
||||
}
|
||||
|
||||
public RuntimeService getRuntimeService() {
|
||||
return runtimeService;
|
||||
}
|
||||
|
||||
public void setRuntimeService(RuntimeService runtimeService) {
|
||||
this.runtimeService = runtimeService;
|
||||
}
|
||||
|
||||
public HistoryService getHistoryService() {
|
||||
return historyService;
|
||||
}
|
||||
|
||||
public void setHistoryService(HistoryService historyService) {
|
||||
this.historyService = historyService;
|
||||
}
|
||||
|
||||
public IdentityService getIdentityService() {
|
||||
return identityService;
|
||||
}
|
||||
|
||||
public void setIdentityService(IdentityService identityService) {
|
||||
this.identityService = identityService;
|
||||
}
|
||||
|
||||
public TaskService getTaskService() {
|
||||
return taskService;
|
||||
}
|
||||
|
||||
public void setTaskService(TaskService taskService) {
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
public FormService getFormService() {
|
||||
return formService;
|
||||
}
|
||||
|
||||
public void setFormService(FormService formService) {
|
||||
this.formService = formService;
|
||||
}
|
||||
|
||||
public ManagementService getManagementService() {
|
||||
return managementService;
|
||||
}
|
||||
|
||||
public void setManagementService(ManagementService managementService) {
|
||||
this.managementService = managementService;
|
||||
}
|
||||
|
||||
public ProcessEngineConfiguration getProcessEngineConfiguration() {
|
||||
return processEngineConfiguration;
|
||||
}
|
||||
|
||||
public void setProcessEngineConfiguration(
|
||||
ProcessEngineConfiguration processEngineConfiguration) {
|
||||
this.processEngineConfiguration = processEngineConfiguration;
|
||||
}
|
||||
|
||||
public BizProcessHandler getBussinessProcessHandler(String processDefinitionId){
|
||||
BizProcessHandler handler=null;
|
||||
try{
|
||||
handler=bussinessProcessHandlerFactory.buildBussinessProcessHandler(processDefinitionId);
|
||||
}catch(Exception e){
|
||||
logger.error("", e);
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据流程定义ID获取流程定义对象
|
||||
* @param procDefId
|
||||
* @return
|
||||
*/
|
||||
public ProcessDefinition getProcessDefinition(String procDefId) {
|
||||
if(procDefId==null){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"procDefId is null");
|
||||
}
|
||||
ProcessDefinition processDefinition=null;
|
||||
try{
|
||||
processDefinition=this.repositoryService.getProcessDefinition(procDefId);
|
||||
}catch(Exception e){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2002,"当前流程定义未找到!procDefId:"+procDefId,e);
|
||||
}
|
||||
if (processDefinition == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2002,"当前流程定义未找到!procDefId:"+procDefId);
|
||||
}
|
||||
return processDefinition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据流程定义ID获取流程定义对象
|
||||
* @param procDefId
|
||||
* @return
|
||||
*/
|
||||
public ReadOnlyProcessDefinition getDeployedProcessDefinition(String procDefId) {
|
||||
if(procDefId==null){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"procDefId is null");
|
||||
}
|
||||
RepositoryServiceImpl repositoryServiceImpl = (org.activiti.engine.impl.RepositoryServiceImpl) repositoryService;
|
||||
ReadOnlyProcessDefinition rpd=null;
|
||||
try{
|
||||
rpd = repositoryServiceImpl
|
||||
.getDeployedProcessDefinition(procDefId);
|
||||
|
||||
}catch(Exception e){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2002,"当前流程定义未找到!procDefId:"+procDefId,e);
|
||||
}
|
||||
return rpd;
|
||||
}
|
||||
/**
|
||||
* 根据流程实例ID获取流程程实例对象
|
||||
* @param procDefId
|
||||
* @return
|
||||
*/
|
||||
public ProcessInstance getProcessInstance(String procInstId) {
|
||||
if(procInstId==null){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"procInstId is null");
|
||||
}
|
||||
ProcessInstance processInstance = runtimeService
|
||||
.createProcessInstanceQuery()
|
||||
.processInstanceId(procInstId)
|
||||
.active().singleResult();
|
||||
if (processInstance == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2051,"当前流程实例未找到!procInstId:"+procInstId);
|
||||
}
|
||||
return processInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程实例ID获取流程程实例对象
|
||||
* @param procDefId
|
||||
* @return
|
||||
*/
|
||||
public ProcessInstance getProcessInstance(ProcessInputModel processInputModel) {
|
||||
String procInstId=processInputModel.getWf_procInstId();
|
||||
if(procInstId==null){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"procInstId is null,processInputModel:"+processInputModel);
|
||||
}
|
||||
ProcessInstance processInstance = runtimeService
|
||||
.createProcessInstanceQuery()
|
||||
.processInstanceId(procInstId)
|
||||
.active().singleResult();
|
||||
if (processInstance == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2051,"当前流程实例未找到!procInstId:"+procInstId);
|
||||
}
|
||||
return processInstance;
|
||||
}
|
||||
/**
|
||||
* 根据任务ID获得任务实例
|
||||
*
|
||||
* @param taskId
|
||||
* 任务ID
|
||||
* @return
|
||||
* @
|
||||
*/
|
||||
public TaskEntity findTaskById(String taskId) {
|
||||
if(taskId==null){
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2001,"taskId is null");
|
||||
}
|
||||
TaskEntity task = (TaskEntity) taskService.createTaskQuery()
|
||||
.taskId(taskId).singleResult();
|
||||
if (task == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2052,"当前待办任务未找到!taskId:"+taskId);
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务审批人和流程实例ID获得任务实例
|
||||
*
|
||||
* @param taskId
|
||||
* 任务ID
|
||||
* @return
|
||||
* @
|
||||
*/
|
||||
public TaskEntity findTaskByAssignee(String procInstId,String assignee) {
|
||||
TaskEntity task = (TaskEntity) taskService.createTaskQuery()
|
||||
.processInstanceId(procInstId)
|
||||
.taskAssignee(assignee).singleResult();
|
||||
if (task == null) {
|
||||
throw new WorkFlowException(ExceptionErrorCode.B2052,"当前待办任务未找到!procInstId:"+procInstId+",assignee:"+assignee);
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param taskId
|
||||
* 当前任务ID
|
||||
*
|
||||
* @param activityId
|
||||
* 流程转向执行任务节点ID<br>
|
||||
* 此参数为空,默认为提交操作
|
||||
* @param variables
|
||||
* 流程变量
|
||||
* @
|
||||
*/
|
||||
public void commitProcess(String taskId,String activityId, Map<String, Object> variables) {
|
||||
if (variables == null) {
|
||||
variables = new HashMap<String, Object>();
|
||||
}
|
||||
taskService.complete(taskId, activityId,variables);
|
||||
}
|
||||
|
||||
public static ProcessErrorLog buildProcessErrorLog(
|
||||
ProcessInputModel processInputModel, String errorMsg, String jsonMsg) {
|
||||
ProcessErrorLog processErrorLog = new ProcessErrorLog(
|
||||
StringUtils.isEmpty(processInputModel.getWf_procInstId()) ? processInputModel.getWf_curActDefId()
|
||||
: processInputModel.getWf_procInstId(),
|
||||
processInputModel.getWf_procTitle(),
|
||||
processInputModel.getWf_sendUserId() == null ? processInputModel
|
||||
.getWf_sender() : processInputModel.getWf_sendUserId(),
|
||||
processInputModel.getWf_actionType(), errorMsg, jsonMsg);
|
||||
processErrorLog.setAppId(processInputModel.getWf_appId());
|
||||
if (processInputModel.getWf_receivers() != null
|
||||
&& !processInputModel.getWf_receivers().isEmpty()) {
|
||||
processErrorLog.setReceivers(processInputModel.getWf_receivers()
|
||||
.toString());
|
||||
} else {
|
||||
processErrorLog.setReceivers(processInputModel.getWf_receiver());
|
||||
}
|
||||
processErrorLog.setProcessLogLevel("error");
|
||||
//processErrorLog.setDataSource(StringUtils.isEmpty(processInputModel.getWf_data_source())?ProcessErrorLog.DATA_SOURCE_REST:ProcessErrorLog.DATA_SOURCE_MANAGER);
|
||||
processErrorLog
|
||||
.setProcessDefName(processInputModel.getWf_procDefName());
|
||||
return processErrorLog;
|
||||
}
|
||||
|
||||
public static ProcessErrorLog buildProcessInfoLog(
|
||||
ProcessInstanceModel processInstanceModel, String jsonMsg) {
|
||||
ProcessInputModel processInputModel=processInstanceModel.getProcessInputModel();
|
||||
ProcessErrorLog processErrorLog = new ProcessErrorLog(
|
||||
StringUtils.isEmpty(processInstanceModel.getTopProcInstId()) ? processInputModel.getWf_procInstId()
|
||||
: processInstanceModel.getTopProcInstId(),
|
||||
processInputModel.getWf_procTitle(),
|
||||
processInputModel.getWf_sendUserId()==null?processInputModel.getWf_sender():processInputModel.getWf_sendUserId(),
|
||||
processInputModel.getWf_actionType(), "", jsonMsg);
|
||||
processErrorLog.setAppId(processInputModel.getWf_appId());
|
||||
if(processInputModel.getWf_receivers()!=null&&!processInputModel.getWf_receivers().isEmpty()){
|
||||
processErrorLog.setReceivers(processInputModel.getWf_receivers().toString());
|
||||
}else{
|
||||
processErrorLog.setReceivers(processInputModel.getWf_receiver());
|
||||
}
|
||||
//processErrorLog.setDataSource(StringUtils.isEmpty(processInputModel.getWf_data_source())?ProcessErrorLog.DATA_SOURCE_REST:ProcessErrorLog.DATA_SOURCE_MANAGER);
|
||||
processErrorLog.setProcessLogLevel("info");
|
||||
processErrorLog
|
||||
.setProcessDefName(processInputModel.getWf_procDefName());
|
||||
return processErrorLog;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import org.activiti.engine.FormService;
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.IdentityService;
|
||||
import org.activiti.engine.ManagementService;
|
||||
import org.activiti.engine.ProcessEngineConfiguration;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
|
||||
/**
|
||||
* 获取Activiti5相关Service的辅助类
|
||||
*
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public interface ActivitiService {
|
||||
|
||||
RepositoryService getRepositoryService();
|
||||
|
||||
RuntimeService getRuntimeService();
|
||||
|
||||
HistoryService getHistoryService();
|
||||
|
||||
IdentityService getIdentityService();
|
||||
|
||||
TaskService getTaskService();
|
||||
|
||||
FormService getFormService();
|
||||
|
||||
ManagementService getManagementService();
|
||||
|
||||
ProcessEngineConfiguration getProcessEngineConfiguration();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.config.model.ActivityRule;
|
||||
import com.blueland.bpm.engine.config.service.ActivityRuleManager;
|
||||
@Service
|
||||
public class ActivityRuleService {
|
||||
@Autowired
|
||||
GroovyScriptEngine groovyScriptEngine;
|
||||
@Autowired
|
||||
ActivityRuleManager activityRuleManager;
|
||||
public boolean isFilterActivityByRule(String procDefId,String sourceActId,String targetActId,Map vars,String ruleType){
|
||||
ActivityRule activityRule=activityRuleManager.getActivityRule(procDefId,sourceActId,targetActId,ruleType);
|
||||
if(activityRule==null){
|
||||
return false;
|
||||
}
|
||||
String ruleScript=activityRule.getRuleScript();
|
||||
return groovyScriptEngine.executeBoolean(ruleScript, vars);
|
||||
}
|
||||
public Object validateActivityRule(String procDefId,String sourceActId,String targetActId,Map vars,String ruleType){
|
||||
ActivityRule activityRule=activityRuleManager.getActivityRule(procDefId,sourceActId,targetActId,ruleType);
|
||||
String ruleScript=activityRule.getRuleScript();
|
||||
return groovyScriptEngine.executeObject(ruleScript, vars);
|
||||
}
|
||||
|
||||
public Object validateActivityRule(String ruleScript){
|
||||
if(StringUtils.isEmpty(ruleScript)){
|
||||
return null;
|
||||
}
|
||||
return groovyScriptEngine.executeObject(ruleScript, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.common.util.DateUtil;
|
||||
import com.blueland.bpm.engine.core.model.ActivityDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.model.ActivityInstanceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessInstanceModel;
|
||||
import com.blueland.bpm.engine.util.JsonUtil;
|
||||
import com.blueland.bpm.engine.util.WorkFlowContants;
|
||||
import com.blueland.bpm.log.model.ProcessErrorLog;
|
||||
import com.blueland.bpm.log.service.ProcessErrorLogManager;
|
||||
/**
|
||||
* 流程自动运行Service
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class AutoRunOneProcess extends AbstractServiceHelper {
|
||||
@Autowired
|
||||
ProcessDefinitionService processDefinitionService;
|
||||
@Autowired
|
||||
private ProcessErrorLogManager processErrorLogManager;
|
||||
@Autowired
|
||||
ProcessExecuteServiceFacde processExecuteService;
|
||||
@Autowired
|
||||
ProcessInstanceService processInstanceService;
|
||||
// test_pt普通流程,test_expall 测试条件网关,testparentflow,测试父子流程,testParallelGateway:测试并行网关啊,test_neiqiansubflow内嵌子流程
|
||||
String procDefKey = "test_neiqiansubflow";
|
||||
String procTitle = "测试" + procDefKey;
|
||||
String procStartUserId = "1001220126000600001";
|
||||
String appId = "DEMO_SYS";
|
||||
|
||||
public ProcessInstanceModel autoRunOneProcess(String procDefKey,String procStartUserId,String appId) {
|
||||
this.procDefKey = procDefKey;
|
||||
this.procStartUserId = procStartUserId;
|
||||
this.appId = appId;
|
||||
this.procTitle = "自动化模拟测试流程:" + procDefKey+DateUtil.convertDateToString("yyyyMMdd-HH:mm:ss", new Date());
|
||||
ProcessInputModel processInputModel = buildProcessInputModel();
|
||||
processInputModel.setWf_curComment("意见:"+processInputModel.getWf_curActDefName()+":"+new java.util.Random().nextInt());
|
||||
Map<String, Object> resultData = processExecuteService
|
||||
.nextExecute(processInputModel);
|
||||
ProcessInstanceModel processInstanceModel = (ProcessInstanceModel) resultData
|
||||
.get("processInstanceModel");
|
||||
next(resultData,new HashMap<String,ActivityInstanceModel>());
|
||||
return processInstanceModel;
|
||||
}
|
||||
|
||||
|
||||
public ProcessInstanceModel autoRunByLog(String procInstId) {
|
||||
ProcessErrorLog params=new ProcessErrorLog();
|
||||
params.setProcessInstanceId(procInstId);
|
||||
params.setProcessLogLevel("info");
|
||||
params.setSortColumns(" PELOG_CREATE_TIME");
|
||||
List<ProcessErrorLog> processErrorLogs=processErrorLogManager.findByExample(params);
|
||||
ProcessInstanceModel curtProcessInstanceModel =null;
|
||||
for (ProcessErrorLog processErrorLog : processErrorLogs) {
|
||||
ProcessInputModel processInputModel=(ProcessInputModel) JsonUtil.convertToBean(processErrorLog.getProcessMsg(), ProcessInputModel.class);
|
||||
if(!processErrorLog.getActionType().equals("lauch_save_process")) {
|
||||
processInputModel.setWf_procInstId(curtProcessInstanceModel.getProcInstId());
|
||||
List<ActivityInstanceModel> nextActivitys=curtProcessInstanceModel.getNextActivity();
|
||||
ActivityInstanceModel curActivityInstanceModel=null;
|
||||
for (ActivityInstanceModel activityInstanceModel : nextActivitys) {
|
||||
if(activityInstanceModel.getActDefId().equals(processInputModel.getWf_curActDefId())&&activityInstanceModel.getReceiverUserId().equals(processInputModel.getWf_sendUserId())){
|
||||
curActivityInstanceModel=activityInstanceModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
processInputModel.setWf_curActInstId(curActivityInstanceModel.getActInstId());
|
||||
}
|
||||
Map<String, Object> resultData = processExecuteService
|
||||
.nextExecute(processInputModel);
|
||||
curtProcessInstanceModel = (ProcessInstanceModel) resultData
|
||||
.get("processInstanceModel");
|
||||
|
||||
}
|
||||
return curtProcessInstanceModel;
|
||||
}
|
||||
|
||||
public void next(Map<String, Object> resultData,Map<String,ActivityInstanceModel> taskIds) {
|
||||
ProcessInstanceModel processInstanceModel = (ProcessInstanceModel) resultData
|
||||
.get("processInstanceModel");
|
||||
if(processInstanceModel==null){
|
||||
return;
|
||||
}
|
||||
List<ActivityInstanceModel> nextActInsts = processInstanceService.getTopProcessAllTasks(processInstanceModel.getTopProcInstId());
|
||||
if(nextActInsts==null||nextActInsts.isEmpty()){
|
||||
return;
|
||||
}
|
||||
for (ActivityInstanceModel nextActInst : nextActInsts) {
|
||||
/* if(taskIds.containsKey(nextActInst.getActInstId())){
|
||||
continue;
|
||||
}*/
|
||||
try{
|
||||
if(processInstanceService.getTask(nextActInst.getActInstId())==null){
|
||||
return;
|
||||
}
|
||||
}catch(Exception e){return;}
|
||||
ProcessInputModel processInputModel = buildProcessInputModel();
|
||||
List<ActivityDefinitionModel> activityDefinitionModels=processDefinitionService.getNextActivity(nextActInst.getProcInstId(), nextActInst.getProcDefId(), nextActInst.getActDefId(), new HashMap());
|
||||
for (int i=0;i<activityDefinitionModels.size() ; i++) {
|
||||
ActivityDefinitionModel activityDefinitionModel=activityDefinitionModels.get(i);
|
||||
if(activityDefinitionModel.getActDefId().equals(nextActInst.getPrevActDefId())){
|
||||
ActivityInstanceModel historyTask=processInstanceService.getHistoryTask(nextActInst.getPrevActInstId());
|
||||
if(historyTask!=null&&historyTask.getProcInstId().equals(nextActInst.getProcInstId())){
|
||||
activityDefinitionModels.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
processInputModel.setWf_nextActDefId(activityDefinitionModels.get(0).getActDefId());
|
||||
processInputModel.setWf_nextActDefType(activityDefinitionModels.get(0).getActType());
|
||||
processInputModel
|
||||
.setWf_actionType(WorkFlowContants.ACTION_TYPE_EXECUTE_ACTIVITY);
|
||||
processInputModel.setWf_procDefId(nextActInst.getProcDefId());
|
||||
processInputModel.setWf_procDefName(nextActInst.getProcDefName());
|
||||
processInputModel.setWf_curActDefId(nextActInst.getActDefId());
|
||||
processInputModel.setWf_curActDefName(nextActInst.getActDefName());
|
||||
processInputModel.setWf_curActInstId(nextActInst.getActInstId());
|
||||
processInputModel.setWf_procInstId(nextActInst.getProcInstId());
|
||||
processInputModel.setWf_sendUserId(nextActInst.getReceiverUserId());
|
||||
processInputModel.setWf_sendUserOrgId(nextActInst
|
||||
.getReceiverOrgId());
|
||||
processInputModel.setWf_curComment("意见1111:"+processInputModel.getWf_curActDefName()+":"+new java.util.Random().nextInt());
|
||||
Map<String, Object> tempResultData = processExecuteService
|
||||
.nextExecute(processInputModel);
|
||||
taskIds.put(nextActInst.getActDefId(),nextActInst);
|
||||
next(tempResultData,taskIds);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ProcessInputModel buildProcessInputModel() {
|
||||
ProcessDefinitionModel processDefinitionModel = processDefinitionService
|
||||
.getProcessDefBykey(procDefKey);
|
||||
ActivityDefinitionModel actDef=processDefinitionService.getStartActivity(processDefinitionModel.getProcDefId());
|
||||
ProcessInputModel processInputModel = new ProcessInputModel();
|
||||
processInputModel.setWf_procTitle(procTitle);
|
||||
processInputModel.setWf_appId(appId);
|
||||
processInputModel
|
||||
.setWf_procDefId(processDefinitionModel.getProcDefId());
|
||||
processInputModel.setWf_procDefKey(procDefKey);
|
||||
processInputModel
|
||||
.setWf_actionType(WorkFlowContants.ACTION_TYPE_LAUCH_PROCESS);
|
||||
processInputModel.setWf_procDefName(processDefinitionModel
|
||||
.getProcDefName());
|
||||
processInputModel.setWf_sendUserId(procStartUserId);
|
||||
processInputModel.setWf_sendUserOrgId("204300015350");
|
||||
processInputModel.setWf_businessKey(java.util.UUID.randomUUID().toString());
|
||||
processInputModel.setWf_curActDefId(actDef.getActDefId());
|
||||
processInputModel.setWf_curActDefName(actDef.getActDefName());
|
||||
processInputModel.setWf_curActDefType(actDef.getActType());
|
||||
processInputModel.setWf_uniteworkUrl("http://test");
|
||||
return processInputModel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import org.activiti.engine.ProcessEngineConfiguration;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.blueland.bpm.common.util.ClassUtils;
|
||||
import com.blueland.bpm.engine.config.model.ProcessInfoConfig;
|
||||
import com.blueland.bpm.engine.config.service.ProcessInfoConfigManager;
|
||||
import com.blueland.bpm.engine.core.handler.BizProcessHandler;
|
||||
/**
|
||||
* 业务应用代理处理工程
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class BizProcessHandlerFactory {
|
||||
@Autowired
|
||||
private ProcessInfoConfigManager processInfoConfigManager;
|
||||
|
||||
protected Logger logger = LoggerFactory
|
||||
.getLogger(ProcessExecutorFactory.class);
|
||||
@Autowired
|
||||
protected ProcessEngineConfiguration processEngineConfiguration;
|
||||
|
||||
public BizProcessHandlerFactory() {
|
||||
|
||||
}
|
||||
|
||||
public BizProcessHandler buildBussinessProcessHandler(String processDefinitionId) {
|
||||
Assert.notNull(processDefinitionId, "流程定义ID不允许为空");
|
||||
ProcessInfoConfig processInfoConfig=processInfoConfigManager.getById(processDefinitionId);
|
||||
Assert.notNull(processInfoConfig, String.format("查询流程配置信息失败,processDefinitionId[%s]",processDefinitionId));
|
||||
if(StringUtils.isEmpty(processInfoConfig.getProcessHandlerClassPath())){
|
||||
return null;
|
||||
}
|
||||
BizProcessHandler bussinessProcessHandler = null;
|
||||
try {
|
||||
bussinessProcessHandler = (BizProcessHandler) ClassUtils.getInstance(processInfoConfig.getProcessHandlerClassPath());
|
||||
} catch (Exception e) {
|
||||
logger.error("无法初始化BussinessProcessHandler实例,processInfoConfig{}",new Object[]{processInfoConfig}, e);
|
||||
}
|
||||
|
||||
return bussinessProcessHandler;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.identity.OrgService;
|
||||
import com.blueland.bpm.identity.RoleService;
|
||||
import com.blueland.bpm.identity.UserService;
|
||||
import com.blueland.bpm.identity.model.Org;
|
||||
import com.blueland.bpm.identity.model.Role;
|
||||
import com.blueland.bpm.identity.model.User;
|
||||
|
||||
@Service("scriptImpl")
|
||||
public class DefaultScriptImpl implements java.io.Serializable{
|
||||
@Autowired
|
||||
OrgService orgService;
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
RoleService roleService;
|
||||
|
||||
public boolean isUserInOrg(String userId, String orgId) {
|
||||
User user = userService.getUserById(userId);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
return user.getOrgId().equals(orgId);
|
||||
}
|
||||
|
||||
public boolean isUserInRole(String userId, String roleId) {
|
||||
return roleService.isUserInRole(roleId, userId);
|
||||
}
|
||||
|
||||
public boolean isCompanyLeader(String userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDeptLeader(String userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户
|
||||
*/
|
||||
public User getCurUser() {
|
||||
User user = userService.getUserById("gaof0709");
|
||||
return user;
|
||||
}
|
||||
|
||||
public List<Role> getCurUserRoles() {
|
||||
User user = userService.getUserById("gaof0709");
|
||||
return roleService.findRoleByUserId(user.getUserId());
|
||||
}
|
||||
|
||||
public Org getCurUserOrg() {
|
||||
User user = userService.getUserById("gaof0709");
|
||||
return orgService.getOrgById(user.getOrgId());
|
||||
}
|
||||
|
||||
public void getCurrentDate() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import com.blueland.bpm.engine.core.model.ProcessInputModel;
|
||||
|
||||
public interface ExtCoreService {
|
||||
public String getDeputeMandataryUserId(String userId, String processDefKey, String appId);
|
||||
|
||||
public void recordProcessInfoLog(ProcessInputModel processInputModel, String jsonMsg);
|
||||
|
||||
public void recordProcessErrorLog(String errorMsg, ProcessInputModel processInputModel,
|
||||
String jsonMsg);
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import groovy.lang.GroovyShell;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.blueland.bpm.engine.core.script.GroovyBinding;
|
||||
/**
|
||||
* Groovy脚本引擎
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
@Service
|
||||
public class GroovyScriptEngine implements BeanPostProcessor {
|
||||
//private Log logger = LogFactory.getLog(GroovyScriptEngine.class);
|
||||
private GroovyBinding binding = new GroovyBinding();
|
||||
|
||||
public void execute(String script, Map<String, Object> vars)
|
||||
{
|
||||
executeObject(script, vars);
|
||||
}
|
||||
|
||||
private void setParameters(GroovyShell shell, Map<String, Object> vars)
|
||||
{
|
||||
if (vars == null) return;
|
||||
Set set = vars.entrySet();
|
||||
for (Iterator it = set.iterator(); it.hasNext(); ) {
|
||||
Map.Entry entry = (Map.Entry)it.next();
|
||||
shell.setVariable((String)entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean executeBoolean(String script, Map<String, Object> vars)
|
||||
{
|
||||
Boolean rtn = (Boolean)executeObject(script, vars);
|
||||
return rtn.booleanValue();
|
||||
}
|
||||
|
||||
public String executeString(String script, Map<String, Object> vars)
|
||||
{
|
||||
String str = (String)executeObject(script, vars);
|
||||
return str;
|
||||
}
|
||||
|
||||
public int executeInt(String script, Map<String, Object> vars)
|
||||
{
|
||||
Integer rtn = (Integer)executeObject(script, vars);
|
||||
return rtn.intValue();
|
||||
}
|
||||
|
||||
public float executeFloat(String script, Map<String, Object> vars)
|
||||
{
|
||||
Float rtn = (Float)executeObject(script, vars);
|
||||
return rtn.floatValue();
|
||||
}
|
||||
|
||||
public Object executeObject(String script, Map<String, Object> vars)
|
||||
{
|
||||
// this.logger.debug("执行:" + script);
|
||||
GroovyShell shell = new GroovyShell(this.binding);
|
||||
setParameters(shell, vars);
|
||||
|
||||
script = script.replace("'", "'")
|
||||
.replace(""", "\"")
|
||||
.replace(">", ">")
|
||||
.replace("<", "<")
|
||||
.replace("&nuot;", "\n")
|
||||
.replace("&", "&");
|
||||
|
||||
Object rtn = shell.evaluate(script);
|
||||
this.binding.clearVariables();
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException
|
||||
{
|
||||
// boolean rtn = BeanUtils.isInherit(bean.getClass(), BaseService.class);
|
||||
// boolean isImplScript = BeanUtils.isInherit(bean.getClass(), IScript.class);
|
||||
// if ((rtn) || (isImplScript)) {
|
||||
this.binding.setProperty(beanName, bean);
|
||||
// }
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException
|
||||
{
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
public interface IScript
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.blueland.bpm.common.page.Page;
|
||||
import com.blueland.bpm.common.util.ServiceResponse;
|
||||
import com.blueland.bpm.engine.config.model.ActivityInfoConfig;
|
||||
import com.blueland.bpm.engine.config.model.ProcessInfoConfig;
|
||||
import com.blueland.bpm.engine.util.WorkFlowException;
|
||||
/**
|
||||
* 流程管理配置Service
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public interface ProcessConfigService extends ActivitiService{
|
||||
|
||||
/**
|
||||
* 获取流程绑定的界面路径
|
||||
* 获取界面路径的优先级为:1:环节,2:流程
|
||||
* @param processDefId
|
||||
* @param activityDefId
|
||||
* @param version
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public String getWorkflowPage(String processDefId,String activityDefId) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取流程配置绑定的桌面端、手机端相关参数
|
||||
* 获取数据的优先级为:1:环节,2:流程
|
||||
* @param processDefId
|
||||
* @param activityDefId
|
||||
* @param version
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public Map<String,String> getPortalPage(String processDefId,String activityDefId) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取流程配置列表
|
||||
* @param params
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public Page<List<ProcessInfoConfig>> findProcessInfoConfigsPage(ProcessInfoConfig params) throws WorkFlowException;
|
||||
|
||||
public List<String> getAllProcessIdForExport(ProcessInfoConfig params);
|
||||
/**
|
||||
* 获取流程配置列表
|
||||
* @param params
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public List<ProcessInfoConfig> findProcessInfoConfigs(ProcessInfoConfig params) throws WorkFlowException;
|
||||
public ActivityInfoConfig getActivityInfoConfig(String processDefId,String activityDefId) throws WorkFlowException;
|
||||
/**
|
||||
* 获取流程环节配置
|
||||
* @param processDefId
|
||||
* @param activityDefId
|
||||
* @param opScope
|
||||
* @param pageDetailVaribale
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public ActivityInfoConfig getActivityInfoConfig(String processDefId,String activityDefId,String opScope,Map pageDetailVaribale) throws WorkFlowException;
|
||||
/**
|
||||
* 获取流程环节配置
|
||||
* @param processDefId
|
||||
* @param activityDefId
|
||||
* @param opScope
|
||||
* @param pageDetailVaribale
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public ActivityInfoConfig getActivityInfoConfigByLocal(String processDefId,
|
||||
String activityDefId);
|
||||
/**
|
||||
* 获取流程配置
|
||||
* @param processDefId
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public ProcessInfoConfig getProcessInfoConfig(String processDefId) throws WorkFlowException;
|
||||
/**
|
||||
* 删除流程配置
|
||||
* @param processDefId
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public boolean deleteProcessInfoConfig(String processDefId) throws WorkFlowException;
|
||||
/**
|
||||
* 导出一个流程数据
|
||||
* @param processDefId
|
||||
* @return
|
||||
*/
|
||||
public ByteArrayOutputStream exportOneProcessData(String processDefId);
|
||||
/**
|
||||
* 导入一个流程数据
|
||||
* @param fileContent
|
||||
* @param importType
|
||||
* @return
|
||||
*/
|
||||
public ServiceResponse<Void> importOneProcessData(String proceDefId,String tenantId,String deploymentId,String fileContent,
|
||||
String importType);
|
||||
/**
|
||||
* 判断是否流程贯彻流程
|
||||
* @param processDefId
|
||||
* @param activityDefId
|
||||
* @return
|
||||
*/
|
||||
public boolean isThroughBizAppProcess(String processDefId, String activityDefId);
|
||||
/**
|
||||
* 判断流程按钮是否有权限操作,如当前流程、待办是否有退回上一步、作废等操作权限
|
||||
* @param butOperateId
|
||||
* @param pageDetailVaribale
|
||||
* @return
|
||||
*/
|
||||
public boolean hasActivityButOperatePower(String butOperateId, Map<String,Object> pageDetailVaribale);
|
||||
|
||||
|
||||
/**
|
||||
* 导出某个应用下所有角色
|
||||
* @param appId
|
||||
* @return
|
||||
*/
|
||||
public ByteArrayOutputStream exportAllRoleData(String appId);
|
||||
|
||||
|
||||
/**
|
||||
* 导入某个应用下所有角色
|
||||
* @param fileContent
|
||||
* @return
|
||||
*/
|
||||
public void importAllRoleData(String fileContent) ;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param processInstanceId
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getPreTaskAssignee(String processInstanceId, String taskId) ;
|
||||
|
||||
/**
|
||||
* 获取流程配置和模型列表
|
||||
* @param params
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
public Page<List<ProcessInfoConfig>> findProcessConfigAndModel(ProcessInfoConfig params) throws WorkFlowException;
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
package com.blueland.bpm.engine.core.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.apache.commons.collections.MultiMap;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
|
||||
import com.blueland.bpm.common.page.Page;
|
||||
import com.blueland.bpm.engine.core.model.ActivityDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
|
||||
import com.blueland.bpm.engine.core.model.ProcessDefinitionModel;
|
||||
import com.blueland.bpm.engine.core.model.SearchProcessListDTO;
|
||||
|
||||
/**
|
||||
* 流程定义Service
|
||||
* @version: 1.0
|
||||
* @author lw
|
||||
*/
|
||||
public interface ProcessDefinitionService extends ActivitiService{
|
||||
/**
|
||||
* 根据流程实例ID查询流程定义对象{@link ProcessDefinition}
|
||||
*
|
||||
* @param processInstanceId
|
||||
* 流程实例ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*/
|
||||
public ProcessDefinitionModel getProcessDefByPid(String processInstanceId);
|
||||
|
||||
/**
|
||||
* 根据流程定义ID查询流程定义对象{@link ProcessDefinition}
|
||||
*
|
||||
* @param processDefinitionId
|
||||
* 流程定义对象ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*/
|
||||
public ProcessDefinitionModel getProcessDef(String processDefinitionId);
|
||||
/**
|
||||
* 获取流程所有环节
|
||||
* @param processDefinitionId
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityDefinitionModel> getProcessActivitys(String processDefinitionId);
|
||||
/**
|
||||
* 获取流程所有用户任务环节
|
||||
* @param processDefinitionId
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityDefinitionModel> getProcessUserActivitys(String processDefinitionId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取开始环节
|
||||
* @param processDefinitionId
|
||||
* @return
|
||||
*/
|
||||
public ActivityDefinitionModel getStartActivity(String processDefinitionId);
|
||||
/**
|
||||
* 获取环节对象
|
||||
* @param processDefinitionId
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
public ActivityDefinitionModel getActivity(String processDefinitionId,
|
||||
String activityId);
|
||||
/**
|
||||
* 获取下一步环节列表
|
||||
* @param processInstId
|
||||
* @param processDefinitionId
|
||||
* @param activityId
|
||||
* @param conditionMap
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityDefinitionModel> getNextActivity(String processInstId,String processDefinitionId,
|
||||
String activityId, Map conditionMap);
|
||||
|
||||
/**
|
||||
* 获取补发撤销下一步环节列表
|
||||
* @param processInstId
|
||||
* @param processDefinitionId
|
||||
* @param activityId
|
||||
* @param conditionMap
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityDefinitionModel> getMultiActivity(String processInstId,String processDefinitionId,
|
||||
String activityId, Map conditionMap);
|
||||
|
||||
/**
|
||||
* 获取上一环节列表
|
||||
* @param processDefinitionId
|
||||
* @param activityId
|
||||
* @param conditionMap
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityDefinitionModel> getPrevActivity(String processDefinitionId,
|
||||
String activityId, Map conditionMap);
|
||||
/**
|
||||
* 获取环节用户列表
|
||||
* @param processInstId
|
||||
* @param processDefinitionId
|
||||
* @param curActivityId
|
||||
* @param curActInstId
|
||||
* @param destActivityId
|
||||
* @param userId
|
||||
* @param filterIds
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityResourceModel> getActivityUserTree(String processInstId,String processDefinitionId,
|
||||
String curActInstId, String curActivityId,String destActivityId,String userId,String userOrgId,List<String> filterIds,Map conditionMap) ;
|
||||
|
||||
/**
|
||||
* 获取指定环节绑定资源
|
||||
*
|
||||
* @param activityDefinitionModel
|
||||
* @return
|
||||
*/
|
||||
public List<ActivityResourceModel> getResource(String procDefId,String actDefId);
|
||||
|
||||
/**
|
||||
* 按条件 查询流程定义列表
|
||||
* @param SearchProcessListDTO
|
||||
* @return Page
|
||||
*/
|
||||
public Page<List> findProcessDefList(SearchProcessListDTO searchProcessList);
|
||||
|
||||
|
||||
/**
|
||||
* 按条件 查询流程定义列表
|
||||
* @param SearchProcessListDTO
|
||||
* @return List
|
||||
*/
|
||||
public List<ProcessDefinitionModel> findProcessDefs(SearchProcessListDTO searchProcessList) ;
|
||||
|
||||
public List<ProcessDefinitionModel> findProcessDefsNotCascide(SearchProcessListDTO searchProcessList);
|
||||
/**
|
||||
* 查询指定流程定义key下的所有历史版本模型
|
||||
* @return
|
||||
*/
|
||||
public List<ProcessDefinitionModel> findAllVersionProcessDefs(String procDefkey);
|
||||
|
||||
/**
|
||||
* 根据流程定义ID查询流程定义对象{@link ProcessDefinition}
|
||||
*
|
||||
* @param processDefinitionId
|
||||
* 流程定义对象ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*/
|
||||
public ProcessDefinitionModel getProcessDefBykey(String processDefinitionKey);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询有权限起草的流程定义列表{@link ProcessDefinition}
|
||||
*
|
||||
* @param userId
|
||||
* 用户ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*/
|
||||
public Map<String,List<ProcessDefinitionModel>> findProcessDefStartByUser(String tenantId, String userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询有权限起草的流程定义列表{@link ProcessDefinition}
|
||||
*
|
||||
* @param userId
|
||||
* 用户ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*/
|
||||
public Map<String,List<ProcessDefinitionModel>> findProcessDefStartByUser(String tenantId, String userId, String flowType);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询有权限起草的流程定义列表{@link ProcessDefinition}
|
||||
*
|
||||
* @param userId
|
||||
* 用户ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*/
|
||||
public ProcessDefinitionModel getProcessDefStartByUser(String userId,String processDefKey);
|
||||
|
||||
/**
|
||||
* 是否有权限起草固定流程
|
||||
*
|
||||
* @param userId
|
||||
* 用户ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*/
|
||||
public boolean isStartProcessPower(String userId,String processDefKey) ;
|
||||
/**
|
||||
* 根据用户ID查询有权限起草的流程定义列表{@link ProcessDefinition}
|
||||
*
|
||||
* @param userId
|
||||
* 用户ID
|
||||
* @return 流程定义对象{@link ProcessDefinition}
|
||||
*//*
|
||||
public Page<Object[]> findProcessDefAndDeployList(String userId) ;*/
|
||||
|
||||
/**
|
||||
* 部署classpath下面的流程定义
|
||||
* <p>
|
||||
* 从属性配置文件中获取属性<b>com.blueland.bpm.engine.modules</b>扫描**deployments**
|
||||
* </p>
|
||||
* <p>
|
||||
* 然后从每个**deployments/${module}**查找在属性配置文件中的属性**com.blueland.bpm.engine.module.keys.${
|
||||
* submodule}**
|
||||
* <p>
|
||||
* 配置实例:
|
||||
*
|
||||
* <pre>
|
||||
* #com.blueland.bpm.engine for deploy
|
||||
* com.blueland.bpm.engine.modules=budget,erp,oa
|
||||
* com.blueland.bpm.engine.module.keys.budget=budget
|
||||
* com.blueland.bpm.engine.module.keys.erp=acceptInsurance,billing,effectInsurance,endorsement,payment
|
||||
* com.blueland.bpm.engine.module.keys.oa=caruse,leave,officalstamp,officesupply,out,overtime
|
||||
* </pre>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @param processKey
|
||||
* 流程定义KEY
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deployFromClasspath(String exportDir, String... processKey);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 部署单个流程定义
|
||||
*
|
||||
* @param resourceLoader
|
||||
* {@link ResourceLoader}
|
||||
* @param processKey
|
||||
* 模块名称
|
||||
* @param subModule
|
||||
* 流程定义名称
|
||||
* @throws IOException
|
||||
* 找不到zip文件时
|
||||
*/
|
||||
public ProcessDefinitionModel deploySingleProcess(String tenantId,InputStream inputStream, String fileName);
|
||||
|
||||
/**
|
||||
* 重新部署单个流程定义
|
||||
*
|
||||
* @param processKey
|
||||
* 流程定义KEY
|
||||
* @throws Exception
|
||||
* @see #deployFromClasspath
|
||||
*/
|
||||
public void redeploy(String exportDir, String... processKey);
|
||||
|
||||
/**
|
||||
* 重新部署所有流程定义,调用:{@link #deployFromClasspath()}完成功能
|
||||
*
|
||||
* @throws Exception
|
||||
* @see #deployFromClasspath
|
||||
*/
|
||||
public void deployAllFromClasspath(String exportDir) throws Exception ;
|
||||
|
||||
/**
|
||||
* 加载流程定义的bpmn.xml或图片资源
|
||||
*
|
||||
* @param processDefinitionId
|
||||
* 流程定义ID
|
||||
* @param resourceType
|
||||
* image:图片资源,xml:bpmn.xml
|
||||
* @return InputStream
|
||||
*/
|
||||
public InputStream loadProcessResource(String processDefinitionId,
|
||||
String resourceType) ;
|
||||
/**
|
||||
* 更新流程部署模型
|
||||
* @param deploymentId
|
||||
* @param processDefinitionId
|
||||
* @param resourceByte
|
||||
* @param isUpdateImage
|
||||
*/
|
||||
public void updateDeploymentResource(String deploymentId,String processDefinitionId,byte[] resourceByte,boolean isUpdateImage);
|
||||
/**
|
||||
* 更新流程部署模型并刷新缓存
|
||||
* @param bpmnModel
|
||||
* @param processDefinition
|
||||
* @param isUpdateImage
|
||||
* @return
|
||||
*/
|
||||
public boolean updateDeploymentResourceAndCache(BpmnModel bpmnModel,ProcessDefinitionModel processDefinition,boolean isUpdateImage);
|
||||
/**
|
||||
* 刷新流程缓存
|
||||
* @param processDefinitionId
|
||||
*/
|
||||
public void refreshProcessDefineCache(String processDefinitionId);
|
||||
/**
|
||||
* 删除流程定义
|
||||
* @param procDefId
|
||||
* @param deploymentId
|
||||
* @param cascode
|
||||
* @return
|
||||
*/
|
||||
public boolean delete(String procDefId, String deploymentId,boolean cascode);
|
||||
|
||||
|
||||
/**
|
||||
* 查询指定资源的值在哪里流程定义中(资源类型包含角色、组织、人员)
|
||||
* 可以按租户或者单个流程定义KEY来查询
|
||||
* @param tenantId 租户ID
|
||||
* @param procDefKey 流程定义
|
||||
* @param type 资源类型
|
||||
* @param resourceVal 资源值
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> findProcessDefsByResource(
|
||||
String tenantId, String procDefKey, String resourceType, String resourceVal) ;
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user