From d3e998f2fbb43b8e4c7108197390f216ae71c534 Mon Sep 17 00:00:00 2001 From: zhulh Date: Tue, 6 Aug 2019 15:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=8E=A5=E5=8F=A3=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E6=B5=81=E7=A8=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebContent/WEB-INF/web.xml | 44 +++--- src/com/amarsoft/app/flow/FlowAction.java | 104 ++++++------- .../flow/task/BaseFlowTaskDataService.java | 116 ++++++++------ .../flow/action/comm/BaseFlowStartAction.java | 142 +++++++++++++++--- .../tenwa/flow/action/comm/CommonAction.java | 11 +- .../flow/action/comm/FlowController.java | 69 +++++++++ 6 files changed, 344 insertions(+), 142 deletions(-) create mode 100644 src_sys/com/tenwa/flow/action/comm/FlowController.java diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 654b9025b..f7bfa3e24 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -54,7 +54,7 @@ RunFilter /servlet/view/* - + WebServiceFilter com.tenwa.makeContract.WebServiceFilter @@ -63,7 +63,7 @@ WebServiceFilter /services/* - + InitAREServlet com.amarsoft.are.InitAREServlet @@ -110,7 +110,7 @@ GBK - + InitSecondHandCarConfig com.amarsoft.app.awe.config.InitSecondHandCarConfig @@ -120,7 +120,7 @@ 1 - + InitCollectConfig com.amarsoft.app.awe.config.InitCollectConfig @@ -130,7 +130,7 @@ 1 - + RewriteRunJavaMethodServlet com.tenwa.workflow.RewriteRunJavaMethodServlet @@ -164,6 +164,10 @@ als + + FlowController + com.tenwa.flow.action.comm.FlowController + DisplayChart org.jfree.chart.servlet.DisplayChart @@ -252,6 +256,10 @@ RedirectorDialogServlet /RedirectorDialog + + FlowController + /startFlow + RunJavaMethodServlet /servlet/run @@ -507,7 +515,7 @@ RestfullServlet /webapi/resf/* - + XFireServlet @@ -518,8 +526,8 @@ XFireServlet /services/* - - + + restfull自动扫描路径设置 RestfullScanPackage @@ -535,7 +543,7 @@ apx.com.amarsoft.als.apzl.apply.business.query.controller, apx.com.amarsoft.als.apzl.apply.business.start.controller, - + apx.com.amarsoft.als.apzl.apply.business.doc.detail.controller, apx.com.amarsoft.als.apzl.apply.business.doc.upload.controller, apx.com.amarsoft.als.apzl.apply.business.doc.delete.controller, @@ -547,24 +555,24 @@ apx.com.amarsoft.als.currency.select.apzl.product.controller, apx.com.amarsoft.als.currency.select.apzl.contract.controller, - - + + apx.com.amarsoft.als.business.opinion.sign.controller, apx.com.amarsoft.als.business.opinion.history.controller, - + apx.com.amarsoft.als.business.attachment.controller, apx.com.amarsoft.als.doc.attribute.controller, - + apx.com.amarsoft.als.business.action.ready.controller, apx.com.amarsoft.als.business.action.submit.controller, apx.com.amarsoft.als.business.action.back.controller, apx.com.amarsoft.als.business.comm.action.controller, - + apx.com.amarsoft.als.base.awe.controller, @@ -584,14 +592,14 @@ NoCheckURI - /resf/logon/manager/logon, + /resf/logon/manager/logon, /resf/logon/manager/logout, - /resf/user/center/manager/acquisition/gesture, + /resf/user/center/manager/acquisition/gesture, /resf/user/center/manager/close/gesture, /resf/user/center/manager/detection/version, - + /resf/files/down/docById, /resf/files/downloadPlist, /resf/files/downloadApp, @@ -619,4 +627,4 @@ - \ No newline at end of file + diff --git a/src/com/amarsoft/app/flow/FlowAction.java b/src/com/amarsoft/app/flow/FlowAction.java index aa7bc87ff..f57ea41c2 100644 --- a/src/com/amarsoft/app/flow/FlowAction.java +++ b/src/com/amarsoft/app/flow/FlowAction.java @@ -66,7 +66,7 @@ import com.tenwa.officetempalte.util.FileOperatorUtil; import com.tenwa.reckon.util.UUIDUtil; /** - * + * * زࣨ߼ҵʵе runJavaMethodTrans, гʼ̡ȡ̡ء˻ Ȳ */ public class FlowAction { @@ -248,7 +248,7 @@ public class FlowAction { /** * ʼ - * + * * @return success-ɹ; error-ʧ */ public String initFlow(JBOTransaction tx) throws Exception { @@ -258,7 +258,7 @@ public class FlowAction { /** * ȡ - * + * * @return success-ɹ; error-ʧ */ public String delete(JBOTransaction tx) throws Exception { @@ -326,7 +326,7 @@ public class FlowAction { /** * xuyunlong еݹ鵵 - * + * * @param tx * @throws Exception */ @@ -347,13 +347,15 @@ public class FlowAction { this.getFlowStartActionParm(tx, sObjectNo)); } dataTaskService.initPhaseNodes(); - dataTaskService.phaseFlowStepData(); + //dataTaskService.phaseFlowStepData(); + //δȷӿڷ̷ԣ޸Ĵ˷ + dataTaskService.phaseFlowStepData( sPhaseNo ); } /** * objectType,objectNoFLOW_TASKвµphaseNoҳύʱ¼Ƿύ - * + * * @return curPhaseNo--µphaseNo */ public String getCurPhaseNo(JBOTransaction tx) throws Exception { @@ -392,7 +394,7 @@ public class FlowAction { /** * taskNoǷѾǩ - * + * * @return yes-; no-; */ public String isSignOpinion(JBOTransaction tx) throws Exception { @@ -413,7 +415,7 @@ public class FlowAction { /** * - * + * * @return success-ɹ; error-ʧ */ public String takeBack(JBOTransaction tx) throws Exception { @@ -452,7 +454,7 @@ public class FlowAction { /** * ˻ǰһ - * + * * @return success-ɹ; error-ʧ */ public String backStep(JBOTransaction tx) throws Exception { @@ -480,7 +482,7 @@ public class FlowAction { /** * ˻صָ̽ڵ - * + * * @param ReturnPoint * ָ˻ص * @throws Exception @@ -494,19 +496,19 @@ public class FlowAction { .createQuery( "select O.flowno,O.phaseno,O.objecttype,O.objectno,O.userid,O.orgid from O where serialNo=:serialNo ") .setParameter("serialNo", taskNo).getSingleResult(false); - + String objectNo = ft.getAttribute("objectno").getString(); - + BizObject boFBO = JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME, tx) .createQuery("flow_unid = '" + objectNo + "'").getSingleResult(false); - + String fixedFlowParam = boFBO.getAttribute("FixedFlowParam").getString(); - + JSONObject jsonFixedFlowParam = JSONDecoder.decode(fixedFlowParam.replaceAll("@", ",")); Map scriptMap = FileOperatorUtil.getJsonObjectToMap(jsonFixedFlowParam); - + scriptMap.put("ObjectNo", objectNo); - + BizObjectManager bm1 = JBOFactory.getFactory().getManager(FLOW_MODEL.CLASS_NAME); BizObjectQuery bq1 = bm1 .createQuery( @@ -524,25 +526,25 @@ public class FlowAction { Any returnData = Expression.getExpressionValue(strScript, context); } - + // BizObjectManager utdbom = JBOFactory.getBizObjectManager(USER_TASK_DATA.CLASS_NAME, tx); BizObjectManager utibom = JBOFactory.getBizObjectManager(USER_TASK_INFO.CLASS_NAME, tx); BizObject utdbo = utdbom.createQuery("taskno = '" + taskNo + "' and userid = '" + ft.getAttribute("userid").toString() + "' and (status = 'approve_status01' or status = 'approve_status03')").getSingleResult(true); if(utdbo != null) { - int taskNumber = utibom.createQuery("userid = '" + utdbo.getAttribute("userid") + int taskNumber = utibom.createQuery("userid = '" + utdbo.getAttribute("userid") + "' and roleid = '" + utdbo.getAttribute("roleid") + "'").getSingleResult(false).getAttribute("task_number").getInt(); ARE.getLog().info("***********־***:Ϊ"+ taskNo + "" + utdbo.getAttribute("userid") + "ûرһ񣬵ǰδΪ" + taskNumber); String status = utdbo.getAttribute("status").toString(); if("approve_status01".equals(status)) { - utibom.createQuery("update O set task_number = task_number - 1 where userid = '" + utdbo.getAttribute("userid") + utibom.createQuery("update O set task_number = task_number - 1 where userid = '" + utdbo.getAttribute("userid") + "' and roleid = '" + utdbo.getAttribute("roleid") + "'").executeUpdate(); } utdbo.setAttributeValue("status", "approve_status02"); utdbo.setAttributeValue("endtime", StringFunction.getTodayNow()); utdbom.saveObject(utdbo); } - + PhaseInfoArchive(ft.getAttribute("flowno").getString(), ft .getAttribute("phaseno").getString(), ft.getAttribute("objecttype").getString(), @@ -554,13 +556,13 @@ public class FlowAction { ("Y".equalsIgnoreCase(recommit) ? taskNo : ""), tx); //̻֪֮ͨ new FLowStepEndNotice().StepEndNotice(tx, ft.getAttribute("objectno").getString(),this.taskNo,"back"); - + return "˻سɹ"; } /** * ˻ز - * + * * @param ReturnPoint * ָ˻ص * @throws Exception @@ -579,7 +581,7 @@ public class FlowAction { /** * ػȡ - * + * * @return taskSerialNo-ȡˮ; ""-; "error"-ʧ */ public String fetchTask(JBOTransaction tx) throws Exception { @@ -589,7 +591,7 @@ public class FlowAction { /** * ˻ص - * + * * @return success-ɹ; error-ʧ */ public String returnTaskToPool(JBOTransaction tx) throws Exception { @@ -664,7 +666,7 @@ public class FlowAction { /** * ˵ʷ - * + * * @param tx * @throws Exception */ @@ -696,7 +698,7 @@ public class FlowAction { /** * flow_objectݻȡδɵflow_taskˮ - * + * * @return taskSerialNo */ public String getUnfinishedTaskNo(JBOTransaction tx) throws Exception { @@ -739,7 +741,7 @@ public class FlowAction { /** * flowNo,phaseNoжǷؽڵ - * + * * @return yes-; no-; error-ѯ */ public String isPoolSubmit(JBOTransaction tx) throws Exception { @@ -754,7 +756,7 @@ public class FlowAction { /** * flowNo,phaseNoжǷǴַڵ - * + * * @return yes-; no-; error-ѯ */ public String isMeeting(JBOTransaction tx) throws Exception { @@ -774,7 +776,7 @@ public class FlowAction { /** * taskNo,phaseOpinionһ׶θһ׶κšһ׶ - * + * * @return һ׶θһ׶κšһ׶ */ public String getNextPhaseNumAndInfo(Transaction Sqlca) throws Exception { @@ -796,7 +798,7 @@ public class FlowAction { /** * ȡһ׶ - * + * * @param tx * @return */ @@ -806,7 +808,7 @@ public class FlowAction { /** * ȡһ׶Ϣ - * + * * @param trans * @return */ @@ -818,7 +820,7 @@ public class FlowAction { /** * ݵǰȡôԱ - * + * * @param trans * @return * @throws Exception @@ -859,7 +861,7 @@ public class FlowAction { /** * ȡԱб - * + * * @param trans * @return */ @@ -909,7 +911,7 @@ public class FlowAction { /** * taskNo,phaseOpinionõύб - * + * * @param Sqlca * @return {phaseno:actions,phaseno2:actions2} */ @@ -953,7 +955,7 @@ public class FlowAction { /** * ˻ֱύ裬Ͳûѡ - * @throws Exception + * @throws Exception */ public String checkBackType(JBOTransaction tx) throws Exception { FlowTask ft = new FlowTask(taskNo, tx); @@ -967,10 +969,10 @@ public class FlowAction { return "false"; } } - + /** * taskNoõflowTask󣬸phaseAction, phaseOpinionύ - * + * * @return */ public String submit(JBOTransaction tx) throws Exception { @@ -985,25 +987,25 @@ public class FlowAction { } else if (!StringX.isEmpty(ft.getAttribute("endTime"))) { return "Զύ"; } - + // BizObjectManager utdbom = JBOFactory.getBizObjectManager(USER_TASK_DATA.CLASS_NAME, tx); BizObjectManager utibom = JBOFactory.getBizObjectManager(USER_TASK_INFO.CLASS_NAME, tx); BizObject utdbo = utdbom.createQuery("taskno = '" + taskNo + "' and userid = '" + userID + "' and (status = 'approve_status01' or status = 'approve_status03')").getSingleResult(true); if(utdbo != null) { - int taskNumber = utibom.createQuery("userid = '" + utdbo.getAttribute("userid") + int taskNumber = utibom.createQuery("userid = '" + utdbo.getAttribute("userid") + "' and roleid = '" + utdbo.getAttribute("roleid") + "'").getSingleResult(false).getAttribute("task_number").getInt(); ARE.getLog().info("***********־***:Ϊ"+ taskNo + "" + utdbo.getAttribute("userid") + "ûرһ񣬵ǰδΪ" + taskNumber); String status = utdbo.getAttribute("status").toString(); if("approve_status01".equals(status)) { - utibom.createQuery("update O set task_number = task_number - 1 where userid = '" + utdbo.getAttribute("userid") + utibom.createQuery("update O set task_number = task_number - 1 where userid = '" + utdbo.getAttribute("userid") + "' and roleid = '" + utdbo.getAttribute("roleid") + "'").executeUpdate(); } utdbo.setAttributeValue("status", "approve_status02"); utdbo.setAttributeValue("endtime", StringFunction.getTodayNow()); utdbom.saveObject(utdbo); } - + // beginTimeЩ¼ ftManager .createQuery( @@ -1056,7 +1058,7 @@ public class FlowAction { return str; } } - + if (!StringX.isSpace(phaseAction)) phaseAction = phaseAction.replace("@", ","); @@ -1091,7 +1093,7 @@ public class FlowAction { .setParameter("serialNo", taskNo) .setParameter("phaseAction", "һ֧ûн") .setParameter("endTime", endTime).executeUpdate(); - + }else{ flowService.commitAction(taskNo, phaseAction, phaseOpinion, "", tx); Transaction Sqlca =null; @@ -1105,9 +1107,9 @@ public class FlowAction { } }else{ flowService.commitAction(taskNo, phaseAction, phaseOpinion, "", tx); - + if(ft.getAttribute("FLOWSTATE").getString().equals("ANYBACK")){ //˻֮ύ - + if(ft.getAttribute("ASSIGNEDTASKNO")!=null){ if(ft.getAttribute("ASSIGNEDTASKNO").getString().length()>0){//˻ύԭҪ״̬ ftManager.createQuery("update o set FLOWSTATE='NORMAL' WHERE objectno=:objectno and endtime is null") @@ -1140,7 +1142,7 @@ public class FlowAction { /** * ,flowStateΪvoted - * + * * @return */ public String endMeetingTask(JBOTransaction tx) throws Exception { @@ -1164,7 +1166,7 @@ public class FlowAction { /** * ܽ׶εtaskNoõͶƱίԱ - * + * * @return */ public String getVotedNum(JBOTransaction tx) throws Exception { @@ -1242,7 +1244,7 @@ public class FlowAction { /** * objectType, objectNo,flowNo õList(StringBuffer)Ϊ̽ڵnodes, * ڵϢnodeText, ڵconn, ʵ·realPathStringBuffer - * + * * @return */ public List getFlowImgBufs() throws JBOException { @@ -1410,7 +1412,7 @@ public class FlowAction { /** * ָ - * + * * @param ReturnPoint * ѡָԱ޸ĵǰִԱ * @throws Exception @@ -1444,7 +1446,7 @@ public class FlowAction { /** * objectType,objectNoFLOW_TASKвµphaseNoҳύʱ¼Ƿύ - * + * * @return curPhaseNo--µphaseNo */ public String getPhaseDescribe(JBOTransaction tx) throws Exception { @@ -2004,5 +2006,5 @@ public class FlowAction { public void setNextNodeType(String nextNodeType) { this.nextNodeType = nextNodeType; } - + } diff --git a/src_core/com/tenwa/flow/task/BaseFlowTaskDataService.java b/src_core/com/tenwa/flow/task/BaseFlowTaskDataService.java index cfd30776a..8846a3abf 100644 --- a/src_core/com/tenwa/flow/task/BaseFlowTaskDataService.java +++ b/src_core/com/tenwa/flow/task/BaseFlowTaskDataService.java @@ -38,8 +38,8 @@ public class BaseFlowTaskDataService { public MapflowParam=new HashMap(); public String sFlowParam=""; public MapflowStepBeans=new HashMap(); - public ListcallBackBean=new ArrayList(); - + public ListcallBackBean=new ArrayList(); + public BaseFlowTaskDataService(JBOTransaction tx,String flowUnid,String flowNo,String taskNo,MapcParam)throws Exception{ this.flowUnid=flowUnid; this.baseTx=tx; @@ -51,11 +51,11 @@ public class BaseFlowTaskDataService { } //ʼɾڵ public void initDeleteNodes()throws Exception{ - + } //ʼ鵵ڵ public void initPhaseNodes()throws Exception{ - + } public void exectueFlowDelete()throws Exception{ String deleteSctip=getFlowDeleteScript(); @@ -64,17 +64,17 @@ public class BaseFlowTaskDataService { } public void exectureGroovyScript(String groovyScript) throws Exception{ if(null!=groovyScript && groovyScript.length()>5){ - ScriptEngineManager factory = new ScriptEngineManager(); - //ÿһengineʵ - ScriptEngine engine = factory.getEngineByName("groovy"); - assert engine != null; - //javax.script.Bindings - Bindings binding = engine.createBindings(); - binding.put("TreeView",this); + ScriptEngineManager factory = new ScriptEngineManager(); + //ÿһengineʵ + ScriptEngine engine = factory.getEngineByName("groovy"); + assert engine != null; + //javax.script.Bindings + Bindings binding = engine.createBindings(); + binding.put("TreeView",this); binding.put("fixedParam", this.getFlowParam()); - //scriptıļ,Ȼȡļ - engine.eval("def deleteFlowCheckNode(){"+groovyScript+"}",binding); - Object time = (Object)((Invocable)engine).invokeFunction("deleteFlowCheckNode", null); + //scriptıļ,Ȼȡļ + engine.eval("def deleteFlowCheckNode(){"+groovyScript+"}",binding); + Object time = (Object)((Invocable)engine).invokeFunction("deleteFlowCheckNode", null); } } public void removeDeleteNode(String nodeno)throws Exception{ @@ -115,7 +115,7 @@ public class BaseFlowTaskDataService { BizObjectManager prodNodeInfoManger = JBOFactory.getBizObjectManager(AWE_DO_CATALOG.CLASS_NAME); BizObject template=prodNodeInfoManger.createQuery("SELECT jboclass,jbowhere FROM O WHERE dono=:dono and jboclass<>'jbo.app.tenwa.doc.LB_DOCRELATIVE' and jboclass<>'jbo.app.tenwa.doc.LB_DOCLIBRARY' ").setParameter("dono",tempNO).getSingleResult(false); if(template!=null){ - this.executeJboDeleteOrUpdateSQL(template.getAttribute("jboclass").getString(), "delete from O where O.FlowUnid=:FlowUnid", cparam); + this.executeJboDeleteOrUpdateSQL(template.getAttribute("jboclass").getString(), "delete from O where O.FlowUnid=:FlowUnid", cparam); } } public void executeJboDeleteOrUpdateSQL(String jboClass,String sql,Mapcparam)throws Exception{ @@ -141,9 +141,19 @@ public class BaseFlowTaskDataService { } } } - public void phaseFlowStepData() throws Exception{ - String phaseSctip=this.getFlowPhaseScript(); - this.exectureGroovyScript(phaseSctip); + + public void phaseFlowStepData() throws Exception { + phaseFlowStepData ( null ); + } + + public void phaseFlowStepData( String phaseNo ) throws Exception{ + String phaseSctip = null; + if (phaseNo == null) { + phaseSctip = this.getFlowPhaseScript(); + } else { + phaseSctip = this.getFlowPhaseScript( phaseNo ); + } + this.exectureGroovyScript(phaseSctip); this.callBackBean.addAll(this.flowStepBeans.values()); for(String nodes:this.flowStepBeans.keySet()){ String templateData=""; @@ -165,8 +175,8 @@ public class BaseFlowTaskDataService { boFPH.setAttributeValue("taskno", paramMap.get("TaskNo")); bm.saveObject(boFPH); }else if(stepBean.getOperatorType().equals("script")){ - - this.executeFlowScript(stepBean.getOperatorContent(), paramMap); + + this.executeFlowScript(stepBean.getOperatorContent(), paramMap); } } } @@ -180,7 +190,7 @@ public class BaseFlowTaskDataService { key=key.replace(":",""); param.add(key); } - return param; + return param; } public String getPageNodesId(Mapnodes)throws Exception{ @@ -213,43 +223,57 @@ public class BaseFlowTaskDataService { } return ""; } - + + public String getFlowPhaseScript() throws Exception { + return getFlowPhaseScript( null ); + } + /** * õһĹ鵵ű * @param tx * @param sObjectNo * @throws Exception */ - public String getFlowPhaseScript() throws Exception { - Transaction Sqlca = null; - BizObject taskObject=JBOFactory.getFactory().getManager(FLOW_TASK.CLASS_NAME).createQuery("SELECT phaseno FROM o WHERE o.serialno =:taskno").setParameter("taskno", this.taskNo).getSingleResult(false); - BizObjectManager bm1 = null; - BizObjectQuery bq1 = null; - bm1 = JBOFactory.getFactory().getManager(FLOW_MODEL.CLASS_NAME); - bq1 = bm1.createQuery("SELECT o.PHASESCRIPT FROM O where O.phaseno=:phaseno and O.flowno=:flowno").setParameter("flowno",this.flowNo) - .setParameter("phaseno", taskObject.getAttribute("phaseno").getString()); - BizObject stepConfig = bq1.getSingleResult(true); - if(stepConfig.getAttribute("PHASESCRIPT")==null){return "";} - String strScript = stepConfig.getAttribute("PHASESCRIPT").getString(); - if (null != strScript && strScript.length() > 5) { - return strScript; + public String getFlowPhaseScript( String phaseNo ) throws Exception { + if ( phaseNo == null ) { + BizObject taskObject=JBOFactory.getFactory().getManager(FLOW_TASK.CLASS_NAME).createQuery("SELECT phaseno FROM o WHERE o.serialno =:taskno").setParameter("taskno", this.taskNo).getSingleResult(false); + BizObjectManager bm1 = null; + BizObjectQuery bq1 = null; + bm1 = JBOFactory.getFactory().getManager(FLOW_MODEL.CLASS_NAME); + bq1 = bm1.createQuery("SELECT o.PHASESCRIPT FROM O where O.phaseno=:phaseno and O.flowno=:flowno").setParameter("flowno",this.flowNo) + .setParameter("phaseno", taskObject.getAttribute("phaseno").getString()); + BizObject stepConfig = bq1.getSingleResult(true); + if(stepConfig.getAttribute("PHASESCRIPT")==null){return "";} + String strScript = stepConfig.getAttribute("PHASESCRIPT").getString(); + if (null != strScript && strScript.length() > 5) { + return strScript; + } + return ""; + } else { + BizObjectManager bm = JBOFactory.getFactory().getManager( FLOW_MODEL.CLASS_NAME ); + BizObject bo = bm.createQuery( "SELECT o.PHASESCRIPT FROM O where O.phaseno = :phaseNo and O.flowno = :flowNo" ) + .setParameter( "phaseNo", phaseNo ).setParameter( "flowNo", this.flowNo ).getSingleResult( false ); + if ( bo != null && bo.getAttribute("PHASESCRIPT") != null ) { + return bo.getAttribute("PHASESCRIPT").toString(); + } else { + return ""; + } } - return ""; } - - - + + + /** * ִǰؼ - * + * * @param tx * @param sObjectNo * @throws Exception */ public void executeFlowScript(String script,Mapcparam) throws Exception { Map scriptMap = new HashMap(); - - if (null != script && script.length() > 5) { + + if (null != script && script.length() > 5) { ELContext context = new ELContext(); context.setJBOTransaction(this.baseTx); for (String key : cparam.keySet()) { @@ -259,8 +283,8 @@ public class BaseFlowTaskDataService { Any returnData = Expression.getExpressionValue(script, context); } } - - + + public String getFlowUnid() { return flowUnid; } @@ -279,7 +303,7 @@ public class BaseFlowTaskDataService { public void setBaseTx(JBOTransaction baseTx) { this.baseTx = baseTx; } - + public Map getFlowParam() { return flowParam; } @@ -298,5 +322,5 @@ public class BaseFlowTaskDataService { public void setFlowStepBeans(Map flowStepBeans) { this.flowStepBeans = flowStepBeans; } - + } diff --git a/src_sys/com/tenwa/flow/action/comm/BaseFlowStartAction.java b/src_sys/com/tenwa/flow/action/comm/BaseFlowStartAction.java index 8b256a77c..6dba4f5e1 100644 --- a/src_sys/com/tenwa/flow/action/comm/BaseFlowStartAction.java +++ b/src_sys/com/tenwa/flow/action/comm/BaseFlowStartAction.java @@ -4,6 +4,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import apx.com.amarsoft.als.base.flow.FlowTask; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.amarsoft.app.flow.FlowAction; +import com.amarsoft.awe.util.ASResultSet; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; 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; @@ -24,29 +31,32 @@ public class BaseFlowStartAction extends FlowBussionAction { public void setError_message(String error_message) { this.error_message = error_message; } + + //һҪύIJ + private String submitTask; + + private String operator; + + public String getSubmitTask() { + return submitTask; + } + + public void setSubmitTask(String submitTask) { + this.submitTask = submitTask; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + @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); + return this.startFlow( tx, createBusinessObject( tx ) ); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -54,6 +64,90 @@ public class BaseFlowStartAction extends FlowBussionAction { return error_message; } } + + public String createBusinessObject ( JBOTransaction tx ) throws Exception { + //ʼǰûϢ + 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 flowunid; + } + + //ӿڵ÷̷ + @Override + public String interfaceInitFlow ( JBOTransaction tx ) throws Exception { + String sReturn = ""; + try { + String flowunid = createBusinessObject( tx ); + String sResult = this.startFlow( tx, flowunid ); + if ( sResult.indexOf( "success" ) != -1 ) { + //ʼݲύָ + String submitTask = this.getSubmitTask(); + if ( submitTask != null && !"".equals( submitTask ) ) { + //ִҪύIJ + FlowAction flowAction = new FlowAction(); + BizObject flowTask = JBOFactory.getBizObjectManager( "jbo.sys.FLOW_TASK", tx ) + .createQuery( " objectno = :FlowUnid" ) + .setParameter( "FlowUnid", flowunid ) + .getSingleResult( false ); + //õǰ + flowAction.setTaskNo( flowTask.getAttribute("SERIALNO").toString() ); + flowAction.setUserID( this.getOperator() ); + flowAction.setFlowNo( this.getFlowNo() ); + flowAction.setUserID( this.CurUserID ); + flowAction.setNextNodeType( "TASK" ); + if ( !"1000".equals( submitTask ) ) { + //ȡύĴϢ + ASResultSet rs = null; + Transaction tran = Transaction.createTransaction( tx ); + try { + rs = tran.getASResultSet( new SqlObject( "select actionscript from flow_model where phaseno = '" + + submitTask + "' and flowno = '" + this.getFlowNo() + "'" ) ); + if( rs.next() ) { + String actionScript = rs.getString( "actionscript" ); + flowAction.setPhaseOpinion( submitTask ); + JSONArray ja = JSONArray.parseArray( actionScript ); + JSONObject obj = ja.getJSONObject( 0 ); + flowAction.setPhaseAction( obj.getString( "userinfo" ).replaceAll( ",", " " ) ); + } else { + throw new Exception( "δҵϢ" ); + } + } catch(Exception e) { + e.printStackTrace(); + throw new Exception("ȡʧ"); + } finally { + if(rs != null) rs.close(); + } + } else { + flowAction.setPhaseOpinion( submitTask ); + flowAction.setPhaseAction( "AutoFinish" ); + } + flowAction.submit( tx ); + } + sReturn = "success@" + flowunid; + } + } catch (Exception e) { + e.printStackTrace(); + tx.rollback(); + sReturn = error_message; + } + return sReturn; + } /** * ֮ǰԶ * @param tx @@ -61,9 +155,9 @@ public class BaseFlowStartAction extends FlowBussionAction { * @throws Exception */ public void customOperation(JBOTransaction tx,BizObject flowBussiness)throws Exception{ - + } - + /** *̻ * @param tx @@ -96,7 +190,7 @@ public class BaseFlowStartAction extends FlowBussionAction { if(OperatorUser.length()>0){OperatorUser+=",";} OperatorUser=OperatorUser+flowTask.get(k).getAttribute("username").getString(); } - } + } if(res!=""){ res+=","; } @@ -139,5 +233,5 @@ public class BaseFlowStartAction extends FlowBussionAction { } } } - + } diff --git a/src_sys/com/tenwa/flow/action/comm/CommonAction.java b/src_sys/com/tenwa/flow/action/comm/CommonAction.java index d0c00f81c..d8ebadb13 100644 --- a/src_sys/com/tenwa/flow/action/comm/CommonAction.java +++ b/src_sys/com/tenwa/flow/action/comm/CommonAction.java @@ -24,6 +24,11 @@ public abstract class CommonAction extends BaseTable { return null; }; + //һڽӿڵõķ̷, һЩҪϢ + public String interfaceInitFlow ( JBOTransaction tx ) throws Exception { + return null; + }; + public String deleteFlow(JBOTransaction tx) throws Exception { this.getFlowService().delete(ObjectNo, ObjectType, tx); return "success"; @@ -56,10 +61,10 @@ public abstract class CommonAction extends BaseTable { }else{ returnValue = "failed" + "@" + flowAction.getTaskNo(); } - + return returnValue; } - + public String getApplyType() { @@ -81,7 +86,7 @@ public abstract class CommonAction extends BaseTable { }else{ return flowService; } - + } public String getObjectNo() { diff --git a/src_sys/com/tenwa/flow/action/comm/FlowController.java b/src_sys/com/tenwa/flow/action/comm/FlowController.java new file mode 100644 index 000000000..b1f6c87f3 --- /dev/null +++ b/src_sys/com/tenwa/flow/action/comm/FlowController.java @@ -0,0 +1,69 @@ +package com.tenwa.flow.action.comm; + +import com.amarsoft.awe.util.JavaMethod; +import com.amarsoft.context.ASUser; +import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.stereotype.Controller; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URLDecoder; +import java.util.HashMap; +import java.util.Map; + +@Controller +public class FlowController extends HttpServlet { + + public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + this.doGet(request, response); + } + + /** + * 共需要传递几个基础参数 + * ClassName: 用于查找需要执行的startAction + * Args内必须提供参数 + * ApplyType: 用于查找哪个流程 + * @return + */ + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + response.setContentType( "text/html; charset=GBK" ); + response.setHeader( "Cache-Control", "no-store" ); + response.setHeader( "Pragma", "no-cache" ); + response.setDateHeader( "Expires", 0L ); + response.setCharacterEncoding( "utf-8" ); + PrintWriter out = response.getWriter(); + Map result = new HashMap<>(); + String sClassName = request.getParameter( "ClassName" ); + //发起流程固定initFLow + String sMethodName = "interfaceInitFlow"; + String sArgs = request.getParameter( "Args" ); + try { + if ( sArgs == null ) { + sArgs = ""; + } else { + if ( sArgs.indexOf( "CurUserID" ) == -1 ) { + sArgs += ",CurUserID=8006U00000001"; + } + sArgs = URLDecoder.decode(sArgs, "UTF-8").replace("Ж", "+").replace("ё", "%"); + } + ASUser CurUser = ASUser.getUser( "8006U00000001", null ); + String sResult = JavaMethod.runTrans( sClassName, sMethodName, sArgs, CurUser ).getReturnText(); + if ( sResult.indexOf( "success" ) == -1 ) { + throw new Exception( "发起流程失败" ); + } + result.put( "data", sResult.split( "@" )[ 1 ] ); + result.put( "status", "success" ); + } catch ( Exception e ) { + e.printStackTrace(); + result.put( "status", "error" ); + } + ObjectMapper objectMapper = new ObjectMapper(); + out.print( objectMapper.writeValueAsString( result ) ); + out.flush(); + out.close(); + } +}