自定义工作流

本文档详细阐述了一个自定义工作流的需求和设计。需求包括网格员上报、社区及街镇综治中心的处理流程,涉及退回、撤回操作。在表设计方面,有事件上报、流程实例和流程记录表。在Java实现中,采用了状态设计模式,包括网格员上报、处理单位签收等多个操作,并利用策略模式解决复杂逻辑。总结中提到,通过一个接口即可供前端调用,实现了灵活的工作流处理。
摘要由CSDN通过智能技术生成

需求:

综治子系统:统一受理平台和矛盾纠纷系统合二为一,因为流程一样,主要流程如下图
在这里插入图片描述
1、网格员上报到社区综治中心
2、社区综治中心可以选择上报到街镇综治中心或派遣给社区单位签收或派遣给具体的网格员进行处理
3、社区单位签收(派遣)具体的处理人员进行处理
4、街镇综治中心可以选择上报到区综治中心或派遣到街镇单位签收或下派到社区综治中心处理
5、街镇单位签收(派遣)具体的处理人员进行处理
6、区综治中心可以派遣到区具体的区处理单位进行处理或下派到具体的街镇综治中心
其中所有单位和具体处理人员可以进行退回操作,退回到上一级
其中所有综治中心和单位可以进行撤回操作

表设计

1、事件上报表
在这里插入图片描述
2、流程实例表
在这里插入图片描述
3、流程记录表
在这里插入图片描述

java流程设计(采用状态设计模式)

1、创建抽象类,定义handle方法和setEventBase两个方法,让具体实现者实现

public abstract class ProcessHandle {
   

	protected ProcessRecordingMapper processRecordingMapper;
	protected InstanceMapper mapper;
	protected IEventBaseService baseService;
	protected ProcessContent content;


	public ProcessHandle(ProcessContent content) {
   
		this.content = content;
		this.mapper = this.content.getMapper();
		this.baseService = this.content.getBaseService();
		this.processRecordingMapper = this.content.getProcessRecordingMapper();
	}

	/**
	 * 执行处理
	 *
	 * @throws ProcessHandleException
	 */
	abstract void handle() throws ProcessHandleException;

	/**
	 * 设置事件状态
	 *
	 * @param eventId
	 * @throws ProcessHandleException
	 */
	void setEventBase(Long eventId) {
   

	}


}

2、网格员上报操作实现

public class ReportHandle extends ProcessHandle {
   
	public ReportHandle(ProcessContent content) {
   
		super(content);
	}

	@Override
	public void handle() {
   
		if (this.content == null || !this.content.getInstanceVO().getCategory().equals(ProcessConstant.PROCESS_TYPE_REPORT)) {
   
			log.info("上报处理初始化异常!");
			throw new ProcessHandleException("上报处理初始化异常!");
		}
		InstanceVO instanceVO = this.content.getInstanceVO();
		//生成当前节点
		setEventBase(instanceVO.getEventId());

		//设置当前实例动作
		switch (instanceVO.getRoleName()) {
   
			case ProcessConstant.PROCESS_ROLE_GRIDEMP:
				instanceVO.setNowNode(ProcessConstant.NODE_LOCATION_WGYSB);
				instanceVO.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_SB);
				break;
			case ProcessConstant.PROCESS_ROLE_COMMUNITY:
				instanceVO.setNowNode(ProcessConstant.NODE_LOCATION_SQZXSL);
				instanceVO.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_SBJZZZZX);
				break;
			case ProcessConstant.PROCESS_ROLE_STREET_TOWN:
				instanceVO.setNowNode(ProcessConstant.NODE_LOCATION_JZZXSL);
				instanceVO.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_SBQZZZX);
				break;
			default:
				throw new ProcessHandleException("上报处理异常!");
		}
		this.setEventBase(instanceVO.getEventId());
		if (mapper.insert(instanceVO) == 0) {
   
			throw new ProcessHandleException("上报处理异常!");
		}
	}

	@Override
	public void setEventBase(Long eventId) {
   
		this.content.setEventBase(baseService.getById(eventId));
		this.content.getEventBase().setHandleStatus(ProcessConstant.PROCESS_PENDING);
	}
}

3、派遣操作流程实现

public class SendHandle extends ProcessHandle {
   

	SendHandle(ProcessContent content) {
   
		super(content);
	}

	@Override
	public void handle() {
   
		if (this.content == null || !this.content.getInstanceVO().getCategory().equals(ProcessConstant.PROCESS_TYPE_SEND)) {
   
			log.info("派遣处理初始化异常!");
			throw new ProcessHandleException("派遣处理初始化异常!");
		}

		InstanceVO instanceVO = this.content.getInstanceVO();
		instanceVO.setHandleStatus(ProcessConstant.UNTREATED);
		switch (instanceVO.getRoleName()) {
   
			case ProcessConstant.PROCESS_ROLE_COMMUNITY:
				instanceVO.setNowNode(ProcessConstant.NODE_LOCATION_SQZXSL);
				if (instanceVO.getIsSendGridEmp() == 1) {
   
					instanceVO.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_ZPWGYCL);
				} else {
   
					instanceVO.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_ZPSCDWCL);
				}
				break;
			case ProcessConstant.PROCESS_ROLE_STREET_TOWN:
				instanceVO.setNowNode(ProcessConstant.NODE_LOCATION_JZZXSL);
				instanceVO.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_ZPJZDWCL);
				break;
			case ProcessConstant.PROCESS_ROLE_STREET_AREA:
				instanceVO.setNowNode(ProcessConstant.NODE_LOCATION_QZXSL);
				instanceVO.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_ZPQDWCL);
				break;
			default:
				throw new ProcessHandleException("派遣处理异常!");
		}
		setEventBase(instanceVO.getEventId());
		if (mapper.insert(instanceVO) == 0) {
   
			throw new ProcessHandleException("派遣处理异常!");
		}

	}

	@Override
	public void setEventBase(Long eventId) {
   
		this.content.setEventBase(baseService.getById(eventId));
		this.content.getEventBase().setHandleStatus(ProcessConstant.PROCESS_SIGN_FOR);
	}
}

4、处理单位签收处理

public class SignForHandle extends ProcessHandle {
   
	public SignForHandle(ProcessContent content) {
   
		super(content);
	}

	@Override
	public void handle() {
   
		if (this.content == null || !this.content.getInstanceVO().getCategory().equals(ProcessConstant.PROCESS_TYPE_SIGN_FOR)) {
   
			log.info("签收处理初始化异常!");
			throw new ProcessHandleException("签收处理初始化异常!");
		}
		InstanceVO instance = this.content.getInstanceVO();
		Instance preInstance = content.getPreInstance();
		instance.setOrders(preInstance.getOrders() + 1);
		if (instance.getRoleName().equals(ProcessConstant.PROCESS_ROLE_COMMUNITY_UNIT)) {
   
			//生成当前节点(社区单位签收)
			instance.setNowNode(ProcessConstant.NODE_LOCATION_SQDWQS);
			instance.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_SQDWQS);
		} else if (instance.getRoleName().equals(ProcessConstant.PROCESS_ROLE_STREET_UNIT)) {
   
			//生成当前节点(街镇单位签收)
			instance.setNowNode(ProcessConstant.NODE_LOCATION_JZDWQS);
			instance.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_JZDWQS);
		} else if (instance.getRoleName().equals(ProcessConstant.PROCESS_ROLE_AREA_UNIT)) {
   
			//生成当前节点(区单位签收)
			instance.setNowNode(ProcessConstant.NODE_LOCATION_QDWQS);
			instance.setActionInfomation(ProcessConstant.PROCESS_DETILE_TYPE_QDWQS);
		} else {
   
			throw new ProcessHandleException("请正确分配角色!");
		}
		if (mapper.insert(instance) == 0) {
   
			throw new ProcessHandleException("签收处理异常!");
		}
		//改变事件主表状态
		this.setEventBase(instance.getEventId());

	}

	@Override
	public void setEventBase(Long eventId) {
   
		this.content.setEventBase(baseService.getById(eventId))
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值