增加任务池
This commit is contained in:
parent
851b0281e6
commit
a62eea6f4e
@ -67,8 +67,9 @@
|
||||
{usertype:'流程中指定步骤的人员'},
|
||||
{usertype:'提交人所在部门的角色'},
|
||||
{usertype:'流程发起人所在部门的角色'},
|
||||
{usertype:'选择指定任务池角色'},
|
||||
{usertype:'根据SQL语句'},
|
||||
{usertype:'根据java代码'}
|
||||
{usertype:'根据java代码'},
|
||||
];
|
||||
if("<%=selectbase%>"=="true"){
|
||||
jsonData=[{usertype:'指定人员'},
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
}*/
|
||||
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
|
||||
dwTemp.Style="1"; //设置DW风格 1:Grid 2:Freeform
|
||||
dwTemp.ReadOnly = "1"; //设置是否只读 1:只读 0:可写
|
||||
dwTemp.ReadOnly = "0"; //设置是否只读 1:只读 0:可写
|
||||
dwTemp.setPageSize(20);
|
||||
dwTemp.genHTMLObjectWindow("");
|
||||
String sButtons[][] = {
|
||||
@ -27,6 +27,7 @@
|
||||
{(CurUser.hasRole("099")||CurUser.hasRole("299")?"true":"false"),"","Button","主菜单授权","给角色授权主菜单","my_AddMenu()","","","","btn_icon_menu"},
|
||||
{(CurUser.hasRole("099")||CurUser.hasRole("299")?"true":"false"),"","Button","多角色菜单授权","给多个角色授权主菜单","much_AddMenu()","","","","btn_icon_roles"},
|
||||
{(CurUser.hasRole("099")||CurUser.hasRole("299")?"true":"false"),"","Button","变更生效","同步缓存中数据使数据库变更生效","reloadCacheRole()","","","","btn_icon_valid"},
|
||||
{(CurUser.hasRole("099")||CurUser.hasRole("299")?"true":"false"),"","Button","保存","保存","as_save(0)","","","","btn_icon_save"}
|
||||
};
|
||||
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
|
||||
<script type="text/javascript">
|
||||
|
||||
27
WebContent/AppConfig/RoleManage/UserTaskInfo.jsp
Normal file
27
WebContent/AppConfig/RoleManage/UserTaskInfo.jsp
Normal file
@ -0,0 +1,27 @@
|
||||
<%@ page contentType="text/html; charset=GBK"%>
|
||||
<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><%
|
||||
/*
|
||||
Author: undefined 2018-06-10
|
||||
Content: 示例详情页面
|
||||
History Log:
|
||||
*/
|
||||
String userId = CurPage.getParameter("UserId");
|
||||
String roleId = CurPage.getParameter("RoleId");
|
||||
String sTempletNo = "UserTaskInfo";//--模板号--
|
||||
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
|
||||
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
|
||||
dwTemp.Style = "2";//freeform
|
||||
//dwTemp.ReadOnly = "-2";//只读模式
|
||||
dwTemp.genHTMLObjectWindow(userId + "," + roleId);
|
||||
|
||||
String sButtons[][] = {
|
||||
{"true","All","Button","保存","保存所有修改","as_save(0, 'returnList()')","","","",""},
|
||||
{"true","","Button","返回","返回列表","returnList()","","","","btn_icon_return"}
|
||||
};
|
||||
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
|
||||
<script type="text/javascript">
|
||||
function returnList(){
|
||||
AsDialog.ClosePage();
|
||||
}
|
||||
</script>
|
||||
<%@ include file="/Frame/resources/include/include_end.jspf"%>
|
||||
@ -19,7 +19,8 @@
|
||||
dwTemp.ReadOnly = "1"; //设置是否只读 1:只读 0:可写
|
||||
dwTemp.genHTMLObjectWindow(sRoleID);
|
||||
String sButtons[][] = {
|
||||
{"true","","Button","导出Excel","导出Excel","exportAll()","","","",""},
|
||||
{"true","","Button","导出Excel","导出Excel","exportAll()","","","","btn_icon_export"},
|
||||
{"true","","Button","配置任务权重","配置任务权重","configWeight()","","","","btn_icon_edit"}
|
||||
};
|
||||
%> <%@include file="/Frame/resources/include/ui/include_list.jspf"%>
|
||||
<script type="text/javascript">
|
||||
@ -29,5 +30,14 @@
|
||||
//amarExport("myiframe0");
|
||||
as_defaultExport();
|
||||
}
|
||||
|
||||
function configWeight() {
|
||||
var userId = getItemValue(0,getRow(), "userid");
|
||||
var roleid = getItemValue(0,getRow(), "roleid");
|
||||
var sUrl = "/AppConfig/RoleManage/UserTaskInfo.jsp";
|
||||
AsDialog.PopView(sUrl,"UserId=" + userId + "&RoleId=" + roleid,"dialogWidth=900px;dialogHeight=380px;resizable=no;scrollbars=no;status:yes;maximize:no;help:no;",function(){
|
||||
reloadSelf();
|
||||
},"配置任务权重");
|
||||
}
|
||||
</script>
|
||||
<%@ include file="/Frame/resources/include/include_end.jspf"%>
|
||||
@ -130,6 +130,7 @@
|
||||
<attribute name="UPDATEUSER" label="更新人" type="STRING" length="32" />
|
||||
<attribute name="UPDATETIME" label="更新时间" type="STRING" length="20" />
|
||||
<attribute name="REMARK" label="备注" type="STRING" length="250" />
|
||||
<attribute name="TASK_POOL" label="ÈÎÎñ³Ø" type="STRING" length="32" />
|
||||
</attributes>
|
||||
<manager>
|
||||
<managerProperties>
|
||||
|
||||
@ -958,7 +958,8 @@
|
||||
<attribute name="INPUTTIME" label="录入时间" type="STRING" length="20"/>
|
||||
<attribute name="UPDATEUSER" label="更新人" type="STRING" length="32"/>
|
||||
<attribute name="UPDATETIME" label="更新时间" type="STRING" length="20"/>
|
||||
<attribute name="REMARK" label="备注" type="STRING" length="250"/>
|
||||
<attribute name="REMARK" label="备注" type="STRING" length="250"/>
|
||||
<attribute name="TASK_POOL" label="任务池" type="STRING" length="32"/>
|
||||
</attributes>
|
||||
<manager>
|
||||
<managerProperties>
|
||||
@ -1351,7 +1352,7 @@
|
||||
<attribute name="INPUTORG" label="登记机构" type="STRING" length="32"/>
|
||||
<attribute name="INPUTTIME" label="登记时间" type="STRING" length="20"/>
|
||||
<attribute name="UPDATEUSER" label="更新人" type="STRING" length="32"/>
|
||||
<attribute name="UPDATETIME" label="更新时间" type="STRING" length="20"/>
|
||||
<attribute name="UPDATETIME" label="更新时间" type="STRING" length="20"/>
|
||||
</attributes>
|
||||
<manager>
|
||||
<managerProperties>
|
||||
@ -2211,5 +2212,47 @@
|
||||
</managerProperties>
|
||||
</manager>
|
||||
</class>
|
||||
<class name="USER_TASK_DATA" label="" keyAttributes="id">
|
||||
<attributes>
|
||||
<attribute name="id" label="id" type="STRING" length="32"/>
|
||||
<attribute name="userid" label="userid" type="STRING" length="32"/>
|
||||
<attribute name="roleid" label="roleid" type="STRING" length="32"/>
|
||||
<attribute name="flowno" label="flowno" type="STRING" length="32"/>
|
||||
<attribute name="flowunid" label="flowunid" type="STRING" length="32"/>
|
||||
<attribute name="project_id" label="project_id" type="STRING" length="32"/>
|
||||
<attribute name="contract_id" label="contract_id" type="STRING" length="32"/>
|
||||
<attribute name="begintime" label="begintime" type="STRING" length="32"/>
|
||||
<attribute name="endtime" label="endtime" type="STRING" length="32"/>
|
||||
<attribute name="status" label="status" type="STRING" length="32"/>
|
||||
<attribute name="taskno" label="taskno" type="STRING" length="32"/>
|
||||
</attributes>
|
||||
<manager>
|
||||
<managerProperties>
|
||||
<property name="table" value="user_task_data" />
|
||||
<property name="createKey" value="true" />
|
||||
</managerProperties>
|
||||
</manager>
|
||||
</class>
|
||||
<class name="USER_TASK_INFO" label="" keyAttributes="roleid,userid">
|
||||
<attributes>
|
||||
<attribute name="userid" label="userid" type="STRING" length="32"/>
|
||||
<attribute name="roleid" label="roleid" type="STRING" length="32"/>
|
||||
<attribute name="task_weight" label="task_weight" type="STRING" length="32"/>
|
||||
<attribute name="task_number" label="task_number" type="STRING" length="32"/>
|
||||
<attribute name="induction_state" label="induction_state" type="STRING" length="32"/>
|
||||
<attribute name="inputuserid" label="inputuserid" type="STRING" length="32"/>
|
||||
<attribute name="inputorgid" label="inputorgid" type="STRING" length="32"/>
|
||||
<attribute name="inputtime" label="inputtime" type="STRING" length="32"/>
|
||||
<attribute name="updateuserid" label="updateuserid" type="STRING" length="32"/>
|
||||
<attribute name="updateorgid" label="updateorgid" type="STRING" length="32"/>
|
||||
<attribute name="updatetime" label="updatetime" type="STRING" length="32"/>
|
||||
</attributes>
|
||||
<manager>
|
||||
<managerProperties>
|
||||
<property name="table" value="user_task_info" />
|
||||
<property name="createKey" value="true" />
|
||||
</managerProperties>
|
||||
</manager>
|
||||
</class>
|
||||
</package>
|
||||
</jbo>
|
||||
|
||||
@ -18,6 +18,8 @@ import jbo.sys.FLOW_ENTRUSTED_USER;
|
||||
import jbo.sys.FLOW_MODEL;
|
||||
import jbo.sys.FLOW_TASK;
|
||||
import jbo.sys.FLOW_TASK_USER_HIS;
|
||||
import jbo.sys.USER_TASK_DATA;
|
||||
import jbo.sys.USER_TASK_INFO;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@ -489,6 +491,25 @@ 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);
|
||||
|
||||
//处理任务池
|
||||
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")
|
||||
+ "' 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);
|
||||
}
|
||||
|
||||
PhaseInfoArchive(ft.getAttribute("flowno").getString(), ft
|
||||
.getAttribute("phaseno").getString(),
|
||||
ft.getAttribute("objecttype").getString(),
|
||||
@ -555,6 +576,9 @@ public class FlowAction {
|
||||
.setParameter("userID", AssignmentId).getSingleResult(false);
|
||||
if (userBO != null) {
|
||||
this.initFlowTaskUserHis(tx);
|
||||
//重新指派处理人的同时,修改任务池数据
|
||||
FlowTask tf = new FlowTask(taskNo, tx);
|
||||
userID = tf.UserID;
|
||||
JBOFactory
|
||||
.getBizObjectManager("jbo.sys.FLOW_TASK")
|
||||
.createQuery(
|
||||
@ -568,7 +592,38 @@ public class FlowAction {
|
||||
.setParameter("orgName",
|
||||
userBO.getAttribute("orgName").getString())
|
||||
.executeUpdate();
|
||||
|
||||
String role = tf.PhaseOpinion4;
|
||||
String curRole = role;
|
||||
Transaction tran = Transaction.createTransaction(tx);
|
||||
ASUser user = ASUser.getUser(AssignmentId, tran);
|
||||
if(!"".equals(role)) {
|
||||
String now = StringFunction.getTodayNow().replaceAll(":", "△");
|
||||
SqlObject sql = null;
|
||||
if(user.getRoleTable().contains(role)) {
|
||||
sql = new SqlObject(("insert into user_task_data "
|
||||
+ "select sys_guid() ,'" + AssignmentId + "', roleid, flowno, flowunid, project_id, contract_id, '" + now + "', endtime,"
|
||||
+ " 'approve_status03', taskno"
|
||||
+ " from user_task_data where userid = '" + userID + "' and taskno = '" + taskNo + "' and (status = 'approve_status01' or status = 'approve_status03')"));
|
||||
sql.setDebugSql(sql.getDebugSql().replaceAll("△", ":"));
|
||||
sql.setOriginalSql(sql.getOriginalSql().replaceAll("△", ":"));
|
||||
sql.setRunSql(sql.getRunSql().replaceAll("△", ":"));
|
||||
tran.executeSQL(sql);
|
||||
sql = new SqlObject("update user_task_info set task_number = nvl(task_number, 0) + 1 "
|
||||
+ " where userid = '" + AssignmentId + "' and roleid = '" + curRole + "'");
|
||||
tran.executeSQL(sql);
|
||||
} else {
|
||||
role = user.getRoleTable().get(0);
|
||||
}
|
||||
sql = new SqlObject("update user_task_data set endtime = '" + now + "',status = 'approve_status04'"
|
||||
+ " where userid = '" + userID + "' and taskno = '" + taskNo + "' and (status = 'approve_status01' or status = 'approve_status03')");
|
||||
sql.setDebugSql(sql.getDebugSql().replaceAll("△", ":"));
|
||||
sql.setOriginalSql(sql.getOriginalSql().replaceAll("△", ":"));
|
||||
sql.setRunSql(sql.getRunSql().replaceAll("△", ":"));
|
||||
tran.executeSQL(sql);
|
||||
sql = new SqlObject("update user_task_info set task_number = nvl(task_number, 0) - 1 "
|
||||
+ " where userid = '" + userID + "' and roleid = '" + curRole + "'");
|
||||
tran.executeSQL(sql);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -879,6 +934,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")
|
||||
+ "' 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);
|
||||
}
|
||||
|
||||
// 更新beginTime锁这些记录
|
||||
ftManager
|
||||
.createQuery(
|
||||
|
||||
@ -22,6 +22,9 @@ import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE;
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
|
||||
public class ColRelativeInfo {
|
||||
|
||||
@ -278,4 +281,12 @@ public class ColRelativeInfo {
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static String getTaskNumber(String UserID, String RoleID) throws Exception {
|
||||
JBOTransaction tx = JBOFactory.createJBOTransaction();
|
||||
Transaction tran = Transaction.createTransaction(tx);
|
||||
String result = tran.getString(new SqlObject("select count(1) from user_task_data where userid = '" + UserID + "' and roleid = '" + RoleID + "' and status = 'approve_status01' group by userid,roleid"));
|
||||
tx.commit();
|
||||
return result == null ? "" : result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +41,8 @@ public class SelectUser {
|
||||
sql=this.getSelectRoleSql(curpid);
|
||||
}else if(this.selectType.equals("Á÷³ÌÖÐÖ¸¶¨²½ÖèµÄÈËÔ±")){
|
||||
sql=this.getSelectFlowSetpSql();
|
||||
}else if(this.selectType.equals("Ñ¡ÔñÖ¸¶¨ÈÎÎñ³Ø½ÇÉ«")){
|
||||
sql=this.getSelectTaskPool();
|
||||
}
|
||||
ASResultSet rs = null;
|
||||
try {
|
||||
@ -64,7 +66,6 @@ public class SelectUser {
|
||||
return chileNode;
|
||||
}
|
||||
public String getSelectUserSql(String curpid) throws Exception{
|
||||
System.out.println("curpid===="+curpid);
|
||||
String sql="SELECT sortno,orgid treeid,orgname treename,parentid ,nodetype FROM ( ";
|
||||
sql+=" SELECT orgid,orgname,sortno,relativeorgid parentid,'fold' nodetype FROM org_info WHERE sortno<>'8' ";
|
||||
sql+=" UNION ";
|
||||
@ -103,7 +104,7 @@ public String getSelectRoleSql(String curpid) throws Exception{
|
||||
sql+=" WHERE ( a.parentid=8 or a.parentid like '"+curpid+"%')";
|
||||
sql+=" and a.treename like '"+this.serarchData+"%'";
|
||||
}else{
|
||||
sql+=" WHERE ( a.parentid=8 or a.parentid like '"+curpid+"%')";
|
||||
sql+=" WHERE ( a.parentid=8 or a.parentid like '%"+curpid+"%')";
|
||||
}
|
||||
if(this.nodetype.equals("fold")){
|
||||
sql+=" and a.nodetype like '"+this.nodetype+"%'";
|
||||
@ -111,6 +112,12 @@ public String getSelectRoleSql(String curpid) throws Exception{
|
||||
sql+=" ORDER BY sortno";
|
||||
return sql;
|
||||
}
|
||||
public String getSelectTaskPool() throws Exception{
|
||||
String sql = "SELECT sortno,roleid treeid,rolename treename,parentid ,nodetype FROM ( "
|
||||
+ " SELECT roleid,rolename,sortno,belongorg parentid,'leaf' nodetype FROM role_info where task_pool = 'Y' ) a "
|
||||
+ " ORDER BY sortno";
|
||||
return sql;
|
||||
}
|
||||
public String getSelectFlowSetpSql() throws Exception{
|
||||
String sql="SELECT phaseno sortno,phaseno treeid,phasename treename,nodetype FROM ( ";
|
||||
sql+="SELECT phaseno,phasename,'leaf' nodetype FROM flow_model WHERE flowno='"+this.flowno+"' AND phasetype NOT IN('1040','1050')) a " ;
|
||||
|
||||
17
src_tenwa/com/tenwa/handler/UserTaskInfoHandler.java
Normal file
17
src_tenwa/com/tenwa/handler/UserTaskInfoHandler.java
Normal file
@ -0,0 +1,17 @@
|
||||
package com.tenwa.handler;
|
||||
|
||||
import com.amarsoft.app.als.sys.tools.DateUtil;
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.awe.dw.handler.impl.CommonHandler;
|
||||
|
||||
public class UserTaskInfoHandler extends CommonHandler {
|
||||
|
||||
@Override
|
||||
protected void initDisplayForAdd(BizObject bo) throws Exception {
|
||||
bo.setAttributeValue("userid", this.asPage.getParameter("UserId"));
|
||||
bo.setAttributeValue("roleid", this.asPage.getParameter("RoleId"));
|
||||
bo.setAttributeValue("inputuserid", this.curUser.getUserID());
|
||||
bo.setAttributeValue("inputorgid", this.curUser.getOrgID());
|
||||
bo.setAttributeValue("inputtime", DateUtil.getTodayNow());
|
||||
}
|
||||
}
|
||||
207
src_tenwa/com/tenwa/lease/app/quartzmession/TaskPool.java
Normal file
207
src_tenwa/com/tenwa/lease/app/quartzmession/TaskPool.java
Normal file
@ -0,0 +1,207 @@
|
||||
package com.tenwa.lease.app.quartzmession;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import com.amarsoft.app.als.sys.tools.DateUtil;
|
||||
import com.amarsoft.are.ARE;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.awe.util.ASResultSet;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.amarsoft.context.ASUser;
|
||||
|
||||
public class TaskPool implements Job {
|
||||
|
||||
/**
|
||||
* 为规避定时任务的并行,使用存储过程分单
|
||||
* @author zhulh
|
||||
*//*
|
||||
@Override
|
||||
public void execute(JobExecutionContext arg0) throws JobExecutionException {
|
||||
Transaction tran = null;
|
||||
try {
|
||||
tran = Transaction.createTransaction(JBOFactory.createJBOTransaction());
|
||||
tran.executeSQL(new SqlObject("{call proc_task_pool()}"));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
if(tran != null) tran.rollback();
|
||||
} catch (JBOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if(tran != null) tran.commit();
|
||||
} catch (JBOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//防止手动触发时,与自动触发任务冲突导致的数据紊乱
|
||||
@Override
|
||||
public synchronized void execute(JobExecutionContext arg0) throws JobExecutionException{
|
||||
Transaction tran = null;
|
||||
ASResultSet rsRole = null;
|
||||
ASResultSet rsUser = null;
|
||||
ASResultSet rsFlow = null;
|
||||
try {
|
||||
//开启事务
|
||||
tran = Transaction.createTransaction(JBOFactory.createJBOTransaction());
|
||||
//搜索所有任务池角色
|
||||
rsRole = tran.getASResultSet(new SqlObject("select roleid from role_info where task_pool = 'Y'"));
|
||||
while(rsRole.next()) {
|
||||
String roleId = rsRole.getString("roleid");
|
||||
//获取此角色下上岗用户
|
||||
rsUser = tran.getASResultSet(
|
||||
new SqlObject("select uti.userid, uti.task_weight, nvl(utd.cou,0) tasknumber from user_task_info uti left join (select userid,roleid,count(1) cou from user_task_data where status = 'approve_status01' group by userid,roleid) utd on utd.userid=uti.userid and utd.roleid=uti.roleid where uti.roleid = '" +
|
||||
roleId + "' and exists(select 1 from user_role where roleid=uti.roleid and userid=uti.userid) and uti.induction_state = 'induction_state01' and to_number(uti.task_weight) > to_number(nvl(utd.cou,0)) order by to_number(uti.task_weight)-to_number(nvl(utd.cou, '0'))"));
|
||||
|
||||
//获得需要分配的待办
|
||||
SqlObject sql = new SqlObject("select serialno, objectno, flowno from flow_task where userid = '" + roleId + "' order by to_date(begintime,'yyyy/mm/dd hh24△mi△ss')");
|
||||
sql.setDebugSql(sql.getDebugSql().replaceAll("△", ":"));
|
||||
sql.setOriginalSql(sql.getOriginalSql().replaceAll("△", ":"));
|
||||
sql.setRunSql(sql.getRunSql().replaceAll("△", ":"));
|
||||
rsFlow = tran.getASResultSet(sql);
|
||||
|
||||
List<String> userLists = new ArrayList<String>();
|
||||
while(rsUser.next()) {
|
||||
double taskWeight = rsUser.getInt("task_weight");//获得权重
|
||||
double taskNumber = rsUser.getInt("tasknumber");;//获得已收到待办
|
||||
String cou = tran.getString(new SqlObject("select count(1) from user_task_data where userid = '" + rsUser.getString("userid") + "' and roleid = '" + roleId + "' and status = 'approve_status01' group by userid,roleid"));
|
||||
if(cou == null) {
|
||||
cou = "0";
|
||||
}
|
||||
taskNumber = Double.parseDouble(cou);
|
||||
String weight = (taskNumber == 0 ? "0" : taskNumber/taskWeight + "") + "@" + taskNumber + "@" + taskWeight + "@" + rsUser.getString("userid") + "@0";
|
||||
|
||||
userLists.add(weight);
|
||||
}
|
||||
|
||||
List<String> removeUsers = new ArrayList<String>();
|
||||
|
||||
while(rsFlow.next()) {
|
||||
if(userLists.size() == 0) {
|
||||
break;
|
||||
}
|
||||
//为权重任务池排序
|
||||
sortList(userLists);
|
||||
//获取可随机用户数
|
||||
int number = getRandomNumber(userLists);
|
||||
String userWeight = userLists.get(number);
|
||||
double taskNumber = Double.parseDouble(userWeight.split("@")[1]);
|
||||
double taskWeight = Double.parseDouble(userWeight.split("@")[2]);
|
||||
double actualWeight = (taskNumber + 1) / taskWeight;
|
||||
String userId = userWeight.split("@")[3];
|
||||
ASUser user = ASUser.getUser(userId, tran);
|
||||
int n = Integer.parseInt(userWeight.split("@")[4]) + 1;
|
||||
//重新打包用户
|
||||
userWeight = actualWeight + "@" + (taskNumber + 1) + "@" + taskWeight + "@" + userId + "@" + n;
|
||||
if(actualWeight == 1.0) {//任务满了的情况,就从用户任务集合删除
|
||||
userLists.remove(number);
|
||||
removeUsers.add(userWeight);
|
||||
} else {
|
||||
userLists.set(number, userWeight);
|
||||
}
|
||||
|
||||
ARE.getLog().info("******************任务池日志*****为" + user.getUserID() + "增加单子:" + rsFlow.getString("serialno"));
|
||||
|
||||
tran.executeSQL(new SqlObject("update flow_task set "
|
||||
+ "phaseopinion4 = '" + roleId + "', userid = '" + user.getUserID() + "',"
|
||||
+ "username = '" + user.getUserName() + "', orgid = '" + user.getOrgID() + "',"
|
||||
+ "orgname = '" + user.getOrgName() + "' where serialno = '" + rsFlow.getString("serialno") + "'"));
|
||||
SqlObject so = new SqlObject("insert into user_task_data(id,roleid,userid,taskno,flowno,flowunid,project_id,contract_id,begintime,endtime,status)"
|
||||
+ "select sys_guid(),'" + roleId + "','" + user.getUserID() + "','" + rsFlow.getString("serialno") + "','" + rsFlow.getString("flowno") + "',flow_unid,proj_id,contract_id,'"
|
||||
+ DateUtil.getTodayNow().replaceAll(":", "△") + "','','approve_status01' from flow_bussiness_object where flow_unid = '" + rsFlow.getString("objectno") + "'");
|
||||
so.setDebugSql(so.getDebugSql().replaceAll("△", ":"));
|
||||
so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":"));
|
||||
so.setRunSql(so.getRunSql().replaceAll("△", ":"));
|
||||
tran.executeSQL(so);
|
||||
}
|
||||
userLists.addAll(removeUsers);
|
||||
for(String user : userLists) {
|
||||
if(Integer.parseInt(user.split("@")[4]) == 0) {
|
||||
continue;
|
||||
}
|
||||
ARE.getLog().info("******************任务池日志*****为" + user.split("@")[3] + "增加任务:" + user.split("@")[4] + "数据为:" + user);
|
||||
tran.executeSQL(new SqlObject("update user_task_info set task_number = nvl(task_number,0) + "
|
||||
+ Integer.parseInt(user.split("@")[4]) +" where userid = '" + user.split("@")[3] + "' and roleid = '" + roleId + "'"));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
if(tran != null) tran.rollback();
|
||||
} catch (JBOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if(tran != null) tran.commit();
|
||||
} catch (JBOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if(rsRole != null) rsRole.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if(rsUser != null) rsUser.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if(rsFlow != null) rsFlow.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sortList(List<String> userLists) {
|
||||
List<String> sortList = new ArrayList<String>(userLists.size());
|
||||
for(int i = 0; i < userLists.size(); i ++) {
|
||||
double weight = Double.parseDouble(userLists.get(i).split("@")[0]);
|
||||
int j = 0;
|
||||
for(; j < sortList.size(); j ++) {
|
||||
double sweight = Double.parseDouble(sortList.get(j).split("@")[0]);
|
||||
if(sweight >= weight) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
sortList.add(j, userLists.get(i));
|
||||
}
|
||||
userLists.clear();
|
||||
userLists.addAll(sortList);
|
||||
}
|
||||
|
||||
public static int getRandomNumber(List<String> userLists) {
|
||||
int i = 0;
|
||||
double weight = Double.parseDouble(userLists.get(0).split("@")[0]);
|
||||
for(String userList : userLists) {
|
||||
double sweight = Double.parseDouble(userList.split("@")[0]);
|
||||
if(weight == sweight) {
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
return (int)(Math.random()*(i));
|
||||
}
|
||||
|
||||
public static String modifyStringByIndex(int index,String oriValue, String value) {
|
||||
String[] ori = oriValue.split("@");
|
||||
ori[index] = value;
|
||||
String result = "";
|
||||
for(String o : ori) {
|
||||
result += "@" + o;
|
||||
}
|
||||
return result.substring(1);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user