提交接口发起流程代码

This commit is contained in:
zhulh 2019-08-06 15:17:58 +08:00
parent 1b2b092f88
commit d3e998f2fb
6 changed files with 344 additions and 142 deletions

View File

@ -54,7 +54,7 @@
<filter-name>RunFilter</filter-name>
<url-pattern>/servlet/view/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>WebServiceFilter</filter-name>
<filter-class>com.tenwa.makeContract.WebServiceFilter</filter-class>
@ -63,7 +63,7 @@
<filter-name>WebServiceFilter</filter-name>
<url-pattern>/services/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>InitAREServlet</servlet-name>
<servlet-class>com.amarsoft.are.InitAREServlet</servlet-class>
@ -110,7 +110,7 @@
<param-value>GBK</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>InitSecondHandCarConfig</servlet-name>
<servlet-class>com.amarsoft.app.awe.config.InitSecondHandCarConfig</servlet-class>
@ -120,7 +120,7 @@
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>InitCollectConfig</servlet-name>
<servlet-class>com.amarsoft.app.awe.config.InitCollectConfig</servlet-class>
@ -130,7 +130,7 @@
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>RewriteRunJavaMethodServlet</servlet-name>
<servlet-class>com.tenwa.workflow.RewriteRunJavaMethodServlet</servlet-class>
@ -164,6 +164,10 @@
<param-value>als</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>FlowController</servlet-name>
<servlet-class>com.tenwa.flow.action.comm.FlowController</servlet-class>
</servlet>
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
@ -252,6 +256,10 @@
<servlet-name>RedirectorDialogServlet</servlet-name>
<url-pattern>/RedirectorDialog</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FlowController</servlet-name>
<url-pattern>/startFlow</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RunJavaMethodServlet</servlet-name>
<url-pattern>/servlet/run</url-pattern>
@ -507,7 +515,7 @@
<servlet-name>RestfullServlet</servlet-name>
<url-pattern>/webapi/resf/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>
@ -518,8 +526,8 @@
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<context-param>
<description>restfull自动扫描路径设置</description>
<param-name>RestfullScanPackage</param-name>
@ -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 @@
<param-name>NoCheckURI</param-name>
<param-value>
<!-- 用户 登录/注销 -->
/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 @@
<!--- ================================== -->
<!-- 支持webapi-结束 -->
<!--- ================================== -->
</web-app>
</web-app>

View File

@ -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,objectNo从FLOW_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<String, String> 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, 实际路径realPath的StringBuffer对象
*
*
* @return
*/
public List<StringBuffer> getFlowImgBufs() throws JBOException {
@ -1410,7 +1412,7 @@ public class FlowAction {
/**
* 工作指派
*
*
* @param ReturnPoint
* 选择指派人员修改当前任务执行人员机构
* @throws Exception
@ -1444,7 +1446,7 @@ public class FlowAction {
/**
* 根据objectType,objectNo从FLOW_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;
}
}

View File

@ -38,8 +38,8 @@ public class BaseFlowTaskDataService {
public Map<String,String>flowParam=new HashMap<String,String>();
public String sFlowParam="";
public Map<String,FlowStepBean>flowStepBeans=new HashMap<String,FlowStepBean>();
public List<FlowStepBean>callBackBean=new ArrayList<FlowStepBean>();
public List<FlowStepBean>callBackBean=new ArrayList<FlowStepBean>();
public BaseFlowTaskDataService(JBOTransaction tx,String flowUnid,String flowNo,String taskNo,Map<String,String>cParam)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,Map<String,String>cparam)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(Map<String,String>nodes)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,Map<String,String>cparam) throws Exception {
Map<String, String> scriptMap = new HashMap<String, String>();
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<String, String> getFlowParam() {
return flowParam;
}
@ -298,5 +322,5 @@ public class BaseFlowTaskDataService {
public void setFlowStepBeans(Map<String, FlowStepBean> flowStepBeans) {
this.flowStepBeans = flowStepBeans;
}
}

View File

@ -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;
}
//补充一个需要提交步骤的参数
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="";
//生成业务流程数据并返回流程的编号
Map<String,String>deleteCondition=new HashMap<String,String>();
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 = "";
//生成业务流程数据并返回流程的编号
Map<String,String>deleteCondition = new HashMap<String,String>();
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 ) ) {
//执行需要提交的步骤
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 {
}
}
}
}

View File

@ -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() {

View File

@ -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<String, Object> 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();
}
}