1、在action中要新增lgpDispatchFlowService, lgpDispatchFlow, flowId三个关于流程的变量
2、在prepare函数中要初始化lgpDispatchFlow对象
if (!isNullOrEmptyString(flowId))
{
this.lgpDispatchFlow = (LgpDispatchFlow)this.lgpDispatchFlowService.getById(flowId);
}在菜单中一般是不会配置流程flowId的,所以flowId为null
菜单中生成的url是这样的'contract/LgpContract_ngList.action? type=contract&operating=ng&parentModuleId=2c9082cb41fd9bbf0141fda3a5e40001&moduleId=2c9082cb41fd9bbf0141fda751580002'
3在nglist.action中必须在request中设置如下属性;
this.getRequest().setAttribute("ss_moduleId", this.getRequest().getParameter("parentModuleId"));
this.getRequest().setAttribute("cur_moduleId", this.getRequest().getParameter("moduleId"));
this.getRequest().setAttribute("s_type", this.getRequest().getParameter("type"));
this.getRequest().setAttribute("s_operating", this.getRequest().getParameter("operating"));
必须在map中放置如下的fliter否则查询出的数据不是对应于本模块的记录:
LgmUser user = (LgmUser)this.getSession().getAttribute("loginUser");
Limit limit=RequestUtils.getLimit(getRequest(),"LgpDispatchFlow");
HashMap<String,String> map = new HashMap<String,String>();
map.put("moduleId", ss_moduleId);
map.put("orgId", user.getOrgId());
PageInfo pageInfo = newPageInfo(limit,"LgpDispatchFlow",RequestUtils.getCurrentRowsDisplayed(getRequest(),"LgpDispatchFlow"));
pageInfo.getFilters().putAll(map);
Page page = lgpDispatchFlowService.findWorkFlowByPageInfo(pageInfo);//查找对应模块对应部门下的工作流记录
对应的sql为
String sql = "from LgpWorkFlow as a where a.isActive = '0' ";
sql += "/~ and a.orgId = '[orgId]' ~/";
sql += "/~ and a.moduleId = '[moduleId]' ~/";
sql += " order by a.orderNum";
进入nglist.jsp页面利用ec展示所有的工作流记录 。
4、进入创建工作流页面 通过产生的workFlowString产生对应的ui界面
this.getRequest().setAttribute("workFlowString",
workFlowString.substring(1, workFlowString.length() - 1));
this.getRequest().setAttribute("workFlowPermission", this.getRequest().getParameter("workFlowPermission"));
this.getRequest().setAttribute("curFlowItem", this.getRequest().getParameter("curFlowItem"));
this.getRequest().setAttribute("workFlowId", this.getRequest().getParameter("workFlowId"));
this.getRequest().setAttribute("cur_moduleId", this.getRequest().getParameter("cur_moduleId"));
this.getRequest().setAttribute("s_type", this.getRequest().getParameter("s_type"));
this.getRequest().setAttribute("s_operating", this.getRequest().getParameter("s_operating"));
this.getRequest().setAttribute("ss_moduleId", this.getRequest().getParameter("ss_moduleId"));
this.getRequest().setAttribute("cellFilePath", lgpDispatchFlowService.getWorkFlowId(this.getRequest().getParameter("workFlowId")));//关联表单
同时要关联对应的表单 进入ui拟稿界面。
点击拟稿进入saveWorkFlowNg函数,在该函数中设置一个在重要属性:openType
if(getRequest().getParameter("s_type").equals("receive")){
this.getRequest().setAttribute("openType", "3");
}
else{
this.getRequest().setAttribute("openType", "2");
}
同时设置关联的表单文件路径:this.getRequest().setAttribute("cellFilePath", lgpDispatchFlowService.getWorkFlowId(this.getRequest().getParameter("workFlowId")));
产生用户可见的可编辑函数:LinkedHashMap<String,OaFunctionModel> functionMap = lgpDispatchFlowService.prepareEdit(user, lgpDispatchFlow, this.getRequest().getParameter("cur_moduleId"), this.getRequest().getParameter("s_type"), this.getRequest().getParameter("s_operating"));
设置并行流程项:
String curWorkFlowItemId = lgpDispatchFlow.getCurWorkFlowItemId();
String parallelDealUser = lgpDispatchFlow.getParallelUserIds();
String curLogonUser = "," + user.getUserId() + "^";
if(null != parallelDealUser && parallelDealUser.indexOf(curLogonUser) > -1){
curWorkFlowItemId = lgpDispatchFlow.getParallelWorkFlowItemId();
}
然后根据type类型跳转到相应的页面中
if(this.getRequest().getParameter("s_type").equals("contract")){
return "!/contract/LgpContract_create.action?flowId="+this.lgpDispatchFlow.getId()+"&cur_moduleId="+this.getRequest().getParameter("cur_moduleId")
+"&s_type="+this.getRequest().getParameter("s_type")+"&s_operating="+this.getRequest().getParameter("s_operating")+"&parentModuleId="+this.getRequest().getParameter("ss_moduleId");
在每一个action的方法中都要设置
this.getRequest().setAttribute("workFlowId", this.getRequest().getParameter("workFlowId"));
this.getRequest().setAttribute("cur_moduleId", this.getRequest().getParameter("cur_moduleId"));
this.getRequest().setAttribute("s_type", this.getRequest().getParameter("s_type"));
this.getRequest().setAttribute("s_operating", this.getRequest().getParameter("s_operating"));
this.getRequest().setAttribute("parentModuleId", this.getRequest().getParameter("parentModuleId"));
this.getRequest().setAttribute("flowId", this.getRequest().getParameter("flowId"));
在对应的jsp页面上需要添加隐藏域保留工作流中的必需属性。
<s:hidden id="s_type" name="s_type" value="%{#request.s_type}" ></s:hidden>
<s:hidden id="s_operating" name="s_operating" value="%{#request.s_operating}" ></s:hidden>
<s:hidden id="flowId" name="flowId" value="%{#request.flowId}"></s:hidden>
保存对象时一定要先保存流程对象
if(isNullOrEmptyString(flowId)){
lgpDispatchFlowService.saveDispatch(lgpDispatchFlow,this.getRequest().getParameter("workFlowId"),user);
}else if(isNullOrEmptyString(lgpDispatchFlow.getModuleId())){
lgpDispatchFlowService.saveDistributeDispatch(lgpDispatchFlow,this.getRequest().getParameter("workFlowId"),user,org);
}
然后设置对象和流程的关联
lgpContract.setDispatchflowId(this.lgpDispatchFlow.getId());
最后执行对象的保存操作并在请求中添加对应的工作流必需属性
在创建完对象后在重定向到edit.action中这样对象就关联到了工作流上,后续的所有操作都是在基于工作流基础上的对象的操作