package com.tenwa.flow.action.comm; import java.util.HashMap; import java.util.List; import java.util.Map; import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; import jbo.com.tenwa.entity.comm.flow.FLOW_WORK_FLAG; import jbo.sys.FLOW_OBJECT; import jbo.sys.FLOW_TASK; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.tenwa.comm.util.jboutil.DataOperatorUtil; public class BaseFlowStartAction extends FlowBussionAction { private String error_message = "failed@发起流程出错"; public String getError_message() { return error_message; } public void setError_message(String error_message) { this.error_message = error_message; } @Override public String initFLow(JBOTransaction tx) throws Exception { try { //初始化当前用户信息 String flowunid=""; //生成业务流程数据并返回流程的编号 MapdeleteCondition=new HashMap(); BizObject flowBussiness=this.initFLowBusinonObject(tx); this.customOperation(tx,flowBussiness); flowunid=flowBussiness.getAttribute("flow_unid").toString(); if(this.getFlowMutexConfig().size()>0){ String checkResult=this.flowMutexCheck(tx); if(checkResult.length()>0) { deleteCondition.put("flow_unid",flowunid); DataOperatorUtil.deleteJBOByCondtion(FLOW_BUSSINESS_OBJECT.CLASS_NAME, deleteCondition, tx); return "failed@"+checkResult; } this.flowMutexInfoInit(tx); } this.updateFLowBusinonObject(tx); this.executeFlowStartScript(tx, flowBussiness); return this.startFlow(tx,flowunid); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); tx.rollback(); return error_message; } } /** * 发起流程之前自定义操作 * @param tx * @param flowBussiness * @throws Exception */ public void customOperation(JBOTransaction tx,BizObject flowBussiness)throws Exception{ } /** *流程互斥检查 * @param tx * @throws Exception */ public String flowMutexCheck(JBOTransaction tx)throws Exception{ BizObjectManager bom=JBOFactory.getBizObjectManager(FLOW_WORK_FLAG.CLASS_NAME); tx.join(bom); String mutextKeyValue=""; String mutextKey=""; String res=""; String sql="SELECT O.flow_unid,O.flow_name FROM O WHERE O.mutex_key=:mutex_key AND O.flow_name=:flownameb AND EXISTS (SELECT fc.flow_nameb FROM jbo.com.tenwa.entity.comm.flow.FLOW_MUTEX_CONFIG fc WHERE fc.flow_nameA=:flowname)"; for(int i=0;isearchCondtion=new HashMap(); mutextKeyValue=this.FlowParam.get(mutextKey); ListmutexList=bom.createQuery(sql).setParameter("mutex_key",mutextKeyValue).setParameter("flownameb",this.getFlowMutexConfig().get(i).getAttribute("flow_nameb").getString()).setParameter("flowname",this.getFlowNo()).getResultList(false); if(mutexList.size()>0){ for(int j=0;j flowTask = JBOFactory.getBizObjectManager(FLOW_TASK.CLASS_NAME).createQuery("objectno=:objectno and (endtime is null or endtime='') ").setParameter("objectno", mutexList.get(j).getAttribute("flow_unid").getString()).getResultList(false); String OperatorUser =""; if(flowTask.size()>0){ for(int k=0;k0){OperatorUser+=",";} OperatorUser=OperatorUser+flowTask.get(k).getAttribute("username").getString(); } } if(res!=""){ res+=","; } res+=flowobject.getAttribute("flowname").getString()+"[当前处理人:"+OperatorUser+"]"; } } } if(res.length()>0){res="当前流程和下面流程互斥不同时执行【"+res+"】";} return res; } /** * 保存互斥信息 * @param tx * @throws Exception */ public void flowMutexInfoInit(JBOTransaction tx) throws Exception{ BizObjectManager bom=JBOFactory.getBizObjectManager(FLOW_WORK_FLAG.CLASS_NAME); tx.join(bom); String mutextKey=""; String mutextKeyValue=""; for(int i=0;i