From 170daa93e17d877c1fcec1b0cc947c03f0066023 Mon Sep 17 00:00:00 2001 From: gityjf <2211675158@qq.com> Date: Fri, 29 Jan 2021 15:34:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=81=E7=A8=8B=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=8F=90=E4=BA=A4=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseFunction/BaseFlowFunction.jspf | 2 +- src/com/amarsoft/app/flow/FlowAction.java | 296 +++++++++--------- 2 files changed, 152 insertions(+), 146 deletions(-) diff --git a/WebContent/Tenwa/Core/FlowManager/BaseFunction/BaseFlowFunction.jspf b/WebContent/Tenwa/Core/FlowManager/BaseFunction/BaseFlowFunction.jspf index 2b997e5bf..92dcb115c 100644 --- a/WebContent/Tenwa/Core/FlowManager/BaseFunction/BaseFlowFunction.jspf +++ b/WebContent/Tenwa/Core/FlowManager/BaseFunction/BaseFlowFunction.jspf @@ -115,7 +115,7 @@ FlowFunction.doSubmit=function(sObjectType,sObjectNo,sTaskNo,sFlowName,sFlowNo,s alert("提交成功!"); FlowFunction.successCallBackReload(); }else{ - alert("提交失败!"); + alert(sPhaseInfo); } },"提交下一步");} },sFlowName+":预警检查"); diff --git a/src/com/amarsoft/app/flow/FlowAction.java b/src/com/amarsoft/app/flow/FlowAction.java index bf85fd3d6..494cbb258 100644 --- a/src/com/amarsoft/app/flow/FlowAction.java +++ b/src/com/amarsoft/app/flow/FlowAction.java @@ -2,13 +2,7 @@ package com.amarsoft.app.flow; import java.sql.SQLException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; +import java.util.*; import jbo.app.APP_BUSINESS_TEMPLATE; import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; @@ -248,6 +242,9 @@ public class FlowAction { this.flowService = flowService; } + //处理重复提交数据重复,只适用单体服务 + private static Set taskSet = new HashSet<>(); + /** * 初始化流程 * @@ -1027,70 +1024,76 @@ public class FlowAction { */ public String submit(JBOTransaction tx) throws Exception { String str = "success", attribute7, endTime = StringFunction.getTodayNow(); - int attribute8; - BizObjectManager ftManager = JBOFactory.getBizObjectManager("jbo.sys.FLOW_TASK", tx); - - BizObject ft = ftManager.createQuery( - "select O.relativeSerialNo,O.endTime,FM.attribute7,FM.attribute8 from O,jbo.sys.FLOW_MODEL FM where O.flowNo=FM.flowNo and O.phaseNo=FM.phaseNo and serialNo=:serialNo ") - .setParameter("serialNo", taskNo).getSingleResult(false); - if (ft == null) {return "此流程任务已经不存在,请刷新列表!"; - } else if (!StringX.isEmpty(ft.getAttribute("endTime"))) { - return "此流程任务已自动提交!"; + if(taskSet.contains(taskNo)){ + return "此流程任务已发起提交,勿重复发起!"; } + try { + ARE.getLog().warn("duplicate data validate use flow_task : "+taskNo); + taskSet.add(taskNo); + int attribute8; + BizObjectManager ftManager = JBOFactory.getBizObjectManager("jbo.sys.FLOW_TASK", tx); - //处理任务池 - 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") - + "' 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") - + "' and roleid = '" + utdbo.getAttribute("roleid") + "'").executeUpdate(); + BizObject ft = ftManager.createQuery( + "select O.relativeSerialNo,O.endTime,FM.attribute7,FM.attribute8 from O,jbo.sys.FLOW_MODEL FM where O.flowNo=FM.flowNo and O.phaseNo=FM.phaseNo and serialNo=:serialNo ") + .setParameter("serialNo", taskNo).getSingleResult(false); + if (ft == null) {return "此流程任务已经不存在,请刷新列表!"; + } else if (!StringX.isEmpty(ft.getAttribute("endTime"))) { + return "此流程任务已自动提交!"; } - utdbo.setAttributeValue("status", "approve_status02"); - utdbo.setAttributeValue("endtime", StringFunction.getTodayNow()); - utdbom.saveObject(utdbo); - } - // 更新beginTime锁这些记录 - ftManager - .createQuery( - "update O set beginTime=beginTime where relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' ") - .setParameter("relativeSerialNo", - ft.getAttribute("relativeSerialNo").getString()) - .executeUpdate(); - // 查相同relativeserialno且不是5000传阅阶段的记录 - BizObject allTaskNumBo = ftManager - .createQuery(" select count(1) as v.allTaskNum from O where relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' ") - .setParameter("relativeSerialNo",ft.getAttribute("relativeSerialNo").getString()).getSingleResult(false); - int allTaskNum = allTaskNumBo.getAttribute("allTaskNum").getInt(); - //多人处理 - if (allTaskNum > 1) { - attribute7 = ft.getAttribute("attribute7").getString();// 01,单人处理,02,多人全部,03,多人任一,04,N人处理 - attribute8 = ft.getAttribute("attribute8").getInt();// N人处理时设置的人数 - if ("04".equals(attribute7)&& (ft.getAttribute("attribute8").isNull()|| attribute8 >= allTaskNum || attribute8 < 1)) { - // 如果N人处理时没设置人数,则当做 - // 02,多人全部 - attribute7 = "02"; + //处理任务池 + 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") + + "' 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") + + "' and roleid = '" + utdbo.getAttribute("roleid") + "'").executeUpdate(); + } + utdbo.setAttributeValue("status", "approve_status02"); + utdbo.setAttributeValue("endtime", StringFunction.getTodayNow()); + utdbom.saveObject(utdbo); } - // 已提交的任务数 - BizObject commitedTaskNumBo = ftManager + + // 更新beginTime锁这些记录 + ftManager .createQuery( - " select count(1) as v.commited from O where relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' and endTime is not null and length(endTime)>0 ") + "update O set beginTime=beginTime where relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' ") .setParameter("relativeSerialNo", ft.getAttribute("relativeSerialNo").getString()) - .getSingleResult(false); - int commited = commitedTaskNumBo.getAttribute("commited").getInt(); + .executeUpdate(); + // 查相同relativeserialno且不是5000传阅阶段的记录 + BizObject allTaskNumBo = ftManager + .createQuery(" select count(1) as v.allTaskNum from O where relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' ") + .setParameter("relativeSerialNo",ft.getAttribute("relativeSerialNo").getString()).getSingleResult(false); + int allTaskNum = allTaskNumBo.getAttribute("allTaskNum").getInt(); + //多人处理 + if (allTaskNum > 1) { + attribute7 = ft.getAttribute("attribute7").getString();// 01,单人处理,02,多人全部,03,多人任一,04,N人处理 + attribute8 = ft.getAttribute("attribute8").getInt();// N人处理时设置的人数 + if ("04".equals(attribute7)&& (ft.getAttribute("attribute8").isNull()|| attribute8 >= allTaskNum || attribute8 < 1)) { + // 如果N人处理时没设置人数,则当做 + // 02,多人全部 + attribute7 = "02"; + } + // 已提交的任务数 + BizObject commitedTaskNumBo = ftManager + .createQuery( + " select count(1) as v.commited from O where relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' and endTime is not null and length(endTime)>0 ") + .setParameter("relativeSerialNo", + ft.getAttribute("relativeSerialNo").getString()) + .getSingleResult(false); + int commited = commitedTaskNumBo.getAttribute("commited").getInt(); - if ("02".equals(attribute7) && commited + 1 < allTaskNum /* + if ("02".equals(attribute7) && commited + 1 < allTaskNum /* * 多人全部,已提交人数 * +1<总人数 */ - || "04".equals(attribute7) && commited + 1 < attribute8 /* + || "04".equals(attribute7) && commited + 1 < attribute8 /* * N人处理, * 已提交人数 * + @@ -1098,95 +1101,98 @@ public class FlowAction { * < * N */) { - // 仅结束当前任务 - ftManager - .createQuery( - "update O set endTime=:endTime,phaseAction=:phaseAction where serialNo=:serialNo") - .setParameter("serialNo", taskNo) - .setParameter("phaseAction", "未达到人数") - .setParameter("endTime", endTime).executeUpdate(); - return str; + // 仅结束当前任务 + ftManager + .createQuery( + "update O set endTime=:endTime,phaseAction=:phaseAction where serialNo=:serialNo") + .setParameter("serialNo", taskNo) + .setParameter("phaseAction", "未达到人数") + .setParameter("endTime", endTime).executeUpdate(); + return str; + } } + + if (!StringX.isSpace(phaseAction)) + phaseAction = phaseAction.replace("@", ","); + + // 根据任务编号,查出流程的编号,阶段编号,对象类型,对象编号:新增加xuyunlong 归档每一步归档 + ft = ftManager + .createQuery( + "select O.flowno,O.phaseno,O.FLOWSTATE,O.ASSIGNEDTASKNO,O.objecttype,O.objectno,O.userid,O.orgid from O where serialNo=:serialNo ") + .setParameter("serialNo", taskNo).getSingleResult(false); + // 将数据保存到历史记录里 + PhaseInfoArchive(ft.getAttribute("flowno").getString(), ft + .getAttribute("phaseno").getString(), + ft.getAttribute("objecttype").getString(), + ft.getAttribute("objectno").getString(), taskNo, ft + .getAttribute("userid").getString(), + ft.getAttribute("orgid").getString(), tx); + + if (this.phaseOpinion.equals("1000") + || this.phaseOpinion.equals("8000")) { + // 删除流程互斥 + FlowUtil.deleteWorkFlowConflict(ft.getAttribute("objectno") + .getString(), tx); + Map condtion = new HashMap(); + condtion.put("FlowUnid", ft.getAttribute("objectno").getString()); + DataOperatorUtil.deleteJBOByCondtion(FLOW_STEP_NODE.CLASS_NAME, + condtion, tx); + } + if(this.nextNodeType.indexOf("JOIN")>=0){ + if(this.getIsStepLastUser(tx).equals("No")){ + ftManager + .createQuery( + "update O set endTime=:endTime,phaseAction=:phaseAction,taskstate=1 where serialNo=:serialNo") + .setParameter("serialNo", taskNo) + .setParameter("phaseAction", "另外一个分支没有结束") + .setParameter("endTime", endTime).executeUpdate(); + + }else{ + flowService.commitAction(taskNo, phaseAction, phaseOpinion, "", tx); + Transaction Sqlca =null; + Sqlca = Transaction.createTransaction(tx); + ASResultSet rs = null; + String sql="update flow_task set userid=replace(userid,'*','') where objectno=:objectno and userid like '*%' "; + SqlObject asql = new SqlObject(sql); + asql.setParameter("objectno",ft.getAttribute("objectno").getString()); + Sqlca.executeSQL(asql); + } + }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") + .setParameter("objectno", ft.getAttribute("objectno").getString()).executeUpdate(); + } + } + } + } + // 更新代理人 + BizObject taskUser = ftManager.createQuery("select O.userId from O where O.SERIALNO=:taskNo").setParameter("taskNo", this.taskNo).getSingleResult(false); + if (!taskUser.getAttribute("userId").getString().equals(this.userID)) { + this.doFinishAssignTask(tx); + } + // 更新其他任务的endTime + ftManager + .createQuery( + "update O set endTime=:endTime, phaseAction=:phaseAction where ( endTime is null or endTime='' ) and relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' ") + .setParameter("relativeSerialNo", + ft.getAttribute("relativeSerialNo").getString()) + .setParameter("endTime", endTime) + .setParameter("phaseAction", "AutoFinish").executeUpdate(); + // 生成传阅的代办 + this.startPassedByUser(tx); + savePushMsg(tx); + //流程或步骤结束之后的通知 + new FLowStepEndNotice().StepEndNotice(tx, ft.getAttribute("objectno").getString(),this.taskNo,"next"); + }finally { + taskSet.remove(taskNo); + ARE.getLog().warn("current keep duplicate validate : "+taskSet.toString()); } - - if (!StringX.isSpace(phaseAction)) - phaseAction = phaseAction.replace("@", ","); - - // 根据任务编号,查出流程的编号,阶段编号,对象类型,对象编号:新增加xuyunlong 归档每一步归档 - ft = ftManager - .createQuery( - "select O.flowno,O.phaseno,O.FLOWSTATE,O.ASSIGNEDTASKNO,O.objecttype,O.objectno,O.userid,O.orgid from O where serialNo=:serialNo ") - .setParameter("serialNo", taskNo).getSingleResult(false); - // 将数据保存到历史记录里 - PhaseInfoArchive(ft.getAttribute("flowno").getString(), ft - .getAttribute("phaseno").getString(), - ft.getAttribute("objecttype").getString(), - ft.getAttribute("objectno").getString(), taskNo, ft - .getAttribute("userid").getString(), - ft.getAttribute("orgid").getString(), tx); - - if (this.phaseOpinion.equals("1000") - || this.phaseOpinion.equals("8000")) { - // 删除流程互斥 - FlowUtil.deleteWorkFlowConflict(ft.getAttribute("objectno") - .getString(), tx); - Map condtion = new HashMap(); - condtion.put("FlowUnid", ft.getAttribute("objectno").getString()); - DataOperatorUtil.deleteJBOByCondtion(FLOW_STEP_NODE.CLASS_NAME, - condtion, tx); - } - if(this.nextNodeType.indexOf("JOIN")>=0){ - if(this.getIsStepLastUser(tx).equals("No")){ - ftManager - .createQuery( - "update O set endTime=:endTime,phaseAction=:phaseAction,taskstate=1 where serialNo=:serialNo") - .setParameter("serialNo", taskNo) - .setParameter("phaseAction", "另外一个分支没有结束") - .setParameter("endTime", endTime).executeUpdate(); - - }else{ - flowService.commitAction(taskNo, phaseAction, phaseOpinion, "", tx); - Transaction Sqlca =null; - Sqlca = Transaction.createTransaction(tx); - ASResultSet rs = null; - String sql="update flow_task set userid=replace(userid,'*','') where objectno=:objectno and userid like '*%' "; - SqlObject asql = new SqlObject(sql); - asql.setParameter("objectno",ft.getAttribute("objectno").getString()); - Sqlca.executeSQL(asql); - } - }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") - .setParameter("objectno", ft.getAttribute("objectno").getString()).executeUpdate(); - } - } - } - } - // 更新代理人 - BizObject taskUser = ftManager.createQuery("select O.userId from O where O.SERIALNO=:taskNo").setParameter("taskNo", this.taskNo).getSingleResult(false); - if (!taskUser.getAttribute("userId").getString().equals(this.userID)) { - this.doFinishAssignTask(tx); - } - // 更新其他任务的endTime - ftManager - .createQuery( - "update O set endTime=:endTime, phaseAction=:phaseAction where ( endTime is null or endTime='' ) and relativeSerialNo=:relativeSerialNo and phaseNo<>'5000' ") - .setParameter("relativeSerialNo", - ft.getAttribute("relativeSerialNo").getString()) - .setParameter("endTime", endTime) - .setParameter("phaseAction", "AutoFinish").executeUpdate(); - // 生成传阅的代办 - this.startPassedByUser(tx); - savePushMsg(tx); - //流程或步骤结束之后的通知 - new FLowStepEndNotice().StepEndNotice(tx, ft.getAttribute("objectno").getString(),this.taskNo,"next"); return str; - } /**