添加流程重复提交校验
This commit is contained in:
parent
a2be8ebd25
commit
170daa93e1
@ -115,7 +115,7 @@ FlowFunction.doSubmit=function(sObjectType,sObjectNo,sTaskNo,sFlowName,sFlowNo,s
|
||||
alert("提交成功!");
|
||||
FlowFunction.successCallBackReload();
|
||||
}else{
|
||||
alert("Ìύʧ°Ü!");
|
||||
alert(sPhaseInfo);
|
||||
}
|
||||
},"提交下一步");}
|
||||
},sFlowName+":预警检查");
|
||||
|
||||
@ -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<String> 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<String, String> condtion = new HashMap<String, String>();
|
||||
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<String, String> condtion = new HashMap<String, String>();
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user